diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 9140a46eea2..da97e3a510f 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -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.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 * FILE: ntoskrnl/ke/main.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,29 @@ volatile BOOLEAN Initialized = FALSE; /* 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 CreateSystemRootLink (PCSZ ParameterLine) { @@ -437,7 +461,7 @@ ExpInitializeExecutive(VOID) assert(FIELD_OFFSET(KPCR, CurrentThread) == KPCR_CURRENT_THREAD); LdrInit1(); - + KeLowerIrql(DISPATCH_LEVEL); NtEarlyInitVdm(); @@ -461,7 +485,7 @@ ExpInitializeExecutive(VOID) KeInit2(); KeLowerIrql(PASSIVE_LEVEL); - + ObInit(); PiInitProcessManager(); @@ -476,7 +500,7 @@ ExpInitializeExecutive(VOID) HalDisplayString("are welcome to change it and/or distribute copies of it " "under certain\n"); HalDisplayString("conditions. There is absolutely no warranty for " - "ReactOS.\n"); + "ReactOS.\n\n"); /* Initialize all processors */ KeNumberProcessors = 0; @@ -494,19 +518,23 @@ ExpInitializeExecutive(VOID) if (KeNumberProcessors > 1) { - sprintf(str, "Found %d system processors.\n", - KeNumberProcessors); + sprintf(str, + "Found %d system processors. [%lu MB Memory]\n", + KeNumberProcessors, + (KeLoaderBlock.MemHigher + 1088)/ 1024); } else { - strcpy(str, "Found 1 system processor.\n"); + sprintf(str, + "Found 1 system processor. [%lu MB Memory]\n", + (KeLoaderBlock.MemHigher + 1088)/ 1024); } HalDisplayString(str); /* * Initialize various critical subsystems */ - HalInitSystem (1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); + HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); ExInit(); IoInit(); @@ -517,7 +545,70 @@ ExpInitializeExecutive(VOID) MmInit3(); /* 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 @@ -526,36 +617,17 @@ ExpInitializeExecutive(VOID) KdbEnter(); #endif /* KDBG */ - /* - * 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 */ + /* Pass 3: process boot loaded drivers */ for (i=1; i < KeLoaderBlock.ModsCount; i++) { start = KeLoaderModules[i].ModStart; length = KeLoaderModules[i].ModEnd - start; 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", - name, start, length); + name, start, length); LdrProcessDriver((PVOID)start, name, length); } } @@ -577,7 +649,7 @@ ExpInitializeExecutive(VOID) /* * Start the motherboard enumerator (the HAL) */ - HalInitSystem (2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); + HalInitSystem(2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); /* * Load boot start drivers diff --git a/reactos/ntoskrnl/rtl/nls.c b/reactos/ntoskrnl/rtl/nls.c index ac427ddec1c..e93f8b5a6af 100644 --- a/reactos/ntoskrnl/rtl/nls.c +++ b/reactos/ntoskrnl/rtl/nls.c @@ -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 * PROJECT: ReactOS kernel @@ -23,24 +23,20 @@ #include //#include +#define NDEBUG +#include -BOOLEAN -NlsMbCodePageTag = FALSE; +/* GLOBALS *******************************************************************/ -BOOLEAN -NlsMbOemCodePageTag = FALSE; +BOOLEAN NlsMbCodePageTag = FALSE; +BOOLEAN NlsMbOemCodePageTag = FALSE; -BYTE -NlsLeadByteInfo = 0; /* ? */ +BYTE NlsLeadByteInfo = 0; /* ? */ -USHORT -NlsOemLeadByteInfo = 0; +USHORT NlsOemLeadByteInfo = 0; -USHORT -NlsAnsiCodePage = 0; - -USHORT -NlsOemCodePage = 0; /* not exported */ +USHORT NlsAnsiCodePage = 0; +USHORT NlsOemCodePage = 0; /* not exported */ #if 0 @@ -55,68 +51,131 @@ CHAR UnicodeToOemTable [65536]; /* FUNCTIONS *****************************************************************/ NTSTATUS -STDCALL -RtlCustomCPToUnicodeN ( - PRTL_NLS_DATA NlsData, - PWCHAR UnicodeString, - ULONG UnicodeSize, - PULONG ResultSize, - PCHAR CustomString, - ULONG CustomSize) +RtlpInitNlsSections(ULONG Mod1Start, + ULONG Mod1End, + ULONG Mod2Start, + ULONG Mod2End, + ULONG Mod3Start, + ULONG Mod3End) { - ULONG Size = 0; - ULONG i; + UNICODE_STRING UnicodeString; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE DirectoryHandle; + HANDLE SectionHandle; + NTSTATUS Status; + LARGE_INTEGER SectionSize; - if (NlsData->DbcsFlag == FALSE) - { - /* single-byte code page */ - if (CustomSize > (UnicodeSize / sizeof(WCHAR))) - Size = UnicodeSize / sizeof(WCHAR); - else - Size = CustomSize; + 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); - if (ResultSize != NULL) - *ResultSize = Size * sizeof(WCHAR); + /* 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); - for (i = 0; i < Size; i++) - { - *UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString]; - UnicodeString++; - CustomString++; - } - } + /* 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, + 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 - { - /* multi-byte code page */ - /* FIXME */ + Size = CustomSize; - } + 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 -STDCALL -RtlGetDefaultCodePage ( - PUSHORT AnsiCodePage, - PUSHORT OemCodePage - ) +VOID STDCALL +RtlGetDefaultCodePage(PUSHORT AnsiCodePage, + PUSHORT OemCodePage) { - *AnsiCodePage = NlsAnsiCodePage; - *OemCodePage = NlsOemCodePage; + *AnsiCodePage = NlsAnsiCodePage; + *OemCodePage = NlsOemCodePage; } -NTSTATUS -STDCALL -RtlMultiByteToUnicodeN ( - PWCHAR UnicodeString, - ULONG UnicodeSize, - PULONG ResultSize, - PCHAR MbString, - ULONG MbSize - ) +NTSTATUS STDCALL +RtlMultiByteToUnicodeN(PWCHAR UnicodeString, + ULONG UnicodeSize, + PULONG ResultSize, + PCHAR MbString, + ULONG MbSize) { ULONG Size = 0; ULONG i; @@ -154,13 +213,10 @@ RtlMultiByteToUnicodeN ( } -NTSTATUS -STDCALL -RtlMultiByteToUnicodeSize ( - PULONG UnicodeSize, - PCHAR MbString, - ULONG MbSize - ) +NTSTATUS STDCALL +RtlMultiByteToUnicodeSize(PULONG UnicodeSize, + PCHAR MbString, + ULONG MbSize) { if (NlsMbCodePageTag == FALSE) { @@ -311,12 +367,10 @@ RtlUnicodeToMultiByteN ( } -NTSTATUS -STDCALL -RtlUnicodeToMultiByteSize ( - PULONG MbSize, - PWCHAR UnicodeString, - ULONG UnicodeSize) +NTSTATUS STDCALL +RtlUnicodeToMultiByteSize(PULONG MbSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) { if (NlsMbCodePageTag == FALSE) { @@ -334,8 +388,7 @@ RtlUnicodeToMultiByteSize ( } -NTSTATUS -STDCALL +NTSTATUS STDCALL RtlUnicodeToOemN ( PCHAR OemString, ULONG OemSize, @@ -379,8 +432,7 @@ RtlUnicodeToOemN ( } -NTSTATUS -STDCALL +NTSTATUS STDCALL RtlUpcaseUnicodeToCustomCPN ( PRTL_NLS_DATA NlsData, PCHAR CustomString, @@ -423,15 +475,12 @@ RtlUpcaseUnicodeToCustomCPN ( } -NTSTATUS -STDCALL -RtlUpcaseUnicodeToMultiByteN ( - PCHAR MbString, - ULONG MbSize, - PULONG ResultSize, - PWCHAR UnicodeString, - ULONG UnicodeSize - ) +NTSTATUS STDCALL +RtlUpcaseUnicodeToMultiByteN(PCHAR MbString, + ULONG MbSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) { ULONG Size = 0; ULONG i; @@ -470,15 +519,12 @@ RtlUpcaseUnicodeToMultiByteN ( } -NTSTATUS -STDCALL -RtlUpcaseUnicodeToOemN ( - PCHAR OemString, - ULONG OemSize, - PULONG ResultSize, - PWCHAR UnicodeString, - ULONG UnicodeSize - ) +NTSTATUS STDCALL +RtlUpcaseUnicodeToOemN(PCHAR OemString, + ULONG OemSize, + PULONG ResultSize, + PWCHAR UnicodeString, + ULONG UnicodeSize) { ULONG Size = 0; ULONG i;