4 #if (PHNT_MODE != PHNT_MODE_KERNEL)
9 typedef struct _LDR_SERVICE_TAG_RECORD
11 struct _LDR_SERVICE_TAG_RECORD *Next;
13 } LDR_SERVICE_TAG_RECORD, *PLDR_SERVICE_TAG_RECORD;
16 typedef struct _LDRP_CSLIST
18 PSINGLE_LIST_ENTRY Tail;
19 } LDRP_CSLIST, *PLDRP_CSLIST;
22 typedef enum _LDR_DDAG_STATE
24 LdrModulesMerged = -5,
25 LdrModulesInitError = -4,
26 LdrModulesSnapError = -3,
27 LdrModulesUnloaded = -2,
28 LdrModulesUnloading = -1,
29 LdrModulesPlaceHolder = 0,
30 LdrModulesMapping = 1,
32 LdrModulesWaitingForDependencies = 3,
33 LdrModulesSnapping = 4,
34 LdrModulesSnapped = 5,
35 LdrModulesCondensed = 6,
36 LdrModulesReadyToInit = 7,
37 LdrModulesInitializing = 8,
38 LdrModulesReadyToRun = 9
42 typedef struct _LDR_DDAG_NODE
45 PLDR_SERVICE_TAG_RECORD ServiceTagList;
48 ULONG DependencyCount;
51 LDRP_CSLIST Dependencies;
52 SINGLE_LIST_ENTRY RemovalLink;
54 LDRP_CSLIST IncomingDependencies;
56 SINGLE_LIST_ENTRY CondenseLink;
59 } LDR_DDAG_NODE, *PLDR_DDAG_NODE;
62 typedef struct _LDR_DEPENDENCY_RECORD
64 SINGLE_LIST_ENTRY DependencyLink;
65 PLDR_DDAG_NODE DependencyNode;
66 SINGLE_LIST_ENTRY IncomingDependencyLink;
67 PLDR_DDAG_NODE IncomingDependencyNode;
68 } LDR_DEPENDENCY_RECORD, *PLDR_DEPENDENCY_RECORD;
71 typedef enum _LDR_DLL_LOAD_REASON
73 LoadReasonStaticDependency,
74 LoadReasonStaticForwarderDependency,
75 LoadReasonDynamicForwarderDependency,
76 LoadReasonDelayloadDependency,
77 LoadReasonDynamicLoad,
78 LoadReasonAsImageLoad,
80 LoadReasonUnknown = -1
81 } LDR_DLL_LOAD_REASON, *PLDR_DLL_LOAD_REASON;
83 #define LDRP_PACKAGED_BINARY 0x00000001
84 #define LDRP_IMAGE_DLL 0x00000004
85 #define LDRP_LOAD_IN_PROGRESS 0x00001000
86 #define LDRP_ENTRY_PROCESSED 0x00004000
87 #define LDRP_DONT_CALL_FOR_THREADS 0x00040000
88 #define LDRP_PROCESS_ATTACH_CALLED 0x00080000
89 #define LDRP_PROCESS_ATTACH_FAILED 0x00100000
90 #define LDRP_IMAGE_NOT_AT_BASE 0x00200000 // Vista and below
91 #define LDRP_COR_IMAGE 0x00400000
92 #define LDRP_DONT_RELOCATE 0x00800000
93 #define LDRP_REDIRECTED 0x10000000
94 #define LDRP_COMPAT_DATABASE_PROCESSED 0x80000000
97 #define LDR_DATA_TABLE_ENTRY_SIZE_WINXP FIELD_OFFSET(LDR_DATA_TABLE_ENTRY, DdagNode)
98 #define LDR_DATA_TABLE_ENTRY_SIZE_WIN7 FIELD_OFFSET(LDR_DATA_TABLE_ENTRY, BaseNameHashValue)
99 #define LDR_DATA_TABLE_ENTRY_SIZE_WIN8 FIELD_OFFSET(LDR_DATA_TABLE_ENTRY, ImplicitPathOptions)
102 typedef struct _LDR_DATA_TABLE_ENTRY
104 LIST_ENTRY InLoadOrderLinks;
105 LIST_ENTRY InMemoryOrderLinks;
108 LIST_ENTRY InInitializationOrderLinks;
109 LIST_ENTRY InProgressLinks;
122 ULONG PackagedBinary : 1;
123 ULONG MarkedForRemoval : 1;
125 ULONG LoadNotificationsSent : 1;
126 ULONG TelemetryEntryProcessed : 1;
127 ULONG ProcessStaticImport : 1;
128 ULONG InLegacyLists : 1;
131 ULONG InExceptionTable : 1;
132 ULONG ReservedFlags1 : 2;
133 ULONG LoadInProgress : 1;
134 ULONG LoadConfigProcessed : 1;
135 ULONG EntryProcessed : 1;
136 ULONG ProtectDelayLoad : 1;
137 ULONG ReservedFlags3 : 2;
138 ULONG DontCallForThreads : 1;
139 ULONG ProcessAttachCalled : 1;
140 ULONG ProcessAttachFailed : 1;
141 ULONG CorDeferredValidate : 1;
143 ULONG DontRelocate : 1;
145 ULONG ReservedFlags5 : 3;
146 ULONG Redirected : 1;
147 ULONG ReservedFlags6 : 2;
148 ULONG CompatDatabaseProcessed : 1;
151 USHORT ObsoleteLoadCount;
153 LIST_ENTRY HashLinks;
155 struct _ACTIVATION_CONTEXT *EntryPointActivationContext;
157 PLDR_DDAG_NODE DdagNode;
158 LIST_ENTRY NodeModuleLink;
159 struct _LDRP_LOAD_CONTEXT *LoadContext;
161 PVOID SwitchBackContext;
164 ULONG_PTR OriginalBase;
165 LARGE_INTEGER LoadTime;
166 ULONG BaseNameHashValue;
167 LDR_DLL_LOAD_REASON LoadReason;
168 ULONG ImplicitPathOptions;
169 ULONG ReferenceCount;
170 } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
172 typedef BOOLEAN (NTAPI *PDLL_INIT_ROUTINE)(
173 _In_ PVOID DllHandle,
175 _In_opt_ PCONTEXT Context
182 _In_opt_ PWSTR DllPath,
183 _In_opt_ PULONG DllCharacteristics,
185 _Out_ PVOID *DllHandle
199 _In_opt_ PWSTR DllPath,
200 _In_opt_ PULONG DllCharacteristics,
202 _Out_ PVOID *DllHandle
205 #define LDR_GET_DLL_HANDLE_EX_UNCHANGED_REFCOUNT 0x00000001
206 #define LDR_GET_DLL_HANDLE_EX_PIN 0x00000002
213 _In_opt_ PCWSTR DllPath,
214 _In_opt_ PULONG DllCharacteristics,
216 _Out_opt_ PVOID *DllHandle
219 #if (PHNT_VERSION >= PHNT_WIN7)
224 LdrGetDllHandleByMapping(
226 _Out_ PVOID *DllHandle
230 #if (PHNT_VERSION >= PHNT_WIN7)
235 LdrGetDllHandleByName(
238 _Out_ PVOID *DllHandle
242 #define LDR_ADDREF_DLL_PIN 0x00000001
255 LdrGetProcedureAddress(
256 _In_ PVOID DllHandle,
258 _In_opt_ ULONG ProcedureNumber,
259 _Out_ PVOID *ProcedureAddress
263 #define LDR_GET_PROCEDURE_ADDRESS_DONT_RECORD_FORWARDER 0x00000001
265 #if (PHNT_VERSION >= PHNT_VISTA)
270 LdrGetProcedureAddressEx(
271 _In_ PVOID DllHandle,
273 _In_opt_ ULONG ProcedureNumber,
274 _Out_ PVOID *ProcedureAddress,
279 #define LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS 0x00000001
280 #define LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY 0x00000002
282 #define LDR_LOCK_LOADER_LOCK_DISPOSITION_INVALID 0
283 #define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_ACQUIRED 1
284 #define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_NOT_ACQUIRED 2
291 _Out_opt_ ULONG *Disposition,
295 #define LDR_UNLOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS 0x00000001
310 _In_ PSTR LoaderName,
311 _In_ NTSTATUS Success,
312 _In_ NTSTATUS Conflict,
313 _In_ NTSTATUS Invalid
319 LdrRelocateImageWithBias(
322 _In_ PSTR LoaderName,
323 _In_ NTSTATUS Success,
324 _In_ NTSTATUS Conflict,
325 _In_ NTSTATUS Invalid
329 PIMAGE_BASE_RELOCATION
331 LdrProcessRelocationBlock(
333 _In_ ULONG SizeOfBlock,
334 _In_ PUSHORT NextOffset,
341 LdrVerifyMappedImageMatchesChecksum(
342 _In_ PVOID BaseAddress,
343 _In_ SIZE_T NumberOfBytes,
344 _In_ ULONG FileLength
347 typedef VOID (NTAPI *PLDR_IMPORT_MODULE_CALLBACK)(
348 _In_ PVOID Parameter,
355 LdrVerifyImageMatchesChecksum(
356 _In_ HANDLE ImageFileHandle,
357 _In_opt_ PLDR_IMPORT_MODULE_CALLBACK ImportCallbackRoutine,
358 _In_ PVOID ImportCallbackParameter,
359 _Out_opt_ PUSHORT ImageCharacteristics
363 typedef struct _LDR_IMPORT_CALLBACK_INFO
365 PLDR_IMPORT_MODULE_CALLBACK ImportCallbackRoutine;
366 PVOID ImportCallbackParameter;
367 } LDR_IMPORT_CALLBACK_INFO, *PLDR_IMPORT_CALLBACK_INFO;
370 typedef struct _LDR_SECTION_INFO
372 HANDLE SectionHandle;
373 ACCESS_MASK DesiredAccess;
375 ULONG SectionPageProtection;
376 ULONG AllocationAttributes;
377 } LDR_SECTION_INFO, *PLDR_SECTION_INFO;
380 typedef struct _LDR_VERIFY_IMAGE_INFO
384 LDR_IMPORT_CALLBACK_INFO CallbackInfo;
385 LDR_SECTION_INFO SectionInfo;
386 USHORT ImageCharacteristics;
387 } LDR_VERIFY_IMAGE_INFO, *PLDR_VERIFY_IMAGE_INFO;
389 #if (PHNT_VERSION >= PHNT_VISTA)
394 LdrVerifyImageMatchesChecksumEx(
395 _In_ HANDLE ImageFileHandle,
396 _Inout_ PLDR_VERIFY_IMAGE_INFO VerifyInfo
400 #if (PHNT_VERSION >= PHNT_VISTA)
405 LdrQueryModuleServiceTags(
406 _In_ PVOID DllHandle,
407 _Out_writes_(*BufferSize) PULONG ServiceTagBuffer,
408 _Inout_ PULONG BufferSize
414 #define LDR_DLL_NOTIFICATION_REASON_LOADED 1
415 #define LDR_DLL_NOTIFICATION_REASON_UNLOADED 2
417 typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA
424 } LDR_DLL_LOADED_NOTIFICATION_DATA, *PLDR_DLL_LOADED_NOTIFICATION_DATA;
426 typedef struct _LDR_DLL_UNLOADED_NOTIFICATION_DATA
433 } LDR_DLL_UNLOADED_NOTIFICATION_DATA, *PLDR_DLL_UNLOADED_NOTIFICATION_DATA;
435 typedef union _LDR_DLL_NOTIFICATION_DATA
437 LDR_DLL_LOADED_NOTIFICATION_DATA Loaded;
438 LDR_DLL_UNLOADED_NOTIFICATION_DATA Unloaded;
439 } LDR_DLL_NOTIFICATION_DATA, *PLDR_DLL_NOTIFICATION_DATA;
441 typedef VOID (NTAPI *PLDR_DLL_NOTIFICATION_FUNCTION)(
442 _In_ ULONG NotificationReason,
443 _In_ PLDR_DLL_NOTIFICATION_DATA NotificationData,
444 _In_opt_ PVOID Context
447 #if (PHNT_VERSION >= PHNT_VISTA)
452 LdrRegisterDllNotification(
454 _In_ PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction,
462 LdrUnregisterDllNotification(
472 #if (PHNT_VERSION >= PHNT_VISTA)
478 LdrAddLoadAsDataTable(
489 LdrRemoveLoadAsDataTable(
490 _In_ PVOID InitModule,
491 _Out_opt_ PVOID *BaseModule,
492 _Out_opt_ PSIZE_T
Size,
500 LdrGetFileNameFromLoadAsDataTable(
502 _Out_ PVOID *pFileNamePrt
507 #endif // (PHNT_MODE != PHNT_MODE_KERNEL)