(HID minidriver: question for async I/O and surprise removal on Win8.1/10)
Hello.
I have a HID minidriver (over USB), and I see a strange problem under Windows 8.1/10, but not Windows 7/Vista. My user-mode component queues an asynchronous write IRP to my minidriver (queued in a IOCSQ), just so that if the app dies, I can be notified and clean up in kernel-mode, and place the device in a reset state for its next use. Normally, should the device be unplugged from its USB port, I do expect that even if there is asynchronous I/O pending for the device that I will receive in the minidriver a surprise removal IRP so I can cancel outstanding I/O and cleanup as mandated for this IRP, and that the user-mode component be notified of device departure. But this is not the case under Windows 8.1 and 10 (no surprise removal IRP received), though it works as I expect it to under Windows 7/Vista. For the Windows 8.1/10 case, I receive no surprise removal IRP, and my user-mode component receives no notification for device departure (so it can close its handle), while for Windows 7/Vista I do get surprise removal, in which I cancel outstanding I/O and cleanup as mandated in kernel-mode, and my user-mode component receives a device departure message, so it can close its handle. Now I have a temporary workaround in my kernel-mode minidriver where I note the absence of the device, and clean up outstanding I/O. I then immediately receive a surprise removal IRP in my minidriver, and everything proceeds normally.
Does anyone have any idea why subsequent to a USB unplug that I must cancel outstanding asynchronous I/O before I may receive a surprise removal IRP, and that only in Windows 8.1/10? I did not realize that this is required.
Thank you,
Philip Lukidis