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 (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...
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 #
Hi,
Thnaks for the detailed answers,
It cleared all my doubts,
Raja