Unable to support 2 similar devices using same driver.

I have 2 similar USB devices which are being plugged into 2 USB Ports on the same PC simultaneously. I want to use a single driver for both the instances.
I have a scenario wherein on a fresh system (registry and service cleaned up) the installation of the first device happens successfully and when we hook up the second device, the driver gets removed and unloaded and both of them are loaded again.

List of IRP’s when the first device is hooked.
After AddDevice
IRP_MN_QUERY_LEGACY_BUS_INFORMATION
IRP_MN_QUERY_RESOURCE_REQUIREMENTS
IRP_MN_FILTER_RESOURCE_REQUIREMENTS
IRP_MN_START_DEVICE
IRP_MN_QUERY_CAPABILITIES
IRP_MN_QUERY_PNP_DEVICE_STATE
IRP_MN_QUERY_DEVICE_RELATIONS
IRP_MN_QUERY_DEVICE_TEXT
IRP_MN_QUERY_ID
IRP_MN_QUERY_INTERFACE
IRP_MN_QUERY_DEVICE_RELATIONS

When i hook up the second device, the IRP IRP_MN_QUERY_CAPABILITIES is sent 4 times followed by IRP_MN_QUERY_DEVICE_RELATIONS

Then i get the Found New Hardware Popup and when i go ahead and start the installation of the second device, i get the following IRP’s
IRP_MN_QUERY_DEVICE_RELATIONS which returns with a failure STATUS_NOT_SUPPORTED
After this, we get the IRP_MN_QUERY_REMOVE_DEVICE and IRP_MN_REMOVE_DEVICE and the driver is Unloaded.

Now, the driver is loaded again i.e. DriverEntry is called and AddDevice is called twice. The devices get installed successfully, as seen in the Device Manager.

Now if i remove both the devices and then if i insert them back, this behavior is not seen.

Any help in this regard is highly appreciated.

This is normal behavior. The driver is unloaded b/c the new instance is copying over a new version of the driver (or something similar which would make the OS think that the driver image being installed is different than the one on disk) and to have the new version load, it must version unload the old version by query remove->removing the first instance. After the 2nd instance is installed, you do not see the query remove->remove b/c both are installed and can run w/out further file changes

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Tuesday, September 16, 2008 6:15 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Unable to support 2 similar devices using same driver.

I have 2 similar USB devices which are being plugged into 2 USB Ports on the same PC simultaneously. I want to use a single driver for both the instances.
I have a scenario wherein on a fresh system (registry and service cleaned up) the installation of the first device happens successfully and when we hook up the second device, the driver gets removed and unloaded and both of them are loaded again.

List of IRP’s when the first device is hooked.
After AddDevice
IRP_MN_QUERY_LEGACY_BUS_INFORMATION
IRP_MN_QUERY_RESOURCE_REQUIREMENTS
IRP_MN_FILTER_RESOURCE_REQUIREMENTS
IRP_MN_START_DEVICE
IRP_MN_QUERY_CAPABILITIES
IRP_MN_QUERY_PNP_DEVICE_STATE
IRP_MN_QUERY_DEVICE_RELATIONS
IRP_MN_QUERY_DEVICE_TEXT
IRP_MN_QUERY_ID
IRP_MN_QUERY_INTERFACE
IRP_MN_QUERY_DEVICE_RELATIONS

When i hook up the second device, the IRP IRP_MN_QUERY_CAPABILITIES is sent 4 times followed by IRP_MN_QUERY_DEVICE_RELATIONS

Then i get the Found New Hardware Popup and when i go ahead and start the installation of the second device, i get the following IRP’s
IRP_MN_QUERY_DEVICE_RELATIONS which returns with a failure STATUS_NOT_SUPPORTED
After this, we get the IRP_MN_QUERY_REMOVE_DEVICE and IRP_MN_REMOVE_DEVICE and the driver is Unloaded.

Now, the driver is loaded again i.e. DriverEntry is called and AddDevice is called twice. The devices get installed successfully, as seen in the Device Manager.

Now if i remove both the devices and then if i insert them back, this behavior is not seen.

Any help in this regard is highly appreciated.


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