#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
    );
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
    );
View code on GitHubNo description available.
Function NtCreateSemaphore creates Semaphore Object with or without name in Object Namespace, and sets initial and maximum releases number.
Result of call - pointer to HANDLE to Semaphore Object.
Access rights to Semaphore Object. Can be one of:
Optional pointer to OBJECT_ATTRIBUTES structure containing semaphore's name.
Initial state of semaphore. Typically the same as MaximumCount.
Maximum releases number.