Skip to content

Commit ddd59f1

Browse files
committed
[FREELDR] peloader.c: Fix some traces
1 parent 9382aa2 commit ddd59f1

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

boot/freeldr/freeldr/lib/peloader.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ PeLdrpBindImportName(
158158
//TRACE("PeLdrpBindImportName(): DllBase 0x%p, ImageBase 0x%p, ThunkData 0x%p, ExportDirectory 0x%p, ExportSize %d, ProcessForwards 0x%X\n",
159159
// DllBase, ImageBase, ThunkData, ExportDirectory, ExportSize, ProcessForwards);
160160

161-
/* Check passed DllBase param */
162-
if (DllBase == NULL)
161+
/* Check passed DllBase */
162+
if (!DllBase)
163163
{
164-
WARN("DllBase == NULL!\n");
164+
WARN("DllBase == NULL\n");
165165
return FALSE;
166166
}
167167

@@ -235,13 +235,8 @@ PeLdrpBindImportName(
235235
/* Compare the names */
236236
Result = strcmp(ExportName, (PCHAR)ImportData->Name);
237237

238-
// TRACE("Binary search: comparing Import '__', Export '%s'\n",
239-
// VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name[0]),
240-
// (PCHAR)VaToPa(RVA(DllBase, NameTable[Middle])));
241-
242-
// TRACE("TE->u1.AOD %p, fulladdr %p\n",
243-
// ThunkData->u1.AddressOfData,
244-
// ((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name );
238+
// TRACE("Binary search: comparing Import '%s', Export '%s'\n",
239+
// (PCHAR)ImportData->Name, ExportName);
245240

246241
/* Depending on result of strcmp, perform different actions */
247242
if (Result > 0)
@@ -270,7 +265,6 @@ PeLdrpBindImportName(
270265

271266
/* Everything alright, get the ordinal */
272267
Ordinal = OrdinalTable[Middle];
273-
274268
//TRACE("PeLdrpBindImportName() found Ordinal %d\n", Ordinal);
275269
}
276270
}
@@ -436,7 +430,8 @@ PeLdrpLoadAndScanReferencedDll(
436430
(*DataTableEntry)->Flags |= LDRP_DRIVER_DEPENDENT_DLL;
437431

438432
/* Scan its dependencies too */
439-
TRACE("PeLdrScanImportDescriptorTable() calling ourselves for %S\n",
433+
TRACE("PeLdrScanImportDescriptorTable() calling ourselves for '%.*S'\n",
434+
(*DataTableEntry)->BaseDllName.Length / sizeof(WCHAR),
440435
VaToPa((*DataTableEntry)->BaseDllName.Buffer));
441436
Success = PeLdrScanImportDescriptorTable(ModuleListHead, DirectoryPath, *DataTableEntry);
442437
if (!Success)
@@ -464,13 +459,14 @@ PeLdrpScanImportAddressTable(
464459
BOOLEAN Success;
465460
ULONG ExportSize;
466461

467-
TRACE("PeLdrpScanImportAddressTable(): DllBase 0x%p, "
468-
"ImageBase 0x%p, ThunkData 0x%p\n", DllBase, ImageBase, ThunkData);
462+
TRACE("PeLdrpScanImportAddressTable(): "
463+
"DllBase 0x%p, ImageBase 0x%p, ThunkData 0x%p\n",
464+
DllBase, ImageBase, ThunkData);
469465

470466
/* Obtain the export table from the DLL's base */
471-
if (DllBase == NULL)
467+
if (!DllBase)
472468
{
473-
ERR("Error, DllBase == NULL!\n");
469+
ERR("DllBase == NULL\n");
474470
return FALSE;
475471
}
476472
else
@@ -481,13 +477,12 @@ PeLdrpScanImportAddressTable(
481477
IMAGE_DIRECTORY_ENTRY_EXPORT,
482478
&ExportSize);
483479
}
484-
485480
TRACE("PeLdrpScanImportAddressTable(): ExportDirectory 0x%p\n", ExportDirectory);
486481

487-
/* If pointer to Export Directory is */
488-
if (ExportDirectory == NULL)
482+
/* Fail if no export directory */
483+
if (!ExportDirectory)
489484
{
490-
ERR("DllBase=%p(%p)\n", DllBase, VaToPa(DllBase));
485+
ERR("No ExportDir, DllBase = %p (%p)\n", DllBase, VaToPa(DllBase));
491486
return FALSE;
492487
}
493488

@@ -603,9 +598,10 @@ PeLdrCheckForLoadedDll(
603598
LDR_DATA_TABLE_ENTRY,
604599
InLoadOrderLinks);
605600

606-
TRACE("PeLdrCheckForLoadedDll: DTE %p, EP %p, base %p name '%.*ws'\n",
601+
TRACE("PeLdrCheckForLoadedDll: DTE %p, EP %p, Base %p, Name '%.*S'\n",
607602
DataTableEntry, DataTableEntry->EntryPoint, DataTableEntry->DllBase,
608-
DataTableEntry->BaseDllName.Length / 2, VaToPa(DataTableEntry->BaseDllName.Buffer));
603+
DataTableEntry->BaseDllName.Length / sizeof(WCHAR),
604+
VaToPa(DataTableEntry->BaseDllName.Buffer));
609605

610606
/* Compare names */
611607
if (PeLdrpCompareDllName(DllName, &DataTableEntry->BaseDllName))

0 commit comments

Comments
 (0)