[FREELDR]

- Fix dprints (be careful when "Status" variables are booleans).
- Don't fail when trying to load an non-existent KD transport dll.

svn path=/branches/kd++/; revision=58971
This commit is contained in:
Hermès Bélusca-Maïto 2013-05-08 17:52:16 +00:00
parent 0811c4fabe
commit 1398bd62c8
3 changed files with 28 additions and 25 deletions

View file

@ -1568,7 +1568,7 @@ LoadBootDeviceDriver(VOID)
ULONG ImportTableSize;
PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE;
CHAR NtBootDdPath[MAX_PATH];
PVOID ImageBase;
PVOID ImageBase = NULL;
ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath);
BOOLEAN Status;

View file

@ -255,11 +255,12 @@ WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
return TRUE;
}
/* WinLdrLoadImage loads the specified image from the file (it doesn't
perform any additional operations on the filename, just directly
calls the file I/O routines), and relocates it so that it's ready
to be used when paging is enabled.
Addressing mode: physical
/*
* WinLdrLoadImage loads the specified image from the file (it doesn't
* perform any additional operations on the filename, just directly
* calls the file I/O routines), and relocates it so that it's ready
* to be used when paging is enabled.
* Addressing mode: physical
*/
BOOLEAN
WinLdrLoadImage(IN PCHAR FileName,
@ -430,7 +431,6 @@ WinLdrLoadImage(IN PCHAR FileName,
if (Status != ESUCCESS)
return FALSE;
/* Relocate the image, if it needs it */
if (NtHeaders->OptionalHeader.ImageBase != (ULONG_PTR)VirtualBase)
{
@ -756,7 +756,7 @@ WinLdrpLoadAndScanReferencedDll(PLIST_ENTRY ModuleListHead,
{
CHAR FullDllName[256];
BOOLEAN Status;
PVOID BasePA;
PVOID BasePA = NULL;
/* Prepare the full path to the file to be loaded */
strcpy(FullDllName, DirectoryPath);
@ -781,7 +781,7 @@ WinLdrpLoadAndScanReferencedDll(PLIST_ENTRY ModuleListHead,
DataTableEntry);
if (!Status)
{
ERR("WinLdrAllocateDataTableEntry() failed with Status=0x%X\n", Status);
ERR("WinLdrAllocateDataTableEntry() failed\n");
return Status;
}
@ -791,7 +791,7 @@ WinLdrpLoadAndScanReferencedDll(PLIST_ENTRY ModuleListHead,
Status = WinLdrScanImportDescriptorTable(ModuleListHead, DirectoryPath, *DataTableEntry);
if (!Status)
{
ERR("WinLdrScanImportDescriptorTable() failed with Status=0x%X\n", Status);
ERR("WinLdrScanImportDescriptorTable() failed\n");
return Status;
}

View file

@ -237,7 +237,7 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
CHAR DllName[1024];
PCHAR DriverNamePos;
BOOLEAN Status;
PVOID DriverBase;
PVOID DriverBase = NULL;
// Separate the path to file name and directory path
_snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
@ -259,7 +259,6 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
TRACE("DriverPath: %s, DllName: %s, LPB\n", DriverPath, DllName);
// Check if driver is already loaded
Status = WinLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
if (Status)
@ -424,7 +423,7 @@ WinLdrDetectVersion()
}
static
PVOID
BOOLEAN
LoadModule(
PLOADER_PARAMETER_BLOCK LoaderBlock,
PCCH Path,
@ -434,10 +433,10 @@ LoadModule(
BOOLEAN IsKdTransportDll,
ULONG Percentage)
{
BOOLEAN Status;
CHAR FullFileName[MAX_PATH];
CHAR ProgressString[256];
NTSTATUS Status;
PVOID BaseAdress;
PVOID BaseAdress = NULL;
UiDrawBackdrop();
sprintf(ProgressString, "Loading %s...", File);
@ -448,8 +447,12 @@ LoadModule(
strcat(FullFileName, File);
Status = WinLdrLoadImage(FullFileName, MemoryType, &BaseAdress);
TRACE("%s loaded with status %d at %p\n",
File, Status, BaseAdress);
if (!Status)
{
TRACE("Loading %s failed\n", File);
return FALSE;
}
TRACE("%s loaded successfully at %p\n", File, BaseAdress);
strcpy(FullFileName, "WINDOWS\\SYSTEM32\\");
strcat(FullFileName, File);
@ -458,13 +461,13 @@ LoadModule(
* the Kernel Debugger Transport DLL, to make the
* PE loader happy.
*/
WinLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
(IsKdTransportDll ? "KDCOM.DLL" : File),
FullFileName,
BaseAdress,
Dte);
Status = WinLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
(IsKdTransportDll ? "KDCOM.DLL" : File),
FullFileName,
BaseAdress,
Dte);
return BaseAdress;
return Status;
}
static
@ -679,11 +682,11 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
UiDrawBackdrop();
UiDrawProgressBarCenter(15, 100, "Loading system hive...");
Status = WinLdrInitSystemHive(LoaderBlock, BootPath);
TRACE("SYSTEM hive loaded with status %d\n", Status);
TRACE("SYSTEM hive %s\n", (Status ? "loaded" : "not loaded"));
/* Load NLS data, OEM font, and prepare boot drivers list */
Status = WinLdrScanSystemHive(LoaderBlock, BootPath);
TRACE("SYSTEM hive scanned with status %d\n", Status);
TRACE("SYSTEM hive %s\n", (Status ? "scanned" : "not scanned"));
/* Finish loading */
LoadAndBootWindowsCommon(OperatingSystemVersion,