From a7c4f6c2aab0ab07cf38c6f45b8d6e16c1003d3f Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sun, 26 May 2024 10:50:31 +0200 Subject: [PATCH] Fix MmMapHalMemory() not using the ReturnAddress for calculating virtual address --- xtoskrnl/mm/hlpool.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xtoskrnl/mm/hlpool.c b/xtoskrnl/mm/hlpool.c index d4c62c1..e1a9e84 100644 --- a/xtoskrnl/mm/hlpool.c +++ b/xtoskrnl/mm/hlpool.c @@ -186,14 +186,14 @@ MmMapHalMemory(IN PHYSICAL_ADDRESS PhysicalAddress, } /* Get PTE pointer and advance to next page */ - PtePointer = (PHARDWARE_PTE)MmpGetPteAddress(VirtualAddress); - VirtualAddress = (PVOID)(ULONG_PTR)VirtualAddress + MM_PAGE_SIZE; + PtePointer = (PHARDWARE_PTE)MmpGetPteAddress(ReturnAddress); + ReturnAddress = (PVOID)(ULONG_PTR)ReturnAddress + MM_PAGE_SIZE; /* Check if PTE is valid */ if(PtePointer->Valid) { /* PTE is not available, go to the next one */ - BaseAddress = VirtualAddress; + BaseAddress = ReturnAddress; MappedPages = 0; continue; } @@ -203,7 +203,7 @@ MmMapHalMemory(IN PHYSICAL_ADDRESS PhysicalAddress, } /* Take the actual base address with an offset */ - VirtualAddress = (PVOID)(ULONG_PTR)(BaseAddress + PAGE_OFFSET(PhysicalAddress.LowPart)); + ReturnAddress = (PVOID)(ULONG_PTR)(BaseAddress + PAGE_OFFSET(PhysicalAddress.LowPart)); /* Check if base address starts at the beginning of the heap */ if(BaseAddress == MmpHalHeapStart)