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

+127 -17
View File
@@ -5,10 +5,12 @@
#include <ntlite/syscall.h>
#include <string.h>
// Validates the canonical global resource-path syntax understood by rssrv.
// Validates canonical global resource-path syntax. The namespace root is represented by exactly "/".
static KSTATUS NtlValidateResourcePath(SYS_STRING_VIEW path) {
if (!path.Data || path.Length < 2 || path.Length > NTL_RESOURCE_PATH_MAX || path.Data[0] != '/')
if (!path.Data || path.Length == 0 || path.Length > NTL_RESOURCE_PATH_MAX || path.Data[0] != '/')
return NTLSTATUS_INVALID_PARAMETER;
if (path.Length == 1)
return NTLSTATUS_SUCCESS;
if (path.Data[path.Length - 1] == '/')
return NTLSTATUS_INVALID_PARAMETER;
@@ -23,7 +25,7 @@ static KSTATUS NtlValidateResourcePath(SYS_STRING_VIEW path) {
}
size_t componentLength = i - componentStart;
if (componentLength == 0 ||
if (componentLength == 0 || componentLength > NTL_RESOURCE_NAME_MAX ||
(componentLength == 1 && path.Data[componentStart] == '.') ||
(componentLength == 2 && path.Data[componentStart] == '.' && path.Data[componentStart + 1] == '.'))
return NTLSTATUS_INVALID_PARAMETER;
@@ -32,20 +34,21 @@ static KSTATUS NtlValidateResourcePath(SYS_STRING_VIEW path) {
return NTLSTATUS_SUCCESS;
}
// Builds one inline request header and path payload.
// Builds one inline request header with a path and optional operation-specific payload.
static KSTATUS NtlBuildResourceRequest(uint8_t* buffer,
size_t bufferSize,
uint32_t operation,
SYS_STRING_VIEW path,
SYS_STRING_VIEW aux,
SYS_RIGHTS rights,
SYS_RIGHTS exportRights,
uint32_t kind,
uint32_t* lengthOut) {
KSTATUS status = NtlValidateResourcePath(path);
if (!KSUCCESS(status) || !buffer || !lengthOut)
if (!KSUCCESS(status) || !buffer || !lengthOut || !SysSvIsValid(aux))
return KSUCCESS(status) ? NTLSTATUS_INVALID_PARAMETER : status;
size_t total = sizeof(NTL_RESOURCE_REQUEST) + path.Length;
if (total > bufferSize || total > SYS_PORT_MAX_INLINE_BYTES)
size_t total = sizeof(NTL_RESOURCE_REQUEST) + path.Length + aux.Length;
if (total > bufferSize || total > SYS_PORT_MAX_INLINE_BYTES || aux.Length > UINT32_MAX)
return NTLSTATUS_BUFFER_TOO_SMALL;
NTL_RESOURCE_REQUEST header;
@@ -58,8 +61,11 @@ static KSTATUS NtlBuildResourceRequest(uint8_t* buffer,
header.ExportRights = exportRights;
header.Kind = kind;
header.PathLength = (uint32_t)path.Length;
header.AuxLength = (uint32_t)aux.Length;
memcpy(buffer, &header, sizeof(header));
memcpy(buffer + sizeof(header), path.Data, path.Length);
if (aux.Length)
memcpy(buffer + sizeof(header) + path.Length, aux.Data, aux.Length);
*lengthOut = (uint32_t)total;
return NTLSTATUS_SUCCESS;
}
@@ -102,7 +108,7 @@ static KSTATUS NtlCallResource(SYS_HANDLE session,
return status;
if (info.Type != SYS_PORT_MESSAGE_REPLY || info.PayloadLength != sizeof(reply) ||
reply.Size != sizeof(reply) || reply.Version != NTL_RESOURCE_PROTOCOL_VERSION) {
reply.Size != sizeof(reply) || reply.Version != NTL_RESOURCE_PROTOCOL_VERSION || reply.NameLength != 0) {
if (replyHandle != SYS_HANDLE_INVALID) (void)SysCloseHandle(replyHandle);
return NTLSTATUS_FAILURE;
}
@@ -164,7 +170,8 @@ KSTATUS NtlResourceLookup(SYS_HANDLE session,
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX];
uint32_t payloadLength = 0;
KSTATUS status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_LOOKUP,
path, desiredRights, 0, NTL_RESOURCE_KIND_INVALID,
path, SysSvFromParts((const char*)0, 0),
desiredRights, 0, NTL_RESOURCE_KIND_INVALID,
&payloadLength);
if (!KSUCCESS(status)) return status;
@@ -186,14 +193,15 @@ KSTATUS NtlResourceLookup(SYS_HANDLE session,
return NTLSTATUS_SUCCESS;
}
// Queries one bound resource kind without transferring authority.
// Queries one exact namespace node kind without transferring authority.
KSTATUS NtlResourceQuery(SYS_HANDLE session, SYS_STRING_VIEW path, uint32_t* kindOut) {
if (!kindOut) return NTLSTATUS_INVALID_PARAMETER;
*kindOut = NTL_RESOURCE_KIND_INVALID;
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX];
uint32_t payloadLength = 0;
KSTATUS status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_QUERY,
path, 0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
path, SysSvFromParts((const char*)0, 0),
0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
if (!KSUCCESS(status)) return status;
NTL_RESOURCE_REPLY reply;
@@ -213,7 +221,7 @@ KSTATUS NtlResourceResolve(SYS_HANDLE session,
SYS_HANDLE* rootHandleOut,
uint32_t* kindOut,
uint32_t* resolvedLengthOut) {
if (!rootHandleOut || !kindOut || !resolvedLengthOut ||
if (!rootHandleOut || !kindOut || !resolvedLengthOut || path.Length < 2 ||
(flags & ~NTL_RESOURCE_RESOLVE_FLAG_MODIFY) != 0)
return NTLSTATUS_INVALID_PARAMETER;
*rootHandleOut = SYS_HANDLE_INVALID;
@@ -223,7 +231,8 @@ KSTATUS NtlResourceResolve(SYS_HANDLE session,
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX];
uint32_t payloadLength = 0;
KSTATUS status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_RESOLVE,
path, 0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
path, SysSvFromParts((const char*)0, 0),
0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
if (!KSUCCESS(status)) return status;
((NTL_RESOURCE_REQUEST*)payload)->Flags = flags;
@@ -253,6 +262,104 @@ KSTATUS NtlResourceResolve(SYS_HANDLE session,
return NTLSTATUS_SUCCESS;
}
// Enumerates one immediate namespace child after the cursor's last returned bytewise name.
KSTATUS NtlResourceEnumerate(SYS_HANDLE session,
SYS_STRING_VIEW directoryPath,
NTL_RESOURCE_ENUM_CURSOR* cursor,
NTL_RESOURCE_ENUM_ENTRY* entryOut) {
if (session == SYS_HANDLE_INVALID || !cursor || !entryOut ||
cursor->NameLength > NTL_RESOURCE_NAME_MAX || cursor->Name[cursor->NameLength] != '\0')
return NTLSTATUS_INVALID_PARAMETER;
memset(entryOut, 0, sizeof(*entryOut));
SYS_STRING_VIEW after = SysSvFromParts(cursor->Name, cursor->NameLength);
uint8_t requestPayload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX + NTL_RESOURCE_NAME_MAX];
uint32_t requestLength = 0;
KSTATUS status = NtlBuildResourceRequest(requestPayload, sizeof(requestPayload), NTL_RESOURCE_OP_ENUMERATE,
directoryPath, after, 0, 0, NTL_RESOURCE_KIND_INVALID,
&requestLength);
if (!KSUCCESS(status)) return status;
uint8_t replyPayload[sizeof(NTL_RESOURCE_REPLY) + NTL_RESOURCE_NAME_MAX];
memset(replyPayload, 0, sizeof(replyPayload));
SYS_PORT_MESSAGE_INFO info;
memset(&info, 0, sizeof(info));
info.Size = sizeof(info);
SYS_CALL_PORT_REQUEST call;
memset(&call, 0, sizeof(call));
call.Size = sizeof(call);
call.EndpointHandle = session;
call.Flags = SYS_PORT_FLAG_NONE;
call.RequestPayload = requestPayload;
call.RequestLength = requestLength;
call.ReplyPayload = replyPayload;
call.ReplyCapacity = sizeof(replyPayload);
call.ReplyInfoOut = &info;
call.TimeoutMilliseconds = SYS_PORT_TIMEOUT_INFINITE;
status = SysCallPort(&call);
if (!KSUCCESS(status)) return status;
if (info.Type != SYS_PORT_MESSAGE_REPLY || info.HandleCount != 0 || info.PayloadLength < sizeof(NTL_RESOURCE_REPLY))
return NTLSTATUS_FAILURE;
NTL_RESOURCE_REPLY reply;
memcpy(&reply, replyPayload, sizeof(reply));
if (reply.Size != sizeof(reply) || reply.Version != NTL_RESOURCE_PROTOCOL_VERSION ||
reply.Operation != NTL_RESOURCE_OP_ENUMERATE || reply.Flags != NTL_RESOURCE_FLAG_NONE ||
reply.ResolvedLength != 0 || reply.NameLength > NTL_RESOURCE_NAME_MAX ||
info.PayloadLength != sizeof(reply) + reply.NameLength)
return NTLSTATUS_FAILURE;
if (!KSUCCESS(reply.Status)) {
if (reply.NameLength != 0)
return NTLSTATUS_FAILURE;
return reply.Status;
}
if (reply.NameLength == 0 || reply.Kind == NTL_RESOURCE_KIND_INVALID)
return NTLSTATUS_FAILURE;
memcpy(entryOut->Name, replyPayload + sizeof(reply), reply.NameLength);
entryOut->Name[reply.NameLength] = '\0';
entryOut->Kind = reply.Kind;
memcpy(cursor->Name, entryOut->Name, reply.NameLength + 1u);
cursor->NameLength = reply.NameLength;
return NTLSTATUS_SUCCESS;
}
// Creates one namespace directory through an administrative resource session.
KSTATUS NtlResourceCreateDirectory(SYS_HANDLE session, SYS_STRING_VIEW path) {
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX];
uint32_t payloadLength = 0;
KSTATUS status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_CREATE_DIRECTORY,
path, SysSvFromParts((const char*)0, 0),
0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
if (!KSUCCESS(status)) return status;
NTL_RESOURCE_REPLY reply;
status = NtlCallResource(session, payload, payloadLength, (const SYS_PORT_HANDLE_TRANSFER*)0, 0,
&reply, (SYS_HANDLE*)0);
if (!KSUCCESS(status)) return status;
if (reply.Operation != NTL_RESOURCE_OP_CREATE_DIRECTORY) return NTLSTATUS_FAILURE;
return reply.Status;
}
// Creates one absolute namespace symbolic link through an administrative resource session.
KSTATUS NtlResourceCreateSymbolicLink(SYS_HANDLE session, SYS_STRING_VIEW path, SYS_STRING_VIEW target) {
KSTATUS status = NtlValidateResourcePath(target);
if (!KSUCCESS(status)) return status;
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX * 2u];
uint32_t payloadLength = 0;
status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_CREATE_SYMBOLIC_LINK,
path, target, 0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
if (!KSUCCESS(status)) return status;
NTL_RESOURCE_REPLY reply;
status = NtlCallResource(session, payload, payloadLength, (const SYS_PORT_HANDLE_TRANSFER*)0, 0,
&reply, (SYS_HANDLE*)0);
if (!KSUCCESS(status)) return status;
if (reply.Operation != NTL_RESOURCE_OP_CREATE_SYMBOLIC_LINK) return NTLSTATUS_FAILURE;
return reply.Status;
}
// Binds an explicitly attenuated capability into an administrative resource session.
KSTATUS NtlResourceBind(SYS_HANDLE session,
SYS_STRING_VIEW path,
@@ -260,14 +367,16 @@ KSTATUS NtlResourceBind(SYS_HANDLE session,
SYS_HANDLE resourceHandle,
SYS_RIGHTS namespaceRights,
SYS_RIGHTS exportRights) {
if (kind == NTL_RESOURCE_KIND_INVALID || resourceHandle == SYS_HANDLE_INVALID ||
if (kind == NTL_RESOURCE_KIND_INVALID || kind == NTL_RESOURCE_KIND_NAMESPACE_DIRECTORY ||
kind == NTL_RESOURCE_KIND_SYMBOLIC_LINK || resourceHandle == SYS_HANDLE_INVALID ||
!(namespaceRights & SYS_RIGHT_TRANSFER) || !exportRights ||
(exportRights & ~namespaceRights) != 0)
return NTLSTATUS_INVALID_PARAMETER;
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX];
uint32_t payloadLength = 0;
KSTATUS status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_BIND,
path, namespaceRights, exportRights, kind, &payloadLength);
path, SysSvFromParts((const char*)0, 0),
namespaceRights, exportRights, kind, &payloadLength);
if (!KSUCCESS(status)) return status;
SYS_PORT_HANDLE_TRANSFER transfer;
@@ -281,12 +390,13 @@ KSTATUS NtlResourceBind(SYS_HANDLE session,
return reply.Status;
}
// Removes one resource name through an administrative session.
// Removes one non-root namespace node through an administrative session.
KSTATUS NtlResourceUnbind(SYS_HANDLE session, SYS_STRING_VIEW path) {
uint8_t payload[sizeof(NTL_RESOURCE_REQUEST) + NTL_RESOURCE_PATH_MAX];
uint32_t payloadLength = 0;
KSTATUS status = NtlBuildResourceRequest(payload, sizeof(payload), NTL_RESOURCE_OP_UNBIND,
path, 0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
path, SysSvFromParts((const char*)0, 0),
0, 0, NTL_RESOURCE_KIND_INVALID, &payloadLength);
if (!KSUCCESS(status)) return status;
NTL_RESOURCE_REPLY reply;