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.
Each call to IoAcquireRemoveLock must have a corresponding call to IoReleaseRemoveLock.

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.

Requirements

Requirement Value
Minimum supported client Available starting with Windows 2000.
Target Platform Desktop
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <= DISPATCH_LEVEL
DDI compliance rules RemoveLock(wdm), RemoveLockCheck(wdm), RemoveLockForward(wdm), RemoveLockForward2(wdm), RemoveLockForwardDeviceControl(wdm), RemoveLockForwardDeviceControl2(wdm), RemoveLockForwardDeviceControlInternal(wdm), RemoveLockForwardDeviceControlInternal2(wdm), RemoveLockForwardRead(wdm), RemoveLockForwardRead2(wdm), RemoveLockForwardWrite(wdm), RemoveLockForwardWrite2(wdm), RemoveLockMnRemove(wdm), RemoveLockMnRemove2(wdm), RemoveLockMnSurpriseRemove(wdm), RemoveLockQueryMnRemove(wdm), RemoveLockRelease2(wdm), RemoveLockReleaseCleanup(wdm), RemoveLockReleaseClose(wdm), RemoveLockReleaseCreate(wdm), RemoveLockReleaseDeviceControl(wdm), RemoveLockReleaseInternalDeviceControl(wdm), RemoveLockReleasePnp(wdm), RemoveLockReleasePower(wdm), RemoveLockReleaseRead(wdm), RemoveLockReleaseShutdown(wdm), RemoveLockReleaseSystemControl(wdm), RemoveLockReleaseWrite(wdm)

See also

IoAcquireRemoveLock

IoInitializeRemoveLock

IoReleaseRemoveLockAndWait