mirror of
https://github.com/reactos/reactos.git
synced 2025-04-19 12:08:55 +00:00
- 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. svn path=/trunk/; revision=24408
This commit is contained in:
parent
52d60b023b
commit
0bfcd77883
8 changed files with 123 additions and 249 deletions
|
@ -45,9 +45,104 @@ ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
|||
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
|
||||
INIT_FUNCTION
|
||||
|
@ -781,8 +876,8 @@ ExPhase2Init(PVOID Context)
|
|||
/* 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);
|
||||
|
|
|
@ -14,6 +14,9 @@ extern ULONG NtMinorVersion;
|
|||
extern FAST_MUTEX ExpEnvironmentLock;
|
||||
extern ERESOURCE ExpFirmwareTableResource;
|
||||
extern LIST_ENTRY ExpFirmwareTableProviderListHead;
|
||||
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
||||
ULONG ExpUnicodeCaseTableDataOffset;
|
||||
PVOID ExpNlsSectionPointer;
|
||||
|
||||
#define MAX_FAST_REFS 7
|
||||
|
||||
|
|
|
@ -1,48 +1,6 @@
|
|||
#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
|
||||
RtlQueryAtomListInAtomTable(
|
||||
|
|
|
@ -407,6 +407,25 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
|||
DPRINT1("SMP Boot support not yet present\n");
|
||||
}
|
||||
|
||||
/* Setup the Idle Thread */
|
||||
KeInitializeThread(InitProcess,
|
||||
InitThread,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
IdleStack);
|
||||
InitThread->NextProcessor = Number;
|
||||
InitThread->Priority = HIGH_PRIORITY;
|
||||
InitThread->State = Running;
|
||||
InitThread->Affinity = 1 << Number;
|
||||
InitThread->WaitIrql = DISPATCH_LEVEL;
|
||||
InitProcess->ActiveProcessors = 1 << Number;
|
||||
|
||||
/* HACK for MmUpdatePageDir */
|
||||
((PETHREAD)InitThread)->ThreadsProcess = (PEPROCESS)InitProcess;
|
||||
|
||||
/* Initialize Kernel Memory Address Space */
|
||||
MmInit1(FirstKrnlPhysAddr,
|
||||
LastKrnlPhysAddr,
|
||||
|
@ -435,25 +454,6 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
|
|||
SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] =
|
||||
(KeFeatureBits & KF_RDTSC);
|
||||
|
||||
/* Setup the Idle Thread */
|
||||
KeInitializeThread(InitProcess,
|
||||
InitThread,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
IdleStack);
|
||||
InitThread->NextProcessor = Number;
|
||||
InitThread->Priority = HIGH_PRIORITY;
|
||||
InitThread->State = Running;
|
||||
InitThread->Affinity = 1 << Number;
|
||||
InitThread->WaitIrql = DISPATCH_LEVEL;
|
||||
InitProcess->ActiveProcessors = 1 << Number;
|
||||
|
||||
/* HACK for MmUpdatePageDir */
|
||||
((PETHREAD)InitThread)->ThreadsProcess = (PEPROCESS)InitProcess;
|
||||
|
||||
/* Set up the thread-related fields in the PRCB */
|
||||
Prcb->CurrentThread = InitThread;
|
||||
Prcb->NextThread = NULL;
|
||||
|
|
|
@ -291,7 +291,7 @@ MmCreatePeb(PEPROCESS Process)
|
|||
|
||||
/* Map NLS Tables */
|
||||
DPRINT("Mapping NLS\n");
|
||||
Status = MmMapViewOfSection(NlsSectionObject,
|
||||
Status = MmMapViewOfSection(ExpNlsSectionPointer,
|
||||
(PEPROCESS)Process,
|
||||
&TableBase,
|
||||
0,
|
||||
|
@ -322,9 +322,9 @@ MmCreatePeb(PEPROCESS Process)
|
|||
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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -198,9 +198,6 @@ RtlpCaptureStackLimits(IN ULONG_PTR Ebp,
|
|||
|
||||
/* FIXME: Super native implementation */
|
||||
|
||||
/* FIXME: ROS HACK */
|
||||
if (!Thread) return FALSE;
|
||||
|
||||
/* Start with defaults */
|
||||
*StackBegin = Thread->StackLimit;
|
||||
*StackEnd = (ULONG_PTR)Thread->StackBase;
|
||||
|
|
|
@ -1,178 +0,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);
|
||||
}
|
Loading…
Reference in a new issue