From 2b679c11d40306736fcdf9a24850cfe0820cc267 Mon Sep 17 00:00:00 2001 From: belliash Date: Sun, 11 Dec 2022 13:56:40 +0100 Subject: [PATCH] Fix a bug in BlAddVirtualMemoryMapping() routine causing PF (Page Fault) on systems with more than 3GB of RAM --- xtldr/memory.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/xtldr/memory.c b/xtldr/memory.c index 5424a32..3a8a3cf 100644 --- a/xtldr/memory.c +++ b/xtldr/memory.c @@ -145,21 +145,20 @@ BlAddVirtualMemoryMapping(IN PLIST_ENTRY MemoryMappings, if((Mapping2->PhysicalAddress >= Mapping1->PhysicalAddress && PhysicalAddress2End <= PhysicalAddressEnd) || (Mapping2->NumberOfPages == 0)) { - /* Make sure it's memory type is LoaderFree */ - if(Mapping2->MemoryType != LoaderFree) + /* If it is of LoaderFree type, then we can skip it */ + if(Mapping2->MemoryType == LoaderFree) { - /* LoaderFree memory type is strictly expected */ - return STATUS_EFI_INVALID_PARAMETER; + /* Store address of the next mapping */ + MappingListEntry = ListEntry->Flink; + + /* Remove mapping from the list and free up it's memory */ + RtlRemoveEntryList(&Mapping2->ListEntry); + BlEfiMemoryFreePool(Mapping2); + ListEntry = MappingListEntry; + + /* Go to the next mapping */ + continue; } - - /* Store address of the next mapping */ - MappingListEntry = ListEntry->Flink; - - /* Remove mapping from the list and free up it's memory */ - RtlRemoveEntryList(&Mapping2->ListEntry); - BlEfiMemoryFreePool(Mapping2); - ListEntry = MappingListEntry; - continue; } /* Determine phsical address order */