none
Query regarding the GUID_TARGET_DEVICE_REMOVE_COMPLETE vs GUID_IO_MEDIA_REMOVAL RRS feed

  • Question

  • Hi, 

    I have question regarding the event handling of USB drive. In my driver code i am getting disk device object pointer for USB device and then registering target device change PNP notification on the file object. 

    IoGetDeviceObjectPointer(DrvName, FILE_READ_ATTRIBUTES, &pFileObj, &pDevObj);

    ...

    IoRegisterPlugPlayNotification(EventCategoryTargetDeviceChange,.., pFileObj,..); 

    When i do surprise remove the USB drive from the system, i am not getting the GUID_TARGET_DEVICE_REMOVE_COMPLETE event as per this doc https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/handling-a-guid-target-device-remove-complete-event but getting event GUID_IO_MEDIA_ARRIVAL. 

    Why this strange behavior, is there anything wrong in my PNP registration.? 

    Thanks,

    Poo


    Saturday, November 16, 2019 5:10 AM

All replies

  • Any one can clarify my question?
    Monday, November 18, 2019 3:46 PM
  • The notifications you get here depend on many things, some of which are not obvious.  If your device is considered "removable", then you get the equivalent of an "eject", not a surprise removal.  I'm guessing that what you're seeing.  If you were opening the USB device rather than the disk device. I'm guessing you'd see the removal notification you expect.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Monday, November 18, 2019 6:44 PM
  • I am opening using this name 

    "\\DosDevices\\PhysicalDrive1" to open the device. In this case i am opening disk or USB device?

    Tuesday, November 19, 2019 7:50 PM