IoReleaseRemoveLock macro (wdm.h)
The IoReleaseRemoveLock routine releases a remove lock acquired with a previous call to IoAcquireRemoveLock.
Syntax
void IoReleaseRemoveLock(
[in] RemoveLock,
[in] Tag
);
Parameters
[in] RemoveLock
Pointer to an IO_REMOVE_LOCK structure that the caller passed to a previous call to IoAcquireRemoveLock.
[in] Tag
Pointer to a caller-supplied tag that was passed to 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 call to IoAcquireRemoveLock did not specify a Tag, then this parameter is NULL.
Return value
None
Remarks
A driver calls IoReleaseRemoveLock when it has completed the I/O operation for which it called IoAcquireRemoveLock.
- For I/O operations (including power and PnP IRPs) that set an IoCompletion routine, a driver should call IoReleaseRemoveLock in the IoCompletion routine, after calling IoCompleteRequest.
- For I/O operations that do not set an IoCompletion routine, a driver should call IoReleaseRemoveLock after passing the current IRP to the next-lower driver, but before exiting the dispatch routine.
IoReleaseRemoveLock decrements the count of outstanding acquisitions of the remove lock. If the count goes to zero and the driver has received an IRP_MN_REMOVE_DEVICE request, IoReleaseRemoveLock sets an internal event. When a driver is ready to delete a device object, it calls a similar routine, IoReleaseRemoveLockAndWait. The driver makes this call only in its dispatch code for an IRP_MN_REMOVE_DEVICE request. The IoReleaseRemoveLockAndWait routine does not return until IoReleaseRemoveLock sets the event that indicates the acquisition count is zero. After IoReleaseRemoveLockAndWait returns, the driver can safely detach and delete the device object.
For more information, see Using Remove Locks.