ExAcquireResourceExclusiveLite function (wdm.h)
The ExAcquireResourceExclusiveLite routine acquires the given resource for exclusive access by the calling thread.
Syntax
BOOLEAN ExAcquireResourceExclusiveLite(
[in, out] PERESOURCE Resource,
[in] BOOLEAN Wait
);
Parameters
[in, out] Resource
A pointer to the resource to acquire.
[in] Wait
Specifies the routine's behavior whenever the resource cannot be acquired immediately. If TRUE, the caller is put into a wait state until the resource can be acquired. If FALSE, the routine immediately returns, regardless of whether the resource can be acquired.
Return value
ExAcquireResourceExclusiveLite returns TRUE if the resource is acquired. This routine returns FALSE if the input Wait is FALSE and exclusive access cannot be granted immediately.
Remarks
The following list describes whether and when a caller is given exclusive access to a given resource:
If the resource is currently not owned, exclusive access is granted immediately to the current thread.
If the caller already had acquired the resource for exclusive access, the current thread is granted the same type of access recursively.-
If the caller has shared access to the resource, the caller must release the lock before it attempts to reacquire it exclusively.
If the resource is currently owned as exclusive by another thread, or if the caller only has shared access to the resource, the current thread is put into a wait state until the resource can be acquired.
If two threads each hold a shared lock on the same resource and both attempt to acquire the lock exclusively without releasing their shared lock, they will deadlock. This means that each thread will wait for the other to release its shared hold on the lock, and neither will release its shared hold until the other does.
The caller can release the resource by calling either ExReleaseResourceLite or ExReleaseResourceForThreadLite.
Normal kernel APC delivery must be disabled before calling this routine. Disable normal kernel APC delivery by calling KeEnterCriticalRegion. Delivery must remain disabled until the resource is released, at which point it can be reenabled by calling KeLeaveCriticalRegion. For more information, see Disabling APCs.
Requirements
Requirement | Value |
---|---|
Target Platform | Universal |
Header | wdm.h (include Wdm.h, Ntddk.h, Ntifs.h) |
Library | NtosKrnl.lib |
DLL | NtosKrnl.exe |
IRQL | IRQL <= APC_LEVEL |
DDI compliance rules | ExclusiveResourceAccess(wdm), HwStorPortProhibitedDDIs(storport), IrqlExApcLte3(wdm), WithinCriticalRegion(storport), WithinCriticalRegion(storport), WithinCriticalRegion(wdm) |
See also
ExIsResourceAcquiredExclusiveLite