[SDK][ACGENRAL] Add the shim IgnoreFreeLibrary
[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 ULONG RtlpDphGlobalFlags;
50 extern BOOLEAN g_ShimsEnabled;
51 extern PVOID g_pShimEngineModule;
52 extern PVOID g_pfnSE_DllLoaded;
53 extern PVOID g_pfnSE_DllUnloaded;
54 extern PVOID g_pfnSE_InstallBeforeInit;
55 extern PVOID g_pfnSE_InstallAfterInit;
56 extern PVOID g_pfnSE_ProcessDying;
57
58 /* ldrinit.c */
59 NTSTATUS NTAPI LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL);
60 VOID NTAPI LdrpInitializeThread(IN PCONTEXT Context);
61 NTSTATUS NTAPI LdrpInitializeTls(VOID);
62 NTSTATUS NTAPI LdrpAllocateTls(VOID);
63 VOID NTAPI LdrpFreeTls(VOID);
64 VOID NTAPI LdrpCallTlsInitializers(PVOID BaseAddress, ULONG Reason);
65 BOOLEAN NTAPI LdrpCallInitRoutine(PDLL_INIT_ROUTINE EntryPoint, PVOID BaseAddress, ULONG Reason, PVOID Context);
66 NTSTATUS NTAPI LdrpInitializeProcess(PCONTEXT Context, PVOID SystemArgument1);
67 VOID NTAPI LdrpInitFailure(NTSTATUS Status);
68 VOID NTAPI LdrpValidateImageForMp(IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry);
69 VOID NTAPI LdrpEnsureLoaderLockIsHeld(VOID);
70
71 /* ldrpe.c */
72 NTSTATUS
73 NTAPI
74 LdrpSnapThunk(IN PVOID ExportBase,
75 IN PVOID ImportBase,
76 IN PIMAGE_THUNK_DATA OriginalThunk,
77 IN OUT PIMAGE_THUNK_DATA Thunk,
78 IN PIMAGE_EXPORT_DIRECTORY ExportEntry,
79 IN ULONG ExportSize,
80 IN BOOLEAN Static,
81 IN LPSTR DllName);
82
83 NTSTATUS NTAPI
84 LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
85 IN PLDR_DATA_TABLE_ENTRY LdrEntry);
86
87
88 /* ldrutils.c */
89 NTSTATUS NTAPI
90 LdrpGetProcedureAddress(IN PVOID BaseAddress,
91 IN PANSI_STRING Name,
92 IN ULONG Ordinal,
93 OUT PVOID *ProcedureAddress,
94 IN BOOLEAN ExecuteInit);
95
96 PLDR_DATA_TABLE_ENTRY NTAPI
97 LdrpAllocateDataTableEntry(IN PVOID BaseAddress);
98
99 VOID NTAPI
100 LdrpInsertMemoryTableEntry(IN PLDR_DATA_TABLE_ENTRY LdrEntry);
101
102 NTSTATUS NTAPI
103 LdrpLoadDll(IN BOOLEAN Redirected,
104 IN PWSTR DllPath OPTIONAL,
105 IN PULONG DllCharacteristics OPTIONAL,
106 IN PUNICODE_STRING DllName,
107 OUT PVOID *BaseAddress,
108 IN BOOLEAN CallInit);
109
110 VOID NTAPI
111 LdrpUpdateLoadCount2(IN PLDR_DATA_TABLE_ENTRY LdrEntry,
112 IN ULONG Flags);
113
114 ULONG NTAPI
115 LdrpClearLoadInProgress(VOID);
116
117 NTSTATUS
118 NTAPI
119 LdrpSetProtection(PVOID ViewBase,
120 BOOLEAN Restore);
121
122 BOOLEAN
123 NTAPI
124 LdrpCheckForLoadedDllHandle(IN PVOID Base,
125 OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
126
127 BOOLEAN NTAPI
128 LdrpCheckForLoadedDll(IN PWSTR DllPath,
129 IN PUNICODE_STRING DllName,
130 IN BOOLEAN Flag,
131 IN BOOLEAN RedirectedDll,
132 OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
133
134 NTSTATUS NTAPI
135 LdrpMapDll(IN PWSTR SearchPath OPTIONAL,
136 IN PWSTR DllPath2,
137 IN PWSTR DllName OPTIONAL,
138 IN PULONG DllCharacteristics,
139 IN BOOLEAN Static,
140 IN BOOLEAN Redirect,
141 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry);
142
143 PVOID NTAPI
144 LdrpFetchAddressOfEntryPoint(PVOID ImageBase);
145
146 VOID NTAPI
147 LdrpFreeUnicodeString(PUNICODE_STRING String);
148
149 VOID NTAPI
150 LdrpGetShimEngineInterface(VOID);
151
152 VOID
153 NTAPI
154 LdrpLoadShimEngine(IN PWSTR ImageName,
155 IN PUNICODE_STRING ProcessImage,
156 IN PVOID pShimData);
157
158 VOID NTAPI
159 LdrpUnloadShimEngine(VOID);
160
161
162 /* FIXME: Cleanup this mess */
163 typedef NTSTATUS (NTAPI *PEPFUNC)(PPEB);
164 NTSTATUS LdrMapSections(HANDLE ProcessHandle,
165 PVOID ImageBase,
166 HANDLE SectionHandle,
167 PIMAGE_NT_HEADERS NTHeaders);
168 NTSTATUS LdrMapNTDllForProcess(HANDLE ProcessHandle,
169 PHANDLE NTDllSectionHandle);
170 ULONG
171 LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders);
172
173 NTSTATUS
174 NTAPI
175 LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
176 IN LPSTR ImportName,
177 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
178 OUT PBOOLEAN Existing);
179
180 VOID
181 NTAPI
182 LdrpFinalizeAndDeallocateDataTableEntry(IN PLDR_DATA_TABLE_ENTRY Entry);
183
184 /* EOF */