Dispatch called after Unload by Steve
Steve
Wed Mar 23 18:20:19 CST 2005
Another easy solution is to close the app before you
uninstall your driver! A more complicated alternative is
that you get the driver to inform user mode apps (via a
notification system) that it is about to unload and that
they should close all handles to the driver.
Look at the ddk help on ProtocolUnload. This is the
callback specified in the protocol characteristics that
you used when you registered the protocol using
NdisRegisterProtocol.
The help says ... ProtocolUnload performs driver-
determined cleanup operations. For example,
ProtocolUnload could request clients to close handles
that they have opened to device objects exported by the
protocol. Until all such handles are closed, the I/O
Manager will not call the DriverUnload function that the
protocol registered in the driver object passed to its
DriverEntry function. After all the handles are closed,
ProtocolUnload could call IoDeleteDevice one or more
times to delete device objects created by the protocol.
In the passthru example, that your driver is probably
based on, the driver's device object is deleted in
PtDeregisterDevice() using NdisMDeregisterDevice().
Good luck.
Steve
>-----Original Message-----
>I'm just guessing here, but I expect your user mode app
>opens a handle to your IM driver when it starts and
>closes it when it finishes. This is bound to lead to
>problems because you'll be left with an invalid handle
>when the IM is uninstalled.
>
>There is an easy fix for your problem. Have your user
>mode app open and close its handle to the IM driver
>everytime you send an IOCTL. This way, if you uninstall
>the driver, when the user mode app attemps to open it
>again it will/should fail! This is what I do and I have
>no problems.
>
>Steve.
>
>>-----Original Message-----
>>I have an NDIS IM driver that has an IOControl
interface
>that is called at
>>least once a second by an application. Whenever the
>driver is uninstalled
>>and the application continues to send IRPs, the
Dispatch
>routine of the
>>driver gets called AFTER the Unload has completed
>causing a BSOD because the
>>reference data has been released by the Unload.
>>
>>How can I prevent this call to Dispatch after the
Unload?
>>
>>
>>Larry C
>>
>>
>>.
>>
>.
>