isolate POSIX builds from the host UCRT, wire lwext4 and ntfs-3g as ext4.sys and ntfs.sys, split the FAT driver into directory/file/async/driver/mount units, add posixsrv and dwm plus input/console/desktop syscall clients and a pile of new smoke targets, rename serial.sys to cereal.sys, name HDA/USB/lwIP/AHCI workers, harden ATA probing/reset/removal around actual hardware deadlines, absent-channel detection, diagnostics and explicit worker lifetime, redo ACPI S5 shutdown around GAS/MMIO and HW-reduced firmware, scan SSDTs for _S5 and deal with Intel SMI sleep trapping, make serial and SMP timeouts use real monotonic deadlines, add thread names and fix terminal thread teardown, scheduler and APC prepare/commit races, make advisory file locks queryable and preserve split ranges and add mutable file append state, add shared-memory pipes with kernel-assisted wait/wake, introduce capability-scoped input and display managers, split surface map rights into read/write, add explicit unmap and replace present with commit/generation/damage tracking while keeping physical presentation under the display manager, decouple native exception classes from Win32 exception numbers and translate them in kernel32, add opaque process startup data, bump the resource protocol to v3 with namespace directories, symlinks and enumeration and service control to v2 with generic READY handle exports, add the new POSIX errno/status surface and rebuild fds around posixsrv-owned shared open descriptions, descriptor-local flags, exact inheritance snapshots, dup/fcntl/record locks and shared-ring pipes, add waitpid, POSIX credentials/groups/sessions/passwd/group lookups and move sockets onto stable open descriptions, port the shells and apps to the new console/input services and surface commit API, teach init to load services.ini and start/supervise RSSRV, DWM and generic services under restricted capabilities while publishing their endpoints through RSSRV, split RSSRV into namespace, volume, display, session, input, console and resource components and make /SystemRoot a real symlink to the independently published system volume, shift the syscall table again, expand lock/resource/surface/POSIX/service/thread smoke coverage, make docs scream ASK QUESTIONS and DISCUSS at LLMs, replace MIT No Attribution with WTFPL+.

This commit is contained in:
maksw committed 2026-09-16 10:33:20 +02:00
1 parent 3dacbd32c8
commit 73abd6f90d
441 files changed
+187073 -6549

No files matched your search

+175 -34
View File
@@ -18,6 +18,7 @@
#include <ntlite/service.h>
#include <ntlite/audio.h>
#include <ntlite/volume_manager.h>
#include <ntlite/thread.h>
// Syscall ABI convention: status-returning calls use KSTATUS. Syscalls use at most
// four register arguments; larger operations use request structures. Every
@@ -38,6 +39,9 @@
#define SYS_STARTUP_CAP_SERVICE_CONTROL 2u
#define SYS_STARTUP_CAP_SYSTEM_VOLUME_NAMESPACE 3u
#define SYS_STARTUP_CAP_VOLUME_MANAGER 4u
#define SYS_STARTUP_CAP_INPUT_MANAGER 5u
#define SYS_STARTUP_CAP_DISPLAY_MANAGER 6u
#define SYS_STARTUP_CAP_SESSION_CONTROL 7u
#define SYS_STARTUP_CAPABILITY_MAX 32u
typedef struct SYS_STARTUP_CAPABILITY {
@@ -186,7 +190,7 @@ typedef struct SYS_TRAP_FRAME_INFO {
// Structured exception delivery ABI. The kernel owns capture, delivery, and
// context validation; personalities own VEH, SEH, signal, and unwind policy.
#define SYS_EXCEPTION_ABI_VERSION 1u
#define SYS_EXCEPTION_ABI_VERSION 2u
#define SYS_EXCEPTION_MAXIMUM_PARAMETERS 15u
#define SYS_EXCEPTION_FLAG_NONE 0x00000000u
@@ -198,31 +202,28 @@ typedef struct SYS_TRAP_FRAME_INFO {
#define SYS_RAISE_EXCEPTION_FLAG_NONE 0x00000000u
#define SYS_RAISE_EXCEPTION_FLAG_NONCONTINUABLE 0x00000001u
// Common exception codes intentionally match the Windows values used by user
// VEH/SEH code. The native ABI remains policy-neutral; the matching numbers
// only avoid needless translation in the Win32 personality.
#define SYS_EXCEPTION_CODE_GUARD_PAGE_VIOLATION 0x80000001u
#define SYS_EXCEPTION_CODE_DATATYPE_MISALIGNMENT 0x80000002u
#define SYS_EXCEPTION_CODE_BREAKPOINT 0x80000003u
#define SYS_EXCEPTION_CODE_SINGLE_STEP 0x80000004u
#define SYS_EXCEPTION_CODE_ACCESS_VIOLATION 0xC0000005u
#define SYS_EXCEPTION_CODE_ILLEGAL_INSTRUCTION 0xC000001Du
#define SYS_EXCEPTION_CODE_NONCONTINUABLE_EXCEPTION 0xC0000025u
#define SYS_EXCEPTION_CODE_INVALID_DISPOSITION 0xC0000026u
#define SYS_EXCEPTION_CODE_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
#define SYS_EXCEPTION_CODE_FLT_DENORMAL_OPERAND 0xC000008Du
#define SYS_EXCEPTION_CODE_FLT_DIVIDE_BY_ZERO 0xC000008Eu
#define SYS_EXCEPTION_CODE_FLT_INEXACT_RESULT 0xC000008Fu
#define SYS_EXCEPTION_CODE_FLT_INVALID_OPERATION 0xC0000090u
#define SYS_EXCEPTION_CODE_FLT_OVERFLOW 0xC0000091u
#define SYS_EXCEPTION_CODE_FLT_STACK_CHECK 0xC0000092u
#define SYS_EXCEPTION_CODE_FLT_UNDERFLOW 0xC0000093u
#define SYS_EXCEPTION_CODE_INT_DIVIDE_BY_ZERO 0xC0000094u
#define SYS_EXCEPTION_CODE_INT_OVERFLOW 0xC0000095u
#define SYS_EXCEPTION_CODE_PRIVILEGED_INSTRUCTION 0xC0000096u
#define SYS_EXCEPTION_CODE_STACK_OVERFLOW 0xC00000FDu
#define SYS_EXCEPTION_CODE_NTLITE_UNKNOWN 0xE0000001u
#define SYS_EXCEPTION_CODE_NTLITE_USER_RAISED 0xE0000002u
// Native exception codes are an nt-lite ABI. Personality runtimes translate
// them to their own exception or signal namespaces at the user-mode boundary.
#define SYS_EXCEPTION_CODE_UNKNOWN 1u
#define SYS_EXCEPTION_CODE_USER_RAISED 2u
#define SYS_EXCEPTION_CODE_ACCESS_VIOLATION 3u
#define SYS_EXCEPTION_CODE_DATATYPE_MISALIGNMENT 4u
#define SYS_EXCEPTION_CODE_ILLEGAL_INSTRUCTION 5u
#define SYS_EXCEPTION_CODE_PRIVILEGED_INSTRUCTION 6u
#define SYS_EXCEPTION_CODE_BREAKPOINT 7u
#define SYS_EXCEPTION_CODE_SINGLE_STEP 8u
#define SYS_EXCEPTION_CODE_INT_DIVIDE_BY_ZERO 9u
#define SYS_EXCEPTION_CODE_INT_OVERFLOW 10u
#define SYS_EXCEPTION_CODE_ARRAY_BOUNDS_EXCEEDED 11u
#define SYS_EXCEPTION_CODE_FLT_DENORMAL_OPERAND 12u
#define SYS_EXCEPTION_CODE_FLT_DIVIDE_BY_ZERO 13u
#define SYS_EXCEPTION_CODE_FLT_INEXACT_RESULT 14u
#define SYS_EXCEPTION_CODE_FLT_INVALID_OPERATION 15u
#define SYS_EXCEPTION_CODE_FLT_OVERFLOW 16u
#define SYS_EXCEPTION_CODE_FLT_STACK_CHECK 17u
#define SYS_EXCEPTION_CODE_FLT_UNDERFLOW 18u
#define SYS_EXCEPTION_CODE_STACK_OVERFLOW 19u
#define SYS_EXCEPTION_CODE_GUARD_PAGE_VIOLATION 20u
#define SYS_EXCEPTION_DISPOSITION_CONTINUE_EXECUTION 0u
#define SYS_EXCEPTION_DISPOSITION_CONTINUE_SEARCH 1u
@@ -283,7 +284,9 @@ typedef struct SYS_EXCEPTION_RECORD {
uint64_t ErrorCode;
uint32_t ParameterCount;
uint32_t Reserved;
// Meaningful only when Code is SYS_EXCEPTION_CODE_USER_RAISED. The native
// kernel treats this as an opaque personality/application value.
uint32_t UserCode;
uint64_t Parameters[SYS_EXCEPTION_MAXIMUM_PARAMETERS];
} SYS_EXCEPTION_RECORD;
@@ -327,7 +330,8 @@ typedef struct SYS_CONTINUE_EXCEPTION_REQUEST {
typedef struct SYS_RAISE_EXCEPTION_REQUEST {
uint32_t Size;
uint32_t Flags;
uint32_t Code;
// Opaque user/personality exception value carried in SYS_EXCEPTION_RECORD.UserCode.
uint32_t UserCode;
uint32_t ParameterCount;
const uint64_t* Parameters;
} SYS_RAISE_EXCEPTION_REQUEST;
@@ -496,6 +500,72 @@ typedef struct SYS_UNLOCK_FILE_REQUEST {
uint64_t Length;
} SYS_UNLOCK_FILE_REQUEST;
#define SYS_FILE_LOCK_NONE 0u
typedef struct SYS_FILE_LOCK_INFO {
uint32_t Size;
uint32_t Mode;
uint32_t OwnerProcessId;
uint32_t Reserved;
uint64_t Offset;
uint64_t Length;
} SYS_FILE_LOCK_INFO;
typedef struct SYS_QUERY_FILE_LOCK_REQUEST {
uint32_t Size;
SYS_HANDLE FileHandle;
uint32_t Mode;
uint32_t Flags;
uint64_t Offset;
uint64_t Length;
SYS_FILE_LOCK_INFO* InfoOut;
} SYS_QUERY_FILE_LOCK_REQUEST;
#define SYS_FILE_STATUS_APPEND 0x00000001u
typedef struct SYS_SET_FILE_STATUS_REQUEST {
uint32_t Size;
SYS_HANDLE FileHandle;
uint32_t Mask;
uint32_t Flags;
} SYS_SET_FILE_STATUS_REQUEST;
#define SYS_PIPE_ATOMIC_WRITE_MAX 4096u
#define SYS_PIPE_BUFFER_CAPACITY 16384u
#define SYS_PIPE_SHARED_VERSION 1u
#define SYS_PIPE_SHARED_MAGIC 0x31504950u
#define SYS_PIPE_SHARED_HEADER_BYTES 4096u
// Shared pipe state. The first page is mapped read-only and contains
// kernel-authoritative lifecycle state. The following pages are writable and
// form the user-mode ring data plane. Positions are monotonic byte counters.
typedef struct SYS_PIPE_SHARED_STATE {
uint32_t Magic;
uint32_t Version;
uint32_t Capacity;
uint32_t HeaderBytes;
volatile long ReaderOpen;
volatile long WriterOpen;
uint8_t HeaderReserved[SYS_PIPE_SHARED_HEADER_BYTES - 24u];
volatile uint64_t ReadPosition;
volatile uint64_t WritePosition;
volatile long ReadLock;
volatile long WriteLock;
volatile long ReadWaiters;
volatile long WriteWaiters;
uint8_t RingReserved[16];
uint8_t Buffer[SYS_PIPE_BUFFER_CAPACITY];
} SYS_PIPE_SHARED_STATE;
typedef struct SYS_CREATE_PIPE_REQUEST {
uint32_t Size;
uint32_t Flags;
SYS_HANDLE* ReadHandleOut;
SYS_HANDLE* WriteHandleOut;
SYS_PIPE_SHARED_STATE** SharedStateOut;
} SYS_CREATE_PIPE_REQUEST;
typedef struct SYS_WRITE_CONSOLE_REQUEST {
uint32_t Size;
SYS_STRING_VIEW Text;
@@ -584,6 +654,8 @@ typedef struct SYS_CREATE_THREAD_REQUEST {
uintptr_t Argument;
uint32_t Priority;
uint32_t Flags;
// Both outputs are optional for a running detached thread. Suspended creation
// requires ThreadHandleOut so the caller retains a capability to resume it.
SYS_HANDLE* ThreadHandleOut;
uint32_t* ThreadIdOut;
} SYS_CREATE_THREAD_REQUEST;
@@ -666,8 +738,11 @@ KSTATUS SysKillProcess(SYS_HANDLE processHandle, int32_t exitCode);
#define SYS_THREAD_WAIT_SURFACE 16u
#define SYS_THREAD_WAIT_TIMER 17u
#define SYS_THREAD_WAIT_DISPLAY_CLOCK 18u
#define SYS_THREAD_WAIT_PIPE 19u
#define SYS_THREAD_WAIT_UNKNOWN 0xffffffffu
#define SYS_THREAD_NAME_MAX NTL_THREAD_NAME_MAX
typedef struct SYS_THREAD_INFO {
uint32_t Size;
uint32_t ProcessId;
@@ -691,8 +766,18 @@ typedef struct SYS_THREAD_INFO {
uint32_t WaitObjectType;
uint32_t WaitStatus;
uint32_t KernelApcDisable;
char Name[SYS_THREAD_NAME_MAX];
} SYS_THREAD_INFO;
// Sets one thread description. ThreadHandle == SYS_HANDLE_INVALID targets the
// calling thread. Name may be empty to clear the description.
typedef struct SYS_SET_THREAD_NAME_REQUEST {
uint32_t Size;
SYS_HANDLE ThreadHandle;
SYS_STRING_VIEW Name;
} SYS_SET_THREAD_NAME_REQUEST;
typedef struct SYS_PROCESS_INFO {
uint32_t Size;
uint32_t ProcessId;
@@ -734,6 +819,8 @@ KSTATUS SysResumeThread(SYS_HANDLE threadHandle, uint32_t* previousSuspendCountO
uint32_t SysGetCurrentTid(void);
uint32_t SysGetCurrentPid(void);
KSTATUS SysSetThreadPriority(uint32_t priority);
KSTATUS SysSetThreadName(const SYS_SET_THREAD_NAME_REQUEST* request);
KSTATUS SysQueryThreadName(SYS_HANDLE threadHandle, char* buffer, size_t bufferSize, size_t* lengthOut);
KSTATUS SysYield(void);
#define SYS_TIMER_FLAG_NONE 0u
@@ -923,6 +1010,10 @@ KSTATUS SysTruncateFile(SYS_HANDLE handle, uint64_t newSize);
KSTATUS SysFlushFile(SYS_HANDLE handle);
KSTATUS SysLockFile(const SYS_LOCK_FILE_REQUEST* request);
KSTATUS SysUnlockFile(const SYS_UNLOCK_FILE_REQUEST* request);
KSTATUS SysQueryFileLock(const SYS_QUERY_FILE_LOCK_REQUEST* request);
KSTATUS SysSetFileStatus(const SYS_SET_FILE_STATUS_REQUEST* request);
KSTATUS SysCreatePipe(const SYS_CREATE_PIPE_REQUEST* request);
KSTATUS SysNotifyPipe(SYS_HANDLE pipeHandle);
KSTATUS SysReadDir(SYS_HANDLE handle, SYS_DIR_ENTRY* entryOut);
@@ -983,13 +1074,39 @@ typedef struct SYS_CREATE_SURFACE_REQUEST {
} SYS_CREATE_SURFACE_REQUEST;
KSTATUS SysCreateSurface(const SYS_CREATE_SURFACE_REQUEST* request);
KSTATUS SysMapSurface(SYS_HANDLE surfaceHandle, void** baseOut, uint32_t* pitchBytesOut);
KSTATUS SysMapSurface(SYS_HANDLE surfaceHandle, uint32_t flags, void** baseOut, uint32_t* pitchBytesOut);
KSTATUS SysUnmapSurface(void* base);
KSTATUS SysQuerySurface(SYS_HANDLE surfaceHandle, SYS_SURFACE_DESC* descOut);
KSTATUS SysPresentSurface(SYS_HANDLE surfaceHandle, const DISPLAY_RECT* rects, uint32_t rectCount);
KSTATUS SysCommitSurface(SYS_HANDLE surfaceHandle, const DISPLAY_RECT* rects, uint32_t rectCount, uint64_t* generationOut);
KSTATUS SysClearScreen(uint32_t color);
KSTATUS SysGetScreenSize(int* widthOut, int* heightOut);
KSTATUS SysQueryDisplayInfo(SYS_DISPLAY_INFO* infoOut);
#define SYS_DISPLAY_MANAGER_CURSOR_FLAG_NONE 0x00000000u
#define SYS_DISPLAY_MANAGER_CURSOR_FLAG_SHOW 0x00000001u
#define SYS_DISPLAY_MANAGER_CURSOR_FLAG_HIDE 0x00000002u
typedef struct SYS_DISPLAY_MANAGER_CURSOR_REQUEST {
uint32_t Size;
SYS_HANDLE ManagerHandle;
uint32_t Flags;
int32_t X;
int32_t Y;
} SYS_DISPLAY_MANAGER_CURSOR_REQUEST;
// Capability-scoped display operations used by the native resource plane.
KSTATUS SysQueryDisplayManagerInfo(SYS_HANDLE managerHandle, SYS_DISPLAY_INFO* infoOut);
KSTATUS SysSetDisplayManagerCursor(const SYS_DISPLAY_MANAGER_CURSOR_REQUEST* request);
KSTATUS SysPresentDisplayManagerSurface(SYS_HANDLE managerHandle, SYS_HANDLE surfaceHandle,
const DISPLAY_RECT* rects, uint32_t rectCount);
KSTATUS SysWriteDisplayManagerConsole(SYS_HANDLE managerHandle, const SYS_WRITE_CONSOLE_REQUEST* request);
KSTATUS SysQueryDisplayManagerConsoleInfo(SYS_HANDLE managerHandle, SYS_CONSOLE_INFO* infoOut);
KSTATUS SysSetDisplayManagerConsoleCursor(SYS_HANDLE managerHandle, int x, int y);
KSTATUS SysFillDisplayManagerConsoleCharacter(SYS_HANDLE managerHandle, const SYS_FILL_CONSOLE_CHARACTER_REQUEST* request);
KSTATUS SysFillDisplayManagerConsoleAttribute(SYS_HANDLE managerHandle, const SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST* request);
KSTATUS SysPutDisplayManagerConsoleCharacter(SYS_HANDLE managerHandle, const SYS_PUT_SCREEN_CHAR_REQUEST* request);
KSTATUS SysClearDisplayManagerConsole(SYS_HANDLE managerHandle, uint32_t color);
// Display clocks are waitable pacing objects. Providers with frame-event
// support signal them once per submitted frame. Other providers use the boot processor
// scheduler tick, with PeriodMilliseconds rounded up to one or more ticks.
@@ -1006,14 +1123,38 @@ typedef struct SYS_OPEN_DISPLAY_CLOCK_REQUEST {
KSTATUS SysOpenDisplayClock(const SYS_OPEN_DISPLAY_CLOCK_REQUEST* request);
// Input.
#define SYS_INPUT_MANAGER_EVENT_FLAG_NONE 0x00000000u
#define SYS_INPUT_MANAGER_EVENT_KEY 1u
#define SYS_INPUT_MANAGER_EVENT_MOUSE 2u
typedef struct SYS_INPUT_MANAGER_EVENT {
uint32_t Size;
uint32_t Type;
uint64_t Sequence;
union {
INPUT_KEY_EVENT Key;
INPUT_MOUSE_EVENT Mouse;
} Data;
} SYS_INPUT_MANAGER_EVENT;
typedef struct SYS_INPUT_MANAGER_READ_REQUEST {
uint32_t Size;
SYS_HANDLE ManagerHandle;
uint32_t Flags;
uint64_t TimeoutMilliseconds;
SYS_INPUT_MANAGER_EVENT* EventOut;
} SYS_INPUT_MANAGER_READ_REQUEST;
// Reads the next normalized physical input event through an input-manager capability.
KSTATUS SysReadInputManagerEvent(const SYS_INPUT_MANAGER_READ_REQUEST* request);
#define SYS_INPUT_QUEUE_FLAG_NONE 0x00000000u
#define SYS_INPUT_EVENT_FLAG_NONE 0x00000000u
#define SYS_GLOBAL_INPUT_STATE_FLAG_NONE 0x00000000u
#define SYS_GLOBAL_INPUT_KEY_BYTES 32u
// SysQueryGlobalInputState snapshots the current physical input state. It does
// not consume queued keyboard or mouse events and is intentionally global; a
// later routed input context API should use a context handle instead.
// Legacy kernel-global input snapshot retained for compatibility. Normal interactive
// clients should consume RSSRV logical input through <ntlite/input_service.h>.
typedef struct SYS_GLOBAL_INPUT_STATE {
uint32_t Size;
uint32_t Flags;
@@ -1267,7 +1408,7 @@ typedef struct SYS_MEMORY_STATUS {
// Public stats payloads start with Size and Version. Size is the byte count
// returned for that payload, including any trailing records. Version describes
// the field layout for fixed fields in the named payload.
#define SYS_STATS_VERSION 1u
#define SYS_STATS_VERSION 3u
typedef struct SYS_EXCEPTION_STATS {