mirror of
https://github.com/reactos/reactos.git
synced 2024-08-20 18:35:32 +00:00
- Make arc-path passed to the kernel look a bit more correct (still a hack of course)
- Add KdCom.dll loading along with ntoskrnl.exe and hal.dll - Move registry-related code to a new file wlregistry.c - WinLdrLoadAndScanSystemHive() is going to combine loading, initializing and parsing registry. NLS / OEM font data loading is marked with FIXMEs now, since it needs going into that routine (because registry tells the file names, not hardcoding them) svn path=/trunk/; revision=24427
This commit is contained in:
parent
9bfa61479f
commit
0b9fa0e21a
|
@ -72,6 +72,7 @@
|
|||
<file>peloader.c</file>
|
||||
<file>winldr.c</file>
|
||||
<file>wlmemory.c</file>
|
||||
<file>wlregistry.c</file>
|
||||
</directory>
|
||||
<file>freeldr.c</file>
|
||||
<file>debug.c</file>
|
||||
|
|
|
@ -74,4 +74,9 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
ULONG TssBasePage,
|
||||
PVOID GdtIdt);
|
||||
|
||||
// wlregistry.c
|
||||
BOOLEAN WinLdrLoadAndScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||
IN LPCSTR DirectoryPath);
|
||||
|
||||
|
||||
#endif // defined __WINLDR_H
|
||||
|
|
|
@ -1,123 +1,123 @@
|
|||
/*
|
||||
* PROJECT: EFI Windows Loader
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: freeldr/winldr/conversion.c
|
||||
* PURPOSE: Physical <-> Virtual addressing mode conversions
|
||||
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ***************************************************************/
|
||||
|
||||
#include <freeldr.h>
|
||||
|
||||
//#include <ndk/ldrtypes.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
||||
/* Arch-specific addresses translation implementation */
|
||||
PVOID
|
||||
VaToPa(PVOID Va)
|
||||
{
|
||||
return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE);
|
||||
}
|
||||
|
||||
PVOID
|
||||
PaToVa(PVOID Pa)
|
||||
{
|
||||
return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE);
|
||||
}
|
||||
|
||||
VOID
|
||||
List_PaToVa(LIST_ENTRY *ListEntry)
|
||||
{
|
||||
LIST_ENTRY *ListHead = ListEntry;
|
||||
LIST_ENTRY *Next = ListEntry->Flink;
|
||||
LIST_ENTRY *NextPA;
|
||||
|
||||
//Print(L"\n\nList_Entry: %X, First Next: %X\n", ListEntry, Next);
|
||||
//
|
||||
// Walk through the whole list
|
||||
//
|
||||
if (Next != NULL)
|
||||
{
|
||||
while (Next != PaToVa(ListHead))
|
||||
{
|
||||
NextPA = VaToPa(Next);
|
||||
//Print(L"Current: %X, Flink: %X, Blink: %X\n", Next, NextPA->Flink, NextPA->Blink);
|
||||
|
||||
NextPA->Flink = PaToVa((PVOID)NextPA->Flink);
|
||||
NextPA->Blink = PaToVa((PVOID)NextPA->Blink);
|
||||
|
||||
//Print(L"After converting Flink: %X, Blink: %X\n", NextPA->Flink, NextPA->Blink);
|
||||
|
||||
Next = NextPA->Flink;
|
||||
}
|
||||
|
||||
//
|
||||
// Finally convert first Flink/Blink
|
||||
//
|
||||
ListEntry->Flink = PaToVa((PVOID)ListEntry->Flink);
|
||||
if (ListEntry->Blink)
|
||||
ListEntry->Blink = PaToVa((PVOID)ListEntry->Blink);
|
||||
}
|
||||
}
|
||||
|
||||
// This function converts only Child->Child, and calls itself for each Sibling
|
||||
VOID
|
||||
ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
|
||||
{
|
||||
PCONFIGURATION_COMPONENT_DATA Child;
|
||||
PCONFIGURATION_COMPONENT_DATA Sibling;
|
||||
|
||||
DbgPrint((DPRINT_WINDOWS, "ConvertConfigToVA(Start 0x%X)", Start));
|
||||
Child = Start;
|
||||
|
||||
while (Child != NULL)
|
||||
{
|
||||
if (Child->ConfigurationData)
|
||||
Child->ConfigurationData = PaToVa(Child->ConfigurationData);
|
||||
|
||||
if (Child->Child)
|
||||
Child->Child = PaToVa(Child->Child);
|
||||
|
||||
if (Child->Parent)
|
||||
Child->Parent = PaToVa(Child->Parent);
|
||||
|
||||
if (Child->Sibling)
|
||||
Child->Sibling = PaToVa(Child->Sibling);
|
||||
|
||||
DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Child, Child->ComponentEntry.Class));
|
||||
|
||||
// If the child has a sibling list, then search the sibling list
|
||||
// for an entry that matches the specified class, type, and key.
|
||||
Sibling = Child->Sibling;
|
||||
while (Sibling != NULL)
|
||||
{
|
||||
if (Sibling->ConfigurationData)
|
||||
Sibling->ConfigurationData = PaToVa(Sibling->ConfigurationData);
|
||||
|
||||
if (Sibling->Child)
|
||||
Sibling->Child = PaToVa(Sibling->Child);
|
||||
|
||||
if (Sibling->Parent)
|
||||
Sibling->Parent = PaToVa(Sibling->Parent);
|
||||
|
||||
if (Sibling->Sibling)
|
||||
Sibling->Sibling = PaToVa(Sibling->Sibling);
|
||||
|
||||
DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Sibling, Sibling->ComponentEntry.Class));
|
||||
|
||||
// If the sibling has a child tree, then search the child tree
|
||||
// for an entry that matches the specified class, type, and key.
|
||||
if (VaToPa(Sibling->Child) != NULL)
|
||||
ConvertConfigToVA(VaToPa(Sibling->Child));
|
||||
|
||||
Sibling = VaToPa(Sibling->Sibling);
|
||||
}
|
||||
|
||||
Child = VaToPa(Child->Child);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* PROJECT: EFI Windows Loader
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: freeldr/winldr/conversion.c
|
||||
* PURPOSE: Physical <-> Virtual addressing mode conversions
|
||||
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ***************************************************************/
|
||||
|
||||
#include <freeldr.h>
|
||||
|
||||
//#include <ndk/ldrtypes.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
||||
/* Arch-specific addresses translation implementation */
|
||||
PVOID
|
||||
VaToPa(PVOID Va)
|
||||
{
|
||||
return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE);
|
||||
}
|
||||
|
||||
PVOID
|
||||
PaToVa(PVOID Pa)
|
||||
{
|
||||
return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE);
|
||||
}
|
||||
|
||||
VOID
|
||||
List_PaToVa(LIST_ENTRY *ListEntry)
|
||||
{
|
||||
LIST_ENTRY *ListHead = ListEntry;
|
||||
LIST_ENTRY *Next = ListEntry->Flink;
|
||||
LIST_ENTRY *NextPA;
|
||||
|
||||
//Print(L"\n\nList_Entry: %X, First Next: %X\n", ListEntry, Next);
|
||||
//
|
||||
// Walk through the whole list
|
||||
//
|
||||
if (Next != NULL)
|
||||
{
|
||||
while (Next != PaToVa(ListHead))
|
||||
{
|
||||
NextPA = VaToPa(Next);
|
||||
//Print(L"Current: %X, Flink: %X, Blink: %X\n", Next, NextPA->Flink, NextPA->Blink);
|
||||
|
||||
NextPA->Flink = PaToVa((PVOID)NextPA->Flink);
|
||||
NextPA->Blink = PaToVa((PVOID)NextPA->Blink);
|
||||
|
||||
//Print(L"After converting Flink: %X, Blink: %X\n", NextPA->Flink, NextPA->Blink);
|
||||
|
||||
Next = NextPA->Flink;
|
||||
}
|
||||
|
||||
//
|
||||
// Finally convert first Flink/Blink
|
||||
//
|
||||
ListEntry->Flink = PaToVa((PVOID)ListEntry->Flink);
|
||||
if (ListEntry->Blink)
|
||||
ListEntry->Blink = PaToVa((PVOID)ListEntry->Blink);
|
||||
}
|
||||
}
|
||||
|
||||
// This function converts only Child->Child, and calls itself for each Sibling
|
||||
VOID
|
||||
ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
|
||||
{
|
||||
PCONFIGURATION_COMPONENT_DATA Child;
|
||||
PCONFIGURATION_COMPONENT_DATA Sibling;
|
||||
|
||||
DbgPrint((DPRINT_WINDOWS, "ConvertConfigToVA(Start 0x%X)", Start));
|
||||
Child = Start;
|
||||
|
||||
while (Child != NULL)
|
||||
{
|
||||
if (Child->ConfigurationData)
|
||||
Child->ConfigurationData = PaToVa(Child->ConfigurationData);
|
||||
|
||||
if (Child->Child)
|
||||
Child->Child = PaToVa(Child->Child);
|
||||
|
||||
if (Child->Parent)
|
||||
Child->Parent = PaToVa(Child->Parent);
|
||||
|
||||
if (Child->Sibling)
|
||||
Child->Sibling = PaToVa(Child->Sibling);
|
||||
|
||||
DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Child, Child->ComponentEntry.Class));
|
||||
|
||||
// If the child has a sibling list, then search the sibling list
|
||||
// for an entry that matches the specified class, type, and key.
|
||||
Sibling = Child->Sibling;
|
||||
while (Sibling != NULL)
|
||||
{
|
||||
if (Sibling->ConfigurationData)
|
||||
Sibling->ConfigurationData = PaToVa(Sibling->ConfigurationData);
|
||||
|
||||
if (Sibling->Child)
|
||||
Sibling->Child = PaToVa(Sibling->Child);
|
||||
|
||||
if (Sibling->Parent)
|
||||
Sibling->Parent = PaToVa(Sibling->Parent);
|
||||
|
||||
if (Sibling->Sibling)
|
||||
Sibling->Sibling = PaToVa(Sibling->Sibling);
|
||||
|
||||
DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Sibling, Sibling->ComponentEntry.Class));
|
||||
|
||||
// If the sibling has a child tree, then search the child tree
|
||||
// for an entry that matches the specified class, type, and key.
|
||||
if (VaToPa(Sibling->Child) != NULL)
|
||||
ConvertConfigToVA(VaToPa(Sibling->Child));
|
||||
|
||||
Sibling = VaToPa(Sibling->Sibling);
|
||||
}
|
||||
|
||||
Child = VaToPa(Child->Child);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
104
reactos/boot/freeldr/freeldr/windows/wlregistry.c
Normal file
104
reactos/boot/freeldr/freeldr/windows/wlregistry.c
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* PROJECT: EFI Windows Loader
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: freeldr/winldr/wlregistry.c
|
||||
* PURPOSE: Registry support functions
|
||||
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ***************************************************************/
|
||||
|
||||
#include <freeldr.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||
IN LPCSTR DirectoryPath,
|
||||
IN LPCSTR HiveName)
|
||||
{
|
||||
PFILE FileHandle;
|
||||
CHAR FullHiveName[256];
|
||||
BOOLEAN Status;
|
||||
ULONG HiveFileSize;
|
||||
ULONG_PTR HiveDataPhysical;
|
||||
PVOID HiveDataVirtual;
|
||||
|
||||
/* Concatenate path and filename to get the full name */
|
||||
strcpy(FullHiveName, DirectoryPath);
|
||||
strcat(FullHiveName, HiveName);
|
||||
//Print(L"Loading %s...\n", FullHiveName);
|
||||
FileHandle = FsOpenFile(FullHiveName);
|
||||
|
||||
if (FileHandle == NULL)
|
||||
{
|
||||
UiMessageBox("Opening hive file failed!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get the file length */
|
||||
HiveFileSize = FsGetFileSize(FileHandle);
|
||||
|
||||
if (HiveFileSize == 0)
|
||||
{
|
||||
FsCloseFile(FileHandle);
|
||||
UiMessageBox("Hive file has 0 size!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Round up the size to page boundary and alloc memory */
|
||||
HiveDataPhysical = (ULONG_PTR)MmAllocateMemory(
|
||||
MM_SIZE_TO_PAGES(HiveFileSize + MM_PAGE_SIZE - 1) << MM_PAGE_SHIFT);
|
||||
|
||||
if (HiveDataPhysical == 0)
|
||||
{
|
||||
FsCloseFile(FileHandle);
|
||||
UiMessageBox("Unable to alloc memory for a hive!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Convert address to virtual */
|
||||
HiveDataVirtual = (PVOID)(KSEG0_BASE | HiveDataPhysical);
|
||||
|
||||
/* Fill LoaderBlock's entries */
|
||||
LoaderBlock->RegistryLength = HiveFileSize;
|
||||
LoaderBlock->RegistryBase = HiveDataVirtual;
|
||||
|
||||
/* Finally read from file to the memory */
|
||||
Status = FsReadFile(FileHandle, HiveFileSize, NULL, (PVOID)HiveDataPhysical);
|
||||
FsCloseFile(FileHandle);
|
||||
if (!Status)
|
||||
{
|
||||
UiMessageBox("Unable to read from hive file!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN WinLdrLoadAndScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||
IN LPCSTR DirectoryPath)
|
||||
{
|
||||
CHAR SearchPath[1024];
|
||||
BOOLEAN Status;
|
||||
|
||||
// There is a simple logic here: try to load usual hive (system), if it
|
||||
// fails, then give system.alt a try, and finally try a system.sav
|
||||
|
||||
// FIXME: For now we only try system
|
||||
strcpy(SearchPath, DirectoryPath);
|
||||
strcat(SearchPath, "SYSTEM32\\CONFIG\\");
|
||||
Status = WinLdrLoadSystemHive(LoaderBlock, SearchPath, "SYSTEM");
|
||||
|
||||
// Fail if failed...
|
||||
if (!Status)
|
||||
return FALSE;
|
||||
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
Loading…
Reference in a new issue