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 typedef 33 NTSTATUS 34 (NTAPI* PLDR_APP_COMPAT_DLL_REDIRECTION_CALLBACK_FUNCTION)( 35 _In_ ULONG Flags, 36 _In_ PCWSTR DllName, 37 _In_ PCWSTR DllPath OPTIONAL, 38 _Inout_opt_ PULONG DllCharacteristics, 39 _In_ PVOID CallbackData, 40 _Outptr_ PWSTR* EffectiveDllPath); 41 42 /* Global data */ 43 extern RTL_CRITICAL_SECTION LdrpLoaderLock; 44 extern BOOLEAN LdrpInLdrInit; 45 extern PVOID LdrpHeap; 46 extern LIST_ENTRY LdrpHashTable[LDR_HASH_TABLE_ENTRIES]; 47 extern BOOLEAN ShowSnaps; 48 extern UNICODE_STRING LdrpDefaultPath; 49 extern HANDLE LdrpKnownDllObjectDirectory; 50 extern ULONG LdrpNumberOfProcessors; 51 extern ULONG LdrpFatalHardErrorCount; 52 extern PUNICODE_STRING LdrpTopLevelDllBeingLoaded; 53 extern PLDR_DATA_TABLE_ENTRY LdrpCurrentDllInitializer; 54 extern UNICODE_STRING LdrApiDefaultExtension; 55 extern BOOLEAN LdrpLdrDatabaseIsSetup; 56 extern ULONG LdrpActiveUnloadCount; 57 extern BOOLEAN LdrpShutdownInProgress; 58 extern UNICODE_STRING LdrpKnownDllPath; 59 extern PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache, LdrpLoadedDllHandleCache; 60 extern BOOLEAN RtlpPageHeapEnabled; 61 extern ULONG RtlpDphGlobalFlags; 62 extern BOOLEAN g_ShimsEnabled; 63 extern PVOID g_pShimEngineModule; 64 extern PVOID g_pfnSE_DllLoaded; 65 extern PVOID g_pfnSE_DllUnloaded; 66 extern PVOID g_pfnSE_InstallBeforeInit; 67 extern PVOID g_pfnSE_InstallAfterInit; 68 extern PVOID g_pfnSE_ProcessDying; 69 70 /* ldrinit.c */ 71 NTSTATUS NTAPI LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL); 72 VOID NTAPI LdrpInitializeThread(IN PCONTEXT Context); 73 NTSTATUS NTAPI LdrpInitializeTls(VOID); 74 NTSTATUS NTAPI LdrpAllocateTls(VOID); 75 VOID NTAPI LdrpFreeTls(VOID); 76 VOID NTAPI LdrpCallTlsInitializers(IN PLDR_DATA_TABLE_ENTRY LdrEntry, IN ULONG Reason); 77 BOOLEAN NTAPI LdrpCallInitRoutine(IN PDLL_INIT_ROUTINE EntryPoint, IN PVOID BaseAddress, IN ULONG Reason, IN PVOID Context); 78 NTSTATUS NTAPI LdrpInitializeProcess(IN PCONTEXT Context, IN PVOID SystemArgument1); 79 VOID NTAPI LdrpInitFailure(NTSTATUS Status); 80 VOID NTAPI LdrpValidateImageForMp(IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry); 81 VOID NTAPI LdrpEnsureLoaderLockIsHeld(VOID); 82 83 /* ldrpe.c */ 84 NTSTATUS 85 NTAPI 86 LdrpSnapThunk(IN PVOID ExportBase, 87 IN PVOID ImportBase, 88 IN PIMAGE_THUNK_DATA OriginalThunk, 89 IN OUT PIMAGE_THUNK_DATA Thunk, 90 IN PIMAGE_EXPORT_DIRECTORY ExportEntry, 91 IN ULONG ExportSize, 92 IN BOOLEAN Static, 93 IN LPSTR DllName); 94 95 NTSTATUS NTAPI 96 LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL, 97 IN PLDR_DATA_TABLE_ENTRY LdrEntry); 98 99 100 /* ldrutils.c */ 101 NTSTATUS NTAPI 102 LdrpGetProcedureAddress(IN PVOID BaseAddress, 103 IN PANSI_STRING Name, 104 IN ULONG Ordinal, 105 OUT PVOID *ProcedureAddress, 106 IN BOOLEAN ExecuteInit); 107 108 PLDR_DATA_TABLE_ENTRY NTAPI 109 LdrpAllocateDataTableEntry(IN PVOID BaseAddress); 110 111 VOID NTAPI 112 LdrpInsertMemoryTableEntry(IN PLDR_DATA_TABLE_ENTRY LdrEntry); 113 114 NTSTATUS NTAPI 115 LdrpLoadDll(IN BOOLEAN Redirected, 116 IN PWSTR DllPath OPTIONAL, 117 IN PULONG DllCharacteristics OPTIONAL, 118 IN PUNICODE_STRING DllName, 119 OUT PVOID *BaseAddress, 120 IN BOOLEAN CallInit); 121 122 VOID NTAPI 123 LdrpUpdateLoadCount2(IN PLDR_DATA_TABLE_ENTRY LdrEntry, 124 IN ULONG Flags); 125 126 ULONG NTAPI 127 LdrpClearLoadInProgress(VOID); 128 129 NTSTATUS 130 NTAPI 131 LdrpSetProtection(PVOID ViewBase, 132 BOOLEAN Restore); 133 134 BOOLEAN 135 NTAPI 136 LdrpCheckForLoadedDllHandle(IN PVOID Base, 137 OUT PLDR_DATA_TABLE_ENTRY *LdrEntry); 138 139 BOOLEAN NTAPI 140 LdrpCheckForLoadedDll(IN PWSTR DllPath, 141 IN PUNICODE_STRING DllName, 142 IN BOOLEAN Flag, 143 IN BOOLEAN RedirectedDll, 144 OUT PLDR_DATA_TABLE_ENTRY *LdrEntry); 145 146 NTSTATUS NTAPI 147 LdrpMapDll(IN PWSTR SearchPath OPTIONAL, 148 IN PWSTR DllPath2, 149 IN PWSTR DllName OPTIONAL, 150 IN PULONG DllCharacteristics, 151 IN BOOLEAN Static, 152 IN BOOLEAN Redirect, 153 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry); 154 155 PVOID NTAPI 156 LdrpFetchAddressOfEntryPoint(PVOID ImageBase); 157 158 VOID NTAPI 159 LdrpFreeUnicodeString(PUNICODE_STRING String); 160 161 VOID NTAPI 162 LdrpGetShimEngineInterface(VOID); 163 164 VOID 165 NTAPI 166 LdrpLoadShimEngine(IN PWSTR ImageName, 167 IN PUNICODE_STRING ProcessImage, 168 IN PVOID pShimData); 169 170 VOID NTAPI 171 LdrpUnloadShimEngine(VOID); 172 173 /* verifier.c */ 174 175 NTSTATUS NTAPI 176 LdrpInitializeApplicationVerifierPackage(IN HANDLE KeyHandle, 177 IN PPEB Peb, 178 IN BOOLEAN SystemWide, 179 IN BOOLEAN ReadAdvancedOptions); 180 181 NTSTATUS NTAPI 182 AVrfInitializeVerifier(VOID); 183 184 VOID NTAPI 185 AVrfDllLoadNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry); 186 187 VOID NTAPI 188 AVrfDllUnloadNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry); 189 190 VOID NTAPI 191 AVrfPageHeapDllNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry); 192 193 194 /* FIXME: Cleanup this mess */ 195 typedef NTSTATUS (NTAPI *PEPFUNC)(PPEB); 196 NTSTATUS LdrMapSections(HANDLE ProcessHandle, 197 PVOID ImageBase, 198 HANDLE SectionHandle, 199 PIMAGE_NT_HEADERS NTHeaders); 200 NTSTATUS LdrMapNTDllForProcess(HANDLE ProcessHandle, 201 PHANDLE NTDllSectionHandle); 202 ULONG 203 LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders); 204 205 NTSTATUS 206 NTAPI 207 LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL, 208 IN LPSTR ImportName, 209 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry, 210 OUT PBOOLEAN Existing); 211 212 VOID 213 NTAPI 214 LdrpFinalizeAndDeallocateDataTableEntry(IN PLDR_DATA_TABLE_ENTRY Entry); 215 216 217 /* path.c */ 218 BOOLEAN 219 NTAPI 220 RtlDoesFileExists_UStr( 221 IN PUNICODE_STRING FileName 222 ); 223 224 /* EOF */ 225