KernelMain reports more details about memory usage, LdrResolveImports catches kernel32, user32, ole32 and winmm and redirects them to win32.
This commit is contained in:
1 parent
129be91e15
commit
c13dd99150
7 files changed
+116
-1190
No files matched your search
+13
-7
@@ -78,9 +78,8 @@ typedef KSTATUS (*DRIVER_ENTRY_FN)(const HAL_API *);
|
||||
// Phase Helper: Resolve Imports for all registered modules
|
||||
// ---------------------------------------------------------------------------
|
||||
static void ResolveSystemImports(BOOT_INFO* bootInfo) {
|
||||
// Resolve imports for all loaded modules (drivers may import from hal.dll,
|
||||
// win32.dll imports from syscall.dll, etc).
|
||||
// Starting at 2 to skip the kernel and HAL base images, as per your design.
|
||||
// Resolve imports for all loaded modules (drivers may import from hal.dll, win32.dll imports from syscall.dll, etc).
|
||||
// Starting at 2 to skip the kernel and HAL base images.
|
||||
for (uint32_t i = 2; i < bootInfo->ModuleCount; i++) {
|
||||
LdrResolveImports(bootInfo->Modules[i].VirtBase);
|
||||
}
|
||||
@@ -112,7 +111,7 @@ static void InitializeDrivers(BOOT_INFO* bootInfo, const HAL_API* hal) {
|
||||
|
||||
// Identify .sys files by extension
|
||||
size_t len = strlen(name);
|
||||
if (len < 4 || strcmp(name + len - 4, ".sys") != 0) continue;
|
||||
if (len < 4 || strcmp(name + len - 4, ".sys")) continue;
|
||||
|
||||
DbgPrint("KernelMain: Executing DriverEntry for %s\n", name);
|
||||
|
||||
@@ -235,7 +234,7 @@ static void LoadAndRegisterDll(const char* filename) {
|
||||
IoCloseFile(f);
|
||||
|
||||
// Map the DLL into memory
|
||||
// Passing 'true' for user-mode so init.exe can access its code
|
||||
// Passing 'true' for user-mode
|
||||
uintptr_t mappedBase = 0;
|
||||
s = LdrLoadImage(mem, size, &mappedBase, true);
|
||||
if (!KSUCCESS(s)) {
|
||||
@@ -384,8 +383,6 @@ extern void KernelMain(BOOT_INFO* bootInfo) {
|
||||
//
|
||||
KeInitializeScheduler();
|
||||
// hal->Screen.Clear(0x000000);
|
||||
DbgPrint("KernelMain: initialisation complete. %.2f MB free.\n",
|
||||
(float)MmFreeFrameCount() * PAGE_SIZE / (1024.0f * 1024.0f));
|
||||
|
||||
DbgPrint("KernelMain: Loading system DLLs...\n");
|
||||
LoadAndRegisterDll("syscall.dll");
|
||||
@@ -406,6 +403,15 @@ extern void KernelMain(BOOT_INFO* bootInfo) {
|
||||
DbgPrint("KernelMain: Starting scheduler... Handing over control.\n");
|
||||
_enable();
|
||||
|
||||
float freeMB = (float)MmFreeFrameCount() * PAGE_SIZE / (1024.0f * 1024.0f);
|
||||
float kernelMB = (float)MmGetKernelPoolUsage() / (1024.0f * 1024.0f);
|
||||
float userMB = (float)MmGetUserHeapUsage() / (1024.0f * 1024.0f);
|
||||
|
||||
DbgPrint("Memory Status:\n");
|
||||
DbgPrint(" -> Free (PMM): %.2f MB\n", freeMB);
|
||||
DbgPrint(" -> Kernel Pool: %.2f MB\n", kernelMB);
|
||||
DbgPrint(" -> User Heap: %.2f MB\n", userMB);
|
||||
|
||||
while (1) {
|
||||
//DbgPrint("KernelMain: Idle loop. Free memory: %.2f MB.\n",
|
||||
//(float)(MmFreeFrameCount() * PAGE_SIZE) / (1024.0f * 1024.0f));
|
||||
|
||||
Reference in new issue
Block a user