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:
maksw committed 2026-10-12 18:17:43 +02:00
1 parent 899225f551
commit c0ad63c27f
226 files changed
+6562 -4147

No files matched your search

+20 -18
View File
@@ -1,5 +1,7 @@
// Native user-mode exception runtime. This file owns process-local native handler dispatch.
#include <ntlite/atomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
@@ -10,7 +12,7 @@
#define NTL_EXCEPTION_MAX_HANDLERS 16u
typedef struct NTL_EXCEPTION_HANDLER_ENTRY {
uint32_t Active;
bool Active;
uint32_t Previous;
uint32_t Next;
NTL_EXCEPTION_HANDLER Handler;
@@ -22,14 +24,14 @@ typedef struct NTL_EXCEPTION_HANDLER_SNAPSHOT {
void* Context;
} NTL_EXCEPTION_HANDLER_SNAPSHOT;
static volatile long gNtlExceptionLock;
static volatile int32_t gNtlExceptionLock;
static uint32_t gNtlExceptionListHead = UINT32_MAX;
static uint32_t gNtlExceptionListTail = UINT32_MAX;
static NTL_EXCEPTION_HANDLER_ENTRY gNtlExceptionHandlers[NTL_EXCEPTION_MAX_HANDLERS];
// Acquires the process-local exception handler lock.
static void NtlpExceptionLock(void) {
while (_InterlockedCompareExchange(&gNtlExceptionLock, 1, 0) != 0)
while (NtlAtomicCompareExchange32(&gNtlExceptionLock, 1, 0) != 0)
_mm_pause();
_ReadWriteBarrier();
}
@@ -37,11 +39,11 @@ static void NtlpExceptionLock(void) {
// Releases the process-local exception handler lock.
static void NtlpExceptionUnlock(void) {
_ReadWriteBarrier();
_InterlockedExchange(&gNtlExceptionLock, 0);
NtlAtomicExchange32(&gNtlExceptionLock, 0);
}
// Returns a generic status after a failed exception-continue syscall.
static uint32_t NtlpStatusOrFailure(uint32_t status) {
static KSTATUS NtlpStatusOrFailure(KSTATUS status) {
return status == NTLSTATUS_SUCCESS ? NTLSTATUS_FAILURE : status;
}
@@ -52,7 +54,7 @@ static void NtlpTerminateExceptionDispatch(void) {
request.Size = sizeof(request);
request.Disposition = SYS_EXCEPTION_DISPOSITION_TERMINATE_PROCESS;
uint32_t status = SysContinueException(&request);
KSTATUS status = SysContinueException(&request);
while (true) SysExitProcess((int32_t)NtlpStatusOrFailure(status));
}
@@ -63,7 +65,7 @@ static void NtlpContinueExceptionSearch(void) {
request.Size = sizeof(request);
request.Disposition = SYS_EXCEPTION_DISPOSITION_CONTINUE_SEARCH;
uint32_t status = SysContinueException(&request);
KSTATUS status = SysContinueException(&request);
while (true) SysExitProcess((int32_t)NtlpStatusOrFailure(status));
}
@@ -75,23 +77,23 @@ static void NtlpContinueExecution(SYS_USER_CONTEXT* context) {
request.Disposition = SYS_EXCEPTION_DISPOSITION_CONTINUE_EXECUTION;
request.Context = context;
uint32_t status = SysContinueException(&request);
KSTATUS status = SysContinueException(&request);
while (true) SysExitProcess((int32_t)NtlpStatusOrFailure(status));
}
// Returns whether one kernel-provided exception frame has the expected ABI shape.
static int NtlpFrameIsValid(SYS_EXCEPTION_FRAME* frame) {
static bool NtlpFrameIsValid(SYS_EXCEPTION_FRAME* frame) {
if (!frame)
return 0;
return false;
if (frame->Size != sizeof(*frame) || frame->Version != SYS_EXCEPTION_ABI_VERSION)
return 0;
return false;
if (frame->ExceptionRecord.Size != sizeof(frame->ExceptionRecord) ||
frame->ExceptionRecord.Version != SYS_EXCEPTION_ABI_VERSION)
return 0;
return false;
if (frame->ContextRecord.Size != sizeof(frame->ContextRecord) ||
frame->ContextRecord.Version != SYS_EXCEPTION_ABI_VERSION)
return 0;
return 1;
return false;
return true;
}
// Copies the current handler list so callbacks can run without holding the list lock.
@@ -139,13 +141,13 @@ static void NtlpUserExceptionDispatcher(SYS_EXCEPTION_FRAME* frame) {
}
// Registers the native dispatcher for the current process when no other dispatcher owns the process.
NTL_EXCEPTION_API uint32_t NtlInitializeExceptionRuntime(void) {
NTL_EXCEPTION_API KSTATUS NtlInitializeExceptionRuntime(void) {
NtlpExceptionLock();
SYS_EXCEPTION_DISPATCHER_REQUEST current;
memset(&current, 0, sizeof(current));
current.Size = sizeof(current);
uint32_t status = SysGetExceptionDispatcher(&current);
KSTATUS status = SysGetExceptionDispatcher(&current);
if (status != NTLSTATUS_SUCCESS) {
NtlpExceptionUnlock();
return status;
@@ -171,7 +173,7 @@ NTL_EXCEPTION_API uint32_t NtlInitializeExceptionRuntime(void) {
}
// Adds one process-local native exception handler.
NTL_EXCEPTION_API void* NtlAddExceptionHandler(int first, NTL_EXCEPTION_HANDLER handler, void* context) {
NTL_EXCEPTION_API void* NtlAddExceptionHandler(bool first, NTL_EXCEPTION_HANDLER handler, void* context) {
if (!handler)
return 0;
if (NtlInitializeExceptionRuntime() != NTLSTATUS_SUCCESS)
@@ -217,7 +219,7 @@ NTL_EXCEPTION_API void* NtlAddExceptionHandler(int first, NTL_EXCEPTION_HANDLER
}
// Removes one process-local native exception handler.
NTL_EXCEPTION_API uint32_t NtlRemoveExceptionHandler(void* handle) {
NTL_EXCEPTION_API KSTATUS NtlRemoveExceptionHandler(void* handle) {
if (!handle)
return NTLSTATUS_INVALID_PARAMETER;