Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

702 lines
17 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. ldrp.h
  5. Abstract:
  6. Private types... for executive portion of loader
  7. Author:
  8. Mark Lucovsky (markl) 26-Mar-1990
  9. Revision History:
  10. --*/
  11. #ifndef _LDRP_
  12. #define _LDRP_
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <string.h>
  17. #define NOEXTAPI
  18. #include "wdbgexts.h"
  19. #include <ntdbg.h>
  20. #include <sxstypes.h>
  21. #if defined(_WIN64)
  22. extern INVERTED_FUNCTION_TABLE LdrpInvertedFunctionTable;
  23. #endif
  24. #if DBG
  25. #define LdrpShouldDbgPrintStatus(st) \
  26. (!NT_SUCCESS(st) \
  27. && (ShowSnaps \
  28. || ( (st) != STATUS_NO_SUCH_FILE \
  29. && (st) != STATUS_DLL_NOT_FOUND \
  30. && (st) != STATUS_OBJECT_NAME_NOT_FOUND \
  31. )))
  32. #else
  33. #define LdrpShouldDbgPrintStatus(st) (FALSE)
  34. #endif
  35. #if DBG
  36. #define LDR_ERROR_DPFLTR DPFLTR_ERROR_LEVEL
  37. #else
  38. #define LDR_ERROR_DPFLTR ((ShowSnaps || ShowErrors) ? DPFLTR_ERROR_LEVEL : DPFLTR_INFO_LEVEL)
  39. #endif // DBG
  40. extern BOOLEAN LdrpImageHasTls;
  41. extern UNICODE_STRING LdrpDefaultPath;
  42. HANDLE LdrpKnownDllObjectDirectory;
  43. #define LDRP_MAX_KNOWN_PATH 128
  44. WCHAR LdrpKnownDllPathBuffer[LDRP_MAX_KNOWN_PATH];
  45. UNICODE_STRING LdrpKnownDllPath;
  46. extern PLDR_MANIFEST_PROBER_ROUTINE LdrpManifestProberRoutine;
  47. extern PLDR_APP_COMPAT_DLL_REDIRECTION_CALLBACK_FUNCTION LdrpAppCompatDllRedirectionCallbackFunction;
  48. extern PVOID LdrpAppCompatDllRedirectionCallbackData;
  49. extern PVOID LdrpHeap;
  50. extern RTL_CRITICAL_SECTION LdrpLoaderLock;
  51. extern PCUNICODE_STRING LdrpTopLevelDllBeingLoaded;
  52. extern PTEB LdrpTopLevelDllBeingLoadedTeb;
  53. extern BOOLEAN LdrpBreakOnExceptions;
  54. extern PLDR_DATA_TABLE_ENTRY LdrpNtDllDataTableEntry;
  55. extern PLDR_DATA_TABLE_ENTRY LdrpCurrentDllInitializer;
  56. extern BOOLEAN LdrpShowInitRoutines;
  57. extern BOOLEAN LdrpShowRecursiveDllLoads;
  58. extern BOOLEAN LdrpBreakOnRecursiveDllLoads;
  59. extern BOOLEAN LdrpLoaderLockAcquisionCount;
  60. #define ASCII_CHAR_IS_N(_ch) (((_ch) == 'n') || ((_ch) == 'N'))
  61. #define ASCII_CHAR_IS_T(_ch) (((_ch) == 't') || ((_ch) == 'T'))
  62. #define ASCII_CHAR_IS_D(_ch) (((_ch) == 'd') || ((_ch) == 'D'))
  63. #define ASCII_CHAR_IS_L(_ch) (((_ch) == 'l') || ((_ch) == 'L'))
  64. #define ASCII_CHAR_IS_DOT(_ch) ((_ch) == '.')
  65. #define ASCII_STRING_IS_NTDLL(_p) \
  66. ((_p) != NULL) && \
  67. (((_p)->Length == (5 * sizeof(CHAR))) && \
  68. (ASCII_CHAR_IS_N((_p)->Buffer[0]) && \
  69. ASCII_CHAR_IS_T((_p)->Buffer[1]) && \
  70. ASCII_CHAR_IS_D((_p)->Buffer[2]) && \
  71. ASCII_CHAR_IS_L((_p)->Buffer[3]) && \
  72. ASCII_CHAR_IS_L((_p)->Buffer[4])) || \
  73. ((_p)->Length == ((5 + 1 + 3) * sizeof(CHAR))) && \
  74. (ASCII_CHAR_IS_N((_p)->Buffer[0]) && \
  75. ASCII_CHAR_IS_T((_p)->Buffer[1]) && \
  76. ASCII_CHAR_IS_D((_p)->Buffer[2]) && \
  77. ASCII_CHAR_IS_L((_p)->Buffer[3]) && \
  78. ASCII_CHAR_IS_L((_p)->Buffer[4]) && \
  79. ASCII_CHAR_IS_DOT((_p)->Buffer[5]) && \
  80. ASCII_CHAR_IS_D((_p)->Buffer[6]) && \
  81. ASCII_CHAR_IS_L((_p)->Buffer[7]) && \
  82. ASCII_CHAR_IS_L((_p)->Buffer[8])))
  83. //
  84. // + 1 is to preserve that code was using 266
  85. // after explaining why it should be 265. Note
  86. // that sizeof("") includes a nul.
  87. // DOS_MAX_PATH_LENGTH is 260 (Win32 MAX_PATH)
  88. // LDR_MAX_PATH is 266
  89. // We will be removing path length limits in the
  90. // ldr in the future.
  91. //
  92. // a-JayK August 2000
  93. //
  94. #define LDR_MAX_PATH (DOS_MAX_PATH_LENGTH + sizeof("\\??\\") + 1)
  95. LIST_ENTRY RtlpCalloutEntryList;
  96. #if defined(_AMD64_) || defined(_IA64_)
  97. extern LIST_ENTRY RtlpDynamicFunctionTable;
  98. #endif
  99. RTL_CRITICAL_SECTION RtlpCalloutEntryLock;
  100. typedef struct _LDRP_DLL_NOTIFICATION_BLOCK {
  101. LIST_ENTRY Links;
  102. PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction;
  103. PVOID Context;
  104. } LDRP_DLL_NOTIFICATION_BLOCK, *PLDRP_DLL_NOTIFICATION_BLOCK;
  105. //
  106. // Synchronized via LdrpLoaderLock
  107. //
  108. LIST_ENTRY LdrpDllNotificationList;
  109. #define LDR_NUMBER_OF(x) (sizeof(x) / sizeof((x)[0]))
  110. #if defined (BUILD_WOW6432)
  111. NTSTATUS
  112. LdrpWx86FormatVirtualImage(
  113. IN PUNICODE_STRING DosImagePathName OPTIONAL,
  114. IN PIMAGE_NT_HEADERS32 NtHeaders,
  115. IN PVOID DllBase
  116. );
  117. NTSTATUS
  118. Wx86SetRelocatedSharedProtection (
  119. IN PVOID Base,
  120. IN BOOLEAN Reset
  121. );
  122. ULONG
  123. LdrpWx86RelocatedFixupDiff(
  124. IN PUCHAR ImageBase,
  125. IN PIMAGE_NT_HEADERS NtHeaders,
  126. IN ULONG Offset
  127. );
  128. BOOLEAN
  129. LdrpWx86DllHasRelocatedSharedSection(
  130. IN PUCHAR ImageBase);
  131. #define NATIVE_PAGE_SIZE 0x2000
  132. #define NATIVE_PAGE_SHIFT 13L
  133. #define NATIVE_BYTES_TO_PAGES(Size) ((ULONG)((ULONG_PTR)(Size) >> NATIVE_PAGE_SHIFT) + \
  134. (((ULONG)(Size) & (NATIVE_PAGE_SIZE - 1)) != 0))
  135. #else
  136. #define NATIVE_PAGE_SIZE PAGE_SIZE
  137. #define NATIVE_PAGE_SHIFT PAGE_SHIFT
  138. #define NATIVE_BYTES_TO_PAGES(Size) BYTES_TO_PAGES(Size)
  139. #endif
  140. VOID
  141. RtlpWaitForCriticalSection (
  142. IN PRTL_CRITICAL_SECTION CriticalSection
  143. );
  144. VOID
  145. RtlpUnWaitCriticalSection (
  146. IN PRTL_CRITICAL_SECTION CriticalSection
  147. );
  148. #define LDRP_HASH_TABLE_SIZE 32
  149. #define LDRP_HASH_MASK (LDRP_HASH_TABLE_SIZE-1)
  150. #define LDRP_COMPUTE_HASH_INDEX(wch) ( (RtlUpcaseUnicodeChar((wch)) - (WCHAR)'A') & LDRP_HASH_MASK )
  151. LIST_ENTRY LdrpHashTable[LDRP_HASH_TABLE_SIZE];
  152. // LDRP_BAD_DLL Sundown: sign-extended value.
  153. #define LDRP_BAD_DLL LongToPtr(0xffbadd11)
  154. LIST_ENTRY LdrpDefaultPathCache;
  155. typedef struct _LDRP_PATH_CACHE {
  156. LIST_ENTRY Links;
  157. UNICODE_STRING Component;
  158. HANDLE Directory;
  159. } LDRP_PATH_CACHE, *PLDRP_PATH_CACHE;
  160. NTSTATUS
  161. LdrpSnapIAT(
  162. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry_Export,
  163. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry_Import,
  164. IN PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor,
  165. IN BOOLEAN SnapForwardersOnly
  166. );
  167. NTSTATUS
  168. LdrpSnapThunk(
  169. IN PVOID DllBase,
  170. IN PVOID ImageBase,
  171. IN PIMAGE_THUNK_DATA OriginalThunk,
  172. IN OUT PIMAGE_THUNK_DATA Thunk,
  173. IN PIMAGE_EXPORT_DIRECTORY ExportDirectory,
  174. IN ULONG ExportSize,
  175. IN BOOLEAN StaticSnap,
  176. IN PSZ DllName OPTIONAL
  177. );
  178. USHORT
  179. LdrpNameToOrdinal(
  180. IN PSZ Name,
  181. IN ULONG NumberOfNames,
  182. IN PVOID DllBase,
  183. IN PULONG NameTableBase,
  184. IN PUSHORT NameOrdinalTableBase
  185. );
  186. PLDR_DATA_TABLE_ENTRY
  187. LdrpAllocateDataTableEntry(
  188. IN PVOID DllBase
  189. );
  190. VOID
  191. LdrpDeallocateDataTableEntry(
  192. IN PLDR_DATA_TABLE_ENTRY Entry
  193. );
  194. VOID
  195. LdrpFinalizeAndDeallocateDataTableEntry(
  196. IN PLDR_DATA_TABLE_ENTRY Entry
  197. );
  198. BOOLEAN
  199. LdrpCheckForLoadedDll(
  200. IN PWSTR DllPath OPTIONAL,
  201. IN PUNICODE_STRING DllName,
  202. IN BOOLEAN StaticLink,
  203. IN BOOLEAN Redirected,
  204. OUT PLDR_DATA_TABLE_ENTRY *LdrDataTableEntry
  205. );
  206. BOOLEAN
  207. LdrpCheckForLoadedDllHandle(
  208. IN PVOID DllHandle,
  209. OUT PLDR_DATA_TABLE_ENTRY *LdrDataTableEntry
  210. );
  211. NTSTATUS
  212. LdrpMapDll(
  213. IN PWSTR DllPath OPTIONAL,
  214. IN PWSTR DllName,
  215. IN PULONG DllCharacteristics OPTIONAL,
  216. IN BOOLEAN StaticLink,
  217. IN BOOLEAN Redirected,
  218. OUT PLDR_DATA_TABLE_ENTRY *LdrDataTableEntry
  219. );
  220. NTSTATUS
  221. LdrpWalkImportDescriptor(
  222. IN PWSTR DllPath OPTIONAL,
  223. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry
  224. );
  225. NTSTATUS
  226. LdrpRunInitializeRoutines(
  227. IN PCONTEXT Context OPTIONAL
  228. );
  229. int
  230. LdrpInitializeProcessWrapperFilter(
  231. IN const struct _EXCEPTION_POINTERS *ExceptionPointers
  232. );
  233. int
  234. LdrpGenericExceptionFilter(
  235. IN const struct _EXCEPTION_POINTERS *ExceptionPointers,
  236. IN PCSTR FunctionName
  237. );
  238. //
  239. // These functions are VOID because they should really never be able to fail.
  240. //
  241. // In the current implementation, they do perform ANSI -> UNICODE conversions
  242. // which may fail in the current code page (may have been changed since when
  243. // the DLL was loaded) and apply Fusion DLL redirection to DLLs which can
  244. // require a large filename buffer than is allocated on the stack.
  245. //
  246. // These cases are ignored for now. Both problems should be fixed by
  247. // reworking the LDR_DATA_TABLE_ENTRY to have an array of pointers to the
  248. // downstream LDR_DATA_TABLE_ENTRY structs and not have to do any work
  249. // later on, but that's a lot of work for now; the ANSI -> UNICODE thing
  250. // has been there for ages and in practice, the paths that Fusion
  251. // redirects to have to fix in DOS_MAX_PATH_LENGTH, so we'll emit some
  252. // debug spew in the failure case, but ignore the failures.
  253. //
  254. // I started both fixes (returning status or allocating the array
  255. // at dll load time) but neither are trivial. Returning a status will just
  256. // make FreeLibrary() fail and leave the refcounts of the DLLs after the
  257. // one that failed inconsistent. Allocating the array is nontrivial
  258. // to do it the right way where the LDR_DATA_TABLE_ENTRY and the array
  259. // are allocated in a single allocation, and having the loader make more
  260. // even heap allocations seems like the wrong thing to do.
  261. //
  262. // -mgrier 11/20/2000
  263. //
  264. /*
  265. VOID
  266. LdrpReferenceLoadedDll(
  267. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry
  268. );
  269. VOID
  270. LdrpDereferenceLoadedDll(
  271. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry
  272. );
  273. VOID
  274. LdrpPinLoadedDll(
  275. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry
  276. );
  277. */
  278. #define LdrpReferenceLoadedDll(LdrDataTableEntry) LdrpUpdateLoadCount2(LdrDataTableEntry, LDRP_UPDATE_LOAD_COUNT_INCREMENT)
  279. #define LdrpDereferenceLoadedDll(LdrDataTableEntry) LdrpUpdateLoadCount2(LdrDataTableEntry, LDRP_UPDATE_LOAD_COUNT_DECREMENT)
  280. #define LdrpPinLoadedDll(LdrDataTableEntry) LdrpUpdateLoadCount2(LdrDataTableEntry, LDRP_UPDATE_LOAD_COUNT_PIN)
  281. #define LDRP_UPDATE_LOAD_COUNT_INCREMENT (1)
  282. #define LDRP_UPDATE_LOAD_COUNT_DECREMENT (2)
  283. #define LDRP_UPDATE_LOAD_COUNT_PIN (3)
  284. VOID
  285. LdrpUpdateLoadCount3(
  286. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry,
  287. IN ULONG UpdateCountHow,
  288. IN OUT PUNICODE_STRING PreAllocatedRedirectionBuffer OPTIONAL
  289. );
  290. VOID
  291. LdrpUpdateLoadCount2(
  292. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry,
  293. IN ULONG UpdateCountHow
  294. );
  295. NTSTATUS
  296. LdrpInitializeProcess(
  297. IN PCONTEXT Context OPTIONAL,
  298. IN PVOID SystemDllBase,
  299. IN PUNICODE_STRING UnicodeImageName,
  300. IN BOOLEAN UseCOR,
  301. IN BOOLEAN ImageFileOptionsPresent
  302. );
  303. VOID
  304. LdrpInitialize(
  305. IN PCONTEXT Context,
  306. IN PVOID SystemArgument1,
  307. IN PVOID SystemArgument2
  308. );
  309. VOID
  310. LdrpInsertMemoryTableEntry(
  311. IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry
  312. );
  313. NTSTATUS
  314. LdrpResolveDllName(
  315. IN PWSTR DllPath OPTIONAL,
  316. IN PWSTR DllName,
  317. IN BOOLEAN Redirected,
  318. OUT PUNICODE_STRING FullDllName,
  319. OUT PUNICODE_STRING BaseDllName,
  320. OUT PHANDLE DllFile
  321. );
  322. NTSTATUS
  323. LdrpResolveDllNameForAppPrivateRedirection(
  324. IN PCUNICODE_STRING DllName,
  325. OUT PUNICODE_STRING FullDllName
  326. );
  327. NTSTATUS
  328. LdrpCreateDllSection(
  329. IN PUNICODE_STRING FullDllName,
  330. IN HANDLE DllFile,
  331. IN PUNICODE_STRING BaseName,
  332. IN PULONG DllCharacteristics OPTIONAL,
  333. OUT PHANDLE SectionHandle
  334. );
  335. VOID
  336. LdrpInitializePathCache(
  337. VOID
  338. );
  339. PVOID
  340. LdrpFetchAddressOfEntryPoint(
  341. IN PVOID Base
  342. );
  343. NTSTATUS
  344. LdrpCheckForKnownDll(
  345. IN PWSTR DllName,
  346. OUT PUNICODE_STRING FullDllName,
  347. OUT PUNICODE_STRING BaseDllName,
  348. OUT HANDLE *Section
  349. );
  350. NTSTATUS
  351. LdrpSetProtection(
  352. IN PVOID Base,
  353. IN BOOLEAN Reset,
  354. IN BOOLEAN StaticLink
  355. );
  356. #if DBG
  357. ULONG LdrpCompareCount;
  358. ULONG LdrpSnapBypass;
  359. ULONG LdrpNormalSnap;
  360. ULONG LdrpSectionOpens;
  361. ULONG LdrpSectionCreates;
  362. ULONG LdrpSectionMaps;
  363. ULONG LdrpSectionRelocates;
  364. BOOLEAN LdrpDisplayLoadTime;
  365. LARGE_INTEGER BeginTime, InitcTime, InitbTime, IniteTime, EndTime, ElapsedTime, Interval;
  366. #endif // DBG
  367. extern BOOLEAN ShowSnaps;
  368. extern BOOLEAN ShowErrors;
  369. BOOLEAN RtlpTimoutDisable;
  370. LARGE_INTEGER RtlpTimeout;
  371. ULONG NtGlobalFlag;
  372. LIST_ENTRY RtlCriticalSectionList;
  373. RTL_CRITICAL_SECTION RtlCriticalSectionLock;
  374. BOOLEAN LdrpShutdownInProgress;
  375. extern BOOLEAN LdrpInLdrInit;
  376. extern BOOLEAN LdrpLdrDatabaseIsSetup;
  377. extern BOOLEAN LdrpVerifyDlls;
  378. extern BOOLEAN LdrpShutdownInProgress;
  379. extern BOOLEAN LdrpImageHasTls;
  380. extern BOOLEAN LdrpVerifyDlls;
  381. PLDR_DATA_TABLE_ENTRY LdrpImageEntry;
  382. LIST_ENTRY LdrpUnloadHead;
  383. BOOLEAN LdrpActiveUnloadCount;
  384. PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache;
  385. PLDR_DATA_TABLE_ENTRY LdrpLoadedDllHandleCache;
  386. ULONG LdrpFatalHardErrorCount;
  387. UNICODE_STRING LdrpDefaultPath;
  388. RTL_CRITICAL_SECTION FastPebLock;
  389. HANDLE LdrpShutdownThreadId;
  390. PLDR_DATA_TABLE_ENTRY LdrpImageEntry;
  391. ULONG LdrpNumberOfProcessors;
  392. extern UNICODE_STRING DefaultExtension;
  393. extern UNICODE_STRING User32String;
  394. extern UNICODE_STRING Kernel32String;
  395. typedef struct _LDRP_TLS_ENTRY {
  396. LIST_ENTRY Links;
  397. IMAGE_TLS_DIRECTORY Tls;
  398. } LDRP_TLS_ENTRY, *PLDRP_TLS_ENTRY;
  399. LIST_ENTRY LdrpTlsList;
  400. ULONG LdrpNumberOfTlsEntries;
  401. NTSTATUS
  402. LdrpInitializeTls(
  403. VOID
  404. );
  405. NTSTATUS
  406. LdrpAllocateTls(
  407. VOID
  408. );
  409. VOID
  410. LdrpFreeTls(
  411. VOID
  412. );
  413. VOID
  414. LdrpCallTlsInitializers(
  415. PVOID DllBase,
  416. ULONG Reason
  417. );
  418. NTSTATUS
  419. LdrpAllocateUnicodeString(
  420. OUT PUNICODE_STRING StringOut,
  421. IN USHORT Length
  422. );
  423. NTSTATUS
  424. LdrpCopyUnicodeString(
  425. OUT PUNICODE_STRING StringOut,
  426. IN PCUNICODE_STRING StringIn
  427. );
  428. VOID
  429. LdrpFreeUnicodeString(
  430. IN OUT PUNICODE_STRING String
  431. );
  432. VOID
  433. LdrpEnsureLoaderLockIsHeld(
  434. VOID
  435. );
  436. #define LDRP_LOAD_DLL_FLAG_DLL_IS_REDIRECTED (0x00000001)
  437. NTSTATUS
  438. LdrpLoadDll(
  439. IN ULONG Flags OPTIONAL,
  440. IN PWSTR DllPath OPTIONAL,
  441. IN PULONG DllCharacteristics OPTIONAL,
  442. IN PUNICODE_STRING DllName,
  443. OUT PVOID *DllHandle,
  444. IN BOOLEAN RunInitRoutines
  445. );
  446. NTSTATUS
  447. NTAPI
  448. LdrpGetProcedureAddress(
  449. IN PVOID DllHandle,
  450. IN CONST ANSI_STRING* ProcedureName OPTIONAL,
  451. IN ULONG ProcedureNumber OPTIONAL,
  452. OUT PVOID *ProcedureAddress,
  453. IN BOOLEAN RunInitRoutines
  454. );
  455. PLIST_ENTRY
  456. RtlpLockProcessHeapsList( VOID );
  457. VOID
  458. RtlpUnlockProcessHeapsList( VOID );
  459. BOOLEAN
  460. RtlpSerializeHeap(
  461. IN PVOID HeapHandle
  462. );
  463. ULONG NtdllBaseTag;
  464. #define MAKE_TAG( t ) (RTL_HEAP_MAKE_TAG( NtdllBaseTag, t ))
  465. #define CSR_TAG 0
  466. #define LDR_TAG 1
  467. #define CURDIR_TAG 2
  468. #define TLS_TAG 3
  469. #define DBG_TAG 4
  470. #define SE_TAG 5
  471. #define TEMP_TAG 6
  472. #define ATOM_TAG 7
  473. PVOID
  474. LdrpDefineDllTag(
  475. PWSTR TagName,
  476. PUSHORT TagIndex
  477. );
  478. #define LDRP_ACTIVATE_ACTIVATION_CONTEXT(LdrpDllActivateActivationContext_TableEntry) \
  479. { \
  480. RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME LdrpDllActivateActivationContext_ActivationFrame = \
  481. { sizeof(LdrpDllActivateActivationContext_ActivationFrame), \
  482. RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER \
  483. }; \
  484. \
  485. RtlActivateActivationContextUnsafeFast(&LdrpDllActivateActivationContext_ActivationFrame, LdrpDllActivateActivationContext_TableEntry->EntryPointActivationContext); \
  486. __try {
  487. #define LDRP_DEACTIVATE_ACTIVATION_CONTEXT() \
  488. } __finally { \
  489. RtlDeactivateActivationContextUnsafeFast(&LdrpDllActivateActivationContext_ActivationFrame); \
  490. } \
  491. }
  492. #if defined(_X86_)
  493. BOOLEAN
  494. LdrpCallInitRoutine(
  495. IN PDLL_INIT_ROUTINE InitRoutine,
  496. IN PVOID DllHandle,
  497. IN ULONG Reason,
  498. IN PCONTEXT Context OPTIONAL
  499. );
  500. #else
  501. #define LdrpCallInitRoutine(InitRoutine, DllHandle, Reason, Context) \
  502. (InitRoutine)((DllHandle), (Reason), (Context))
  503. #endif
  504. NTSTATUS
  505. LdrpCorValidateImage(
  506. IN OUT PVOID *pImageBase,
  507. IN LPWSTR ImageName
  508. );
  509. VOID
  510. LdrpCorUnloadImage(
  511. IN PVOID ImageBase
  512. );
  513. VOID
  514. LdrpCorReplaceStartContext(
  515. IN PCONTEXT Context
  516. );
  517. typedef VOID (*PCOR_EXE_MAIN)(VOID);
  518. extern PCOR_EXE_MAIN CorExeMain;
  519. VOID
  520. LdrpSendDllUnloadedNotifications(
  521. PLDR_DATA_TABLE_ENTRY Entry,
  522. ULONG Flags
  523. );
  524. VOID
  525. LdrpSendDllLoadedNotifications(
  526. PLDR_DATA_TABLE_ENTRY Entry,
  527. ULONG Flags
  528. );
  529. //
  530. // The prototypes for the shim engine callback
  531. //
  532. typedef void (*PFNSE_INSTALLBEFOREINIT)(PUNICODE_STRING UnicodeImageName,
  533. PVOID pShimExeData);
  534. typedef BOOLEAN (*PFNSE_INSTALLAFTERINIT)(PUNICODE_STRING UnicodeImageName,
  535. PVOID pShimExeData);
  536. typedef void (*PFNSE_DLLLOADED)(PLDR_DATA_TABLE_ENTRY LdrEntry);
  537. typedef void (*PFNSE_DLLUNLOADED)(PLDR_DATA_TABLE_ENTRY LdrEntry);
  538. typedef void (*PFNSE_GETPROCADDRESS)(PVOID* pProcAddress);
  539. typedef int (*PFNSE_ISSHIMDLL)(PVOID pDllBase);
  540. typedef void (*PFNSE_PROCESSDYING)(void);
  541. //
  542. // Private function from ntos\rtl\stktrace.c needed to pickup the real address
  543. // of a stack trace given an index.
  544. //
  545. PVOID
  546. RtlpGetStackTraceAddress (
  547. USHORT Index
  548. );
  549. //
  550. // Function defined in ntos\rtl\stktrace.c needed to speedup
  551. // RtlCaptureStackContext on x86.
  552. //
  553. VOID
  554. RtlpStkMarkDllRange (
  555. PLDR_DATA_TABLE_ENTRY DllEntry
  556. );
  557. VOID
  558. RtlpCheckForCriticalSectionsInMemoryRange(
  559. IN PVOID StartAddress,
  560. IN SIZE_T RegionSize,
  561. IN PVOID Information
  562. );
  563. //
  564. // resource.c
  565. //
  566. extern BOOLEAN RtlpCriticalSectionVerifier;
  567. BOOLEAN
  568. RtlpCreateCriticalSectionSem(
  569. IN PRTL_CRITICAL_SECTION CriticalSection
  570. );
  571. //
  572. // Application verifier
  573. //
  574. #include "avrfp.h"
  575. #endif // _LDRP_