Expand Minimize

IoReleaseRemoveLock routine

The IoReleaseRemoveLock routine releases a remove lock acquired with a previous call to IoAcquireRemoveLock.

Syntax


VOID IoReleaseRemoveLock(
  _In_  PIO_REMOVE_LOCK RemoveLock,
  _In_  PVOID Tag
);

Parameters

RemoveLock [in]

Pointer to an IO_REMOVE_LOCK structure that the caller passed to a previous call to IoAcquireRemoveLock.

Tag [in]

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 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.

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

Version

Available starting with Windows 2000.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

Library

Ntoskrnl.lib

IRQL

<= DISPATCH_LEVEL

DDI compliance rules

RemoveLock, RemoveLockCheck, RemoveLockForward, RemoveLockForward2, RemoveLockForwardDeviceControl, RemoveLockForwardDeviceControl2, RemoveLockForwardDeviceControlInternal, RemoveLockForwardDeviceControlInternal2, RemoveLockForwardRead, RemoveLockForwardRead2, RemoveLockForwardWrite, RemoveLockForwardWrite2, RemoveLockMnRemove, RemoveLockMnSurpriseRemove, RemoveLockQueryMnRemove, RemoveLockRelease2, RemoveLockReleaseCleanup, RemoveLockReleaseClose, RemoveLockReleaseCreate, RemoveLockReleaseDeviceControl, RemoveLockReleaseInternalDeviceControl, RemoveLockReleasePnp, RemoveLockReleasePower, RemoveLockReleaseRead, RemoveLockReleaseShutdown, RemoveLockReleaseSystemControl, RemoveLockReleaseWrite

See also

IoAcquireRemoveLock
IoInitializeRemoveLock
IoReleaseRemoveLockAndWait

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft