-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathntldr.h
864 lines (740 loc) · 21.1 KB
/
ntldr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
/*++ BUILD Version: 0004 // Increment this if a change has global effects
Copyright (c) Microsoft Corporation. All rights reserved.
You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt).
If you do not agree to the terms, do not use the code.
Module Name:
ntldr.h
Abstract:
This module implements the public interfaces of the Loader (Ldr)
subsystem. Ldr is coupled with the session manager. It is not
a separate process.
--*/
#ifndef _NTLDRAPI_
#define _NTLDRAPI_
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
//
// Private flags for loader data table entries
//
#define LDRP_STATIC_LINK 0x00000002
#define LDRP_IMAGE_DLL 0x00000004
#define LDRP_LOAD_IN_PROGRESS 0x00001000
#define LDRP_UNLOAD_IN_PROGRESS 0x00002000
#define LDRP_ENTRY_PROCESSED 0x00004000
#define LDRP_ENTRY_INSERTED 0x00008000
#define LDRP_CURRENT_LOAD 0x00010000
#define LDRP_FAILED_BUILTIN_LOAD 0x00020000
#define LDRP_DONT_CALL_FOR_THREADS 0x00040000
#define LDRP_PROCESS_ATTACH_CALLED 0x00080000
#define LDRP_DEBUG_SYMBOLS_LOADED 0x00100000
#define LDRP_IMAGE_NOT_AT_BASE 0x00200000
#define LDRP_COR_IMAGE 0x00400000
#define LDRP_COR_OWNS_UNMAP 0x00800000
#define LDRP_SYSTEM_MAPPED 0x01000000
#define LDRP_IMAGE_VERIFYING 0x02000000
#define LDRP_DRIVER_DEPENDENT_DLL 0x04000000
#define LDRP_ENTRY_NATIVE 0x08000000
#define LDRP_REDIRECTED 0x10000000
#define LDRP_NON_PAGED_DEBUG_INFO 0x20000000
#define LDRP_MM_LOADED 0x40000000
#define LDRP_COMPAT_DATABASE_PROCESSED 0x80000000
//
// Loader Data Table. Used to track DLLs loaded into an
// image.
//
typedef struct _LDR_DATA_TABLE_ENTRY {
LIST_ENTRY InLoadOrderLinks;
LIST_ENTRY InMemoryOrderLinks;
LIST_ENTRY InInitializationOrderLinks;
PVOID DllBase;
PVOID EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
ULONG Flags;
USHORT LoadCount;
USHORT TlsIndex;
union {
LIST_ENTRY HashLinks;
struct {
PVOID SectionPointer;
ULONG CheckSum;
};
};
union {
struct {
ULONG TimeDateStamp;
};
struct {
PVOID LoadedImports;
};
};
struct _ACTIVATION_CONTEXT * EntryPointActivationContext;
PVOID PatchInformation;
} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
typedef const struct _LDR_DATA_TABLE_ENTRY *PCLDR_DATA_TABLE_ENTRY;
typedef struct _KLDR_DATA_TABLE_ENTRY {
LIST_ENTRY InLoadOrderLinks;
PVOID ExceptionTable;
ULONG ExceptionTableSize;
// ULONG padding on IA64
PVOID GpValue;
PNON_PAGED_DEBUG_INFO NonPagedDebugInfo;
PVOID DllBase;
PVOID EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
ULONG Flags;
USHORT LoadCount;
USHORT __Unused5;
PVOID SectionPointer;
ULONG CheckSum;
// ULONG padding on IA64
PVOID LoadedImports;
PVOID PatchInformation;
} KLDR_DATA_TABLE_ENTRY, *PKLDR_DATA_TABLE_ENTRY;
typedef struct _LDR_DATA_TABLE_ENTRY32 {
LIST_ENTRY32 InLoadOrderLinks;
LIST_ENTRY32 InMemoryOrderLinks;
LIST_ENTRY32 InInitializationOrderLinks;
ULONG DllBase;
ULONG EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING32 FullDllName;
UNICODE_STRING32 BaseDllName;
ULONG Flags;
USHORT LoadCount;
USHORT TlsIndex;
union {
LIST_ENTRY32 HashLinks;
struct {
ULONG SectionPointer;
ULONG CheckSum;
};
};
union {
struct {
ULONG TimeDateStamp;
};
struct {
ULONG LoadedImports;
};
};
//
// NOTE : Do not grow this structure at the dump files used a packed
// array of these structures.
//
} LDR_DATA_TABLE_ENTRY32, *PLDR_DATA_TABLE_ENTRY32;
typedef struct _LDR_DATA_TABLE_ENTRY64 {
LIST_ENTRY64 InLoadOrderLinks;
LIST_ENTRY64 InMemoryOrderLinks;
LIST_ENTRY64 InInitializationOrderLinks;
ULONG64 DllBase;
ULONG64 EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING64 FullDllName;
UNICODE_STRING64 BaseDllName;
ULONG Flags;
USHORT LoadCount;
USHORT TlsIndex;
union {
LIST_ENTRY64 HashLinks;
struct {
ULONG64 SectionPointer;
ULONG CheckSum;
};
};
union {
struct {
ULONG TimeDateStamp;
};
struct {
ULONG64 LoadedImports;
};
};
//
// NOTE : Do not grow this structure at the dump files used a packed
// array of these structures.
//
} LDR_DATA_TABLE_ENTRY64, *PLDR_DATA_TABLE_ENTRY64;
typedef struct _KLDR_DATA_TABLE_ENTRY32 {
LIST_ENTRY32 InLoadOrderLinks;
ULONG __Undefined1;
ULONG __Undefined2;
ULONG __Undefined3;
ULONG NonPagedDebugInfo;
ULONG DllBase;
ULONG EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING32 FullDllName;
UNICODE_STRING32 BaseDllName;
ULONG Flags;
USHORT LoadCount;
USHORT __Undefined5;
ULONG __Undefined6;
ULONG CheckSum;
ULONG TimeDateStamp;
//
// NOTE : Do not grow this structure at the dump files used a packed
// array of these structures.
//
} KLDR_DATA_TABLE_ENTRY32, *PKLDR_DATA_TABLE_ENTRY32;
typedef struct _KLDR_DATA_TABLE_ENTRY64 {
LIST_ENTRY64 InLoadOrderLinks;
ULONG64 __Undefined1;
ULONG64 __Undefined2;
ULONG64 __Undefined3;
ULONG64 NonPagedDebugInfo;
ULONG64 DllBase;
ULONG64 EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING64 FullDllName;
UNICODE_STRING64 BaseDllName;
ULONG Flags;
USHORT LoadCount;
USHORT __Undefined5;
ULONG64 __Undefined6;
ULONG CheckSum;
ULONG __padding1;
ULONG TimeDateStamp;
ULONG __padding2;
//
// NOTE : Do not grow this structure at the dump files used a packed
// array of these structures.
//
} KLDR_DATA_TABLE_ENTRY64, *PKLDR_DATA_TABLE_ENTRY64;
#define DLL_PROCESS_ATTACH 1 // winnt
#define DLL_THREAD_ATTACH 2 // winnt
#define DLL_THREAD_DETACH 3 // winnt
#define DLL_PROCESS_DETACH 0 // winnt
#define DLL_PROCESS_VERIFIER 4 // winnt
typedef
BOOLEAN
(*PDLL_INIT_ROUTINE) (
IN PVOID DllHandle,
IN ULONG Reason,
IN PCONTEXT Context OPTIONAL
);
typedef
BOOLEAN
(*PPROCESS_STARTER_ROUTINE) (
IN PVOID RealStartAddress
);
NTSYSAPI
VOID
LdrProcessStarterHelper(
IN PPROCESS_STARTER_ROUTINE ProcessStarter,
IN PVOID RealStartAddress
);
NTSYSAPI
VOID
NTAPI
LdrShutdownProcess(
VOID
);
NTSYSAPI
VOID
NTAPI
LdrShutdownThread(
VOID
);
NTSYSAPI
NTSTATUS
NTAPI
LdrLoadDll(
IN PCWSTR DllPath OPTIONAL,
IN PULONG DllCharacteristics OPTIONAL,
IN PCUNICODE_STRING DllName,
OUT PVOID *DllHandle
);
NTSYSAPI
NTSTATUS
NTAPI
LdrGetDllHandle(
IN PCWSTR DllPath OPTIONAL,
IN PULONG DllCharacteristics OPTIONAL,
IN PCUNICODE_STRING DllName,
OUT PVOID *DllHandle
);
NTSYSAPI
NTSTATUS
NTAPI
LdrUnloadDll(
IN PVOID DllHandle
);
typedef
NTSTATUS
(NTAPI * PLDR_MANIFEST_PROBER_ROUTINE) (
IN PVOID DllBase,
IN PCWSTR FullDllPath,
OUT PVOID *ActivationContext
);
NTSYSAPI
VOID
NTAPI
LdrSetDllManifestProber(
IN PLDR_MANIFEST_PROBER_ROUTINE ManifestProberRoutine
);
#if defined(BLDR_KERNEL_RUNTIME)
typedef ULONG ARC_STATUS;
typedef ARC_STATUS LDR_RELOCATE_IMAGE_RETURN_TYPE;
#else
typedef NTSTATUS LDR_RELOCATE_IMAGE_RETURN_TYPE;
#endif
LDR_RELOCATE_IMAGE_RETURN_TYPE
LdrRelocateImage (
__in PVOID NewBase,
__in PCSTR LoaderName,
__in LDR_RELOCATE_IMAGE_RETURN_TYPE Success,
__in LDR_RELOCATE_IMAGE_RETURN_TYPE Conflict,
__in LDR_RELOCATE_IMAGE_RETURN_TYPE Invalid
);
LDR_RELOCATE_IMAGE_RETURN_TYPE
LdrRelocateImageWithBias (
__in PVOID NewBase,
__in LONGLONG Bias,
__in PCSTR LoaderName,
__in LDR_RELOCATE_IMAGE_RETURN_TYPE Success,
__in LDR_RELOCATE_IMAGE_RETURN_TYPE Conflict,
__in LDR_RELOCATE_IMAGE_RETURN_TYPE Invalid
);
PIMAGE_BASE_RELOCATION
NTAPI
LdrProcessRelocationBlock(
IN ULONG_PTR VA,
IN ULONG SizeOfBlock,
IN PUSHORT NextOffset,
IN LONG_PTR Diff
);
BOOLEAN
NTAPI
LdrVerifyMappedImageMatchesChecksum (
IN PVOID BaseAddress,
IN SIZE_T NumberOfBytes,
IN ULONG FileLength
);
typedef
VOID
(*PLDR_IMPORT_MODULE_CALLBACK)(
IN PVOID Parameter,
PCHAR ModuleName
);
NTSTATUS
NTAPI
LdrVerifyImageMatchesChecksum (
IN HANDLE ImageFileHandle,
IN PLDR_IMPORT_MODULE_CALLBACK ImportCallbackRoutine OPTIONAL,
IN PVOID ImportCallbackParameter,
OUT PUSHORT ImageCharacteristics OPTIONAL
);
NTSYSAPI
NTSTATUS
NTAPI
LdrGetProcedureAddress(
IN PVOID DllHandle,
IN CONST ANSI_STRING* ProcedureName OPTIONAL,
IN ULONG ProcedureNumber OPTIONAL,
OUT PVOID *ProcedureAddress
);
#define LDR_RESOURCE_ID_NAME_MASK ((~(ULONG_PTR)0) << 16) /* lower 16bits clear */
#define LDR_RESOURCE_ID_NAME_MINVAL (( (ULONG_PTR)1) << 16) /* 17th bit set */
//
// These are how you currently pass the flag to FindResource.
//
// VIEW_TO_DATAFILE and DATAFILE_TO_VIEW are idempotent,
// so you can covert a datafile to a datafile with VIEW_TO_DATAFILE.
// Think of better names therefore..
//
#define LDR_VIEW_TO_DATAFILE(x) ((PVOID)(((ULONG_PTR)(x)) | (ULONG_PTR)1))
#define LDR_IS_DATAFILE(x) (((ULONG_PTR)(x)) & (ULONG_PTR)1)
#define LDR_IS_VIEW(x) (!LDR_IS_DATAFILE(x))
#define LDR_DATAFILE_TO_VIEW(x) ((PVOID)(((ULONG_PTR)(x)) & ~(ULONG_PTR)1))
//
// These functions work on ULONG, ULONG_PTR, ULONG64, etc.
// They do not work on pointers.
//
#define LDR_VIEW_TO_DATAFILE_INTEGER(x) ((x) | 1)
#define LDR_IS_DATAFILE_INTEGER(x) (((x) & 1) == 1)
#define LDR_IS_VIEW_INTEGER(x) (((x) & 1) == 0)
#define LDR_DATAFILE_TO_VIEW_INTEGER(x) ((x) - ((x) & 1))
//
// Flags to LdrCreateOutOfProcessImage.
//
// These first two values must not share any bits, even though this is an enum,
// because LDR_DLL_MAPPED_AS_UNREFORMATED_IMAGE is actually changed to one of them
// and then it is treated as bits.
#define LDR_DLL_MAPPED_AS_IMAGE (0x00000001)
#define LDR_DLL_MAPPED_AS_DATA (0x00000002)
#define LDR_DLL_MAPPED_AS_UNFORMATED_IMAGE (0x00000003)
#define LDR_DLL_MAPPED_AS_MASK (0x00000003)
//
// These are flags to a function that doesn't yet exist:
// LdrpSearchResourceSectionEx and/or LdrpSearchOutOfProcessResourceSection
//
#define LDRP_FIND_RESOURCE_DATA (0x00000000)
#define LDRP_FIND_RESOURCE_DIRECTORY (0x00000002)
//
// Flags to LdrFindResourceEx/LdrpSearchResourceSection/LdrFindOutOfProcessResource.
//
#define LDR_FIND_RESOURCE_LANGUAGE_CAN_FALLBACK (0x00000000)
#define LDR_FIND_RESOURCE_LANGUAGE_EXACT (0x00000004)
#define LDR_FIND_RESOURCE_LANGUAGE_REDIRECT_VERSION (0x00000008)
NTSYSAPI
NTSTATUS
NTAPI
LdrFindResourceDirectory_U(
IN PVOID DllHandle,
IN CONST ULONG_PTR* ResourceIdPath,
IN ULONG ResourceIdPathLength,
OUT PIMAGE_RESOURCE_DIRECTORY *ResourceDirectory
);
NTSYSAPI
NTSTATUS
NTAPI
LdrFindResource_U(
IN PVOID DllHandle,
IN CONST ULONG_PTR* ResourceIdPath,
IN ULONG ResourceIdPathLength,
OUT PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry
);
NTSTATUS
NTAPI
LdrFindResourceEx_U(
ULONG Flags,
IN PVOID DllHandle,
IN CONST ULONG_PTR* ResourceIdPath,
IN ULONG ResourceIdPathLength,
OUT PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry
);
#ifndef NTOS_KERNEL_RUNTIME
#if !defined(RTL_BUFFER)
// This is duplicated in nturtl.h.
#define RTL_BUFFER RTL_BUFFER
typedef struct _RTL_BUFFER {
PUCHAR Buffer;
PUCHAR StaticBuffer;
SIZE_T Size;
SIZE_T StaticSize;
SIZE_T ReservedForAllocatedSize; // for future doubling
PVOID ReservedForIMalloc; // for future pluggable growth
} RTL_BUFFER, *PRTL_BUFFER;
#endif
//
// This will always contain the MS-DOS header,
// File header, Optional header, and Section headers.
//
// If multiple fast resource loads are needed, we could
// populate it on demand with resource directory stuff too.
//
// This struct is opaque.
// Only access it with Ldr*OutOfProcess* functions.
//
typedef struct _LDR_OUT_OF_PROCESS_IMAGE {
RTL_BUFFER HeadersBuffer;
HANDLE ProcessHandle;
ULONG64 DllHandle; // base of mapped section, not kernel handle
ULONG Flags;
} LDR_OUT_OF_PROCESS_IMAGE, *PLDR_OUT_OF_PROCESS_IMAGE;
NTSTATUS
NTAPI
LdrCreateOutOfProcessImage(
IN ULONG Flags,
IN HANDLE ProcessHandle,
IN ULONG64 DllHandle, // base of mapped section, not kernel handle
OUT PLDR_OUT_OF_PROCESS_IMAGE Image
);
//
// - You may destroy an out of process image that is all zeros.
// - You may destroy an out of process image repeatedly.
//
NTSYSAPI
VOID
NTAPI
LdrDestroyOutOfProcessImage(
IN OUT PLDR_OUT_OF_PROCESS_IMAGE Image
);
NTSTATUS
NTAPI
LdrFindCreateProcessManifest(
IN ULONG Flags,
PLDR_OUT_OF_PROCESS_IMAGE Image,
IN CONST ULONG_PTR* ResourceIdPath,
IN ULONG ResourceIdPathLength,
OUT PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry
);
NTSTATUS
NTAPI
LdrAccessOutOfProcessResource(
IN ULONG Flags,
PLDR_OUT_OF_PROCESS_IMAGE Image,
IN CONST IMAGE_RESOURCE_DATA_ENTRY* DataEntry,
OUT PULONG64 Address OPTIONAL,
OUT PULONG Size OPTIONAL
);
#endif
// type, id/name, langid
#define LDR_MAXIMUM_RESOURCE_PATH_DEPTH (3)
typedef struct _LDR_ENUM_RESOURCE_ENTRY {
union {
ULONG_PTR NameOrId;
PIMAGE_RESOURCE_DIRECTORY_STRING Name;
struct {
USHORT Id;
USHORT NameIsPresent;
};
} Path[ LDR_MAXIMUM_RESOURCE_PATH_DEPTH ];
PVOID Data;
ULONG Size;
ULONG Reserved;
} LDR_ENUM_RESOURCE_ENTRY, *PLDR_ENUM_RESOURCE_ENTRY;
NTSYSAPI
NTSTATUS
NTAPI
LdrEnumResources(
IN PVOID DllHandle,
IN CONST ULONG_PTR* ResourceIdPath,
IN ULONG ResourceIdPathLength,
IN OUT PULONG NumberOfResources,
OUT PLDR_ENUM_RESOURCE_ENTRY Resources OPTIONAL
);
NTSYSAPI
NTSTATUS
NTAPI
LdrAccessResource(
IN PVOID DllHandle,
IN CONST IMAGE_RESOURCE_DATA_ENTRY* ResourceDataEntry,
OUT PVOID *Address OPTIONAL,
OUT PULONG Size OPTIONAL
);
NTSTATUS
NTAPI
LdrFindEntryForAddress(
IN PVOID Address,
OUT PLDR_DATA_TABLE_ENTRY *TableEntry
);
NTSYSAPI
NTSTATUS
NTAPI
LdrDisableThreadCalloutsForDll (
IN PVOID DllHandle
);
typedef struct _RTL_PROCESS_MODULE_INFORMATION {
HANDLE Section; // Not filled in
PVOID MappedBase;
PVOID ImageBase;
ULONG ImageSize;
ULONG Flags;
USHORT LoadOrderIndex;
USHORT InitOrderIndex;
USHORT LoadCount;
USHORT OffsetToFileName;
UCHAR FullPathName[ 256 ];
} RTL_PROCESS_MODULE_INFORMATION, *PRTL_PROCESS_MODULE_INFORMATION;
typedef struct _RTL_PROCESS_MODULES {
ULONG NumberOfModules;
RTL_PROCESS_MODULE_INFORMATION Modules[ 1 ];
} RTL_PROCESS_MODULES, *PRTL_PROCESS_MODULES;
NTSTATUS
NTAPI
LdrQueryProcessModuleInformation(
OUT PRTL_PROCESS_MODULES ModuleInformation,
IN ULONG ModuleInformationLength,
OUT PULONG ReturnLength OPTIONAL
);
#define LDR_IMAGE_FILE_OPTIONS_KEY_LARGE_PAGE_DLLS L"LargePageDLLs"
NTSYSAPI
NTSTATUS
NTAPI
LdrOpenImageFileOptionsKey (
IN PCUNICODE_STRING ImagePathName,
IN BOOLEAN Wow64Path,
OUT PHANDLE KeyHandle
);
NTSYSAPI
NTSTATUS
NTAPI
LdrQueryImageFileExecutionOptions(
IN PCUNICODE_STRING ImagePathName,
IN PCWSTR OptionName,
IN ULONG Type,
OUT PVOID Buffer,
IN ULONG BufferSize,
OUT PULONG ResultSize OPTIONAL
);
NTSYSAPI
NTSTATUS
LdrQueryImageFileExecutionOptionsEx(
IN PCUNICODE_STRING ImagePathName,
IN PCWSTR OptionName,
IN ULONG Type,
OUT PVOID Buffer,
IN ULONG BufferSize,
OUT PULONG ResultSize OPTIONAL,
IN BOOLEAN Wow64Path
);
NTSYSAPI
NTSTATUS
NTAPI
LdrQueryImageFileKeyOption (
IN HANDLE KeyHandle,
IN PCWSTR OptionName,
IN ULONG Type,
OUT PVOID Buffer,
IN ULONG BufferSize,
OUT PULONG ResultSize OPTIONAL
);
NTSYSAPI
BOOLEAN
NTAPI
LdrAlternateResourcesEnabled(
VOID
);
PVOID
NTAPI
LdrGetAlternateResourceModuleHandle(
IN PVOID Module
);
NTSYSAPI
PVOID
NTAPI
LdrLoadAlternateResourceModule(
IN PVOID Module,
IN LPCWSTR PathToAlternateModule OPTIONAL
);
NTSYSAPI
BOOLEAN
NTAPI
LdrUnloadAlternateResourceModule(
IN PVOID Module
);
NTSYSAPI
BOOLEAN
NTAPI
LdrFlushAlternateResourceModules(
VOID
);
#define LDR_DLL_LOADED_FLAG_RELOCATED (0x00000001)
typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA {
ULONG Flags;
PCUNICODE_STRING FullDllName;
PCUNICODE_STRING BaseDllName;
PVOID DllBase;
ULONG SizeOfImage;
} LDR_DLL_LOADED_NOTIFICATION_DATA, *PLDR_DLL_LOADED_NOTIFICATION_DATA;
typedef const LDR_DLL_LOADED_NOTIFICATION_DATA *PCLDR_DLL_LOADED_NOTIFICATION_DATA;
#define LDR_DLL_UNLOADED_FLAG_PROCESS_TERMINATION (0x00000001)
typedef struct _LDR_DLL_UNLOADED_NOTIFICATION_DATA {
ULONG Flags;
PCUNICODE_STRING FullDllName;
PCUNICODE_STRING BaseDllName;
PVOID DllBase;
ULONG SizeOfImage;
} LDR_DLL_UNLOADED_NOTIFICATION_DATA, *PLDR_DLL_UNLOADED_NOTIFICATION_DATA;
typedef const LDR_DLL_UNLOADED_NOTIFICATION_DATA *PCLDR_DLL_UNLOADED_NOTIFICATION_DATA;
typedef union _LDR_DLL_NOTIFICATION_DATA {
LDR_DLL_LOADED_NOTIFICATION_DATA Loaded;
LDR_DLL_UNLOADED_NOTIFICATION_DATA Unloaded;
} LDR_DLL_NOTIFICATION_DATA, *PLDR_DLL_NOTIFICATION_DATA;
typedef const LDR_DLL_NOTIFICATION_DATA *PCLDR_DLL_NOTIFICATION_DATA;
#define LDR_DLL_NOTIFICATION_REASON_LOADED (1)
#define LDR_DLL_NOTIFICATION_REASON_UNLOADED (2)
typedef
VOID (NTAPI *PLDR_DLL_NOTIFICATION_FUNCTION)(
IN ULONG NotificationReason,
IN PCLDR_DLL_NOTIFICATION_DATA NotificationData,
IN PVOID Context
);
NTSTATUS
NTAPI
LdrRegisterDllNotification(
IN ULONG Flags,
IN PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction,
IN PVOID Context,
OUT PVOID *Cookie
);
NTSTATUS
NTAPI
LdrUnregisterDllNotification(
IN PVOID Cookie
);
typedef
VOID (NTAPI *PLDR_LOADED_MODULE_ENUMERATION_CALLBACK_FUNCTION)(
IN PCLDR_DATA_TABLE_ENTRY DataTableEntry,
IN PVOID Context,
IN OUT BOOLEAN *StopEnumeration
);
NTSYSAPI
NTSTATUS
NTAPI
LdrEnumerateLoadedModules(
IN ULONG Flags,
IN PLDR_LOADED_MODULE_ENUMERATION_CALLBACK_FUNCTION CallbackFunction,
IN PVOID Context
);
#define LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS (0x00000001)
#define LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY (0x00000002)
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_INVALID (0)
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_ACQUIRED (1)
#define LDR_LOCK_LOADER_LOCK_DISPOSITION_LOCK_NOT_ACQUIRED (2)
NTSYSAPI
NTSTATUS
NTAPI
LdrLockLoaderLock(
IN ULONG Flags,
OUT ULONG *Disposition OPTIONAL, // not optional if LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY is set
OUT PVOID *Cookie
);
#define LDR_UNLOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS (0x00000001)
NTSYSAPI
NTSTATUS
NTAPI
LdrUnlockLoaderLock(
IN ULONG Flags,
IN OUT PVOID Cookie
);
#define LDR_GET_DLL_HANDLE_EX_UNCHANGED_REFCOUNT (0x00000001)
#define LDR_GET_DLL_HANDLE_EX_PIN (0x00000002)
NTSYSAPI
NTSTATUS
NTAPI
LdrGetDllHandleEx(
IN ULONG Flags,
IN PCWSTR DllPath OPTIONAL,
IN PULONG DllCharacteristics OPTIONAL,
IN PCUNICODE_STRING DllName,
OUT PVOID *DllHandle OPTIONAL
);
#define LDR_ADDREF_DLL_PIN (0x00000001)
NTSYSAPI
NTSTATUS
NTAPI
LdrAddRefDll(
ULONG Flags,
PVOID DllHandle
);
typedef
NTSTATUS (NTAPI *PLDR_APP_COMPAT_DLL_REDIRECTION_CALLBACK_FUNCTION)(
IN ULONG Flags,
IN PCWSTR DllName,
IN PCWSTR DllPath OPTIONAL,
IN OUT PULONG DllCharacteristics OPTIONAL,
IN PVOID CallbackData,
OUT PWSTR *EffectiveDllPath
);
NTSYSAPI
NTSTATUS
NTAPI
LdrSetAppCompatDllRedirectionCallback(
IN ULONG Flags,
IN PLDR_APP_COMPAT_DLL_REDIRECTION_CALLBACK_FUNCTION CallbackFunction,
IN PVOID CallbackData
);
#ifdef __cplusplus
}
#endif
#endif // _NTLDRAPI_