NtCreateSemaphore - 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 NtCreateSemaphore routine creates a semaphore object, sets the initial count of the semaphore to the specified value,
 * and opens a handle to the object with the specified desired access.
 *
 * @param SemaphoreHandle A pointer to a variable that receives the semaphore object handle.
 * @param DesiredAccess The access mask that specifies the requested access to the semaphore object.
 * @param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
 * @param InitialCount The initial count of the semaphore object.
 * @param MaximumCount The maximum count of the semaphore object.
 * @return NTSTATUS Successful or errant status.
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreateSemaphore(
    _Out_ PHANDLE SemaphoreHandle,
    _In_ ACCESS_MASK DesiredAccess,
    _In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
    _In_ LONG InitialCount,
    _In_ LONG MaximumCount
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwCreateSemaphore(
    _Out_ PHANDLE SemaphoreHandle,
    _In_ ACCESS_MASK DesiredAccess,
    _In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
    _In_ LONG InitialCount,
    _In_ LONG MaximumCount
    );

#endif

View code on GitHub

Function NtCreateSemaphore creates Semaphore Object with or without name in Object Namespace, and sets initial and maximum releases number.

SemaphoreHandle

Result of call - pointer to HANDLE to Semaphore Object.

DesiredAccess

Access rights to Semaphore Object. Can be one of:

ObjectAttributes

Optional pointer to OBJECT_ATTRIBUTES structure containing semaphore's name.

InitialCount

Initial state of semaphore. Typically the same as MaximumCount.

MaximumCount

Maximum releases number.

Documented by

See also