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
+12
-10
@@ -1,5 +1,7 @@
|
||||
// Native userspace path policy. RSSRV resolves global resource prefixes; kernel I/O sees only capabilities and relative paths.
|
||||
|
||||
#include <ntlite/atomic.h>
|
||||
#include <intrin.h>
|
||||
#include <ntlite/path.h>
|
||||
#include <ntlite/resource.h>
|
||||
#include <string.h>
|
||||
@@ -14,49 +16,49 @@ typedef struct NTL_RESOLVED_ROOT {
|
||||
size_t ResolvedLength;
|
||||
} NTL_RESOLVED_ROOT;
|
||||
|
||||
static volatile long gPathState;
|
||||
static volatile long gPathLock;
|
||||
static volatile int32_t gPathState;
|
||||
static volatile int32_t gPathLock;
|
||||
static char gCurrentDirectory[SYS_PATH_MAX + 1u];
|
||||
static size_t gCurrentDirectoryLength;
|
||||
static size_t gCurrentDirectoryRootLength;
|
||||
|
||||
// Acquires the tiny userspace CWD lock without introducing a kernel object.
|
||||
static void NtlpLockPathState(void) {
|
||||
while (_InterlockedCompareExchange(&gPathLock, 1, 0) != 0)
|
||||
while (NtlAtomicCompareExchange32(&gPathLock, 1, 0) != 0)
|
||||
(void)SysYield();
|
||||
}
|
||||
|
||||
// Releases the userspace CWD lock.
|
||||
static void NtlpUnlockPathState(void) {
|
||||
_InterlockedExchange(&gPathLock, 0);
|
||||
NtlAtomicExchange32(&gPathLock, 0);
|
||||
}
|
||||
|
||||
// Initializes the process-local CWD from opaque loader data, or /SystemRoot for bootstrap init.
|
||||
static KSTATUS NtlpEnsurePathState(void) {
|
||||
if (_InterlockedCompareExchange(&gPathState, 2, 2) == 2)
|
||||
if (NtlAtomicCompareExchange32(&gPathState, 2, 2) == 2)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
if (_InterlockedCompareExchange(&gPathState, 1, 0) == 0) {
|
||||
if (NtlAtomicCompareExchange32(&gPathState, 1, 0) == 0) {
|
||||
SYS_STRING_VIEW inherited;
|
||||
KSTATUS status = NtlpGetLoaderCurrentDirectory(&inherited);
|
||||
if (!KSUCCESS(status))
|
||||
inherited = SYS_SV_LITERAL("/SystemRoot");
|
||||
if (!SysSvIsValid(inherited) || inherited.Length == 0 || inherited.Length > SYS_PATH_MAX ||
|
||||
inherited.Data[0] != '/' || SysSvContainsByte(inherited, '\\') || SysSvContainsByte(inherited, '\0')) {
|
||||
_InterlockedExchange(&gPathState, 0);
|
||||
NtlAtomicExchange32(&gPathState, 0);
|
||||
return NTLSTATUS_FAILURE;
|
||||
}
|
||||
memcpy(gCurrentDirectory, inherited.Data, inherited.Length);
|
||||
gCurrentDirectory[inherited.Length] = '\0';
|
||||
gCurrentDirectoryLength = inherited.Length;
|
||||
gCurrentDirectoryRootLength = 0;
|
||||
_InterlockedExchange(&gPathState, 2);
|
||||
NtlAtomicExchange32(&gPathState, 2);
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
while (_InterlockedCompareExchange(&gPathState, 2, 2) == 1)
|
||||
while (NtlAtomicCompareExchange32(&gPathState, 2, 2) == 1)
|
||||
(void)SysYield();
|
||||
return _InterlockedCompareExchange(&gPathState, 2, 2) == 2
|
||||
return NtlAtomicCompareExchange32(&gPathState, 2, 2) == 2
|
||||
? NTLSTATUS_SUCCESS : NTLSTATUS_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user