FltAcquireResourceExclusive function (fltkernel.h)

The FltAcquireResourceExclusive routine acquires the given resource for exclusive access by the calling thread.

Syntax

VOID FLTAPI FltAcquireResourceExclusive(
  [in/out] PERESOURCE Resource
);

Parameters

[in/out] Resource

A pointer to an opaque ERESOURCE structure. This structure must be allocated by the caller from nonpaged pool and initialized by calling ExInitializeResourceLite or ExReinitializeResourceLite.

Return value

None

Remarks

FltAcquireResourceExclusive acquires the given resource for exclusive access by the calling thread.

The following circumstances determine whether or when the caller is given exclusive access to the given resource:

  • If the resource is currently not owned, exclusive access is granted immediately to the current thread.

  • If the caller already has acquired the resource for exclusive access, the current thread is granted the same type of access recursively.

  • Callers who have shared access to the resource must release the lock and then 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.

FltAcquireResourceExclusive is a wrapper for ExAcquireResourceExclusiveLite that disables normal kernel APC delivery.

Because FltAcquireResourceExclusive disables normal kernel APC delivery, it is not necessary to call KeEnterCriticalRegion or FsRtlEnterFileSystem before calling FltAcquireResourceExclusive.

To release the resource after it is acquired, call FltReleaseResource. Every successful call to FltAcquireResourceExclusive must be matched by a subsequent call to FltReleaseResource.

To acquire a resource for shared access, call FltAcquireResourceShared.

To delete a resource from the system's resource list, call ExDeleteResourceLite.

To initialize a resource for reuse, call ExReinitializeResourceLite.

For more information about ERESOURCE structures, see Introduction to ERESOURCE Routines.

Requirements

Requirement Value
Minimum supported client Windows XP SP2
Minimum supported server Windows Server 2003 SP1
Header fltkernel.h
Library FltMgr.lib
IRQL IRQL <= APC_LEVEL