Hi
I have a minidriver/class driver Architecture. The classdriver is a Kernel
DLL and I have the Problem of updating it. The DLL is dynamically loaded by
the Kernel when the minidriver is installed. When the minidriver is unloaded
(hardware device removed) the class driver still remains loaded. Is it a way
to unload it also, either from the minidriver or using a SetupDi routine ?
thanks
horatiu
IIRC , NT 4.0 does not makes any effort to maintain reference counts on
kernel modules. So it will stay there.
On Windows 2000 an up , kernel mode DLL’s are allowed to specify 2 methods
called
DllInitialize & DllUnload which allows a kernel mode DLL to perform
initialization tasks, respectivly cleanup.
You simply must export DllUnload method (prototype is found in DDK, IIRC) to
allow a DLL to be unloaded.
The issue is that when your main driver is unloaded, as a result of deletion
of its DriverObject, the OS will
try to dereference imports. If it finds that a DLL must be unloaded, it will
try to call it’s DllUnload method.
if the DLL does not export this method, then the OS assumes that the DLL
cannot perform required cleanup opeartions , and will leave the DLL in
memory. If it finds this exported method, and the DLL is required to return
a BOOLEAN value which indicates to the Mm whatever it can unload the DLL or
not. If the DLL signaled that the Mm can unload it, the Memory manager will
unload.
If you think , this mechanism is ok, since the OS cannot blindly unload a
DLL which did not performed necessarely cleanup. The DLL could create
threads, system objects and so on , and a blind unload can lead to imediate
system crash
Ciao, Dan
----- Original Message -----
From: “Horatiu G.”
To: “NT Developers Interest List”
Sent: Friday, July 05, 2002 2:48 PM
Subject: [ntdev] unloading Kernel DLL’s
> Hi
>
> I have a minidriver/class driver Architecture. The classdriver is a Kernel
> DLL and I have the Problem of updating it. The DLL is dynamically loaded
by
> the Kernel when the minidriver is installed. When the minidriver is
unloaded
> (hardware device removed) the class driver still remains loaded. Is it a
way
> to unload it also, either from the minidriver or using a SetupDi routine ?
>
> thanks
> horatiu
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to %%email.unsub%%
>
Sorry , retuen value is a NTSTATUS , not a boolean.
----- Original Message -----
From: “Horatiu G.”
To: “NT Developers Interest List”
Sent: Friday, July 05, 2002 2:48 PM
Subject: [ntdev] unloading Kernel DLL’s
> Hi
>
> I have a minidriver/class driver Architecture. The classdriver is a Kernel
> DLL and I have the Problem of updating it. The DLL is dynamically loaded
by
> the Kernel when the minidriver is installed. When the minidriver is
unloaded
> (hardware device removed) the class driver still remains loaded. Is it a
way
> to unload it also, either from the minidriver or using a SetupDi routine ?
>
> thanks
> horatiu
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to %%email.unsub%%
>