OK, I’v solved the BSOD. But now my new problem is:
- If I set a cancel routine, the I/O managers cancels the IRP immediatly
- If I do not set a cancel routine, the I/O managers doesn’t seem to
cancel the IRP at CloseHandle()
So I tried to use my own device queue, but I have the same result:
KIRQL CancelIrql;
Irp->IoStatus.Status=STATUS_PENDING;
IoAcquireCancelSpinLock(&CancelIrql); // should it be used in my case ??
IoSetCancelRoutine(Irp,CancelWaitingIrp);
InsertTailList(&Extension->WaitingQueue, &Irp->Tail.Overlay.ListEntry);
IoReleaseCancelSpinLock(CancelIrql);
IoMarkIrpPending(Irp);
return STATUS_PENDING;
And the cancel routine:
if(Irp->IoStatus.Status==STATUS_PENDING)
{
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
IoReleaseCancelSpinLock(Irp->CancelIrql);
Irp->IoStatus.Information=0;
Irp->IoStatus.Status=STATUS_CANCELLED;
IoCompleteRequest(Irp,IO_NO_INCREMENT);
}
else
IoReleaseCancelSpinLock(Irp->CancelIrql);