51 TRACE(
"PeLdrpCompareDllName: %s and %wZ, Length = %d "
111 PCHAR ExportName, ForwarderName;
120 WARN(
"DllBase == NULL!\n");
125 ThunkData =
VaToPa(ThunkData);
137 if (!ProcessForwards)
141 ThunkData->u1.AddressOfData =
147 ImportData =
VaToPa((
PVOID)ThunkData->u1.AddressOfData);
150 NameTable =
VaToPa(
RVA(DllBase, ExportDirectory->AddressOfNames));
151 OrdinalTable =
VaToPa(
RVA(DllBase, ExportDirectory->AddressOfNameOrdinals));
161 ExportName =
VaToPa(
RVA(DllBase, NameTable[Hint]));
165 if ((Hint < ExportDirectory->NumberOfNames) &&
168 Ordinal = OrdinalTable[Hint];
180 High = ExportDirectory->NumberOfNames - 1;
189 ExportName =
VaToPa(
RVA(DllBase, NameTable[Middle]));
223 ERR(
"Did not find export '%s'!\n", (
PCHAR)ImportData->
Name);
228 Ordinal = OrdinalTable[Middle];
235 if (Ordinal >= ExportDirectory->NumberOfFunctions)
237 ERR(
"Ordinal number is invalid!\n");
255 CHAR ForwardDllName[256];
257 TRACE(
"PeLdrpBindImportName(): ForwarderName %s\n", ForwarderName);
260 RtlCopyMemory(ForwardDllName, ForwarderName,
sizeof(ForwardDllName));
283 ERR(
"PeLdrpLoadAndScanReferencedDll() failed to load forwarder dll.\n");
296 if (RefExportDirectory)
304 ImportName =
strrchr(ForwarderName,
'.') + 1;
313 ImportByName->
Hint = 0;
330 ThunkData->u1 = RefThunkData.
u1;
392 TRACE(
"PeLdrScanImportDescriptorTable() calling ourselves for %S\n",
393 VaToPa((*DataTableEntry)->BaseDllName.Buffer));
398 ERR(
"PeLdrScanImportDescriptorTable() failed\n");
420 TRACE(
"PeLdrpScanImportAddressTable(): DllBase 0x%X, "
421 "ImageBase 0x%X, ThunkData 0x%X\n", DllBase, ImageBase, ThunkData);
426 ERR(
"Error, DllBase == NULL!\n");
438 TRACE(
"PeLdrpScanImportAddressTable(): ExportDirectory 0x%X\n", ExportDirectory);
441 if (ExportDirectory ==
NULL)
443 ERR(
"DllBase=%p(%p)\n", DllBase,
VaToPa(DllBase));
486 TRACE(
"PeLdrCheckForLoadedDll: DllName %s\n", DllName);
498 TRACE(
"PeLdrCheckForLoadedDll: DTE %p, EP %p, base %p name '%.*ws'\n",
507 *LoadedEntry = DataTableEntry;
509 TRACE(
"PeLdrCheckForLoadedDll: LoadedEntry %X\n", DataTableEntry);
514 ModuleEntry = ModuleEntry->
Flink;
529 ULONG ImportTableSize;
542 BaseName.
Length = ScanDTE->BaseDllName.Length;
543 TRACE(
"PeLdrScanImportDescriptorTable(): %wZ ImportTable = 0x%X\n",
544 &BaseName, ImportTable);
549 if (ImportTable ==
NULL)
553 for (;(ImportTable->
Name != 0) && (ImportTable->
FirstThunk != 0);ImportTable++)
557 TRACE(
"PeLdrScanImportDescriptorTable(): Looking at %s\n", ImportName);
569 &ScanDTE->InLoadOrderLinks,
573 ERR(
"PeLdrpLoadAndScanReferencedDll() failed\n");
584 &ScanDTE->InLoadOrderLinks);
588 ERR(
"PeLdrpScanImportAddressTable() failed: ImportName = '%s', DirectoryPath = '%s'\n",
589 ImportName, DirectoryPath);
611 TRACE(
"PeLdrAllocateDataTableEntry('%s', '%s', %p)\n",
617 if (DataTableEntry ==
NULL)
625 DataTableEntry->
DllBase = BaseVA;
642 BaseDllNameBuffer =
Buffer;
652 *
Buffer++ = *BaseDllName++;
702 TRACE(
"Inserting DTE %p, name='%.*S' DllBase=%p\n", DataTableEntry,
708 *NewEntry = DataTableEntry;
751 ULONG VirtualSize, SizeOfRawData, NumberOfSections;
801 if (PhysicalBase ==
NULL)
806 if (PhysicalBase ==
NULL)
815 VirtualBase =
PaToVa(PhysicalBase);
817 TRACE(
"Base PA: 0x%X, VA: 0x%X\n", PhysicalBase, VirtualBase);
848 for (
i = 0;
i < NumberOfSections;
i++)
854 if (VirtualSize == 0)
855 VirtualSize = SizeOfRawData;
865 if (SizeOfRawData > VirtualSize)
866 SizeOfRawData = VirtualSize;
870 if (SizeOfRawData != 0)
882 ERR(
"PeLdrLoadImage(): Error reading section from file!\n");
888 if (SizeOfRawData < VirtualSize)
890 TRACE(
"PeLdrLoadImage(): SORD %d < VS %d\n", SizeOfRawData, VirtualSize);
919 *ImageBasePA = PhysicalBase;
921 TRACE(
"PeLdrLoadImage() done, PA = %p\n", *ImageBasePA);
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
#define DBG_DEFAULT_CHANNEL(ch)
ARC_STATUS ArcClose(ULONG FileId)
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
PVOID MmAllocateMemoryAtAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType)
VOID MmFreeMemory(PVOID MemoryPointer)
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
struct _LDR_DATA_TABLE_ENTRY * PLDR_DATA_TABLE_ENTRY
FORCEINLINE PVOID VaToPa(PVOID Va)
FORCEINLINE PVOID PaToVa(PVOID Pa)
#define IMAGE_DIRECTORY_ENTRY_EXPORT
struct _IMAGE_EXPORT_DIRECTORY * PIMAGE_EXPORT_DIRECTORY
#define RtlImageDirectoryEntryToData
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
LIST_ENTRY * ModuleListHead
#define LDRP_IMAGE_INTEGRITY_FORCED
#define LDRP_DRIVER_DEPENDENT_DLL
#define LDRP_ENTRY_PROCESSED
ULONG NTAPI LdrRelocateImageWithBias(_In_ PVOID BaseAddress, _In_ LONGLONG AdditionalBias, _In_opt_ PCSTR LoaderName, _In_ ULONG Success, _In_ ULONG Conflict, _In_ ULONG Invalid)
_In_ ULONG _In_ ULONG _In_ ULONG Length
struct _IMAGE_IMPORT_DESCRIPTOR * PIMAGE_IMPORT_DESCRIPTOR
#define IMAGE_SNAP_BY_ORDINAL(Ordinal)
#define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY
#define IMAGE_FIRST_SECTION(NtHeader)
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
#define IMAGE_FILE_EXECUTABLE_IMAGE
#define IMAGE_DIRECTORY_ENTRY_IMPORT
struct _IMAGE_IMPORT_BY_NAME * PIMAGE_IMPORT_BY_NAME
#define IMAGE_ORDINAL(Ordinal)
BOOLEAN PeLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
static BOOLEAN PeLdrpScanImportAddressTable(IN OUT PLIST_ENTRY ModuleListHead, IN PVOID DllBase, IN PVOID ImageBase, IN PIMAGE_THUNK_DATA ThunkData, IN PCSTR DirectoryPath, IN PLIST_ENTRY Parent)
VOID PeLdrFreeDataTableEntry(_In_ PLDR_DATA_TABLE_ENTRY Entry)
BOOLEAN PeLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead, IN PCH DllName, OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry)
static BOOLEAN PeLdrpBindImportName(IN OUT PLIST_ENTRY ModuleListHead, IN PVOID DllBase, IN PVOID ImageBase, IN PIMAGE_THUNK_DATA ThunkData, IN PIMAGE_EXPORT_DIRECTORY ExportDirectory, IN ULONG ExportSize, IN BOOLEAN ProcessForwards, IN PCSTR DirectoryPath, IN PLIST_ENTRY Parent)
PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback
static BOOLEAN PeLdrpLoadAndScanReferencedDll(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PCH ImportName, IN PLIST_ENTRY Parent OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry)
static BOOLEAN PeLdrpCompareDllName(IN PCH DllName, IN PUNICODE_STRING UnicodeName)
BOOLEAN PeLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH BaseDllName, IN PCCH FullDllName, IN PVOID BasePA, OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
BOOLEAN PeLdrLoadImage(_In_ PCSTR FilePath, _In_ TYPE_OF_MEMORY MemoryType, _Out_ PVOID *ImageBasePA)
Loads the specified image from the file.
VOID(NTAPI * PELDR_IMPORTDLL_LOAD_CALLBACK)(_In_ PCSTR FileName)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
PULONG MinorVersion OPTIONAL
base of all file and directory entries
union _IMAGE_THUNK_DATA32::@2121 u1
UNICODE_STRING FullDllName
LIST_ENTRY InLoadOrderLinks
UNICODE_STRING BaseDllName
struct _LIST_ENTRY * Flink
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
static WLX_DISPATCH_VERSION_1_4 FunctionTable
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO