Got it. Thanks.
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Thursday, August 09, 2012 6:19 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
You are fine. By not setting a completion routine at all, when the lower
driver completes the request the completed request completes back to the
io manager immediately, thus freeing the irp.
d
debt from my phone
From: Hayden Smith
Sent: 8/9/2012 4:23 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
Yes, I think I am confused.
So, currently I have a function SendAwaitUrb that builds the irp with
IoBuildXx. I do not register a completion routine but just wait on an
event that is set by the lower driver when the request is complete.
I then just return from the SendAwaitUrb function with the lower drivers
status from the IoStatusBlock (registered in the call to IoBuildXx).
I do not do anything with the irp, it is not completed or freed. This
appears to be the same technique as used in many ddk sample drivers - in
those cases I do not see how the irps are completed or freed!?
This currently works with no problem. However I am concerned that I am
allocating lots of irps that are never freed as they are allocated in a
thread that belongs to my driver. They will ultimately only be freed
when my driver thread is terminated.
Are you suggesting that I MUST make a completion routine in order to
complete the irp
OR
Can I just call IoCompleteRequest after the event is signaled and the
KeWaitXx has returned.
Either way I should take care of these irps, right?
Hayden
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Thursday, August 09, 2012 3:31 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
You are confusing yourself. When you build an irp with IoBuildXxx, you
can complete it in three ways
- return something != STATUS_MORE_PROCESSING_REQUIRED in your
completion routine
- return STATUS_MORE_PROCESSING_REQUIRED in your completion routine and
explicitly call IoCompleteRequest in the completion routine
- return STATUS_MORE_PROCESSING_REQUIRED in your completion routine and
explicitly call IoCompleteRequest somewhere outside of the completion
routine
Don’t rely on thread termination to clean up the irp on your behalf,
especially when you are in an arbitrary thread context like the pnp
start irp
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Hayden Smith
Sent: Thursday, August 9, 2012 2:52 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
Hi,
Thanks for your answer Doron.
So, on further inspection I found that my function SendAwaitUrb that
calls IoBuildDev… can be called directly from my PNP dispatch
function. In this case the irp from IoBuildDev… is created in the
context of the PNP request and so will be freed when IoCompleteRequest
is called for the original irp as long as this is not completed with
STATUS_MORE_PROCESSING_REQUIRED.
However when this function is called from my driver allocated thread I
need to explicitly complete the allocated irp with IoCompleteRequest
which will then free the irp.
Hayden
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Hayden Smith
Sent: Thursday, August 09, 2012 1:51 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
So I do need to complete the request, and according to the documentation
for IoBuildDeviceIoControlRequest IoCompleteRequest is the way to do it
as this will free the irp.
Thanks,
Hayden
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Thursday, August 09, 2012 1:34 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
Correct, but for IoBuildXxx generated irps, you need to complete the
request back to the io manager so the irp can be freed. This is unlike
IoAllocateIrp created IRPs which must never be completed back to the io
manager to be freed, your driver must free them with IoFreeIrp
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bill Wandel
Sent: Thursday, August 9, 2012 1:30 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Basic question regarding
IoBuildDeviceIoControlRequest and IoCompleteRequest
The driver that you send the IRP to completes the request.
Bill Wandel
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@lasercard.com
Sent: Thursday, August 09, 2012 4:19 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Basic question regarding IoBuildDeviceIoControlRequest
and IoCompleteRequest
Hi,
In my driver I use IoBuildDeviceIoControlRequest to send a URB down the
stack. I wait on an event for the completion of the IRP. This is
called in the context of a driver allocated thread that comes into
existance when the driver is loaded and terminates when the driver is
unloaded.
Now the documentation for IoBuildDeviceIoControlRequest states that the
IRP 's created by IoBuildDeviceIoControlRequest must be completed by a
driver’s call to IoCompleteRequest, this is when the I/O manager frees
the IRP. It also states that when the thread exits the I/O manager
cancels the IRP.
I noticed that all the samples in the DDK do not call IoCompleteRequest.
So in these cases the driver writer is deffering the freeing of the IRP
to the time the thread is terminated? Correct?
For my driver the thread is not terminated until the driver is unloaded
so there could be 1000’s of IRP’s hanging around that are not getting
freed.
Is this correct? Seems like this could be a big problem!
Should I be calling IoCompleteRequest?
Thanks,
Hayden
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
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