[WINHTTP] Sync with Wine Staging 3.9. CORE-14656
[reactos.git] / dll / ntdll / include / ntdllp.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS System Libraries
4 * FILE: dll/ntdll/include/ntdllp.h
5 * PURPOSE: Native Library Internal Header
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9 #pragma once
10
11 #define LDR_HASH_TABLE_ENTRIES 32
12 #define LDR_GET_HASH_ENTRY(x) (RtlUpcaseUnicodeChar((x)) & (LDR_HASH_TABLE_ENTRIES - 1))
13
14 /* LdrpUpdateLoadCount2 flags */
15 #define LDRP_UPDATE_REFCOUNT 0x01
16 #define LDRP_UPDATE_DEREFCOUNT 0x02
17 #define LDRP_UPDATE_PIN 0x03
18
19 /* Loader flags */
20 #define IMAGE_LOADER_FLAGS_COMPLUS 0x00000001
21 #define IMAGE_LOADER_FLAGS_SYSTEM_GLOBAL 0x01000000
22
23 /* Page heap flags */
24 #define DPH_FLAG_DLL_NOTIFY 0x40
25
26 typedef struct _LDRP_TLS_DATA
27 {
28 LIST_ENTRY TlsLinks;
29 IMAGE_TLS_DIRECTORY TlsDirectory;
30 } LDRP_TLS_DATA, *PLDRP_TLS_DATA;
31
32 /* Global data */
33 extern RTL_CRITICAL_SECTION LdrpLoaderLock;
34 extern BOOLEAN LdrpInLdrInit;
35 extern LIST_ENTRY LdrpHashTable[LDR_HASH_TABLE_ENTRIES];
36 extern BOOLEAN ShowSnaps;
37 extern UNICODE_STRING LdrpDefaultPath;
38 extern HANDLE LdrpKnownDllObjectDirectory;
39 extern ULONG LdrpNumberOfProcessors;
40 extern ULONG LdrpFatalHardErrorCount;
41 extern PUNICODE_STRING LdrpTopLevelDllBeingLoaded;
42 extern PLDR_DATA_TABLE_ENTRY LdrpCurrentDllInitializer;
43 extern UNICODE_STRING LdrApiDefaultExtension;
44 extern BOOLEAN LdrpLdrDatabaseIsSetup;
45 extern ULONG LdrpActiveUnloadCount;
46 extern BOOLEAN LdrpShutdownInProgress;
47 extern UNICODE_STRING LdrpKnownDllPath;
48 extern PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache, LdrpLoadedDllHandleCache;
49 extern BOOLEAN RtlpPageHeapEnabled;
50 extern ULONG RtlpDphGlobalFlags;
51 extern BOOLEAN g_ShimsEnabled;
52 extern PVOID g_pShimEngineModule;
53 extern PVOID g_pfnSE_DllLoaded;
54 extern PVOID g_pfnSE_DllUnloaded;
55 extern PVOID g_pfnSE_InstallBeforeInit;
56 extern PVOID g_pfnSE_InstallAfterInit;
57 extern PVOID g_pfnSE_ProcessDying;
58
59 /* ldrinit.c */
60 NTSTATUS NTAPI LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL);
61 VOID NTAPI LdrpInitializeThread(IN PCONTEXT Context);
62 NTSTATUS NTAPI LdrpInitializeTls(VOID);
63 NTSTATUS NTAPI LdrpAllocateTls(VOID);
64 VOID NTAPI LdrpFreeTls(VOID);
65 VOID NTAPI LdrpCallTlsInitializers(PVOID BaseAddress, ULONG Reason);
66 BOOLEAN NTAPI LdrpCallInitRoutine(PDLL_INIT_ROUTINE EntryPoint, PVOID BaseAddress, ULONG Reason, PVOID Context);
67 NTSTATUS NTAPI LdrpInitializeProcess(PCONTEXT Context, PVOID SystemArgument1);
68 VOID NTAPI LdrpInitFailure(NTSTATUS Status);
69 VOID NTAPI LdrpValidateImageForMp(IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry);
70 VOID NTAPI LdrpEnsureLoaderLockIsHeld(VOID);
71
72 /* ldrpe.c */
73 NTSTATUS
74 NTAPI
75 LdrpSnapThunk(IN PVOID ExportBase,
76 IN PVOID ImportBase,
77 IN PIMAGE_THUNK_DATA OriginalThunk,
78 IN OUT PIMAGE_THUNK_DATA Thunk,
79 IN PIMAGE_EXPORT_DIRECTORY ExportEntry,
80 IN ULONG ExportSize,
81 IN BOOLEAN Static,
82 IN LPSTR DllName);
83
84 NTSTATUS NTAPI
85 LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
86 IN PLDR_DATA_TABLE_ENTRY LdrEntry);
87
88
89 /* ldrutils.c */
90 NTSTATUS NTAPI
91 LdrpGetProcedureAddress(IN PVOID BaseAddress,
92 IN PANSI_STRING Name,
93 IN ULONG Ordinal,
94 OUT PVOID *ProcedureAddress,
95 IN BOOLEAN ExecuteInit);
96
97 PLDR_DATA_TABLE_ENTRY NTAPI
98 LdrpAllocateDataTableEntry(IN PVOID BaseAddress);
99
100 VOID NTAPI
101 LdrpInsertMemoryTableEntry(IN PLDR_DATA_TABLE_ENTRY LdrEntry);
102
103 NTSTATUS NTAPI
104 LdrpLoadDll(IN BOOLEAN Redirected,
105 IN PWSTR DllPath OPTIONAL,
106 IN PULONG DllCharacteristics OPTIONAL,
107 IN PUNICODE_STRING DllName,
108 OUT PVOID *BaseAddress,
109 IN BOOLEAN CallInit);
110
111 VOID NTAPI
112 LdrpUpdateLoadCount2(IN PLDR_DATA_TABLE_ENTRY LdrEntry,
113 IN ULONG Flags);
114
115 ULONG NTAPI
116 LdrpClearLoadInProgress(VOID);
117
118 NTSTATUS
119 NTAPI
120 LdrpSetProtection(PVOID ViewBase,
121 BOOLEAN Restore);
122
123 BOOLEAN
124 NTAPI
125 LdrpCheckForLoadedDllHandle(IN PVOID Base,
126 OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
127
128 BOOLEAN NTAPI
129 LdrpCheckForLoadedDll(IN PWSTR DllPath,
130 IN PUNICODE_STRING DllName,
131 IN BOOLEAN Flag,
132 IN BOOLEAN RedirectedDll,
133 OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
134
135 NTSTATUS NTAPI
136 LdrpMapDll(IN PWSTR SearchPath OPTIONAL,
137 IN PWSTR DllPath2,
138 IN PWSTR DllName OPTIONAL,
139 IN PULONG DllCharacteristics,
140 IN BOOLEAN Static,
141 IN BOOLEAN Redirect,
142 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry);
143
144 PVOID NTAPI
145 LdrpFetchAddressOfEntryPoint(PVOID ImageBase);
146
147 VOID NTAPI
148 LdrpFreeUnicodeString(PUNICODE_STRING String);
149
150 VOID NTAPI
151 LdrpGetShimEngineInterface(VOID);
152
153 VOID
154 NTAPI
155 LdrpLoadShimEngine(IN PWSTR ImageName,
156 IN PUNICODE_STRING ProcessImage,
157 IN PVOID pShimData);
158
159 VOID NTAPI
160 LdrpUnloadShimEngine(VOID);
161
162 /* verifier.c */
163
164 NTSTATUS NTAPI
165 LdrpInitializeApplicationVerifierPackage(IN HANDLE KeyHandle,
166 IN PPEB Peb,
167 IN BOOLEAN SystemWide,
168 IN BOOLEAN ReadAdvancedOptions);
169
170 NTSTATUS NTAPI
171 AVrfInitializeVerifier(VOID);
172
173 VOID NTAPI
174 AVrfDllLoadNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry);
175
176 VOID NTAPI
177 AVrfDllUnloadNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry);
178
179 VOID NTAPI
180 AVrfPageHeapDllNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry);
181
182
183 /* FIXME: Cleanup this mess */
184 typedef NTSTATUS (NTAPI *PEPFUNC)(PPEB);
185 NTSTATUS LdrMapSections(HANDLE ProcessHandle,
186 PVOID ImageBase,
187 HANDLE SectionHandle,
188 PIMAGE_NT_HEADERS NTHeaders);
189 NTSTATUS LdrMapNTDllForProcess(HANDLE ProcessHandle,
190 PHANDLE NTDllSectionHandle);
191 ULONG
192 LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders);
193
194 NTSTATUS
195 NTAPI
196 LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
197 IN LPSTR ImportName,
198 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
199 OUT PBOOLEAN Existing);
200
201 VOID
202 NTAPI
203 LdrpFinalizeAndDeallocateDataTableEntry(IN PLDR_DATA_TABLE_ENTRY Entry);
204
205 /* EOF */