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)
{ {
@ -437,7 +461,7 @@ ExpInitializeExecutive(VOID)
assert(FIELD_OFFSET(KPCR, CurrentThread) == KPCR_CURRENT_THREAD); assert(FIELD_OFFSET(KPCR, CurrentThread) == KPCR_CURRENT_THREAD);
LdrInit1(); LdrInit1();
KeLowerIrql(DISPATCH_LEVEL); KeLowerIrql(DISPATCH_LEVEL);
NtEarlyInitVdm(); NtEarlyInitVdm();
@ -461,7 +485,7 @@ ExpInitializeExecutive(VOID)
KeInit2(); KeInit2();
KeLowerIrql(PASSIVE_LEVEL); KeLowerIrql(PASSIVE_LEVEL);
ObInit(); ObInit();
PiInitProcessManager(); PiInitProcessManager();
@ -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,19 +518,23 @@ 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);
/* /*
* Initialize various critical subsystems * Initialize various critical subsystems
*/ */
HalInitSystem (1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
ExInit(); ExInit();
IoInit(); IoInit();
@ -517,7 +545,70 @@ ExpInitializeExecutive(VOID)
MmInit3(); MmInit3();
/* Report all resources used by hal */ /* Report all resources used by hal */
HalReportResourceUsage (); HalReportResourceUsage();
// DumpBIOSMemoryMap();
/*
* Initalize services loaded at boot time
*/
DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount);
for (i=0; i < KeLoaderBlock.ModsCount; i++)
{
CPRINT("Module: '%s' at %08lx, length 0x%08lx\n",
KeLoaderModules[i].String,
KeLoaderModules[i].ModStart,
KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart);
}
/* 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++)
{
start = KeLoaderModules[i].ModStart;
name = (PCHAR)KeLoaderModules[i].String;
if (RtlpCheckFileNameExtension(name, "") ||
RtlpCheckFileNameExtension(name, ".hiv"))
{
CPRINT("Process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start);
}
}
/* /*
* Enter the kernel debugger before starting up the boot drivers * Enter the kernel debugger before starting up the boot drivers
@ -526,36 +617,17 @@ ExpInitializeExecutive(VOID)
KdbEnter(); KdbEnter();
#endif /* KDBG */ #endif /* KDBG */
/* /* Pass 3: process boot loaded drivers */
* Initalize services loaded at boot time
*/
DPRINT1("%d files loaded\n",KeLoaderBlock.ModsCount);
for (i=0; i < KeLoaderBlock.ModsCount; i++)
{
CPRINT("Module: %s\n", KeLoaderModules[i].String);
}
/* Pass 1: load registry chunks passed in */
for (i = 1; i < KeLoaderBlock.ModsCount; i++)
{
start = KeLoaderModules[i].ModStart;
if (strcmp ((PCHAR) start, "REGEDIT4") == 0)
{
CPRINT("Process registry chunk at %08lx\n", start);
CmImportHive((PCHAR) start);
}
}
/* Pass 2: 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);
LdrProcessDriver((PVOID)start, name, length); LdrProcessDriver((PVOID)start, name, length);
} }
} }
@ -577,7 +649,7 @@ ExpInitializeExecutive(VOID)
/* /*
* Start the motherboard enumerator (the HAL) * Start the motherboard enumerator (the HAL)
*/ */
HalInitSystem (2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); HalInitSystem(2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/* /*
* Load boot start drivers * Load boot start drivers

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,68 +51,131 @@ CHAR UnicodeToOemTable [65536];
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS NTSTATUS
STDCALL RtlpInitNlsSections(ULONG Mod1Start,
RtlCustomCPToUnicodeN ( ULONG Mod1End,
PRTL_NLS_DATA NlsData, ULONG Mod2Start,
PWCHAR UnicodeString, ULONG Mod2End,
ULONG UnicodeSize, ULONG Mod3Start,
PULONG ResultSize, ULONG Mod3End)
PCHAR CustomString,
ULONG CustomSize)
{ {
ULONG Size = 0; UNICODE_STRING UnicodeString;
ULONG i; OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE DirectoryHandle;
HANDLE SectionHandle;
NTSTATUS Status;
LARGE_INTEGER SectionSize;
if (NlsData->DbcsFlag == FALSE) DPRINT("Ansi section start: 0x%08lX\n", Mod1Start);
{ DPRINT("Ansi section end: 0x%08lX\n", Mod1End);
/* single-byte code page */ DPRINT("Oem section start: 0x%08lX\n", Mod2Start);
if (CustomSize > (UnicodeSize / sizeof(WCHAR))) DPRINT("Oem section end: 0x%08lX\n", Mod2End);
Size = UnicodeSize / sizeof(WCHAR); DPRINT("Upcase section start: 0x%08lX\n", Mod3Start);
else DPRINT("Upcase section end: 0x%08lX\n", Mod3End);
Size = CustomSize;
if (ResultSize != NULL) /* Create the '\NLS' directory */
*ResultSize = Size * sizeof(WCHAR); RtlInitUnicodeString(&UnicodeString,
L"\\NLS");
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeString,
OBJ_PERMANENT,
NULL,
NULL);
Status = NtCreateDirectoryObject(&DirectoryHandle,
0,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
return(Status);
for (i = 0; i < Size; i++) /* Create the 'NlsSectionUnicode' section */
{ RtlInitUnicodeString(&UnicodeString,
*UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString]; L"NlsSectionUnicode");
UnicodeString++; InitializeObjectAttributes(&ObjectAttributes,
CustomString++; &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,
ULONG UnicodeSize,
PULONG ResultSize,
PCHAR CustomString,
ULONG CustomSize)
{
ULONG Size = 0;
ULONG i;
if (NlsData->DbcsFlag == FALSE)
{
/* single-byte code page */
if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else else
{ Size = CustomSize;
/* multi-byte code page */
/* FIXME */
} if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
return STATUS_SUCCESS; for (i = 0; i < Size; i++)
{
*UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString];
UnicodeString++;
CustomString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
}
return STATUS_SUCCESS;
} }
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 ( ULONG UnicodeSize,
PWCHAR UnicodeString, PULONG ResultSize,
ULONG UnicodeSize, PCHAR MbString,
PULONG ResultSize, ULONG MbSize)
PCHAR MbString,
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 ( PCHAR MbString,
PULONG UnicodeSize, ULONG MbSize)
PCHAR MbString,
ULONG MbSize
)
{ {
if (NlsMbCodePageTag == FALSE) if (NlsMbCodePageTag == FALSE)
{ {
@ -311,12 +367,10 @@ RtlUnicodeToMultiByteN (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUnicodeToMultiByteSize(PULONG MbSize,
RtlUnicodeToMultiByteSize ( PWCHAR UnicodeString,
PULONG MbSize, ULONG UnicodeSize)
PWCHAR UnicodeString,
ULONG UnicodeSize)
{ {
if (NlsMbCodePageTag == FALSE) if (NlsMbCodePageTag == FALSE)
{ {
@ -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 ( ULONG MbSize,
PCHAR MbString, PULONG ResultSize,
ULONG MbSize, PWCHAR UnicodeString,
PULONG ResultSize, ULONG UnicodeSize)
PWCHAR UnicodeString,
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 ( ULONG OemSize,
PCHAR OemString, PULONG ResultSize,
ULONG OemSize, PWCHAR UnicodeString,
PULONG ResultSize, ULONG UnicodeSize)
PWCHAR UnicodeString,
ULONG UnicodeSize
)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; ULONG i;