Hi everyone!
For a couple days now I’m looking into this problem, and every bit of
information I gather seems to only increase my confusion (Nirwhana seems
close at times…)
Here is my problem/question:
How can I add my own partition device objects (type FILE_DEVICE_DISK; not
attached to any specific hardware) as sub directories on NTFS volumes, and
what requests do I need to handle so it really works?
The current situation:
My driver has a ‘master’ control device. At run time, it can create
multiple ‘disk’ devices and for each ‘disk’ device there will be a number
of ‘partition’ devices. It is no PnP driver [would not be sensible without
any associated hardware me thinks].
Up to now I was happy to create drive letters with DefineDosDevice() to
access the partition devices [works fine], but now I’m supposed to ‘mount’
those partitions to a sub directory of a NTFS volume, so instead of, say,
having drive letters K:, L:, M: I should get D:\Virt\P1, D:\Virt\P2,
D:\Virt\P3 as root directories for the three partitions. So I created a
GUID for each partition device and a symbolic link named
Volume{…guid…}.
There is no real disk or other specific hardware behind the driver, the
data for the disk/partition devices is obtained from special files
scattered around everywhere, and it’s uncommon to see the same source
‘mounted’ more than 1-2 times [so I don’t want anything persistent]
Now, when calling SetVolumeMountPoint( “F:\EMPTY\”,
“\\?\Volume{…guid…}\”) it always fails. (when I pick an existing
Volume{…} from an unassigned partition from a normal hard disk, it
works, just my device won’t work. When calling SetVolumeMountPoint(), my
partition device receives the following requests in this order:
IRP_MJ_CREATE [returns STATUS_SUCCESS, info=1]
IRP_MJ_CLEANUP [returns STATUS_SUCCESS, info=0]
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME [returns STATUS_BUFFER_OVERFLOW, info=4]
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME [returns STATUS_SUCCESS, info=66, device
name returned ‘\Device\VogonVirtualVolume_D1_P2’
IRP_MJ_CLOSE
After the partition device has received those requests,
SetVolumeMountPoint() returns an error.
While trying to solve this problem, I’ve read about the mount manager and
other stuff and tried to use IoRegisterDeviceInterface(). Since my device
object is no PDO this failed every time of course, so I used
IoReportDetectedDevice() with an empty resource list (counter==0) to get a
PDO and then IoAttachDeviceToDeviceStack() to attach my partition device
object to the newly created PDO.
This was a bad mistake as now I get a “windows detected new
hardware”-message for each mounted partition on each windows startup. And
even worse, the SetVolumeMountPoint still fails.
Could someone please point me in the right direction how to do this
properly? I can’t believe that it is/can be so difficult to just let my
own partition devices show up as sub directories…
Cheers,
Michael
Vogon International GmbH
http://www.vogon-international.com