36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
// Public nt-lite DDK mutex declarations.
|
|
|
|
#pragma once
|
|
|
|
#include <ntlite/status.h>
|
|
#include <ntlite/ddk/list.h>
|
|
#include <ntlite/ddk/object.h>
|
|
#include <ntlite/ddk/sync.h>
|
|
#include <ntlite/ddk/thread.h>
|
|
|
|
typedef struct MUTEX {
|
|
OBJECT Header;
|
|
SPINLOCK Lock;
|
|
THREAD* Owner;
|
|
LIST_ENTRY WaitList;
|
|
LIST_ENTRY OwnerLink;
|
|
KE_SCHEDULING_CLASS DonationClass;
|
|
uint32_t DonationPriority;
|
|
uint8_t HasDonation;
|
|
uint8_t Abandoned;
|
|
} MUTEX;
|
|
|
|
// Tests whether a mutex acquisition transferred ownership to the caller.
|
|
#define KE_MUTEX_ACQUIRE_SUCCEEDED(status) \
|
|
((status) == NTLSTATUS_SUCCESS || (status) == NTLSTATUS_ABANDONED)
|
|
|
|
// Creates a mutex object.
|
|
__declspec(dllexport) KSTATUS KeMutexCreate(MUTEX** out);
|
|
|
|
// Acquires a mutex within the requested timeout and reports abandonment on transfer.
|
|
// Zero performs a nonblocking probe; KE_WAIT_INFINITE waits without a timeout.
|
|
__declspec(dllexport) KSTATUS KeAcquireMutex(MUTEX* mutex, uint64_t timeoutMilliseconds);
|
|
|
|
// Releases a mutex.
|
|
__declspec(dllexport) void KeReleaseMutex(MUTEX* mutex);
|