0

how can i use the device after lock it by FSCTL_LOCK_VOLUME win32 api control code for example listing files in the device or delete files from the device and etc .
i can list all files by FindFirstFile() and FindNextFile() when the device isn't lock but when i lock them i can't use this two function .
is there any alternative function for example to list files which worked with device handle ?
the msdn said :

A locked volume can be accessed only through handles to the file object (*hDevice) that locks the volume.

thanks a lot , good luck .

1 Answers1

1

You can't.

Once the volume is locked, it is accessible only as a raw view of the volume data structures, not as files. That's what FSCTL_LOCK_VOLUME is for, to let you mess about with the raw data structures. You can use ReadFile, ReadFileEx and WriteFile and WriteFileEx and cousins, on the handle you passed to DeviceIoControl to read the raw volume.

If you don't want to do that, but just stop other people modifying the disk while you are looking at it (for backup etc) you might consider shadow copies. It does depend what you are trying to do though.

Ben
  • 34,935
  • 6
  • 74
  • 113