From 7193e698f14d234996352a1d9d7afd3874a91491 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sun, 7 Apr 2024 17:49:24 +0200 Subject: [PATCH] Store page map level --- sdk/xtdk/xtfw.h | 1 + xtldr/modules/xtos_o/xtos.c | 3 +++ xtoskrnl/includes/globals.h | 3 +++ xtoskrnl/mm/globals.c | 3 +++ xtoskrnl/mm/init.c | 4 +++- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sdk/xtdk/xtfw.h b/sdk/xtdk/xtfw.h index b40be10..6470f82 100644 --- a/sdk/xtdk/xtfw.h +++ b/sdk/xtdk/xtfw.h @@ -108,6 +108,7 @@ typedef struct _LOADER_GRAPHICS_INFORMATION_BLOCK typedef struct _LOADER_INFORMATION_BLOCK { PVOID DbgPrint; + ULONG PageMapLevel; LOADER_GRAPHICS_INFORMATION_BLOCK FrameBuffer; } LOADER_INFORMATION_BLOCK, *PLOADER_INFORMATION_BLOCK; diff --git a/xtldr/modules/xtos_o/xtos.c b/xtldr/modules/xtos_o/xtos.c index c05e8e2..ceaab59 100644 --- a/xtldr/modules/xtos_o/xtos.c +++ b/xtldr/modules/xtos_o/xtos.c @@ -468,6 +468,9 @@ XtpInitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap, LoaderBlock->LoaderInformation.FrameBuffer.Initialized = FALSE; } + /* Store page map level */ + LoaderBlock->LoaderInformation.PageMapLevel = 3; + /* Close FrameBuffer protocol */ XtLdrProtocol->Protocol.Close(ProtocolHandle, &FrameBufGuid); diff --git a/xtoskrnl/includes/globals.h b/xtoskrnl/includes/globals.h index dea6b0a..e6287e0 100644 --- a/xtoskrnl/includes/globals.h +++ b/xtoskrnl/includes/globals.h @@ -57,4 +57,7 @@ EXTERN ULONG MmNumberOfPhysicalPages; /* Old biggest free memory descriptor */ EXTERN LOADER_MEMORY_MAPPING MmOldFreeDescriptor; +/* Page Map Level */ +EXTERN ULONG MmPageMapLevel; + #endif /* __XTOSKRNL_GLOBALS_H */ diff --git a/xtoskrnl/mm/globals.c b/xtoskrnl/mm/globals.c index b2c75f6..0a7487f 100644 --- a/xtoskrnl/mm/globals.c +++ b/xtoskrnl/mm/globals.c @@ -23,3 +23,6 @@ ULONG MmNumberOfPhysicalPages; /* Old biggest free memory descriptor */ LOADER_MEMORY_MAPPING MmOldFreeDescriptor; + +/* Page Map Level */ +ULONG MmPageMapLevel; diff --git a/xtoskrnl/mm/init.c b/xtoskrnl/mm/init.c index 5c85b22..6a51123 100644 --- a/xtoskrnl/mm/init.c +++ b/xtoskrnl/mm/init.c @@ -31,6 +31,9 @@ MmInitializeMemoryManager(VOID) KePanic(0); } + /* Store Page Map Level */ + MmPageMapLevel = KeInitializationBlock->LoaderInformation.PageMapLevel; + /* Proceed with architecture specific initialization */ MmpInitializeArchitecture(); } @@ -108,7 +111,6 @@ MmpScanMemoryDescriptors(VOID) /* Store original free descriptor */ RtlCopyMemory(&MmOldFreeDescriptor, MmFreeDescriptor, sizeof(LOADER_MEMORY_MAPPING)); - } /** Checks whether the specified memory type should be considered as free.