Files
nt-lite/code/public/ntlite/ddk/semaphore.h
T

28 lines
815 B
C

// Public nt-lite DDK semaphore declarations.
#pragma once
#include <stdint.h>
#include <ntlite/status.h>
#include <ntlite/ddk/list.h>
#include <ntlite/ddk/object.h>
#include <ntlite/ddk/sync.h>
typedef struct SEMAPHORE {
OBJECT Header;
SPINLOCK Lock;
int32_t Count;
int32_t MaxCount;
LIST_ENTRY WaitList;
} SEMAPHORE;
// Creates a counting semaphore.
__declspec(dllexport) KSTATUS KeSemaphoreCreate(int32_t initial, int32_t max, SEMAPHORE** out);
// Waits for a semaphore count within the requested timeout.
// Zero performs a nonblocking probe; KE_WAIT_INFINITE waits without a timeout.
__declspec(dllexport) KSTATUS KeWaitSemaphore(SEMAPHORE* semaphore, uint64_t timeoutMilliseconds);
// Releases one semaphore count.
__declspec(dllexport) void KeSignalSemaphore(SEMAPHORE* semaphore);