Extraneous mounted drives in Win7

I have a KMDF based virtual disk application which consists of a bus, disk function device (FILE_DEVICE_DISK), and a user mode app. The target operating systems are XP and later. I expose the drives to userland and explorer by calling IoCreateSymbolicLink in the disk driver, and also DefineDosDevice in the user app (some OSs don’t have the drive show up if I only create the link in the kernel). The problem that I face is that in Win7 (possibly Vista, I haven’t checked), some entity is also mapping it’s own drive letters along with the one that I create. I end up with multiple drive letters that point to the same device. I’m not registering any device interfaces, so I can’t see how it’d be the mount manager (although i do handle mount manager ioctls, since I had been experimenting with the idea od using mount manager instead of create symbolic link) - so what is creating these extraneous drive letter mappings?

>I end up with multiple drive letters that point to the same device.
Do you see all these drive letters(\DosDevices\X:) in HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices too?

Igor Sharovar

I think so… I’ll check when I get back to that machine

> I’m not registering any device interfaces, so I can’t see how it’d be the mount manager

(although i do handle mount manager ioctls, since I had been experimenting with the idea od using
mount manager instead of create symbolic link) - so what is creating these extraneous
drive letter mappings?

Actually, I don’t know what you mean by “registering device interfaces”, but , IIRC, in order for drive letter to appear a DO for partition has to be created by DISK.SYS. How do you handle IOCTL_DISK_GET_DRIVE_LAYOUT_EX and friends in your driver??? If you convince DISK.SYS.that your disk has partitions it is going to create DOs for all partition that you report, and, at this point, drive letters get assigned to them( or to the logical volumes mounted on them if you report your disk as a basic one) by the Mount Manager, and appears in the registry under HKLM\SYSTEM\MountedDevices. All that has to be done is a call to class function that creates disk and partition devices (I cannot immediately recall its name, so I will refer to it as ClassCreateDevice() here) with DISK.SYS.’ s DRIVER_OBJECT passed to it as a parameter.

For the sake of experiment you try to do it in some bogus driver that has no relationship to disks whatsoever and gets loaded via SCM - if you create a DO for some non-existent partition of the existing disk by ClassCreateDevice() with DISK.SYS.’ s DRIVER_OBJECT you will see a new drive letter under HKLM\SYSTEM\MountedDevices. It is understandable that this “partition” will be of zero practical usefulness, but drive letter will be there…

Anton Bassov

I had actually been registering device interfaces. if i dont call WDFDeviceCreateDeviceInterface with both GUID_INTERFACE_DISK and MOUNTDEV_MOUNTED_DEVICE_GUID, i can’t get a drive letter to show up in explorer. In all operating systems other than Win7, I can create a symbolic link to my drive, or use definedosdevice to create one. In win7, as soon as i click on my drive to format it, some autogenerated drive letter appears.

I don’t really want the mount manager to do this for me, i thought that if i didn’t register with it, i could assign my own letter to it, but that doesn’t seem to be the case.

if i look in winobj, the link that i created (J:) points to my device, \Device\MyDevice2, the other drive (G:, which appears when I select Format in the right click menu of explorer), points to \Device\HarddiskVolume3

even if i don’t register as a disk or with mount manager, right before the format drive dialog appears, an extraneous drive letter is created for me… I read Anton’s post, but it doesn’t help me understand why the behavior doesn’t occur in other windows versions, or what i could do to stop it.