diff --git a/reactos/include/ntos/rtl.h b/reactos/include/ntos/rtl.h index 38b5a71a51c..0933529892b 100755 --- a/reactos/include/ntos/rtl.h +++ b/reactos/include/ntos/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.8 2003/05/15 11:01:02 ekohl Exp $ +/* $Id: rtl.h,v 1.9 2003/05/16 17:33:51 ekohl Exp $ * */ @@ -1218,10 +1218,10 @@ RtlInitCodePageTable ( VOID STDCALL RtlInitNlsTables ( - OUT PNLSTABLEINFO NlsTable, - IN PUSHORT CaseTableBase, + IN PUSHORT AnsiTableBase, IN PUSHORT OemTableBase, - IN PUSHORT AnsiTableBase + IN PUSHORT CaseTableBase, + OUT PNLSTABLEINFO NlsTable ); VOID diff --git a/reactos/include/ntos/rtltypes.h b/reactos/include/ntos/rtltypes.h index 159ee13f37b..6d540063123 100755 --- a/reactos/include/ntos/rtltypes.h +++ b/reactos/include/ntos/rtltypes.h @@ -1,4 +1,4 @@ -/* $Id: rtltypes.h,v 1.6 2003/05/15 11:01:02 ekohl Exp $ +/* $Id: rtltypes.h,v 1.7 2003/05/16 17:33:51 ekohl Exp $ * */ @@ -160,7 +160,7 @@ typedef struct _CPTABLEINFO { USHORT CodePage; USHORT MaximumCharacterSize; // SBCS = 1, DBCS = 2 - USHORT DefaultCharacter; + USHORT DefaultChar; USHORT UniDefaultChar; USHORT TransDefaultChar; USHORT TransUniDefaultChar; @@ -180,6 +180,19 @@ typedef struct _NLSTABLEINFO PUSHORT LowerCaseTable; } NLSTABLEINFO, *PNLSTABLEINFO; +typedef struct _NLS_FILE_HEADER +{ + USHORT HeaderSize; + USHORT CodePage; + USHORT MaximumCharacterSize; // SBCS = 1, DBCS = 2 + USHORT DefaultChar; + USHORT UniDefaultChar; + USHORT TransDefaultChar; + USHORT TransUniDefaultChar; + USHORT DBCSCodePage; + UCHAR LeadByte[MAXIMUM_LEADBYTES]; +} PACKED NLS_FILE_HEADER, *PNLS_FILE_HEADER; + typedef struct _RTL_GENERIC_TABLE { diff --git a/reactos/lib/ntdll/rtl/nls.c b/reactos/lib/ntdll/rtl/nls.c index c3673f1a877..a132046ba50 100644 --- a/reactos/lib/ntdll/rtl/nls.c +++ b/reactos/lib/ntdll/rtl/nls.c @@ -1,4 +1,4 @@ -/* $Id: nls.c,v 1.8 2003/05/15 11:03:21 ekohl Exp $ +/* $Id: nls.c,v 1.9 2003/05/16 17:34:25 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -123,10 +123,10 @@ RtlInitCodePageTable(IN PUSHORT TableBase, VOID STDCALL -RtlInitNlsTables(OUT PNLSTABLEINFO NlsTable, - IN PUSHORT CaseTableBase, +RtlInitNlsTables(IN PUSHORT AnsiTableBase, IN PUSHORT OemTableBase, - IN PUSHORT AnsiTableBase) + IN PUSHORT CaseTableBase, + OUT PNLSTABLEINFO NlsTable) { UNIMPLEMENTED; } diff --git a/reactos/ntoskrnl/include/internal/nls.h b/reactos/ntoskrnl/include/internal/nls.h index 1727a26d2bf..d99f8328dc9 100644 --- a/reactos/ntoskrnl/include/internal/nls.h +++ b/reactos/ntoskrnl/include/internal/nls.h @@ -20,13 +20,7 @@ #ifndef __NTOSKRNL_INCLUDE_INTERNAL_NLS_H #define __NTOSKRNL_INCLUDE_INTERNAL_NLS_H - -extern PSECTION_OBJECT NlsSection; - - -VOID RtlpInitNlsTables(VOID); -NTSTATUS RtlpInitNlsSection(VOID); - +VOID RtlpCreateDefaultNlsTables(VOID); #endif /* __NTOSKRNL_INCLUDE_INTERNAL_NLS_H */ diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index f7be0c35cc0..eafaa7b641c 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.154 2003/05/15 11:05:20 ekohl Exp $ +/* $Id: main.c,v 1.155 2003/05/16 17:35:12 ekohl Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/main.c @@ -333,10 +333,10 @@ ExpInitializeExecutive(VOID) LastKernelAddress, (PADDRESS_RANGE)&KeMemoryMap, KeMemoryMapRangeCount); - + /* Create default nls tables */ - RtlpInitNlsTables(); - + RtlpCreateDefaultNlsTables(); + /* * Initialize the kernel debugger */ @@ -426,10 +426,6 @@ ExpInitializeExecutive(VOID) CmInitializeRegistry(); NtInit(); MmInit3(); - - /* Create the nls section */ - RtlpInitNlsSection(); - CcInit(); KdInit2(); FsRtlpInitFileLockingImplementation(); @@ -449,6 +445,7 @@ ExpInitializeExecutive(VOID) KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart); } + /* Pass 2: import system hive registry chunk */ SetupBoot = TRUE; for (i = 1; i < KeLoaderBlock.ModsCount; i++) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index adc7f7ec486..b7f38fe9ece 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.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: section.c,v 1.110 2003/05/14 10:52:46 ekohl Exp $ +/* $Id: section.c,v 1.111 2003/05/16 17:36:23 ekohl Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c @@ -3584,113 +3584,16 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, OUT PVOID * MappedBase, IN OUT PULONG ViewSize) { - PSECTION_OBJECT Section; - PMADDRESS_SPACE AddressSpace; - NTSTATUS Status; - - DPRINT("MmMapViewInSystemSpace() called\n"); - - Section = (PSECTION_OBJECT)SectionObject; - AddressSpace = MmGetKernelAddressSpace(); - - MmLockSection(SectionObject); - MmLockAddressSpace(AddressSpace); - - if ((*ViewSize) == 0) - { - (*ViewSize) = Section->MaximumSize.u.LowPart; - } - else if ((*ViewSize) > Section->MaximumSize.u.LowPart) - { - (*ViewSize) = Section->MaximumSize.u.LowPart; - } - - MmLockSectionSegment(Section->Segments); - - Status = MmMapViewOfSegment(NULL, - AddressSpace, - Section, - Section->Segments, - MappedBase, - *ViewSize, - PAGE_READWRITE, - 0); - - MmUnlockSectionSegment(Section->Segments); - MmUnlockAddressSpace(AddressSpace); - MmUnlockSection(Section); - - return Status; + UNIMPLEMENTED; + return (STATUS_NOT_IMPLEMENTED); } NTSTATUS STDCALL MmUnmapViewInSystemSpace (IN PVOID MappedBase) { - PMEMORY_AREA MemoryArea; - PMADDRESS_SPACE AddressSpace; - PSECTION_OBJECT Section; - PMM_SECTION_SEGMENT Segment; - KIRQL oldIrql; - PLIST_ENTRY CurrentEntry; - PMM_REGION CurrentRegion; - NTSTATUS Status; - - DPRINT("MmUnmapViewInSystemSpace() called\n"); - - AddressSpace = MmGetKernelAddressSpace(); - - DPRINT("Opening memory area at base address %x\n", - MappedBase); - MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, - MappedBase); - if (MemoryArea == NULL) - { - return STATUS_UNSUCCESSFUL; - } - - MemoryArea->DeleteInProgress = TRUE; - - MmLockSection(MemoryArea->Data.SectionData.Section); - MmLockSectionSegment(MemoryArea->Data.SectionData.Segment); - Section = MemoryArea->Data.SectionData.Section; - Segment = MemoryArea->Data.SectionData.Segment; - KeAcquireSpinLock(&Section->ViewListLock, &oldIrql); - RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry); - KeReleaseSpinLock(&Section->ViewListLock, oldIrql); - - CurrentEntry = MemoryArea->Data.SectionData.RegionListHead.Flink; - while (CurrentEntry != &MemoryArea->Data.SectionData.RegionListHead) - { - CurrentRegion = - CONTAINING_RECORD(CurrentEntry, MM_REGION, RegionListEntry); - CurrentEntry = CurrentEntry->Flink; - ExFreePool(CurrentRegion); - } - - if (MemoryArea->Data.SectionData.Section->AllocationAttributes & - SEC_PHYSICALMEMORY) - { - Status = MmFreeMemoryArea(AddressSpace, - MappedBase, - 0, - NULL, - NULL); - } - else - { - Status = MmFreeMemoryArea(AddressSpace, - MappedBase, - 0, - MmFreeSectionPage, - MemoryArea); - } - - MmUnlockSectionSegment(Segment); - MmUnlockSection(Section); - ObDereferenceObject(Section); - - return(STATUS_SUCCESS); + UNIMPLEMENTED; + return (STATUS_NOT_IMPLEMENTED); } diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index 7ca1ab54ec0..786cf9da1b6 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.98 2003/05/15 11:06:24 ekohl Exp $ +/* $Id: process.c,v 1.99 2003/05/16 17:37:17 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -28,7 +28,6 @@ #include #include #include -#include #define NDEBUG #include @@ -315,11 +314,8 @@ PsCreatePeb(HANDLE ProcessHandle, PEPROCESS Process, PVOID ImageBase) { - LARGE_INTEGER SectionOffset; ULONG PebSize; PPEB Peb; - PUCHAR BaseAddress; - ULONG ViewSize; NTSTATUS Status; /* Allocate the Process Environment Block (PEB) */ @@ -340,37 +336,10 @@ PsCreatePeb(HANDLE ProcessHandle, KeAttachProcess(Process); - /* Map the NLS section into the new process */ - BaseAddress = NULL; - ViewSize = 0; - SectionOffset.QuadPart = 0LL; - Status = MmMapViewOfSection(NlsSection, - Process, - (PVOID*)&BaseAddress, - 0, - 0, - &SectionOffset, - &ViewSize, - ViewShare, - SEC_NO_CHANGE | MEM_TOP_DOWN, - PAGE_READONLY); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmMapViewOfSection() failed (Status %lx)\n", Status); - KeDetachProcess(); - return(Status); - } - - DPRINT("BaseAddress %p ViewSize %lu\n", BaseAddress, ViewSize); - /* Initialize the PEB */ RtlZeroMemory(Peb, sizeof(PEB)); Peb->ImageBaseAddress = ImageBase; - /* FIXME: Initialize more PEB variables */ - Peb->AnsiCodePageData = BaseAddress; -// Peb->OemCodePageData = - Process->Peb = Peb; KeDetachProcess(); diff --git a/reactos/ntoskrnl/rtl/nls.c b/reactos/ntoskrnl/rtl/nls.c index be5bd8e2614..d0521818da8 100644 --- a/reactos/ntoskrnl/rtl/nls.c +++ b/reactos/ntoskrnl/rtl/nls.c @@ -1,4 +1,4 @@ -/* $Id: nls.c,v 1.11 2003/05/15 11:07:07 ekohl Exp $ +/* $Id: nls.c,v 1.12 2003/05/16 17:38:41 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -49,13 +49,11 @@ PCHAR UnicodeToOemTable =NULL; /* size: 65536*sizeof(CHAR) */ PWCHAR UnicodeUpcaseTable = NULL; /* size: 65536*sizeof(WCHAR) */ PWCHAR UnicodeLowercaseTable = NULL; /* size: 65536*sizeof(WCHAR) */ -PSECTION_OBJECT NlsSection = NULL; - /* FUNCTIONS *****************************************************************/ VOID -RtlpInitNlsTables(VOID) +RtlpCreateDefaultNlsTables(VOID) { INT i; PCHAR pc; @@ -143,81 +141,6 @@ RtlpInitNlsTables(VOID) UnicodeLowercaseTable[i] = (WCHAR)i - (L'A' - L'a'); /* FIXME: initialize codepage info */ - -} - - -NTSTATUS -RtlpInitNlsSection(VOID) -{ - HANDLE SectionHandle; - LARGE_INTEGER SectionSize; - NTSTATUS Status; - - PUCHAR MappedBuffer; - ULONG Size; - ULONG ViewSize; - - DPRINT1("RtlpInitNlsSection() called\n"); - - Size = 4096; - - DPRINT("Nls section size: 0x%lx\n", Size); - - /* Create the nls section */ - SectionSize.QuadPart = (ULONGLONG)Size; - Status = NtCreateSection(&SectionHandle, - SECTION_ALL_ACCESS, - NULL, - &SectionSize, - PAGE_READWRITE, - SEC_COMMIT, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtCreateSection() failed (Status %lx)\n", Status); - KeBugCheck(0); - return(Status); - } - - /* Get the pointer to the nls section object */ - Status = ObReferenceObjectByHandle(SectionHandle, - SECTION_ALL_ACCESS, - MmSectionObjectType, - KernelMode, - (PVOID*)&NlsSection, - NULL); - NtClose(SectionHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT1("ObReferenceObjectByHandle() failed (Status %lx)\n", Status); - KeBugCheck(0); - return(Status); - } - - /* Map the nls section into system address space */ - ViewSize = 4096; - Status = MmMapViewInSystemSpace(NlsSection, - (PVOID*)&MappedBuffer, - &ViewSize); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmMapViewInSystemSpace() failed (Status %lx)\n", Status); - KeBugCheck(0); - return(Status); - } - - DPRINT1("BaseAddress %p\n", MappedBuffer); - - strcpy(MappedBuffer, "This is a teststring!"); - - /* ... */ - - - - DPRINT1("RtlpInitNlsSection() done\n"); - - return(STATUS_SUCCESS); } @@ -273,15 +196,62 @@ VOID STDCALL RtlInitCodePageTable(IN PUSHORT TableBase, OUT PCPTABLEINFO CodePageTable) { - UNIMPLEMENTED; + PNLS_FILE_HEADER NlsFileHeader; + PUSHORT Ptr; + USHORT Offset; + + DPRINT1("RtlInitCodePageTable() called\n"); + + NlsFileHeader = (PNLS_FILE_HEADER)TableBase; + + CodePageTable->CodePage = NlsFileHeader->CodePage; + CodePageTable->MaximumCharacterSize = NlsFileHeader->MaximumCharacterSize; + CodePageTable->DefaultChar = NlsFileHeader->DefaultChar; + CodePageTable->UniDefaultChar = NlsFileHeader->UniDefaultChar; + CodePageTable->TransDefaultChar = NlsFileHeader->TransDefaultChar; + CodePageTable->TransUniDefaultChar = NlsFileHeader->TransUniDefaultChar; + + RtlCopyMemory(&CodePageTable->LeadByte, + &NlsFileHeader->LeadByte, + MAXIMUM_LEADBYTES); + + /* Set Pointer to start of multi byte table */ + Ptr = (PUSHORT)((ULONG_PTR)TableBase + 2 * NlsFileHeader->HeaderSize); + + /* Get offset to the wide char table */ + Offset = (USHORT)(*Ptr++) + NlsFileHeader->HeaderSize + 1; + + /* Set pointer to the multi byte table */ + CodePageTable->MultiByteTable = Ptr; + + /* Skip ANSI and OEM table */ + Ptr += 256; + if (*Ptr++) + Ptr += 256; + + /* Set pointer to DBCS ranges */ + CodePageTable->DBCSRanges = (PUSHORT)Ptr; + + if (*Ptr > 0) + { + CodePageTable->DBCSCodePage = 1; + CodePageTable->DBCSOffsets = (PUSHORT)++Ptr; + } + else + { + CodePageTable->DBCSCodePage = 0; + CodePageTable->DBCSOffsets = 0; + } + + CodePageTable->WideCharTable = (PVOID)((ULONG_PTR)TableBase + 2 * Offset); } VOID STDCALL -RtlInitNlsTables(OUT PNLSTABLEINFO NlsTable, - IN PUSHORT CaseTableBase, +RtlInitNlsTables(IN PUSHORT AnsiTableBase, IN PUSHORT OemTableBase, - IN PUSHORT AnsiTableBase) + IN PUSHORT CaseTableBase, + OUT PNLSTABLEINFO NlsTable) { UNIMPLEMENTED; }