WriteFile oddity
- From: Zackmann <zackmann@xxxxxxxx>
- Date: Wed, 15 Aug 2007 05:39:21 -0700
For physically writing on a USB stick I use the functions "CreateFile"
and then "WriteFile" on the basis
of the handle returned by CreateFile. I call "Write File" with
standard parameters, i.e. Generic_Write /
File_Share_Read or File_Share_Write / Open_Existing.
While these functions work properly when physically writing on the
volume or on the partition via
"CreateFile('\\{drive letter}:',.....)" and write data exactly
according to instructions, the writing
process fails when opening the physical drive via
"CreateFile('PhysicalDrive{drive number}',.....)".
As in some cases I want to write the MBR but am unable to address it
via the volume, I also need this
call.
What is particularly odd is that, officially, no error occurs.
CreateFile returns a valid handle and
WriteFile returns both "true" and a number of (allegedly) written
bytes, which exactly corresponds
to the requested number in the WriteFile command.
However, *nothing at all* is written on the USB stick. Is this problem
already known or has anybody
noticed a similar conduct? By the way, dismounting or locking the
target drive does not change the
described conduct in any way. The problem occurs on different
computers, with different USB sticks and
both under XP and under Vista all alike.
I would be very grateful for receiving field reports or solutions to
the problem.
.
- Prev by Date: RE: DeleteFileW returns incorrect error code in Vista for DLLs
- Next by Date: APIs to load registry from non running system
- Previous by thread: CreateFile Question
- Next by thread: APIs to load registry from non running system
- Index(es):
Relevant Pages
|