From MSDN DDK document,

IRPs created using IoBuildDeviceIoControlRequest must be completed by
calling IoCompleteRequest and not by merely deallocating the IRP with
IoFreeIrp. IoBuildDeviceIoControlRequest queues the IRPs it creates in the
IRP queue of the current thread. Freeing these IRPs without completing them
might result in a system crash when the thread terminates as the thread
attempts to deallocate the IRP's memory.

However, from DDK examples and likes from other sources, I didn't see any
FreeIrp or CompleteIrp for this reason. Seems to me the IRP is not freed
anywhere through the code.

Who frees this IRP?

Re: Who will free Irp from IoBuildDeviceIoControlRequest? by Eliyas

Eliyas
Tue Mar 15 11:30:47 CST 2005

System will free the IRP. Drivers shouldn't free IRPs created using
IoBuildDeviceIoControlRequest and IoBuildAsynchronousFsdRequest.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx



Re: Who will free Irp from IoBuildDeviceIoControlRequest? by Calvin

Calvin
Tue Mar 15 11:37:58 CST 2005

Don't worry...nt!IopCompleteRequest will do that. It's called either by
nt!IofCompleteRequest or a special kernel mode APC as a result of
asynchronous I/O completion.

HTH,
/calvin
--
Calvin Guan Software Engineer/Radeon NT Drivers
ATI Technologies Inc. Markham ON, Canada www.ati.com


"jasonlue" <jasonlue@discussions.microsoft.com> wrote in message
news:72732A78-E22A-4A36-A0CF-507C78908AF1@microsoft.com...
> From MSDN DDK document,
>
> IRPs created using IoBuildDeviceIoControlRequest must be completed by
> calling IoCompleteRequest and not by merely deallocating the IRP with
> IoFreeIrp. IoBuildDeviceIoControlRequest queues the IRPs it creates in the
> IRP queue of the current thread. Freeing these IRPs without completing
them
> might result in a system crash when the thread terminates as the thread
> attempts to deallocate the IRP's memory.
>
> However, from DDK examples and likes from other sources, I didn't see any
> FreeIrp or CompleteIrp for this reason. Seems to me the IRP is not freed
> anywhere through the code.
>
> Who frees this IRP?



Re: Who will free Irp from IoBuildDeviceIoControlRequest? by Maxim

Maxim
Wed Mar 16 06:44:14 CST 2005

> However, from DDK examples and likes from other sources, I didn't see any
> FreeIrp or CompleteIrp for this reason. Seems to me the IRP is not freed
> anywhere through the code.
>
> Who frees this IRP?

IopCompleteRequest, which is called either by IopSynchronousServiceTail after
return from IoCallDriver (if the driver returned non-pending status) or queued
as an APC for a thread in IoCompleteRequest (if IoMarkIrpPending was called for
the IRP).

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Who will free Irp from IoBuildDeviceIoControlRequest? by Doron

Doron
Wed Mar 16 10:35:59 CST 2005

If you set a completion routine, you either call IoCompleteRequest in it and
return STATUS_MORE_PROCESSING_REQUIRED, or leave the irp alone and return
any status code that is not equal to
STATUS_MORE_PROCESSING_REQUIRED.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Eliyas Yakub [MSFT]" <eliyasy@online.microsoft.com> wrote in message
news:e06x6SYKFHA.1620@TK2MSFTNGP14.phx.gbl...
> System will free the IRP. Drivers shouldn't free IRPs created using
> IoBuildDeviceIoControlRequest and IoBuildAsynchronousFsdRequest.
>
> --
> -Eliyas
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
>