Author: ion Date: Thu Oct 5 05:44:54 2006 New Revision: 24408
URL: http://svn.reactos.org/svn/reactos?rev=24408&view=rev Log: - Implement ExpInitNls to initialize the NLS Section using the new semantics recently implemented. Works pretty much like the previous code in rtl/nls.c except it uses the new variable names as well as maps a view of the NLS Table into the system process.c - Delete rtl/nls.c and all the associated deprecated code. - Do MmInit1 and SharedUserData stuff *after* initializing the initial thread, to avoid an ASSERT during bootup.
Removed: trunk/reactos/ntoskrnl/rtl/nls.c Modified: trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ex.h trunk/reactos/ntoskrnl/include/internal/rtl.h trunk/reactos/ntoskrnl/ke/i386/kiinit.c trunk/reactos/ntoskrnl/mm/process.c trunk/reactos/ntoskrnl/ntoskrnl.rbuild trunk/reactos/ntoskrnl/rtl/libsupp.c
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=2440... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Oct 5 05:44:54 2006 @@ -45,8 +45,103 @@ ULONG ExpUnicodeCaseTableDataOffset; NLSTABLEINFO ExpNlsTableInfo; ULONG ExpNlsTableSize; +PVOID ExpNlsSectionPointer;
/* FUNCTIONS ****************************************************************/ + +VOID +NTAPI +ExpInitNls(VOID) +{ + LARGE_INTEGER SectionSize; + NTSTATUS Status; + HANDLE NlsSection; + PVOID SectionBase = NULL; + ULONG ViewSize = 0; + LARGE_INTEGER SectionOffset = {{0}}; + + /* Set the section size */ + SectionSize.QuadPart = ExpNlsTableSize; + + /* Create the NLS Section */ + Status = ZwCreateSection(&NlsSection, + SECTION_ALL_ACCESS, + NULL, + &SectionSize, + PAGE_READWRITE, + SEC_COMMIT, + NULL); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 1, 0, 0); + } + + /* Get a pointer to the section */ + Status = ObReferenceObjectByHandle(NlsSection, + SECTION_ALL_ACCESS, + MmSectionObjectType, + KernelMode, + &ExpNlsSectionPointer, + NULL); + ZwClose(NlsSection); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0); + } + + /* Map the NLS Section in system space */ + Status = MmMapViewInSystemSpace(ExpNlsSectionPointer, + &SectionBase, + &ExpNlsTableSize); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0); + } + + /* Copy the codepage data in its new location. */ + RtlMoveMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize); + + /* Free the previously allocated buffer and set the new location */ + ExFreePool(ExpNlsTableBase); + ExpNlsTableBase = SectionBase; + + /* Initialize the NLS Tables */ + RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase + + ExpAnsiCodePageDataOffset), + (PVOID)((ULONG_PTR)ExpNlsTableBase + + ExpOemCodePageDataOffset), + (PVOID)((ULONG_PTR)ExpNlsTableBase + + ExpUnicodeCaseTableDataOffset), + &ExpNlsTableInfo); + RtlResetRtlTranslations(&ExpNlsTableInfo); + + /* Reset the base to 0 */ + SectionBase = NULL; + + /* Map the section in the system process */ + Status = MmMapViewOfSection(ExpNlsSectionPointer, + PsGetCurrentProcess(), + &SectionBase, + 0L, + 0L, + &SectionOffset, + &ViewSize, + ViewShare, + 0L, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 5, 0, 0); + } + + /* Copy the table into the system process and set this as the base */ + RtlMoveMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize); + ExpNlsTableBase = SectionBase; +}
static VOID @@ -781,8 +876,8 @@ /* Call KD Providers at Phase 2 */ KdInitSystem(2, KeLoaderBlock);
- /* Import and create NLS Data and Sections */ - RtlpInitNls(); + /* Create NLS section */ + ExpInitNls();
/* Import and Load Registry Hives */ CmInitHives(ExpInTextModeSetup);
Modified: trunk/reactos/ntoskrnl/include/internal/ex.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/e... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ex.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ex.h Thu Oct 5 05:44:54 2006 @@ -14,6 +14,9 @@ extern FAST_MUTEX ExpEnvironmentLock; extern ERESOURCE ExpFirmwareTableResource; extern LIST_ENTRY ExpFirmwareTableProviderListHead; +ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset; +ULONG ExpUnicodeCaseTableDataOffset; +PVOID ExpNlsSectionPointer;
#define MAX_FAST_REFS 7
Modified: trunk/reactos/ntoskrnl/include/internal/rtl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/r... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/rtl.h (original) +++ trunk/reactos/ntoskrnl/include/internal/rtl.h Thu Oct 5 05:44:54 2006 @@ -1,47 +1,5 @@ #ifndef __NTOSKRNL_INCLUDE_INTERNAL_NLS_H #define __NTOSKRNL_INCLUDE_INTERNAL_NLS_H - -extern PVOID NlsSectionObject; - -extern ULONG NlsAnsiTableOffset; -extern ULONG NlsOemTableOffset; -extern ULONG NlsUnicodeTableOffset; - -extern PUSHORT NlsUnicodeUpcaseTable; -extern PUSHORT NlsUnicodeLowercaseTable; - -VOID -NTAPI -RtlpInitNls(VOID); - -VOID -NTAPI -RtlpImportAnsiCodePage( - PUSHORT TableBase, - ULONG Size -); - -VOID -NTAPI -RtlpImportOemCodePage( - PUSHORT TableBase, - ULONG Size -); - -VOID -NTAPI -RtlpImportUnicodeCasemap( - PUSHORT TableBase, - ULONG Size -); - -VOID -NTAPI -RtlpCreateInitialNlsTables(VOID); - -VOID -NTAPI -RtlpCreateNlsSection(VOID);
NTSTATUS NTAPI
Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original) +++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Thu Oct 5 05:44:54 2006 @@ -407,34 +407,6 @@ DPRINT1("SMP Boot support not yet present\n"); }
- /* Initialize Kernel Memory Address Space */ - MmInit1(FirstKrnlPhysAddr, - LastKrnlPhysAddr, - LastKernelAddress, - (PADDRESS_RANGE)&KeMemoryMap, - KeMemoryMapRangeCount, - 4096); - - /* Sets up the Text Sections of the Kernel and HAL for debugging */ - LdrInit1(); - - /* Set the NX Support policy */ - SharedUserData->NXSupportPolicy = NXSupportPolicy; - - /* Set basic CPU Features that user mode can read */ - SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = - (KeFeatureBits & KF_MMX); - SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = - (KeFeatureBits & KF_CMPXCHG8B); - SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = - ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI)); - SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = - ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI64)); - SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = - (KeFeatureBits & KF_3DNOW); - SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = - (KeFeatureBits & KF_RDTSC); - /* Setup the Idle Thread */ KeInitializeThread(InitProcess, InitThread, @@ -454,6 +426,34 @@ /* HACK for MmUpdatePageDir */ ((PETHREAD)InitThread)->ThreadsProcess = (PEPROCESS)InitProcess;
+ /* Initialize Kernel Memory Address Space */ + MmInit1(FirstKrnlPhysAddr, + LastKrnlPhysAddr, + LastKernelAddress, + (PADDRESS_RANGE)&KeMemoryMap, + KeMemoryMapRangeCount, + 4096); + + /* Sets up the Text Sections of the Kernel and HAL for debugging */ + LdrInit1(); + + /* Set the NX Support policy */ + SharedUserData->NXSupportPolicy = NXSupportPolicy; + + /* Set basic CPU Features that user mode can read */ + SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = + (KeFeatureBits & KF_MMX); + SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = + (KeFeatureBits & KF_CMPXCHG8B); + SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = + ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI)); + SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = + ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI64)); + SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = + (KeFeatureBits & KF_3DNOW); + SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = + (KeFeatureBits & KF_RDTSC); + /* Set up the thread-related fields in the PRCB */ Prcb->CurrentThread = InitThread; Prcb->NextThread = NULL;
Modified: trunk/reactos/ntoskrnl/mm/process.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/process.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/mm/process.c (original) +++ trunk/reactos/ntoskrnl/mm/process.c Thu Oct 5 05:44:54 2006 @@ -291,7 +291,7 @@
/* Map NLS Tables */ DPRINT("Mapping NLS\n"); - Status = MmMapViewOfSection(NlsSectionObject, + Status = MmMapViewOfSection(ExpNlsSectionPointer, (PEPROCESS)Process, &TableBase, 0, @@ -322,9 +322,9 @@ Peb->Mutant = NULL;
/* NLS */ - Peb->AnsiCodePageData = (char*)TableBase + NlsAnsiTableOffset; - Peb->OemCodePageData = (char*)TableBase + NlsOemTableOffset; - Peb->UnicodeCaseTableData = (char*)TableBase + NlsUnicodeTableOffset; + Peb->AnsiCodePageData = (PCHAR)TableBase + ExpAnsiCodePageDataOffset; + Peb->OemCodePageData = (PCHAR)TableBase + ExpOemCodePageDataOffset; + Peb->UnicodeCaseTableData = (PCHAR)TableBase + ExpUnicodeCaseTableDataOffset;
/* Default Version Data (could get changed below) */ Peb->OSMajorVersion = NtMajorVersion;
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?re... ============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Thu Oct 5 05:44:54 2006 @@ -315,7 +315,6 @@ </if> <file>libsupp.c</file> <file>misc.c</file> - <file>nls.c</file> <file>regio.c</file> <file>strtok.c</file> </directory>
Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/libsupp.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/rtl/libsupp.c (original) +++ trunk/reactos/ntoskrnl/rtl/libsupp.c Thu Oct 5 05:44:54 2006 @@ -197,9 +197,6 @@ PKTHREAD Thread = KeGetCurrentThread();
/* FIXME: Super native implementation */ - - /* FIXME: ROS HACK */ - if (!Thread) return FALSE;
/* Start with defaults */ *StackBegin = Thread->StackLimit;
Removed: trunk/reactos/ntoskrnl/rtl/nls.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/nls.c?rev=2440... ============================================================================== --- trunk/reactos/ntoskrnl/rtl/nls.c (original) +++ trunk/reactos/ntoskrnl/rtl/nls.c (removed) @@ -1,178 +1,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/nls.c - * PURPOSE: Bitmap functions - * - * PROGRAMMERS: Eric Kohl - */ - -#include <ntoskrnl.h> -#define NDEBUG -#include <internal/debug.h> - -#if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, RtlpInitNls) -#pragma alloc_text(INIT, RtlpImportAnsiCodePage) -#pragma alloc_text(INIT, RtlpImportOemCodePage) -#pragma alloc_text(INIT, RtlpImportUnicodeCasemap) -#pragma alloc_text(INIT, RtlpCreateInitialNlsTables) -#pragma alloc_text(INIT, RtlpCreateNlsSection) -#endif - - -/* GLOBALS *******************************************************************/ - - -static PUSHORT NlsAnsiCodePageTable = NULL; -static ULONG NlsAnsiCodePageTableSize = 0; - -static PUSHORT NlsOemCodePageTable = NULL; -static ULONG NlsOemCodePageTableSize = 0; - -static PUSHORT NlsUnicodeCasemapTable = NULL; -static ULONG NlsUnicodeCasemapTableSize = 0; - -PVOID NlsSectionObject = NULL; -static PVOID NlsSectionBase = NULL; -static ULONG NlsSectionViewSize = 0; - -ULONG NlsAnsiTableOffset = 0; -ULONG NlsOemTableOffset = 0; -ULONG NlsUnicodeTableOffset = 0; - - -/* FUNCTIONS *****************************************************************/ - -VOID -INIT_FUNCTION -STDCALL -RtlpInitNls(VOID) -{ - ULONG_PTR BaseAddress; - - /* Import NLS Data */ - BaseAddress = CachedModules[AnsiCodepage]->ModStart; - RtlpImportAnsiCodePage((PUSHORT)BaseAddress, - CachedModules[AnsiCodepage]->ModEnd - BaseAddress); - - BaseAddress = CachedModules[OemCodepage]->ModStart; - RtlpImportOemCodePage((PUSHORT)BaseAddress, - CachedModules[OemCodepage]->ModEnd - BaseAddress); - - BaseAddress = CachedModules[UnicodeCasemap]->ModStart; - RtlpImportUnicodeCasemap((PUSHORT)BaseAddress, - CachedModules[UnicodeCasemap]->ModEnd - BaseAddress); - - /* Create the NLS section */ - RtlpCreateNlsSection(); -} - -VOID -INIT_FUNCTION -NTAPI -RtlpImportAnsiCodePage(PUSHORT TableBase, - ULONG Size) -{ - NlsAnsiCodePageTable = TableBase; - NlsAnsiCodePageTableSize = Size; -} - - -VOID -INIT_FUNCTION -NTAPI -RtlpImportOemCodePage(PUSHORT TableBase, - ULONG Size) -{ - NlsOemCodePageTable = TableBase; - NlsOemCodePageTableSize = Size; -} - - -VOID -NTAPI -INIT_FUNCTION -RtlpImportUnicodeCasemap(PUSHORT TableBase, - ULONG Size) -{ - NlsUnicodeCasemapTable = TableBase; - NlsUnicodeCasemapTableSize = Size; -} - -VOID -NTAPI -INIT_FUNCTION -RtlpCreateNlsSection(VOID) -{ - NLSTABLEINFO NlsTable; - LARGE_INTEGER SectionSize; - NTSTATUS Status; - - DPRINT("RtlpCreateNlsSection() called\n"); - - NlsSectionViewSize = ROUND_UP(NlsAnsiCodePageTableSize, PAGE_SIZE) + - ROUND_UP(NlsOemCodePageTableSize, PAGE_SIZE) + - ROUND_UP(NlsUnicodeCasemapTableSize, PAGE_SIZE); - - DPRINT("NlsSectionViewSize %lx\n", NlsSectionViewSize); - - SectionSize.QuadPart = (LONGLONG)NlsSectionViewSize; - Status = MmCreateSection(&NlsSectionObject, - SECTION_ALL_ACCESS, - NULL, - &SectionSize, - PAGE_READWRITE, - SEC_COMMIT, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmCreateSection() failed\n"); - KEBUGCHECKEX(0x32, Status, 1, 1, 0); - } - Status = ObInsertObject(NlsSectionObject, - NULL, - SECTION_ALL_ACCESS, - 0, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - ObDereferenceObject(NlsSectionObject); - } - Status = MmMapViewInSystemSpace(NlsSectionObject, - &NlsSectionBase, - &NlsSectionViewSize); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmMapViewInSystemSpace() failed\n"); - KEBUGCHECKEX(0x32, Status, 1, 3, 0); - } - - DPRINT("NlsSection: Base %p Size %lx\n", - NlsSectionBase, - NlsSectionViewSize); - - NlsAnsiTableOffset = 0; - RtlCopyMemory((PVOID)((ULONG)NlsSectionBase + NlsAnsiTableOffset), - NlsAnsiCodePageTable, - NlsAnsiCodePageTableSize); - - NlsOemTableOffset = NlsAnsiTableOffset + ROUND_UP(NlsAnsiCodePageTableSize, PAGE_SIZE); - RtlCopyMemory((PVOID)((ULONG)NlsSectionBase + NlsOemTableOffset), - NlsOemCodePageTable, - NlsOemCodePageTableSize); - - NlsUnicodeTableOffset = NlsOemTableOffset + ROUND_UP(NlsOemCodePageTableSize, PAGE_SIZE); - RtlCopyMemory((PVOID)((ULONG)NlsSectionBase + NlsUnicodeTableOffset), - NlsUnicodeCasemapTable, - NlsUnicodeCasemapTableSize); - - RtlInitNlsTables ((PVOID)((ULONG)NlsSectionBase + NlsAnsiTableOffset), - (PVOID)((ULONG)NlsSectionBase + NlsOemTableOffset), - (PVOID)((ULONG)NlsSectionBase + NlsUnicodeTableOffset), - &NlsTable); - - RtlResetRtlTranslations (&NlsTable); -}