Hello,
maybe I just need to stand up to find the answer 
I assume the answer for my question is that easy, that I just do not find it.
If a request comes from the device of a driver above me (which is the normal case) where do I find the device object for the device of this driver?
I need to send a request (IRP) to this device/driver.
Thanks
Norbert
Norbert Wietschorke wrote:
If a request comes from the device of a driver above me (which
is the normal case) where do I find the device object for the
device of this driver? I need to send a request (IRP) to this
device/driver.
I would question your design in this case, why is the information you need not already present in the IRP you received?
If this from within your stack, you can call IoGetAttachedDeviceReference to get the top of the stack, which may or o may not be the driver which sent you the io request (the driver which sent the irp could be above you but there may be another driver layered on top of it). Remember to call ObDereferenceObject when you are done with the devobj
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmx.de
Sent: Tuesday, October 06, 2009 12:50 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Sending a IRP to the driver above me
Hello,
maybe I just need to stand up to find the answer 
I assume the answer for my question is that easy, that I just do not find it.
If a request comes from the device of a driver above me (which is the normal case) where do I find the device object for the device of this driver?
I need to send a request (IRP) to this device/driver.
Thanks
Norbert
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
> If a request comes from the device of a driver above me (which > is the normal case)
Well, this is not only the “normal case” but the only possible one unless you are on top of the stack- you always receive an IRP from a driver above you, which, however, does not imply that IRP was actually originated by this driver…
where do I find the device object for the device of this driver?
…in AttachedDevice field of your PDEVICE_OBJECT.
I need to send a request (IRP) to this device/driver.
As Doron already pointed out, if you are about to send IRP to your target device you can send it to the top of the stack. However, please note that once any driver in a stack may choose not to pass IRP down and, instead, complete it with this or that status, there is no guarantee that IRP will eventually reach your target driver.
In other words, everything depends on what you are trying to do. Are you trying to implement/use some proprietary channel of communication between your device and the one attached to it? If this is the case, is there any chance to make things work the other way around and make the driver above you on the stack send an IRP to yours in order to enable this channel?
In any case, if you want to send IRP directly to attached device don’t forget to reference it before actually using it…
Anton Bassov
>If a request comes from the device of a driver above me (which is the normal >case) where do I find the device object for the device of this driver? I need to >send a request (IRP) to this device/driver.
I don’t know your design but why you don’t want to provide additional information, for a driver who originate Irp, in your Completion routine. This information would be read in Completion routine of the driver who send Irp.
Igor Sharovar
Some drivers rely IRPs. Good luck.
Forgive me for jumping in …
Actually the question was, if I read it correct, when a driver at the
lower level of a stack gets an IRP, how could the lower driver
communicate back to upper driver. In other words, how could the lower
driver get to the device object of the upper driver, and send an IRP
“Hey why are you bugging me …”
It is totally counter intuitive to me, so I don’t know why it is needed.
An obvious problem could be a cycle of IRP going back and forth…
But who knows, these days in the name of reverse engineering, security
and all … anything being considered legit !!!
So completion routine and others are not related to the question !!!.
-pro
xxxxx@hotmail.com wrote:
> If a request comes from the device of a driver above me (which is the normal >case) where do I find the device object for the device of this driver? I need to >send a request (IRP) to this device/driver.
>
I don’t know your design but why you don’t want to provide additional information, for a driver who originate Irp, in your Completion routine. This information would be read in Completion routine of the driver who send Irp.
Igor Sharovar
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
My driver is sitting below the PartMgr and with Vista some IOCTL functions are moved from the disk to the partmgr. and from the UpperFilter load order I know (sure this is not guaranteed) that PartMgr is above my driver.
What I read from the replies is, that I could send the IOCTL either to the top of the stack (using IoGetAttachedDeviceReference) or using the AttachedDevice field.
I assume using top of the stack could be better as it’s then not required that PartMgr is directly above my driver. Sure I need to check that the drivers between will not filter out the IOCTL.
But as for common things like IOCTL_DISK_GET_DRIVE_LAYOUT_EX they shouldn’t.
I will try it.
Thanks for all answers.
Norbert
>What I read from the replies is, that I could send the IOCTL either to the top >of the stack (using IoGetAttachedDeviceReference) or using the >AttachedDevice field.
Is your driver a class disk driver? If it is , I just curious why do you need that?
The sample of class disk of WDK sends Irp to the the top most driver but probably only in one case.
Igor Sharovar