Expand Minimize

IoReleaseRemoveLockAndWait routine

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.

Syntax


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

Parameters

RemoveLock [in]

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

Tag [in]

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.

Return value

None

Remarks

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.

Requirements

Version

Available starting with Windows 2000.

Header

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

Library

Ntoskrnl.lib

IRQL

PASSIVE_LEVEL

DDI compliance rules

IoReleaseRemoveLockAndWaitOutsideRemoveDevice, RemoveLock, RemoveLockCheck, RemoveLockMnRemove, RemoveLockMnRemove2, RemoveLockReleaseCleanup, RemoveLockReleaseClose, RemoveLockReleaseCreate, RemoveLockReleaseDeviceControl, RemoveLockReleaseInternalDeviceControl, RemoveLockReleasePower, RemoveLockReleaseRead, RemoveLockReleaseShutdown, RemoveLockReleaseSystemControl, RemoveLockReleaseWrite

See also

DispatchPnp
IoAcquireRemoveLock
IoDeleteDevice
IoDetachDevice
IoInitializeRemoveLock
IoReleaseRemoveLock
IRP_MN_WAIT_WAKE

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft