PLDR_DATA_TABLE_ENTRY DataTableEntry;
LIST_ENTRY *ModuleEntry;
- DPRINTM(DPRINT_WINDOWS, "WinLdrCheckForLoadedDll: DllName %X, LoadedEntry: %X\n",
+ DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: DllName %X, LoadedEntry: %X\n",
DllName, LoadedEntry);
/* Just go through each entry in the LoadOrderList and compare loaded module's
LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
- DPRINTM(DPRINT_WINDOWS, "WinLdrCheckForLoadedDll: DTE %p, EP %p\n",
+ DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: DTE %p, EP %p\n",
DataTableEntry, DataTableEntry->EntryPoint);
/* Compare names */
to the caller and increase load count for it */
*LoadedEntry = DataTableEntry;
DataTableEntry->LoadCount++;
- DPRINTM(DPRINT_WINDOWS, "WinLdrCheckForLoadedDll: LoadedEntry %X\n", DataTableEntry);
+ DPRINTM(DPRINT_PELOADER, "WinLdrCheckForLoadedDll: LoadedEntry %X\n", DataTableEntry);
return TRUE;
}
BaseName.Buffer = VaToPa(ScanDTE->BaseDllName.Buffer);
BaseName.MaximumLength = ScanDTE->BaseDllName.MaximumLength;
BaseName.Length = ScanDTE->BaseDllName.Length;
- DPRINTM(DPRINT_WINDOWS, "WinLdrScanImportDescriptorTable(): %wZ ImportTable = 0x%X\n",
+ DPRINTM(DPRINT_PELOADER, "WinLdrScanImportDescriptorTable(): %wZ ImportTable = 0x%X\n",
&BaseName, ImportTable);
}
{
/* Get pointer to the name */
ImportName = (PCH)VaToPa(RVA(ScanDTE->DllBase, ImportTable->Name));
- DPRINTM(DPRINT_WINDOWS, "WinLdrScanImportDescriptorTable(): Looking at %s\n", ImportName);
+ DPRINTM(DPRINT_PELOADER, "WinLdrScanImportDescriptorTable(): Looking at %s\n", ImportName);
/* In case we get a reference to ourselves - just skip it */
if (WinLdrpCompareDllName(ImportName, &ScanDTE->BaseDllName))
if (!Status)
{
- DPRINTM(DPRINT_WINDOWS, "WinLdrpLoadAndScanReferencedDll() failed\n");
+ DPRINTM(DPRINT_PELOADER, "WinLdrpLoadAndScanReferencedDll() failed\n");
return Status;
}
}
if (!Status)
{
- DPRINTM(DPRINT_WINDOWS, "WinLdrpScanImportAddressTable() failed\n");
+ DPRINTM(DPRINT_PELOADER, "WinLdrpScanImportAddressTable() failed\n");
return Status;
}
}
/* This is the real image base - in form of a virtual address */
VirtualBase = PaToVa(PhysicalBase);
- DPRINTM(DPRINT_WINDOWS, "Base PA: 0x%X, VA: 0x%X\n", PhysicalBase, VirtualBase);
+ DPRINTM(DPRINT_PELOADER, "Base PA: 0x%X, VA: 0x%X\n", PhysicalBase, VirtualBase);
/* Set to 0 position and fully load the file image */
FsSetFilePointer(FileHandle, 0);
/* Seek to the correct position */
FsSetFilePointer(FileHandle, SectionHeader->PointerToRawData);
- DPRINTM(DPRINT_WINDOWS, "SH->VA: 0x%X\n", SectionHeader->VirtualAddress);
+ DPRINTM(DPRINT_PELOADER, "SH->VA: 0x%X\n", SectionHeader->VirtualAddress);
/* Read this section from the file, size = SizeOfRawData */
Status = FsReadFile(FileHandle, SizeOfRawData, &BytesRead, (PUCHAR)PhysicalBase + SectionHeader->VirtualAddress);
if (!Status && (BytesRead == 0))
{
- DPRINTM(DPRINT_WINDOWS, "WinLdrLoadImage(): Error reading section from file!\n");
+ DPRINTM(DPRINT_PELOADER, "WinLdrLoadImage(): Error reading section from file!\n");
break;
}
}
/* Size of data is less than the virtual size - fill up the remainder with zeroes */
if (SizeOfRawData < VirtualSize)
{
- DPRINTM(DPRINT_WINDOWS, "WinLdrLoadImage(): SORD %d < VS %d\n", SizeOfRawData, VirtualSize);
+ DPRINTM(DPRINT_PELOADER, "WinLdrLoadImage(): SORD %d < VS %d\n", SizeOfRawData, VirtualSize);
RtlZeroMemory((PVOID)(SectionHeader->VirtualAddress + (ULONG)PhysicalBase + SizeOfRawData), VirtualSize - SizeOfRawData);
}
/* Relocate the image, if it needs it */
if (NtHeaders->OptionalHeader.ImageBase != (ULONG)VirtualBase)
{
- DPRINTM(DPRINT_WINDOWS, "Relocating %p -> %p\n",
+ DPRINTM(DPRINT_PELOADER, "Relocating %p -> %p\n",
NtHeaders->OptionalHeader.ImageBase, VirtualBase);
Status = (BOOLEAN)LdrRelocateImageWithBias(PhysicalBase,
(ULONG_PTR)VirtualBase - (ULONG_PTR)PhysicalBase,
UnicodeNamePA.Length = UnicodeName->Length;
UnicodeNamePA.MaximumLength = UnicodeName->MaximumLength;
UnicodeNamePA.Buffer = VaToPa(UnicodeName->Buffer);
- DPRINTM(DPRINT_WINDOWS, "WinLdrpCompareDllName: %s and %wZ, Length = %d "
+ DPRINTM(DPRINT_PELOADER, "WinLdrpCompareDllName: %s and %wZ, Length = %d "
"UN->Length %d\n", DllName, &UnicodeNamePA, Length, UnicodeName->Length);
if ((Length * sizeof(WCHAR)) > UnicodeName->Length)
LONG High, Low, Middle, Result;
ULONG Hint;
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName(): DllBase 0x%X, ImageBase 0x%X, ThunkData 0x%X, ExportDirectory 0x%X, ExportSize %d, ProcessForwards 0x%X\n",
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): DllBase 0x%X, ImageBase 0x%X, ThunkData 0x%X, ExportDirectory 0x%X, ExportSize %d, ProcessForwards 0x%X\n",
// DllBase, ImageBase, ThunkData, ExportDirectory, ExportSize, ProcessForwards);
/* Check passed DllBase param */
if(DllBase == NULL)
{
- DPRINTM(DPRINT_WINDOWS, "WARNING: DllBase == NULL!\n");
+ DPRINTM(DPRINT_PELOADER, "WARNING: DllBase == NULL!\n");
return FALSE;
}
{
/* Yes, calculate the ordinal */
Ordinal = (ULONG)(IMAGE_ORDINAL(ThunkData->u1.Ordinal) - (UINT32)ExportDirectory->Base);
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName(): Ordinal %d\n", Ordinal);
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): Ordinal %d\n", Ordinal);
}
else
{
if (!ProcessForwards)
{
/* AddressOfData in thunk entry will become a virtual address (from relative) */
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName(): ThunkData->u1.AOD was %p\n", ThunkData->u1.AddressOfData);
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): ThunkData->u1.AOD was %p\n", ThunkData->u1.AddressOfData);
ThunkData->u1.AddressOfData =
(ULONG)RVA(ImageBase, ThunkData->u1.AddressOfData);
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName(): ThunkData->u1.AOD became %p\n", ThunkData->u1.AddressOfData);
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): ThunkData->u1.AOD became %p\n", ThunkData->u1.AddressOfData);
}
/* Get pointers to Name and Ordinal tables (RVA -> VA) */
NameTable = (PULONG)VaToPa(RVA(DllBase, ExportDirectory->AddressOfNames));
OrdinalTable = (PUSHORT)VaToPa(RVA(DllBase, ExportDirectory->AddressOfNameOrdinals));
- //DPRINTM(DPRINT_WINDOWS, "NameTable 0x%X, OrdinalTable 0x%X, ED->AddressOfNames 0x%X, ED->AOFO 0x%X\n",
+ //DPRINTM(DPRINT_PELOADER, "NameTable 0x%X, OrdinalTable 0x%X, ED->AddressOfNames 0x%X, ED->AOFO 0x%X\n",
// NameTable, OrdinalTable, ExportDirectory->AddressOfNames, ExportDirectory->AddressOfNameOrdinals);
/* Get the hint, convert it to a physical pointer */
Hint = ((PIMAGE_IMPORT_BY_NAME)VaToPa((PVOID)ThunkData->u1.AddressOfData))->Hint;
- //DPRINTM(DPRINT_WINDOWS, "HintIndex %d\n", Hint);
+ //DPRINTM(DPRINT_PELOADER, "HintIndex %d\n", Hint);
/* If Hint is less than total number of entries in the export directory,
and import name == export name, then we can just get it from the OrdinalTable */
)
{
Ordinal = OrdinalTable[Hint];
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName(): Ordinal %d\n", Ordinal);
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): Ordinal %d\n", Ordinal);
}
else
{
/* It's not the easy way, we have to lookup import name in the name table.
Let's use a binary search for this task. */
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName() looking up the import name using binary search...\n");
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName() looking up the import name using binary search...\n");
/* Low boundary is set to 0, and high boundary to the maximum index */
Low = 0;
Result = strcmp(VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa((PVOID)ThunkData->u1.AddressOfData))->Name[0]),
(PCHAR)VaToPa(RVA(DllBase, NameTable[Middle])));
- /*DPRINTM(DPRINT_WINDOWS, "Binary search: comparing Import '__', Export '%s'\n",*/
+ /*DPRINTM(DPRINT_PELOADER, "Binary search: comparing Import '__', Export '%s'\n",*/
/*VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name[0]),*/
/*(PCHAR)VaToPa(RVA(DllBase, NameTable[Middle])));*/
- /*DPRINTM(DPRINT_WINDOWS, "TE->u1.AOD %p, fulladdr %p\n",
+ /*DPRINTM(DPRINT_PELOADER, "TE->u1.AOD %p, fulladdr %p\n",
ThunkData->u1.AddressOfData,
((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name );*/
if (High < Low)
{
//Print(L"Error in binary search\n");
- DPRINTM(DPRINT_WINDOWS, "Error in binary search!\n");
+ DPRINTM(DPRINT_PELOADER, "Error in binary search!\n");
return FALSE;
}
/* Everything allright, get the ordinal */
Ordinal = OrdinalTable[Middle];
- //DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName() found Ordinal %d\n", Ordinal);
+ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName() found Ordinal %d\n", Ordinal);
}
}
/* Check ordinal number for validity! */
if (Ordinal >= ExportDirectory->NumberOfFunctions)
{
- DPRINTM(DPRINT_WINDOWS, "Ordinal number is invalid!\n");
+ DPRINTM(DPRINT_PELOADER, "Ordinal number is invalid!\n");
return FALSE;
}
/* Strip out its extension */
*strchr(ForwardDllName,'.') = '\0';
- DPRINTM(DPRINT_WINDOWS, "WinLdrpBindImportName(): ForwardDllName %s\n", ForwardDllName);
+ DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): ForwardDllName %s\n", ForwardDllName);
if (!WinLdrCheckForLoadedDll(WinLdrBlock, ForwardDllName, &DataTableEntry))
{
/* We can't continue if DLL couldn't be loaded, so bomb out with an error */
//Print(L"Error loading DLL!\n");
- DPRINTM(DPRINT_WINDOWS, "Error loading DLL!\n");
+ DPRINTM(DPRINT_PELOADER, "Error loading DLL!\n");
return FALSE;
}
strcpy(FullDllName, DirectoryPath);
strcat(FullDllName, ImportName);
- DPRINTM(DPRINT_WINDOWS, "Loading referenced DLL: %s\n", FullDllName);
+ DPRINTM(DPRINT_PELOADER, "Loading referenced DLL: %s\n", FullDllName);
//Print(L"Loading referenced DLL: %s\n", FullDllName);
/* Load the image */
if (!Status)
{
- DPRINTM(DPRINT_WINDOWS, "WinLdrLoadImage() failed\n");
+ DPRINTM(DPRINT_PELOADER, "WinLdrLoadImage() failed\n");
return Status;
}
if (!Status)
{
- DPRINTM(DPRINT_WINDOWS,
+ DPRINTM(DPRINT_PELOADER,
"WinLdrAllocateDataTableEntry() failed with Status=0x%X\n", Status);
return Status;
}
/* Scan its dependencies too */
- DPRINTM(DPRINT_WINDOWS,
+ DPRINTM(DPRINT_PELOADER,
"WinLdrScanImportDescriptorTable() calling ourselves for %S\n",
VaToPa((*DataTableEntry)->BaseDllName.Buffer));
Status = WinLdrScanImportDescriptorTable(WinLdrBlock, DirectoryPath, *DataTableEntry);
if (!Status)
{
- DPRINTM(DPRINT_WINDOWS,
+ DPRINTM(DPRINT_PELOADER,
"WinLdrScanImportDescriptorTable() failed with Status=0x%X\n", Status);
return Status;
}
BOOLEAN Status;
ULONG ExportSize;
- DPRINTM(DPRINT_WINDOWS, "WinLdrpScanImportAddressTable(): DllBase 0x%X, "
+ DPRINTM(DPRINT_PELOADER, "WinLdrpScanImportAddressTable(): DllBase 0x%X, "
"ImageBase 0x%X, ThunkData 0x%X\n", DllBase, ImageBase, ThunkData);
/* Obtain the export table from the DLL's base */
&ExportSize);
}
- DPRINTM(DPRINT_WINDOWS, "WinLdrpScanImportAddressTable(): ExportDirectory 0x%X\n", ExportDirectory);
+ DPRINTM(DPRINT_PELOADER, "WinLdrpScanImportAddressTable(): ExportDirectory 0x%X\n", ExportDirectory);
/* If pointer to Export Directory is */
if (ExportDirectory == NULL)