clean up and standardize types across the codebase, unify atomic operations, improve UTF-8 handling throughout the system, remove obsolete input and named queue interfaces, redesign process preparation and creation, tighten IPC and service boundaries, improve error handling and reliability, minor documentation cleanup, fix doom surfaces, fix panic in ini parsing.
This commit is contained in:
1 parent
899225f551
commit
c0ad63c27f
226 files changed
+6562
-4147
No files matched your search
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddk/list.h>
|
||||
#include <ntlite/ddk/object.h>
|
||||
@@ -36,7 +37,7 @@ struct IO_ASYNC_REQUEST_OBJECT {
|
||||
OBJECT Header;
|
||||
LIST_ENTRY Link;
|
||||
IO_ASYNC_REQUEST_STATE State;
|
||||
uint8_t CancelRequested;
|
||||
bool CancelRequested;
|
||||
struct EVENT* WaitEvent;
|
||||
struct EVENT* CompletionEvent;
|
||||
struct KAPC* CompletionApc;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <ntlite/status.h>
|
||||
|
||||
struct DEVICE_OBJECT;
|
||||
@@ -52,7 +53,7 @@ typedef struct IO_AUDIO_PROVIDER_OPERATIONS {
|
||||
// Stops DMA before unregister permits provider storage to be released.
|
||||
void (*Stop)(void* providerContext);
|
||||
// Applies endpoint gain and mute only with IO_AUDIO_ENDPOINT_CAP_HARDWARE_GAIN.
|
||||
KSTATUS (*SetGain)(void* providerContext, int32_t gainMilliDb, uint8_t muted);
|
||||
KSTATUS (*SetGain)(void* providerContext, int32_t gainMilliDb, bool muted);
|
||||
} IO_AUDIO_PROVIDER_OPERATIONS;
|
||||
|
||||
// Registers one fixed-format render ring owned by a hardware provider.
|
||||
@@ -61,7 +62,7 @@ typedef struct IO_AUDIO_ENDPOINT_REGISTRATION {
|
||||
struct DEVICE_OBJECT* Device;
|
||||
IO_AUDIO_ENDPOINT_KIND Kind;
|
||||
uint32_t Capabilities;
|
||||
uint8_t InitiallyAvailable;
|
||||
bool InitiallyAvailable;
|
||||
void* ProviderContext;
|
||||
IO_AUDIO_PROVIDER_OPERATIONS Operations;
|
||||
void* PeriodBuffer;
|
||||
@@ -96,7 +97,7 @@ typedef struct NTL_DDK_AUDIO {
|
||||
uint64_t timestampTicks);
|
||||
|
||||
// Updates jack-derived endpoint availability without changing endpoint identity.
|
||||
void (*SetEndpointAvailable)(IO_AUDIO_ENDPOINT* endpoint, uint8_t available);
|
||||
void (*SetEndpointAvailable)(IO_AUDIO_ENDPOINT* endpoint, bool available);
|
||||
|
||||
// Fails an endpoint and wakes every stream owner.
|
||||
void (*ReportEndpointFailure)(IO_AUDIO_ENDPOINT* endpoint,
|
||||
|
||||
@@ -43,4 +43,4 @@ typedef enum KE_PANIC_CODE {
|
||||
__declspec(dllexport) void DbgPrint(const char* fmt, ...);
|
||||
|
||||
// Stops the system with a formatted diagnostic message.
|
||||
__declspec(dllexport) _Noreturn void KePanic(int code, const char* fmt, ...);
|
||||
__declspec(dllexport) _Noreturn void KePanic(int32_t code, const char* fmt, ...);
|
||||
@@ -40,24 +40,24 @@ DISPLAY_API void KeDisplaySuspendConsole(bool suspend);
|
||||
DISPLAY_API KSTATUS KeDisplayGetMode(DISPLAY_MODE* outMode);
|
||||
|
||||
// Queries the current display size.
|
||||
DISPLAY_API KSTATUS KeDisplayGetSize(int* outWidth, int* outHeight);
|
||||
DISPLAY_API KSTATUS KeDisplayGetSize(int32_t* outWidth, int32_t* outHeight);
|
||||
|
||||
DISPLAY_API KSTATUS KeDisplayBlit(int x, int y, int w, int h, const uint32_t* pixels);
|
||||
DISPLAY_API KSTATUS KeDisplayBlitPitched(int x, int y, int w, int h, const uint32_t* pixels, uint32_t pitchBytes);
|
||||
DISPLAY_API KSTATUS KeDisplayPresentPitched(int x, int y, int w, int h, const uint32_t* pixels, uint32_t pitchBytes);
|
||||
DISPLAY_API KSTATUS KeDisplayFillRect(int x, int y, int w, int h, uint32_t color);
|
||||
DISPLAY_API KSTATUS KeDisplayBlit(int32_t x, int32_t y, int32_t w, int32_t h, const uint32_t* pixels);
|
||||
DISPLAY_API KSTATUS KeDisplayBlitPitched(int32_t x, int32_t y, int32_t w, int32_t h, const uint32_t* pixels, uint32_t pitchBytes);
|
||||
DISPLAY_API KSTATUS KeDisplayPresentPitched(int32_t x, int32_t y, int32_t w, int32_t h, const uint32_t* pixels, uint32_t pitchBytes);
|
||||
DISPLAY_API KSTATUS KeDisplayFillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||
DISPLAY_API KSTATUS KeDisplayClear(uint32_t color);
|
||||
DISPLAY_API KSTATUS KeDisplayCopyRect(int dstX, int dstY, int srcX, int srcY, int w, int h);
|
||||
DISPLAY_API KSTATUS KeDisplayScroll(int lines);
|
||||
DISPLAY_API KSTATUS KeDisplayPutChar(char c, int x, int y, uint32_t fg, uint32_t bg);
|
||||
DISPLAY_API KSTATUS KeDisplayCopyRect(int32_t dstX, int32_t dstY, int32_t srcX, int32_t srcY, int32_t w, int32_t h);
|
||||
DISPLAY_API KSTATUS KeDisplayScroll(int32_t lines);
|
||||
DISPLAY_API KSTATUS KeDisplayPutChar(char c, int32_t x, int32_t y, uint32_t fg, uint32_t bg);
|
||||
DISPLAY_API KSTATUS KeDisplayPrintChar(char c, uint32_t fg, uint32_t bg);
|
||||
DISPLAY_API KSTATUS KeDisplayGetConsoleInfo(KE_CONSOLE_INFO* outInfo);
|
||||
DISPLAY_API KSTATUS KeDisplaySetConsoleCursor(int col, int row);
|
||||
DISPLAY_API KSTATUS KeDisplayFillConsoleChars(char c, int col, int row, size_t length, size_t* writtenOut);
|
||||
DISPLAY_API KSTATUS KeDisplayFillConsoleAttrs(uint16_t attr, int col, int row, size_t length, size_t* writtenOut);
|
||||
DISPLAY_API KSTATUS KeDisplaySetConsoleCursor(int32_t col, int32_t row);
|
||||
DISPLAY_API KSTATUS KeDisplayFillConsoleChars(char c, int32_t col, int32_t row, size_t length, size_t* writtenOut);
|
||||
DISPLAY_API KSTATUS KeDisplayFillConsoleAttrs(uint16_t attr, int32_t col, int32_t row, size_t length, size_t* writtenOut);
|
||||
DISPLAY_API KSTATUS KeDisplayPresent(const DISPLAY_RECT* rects, size_t rectCount);
|
||||
DISPLAY_API KSTATUS KeDisplaySync(void);
|
||||
DISPLAY_API KSTATUS KeDisplayQueryInfo(KE_DISPLAY_INFO* outInfo);
|
||||
DISPLAY_API KSTATUS KeDisplaySetCursorImage(int width, int height, int hotX, int hotY, const uint32_t* argbPixels);
|
||||
DISPLAY_API KSTATUS KeDisplaySetCursorPosition(int x, int y);
|
||||
DISPLAY_API KSTATUS KeDisplaySetCursorImage(int32_t width, int32_t height, int32_t hotX, int32_t hotY, const uint32_t* argbPixels);
|
||||
DISPLAY_API KSTATUS KeDisplaySetCursorPosition(int32_t x, int32_t y);
|
||||
DISPLAY_API KSTATUS KeDisplayShowCursor(bool show);
|
||||
@@ -21,7 +21,7 @@ struct KDPC {
|
||||
void* Context;
|
||||
void* SystemArgument1;
|
||||
void* SystemArgument2;
|
||||
volatile long Inserted;
|
||||
volatile int32_t Inserted;
|
||||
};
|
||||
|
||||
// Initializes a DPC object.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddk/list.h>
|
||||
#include <ntlite/ddk/object.h>
|
||||
@@ -17,13 +18,13 @@ typedef struct EVENT {
|
||||
OBJECT Header;
|
||||
SPINLOCK Lock;
|
||||
EVENT_TYPE Type;
|
||||
uint32_t Signaled;
|
||||
bool Signaled;
|
||||
LIST_ENTRY WaitList;
|
||||
LIST_ENTRY MultiWaitList;
|
||||
} EVENT;
|
||||
|
||||
// Creates an event object.
|
||||
__declspec(dllexport) KSTATUS KeEventCreate(EVENT_TYPE type, uint32_t initialState, EVENT** out);
|
||||
__declspec(dllexport) KSTATUS KeEventCreate(EVENT_TYPE type, bool initialState, EVENT** out);
|
||||
|
||||
// Signals an event.
|
||||
__declspec(dllexport) void KeSignalEvent(EVENT* event);
|
||||
@@ -32,7 +33,7 @@ __declspec(dllexport) void KeSignalEvent(EVENT* event);
|
||||
__declspec(dllexport) void KeClearEvent(EVENT* event);
|
||||
|
||||
// Waits for an event.
|
||||
__declspec(dllexport) KSTATUS KeWaitForEvent(EVENT* event, uint8_t alertable);
|
||||
__declspec(dllexport) KSTATUS KeWaitForEvent(EVENT* event, bool alertable);
|
||||
|
||||
// Attempts to wait for an event without blocking.
|
||||
__declspec(dllexport) KSTATUS KeTryWaitEvent(EVENT* event);
|
||||
@@ -40,6 +41,6 @@ __declspec(dllexport) KSTATUS KeTryWaitEvent(EVENT* event);
|
||||
// Waits for one of several events.
|
||||
__declspec(dllexport) KSTATUS KeWaitForMultipleEvents(EVENT** events,
|
||||
uint32_t count,
|
||||
uint8_t alertable,
|
||||
bool alertable,
|
||||
uint64_t timeoutMs,
|
||||
uint32_t* signaledIndexOut);
|
||||
@@ -121,7 +121,7 @@ typedef struct IRP {
|
||||
// Current remove-lock layout.
|
||||
typedef struct IO_REMOVE_LOCK {
|
||||
SPINLOCK Lock;
|
||||
volatile long IoCount;
|
||||
volatile int32_t IoCount;
|
||||
bool Removing;
|
||||
struct EVENT* RemovedEvent;
|
||||
} IO_REMOVE_LOCK;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// Interrupt request level value used by DDK synchronization and IRP state.
|
||||
typedef uint8_t KIRQL;
|
||||
@@ -35,7 +36,7 @@ __declspec(dllexport) void KeAssertIrql(KIRQL expected);
|
||||
__declspec(dllexport) void KeAssertIrqlAtOrBelow(KIRQL maxIrql);
|
||||
|
||||
// Returns nonzero when the current context may block.
|
||||
__declspec(dllexport) int KeCanWait(void);
|
||||
__declspec(dllexport) bool KeCanWait(void);
|
||||
|
||||
// Returns a diagnostic name for an IRQL.
|
||||
__declspec(dllexport) const char* KeIrqlName(KIRQL irql);
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddk/list.h>
|
||||
#include <ntlite/ddk/object.h>
|
||||
@@ -16,8 +17,8 @@ typedef struct MUTEX {
|
||||
LIST_ENTRY OwnerLink;
|
||||
KE_SCHEDULING_CLASS DonationClass;
|
||||
uint32_t DonationPriority;
|
||||
uint8_t HasDonation;
|
||||
uint8_t Abandoned;
|
||||
bool HasDonation;
|
||||
bool Abandoned;
|
||||
} MUTEX;
|
||||
|
||||
// Tests whether a mutex acquisition transferred ownership to the caller.
|
||||
|
||||
@@ -24,7 +24,6 @@ typedef enum OBJECT_TYPE {
|
||||
ObjectTypeUsbPipe = 14,
|
||||
ObjectTypeFileMapping = 15,
|
||||
ObjectTypeSurface = 16,
|
||||
ObjectTypeInputQueue = 17,
|
||||
ObjectTypeImageSection = 18,
|
||||
ObjectTypeTimer = 19,
|
||||
ObjectTypeDisplayClock = 20,
|
||||
@@ -51,9 +50,9 @@ typedef enum OBJECT_LIFETIME_STATE {
|
||||
// Object header embedded by kernel and driver-owned reference-counted objects.
|
||||
typedef struct OBJECT {
|
||||
OBJECT_TYPE Type;
|
||||
volatile long RefCount;
|
||||
volatile long LifetimeState;
|
||||
volatile long Flags;
|
||||
volatile int32_t RefCount;
|
||||
volatile int32_t LifetimeState;
|
||||
volatile uint32_t Flags;
|
||||
void (*Destroy)(struct OBJECT* self);
|
||||
} OBJECT;
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ntlite/atomic.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <intrin.h>
|
||||
#include <ntlite/ddk/irql.h>
|
||||
|
||||
// Legacy spinlock storage used by current driver-visible objects.
|
||||
typedef struct SPINLOCK {
|
||||
volatile long Locked;
|
||||
volatile int32_t Locked;
|
||||
} SPINLOCK;
|
||||
|
||||
#define SPINLOCK_INIT { 0 }
|
||||
@@ -43,7 +45,7 @@ static __forceinline uintptr_t KeAcquireSpinlock(SPINLOCK* sl) {
|
||||
if (oldIrql < DISPATCH_LEVEL)
|
||||
KeRaiseIrql(DISPATCH_LEVEL);
|
||||
|
||||
while (_InterlockedCompareExchange(&sl->Locked, 1, 0) != 0)
|
||||
while (NtlAtomicCompareExchange32(&sl->Locked, 1, 0) != 0)
|
||||
_mm_pause();
|
||||
|
||||
return KiPackSpinlockCookie(flags, oldIrql);
|
||||
@@ -54,7 +56,7 @@ static __forceinline void KeReleaseSpinlock(SPINLOCK* sl, uintptr_t cookie) {
|
||||
uintptr_t flags = KiSpinlockCookieFlags(cookie);
|
||||
KIRQL oldIrql = KiSpinlockCookieIrql(cookie);
|
||||
|
||||
_InterlockedExchange(&sl->Locked, 0);
|
||||
NtlAtomicExchange32(&sl->Locked, 0);
|
||||
|
||||
// Restore the caller's hardware interrupt state before dropping to an
|
||||
// IRQL that can dispatch APCs. PASSIVE_LEVEL with IF still clear is not a
|
||||
@@ -64,23 +66,23 @@ static __forceinline void KeReleaseSpinlock(SPINLOCK* sl, uintptr_t cookie) {
|
||||
}
|
||||
|
||||
// Attempts to acquire a spinlock without blocking.
|
||||
static __forceinline int KeTryAcquireSpinlock(SPINLOCK* sl, uintptr_t* outCookie) {
|
||||
static __forceinline bool KeTryAcquireSpinlock(SPINLOCK* sl, uintptr_t* outCookie) {
|
||||
uintptr_t flags = KeDisableInterrupts();
|
||||
|
||||
KIRQL oldIrql = KeGetCurrentIrql();
|
||||
if (oldIrql < DISPATCH_LEVEL)
|
||||
KeRaiseIrql(DISPATCH_LEVEL);
|
||||
|
||||
if (_InterlockedCompareExchange(&sl->Locked, 1, 0) == 0) {
|
||||
if (NtlAtomicCompareExchange32(&sl->Locked, 1, 0) == 0) {
|
||||
*outCookie = KiPackSpinlockCookie(flags, oldIrql);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keep the failed-acquire unwind consistent with normal release: restore
|
||||
// IF before a PASSIVE transition can dispatch pending APCs.
|
||||
KeRestoreInterrupts(flags);
|
||||
KeLowerIrql(oldIrql);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Acquires a spinlock for DPC-level code.
|
||||
|
||||
Reference in new issue
Block a user