Are you deleting the control device when the last FDO is removed even when there are open handles against the CDO? Or are you delaying the delete until the handle has been closed?
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of David R. Cattley
Sent: Saturday, April 05, 2008 5:47 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Control Device Inhibits Unload
Tim,
I have seen this exact behavior in NDIS IM drivers with control devices.
The Control Device does indeed close and go away. However, there is nothing
at that point triggering PnP to check the count of devices in the driver
object and to request the driver shutdown. The next time you plug-in a
device and remove it, however, with the Control Device closed, you will see
the unload occur.
This knawed at me a long time until I finally figured out that the dynamic
load/unload of the driver is a policy implemented by PnP. The control
device is not part of a PnP stack and so if it is the last DO to go, its
departure is unknown to PnP. If (as is the normal case surely for your
driver) the control device departs before the PnP DO (FiDOs) depart, then,
PnP never sees the CDO’s ‘reference’ on the driver object as being an issue
for deciding to unload the driver.
-dave
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Saturday, April 05, 2008 12:37 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Control Device Inhibits Unload
Tim, can you register a EvtFileClose/Cleanup and verify that the handle is
actually being closed after you s.r. with the UI open?
Thx!
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Friday, April 04, 2008 6:54 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Control Device Inhibits Unload
So it’s not just the fact that you had a control device, it’s either that
you opened the control device or that you had it opened after the filter
device object was removed?
Does the control panel do anything with the control device besides open a
handle to it?
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 04, 2008 6:46 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Control Device Inhibits Unload
I have a KMDF filter driver based on the toaster/filter sample. It’s a
lower filter to usbaudio.sys for a couple of video cameras. I use the
control device object to communicate with the device through a control
panel applet. The applet opens an instance of the control device, and
keeps it open until the applet dialog closes.
While chasing down another problem today, I ran the following scenario:
- Plug in device. Driver loads, creates control device, all is happy.
- Start control panel, which opens handle to control device.
- Surprise-remove the device.
At this point, the filter device closes up shop properly. The driver
runs WdfObjectDelete on the control device, thereby releasing its
reference. Now:
- Stop control panel app, thereby closing the control device handle.
- Re-plug the device.
What happens here is functionally correct: a new filter device is
created, it creates a new control device, and that control device can be
used. However, during that entire unplug/replug, the filter driver
never got unloaded. I expected that closing the control panel app,
which closes the control device handle, would release the last driver
reference and allow the driver to unload. That does not happen. If I
had left the control panel app up during the replug, I would expect
this, but when the last open handle is closed, I expected it to unload.
If I do another surprise removal here, without involving control panel,
the driver does unload normally, so it’s not like there is some dangling
instance somewhere.
This is quite repeatable. I’d appreciate any thoughts, besides “don’t
do that”.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer