Hi,
beneath others my driver registers an EvtDeviceReleaseHardware and an EvtFileCleanup handler registered to the devices file objects with WdfDeviceInitSetFileObjectConfig.
My application registers DBT_DEVICEQUERYREMOVE, DBT_DEVICEREMOVEPENDING or DBT_DEVICEREMOVECOMPLETE and closes its open handles to the drivers upon receive.
When unloading or disabling the driver while a user client still has a file object to the driver open the tear down sequence is as expected:
EvtFileCleanup
EvtDeviceReleaseHardware
This allows to turn down user client stuff while still be able to access the device
At surprise removal (USB or 1394) the order is inverse:
EvtDeviceReleaseHardware
EvtFileCleanup
This makes it complicated to keep track of the object dependencies. Well, not complicated but adds pit falls and additional order checks.
Is there a way to enforce to close file objects before handling EvtDeviceReleaseHardware?
EvtFileCleanup
This makes it complicated to keep track of the object dependencies. Well, not complicated but adds
pit falls and additional order checks.
No, you can’t enforce the order. This is why surprise removal exists, your device is gone but there are still handles open, but we need to partially tear down the stack’s state.
d
Bent by my phone
From: xxxxx@dynax.atmailto:xxxxx Sent: ?10/?2/?2013 2:00 AM To: Windows System Software Devs Interest Listmailto:xxxxx Subject: [ntdev] ordered device/user client tear down
Hi, beneath others my driver registers an EvtDeviceReleaseHardware and an EvtFileCleanup handler registered to the devices file objects with WdfDeviceInitSetFileObjectConfig.
My application registers DBT_DEVICEQUERYREMOVE, DBT_DEVICEREMOVEPENDING or DBT_DEVICEREMOVECOMPLETE and closes its open handles to the drivers upon receive.
When unloading or disabling the driver while a user client still has a file object to the driver open the tear down sequence is as expected: 1. EvtFileCleanup 2. EvtDeviceReleaseHardware This allows to turn down user client stuff while still be able to access the device
At surprise removal (USB or 1394) the order is inverse: 1. EvtDeviceReleaseHardware 2. EvtFileCleanup This makes it complicated to keep track of the object dependencies. Well, not complicated but adds pit falls and additional order checks.
Is there a way to enforce to close file objects before handling EvtDeviceReleaseHardware?
Surprise removal MUST NOT tear the driver structures. It only should flag them as not accepting any new I/O requests, and also cancel any requests in progress.