Ejecting a USB Device

All,
Several years ago we developed a USB driver using WDM. As part of a test
application, we have been using CM_Request_Device_Eject() to remove the
device. This worked quite nicely. We just recently ported the driver’s
functionality over to KMDF. Now when we call CM_Request_Device_Eject(), the
device does not get removed but instead it still appears in the Device
Manager with a yellow exclamation mark. When we display the Properties, we
see that the error code is 47 - the device has been prepared for safe
removal. Once the device is disconnected everything is cleaned up. Below are
a few data points:

  1. When CM_Request_Device_Eject() is being processed, the Exit DO and
    Release Hardware Event handles are both being called.
  2. In the AddDevice routine, we’re calling WdfDeviceSetPnpCapabilities with
    the following fields set to WdfTrue:
    SurpriseRemovalOk, Removable, EjectSupported, and SilentInstall. The rest of
    the filelds are set to the defaults used by the INIT macro.
  3. We’re observing this behaviour on 32-bit, Win7.

Any ideas of what could be going on here would be greatly appreciated.
TIA!

> see that the error code is 47 - the device has been prepared for safe

removal. Once the device is disconnected everything is cleaned up.

This is the same for inbox USBSTOR driver and flash disk devices.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Maybe so but this is not how our unclassified, WDM driver works. In that
case, when you eject the device via CM_Request_Device_Eject, the device
driver is gracefully removed and then re-enumerated. No hot plugging is
necessary. Makes for a *great* test bed. Thus we want that same behavior
with our KMDF driver.

On Fri, Sep 5, 2014 at 4:40 AM, Maxim S. Shatskih
wrote:

> > see that the error code is 47 - the device has been prepared for safe
> > removal. Once the device is disconnected everything is cleaned up.
>
> This is the same for inbox USBSTOR driver and flash disk devices.
>
> –
> Maxim S. Shatskih
> Microsoft MVP on File System And Storage
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> 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
>