Hello,
DDK document suggests using IoReleaseRemoveLockAndWait in
IRP_MN_REMOVE_DEVICE dispatch code. However, my driver is not PNP.
I try to use the function in the Unload routine,
but it does not do what it’s supposed to do.
Excerpt from code
/////////////////////////
// FilterDispathRoutine
/////////////////////////
…
IoAcquireRemoveLock(DeviceExtension->RemoveLock, tag);
IoSetCompletionRoutine(Irp,
MyCompletionRoutine,
(PVOID) tag,
TRUE,
TRUE,
TRUE);
return IoCallDriver(pDevExt->FileSysObjPtr, Irp);
////////////////////////
// MyCompletionRoutine
////////////////////////
…
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, tag);
///////////
// Unload
///////////
…
IoAcquireRemoveLock(DeviceExtension->RemoveLock, tag);
IoReleaseRemoveLockAndWait(DeviceExtension->RemoveLock, tag);
IoDetachDevice(DeviceExtension->FileSysObjPtr);
IoDeleteDevice(CurrentDeviceObject);
///////////
I got a DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS
if the driver is unloaded when there are on-going read/write
to the device. Please tell me what I missing. Your help
is greatly appreciated.
Chu Bun