From: Chris Telting [telting-ml@mindspring.com] Sent: Thursday, October 26, 2000 1:11 PM To: NT Developers Interest List Subject: [ntdev] Re: Can any one tell me what's wrong with this filter code? > However technically you can't do: > > > > > KeSetEvent(event, 0, FALSE) ; > > > > > > > > if (NT_SUCCESS(Irp->IoStatus.Status)) > > > > DbgPrint("Transfer Success\n") ; > > > > else DbgPrint("Transfer Error\n") ; > > in your completion handler as once you call KeSetEvent then the IRP can be > completed in your dispatch routine before you get to your "if" statement > that references the IRP. Good point. But that's only debug code I put in after the fact to try to figure stuff out. I WOULD know if it triggered a page fault which is the worst it could do. > Actually it just hit me what the problem is here. I was looking at the fact > that you comment out the IrpPending test, and I was thinking that this could > be a source of the problem. Then I re-examined the dispatch side and: I left that commented code in just to show that I was aware of it and had tried it. > > > > > status = IoCallDriver(devExt->NextDevice, Irp) ; > > > > KeWaitForSingleObject(&event, Executive, > > KernelMode, FALSE, NULL) ; > > > > DbgPrint("Continue and Complete\n") ; > > > > > > > > IoCompleteRequest(Irp, IO_NO_INCREMENT) ; > > > > > > > > return status ; > > The problem is that you are returning the value produced by the call to > IoCallDriver. Bad news if IoCallDriver returned STATUS_PENDING! You should > instead be setting status to Irp->IoStatus.Status, ASSERTing that status > does not equal STATUS_PENDING and returning that value. Ok I'll try that though I think I use to return Irp->IoStatus.Status in a previous incarnation but it wouldn't hurt to try it again. Here goes... (Trying not to get my hopes up so it doesn't jinx it) case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: { KIRQL Irql ; KEVENT event ; DbgPrint("URB Function: URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n") ; Irql = KeGetCurrentIrql() ; if (Irql == PASSIVE_LEVEL) DbgPrint("IRQL: PASSIVE_LEVEL (%u)\n", Irql) ; else if (Irql == APC_LEVEL) DbgPrint("IRQL: APC_LEVEL (%u)\n", Irql) ; else if (Irql == DISPATCH_LEVEL) DbgPrint("IRQL: DISPATCH_LEVEL (%u)\n", Irql) ; else DbgPrint("IRQL: %u\n", Irql) ; KeInitializeEvent(&event, NotificationEvent, FALSE) ; IoCopyCurrentIrpStackLocationToNext(Irp) ; IoSetCompletionRoutine(Irp, (PIO_COMPLETION_ROUTINE)InterruptTransferComplete, &event, TRUE, TRUE, TRUE) ; status = IoCallDriver(devExt->NextDevice, Irp) ; KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL) ; DbgPrint("Continue and Complete\n") ; status = Irp->IoStatus.Status ; ASSERT(status != STATUS_PENDING) ; IoCompleteRequest(Irp, IO_NO_INCREMENT) ; return status ; } ; NTSTATUS InterruptTransferComplete(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Data) { 2 PKEVENT event ; DbgPrint("InterruptTrandferComplete\n") ; // Shouldn't matter because we are signaling an event to continue in // the dispatch function. // // if (Irp->PendingReturned) // { // DbgPrint("IoMarkIrpPending\n") ; // IoMarkIrpPending(Irp) ; // } ; if (NT_SUCCESS(Irp->IoStatus.Status)) DbgPrint("Transfer Success\n") ; else DbgPrint("Transfer Error\n") ; event = (PKEVENT)Data ; KeSetEvent(event, 0, FALSE) ; return STATUS_MORE_PROCESSING_REQUIRED ; } ; (Says the lord prayer and crosses himself) ... (softice) Break due to KeBugCheckEx (Unhandled kernel mode exception) Error=7F(UNEXPECTED_KERNEL_MODE_TRAP) P1=8 P2=0 P3=0 P4=0 Same on blue screen on go --- You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com