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

@@ -0,0 +1,161 @@
// Cross-process surface smoke test. It proves transferred read-only mapping, shared backing, and commit wakeup.
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <ntlite/process_loader.h>
#include <ntlite/syscall.h>
#define TEST_SURFACE_TAG 0x53555246u
#define TEST_READY_TAG 0x53555245u
#define TEST_WIDTH 32u
#define TEST_HEIGHT 16u
#define TEST_PIXEL_X 7u
#define TEST_PIXEL_Y 5u
#define TEST_VALUE_A 0x00123456u
#define TEST_VALUE_B 0x00ABCDEFu
// Terminates the test without depending on a compiler runtime return path.
static void exit_now(int code) {
for (;;) SysExitProcess(code);
}
// Writes one diagnostic string through the native console path.
static void print(const char* text) {
SYS_WRITE_CONSOLE_REQUEST request = { sizeof(request), SysSvFromCstr(text) };
(void)SysWriteConsole(&request);
}
// Returns whether this process was launched as the verifier child.
static bool is_child(void) {
SYS_PEB* peb = SysGetPeb();
static const char marker[] = "surface-cross-process-child";
return peb && peb->CommandLine.Length == sizeof(marker) - 1u &&
memcmp(peb->CommandLine.Data, marker, sizeof(marker) - 1u) == 0;
}
// Reads one pixel from a pitch-based XRGB8888 mapping.
static uint32_t read_pixel(const void* base, uint32_t pitch) {
const uint8_t* row = (const uint8_t*)base + (size_t)TEST_PIXEL_Y * pitch;
return ((const uint32_t*)row)[TEST_PIXEL_X];
}
// Writes one pixel to a pitch-based XRGB8888 mapping.
static void write_pixel(void* base, uint32_t pitch, uint32_t value) {
uint8_t* row = (uint8_t*)base + (size_t)TEST_PIXEL_Y * pitch;
((uint32_t*)row)[TEST_PIXEL_X] = value;
}
// Runs the child side using only the attenuated capabilities supplied at process construction.
static void run_child(void) {
SYS_HANDLE surface = SysGetStartupCapability(TEST_SURFACE_TAG);
SYS_HANDLE ready = SysGetStartupCapability(TEST_READY_TAG);
if (surface == SYS_HANDLE_INVALID || ready == SYS_HANDLE_INVALID) exit_now(10);
void* invalidBase = (void*)0;
uint32_t invalidPitch = 0;
KSTATUS status = SysMapSurface(surface, SYS_SURFACE_MAP_READ | SYS_SURFACE_MAP_WRITE,
&invalidBase, &invalidPitch);
if (status != NTLSTATUS_ACCESS_DENIED) exit_now(11);
void* base = (void*)0;
uint32_t pitch = 0;
status = SysMapSurface(surface, SYS_SURFACE_MAP_READ, &base, &pitch);
if (!KSUCCESS(status) || !base || pitch < TEST_WIDTH * sizeof(uint32_t)) exit_now(12);
if (read_pixel(base, pitch) != TEST_VALUE_A) exit_now(13);
status = SysSignalEvent(ready);
if (!KSUCCESS(status)) exit_now(14);
status = SysWait(surface, SYS_WAIT_FLAG_NONE);
if (!KSUCCESS(status)) exit_now(15);
if (read_pixel(base, pitch) != TEST_VALUE_B) exit_now(16);
SYS_SURFACE_DESC desc;
memset(&desc, 0, sizeof(desc));
status = SysQuerySurface(surface, &desc);
if (!KSUCCESS(status) || desc.ContentGeneration != 1u || desc.CommitCount != 1u) exit_now(17);
status = SysUnmapSurface(base);
if (!KSUCCESS(status)) exit_now(18);
exit_now(0);
}
// Creates the producer surface, transfers an attenuated capability, and verifies child observation after commit.
int main(void) {
if (is_child()) run_child();
SYS_PEB* peb = SysGetPeb();
if (!peb || peb->Magic != SYS_PEB_MAGIC || peb->Version != SYS_ENV_VERSION) exit_now(1);
SYS_HANDLE surface = SYS_HANDLE_INVALID;
SYS_CREATE_SURFACE_REQUEST createSurface;
memset(&createSurface, 0, sizeof(createSurface));
createSurface.Size = sizeof(createSurface);
createSurface.Width = TEST_WIDTH;
createSurface.Height = TEST_HEIGHT;
createSurface.Format = SYS_SURFACE_FORMAT_XRGB8888;
createSurface.Flags = SYS_SURFACE_FLAG_NONE;
createSurface.HandleOut = &surface;
KSTATUS status = SysCreateSurface(&createSurface);
if (!KSUCCESS(status)) exit_now(2);
void* base = (void*)0;
uint32_t pitch = 0;
status = SysMapSurface(surface, SYS_SURFACE_MAP_READ | SYS_SURFACE_MAP_WRITE, &base, &pitch);
if (!KSUCCESS(status)) exit_now(3);
write_pixel(base, pitch, TEST_VALUE_A);
SYS_HANDLE ready = SYS_HANDLE_INVALID;
status = SysCreateEvent(0u, 0u, &ready);
if (!KSUCCESS(status)) exit_now(4);
NTL_PROCESS_STARTUP_CAPABILITY startup[2];
memset(startup, 0, sizeof(startup));
startup[0].Tag = TEST_SURFACE_TAG;
startup[0].SourceHandle = surface;
startup[0].DesiredRights = SYS_RIGHT_QUERY | SYS_RIGHT_WAIT | SYS_SURFACE_RIGHT_MAP_READ;
startup[0].DuplicateFlags = SYS_DUPLICATE_HANDLE_FLAG_NONE;
startup[1].Tag = TEST_READY_TAG;
startup[1].SourceHandle = ready;
startup[1].DesiredRights = SYS_RIGHT_QUERY | SYS_EVENT_RIGHT_SIGNAL;
startup[1].DuplicateFlags = SYS_DUPLICATE_HANDLE_FLAG_NONE;
SYS_HANDLE child = SYS_HANDLE_INVALID;
NTL_CREATE_SYSTEM_PROCESS_REQUEST create;
memset(&create, 0, sizeof(create));
create.Size = sizeof(create);
create.Flags = NTL_PROCESS_LOAD_FLAG_NONE;
create.ImageFile = SYS_HANDLE_INVALID;
create.Path = peb->ImagePath;
create.CommandLine = SYS_SV_LITERAL("surface-cross-process-child");
create.SecurityContext = SYS_SECURITY_CONTEXT_CURRENT;
create.ResolveModuleName = NtlResolveSystemModuleName;
create.StartupCapabilities = startup;
create.StartupCapabilityCount = 2u;
create.ProcessHandleOut = &child;
status = NtlCreateSystemProcess(&create);
if (!KSUCCESS(status)) exit_now(5);
status = SysWait(ready, SYS_WAIT_FLAG_NONE);
if (!KSUCCESS(status)) exit_now(6);
write_pixel(base, pitch, TEST_VALUE_B);
DISPLAY_RECT damage = { (int32_t)TEST_PIXEL_X, (int32_t)TEST_PIXEL_Y, 1, 1 };
uint64_t generation = 0;
status = SysCommitSurface(surface, &damage, 1u, &generation);
if (!KSUCCESS(status) || generation != 1u) exit_now(7);
status = SysWait(child, SYS_WAIT_FLAG_NONE);
if (!KSUCCESS(status)) exit_now(8);
int32_t childExit = -1;
status = SysGetProcessExitCode(child, &childExit);
if (!KSUCCESS(status) || childExit != 0) exit_now(9);
(void)SysCloseHandle(child);
(void)SysCloseHandle(ready);
(void)SysUnmapSurface(base);
(void)SysCloseHandle(surface);
print("surface_cross_process_smoke: PASS\n");
return 0;
}