- Use KeLoaderBlock for registry hive loading.

- Get rid of the CACHED_MODULE array and associated structures and stop using them, get rid of ParseAndCacheLoadedModules. Stop using KeLoadedModules and KeLoadedModuleCount outside of freeldr.c.
- Except for MmInit1, the kernel should now be totally isolated from FreeLDR-specific data.

svn path=/trunk/; revision=24409
This commit is contained in:
Alex Ionescu 2006-10-05 02:02:27 +00:00
parent 0bfcd77883
commit 5162751ab3
5 changed files with 40 additions and 79 deletions

View file

@ -27,10 +27,9 @@
// Ke: // Ke:
// //
// - FIXES: // - FIXES:
// * Stop using CachedModules.
// * Try to make MmInit1 NTLDR compatible.
// * Sanitize some context fields during conversions. // * Sanitize some context fields during conversions.
// * Figure out why the DPC stack doesn't really work. // * Figure out why the DPC stack doesn't really work.
// * Try to make MmInit1 NTLDR compatible.
// * Add DR macro/save and VM macro/save. // * Add DR macro/save and VM macro/save.
// - FEATURES: // - FEATURES:
// * New optimized table-based tick-hashed timer implementation. // * New optimized table-based tick-hashed timer implementation.

View file

@ -136,18 +136,48 @@ STDCALL
CmInitHives(BOOLEAN SetupBoot) CmInitHives(BOOLEAN SetupBoot)
{ {
PCHAR BaseAddress; PCHAR BaseAddress;
PLIST_ENTRY ListHead, NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock = NULL;
/* Load Registry Hives. This one can be missing. */ /* Load Registry Hives. This one can be missing. */
if (CachedModules[SystemRegistry]) { BaseAddress = KeLoaderBlock->RegistryBase;
BaseAddress = (PCHAR)CachedModules[SystemRegistry]->ModStart; if (BaseAddress)
{
CmImportSystemHive(BaseAddress, CmImportSystemHive(BaseAddress,
CachedModules[SystemRegistry]->ModEnd - (ULONG_PTR)BaseAddress); KeLoaderBlock->RegistryLength);
} }
BaseAddress = (PCHAR)CachedModules[HardwareRegistry]->ModStart; /* Loop the memory descriptors */
CmImportHardwareHive(BaseAddress, ListHead = &KeLoaderBlock->MemoryDescriptorListHead;
CachedModules[HardwareRegistry]->ModEnd - (ULONG_PTR)BaseAddress); NextEntry = ListHead->Flink;
while (NextEntry != ListHead)
{
/* Get the current block */
MdBlock = CONTAINING_RECORD(NextEntry,
MEMORY_ALLOCATION_DESCRIPTOR,
ListEntry);
/* Check if this is an registry block */
if (MdBlock->MemoryType == LoaderRegistryData)
{
/* Check if it's not the SYSTEM hive that we already initialized */
if ((MdBlock->BasePage) != ((ULONG_PTR)BaseAddress >> PAGE_SHIFT))
{
/* Hardware hive break out */
break;
}
}
/* Go to the next block */
NextEntry = MdBlock->ListEntry.Flink;
}
/* We need a hardware hive */
ASSERT(MdBlock);
BaseAddress = (PCHAR)(MdBlock->BasePage << PAGE_SHIFT);
CmImportHardwareHive(BaseAddress,
MdBlock->PageCount << PAGE_SHIFT);
/* Create dummy keys if no hardware hive was found */ /* Create dummy keys if no hardware hive was found */
CmImportHardwareHive (NULL, 0); CmImportHardwareHive (NULL, 0);

View file

@ -25,17 +25,14 @@ ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
ULONG NtGlobalFlag; ULONG NtGlobalFlag;
ULONG ExSuiteMask; ULONG ExSuiteMask;
extern LOADER_MODULE KeLoaderModules[64];
extern ULONG KeLoaderModuleCount;
extern ULONG KiServiceLimit;
BOOLEAN NoGuiBoot = FALSE;
/* Init flags and settings */ /* Init flags and settings */
ULONG ExpInitializationPhase; ULONG ExpInitializationPhase;
BOOLEAN ExpInTextModeSetup; BOOLEAN ExpInTextModeSetup;
BOOLEAN IoRemoteBootClient; BOOLEAN IoRemoteBootClient;
ULONG InitSafeBootMode; ULONG InitSafeBootMode;
BOOLEAN NoGuiBoot = FALSE;
/* NT Boot Path */ /* NT Boot Path */
UNICODE_STRING NtSystemRoot; UNICODE_STRING NtSystemRoot;
@ -294,52 +291,6 @@ InitSystemSharedUserPage (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
} }
} }
VOID
FORCEINLINE
ParseAndCacheLoadedModules(VOID)
{
ULONG i;
PCHAR Name;
/* Loop the Module List and get the modules we want */
for (i = 1; i < KeLoaderModuleCount; i++)
{
/* Get the Name of this Module */
if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\')))
{
/* Save the name */
Name = (PCHAR)KeLoaderModules[i].String;
}
else
{
/* No name, skip */
Name++;
}
/* Now check for any of the modules we will need later */
if (!_stricmp(Name, "ansi.nls"))
{
CachedModules[AnsiCodepage] = &KeLoaderModules[i];
}
else if (!_stricmp(Name, "oem.nls"))
{
CachedModules[OemCodepage] = &KeLoaderModules[i];
}
else if (!_stricmp(Name, "casemap.nls"))
{
CachedModules[UnicodeCasemap] = &KeLoaderModules[i];
}
else if (!_stricmp(Name, "system") || !_stricmp(Name, "system.hiv"))
{
CachedModules[SystemRegistry] = &KeLoaderModules[i];
}
else if (!_stricmp(Name, "hardware") || !_stricmp(Name, "hardware.hiv"))
{
CachedModules[HardwareRegistry] = &KeLoaderModules[i];
}
}
}
VOID VOID
INIT_FUNCTION INIT_FUNCTION
ExpDisplayNotice(VOID) ExpDisplayNotice(VOID)
@ -577,9 +528,6 @@ ExpInitializeExecutive(IN ULONG Cpu,
PLIST_ENTRY NextEntry, ListHead; PLIST_ENTRY NextEntry, ListHead;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
/* FIXME: Deprecate soon */
ParseAndCacheLoadedModules();
/* Validate Loader */ /* Validate Loader */
if (!ExpIsLoaderValid(LoaderBlock)) if (!ExpIsLoaderValid(LoaderBlock))
{ {

View file

@ -18,18 +18,6 @@ typedef struct _KPROFILE_SOURCE_OBJECT
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
} KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT; } KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT;
/* Cached modules from the loader block */
typedef enum _CACHED_MODULE_TYPE
{
AnsiCodepage,
OemCodepage,
UnicodeCasemap,
SystemRegistry,
HardwareRegistry,
MaximumCachedModuleType,
} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE;
extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
typedef enum _CONNECT_TYPE typedef enum _CONNECT_TYPE
{ {
NoConnect, NoConnect,
@ -122,6 +110,7 @@ extern BOOLEAN KeThreadDpcEnable;
extern LARGE_INTEGER KiTimeIncrementReciprocal; extern LARGE_INTEGER KiTimeIncrementReciprocal;
extern UCHAR KiTimeIncrementShiftCount; extern UCHAR KiTimeIncrementShiftCount;
extern ULONG KiTimeLimitIsrMicroseconds; extern ULONG KiTimeLimitIsrMicroseconds;
extern ULONG KiServiceLimit;
extern LIST_ENTRY BugcheckCallbackListHead, BugcheckReasonCallbackListHead; extern LIST_ENTRY BugcheckCallbackListHead, BugcheckReasonCallbackListHead;
extern KSPIN_LOCK BugCheckCallbackLock; extern KSPIN_LOCK BugCheckCallbackLock;
extern KDPC KiExpireTimerDpc; extern KDPC KiExpireTimerDpc;

View file

@ -18,7 +18,6 @@
LOADER_MODULE KeLoaderModules[64]; LOADER_MODULE KeLoaderModules[64];
ULONG KeLoaderModuleCount; ULONG KeLoaderModuleCount;
static CHAR KeLoaderModuleStrings[64][256]; static CHAR KeLoaderModuleStrings[64][256];
PLOADER_MODULE CachedModules[MaximumCachedModuleType];
/* FreeLDR Memory Data */ /* FreeLDR Memory Data */
ADDRESS_RANGE KeMemoryMap[64]; ADDRESS_RANGE KeMemoryMap[64];
@ -171,10 +170,6 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
if (!(_stricmp(DriverName, "hardware")) || if (!(_stricmp(DriverName, "hardware")) ||
!(_stricmp(DriverName, "hardware.hiv"))) !(_stricmp(DriverName, "hardware.hiv")))
{ {
/* Save registry data */
LoaderBlock->RegistryBase = ModStart;
LoaderBlock->RegistryLength = ModSize;
/* Create an MD for it */ /* Create an MD for it */
MdEntry = &BldrMemoryDescriptors[i]; MdEntry = &BldrMemoryDescriptors[i];
MdEntry->MemoryType = LoaderRegistryData; MdEntry->MemoryType = LoaderRegistryData;