Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IRP handling without IoCompleteRequest (Irp, IO_NO_INCREMENT)

400 views
Skip to first unread message

yathirajarao

unread,
Jun 10, 2008, 8:50:16 AM6/10/08
to

Hi,

I am learning windows driver model (book by Walter oney)

Following is my theoretical doubt regarding IRP handing

I know that every driver in the Driver stack should complete the IRP
with

IoCompleteRequest(...). Is it true?

I found that some ddk sample drivers not completing the IRP, but they
sening the IRP down

the stack with IoCallDriver() and returning from the dispatch
function. (without setting
any Io completion routine and without calling IoCompleteRequest (Irp,
IO_NO_INCREMENT))

Ex: Mouse class

case IRP_MN_STOP_DEVICE:

IoSkipCurrentIrpStackLocation (Irp);
status = IoCallDriver (data->TopPort, Irp);
break;


If suppose the driver stack is like this

| |
|Driver A |
|------------ |
|Driver B |
|-------------|
|Driver C |
|_______ |

IRP received the IRP at

Driver A
--------
Driver A - Sets the IoSetCompletionRoutine and send the IRP down to
Driver B.
(Inside the Io completion routine, it completes IRP with
IoCompleteRequest (Irp,IO_NO_INCREMENT)

Driver B:
---------
Sends the IRP down to Driver C without setting
IOCompletionroutine (and without waiting

syncronously) (It won't call IoCompleteRequest)

Driver C:
----------

Process the IRP and calls IoCompleteRequest (Irp, IO_NO_INCREMENT).


My query is:
============

After driver C called IoCompleteRequest, IoManager checks for the
completion routine of

driver B. Since it is not set, what IOmanager will do?

Since Drivver B won't call IoCompleteRequest, Who will call the
IoCompletionRoutine of

Driver A.


Thanks
Raja

Don Burn

unread,
Jun 10, 2008, 8:56:48 AM6/10/08
to
NO THIS IS VERY WRONG. Each IRP should only have one IoCompleteRequest
called on it (with one special case where more than one can be called). So
if you pass the IRP down, you no longer own it and you should not complete
it. The I/O manager is the one to walk back the IRP stack calling
completiong routines as needed. The one specail case is if you have a
completion routine and return STATUS_MORE_PROCESSING_REQUIRED which
indicates you want the IRP and cancel the completion.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply


"yathirajarao" <yathir...@gmail.com> wrote in message
news:bd86bcb4-6ee6-4686...@d19g2000prm.googlegroups.com...

Uv

unread,
Jun 11, 2008, 12:52:01 PM6/11/08
to

IoCallDriver is a way to call *down* the stack. IoCompleteRequest is
the way to pass on handling to driver *above* you.
There are, in general, four standard ways any driver can process IRPs:
1. Process, then send down and forget about it. In this case, call
IoCallDriver, then DO NOT TOUCH THE IRP AFTER THAT. EVER.
2. Install completion callback then call IoCallDriver, so that you can
process the IRP as it is coming upwards. Here you can have two cases:
a. Synchronous: You dont need further processing and therefore you
return STATUS_SUCCESS from the completion routine. In this case, DO
NOT CALL IoCompleteRequest. Someone below you has already called it,
and therefore you must NOT call it again.
b. Asynchronous: You _do_ need further processing, but cannot do it
in the completion callback - so you signal another execution context
(with an event perhaps) to do your work. In this case you must return
STATUS_MORE_PROCESSING_REQUIRED in your completion routine. This tells
the IO Manager that the IRP cannot be completed at the moment.
Somewhere else in your code, you complete processing that IRP and now
you MUST CALL IoCompleteRequest on it. This is the special case which
Don spoke of. This IRP needed 2 calls to IoCompleteRequest (one by the
driver below you and one by your driver) and if drivers above you do
the same thing, it may be possible that IoCompleteRequest is called on
this IRP by those drivers again as well.
3. You are the actual handler for that IRP. The IRP terminates in your
handler routine. In this case, you dont ever call IoCallDriver. You
call IoCompleteRequest and NEVER TOUCH THE IRP AGAIN.

In #1, your driver never calls IoCompleteRequest. Some driver below
you does that.
In #2a, your driver never calls IoCompleteRequest. Some driver below
you does that. All you do is to hook onto the upward call path.
In #2b, Your driver calls IoCallDriver AND IoCompleteRequest. Special
case!
In #3, your driver calls IoCompleteRequest only.

In #

yathirajarao

unread,
Jun 12, 2008, 12:58:59 AM6/12/08
to
> In #- Hide quoted text -
>
> - Show quoted text -

Hi,

Thnaks for the detailed answers,

It cleared all my doubts,

Raja

0 new messages