NtQuerySemaphore - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTEXAPI_H
#if (PHNT_MODE != PHNT_MODE_KERNEL)

/**
 * The NtQuerySemaphore routine retrieves information about a semaphore object.
 *
 * @param SemaphoreHandle A handle to the semaphore object.
 * @param SemaphoreInformationClass The type of information to be retrieved.
 * @param SemaphoreInformation A pointer to a buffer that receives the requested information.
 * @param SemaphoreInformationLength The size of the buffer pointed to by SemaphoreInformation.
 * @param ReturnLength A pointer to a variable that receives the size of the data returned in the buffer.
 * @return NTSTATUS Successful or errant status.
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtQuerySemaphore(
    _In_ HANDLE SemaphoreHandle,
    _In_ SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
    _Out_writes_bytes_(SemaphoreInformationLength) PVOID SemaphoreInformation,
    _In_ ULONG SemaphoreInformationLength,
    _Out_opt_ PULONG ReturnLength
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwQuerySemaphore(
    _In_ HANDLE SemaphoreHandle,
    _In_ SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
    _Out_writes_bytes_(SemaphoreInformationLength) PVOID SemaphoreInformation,
    _In_ ULONG SemaphoreInformationLength,
    _Out_opt_ PULONG ReturnLength
    );

#endif

View code on GitHub

Function NtQuerySemaphore retrieve semaphore's parameters (see SEMAPHORE_BASIC_INFORMATION).

SemaphoreHandle

HANDLE to Semaphore Object opened with SEMAPHORE_QUERY_STATE access.

SemaphoreInformationClass

Information class described in SEMAPHORE_INFORMATION_CLASS section.

SemaphoreInformation

Pointer to user's allocated buffer for result data.

SemaphoreInformationLength

Size of SemaphoreInformation buffer, in bytes.

ReturnLength

Optionally returns required buffer size.

Documented by

See also