From 8be271b56b87f9a77bed1c337f17349f707e9e35 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Thu, 4 Aug 2011 13:10:57 +0000 Subject: [PATCH] [NTOSKRNL]: NLS tables should be mapped before PEB. [NTOSKRNL]: Handle failure of NLS and PEB mapping correctly. [NTOSKRNL]: Only set Peb->OsCSDVersion if NtHeader->Win32VersionValue is set. svn path=/trunk/; revision=53059 --- reactos/ntoskrnl/mm/ARM3/procsup.c | 63 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index f40e5171256..79612f17b31 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -576,13 +576,7 @@ MmCreatePeb(IN PEPROCESS Process, // Attach to Process // KeAttachProcess(&Process->Pcb); - - // - // Allocate the PEB - // - Status = MiCreatePebOrTeb(Process, sizeof(PEB), (PULONG_PTR)&Peb); - ASSERT(NT_SUCCESS(Status)); - + // // Map NLS Tables // @@ -596,7 +590,25 @@ MmCreatePeb(IN PEPROCESS Process, ViewShare, MEM_TOP_DOWN, PAGE_READONLY); - if (!NT_SUCCESS(Status)) return Status; + DPRINT1("NLS Tables at: %p\n", TableBase); + if (!NT_SUCCESS(Status)) + { + /* Cleanup and exit */ + KeDetachProcess(); + return Status; + } + + // + // Allocate the PEB + // + Status = MiCreatePebOrTeb(Process, sizeof(PEB), (PULONG_PTR)&Peb); + DPRINT1("PEB at: %p\n", Peb); + if (!NT_SUCCESS(Status)) + { + /* Cleanup and exit */ + KeDetachProcess(); + return Status; + } // // Use SEH in case we can't load the PEB @@ -636,7 +648,7 @@ MmCreatePeb(IN PEPROCESS Process, // Heap and Debug Data // Peb->NumberOfProcessors = KeNumberProcessors; - Peb->BeingDebugged = (BOOLEAN)(Process->DebugPort != NULL ? TRUE : FALSE); + Peb->BeingDebugged = (BOOLEAN)(Process->DebugPort != NULL); Peb->NtGlobalFlag = NtGlobalFlag; /*Peb->HeapSegmentReserve = MmHeapSegmentReserve; Peb->HeapSegmentCommit = MmHeapSegmentCommit; @@ -730,34 +742,20 @@ MmCreatePeb(IN PEPROCESS Process, Peb->OSMinorVersion = (NtHeaders->OptionalHeader.Win32VersionValue >> 8) & 0xFF; Peb->OSBuildNumber = (NtHeaders->OptionalHeader.Win32VersionValue >> 16) & 0x3FFF; Peb->OSPlatformId = (NtHeaders->OptionalHeader.Win32VersionValue >> 30) ^ 2; - } - // - // Process the image config data overrides if specfied - // - if (ImageConfigData != NULL) - { - // - // Process CSD version override - // - if (ImageConfigData->CSDVersion) + /* Process CSD version override */ + if ((ImageConfigData) && (ImageConfigData->CSDVersion)) { - // - // Set new data - // + /* Take the value from the image configuration directory */ Peb->OSCSDVersion = ImageConfigData->CSDVersion; } + } - // - // Process affinity mask ovverride - // - if (ImageConfigData->ProcessAffinityMask) - { - // - // Set new data - // - ProcessAffinityMask = ImageConfigData->ProcessAffinityMask; - } + /* Process optional process affinity mask override */ + if ((ImageConfigData) && (ImageConfigData->ProcessAffinityMask)) + { + /* Take the value from the image configuration directory */ + ProcessAffinityMask = ImageConfigData->ProcessAffinityMask; } // @@ -767,6 +765,7 @@ MmCreatePeb(IN PEPROCESS Process, // // Force it to use CPU 0 // + /* FIXME: this should use the MmRotatingUniprocessorNumber */ Peb->ImageProcessAffinityMask = 0; } else