IRP_MN_QUERY_DEVICE_REMOVE after pdo creation

Hi,

I’m developing a driver that enumerates virtual disks. The driver creates the main bus extender device and listed under SCSI devices (at least under xp, in w7 is inside another subtree).

The the device receives a custom IOCTL, it creates a disk device that handles IRP_MN_QUERY_CAPABILITIES, IRP_MN_QUERY_DEVICE_RELATIONS, SCSI ioctl’s and, i think, almost all kind of messages.

The enumerator device, after receiving IRP_MN_QUERY_DEVICE_RELATIONS to enumerate child devices (checked I add the disk device to the list) and some scsi requests, it receives a IRP_MN_QUERY_DEVICE_REMOVE and because there is no paging file active, it returns STATUS_SUCCESS so the device is destroyed in the IRP_MN_REMOVE_DEVICE and Windows informs that there was an error installing the device (code 9)

After a half day, i changed the IRP_MN_QUERY_DEVICE_REMOVE to always return STATUS_UNSUCCEEDED so the remove query is cancelled, device setup continues ok and also the disk manager recognizes the new volume (ask me to partition and format if the “virtual” image is new) and works perfectly.

I cannot understand why the pdo receives the IRP_MN_QUERY_DEVICE_REMOVE in the middle of the device recognition by the o.s.

Another question is that I testes the driver in Windows 7 but when I create a virtual disk, w7 asks me for restart (in xp it is not necessary).

Best regards, Mauro.

Did you look at the setup logs to see why the q.r. was sent?

d

dent from a phine with no keynoard

-----Original Message-----
From: xxxxx@caiman.com.ar
Sent: Monday, March 21, 2011 8:31 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] IRP_MN_QUERY_DEVICE_REMOVE after pdo creation

Hi,

I’m developing a driver that enumerates virtual disks. The driver creates the main bus extender device and listed under SCSI devices (at least under xp, in w7 is inside another subtree).

The the device receives a custom IOCTL, it creates a disk device that handles IRP_MN_QUERY_CAPABILITIES, IRP_MN_QUERY_DEVICE_RELATIONS, SCSI ioctl’s and, i think, almost all kind of messages.

The enumerator device, after receiving IRP_MN_QUERY_DEVICE_RELATIONS to enumerate child devices (checked I add the disk device to the list) and some scsi requests, it receives a IRP_MN_QUERY_DEVICE_REMOVE and because there is no paging file active, it returns STATUS_SUCCESS so the device is destroyed in the IRP_MN_REMOVE_DEVICE and Windows informs that there was an error installing the device (code 9)

After a half day, i changed the IRP_MN_QUERY_DEVICE_REMOVE to always return STATUS_UNSUCCEEDED so the remove query is cancelled, device setup continues ok and also the disk manager recognizes the new volume (ask me to partition and format if the “virtual” image is new) and works perfectly.

I cannot understand why the pdo receives the IRP_MN_QUERY_DEVICE_REMOVE in the middle of the device recognition by the o.s.

Another question is that I testes the driver in Windows 7 but when I create a virtual disk, w7 asks me for restart (in xp it is not necessary).

Best regards, Mauro.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi,

I install the driver without problems with the .inf file and using SetupDi… apis and it creates the bus_extender device without errors.

Then, to mount a drive, I open the bus_extender (for now using a symbolic link) and send the DeviceIOControl with a custom code to indicate the driver to create the file_disk device.

The device is created without errors, starts receiving the corresponding IRP_MJ_SCSI and IRP_MJ_PNP requests. and windows informs that a new device was found.

After the bus device processes IRP_MN_QUERY_DEVICE_RELATIONS (BusRelations) where I include the new created disk_device and the file_device receives some IRP_MJ_SCSI, there is a pause about 1 or 2 seconds.

The the file_device receives a IRP_MN_QUERY_DEVICE_RELATIONS (RemovalRelations) which I don’t process and the IRP_MN_QUERY_REMOVE_DEVICE.

If at this point I return STATUS_SUCCESS, the file_device is removed and windows informs of an error while installing the new device.

If I return STATUS_UNSUCCESSFUL, the installation continues and terminates ok. Windows informs that the hardware is ready to be used and disk manager detects the new disk (I can partition, format, mount anywhere)

But I want not to return always STATUS_UNSUCCESSFUL in order to be able to unmount the device on the fly.