How does a lower level driver communicate with higeh level driver?

Hello all,

I know that a high level driver can call build a IOCTL Irp and call IoCallDriver to communicate with lower level driver. But I don’t kown how a lower level driver communicate with high level driver?

Please give me some advice! Thanks.

You can build IOCTLs and IoCallDriver any driver you want as long as you
know the DeviceObject you aim at.
If the drivers are “your” drivers and the IOCTLs are “your” custom IOCTLs
you have perfect control of what
is going to happen regardless of the altitude. Otherwise be prepared to be
hit by your own request in your lower
level driver.

Regards
Else

xxxxx@yahoo.com.
cn To: “Windows System Software Devs Interest List”
Sent by: cc:
bounce-294474-16691@li Subject: [ntdev] How does a lower level driver communicate with higeh level driver?
sts.osr.com

07/20/2007 09:58 AM
Please respond to
“Windows System
Software Devs Interest
List”

Hello all,

I know that a high level driver can call build a IOCTL Irp and call
IoCallDriver to communicate with lower level driver. But I don’t kown how a
lower level driver communicate with high level driver?

Please give me some advice! Thanks.


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

Hello,

if you just want to get the highest-level device object of your device stack at any given time,
simply call IoGetAttachedDeviceReference with your own device object.

Don’t forget to dereference the object once you’re done.

Higher and lower driver are both written by myself. Higher driver is not the highest driver in the driver stach. How can I get the device object of the higher driver in the lower driver?

As Else Kluger already said, if you’re using custom IOCTLs no other drivers know about, you can usually call the highest device object.

All higher devices will get the device control request, but they won’t know them and just pass the IRP down to the next lower, eventually your higher, device.

That’s the theory, but there are some very strict ones completing the IRP indicating failure, so you have to experiment.

If it doesn’t work, use inter-driver communication:
http://www.osronline.com/article.cfm?id=24

If you’ve chosen inter-driver communication, you don’t need to use IOCTLs/IRPs at all, just use your callback routines.

You could also reverse the relationship between your drivers.
The higher device could issue a device control request.
The lower device would eventually receive it (assuming no other device completed the IRP) and pend it.
Once the lower device decides to complete it, the higher device would immediately send another device control request and the lower one would again pend it.

That’s much more complicated, because you have to deal with IRP cancellation, etc…

WOW! That’s I need.

Thank you very much Alyah Nihal!

If you are going to use callbacks, I would suggest using
IRP_MN_QUERY_INTERFACE to pass the callback pointers around. Using
IOCTLs may not work b/c if there are any drivers between your lower and
upper filter, these drivers can fail unknown IOCTLs instead of passing
them down the stack. The rules for IRP_MN_QUERY_INTERFACE require (and
driver verifier enforces) that an unknown interface query is passed down
the stack, guaranteeing that your query flows through the entire stack
until it hits your driver.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com.cn
Sent: Friday, July 20, 2007 12:59 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How does a lower level driver communicate with higeh
level driver?

Hello all,

I know that a high level driver can call build a IOCTL Irp and call
IoCallDriver to communicate with lower level driver. But I don’t kown
how a lower level driver communicate with high level driver?

Please give me some advice! Thanks.


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

> But I don’t kown how a lower level driver communicate with high level driver?

Registering a custom callbacks seems to be the most obvious solution, don’t you think???

Please give me some advice!

I would advise you to look through WDK samples before asking questions - the very first architecture in which a lower driver calls an upper one via upper-driver-supplied callback that comes to my mind is i8042prt - kbdclass pair…

Anton Bassov

> Using IOCTLs may not work b/c if there are any drivers between your lower and

upper filter, these drivers can fail unknown IOCTLs instead of passing them down the stack.

Unfortuantely, this is true - whenever there is a theoretical possibility of having some third-party driver in your stack, it makes sense to assume a theoretical possibility of having to deal with the most idiotic and unprofessional tricks one can possibly think of…

Anton Bassov