FILE_DEVICE_VIRTUAL_DISK Vs. FILE_DEVICE_DISK In Virtual Disk Drivers

Well, this was a new one on me. I worked on a virtual disk driver last year, and I vaguely remember not being able to get it to mount NTFS disks some of the time. I wound up getting it working, but I didn’t know why, at the time.

Christiaan Ghijselinck pointed out this MIcrosoft KB article that clears it up:

Installing the Ramdisk sample driver in a NTFS only machine might make it unusable. To resolve this problem make the following change:

While you call the IoCreateDevice function (RamdiskAddDevice function in pnp.c), change the device type from FILE_DEVICE_VIRTUAL_DISK to FILE_DEVICE_DISK and recompile the driver. After you install the driver, restart the system in order to access the Ramdisk through Explorer.

I double-checked my sources, and indeed, according to my CVS history, that was one of the things I changed from the “first draft” code to the first shipped code. Whoda thunk it.

Incidentally, one of the bits of feedback I left Microsoft at the MVP summit was our severe need of a decent virtual disk sample in the DDK. It’s one of the most-asked questions on NTDEV, and most people are using Jamey Kirby’s stolen code as boilerplate, which is unethical if nothing else, and unmaintained (by him, at least) regardless.

Leave a Reply

Your email address will not be published. Required fields are marked *