Implemented NLS file import.

svn path=/trunk/; revision=4726
This commit is contained in:
Eric Kohl 2003-05-19 14:39:09 +00:00
parent e76752c103
commit 7e921a40c1
5 changed files with 274 additions and 4 deletions

View file

@ -4,4 +4,7 @@ system32\drivers\class2.sys
system32\drivers\disk.sys
system32\drivers\vfatfs.sys
system32\config\system
system32\ansi.nls
system32\oem.nls
system32\casemap.nls
*

View file

@ -20,8 +20,24 @@
#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;
PUSHORT NlsUnicodeLowercaseTable;
VOID RtlpCreateDefaultNlsTables(VOID);
VOID RtlpImportAnsiCodePage(PUSHORT TableBase, ULONG Size);
VOID RtlpImportOemCodePage(PUSHORT TableBase, ULONG Size);
VOID RtlpImportUnicodeCasemap(PUSHORT TableBase, ULONG Size);
VOID RtlpCreateNlsSection(VOID);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_NLS_H */
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: main.c,v 1.156 2003/05/17 13:40:03 hbirr Exp $
/* $Id: main.c,v 1.157 2003/05/19 14:35:48 ekohl Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
@ -459,6 +459,79 @@ ExpInitializeExecutive(VOID)
}
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
length = KeLoaderModules[i].ModEnd - start;
DPRINT("Module: '%s'\n", (PCHAR)KeLoaderModules[i].String);
name = strrchr((PCHAR)KeLoaderModules[i].String, '\\');
if (name == NULL)
{
name = (PCHAR)KeLoaderModules[i].String;
}
else
{
name++;
}
if (!_stricmp (name, "ansi.nls"))
{
DPRINT1("Process ANSI code page file at %08lx\n", start);
RtlpImportAnsiCodePage((PUSHORT)start, length);
}
}
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
length = KeLoaderModules[i].ModEnd - start;
DPRINT("Module: '%s'\n", (PCHAR)KeLoaderModules[i].String);
name = strrchr((PCHAR)KeLoaderModules[i].String, '\\');
if (name == NULL)
{
name = (PCHAR)KeLoaderModules[i].String;
}
else
{
name++;
}
if (!_stricmp (name, "oem.nls"))
{
DPRINT1("Process OEM code page file at %08lx\n", start);
RtlpImportOemCodePage((PUSHORT)start, length);
}
}
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
length = KeLoaderModules[i].ModEnd - start;
DPRINT("Module: '%s'\n", (PCHAR)KeLoaderModules[i].String);
name = strrchr((PCHAR)KeLoaderModules[i].String, '\\');
if (name == NULL)
{
name = (PCHAR)KeLoaderModules[i].String;
}
else
{
name++;
}
if (!_stricmp (name, "casemap.nls"))
{
DPRINT1("Process Unicode casemap file at %08lx\n", start);
RtlpImportUnicodeCasemap((PUSHORT)start, length);
}
}
RtlpCreateNlsSection();
/* Pass 2: import system hive registry chunk */
SetupBoot = TRUE;
for (i = 1; i < KeLoaderBlock.ModsCount; i++)

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.101 2003/05/17 19:16:39 ekohl Exp $
/* $Id: process.c,v 1.102 2003/05/19 14:36:53 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -28,6 +28,7 @@
#include <roscfg.h>
#include <internal/se.h>
#include <internal/kd.h>
#include <internal/nls.h>
#define NDEBUG
#include <internal/debug.h>
@ -318,6 +319,10 @@ PsCreatePeb(HANDLE ProcessHandle,
PPEB Peb;
NTSTATUS Status;
LARGE_INTEGER SectionOffset;
ULONG ViewSize;
PVOID TableBase;
/* Allocate the Process Environment Block (PEB) */
Peb = (PPEB)PEB_BASE;
PebSize = PAGE_SIZE;
@ -334,12 +339,34 @@ PsCreatePeb(HANDLE ProcessHandle,
}
DPRINT("Peb %p PebSize %lu\n", Peb, PebSize);
ViewSize = 0;
SectionOffset.QuadPart = 0LL;
Status = MmMapViewOfSection(NlsSectionObject,
Process,
&TableBase,
0,
0,
&SectionOffset,
&ViewSize,
ViewShare,
SEC_NO_CHANGE | MEM_TOP_DOWN,
PAGE_READONLY);
if (!NT_SUCCESS(Status))
{
DPRINT1("MmMapViewOfSection() failed (Status %lx)\n", Status);
return(Status);
}
DPRINT("TableBase %p ViewSize %lx\n", TableBase, ViewSize);
KeAttachProcess(Process);
/* Initialize the PEB */
RtlZeroMemory(Peb, sizeof(PEB));
Peb->ImageBaseAddress = ImageBase;
Peb->AnsiCodePageData = TableBase + NlsAnsiTableOffset;
Peb->OemCodePageData = TableBase + NlsOemTableOffset;
Peb->UnicodeCaseTableData = TableBase + NlsUnicodeTableOffset;
Process->Peb = Peb;
KeDetachProcess();

View file

@ -1,4 +1,4 @@
/* $Id: nls.c,v 1.12 2003/05/16 17:38:41 ekohl Exp $
/* $Id: nls.c,v 1.13 2003/05/19 14:39:09 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -50,6 +50,26 @@ PWCHAR UnicodeUpcaseTable = NULL; /* size: 65536*sizeof(WCHAR) */
PWCHAR UnicodeLowercaseTable = NULL; /* size: 65536*sizeof(WCHAR) */
/* Experimental */
PUSHORT NlsAnsiCodePageTable = NULL;
ULONG NlsAnsiCodePageTableSize = 0;
PUSHORT NlsOemCodePageTable = NULL;
ULONG NlsOemCodePageTableSize = 0;
PUSHORT NlsUnicodeCasemapTable = NULL;
ULONG NlsUnicodeCasemapTableSize = 0;
PVOID NlsSectionObject = NULL;
PVOID NlsSectionBase = NULL;
ULONG NlsSectionViewSize = 0;
ULONG NlsAnsiTableOffset = 0;
ULONG NlsOemTableOffset = 0;
ULONG NlsUnicodeTableOffset = 0;
/* FUNCTIONS *****************************************************************/
VOID
@ -144,6 +164,137 @@ RtlpCreateDefaultNlsTables(VOID)
}
VOID
RtlpImportAnsiCodePage(PUSHORT TableBase,
ULONG Size)
{
DPRINT1("RtlpImportAnsiCodePage(TableBase %p Size %lu) called\n",
TableBase, Size);
NlsAnsiCodePageTable = ExAllocatePool(NonPagedPool,
Size);
if (NlsAnsiCodePageTable != NULL)
{
NlsAnsiCodePageTableSize = Size;
RtlCopyMemory(NlsAnsiCodePageTable,
TableBase,
Size);
}
}
VOID
RtlpImportOemCodePage(PUSHORT TableBase,
ULONG Size)
{
DPRINT1("RtlpImportOemCodePage(TableBase %p Size %lu) called\n",
TableBase, Size);
NlsOemCodePageTable = ExAllocatePool(NonPagedPool,
Size);
if (NlsOemCodePageTable != NULL)
{
NlsOemCodePageTableSize = Size;
RtlCopyMemory(NlsOemCodePageTable,
TableBase,
Size);
}
}
VOID
RtlpImportUnicodeCasemap(PUSHORT TableBase,
ULONG Size)
{
DPRINT1("RtlpImportUnicodeCasemap(TableBase %p Size %lu) called\n",
TableBase, Size);
NlsUnicodeCasemapTable = ExAllocatePool(NonPagedPool,
Size);
if (NlsUnicodeCasemapTable != NULL)
{
NlsUnicodeCasemapTableSize = Size;
RtlCopyMemory(NlsUnicodeCasemapTable,
TableBase,
Size);
}
}
VOID
RtlpCreateNlsSection(VOID)
{
HANDLE SectionHandle;
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 = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
&SectionSize,
PAGE_READWRITE,
SEC_COMMIT,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateSection() failed\n");
KeBugCheckEx(0x32, Status, 1, 0, 0);
}
Status = ObReferenceObjectByHandle(SectionHandle,
SECTION_ALL_ACCESS,
MmSectionObjectType,
KernelMode,
&NlsSectionObject,
NULL);
NtClose(SectionHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("ObReferenceObjectByHandle() failed\n");
KeBugCheckEx(0x32, Status, 1, 1, 0);
}
Status = MmMapViewInSystemSpace(NlsSectionObject,
&NlsSectionBase,
&NlsSectionViewSize);
NtClose(SectionHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("MmMapViewInSystemSpace() failed\n");
KeBugCheckEx(0x32, Status, 1, 2, 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);
}
NTSTATUS STDCALL
RtlCustomCPToUnicodeN(IN PCPTABLEINFO CustomCP,
PWCHAR UnicodeString,
@ -200,7 +351,7 @@ RtlInitCodePageTable(IN PUSHORT TableBase,
PUSHORT Ptr;
USHORT Offset;
DPRINT1("RtlInitCodePageTable() called\n");
DPRINT("RtlInitCodePageTable() called\n");
NlsFileHeader = (PNLS_FILE_HEADER)TableBase;