4 Boiler plate for irp cancelation, for irp queues you manage yourself
15 //don't need this since we have our own sync. protecting irp cancellation
16 IoReleaseCancelSpinLock(Irp
->CancelIrql
);
18 theLock
= Irp
->Tail
.Overlay
.DriverContext
[3];
21 RemoveEntryList(&Irp
->Tail
.Overlay
.ListEntry
);
24 Irp
->IoStatus
.Status
= STATUS_CANCELLED
;
25 Irp
->IoStatus
.Information
= 0;
27 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
36 Irp
->Tail
.Overlay
.DriverContext
[3] = &theLock
;
38 IoSetCancelRoutine(Irp
, CancelRoutine
);
39 if (Irp
->Cancel
&& IoSetCancelRoutine(Irp
, NULL
))
42 Irp has already been cancelled (before we got to queue it),
43 and we got to remove the cancel routine before the canceler could,
44 so we cancel/complete the irp ourself.
49 Irp
->IoStatus
.Status
= STATUS_CANCELLED
;
50 Irp
->IoStatus
.Information
= 0;
51 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
59 Irp
->IoStatus
.Status
= STATUS_PENDING
;
60 IoMarkIrpPending(Irp
);
62 InsertTailList(Queue
);
73 Irp
= RemoveHeadList(Queue
);
75 if (!IoSetCancelRoutine(Irp
, NULL
))
78 Cancel routine WILL be called after we release the spinlock. It will try to remove
79 the irp from the list and cancel/complete this irp. Since we allready removed it,
80 make its ListEntry point to itself.
83 InitializeListHead(&Irp
->Tail
.Overlay
.ListEntry
);
92 Cancel routine will NOT be called, canceled or not.
93 The Irp might have been canceled (Irp->Cancel flag set) but we don't care,
94 since we are to complete this Irp now anyways.
99 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
100 Irp
->IoStatus
.Information
= 0;
101 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);