The points in time where you create and destroy the control device
object do not work for a pnp driver. For a pnp driver, if you create a
device object in DriverEntry(), you can create a situation where you
don’t unload if no pnp device stacks are built (b/c of the existing
devobj). Furthermore, once you have created the control device object,
you must delete it when you are deleting the last FDO created in your
driver. If you don’t, DriverUnload() is not called and there will be no
way for you to delete the control device object in DriverUnload().
A cleaner way of doing this, which is what I originally proposed to Yu
Zhou is that you create a raw PDO per FDO. That way you can get one to
one mapping with the FDO, you get guarantees that the raw PDO doesn’t
have any open handles and there is less management in the flow from
PDO->FDO where in the control devobj->FDO you have to build in
addressing into every message to address a separate FDO. Now, the
breakdown here is that I proposed to Yu Zhou to do this in KMDF. Doing
this in KMDF is very simple and trivial. Doing this in WDM is not.
d
– I can spell, I just can’t type.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S.
Shatskih
Sent: Thursday, May 25, 2006 4:52 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] how can I implement PDO pnp dispach routine
I would recommend to have 1 per-driver named non-PnP control device
object, created in DriverEntry and deleted in Unload.
You can access all “working” stacks from it by names, and even have
a “list the names of all working stacks” IOCTL. Something like NDISPROT
sample does with network adapters - it has only 1 control device, not a
per-adapter one.
NdisMRegisterDevice is a similar thing.
In the past, I was against this approach and considered the approach
of per-working-stack control device, but after I have considered the
hardships or removal of this control device when the working stack is
destroyed by PnP I would not recommend this idea anymore.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer