The IoReleaseRemoveLockAndWait routine releases a remove lock that the driver acquired in a previous call to IoAcquireRemoveLock, and waits until all acquisitions of the lock have been released.
void IoReleaseRemoveLockAndWait( RemoveLock, Tag );
Pointer to an IO_REMOVE_LOCK structure that the caller passed in a previous call to IoAcquireRemoveLock.
Pointer to a caller-supplied tag that was passed in a previous call to IoAcquireRemoveLock.
If a driver specified a Tag when it acquired the lock, the driver must specify the same Tag when releasing the lock. If the tags do not match, this routine asserts on a checked build.
If the call to IoAcquireRemoveLock did not specify a Tag, then this parameter is NULL.
The I/O system only uses this parameter on checked builds.
A driver typically calls this routine in its dispatch code for an IRP_MN_REMOVE_DEVICE request. To allow queued I/O requests to complete, each driver should call IoReleaseRemoveLockAndWait after it passes the remove IRP to the next-lower driver, and before it releases memory, calls IoDetachDevice, or calls IoDeleteDevice. The IoReleaseRemoveLockAndWait routine waits for the bus driver to cancel any IRPs that might be outstanding (for example, an IRP_MN_WAIT_WAKE IRP).
A driver must acquire the remove lock before calling IoReleaseRemoveLockAndWait. Typically, a driver calls IoAcquireRemoveLock early in its DispatchPnp routine, before the switch statement. As a result, the lock is acquired for each PnP operation, including the acquisition that is required before calling IoReleaseRemoveLockAndWait in the code that handles IRP_MN_REMOVE_DEVICE.
To release a lock from code other than the IRP_MN_REMOVE_DEVICE dispatch code, use IoReleaseRemoveLock.
After IoReleaseRemoveLockAndWait has been called for a particular remove lock, subsequent calls to IoAcquireRemoveLock for the same remove lock will fail. IoReleaseRemoveLockAndWait does not return until all outstanding acquisitions of the remove lock have been released.
After IoReleaseRemoveLockAndWait returns, the driver should consider the device to be in a state in which it is ready to be removed and cannot perform I/O operations. Therefore, the driver must not call the IoInitializeRemoveLock routine to re-initialize the remove lock. Violation of this rule while the driver is being verified by Driver Verifier will result in a bug check.
For more information, see Using Remove Locks.
|Windows version||Available starting with Windows 2000.|
|Header||wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)|
|DDI compliance rules||IoReleaseRemoveLockAndWaitOutsideRemoveDevice, RemoveLock, RemoveLockCheck, RemoveLockMnRemove, RemoveLockMnRemove2, RemoveLockReleaseCleanup, RemoveLockReleaseClose, RemoveLockReleaseCreate, RemoveLockReleaseDeviceControl, RemoveLockReleaseInternalDeviceControl, RemoveLockReleasePower, RemoveLockReleaseRead, RemoveLockReleaseShutdown, RemoveLockReleaseSystemControl, RemoveLockReleaseWrite|