Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ldrp.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 ldrp.h 00008 00009 Abstract: 00010 00011 Private types... for executive portion of loader 00012 00013 Author: 00014 00015 Mark Lucovsky (markl) 26-Mar-1990 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #ifndef _LDRP_ 00022 #define _LDRP_ 00023 00024 #include <nt.h> 00025 #include <ntrtl.h> 00026 #include <nturtl.h> 00027 #include <string.h> 00028 #define NOEXTAPI 00029 #include "wdbgexts.h" 00030 #include <ntdbg.h> 00031 00032 extern BOOLEAN LdrpImageHasTls; 00033 extern UNICODE_STRING LdrpDefaultPath; 00034 HANDLE LdrpKnownDllObjectDirectory; 00035 #define LDRP_MAX_KNOWN_PATH 128 00036 WCHAR LdrpKnownDllPathBuffer[LDRP_MAX_KNOWN_PATH]; 00037 UNICODE_STRING LdrpKnownDllPath; 00038 00039 00040 00041 #if defined(WX86) 00042 00043 extern BOOLEAN (*Wx86ProcessInit)(PVOID, BOOLEAN); 00044 00045 BOOLEAN 00046 LdrpWx86DllMapNotify( 00047 PVOID DllBase, 00048 BOOLEAN Mapped 00049 ); 00050 00051 PLDR_DATA_TABLE_ENTRY 00052 LdrpWx86CheckForLoadedDll( 00053 IN PWSTR DllPath, 00054 IN PUNICODE_STRING DllName, 00055 IN BOOLEAN Wx86KnownDll, 00056 OUT PUNICODE_STRING FullDllName 00057 ); 00058 00059 00060 NTSTATUS 00061 LdrpWx86MapDll( 00062 IN PWSTR DllPath OPTIONAL, 00063 IN PULONG DllCharacteristics OPTIONAL, 00064 IN BOOLEAN Wx86KnownDll, 00065 IN BOOLEAN StaticLink, 00066 OUT PUNICODE_STRING DllName, 00067 OUT PLDR_DATA_TABLE_ENTRY *pEntry, 00068 OUT SIZE_T *pViewSize, 00069 OUT HANDLE *pSection 00070 ); 00071 00072 NTSTATUS 00073 LdrpRunWx86DllEntryPoint( 00074 IN PDLL_INIT_ROUTINE InitRoutine, 00075 OUT BOOLEAN *pInitStatus, 00076 IN PVOID DllBase, 00077 IN ULONG Reason, 00078 IN PCONTEXT Context 00079 ); 00080 00081 NTSTATUS 00082 LdrpLoadWx86Dll( 00083 IN PCONTEXT Context 00084 ); 00085 00086 NTSTATUS 00087 LdrpInitWx86( 00088 IN PWX86TIB Wx86Tib, 00089 IN PCONTEXT Context, 00090 IN BOOLEAN NewThread 00091 ); 00092 00093 VOID 00094 LdrpWx86DllProcessDetach( 00095 IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry 00096 ); 00097 00098 #define WX86PLUGIN_MAXPROVIDER 8 // maximum # of providers per plugin 00099 00100 NTSTATUS 00101 Wx86IdentifyPlugin( 00102 IN PVOID ViewBase, 00103 IN PUNICODE_STRING FullDllName 00104 ); 00105 00106 NTSTATUS 00107 Wx86ThunkPluginExport( 00108 IN PVOID DllBase, 00109 IN PCHAR ExportName, 00110 IN ULONG Ordinal, 00111 IN PVOID ExportAddress, 00112 OUT PVOID *ExportThunk 00113 ); 00114 00115 BOOLEAN 00116 Wx86UnloadProviders( 00117 IN PVOID DllBase 00118 ); 00119 #endif 00120 00121 #if defined (_ALPHA_) || defined (BUILD_WOW6432) 00122 NTSTATUS 00123 LdrpWx86FormatVirtualImage( 00124 IN PIMAGE_NT_HEADERS32 NtHeaders, 00125 IN PVOID DllBase 00126 ); 00127 00128 NTSTATUS 00129 Wx86SetRelocatedSharedProtection ( 00130 IN PVOID Base, 00131 IN BOOLEAN Reset 00132 ); 00133 00134 ULONG 00135 LdrpWx86RelocatedFixupDiff( 00136 IN PUCHAR ImageBase, 00137 IN ULONG Offset 00138 ); 00139 00140 BOOLEAN 00141 LdrpWx86DllHasRelocatedSharedSection( 00142 IN PUCHAR ImageBase); 00143 00144 00145 #endif 00146 00147 #if defined (BUILD_WOW6432) 00148 #define NATIVE_PAGE_SIZE 0x2000 00149 #define NATIVE_PAGE_SHIFT 13L 00150 #define NATIVE_BYTES_TO_PAGES(Size) ((ULONG)((ULONG_PTR)(Size) >> NATIVE_PAGE_SHIFT) + \ 00151 (((ULONG)(Size) & (NATIVE_PAGE_SIZE - 1)) != 0)) 00152 #else 00153 #define NATIVE_PAGE_SIZE PAGE_SIZE 00154 #define NATIVE_PAGE_SHIFT PAGE_SHIFT 00155 #define NATIVE_BYTES_TO_PAGES(Size) BYTES_TO_PAGES(Size) 00156 #endif 00157 00158 00159 #define LDRP_HASH_TABLE_SIZE 32 00160 #define LDRP_HASH_MASK (LDRP_HASH_TABLE_SIZE-1) 00161 #define LDRP_COMPUTE_HASH_INDEX(wch) ( (RtlUpcaseUnicodeChar((wch)) - (WCHAR)'A') & LDRP_HASH_MASK ) 00162 LIST_ENTRY LdrpHashTable[LDRP_HASH_TABLE_SIZE]; 00163 00164 00165 // LDRP_BAD_DLL Sundown: sign-extended value. 00166 #define LDRP_BAD_DLL LongToPtr(0xffbadd11) 00167 00168 LIST_ENTRY LdrpDefaultPathCache; 00169 typedef struct _LDRP_PATH_CACHE { 00170 LIST_ENTRY Links; 00171 UNICODE_STRING Component; 00172 HANDLE Directory; 00173 } LDRP_PATH_CACHE, *PLDRP_PATH_CACHE; 00174 00175 00176 NTSTATUS 00177 LdrpSnapIAT( 00178 IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry_Export, 00179 IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry_Import, 00180 IN PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor, 00181 IN BOOLEAN SnapForwardersOnly 00182 ); 00183 00184 NTSTATUS 00185 LdrpSnapLinksToDllHandle( 00186 IN PVOID DllHandle, 00187 IN ULONG NumberOfThunks, 00188 IN OUT PIMAGE_THUNK_DATA FirstThunk 00189 ); 00190 00191 NTSTATUS 00192 LdrpSnapThunk( 00193 IN PVOID DllBase, 00194 IN PVOID ImageBase, 00195 IN PIMAGE_THUNK_DATA OriginalThunk, 00196 IN OUT PIMAGE_THUNK_DATA Thunk, 00197 IN PIMAGE_EXPORT_DIRECTORY ExportDirectory, 00198 IN ULONG ExportSize, 00199 IN BOOLEAN StaticSnap, 00200 IN PSZ DllName OPTIONAL 00201 ); 00202 00203 USHORT 00204 LdrpNameToOrdinal( 00205 IN PSZ Name, 00206 IN ULONG NumberOfNames, 00207 IN PVOID DllBase, 00208 IN PULONG NameTableBase, 00209 IN PUSHORT NameOrdinalTableBase 00210 ); 00211 00212 PLDR_DATA_TABLE_ENTRY 00213 LdrpAllocateDataTableEntry( 00214 IN PVOID DllBase 00215 ); 00216 00217 BOOLEAN 00218 LdrpCheckForLoadedDll( 00219 IN PWSTR DllPath OPTIONAL, 00220 IN PUNICODE_STRING DllName, 00221 IN BOOLEAN StaticLink, 00222 IN BOOLEAN Wx86KnownDll, 00223 OUT PLDR_DATA_TABLE_ENTRY *LdrDataTableEntry 00224 ); 00225 00226 BOOLEAN 00227 LdrpCheckForLoadedDllHandle( 00228 IN PVOID DllHandle, 00229 OUT PLDR_DATA_TABLE_ENTRY *LdrDataTableEntry 00230 ); 00231 00232 NTSTATUS 00233 LdrpMapDll( 00234 IN PWSTR DllPath OPTIONAL, 00235 IN PWSTR DllName, 00236 IN PULONG DllCharacteristics OPTIONAL, 00237 IN BOOLEAN StaticLink, 00238 IN BOOLEAN Wx86KnownDll, 00239 OUT PLDR_DATA_TABLE_ENTRY *LdrDataTableEntry 00240 ); 00241 00242 NTSTATUS 00243 LdrpWalkImportDescriptor( 00244 IN PWSTR DllPath OPTIONAL, 00245 IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry 00246 ); 00247 00248 NTSTATUS 00249 LdrpRunInitializeRoutines( 00250 IN PCONTEXT Context OPTIONAL 00251 ); 00252 00253 #define LdrpReferenceLoadedDll( lde ) LdrpUpdateLoadCount( lde, TRUE ) 00254 #define LdrpDereferenceLoadedDll( lde ) LdrpUpdateLoadCount( lde, FALSE ) 00255 00256 VOID 00257 LdrpUpdateLoadCount ( 00258 IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry, 00259 IN BOOLEAN IncrementCount 00260 ); 00261 00262 NTSTATUS 00263 LdrpInitializeProcess( 00264 IN PCONTEXT Context OPTIONAL, 00265 IN PVOID SystemDllBase, 00266 IN PUNICODE_STRING UnicodeImageName 00267 ); 00268 00269 VOID 00270 LdrpInitialize( 00271 IN PCONTEXT Context, 00272 IN PVOID SystemArgument1, 00273 IN PVOID SystemArgument2 00274 ); 00275 00276 VOID 00277 LdrpInsertMemoryTableEntry( 00278 IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry 00279 ); 00280 00281 BOOLEAN 00282 LdrpResolveDllName( 00283 IN PWSTR DllPath OPTIONAL, 00284 IN PWSTR DllName, 00285 OUT PUNICODE_STRING FullDllName, 00286 OUT PUNICODE_STRING BaseDllName, 00287 OUT PHANDLE DllFile 00288 ); 00289 00290 NTSTATUS 00291 LdrpCreateDllSection( 00292 IN PUNICODE_STRING FullDllName, 00293 IN HANDLE DllFile, 00294 IN PUNICODE_STRING BaseName, 00295 IN PULONG DllCharacteristics OPTIONAL, 00296 OUT PHANDLE SectionHandle 00297 ); 00298 00299 VOID 00300 LdrpInitializePathCache( 00301 VOID 00302 ); 00303 00304 PVOID 00305 LdrpFetchAddressOfEntryPoint( 00306 IN PVOID Base 00307 ); 00308 00309 BOOLEAN 00310 xRtlDosPathNameToNtPathName( 00311 IN PSZ DosFileName, 00312 OUT PSTRING NtFileName, 00313 OUT PSZ *FilePart OPTIONAL, 00314 OUT PRTL_RELATIVE_NAME RelativeName OPTIONAL 00315 ); 00316 00317 ULONG 00318 xRtlDosSearchPath( 00319 PSZ lpPath, 00320 PSZ lpFileName, 00321 PSZ lpExtension, 00322 ULONG nBufferLength, 00323 PSZ lpBuffer, 00324 PSZ *lpFilePart OPTIONAL 00325 ); 00326 00327 ULONG 00328 xRtlGetFullPathName( 00329 PSZ lpFileName, 00330 ULONG nBufferLength, 00331 PSZ lpBuffer, 00332 PSZ *lpFilePart OPTIONAL 00333 ); 00334 00335 PSZ 00336 UnicodeToAnsii( 00337 IN PWSTR String 00338 ); 00339 00340 HANDLE 00341 LdrpCheckForKnownDll( 00342 IN PWSTR DllName, 00343 OUT PUNICODE_STRING FullDllName, 00344 OUT PUNICODE_STRING BaseDllName 00345 ); 00346 00347 NTSTATUS 00348 LdrpSetProtection( 00349 IN PVOID Base, 00350 IN BOOLEAN Reset, 00351 IN BOOLEAN StaticLink 00352 ); 00353 00354 #if DBG 00355 ULONG LdrpCompareCount; 00356 ULONG LdrpSnapBypass; 00357 ULONG LdrpNormalSnap; 00358 ULONG LdrpSectionOpens; 00359 ULONG LdrpSectionCreates; 00360 ULONG LdrpSectionMaps; 00361 ULONG LdrpSectionRelocates; 00362 BOOLEAN LdrpDisplayLoadTime; 00363 LARGE_INTEGER BeginTime, InitcTime, InitbTime, IniteTime, EndTime, ElapsedTime, Interval; 00364 00365 #endif // DBG 00366 00367 BOOLEAN ShowSnaps; 00368 BOOLEAN RtlpTimoutDisable; 00369 LARGE_INTEGER RtlpTimeout; 00370 ULONG NtGlobalFlag; 00371 LIST_ENTRY RtlCriticalSectionList; 00372 RTL_CRITICAL_SECTION RtlCriticalSectionLock; 00373 BOOLEAN LdrpShutdownInProgress; 00374 extern BOOLEAN LdrpInLdrInit; 00375 extern BOOLEAN LdrpLdrDatabaseIsSetup; 00376 extern BOOLEAN LdrpVerifyDlls; 00377 extern BOOLEAN LdrpShutdownInProgress; 00378 extern BOOLEAN LdrpImageHasTls; 00379 extern BOOLEAN LdrpVerifyDlls; 00380 00381 PLDR_DATA_TABLE_ENTRY LdrpImageEntry; 00382 LIST_ENTRY LdrpUnloadHead; 00383 BOOLEAN LdrpActiveUnloadCount; 00384 PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache; 00385 PLDR_DATA_TABLE_ENTRY LdrpLoadedDllHandleCache; 00386 ULONG LdrpFatalHardErrorCount; 00387 UNICODE_STRING LdrpDefaultPath; 00388 RTL_CRITICAL_SECTION FastPebLock; 00389 HANDLE LdrpShutdownThreadId; 00390 PLDR_DATA_TABLE_ENTRY LdrpImageEntry; 00391 ULONG LdrpNumberOfProcessors; 00392 00393 00394 00395 typedef struct _LDRP_TLS_ENTRY { 00396 LIST_ENTRY Links; 00397 IMAGE_TLS_DIRECTORY Tls; 00398 } LDRP_TLS_ENTRY, *PLDRP_TLS_ENTRY; 00399 00400 LIST_ENTRY LdrpTlsList; 00401 ULONG LdrpNumberOfTlsEntries; 00402 00403 NTSTATUS 00404 LdrpInitializeTls( 00405 VOID 00406 ); 00407 00408 NTSTATUS 00409 LdrpAllocateTls( 00410 VOID 00411 ); 00412 VOID 00413 LdrpFreeTls( 00414 VOID 00415 ); 00416 00417 VOID 00418 LdrpCallTlsInitializers( 00419 PVOID DllBase, 00420 ULONG Reason 00421 ); 00422 00423 NTSTATUS 00424 NTAPI 00425 LdrpLoadDll( 00426 IN PWSTR DllPath OPTIONAL, 00427 IN PULONG DllCharacteristics OPTIONAL, 00428 IN PUNICODE_STRING DllName, 00429 OUT PVOID *DllHandle, 00430 IN BOOLEAN RunInitRoutines 00431 ); 00432 00433 NTSTATUS 00434 NTAPI 00435 LdrpGetProcedureAddress( 00436 IN PVOID DllHandle, 00437 IN PANSI_STRING ProcedureName OPTIONAL, 00438 IN ULONG ProcedureNumber OPTIONAL, 00439 OUT PVOID *ProcedureAddress, 00440 IN BOOLEAN RunInitRoutines 00441 ); 00442 00443 PLIST_ENTRY 00444 RtlpLockProcessHeapsList( VOID ); 00445 00446 00447 VOID 00448 RtlpUnlockProcessHeapsList( VOID ); 00449 00450 BOOLEAN 00451 RtlpSerializeHeap( 00452 IN PVOID HeapHandle 00453 ); 00454 00455 ULONG NtdllBaseTag; 00456 00457 #define MAKE_TAG( t ) (RTL_HEAP_MAKE_TAG( NtdllBaseTag, t )) 00458 00459 #define CSR_TAG 0 00460 #define LDR_TAG 1 00461 #define CURDIR_TAG 2 00462 #define TLS_TAG 3 00463 #define DBG_TAG 4 00464 #define SE_TAG 5 00465 #define TEMP_TAG 6 00466 #define ATOM_TAG 7 00467 00468 PVOID 00469 LdrpDefineDllTag( 00470 PWSTR TagName, 00471 PUSHORT TagIndex 00472 ); 00473 00474 #if defined(_X86_) 00475 BOOLEAN 00476 LdrpCallInitRoutine( 00477 IN PDLL_INIT_ROUTINE InitRoutine, 00478 IN PVOID DllHandle, 00479 IN ULONG Reason, 00480 IN PCONTEXT Context OPTIONAL 00481 ); 00482 #else 00483 00484 #define LdrpCallInitRoutine(InitRoutine, DllHandle, Reason, Context) \ 00485 (InitRoutine)((DllHandle), (Reason), (Context)) 00486 00487 #endif 00488 00489 #endif // _LDRP_ 00490 

Generated on Sat May 15 19:40:37 2004 for test by doxygen 1.3.7