Hello,
I’m writing a virtual drive driver for XP. It is loosely based on the
RAMDISK example code. All actual disk I/Os are handled by a system thread.
File system used is NTFS and the drive is read-only (or supposed to be).
Following are a some general setups:
IoCreateDevice:
DeviceType set to FILE_DEVICE_DISK
DeviceCharacteristics set to FILE_READ_ONLY_DEVICE
IRP_MJ_DEVICE_CONTROL dispatch:
For IOCTL_DISK_IS_WRITABLE returns STATUS_MEDIA_WRITE_PROTECTED
IRP_MJ_WRITE dispatch:
returns STATUS_MEDIA_WRITE_PROTECTED
The problem occurs when I try to use explorer to copy files whose size >= 2
MBytes from the virtual disk to another drive. The operation fails with a
“Delay write fail” error: “Windows was unable to save all the data for the
file \Device\MyVirtualDisk\MyBigFile.bin …”. The message shown in WinDbg
is:
MM MODWRITE: failing all io, controlarea 82119B38 status c00000a2
I could not find any thing about “MM MODWRITE” on the internet. “c00000a2”
is a “Write-Protected” error. It looks like some write operations are
attempted on the virtual disk that cause the error. Using FileMon tool, I
found out these writings occur when QueryInformation operations are
performed on the file. If I configure the disk as normal (not
write-protected) and simply return STATUS_SUCCESS in the dispatch_write
routine without actually writing anything, then there is no error. There is
also no error when access the file from other programs such as WordPad,
HexEdit, etc… Any idea what I done wrong? How do I stop QueryInformation
and such from writing to the virtual disk? Thanks for your help.