The IoInitializeRemoveLock routine initializes a remove lock for a device object.
VOID
IoInitializeRemoveLock(
IN PIO_REMOVE_LOCK Lock,
IN ULONG AllocateTag,
IN ULONG MaxLockedMinutes,
IN ULONG HighWatermark
);
The I/O system only uses this parameter on checked builds.
The I/O system only uses this parameter on checked builds. If the lock is held for more than MaxLockedMinutes on a checked build, the system asserts.
The I/O system only uses this parameter on checked builds. If the lock is acquired HighWatermark times on a checked build, the system asserts.
None
Declared in ntddk.h. Include ntddk.h.
A driver can use a remove lock to track outstanding I/O operations on a device and to determine when the driver can delete its device object in response to an IRP_MN_REMOVE_DEVICE request.
Before calling IoInitializeRemoveLock, a driver should allocate an IO_REMOVE_LOCK structure in its device extension. A driver typically calls IoInitializeRemoveLock in its AddDevice routine, when the driver initializes the rest of the device extension for a device object.
Because the driver stores the IO_REMOVE_LOCK structure in the device extension of a device object, the remove lock is deleted when the driver deletes the device extension as part of processing an IRP_MN_REMOVE_DEVICE request.
Callers of IoInitializeRemoveLock must be running at IRQL = PASSIVE_LEVEL.
For more information, see Using Remove Locks.
IoAcquireRemoveLock, IoReleaseRemoveLock, IoReleaseRemoveLockAndWait