My driver allocates stuff from nonpaged pool. The DispatchClose routine does some stuff by queuing a DPC, and this queues a work item to do final stuff requiring PASSIVE_LEVEL, such as disconnecting interrupts and releasing the memory back to the pool.
If this is the last file handle for the driver that has just closed, the DriverUnload will be called.
Does the I/O manager check that any work items associated with the driver have been dequeued and have completed? Or does my
driver have to do that by having the work item post some event that the DriverUnload waits on?
Windows Internals 6th Ed says on pg 205
Device drivers should use only the latter [that is, IoQueueWorkItem] (because this associates the work item with a Device object, allowing for greater accountability and the handling of scenarios in which a driver unloads while its work item is active).
But there's no details on how the kernel handles such scenarios. I'm hoping that it is done seamlessly.
It looks like you're new here. If you want to get involved, click one of these buttons!
|Upcoming OSR Seminars|
|Developing Minifilters||29 July 2019||OSR Seminar Space|
|Writing WDF Drivers||23 Sept 2019||OSR Seminar Space|
|Kernel Debugging||21 Oct 2019||OSR Seminar Space|
|Internals & Software Drivers||18 Nov 2019||Dulles, VA|