Thanks for your answer. However, If I don’t set a cancellation routine
(which causes the BSOD), it seems the pending IRP is never freed or
cancelled: when I call CloseHandle() then CreateFile(), CreateFile()
fails.
Maybe my cancel routine is bad or maybe I should queue the IRP.
Here is my cancel routine:
VOID CancelWaitingIrp(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
{
IoReleaseCancelSpinLock(Irp->CancelIrql);
if(Irp->IoStatus.Status==STATUS_PENDING)
{
Irp->IoStatus.Status=STATUS_CANCELLED;
Irp->IoStatus.Information=0;
IoCompleteRequest(Irp,IO_NO_INCREMENT);
}
}