DDK explaining IoMarkIrpPending explains:
" Unless an IRP's dispatch routine completes the IRP (by calling
IoCompleteRequest) or passes the IRP on to lower drivers, it must call
IoMarkIrpPending with the IRP. Otherwise, the I/O Manager attempts to
complete the IRP as soon as the dispatch routine returns control. "
I understand when to call IoMarkIrpPending. What I didnot understand
is why to call Irp pending. I also *understand* IoCompleteRequest is
something like saying to IoManager " Thanks, I am done. Now I return
back Irp to you".
(Consider a simple case where application sends Irp to top most driver
and top most driver has to handle it and no other lower driver bothers
to know this Irp.)
1. I think IoManager should not touch our Irp (once passed to us)
unless we pass it to next layer in IoCallDriver or unless we complete
Irp. I am curious to know why this is not the case. Why IoManager
bothers to monitor Irp(even if I didnot say 'I am done' with Irp)
after returning from dispatch routine. I agree that it makes sense for
IoManager to look into Irp if I said 'I am done, go ahead'.
2. I know (1) is wrong assumption, then I think we dont have to call
IoCompleteRequest in dispatch routine because if I handle/process the
Irp and return from dispatch routine(without passing down and without
calling IoCompleteRequest), *anyway* IoManager will complete because I
didnot call IoMarkIrpPending.
Thanks for comments.