From c30930d3ec69d40bfe94a523db1a91d82e7c68ce Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Thu, 22 Jul 2010 03:22:43 +0000 Subject: [PATCH] [NTOS]: MiRosTakeOverPebTebRanges now creates a small ~1MB ARM3 memory range on top of the ReactOS per-process VA. This does a couple of things: First of all, it changes the default PEB address to another static address. Still not dynamic like it will be soon, but at least it changes it a bit so we can test if anything breaks due to that. It also likewise changes the addresses of the TEBs (Shifted down by 1MB, basically). Finally, it blocks off that part of address space, which nobody should be using now, to see if anyone does indeed touch it. [NTOS]: Knowing if this change causes issues will help later in determining regressions due to TEB/PEBs mapped as VADs by ARM3, and regressions simply due to the change in VA layout. [NTOS]: When implemented, the VAD mapping for PEB/TEB will only use that ~1MB, which yes, will limit ReactOS processes to each have only 256 threads. That is obviously a temporary limitation, one I doubt we'll even hit, but I'm putting it out here so you know. svn path=/trunk/; revision=48176 --- reactos/ntoskrnl/mm/ARM3/procsup.c | 27 +++++++++++++++++++++++++-- reactos/ntoskrnl/mm/procsup.c | 13 +++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 63b0942f2e7..d2ea798914d 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -25,6 +25,29 @@ MiCreatePebOrTeb(PEPROCESS Process, /* PRIVATE FUNCTIONS **********************************************************/ +VOID +NTAPI +MiRosTakeOverPebTebRanges(IN PEPROCESS Process) +{ + NTSTATUS Status; + PMEMORY_AREA MemoryArea; + PHYSICAL_ADDRESS BoundaryAddressMultiple; + PVOID AllocatedBase = (PVOID)MI_LOWEST_VAD_ADDRESS; + BoundaryAddressMultiple.QuadPart = 0; + + Status = MmCreateMemoryArea(&Process->Vm, + MEMORY_AREA_OWNED_BY_ARM3, + &AllocatedBase, + ((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - 1) - + (ULONG_PTR)MI_LOWEST_VAD_ADDRESS, + PAGE_READWRITE, + &MemoryArea, + TRUE, + 0, + BoundaryAddressMultiple); + ASSERT(NT_SUCCESS(Status)); +} + VOID NTAPI MmDeleteKernelStack(IN PVOID StackBase, @@ -394,8 +417,8 @@ MmCreatePeb(IN PEPROCESS Process, // Peb = MiCreatePebOrTeb(Process, (PVOID)((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1)); - ASSERT(Peb == (PVOID)0x7FFDF000); - + if (!Peb) return STATUS_INSUFFICIENT_RESOURCES; + // // Map NLS Tables // diff --git a/reactos/ntoskrnl/mm/procsup.c b/reactos/ntoskrnl/mm/procsup.c index ededba8ff46..1e5bd9afb2d 100644 --- a/reactos/ntoskrnl/mm/procsup.c +++ b/reactos/ntoskrnl/mm/procsup.c @@ -13,8 +13,10 @@ #define NDEBUG #include -/* FUNCTIONS *****************************************************************/ +VOID NTAPI MiRosTakeOverPebTebRanges(IN PEPROCESS Process); +/* FUNCTIONS *****************************************************************/ + PVOID NTAPI MiCreatePebOrTeb(PEPROCESS Process, @@ -111,6 +113,9 @@ MmInitializeHandBuiltProcess2(IN PEPROCESS Process) FALSE, 0, BoundaryAddressMultiple); + + /* Lock the VAD, ARM3-owned ranges away */ + MiRosTakeOverPebTebRanges(Process); return Status; } @@ -192,7 +197,10 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, { DPRINT1("Failed to create Shared User Data\n"); goto exit; - } + } + + /* Lock the VAD, ARM3-owned ranges away */ + MiRosTakeOverPebTebRanges(Process); /* The process now has an address space */ Process->HasAddressSpace = TRUE; @@ -319,6 +327,7 @@ MmDeleteProcessAddressSpace(PEPROCESS Process) case MEMORY_AREA_SHARED_DATA: case MEMORY_AREA_NO_ACCESS: + case MEMORY_AREA_OWNED_BY_ARM3: MmFreeMemoryArea(&Process->Vm, MemoryArea, NULL, -- 2.17.1