I have an interesting dilemma with WDFWORKITEM. A work item has to be created with a parent object being a WDFDEVICE. Otherwise WdfWorkItemCreate
fails.
So when the driver begins unloading, since the work-item is a child of its device, the framework first waits for the EvtWorkItemFunc
of my WDFWORKITEM to finish before invoking EvtCleanupCallback
on the said device. And because of that my EvtWorkItemFunc
takes its sweet time not realizing that the driver is unloading, which I would prefer to fix.
But I can't seem to find a way to get notified if the device is being cleaned up, or that the driver is being unloaded before the framework starts waiting for my EvtWorkItemFunc
to finish. A classic catch-22.
Alternatively I can't create a WDFWORKITEM with a NULL parent and do all the reference counting manually.
Any suggestions how to resolve this?