[FREELDR]

- Improve List_PaToVa, making the code cleaner
- Dereference LoaderBlock->Extension only after WinLdrSetProcessorContext, since its in kernel address space

svn path=/trunk/; revision=53710
This commit is contained in:
Timo Kreuzer
2011-09-15 11:27:27 +00:00
parent 00502b9642
commit b7e45abc51
2 changed files with 24 additions and 29 deletions
@@ -45,38 +45,32 @@ PaToVa(PVOID Pa)
#endif
VOID
List_PaToVa(LIST_ENTRY *ListEntry)
List_PaToVa(PLIST_ENTRY ListHeadPa)
{
LIST_ENTRY *ListHead = ListEntry;
LIST_ENTRY *Next = ListEntry->Flink;
LIST_ENTRY *NextPA;
PLIST_ENTRY EntryPa, NextPa;
//Print(L"\n\nList_Entry: %X, First Next: %X\n", ListEntry, Next);
//
// Walk through the whole list
//
if (Next != NULL)
/* List must be properly initialized */
ASSERT(ListHeadPa->Flink != 0);
ASSERT(ListHeadPa->Blink != 0);
/* Loop the list in physical address space */
EntryPa = ListHeadPa->Flink;
while (EntryPa != ListHeadPa)
{
while (Next != PaToVa(ListHead))
{
NextPA = VaToPa(Next);
//Print(L"Current: %X, Flink: %X, Blink: %X\n", Next, NextPA->Flink, NextPA->Blink);
/* Save the physical address of the next entry */
NextPa = EntryPa->Flink;
NextPA->Flink = PaToVa((PVOID)NextPA->Flink);
NextPA->Blink = PaToVa((PVOID)NextPA->Blink);
/* Convert the addresses of this entry */
EntryPa->Flink = PaToVa(EntryPa->Flink);
EntryPa->Blink = PaToVa(EntryPa->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);
/* Go to the next entry */
EntryPa = NextPa;
}
/* Finally convert the list head */
ListHeadPa->Flink = PaToVa(ListHeadPa->Flink);
ListHeadPa->Blink = PaToVa(ListHeadPa->Blink);
}
// This function converts only Child->Child, and calls itself for each Sibling
@@ -569,6 +569,7 @@ LoadAndBootWindowsCommon(
PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL;
KERNEL_ENTRY_POINT KiSystemStartup;
LPCSTR SystemRoot;
TRACE("LoadAndBootWindowsCommon()\n");
/* Convert BootPath to SystemRoot */
SystemRoot = strstr(BootPath, "\\");
@@ -631,12 +632,12 @@ LoadAndBootWindowsCommon(
/* Map pages and create memory descriptors */
WinLdrSetupMemoryLayout(LoaderBlock);
/* Save final value of LoaderPagesSpanned */
LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
/* Set processor context */
WinLdrSetProcessorContext();
/* Save final value of LoaderPagesSpanned */
LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
KiSystemStartup, LoaderBlockVA);