ExIsResourceAcquiredShared

This function tests whether the current thread has acquired a given Executive Resource for either exclusive or shared access.

Declaration

BOOLEAN ExIsResourceAcquiredShared (ERESOURCE *Resource);

Parameters

The Resource argument is the address of the ERESOURCE to test.

Return Value

The function returns the current thread’s acquisition count. This is the number of times the thread would have to release the resource (without reacquiring it) before losing access. If the current thread does not have access to the resource, whether exclusive or shared, then the function returns zero.

Availability

The ExIsResourceAcquiredShared function is exported by name from the kernel in version 3.10 only. It is superseded in version 3.50 and higher by ExIsResourceAcquiredShareLite.

Documentation Status

The ExIsResourceAcquiredShared function is nowadays documented—as obsolete, of course—but when it was not obsolete, it was not documented.

Specifically, ExIsResourceAcquiredShared is not documented in the Device Driver Kit (DDK) for Windows NT 3.1. For reasons unknown, it starts to be documented with the DDK for Windows Server 2003 SP1. Note that the return type as given in the documentation and reproduced above is incorrect—or, if you prefer, is correct only on the understanding that the BOOLEAN is not TRUE (1) or FALSE but is non-zero or FALSE.

The replacement in version 3.50 is documented from as long ago as the DDK for Windows NT 3.51. Since at least then, (a DDK for Windows NT 3.50 not having been found for reference), the ExIsResourceAcquiredShared function is supported, presumably for rebuilding old code, by a macro that redefines the function as ExIsResourceAcquiredSharedLite. Even this macro is long deprecated, starting with the DDK for Windows XP.

Behaviour

The ExIsResourceAcquiredShared function examines the given resource’s table of owning threads and owner counts while holding the resource’s spin lock. If the current thread is in the table, the function returns the corresponding count, else it returns zero.

The resource’s table of owning threads and owner counts is for all owners, both shared and exclusive. To this function, exclusive ownership is a particular kind of shared ownership.

IRQL

The ExIsResourceAcquiredShared function can be called at any IRQL up to and including DISPATCH_LEVEL. The Resource is assumed to be in non-paged memory.