Hello:
I am developing USB audio filter driver. I use “IoDeleteDevice”
function in “IRP_MN_REMOVE_DEVICE”.
In normal case, when device is be removed, the “IoDeleteDevice”
should be finished, then, the system call the “DriverUnload” function.
When I unplug the device, the debug message is shown as below:
00000005 0.02962160 REMOVE_DEVICE
00000006 0.02967280 REMOVE_DEVICE - waiting for 0 irps
to complete…
00000007 0.02971200 REMOVE_DEVICE - … DONE waiting.
00000008 0.02973840 iodetach
00000009 0.98685520 remove iodelete before
00000010 0.98689600 remove iodelete after
00000011 0.98696640 VA_DriverUnload
If the debug message is as above sequence, the device will be
unload successfully.
However, in special case, the debug message will be as below:
00000005 0.02962160 REMOVE_DEVICE
00000006 0.02967280 REMOVE_DEVICE - waiting for 0 irps
to complete…
00000007 0.02971200 REMOVE_DEVICE - … DONE waiting.
00000008 0.02973840 iodetach
00000009 0.98685520 remove iodelete before
00000011 0.98696640 VA_DriverUnload
00000010 0.98689600 remove iodelete after
That is, the “IoDeleteDevice” function is not finished, but
the DriverUnload function is be called.
This may cause system be hung.
***********************************************************************************************
The source of this filter driver about “IRP_MN_REMOVE_DEVICE” and
“VA_DriverUnload” is as below:
case IRP_MN_REMOVE_DEVICE:
DBGOUT((“REMOVE_DEVICE”));
if (devExt->state != STATE_REMOVED){
devExt->state = STATE_REMOVED;
IoCopyCurrentIrpStackLocationToNext(irp);
status = IoCallDriver(devExt->topDevObj, irp);
justReturnStatus = TRUE;
DBGOUT((“REMOVE_DEVICE - waiting for %d irps to complete…”,
devExt->pendingActionCount));
DecrementPendingActionCount(devExt);
KeWaitForSingleObject( &devExt->removeEvent,
Executive, // wait reason
KernelMode,
FALSE, // not alertable
NULL ); // no timeout
DBGOUT(("REMOVE_DEVICE - … DONE waiting. "));
IoDetachDevice(devExt->topDevObj);
DBGOUT(( “iodetach” ));
DBGOUT(( “remove iodelete before” ));
IoDeleteDevice(devExt->filterDevObj);
DBGOUT(( “remove iodelete after” ));
}
break;
VOID VA_DriverUnload(IN PDRIVER_OBJECT DriverObject)
{
PAGED_CODE();
DBGOUT((“VA_DriverUnload”));
}
****************************************************************************
How should I solve this problem?
Thank you for help,
Best Regards,
Gordon
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com