refactor syscall ABI and FAT32 driver to use request structs and string views natively, enforce handle access rights on object lookup, add scheduler statistics tracking, fix KiSchedule to prevent 50% idle throttling on CPU-bound threads, better document x64 initial user stack alignment, fix process teardown to properly signal exit events and manage thread counts, optimize doom file I/O with a custom handle struct to internally track position and size, add SubsystemData to TEB for generic thread-local state, apply PAGE_NX to non-executable PE sections in the loader, update native apps, tests, and shells to match new APIs, update kernel32 directory retrieval.
This commit is contained in:
1 parent
603fbdfab1
commit
e1248f4afe
43 files changed
+2892
-1857
No files matched your search
@@ -10,7 +10,37 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Output helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
static void print(const char* s) { SysWriteConsole(s, strlen(s)); }
|
||||
static void print(const char* s) { SYS_WRITE_CONSOLE_REQUEST req = { SysSvFromCstr(s) }; SysWriteConsole(&req); }
|
||||
|
||||
static uint32_t open_file(const char* path, uint32_t* handleOut) {
|
||||
SYS_PATH_HANDLE_REQUEST req = { SysSvFromCstr(path), handleOut };
|
||||
return SysOpenFile(&req);
|
||||
}
|
||||
|
||||
static uint32_t create_file(const char* path, uint32_t* handleOut) {
|
||||
SYS_PATH_HANDLE_REQUEST req = { SysSvFromCstr(path), handleOut };
|
||||
return SysCreateFile(&req);
|
||||
}
|
||||
|
||||
static uint32_t open_dir(const char* path, uint32_t* handleOut) {
|
||||
SYS_PATH_HANDLE_REQUEST req = { SysSvFromCstr(path), handleOut };
|
||||
return SysOpenDir(&req);
|
||||
}
|
||||
|
||||
static uint32_t set_cwd(const char* path) {
|
||||
SYS_PATH_REQUEST req = { SysSvFromCstr(path) };
|
||||
return SysSetCwd(&req);
|
||||
}
|
||||
|
||||
static uint32_t delete_file(const char* path) {
|
||||
SYS_PATH_REQUEST req = { SysSvFromCstr(path) };
|
||||
return SysDeleteFile(&req);
|
||||
}
|
||||
|
||||
static uint32_t create_process(const char* path, uint32_t* handleOut, const char* cmdline) {
|
||||
SYS_CREATE_PROCESS_REQUEST req = { SysSvFromCstr(path), SysSvFromCstr(cmdline), handleOut };
|
||||
return SysCreateProcess(&req);
|
||||
}
|
||||
|
||||
static void printUInt(uint32_t n) {
|
||||
char buf[12]; int i = 0;
|
||||
@@ -101,7 +131,7 @@ static void cmd_write(const char* args) {
|
||||
filename[i] = '\0';
|
||||
if (args[i] == '\0' || args[i+1] == '\0') { print("write: usage: write <filename> <text>\n"); return; }
|
||||
uint32_t hFile;
|
||||
if (SysCreateFile(filename, &hFile) != 0) { print("write: could not create file\n"); return; }
|
||||
if (create_file(filename, &hFile) != 0) { print("write: could not create file\n"); return; }
|
||||
size_t written;
|
||||
SysWriteFile(hFile, args + i + 1, strlen(args + i + 1), &written);
|
||||
SysCloseHandle(hFile);
|
||||
@@ -112,7 +142,7 @@ static void cmd_dir(const char* path) {
|
||||
uint32_t hDir;
|
||||
const char* target = (path && *path != '\0') ? path : ".";
|
||||
|
||||
if (SysOpenDir(target, &hDir) != 0) {
|
||||
if (open_dir(target, &hDir) != 0) {
|
||||
print("dir: failed to open directory\n");
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +172,7 @@ static void cmd_dir(const char* path) {
|
||||
|
||||
static void cmd_type(const char* filename) {
|
||||
uint32_t hFile;
|
||||
if (SysOpenFile(filename, &hFile) != 0) { print("type: cannot open file\n"); return; }
|
||||
if (open_file(filename, &hFile) != 0) { print("type: cannot open file\n"); return; }
|
||||
char buffer[512]; size_t bytesRead;
|
||||
while (SysReadFile(hFile, buffer, sizeof(buffer) - 1, &bytesRead) == 0 && bytesRead > 0) {
|
||||
buffer[bytesRead] = '\0'; print(buffer);
|
||||
@@ -183,8 +213,8 @@ static int runCommand(const char* cmd) {
|
||||
if (strcmp(cmd, "mem") == 0) { cmd_mem(); return 0; }
|
||||
if (strcmp(cmd, "dir") == 0) { cmd_dir("."); return 0; }
|
||||
if (strncmp(cmd, "dir ", 4) == 0) { cmd_dir(cmd + 4); return 0; }
|
||||
if (strncmp(cmd, "cd ", 3) == 0) { if (SysSetCwd(cmd + 3) != 0) print("cd: failed\n"); return 0; }
|
||||
if (strncmp(cmd, "del ", 4) == 0) { SysDeleteFile(cmd + 4); return 0; }
|
||||
if (strncmp(cmd, "cd ", 3) == 0) { if (set_cwd(cmd + 3) != 0) print("cd: failed\n"); return 0; }
|
||||
if (strncmp(cmd, "del ", 4) == 0) { delete_file(cmd + 4); return 0; }
|
||||
if (strncmp(cmd, "type ", 5) == 0) { cmd_type(cmd + 5); return 0; }
|
||||
if (strncmp(cmd, "write ", 6) == 0) { cmd_write(cmd + 6); return 0; }
|
||||
|
||||
@@ -192,7 +222,7 @@ static int runCommand(const char* cmd) {
|
||||
if (!extractProgramPath(cmd, program, sizeof(program))) return 0;
|
||||
|
||||
uint32_t hProc;
|
||||
if (SysCreateProcess(program, &hProc, cmd) == 0) {
|
||||
if (create_process(program, &hProc, cmd) == 0) {
|
||||
SysWaitForProcess(hProc);
|
||||
SysCloseHandle(hProc);
|
||||
while (SysKbPoll()) (void)SysKbReadChar();
|
||||
@@ -201,7 +231,7 @@ static int runCommand(const char* cmd) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
const char* cmdline = SysGetPeb()->CommandLine;
|
||||
const char* cmdline = SysGetPeb()->CommandLine.Data;
|
||||
char lineBuf[MAX_CMD];
|
||||
|
||||
print("shell: command line: ");
|
||||
|
||||
Reference in new issue
Block a user