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.

3073 lines
79 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. nturtl.h
  5. Abstract:
  6. Include file for NT runtime routines that are callable by only
  7. user mode code in various NT subsystems.
  8. Author:
  9. Steve Wood (stevewo) 10-Aug-1989
  10. Environment:
  11. These routines are dynamically linked in the caller's executable and
  12. are callable only from user mode. They make use of Nt system
  13. services.
  14. Revision History:
  15. --*/
  16. #ifndef _NTURTL_
  17. #define _NTURTL_
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if defined (_MSC_VER)
  25. #if ( _MSC_VER >= 800 )
  26. #pragma warning(disable:4514)
  27. #if _MSC_VER >= 1200
  28. #pragma warning(push)
  29. #endif
  30. #pragma warning(disable:4001)
  31. #pragma warning(disable:4201)
  32. #pragma warning(disable:4214)
  33. #endif
  34. #if (_MSC_VER >= 1020)
  35. #pragma once
  36. #endif
  37. #endif
  38. //
  39. // CriticalSection function definitions
  40. //
  41. // begin_winnt
  42. typedef struct _RTL_CRITICAL_SECTION_DEBUG {
  43. USHORT Type;
  44. USHORT CreatorBackTraceIndex;
  45. struct _RTL_CRITICAL_SECTION *CriticalSection;
  46. LIST_ENTRY ProcessLocksList;
  47. ULONG EntryCount;
  48. ULONG ContentionCount;
  49. ULONG Spare[ 2 ];
  50. } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
  51. #define RTL_CRITSECT_TYPE 0
  52. #define RTL_RESOURCE_TYPE 1
  53. typedef struct _RTL_CRITICAL_SECTION {
  54. PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
  55. //
  56. // The following three fields control entering and exiting the critical
  57. // section for the resource
  58. //
  59. LONG LockCount;
  60. LONG RecursionCount;
  61. HANDLE OwningThread; // from the thread's ClientId->UniqueThread
  62. HANDLE LockSemaphore;
  63. ULONG_PTR SpinCount; // force size on 64-bit systems when packed
  64. } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
  65. // end_winnt
  66. //
  67. // These are needed for the debugger and WOW64.
  68. //
  69. typedef struct _RTL_CRITICAL_SECTION_DEBUG32 {
  70. USHORT Type;
  71. USHORT CreatorBackTraceIndex;
  72. ULONG CriticalSection;
  73. LIST_ENTRY32 ProcessLocksList;
  74. ULONG EntryCount;
  75. ULONG ContentionCount;
  76. ULONG Spare[ 2 ];
  77. } RTL_CRITICAL_SECTION_DEBUG32, *PRTL_CRITICAL_SECTION_DEBUG32, RTL_RESOURCE_DEBUG32, *PRTL_RESOURCE_DEBUG32;
  78. typedef struct _RTL_CRITICAL_SECTION_DEBUG64 {
  79. USHORT Type;
  80. USHORT CreatorBackTraceIndex;
  81. ULONG64 CriticalSection;
  82. LIST_ENTRY64 ProcessLocksList;
  83. ULONG EntryCount;
  84. ULONG ContentionCount;
  85. ULONG Spare[ 2 ];
  86. } RTL_CRITICAL_SECTION_DEBUG64, *PRTL_CRITICAL_SECTION_DEBUG64, RTL_RESOURCE_DEBUG64, *PRTL_RESOURCE_DEBUG64;
  87. typedef struct _RTL_CRITICAL_SECTION32 {
  88. ULONG DebugInfo;
  89. LONG LockCount;
  90. LONG RecursionCount;
  91. ULONG OwningThread;
  92. ULONG LockSemaphore;
  93. ULONG SpinCount;
  94. } RTL_CRITICAL_SECTION32, *PRTL_CRITICAL_SECTION32;
  95. typedef struct _RTL_CRITICAL_SECTION64 {
  96. ULONG64 DebugInfo;
  97. LONG LockCount;
  98. LONG RecursionCount;
  99. ULONG64 OwningThread;
  100. ULONG64 LockSemaphore;
  101. ULONG64 SpinCount;
  102. } RTL_CRITICAL_SECTION64, *PRTL_CRITICAL_SECTION64;
  103. //
  104. // Shared resource function definitions
  105. //
  106. typedef struct _RTL_RESOURCE {
  107. //
  108. // The following field controls entering and exiting the critical
  109. // section for the resource
  110. //
  111. RTL_CRITICAL_SECTION CriticalSection;
  112. //
  113. // The following four fields indicate the number of both shared or
  114. // exclusive waiters
  115. //
  116. HANDLE SharedSemaphore;
  117. ULONG NumberOfWaitingShared;
  118. HANDLE ExclusiveSemaphore;
  119. ULONG NumberOfWaitingExclusive;
  120. //
  121. // The following indicates the current state of the resource
  122. //
  123. // <0 the resource is acquired for exclusive access with the
  124. // absolute value indicating the number of recursive accesses
  125. // to the resource
  126. //
  127. // 0 the resource is available
  128. //
  129. // >0 the resource is acquired for shared access with the
  130. // value indicating the number of shared accesses to the resource
  131. //
  132. LONG NumberOfActive;
  133. HANDLE ExclusiveOwnerThread;
  134. ULONG Flags; // See RTL_RESOURCE_FLAG_ equates below.
  135. PRTL_RESOURCE_DEBUG DebugInfo;
  136. } RTL_RESOURCE, *PRTL_RESOURCE;
  137. #define RTL_RESOURCE_FLAG_LONG_TERM ((ULONG) 0x00000001)
  138. NTSYSAPI
  139. NTSTATUS
  140. NTAPI
  141. RtlEnterCriticalSection(
  142. PRTL_CRITICAL_SECTION CriticalSection
  143. );
  144. NTSYSAPI
  145. NTSTATUS
  146. NTAPI
  147. RtlLeaveCriticalSection(
  148. PRTL_CRITICAL_SECTION CriticalSection
  149. );
  150. NTSYSAPI
  151. BOOLEAN
  152. NTAPI
  153. RtlTryEnterCriticalSection(
  154. PRTL_CRITICAL_SECTION CriticalSection
  155. );
  156. NTSYSAPI
  157. NTSTATUS
  158. NTAPI
  159. RtlInitializeCriticalSection(
  160. PRTL_CRITICAL_SECTION CriticalSection
  161. );
  162. NTSYSAPI
  163. VOID
  164. NTAPI
  165. RtlEnableEarlyCriticalSectionEventCreation(
  166. VOID
  167. );
  168. NTSYSAPI
  169. NTSTATUS
  170. NTAPI
  171. RtlInitializeCriticalSectionAndSpinCount(
  172. PRTL_CRITICAL_SECTION CriticalSection,
  173. ULONG SpinCount
  174. );
  175. NTSYSAPI
  176. ULONG
  177. NTAPI
  178. RtlSetCriticalSectionSpinCount(
  179. PRTL_CRITICAL_SECTION CriticalSection,
  180. ULONG SpinCount
  181. );
  182. NTSYSAPI
  183. NTSTATUS
  184. NTAPI
  185. RtlDeleteCriticalSection(
  186. PRTL_CRITICAL_SECTION CriticalSection
  187. );
  188. NTSYSAPI
  189. VOID
  190. NTAPI
  191. RtlInitializeResource(
  192. PRTL_RESOURCE Resource
  193. );
  194. NTSYSAPI
  195. BOOLEAN
  196. NTAPI
  197. RtlAcquireResourceShared(
  198. PRTL_RESOURCE Resource,
  199. BOOLEAN Wait
  200. );
  201. NTSYSAPI
  202. BOOLEAN
  203. NTAPI
  204. RtlAcquireResourceExclusive(
  205. PRTL_RESOURCE Resource,
  206. BOOLEAN Wait
  207. );
  208. NTSYSAPI
  209. VOID
  210. NTAPI
  211. RtlReleaseResource(
  212. PRTL_RESOURCE Resource
  213. );
  214. NTSYSAPI
  215. VOID
  216. NTAPI
  217. RtlConvertSharedToExclusive(
  218. PRTL_RESOURCE Resource
  219. );
  220. NTSYSAPI
  221. VOID
  222. NTAPI
  223. RtlConvertExclusiveToShared(
  224. PRTL_RESOURCE Resource
  225. );
  226. NTSYSAPI
  227. VOID
  228. NTAPI
  229. RtlDeleteResource (
  230. PRTL_RESOURCE Resource
  231. );
  232. NTSYSAPI
  233. VOID
  234. NTAPI
  235. RtlCheckForOrphanedCriticalSections(
  236. IN HANDLE hThread
  237. );
  238. //
  239. // Application verifier types needed by provider dlls
  240. //
  241. // begin_winnt
  242. typedef VOID (* RTL_VERIFIER_DLL_LOAD_CALLBACK) (
  243. PWSTR DllName,
  244. PVOID DllBase,
  245. SIZE_T DllSize,
  246. PVOID Reserved
  247. );
  248. typedef VOID (* RTL_VERIFIER_DLL_UNLOAD_CALLBACK) (
  249. PWSTR DllName,
  250. PVOID DllBase,
  251. SIZE_T DllSize,
  252. PVOID Reserved
  253. );
  254. typedef struct _RTL_VERIFIER_THUNK_DESCRIPTOR {
  255. PCHAR ThunkName;
  256. PVOID ThunkOldAddress;
  257. PVOID ThunkNewAddress;
  258. } RTL_VERIFIER_THUNK_DESCRIPTOR, *PRTL_VERIFIER_THUNK_DESCRIPTOR;
  259. typedef struct _RTL_VERIFIER_DLL_DESCRIPTOR {
  260. PWCHAR DllName;
  261. ULONG DllFlags;
  262. PVOID DllAddress;
  263. PRTL_VERIFIER_THUNK_DESCRIPTOR DllThunks;
  264. } RTL_VERIFIER_DLL_DESCRIPTOR, *PRTL_VERIFIER_DLL_DESCRIPTOR;
  265. typedef struct _RTL_VERIFIER_PROVIDER_DESCRIPTOR {
  266. //
  267. // Filled by verifier provider DLL
  268. //
  269. ULONG Length;
  270. PRTL_VERIFIER_DLL_DESCRIPTOR ProviderDlls;
  271. RTL_VERIFIER_DLL_LOAD_CALLBACK ProviderDllLoadCallback;
  272. RTL_VERIFIER_DLL_UNLOAD_CALLBACK ProviderDllUnloadCallback;
  273. //
  274. // Filled by verifier engine
  275. //
  276. PWSTR VerifierImage;
  277. ULONG VerifierFlags;
  278. ULONG VerifierDebug;
  279. } RTL_VERIFIER_PROVIDER_DESCRIPTOR, *PRTL_VERIFIER_PROVIDER_DESCRIPTOR;
  280. //
  281. // Application verifier standard flags
  282. //
  283. #define RTL_VRF_FLG_FULL_PAGE_HEAP 0x0001
  284. #define RTL_VRF_FLG_LOCK_CHECKS 0x0002
  285. #define RTL_VRF_FLG_HANDLE_CHECKS 0x0004
  286. #define RTL_VRF_FLG_STACK_CHECKS 0x0008
  287. #define RTL_VRF_FLG_APPCOMPAT_CHECKS 0x0010
  288. //
  289. // Application verifier standard stop codes
  290. //
  291. #define APPLICATION_VERIFIER_INTERNAL_ERROR 0x80000000
  292. #define APPLICATION_VERIFIER_INTERNAL_WARNING 0x40000000
  293. #define APPLICATION_VERIFIER_NO_BREAK 0x20000000
  294. #define APPLICATION_VERIFIER_RESERVED_BIT_28 0x10000000
  295. #define APPLICATION_VERIFIER_UNKNOWN_ERROR 0x0001
  296. #define APPLICATION_VERIFIER_ACCESS_VIOLATION 0x0002
  297. #define APPLICATION_VERIFIER_UNSYNCHRONIZED_ACCESS 0x0003
  298. #define APPLICATION_VERIFIER_EXTREME_SIZE_REQUEST 0x0004
  299. #define APPLICATION_VERIFIER_BAD_HEAP_HANDLE 0x0005
  300. #define APPLICATION_VERIFIER_SWITCHED_HEAP_HANDLE 0x0006
  301. #define APPLICATION_VERIFIER_DOUBLE_FREE 0x0007
  302. #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK 0x0008
  303. #define APPLICATION_VERIFIER_DESTROY_PROCESS_HEAP 0x0009
  304. #define APPLICATION_VERIFIER_UNEXPECTED_EXCEPTION 0x000A
  305. #define APPLICATION_VERIFIER_STACK_OVERFLOW 0x000B
  306. #define APPLICATION_VERIFIER_TERMINATE_THREAD_CALL 0x0100
  307. #define APPLICATION_VERIFIER_EXIT_THREAD_OWNS_LOCK 0x0200
  308. #define APPLICATION_VERIFIER_LOCK_IN_UNLOADED_DLL 0x0201
  309. #define APPLICATION_VERIFIER_LOCK_IN_FREED_HEAP 0x0202
  310. #define APPLICATION_VERIFIER_LOCK_DOUBLE_INITIALIZE 0x0203
  311. #define APPLICATION_VERIFIER_LOCK_IN_FREED_MEMORY 0x0204
  312. #define APPLICATION_VERIFIER_LOCK_CORRUPTED 0x0205
  313. #define APPLICATION_VERIFIER_LOCK_INVALID_OWNER 0x0206
  314. #define APPLICATION_VERIFIER_LOCK_INVALID_RECURSION_COUNT 0x0207
  315. #define APPLICATION_VERIFIER_LOCK_INVALID_LOCK_COUNT 0x0208
  316. #define APPLICATION_VERIFIER_LOCK_OVER_RELEASED 0x0209
  317. #define APPLICATION_VERIFIER_LOCK_NOT_INITIALIZED 0x0210
  318. #define APPLICATION_VERIFIER_INVALID_HANDLE 0x0300
  319. #define VERIFIER_STOP(Code, Msg, P1, S1, P2, S2, P3, S3, P4, S4) { \
  320. RtlApplicationVerifierStop ((Code), \
  321. (Msg), \
  322. (ULONG_PTR)(P1),(S1), \
  323. (ULONG_PTR)(P2),(S2), \
  324. (ULONG_PTR)(P3),(S3), \
  325. (ULONG_PTR)(P4),(S4)); \
  326. }
  327. VOID
  328. RtlApplicationVerifierStop (
  329. ULONG_PTR Code,
  330. PCHAR Message,
  331. ULONG_PTR Param1, PCHAR Description1,
  332. ULONG_PTR Param2, PCHAR Description2,
  333. ULONG_PTR Param3, PCHAR Description3,
  334. ULONG_PTR Param4, PCHAR Description4
  335. );
  336. // end_winnt
  337. //
  338. // VectoredExceptionHandler Stuff
  339. //
  340. // begin_winnt
  341. typedef LONG (NTAPI *PVECTORED_EXCEPTION_HANDLER)(
  342. struct _EXCEPTION_POINTERS *ExceptionInfo
  343. );
  344. // end_winnt
  345. NTSYSAPI
  346. BOOLEAN
  347. NTAPI
  348. RtlCallVectoredExceptionHandlers(
  349. IN PEXCEPTION_RECORD ExceptionRecord,
  350. IN PCONTEXT ContextRecord
  351. );
  352. NTSYSAPI
  353. PVOID
  354. NTAPI
  355. RtlAddVectoredExceptionHandler(
  356. IN ULONG FirstHandler,
  357. IN PVECTORED_EXCEPTION_HANDLER VectoredHandler
  358. );
  359. NTSYSAPI
  360. ULONG
  361. NTAPI
  362. RtlRemoveVectoredExceptionHandler(
  363. IN PVOID VectoredHandlerHandle
  364. );
  365. //
  366. // Current Directory Stuff
  367. //
  368. typedef struct _RTL_RELATIVE_NAME {
  369. STRING RelativeName;
  370. HANDLE ContainingDirectory;
  371. } RTL_RELATIVE_NAME, *PRTL_RELATIVE_NAME;
  372. typedef enum _RTL_PATH_TYPE {
  373. RtlPathTypeUnknown, // 0
  374. RtlPathTypeUncAbsolute, // 1
  375. RtlPathTypeDriveAbsolute, // 2
  376. RtlPathTypeDriveRelative, // 3
  377. RtlPathTypeRooted, // 4
  378. RtlPathTypeRelative, // 5
  379. RtlPathTypeLocalDevice, // 6
  380. RtlPathTypeRootLocalDevice // 7
  381. } RTL_PATH_TYPE;
  382. NTSYSAPI
  383. RTL_PATH_TYPE
  384. NTAPI
  385. RtlDetermineDosPathNameType_U(
  386. PCWSTR DosFileName
  387. );
  388. NTSYSAPI
  389. ULONG
  390. NTAPI
  391. RtlIsDosDeviceName_U(
  392. PWSTR DosFileName
  393. );
  394. NTSYSAPI
  395. ULONG
  396. NTAPI
  397. RtlGetFullPathName_U(
  398. PCWSTR lpFileName,
  399. ULONG nBufferLength,
  400. PWSTR lpBuffer,
  401. PWSTR *lpFilePart
  402. );
  403. NTSYSAPI
  404. ULONG
  405. NTAPI
  406. RtlGetCurrentDirectory_U(
  407. ULONG nBufferLength,
  408. PWSTR lpBuffer
  409. );
  410. NTSYSAPI
  411. NTSTATUS
  412. NTAPI
  413. RtlSetCurrentDirectory_U(
  414. IN PUNICODE_STRING PathName
  415. );
  416. NTSYSAPI
  417. ULONG
  418. NTAPI
  419. RtlGetLongestNtPathLength( VOID );
  420. NTSYSAPI
  421. BOOLEAN
  422. NTAPI
  423. RtlDosPathNameToNtPathName_U(
  424. PCWSTR DosFileName,
  425. PUNICODE_STRING NtFileName,
  426. PWSTR *FilePart OPTIONAL,
  427. PRTL_RELATIVE_NAME RelativeName OPTIONAL
  428. );
  429. NTSYSAPI
  430. ULONG
  431. NTAPI
  432. RtlDosSearchPath_U(
  433. IN PCWSTR lpPath,
  434. IN PCWSTR lpFileName,
  435. IN PCWSTR lpExtension,
  436. ULONG nBufferLength,
  437. PWSTR lpBuffer,
  438. PWSTR *lpFilePart
  439. );
  440. #define RTL_DOS_SEARCH_PATH_FLAG_APPLY_ISOLATION_REDIRECTION (0x00000001)
  441. // Flags to preserve Win32 SearchPathW() semantics in the ntdll implementation:
  442. #define RTL_DOS_SEARCH_PATH_FLAG_DISALLOW_DOT_RELATIVE_PATH_SEARCH (0x00000002)
  443. #define RTL_DOS_SEARCH_PATH_FLAG_APPLY_DEFAULT_EXTENSION_WHEN_NOT_RELATIVE_PATH_EVEN_IF_FILE_HAS_EXTENSION (0x00000004)
  444. NTSYSAPI
  445. NTSTATUS
  446. NTAPI
  447. RtlDosSearchPath_Ustr(
  448. IN ULONG Flags,
  449. IN PCUNICODE_STRING Path,
  450. IN PCUNICODE_STRING FileName,
  451. IN PCUNICODE_STRING DefaultExtension OPTIONAL,
  452. OUT PUNICODE_STRING StaticString OPTIONAL,
  453. OUT PUNICODE_STRING DynamicString OPTIONAL,
  454. OUT PCUNICODE_STRING *FullFileNameOut OPTIONAL,
  455. OUT SIZE_T *FilePartPrefixCch OPTIONAL,
  456. OUT SIZE_T *BytesRequired OPTIONAL
  457. );
  458. NTSYSAPI
  459. BOOLEAN
  460. NTAPI
  461. RtlDoesFileExists_U(
  462. PCWSTR FileName
  463. );
  464. // input flags
  465. #define RTL_DOS_APPLY_FILE_REDIRECTION_USTR_FLAG_RESPECT_DOT_LOCAL (1)
  466. // output flags
  467. #define RTL_DOS_APPLY_FILE_REDIRECTION_USTR_OUTFLAG_DOT_LOCAL_REDIRECT (1)
  468. #define RTL_DOS_APPLY_FILE_REDIRECTION_USTR_OUTFLAG_ACTCTX_REDIRECT (2)
  469. NTSYSAPI
  470. NTSTATUS
  471. NTAPI
  472. RtlDosApplyFileIsolationRedirection_Ustr(
  473. IN ULONG Flags,
  474. IN PCUNICODE_STRING FileName,
  475. IN PCUNICODE_STRING DefaultExtension OPTIONAL,
  476. IN PUNICODE_STRING PreAllocatedString OPTIONAL,
  477. OUT PUNICODE_STRING DynamicallyAllocatedString OPTIONAL,
  478. OUT PUNICODE_STRING *FullPath OPTIONAL,
  479. OUT ULONG * OutFlags,
  480. OUT SIZE_T *FilePartPrefixCch OPTIONAL,
  481. OUT SIZE_T *BytesRequired OPTIONAL
  482. );
  483. NTSYSAPI
  484. NTSTATUS
  485. NTAPI
  486. RtlComputePrivatizedDllName_U(
  487. IN PCUNICODE_STRING DllName,
  488. IN OUT PUNICODE_STRING NewDllNameUnderImageDir,
  489. IN OUT PUNICODE_STRING NewDllNameUnderLocalDir
  490. );
  491. NTSYSAPI
  492. NTSTATUS
  493. NTAPI
  494. RtlInitializeProfile (
  495. BOOLEAN KernelToo
  496. );
  497. NTSYSAPI
  498. NTSTATUS
  499. NTAPI
  500. RtlStartProfile (
  501. VOID
  502. );
  503. NTSYSAPI
  504. NTSTATUS
  505. NTAPI
  506. RtlStopProfile (
  507. VOID
  508. );
  509. NTSYSAPI
  510. NTSTATUS
  511. NTAPI
  512. RtlAnalyzeProfile (
  513. VOID
  514. );
  515. //
  516. // User mode only security Rtl routines
  517. //
  518. //
  519. // Structure to hold information about an ACE to be created
  520. //
  521. #ifdef _MAC
  522. #pragma warning( disable : 4121)
  523. #endif
  524. typedef struct {
  525. UCHAR AceType;
  526. UCHAR InheritFlags;
  527. UCHAR AceFlags;
  528. ACCESS_MASK Mask;
  529. PSID *Sid;
  530. } RTL_ACE_DATA, *PRTL_ACE_DATA;
  531. #ifdef _MAC
  532. #pragma warning( default : 4121 )
  533. #endif
  534. NTSYSAPI
  535. NTSTATUS
  536. NTAPI
  537. RtlNewSecurityObject(
  538. PSECURITY_DESCRIPTOR ParentDescriptor,
  539. PSECURITY_DESCRIPTOR CreatorDescriptor,
  540. PSECURITY_DESCRIPTOR * NewDescriptor,
  541. BOOLEAN IsDirectoryObject,
  542. HANDLE Token,
  543. PGENERIC_MAPPING GenericMapping
  544. );
  545. NTSYSAPI
  546. NTSTATUS
  547. NTAPI
  548. RtlNewSecurityObjectEx (
  549. IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
  550. IN PSECURITY_DESCRIPTOR CreatorDescriptor OPTIONAL,
  551. OUT PSECURITY_DESCRIPTOR * NewDescriptor,
  552. IN GUID *ObjectType OPTIONAL,
  553. IN BOOLEAN IsDirectoryObject,
  554. IN ULONG AutoInheritFlags,
  555. IN HANDLE Token,
  556. IN PGENERIC_MAPPING GenericMapping
  557. );
  558. NTSYSAPI
  559. NTSTATUS
  560. NTAPI
  561. RtlNewSecurityObjectWithMultipleInheritance (
  562. IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
  563. IN PSECURITY_DESCRIPTOR CreatorDescriptor OPTIONAL,
  564. OUT PSECURITY_DESCRIPTOR * NewDescriptor,
  565. IN GUID **pObjectType OPTIONAL,
  566. IN ULONG GuidCount,
  567. IN BOOLEAN IsDirectoryObject,
  568. IN ULONG AutoInheritFlags,
  569. IN HANDLE Token,
  570. IN PGENERIC_MAPPING GenericMapping
  571. );
  572. // Values for AutoInheritFlags
  573. // begin_winnt
  574. #define SEF_DACL_AUTO_INHERIT 0x01
  575. #define SEF_SACL_AUTO_INHERIT 0x02
  576. #define SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT 0x04
  577. #define SEF_AVOID_PRIVILEGE_CHECK 0x08
  578. #define SEF_AVOID_OWNER_CHECK 0x10
  579. #define SEF_DEFAULT_OWNER_FROM_PARENT 0x20
  580. #define SEF_DEFAULT_GROUP_FROM_PARENT 0x40
  581. // end_winnt
  582. NTSTATUS
  583. RtlConvertToAutoInheritSecurityObject(
  584. IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
  585. IN PSECURITY_DESCRIPTOR CurrentSecurityDescriptor,
  586. OUT PSECURITY_DESCRIPTOR *NewSecurityDescriptor,
  587. IN GUID *ObjectType OPTIONAL,
  588. IN BOOLEAN IsDirectoryObject,
  589. IN PGENERIC_MAPPING GenericMapping
  590. );
  591. NTSYSAPI
  592. NTSTATUS
  593. NTAPI
  594. RtlSetSecurityObject (
  595. SECURITY_INFORMATION SecurityInformation,
  596. PSECURITY_DESCRIPTOR ModificationDescriptor,
  597. PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  598. PGENERIC_MAPPING GenericMapping,
  599. HANDLE Token
  600. );
  601. NTSYSAPI
  602. NTSTATUS
  603. NTAPI
  604. RtlSetSecurityObjectEx (
  605. IN SECURITY_INFORMATION SecurityInformation,
  606. IN PSECURITY_DESCRIPTOR ModificationDescriptor,
  607. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  608. IN ULONG AutoInheritFlags,
  609. IN PGENERIC_MAPPING GenericMapping,
  610. IN HANDLE Token OPTIONAL
  611. );
  612. NTSYSAPI
  613. NTSTATUS
  614. NTAPI
  615. RtlQuerySecurityObject (
  616. PSECURITY_DESCRIPTOR ObjectDescriptor,
  617. SECURITY_INFORMATION SecurityInformation,
  618. PSECURITY_DESCRIPTOR ResultantDescriptor,
  619. ULONG DescriptorLength,
  620. PULONG ReturnLength
  621. );
  622. NTSYSAPI
  623. NTSTATUS
  624. NTAPI
  625. RtlDeleteSecurityObject (
  626. PSECURITY_DESCRIPTOR * ObjectDescriptor
  627. );
  628. NTSYSAPI
  629. NTSTATUS
  630. NTAPI
  631. RtlNewInstanceSecurityObject(
  632. BOOLEAN ParentDescriptorChanged,
  633. BOOLEAN CreatorDescriptorChanged,
  634. PLUID OldClientTokenModifiedId,
  635. PLUID NewClientTokenModifiedId,
  636. PSECURITY_DESCRIPTOR ParentDescriptor,
  637. PSECURITY_DESCRIPTOR CreatorDescriptor,
  638. PSECURITY_DESCRIPTOR * NewDescriptor,
  639. BOOLEAN IsDirectoryObject,
  640. HANDLE Token,
  641. PGENERIC_MAPPING GenericMapping
  642. );
  643. NTSYSAPI
  644. NTSTATUS
  645. NTAPI
  646. RtlCopySecurityDescriptor(
  647. PSECURITY_DESCRIPTOR InputSecurityDescriptor,
  648. PSECURITY_DESCRIPTOR *OutputSecurityDescriptor
  649. );
  650. //
  651. // list canonicalization
  652. //
  653. NTSYSAPI
  654. NTSTATUS
  655. NTAPI
  656. RtlConvertUiListToApiList(
  657. PUNICODE_STRING UiList OPTIONAL,
  658. PUNICODE_STRING ApiList,
  659. BOOLEAN BlankIsDelimiter
  660. );
  661. NTSYSAPI
  662. NTSTATUS
  663. NTAPI
  664. RtlCreateAndSetSD(
  665. IN PRTL_ACE_DATA AceData,
  666. IN ULONG AceCount,
  667. IN PSID OwnerSid OPTIONAL,
  668. IN PSID GroupSid OPTIONAL,
  669. OUT PSECURITY_DESCRIPTOR *NewDescriptor
  670. );
  671. NTSYSAPI
  672. NTSTATUS
  673. NTAPI
  674. RtlCreateUserSecurityObject(
  675. IN PRTL_ACE_DATA AceData,
  676. IN ULONG AceCount,
  677. IN PSID OwnerSid,
  678. IN PSID GroupSid,
  679. IN BOOLEAN IsDirectoryObject,
  680. IN PGENERIC_MAPPING GenericMapping,
  681. OUT PSECURITY_DESCRIPTOR *NewDescriptor
  682. );
  683. NTSYSAPI
  684. NTSTATUS
  685. NTAPI
  686. RtlDefaultNpAcl(
  687. OUT PACL * pAcl
  688. );
  689. //
  690. // Per-Thread Curdir Support
  691. //
  692. typedef struct _RTL_PERTHREAD_CURDIR {
  693. PRTL_DRIVE_LETTER_CURDIR CurrentDirectories;
  694. PUNICODE_STRING ImageName;
  695. PVOID Environment;
  696. } RTL_PERTHREAD_CURDIR, *PRTL_PERTHREAD_CURDIR;
  697. #define RtlAssociatePerThreadCurdir(BLOCK,CURRENTDIRECTORIES,IMAGENAME,ENVIRONMENT)\
  698. (BLOCK)->CurrentDirectories = (CURRENTDIRECTORIES); \
  699. (BLOCK)->ImageName = (IMAGENAME); \
  700. (BLOCK)->Environment = (ENVIRONMENT); \
  701. NtCurrentTeb()->NtTib.SubSystemTib = (PVOID)(BLOCK) \
  702. #define RtlDisAssociatePerThreadCurdir() \
  703. NtCurrentTeb()->NtTib.SubSystemTib = NULL;
  704. #define RtlGetPerThreadCurdir() \
  705. ((PRTL_PERTHREAD_CURDIR)(NtCurrentTeb()->NtTib.SubSystemTib))
  706. //
  707. // See NTRTL.H for heap functions availble to both kernel and user mode code.
  708. //
  709. #define RtlProcessHeap() (NtCurrentPeb()->ProcessHeap)
  710. NTSYSAPI
  711. BOOLEAN
  712. NTAPI
  713. RtlLockHeap(
  714. IN PVOID HeapHandle
  715. );
  716. NTSYSAPI
  717. BOOLEAN
  718. NTAPI
  719. RtlUnlockHeap(
  720. IN PVOID HeapHandle
  721. );
  722. NTSYSAPI
  723. PVOID
  724. NTAPI
  725. RtlReAllocateHeap(
  726. IN PVOID HeapHandle,
  727. IN ULONG Flags,
  728. IN PVOID BaseAddress,
  729. IN SIZE_T Size
  730. );
  731. NTSYSAPI
  732. BOOLEAN
  733. NTAPI
  734. RtlGetUserInfoHeap(
  735. IN PVOID HeapHandle,
  736. IN ULONG Flags,
  737. IN PVOID BaseAddress,
  738. OUT PVOID *UserValue OPTIONAL,
  739. OUT PULONG UserFlags OPTIONAL
  740. );
  741. NTSYSAPI
  742. BOOLEAN
  743. NTAPI
  744. RtlSetUserValueHeap(
  745. IN PVOID HeapHandle,
  746. IN ULONG Flags,
  747. IN PVOID BaseAddress,
  748. IN PVOID UserValue
  749. );
  750. NTSYSAPI
  751. BOOLEAN
  752. NTAPI
  753. RtlSetUserFlagsHeap(
  754. IN PVOID HeapHandle,
  755. IN ULONG Flags,
  756. IN PVOID BaseAddress,
  757. IN ULONG UserFlagsReset,
  758. IN ULONG UserFlagsSet
  759. );
  760. typedef struct _RTL_HEAP_TAG_INFO {
  761. ULONG NumberOfAllocations;
  762. ULONG NumberOfFrees;
  763. SIZE_T BytesAllocated;
  764. } RTL_HEAP_TAG_INFO, *PRTL_HEAP_TAG_INFO;
  765. NTSYSAPI
  766. ULONG
  767. NTAPI
  768. RtlCreateTagHeap(
  769. IN PVOID HeapHandle,
  770. IN ULONG Flags,
  771. IN PWSTR TagPrefix OPTIONAL,
  772. IN PWSTR TagNames
  773. );
  774. #define RTL_HEAP_MAKE_TAG HEAP_MAKE_TAG_FLAGS
  775. NTSYSAPI
  776. PWSTR
  777. NTAPI
  778. RtlQueryTagHeap(
  779. IN PVOID HeapHandle,
  780. IN ULONG Flags,
  781. IN USHORT TagIndex,
  782. IN BOOLEAN ResetCounters,
  783. OUT PRTL_HEAP_TAG_INFO TagInfo OPTIONAL
  784. );
  785. NTSYSAPI
  786. NTSTATUS
  787. NTAPI
  788. RtlExtendHeap(
  789. IN PVOID HeapHandle,
  790. IN ULONG Flags,
  791. IN PVOID Base,
  792. IN SIZE_T Size
  793. );
  794. NTSYSAPI
  795. SIZE_T
  796. NTAPI
  797. RtlCompactHeap(
  798. IN PVOID HeapHandle,
  799. IN ULONG Flags
  800. );
  801. NTSYSAPI
  802. BOOLEAN
  803. NTAPI
  804. RtlValidateHeap(
  805. IN PVOID HeapHandle,
  806. IN ULONG Flags,
  807. IN PVOID BaseAddress
  808. );
  809. NTSYSAPI
  810. BOOLEAN
  811. NTAPI
  812. RtlValidateProcessHeaps( VOID );
  813. NTSYSAPI
  814. ULONG
  815. NTAPI
  816. RtlGetProcessHeaps(
  817. ULONG NumberOfHeaps,
  818. PVOID *ProcessHeaps
  819. );
  820. typedef
  821. NTSTATUS (NTAPI * PRTL_ENUM_HEAPS_ROUTINE)(
  822. PVOID HeapHandle,
  823. PVOID Parameter
  824. );
  825. NTSYSAPI
  826. NTSTATUS
  827. NTAPI
  828. RtlEnumProcessHeaps(
  829. PRTL_ENUM_HEAPS_ROUTINE EnumRoutine,
  830. PVOID Parameter
  831. );
  832. typedef struct _RTL_HEAP_USAGE_ENTRY {
  833. struct _RTL_HEAP_USAGE_ENTRY *Next;
  834. PVOID Address;
  835. SIZE_T Size;
  836. USHORT AllocatorBackTraceIndex;
  837. USHORT TagIndex;
  838. } RTL_HEAP_USAGE_ENTRY, *PRTL_HEAP_USAGE_ENTRY;
  839. typedef struct _RTL_HEAP_USAGE {
  840. ULONG Length;
  841. SIZE_T BytesAllocated;
  842. SIZE_T BytesCommitted;
  843. SIZE_T BytesReserved;
  844. SIZE_T BytesReservedMaximum;
  845. PRTL_HEAP_USAGE_ENTRY Entries;
  846. PRTL_HEAP_USAGE_ENTRY AddedEntries;
  847. PRTL_HEAP_USAGE_ENTRY RemovedEntries;
  848. ULONG_PTR Reserved[ 8 ];
  849. } RTL_HEAP_USAGE, *PRTL_HEAP_USAGE;
  850. #define HEAP_USAGE_ALLOCATED_BLOCKS HEAP_REALLOC_IN_PLACE_ONLY
  851. #define HEAP_USAGE_FREE_BUFFER HEAP_ZERO_MEMORY
  852. NTSYSAPI
  853. NTSTATUS
  854. NTAPI
  855. RtlUsageHeap(
  856. IN PVOID HeapHandle,
  857. IN ULONG Flags,
  858. IN OUT PRTL_HEAP_USAGE Usage
  859. );
  860. typedef struct _RTL_HEAP_WALK_ENTRY {
  861. PVOID DataAddress;
  862. SIZE_T DataSize;
  863. UCHAR OverheadBytes;
  864. UCHAR SegmentIndex;
  865. USHORT Flags;
  866. union {
  867. struct {
  868. SIZE_T Settable;
  869. USHORT TagIndex;
  870. USHORT AllocatorBackTraceIndex;
  871. ULONG Reserved[ 2 ];
  872. } Block;
  873. struct {
  874. ULONG CommittedSize;
  875. ULONG UnCommittedSize;
  876. PVOID FirstEntry;
  877. PVOID LastEntry;
  878. } Segment;
  879. };
  880. } RTL_HEAP_WALK_ENTRY, *PRTL_HEAP_WALK_ENTRY;
  881. NTSYSAPI
  882. NTSTATUS
  883. NTAPI
  884. RtlWalkHeap(
  885. IN PVOID HeapHandle,
  886. IN OUT PRTL_HEAP_WALK_ENTRY Entry
  887. );
  888. typedef struct _RTL_HEAP_ENTRY {
  889. SIZE_T Size;
  890. USHORT Flags;
  891. USHORT AllocatorBackTraceIndex;
  892. union {
  893. struct {
  894. SIZE_T Settable;
  895. ULONG Tag;
  896. } s1; // All other heap entries
  897. struct {
  898. SIZE_T CommittedSize;
  899. PVOID FirstBlock;
  900. } s2; // RTL_SEGMENT
  901. } u;
  902. } RTL_HEAP_ENTRY, *PRTL_HEAP_ENTRY;
  903. #define RTL_HEAP_BUSY (USHORT)0x0001
  904. #define RTL_HEAP_SEGMENT (USHORT)0x0002
  905. #define RTL_HEAP_SETTABLE_VALUE (USHORT)0x0010
  906. #define RTL_HEAP_SETTABLE_FLAG1 (USHORT)0x0020
  907. #define RTL_HEAP_SETTABLE_FLAG2 (USHORT)0x0040
  908. #define RTL_HEAP_SETTABLE_FLAG3 (USHORT)0x0080
  909. #define RTL_HEAP_SETTABLE_FLAGS (USHORT)0x00E0
  910. #define RTL_HEAP_UNCOMMITTED_RANGE (USHORT)0x0100
  911. #define RTL_HEAP_PROTECTED_ENTRY (USHORT)0x0200
  912. typedef struct _RTL_HEAP_TAG {
  913. ULONG NumberOfAllocations;
  914. ULONG NumberOfFrees;
  915. SIZE_T BytesAllocated;
  916. USHORT TagIndex;
  917. USHORT CreatorBackTraceIndex;
  918. WCHAR TagName[ 24 ];
  919. } RTL_HEAP_TAG, *PRTL_HEAP_TAG;
  920. typedef struct _RTL_HEAP_INFORMATION {
  921. PVOID BaseAddress;
  922. ULONG Flags;
  923. USHORT EntryOverhead;
  924. USHORT CreatorBackTraceIndex;
  925. SIZE_T BytesAllocated;
  926. SIZE_T BytesCommitted;
  927. ULONG NumberOfTags;
  928. ULONG NumberOfEntries;
  929. ULONG NumberOfPseudoTags;
  930. ULONG PseudoTagGranularity;
  931. ULONG Reserved[ 5 ];
  932. PRTL_HEAP_TAG Tags;
  933. PRTL_HEAP_ENTRY Entries;
  934. } RTL_HEAP_INFORMATION, *PRTL_HEAP_INFORMATION;
  935. typedef struct _RTL_PROCESS_HEAPS {
  936. ULONG NumberOfHeaps;
  937. RTL_HEAP_INFORMATION Heaps[ 1 ];
  938. } RTL_PROCESS_HEAPS, *PRTL_PROCESS_HEAPS;
  939. //
  940. // Heap Information APIs & data definitions
  941. //
  942. // begin_winnt
  943. typedef enum _HEAP_INFORMATION_CLASS {
  944. HeapCompatibilityInformation
  945. } HEAP_INFORMATION_CLASS;
  946. NTSTATUS
  947. RtlSetHeapInformation (
  948. IN PVOID HeapHandle,
  949. IN HEAP_INFORMATION_CLASS HeapInformationClass,
  950. IN PVOID HeapInformation OPTIONAL,
  951. IN SIZE_T HeapInformationLength OPTIONAL
  952. );
  953. NTSTATUS
  954. RtlQueryHeapInformation (
  955. IN PVOID HeapHandle,
  956. IN HEAP_INFORMATION_CLASS HeapInformationClass,
  957. OUT PVOID HeapInformation OPTIONAL,
  958. IN SIZE_T HeapInformationLength OPTIONAL,
  959. OUT PSIZE_T ReturnLength OPTIONAL
  960. );
  961. // end_winnt
  962. //
  963. // Debugging support
  964. //
  965. typedef struct _RTL_DEBUG_INFORMATION {
  966. HANDLE SectionHandleClient;
  967. PVOID ViewBaseClient;
  968. PVOID ViewBaseTarget;
  969. ULONG_PTR ViewBaseDelta;
  970. HANDLE EventPairClient;
  971. HANDLE EventPairTarget;
  972. HANDLE TargetProcessId;
  973. HANDLE TargetThreadHandle;
  974. ULONG Flags;
  975. SIZE_T OffsetFree;
  976. SIZE_T CommitSize;
  977. SIZE_T ViewSize;
  978. PRTL_PROCESS_MODULES Modules;
  979. PRTL_PROCESS_BACKTRACES BackTraces;
  980. PRTL_PROCESS_HEAPS Heaps;
  981. PRTL_PROCESS_LOCKS Locks;
  982. PVOID SpecificHeap;
  983. HANDLE TargetProcessHandle;
  984. PVOID Reserved[ 6 ];
  985. } RTL_DEBUG_INFORMATION, *PRTL_DEBUG_INFORMATION;
  986. NTSYSAPI
  987. PRTL_DEBUG_INFORMATION
  988. NTAPI
  989. RtlCreateQueryDebugBuffer(
  990. IN ULONG MaximumCommit OPTIONAL,
  991. IN BOOLEAN UseEventPair
  992. );
  993. NTSYSAPI
  994. NTSTATUS
  995. NTAPI
  996. RtlDestroyQueryDebugBuffer(
  997. IN PRTL_DEBUG_INFORMATION Buffer
  998. );
  999. NTSYSAPI
  1000. NTSTATUS
  1001. NTAPI
  1002. RtlQueryProcessDebugInformation(
  1003. IN HANDLE UniqueProcessId,
  1004. IN ULONG Flags,
  1005. IN OUT PRTL_DEBUG_INFORMATION Buffer
  1006. );
  1007. #define RTL_QUERY_PROCESS_MODULES 0x00000001
  1008. #define RTL_QUERY_PROCESS_BACKTRACES 0x00000002
  1009. #define RTL_QUERY_PROCESS_HEAP_SUMMARY 0x00000004
  1010. #define RTL_QUERY_PROCESS_HEAP_TAGS 0x00000008
  1011. #define RTL_QUERY_PROCESS_HEAP_ENTRIES 0x00000010
  1012. #define RTL_QUERY_PROCESS_LOCKS 0x00000020
  1013. #define RTL_QUERY_PROCESS_MODULES32 0x00000040
  1014. #define RTL_QUERY_PROCESS_NONINVASIVE 0x80000000
  1015. NTSTATUS
  1016. NTAPI
  1017. RtlQueryProcessModuleInformation(
  1018. IN HANDLE hProcess OPTIONAL,
  1019. IN ULONG Flags,
  1020. IN OUT PRTL_DEBUG_INFORMATION Buffer
  1021. );
  1022. NTSYSAPI
  1023. NTSTATUS
  1024. NTAPI
  1025. RtlQueryProcessBackTraceInformation(
  1026. IN OUT PRTL_DEBUG_INFORMATION Buffer
  1027. );
  1028. NTSYSAPI
  1029. NTSTATUS
  1030. NTAPI
  1031. RtlQueryProcessHeapInformation(
  1032. IN OUT PRTL_DEBUG_INFORMATION Buffer
  1033. );
  1034. NTSYSAPI
  1035. NTSTATUS
  1036. NTAPI
  1037. RtlQueryProcessLockInformation(
  1038. IN OUT PRTL_DEBUG_INFORMATION Buffer
  1039. );
  1040. //
  1041. // Routines for manipulating user mode handle tables. Used for Atoms
  1042. // and Local/Global memory allocations.
  1043. //
  1044. typedef struct _RTL_HANDLE_TABLE_ENTRY {
  1045. union {
  1046. ULONG Flags; // Allocated entries have low bit set
  1047. struct _RTL_HANDLE_TABLE_ENTRY *NextFree; // Free entries use this word for free list
  1048. };
  1049. } RTL_HANDLE_TABLE_ENTRY, *PRTL_HANDLE_TABLE_ENTRY;
  1050. #define RTL_HANDLE_ALLOCATED (USHORT)0x0001
  1051. typedef struct _RTL_HANDLE_TABLE {
  1052. ULONG MaximumNumberOfHandles;
  1053. ULONG SizeOfHandleTableEntry;
  1054. ULONG Reserved[ 2 ];
  1055. PRTL_HANDLE_TABLE_ENTRY FreeHandles;
  1056. PRTL_HANDLE_TABLE_ENTRY CommittedHandles;
  1057. PRTL_HANDLE_TABLE_ENTRY UnCommittedHandles;
  1058. PRTL_HANDLE_TABLE_ENTRY MaxReservedHandles;
  1059. } RTL_HANDLE_TABLE, *PRTL_HANDLE_TABLE;
  1060. NTSYSAPI
  1061. void
  1062. NTAPI
  1063. RtlInitializeHandleTable(
  1064. IN ULONG MaximumNumberOfHandles,
  1065. IN ULONG SizeOfHandleTableEntry,
  1066. OUT PRTL_HANDLE_TABLE HandleTable
  1067. );
  1068. NTSYSAPI
  1069. NTSTATUS
  1070. NTAPI
  1071. RtlDestroyHandleTable(
  1072. IN OUT PRTL_HANDLE_TABLE HandleTable
  1073. );
  1074. NTSYSAPI
  1075. PRTL_HANDLE_TABLE_ENTRY
  1076. NTAPI
  1077. RtlAllocateHandle(
  1078. IN PRTL_HANDLE_TABLE HandleTable,
  1079. OUT PULONG HandleIndex OPTIONAL
  1080. );
  1081. NTSYSAPI
  1082. BOOLEAN
  1083. NTAPI
  1084. RtlFreeHandle(
  1085. IN PRTL_HANDLE_TABLE HandleTable,
  1086. IN PRTL_HANDLE_TABLE_ENTRY Handle
  1087. );
  1088. NTSYSAPI
  1089. BOOLEAN
  1090. NTAPI
  1091. RtlIsValidHandle(
  1092. IN PRTL_HANDLE_TABLE HandleTable,
  1093. IN PRTL_HANDLE_TABLE_ENTRY Handle
  1094. );
  1095. NTSYSAPI
  1096. BOOLEAN
  1097. NTAPI
  1098. RtlIsValidIndexHandle(
  1099. IN PRTL_HANDLE_TABLE HandleTable,
  1100. IN ULONG HandleIndex,
  1101. OUT PRTL_HANDLE_TABLE_ENTRY *Handle
  1102. );
  1103. //
  1104. // Routines for thread pool.
  1105. //
  1106. #define WT_EXECUTEDEFAULT 0x00000000 // winnt
  1107. #define WT_EXECUTEINIOTHREAD 0x00000001 // winnt
  1108. #define WT_EXECUTEINUITHREAD 0x00000002 // winnt
  1109. #define WT_EXECUTEINWAITTHREAD 0x00000004 // winnt
  1110. #define WT_EXECUTEONLYONCE 0x00000008 // winnt
  1111. #define WT_EXECUTEINTIMERTHREAD 0x00000020 // winnt
  1112. #define WT_EXECUTELONGFUNCTION 0x00000010 // winnt
  1113. #define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040 // winnt
  1114. #define WT_EXECUTEINPERSISTENTTHREAD 0x00000080 // winnt
  1115. #define WT_SET_MAX_THREADPOOL_THREADS(Flags, Limit) ((Flags) |= (Limit)<<16) // winnt
  1116. typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN ); // winnt
  1117. typedef VOID (NTAPI * WORKERCALLBACKFUNC) (PVOID ); // winnt
  1118. typedef VOID (NTAPI * APC_CALLBACK_FUNCTION) (NTSTATUS, PVOID, PVOID); // winnt
  1119. typedef NTSTATUS (NTAPI RTLP_START_THREAD)(
  1120. PUSER_THREAD_START_ROUTINE,
  1121. PVOID,
  1122. HANDLE *);
  1123. typedef NTSTATUS (NTAPI RTLP_EXIT_THREAD)(
  1124. NTSTATUS );
  1125. typedef RTLP_START_THREAD * PRTLP_START_THREAD ;
  1126. typedef RTLP_EXIT_THREAD * PRTLP_EXIT_THREAD ;
  1127. NTSTATUS
  1128. NTAPI
  1129. RtlSetThreadPoolStartFunc(
  1130. PRTLP_START_THREAD StartFunc,
  1131. PRTLP_EXIT_THREAD ExitFunc
  1132. );
  1133. NTSYSAPI
  1134. NTSTATUS
  1135. NTAPI
  1136. RtlRegisterWait (
  1137. OUT PHANDLE WaitHandle,
  1138. IN HANDLE Handle,
  1139. IN WAITORTIMERCALLBACKFUNC Function,
  1140. IN PVOID Context,
  1141. IN ULONG Milliseconds,
  1142. IN ULONG Flags
  1143. ) ;
  1144. NTSYSAPI
  1145. NTSTATUS
  1146. NTAPI
  1147. RtlDeregisterWait(
  1148. IN HANDLE WaitHandle
  1149. ) ;
  1150. NTSYSAPI
  1151. NTSTATUS
  1152. NTAPI
  1153. RtlDeregisterWaitEx(
  1154. IN HANDLE WaitHandle,
  1155. IN HANDLE Event
  1156. ) ;
  1157. NTSYSAPI
  1158. NTSTATUS
  1159. NTAPI
  1160. RtlQueueWorkItem(
  1161. IN WORKERCALLBACKFUNC Function,
  1162. IN PVOID Context,
  1163. IN ULONG Flags
  1164. ) ;
  1165. NTSTATUS
  1166. NTAPI
  1167. RtlSetIoCompletionCallback (
  1168. IN HANDLE FileHandle,
  1169. IN APC_CALLBACK_FUNCTION CompletionProc,
  1170. IN ULONG Flags
  1171. ) ;
  1172. NTSYSAPI
  1173. NTSTATUS
  1174. NTAPI
  1175. RtlCreateTimerQueue(
  1176. OUT PHANDLE TimerQueueHandle
  1177. ) ;
  1178. NTSYSAPI
  1179. NTSTATUS
  1180. NTAPI
  1181. RtlCreateTimer(
  1182. IN HANDLE TimerQueueHandle,
  1183. OUT HANDLE *Handle,
  1184. IN WAITORTIMERCALLBACKFUNC Function,
  1185. IN PVOID Context,
  1186. IN ULONG DueTime,
  1187. IN ULONG Period,
  1188. IN ULONG Flags
  1189. ) ;
  1190. NTSYSAPI
  1191. NTSTATUS
  1192. NTAPI
  1193. RtlUpdateTimer(
  1194. IN HANDLE TimerQueueHandle,
  1195. IN HANDLE TimerHandle,
  1196. IN ULONG DueTime,
  1197. IN ULONG Period
  1198. ) ;
  1199. NTSYSAPI
  1200. NTSTATUS
  1201. NTAPI
  1202. RtlDeleteTimer(
  1203. IN HANDLE TimerQueueHandle,
  1204. IN HANDLE TimerToCancel,
  1205. IN HANDLE Event
  1206. ) ;
  1207. NTSYSAPI
  1208. NTSTATUS
  1209. NTAPI
  1210. RtlDeleteTimerQueue(
  1211. IN HANDLE TimerQueueHandle
  1212. ) ;
  1213. NTSYSAPI
  1214. NTSTATUS
  1215. NTAPI
  1216. RtlDeleteTimerQueueEx(
  1217. IN HANDLE TimerQueueHandle,
  1218. IN HANDLE Event
  1219. ) ;
  1220. BOOLEAN
  1221. RtlDllShutdownInProgress (
  1222. VOID
  1223. );
  1224. //--------OBSOLETE FUNCTIONS: DONT USE----------//
  1225. VOID
  1226. RtlDebugPrintTimes (
  1227. VOID
  1228. );
  1229. NTSYSAPI
  1230. NTSTATUS
  1231. NTAPI
  1232. RtlCancelTimer(
  1233. IN HANDLE TimerQueueHandle,
  1234. IN HANDLE TimerToCancel
  1235. ) ;
  1236. NTSYSAPI
  1237. NTSTATUS
  1238. NTAPI
  1239. RtlSetTimer(
  1240. IN HANDLE TimerQueueHandle,
  1241. OUT HANDLE *Handle,
  1242. IN WAITORTIMERCALLBACKFUNC Function,
  1243. IN PVOID Context,
  1244. IN ULONG DueTime,
  1245. IN ULONG Period,
  1246. IN ULONG Flags
  1247. ) ;
  1248. //todo:delete below: dont use the below flag. will be deleted
  1249. #define WT_EXECUTEINLONGTHREAD 0x00000010 // winnt
  1250. #define WT_EXECUTEDELETEWAIT 0x00000008 // winnt
  1251. //------end OBSOLUTE FUNCTIONS: DONT USE--------//
  1252. #if (defined(RTL_DECLARE_IMALLOC) && RTL_DECLARE_IMALLOC) \
  1253. || (defined(RTL_DECLARE_STREAMS) && RTL_DECLARE_STREAMS \
  1254. && defined(RTL_DECLARE_MEMORY_STREAM) && RTL_DECLARE_MEMORY_STREAM)
  1255. // Introducing the struct before the typedef works better if the
  1256. // header is enclosed in a C++ namespace.
  1257. struct IMallocVtbl; typedef struct IMallocVtbl IMallocVtbl;
  1258. #if defined(interface) // it's defined in objbase.h
  1259. interface IMalloc; typedef interface IMalloc IMalloc;
  1260. #else
  1261. struct IMalloc; typedef struct IMalloc IMalloc;
  1262. #endif
  1263. #endif
  1264. #if defined(RTL_DECLARE_IMALLOC) && RTL_DECLARE_IMALLOC
  1265. //
  1266. // IMalloc over an RtlHeap
  1267. //
  1268. struct _RTL_IMALLOC;
  1269. typedef struct _RTL_IMALLOC {
  1270. ULONG ReferenceCount;
  1271. ULONG Flags;
  1272. VOID (STDMETHODCALLTYPE* FinalRelease)(struct _RTL_HEAP_IMALLOC*);
  1273. HANDLE Heap;
  1274. ULONG HeapFlags;
  1275. } RTL_IMALLOC, *PRTL_IMALLOC;
  1276. //
  1277. // Don't use NTSYSAPI directly so you can more easily
  1278. // statically link to these functions, independently
  1279. // of how you link to the rest of ntdll.
  1280. //
  1281. #if !defined(RTL_IMALLOC_API)
  1282. #define RTL_IMALLOC_API NTSYSAPI
  1283. #endif
  1284. RTL_IMALLOC_API
  1285. HRESULT
  1286. STDMETHODCALLTYPE
  1287. RtlAllocHeapIMalloc(
  1288. PRTL_HEAP_IMALLOC HeapIMalloc
  1289. );
  1290. RTL_IMALLOC_API
  1291. PVOID
  1292. STDMETHODCALLTYPE
  1293. RtlReallocIMalloc(
  1294. PRTL_IMALLOC Malloc,
  1295. PVOID BlockOfMemory,
  1296. ULONG NumberOfBytes
  1297. );
  1298. RTL_IMALLOC_API
  1299. VOID
  1300. STDMETHODCALLTYPE
  1301. RtlFreeIMalloc(
  1302. PRTL_IMALLOC Malloc,
  1303. PVOID BlockOfMemory
  1304. );
  1305. RTL_IMALLOC_API
  1306. ULONG
  1307. STDMETHODCALLTYPE
  1308. RtlGetSizeIMalloc(
  1309. PRTL_IMALLOC Malloc,
  1310. PVOID BlockOfMemory
  1311. );
  1312. RTL_IMALLOC_API
  1313. BOOL
  1314. STDMETHODCALLTYPE
  1315. RtlDidAllocIMalloc(
  1316. PRTL_IMALLOC Malloc,
  1317. PVOID BlockOfMemory
  1318. );
  1319. RTL_IMALLOC_API
  1320. VOID
  1321. STDMETHODCALLTYPE
  1322. RtlMinimizeIMalloc(
  1323. PRTL_IMALLOC Malloc
  1324. );
  1325. RTL_IMALLOC_API
  1326. PRTL_IMALLOC
  1327. STDMETHODCALLTYPE
  1328. RtlProcessIMalloc(
  1329. VOID
  1330. );
  1331. #endif // RTL_DECLARE_MALLOC
  1332. #if defined(RTL_DECLARE_STREAMS) && RTL_DECLARE_STREAMS
  1333. // Introducing the structs before the typedefs works better if the
  1334. // header is enclosed in a C++ namespace.
  1335. struct tagSTATSTG; typedef struct tagSTATSTG STATSTG;
  1336. struct IStreamVtbl; typedef struct IStreamVtbl IStreamVtbl;
  1337. #if defined(interface) // it's defined in objbase.h
  1338. interface IStream; typedef interface IStream IStream;
  1339. #else
  1340. struct IStream; typedef struct IStream IStream;
  1341. #endif
  1342. #if defined(RTL_DECLARE_FILE_STREAM) && RTL_DECLARE_FILE_STREAM
  1343. //
  1344. // IStream over an NT File handle (not yet adapted for C++)
  1345. //
  1346. struct _RTL_FILE_STREAM;
  1347. typedef struct _RTL_FILE_STREAM
  1348. {
  1349. LONG ReferenceCount;
  1350. ULONG Flags;
  1351. VOID (STDMETHODCALLTYPE* FinalRelease)(struct _RTL_FILE_STREAM*);
  1352. HANDLE FileHandle;
  1353. } RTL_FILE_STREAM, *PRTL_FILE_STREAM;
  1354. //
  1355. // Don't use NTSYSAPI directly so you can more easily
  1356. // statically link to these functions, independently
  1357. // of how you link to the rest of ntdll.
  1358. //
  1359. #if !defined(RTL_FILE_STREAM_API)
  1360. #define RTL_FILE_STREAM_API NTSYSAPI
  1361. #endif
  1362. RTL_FILE_STREAM_API
  1363. HRESULT
  1364. STDMETHODCALLTYPE
  1365. RtlInitFileStream(
  1366. PRTL_FILE_STREAM FileStream
  1367. );
  1368. RTL_FILE_STREAM_API
  1369. HRESULT
  1370. STDMETHODCALLTYPE
  1371. RtlCloseFileStream(
  1372. PRTL_FILE_STREAM FileStream
  1373. );
  1374. RTL_FILE_STREAM_API
  1375. ULONG
  1376. STDMETHODCALLTYPE
  1377. RtlAddRefFileStream(
  1378. PRTL_FILE_STREAM FileStream
  1379. );
  1380. RTL_FILE_STREAM_API
  1381. ULONG
  1382. STDMETHODCALLTYPE
  1383. RtlReleaseFileStream(
  1384. PRTL_FILE_STREAM FileStream
  1385. );
  1386. RTL_FILE_STREAM_API
  1387. HRESULT
  1388. STDMETHODCALLTYPE
  1389. RtlQueryFileStreamInterface(
  1390. IStream* Functions,
  1391. PRTL_FILE_STREAM Data,
  1392. const IID* Interface,
  1393. PVOID* Object
  1394. );
  1395. RTL_FILE_STREAM_API
  1396. HRESULT
  1397. STDMETHODCALLTYPE
  1398. RtlReadFileStream(
  1399. PRTL_FILE_STREAM FileStream,
  1400. PVOID Buffer,
  1401. ULONG BytesToRead,
  1402. ULONG* BytesRead
  1403. );
  1404. RTL_FILE_STREAM_API
  1405. HRESULT
  1406. STDMETHODCALLTYPE
  1407. RtlWriteFileStream(
  1408. PRTL_FILE_STREAM FileStream,
  1409. const VOID* Buffer,
  1410. ULONG BytesToWrite,
  1411. ULONG* BytesWritten
  1412. );
  1413. RTL_FILE_STREAM_API
  1414. HRESULT
  1415. STDMETHODCALLTYPE
  1416. RtlSeekFileStream(
  1417. PRTL_FILE_STREAM FileStream,
  1418. LARGE_INTEGER Distance,
  1419. ULONG Origin,
  1420. ULARGE_INTEGER* NewPosition
  1421. );
  1422. /* returns E_NOTIMPL */
  1423. RTL_FILE_STREAM_API
  1424. HRESULT
  1425. STDMETHODCALLTYPE
  1426. RtlSetFileStreamSize(
  1427. PRTL_FILE_STREAM FileStream,
  1428. ULARGE_INTEGER NewSize
  1429. );
  1430. /* returns E_NOTIMPL */
  1431. RTL_FILE_STREAM_API
  1432. HRESULT
  1433. STDMETHODCALLTYPE
  1434. RtlCopyFileStreamTo(
  1435. PRTL_FILE_STREAM FileStream,
  1436. IStream* AnotherStream,
  1437. ULARGE_INTEGER NumberOfBytesToCopy,
  1438. ULARGE_INTEGER* NumberOfBytesRead,
  1439. ULARGE_INTEGER* NumberOfBytesWritten
  1440. );
  1441. /* returns E_NOTIMPL */
  1442. RTL_FILE_STREAM_API
  1443. HRESULT
  1444. STDMETHODCALLTYPE
  1445. RtlCommitFileStream(
  1446. PRTL_FILE_STREAM FileStream,
  1447. ULONG Flags
  1448. );
  1449. /* returns E_NOTIMPL */
  1450. RTL_FILE_STREAM_API
  1451. HRESULT
  1452. STDMETHODCALLTYPE
  1453. RtlRevertFileStream(
  1454. PRTL_FILE_STREAM FileStream
  1455. );
  1456. /* returns E_NOTIMPL */
  1457. RTL_FILE_STREAM_API
  1458. HRESULT
  1459. STDMETHODCALLTYPE
  1460. RtlLockFileStreamRegion(
  1461. PRTL_FILE_STREAM FileStream,
  1462. ULARGE_INTEGER Offset,
  1463. ULARGE_INTEGER NumberOfBytes,
  1464. ULONG LockType
  1465. );
  1466. /* returns E_NOTIMPL */
  1467. RTL_FILE_STREAM_API
  1468. HRESULT
  1469. STDMETHODCALLTYPE
  1470. RtlUnlockFileStreamRegion(
  1471. PRTL_FILE_STREAM FileStream,
  1472. ULARGE_INTEGER Offset,
  1473. ULARGE_INTEGER NumberOfBytes,
  1474. ULONG LockType
  1475. );
  1476. /* returns E_NOTIMPL */
  1477. RTL_FILE_STREAM_API
  1478. HRESULT
  1479. STDMETHODCALLTYPE
  1480. RtlStatFileStream(
  1481. PRTL_FILE_STREAM FileStream,
  1482. STATSTG* StatusInformation,
  1483. ULONG Flags
  1484. );
  1485. /* returns E_NOTIMPL */
  1486. RTL_FILE_STREAM_API
  1487. HRESULT
  1488. STDMETHODCALLTYPE
  1489. RtlCloneFileStream(
  1490. PRTL_FILE_STREAM FileStream,
  1491. IStream** NewStream
  1492. );
  1493. #endif // RTL_DECLARE_FILE_STREAM
  1494. //
  1495. // functions for implementing a readable IStream over a block of memory
  1496. // (writable/growable in the future)
  1497. //
  1498. #if defined(RTL_DECLARE_MEMORY_STREAM) && RTL_DECLARE_MEMORY_STREAM
  1499. struct _RTL_MEMORY_STREAM_DATA;
  1500. struct _RTL_MEMORY_STREAM_WITH_VTABLE;
  1501. struct _RTL_OUT_OF_PROCESS_MEMORY_STREAM_DATA;
  1502. struct _RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE;
  1503. //
  1504. // Don't use NTSYSAPI directly so you can more easily
  1505. // statically link to these functions, independently
  1506. // of how you link to the rest of ntdll.
  1507. //
  1508. #if !defined(RTL_MEMORY_STREAM_API)
  1509. #define RTL_MEMORY_STREAM_API NTSYSAPI
  1510. #endif
  1511. typedef struct _RTL_MEMORY_STREAM_DATA {
  1512. #define RTLP_MEMORY_STREAM_DATA_PREFIX \
  1513. LONG ReferenceCount; \
  1514. ULONG Flags; \
  1515. PUCHAR Current; \
  1516. PUCHAR Begin; \
  1517. PUCHAR End
  1518. RTLP_MEMORY_STREAM_DATA_PREFIX;
  1519. VOID (STDMETHODCALLTYPE* FinalRelease)(struct _RTL_MEMORY_STREAM_WITH_VTABLE*);
  1520. IMalloc* ReservedForMalloc;
  1521. } RTL_MEMORY_STREAM_DATA, *PRTL_MEMORY_STREAM_DATA;
  1522. typedef struct _RTL_MEMORY_STREAM_WITH_VTABLE {
  1523. const IStreamVtbl* StreamVTable;
  1524. RTL_MEMORY_STREAM_DATA Data;
  1525. } RTL_MEMORY_STREAM_WITH_VTABLE, *PRTL_MEMORY_STREAM_WITH_VTABLE;
  1526. typedef struct _RTL_OUT_OF_PROCESS_MEMORY_STREAM_DATA {
  1527. RTLP_MEMORY_STREAM_DATA_PREFIX;
  1528. VOID (STDMETHODCALLTYPE* FinalRelease)(struct _RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE*);
  1529. HANDLE Process;
  1530. } RTL_OUT_OF_PROCESS_MEMORY_STREAM_DATA, *PRTL_OUT_OF_PROCESS_MEMORY_STREAM_DATA;
  1531. typedef struct _RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE {
  1532. const IStreamVtbl* StreamVTable;
  1533. RTL_OUT_OF_PROCESS_MEMORY_STREAM_DATA Data;
  1534. } RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE, *PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE;
  1535. //
  1536. // These macros generate function pointer types that match the IStream member functions,
  1537. // but IStream* is replaced by "T". As well, an identifier is placed within the type
  1538. // appropriately for defining a typedef or a struct member or a variable.
  1539. // They are used so that a vtable can be somewhat typesafely initialized.
  1540. // This way, if you fill out the vtable in the wrong order, you will like get a compile
  1541. // error (other than were function signatures coincide).
  1542. // Also, you don't have to cast the this pointer in your implementations of member functions.
  1543. //
  1544. // You should define a set of macros like this for any COM interface you implement in C.
  1545. //
  1546. #define RTLP_STREAM_NOTHING /* nothing */
  1547. #define PRTL_QUERYINTERFACE_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, const IID* riid, VOID** ppvObject)
  1548. #define PRTL_ADDREF_STREAM2(T, Name) ULONG (STDMETHODCALLTYPE* Name)(T* This)
  1549. #define PRTL_RELEASE_STREAM2(T, Name) ULONG (STDMETHODCALLTYPE* Name)(T* This)
  1550. #define PRTL_READ_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, VOID* pv, ULONG cb, ULONG* pcbRead)
  1551. #define PRTL_WRITE_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, const VOID* pv, ULONG cb, ULONG* pcbWritten)
  1552. #define PRTL_SEEK_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
  1553. #define PRTL_SET_STREAM_SIZE2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, ULARGE_INTEGER libNewSize)
  1554. #define PRTL_COPY_STREAM_TO2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
  1555. #define PRTL_COMMIT_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, DWORD grfCommitFlags)
  1556. #define PRTL_REVERT_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This)
  1557. #define PRTL_LOCK_STREAM_REGION2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
  1558. #define PRTL_UNLOCK_STREAM_REGION2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
  1559. #define PRTL_STAT_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, STATSTG* pstatstg, DWORD grfStatFlag)
  1560. #define PRTL_CLONE_STREAM2(T, Name) HRESULT (STDMETHODCALLTYPE* Name)(T* This, IStream** ppstm)
  1561. //
  1562. // These macros are like the previous set, but they do not place a name in the
  1563. // type. They are appropriate for casting function pointers.
  1564. // They are used like so:
  1565. // #define RtlOperateOnDerivedFoo (PRTL_OPERATOR_INTERFACE2(RTL_DERIVED_FOO)RtlOperateOnBaseFoo)
  1566. //
  1567. // You should define a set of macros like this for any COM interface you implement in C.
  1568. //
  1569. #define PRTL_QUERYINTERFACE_STREAM1(T) PRTL_QUERYINTERFACE_STREAM2(T, RTLP_STREAM_NOTHING)
  1570. #define PRTL_ADDREF_STREAM1(T) PRTL_ADDREF_STREAM2(T, RTLP_STREAM_NOTHING)
  1571. #define PRTL_RELEASE_STREAM1(T) PRTL_RELEASE_STREAM2(T, RTLP_STREAM_NOTHING)
  1572. #define PRTL_READ_STREAM1(T) PRTL_READ_STREAM2(T, RTLP_STREAM_NOTHING)
  1573. #define PRTL_WRITE_STREAM1(T) PRTL_WRITE_STREAM2(T, RTLP_STREAM_NOTHING)
  1574. #define PRTL_SEEK_STREAM1(T) PRTL_SEEK_STREAM2(T, RTLP_STREAM_NOTHING)
  1575. #define PRTL_SET_STREAM_SIZE1(T) PRTL_SET_STREAM_SIZE2(T, RTLP_STREAM_NOTHING)
  1576. #define PRTL_COPY_STREAM_TO1(T) PRTL_COPY_STREAM_TO2(T, RTLP_STREAM_NOTHING)
  1577. #define PRTL_COMMIT_STREAM1(T) PRTL_COMMIT_STREAM2(T, RTLP_STREAM_NOTHING)
  1578. #define PRTL_REVERT_STREAM1(T) PRTL_REVERT_STREAM2(T, RTLP_STREAM_NOTHING)
  1579. #define PRTL_LOCK_STREAM_REGION1(T) PRTL_LOCK_STREAM_REGION2(T, RTLP_STREAM_NOTHING)
  1580. #define PRTL_UNLOCK_STREAM_REGION1(T) PRTL_UNLOCK_STREAM_REGION2(T, RTLP_STREAM_NOTHING)
  1581. #define PRTL_STAT_STREAM1(T) PRTL_STAT_STREAM2(T, RTLP_STREAM_NOTHING)
  1582. #define PRTL_CLONE_STREAM1(T) PRTL_CLONE_STREAM2(T, RTLP_STREAM_NOTHING)
  1583. //
  1584. // This "template" lets you fill out a VTable
  1585. // with some type safety. Then cast the address of the vtable.
  1586. // Midl ought to provide something like this..
  1587. //
  1588. // You should define a macro like this for any COM interface you implement in C.
  1589. //
  1590. #define RTL_STREAM_VTABLE_TEMPLATE(T) \
  1591. struct \
  1592. { \
  1593. PRTL_QUERYINTERFACE_STREAM2(T, QueryInterface); \
  1594. PRTL_ADDREF_STREAM2(T, AddRef); \
  1595. PRTL_RELEASE_STREAM2(T, Release); \
  1596. PRTL_READ_STREAM2(T, Read); \
  1597. PRTL_WRITE_STREAM2(T, Write); \
  1598. PRTL_SEEK_STREAM2(T, Seek); \
  1599. PRTL_SET_STREAM_SIZE2(T, SetSize); \
  1600. PRTL_COPY_STREAM_TO2(T, CopyTo); \
  1601. PRTL_COMMIT_STREAM2(T, Commit); \
  1602. PRTL_REVERT_STREAM2(T, Revert); \
  1603. PRTL_LOCK_STREAM_REGION2(T, LockRegion); \
  1604. PRTL_UNLOCK_STREAM_REGION2(T, UnlockRegion); \
  1605. PRTL_STAT_STREAM2(T, Stat); \
  1606. PRTL_CLONE_STREAM2(T, Clone); \
  1607. }
  1608. RTL_MEMORY_STREAM_API
  1609. VOID
  1610. STDMETHODCALLTYPE
  1611. RtlInitMemoryStream(
  1612. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream
  1613. );
  1614. RTL_MEMORY_STREAM_API
  1615. VOID
  1616. STDMETHODCALLTYPE
  1617. RtlInitOutOfProcessMemoryStream(
  1618. PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE MemoryStream
  1619. );
  1620. RTL_MEMORY_STREAM_API
  1621. VOID
  1622. STDMETHODCALLTYPE
  1623. RtlFinalReleaseOutOfProcessMemoryStream(
  1624. PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE MemoryStream
  1625. );
  1626. RTL_MEMORY_STREAM_API
  1627. ULONG
  1628. STDMETHODCALLTYPE
  1629. RtlAddRefMemoryStream(
  1630. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream
  1631. );
  1632. #define RtlAddRefOutOfProcessMemoryStream \
  1633. ((PRTL_ADDREF_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlAddRefMemoryStream)
  1634. RTL_MEMORY_STREAM_API
  1635. ULONG
  1636. STDMETHODCALLTYPE
  1637. RtlReleaseMemoryStream(
  1638. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream
  1639. );
  1640. #define RtlReleaseOutOfProcessMemoryStream \
  1641. ((PRTL_RELEASE_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlReleaseMemoryStream)
  1642. RTL_MEMORY_STREAM_API
  1643. HRESULT
  1644. STDMETHODCALLTYPE
  1645. RtlQueryInterfaceMemoryStream(
  1646. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1647. const IID* Interface,
  1648. PVOID* Object
  1649. );
  1650. #define RtlQueryInterfaceOutOfProcessMemoryStream \
  1651. ((PRTL_QUERYINTERFACE_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlQueryInterfaceMemoryStream)
  1652. RTL_MEMORY_STREAM_API
  1653. HRESULT
  1654. STDMETHODCALLTYPE
  1655. RtlReadMemoryStream(
  1656. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1657. PVOID Buffer,
  1658. ULONG BytesToRead,
  1659. ULONG* BytesRead
  1660. );
  1661. RTL_MEMORY_STREAM_API
  1662. HRESULT
  1663. STDMETHODCALLTYPE
  1664. RtlReadOutOfProcessMemoryStream(
  1665. PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1666. PVOID Buffer,
  1667. ULONG BytesToRead,
  1668. ULONG* BytesRead
  1669. );
  1670. // E_NOTIMPL
  1671. RTL_MEMORY_STREAM_API
  1672. HRESULT
  1673. STDMETHODCALLTYPE
  1674. RtlWriteMemoryStream(
  1675. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1676. const VOID* Buffer,
  1677. ULONG BytesToWrite,
  1678. ULONG* BytesWritten
  1679. );
  1680. #define RtlWriteOutOfProcessMemoryStream \
  1681. ((PRTL_WRITE_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlWriteMemoryStream)
  1682. RTL_MEMORY_STREAM_API
  1683. HRESULT
  1684. STDMETHODCALLTYPE
  1685. RtlSeekMemoryStream(
  1686. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1687. LARGE_INTEGER Distance,
  1688. ULONG Origin,
  1689. ULARGE_INTEGER* NewPosition
  1690. );
  1691. #define RtlSeekOutOfProcessMemoryStream \
  1692. ((PRTL_SEEK_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlSeekMemoryStream)
  1693. // E_NOTIMPL
  1694. RTL_MEMORY_STREAM_API
  1695. HRESULT
  1696. STDMETHODCALLTYPE
  1697. RtlSetMemoryStreamSize(
  1698. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1699. ULARGE_INTEGER NewSize
  1700. );
  1701. #define RtlSetOutOfProcessMemoryStreamSize \
  1702. ((PRTL_SET_STREAM_SIZE1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlSetMemoryStreamSize)
  1703. RTL_MEMORY_STREAM_API
  1704. HRESULT
  1705. STDMETHODCALLTYPE
  1706. RtlCopyMemoryStreamTo(
  1707. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1708. IStream* AnotherStream,
  1709. ULARGE_INTEGER NumberOfBytesToCopy,
  1710. ULARGE_INTEGER* NumberOfBytesRead,
  1711. ULARGE_INTEGER* NumberOfBytesWritten
  1712. );
  1713. // E_NOTIMPL
  1714. RTL_MEMORY_STREAM_API
  1715. HRESULT
  1716. STDMETHODCALLTYPE
  1717. RtlCopyOutOfProcessMemoryStreamTo(
  1718. PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1719. IStream* AnotherStream,
  1720. ULARGE_INTEGER NumberOfBytesToCopy,
  1721. ULARGE_INTEGER* NumberOfBytesRead,
  1722. ULARGE_INTEGER* NumberOfBytesWritten
  1723. );
  1724. // E_NOTIMPL
  1725. RTL_MEMORY_STREAM_API
  1726. HRESULT
  1727. STDMETHODCALLTYPE
  1728. RtlCommitMemoryStream(
  1729. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1730. ULONG Flags
  1731. );
  1732. #define RtlCommitOutOfProcessMemoryStream \
  1733. ((PRTL_COMMIT_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlCommitMemoryStream)
  1734. // E_NOTIMPL
  1735. RTL_MEMORY_STREAM_API
  1736. HRESULT
  1737. STDMETHODCALLTYPE
  1738. RtlRevertMemoryStream(
  1739. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream
  1740. );
  1741. #define RtlRevertOutOfProcessMemoryStream \
  1742. ((PRTL_REVERT_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlRevertMemoryStream)
  1743. // E_NOTIMPL
  1744. RTL_MEMORY_STREAM_API
  1745. HRESULT
  1746. STDMETHODCALLTYPE
  1747. RtlLockMemoryStreamRegion(
  1748. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1749. ULARGE_INTEGER Offset,
  1750. ULARGE_INTEGER NumberOfBytes,
  1751. ULONG LockType
  1752. );
  1753. #define RtlLockOutOfProcessMemoryStreamRegion \
  1754. ((PRTL_LOCK_STREAM_REGION1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlLockMemoryStreamRegion)
  1755. // E_NOTIMPL
  1756. RTL_MEMORY_STREAM_API
  1757. HRESULT
  1758. STDMETHODCALLTYPE
  1759. RtlUnlockMemoryStreamRegion(
  1760. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1761. ULARGE_INTEGER Offset,
  1762. ULARGE_INTEGER NumberOfBytes,
  1763. ULONG LockType
  1764. );
  1765. #define RtlUnlockOutOfProcessMemoryStreamRegion \
  1766. ((PRTL_UNLOCK_STREAM_REGION1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlUnlockMemoryStreamRegion)
  1767. // E_NOTIMPL
  1768. RTL_MEMORY_STREAM_API
  1769. HRESULT
  1770. STDMETHODCALLTYPE
  1771. RtlStatMemoryStream(
  1772. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1773. STATSTG* StatusInformation,
  1774. ULONG Flags
  1775. );
  1776. #define RtlStatOutOfProcessMemoryStream \
  1777. ((PRTL_STAT_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlStatMemoryStream)
  1778. // E_NOTIMPL
  1779. RTL_MEMORY_STREAM_API
  1780. HRESULT
  1781. STDMETHODCALLTYPE
  1782. RtlCloneMemoryStream(
  1783. PRTL_MEMORY_STREAM_WITH_VTABLE MemoryStream,
  1784. IStream** NewStream
  1785. );
  1786. #define RtlCloneOutOfProcessMemoryStream \
  1787. ((PRTL_CLONE_STREAM1(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE))RtlCloneMemoryStream)
  1788. #if defined(__cplusplus) && !defined(CINTERFACE)
  1789. #if !defined(interface)
  1790. //
  1791. // we need #define interface struct
  1792. //
  1793. #include "objbase.h"
  1794. #endif
  1795. #ifdef COM_NO_WINDOWS_H
  1796. #include "objidl.h"
  1797. #else
  1798. #define COM_NO_WINDOWS_H
  1799. #include "objidl.h"
  1800. #undef COM_NO_WINDOWS_H
  1801. #endif
  1802. class DECLSPEC_NOVTABLE CRtlMemoryStream : public IStream
  1803. {
  1804. protected:
  1805. operator PRTL_MEMORY_STREAM_WITH_VTABLE()
  1806. {
  1807. return reinterpret_cast<PRTL_MEMORY_STREAM_WITH_VTABLE>(this);
  1808. }
  1809. RTL_MEMORY_STREAM_DATA Data;
  1810. public:
  1811. /* This conflicts with DECLSPEC_NOVTABLE
  1812. static VOID STDMETHODCALLTYPE FinalReleaseGlue(PRTL_MEMORY_STREAM_WITH_VTABLE This)
  1813. {
  1814. return reinterpret_cast<CRtlMemoryStream*>(This)->FinalRelease();
  1815. }
  1816. virtual VOID STDMETHODCALLTYPE FinalRelease() { }
  1817. */
  1818. CRtlMemoryStream()
  1819. {
  1820. RtlInitMemoryStream(*this);
  1821. //Data.FinalRelease = FinalReleaseGlue;
  1822. }
  1823. ULONG STDMETHODCALLTYPE AddRef()
  1824. {
  1825. return RtlAddRefMemoryStream(*this);
  1826. }
  1827. ULONG STDMETHODCALLTYPE ReleaseRef()
  1828. {
  1829. return RtlReleaseMemoryStream(*this);
  1830. }
  1831. HRESULT STDMETHODCALLTYPE QueryInterface(
  1832. const IID& Interface,
  1833. PVOID* Object
  1834. )
  1835. {
  1836. return RtlQueryInterfaceMemoryStream(*this, &Interface, Object);
  1837. }
  1838. HRESULT STDMETHODCALLTYPE Read(
  1839. PVOID Buffer,
  1840. ULONG BytesToRead,
  1841. ULONG* BytesRead
  1842. )
  1843. {
  1844. return RtlReadMemoryStream(*this, Buffer, BytesToRead, BytesRead);
  1845. }
  1846. HRESULT STDMETHODCALLTYPE Write(
  1847. const VOID* Buffer,
  1848. ULONG BytesToWrite,
  1849. ULONG* BytesWritten
  1850. )
  1851. {
  1852. return RtlWriteMemoryStream(*this, Buffer, BytesToWrite, BytesWritten);
  1853. }
  1854. HRESULT STDMETHODCALLTYPE Seek(
  1855. LARGE_INTEGER Distance,
  1856. ULONG Origin,
  1857. ULARGE_INTEGER* NewPosition
  1858. )
  1859. {
  1860. return RtlSeekMemoryStream(*this, Distance, Origin, NewPosition);
  1861. }
  1862. HRESULT STDMETHODCALLTYPE SetSize(
  1863. ULARGE_INTEGER NewSize
  1864. )
  1865. {
  1866. return RtlSetMemoryStreamSize(*this, NewSize);
  1867. }
  1868. HRESULT STDMETHODCALLTYPE CopyTo(
  1869. IStream* AnotherStream,
  1870. ULARGE_INTEGER NumberOfBytesToCopy,
  1871. ULARGE_INTEGER* NumberOfBytesRead,
  1872. ULARGE_INTEGER* NumberOfBytesWritten
  1873. )
  1874. {
  1875. return RtlCopyMemoryStreamTo(
  1876. *this,
  1877. AnotherStream,
  1878. NumberOfBytesToCopy,
  1879. NumberOfBytesRead,
  1880. NumberOfBytesWritten);
  1881. }
  1882. HRESULT STDMETHODCALLTYPE Commit(
  1883. ULONG Flags
  1884. )
  1885. {
  1886. return RtlCommitMemoryStream(*this, Flags);
  1887. }
  1888. HRESULT STDMETHODCALLTYPE Revert()
  1889. {
  1890. return RtlRevertMemoryStream(*this);
  1891. }
  1892. HRESULT STDMETHODCALLTYPE LockRegion(
  1893. ULARGE_INTEGER Offset,
  1894. ULARGE_INTEGER NumberOfBytes,
  1895. ULONG LockType
  1896. )
  1897. {
  1898. return RtlLockMemoryStreamRegion(*this, Offset, NumberOfBytes, LockType);
  1899. }
  1900. HRESULT STDMETHODCALLTYPE UnlockRegion(
  1901. ULARGE_INTEGER Offset,
  1902. ULARGE_INTEGER NumberOfBytes,
  1903. ULONG LockType
  1904. )
  1905. {
  1906. return RtlUnlockMemoryStreamRegion(*this, Offset, NumberOfBytes, LockType);
  1907. }
  1908. HRESULT STDMETHODCALLTYPE Stat(
  1909. STATSTG* StatusInformation,
  1910. ULONG Flags
  1911. )
  1912. {
  1913. return RtlStatMemoryStream(*this, StatusInformation, Flags);
  1914. }
  1915. HRESULT STDMETHODCALLTYPE Clone(
  1916. IStream** NewStream
  1917. )
  1918. {
  1919. return RtlCloneMemoryStream(*this, NewStream);
  1920. }
  1921. private:
  1922. // can't do this outside the class because Data is not public
  1923. static void CompileTimeAssert() {
  1924. C_ASSERT(FIELD_OFFSET(RTL_MEMORY_STREAM_WITH_VTABLE, Data) == FIELD_OFFSET(CRtlMemoryStream, Data));
  1925. }
  1926. };
  1927. C_ASSERT(sizeof(RTL_MEMORY_STREAM_WITH_VTABLE) == sizeof(CRtlMemoryStream));
  1928. class DECLSPEC_NOVTABLE CRtlOutOfProcessMemoryStream : public IStream
  1929. {
  1930. protected:
  1931. operator PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE()
  1932. {
  1933. return reinterpret_cast<PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE>(this);
  1934. }
  1935. RTL_OUT_OF_PROCESS_MEMORY_STREAM_DATA Data;
  1936. public:
  1937. /* This conflicts with DECLSPEC_NOVTABLE
  1938. static VOID STDMETHODCALLTYPE FinalReleaseGlue(PRTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE This)
  1939. {
  1940. return reinterpret_cast<CRtlOutOfProcessMemoryStream*>(This)->FinalRelease();
  1941. }
  1942. virtual VOID STDMETHODCALLTYPE FinalRelease() { }
  1943. */
  1944. CRtlOutOfProcessMemoryStream()
  1945. {
  1946. RtlInitOutOfProcessMemoryStream(*this);
  1947. //Data.FinalRelease = FinalReleaseGlue;
  1948. }
  1949. ULONG STDMETHODCALLTYPE AddRef()
  1950. {
  1951. return RtlAddRefOutOfProcessMemoryStream(*this);
  1952. }
  1953. ULONG STDMETHODCALLTYPE ReleaseRef()
  1954. {
  1955. return RtlReleaseOutOfProcessMemoryStream(*this);
  1956. }
  1957. HRESULT STDMETHODCALLTYPE QueryInterface(
  1958. const IID& Interface,
  1959. PVOID* Object
  1960. )
  1961. {
  1962. return RtlQueryInterfaceOutOfProcessMemoryStream(*this, &Interface, Object);
  1963. }
  1964. HRESULT STDMETHODCALLTYPE Read(
  1965. PVOID Buffer,
  1966. ULONG BytesToRead,
  1967. ULONG* BytesRead
  1968. )
  1969. {
  1970. return RtlReadOutOfProcessMemoryStream(*this, Buffer, BytesToRead, BytesRead);
  1971. }
  1972. HRESULT STDMETHODCALLTYPE Write(
  1973. const VOID* Buffer,
  1974. ULONG BytesToWrite,
  1975. ULONG* BytesWritten
  1976. )
  1977. {
  1978. return RtlWriteOutOfProcessMemoryStream(*this, Buffer, BytesToWrite, BytesWritten);
  1979. }
  1980. HRESULT STDMETHODCALLTYPE Seek(
  1981. LARGE_INTEGER Distance,
  1982. ULONG Origin,
  1983. ULARGE_INTEGER* NewPosition
  1984. )
  1985. {
  1986. return RtlSeekOutOfProcessMemoryStream(*this, Distance, Origin, NewPosition);
  1987. }
  1988. HRESULT STDMETHODCALLTYPE SetSize(
  1989. ULARGE_INTEGER NewSize
  1990. )
  1991. {
  1992. return RtlSetOutOfProcessMemoryStreamSize(*this, NewSize);
  1993. }
  1994. HRESULT STDMETHODCALLTYPE CopyTo(
  1995. IStream* AnotherStream,
  1996. ULARGE_INTEGER NumberOfBytesToCopy,
  1997. ULARGE_INTEGER* NumberOfBytesRead,
  1998. ULARGE_INTEGER* NumberOfBytesWritten
  1999. )
  2000. {
  2001. return RtlCopyOutOfProcessMemoryStreamTo(
  2002. *this,
  2003. AnotherStream,
  2004. NumberOfBytesToCopy,
  2005. NumberOfBytesRead,
  2006. NumberOfBytesWritten);
  2007. }
  2008. HRESULT STDMETHODCALLTYPE Commit(
  2009. ULONG Flags
  2010. )
  2011. {
  2012. return RtlCommitOutOfProcessMemoryStream(*this, Flags);
  2013. }
  2014. HRESULT STDMETHODCALLTYPE Revert()
  2015. {
  2016. return RtlRevertOutOfProcessMemoryStream(*this);
  2017. }
  2018. HRESULT STDMETHODCALLTYPE LockRegion(
  2019. ULARGE_INTEGER Offset,
  2020. ULARGE_INTEGER NumberOfBytes,
  2021. ULONG LockType
  2022. )
  2023. {
  2024. return RtlLockOutOfProcessMemoryStreamRegion(*this, Offset, NumberOfBytes, LockType);
  2025. }
  2026. HRESULT STDMETHODCALLTYPE UnlockRegion(
  2027. ULARGE_INTEGER Offset,
  2028. ULARGE_INTEGER NumberOfBytes,
  2029. ULONG LockType
  2030. )
  2031. {
  2032. return RtlUnlockOutOfProcessMemoryStreamRegion(*this, Offset, NumberOfBytes, LockType);
  2033. }
  2034. HRESULT STDMETHODCALLTYPE Stat(
  2035. STATSTG* StatusInformation,
  2036. ULONG Flags
  2037. )
  2038. {
  2039. return RtlStatOutOfProcessMemoryStream(*this, StatusInformation, Flags);
  2040. }
  2041. HRESULT STDMETHODCALLTYPE Clone(
  2042. IStream** NewStream
  2043. )
  2044. {
  2045. return RtlCloneOutOfProcessMemoryStream(*this, NewStream);
  2046. }
  2047. private:
  2048. // can't do this outside the class because Data is not public
  2049. static void CompileTimeAssert() {
  2050. C_ASSERT(FIELD_OFFSET(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE, Data) == FIELD_OFFSET(CRtlOutOfProcessMemoryStream, Data));
  2051. }
  2052. };
  2053. C_ASSERT(sizeof(RTL_OUT_OF_PROCESS_MEMORY_STREAM_WITH_VTABLE) == sizeof(CRtlOutOfProcessMemoryStream));
  2054. #endif // __cplusplus
  2055. #endif // RTL_DECLARE_MEMORY_STREAM
  2056. #endif // RTL_DECLARE_STREAMS
  2057. #define RTL_CLOSE_HANDLE(handle_) ((handle_) != NULL ? NtClose(handle_) : STATUS_SUCCESS)
  2058. #define RTL_UNMAP_VIEW_OF_SECTION2(process_, base_) ((base_) != NULL ? NtUnmapViewOfSection((process_), (base_)) : STATUS_SUCCESS)
  2059. #define RTL_UNMAP_VIEW_OF_SECTION1(base_) (RTL_UNMAP_VIEW_OF_SECTION2(NtCurrentProcess(), (base_)))
  2060. #if defined(__cplusplus) && !defined(CINTERFACE)
  2061. #define RTL_RELEASE(punk_) do { if ((punk_) != NULL) { (punk_)->Release(); (punk_) = NULL; } } while(0)
  2062. #else
  2063. #define RTL_RELEASE(punk_) do { if ((punk_) != NULL) { (punk_)->lpVtbl->Release(punk_); (punk_) = NULL; } } while(0)
  2064. #endif
  2065. //
  2066. // Activation context management functions
  2067. //
  2068. //
  2069. // Data structures are visible both in ntrtl and Win32 APIs, so their
  2070. // definitions are factored out into a separate header file.
  2071. //
  2072. #define ACTCTX_PROCESS_DEFAULT ((void*)NULL)
  2073. //
  2074. // If you activate this activation context handle,
  2075. // all activation context queries fail and searches
  2076. // drop back to pre-activation context behavior, like
  2077. // searching PATH for .dlls.
  2078. //
  2079. // This constant works at the Win32 and Rtl level, but
  2080. // is intended only for Shell clients, so is kept out of winnt.h
  2081. //
  2082. #define ACTCTX_EMPTY ((void*)(LONG_PTR)-3)
  2083. //
  2084. // NULL can also mean ACTCTX_SYSTEM_DEFAULT. We are between decisions
  2085. // on NULL plus a flag, magic numbers and/or static instances. I generally
  2086. // favor public magic numbers internally mapped to static instances, but
  2087. // I was pushed toward flags to start.
  2088. //
  2089. #define ACTCTX_SYSTEM_DEFAULT ((void*)(LONG_PTR)-4)
  2090. //
  2091. // Reserve a small range of values, 0 through -7.
  2092. // (Note that NtCurrentProcess() == -1, NtCurrentThread() == -2, so I avoided
  2093. // those, though this macro picks them up.)
  2094. //
  2095. // We subtract one instead of comparing against NULL seperately to avoid
  2096. // evaluating the macro parameter more than once.
  2097. //
  2098. #define IS_SPECIAL_ACTCTX(x) (((((LONG_PTR)(x)) - 1) | 7) == -1)
  2099. typedef struct _ACTIVATION_CONTEXT *PACTIVATION_CONTEXT;
  2100. typedef const struct _ACTIVATION_CONTEXT *PCACTIVATION_CONTEXT;
  2101. #define INVALID_ACTIVATION_CONTEXT ((PACTIVATION_CONTEXT) ((LONG_PTR) -1))
  2102. // begin_winnt
  2103. typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
  2104. ActivationContextBasicInformation = 1,
  2105. ActivationContextDetailedInformation = 2,
  2106. AssemblyDetailedInformationInActivationContext = 3,
  2107. FileInformationInAssemblyOfAssemblyInActivationContext = 4,
  2108. MaxActivationContextInfoClass,
  2109. //
  2110. // compatibility with old names
  2111. //
  2112. AssemblyDetailedInformationInActivationContxt = 3,
  2113. FileInformationInAssemblyOfAssemblyInActivationContxt = 4
  2114. } ACTIVATION_CONTEXT_INFO_CLASS;
  2115. #define ACTIVATIONCONTEXTINFOCLASS ACTIVATION_CONTEXT_INFO_CLASS
  2116. // end_winnt
  2117. #define RTL_QUERY_INFORMATION_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT (0x00000001)
  2118. #define RTL_QUERY_INFORMATION_ACTIVATION_CONTEXT_FLAG_ACTIVATION_CONTEXT_IS_MODULE (0x00000002)
  2119. #define RTL_QUERY_INFORMATION_ACTIVATION_CONTEXT_FLAG_ACTIVATION_CONTEXT_IS_ADDRESS (0x00000004)
  2120. #define RTL_QUERY_INFORMATION_ACTIVATION_CONTEXT_FLAG_NO_ADDREF (0x80000000)
  2121. // begin_winnt
  2122. typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
  2123. ULONG ulAssemblyIndex;
  2124. ULONG ulFileIndexInAssembly;
  2125. } ACTIVATION_CONTEXT_QUERY_INDEX, * PACTIVATION_CONTEXT_QUERY_INDEX;
  2126. typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX * PCACTIVATION_CONTEXT_QUERY_INDEX;
  2127. // end_winnt
  2128. NTSYSAPI
  2129. NTSTATUS
  2130. NTAPI
  2131. RtlQueryInformationActivationContext(
  2132. IN ULONG Flags,
  2133. IN PCACTIVATION_CONTEXT ActivationContext,
  2134. IN PVOID SubInstanceIndex,
  2135. IN ACTIVATION_CONTEXT_INFO_CLASS ActivationContextInformationClass,
  2136. OUT PVOID ActivationContextInformation,
  2137. IN SIZE_T ActivationContextInformationLength,
  2138. OUT PSIZE_T ReturnLength OPTIONAL
  2139. );
  2140. NTSYSAPI
  2141. NTSTATUS
  2142. NTAPI
  2143. RtlQueryInformationActiveActivationContext(
  2144. IN ACTIVATION_CONTEXT_INFO_CLASS ActivationContextInformationClass,
  2145. OUT PVOID ActivationContextInformation,
  2146. IN SIZE_T ActivationContextInformationLength,
  2147. OUT PSIZE_T ReturnLength OPTIONAL
  2148. );
  2149. #define FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_PROCESS_DEFAULT (0x00000001)
  2150. #define FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_SYSTEM_DEFAULT (0x00000002)
  2151. #if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
  2152. #if !defined(ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED)
  2153. typedef struct _ACTIVATION_CONTEXT_BASIC_INFORMATION {
  2154. union {
  2155. struct _ACTIVATION_CONTEXT *ActivationContext;
  2156. HANDLE hActCtx; // for compatibility with windows.h/winbase.h clients
  2157. };
  2158. ULONG Flags;
  2159. } ACTIVATION_CONTEXT_BASIC_INFORMATION, *PACTIVATION_CONTEXT_BASIC_INFORMATION;
  2160. typedef const struct _ACTIVATION_CONTEXT_BASIC_INFORMATION *PCACTIVATION_CONTEXT_BASIC_INFORMATION;
  2161. #define ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED 1
  2162. #endif // !defined(ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED)
  2163. #endif
  2164. // begin_winnt
  2165. #define ACTIVATION_CONTEXT_PATH_TYPE_NONE (1)
  2166. #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE (2)
  2167. #define ACTIVATION_CONTEXT_PATH_TYPE_URL (3)
  2168. #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF (4)
  2169. typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
  2170. ULONG ulFlags;
  2171. ULONG ulFilenameLength;
  2172. ULONG ulPathLength;
  2173. PCWSTR lpFileName;
  2174. PCWSTR lpFilePath;
  2175. } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
  2176. typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
  2177. //
  2178. // compatibility with old names
  2179. // The new names use "file" consistently.
  2180. //
  2181. #define _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION _ASSEMBLY_FILE_DETAILED_INFORMATION
  2182. #define ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION ASSEMBLY_FILE_DETAILED_INFORMATION
  2183. #define PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PASSEMBLY_FILE_DETAILED_INFORMATION
  2184. #define PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PCASSEMBLY_FILE_DETAILED_INFORMATION
  2185. typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
  2186. ULONG ulFlags;
  2187. ULONG ulEncodedAssemblyIdentityLength; // in bytes
  2188. ULONG ulManifestPathType; // ACTIVATION_CONTEXT_PATH_TYPE_*
  2189. ULONG ulManifestPathLength; // in bytes
  2190. LARGE_INTEGER liManifestLastWriteTime; // FILETIME
  2191. ULONG ulPolicyPathType; // ACTIVATION_CONTEXT_PATH_TYPE_*
  2192. ULONG ulPolicyPathLength; // in bytes
  2193. LARGE_INTEGER liPolicyLastWriteTime; // FILETIME
  2194. ULONG ulMetadataSatelliteRosterIndex;
  2195. ULONG ulManifestVersionMajor; // 1
  2196. ULONG ulManifestVersionMinor; // 0
  2197. ULONG ulPolicyVersionMajor; // 0
  2198. ULONG ulPolicyVersionMinor; // 0
  2199. ULONG ulAssemblyDirectoryNameLength; // in bytes
  2200. PCWSTR lpAssemblyEncodedAssemblyIdentity;
  2201. PCWSTR lpAssemblyManifestPath;
  2202. PCWSTR lpAssemblyPolicyPath;
  2203. PCWSTR lpAssemblyDirectoryName;
  2204. ULONG ulFileCount;
  2205. } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, * PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
  2206. typedef const struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION * PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION ;
  2207. typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
  2208. ULONG dwFlags;
  2209. ULONG ulFormatVersion;
  2210. ULONG ulAssemblyCount;
  2211. ULONG ulRootManifestPathType;
  2212. ULONG ulRootManifestPathChars;
  2213. ULONG ulRootConfigurationPathType;
  2214. ULONG ulRootConfigurationPathChars;
  2215. ULONG ulAppDirPathType;
  2216. ULONG ulAppDirPathChars;
  2217. PCWSTR lpRootManifestPath;
  2218. PCWSTR lpRootConfigurationPath;
  2219. PCWSTR lpAppDirPath;
  2220. } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
  2221. typedef const struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_DETAILED_INFORMATION;
  2222. // end_winnt
  2223. typedef struct _FINDFIRSTACTIVATIONCONTEXTSECTION {
  2224. ULONG Size;
  2225. ULONG Flags;
  2226. const GUID *ExtensionGuid;
  2227. ULONG Id;
  2228. ULONG Depth;
  2229. ULONG OutFlags;
  2230. } FINDFIRSTACTIVATIONCONTEXTSECTION, *PFINDFIRSTACTIVATIONCONTEXTSECTION;
  2231. typedef const FINDFIRSTACTIVATIONCONTEXTSECTION * PCFINDFIRSTACTIVATIONCONTEXTSECTION;
  2232. #define ACTIVATION_CONTEXT_NOTIFICATION_DESTROY (1)
  2233. #define ACTIVATION_CONTEXT_NOTIFICATION_ZOMBIFY (2)
  2234. #define ACTIVATION_CONTEXT_NOTIFICATION_USED (3)
  2235. typedef
  2236. VOID (NTAPI * PACTIVATION_CONTEXT_NOTIFY_ROUTINE)(
  2237. IN ULONG NotificationType,
  2238. IN PACTIVATION_CONTEXT ActivationContext,
  2239. IN const VOID *ActivationContextData,
  2240. IN PVOID NotificationContext,
  2241. IN PVOID NotificationData,
  2242. IN OUT PBOOLEAN DisableThisNotification
  2243. );
  2244. NTSYSAPI
  2245. NTSTATUS
  2246. NTAPI
  2247. RtlInitializeSxs(
  2248. VOID
  2249. );
  2250. NTSYSAPI
  2251. NTSTATUS
  2252. NTAPI
  2253. RtlCreateActivationContext(
  2254. IN ULONG Flags,
  2255. IN PVOID ActivationContextData,
  2256. IN ULONG ExtraBytes OPTIONAL,
  2257. IN PACTIVATION_CONTEXT_NOTIFY_ROUTINE NotificationRoutine OPTIONAL,
  2258. IN PVOID NotificationContext OPTIONAL,
  2259. OUT PACTIVATION_CONTEXT *ActivationContext
  2260. );
  2261. NTSYSAPI
  2262. VOID
  2263. NTAPI
  2264. RtlAddRefActivationContext(
  2265. IN PACTIVATION_CONTEXT AppCtx
  2266. );
  2267. NTSYSAPI
  2268. VOID
  2269. NTAPI
  2270. RtlReleaseActivationContext(
  2271. IN PACTIVATION_CONTEXT AppCtx
  2272. );
  2273. NTSYSAPI
  2274. NTSTATUS
  2275. NTAPI
  2276. RtlZombifyActivationContext(
  2277. IN PACTIVATION_CONTEXT ActivationContext
  2278. );
  2279. NTSYSAPI
  2280. NTSTATUS
  2281. NTAPI
  2282. RtlGetActiveActivationContext(
  2283. OUT PACTIVATION_CONTEXT *ActivationContext
  2284. );
  2285. NTSYSAPI
  2286. BOOLEAN
  2287. NTAPI
  2288. RtlIsActivationContextActive(
  2289. IN PACTIVATION_CONTEXT ActivationContext
  2290. );
  2291. typedef struct _ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_BEGINNING {
  2292. IN VOID const * Data; // pointer to activation context data
  2293. IN ULONG AssemblyRosterIndex;
  2294. OUT PVOID ResolutionContext;
  2295. OUT UNICODE_STRING Root; // Root path - a default buffer is passed in; if
  2296. // it is not large enough, callback must allocate
  2297. // a string using the RtlAllocateStringRoutine
  2298. // function pointer.
  2299. OUT BOOLEAN KnownRoot; // default is FALSE; set to TRUE if you were able to
  2300. // resolve the storage root immediately. this is
  2301. // how to handle things like run-from-source where
  2302. // the assembly is on read-only removable media like
  2303. // a CD-ROM. If you set it to TRUE, the _SUCCESSFUL
  2304. // vs. _UNSUCCESSFUL callbacks are not made.
  2305. OUT SIZE_T RootCount; // Caller may set to ((SIZE_T) -1) and use the
  2306. // .NoMoreEntries BOOLEAN in the callback to stop enumeration
  2307. OUT BOOLEAN CancelResolution; // set to true if you want to stop the resolution
  2308. } ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_BEGINNING;
  2309. typedef struct _ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_GET_ROOT {
  2310. IN PVOID ResolutionContext;
  2311. IN SIZE_T RootIndex;
  2312. OUT BOOLEAN CancelResolution; // set to true if you want to stop the resolution with STATUS_CANCELLED
  2313. OUT BOOLEAN NoMoreEntries; // set to TRUE if you have no more roots to return.
  2314. OUT UNICODE_STRING Root; // If for some reason you want to skip this index; set .Length to zero
  2315. } ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_GET_ROOT;
  2316. typedef struct _ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_SUCCESSFUL {
  2317. IN PVOID ResolutionContext;
  2318. IN ULONG RootIndexUsed;
  2319. } ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_SUCCESSFUL;
  2320. typedef struct _ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_ENDING {
  2321. IN PVOID ResolutionContext;
  2322. } ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_ENDING;
  2323. typedef union _ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA {
  2324. ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_BEGINNING ResolutionBeginning;
  2325. ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_GET_ROOT GetRoot;
  2326. ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_SUCCESSFUL ResolutionSuccessful;
  2327. ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA_RESOLUTION_ENDING ResolutionEnding;
  2328. } ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA, *PASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA;
  2329. #define ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_REASON_RESOLUTION_BEGINNING (1)
  2330. #define ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_REASON_GET_ROOT (2)
  2331. #define ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_REASON_RESOLUTION_SUCCESSFUL (3)
  2332. #define ASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_REASON_RESOLUTION_ENDING (4)
  2333. typedef
  2334. VOID (NTAPI * PASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_ROUTINE)(
  2335. IN ULONG CallbackReason,
  2336. IN OUT PASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_DATA CallbackData,
  2337. IN PVOID CallbackContext
  2338. );
  2339. NTSYSAPI
  2340. NTSTATUS
  2341. NTAPI
  2342. RtlResolveAssemblyStorageMapEntry(
  2343. IN ULONG Flags,
  2344. IN PACTIVATION_CONTEXT ActivationContext,
  2345. IN ULONG AssemblyRosterIndex,
  2346. IN PASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_ROUTINE Callback,
  2347. IN PVOID CallbackContext
  2348. );
  2349. #define RTL_GET_ASSEMBLY_STORAGE_ROOT_FLAG_ACTIVATION_CONTEXT_USE_PROCESS_DEFAULT (0x00000001)
  2350. #define RTL_GET_ASSEMBLY_STORAGE_ROOT_FLAG_ACTIVATION_CONTEXT_USE_SYSTEM_DEFAULT (0x00000002)
  2351. NTSYSAPI
  2352. NTSTATUS
  2353. NTAPI
  2354. RtlGetAssemblyStorageRoot(
  2355. IN ULONG Flags,
  2356. IN PACTIVATION_CONTEXT ActivationContext,
  2357. IN ULONG AssemblyRosterIndex,
  2358. OUT PCUNICODE_STRING *AssemblyStorageRoot,
  2359. IN PASSEMBLY_STORAGE_MAP_RESOLUTION_CALLBACK_ROUTINE Callback,
  2360. IN PVOID CallbackContext
  2361. );
  2362. //
  2363. // Macro to enable avoiding calling RtlFindActivationContext* APIs if
  2364. // there is no side-by-side redirection going on in the process
  2365. // at all.
  2366. //
  2367. #if NTOS_KERNEL_RUNTIME
  2368. //
  2369. // For kernel mode, this needs to be a real function with probes etc.
  2370. // since it references the process state (peb/teb).
  2371. //
  2372. NTSYSAPI
  2373. BOOLEAN
  2374. NTAPI
  2375. RtlAnyActivationContextDataAvailable(VOID);
  2376. #else
  2377. #define RtlAnyActivationContextDataAvailable() \
  2378. ((NtCurrentTeb()->ActivationContextStack != NULL) || \
  2379. (NtCurrentPeb()->ActivationContextData != NULL) || \
  2380. (NtCurrentPeb()->SystemDefaultActivationContextData != NULL))
  2381. #endif // NTOS_KERNEL_RUNTIME
  2382. #define RtlIsProcessDefaultActivationContextActive() ((NtCurrentTeb()->ActivationContextStack == NULL) || RtlIsActivationContextActive(NULL))
  2383. #define ACTIVATION_CONTEXT_SECTION_KEYED_DATA_FLAG_FOUND_IN_PROCESS_DEFAULT (0x00000001)
  2384. #define ACTIVATION_CONTEXT_SECTION_KEYED_DATA_FLAG_FOUND_IN_SYSTEM_DEFAULT (0x00000002)
  2385. typedef struct _ACTIVATION_CONTEXT_SECTION_KEYED_DATA_2600 {
  2386. ULONG Size;
  2387. ULONG DataFormatVersion;
  2388. PVOID Data;
  2389. ULONG Length;
  2390. PVOID SectionGlobalData;
  2391. ULONG SectionGlobalDataLength;
  2392. PVOID SectionBase;
  2393. ULONG SectionTotalLength;
  2394. PACTIVATION_CONTEXT ActivationContext;
  2395. ULONG AssemblyRosterIndex;
  2396. ULONG Flags;
  2397. } ACTIVATION_CONTEXT_SECTION_KEYED_DATA_2600, *PACTIVATION_CONTEXT_SECTION_KEYED_DATA_2600;
  2398. typedef const ACTIVATION_CONTEXT_SECTION_KEYED_DATA_2600 *PCACTIVATION_CONTEXT_SECTION_KEYED_DATA_2600;
  2399. typedef struct _ACTIVATION_CONTEXT_SECTION_KEYED_DATA_ASSEMBLY_METADATA {
  2400. struct _ACTIVATION_CONTEXT_DATA_ASSEMBLY_INFORMATION * Information;
  2401. PVOID SectionBase;
  2402. ULONG SectionLength;
  2403. PVOID SectionGlobalDataBase;
  2404. ULONG SectionGlobalDataLength;
  2405. } ACTIVATION_CONTEXT_SECTION_KEYED_DATA_ASSEMBLY_METADATA, *PACTIVATION_CONTEXT_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2406. typedef const ACTIVATION_CONTEXT_SECTION_KEYED_DATA_ASSEMBLY_METADATA *PCACTIVATION_CONTEXT_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2407. typedef struct _ACTIVATION_CONTEXT_SECTION_KEYED_DATA {
  2408. ULONG Size;
  2409. ULONG DataFormatVersion;
  2410. PVOID Data;
  2411. ULONG Length;
  2412. PVOID SectionGlobalData;
  2413. ULONG SectionGlobalDataLength;
  2414. PVOID SectionBase;
  2415. ULONG SectionTotalLength;
  2416. PACTIVATION_CONTEXT ActivationContext;
  2417. ULONG AssemblyRosterIndex;
  2418. ULONG Flags;
  2419. // 2600 stops here
  2420. ACTIVATION_CONTEXT_SECTION_KEYED_DATA_ASSEMBLY_METADATA AssemblyMetadata;
  2421. } ACTIVATION_CONTEXT_SECTION_KEYED_DATA, *PACTIVATION_CONTEXT_SECTION_KEYED_DATA;
  2422. typedef const ACTIVATION_CONTEXT_SECTION_KEYED_DATA * PCACTIVATION_CONTEXT_SECTION_KEYED_DATA;
  2423. //
  2424. // Flags for the RtlFindActivationContextSection*() APIs
  2425. //
  2426. #define FIND_ACTIVATION_CONTEXT_SECTION_KEY_RETURN_ACTIVATION_CONTEXT (0x00000001)
  2427. #define FIND_ACTIVATION_CONTEXT_SECTION_KEY_RETURN_FLAGS (0x00000002)
  2428. #define FIND_ACTIVATION_CONTEXT_SECTION_KEY_RETURN_ASSEMBLY_METADATA (0x00000004)
  2429. NTSYSAPI
  2430. NTSTATUS
  2431. NTAPI
  2432. RtlFindActivationContextSectionString(
  2433. IN ULONG Flags,
  2434. IN const GUID *ExtensionGuid OPTIONAL,
  2435. IN ULONG SectionId,
  2436. IN PCUNICODE_STRING StringToFind,
  2437. IN OUT PACTIVATION_CONTEXT_SECTION_KEYED_DATA ReturnedData
  2438. );
  2439. NTSYSAPI
  2440. NTSTATUS
  2441. NTAPI
  2442. RtlFindActivationContextSectionGuid(
  2443. IN ULONG Flags,
  2444. IN const GUID *ExtensionGuid OPTIONAL,
  2445. IN ULONG SectionId,
  2446. IN const GUID *GuidToFind,
  2447. IN OUT PACTIVATION_CONTEXT_SECTION_KEYED_DATA ReturnedData
  2448. );
  2449. #define ACTIVATION_CONTEXT_ASSEMBLY_DATA_IS_ROOT_ASSEMBLY (0x00000001)
  2450. typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DATA {
  2451. ULONG Size;
  2452. ULONG Flags;
  2453. const WCHAR *AssemblyName;
  2454. ULONG AssemblyNameLength; // in bytes
  2455. ULONG HashAlgorithm;
  2456. ULONG PseudoKey;
  2457. } ACTIVATION_CONTEXT_ASSEMBLY_DATA, *PACTIVATION_CONTEXT_ASSEMBLY_DATA;
  2458. typedef const ACTIVATION_CONTEXT_ASSEMBLY_DATA *PCACTIVATION_CONTEXT_ASSEMBLY_DATA;
  2459. NTSYSAPI
  2460. NTSTATUS
  2461. NTAPI
  2462. RtlGetActivationContextAssemblyData(
  2463. IN PCACTIVATION_CONTEXT ActivationContext,
  2464. IN ULONG AssemblyRosterIndex, // note that valid indices are [1 .. AssemblyCount] inclusive
  2465. IN OUT PACTIVATION_CONTEXT_ASSEMBLY_DATA Data
  2466. );
  2467. NTSYSAPI
  2468. NTSTATUS
  2469. NTAPI
  2470. RtlGetActivationContextAssemblyCount(
  2471. IN PCACTIVATION_CONTEXT ActivationContext,
  2472. OUT ULONG *AssemblyCount
  2473. );
  2474. NTSYSAPI
  2475. VOID
  2476. NTAPI
  2477. RtlFreeThreadActivationContextStack(
  2478. VOID
  2479. );
  2480. NTSYSAPI
  2481. NTSTATUS
  2482. NTAPI
  2483. RtlFindFirstActivationContextSection(
  2484. IN OUT PFINDFIRSTACTIVATIONCONTEXTSECTION Context,
  2485. OUT PVOID *Section,
  2486. OUT ULONG *Length,
  2487. OUT PACTIVATION_CONTEXT *ActivationContext OPTIONAL
  2488. );
  2489. NTSYSAPI
  2490. NTSTATUS
  2491. NTAPI
  2492. RtlFindNextActivationContextSection(
  2493. IN OUT PFINDFIRSTACTIVATIONCONTEXTSECTION Context,
  2494. OUT PVOID *Section,
  2495. OUT ULONG *Length,
  2496. OUT PACTIVATION_CONTEXT *ActivationContext OPTIONAL
  2497. );
  2498. NTSYSAPI
  2499. VOID
  2500. NTAPI
  2501. RtlEndFindActivationContextSection(
  2502. IN PFINDFIRSTACTIVATIONCONTEXTSECTION Context
  2503. );
  2504. NTSYSAPI
  2505. NTSTATUS
  2506. NTAPI
  2507. RtlGetActivationContextStack(
  2508. PVOID *Stack
  2509. );
  2510. //
  2511. // RTL_ACTIVATION_CONTEXT_STACK_FRAME
  2512. //
  2513. #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_RELEASE_ON_DEACTIVATION (0x00000001)
  2514. #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_NO_DEACTIVATE (0x00000002)
  2515. #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_ON_FREE_LIST (0x00000004)
  2516. #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_HEAP_ALLOCATED (0x00000008)
  2517. #define RTL_ACTIVATION_CONTEXT_STACK_FRAME_FLAG_NOT_REALLY_ACTIVATED (0x00000010)
  2518. typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME {
  2519. struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME *Previous;
  2520. PACTIVATION_CONTEXT ActivationContext;
  2521. ULONG Flags;
  2522. } RTL_ACTIVATION_CONTEXT_STACK_FRAME, *PRTL_ACTIVATION_CONTEXT_STACK_FRAME;
  2523. typedef const struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME *PCRTL_ACTIVATION_CONTEXT_STACK_FRAME;
  2524. #define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER (1)
  2525. typedef struct _RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME {
  2526. SIZE_T Size;
  2527. ULONG Format;
  2528. RTL_ACTIVATION_CONTEXT_STACK_FRAME Frame;
  2529. } RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME, *PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME;
  2530. #define INVALID_ACTIVATION_CONTEXT_ACTIVATION_COOKIE ((ULONG_PTR) 0)
  2531. NTSYSAPI
  2532. NTSTATUS
  2533. NTAPI
  2534. RtlActivateActivationContext(
  2535. IN ULONG Flags,
  2536. IN PACTIVATION_CONTEXT ActivationContext,
  2537. OUT ULONG_PTR *Cookie
  2538. );
  2539. #define RTL_ACTIVATE_ACTIVATION_CONTEXT_EX_FLAG_RELEASE_ON_STACK_DEALLOCATION (0x00000001)
  2540. NTSYSAPI
  2541. NTSTATUS
  2542. NTAPI
  2543. RtlActivateActivationContextEx(
  2544. IN ULONG Flags,
  2545. IN PTEB Teb,
  2546. IN PACTIVATION_CONTEXT ActivationContext,
  2547. OUT PULONG_PTR Cookie
  2548. );
  2549. #define RTL_DEACTIVATE_ACTIVATION_CONTEXT_FLAG_FORCE_EARLY_DEACTIVATION (0x00000001)
  2550. NTSYSAPI
  2551. VOID
  2552. NTAPI
  2553. RtlDeactivateActivationContext(
  2554. IN ULONG Flags,
  2555. IN ULONG_PTR Cookie
  2556. );
  2557. NTSYSAPI
  2558. VOID
  2559. NTAPI
  2560. RtlActivateActivationContextUnsafeFast(
  2561. IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME Frame,
  2562. IN PACTIVATION_CONTEXT ActivationContext
  2563. );
  2564. NTSYSAPI
  2565. VOID
  2566. NTAPI
  2567. RtlDeactivateActivationContextUnsafeFast(
  2568. IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME Frame
  2569. );
  2570. NTSYSAPI
  2571. VOID
  2572. NTAPI
  2573. RtlPushFrame(
  2574. IN PTEB_ACTIVE_FRAME Frame
  2575. );
  2576. NTSYSAPI
  2577. VOID
  2578. NTAPI
  2579. RtlPopFrame(
  2580. IN PTEB_ACTIVE_FRAME Frame
  2581. );
  2582. NTSYSAPI
  2583. PTEB_ACTIVE_FRAME
  2584. NTAPI
  2585. RtlGetFrame(
  2586. VOID
  2587. );
  2588. NTSYSAPI
  2589. NTSTATUS
  2590. NTAPI
  2591. RtlGetNativeSystemInformation(
  2592. IN ULONG SystemInformationClass,
  2593. IN PVOID NativeSystemInformation,
  2594. IN ULONG InformationLength,
  2595. OUT PULONG ReturnLength OPTIONAL
  2596. );
  2597. #if defined (_MSC_VER) && ( _MSC_VER >= 800 )
  2598. #if _MSC_VER >= 1200
  2599. #pragma warning(pop)
  2600. #else
  2601. #pragma warning(default:4001)
  2602. #pragma warning(default:4201)
  2603. #pragma warning(default:4214)
  2604. #endif
  2605. #endif
  2606. #ifdef __cplusplus
  2607. } // extern "C"
  2608. #endif
  2609. #endif // _NTURTL_