NtReleaseSemaphore - 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 NtReleaseSemaphore routine increases the count of the specified semaphore object by a specified amount.
 *
 * \param SemaphoreHandle A handle to the semaphore object.
 * \param ReleaseCount The amount by which the semaphore object's count is to be increased.
 * \param PreviousCount A pointer to a variable that receives the previous count of the semaphore object.
 * \return NTSTATUS Successful or errant status.
 * \remarks Requires SEMAPHORE_MODIFY_STATE (0x2). ReleaseCount must be positive; zero or a
 * negative value returns STATUS_INVALID_PARAMETER. If the addition exceeds MaximumCount
 * or overflows the signed count, STATUS_SEMAPHORE_LIMIT_EXCEEDED is returned without
 * changing the count or writing PreviousCount. On success, PreviousCount receives the
 * count before the addition and may be NULL. Release does not require prior acquisition.
 */
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
NtReleaseSemaphore(
    _In_ HANDLE SemaphoreHandle,
    _In_ LONG ReleaseCount,
    _Out_opt_ PLONG PreviousCount
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwReleaseSemaphore(
    _In_ HANDLE SemaphoreHandle,
    _In_ LONG ReleaseCount,
    _Out_opt_ PLONG PreviousCount
    );

#endif

View code on GitHub

NtDoc

No description available.

NTinternals.net (undocumented.ntinternals.net)

Function NtReleaseSemaphore increments semaphore's counter, opposite to any waiting function (semaphore is signaled when semaphore's counter is greater then zero).

SemaphoreHandle

HANDLE to Semaphore Object opened with SEMAPHORE_MODIFY_STATE access.

ReleaseCount

Number of increments, typically set to 1.

PreviousCount

Optional pointer to ULONG value receiving semaphore's counter state before call.

Documented by

See also