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:
1 parent
3dacbd32c8
commit
73abd6f90d
441 files changed
+187073
-6549
No files matched your search
@@ -23,6 +23,8 @@
|
||||
#include <string.h>
|
||||
#include <intrin.h>
|
||||
#include <ntlite/syscall.h>
|
||||
#include <ntlite/input_service.h>
|
||||
#include <ntlite/console_service.h>
|
||||
#include <ntlite/exception.h>
|
||||
#include <ntlite/process_loader.h>
|
||||
#include <ntlite/path.h>
|
||||
@@ -338,8 +340,7 @@ static uint32_t K32CreateProcessNative(const char* path, uint32_t imageFile, uin
|
||||
|
||||
// Implements the k32 Write Console Span operation.
|
||||
static void K32WriteConsoleSpan(const char* data, size_t length) {
|
||||
SYS_WRITE_CONSOLE_REQUEST req = { sizeof(SYS_WRITE_CONSOLE_REQUEST), SysSvFromParts(data, length) };
|
||||
SysWriteConsole(&req);
|
||||
(void)NtlConsoleWrite(SYS_HANDLE_INVALID, data, length, 0);
|
||||
}
|
||||
|
||||
// Implements the k32 Debug Print A operation.
|
||||
@@ -745,7 +746,7 @@ __declspec(dllexport) BOOL FlushViewOfFile(const void* lpBaseAddress, size_t dwN
|
||||
// Returns whether one input key is currently held for Win32 adapters.
|
||||
static bool Win32IsInputKeyDown(INPUT_KEY key) {
|
||||
bool down = false;
|
||||
return SysIsKeyDown(key, &down) == NTLSTATUS_SUCCESS && down;
|
||||
return NtlInputIsKeyDown(key, &down) == NTLSTATUS_SUCCESS && down;
|
||||
}
|
||||
|
||||
// GetAsyncKeyState implementation over the canonical input key namespace.
|
||||
@@ -811,18 +812,14 @@ __declspec(dllexport) SHORT GetAsyncKeyState(int vKey) {
|
||||
// FlushConsoleInputBuffer: clear the keyboard input buffer.
|
||||
__declspec(dllexport) BOOL FlushConsoleInputBuffer(HANDLE hConsoleInput) {
|
||||
(void)hConsoleInput;
|
||||
// Drain the keyboard buffer by reading until empty.
|
||||
INPUT_KEY key;
|
||||
while (SysPollKeyboard(&key) == NTLSTATUS_SUCCESS) {
|
||||
char ignored;
|
||||
(void)SysReadKeyboardChar(&ignored);
|
||||
}
|
||||
(void)NtlConsoleFlushInput(SYS_HANDLE_INVALID);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// !Made-up! clear console api.
|
||||
__declspec(dllexport) BOOL ClearConsoleScreenBuffer(HANDLE hConsole) {
|
||||
SysClearScreen(0x012456);
|
||||
(void)hConsole;
|
||||
(void)NtlConsoleClear(SYS_HANDLE_INVALID, 0x012456);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1948,7 +1945,7 @@ __declspec(dllexport) HANDLE GetStdHandle(DWORD nStdHandle) {
|
||||
}
|
||||
|
||||
// ReadConsoleA: blocking read of up to nNumberOfCharsToRead characters.
|
||||
// Each character is read individually via SysReadKeyboardChar so the caller can
|
||||
// Each character is read individually via NtlInputReadKeyboardChar so the caller can
|
||||
// do its own line-editing (echo, backspace, etc.) one char at a time.
|
||||
__declspec(dllexport) BOOL ReadConsoleA(HANDLE hConsoleInput,
|
||||
void* lpBuffer,
|
||||
@@ -1963,7 +1960,7 @@ __declspec(dllexport) BOOL ReadConsoleA(HANDLE hConsoleInput,
|
||||
|
||||
while (i < nNumberOfCharsToRead) {
|
||||
char c = 0;
|
||||
if (SysReadKeyboardChar(&c) != NTLSTATUS_SUCCESS) continue;
|
||||
if (NtlConsoleReadCharacter(SYS_HANDLE_INVALID, &c) != NTLSTATUS_SUCCESS) continue;
|
||||
|
||||
// Ignore unmapped keys (Shift, Ctrl, etc.).
|
||||
if (c == 0) continue;
|
||||
@@ -2013,8 +2010,8 @@ __declspec(dllexport) BOOL GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SYS_CONSOLE_INFO info;
|
||||
uint32_t s = SysGetConsoleInfo(&info);
|
||||
NTL_CONSOLE_INFO info;
|
||||
uint32_t s = NtlConsoleQueryInfo(SYS_HANDLE_INVALID, &info);
|
||||
if (s != NTLSTATUS_SUCCESS) {
|
||||
K32SetConsoleLastError(s);
|
||||
return FALSE;
|
||||
@@ -2045,7 +2042,7 @@ __declspec(dllexport) BOOL SetConsoleCursorPosition(HANDLE hConsoleOutput,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
uint32_t s = SysSetConsoleCursor((int)dwCursorPosition.X, (int)dwCursorPosition.Y);
|
||||
uint32_t s = NtlConsoleSetCursor(SYS_HANDLE_INVALID, (int)dwCursorPosition.X, (int)dwCursorPosition.Y);
|
||||
if (s != NTLSTATUS_SUCCESS) {
|
||||
K32SetConsoleLastError(s);
|
||||
return FALSE;
|
||||
@@ -2071,11 +2068,9 @@ __declspec(dllexport) BOOL FillConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
||||
return TRUE;
|
||||
|
||||
size_t written = 0;
|
||||
SYS_FILL_CONSOLE_CHARACTER_REQUEST request = {
|
||||
sizeof(SYS_FILL_CONSOLE_CHARACTER_REQUEST), cCharacter, { 0, 0, 0 },
|
||||
(int)dwWriteCoord.X, (int)dwWriteCoord.Y, (size_t)nLength, &written
|
||||
};
|
||||
uint32_t s = SysFillConsoleCharacter(&request);
|
||||
uint32_t s = NtlConsoleFillCharacter(SYS_HANDLE_INVALID, cCharacter,
|
||||
(int)dwWriteCoord.X, (int)dwWriteCoord.Y,
|
||||
(size_t)nLength, &written);
|
||||
if (lpNumberOfCharsWritten) *lpNumberOfCharsWritten = (DWORD)written;
|
||||
if (s != NTLSTATUS_SUCCESS) {
|
||||
K32SetConsoleLastError(s);
|
||||
@@ -2102,11 +2097,9 @@ __declspec(dllexport) BOOL FillConsoleOutputAttribute(HANDLE hConsoleOutput,
|
||||
return TRUE;
|
||||
|
||||
size_t written = 0;
|
||||
SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST request = {
|
||||
sizeof(SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST), wAttribute, 0,
|
||||
(int)dwWriteCoord.X, (int)dwWriteCoord.Y, (size_t)nLength, &written
|
||||
};
|
||||
uint32_t s = SysFillConsoleAttribute(&request);
|
||||
uint32_t s = NtlConsoleFillAttribute(SYS_HANDLE_INVALID, wAttribute,
|
||||
(int)dwWriteCoord.X, (int)dwWriteCoord.Y,
|
||||
(size_t)nLength, &written);
|
||||
if (lpNumberOfAttrsWritten) *lpNumberOfAttrsWritten = (DWORD)written;
|
||||
if (s != NTLSTATUS_SUCCESS) {
|
||||
K32SetConsoleLastError(s);
|
||||
@@ -3120,7 +3113,7 @@ __declspec(dllexport) DWORD GetFileType(HANDLE hFile) {
|
||||
#define EXCEPTION_CONTINUE_SEARCH 0
|
||||
#define EXCEPTION_EXECUTE_HANDLER 1
|
||||
#define EXCEPTION_NONCONTINUABLE 0x1UL
|
||||
#define EXCEPTION_MAXIMUM_PARAMETERS SYS_EXCEPTION_MAXIMUM_PARAMETERS
|
||||
#define EXCEPTION_MAXIMUM_PARAMETERS 15u
|
||||
#define WIN_VECTORED_MAX_HANDLERS 16u
|
||||
#define WIN_SEH_MAX_FRAMES 16u
|
||||
|
||||
@@ -3239,10 +3232,61 @@ static uint32_t* WinpVectoredTailSlot(uint32_t isContinue) {
|
||||
return isContinue ? &gWinVectoredContinueTail : &gWinVectoredExceptionTail;
|
||||
}
|
||||
|
||||
// Windows exception values remain a Win32 personality ABI and are translated
|
||||
// explicitly from the native nt-lite exception classes.
|
||||
#define WIN_EXCEPTION_GUARD_PAGE_VIOLATION 0x80000001u
|
||||
#define WIN_EXCEPTION_DATATYPE_MISALIGNMENT 0x80000002u
|
||||
#define WIN_EXCEPTION_BREAKPOINT 0x80000003u
|
||||
#define WIN_EXCEPTION_SINGLE_STEP 0x80000004u
|
||||
#define WIN_EXCEPTION_ACCESS_VIOLATION 0xC0000005u
|
||||
#define WIN_EXCEPTION_ILLEGAL_INSTRUCTION 0xC000001Du
|
||||
#define WIN_EXCEPTION_ARRAY_BOUNDS_EXCEEDED 0xC000008Cu
|
||||
#define WIN_EXCEPTION_FLT_DENORMAL_OPERAND 0xC000008Du
|
||||
#define WIN_EXCEPTION_FLT_DIVIDE_BY_ZERO 0xC000008Eu
|
||||
#define WIN_EXCEPTION_FLT_INEXACT_RESULT 0xC000008Fu
|
||||
#define WIN_EXCEPTION_FLT_INVALID_OPERATION 0xC0000090u
|
||||
#define WIN_EXCEPTION_FLT_OVERFLOW 0xC0000091u
|
||||
#define WIN_EXCEPTION_FLT_STACK_CHECK 0xC0000092u
|
||||
#define WIN_EXCEPTION_FLT_UNDERFLOW 0xC0000093u
|
||||
#define WIN_EXCEPTION_INT_DIVIDE_BY_ZERO 0xC0000094u
|
||||
#define WIN_EXCEPTION_INT_OVERFLOW 0xC0000095u
|
||||
#define WIN_EXCEPTION_PRIVILEGED_INSTRUCTION 0xC0000096u
|
||||
#define WIN_EXCEPTION_STACK_OVERFLOW 0xC00000FDu
|
||||
#define WIN_EXCEPTION_NTLITE_UNKNOWN 0xE04E544Cu
|
||||
|
||||
// Maps one native exception class to the Win32 exception namespace.
|
||||
static DWORD WinpExceptionCodeFromNative(const SYS_EXCEPTION_RECORD* source) {
|
||||
if (!source) return WIN_EXCEPTION_NTLITE_UNKNOWN;
|
||||
if (source->Code == SYS_EXCEPTION_CODE_USER_RAISED)
|
||||
return source->UserCode;
|
||||
|
||||
switch (source->Code) {
|
||||
case SYS_EXCEPTION_CODE_GUARD_PAGE_VIOLATION: return WIN_EXCEPTION_GUARD_PAGE_VIOLATION;
|
||||
case SYS_EXCEPTION_CODE_DATATYPE_MISALIGNMENT: return WIN_EXCEPTION_DATATYPE_MISALIGNMENT;
|
||||
case SYS_EXCEPTION_CODE_BREAKPOINT: return WIN_EXCEPTION_BREAKPOINT;
|
||||
case SYS_EXCEPTION_CODE_SINGLE_STEP: return WIN_EXCEPTION_SINGLE_STEP;
|
||||
case SYS_EXCEPTION_CODE_ACCESS_VIOLATION: return WIN_EXCEPTION_ACCESS_VIOLATION;
|
||||
case SYS_EXCEPTION_CODE_ILLEGAL_INSTRUCTION: return WIN_EXCEPTION_ILLEGAL_INSTRUCTION;
|
||||
case SYS_EXCEPTION_CODE_ARRAY_BOUNDS_EXCEEDED: return WIN_EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
|
||||
case SYS_EXCEPTION_CODE_FLT_DENORMAL_OPERAND: return WIN_EXCEPTION_FLT_DENORMAL_OPERAND;
|
||||
case SYS_EXCEPTION_CODE_FLT_DIVIDE_BY_ZERO: return WIN_EXCEPTION_FLT_DIVIDE_BY_ZERO;
|
||||
case SYS_EXCEPTION_CODE_FLT_INEXACT_RESULT: return WIN_EXCEPTION_FLT_INEXACT_RESULT;
|
||||
case SYS_EXCEPTION_CODE_FLT_INVALID_OPERATION: return WIN_EXCEPTION_FLT_INVALID_OPERATION;
|
||||
case SYS_EXCEPTION_CODE_FLT_OVERFLOW: return WIN_EXCEPTION_FLT_OVERFLOW;
|
||||
case SYS_EXCEPTION_CODE_FLT_STACK_CHECK: return WIN_EXCEPTION_FLT_STACK_CHECK;
|
||||
case SYS_EXCEPTION_CODE_FLT_UNDERFLOW: return WIN_EXCEPTION_FLT_UNDERFLOW;
|
||||
case SYS_EXCEPTION_CODE_INT_DIVIDE_BY_ZERO: return WIN_EXCEPTION_INT_DIVIDE_BY_ZERO;
|
||||
case SYS_EXCEPTION_CODE_INT_OVERFLOW: return WIN_EXCEPTION_INT_OVERFLOW;
|
||||
case SYS_EXCEPTION_CODE_PRIVILEGED_INSTRUCTION: return WIN_EXCEPTION_PRIVILEGED_INSTRUCTION;
|
||||
case SYS_EXCEPTION_CODE_STACK_OVERFLOW: return WIN_EXCEPTION_STACK_OVERFLOW;
|
||||
default: return WIN_EXCEPTION_NTLITE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// Copies native exception state into the Win32-facing exception record.
|
||||
static void WinpBuildExceptionRecord(const SYS_EXCEPTION_RECORD* source, EXCEPTION_RECORD* target) {
|
||||
memset(target, 0, sizeof(*target));
|
||||
target->ExceptionCode = source->Code;
|
||||
target->ExceptionCode = WinpExceptionCodeFromNative(source);
|
||||
if (source->Flags & SYS_EXCEPTION_FLAG_NONCONTINUABLE)
|
||||
target->ExceptionFlags |= EXCEPTION_NONCONTINUABLE;
|
||||
target->ExceptionAddress = (void*)(uintptr_t)source->ExceptionAddress;
|
||||
@@ -3603,7 +3647,7 @@ __declspec(dllexport) void RaiseException(DWORD dwExceptionCode, DWORD dwExcepti
|
||||
SYS_RAISE_EXCEPTION_REQUEST request;
|
||||
memset(&request, 0, sizeof(request));
|
||||
request.Size = sizeof(request);
|
||||
request.Code = dwExceptionCode;
|
||||
request.UserCode = dwExceptionCode;
|
||||
request.Flags = (dwExceptionFlags & EXCEPTION_NONCONTINUABLE) ?
|
||||
SYS_RAISE_EXCEPTION_FLAG_NONCONTINUABLE :
|
||||
SYS_RAISE_EXCEPTION_FLAG_NONE;
|
||||
|
||||
Reference in new issue
Block a user