+ Irp->PendingReturned = TRUE;
+ }
+
+ for (i=Irp->CurrentLocation;i<(ULONG)Irp->StackCount;i++)
+ {
+ /*
+ Completion routines expect the current irp stack location to be the same as when
+ IoSetCompletionRoutine was called to set them. A side effect is that completion
+ routines set by highest level drivers without their own stack location will receive
+ an invalid current stack location (at least it should be considered as invalid).
+ Since the DeviceObject argument passed is taken from the current stack, this value
+ is also invalid (NULL).
+ */
+ if (Irp->CurrentLocation < Irp->StackCount - 1)
+ {
+ IoSetPreviousIrpStackLocation(Irp);
+ DeviceObject = IoGetCurrentIrpStackLocation(Irp)->DeviceObject;
+ }
+ else