Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Proper locking when writing drives

Reply
Thread Tools Display Modes

Proper locking when writing drives

 
 
Maël Hörz
Guest
Posts: n/a

 
      10-22-2009
In an earlier post I asked a question to which I found an answer (I
write a new post because the old thread has expired).

What I wanted to do was writing to a physical disk after having
locked/dismounted all partitions/volumes on this physical disk.

The initial code was this :

LockVolume(LogicalDriveHandle);

// results in access denied
WriteProtectedSector(PhysicalDriveHandle);

DismountVolume(LogicalDriveHandle);
UnlockVolume(LogicalDriveHandle);

The missing part why it did not work is that the physical drive needs to
be opened with denying shared write access. I.e. when calling CreateFile
for PhysicalDriveX either only specify FILE_SHARE_READ or 0 for the file
sharing mode (but not FILE_SHARE_WRITE).
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vista not recognizing raid 0 drives from xp system with plug n pla Docha Windows Vista Hardware 2 01-21-2008 05:31 PM
Optical I/O issues (Event ID 51) when flash memory is present wchp Windows Vista Hardware 1 05-24-2007 01:31 PM
Vista Ultimate x86 or x64 will not install to SATA drives - ok to IDE BobS Windows Vista Installation 16 03-05-2007 08:25 PM
Vista Rejected, XP lost DVDRW drives PWF Windows Vista Hardware 7 02-19-2007 11:41 AM
No CD drives show in Vista Jake Windows Vista Hardware 1 12-31-2006 10:23 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59