[FREELDR] peloader.c: Fix some traces

This commit is contained in:
Hermès Bélusca-Maïto 2024-11-25 22:38:01 +01:00
parent 9382aa286c
commit ddd59f19ae
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -158,10 +158,10 @@ PeLdrpBindImportName(
//TRACE("PeLdrpBindImportName(): DllBase 0x%p, ImageBase 0x%p, ThunkData 0x%p, ExportDirectory 0x%p, ExportSize %d, ProcessForwards 0x%X\n", //TRACE("PeLdrpBindImportName(): DllBase 0x%p, ImageBase 0x%p, ThunkData 0x%p, ExportDirectory 0x%p, ExportSize %d, ProcessForwards 0x%X\n",
// DllBase, ImageBase, ThunkData, ExportDirectory, ExportSize, ProcessForwards); // DllBase, ImageBase, ThunkData, ExportDirectory, ExportSize, ProcessForwards);
/* Check passed DllBase param */ /* Check passed DllBase */
if (DllBase == NULL) if (!DllBase)
{ {
WARN("DllBase == NULL!\n"); WARN("DllBase == NULL\n");
return FALSE; return FALSE;
} }
@ -235,13 +235,8 @@ PeLdrpBindImportName(
/* Compare the names */ /* Compare the names */
Result = strcmp(ExportName, (PCHAR)ImportData->Name); Result = strcmp(ExportName, (PCHAR)ImportData->Name);
// TRACE("Binary search: comparing Import '__', Export '%s'\n", // TRACE("Binary search: comparing Import '%s', Export '%s'\n",
// VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name[0]), // (PCHAR)ImportData->Name, ExportName);
// (PCHAR)VaToPa(RVA(DllBase, NameTable[Middle])));
// TRACE("TE->u1.AOD %p, fulladdr %p\n",
// ThunkData->u1.AddressOfData,
// ((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name );
/* Depending on result of strcmp, perform different actions */ /* Depending on result of strcmp, perform different actions */
if (Result > 0) if (Result > 0)
@ -270,7 +265,6 @@ PeLdrpBindImportName(
/* Everything alright, get the ordinal */ /* Everything alright, get the ordinal */
Ordinal = OrdinalTable[Middle]; Ordinal = OrdinalTable[Middle];
//TRACE("PeLdrpBindImportName() found Ordinal %d\n", Ordinal); //TRACE("PeLdrpBindImportName() found Ordinal %d\n", Ordinal);
} }
} }
@ -436,7 +430,8 @@ PeLdrpLoadAndScanReferencedDll(
(*DataTableEntry)->Flags |= LDRP_DRIVER_DEPENDENT_DLL; (*DataTableEntry)->Flags |= LDRP_DRIVER_DEPENDENT_DLL;
/* Scan its dependencies too */ /* Scan its dependencies too */
TRACE("PeLdrScanImportDescriptorTable() calling ourselves for %S\n", TRACE("PeLdrScanImportDescriptorTable() calling ourselves for '%.*S'\n",
(*DataTableEntry)->BaseDllName.Length / sizeof(WCHAR),
VaToPa((*DataTableEntry)->BaseDllName.Buffer)); VaToPa((*DataTableEntry)->BaseDllName.Buffer));
Success = PeLdrScanImportDescriptorTable(ModuleListHead, DirectoryPath, *DataTableEntry); Success = PeLdrScanImportDescriptorTable(ModuleListHead, DirectoryPath, *DataTableEntry);
if (!Success) if (!Success)
@ -464,13 +459,14 @@ PeLdrpScanImportAddressTable(
BOOLEAN Success; BOOLEAN Success;
ULONG ExportSize; ULONG ExportSize;
TRACE("PeLdrpScanImportAddressTable(): DllBase 0x%p, " TRACE("PeLdrpScanImportAddressTable(): "
"ImageBase 0x%p, ThunkData 0x%p\n", DllBase, ImageBase, ThunkData); "DllBase 0x%p, ImageBase 0x%p, ThunkData 0x%p\n",
DllBase, ImageBase, ThunkData);
/* Obtain the export table from the DLL's base */ /* Obtain the export table from the DLL's base */
if (DllBase == NULL) if (!DllBase)
{ {
ERR("Error, DllBase == NULL!\n"); ERR("DllBase == NULL\n");
return FALSE; return FALSE;
} }
else else
@ -481,13 +477,12 @@ PeLdrpScanImportAddressTable(
IMAGE_DIRECTORY_ENTRY_EXPORT, IMAGE_DIRECTORY_ENTRY_EXPORT,
&ExportSize); &ExportSize);
} }
TRACE("PeLdrpScanImportAddressTable(): ExportDirectory 0x%p\n", ExportDirectory); TRACE("PeLdrpScanImportAddressTable(): ExportDirectory 0x%p\n", ExportDirectory);
/* If pointer to Export Directory is */ /* Fail if no export directory */
if (ExportDirectory == NULL) if (!ExportDirectory)
{ {
ERR("DllBase=%p(%p)\n", DllBase, VaToPa(DllBase)); ERR("No ExportDir, DllBase = %p (%p)\n", DllBase, VaToPa(DllBase));
return FALSE; return FALSE;
} }
@ -603,9 +598,10 @@ PeLdrCheckForLoadedDll(
LDR_DATA_TABLE_ENTRY, LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks); InLoadOrderLinks);
TRACE("PeLdrCheckForLoadedDll: DTE %p, EP %p, base %p name '%.*ws'\n", TRACE("PeLdrCheckForLoadedDll: DTE %p, EP %p, Base %p, Name '%.*S'\n",
DataTableEntry, DataTableEntry->EntryPoint, DataTableEntry->DllBase, DataTableEntry, DataTableEntry->EntryPoint, DataTableEntry->DllBase,
DataTableEntry->BaseDllName.Length / 2, VaToPa(DataTableEntry->BaseDllName.Buffer)); DataTableEntry->BaseDllName.Length / sizeof(WCHAR),
VaToPa(DataTableEntry->BaseDllName.Buffer));
/* Compare names */ /* Compare names */
if (PeLdrpCompareDllName(DllName, &DataTableEntry->BaseDllName)) if (PeLdrpCompareDllName(DllName, &DataTableEntry->BaseDllName))