how can I implement PDO pnp dispach routine

Hi Experts,
I use Bulkusb sample to read my usb point device.Because the driver
is exclusive to win32,I add second device object.
Now I can see second device object name with devicetree.I knowI must
implement IRP_MJ_CREATE/CLEANUP/CLOSE process dispach routine.I debug my pnp dispach routine,I find incoming DeviceObject is always FDO.So how can I implement PDO pnp dispach routine?
After fininshing above,the driver can receive IOCTL from application?
Could you give me an advice?Thanks a lot.


ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ£¡

Hi Yu Zhou,

I think you don??t make it clear yet. I am really confused by what you said.
What does this sentence mean, ??Because the driver is exclusive to win32, I
add second device object.???

Actually, it??s okay that IRP_MJ_PNP always come into your PnP dispatch
routine with FDO, because the PnP IRPs are sent to your FDO, NOT to your
PDO. I don??t know why it is necessary for you to implement a ??PDO PnP
dispatch routine??.

You can find PDO in AddDevice routine
(DriverObject->DriverExtension->AddDevice).

Thanks,

Phillip


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Yu Zhou
Sent: 2006??5??25?? 17:39
To: Windows System Software Devs Interest List
Subject: [ntdev] how can I implement PDO pnp dispach routine

Hi Experts,
I use Bulkusb sample to read my usb point device.Because the driver
is exclusive to win32,I add second device object.
Now I can see second device object name with devicetree.I knowI must
implement IRP_MJ_CREATE/CLEANUP/CLOSE process dispach routine.I debug my pnp
dispach routine,I find incoming DeviceObject is always FDO.So how can I
implement PDO pnp dispach routine?
After fininshing above,the driver can receive IOCTL from application?
Could you give me an advice?Thanks a lot.


http: ??ע?Ż???-3.5G???20M??? —
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</http:>

They are the same for the FDOs and the PDOs. There are no PDOs in you driver, you driver creates FDOs in the AddDevice. The PDOs are created by the underlying USBhub driver.
“Yu Zhou” wrote in message news:xxxxx@ntdev…
Hi Experts,
I use Bulkusb sample to read my usb point device.Because the driver
is exclusive to win32,I add second device object.
Now I can see second device object name with devicetree.I knowI must
implement IRP_MJ_CREATE/CLEANUP/CLOSE process dispach routine.I debug my pnp dispach routine,I find incoming DeviceObject is always FDO.So how can I implement PDO pnp dispach routine?
After fininshing above,the driver can receive IOCTL from application?
Could you give me an advice?Thanks a lot.

------------------------------------------------------------------------------
??ע?Ż???-3.5G???20M???

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

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