From 62cb7586f3ac1ff4b8176cabccce7ee20e37009a Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Tue, 9 Feb 2010 02:22:08 +0000 Subject: [PATCH] [FREELDR]: The hack to set pages from 0x100 to 0x1FF as busy so that the heap allocator wouldn't use them always restored the pages back to Free (since they usually were free on x86). However, if the pages were already being used in the first place, this made them appear free and corrupted existing memory. Fixed the hack so that it restores the previous state of the memory pages. svn path=/trunk/; revision=45517 --- reactos/boot/freeldr/freeldr/mm/meminit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/mm/meminit.c b/reactos/boot/freeldr/freeldr/mm/meminit.c index e3e62c802c2..f59a43f7b54 100644 --- a/reactos/boot/freeldr/freeldr/mm/meminit.c +++ b/reactos/boot/freeldr/freeldr/mm/meminit.c @@ -102,8 +102,11 @@ VOID MmInitializeHeap(PVOID PageLookupTable) { ULONG PagesNeeded; ULONG HeapStart; - + MEMORY_TYPE Type; + PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; + // HACK: Make it so it doesn't overlap kernel space + Type = RealPageLookupTable[0x100].PageAllocated; MmMarkPagesInLookupTable(PageLookupTableAddress, 0x100, 0xFF, LoaderSystemCode); // Find contigious memory block for HEAP:STACK @@ -111,7 +114,7 @@ VOID MmInitializeHeap(PVOID PageLookupTable) HeapStart = MmFindAvailablePages(PageLookupTable, TotalPagesInLookupTable, PagesNeeded, FALSE); // Unapply the hack - MmMarkPagesInLookupTable(PageLookupTableAddress, 0x100, 0xFF, LoaderFree); + MmMarkPagesInLookupTable(PageLookupTableAddress, 0x100, 0xFF, Type); if (HeapStart == 0) {