add doom, disable warnings as errors, massive speedups in the fat32 driver, HAL_KEYBOARD Poll now returns the key and added IsKeyDown used by GetAsyncKeyState, slight upgrade in hal_main drain and pray, more accurate QueryTicks and by that GetTickCount, add GetTickCount64, boot.ini now dictates what executable should init launch, not the kernel, LaunchUserProcess in kmain.c now takes an argument, rearrange syscall numbers, add SysKbIsKeyDown syscall, use include windows.h over manual definitions, add fictional win32 api ClearConsoleScreenBuffer and real FlushConsoleInputBuffer and a clear command to the shell, print exit codes as signed int, StretchDIBits now can stretch, runa.bat now gives 256 MB.
This commit is contained in:
1 parent
cdf7ed4cea
commit
0c7f461c6d
24 files changed
+50236
-1310
No files matched your search
+80
-66
@@ -102,14 +102,14 @@ static uint64_t SyscallExitProcess(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_EXIT_THREAD (true) a0 = exitCode
|
||||
// SYS_EXIT_THREAD (1) a0 = exitCode
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallExitThread(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;
|
||||
THREAD* t = KeGetCurrentThread();
|
||||
if (t) KeExitThread(t, (int)a0);
|
||||
while (true) ;
|
||||
while (true);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -485,7 +485,7 @@ static uint64_t SyscallReadFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_WRITE_FILE (43) a0=handle a1=buf a2=size a3=*bytesWrittenOut
|
||||
// SYS_WRITE_FILE (29) a0=handle a1=buf a2=size a3=*bytesWrittenOut
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallWriteFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -501,7 +501,7 @@ static uint64_t SyscallWriteFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_CREATE_FILE (44) a0=*path a1=*handleOut
|
||||
// SYS_CREATE_FILE (30) a0=*path a1=*handleOut
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallCreateFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -521,7 +521,7 @@ static uint64_t SyscallCreateFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_DELETE_FILE (45) a0=*path
|
||||
// SYS_DELETE_FILE (31) a0=*path
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallDeleteFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -531,7 +531,7 @@ static uint64_t SyscallDeleteFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_TRUNCATE_FILE (46) a0=handle a1=newSize
|
||||
// SYS_TRUNCATE_FILE (32) a0=handle a1=newSize
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallTruncateFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -544,7 +544,7 @@ static uint64_t SyscallTruncateFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_GET_FILE_POS (47) a0=handle -> current seek offset
|
||||
// SYS_GET_FILE_POS (33) a0=handle -> current seek offset
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallGetFilePos(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -557,7 +557,7 @@ static uint64_t SyscallGetFilePos(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_SEEK_FILE (29) a0=handle a1=offset
|
||||
// SYS_SEEK_FILE (34) a0=handle a1=offset
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallSeekFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -570,7 +570,7 @@ static uint64_t SyscallSeekFile(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_GET_FILE_SIZE (30) a0=handle -> uint64_t
|
||||
// SYS_GET_FILE_SIZE (35) a0=handle -> uint64_t
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallGetFileSize(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -583,7 +583,7 @@ static uint64_t SyscallGetFileSize(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_SCREEN_BLIT (31) a0=x a1=y a2=w a3=h a4=*pixels
|
||||
// SYS_SCREEN_BLIT (36) a0=x a1=y a2=w a3=h a4=*pixels
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallScreenBlit(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -595,7 +595,7 @@ static uint64_t SyscallScreenBlit(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_SCREEN_CLEAR (32) a0=color
|
||||
// SYS_SCREEN_CLEAR (37) a0=color
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallScreenClear(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -606,7 +606,7 @@ static uint64_t SyscallScreenClear(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_SCREEN_GET_SIZE (33) a0=*widthOut a1=*heightOut
|
||||
// SYS_SCREEN_GET_SIZE (38) a0=*widthOut a1=*heightOut
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallScreenGetSize(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -620,7 +620,7 @@ static uint64_t SyscallScreenGetSize(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_SCREEN_PUT_CHAR (34) a0=c a1=x a2=y a3=fg a4=bg
|
||||
// SYS_SCREEN_PUT_CHAR (39) a0=c a1=x a2=y a3=fg a4=bg
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallScreenPutChar(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -632,17 +632,30 @@ static uint64_t SyscallScreenPutChar(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_KB_POLL (35) -> 1 or 0
|
||||
// SYS_KB_POLL (40) -> 1 or 0
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallKbPoll(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
(void)a0; (void)a1; (void)a2; (void)a3; (void)a4; (void)a5;
|
||||
if (!gHal) return 0;
|
||||
return gHal->Keyboard.Poll() ? 1u : 0u;
|
||||
return gHal->Keyboard.Poll();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_KB_READ_CHAR (36) -> char (blocks, yields while waiting)
|
||||
// SYS_KB_IS_KEY_DOWN (41) a0=scancode a1=extended -> 1 or 0
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallKbIsKeyDown(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;
|
||||
|
||||
// Check gHal and ensure the HAL struct actually has the new function pointer
|
||||
if (!gHal || !gHal->Keyboard.IsKeyDown) return 0;
|
||||
|
||||
return gHal->Keyboard.IsKeyDown((uint8_t)a0, (bool)a1) ? 1u : 0u;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_KB_READ_CHAR (42) -> char (blocks, yields while waiting)
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallKbReadChar(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -653,7 +666,7 @@ static uint64_t SyscallKbReadChar(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_KB_READ_SCANCODE (37) -> uint8_t (blocks, yields while waiting)
|
||||
// SYS_KB_READ_SCANCODE (43) -> uint8_t (blocks, yields while waiting)
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallKbReadScancode(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -664,7 +677,7 @@ static uint64_t SyscallKbReadScancode(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_KB_GET_MODIFIERS (43) -> uint32_t
|
||||
// SYS_KB_GET_MODIFIERS (44) -> uint32_t
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallKbGetModifiers(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -674,7 +687,7 @@ static uint64_t SyscallKbGetModifiers(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_MOUSE_POLL (44) -> 1 or 0
|
||||
// SYS_MOUSE_POLL (45) -> 1 or 0
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallMousePoll(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -684,7 +697,7 @@ static uint64_t SyscallMousePoll(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_MOUSE_READ (45) a0=*dx a1=*dy a2=*buttons -> 1 or 0
|
||||
// SYS_MOUSE_READ (46) a0=*dx a1=*dy a2=*buttons -> 1 or 0
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallMouseRead(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -696,7 +709,7 @@ static uint64_t SyscallMouseRead(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_MOUSE_GET_POS (46) a0=*x a1=*y
|
||||
// SYS_MOUSE_GET_POS (47) a0=*x a1=*y
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallMouseGetPos(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -707,7 +720,7 @@ static uint64_t SyscallMouseGetPos(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_GET_TICK (47) -> uint64_t milliseconds
|
||||
// SYS_GET_TICK (48) -> uint64_t milliseconds
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallGetTick(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -716,7 +729,7 @@ static uint64_t SyscallGetTick(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_DEBUG_PRINT (39) a0=*str
|
||||
// SYS_DEBUG_PRINT (49) a0=*str
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallDebugPrint(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -726,7 +739,7 @@ static uint64_t SyscallDebugPrint(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_CREATE_PROCESS (40) a0=*path a1=*handleOut a2=*cmdline (optional)
|
||||
// SYS_CREATE_PROCESS (50) a0=*path a1=*handleOut a2=*cmdline (optional)
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallCreateProcess(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -798,7 +811,7 @@ static uint64_t SyscallCreateProcess(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_WAIT_FOR_PROCESS (41) a0=handle
|
||||
// SYS_WAIT_FOR_PROCESS (51) a0=handle
|
||||
// Blocks until the target process signals its ExitEvent.
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallWaitForProcess(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
@@ -814,7 +827,7 @@ static uint64_t SyscallWaitForProcess(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_GET_PROCESS_EXIT_CODE (42) a0=handle a1=*exitCodeOut
|
||||
// SYS_GET_PROCESS_EXIT_CODE (52) a0=handle a1=*exitCodeOut
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallGetProcessExitCode(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -830,7 +843,7 @@ static uint64_t SyscallGetProcessExitCode(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_WRITE_CONSOLE (48) a0=*buf a1=len
|
||||
// SYS_WRITE_CONSOLE (53) a0=*buf a1=len
|
||||
// Writes user console text in white; distinct from green SYS_DEBUG_PRINT.
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallWriteConsole(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
@@ -843,7 +856,7 @@ static uint64_t SyscallWriteConsole(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_OPEN_DIR (49) a0=*dirPath a1=*handleOut
|
||||
// SYS_OPEN_DIR (54) a0=*dirPath a1=*handleOut
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallOpenDir(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -868,7 +881,7 @@ static uint64_t SyscallOpenDir(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_READ_DIR (50) a0=handle a1=*KDIR_ENTRY
|
||||
// SYS_READ_DIR (55) a0=handle a1=*KDIR_ENTRY
|
||||
// Returns STATUS_NO_MORE_FILES when the directory is exhausted.
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallReadDir(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
@@ -889,7 +902,7 @@ static uint64_t SyscallReadDir(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_SET_CWD (51) a0=*path
|
||||
// SYS_SET_CWD (56) a0=*path
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallSetCwd(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -900,7 +913,7 @@ static uint64_t SyscallSetCwd(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_GET_CWD (52) a0=*buf a1=size
|
||||
// SYS_GET_CWD (57) a0=*buf a1=size
|
||||
// ---------------------------------------------------------------------------
|
||||
static uint64_t SyscallGetCwd(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5) {
|
||||
@@ -912,7 +925,7 @@ static uint64_t SyscallGetCwd(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_WAIT_THREAD (53) a0=tid
|
||||
// SYS_WAIT_THREAD (58) a0=tid
|
||||
// Blocks the caller until the thread with the given TID exits.
|
||||
// Searches the current process's thread list; cross-process join is not
|
||||
// supported in v1 (POSIX pthread_join is always intra-process).
|
||||
@@ -956,7 +969,7 @@ static uint64_t SyscallWaitThread(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_GET_PROCESS_PID (54) a0=procHandle a1=*pidOut
|
||||
// SYS_GET_PROCESS_PID (59) a0=procHandle a1=*pidOut
|
||||
// Returns the numeric PID of a process identified by handle.
|
||||
// Used by posix_spawn to map the kernel handle back to a pid_t for waitpid.
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -999,7 +1012,7 @@ static NAMED_QUEUE_ENTRY gNamedQueues[NAMED_QUEUE_MAX];
|
||||
static SPINLOCK gNamedQueueLock;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_PUBLISH_QUEUE (55) a0=*name a1=queueHandle
|
||||
// SYS_PUBLISH_QUEUE (60) a0=*name a1=queueHandle
|
||||
//
|
||||
// Registers the queue identified by 'queueHandle' under 'name'.
|
||||
// Fails with STATUS_ALREADY_EXISTS if the name is already taken.
|
||||
@@ -1047,7 +1060,7 @@ static uint64_t SyscallPublishQueue(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_OPEN_NAMED_QUEUE (56) a0=*name a1=*handleOut
|
||||
// SYS_OPEN_NAMED_QUEUE (61) a0=*name a1=*handleOut
|
||||
//
|
||||
// Looks up 'name' in the registry and allocates a handle to the queue in the
|
||||
// calling process's handle table. Returns STATUS_NOT_FOUND if no match.
|
||||
@@ -1083,7 +1096,7 @@ static uint64_t SyscallOpenNamedQueue(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_QUEUE_DUPLICATE (61) a0=handle a1=targetPid a2=*handleOut
|
||||
// SYS_QUEUE_DUPLICATE (62) a0=handle a1=targetPid a2=*handleOut
|
||||
//
|
||||
// Looks up the QUEUE behind 'handle' in the CALLER's table, then allocates
|
||||
// a new handle for the same object in the TARGET process's table.
|
||||
@@ -1115,7 +1128,7 @@ static uint64_t SyscallQueueDuplicate(uint64_t a0, uint64_t a1, uint64_t a2,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SYS_NAMED_QUEUE_OWNER_PID (62) a0=*name a1=*pidOut
|
||||
// SYS_NAMED_QUEUE_OWNER_PID (63) a0=*name a1=*pidOut
|
||||
//
|
||||
// Returns the ProcessId of whoever published the named queue.
|
||||
// Lets a client get the publisher's PID so it can duplicate one of its
|
||||
@@ -1177,40 +1190,41 @@ static const SYSCALL_HANDLER gSyscallTable[SYS_MAX] = {
|
||||
/* 26 SYS_CLOSE_HANDLE */ SyscallCloseHandle,
|
||||
/* 27 SYS_OPEN_FILE */ SyscallOpenFile,
|
||||
/* 28 SYS_READ_FILE */ SyscallReadFile,
|
||||
/* 29 SYS_SEEK_FILE */ SyscallSeekFile,
|
||||
/* 30 SYS_GET_FILE_SIZE */ SyscallGetFileSize,
|
||||
/* 31 SYS_WRITE_FILE */ SyscallWriteFile,
|
||||
/* 32 SYS_CREATE_FILE */ SyscallCreateFile,
|
||||
/* 33 SYS_DELETE_FILE */ SyscallDeleteFile,
|
||||
/* 34 SYS_TRUNCATE_FILE */ SyscallTruncateFile,
|
||||
/* 35 SYS_GET_FILE_POS */ SyscallGetFilePos,
|
||||
/* 29 SYS_WRITE_FILE */ SyscallWriteFile,
|
||||
/* 30 SYS_CREATE_FILE */ SyscallCreateFile,
|
||||
/* 31 SYS_DELETE_FILE */ SyscallDeleteFile,
|
||||
/* 32 SYS_TRUNCATE_FILE */ SyscallTruncateFile,
|
||||
/* 33 SYS_GET_FILE_POS */ SyscallGetFilePos,
|
||||
/* 34 SYS_SEEK_FILE */ SyscallSeekFile,
|
||||
/* 35 SYS_GET_FILE_SIZE */ SyscallGetFileSize,
|
||||
/* 36 SYS_SCREEN_BLIT */ SyscallScreenBlit,
|
||||
/* 37 SYS_SCREEN_CLEAR */ SyscallScreenClear,
|
||||
/* 38 SYS_SCREEN_GET_SIZE */ SyscallScreenGetSize,
|
||||
/* 39 SYS_SCREEN_PUT_CHAR */ SyscallScreenPutChar,
|
||||
/* 40 SYS_KB_POLL */ SyscallKbPoll,
|
||||
/* 41 SYS_KB_READ_CHAR */ SyscallKbReadChar,
|
||||
/* 42 SYS_KB_READ_SCANCODE */ SyscallKbReadScancode,
|
||||
/* 43 SYS_KB_GET_MODIFIERS */ SyscallKbGetModifiers,
|
||||
/* 44 SYS_MOUSE_POLL */ SyscallMousePoll,
|
||||
/* 45 SYS_MOUSE_READ */ SyscallMouseRead,
|
||||
/* 46 SYS_MOUSE_GET_POS */ SyscallMouseGetPos,
|
||||
/* 47 SYS_GET_TICK */ SyscallGetTick,
|
||||
/* 48 SYS_DEBUG_PRINT */ SyscallDebugPrint,
|
||||
/* 49 SYS_CREATE_PROCESS */ SyscallCreateProcess,
|
||||
/* 50 SYS_WAIT_FOR_PROCESS */ SyscallWaitForProcess,
|
||||
/* 51 SYS_GET_PROCESS_EXIT_CODE */ SyscallGetProcessExitCode,
|
||||
/* 52 SYS_WRITE_CONSOLE */ SyscallWriteConsole,
|
||||
/* 53 SYS_OPEN_DIR */ SyscallOpenDir,
|
||||
/* 54 SYS_READ_DIR */ SyscallReadDir,
|
||||
/* 55 SYS_SET_CWD */ SyscallSetCwd,
|
||||
/* 56 SYS_GET_CWD */ SyscallGetCwd,
|
||||
/* 57 SYS_WAIT_THREAD */ SyscallWaitThread,
|
||||
/* 58 SYS_GET_PROCESS_PID */ SyscallGetProcessPid,
|
||||
/* 59 SYS_PUBLISH_QUEUE */ SyscallPublishQueue,
|
||||
/* 60 SYS_OPEN_NAMED_QUEUE */ SyscallOpenNamedQueue,
|
||||
/* 61 SYS_QUEUE_DUPLICATE */ SyscallQueueDuplicate,
|
||||
/* 62 SYS_NAMED_QUEUE_OWNER_PID */ SyscallNamedQueueOwnerPid,
|
||||
/* 41 SYS_KB_IS_KEY_DOWN */ SyscallKbIsKeyDown,
|
||||
/* 42 SYS_KB_READ_CHAR */ SyscallKbReadChar,
|
||||
/* 43 SYS_KB_READ_SCANCODE */ SyscallKbReadScancode,
|
||||
/* 44 SYS_KB_GET_MODIFIERS */ SyscallKbGetModifiers,
|
||||
/* 45 SYS_MOUSE_POLL */ SyscallMousePoll,
|
||||
/* 46 SYS_MOUSE_READ */ SyscallMouseRead,
|
||||
/* 47 SYS_MOUSE_GET_POS */ SyscallMouseGetPos,
|
||||
/* 48 SYS_GET_TICK */ SyscallGetTick,
|
||||
/* 49 SYS_DEBUG_PRINT */ SyscallDebugPrint,
|
||||
/* 50 SYS_CREATE_PROCESS */ SyscallCreateProcess,
|
||||
/* 51 SYS_WAIT_FOR_PROCESS */ SyscallWaitForProcess,
|
||||
/* 52 SYS_GET_PROCESS_EXIT_CODE */ SyscallGetProcessExitCode,
|
||||
/* 53 SYS_WRITE_CONSOLE */ SyscallWriteConsole,
|
||||
/* 54 SYS_OPEN_DIR */ SyscallOpenDir,
|
||||
/* 55 SYS_READ_DIR */ SyscallReadDir,
|
||||
/* 56 SYS_SET_CWD */ SyscallSetCwd,
|
||||
/* 57 SYS_GET_CWD */ SyscallGetCwd,
|
||||
/* 58 SYS_WAIT_THREAD */ SyscallWaitThread,
|
||||
/* 59 SYS_GET_PROCESS_PID */ SyscallGetProcessPid,
|
||||
/* 60 SYS_PUBLISH_QUEUE */ SyscallPublishQueue,
|
||||
/* 61 SYS_OPEN_NAMED_QUEUE */ SyscallOpenNamedQueue,
|
||||
/* 62 SYS_QUEUE_DUPLICATE */ SyscallQueueDuplicate,
|
||||
/* 63 SYS_NAMED_QUEUE_OWNER_PID */ SyscallNamedQueueOwnerPid,
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
+5
-6
@@ -203,7 +203,7 @@ static void LoadAndRegisterDll(const char* filename) {
|
||||
// Returns the new PROCESS* with one reference owned by the caller.
|
||||
// Returns NULL on failure.
|
||||
// ---------------------------------------------------------------------------
|
||||
static PROCESS* LaunchUserProcess(const char* filePath) {
|
||||
static PROCESS* LaunchUserProcess(const char* filePath, const char* args) {
|
||||
KSTATUS s;
|
||||
FILE_OBJECT* f;
|
||||
|
||||
@@ -238,17 +238,16 @@ static PROCESS* LaunchUserProcess(const char* filePath) {
|
||||
}
|
||||
DbgPrint("Created process (PID %u) with command line: %s\n", proc->ProcessId, filePath);
|
||||
|
||||
strncpy(proc->Cmdline, filePath, sizeof(proc->Cmdline) - 1);
|
||||
strncpy(proc->Cmdline, args, sizeof(proc->Cmdline) - 1);
|
||||
|
||||
// proc->Cmdline is kernel pool (ffffc000...) - not readable at CPL=3.
|
||||
// Copy into user memory before handing the pointer to the initial thread.
|
||||
size_t cmdlineLen = strlen(proc->Cmdline) + 1;
|
||||
char* userCmdline = (char*)MmAllocateUserMemory(cmdlineLen);
|
||||
char* userCmdline = (char*)MmAllocateUserMemory(sizeof(proc->Cmdline));
|
||||
if (!userCmdline) {
|
||||
DbgPrint("LaunchUserProcess: Failed to allocate user cmdline buffer.\n");
|
||||
return (PROCESS*)0;
|
||||
}
|
||||
memcpy(userCmdline, proc->Cmdline, cmdlineLen);
|
||||
memcpy(userCmdline, proc->Cmdline, sizeof(proc->Cmdline));
|
||||
|
||||
// Parse the raw PE file and map it into executable memory
|
||||
uintptr_t imageBase = 0;
|
||||
@@ -331,7 +330,7 @@ void SystemInitThread(void* arg) {
|
||||
DbgPrint(" -> User Heap: %.2f MB\n", (float)MmGetUserHeapUsage() / (1024.0f * 1024.0f));
|
||||
|
||||
// Launch User-Mode Shell (this will trigger AHCI & FAT32 which CAN safely block now)
|
||||
PROCESS* shellProc = LaunchUserProcess(args->bootInfo->CommandLine);
|
||||
PROCESS* shellProc = LaunchUserProcess("init.exe", args->bootInfo->CommandLine);
|
||||
|
||||
if (shellProc) {
|
||||
KSTATUS ws = KeCreateKernelThread((uintptr_t)ProcessWatcherThread,
|
||||
|
||||
+46
-52
@@ -47,24 +47,24 @@
|
||||
#define SYS_SEM_CREATE 15 // (int32_t initial, int32_t max, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_SEM_WAIT 16 // (uint32_t handle) -> KSTATUS
|
||||
#define SYS_SEM_TRY_WAIT 17 // (uint32_t handle) -> KSTATUS
|
||||
#define SYS_SEM_SIGNAL 18 // (uint32_t handle) -> void
|
||||
#define SYS_SEM_SIGNAL 18 // (uint32_t handle) -> KSTATUS
|
||||
|
||||
#define SYS_EVENT_CREATE 19 // (uint32_t type, uint32_t initialState, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_EVENT_SIGNAL 20 // (uint32_t handle) -> void
|
||||
#define SYS_EVENT_CLEAR 21 // (uint32_t handle) -> void
|
||||
#define SYS_EVENT_CREATE 19 // (uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_EVENT_SIGNAL 20 // (uint32_t handle) -> KSTATUS
|
||||
#define SYS_EVENT_CLEAR 21 // (uint32_t handle) -> KSTATUS
|
||||
#define SYS_EVENT_WAIT 22 // (uint32_t handle) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Message Queues
|
||||
// Queue
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_QUEUE_CREATE 23 // (uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_QUEUE_SEND 24 // (uint32_t handle, const QUEUE_MESSAGE* msg, uint32_t blocking) -> KSTATUS
|
||||
#define SYS_QUEUE_RECV 25 // (uint32_t handle, QUEUE_MESSAGE* msg, uint32_t blocking) -> KSTATUS
|
||||
#define SYS_QUEUE_SEND 24 // (uint32_t handle, void* msg, int blocking) -> KSTATUS
|
||||
#define SYS_QUEUE_RECV 25 // (uint32_t handle, void* msg, int blocking) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Handle Management
|
||||
// Handle (unified close for all object types)
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_CLOSE_HANDLE 26 // (uint32_t handle) -> void
|
||||
#define SYS_CLOSE_HANDLE 26 // (uint32_t handle) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// File I/O
|
||||
@@ -72,13 +72,13 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_OPEN_FILE 27 // (const char* path, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_READ_FILE 28 // (uint32_t handle, void* buf, size_t size, size_t* bytesReadOut) -> KSTATUS
|
||||
#define SYS_SEEK_FILE 29 // (uint32_t handle, uint64_t offset) -> KSTATUS
|
||||
#define SYS_GET_FILE_SIZE 30 // (uint32_t handle) -> uint64_t
|
||||
#define SYS_WRITE_FILE 31 // (uint32_t handle, const void* buf, size_t size, size_t* bytesWrittenOut) -> KSTATUS
|
||||
#define SYS_CREATE_FILE 32 // (const char* path, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_DELETE_FILE 33 // (const char* path) -> KSTATUS
|
||||
#define SYS_TRUNCATE_FILE 34 // (uint32_t handle, uint64_t newSize) -> KSTATUS
|
||||
#define SYS_GET_FILE_POS 35 // (uint32_t handle) -> uint64_t
|
||||
#define SYS_WRITE_FILE 29 // (uint32_t handle, const void* buf, size_t size, size_t* bytesWrittenOut) -> KSTATUS
|
||||
#define SYS_CREATE_FILE 30 // (const char* path, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_DELETE_FILE 31 // (const char* path) -> KSTATUS
|
||||
#define SYS_TRUNCATE_FILE 32 // (uint32_t handle, uint64_t newSize) -> KSTATUS
|
||||
#define SYS_GET_FILE_POS 33 // (uint32_t handle) -> uint64_t
|
||||
#define SYS_SEEK_FILE 34 // (uint32_t handle, uint64_t offset) -> KSTATUS
|
||||
#define SYS_GET_FILE_SIZE 35 // (uint32_t handle) -> uint64_t
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Screen / Graphics
|
||||
@@ -92,80 +92,74 @@
|
||||
// Keyboard
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_KB_POLL 40 // () -> uint32_t (1 if key available, 0 otherwise)
|
||||
#define SYS_KB_READ_CHAR 41 // () -> char (blocks, yields while waiting)
|
||||
#define SYS_KB_READ_SCANCODE 42 // () -> uint8_t (blocks, yields while waiting)
|
||||
#define SYS_KB_GET_MODIFIERS 43 // () -> uint32_t (current modifier bitmask)
|
||||
#define SYS_KB_IS_KEY_DOWN 41 // (int scancode) -> uint32_t (1 if down, 0 otherwise)
|
||||
#define SYS_KB_READ_CHAR 42 // () -> char (blocks, yields while waiting)
|
||||
#define SYS_KB_READ_SCANCODE 43 // () -> uint8_t (blocks, yields while waiting)
|
||||
#define SYS_KB_GET_MODIFIERS 44 // () -> uint32_t (current modifier bitmask)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mouse
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_MOUSE_POLL 44 // () -> uint32_t (1 if packet waiting, 0 otherwise)
|
||||
#define SYS_MOUSE_READ 45 // (int* dx, int* dy, uint8_t* buttons) -> uint32_t (1=ok, 0=empty)
|
||||
#define SYS_MOUSE_GET_POS 46 // (int* x, int* y) -> void
|
||||
#define SYS_MOUSE_POLL 45 // () -> uint32_t (1 if packet waiting, 0 otherwise)
|
||||
#define SYS_MOUSE_READ 46 // (int* dx, int* dy, uint8_t* buttons) -> uint32_t (1=ok, 0=empty)
|
||||
#define SYS_MOUSE_GET_POS 47 // (int* x, int* y) -> void
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Timer
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_GET_TICK 47 // () -> uint64_t (milliseconds since boot)
|
||||
#define SYS_GET_TICK 48 // () -> uint64_t (milliseconds since boot)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Debug
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_DEBUG_PRINT 48 // (const char* str) -> void
|
||||
#define SYS_DEBUG_PRINT 49 // (const char* str) -> void
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Process launch & lifecycle
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_CREATE_PROCESS 49 // (const char* path, uint32_t* handleOut, const char* cmdline) -> KSTATUS
|
||||
#define SYS_WAIT_FOR_PROCESS 50 // (uint32_t handle) -> KSTATUS
|
||||
#define SYS_GET_PROCESS_EXIT_CODE 51 // (uint32_t handle, int* exitCodeOut) -> KSTATUS
|
||||
#define SYS_CREATE_PROCESS 50 // (const char* path, const char* args, uint32_t* pidOut) -> KSTATUS
|
||||
#define SYS_WAIT_FOR_PROCESS 51 // (uint32_t pid) -> KSTATUS
|
||||
#define SYS_GET_PROCESS_EXIT_CODE 52 // (uint32_t pid, int* exitCodeOut) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Console output (white text, distinct from green SYS_DEBUG_PRINT)
|
||||
// Console output (white text, for user programs)
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_WRITE_CONSOLE 52 // (const char* buf, size_t len) -> void
|
||||
#define SYS_WRITE_CONSOLE 53 // (const char* str, size_t len) -> void
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Directory enumeration
|
||||
// (Close the handle via SYS_CLOSE_HANDLE like any other object.)
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_OPEN_DIR 53 // (const char* dirPath, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_READ_DIR 54 // (uint32_t handle, KDIR_ENTRY* entryOut) -> KSTATUS
|
||||
#define SYS_OPEN_DIR 54 // (const char* path, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_READ_DIR 55 // (uint32_t handle, DirEntry* entryOut) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Current Working Directory
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_SET_CWD 55 // (const char* path) -> KSTATUS
|
||||
#define SYS_GET_CWD 56 // (char* buf, size_t size) -> KSTATUS
|
||||
#define SYS_SET_CWD 56 // (const char* path) -> KSTATUS
|
||||
#define SYS_GET_CWD 57 // (char* buf, size_t buflen) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Thread join
|
||||
// Thread join (used by pthread_join in posix.dll)
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_WAIT_THREAD 57 // (uint32_t tid) -> KSTATUS
|
||||
// Blocks until the thread with that TID exits.
|
||||
// Returns STATUS_NOT_FOUND if TID unknown.
|
||||
#define SYS_WAIT_THREAD 58 // (uint32_t tid) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Process PID query (needed by posix_spawn -> waitpid)
|
||||
// Process PID query (used by posix_spawn -> waitpid in posix.dll)
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_GET_PROCESS_PID 58 // (uint32_t procHandle, uint32_t* pidOut) -> KSTATUS
|
||||
#define SYS_GET_PROCESS_PID 59 // (uint32_t pid) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Named Queue Registry
|
||||
// SysPublishQueue - register a queue under a name (call once at startup)
|
||||
// SysOpenNamedQueue - resolve a name to a handle (retry until SUCCESS)
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_PUBLISH_QUEUE 59 // (const char* name, uint32_t queueHandle) -> KSTATUS
|
||||
#define SYS_OPEN_NAMED_QUEUE 60 // (const char* name, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_PUBLISH_QUEUE 60 // (const char* name, uint32_t queueHandle) -> KSTATUS
|
||||
#define SYS_OPEN_NAMED_QUEUE 61 // (const char* name, uint32_t* handleOut) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Handle Duplication
|
||||
// Handle duplication
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_QUEUE_DUPLICATE 61 // (uint32_t handle, uint32_t targetPid, uint32_t* handleOut) -> KSTATUS
|
||||
// Duplicates a queue handle into another process's handle table.
|
||||
// Returns the new handle value (valid in targetPid's space) via *handleOut.
|
||||
#define SYS_NAMED_QUEUE_OWNER_PID 62 // (const char* name, uint32_t* pidOut) -> KSTATUS
|
||||
// Returns the ProcessId of whoever published the named queue.
|
||||
#define SYS_QUEUE_DUPLICATE 62 // (uint32_t handle, uint32_t targetPid, uint32_t* handleOut) -> KSTATUS
|
||||
#define SYS_NAMED_QUEUE_OWNER_PID 63 // (const char* name, uint32_t* pidOut) -> KSTATUS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sentinel
|
||||
// ---------------------------------------------------------------------------
|
||||
#define SYS_MAX 63
|
||||
#define SYS_MAX 64
|
||||
Reference in new issue
Block a user