+++ /dev/null
-\r
-\r
-/*\r
-Boiler plate for irp cancelation, for irp queues you manage yourself\r
--Gunnar\r
-*/\r
-\r
-\r
-\r
-CancelRoutine(\r
- DEV_OBJ Dev,\r
- Irp\r
- )\r
-{\r
- //don't need this since we have our own sync. protecting irp cancellation\r
- IoReleaseCancelSpinLock(Irp->CancelIrql); \r
- \r
- theLock = Irp->Tail.Overlay.DriverContext[3];\r
- \r
- Lock(theLock); \r
- RemoveEntryList(&Irp->Tail.Overlay.ListEntry);\r
- Unlock(theLock);\r
- \r
- Irp->IoStatus.Status = STATUS_CANCELLED;\r
- Irp->IoStatus.Information = 0;\r
- \r
- IoCompleteRequest(Irp, IO_NO_INCREMENT);\r
- \r
-}\r
- \r
- \r
-QUEUE_BOLIERPLATE\r
-{\r
- Lock(theLock);\r
- \r
- Irp->Tail.Overlay.DriverContext[3] = &theLock;\r
- \r
- IoSetCancelRoutine(Irp, CancelRoutine);\r
- if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))\r
- { \r
- /*\r
- Irp has already been cancelled (before we got to queue it),\r
- and we got to remove the cancel routine before the canceler could, \r
- so we cancel/complete the irp ourself.\r
- */\r
- \r
- Unlock(theLock);\r
- \r
- Irp->IoStatus.Status = STATUS_CANCELLED;\r
- Irp->IoStatus.Information = 0;\r
- IoCompleteRequest(Irp, IO_NO_INCREMENT);\r
- \r
- return FALSE;\r
- }\r
- \r
- //else were ok \r
- \r
- \r
- Irp->IoStatus.Status = STATUS_PENDING;\r
- IoMarkIrpPending(Irp);\r
- \r
- InsertTailList(Queue);\r
- \r
- Unlock(theLock);\r
- \r
-}\r
- \r
- \r
-DEQUEUE_BOILERPLATE\r
-{\r
- Lock(theLock);\r
- \r
- Irp = RemoveHeadList(Queue);\r
- \r
- if (!IoSetCancelRoutine(Irp, NULL))\r
- {\r
- /*\r
- Cancel routine WILL be called after we release the spinlock. It will try to remove \r
- the irp from the list and cancel/complete this irp. Since we allready removed it, \r
- make its ListEntry point to itself.\r
- */\r
- \r
- InitializeListHead(&Irp->Tail.Overlay.ListEntry);\r
- \r
- Unlock(theLock);\r
- \r
- return;\r
- } \r
- \r
- \r
- /*\r
- Cancel routine will NOT be called, canceled or not.\r
- The Irp might have been canceled (Irp->Cancel flag set) but we don't care,\r
- since we are to complete this Irp now anyways.\r
- */\r
- \r
- Unlock(theLock);\r
- \r
- Irp->IoStatus.Status = STATUS_SUCCESS;\r
- Irp->IoStatus.Information = 0;\r
- IoCompleteRequest(Irp, IO_NO_INCREMENT);\r
- \r
-}\r