(those who may have seen the last version of this, please disregard and
excuse my premature use of the send button
)
I’m seeing differing behavior between Win98 and Win2K/XP when removing a
device. My StopDevice code includes:
KdPrint((DRIVERNAME " - Killing timers…\n"));
KeCancelTimer(&pdx->ReadServiceDpcTimer);
KeCancelTimer(&pdx->WriteServiceDpcTimer);
KdPrint((DRIVERNAME " - Removing DPCs…\n"));
KeRemoveQueueDpc(&pdx->ReadServiceDpc);
KeRemoveQueueDpc(&pdx->WriteServiceDpc);
As I understand the docs, this should stop my timers and flush the DPC
queue of any related requests, so that when KeRemoveQueueDpc returns, no
instances of that DPC remain queued. And in 2K/XP, that’s exactly how
it works. In 98, however, I’m seeing a page fault soon after
RemoveDevice is called, and a stack trace shows 2 calls within the
symbol space of the driver, but not aligned with actual call statements
in the ASM. I suspect that the DPC queue wasn’t properly flushed and a
lingering DPC is calling into what used to be my driver. Does this
sound right? And if so, how do I assure thet the DPC queue does get
completely flushed before allowing my driver to unload.
As always, clues appreciated and thanks in advance.