diff --git a/OVMF/OVMF_VARS_4M.fd b/OVMF/OVMF_VARS_4M.fd index 91d56fa..4eebbda 100644 Binary files a/OVMF/OVMF_VARS_4M.fd and b/OVMF/OVMF_VARS_4M.fd differ diff --git a/OVMF/OVMF_VARS_4M_d.fd b/OVMF/OVMF_VARS_4M_d.fd index c075991..a873cd4 100644 Binary files a/OVMF/OVMF_VARS_4M_d.fd and b/OVMF/OVMF_VARS_4M_d.fd differ diff --git a/build.bat b/build.bat index 9b37aa7..06cbeba 100644 --- a/build.bat +++ b/build.bat @@ -3,7 +3,7 @@ setlocal enabledelayedexpansion set ROOT=%~dp0. set SRC=%ROOT%\code -set DEST=G:\ +set DEST=%NTLITE_DRIVE% if exist "obj" rd /s /q "obj" if exist "bin" rd /s /q "bin" diff --git a/code/kernel/kmain.c b/code/kernel/kmain.c index ba410c3..9bb2793 100644 --- a/code/kernel/kmain.c +++ b/code/kernel/kmain.c @@ -107,21 +107,19 @@ static void InitializeDrivers(BOOT_INFO* bootInfo, const HAL_API* hal) { // Load the driver size_t len = strlen(runtimeKeys[i]); - - // Assemble the path - // "drivers\" is 8 chars; +1 for the NUL terminator already in len. - size_t pathLen = 8 + len + 1; // len already includes the NUL from strlen+1 above - char *path = MmAllocatePool(pathLen); + char* path = MmAllocatePool(len + 10); if (!path) { - DbgPrint("InitializeDrivers: OOM building driver path\n"); + DbgPrint("KernelMain: Failed to allocate memory for driver path. How?\n"); continue; } + + // memcpy manouvers memcpy(path, "drivers\\", 8); - memcpy(path + 8, runtimeKeys[i], len); // len includes the NUL + memcpy(path + 8, runtimeKeys[i], len + 1); s = IoOpenFile(path, &f); if (s != STATUS_SUCCESS) { - DbgPrint("InitializeDrivers: Failed to open runtime driver: %s\n", runtimeKeys[i]); + DbgPrint("InitializeDrivers: Failed to open runtime driver: %s (%s)\n", runtimeKeys[i], path); continue; // Skip this driver but keep going with others } diff --git a/readme.md b/readme.md index acac5c5..158622c 100644 --- a/readme.md +++ b/readme.md @@ -25,12 +25,13 @@ It boots into a shell. ## how 2 build +* open env variables +* set `NTLITE_DRIVE` as your thumbdrive (ex. `G:`) +* set `NTLITE_NTPATH` as your thumbdrive (ex. `\\.\PhysicalDrive7`) * open vs x64 build tools * cd into this directory * `build.bat` -* open `run.bat`/`rund.bat`/`runa.bat`/`runad.bat` -* replace `\\.\PhysicalDrive7` with your thumbdrive partition -* `run.bat`/`rund.bat`/`runa.bat`/`runad.bat` +* `run.bat`(ide)/`rund.bat`(ide, debug)/`runa.bat`(ahci)/`runad.bat`(ahci, debug) * enjoy ## how it looks when built diff --git a/run.bat b/run.bat index 34a2c91..6c6b6ef 100644 --- a/run.bat +++ b/run.bat @@ -1 +1 @@ -@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M.fd -drive format=raw,file=\\.\PhysicalDrive7 -serial stdio +@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M.fd -drive format=raw,file=%NTLITE_NTPATH% -serial stdio diff --git a/runa.bat b/runa.bat index 2027537..1a48adc 100644 --- a/runa.bat +++ b/runa.bat @@ -1 +1 @@ -@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M_d.fd -device ahci,id=ahci -drive format=raw,file=\\.\PhysicalDrive7,if=none,id=disk0 -device ide-hd,bus=ahci.0,drive=disk0 -serial stdio +@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M_d.fd -device ahci,id=ahci -drive format=raw,file=%NTLITE_NTPATH%,if=none,id=disk0 -device ide-hd,bus=ahci.0,drive=disk0 -serial stdio diff --git a/runad.bat b/runad.bat index fa2278a..f9ebbb6 100644 --- a/runad.bat +++ b/runad.bat @@ -1 +1 @@ -@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M_d.fd -device ahci,id=ahci -drive format=raw,file=\\.\PhysicalDrive7,if=none,id=disk0 -device ide-hd,bus=ahci.0,drive=disk0 -m 4G -serial stdio -d in_asm,cpu_reset,int -D qemu.log -no-reboot -no-shutdown +@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M_d.fd -device ahci,id=ahci -drive format=raw,file=%NTLITE_NTPATH%,if=none,id=disk0 -device ide-hd,bus=ahci.0,drive=disk0 -m 4G -serial stdio -d in_asm,cpu_reset,int -D qemu.log -no-reboot -no-shutdown diff --git a/rund.bat b/rund.bat index 4c5cff4..a597b1d 100644 --- a/rund.bat +++ b/rund.bat @@ -1 +1 @@ -@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M.fd -drive format=raw,file=\\.\PhysicalDrive7 -m 4G -serial stdio -d in_asm,cpu_reset,int -D qemu.log -no-reboot -no-shutdown +@start qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=OVMF\OVMF_CODE_4M.fd -drive if=pflash,format=raw,file=OVMF\OVMF_VARS_4M.fd -drive format=raw,file=%NTLITE_NTPATH% -m 4G -serial stdio -d in_asm,cpu_reset,int -D qemu.log -no-reboot -no-shutdown