From 49871ae71b920f9d4667dc4cf4955f2105690c62 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Mon, 4 Oct 2004 17:27:13 +0000 Subject: [PATCH] - Fixed the setting of the page protection for ntoskrnl. The image is loaded without the size of the bss section. Pages after the bss section may not be changed. svn path=/trunk/; revision=11182 --- reactos/ntoskrnl/ldr/loader.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 8474eeb08cb..2629b3717b4 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -1,4 +1,4 @@ -/* $Id: loader.c,v 1.146 2004/09/28 20:16:24 hbirr Exp $ +/* $Id: loader.c,v 1.147 2004/10/04 17:27:13 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -666,7 +666,7 @@ LdrLookupPageProtection(PVOID PageStart, ULONG Length; PVOID BaseAddress; - for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++) + for (Idx = 0; Idx < PEFileHeader->NumberOfSections && (!Write || !Execute); Idx++) { Characteristics = PESectionHeaders[Idx].Characteristics; if (!(Characteristics & IMAGE_SECTION_NOLOAD)) @@ -1111,6 +1111,13 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase, MmSetPageProtect(NULL, PageAddress, Protect); PageAddress = (PVOID)((ULONG_PTR)PageAddress + PAGE_SIZE); } + if (DriverBase == ModuleLoadBase && + Characteristics & IMAGE_SECTION_CHAR_BSS) + { + /* For ntoskrnl, we must stop after the bss section */ + break; + } + } return DriverBase;