Unloading driver and IRP completion routine

Hi everyone,

Currently I’m working on a NDIS/WDM miniport driver that talks to a
lower level driver. It needs to work on both W2K and XP, so it’s NDIS
5.0. It works by allocating the IRP with IoAllocateIrp, set a
completion routine and other parameters, call the driver with
IoCallDriver, and freeing the IRP with IoFreeIrp in the completion
routine. I need to prevent the driver from unloading before the IRP is
completed and freed. I suppose I could do that by waiting for an event
in MiniportHalt, and signalling that event in the completion routine
when it’s done.

Here’s my question:

The completion routine can run at any IRQL <= DISPATCH, ie it may be
preempted at any time. Therefore, in theory it is possible that the
completion routine may be preempted right after it has signalled the
event, but before it returns. Meanwhile, my MiniportHalt would unblock
and return to NDIS, and NDIS would think that we’re all done and unload
us. Bad things will probably happen when the now defunct completion
routine resumes execution. So, is there a better way to do this? Or am
I being paranoid?

Thanks!


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com