Prepared loading of .nls files

svn path=/trunk/; revision=2019
This commit is contained in:
Eric Kohl 2001-06-29 20:43:55 +00:00
parent b6da4ac7a1
commit 965c424c85
2 changed files with 248 additions and 130 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: main.c,v 1.97 2001/06/04 11:27:54 chorns Exp $ /* $Id: main.c,v 1.98 2001/06/29 20:43:55 ekohl Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c * FILE: ntoskrnl/ke/main.c
@ -39,6 +39,7 @@
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/io.h> #include <internal/io.h>
#include <internal/po.h> #include <internal/po.h>
#include <internal/se.h>
#include <napi/shared_data.h> #include <napi/shared_data.h>
#include <internal/v86m.h> #include <internal/v86m.h>
#include <internal/kd.h> #include <internal/kd.h>
@ -66,6 +67,29 @@ volatile BOOLEAN Initialized = FALSE;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
static BOOLEAN
RtlpCheckFileNameExtension(PCHAR FileName,
PCHAR Extension)
{
PCHAR Ext;
Ext = strrchr(FileName, '.');
if ((Extension == NULL) || (*Extension == 0))
{
if (Ext == NULL)
return TRUE;
else
return FALSE;
}
if (*Extension != '.')
Ext++;
if (_stricmp(Ext, Extension) == 0)
return TRUE;
else
return FALSE;
}
static VOID static VOID
CreateSystemRootLink (PCSZ ParameterLine) CreateSystemRootLink (PCSZ ParameterLine)
{ {
@ -476,7 +500,7 @@ ExpInitializeExecutive(VOID)
HalDisplayString("are welcome to change it and/or distribute copies of it " HalDisplayString("are welcome to change it and/or distribute copies of it "
"under certain\n"); "under certain\n");
HalDisplayString("conditions. There is absolutely no warranty for " HalDisplayString("conditions. There is absolutely no warranty for "
"ReactOS.\n"); "ReactOS.\n\n");
/* Initialize all processors */ /* Initialize all processors */
KeNumberProcessors = 0; KeNumberProcessors = 0;
@ -494,12 +518,16 @@ ExpInitializeExecutive(VOID)
if (KeNumberProcessors > 1) if (KeNumberProcessors > 1)
{ {
sprintf(str, "Found %d system processors.\n", sprintf(str,
KeNumberProcessors); "Found %d system processors. [%lu MB Memory]\n",
KeNumberProcessors,
(KeLoaderBlock.MemHigher + 1088)/ 1024);
} }
else else
{ {
strcpy(str, "Found 1 system processor.\n"); sprintf(str,
"Found 1 system processor. [%lu MB Memory]\n",
(KeLoaderBlock.MemHigher + 1088)/ 1024);
} }
HalDisplayString(str); HalDisplayString(str);
@ -519,12 +547,7 @@ ExpInitializeExecutive(VOID)
/* Report all resources used by hal */ /* Report all resources used by hal */
HalReportResourceUsage(); HalReportResourceUsage();
/* // DumpBIOSMemoryMap();
* Enter the kernel debugger before starting up the boot drivers
*/
#ifdef KDBG
KdbEnter();
#endif /* KDBG */
/* /*
* Initalize services loaded at boot time * Initalize services loaded at boot time
@ -532,27 +555,76 @@ ExpInitializeExecutive(VOID)
DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount); DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount);
for (i=0; i < KeLoaderBlock.ModsCount; i++) for (i=0; i < KeLoaderBlock.ModsCount; i++)
{ {
CPRINT("Module: %s\n", KeLoaderModules[i].String); CPRINT("Module: '%s' at %08lx, length 0x%08lx\n",
KeLoaderModules[i].String,
KeLoaderModules[i].ModStart,
KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart);
} }
/* Pass 1: load registry chunks passed in */ /* Pass 1: load nls files */
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
name = (PCHAR)KeLoaderModules[i].String;
if (RtlpCheckFileNameExtension(name, ".nls"))
{
ULONG Mod2Start = 0;
ULONG Mod2End = 0;
ULONG Mod3Start = 0;
ULONG Mod3End = 0;
name = (PCHAR)KeLoaderModules[i+1].String;
if (RtlpCheckFileNameExtension(name, ".nls"))
{
Mod2Start = (ULONG)KeLoaderModules[i+1].ModStart;
Mod2End = (ULONG)KeLoaderModules[i+1].ModEnd;
name = (PCHAR)KeLoaderModules[i+2].String;
if (RtlpCheckFileNameExtension(name, ".nls"))
{
Mod3Start = (ULONG)KeLoaderModules[i+2].ModStart;
Mod3End = (ULONG)KeLoaderModules[i+2].ModEnd;
}
}
/* Initialize nls sections */
RtlpInitNlsSections((ULONG)KeLoaderModules[i].ModStart,
(ULONG)KeLoaderModules[i].ModEnd,
Mod2Start,
Mod2End,
Mod3Start,
Mod3End);
break;
}
}
/* Pass 2: load registry chunks passed in */
for (i = 1; i < KeLoaderBlock.ModsCount; i++) for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{ {
start = KeLoaderModules[i].ModStart; start = KeLoaderModules[i].ModStart;
if (strcmp ((PCHAR) start, "REGEDIT4") == 0) name = (PCHAR)KeLoaderModules[i].String;
if (RtlpCheckFileNameExtension(name, "") ||
RtlpCheckFileNameExtension(name, ".hiv"))
{ {
CPRINT("Process registry chunk at %08lx\n", start); CPRINT("Process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start); CmImportHive((PCHAR) start);
} }
} }
/* Pass 2: process boot loaded drivers */ /*
* Enter the kernel debugger before starting up the boot drivers
*/
#ifdef KDBG
KdbEnter();
#endif /* KDBG */
/* Pass 3: process boot loaded drivers */
for (i=1; i < KeLoaderBlock.ModsCount; i++) for (i=1; i < KeLoaderBlock.ModsCount; i++)
{ {
start = KeLoaderModules[i].ModStart; start = KeLoaderModules[i].ModStart;
length = KeLoaderModules[i].ModEnd - start; length = KeLoaderModules[i].ModEnd - start;
name = (PCHAR)KeLoaderModules[i].String; name = (PCHAR)KeLoaderModules[i].String;
if (strcmp ((PCHAR) start, "REGEDIT4") != 0) if (RtlpCheckFileNameExtension(name, ".sys") ||
RtlpCheckFileNameExtension(name, ".sym"))
{ {
CPRINT("Processing module '%s' at %08lx, length 0x%08lx\n", CPRINT("Processing module '%s' at %08lx, length 0x%08lx\n",
name, start, length); name, start, length);

View file

@ -1,4 +1,4 @@
/* $Id: nls.c,v 1.4 2000/05/13 01:45:40 ekohl Exp $ /* $Id: nls.c,v 1.5 2001/06/29 20:42:47 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -23,24 +23,20 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
//#include <internal/nls.h> //#include <internal/nls.h>
#define NDEBUG
#include <internal/debug.h>
BOOLEAN /* GLOBALS *******************************************************************/
NlsMbCodePageTag = FALSE;
BOOLEAN BOOLEAN NlsMbCodePageTag = FALSE;
NlsMbOemCodePageTag = FALSE; BOOLEAN NlsMbOemCodePageTag = FALSE;
BYTE BYTE NlsLeadByteInfo = 0; /* ? */
NlsLeadByteInfo = 0; /* ? */
USHORT USHORT NlsOemLeadByteInfo = 0;
NlsOemLeadByteInfo = 0;
USHORT USHORT NlsAnsiCodePage = 0;
NlsAnsiCodePage = 0; USHORT NlsOemCodePage = 0; /* not exported */
USHORT
NlsOemCodePage = 0; /* not exported */
#if 0 #if 0
@ -55,9 +51,78 @@ CHAR UnicodeToOemTable [65536];
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS NTSTATUS
STDCALL RtlpInitNlsSections(ULONG Mod1Start,
RtlCustomCPToUnicodeN ( ULONG Mod1End,
PRTL_NLS_DATA NlsData, ULONG Mod2Start,
ULONG Mod2End,
ULONG Mod3Start,
ULONG Mod3End)
{
UNICODE_STRING UnicodeString;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE DirectoryHandle;
HANDLE SectionHandle;
NTSTATUS Status;
LARGE_INTEGER SectionSize;
DPRINT("Ansi section start: 0x%08lX\n", Mod1Start);
DPRINT("Ansi section end: 0x%08lX\n", Mod1End);
DPRINT("Oem section start: 0x%08lX\n", Mod2Start);
DPRINT("Oem section end: 0x%08lX\n", Mod2End);
DPRINT("Upcase section start: 0x%08lX\n", Mod3Start);
DPRINT("Upcase section end: 0x%08lX\n", Mod3End);
/* Create the '\NLS' directory */
RtlInitUnicodeString(&UnicodeString,
L"\\NLS");
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeString,
OBJ_PERMANENT,
NULL,
NULL);
Status = NtCreateDirectoryObject(&DirectoryHandle,
0,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
return(Status);
/* Create the 'NlsSectionUnicode' section */
RtlInitUnicodeString(&UnicodeString,
L"NlsSectionUnicode");
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeString,
OBJ_PERMANENT,
DirectoryHandle,
NULL);
SectionSize.QuadPart = (Mod1End - Mod1Start) +
(Mod2End - Mod2Start) + (Mod3End - Mod3Start);
DPRINT("NlsSectionUnicode size: 0x%I64X\n", SectionSize.QuadPart);
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes,
&SectionSize,
PAGE_READWRITE,
0,
NULL);
if (!NT_SUCCESS(Status))
return(Status);
/* create and initialize code page table */
/* map the nls table into the 'NlsSectionUnicode' section */
NtClose(SectionHandle);
NtClose(DirectoryHandle);
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
RtlCustomCPToUnicodeN(PRTL_NLS_DATA NlsData,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize, ULONG UnicodeSize,
PULONG ResultSize, PULONG ResultSize,
@ -96,27 +161,21 @@ RtlCustomCPToUnicodeN (
} }
VOID VOID STDCALL
STDCALL RtlGetDefaultCodePage(PUSHORT AnsiCodePage,
RtlGetDefaultCodePage ( PUSHORT OemCodePage)
PUSHORT AnsiCodePage,
PUSHORT OemCodePage
)
{ {
*AnsiCodePage = NlsAnsiCodePage; *AnsiCodePage = NlsAnsiCodePage;
*OemCodePage = NlsOemCodePage; *OemCodePage = NlsOemCodePage;
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlMultiByteToUnicodeN(PWCHAR UnicodeString,
RtlMultiByteToUnicodeN (
PWCHAR UnicodeString,
ULONG UnicodeSize, ULONG UnicodeSize,
PULONG ResultSize, PULONG ResultSize,
PCHAR MbString, PCHAR MbString,
ULONG MbSize ULONG MbSize)
)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; ULONG i;
@ -154,13 +213,10 @@ RtlMultiByteToUnicodeN (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlMultiByteToUnicodeSize(PULONG UnicodeSize,
RtlMultiByteToUnicodeSize (
PULONG UnicodeSize,
PCHAR MbString, PCHAR MbString,
ULONG MbSize ULONG MbSize)
)
{ {
if (NlsMbCodePageTag == FALSE) if (NlsMbCodePageTag == FALSE)
{ {
@ -311,10 +367,8 @@ RtlUnicodeToMultiByteN (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUnicodeToMultiByteSize(PULONG MbSize,
RtlUnicodeToMultiByteSize (
PULONG MbSize,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize) ULONG UnicodeSize)
{ {
@ -334,8 +388,7 @@ RtlUnicodeToMultiByteSize (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL
RtlUnicodeToOemN ( RtlUnicodeToOemN (
PCHAR OemString, PCHAR OemString,
ULONG OemSize, ULONG OemSize,
@ -379,8 +432,7 @@ RtlUnicodeToOemN (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL
RtlUpcaseUnicodeToCustomCPN ( RtlUpcaseUnicodeToCustomCPN (
PRTL_NLS_DATA NlsData, PRTL_NLS_DATA NlsData,
PCHAR CustomString, PCHAR CustomString,
@ -423,15 +475,12 @@ RtlUpcaseUnicodeToCustomCPN (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUpcaseUnicodeToMultiByteN(PCHAR MbString,
RtlUpcaseUnicodeToMultiByteN (
PCHAR MbString,
ULONG MbSize, ULONG MbSize,
PULONG ResultSize, PULONG ResultSize,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize ULONG UnicodeSize)
)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; ULONG i;
@ -470,15 +519,12 @@ RtlUpcaseUnicodeToMultiByteN (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUpcaseUnicodeToOemN(PCHAR OemString,
RtlUpcaseUnicodeToOemN (
PCHAR OemString,
ULONG OemSize, ULONG OemSize,
PULONG ResultSize, PULONG ResultSize,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize ULONG UnicodeSize)
)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; ULONG i;