One of the odd problems about receiving your own IRP back is that you need
to complete with STATUS_MORE_PROCESSING_REQUIRED, which is a really bad name
for what should have been
STATUS_PLEASE_DO_NOT_TRY_TO_COMPLETE_THIS_IRP_AT_A_HIGHER_LEVEL, because
there isn’t a higher level. I find a number of people confused by this
name, saying things like “But that doesn’t make any sense. I’ve just freed
the IRP, and therefore there is no more processing required”. So they
complete with STATUS_SUCCESS and wonder why they bluescreen. It is easy to
see how completing with this code suggests that the IRP is somehow in the
“middle of a transfer”, but as you point out, there is no transfer it could
possibly be in the middle of; it’s dead and gone. Some *other* IRP was in
the middle of a transfer, and that’s the IRP you now need to complete in
your completion routine. The confusion is not lessened by the fact that if
you reuse your IRP for another transfer (the classic USB Bulk Transfer
source example we had for decades in the old DDK), you *also* respond with
STATUS_MORE_PROCESSING_REQUIRED. So the same code says “I’m sending the IRP
down again” and “the IRP is dead and gone”. [But Microsoft has not been
noted for selecting sensible names (or even names that are spelled
correctly, e.g, PAGABLE, meaning “something that can be pagged”. And who
would name an API “CreateFile” whose real job is “OpenAnIoHandle”, since it
opens handles to named pipes, mailslots, devices, and, oh yes, files. When
I was first learning Win32 20 years ago (Time Files When You’re Having Fun)
I went looking for a corresponding OpenFile API, thinking that this was
reflecting the old _creat/_open model. Of course, it wasn’t.) Bottom line:
it is confusing when the concepts of “I really am in the middle of a
transfer” and “I have completed using my IRP” are indicated by the same
return value, which has a misleading name.
I haven’t written a driver in years, but I get to read code of non-working
drivers all the time, trying to explain to the client why what they have
[usually outsourced overseas] could not possibly ever work under any
imaginable conditions and can only be salvaged by a total rewrite. And I
often turn them down if they ask me if I could rewrite it, and frequently
point them at OSR. I cannot emulate what’s in Tony’s head [yes, many of
these are file system drivers, and even *I* can see that they don’t work.
If I’m uncertain, I use Driver Verifier to demonstrate that they are wrong,
usually in PnP or Power but often in fundamental ways that are easy to see
and hard to fix].
joe
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, January 05, 2011 2:41 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Reusing IRPs when transfer is incomplete
xxxxx@gmail.com wrote:
Ok let us ignore the case of Iomanager’s Irps. The whole context is for my
own Irps allocated using IoAllocateIrp.
Now I see that I can choose to do a IoReuseIrp inside a completion routine
before sending the Irp down for next stage of transfer after setting up the
next stack. However, I was thinking, why is it ok to wipe out all flags
using IoReuseIrp (assuming IoReuseIrp clears everything) on my own Irp when
it is not ok to do the same on IoManager’s Irp. I understand that no one
else cares for my irp unlike that of Iomanager’s Irp. Hence this should be
alright. But is it ok to alter the state of the Irp in the middle of
transfer in a completion routine before doing next stage of transfer?
Your last sentence does not describe the reality. For an IRP that you
created, when it gets back to your completion routine, its life is over. It
has served its purpose. It has nowhere else to go. It’s not in “the middle
of a transfer” – that’s merely the way you are USING the IRP. The IRP
itself has expired. You are free to do whatever you want with it.
That’s not the case with an I/O manager IRP. When such an IRP reaches your
completion routine, it still has things on its bucket list that must be
accomplished before it can be allowed to die. You must complete such an
IRP, so it can rise up to the next level and fulfill its promises.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
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
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.