Registering a Cancel Routine
If a driver does not have a StartIo routine, its dispatch routines must do the following before queuing an IRP for further processing by other driver routines:
Call IoSetCancelRoutine with the input IRP and the entry point for a driver-supplied Cancel routine.
For information about the cancel spin lock, see Using the System's Cancel Spin Lock.
Drivers that manage their own queues of IRPs, rather than using the I/O manager-supplied device queue, do not need to acquire the cancel spin lock when calling IoSetCancelRoutine. However, these drivers should check the Cancel routine pointer that IoSetCancelRoutine returns to determine whether the Cancel routine has already started.