Author: fireball Date: Wed Mar 21 17:31:57 2007 New Revision: 26148
URL: http://svn.reactos.org/svn/reactos?rev=26148&view=rev Log: - KiRosFrldrLpbToNtLpb(): Round up to the correct size in pages (I don't see a reason to provide a "cropped" size of modules). - Change "FreeLDR BIAS hack" to a better one: measure sizes of all 3 codepages, and place them contiguously. Is this still required at all? On my system I didn't see a case when these tables are placed not contiguously by freeldr. - This fixes early bugcheck in ExpInitNls().
Modified: trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/ke/freeldr.c
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=2614... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Wed Mar 21 17:31:57 2007 @@ -191,6 +191,8 @@ LARGE_INTEGER SectionOffset = {{0}}; PLIST_ENTRY ListHead, NextEntry; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; + ULONG NlsTablesEncountered = 0; + ULONG NlsTableSizes[3]; /* 3 NLS tables */
/* Check if this is boot-time phase 0 initialization */ if (!ExpInitializationPhase) @@ -210,17 +212,16 @@ { /* Increase the table size */ ExpNlsTableSize += MdBlock->PageCount * PAGE_SIZE; + + /* FreeLdr-specific */ + NlsTableSizes[NlsTablesEncountered] = MdBlock->PageCount * PAGE_SIZE; + NlsTablesEncountered++; + ASSERT(NlsTablesEncountered < 4); }
/* Go to the next block */ NextEntry = MdBlock->ListEntry.Flink; } - - /* - * In NT, the memory blocks are contiguous, but in ReactOS they aren't, - * so unless someone fixes FreeLdr, we'll have to use this icky hack. - */ - ExpNlsTableSize += 2 * PAGE_SIZE; // BIAS FOR FREELDR. HACK!
/* Allocate the a new buffer since loader memory will be freed */ ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool, @@ -229,9 +230,27 @@ if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Copy the codepage data in its new location. */ + //RtlCopyMemory(ExpNlsTableBase, + // LoaderBlock->NlsData->AnsiCodePageData, + // ExpNlsTableSize); + + /* + * In NT, the memory blocks are contiguous, but in ReactOS they aren't, + * so unless someone fixes FreeLdr, we'll have to use this icky hack. + */ RtlCopyMemory(ExpNlsTableBase, LoaderBlock->NlsData->AnsiCodePageData, - ExpNlsTableSize); + NlsTableSizes[0]); + + RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]), + LoaderBlock->NlsData->OemCodePageData, + NlsTableSizes[1]); + + RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] + + NlsTableSizes[1]), + LoaderBlock->NlsData->UnicodeCodePageData, + NlsTableSizes[2]); + /* End of Hack */
/* Initialize and reset the NLS TAbles */ RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/ke/freeldr.c (original) +++ trunk/reactos/ntoskrnl/ke/freeldr.c Wed Mar 21 17:31:57 2007 @@ -105,7 +105,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderNlsData; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); continue; @@ -120,7 +120,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderNlsData; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); continue; @@ -135,7 +135,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderNlsData; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); continue; @@ -157,7 +157,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderRegistryData; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); continue; @@ -172,7 +172,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderRegistryData; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); continue; @@ -185,7 +185,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderSystemCode; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); } @@ -195,7 +195,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderHalCode; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); } @@ -205,7 +205,7 @@ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderBootDriver; MdEntry->BasePage = (ULONG_PTR)ModStart >> PAGE_SHIFT; - MdEntry->PageCount = ModSize >> PAGE_SHIFT; + MdEntry->PageCount = (ModSize + PAGE_SIZE - 1) >> PAGE_SHIFT; InsertTailList(&LoaderBlock->MemoryDescriptorListHead, &MdEntry->ListEntry); }