Documentation Bug: "Handling IRPs: What Every Driver Writer Needs to Know"

http://www.microsoft.com/whdc/driver/kernel/IRPs.mspx, page 9 line 14:

“If the value of the Irp->PendingReturned field is TRUE, the IoCallDriver
routine will return (or has already returned) STATUS_PENDING. If Irp
>PendingReturned is FALSE, IoCallDriver has already returned with the value
in the Irp >IoStatus.Status field.”

The last is wrong. When Irp >PendingReturned is FALSE the IRP completes
synchronously, therefore IoCompletion routine is called always before
IoCallDriver returns.

Thanks,
mK


Express yourself instantly with MSN Messenger! Download today it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Yes, but this is rather a misprint, the described situation is rare, but
possible.
For example, in the following code IoCallDriver always returns before Irp
will be fully completed( i.e. the last completion routine will be called ).

NTSTATUS
CompletionRoutine(…,Context )
{

KeSetEvent( Context->Event,… );
return STATUS_MORE_PROCESSING_REQUIRED;
}

NTSTATUS
DispatchRoutine( … )
{

ASSERT( KeGetCurrentIrql() <= APC_LEVEL );

Context->Event = &Event;
IoSetCompletionRoutine( Irp, CompletionRoutine, Context, TRUE, TRUE,
TRUE );
RC = IoCallDriver( LowerDevice, Irp );
KeWaitForSingleObject( &Event, … );
if( STATUS_PENDING == RC ) {
RC = Irp >IoStatus.Status;
}
…;
IoCompleteRequest( Irp, … );
return RC;
}

“Misha Karpin” wrote in message
news:xxxxx@ntdev…
> http://www.microsoft.com/whdc/driver/kernel/IRPs.mspx, page 9 line 14:
>
> “If the value of the Irp->PendingReturned field is TRUE, the IoCallDriver
> routine will return (or has already returned) STATUS_PENDING. If Irp
> >PendingReturned is FALSE, IoCallDriver has already returned with the
> >value
> in the Irp >IoStatus.Status field.”
>
> The last is wrong. When Irp >PendingReturned is FALSE the IRP completes
> synchronously, therefore IoCompletion routine is called always before
> IoCallDriver returns.
>
> Thanks,
> mK
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it’s FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>