rewrite init to restart failed processes, add file renaming, directory creation, directory renaming, directory removal, add process killing, unify shells, readme changes.

This commit is contained in:
maksw committed 2026-05-13 10:41:48 +02:00
1 parent f80e66ecde
commit ddb074f0e0
16 files changed
+476 -641

No files matched your search

+71
View File
@@ -1177,6 +1177,72 @@ static uint64_t SyscallNamedQueueOwnerPid(uint64_t a0, uint64_t a1, uint64_t a2,
return STATUS_NOT_FOUND;
}
static uint64_t SyscallKillProcess(uint64_t a0, uint64_t a1, uint64_t a2,
uint64_t a3, uint64_t a4, uint64_t a5) {
(void)a2; (void)a3; (void)a4; (void)a5;
PROCESS* proc = KeGetProcessById((uint32_t)a0);
if (!proc) return STATUS_NOT_FOUND;
THREAD* self = KeGetCurrentThread();
int exitCode = (int)a1;
if (self && self->Owner == proc) {
KeExitProcess(proc, exitCode);
ObDereferenceObject(&proc->Header);
KeExitThread(self, exitCode);
while (true) ;
}
KeExitProcess(proc, exitCode);
ObDereferenceObject(&proc->Header);
return STATUS_SUCCESS;
}
// ---------------------------------------------------------------------------
// SYS_GET_PROCESS_LIST (65) a0=*pidsOut a1=maxCount a2=*countOut
// ---------------------------------------------------------------------------
static uint64_t SyscallGetProcessList(uint64_t a0, uint64_t a1, uint64_t a2,
uint64_t a3, uint64_t a4, uint64_t a5) {
(void)a3; (void)a4; (void)a5;
uint32_t* pidsOut = (uint32_t*)(uintptr_t)a0;
size_t maxCount = (size_t)a1;
size_t* countOut = (size_t*)(uintptr_t)a2;
size_t count = KeCopyProcessIds(pidsOut, maxCount);
if (countOut) *countOut = count;
return STATUS_SUCCESS;
}
// ---------------------------------------------------------------------------
// SYS_RENAME_FILE (66) a0=*oldPath a1=*newPath
// ---------------------------------------------------------------------------
static uint64_t SyscallRenameFile(uint64_t a0, uint64_t a1, uint64_t a2,
uint64_t a3, uint64_t a4, uint64_t a5) {
(void)a2; (void)a3; (void)a4; (void)a5;
const char* oldPath = (const char*)(uintptr_t)a0;
const char* newPath = (const char*)(uintptr_t)a1;
if (!oldPath || !newPath) return STATUS_INVALID_PARAMETER;
return IoRenameFile(oldPath, newPath);
}
// ---------------------------------------------------------------------------
// SYS_CREATE_DIR (67) a0=*path
// ---------------------------------------------------------------------------
static uint64_t SyscallCreateDir(uint64_t a0, uint64_t a1, uint64_t a2,
uint64_t a3, uint64_t a4, uint64_t a5) {
(void)a1; (void)a2; (void)a3; (void)a4; (void)a5;
const char* path = (const char*)(uintptr_t)a0;
if (!path) return STATUS_INVALID_PARAMETER;
return IoCreateDir(path);
}
// ---------------------------------------------------------------------------
// SYS_REMOVE_DIR (68) a0=*path
// ---------------------------------------------------------------------------
static uint64_t SyscallRemoveDir(uint64_t a0, uint64_t a1, uint64_t a2,
uint64_t a3, uint64_t a4, uint64_t a5) {
(void)a1; (void)a2; (void)a3; (void)a4; (void)a5;
const char* path = (const char*)(uintptr_t)a0;
if (!path) return STATUS_INVALID_PARAMETER;
return IoRemoveDir(path);
}
// ===========================================================================
// Dispatch table - index must match SYS_* in syscall_nr.h exactly.
// ===========================================================================
@@ -1248,6 +1314,11 @@ static const SYSCALL_HANDLER gSyscallTable[SYS_MAX] = {
/* 61 SYS_OPEN_NAMED_QUEUE */ SyscallOpenNamedQueue,
/* 62 SYS_QUEUE_DUPLICATE */ SyscallQueueDuplicate,
/* 63 SYS_NAMED_QUEUE_OWNER_PID */ SyscallNamedQueueOwnerPid,
/* 64 SYS_KILL_PROCESS */ SyscallKillProcess,
/* 65 SYS_GET_PROCESS_LIST */ SyscallGetProcessList,
/* 66 SYS_RENAME_FILE */ SyscallRenameFile,
/* 67 SYS_CREATE_DIR */ SyscallCreateDir,
/* 68 SYS_REMOVE_DIR */ SyscallRemoveDir,
};
// ---------------------------------------------------------------------------