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:
1 parent
899225f551
commit
c0ad63c27f
226 files changed
+6562
-4147
No files matched your search
@@ -187,6 +187,10 @@ static KSTATUS RssrvConsoleMutate(RSSRV_CONSOLE_STATE* console,
|
||||
request->Data.Cursor.Y);
|
||||
break;
|
||||
case NTL_CONSOLE_OP_FILL_CHARACTER:
|
||||
if ((uint8_t)request->Data.FillCharacter.Character > 0x7Fu) {
|
||||
status = NTLSTATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
if (request->Data.FillCharacter.Reserved[0] || request->Data.FillCharacter.Reserved[1] ||
|
||||
request->Data.FillCharacter.Reserved[2]) {
|
||||
status = NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -212,6 +216,10 @@ static KSTATUS RssrvConsoleMutate(RSSRV_CONSOLE_STATE* console,
|
||||
&written);
|
||||
break;
|
||||
case NTL_CONSOLE_OP_PUT_CHARACTER:
|
||||
if ((uint8_t)request->Data.PutCharacter.Character > 0x7Fu) {
|
||||
status = NTLSTATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
if (request->Data.PutCharacter.Reserved[0] || request->Data.PutCharacter.Reserved[1] ||
|
||||
request->Data.PutCharacter.Reserved[2]) {
|
||||
status = NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
@@ -64,7 +64,7 @@ KSTATUS RssrvDisplayQueryConsoleInfo(RSSRV_DISPLAY_STATE* display, SYS_CONSOLE_I
|
||||
}
|
||||
|
||||
// Updates the kernel-backed console cursor through delegated authority.
|
||||
KSTATUS RssrvDisplaySetConsoleCursor(RSSRV_DISPLAY_STATE* display, int x, int y) {
|
||||
KSTATUS RssrvDisplaySetConsoleCursor(RSSRV_DISPLAY_STATE* display, int32_t x, int32_t y) {
|
||||
if (!display || display->Manager == SYS_HANDLE_INVALID)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
return SysSetDisplayManagerConsoleCursor(display->Manager, x, y);
|
||||
@@ -72,7 +72,7 @@ KSTATUS RssrvDisplaySetConsoleCursor(RSSRV_DISPLAY_STATE* display, int x, int y)
|
||||
|
||||
// Fills kernel-backed console characters through delegated authority.
|
||||
KSTATUS RssrvDisplayFillConsoleCharacter(RSSRV_DISPLAY_STATE* display, char character,
|
||||
int x, int y, size_t length, size_t* writtenOut) {
|
||||
int32_t x, int32_t y, size_t length, size_t* writtenOut) {
|
||||
if (!display || display->Manager == SYS_HANDLE_INVALID)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
SYS_FILL_CONSOLE_CHARACTER_REQUEST request;
|
||||
@@ -88,7 +88,7 @@ KSTATUS RssrvDisplayFillConsoleCharacter(RSSRV_DISPLAY_STATE* display, char char
|
||||
|
||||
// Fills kernel-backed console attributes through delegated authority.
|
||||
KSTATUS RssrvDisplayFillConsoleAttribute(RSSRV_DISPLAY_STATE* display, uint16_t attribute,
|
||||
int x, int y, size_t length, size_t* writtenOut) {
|
||||
int32_t x, int32_t y, size_t length, size_t* writtenOut) {
|
||||
if (!display || display->Manager == SYS_HANDLE_INVALID)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST request;
|
||||
@@ -104,7 +104,7 @@ KSTATUS RssrvDisplayFillConsoleAttribute(RSSRV_DISPLAY_STATE* display, uint16_t
|
||||
|
||||
// Draws one explicit glyph through delegated console authority.
|
||||
KSTATUS RssrvDisplayPutConsoleCharacter(RSSRV_DISPLAY_STATE* display, char character,
|
||||
int x, int y, uint32_t foreground, uint32_t background) {
|
||||
int32_t x, int32_t y, uint32_t foreground, uint32_t background) {
|
||||
if (!display || display->Manager == SYS_HANDLE_INVALID)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
SYS_PUT_SCREEN_CHAR_REQUEST request;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RSSRV logical input. The kernel reports normalized physical events; RSSRV owns interpretation, pointer state, and routing.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "rssrv_internal.h"
|
||||
#include <ntlite/port.h>
|
||||
#include <stdlib.h>
|
||||
@@ -35,6 +36,7 @@ static const RSSRV_KEY_CHAR_PAIR gInputCharMap[] = {
|
||||
{ INPUT_KEY_COMMA, ',', '<' }, { INPUT_KEY_PERIOD, '.', '>' },
|
||||
{ INPUT_KEY_SLASH, '/', '?' },
|
||||
{ INPUT_KEY_SPACE, ' ', ' ' }, { INPUT_KEY_TAB, '\t', '\t' },
|
||||
{ INPUT_KEY_ESCAPE, '\x1B', '\x1B' },
|
||||
{ INPUT_KEY_ENTER, '\n', '\n' }, { INPUT_KEY_BACKSPACE, '\b', '\b' },
|
||||
{ INPUT_KEY_KP_DIVIDE, '/', '/' }, { INPUT_KEY_KP_MULTIPLY, '*', '*' },
|
||||
{ INPUT_KEY_KP_MINUS, '-', '-' }, { INPUT_KEY_KP_PLUS, '+', '+' },
|
||||
@@ -57,7 +59,7 @@ static void RssrvInputUnlock(RSSRV_INPUT_STATE* input) {
|
||||
}
|
||||
|
||||
// Tests one logical key bit while the input mutex is held.
|
||||
static int RssrvInputKeyDownLocked(const RSSRV_INPUT_STATE* input, INPUT_KEY key) {
|
||||
static bool RssrvInputKeyDownLocked(const RSSRV_INPUT_STATE* input, INPUT_KEY key) {
|
||||
return key < NTL_INPUT_KEY_BYTES * 8u &&
|
||||
(input->KeyDown[key >> 3] & (uint8_t)(1u << (key & 7u))) != 0;
|
||||
}
|
||||
@@ -70,7 +72,7 @@ static void RssrvInputSetKeyDownLocked(RSSRV_INPUT_STATE* input, INPUT_KEY key,
|
||||
}
|
||||
|
||||
// Returns whether duplicate physical make events should generate repeated logical key records.
|
||||
static int RssrvInputKeyIsRepeatable(INPUT_KEY key) {
|
||||
static bool RssrvInputKeyIsRepeatable(INPUT_KEY key) {
|
||||
switch (key) {
|
||||
case INPUT_KEY_NONE:
|
||||
case INPUT_KEY_LEFT_SHIFT:
|
||||
@@ -83,9 +85,9 @@ static int RssrvInputKeyIsRepeatable(INPUT_KEY key) {
|
||||
case INPUT_KEY_RIGHT_GUI:
|
||||
case INPUT_KEY_CAPS_LOCK:
|
||||
case INPUT_KEY_NUM_LOCK:
|
||||
return 0;
|
||||
return false;
|
||||
default:
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,15 +249,15 @@ static void RssrvInputRepeatThread(uintptr_t argument) {
|
||||
// Applies one normalized relative mouse event and lets Session 0 own cursor and target routing policy.
|
||||
static void RssrvInputApplyMouse(RSSRV_INPUT_STATE* input, const INPUT_MOUSE_EVENT* event) {
|
||||
if (!input || !event) return;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int changed = 0;
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
bool changed = false;
|
||||
if (!KSUCCESS(RssrvInputLock(input))) return;
|
||||
|
||||
int nx = input->MouseX + event->dx;
|
||||
int ny = input->MouseY + event->dy;
|
||||
int width = input->MouseWidth > 0 ? input->MouseWidth : 1;
|
||||
int height = input->MouseHeight > 0 ? input->MouseHeight : 1;
|
||||
int32_t nx = input->MouseX + event->dx;
|
||||
int32_t ny = input->MouseY + event->dy;
|
||||
int32_t width = input->MouseWidth > 0 ? input->MouseWidth : 1;
|
||||
int32_t height = input->MouseHeight > 0 ? input->MouseHeight : 1;
|
||||
if (nx < 0) nx = 0;
|
||||
if (ny < 0) ny = 0;
|
||||
if (nx >= width) nx = width - 1;
|
||||
@@ -313,7 +315,7 @@ static void RssrvInputRawThread(uintptr_t argument) {
|
||||
|
||||
// Reads or peeks one logical keyboard record, blocking on the queue event when requested.
|
||||
KSTATUS RssrvInputReadKeyRecord(RSSRV_INPUT_STATE* input,
|
||||
int peek,
|
||||
bool peek,
|
||||
uint64_t timeoutMilliseconds,
|
||||
INPUT_KEY_RECORD* recordOut) {
|
||||
if (!input || !recordOut) return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -351,7 +353,7 @@ KSTATUS RssrvInputFlushKeys(RSSRV_INPUT_STATE* input, uint32_t* discardedOut) {
|
||||
|
||||
// Reads or peeks one logical mouse record, blocking on the queue event when requested.
|
||||
static KSTATUS RssrvInputGetMouse(RSSRV_INPUT_STATE* input,
|
||||
int peek,
|
||||
bool peek,
|
||||
uint64_t timeoutMilliseconds,
|
||||
INPUT_MOUSE_EVENT* eventOut) {
|
||||
if (!input || !eventOut) return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -470,12 +472,12 @@ static void RssrvInputSessionThread(uintptr_t argument) {
|
||||
memset(&state, 0, sizeof(state));
|
||||
switch (request.Operation) {
|
||||
case NTL_INPUT_OP_READ_KEY:
|
||||
status = RssrvInputReadKeyRecord(input, 0, request.TimeoutMilliseconds, &key);
|
||||
status = RssrvInputReadKeyRecord(input, false, request.TimeoutMilliseconds, &key);
|
||||
(void)RssrvInputReply(endpoint, info.MessageId, request.Operation, status,
|
||||
KSUCCESS(status) ? &key : 0, 0, 0);
|
||||
break;
|
||||
case NTL_INPUT_OP_PEEK_KEY:
|
||||
status = RssrvInputReadKeyRecord(input, 1, request.TimeoutMilliseconds, &key);
|
||||
status = RssrvInputReadKeyRecord(input, true, request.TimeoutMilliseconds, &key);
|
||||
(void)RssrvInputReply(endpoint, info.MessageId, request.Operation, status,
|
||||
KSUCCESS(status) ? &key : 0, 0, 0);
|
||||
break;
|
||||
|
||||
@@ -259,7 +259,8 @@ KSTATUS RssrvNamespaceInitialize(RSSRV_NAMESPACE* namespaceState) {
|
||||
|
||||
// Validates one canonical absolute native resource path, including the root path "/".
|
||||
KSTATUS RssrvNamespaceValidatePath(const char* path, uint32_t length) {
|
||||
if (!path || length == 0 || length > NTL_RESOURCE_PATH_MAX || path[0] != '/')
|
||||
if (!path || length == 0 || length > NTL_RESOURCE_PATH_MAX || path[0] != '/' ||
|
||||
!SysSvIsUtf8Text(SysSvFromParts(path, length)))
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (length == 1)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RSSRV resource protocol listeners, sessions, request validation, and capability transfer.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "rssrv_internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -7,7 +8,7 @@
|
||||
typedef struct RSSRV_SESSION {
|
||||
RSSRV_RESOURCE_SERVICE* Service;
|
||||
SYS_HANDLE Endpoint;
|
||||
uint32_t Administrative;
|
||||
bool Administrative;
|
||||
} RSSRV_SESSION;
|
||||
|
||||
// Replies with one fixed resource-protocol reply and no handle transfer.
|
||||
@@ -317,6 +318,11 @@ static uint32_t RssrvDispatchRequest(RSSRV_RESOURCE_SERVICE* service,
|
||||
NTLSTATUS_INVALID_PARAMETER, NTL_RESOURCE_KIND_INVALID);
|
||||
return 0;
|
||||
}
|
||||
if (!SysSvIsUtf8Text(SysSvFromParts(aux, request.AuxLength))) {
|
||||
(void)RssrvReplyStatus(endpoint, info->MessageId, operation,
|
||||
NTLSTATUS_INVALID_PARAMETER, NTL_RESOURCE_KIND_INVALID);
|
||||
return 0;
|
||||
}
|
||||
for (uint32_t i = 0; i < request.AuxLength; ++i) {
|
||||
if (aux[i] == '/' || aux[i] == '\\' || aux[i] == '\0') {
|
||||
(void)RssrvReplyStatus(endpoint, info->MessageId, operation,
|
||||
|
||||
@@ -21,7 +21,7 @@ void RssrvSetCurrentThreadName(const char* name) {
|
||||
}
|
||||
|
||||
// Terminates RSSRV without depending on a compiler runtime return path.
|
||||
void RssrvExit(int code) {
|
||||
void RssrvExit(int32_t code) {
|
||||
for (;;) SysExitProcess(code);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <ntlite/console_service.h>
|
||||
#include <ntlite/syscall.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define RSSRV_LISTENER_BACKLOG 16u
|
||||
#define RSSRV_SYMBOLIC_LINK_MAX_DEPTH 16u
|
||||
@@ -49,7 +50,7 @@ typedef struct RSSRV_NAMESPACE_BINDING_VIEW {
|
||||
uint32_t Kind;
|
||||
SYS_RIGHTS ExportRights;
|
||||
uint32_t ResolvedLength;
|
||||
uint32_t Locked;
|
||||
bool Locked;
|
||||
} RSSRV_NAMESPACE_BINDING_VIEW;
|
||||
|
||||
typedef struct RSSRV_NAMESPACE_ENTRY {
|
||||
@@ -135,7 +136,7 @@ typedef struct RSSRV_VOLUME_STATE {
|
||||
typedef struct RSSRV_LISTENER_WORKER {
|
||||
RSSRV_RESOURCE_SERVICE* Service;
|
||||
SYS_HANDLE Listener;
|
||||
uint32_t Administrative;
|
||||
bool Administrative;
|
||||
} RSSRV_LISTENER_WORKER;
|
||||
|
||||
struct RSSRV_RESOURCE_SERVICE {
|
||||
@@ -160,7 +161,7 @@ typedef struct RSSRV_STATE {
|
||||
void RssrvSetCurrentThreadName(const char* name);
|
||||
|
||||
// Terminates RSSRV without depending on a compiler runtime return path.
|
||||
void RssrvExit(int code);
|
||||
void RssrvExit(int32_t code);
|
||||
|
||||
// Initializes the native namespace root and its synchronization object.
|
||||
KSTATUS RssrvNamespaceInitialize(RSSRV_NAMESPACE* namespaceState);
|
||||
@@ -230,13 +231,13 @@ KSTATUS RssrvDisplayPublishDevice(RSSRV_DISPLAY_STATE* display);
|
||||
KSTATUS RssrvDisplayQueryInfo(RSSRV_DISPLAY_STATE* display, SYS_DISPLAY_INFO* infoOut);
|
||||
KSTATUS RssrvDisplayWriteConsole(RSSRV_DISPLAY_STATE* display, const char* data, size_t length);
|
||||
KSTATUS RssrvDisplayQueryConsoleInfo(RSSRV_DISPLAY_STATE* display, SYS_CONSOLE_INFO* infoOut);
|
||||
KSTATUS RssrvDisplaySetConsoleCursor(RSSRV_DISPLAY_STATE* display, int x, int y);
|
||||
KSTATUS RssrvDisplaySetConsoleCursor(RSSRV_DISPLAY_STATE* display, int32_t x, int32_t y);
|
||||
KSTATUS RssrvDisplayFillConsoleCharacter(RSSRV_DISPLAY_STATE* display, char character,
|
||||
int x, int y, size_t length, size_t* writtenOut);
|
||||
int32_t x, int32_t y, size_t length, size_t* writtenOut);
|
||||
KSTATUS RssrvDisplayFillConsoleAttribute(RSSRV_DISPLAY_STATE* display, uint16_t attribute,
|
||||
int x, int y, size_t length, size_t* writtenOut);
|
||||
int32_t x, int32_t y, size_t length, size_t* writtenOut);
|
||||
KSTATUS RssrvDisplayPutConsoleCharacter(RSSRV_DISPLAY_STATE* display, char character,
|
||||
int x, int y, uint32_t foreground, uint32_t background);
|
||||
int32_t x, int32_t y, uint32_t foreground, uint32_t background);
|
||||
KSTATUS RssrvDisplayClearConsole(RSSRV_DISPLAY_STATE* display, uint32_t color);
|
||||
|
||||
// Initializes Session 0, input routing, and display ownership.
|
||||
@@ -266,7 +267,7 @@ KSTATUS RssrvInputInitialize(RSSRV_INPUT_STATE* input,
|
||||
RSSRV_SESSION_STATE* session,
|
||||
SYS_HANDLE manager);
|
||||
KSTATUS RssrvInputStart(RSSRV_INPUT_STATE* input);
|
||||
KSTATUS RssrvInputReadKeyRecord(RSSRV_INPUT_STATE* input, int peek,
|
||||
KSTATUS RssrvInputReadKeyRecord(RSSRV_INPUT_STATE* input, bool peek,
|
||||
uint64_t timeoutMilliseconds, INPUT_KEY_RECORD* recordOut);
|
||||
KSTATUS RssrvInputFlushKeys(RSSRV_INPUT_STATE* input, uint32_t* discardedOut);
|
||||
|
||||
@@ -296,7 +297,7 @@ KSTATUS RssrvVolumesQueryPublishedPath(RSSRV_VOLUME_STATE* volumes,
|
||||
KSTATUS RssrvVolumesStartWorker(RSSRV_VOLUME_STATE* volumes);
|
||||
|
||||
// Returns whether a path belongs to the RSSRV-owned automatic mounted-volume naming family.
|
||||
int RssrvVolumesOwnPath(const char* path, uint32_t length);
|
||||
bool RssrvVolumesOwnPath(const char* path, uint32_t length);
|
||||
|
||||
// Initializes the public/admin resource protocol component around existing namespace state.
|
||||
KSTATUS RssrvResourceInitialize(RSSRV_RESOURCE_SERVICE* service,
|
||||
|
||||
@@ -106,7 +106,9 @@ static void RssrvSessionReplyDwm(SYS_HANDLE endpoint,
|
||||
// Applies one DWM focus/capture request while preserving RSSRV as the session authority owner.
|
||||
static KSTATUS RssrvSessionApplyDwmRequest(RSSRV_SESSION_STATE* session,
|
||||
const NTL_SESSION_DWM_REQUEST* request) {
|
||||
if (!session || !request || request->Enabled > 1u) return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (!session || !request ||
|
||||
((const uint8_t*)request)[offsetof(NTL_SESSION_DWM_REQUEST, Enabled)] > 1u)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
KSTATUS status = RssrvSessionLock(session);
|
||||
if (!KSUCCESS(status)) return status;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RSSRV mounted-volume publication and /Device/HarddiskVolumeN synchronization.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "rssrv_internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -23,12 +24,12 @@ static RSSRV_VOLUME_PUBLICATION* RssrvFindPublishedVolume(RSSRV_VOLUME_STATE* vo
|
||||
}
|
||||
|
||||
// Returns whether one kernel volume instance is present in the current manager snapshot.
|
||||
static int RssrvSnapshotContainsVolume(const SYS_VOLUME_INFO* snapshot, uint32_t count, uint32_t instanceId) {
|
||||
static bool RssrvSnapshotContainsVolume(const SYS_VOLUME_INFO* snapshot, uint32_t count, uint32_t instanceId) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
if (snapshot[i].InstanceId == instanceId)
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Builds one RSSRV-local /Device/HarddiskVolumeN name without introducing a formatting-runtime dependency.
|
||||
@@ -272,7 +273,7 @@ KSTATUS RssrvVolumesStartWorker(RSSRV_VOLUME_STATE* volumes) {
|
||||
}
|
||||
|
||||
// Returns whether a path belongs to the RSSRV-owned automatic mounted-volume naming family.
|
||||
int RssrvVolumesOwnPath(const char* path, uint32_t length) {
|
||||
bool RssrvVolumesOwnPath(const char* path, uint32_t length) {
|
||||
static const char prefix[] = "/Device/HarddiskVolume";
|
||||
uint32_t prefixLength = (uint32_t)(sizeof(prefix) - 1u);
|
||||
return path && length >= prefixLength && memcmp(path, prefix, prefixLength) == 0;
|
||||
|
||||
Reference in new issue
Block a user