In your initial posting you said that the I/O manager frees your IRP when
you return MORE_PROCESSING_REQUIRED, that’s where “not telling the whole
story” came from. Now you are not saying that anymore.
The IRP completion is done by IoCompleteRequest. To answer your question,
it’s natural to turn attention to IoCompleteRequest. Let me tell you what I
think IoCompleteRequest is doing, and you can try to verify that. This is a
very crude description, but I believe it is correct in its major features.
Generally, the function walks IRP stack locations, from the current to the
oldest one, calling completion routines. At the same time, it moves the
current location’s pointer in the IRP by one position, before it calls the
completion routine. If a completion routine returns
MORE_PROCESSING_REQUIRED, IoCompleteRequest immediately exits. If you
immediately call IoCompleteRequest again on this IRP, it will continue
walking and calling completion routines, from the place it stopped the last
time. Because the current location’s pointer was moved before calling that
last completion routine (which returned MORE_PROCESSING_REQUIRED), this time
it will call the next older completion routine and proceed from that to
older ones.
(Of course, all the above is done with paying proper attention to whether
the completion routine at hand is even specified (not NULL), and whether it
needs to be called given the IRP completion status (success, failure or
cancel) which is determined by IoStatus.Status and Cancel fields in the
IRP).
When IoCompleteRequest reaches the point where there are no more locations
to walk (when the current location’s pointer is beyond the oldest one), it
will do whatever other processing needs to be done on the IRP to dispose of
it, including freeing the IRP.
(It looks like IoCompleteRequest has a notion of one “immaterial” location
that corresponds to this final processing, because it accounts for this
processing by moving the current location’s pointer by one more position,
before doing the final processing (of course, there is no valid memory where
it points now, that’s why I call it “immaterial”). This is used to make sure
that IoCompleteRequest can’t be hoaxed into doing the final processing more
than once).
To summarize, it looks to me that you can return MORE_PROCESSING_REQUIRED
and then later call IoCompleteRequest to do the final processing. Or you can
return SUCCESS and then IoCompleteRequest will continue and do the final
processing immediately after that.
“Leonid Meyerovich” wrote in message
news:xxxxx@ntdev…
>
>
> Thanks everybody for answering,
> I am certainly telling the whole story, my completion routine works fine
and
> this is the last completion routine for the IRP I have created.
>
> I think my I/O Manager doesn’t free my IRPs when completion routine
returns
> MORE_PROCESSING_REQUIRED (BTW, how can I check it?), even driver keep
> working .
>
> So, return from completion routine STATUS_SUCCESS is the only sign for I/O
> Manager to free synchronous IRP. Please correct me if I am wrong.
>
> Thank you
> Leonid
>
>
> ----- Original Message -----
> From: “Ivan Bublikov”
> Newsgroups: ntdev
> To: “Windows System Software Devs Interest List”
> Sent: Wednesday, October 08, 2003 11:44 PM
> Subject: [ntdev] Re: Synchronous IRP clean up question.
>
>
> > My best quess is that you might have an error in how you set up your
> > completion routine and it’s not getting called. If you are sure that it
> is,
> > then tell me how you know that “I/O manager” frees the IRP.
> >
> > Everyone is sure that you are not telling the whole story about what you
> are
> > doing with the IRP, because there is no way the “I/O manager” will free
it
> > when it sees MORE_PROCESSING_REQUIRED as the return code from a
completion
> > routine, because “I/O manager” is pretty sure in this case that the IRP
> > might have already been freed in the completion routine itself!
> >
> > “Leonid Meyerovich” wrote in message
> > news:xxxxx@ntdev…
> > >
> > > Hello,
> > >
> > > IoBuildDeviceIoControlRequest is synchronous IRP and according DDK and
> > > Walter Oney’s book I/O manager automaticaly cleans up it following a
> call
> > to
> > > IoCompleteRequest. It also deletes this IRP after completion routine
> > > returns.
> > > I remember that in Art Baker book “The Windows 2000 Device Driver
Book”
> > I/O
> > > manager frees IRP on return STATUS_SUCCESS from competion routine.
> > > I am using STATUS_MORE_PROCESSING_REQUIRED to return from completion
> > routine
> > > and it looks like I/O Manager still frees my IRP.
> > > How I/O Manager decides that it can free IRP after completion routine
> > > returns?
> > >
> > > Thank you
> > > Leonid
> > >
> > >
> > >
> > >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@v-one.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>