[FREELDR] Rename the PE loader functions 'PeLdr*' instead of 'WinLdr*'.

This commit is contained in:
Hermès Bélusca-Maïto 2019-09-19 02:47:29 +02:00
parent 97f31ac396
commit 658d5a3ff5
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 503 additions and 512 deletions

View file

@ -1639,7 +1639,7 @@ LoadBootDeviceDriver(VOID)
strcat(NtBootDdPath, "\\NTBOOTDD.SYS");
/* Load file */
Success = WinLdrLoadImage(NtBootDdPath, LoaderBootDriver, &ImageBase);
Success = PeLdrLoadImage(NtBootDdPath, LoaderBootDriver, &ImageBase);
if (!Success)
{
/* That's OK. File simply doesn't exist */
@ -1647,15 +1647,15 @@ LoadBootDeviceDriver(VOID)
}
/* Allocate a DTE for ntbootdd */
Success = WinLdrAllocateDataTableEntry(&ModuleListHead, "ntbootdd.sys",
"NTBOOTDD.SYS", ImageBase, &BootDdDTE);
Success = PeLdrAllocateDataTableEntry(&ModuleListHead, "ntbootdd.sys",
"NTBOOTDD.SYS", ImageBase, &BootDdDTE);
if (!Success)
return EIO;
/* Add the PE part of freeldr.sys to the list of loaded executables, it
contains ScsiPort* exports, imported by ntbootdd.sys */
Success = WinLdrAllocateDataTableEntry(&ModuleListHead, "scsiport.sys",
"FREELDR.SYS", &__ImageBase, &FreeldrDTE);
Success = PeLdrAllocateDataTableEntry(&ModuleListHead, "scsiport.sys",
"FREELDR.SYS", &__ImageBase, &FreeldrDTE);
if (!Success)
{
RemoveEntryList(&BootDdDTE->InLoadOrderLinks);
@ -1663,7 +1663,7 @@ LoadBootDeviceDriver(VOID)
}
/* Fix imports */
Success = WinLdrScanImportDescriptorTable(&ModuleListHead, "", BootDdDTE);
Success = PeLdrScanImportDescriptorTable(&ModuleListHead, "", BootDdDTE);
/* Now unlinkt the DTEs, they won't be valid later */
RemoveEntryList(&BootDdDTE->InLoadOrderLinks);

View file

@ -19,23 +19,27 @@
#pragma once
BOOLEAN
WinLdrLoadImage(IN PCHAR FileName,
TYPE_OF_MEMORY MemoryType,
OUT PVOID *ImageBasePA);
PeLdrLoadImage(
IN PCHAR FileName,
IN TYPE_OF_MEMORY MemoryType,
OUT PVOID *ImageBasePA);
BOOLEAN
WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH BaseDllName,
IN PCCH FullDllName,
IN PVOID BasePA,
OUT PLDR_DATA_TABLE_ENTRY *NewEntry);
PeLdrAllocateDataTableEntry(
IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH BaseDllName,
IN PCCH FullDllName,
IN PVOID BasePA,
OUT PLDR_DATA_TABLE_ENTRY *NewEntry);
BOOLEAN
WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH DirectoryPath,
IN PLDR_DATA_TABLE_ENTRY ScanDTE);
PeLdrScanImportDescriptorTable(
IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH DirectoryPath,
IN PLDR_DATA_TABLE_ENTRY ScanDTE);
BOOLEAN
WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead,
IN PCH DllName,
OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
PeLdrCheckForLoadedDll(
IN OUT PLIST_ENTRY ModuleListHead,
IN PCH DllName,
OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);

File diff suppressed because it is too large Load diff

View file

@ -258,7 +258,7 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
TRACE("DriverPath: '%s', DllName: '%s', LPB\n", DriverPath, DllName);
// Check if driver is already loaded
Success = WinLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
Success = PeLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
if (Success)
{
// We've got the pointer to its DTE, just return success
@ -267,15 +267,15 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
// It's not loaded, we have to load it
RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
Success = WinLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
if (!Success)
return FALSE;
// Allocate a DTE for it
Success = WinLdrAllocateDataTableEntry(LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE);
Success = PeLdrAllocateDataTableEntry(LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE);
if (!Success)
{
ERR("WinLdrAllocateDataTableEntry() failed\n");
ERR("PeLdrAllocateDataTableEntry() failed\n");
return FALSE;
}
@ -284,10 +284,10 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
// Look for any dependencies it may have, and load them too
RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%s", BootPath, DriverPath);
Success = WinLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
Success = PeLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
if (!Success)
{
ERR("WinLdrScanImportDescriptorTable() failed for %s\n", FullPath);
ERR("PeLdrScanImportDescriptorTable() failed for %s\n", FullPath);
return FALSE;
}
@ -451,7 +451,7 @@ LoadModule(
RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
Success = WinLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
if (!Success)
{
TRACE("Loading %s failed\n", File);
@ -464,11 +464,11 @@ LoadModule(
* the Kernel Debugger Transport DLL, to make the
* PE loader happy.
*/
Success = WinLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
ImportName,
FullFileName,
BaseAddress,
Dte);
Success = PeLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
ImportName,
FullFileName,
BaseAddress,
Dte);
return Success;
}
@ -640,11 +640,11 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
}
/* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
Success = WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
Success &= WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
Success &= PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
if (KdComDTE)
{
Success &= WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdComDTE);
Success &= PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdComDTE);
}
return Success;