From f5aebd93f1c9082045915c795599ee02b4df50d8 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sat, 17 May 2003 13:40:03 +0000 Subject: [PATCH] - Free memory for boot load files, except ntoskrnl.exe and hal.dll. svn path=/trunk/; revision=4696 --- reactos/ntoskrnl/ke/main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index eafaa7b641c..0c8e588c5ab 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: main.c,v 1.155 2003/05/16 17:35:12 ekohl Exp $ +/* $Id: main.c,v 1.156 2003/05/17 13:40:03 hbirr Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/main.c @@ -285,6 +285,19 @@ InitSystemSharedUserPage (PCSZ ParameterLine) } } +VOID STATIC +MiFreeBootDriverMemory(PVOID StartAddress, ULONG Length) +{ + PHYSICAL_ADDRESS Page; + ULONG i; + + for (i = 0; i < PAGE_ROUND_UP(Length)/PAGE_SIZE; i++) + { + Page = MmGetPhysicalAddressForProcess(NULL, StartAddress + i * PAGE_SIZE); + MmDeleteVirtualMapping(NULL, StartAddress + i * PAGE_SIZE, FALSE, NULL, NULL); + MmDereferencePage(Page); + } +} VOID ExpInitializeExecutive(VOID) @@ -525,6 +538,12 @@ ExpInitializeExecutive(VOID) if (RtlpCheckFileNameExtension(name, ".sys")) BootDriverCount++; } + /* Pass 5: free memory for all boot files, except ntoskrnl.exe and hal.dll */ + for (i = 2; i < KeLoaderBlock.ModsCount; i++) + { + MiFreeBootDriverMemory((PVOID)KeLoaderModules[i].ModStart, + KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart); + } if (BootDriverCount == 0) {