none
LWF driver, UnregisterDeviceEx() and work items RRS feed

  • Question

  • Hello,

    I have verified that IoQueueWorkItem() fails when it is called after UnregisterDeviceEx(). Logically it is right because control device object is parameter in IoAllocateWorkItem() and unregistering makes device object invalid. 

    What about case when work item is already queued ? If work item is already queued but not finished can I call UnregisterDeviceEx() ? Does exist synchronization in system  which waits unregistering of device till running work items are finished ?

    Monday, September 9, 2019 11:27 AM

Answers

  • The WDM based answer is that there is no synchronization to drain already queued work items and device object deletion. The device object will be valid memory until the work item returns (as an io work item holds an Ob reference), but there is no guarantee the device object will be in a good state when the work item runs (as it may run after device object deletion). NDIS May add synchronization on top of wdm, but you are referring to the wdm APIs so I assume you are using them directly.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Peter Skvarka Monday, September 9, 2019 7:52 PM
    Monday, September 9, 2019 5:32 PM