Re: FlushFileBuffers in non-privileged user mode



On Oct 18, 12:28 am, Uwe Sieber <m...@xxxxxxxxxxxxx> wrote:
Hirakawa wrote:
On Oct 17, 8:00 pm, J de Boyne Pollard <j.deboynepoll...@xxxxxxxxx>
wrote:
H> Good day. I am currently working on an encryption software
H> that need to flush file cache before the software end.

Why do you think that it needs to do that?

H> Is there any other method I can try to make FlushFileBuffers
H> works in non-privileged user mode?

<URL:http://homepages.tesco.net./~J.deBoynePollard/FGA/put-down-the-
chocolate-covered-banana.html>

Hi, thank you for reply.

In Windows 2000 and XP user mode, if the working device that I am
using is a removable disk (either Flash Drive or HDD), I will have the
problem of data corruption or small file (<4k) lost. Therefore I need
to make sure that everything is flush back before user plug out or
safely remove the device.

'Safely remove' is good enough, it flushes for you.

To prevent caching problems at all just use FILE_FLAG_NO_BUFFERING
or FILE_FLAG_WRITE_THROUGH.

Uwe

Hi Uwe, I visited your website before and you have a great eject
device software. Since you're here, can I ask you a question about
safely remove composite usb mass storage device? (I hope you don't
mind)

I got some devices with me right now which cannot be safely remove by
Win2K and WinVista. Those devices are composite device and I think I
might have problem to flush the cache under user mode. May I know how
your eject software flush the file cache under user mode?

Back to my problem, some of my users report to me that under Windows
2000 user mode, they have data corruption problem even though OS
return safely remove successful message. It seems that due to FAT32,
the write back of cache is slower than FAT. That's the reason why I am
seeking for a solution to flush file buffers in non privileged mode.

Currently I am using the following line to get the handle and send to
flushfilebuffers in Administrator Mode:

CreateFile(szVolumeName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ
| FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, 0);

.


Loading