BOOLEAN
IoCancelIrp(
IN PIRP Irp
);
IoCancelIrp sets the cancel bit in a given IRP and calls the cancel routine for the IRP if there is one.
IoCancelIrp returns TRUE if the IRP was canceled and FALSE if the IRP’s cancel bit was set but the IRP was not cancelable.
If the IRP has a cancel routine, IoCancelIrp sets the cancel bit and calls the cancel routine.
If Irp->CancelRoutine is NULL, and therefore the IRP is not cancelable, IoCancelIrp sets the IRP’s cancel bit and returns FALSE. The IRP should be canceled at a later time when it becomes cancelable.
If a driver that does not own the IRP calls IoCancelIrp, the results are unpredictable. The IRP might be completed with a successful status even though its cancel bit was set.
An intermediate driver should not arbitrarily call IoCancelIrp unless that driver created the IRP passed in the call. Otherwise, the intermediate driver might cancel an IRP that some higher-level driver is tracking for purposes of its own.
Callers of IoCancelIrp must be running at IRQL <= DISPATCH_LEVEL.