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