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.

8701 lines
285 KiB

  1. /*++ BUILD Version: 0082 Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. winnt.h
  5. Abstract:
  6. This module defines the 32-Bit Windows types and constants that are
  7. defined by NT, but exposed through the Win32 API.
  8. Revision History:
  9. --*/
  10. #ifndef _WINNT_
  11. #define _WINNT_
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <ctype.h>
  16. #define ANYSIZE_ARRAY 1
  17. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  18. #define RESTRICTED_POINTER __restrict
  19. #else
  20. #define RESTRICTED_POINTER
  21. #endif
  22. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
  23. #define UNALIGNED __unaligned
  24. #if defined(_WIN64)
  25. #define UNALIGNED64 __unaligned
  26. #else
  27. #define UNALIGNED64
  28. #endif
  29. #else
  30. #define UNALIGNED
  31. #define UNALIGNED64
  32. #endif
  33. #if defined(_WIN64) || defined(_M_ALPHA)
  34. #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
  35. #define MEMORY_ALLOCATION_ALIGNMENT 16
  36. #else
  37. #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
  38. #define MEMORY_ALLOCATION_ALIGNMENT 8
  39. #endif
  40. //
  41. // TYPE_ALIGNMENT will return the alignment requirements of a given type for
  42. // the current platform.
  43. //
  44. #ifdef __cplusplus
  45. #if _MSC_VER >= 1300
  46. #define TYPE_ALIGNMENT( t ) __alignof(t)
  47. #endif
  48. #else
  49. #define TYPE_ALIGNMENT( t ) \
  50. FIELD_OFFSET( struct { char x; t test; }, test )
  51. #endif
  52. #if defined(_WIN64)
  53. #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( DWORD ) ? \
  54. TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( DWORD ))
  55. #define PROBE_ALIGNMENT32( _s ) TYPE_ALIGNMENT( DWORD )
  56. #else
  57. #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
  58. #endif
  59. //
  60. // C_ASSERT() can be used to perform many compile-time assertions:
  61. // type sizes, field offsets, etc.
  62. //
  63. // An assertion failure results in error C2118: negative subscript.
  64. //
  65. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  66. #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  67. #define POINTER_64 __ptr64
  68. typedef unsigned __int64 POINTER_64_INT;
  69. #if defined(_WIN64)
  70. #define POINTER_32 __ptr32
  71. #else
  72. #define POINTER_32
  73. #endif
  74. #else
  75. #if defined(_MAC) && defined(_MAC_INT_64)
  76. #define POINTER_64 __ptr64
  77. typedef unsigned __int64 POINTER_64_INT;
  78. #else
  79. #define POINTER_64
  80. typedef unsigned long POINTER_64_INT;
  81. #endif
  82. #define POINTER_32
  83. #endif
  84. #if defined(_IA64_) || defined(_AMD64_)
  85. #define FIRMWARE_PTR
  86. #else
  87. #define FIRMWARE_PTR POINTER_32
  88. #endif
  89. #include <basetsd.h>
  90. #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64)) && !defined(MIDL_PASS)
  91. #define DECLSPEC_IMPORT __declspec(dllimport)
  92. #else
  93. #define DECLSPEC_IMPORT
  94. #endif
  95. #ifndef DECLSPEC_NORETURN
  96. #if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
  97. #define DECLSPEC_NORETURN __declspec(noreturn)
  98. #else
  99. #define DECLSPEC_NORETURN
  100. #endif
  101. #endif
  102. #ifndef DECLSPEC_ALIGN
  103. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  104. #define DECLSPEC_ALIGN(x) __declspec(align(x))
  105. #else
  106. #define DECLSPEC_ALIGN(x)
  107. #endif
  108. #endif
  109. #ifndef DECLSPEC_CACHEALIGN
  110. #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
  111. #endif
  112. #ifndef DECLSPEC_UUID
  113. #if (_MSC_VER >= 1100) && defined (__cplusplus)
  114. #define DECLSPEC_UUID(x) __declspec(uuid(x))
  115. #else
  116. #define DECLSPEC_UUID(x)
  117. #endif
  118. #endif
  119. #ifndef DECLSPEC_NOVTABLE
  120. #if (_MSC_VER >= 1100) && defined(__cplusplus)
  121. #define DECLSPEC_NOVTABLE __declspec(novtable)
  122. #else
  123. #define DECLSPEC_NOVTABLE
  124. #endif
  125. #endif
  126. #ifndef DECLSPEC_SELECTANY
  127. #if (_MSC_VER >= 1100)
  128. #define DECLSPEC_SELECTANY __declspec(selectany)
  129. #else
  130. #define DECLSPEC_SELECTANY
  131. #endif
  132. #endif
  133. #ifndef NOP_FUNCTION
  134. #if (_MSC_VER >= 1210)
  135. #define NOP_FUNCTION __noop
  136. #else
  137. #define NOP_FUNCTION (void)0
  138. #endif
  139. #endif
  140. #ifndef DECLSPEC_ADDRSAFE
  141. #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
  142. #define DECLSPEC_ADDRSAFE __declspec(address_safe)
  143. #else
  144. #define DECLSPEC_ADDRSAFE
  145. #endif
  146. #endif
  147. #ifndef FORCEINLINE
  148. #if (_MSC_VER >= 1200)
  149. #define FORCEINLINE __forceinline
  150. #else
  151. #define FORCEINLINE __inline
  152. #endif
  153. #endif
  154. #ifndef DECLSPEC_DEPRECATED
  155. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  156. #define DECLSPEC_DEPRECATED __declspec(deprecated)
  157. #define DEPRECATE_SUPPORTED
  158. #else
  159. #define DECLSPEC_DEPRECATED
  160. #undef DEPRECATE_SUPPORTED
  161. #endif
  162. #endif
  163. typedef void *PVOID;
  164. typedef void * POINTER_64 PVOID64;
  165. #if ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) && !defined(_M_AMD64)
  166. #define NTAPI __stdcall
  167. #else
  168. #define _cdecl
  169. #define NTAPI
  170. #endif
  171. //
  172. // Define API decoration for direct importing system DLL references.
  173. //
  174. #if !defined(_NTSYSTEM_)
  175. #define NTSYSAPI DECLSPEC_IMPORT
  176. #define NTSYSCALLAPI DECLSPEC_IMPORT
  177. #else
  178. #define NTSYSAPI
  179. #if defined(_NTDLLBUILD_)
  180. #define NTSYSCALLAPI
  181. #else
  182. #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
  183. #endif
  184. #endif
  185. //
  186. // Basics
  187. //
  188. #ifndef VOID
  189. #define VOID void
  190. typedef char CHAR;
  191. typedef short SHORT;
  192. typedef long LONG;
  193. #endif
  194. //
  195. // UNICODE (Wide Character) types
  196. //
  197. #ifndef _MAC
  198. typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
  199. #else
  200. // some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
  201. typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
  202. #endif
  203. typedef WCHAR *PWCHAR;
  204. typedef WCHAR *LPWCH, *PWCH;
  205. typedef CONST WCHAR *LPCWCH, *PCWCH;
  206. typedef WCHAR *NWPSTR;
  207. typedef WCHAR *LPWSTR, *PWSTR;
  208. typedef WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
  209. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  210. typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
  211. //
  212. // ANSI (Multi-byte Character) types
  213. //
  214. typedef CHAR *PCHAR;
  215. typedef CHAR *LPCH, *PCH;
  216. typedef CONST CHAR *LPCCH, *PCCH;
  217. typedef CHAR *NPSTR;
  218. typedef CHAR *LPSTR, *PSTR;
  219. typedef CONST CHAR *LPCSTR, *PCSTR;
  220. //
  221. // Neutral ANSI/UNICODE types and macros
  222. //
  223. #ifdef UNICODE // r_winnt
  224. #ifndef _TCHAR_DEFINED
  225. typedef WCHAR TCHAR, *PTCHAR;
  226. typedef WCHAR TBYTE , *PTBYTE ;
  227. #define _TCHAR_DEFINED
  228. #endif /* !_TCHAR_DEFINED */
  229. typedef LPWSTR LPTCH, PTCH;
  230. typedef LPWSTR PTSTR, LPTSTR;
  231. typedef LPCWSTR PCTSTR, LPCTSTR;
  232. typedef LPUWSTR PUTSTR, LPUTSTR;
  233. typedef LPCUWSTR PCUTSTR, LPCUTSTR;
  234. typedef LPWSTR LP;
  235. #define __TEXT(quote) L##quote // r_winnt
  236. #else /* UNICODE */ // r_winnt
  237. #ifndef _TCHAR_DEFINED
  238. typedef char TCHAR, *PTCHAR;
  239. typedef unsigned char TBYTE , *PTBYTE ;
  240. #define _TCHAR_DEFINED
  241. #endif /* !_TCHAR_DEFINED */
  242. typedef LPSTR LPTCH, PTCH;
  243. typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
  244. typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
  245. #define __TEXT(quote) quote // r_winnt
  246. #endif /* UNICODE */ // r_winnt
  247. #define TEXT(quote) __TEXT(quote) // r_winnt
  248. typedef SHORT *PSHORT;
  249. typedef LONG *PLONG;
  250. #ifdef STRICT
  251. typedef void *HANDLE;
  252. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  253. #else
  254. typedef PVOID HANDLE;
  255. #define DECLARE_HANDLE(name) typedef HANDLE name
  256. #endif
  257. typedef HANDLE *PHANDLE;
  258. //
  259. // Flag (bit) fields
  260. //
  261. typedef BYTE FCHAR;
  262. typedef WORD FSHORT;
  263. typedef DWORD FLONG;
  264. // Component Object Model defines, and macros
  265. #ifndef _HRESULT_DEFINED
  266. #define _HRESULT_DEFINED
  267. typedef LONG HRESULT;
  268. #endif // !_HRESULT_DEFINED
  269. #ifdef __cplusplus
  270. #define EXTERN_C extern "C"
  271. #else
  272. #define EXTERN_C extern
  273. #endif
  274. #if defined(_WIN32) || defined(_MPPC_)
  275. // Win32 doesn't support __export
  276. #ifdef _68K_
  277. #define STDMETHODCALLTYPE __cdecl
  278. #else
  279. #define STDMETHODCALLTYPE __stdcall
  280. #endif
  281. #define STDMETHODVCALLTYPE __cdecl
  282. #define STDAPICALLTYPE __stdcall
  283. #define STDAPIVCALLTYPE __cdecl
  284. #else
  285. #define STDMETHODCALLTYPE __export __stdcall
  286. #define STDMETHODVCALLTYPE __export __cdecl
  287. #define STDAPICALLTYPE __export __stdcall
  288. #define STDAPIVCALLTYPE __export __cdecl
  289. #endif
  290. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  291. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  292. #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
  293. #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  294. // The 'V' versions allow Variable Argument lists.
  295. #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
  296. #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
  297. #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
  298. #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
  299. typedef char CCHAR;
  300. typedef DWORD LCID;
  301. typedef PDWORD PLCID;
  302. typedef WORD LANGID;
  303. #define APPLICATION_ERROR_MASK 0x20000000
  304. #define ERROR_SEVERITY_SUCCESS 0x00000000
  305. #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
  306. #define ERROR_SEVERITY_WARNING 0x80000000
  307. #define ERROR_SEVERITY_ERROR 0xC0000000
  308. //
  309. // _M_IX86 included so that EM CONTEXT structure compiles with
  310. // x86 programs. *** TBD should this be for all architectures?
  311. //
  312. //
  313. // 16 byte aligned type for 128 bit floats
  314. //
  315. //
  316. // For we define a 128 bit structure and use __declspec(align(16)) pragma to
  317. // align to 128 bits.
  318. //
  319. #if defined(_M_IA64) && !defined(MIDL_PASS)
  320. __declspec(align(16))
  321. #endif
  322. typedef struct _FLOAT128 {
  323. __int64 LowPart;
  324. __int64 HighPart;
  325. } FLOAT128;
  326. typedef FLOAT128 *PFLOAT128;
  327. //
  328. // __int64 is only supported by 2.0 and later midl.
  329. // __midl is set by the 2.0 midl and not by 1.0 midl.
  330. //
  331. #define _ULONGLONG_
  332. #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64)))
  333. typedef __int64 LONGLONG;
  334. typedef unsigned __int64 ULONGLONG;
  335. #define MAXLONGLONG (0x7fffffffffffffff)
  336. #else
  337. #if defined(_MAC) && defined(_MAC_INT_64)
  338. typedef __int64 LONGLONG;
  339. typedef unsigned __int64 ULONGLONG;
  340. #define MAXLONGLONG (0x7fffffffffffffff)
  341. #else
  342. typedef double LONGLONG;
  343. typedef double ULONGLONG;
  344. #endif //_MAC and int64
  345. #endif
  346. typedef LONGLONG *PLONGLONG;
  347. typedef ULONGLONG *PULONGLONG;
  348. // Update Sequence Number
  349. typedef LONGLONG USN;
  350. #if defined(MIDL_PASS)
  351. typedef struct _LARGE_INTEGER {
  352. #else // MIDL_PASS
  353. typedef union _LARGE_INTEGER {
  354. struct {
  355. DWORD LowPart;
  356. LONG HighPart;
  357. };
  358. struct {
  359. DWORD LowPart;
  360. LONG HighPart;
  361. } u;
  362. #endif //MIDL_PASS
  363. LONGLONG QuadPart;
  364. } LARGE_INTEGER;
  365. typedef LARGE_INTEGER *PLARGE_INTEGER;
  366. #if defined(MIDL_PASS)
  367. typedef struct _ULARGE_INTEGER {
  368. #else // MIDL_PASS
  369. typedef union _ULARGE_INTEGER {
  370. struct {
  371. DWORD LowPart;
  372. DWORD HighPart;
  373. };
  374. struct {
  375. DWORD LowPart;
  376. DWORD HighPart;
  377. } u;
  378. #endif //MIDL_PASS
  379. ULONGLONG QuadPart;
  380. } ULARGE_INTEGER;
  381. typedef ULARGE_INTEGER *PULARGE_INTEGER;
  382. // end_ntminiport end_ntndis end_ntminitape
  383. //
  384. // Locally Unique Identifier
  385. //
  386. typedef struct _LUID {
  387. DWORD LowPart;
  388. LONG HighPart;
  389. } LUID, *PLUID;
  390. #define _DWORDLONG_
  391. typedef ULONGLONG DWORDLONG;
  392. typedef DWORDLONG *PDWORDLONG;
  393. //
  394. // Define operations to logically shift an int64 by 0..31 bits and to multiply
  395. // 32-bits by 32-bits to form a 64-bit product.
  396. //
  397. #if defined(MIDL_PASS) || defined(RC_INVOKED)
  398. //
  399. // Midl does not understand inline assembler. Therefore, the Rtl functions
  400. // are used for shifts by 0.31 and multiplies of 32-bits times 32-bits to
  401. // form a 64-bit product.
  402. //
  403. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  404. #define UInt32x32To64(a, b) ((ULONGLONG)((DWORD)(a)) * (ULONGLONG)((DWORD)(b)))
  405. #define Int64ShllMod32(a, b) ((ULONGLONG)(a) << (b))
  406. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  407. #define Int64ShrlMod32(a, b) ((ULONGLONG)(a) >> (b))
  408. #elif defined(_M_MRX000)
  409. //
  410. // MIPS uses intrinsic functions to perform shifts by 0..31 and multiplies of
  411. // 32-bits times 32-bits to 64-bits.
  412. //
  413. #define Int32x32To64 __emul
  414. #define UInt32x32To64 __emulu
  415. #define Int64ShllMod32 __ll_lshift
  416. #define Int64ShraMod32 __ll_rshift
  417. #define Int64ShrlMod32 __ull_rshift
  418. #if defined (__cplusplus)
  419. extern "C" {
  420. #endif
  421. LONGLONG
  422. NTAPI
  423. Int32x32To64 (
  424. LONG Multiplier,
  425. LONG Multiplicand
  426. );
  427. ULONGLONG
  428. NTAPI
  429. UInt32x32To64 (
  430. DWORD Multiplier,
  431. DWORD Multiplicand
  432. );
  433. ULONGLONG
  434. NTAPI
  435. Int64ShllMod32 (
  436. ULONGLONG Value,
  437. DWORD ShiftCount
  438. );
  439. LONGLONG
  440. NTAPI
  441. Int64ShraMod32 (
  442. LONGLONG Value,
  443. DWORD ShiftCount
  444. );
  445. ULONGLONG
  446. NTAPI
  447. Int64ShrlMod32 (
  448. ULONGLONG Value,
  449. DWORD ShiftCount
  450. );
  451. #if defined (__cplusplus)
  452. };
  453. #endif
  454. #pragma intrinsic(__emul)
  455. #pragma intrinsic(__emulu)
  456. #pragma intrinsic(__ll_lshift)
  457. #pragma intrinsic(__ll_rshift)
  458. #pragma intrinsic(__ull_rshift)
  459. #elif defined(_M_IX86)
  460. //
  461. // The x86 C compiler understands inline assembler. Therefore, inline functions
  462. // that employ inline assembler are used for shifts of 0..31. The multiplies
  463. // rely on the compiler recognizing the cast of the multiplicand to int64 to
  464. // generate the optimal code inline.
  465. //
  466. #define Int32x32To64( a, b ) (LONGLONG)((LONGLONG)(LONG)(a) * (LONG)(b))
  467. #define UInt32x32To64( a, b ) (ULONGLONG)((ULONGLONG)(DWORD)(a) * (DWORD)(b))
  468. ULONGLONG
  469. NTAPI
  470. Int64ShllMod32 (
  471. ULONGLONG Value,
  472. DWORD ShiftCount
  473. );
  474. LONGLONG
  475. NTAPI
  476. Int64ShraMod32 (
  477. LONGLONG Value,
  478. DWORD ShiftCount
  479. );
  480. ULONGLONG
  481. NTAPI
  482. Int64ShrlMod32 (
  483. ULONGLONG Value,
  484. DWORD ShiftCount
  485. );
  486. #if _MSC_VER >= 1200
  487. #pragma warning(push)
  488. #endif
  489. #pragma warning(disable:4035) // re-enable below
  490. __inline ULONGLONG
  491. NTAPI
  492. Int64ShllMod32 (
  493. ULONGLONG Value,
  494. DWORD ShiftCount
  495. )
  496. {
  497. __asm {
  498. mov ecx, ShiftCount
  499. mov eax, dword ptr [Value]
  500. mov edx, dword ptr [Value+4]
  501. shld edx, eax, cl
  502. shl eax, cl
  503. }
  504. }
  505. __inline LONGLONG
  506. NTAPI
  507. Int64ShraMod32 (
  508. LONGLONG Value,
  509. DWORD ShiftCount
  510. )
  511. {
  512. __asm {
  513. mov ecx, ShiftCount
  514. mov eax, dword ptr [Value]
  515. mov edx, dword ptr [Value+4]
  516. shrd eax, edx, cl
  517. sar edx, cl
  518. }
  519. }
  520. __inline ULONGLONG
  521. NTAPI
  522. Int64ShrlMod32 (
  523. ULONGLONG Value,
  524. DWORD ShiftCount
  525. )
  526. {
  527. __asm {
  528. mov ecx, ShiftCount
  529. mov eax, dword ptr [Value]
  530. mov edx, dword ptr [Value+4]
  531. shrd eax, edx, cl
  532. shr edx, cl
  533. }
  534. }
  535. #if _MSC_VER >= 1200
  536. #pragma warning(pop)
  537. #else
  538. #pragma warning(default:4035)
  539. #endif
  540. #elif defined(_M_ALPHA)
  541. //
  542. // Alpha has native 64-bit operations that are just as fast as their 32-bit
  543. // counter parts. Therefore, the int64 data type is used directly to form
  544. // shifts of 0..31 and multiplies of 32-bits times 32-bits to form a 64-bit
  545. // product.
  546. //
  547. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  548. #define UInt32x32To64(a, b) ((ULONGLONG)((DWORD)(a)) * (ULONGLONG)((DWORD)(b)))
  549. #define Int64ShllMod32(a, b) ((ULONGLONG)(a) << (b))
  550. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  551. #define Int64ShrlMod32(a, b) ((ULONGLONG)(a) >> (b))
  552. #elif defined(_M_PPC)
  553. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  554. #define UInt32x32To64(a, b) ((ULONGLONG)((DWORD)(a)) * (ULONGLONG)((DWORD)(b)))
  555. #define Int64ShllMod32(a, b) ((ULONGLONG)(a) << (b))
  556. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  557. #define Int64ShrlMod32(a, b) ((ULONGLONG)(a) >> (b))
  558. #elif defined(_68K_) || defined(_MPPC_)
  559. //
  560. // The Macintosh 68K and PowerPC compilers do not currently support int64.
  561. //
  562. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  563. #define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b)))
  564. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  565. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  566. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  567. #elif defined(_M_IA64) || defined(_M_AMD64)
  568. //
  569. // IA64 has native 64-bit operations that are just as fast as their 32-bit
  570. // counter parts. Therefore, the int64 data type is used directly to form
  571. // shifts of 0..31 and multiplies of 32-bits times 32-bits to form a 64-bit
  572. // product.
  573. //
  574. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  575. #define UInt32x32To64(a, b) ((ULONGLONG)((DWORD)(a)) * (ULONGLONG)((DWORD)(b)))
  576. #define Int64ShllMod32(a, b) ((ULONGLONG)(a) << (b))
  577. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  578. #define Int64ShrlMod32(a, b) ((ULONGLONG)(a) >> (b))
  579. #else
  580. #error Must define a target architecture.
  581. #endif
  582. #define ANSI_NULL ((CHAR)0)
  583. #define UNICODE_NULL ((WCHAR)0)
  584. #define UNICODE_STRING_MAX_BYTES ((WORD ) 65534)
  585. #define UNICODE_STRING_MAX_CHARS (32767)
  586. typedef BYTE BOOLEAN;
  587. typedef BOOLEAN *PBOOLEAN;
  588. //
  589. // Doubly linked list structure. Can be used as either a list head, or
  590. // as link words.
  591. //
  592. typedef struct _LIST_ENTRY {
  593. struct _LIST_ENTRY *Flink;
  594. struct _LIST_ENTRY *Blink;
  595. } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
  596. //
  597. // Singly linked list structure. Can be used as either a list head, or
  598. // as link words.
  599. //
  600. typedef struct _SINGLE_LIST_ENTRY {
  601. struct _SINGLE_LIST_ENTRY *Next;
  602. } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
  603. //
  604. // These are needed for portable debugger support.
  605. //
  606. typedef struct LIST_ENTRY32 {
  607. DWORD Flink;
  608. DWORD Blink;
  609. } LIST_ENTRY32;
  610. typedef LIST_ENTRY32 *PLIST_ENTRY32;
  611. typedef struct LIST_ENTRY64 {
  612. ULONGLONG Flink;
  613. ULONGLONG Blink;
  614. } LIST_ENTRY64;
  615. typedef LIST_ENTRY64 *PLIST_ENTRY64;
  616. #include <guiddef.h>
  617. #ifndef __OBJECTID_DEFINED
  618. #define __OBJECTID_DEFINED
  619. typedef struct _OBJECTID { // size is 20
  620. GUID Lineage;
  621. DWORD Uniquifier;
  622. } OBJECTID;
  623. #endif // !_OBJECTID_DEFINED
  624. #define MINCHAR 0x80
  625. #define MAXCHAR 0x7f
  626. #define MINSHORT 0x8000
  627. #define MAXSHORT 0x7fff
  628. #define MINLONG 0x80000000
  629. #define MAXLONG 0x7fffffff
  630. #define MAXBYTE 0xff
  631. #define MAXWORD 0xffff
  632. #define MAXDWORD 0xffffffff
  633. //
  634. // Calculate the byte offset of a field in a structure of type type.
  635. //
  636. #define FIELD_OFFSET(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
  637. #if(_WIN32_WINNT > 0x0500)
  638. //
  639. // Calculate the size of a field in a structure of type type, without
  640. // knowing or stating the type of the field.
  641. //
  642. #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  643. //
  644. // Calculate the size of a structure of type type up through and
  645. // including a field.
  646. //
  647. #define RTL_SIZEOF_THROUGH_FIELD(type, field) \
  648. (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
  649. //
  650. // RTL_CONTAINS_FIELD usage:
  651. //
  652. // if (RTL_CONTAINS_FIELD(pBlock, pBlock->cbSize, dwMumble)) { // safe to use pBlock->dwMumble
  653. //
  654. #define RTL_CONTAINS_FIELD(Struct, Size, Field) \
  655. ( (((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)) )
  656. //
  657. // Return the number of elements in a statically sized array.
  658. // DWORD Buffer[100];
  659. // RTL_NUMBER_OF(Buffer) == 100
  660. // This is also popularly known as: NUMBER_OF, ARRSIZE, _countof, NELEM, etc.
  661. //
  662. #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
  663. //
  664. // An expression that yields the type of a field in a struct.
  665. //
  666. #define RTL_FIELD_TYPE(type, field) (((type*)0)->field)
  667. // RTL_ to avoid collisions in the global namespace.
  668. //
  669. // Given typedef struct _FOO { BYTE Bar[123]; } FOO;
  670. // RTL_NUMBER_OF_FIELD(FOO, Bar) == 123
  671. //
  672. #define RTL_NUMBER_OF_FIELD(type, field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type, field)))
  673. //
  674. // eg:
  675. // typedef struct FOO {
  676. // DWORD Integer;
  677. // PVOID Pointer;
  678. // } FOO;
  679. //
  680. // RTL_PADDING_BETWEEN_FIELDS(FOO, Integer, Pointer) == 0 for Win32, 4 for Win64
  681. //
  682. #define RTL_PADDING_BETWEEN_FIELDS(T, F1, F2) \
  683. ((FIELD_OFFSET(T, F2) > FIELD_OFFSET(T, F1)) \
  684. ? (FIELD_OFFSET(T, F2) - FIELD_OFFSET(T, F1) - RTL_FIELD_SIZE(T, F1)) \
  685. : (FIELD_OFFSET(T, F1) - FIELD_OFFSET(T, F2) - RTL_FIELD_SIZE(T, F2)))
  686. // RTL_ to avoid collisions in the global namespace.
  687. #if defined(__cplusplus)
  688. #define RTL_CONST_CAST(type) const_cast<type>
  689. #else
  690. #define RTL_CONST_CAST(type) (type)
  691. #endif
  692. // like sizeof
  693. // usually this would be * CHAR_BIT, but we don't necessarily have #include <limits.h>
  694. #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8)
  695. #define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field)))
  696. #endif /* _WIN32_WINNT > 0x0500 */
  697. //
  698. // Calculate the address of the base of the structure given its type, and an
  699. // address of a field within the structure.
  700. //
  701. #define CONTAINING_RECORD(address, type, field) ((type *)( \
  702. (PCHAR)(address) - \
  703. (ULONG_PTR)(&((type *)0)->field)))
  704. #define VER_SERVER_NT 0x80000000
  705. #define VER_WORKSTATION_NT 0x40000000
  706. #define VER_SUITE_SMALLBUSINESS 0x00000001
  707. #define VER_SUITE_ENTERPRISE 0x00000002
  708. #define VER_SUITE_BACKOFFICE 0x00000004
  709. #define VER_SUITE_COMMUNICATIONS 0x00000008
  710. #define VER_SUITE_TERMINAL 0x00000010
  711. #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
  712. #define VER_SUITE_EMBEDDEDNT 0x00000040
  713. #define VER_SUITE_DATACENTER 0x00000080
  714. #define VER_SUITE_SINGLEUSERTS 0x00000100
  715. #define VER_SUITE_PERSONAL 0x00000200
  716. #define VER_SUITE_BLADE 0x00000400
  717. //
  718. // Language IDs.
  719. //
  720. // The following two combinations of primary language ID and
  721. // sublanguage ID have special semantics:
  722. //
  723. // Primary Language ID Sublanguage ID Result
  724. // ------------------- --------------- ------------------------
  725. // LANG_NEUTRAL SUBLANG_NEUTRAL Language neutral
  726. // LANG_NEUTRAL SUBLANG_DEFAULT User default language
  727. // LANG_NEUTRAL SUBLANG_SYS_DEFAULT System default language
  728. // LANG_INVARIANT SUBLANG_NEUTRAL Invariant locale
  729. //
  730. //
  731. // Primary language IDs.
  732. //
  733. #define LANG_NEUTRAL 0x00
  734. #define LANG_INVARIANT 0x7f
  735. #define LANG_AFRIKAANS 0x36
  736. #define LANG_ALBANIAN 0x1c
  737. #define LANG_ARABIC 0x01
  738. #define LANG_ARMENIAN 0x2b
  739. #define LANG_ASSAMESE 0x4d
  740. #define LANG_AZERI 0x2c
  741. #define LANG_BASQUE 0x2d
  742. #define LANG_BELARUSIAN 0x23
  743. #define LANG_BENGALI 0x45
  744. #define LANG_BULGARIAN 0x02
  745. #define LANG_CATALAN 0x03
  746. #define LANG_CHINESE 0x04
  747. #define LANG_CROATIAN 0x1a
  748. #define LANG_CZECH 0x05
  749. #define LANG_DANISH 0x06
  750. #define LANG_DIVEHI 0x65
  751. #define LANG_DUTCH 0x13
  752. #define LANG_ENGLISH 0x09
  753. #define LANG_ESTONIAN 0x25
  754. #define LANG_FAEROESE 0x38
  755. #define LANG_FARSI 0x29
  756. #define LANG_FINNISH 0x0b
  757. #define LANG_FRENCH 0x0c
  758. #define LANG_GALICIAN 0x56
  759. #define LANG_GEORGIAN 0x37
  760. #define LANG_GERMAN 0x07
  761. #define LANG_GREEK 0x08
  762. #define LANG_GUJARATI 0x47
  763. #define LANG_HEBREW 0x0d
  764. #define LANG_HINDI 0x39
  765. #define LANG_HUNGARIAN 0x0e
  766. #define LANG_ICELANDIC 0x0f
  767. #define LANG_INDONESIAN 0x21
  768. #define LANG_ITALIAN 0x10
  769. #define LANG_JAPANESE 0x11
  770. #define LANG_KANNADA 0x4b
  771. #define LANG_KASHMIRI 0x60
  772. #define LANG_KAZAK 0x3f
  773. #define LANG_KONKANI 0x57
  774. #define LANG_KOREAN 0x12
  775. #define LANG_KYRGYZ 0x40
  776. #define LANG_LATVIAN 0x26
  777. #define LANG_LITHUANIAN 0x27
  778. #define LANG_MACEDONIAN 0x2f // the Former Yugoslav Republic of Macedonia
  779. #define LANG_MALAY 0x3e
  780. #define LANG_MALAYALAM 0x4c
  781. #define LANG_MANIPURI 0x58
  782. #define LANG_MARATHI 0x4e
  783. #define LANG_MONGOLIAN 0x50
  784. #define LANG_NEPALI 0x61
  785. #define LANG_NORWEGIAN 0x14
  786. #define LANG_ORIYA 0x48
  787. #define LANG_POLISH 0x15
  788. #define LANG_PORTUGUESE 0x16
  789. #define LANG_PUNJABI 0x46
  790. #define LANG_ROMANIAN 0x18
  791. #define LANG_RUSSIAN 0x19
  792. #define LANG_SANSKRIT 0x4f
  793. #define LANG_SERBIAN 0x1a
  794. #define LANG_SINDHI 0x59
  795. #define LANG_SLOVAK 0x1b
  796. #define LANG_SLOVENIAN 0x24
  797. #define LANG_SPANISH 0x0a
  798. #define LANG_SWAHILI 0x41
  799. #define LANG_SWEDISH 0x1d
  800. #define LANG_SYRIAC 0x5a
  801. #define LANG_TAMIL 0x49
  802. #define LANG_TATAR 0x44
  803. #define LANG_TELUGU 0x4a
  804. #define LANG_THAI 0x1e
  805. #define LANG_TURKISH 0x1f
  806. #define LANG_UKRAINIAN 0x22
  807. #define LANG_URDU 0x20
  808. #define LANG_UZBEK 0x43
  809. #define LANG_VIETNAMESE 0x2a
  810. //
  811. // Sublanguage IDs.
  812. //
  813. // The name immediately following SUBLANG_ dictates which primary
  814. // language ID that sublanguage ID can be combined with to form a
  815. // valid language ID.
  816. //
  817. #define SUBLANG_NEUTRAL 0x00 // language neutral
  818. #define SUBLANG_DEFAULT 0x01 // user default
  819. #define SUBLANG_SYS_DEFAULT 0x02 // system default
  820. #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01 // Arabic (Saudi Arabia)
  821. #define SUBLANG_ARABIC_IRAQ 0x02 // Arabic (Iraq)
  822. #define SUBLANG_ARABIC_EGYPT 0x03 // Arabic (Egypt)
  823. #define SUBLANG_ARABIC_LIBYA 0x04 // Arabic (Libya)
  824. #define SUBLANG_ARABIC_ALGERIA 0x05 // Arabic (Algeria)
  825. #define SUBLANG_ARABIC_MOROCCO 0x06 // Arabic (Morocco)
  826. #define SUBLANG_ARABIC_TUNISIA 0x07 // Arabic (Tunisia)
  827. #define SUBLANG_ARABIC_OMAN 0x08 // Arabic (Oman)
  828. #define SUBLANG_ARABIC_YEMEN 0x09 // Arabic (Yemen)
  829. #define SUBLANG_ARABIC_SYRIA 0x0a // Arabic (Syria)
  830. #define SUBLANG_ARABIC_JORDAN 0x0b // Arabic (Jordan)
  831. #define SUBLANG_ARABIC_LEBANON 0x0c // Arabic (Lebanon)
  832. #define SUBLANG_ARABIC_KUWAIT 0x0d // Arabic (Kuwait)
  833. #define SUBLANG_ARABIC_UAE 0x0e // Arabic (U.A.E)
  834. #define SUBLANG_ARABIC_BAHRAIN 0x0f // Arabic (Bahrain)
  835. #define SUBLANG_ARABIC_QATAR 0x10 // Arabic (Qatar)
  836. #define SUBLANG_AZERI_LATIN 0x01 // Azeri (Latin)
  837. #define SUBLANG_AZERI_CYRILLIC 0x02 // Azeri (Cyrillic)
  838. #define SUBLANG_CHINESE_TRADITIONAL 0x01 // Chinese (Taiwan)
  839. #define SUBLANG_CHINESE_SIMPLIFIED 0x02 // Chinese (PR China)
  840. #define SUBLANG_CHINESE_HONGKONG 0x03 // Chinese (Hong Kong S.A.R., P.R.C.)
  841. #define SUBLANG_CHINESE_SINGAPORE 0x04 // Chinese (Singapore)
  842. #define SUBLANG_CHINESE_MACAU 0x05 // Chinese (Macau S.A.R.)
  843. #define SUBLANG_DUTCH 0x01 // Dutch
  844. #define SUBLANG_DUTCH_BELGIAN 0x02 // Dutch (Belgian)
  845. #define SUBLANG_ENGLISH_US 0x01 // English (USA)
  846. #define SUBLANG_ENGLISH_UK 0x02 // English (UK)
  847. #define SUBLANG_ENGLISH_AUS 0x03 // English (Australian)
  848. #define SUBLANG_ENGLISH_CAN 0x04 // English (Canadian)
  849. #define SUBLANG_ENGLISH_NZ 0x05 // English (New Zealand)
  850. #define SUBLANG_ENGLISH_EIRE 0x06 // English (Irish)
  851. #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07 // English (South Africa)
  852. #define SUBLANG_ENGLISH_JAMAICA 0x08 // English (Jamaica)
  853. #define SUBLANG_ENGLISH_CARIBBEAN 0x09 // English (Caribbean)
  854. #define SUBLANG_ENGLISH_BELIZE 0x0a // English (Belize)
  855. #define SUBLANG_ENGLISH_TRINIDAD 0x0b // English (Trinidad)
  856. #define SUBLANG_ENGLISH_ZIMBABWE 0x0c // English (Zimbabwe)
  857. #define SUBLANG_ENGLISH_PHILIPPINES 0x0d // English (Philippines)
  858. #define SUBLANG_FRENCH 0x01 // French
  859. #define SUBLANG_FRENCH_BELGIAN 0x02 // French (Belgian)
  860. #define SUBLANG_FRENCH_CANADIAN 0x03 // French (Canadian)
  861. #define SUBLANG_FRENCH_SWISS 0x04 // French (Swiss)
  862. #define SUBLANG_FRENCH_LUXEMBOURG 0x05 // French (Luxembourg)
  863. #define SUBLANG_FRENCH_MONACO 0x06 // French (Monaco)
  864. #define SUBLANG_GERMAN 0x01 // German
  865. #define SUBLANG_GERMAN_SWISS 0x02 // German (Swiss)
  866. #define SUBLANG_GERMAN_AUSTRIAN 0x03 // German (Austrian)
  867. #define SUBLANG_GERMAN_LUXEMBOURG 0x04 // German (Luxembourg)
  868. #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05 // German (Liechtenstein)
  869. #define SUBLANG_ITALIAN 0x01 // Italian
  870. #define SUBLANG_ITALIAN_SWISS 0x02 // Italian (Swiss)
  871. #if _WIN32_WINNT >= 0x0501
  872. #define SUBLANG_KASHMIRI_SASIA 0x02 // Kashmiri (South Asia)
  873. #endif
  874. #define SUBLANG_KASHMIRI_INDIA 0x02 // For app compatibility only
  875. #define SUBLANG_KOREAN 0x01 // Korean (Extended Wansung)
  876. #define SUBLANG_LITHUANIAN 0x01 // Lithuanian
  877. #define SUBLANG_MALAY_MALAYSIA 0x01 // Malay (Malaysia)
  878. #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02 // Malay (Brunei Darussalam)
  879. #define SUBLANG_NEPALI_INDIA 0x02 // Nepali (India)
  880. #define SUBLANG_NORWEGIAN_BOKMAL 0x01 // Norwegian (Bokmal)
  881. #define SUBLANG_NORWEGIAN_NYNORSK 0x02 // Norwegian (Nynorsk)
  882. #define SUBLANG_PORTUGUESE 0x02 // Portuguese
  883. #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01 // Portuguese (Brazilian)
  884. #define SUBLANG_SERBIAN_LATIN 0x02 // Serbian (Latin)
  885. #define SUBLANG_SERBIAN_CYRILLIC 0x03 // Serbian (Cyrillic)
  886. #define SUBLANG_SPANISH 0x01 // Spanish (Castilian)
  887. #define SUBLANG_SPANISH_MEXICAN 0x02 // Spanish (Mexican)
  888. #define SUBLANG_SPANISH_MODERN 0x03 // Spanish (Modern)
  889. #define SUBLANG_SPANISH_GUATEMALA 0x04 // Spanish (Guatemala)
  890. #define SUBLANG_SPANISH_COSTA_RICA 0x05 // Spanish (Costa Rica)
  891. #define SUBLANG_SPANISH_PANAMA 0x06 // Spanish (Panama)
  892. #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07 // Spanish (Dominican Republic)
  893. #define SUBLANG_SPANISH_VENEZUELA 0x08 // Spanish (Venezuela)
  894. #define SUBLANG_SPANISH_COLOMBIA 0x09 // Spanish (Colombia)
  895. #define SUBLANG_SPANISH_PERU 0x0a // Spanish (Peru)
  896. #define SUBLANG_SPANISH_ARGENTINA 0x0b // Spanish (Argentina)
  897. #define SUBLANG_SPANISH_ECUADOR 0x0c // Spanish (Ecuador)
  898. #define SUBLANG_SPANISH_CHILE 0x0d // Spanish (Chile)
  899. #define SUBLANG_SPANISH_URUGUAY 0x0e // Spanish (Uruguay)
  900. #define SUBLANG_SPANISH_PARAGUAY 0x0f // Spanish (Paraguay)
  901. #define SUBLANG_SPANISH_BOLIVIA 0x10 // Spanish (Bolivia)
  902. #define SUBLANG_SPANISH_EL_SALVADOR 0x11 // Spanish (El Salvador)
  903. #define SUBLANG_SPANISH_HONDURAS 0x12 // Spanish (Honduras)
  904. #define SUBLANG_SPANISH_NICARAGUA 0x13 // Spanish (Nicaragua)
  905. #define SUBLANG_SPANISH_PUERTO_RICO 0x14 // Spanish (Puerto Rico)
  906. #define SUBLANG_SWEDISH 0x01 // Swedish
  907. #define SUBLANG_SWEDISH_FINLAND 0x02 // Swedish (Finland)
  908. #define SUBLANG_URDU_PAKISTAN 0x01 // Urdu (Pakistan)
  909. #define SUBLANG_URDU_INDIA 0x02 // Urdu (India)
  910. #define SUBLANG_UZBEK_LATIN 0x01 // Uzbek (Latin)
  911. #define SUBLANG_UZBEK_CYRILLIC 0x02 // Uzbek (Cyrillic)
  912. //
  913. // Sorting IDs.
  914. //
  915. #define SORT_DEFAULT 0x0 // sorting default
  916. #define SORT_JAPANESE_XJIS 0x0 // Japanese XJIS order
  917. #define SORT_JAPANESE_UNICODE 0x1 // Japanese Unicode order
  918. #define SORT_CHINESE_BIG5 0x0 // Chinese BIG5 order
  919. #define SORT_CHINESE_PRCP 0x0 // PRC Chinese Phonetic order
  920. #define SORT_CHINESE_UNICODE 0x1 // Chinese Unicode order
  921. #define SORT_CHINESE_PRC 0x2 // PRC Chinese Stroke Count order
  922. #define SORT_CHINESE_BOPOMOFO 0x3 // Traditional Chinese Bopomofo order
  923. #define SORT_KOREAN_KSC 0x0 // Korean KSC order
  924. #define SORT_KOREAN_UNICODE 0x1 // Korean Unicode order
  925. #define SORT_GERMAN_PHONE_BOOK 0x1 // German Phone Book order
  926. #define SORT_HUNGARIAN_DEFAULT 0x0 // Hungarian Default order
  927. #define SORT_HUNGARIAN_TECHNICAL 0x1 // Hungarian Technical order
  928. #define SORT_GEORGIAN_TRADITIONAL 0x0 // Georgian Traditional order
  929. #define SORT_GEORGIAN_MODERN 0x1 // Georgian Modern order
  930. // end_r_winnt
  931. //
  932. // A language ID is a 16 bit value which is the combination of a
  933. // primary language ID and a secondary language ID. The bits are
  934. // allocated as follows:
  935. //
  936. // +-----------------------+-------------------------+
  937. // | Sublanguage ID | Primary Language ID |
  938. // +-----------------------+-------------------------+
  939. // 15 10 9 0 bit
  940. //
  941. //
  942. // Language ID creation/extraction macros:
  943. //
  944. // MAKELANGID - construct language id from a primary language id and
  945. // a sublanguage id.
  946. // PRIMARYLANGID - extract primary language id from a language id.
  947. // SUBLANGID - extract sublanguage id from a language id.
  948. //
  949. #define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
  950. #define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
  951. #define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
  952. //
  953. // A locale ID is a 32 bit value which is the combination of a
  954. // language ID, a sort ID, and a reserved area. The bits are
  955. // allocated as follows:
  956. //
  957. // +-------------+---------+-------------------------+
  958. // | Reserved | Sort ID | Language ID |
  959. // +-------------+---------+-------------------------+
  960. // 31 20 19 16 15 0 bit
  961. //
  962. //
  963. // Locale ID creation/extraction macros:
  964. //
  965. // MAKELCID - construct the locale id from a language id and a sort id.
  966. // MAKESORTLCID - construct the locale id from a language id, sort id, and sort version.
  967. // LANGIDFROMLCID - extract the language id from a locale id.
  968. // SORTIDFROMLCID - extract the sort id from a locale id.
  969. // SORTVERSIONFROMLCID - extract the sort version from a locale id.
  970. //
  971. #define NLS_VALID_LOCALE_MASK 0x000fffff
  972. #define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | \
  973. ((DWORD)((WORD )(lgid)))))
  974. #define MAKESORTLCID(lgid, srtid, ver) \
  975. ((DWORD)((MAKELCID(lgid, srtid)) | \
  976. (((DWORD)((WORD )(ver))) << 20)))
  977. #define LANGIDFROMLCID(lcid) ((WORD )(lcid))
  978. #define SORTIDFROMLCID(lcid) ((WORD )((((DWORD)(lcid)) >> 16) & 0xf))
  979. #define SORTVERSIONFROMLCID(lcid) ((WORD )((((DWORD)(lcid)) >> 20) & 0xf))
  980. //
  981. // Default System and User IDs for language and locale.
  982. //
  983. #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
  984. #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
  985. #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
  986. #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
  987. #define LOCALE_NEUTRAL \
  988. (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
  989. #define LOCALE_INVARIANT \
  990. (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
  991. // begin_ntminiport begin_ntndis begin_ntminitape
  992. //
  993. // Macros used to eliminate compiler warning generated when formal
  994. // parameters or local variables are not declared.
  995. //
  996. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  997. // referenced but will be once the module is completely developed.
  998. //
  999. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  1000. // referenced but will be once the module is completely developed.
  1001. //
  1002. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  1003. //
  1004. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  1005. // eventually be made into a null macro to help determine whether there
  1006. // is unfinished work.
  1007. //
  1008. #if ! defined(lint)
  1009. #define UNREFERENCED_PARAMETER(P) (P)
  1010. #define DBG_UNREFERENCED_PARAMETER(P) (P)
  1011. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  1012. #else // lint
  1013. // Note: lint -e530 says don't complain about uninitialized variables for
  1014. // this varible. Error 527 has to do with unreachable code.
  1015. // -restore restores checking to the -save state
  1016. #define UNREFERENCED_PARAMETER(P) \
  1017. /*lint -save -e527 -e530 */ \
  1018. { \
  1019. (P) = (P); \
  1020. } \
  1021. /*lint -restore */
  1022. #define DBG_UNREFERENCED_PARAMETER(P) \
  1023. /*lint -save -e527 -e530 */ \
  1024. { \
  1025. (P) = (P); \
  1026. } \
  1027. /*lint -restore */
  1028. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  1029. /*lint -save -e527 -e530 */ \
  1030. { \
  1031. (V) = (V); \
  1032. } \
  1033. /*lint -restore */
  1034. #endif // lint
  1035. //
  1036. // Macro used to eliminate compiler warning 4715 within a switch statement
  1037. // when all possible cases have already been accounted for.
  1038. //
  1039. // switch (a & 3) {
  1040. // case 0: return 1;
  1041. // case 1: return Foo();
  1042. // case 2: return Bar();
  1043. // case 3: return 1;
  1044. // DEFAULT_UNREACHABLE;
  1045. //
  1046. #if (_MSC_VER > 1200)
  1047. #define DEFAULT_UNREACHABLE default: __assume(0)
  1048. #else
  1049. //
  1050. // Older compilers do not support __assume(), and there is no other free
  1051. // method of eliminating the warning.
  1052. //
  1053. #define DEFAULT_UNREACHABLE
  1054. #endif
  1055. #ifndef WIN32_NO_STATUS
  1056. /*lint -save -e767 */
  1057. #define STATUS_WAIT_0 ((DWORD )0x00000000L)
  1058. #define STATUS_ABANDONED_WAIT_0 ((DWORD )0x00000080L)
  1059. #define STATUS_USER_APC ((DWORD )0x000000C0L)
  1060. #define STATUS_TIMEOUT ((DWORD )0x00000102L)
  1061. #define STATUS_PENDING ((DWORD )0x00000103L)
  1062. #define DBG_EXCEPTION_HANDLED ((DWORD )0x00010001L)
  1063. #define DBG_CONTINUE ((DWORD )0x00010002L)
  1064. #define STATUS_SEGMENT_NOTIFICATION ((DWORD )0x40000005L)
  1065. #define DBG_TERMINATE_THREAD ((DWORD )0x40010003L)
  1066. #define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L)
  1067. #define DBG_CONTROL_C ((DWORD )0x40010005L)
  1068. #define DBG_CONTROL_BREAK ((DWORD )0x40010008L)
  1069. #define STATUS_GUARD_PAGE_VIOLATION ((DWORD )0x80000001L)
  1070. #define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L)
  1071. #define STATUS_BREAKPOINT ((DWORD )0x80000003L)
  1072. #define STATUS_SINGLE_STEP ((DWORD )0x80000004L)
  1073. #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L)
  1074. #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L)
  1075. #define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L)
  1076. #define STATUS_INVALID_HANDLE ((DWORD )0xC0000008L)
  1077. #define STATUS_NO_MEMORY ((DWORD )0xC0000017L)
  1078. #define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL)
  1079. #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L)
  1080. #define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L)
  1081. #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD )0xC000008CL)
  1082. #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD )0xC000008DL)
  1083. #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD )0xC000008EL)
  1084. #define STATUS_FLOAT_INEXACT_RESULT ((DWORD )0xC000008FL)
  1085. #define STATUS_FLOAT_INVALID_OPERATION ((DWORD )0xC0000090L)
  1086. #define STATUS_FLOAT_OVERFLOW ((DWORD )0xC0000091L)
  1087. #define STATUS_FLOAT_STACK_CHECK ((DWORD )0xC0000092L)
  1088. #define STATUS_FLOAT_UNDERFLOW ((DWORD )0xC0000093L)
  1089. #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD )0xC0000094L)
  1090. #define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L)
  1091. #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L)
  1092. #define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL)
  1093. #define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL)
  1094. #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD )0xC00002B4L)
  1095. #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD )0xC00002B5L)
  1096. #define STATUS_REG_NAT_CONSUMPTION ((DWORD )0xC00002C9L)
  1097. #if defined(STATUS_SUCCESS) || (_WIN32_WINNT > 0x0500) || (_WIN32_FUSION >= 0x0100)
  1098. #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD )0xC015000FL)
  1099. #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD )0xC0150010L)
  1100. #endif
  1101. /*lint -restore */
  1102. #endif
  1103. #define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects
  1104. #define MAXIMUM_SUSPEND_COUNT MAXCHAR // Maximum times thread can be suspended
  1105. typedef ULONG_PTR KSPIN_LOCK;
  1106. typedef KSPIN_LOCK *PKSPIN_LOCK;
  1107. #if defined(_AMD64_)
  1108. #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
  1109. //
  1110. // Define function to get the caller's EFLAGs value.
  1111. //
  1112. #define GetCallersEflags() __getcallerseflags()
  1113. unsigned __int32
  1114. __getcallerseflags (
  1115. VOID
  1116. );
  1117. #pragma intrinsic(__getcallerseflags)
  1118. //
  1119. // Define function to read the value of the time stamp counter
  1120. //
  1121. #define ReadTimeStampCounter() __rdtsc()
  1122. DWORD64
  1123. __rdtsc (
  1124. VOID
  1125. );
  1126. #pragma intrinsic(__rdtsc)
  1127. //
  1128. // Define functions to move strings or bytes, words, dwords, and qwords.
  1129. //
  1130. VOID
  1131. __movsb (
  1132. IN PBYTE Destination,
  1133. IN PBYTE Source,
  1134. IN DWORD Count
  1135. );
  1136. VOID
  1137. __movsw (
  1138. IN PWORD Destination,
  1139. IN PWORD Source,
  1140. IN DWORD Count
  1141. );
  1142. VOID
  1143. __movsd (
  1144. IN PDWORD Destination,
  1145. IN PDWORD Source,
  1146. IN DWORD Count
  1147. );
  1148. VOID
  1149. __movsq (
  1150. IN PULONGLONG Destination,
  1151. IN PULONGLONG Source,
  1152. IN DWORD Count
  1153. );
  1154. #pragma intrinsic(__movsb)
  1155. #pragma intrinsic(__movsw)
  1156. #pragma intrinsic(__movsd)
  1157. #pragma intrinsic(__movsq)
  1158. //
  1159. // Define functions to capture the high 64-bits of a 128-bit multiply.
  1160. //
  1161. #define MultiplyHigh __mulh
  1162. #define UnsignedMultiplyHigh __umulh
  1163. LONGLONG
  1164. MultiplyHigh (
  1165. IN LONGLONG Multiplier,
  1166. IN LONGLONG Multiplicand
  1167. );
  1168. ULONGLONG
  1169. UnsignedMultiplyHigh (
  1170. IN ULONGLONG Multiplier,
  1171. IN ULONGLONG Multiplicand
  1172. );
  1173. #pragma intrinsic(__mulh)
  1174. #pragma intrinsic(__umulh)
  1175. //
  1176. // Define functions to read and write the uer TEB and the system PCR/PRCB.
  1177. //
  1178. BYTE
  1179. __readgsbyte (
  1180. IN DWORD Offset
  1181. );
  1182. WORD
  1183. __readgsword (
  1184. IN DWORD Offset
  1185. );
  1186. DWORD
  1187. __readgsdword (
  1188. IN DWORD Offset
  1189. );
  1190. DWORD64
  1191. __readgsqword (
  1192. IN DWORD Offset
  1193. );
  1194. VOID
  1195. __writegsbyte (
  1196. IN DWORD Offset,
  1197. IN BYTE Data
  1198. );
  1199. VOID
  1200. __writegsword (
  1201. IN DWORD Offset,
  1202. IN WORD Data
  1203. );
  1204. VOID
  1205. __writegsdword (
  1206. IN DWORD Offset,
  1207. IN DWORD Data
  1208. );
  1209. VOID
  1210. __writegsqword (
  1211. IN DWORD Offset,
  1212. IN DWORD64 Data
  1213. );
  1214. #pragma intrinsic(__readgsbyte)
  1215. #pragma intrinsic(__readgsword)
  1216. #pragma intrinsic(__readgsdword)
  1217. #pragma intrinsic(__readgsqword)
  1218. #pragma intrinsic(__writegsbyte)
  1219. #pragma intrinsic(__writegsword)
  1220. #pragma intrinsic(__writegsdword)
  1221. #pragma intrinsic(__writegsqword)
  1222. #endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
  1223. //
  1224. // The following flags control the contents of the CONTEXT structure.
  1225. //
  1226. #if !defined(RC_INVOKED)
  1227. #define CONTEXT_AMD64 0x100000
  1228. // end_wx86
  1229. #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
  1230. #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
  1231. #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
  1232. #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
  1233. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
  1234. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
  1235. // begin_wx86
  1236. #endif // !defined(RC_INVOKED)
  1237. //
  1238. // Define 128-bit 16-byte aligned xmm register type.
  1239. //
  1240. typedef struct DECLSPEC_ALIGN(16) _M128 {
  1241. ULONGLONG Low;
  1242. LONGLONG High;
  1243. } M128, *PM128;
  1244. //
  1245. // Format of data for fnsave/frstor instructions.
  1246. //
  1247. // This structure is used to store the legacy floating point state.
  1248. //
  1249. typedef struct _LEGACY_SAVE_AREA {
  1250. WORD ControlWord;
  1251. WORD Reserved0;
  1252. WORD StatusWord;
  1253. WORD Reserved1;
  1254. WORD TagWord;
  1255. WORD Reserved2;
  1256. DWORD ErrorOffset;
  1257. WORD ErrorSelector;
  1258. WORD ErrorOpcode;
  1259. DWORD DataOffset;
  1260. WORD DataSelector;
  1261. WORD Reserved3;
  1262. BYTE FloatRegisters[8 * 10];
  1263. } LEGACY_SAVE_AREA, *PLEGACY_SAVE_AREA;
  1264. #define LEGACY_SAVE_AREA_LENGTH ((sizeof(LEGACY_SAVE_AREA) + 15) & ~15)
  1265. //
  1266. // Context Frame
  1267. //
  1268. // This frame has a several purposes: 1) it is used as an argument to
  1269. // NtContinue, 2) is is used to constuct a call frame for APC delivery,
  1270. // and 3) it is used in the user level thread creation routines.
  1271. //
  1272. //
  1273. // The flags field within this record controls the contents of a CONTEXT
  1274. // record.
  1275. //
  1276. // If the context record is used as an input parameter, then for each
  1277. // portion of the context record controlled by a flag whose value is
  1278. // set, it is assumed that that portion of the context record contains
  1279. // valid context. If the context record is being used to modify a threads
  1280. // context, then only that portion of the threads context is modified.
  1281. //
  1282. // If the context record is used as an output parameter to capture the
  1283. // context of a thread, then only those portions of the thread's context
  1284. // corresponding to set flags will be returned.
  1285. //
  1286. // CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
  1287. //
  1288. // CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
  1289. //
  1290. // CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
  1291. //
  1292. // CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
  1293. //
  1294. // CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
  1295. // Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
  1296. //
  1297. typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
  1298. //
  1299. // Register parameter home addresses.
  1300. //
  1301. DWORD64 P1Home;
  1302. DWORD64 P2Home;
  1303. DWORD64 P3Home;
  1304. DWORD64 P4Home;
  1305. DWORD64 P5Home;
  1306. DWORD64 P6Home;
  1307. //
  1308. // Control flags.
  1309. //
  1310. DWORD ContextFlags;
  1311. DWORD MxCsr;
  1312. //
  1313. // Segment Registers and processor flags.
  1314. //
  1315. WORD SegCs;
  1316. WORD SegDs;
  1317. WORD SegEs;
  1318. WORD SegFs;
  1319. WORD SegGs;
  1320. WORD SegSs;
  1321. DWORD EFlags;
  1322. //
  1323. // Debug registers
  1324. //
  1325. DWORD64 Dr0;
  1326. DWORD64 Dr1;
  1327. DWORD64 Dr2;
  1328. DWORD64 Dr3;
  1329. DWORD64 Dr6;
  1330. DWORD64 Dr7;
  1331. //
  1332. // Integer registers.
  1333. //
  1334. DWORD64 Rax;
  1335. DWORD64 Rcx;
  1336. DWORD64 Rdx;
  1337. DWORD64 Rbx;
  1338. DWORD64 Rsp;
  1339. DWORD64 Rbp;
  1340. DWORD64 Rsi;
  1341. DWORD64 Rdi;
  1342. DWORD64 R8;
  1343. DWORD64 R9;
  1344. DWORD64 R10;
  1345. DWORD64 R11;
  1346. DWORD64 R12;
  1347. DWORD64 R13;
  1348. DWORD64 R14;
  1349. DWORD64 R15;
  1350. //
  1351. // Program counter.
  1352. //
  1353. DWORD64 Rip;
  1354. //
  1355. // MMX/floating point state.
  1356. //
  1357. M128 Xmm0;
  1358. M128 Xmm1;
  1359. M128 Xmm2;
  1360. M128 Xmm3;
  1361. M128 Xmm4;
  1362. M128 Xmm5;
  1363. M128 Xmm6;
  1364. M128 Xmm7;
  1365. M128 Xmm8;
  1366. M128 Xmm9;
  1367. M128 Xmm10;
  1368. M128 Xmm11;
  1369. M128 Xmm12;
  1370. M128 Xmm13;
  1371. M128 Xmm14;
  1372. M128 Xmm15;
  1373. //
  1374. // Legacy floating point state.
  1375. //
  1376. LEGACY_SAVE_AREA FltSave;
  1377. DWORD Fill;
  1378. } CONTEXT, *PCONTEXT;
  1379. #endif // _AMD64_
  1380. //
  1381. // Define function to return the current Thread Environment Block
  1382. //
  1383. #ifdef _ALPHA_ // winnt
  1384. void *_rdteb(void); // winnt
  1385. #if defined(_M_ALPHA) // winnt
  1386. #pragma intrinsic(_rdteb) // winnt
  1387. #endif // winnt
  1388. #endif // winnt
  1389. #if defined(_M_ALPHA)
  1390. #define NtCurrentTeb() ((struct _TEB *)_rdteb())
  1391. #else
  1392. struct _TEB *
  1393. NtCurrentTeb(void);
  1394. #endif
  1395. //
  1396. // Define functions to get the address of the current fiber and the
  1397. // current fiber data.
  1398. //
  1399. #ifdef _ALPHA_
  1400. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  1401. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  1402. // begin_ntddk begin_nthal
  1403. //
  1404. // The following flags control the contents of the CONTEXT structure.
  1405. //
  1406. #if !defined(RC_INVOKED)
  1407. #define CONTEXT_ALPHA 0x00020000
  1408. #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
  1409. #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
  1410. #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
  1411. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  1412. #endif
  1413. #ifndef _PORTABLE_32BIT_CONTEXT
  1414. //
  1415. // Context Frame
  1416. //
  1417. // This frame has a several purposes: 1) it is used as an argument to
  1418. // NtContinue, 2) it is used to construct a call frame for APC delivery,
  1419. // 3) it is used to construct a call frame for exception dispatching
  1420. // in user mode, 4) it is used in the user level thread creation
  1421. // routines, and 5) it is used to to pass thread state to debuggers.
  1422. //
  1423. // N.B. Because this record is used as a call frame, it must be EXACTLY
  1424. // a multiple of 16 bytes in length.
  1425. //
  1426. // There are two variations of the context structure. This is the real one.
  1427. //
  1428. typedef struct _CONTEXT {
  1429. //
  1430. // This section is specified/returned if the ContextFlags word contains
  1431. // the flag CONTEXT_FLOATING_POINT.
  1432. //
  1433. ULONGLONG FltF0;
  1434. ULONGLONG FltF1;
  1435. ULONGLONG FltF2;
  1436. ULONGLONG FltF3;
  1437. ULONGLONG FltF4;
  1438. ULONGLONG FltF5;
  1439. ULONGLONG FltF6;
  1440. ULONGLONG FltF7;
  1441. ULONGLONG FltF8;
  1442. ULONGLONG FltF9;
  1443. ULONGLONG FltF10;
  1444. ULONGLONG FltF11;
  1445. ULONGLONG FltF12;
  1446. ULONGLONG FltF13;
  1447. ULONGLONG FltF14;
  1448. ULONGLONG FltF15;
  1449. ULONGLONG FltF16;
  1450. ULONGLONG FltF17;
  1451. ULONGLONG FltF18;
  1452. ULONGLONG FltF19;
  1453. ULONGLONG FltF20;
  1454. ULONGLONG FltF21;
  1455. ULONGLONG FltF22;
  1456. ULONGLONG FltF23;
  1457. ULONGLONG FltF24;
  1458. ULONGLONG FltF25;
  1459. ULONGLONG FltF26;
  1460. ULONGLONG FltF27;
  1461. ULONGLONG FltF28;
  1462. ULONGLONG FltF29;
  1463. ULONGLONG FltF30;
  1464. ULONGLONG FltF31;
  1465. //
  1466. // This section is specified/returned if the ContextFlags word contains
  1467. // the flag CONTEXT_INTEGER.
  1468. //
  1469. // N.B. The registers gp, sp, and ra are defined in this section, but are
  1470. // considered part of the control context rather than part of the integer
  1471. // context.
  1472. //
  1473. ULONGLONG IntV0; // $0: return value register, v0
  1474. ULONGLONG IntT0; // $1: temporary registers, t0 - t7
  1475. ULONGLONG IntT1; // $2:
  1476. ULONGLONG IntT2; // $3:
  1477. ULONGLONG IntT3; // $4:
  1478. ULONGLONG IntT4; // $5:
  1479. ULONGLONG IntT5; // $6:
  1480. ULONGLONG IntT6; // $7:
  1481. ULONGLONG IntT7; // $8:
  1482. ULONGLONG IntS0; // $9: nonvolatile registers, s0 - s5
  1483. ULONGLONG IntS1; // $10:
  1484. ULONGLONG IntS2; // $11:
  1485. ULONGLONG IntS3; // $12:
  1486. ULONGLONG IntS4; // $13:
  1487. ULONGLONG IntS5; // $14:
  1488. ULONGLONG IntFp; // $15: frame pointer register, fp/s6
  1489. ULONGLONG IntA0; // $16: argument registers, a0 - a5
  1490. ULONGLONG IntA1; // $17:
  1491. ULONGLONG IntA2; // $18:
  1492. ULONGLONG IntA3; // $19:
  1493. ULONGLONG IntA4; // $20:
  1494. ULONGLONG IntA5; // $21:
  1495. ULONGLONG IntT8; // $22: temporary registers, t8 - t11
  1496. ULONGLONG IntT9; // $23:
  1497. ULONGLONG IntT10; // $24:
  1498. ULONGLONG IntT11; // $25:
  1499. ULONGLONG IntRa; // $26: return address register, ra
  1500. ULONGLONG IntT12; // $27: temporary register, t12
  1501. ULONGLONG IntAt; // $28: assembler temp register, at
  1502. ULONGLONG IntGp; // $29: global pointer register, gp
  1503. ULONGLONG IntSp; // $30: stack pointer register, sp
  1504. ULONGLONG IntZero; // $31: zero register, zero
  1505. //
  1506. // This section is specified/returned if the ContextFlags word contains
  1507. // the flag CONTEXT_FLOATING_POINT.
  1508. //
  1509. ULONGLONG Fpcr; // floating point control register
  1510. ULONGLONG SoftFpcr; // software extension to FPCR
  1511. //
  1512. // This section is specified/returned if the ContextFlags word contains
  1513. // the flag CONTEXT_CONTROL.
  1514. //
  1515. // N.B. The registers gp, sp, and ra are defined in the integer section,
  1516. // but are considered part of the control context rather than part of
  1517. // the integer context.
  1518. //
  1519. ULONGLONG Fir; // (fault instruction) continuation address
  1520. DWORD Psr; // processor status
  1521. //
  1522. // The flags values within this flag control the contents of
  1523. // a CONTEXT record.
  1524. //
  1525. // If the context record is used as an input parameter, then
  1526. // for each portion of the context record controlled by a flag
  1527. // whose value is set, it is assumed that that portion of the
  1528. // context record contains valid context. If the context record
  1529. // is being used to modify a thread's context, then only that
  1530. // portion of the threads context will be modified.
  1531. //
  1532. // If the context record is used as an IN OUT parameter to capture
  1533. // the context of a thread, then only those portions of the thread's
  1534. // context corresponding to set flags will be returned.
  1535. //
  1536. // The context record is never used as an OUT only parameter.
  1537. //
  1538. DWORD ContextFlags;
  1539. DWORD Fill[4]; // padding for 16-byte stack frame alignment
  1540. } CONTEXT, *PCONTEXT;
  1541. #else
  1542. #error _PORTABLE_32BIT_CONTEXT no longer supported on Alpha.
  1543. #endif // _PORTABLE_32BIT_CONTEXT
  1544. // end_ntddk end_nthal
  1545. #endif // _ALPHA_
  1546. #ifdef _ALPHA_
  1547. VOID
  1548. __jump_unwind (
  1549. PVOID VirtualFramePointer,
  1550. PVOID TargetPc
  1551. );
  1552. #endif // _ALPHA_
  1553. #ifdef _X86_
  1554. //
  1555. // Disable these two pragmas that evaluate to "sti" "cli" on x86 so that driver
  1556. // writers to not leave them inadvertantly in their code.
  1557. //
  1558. #if !defined(MIDL_PASS)
  1559. #if !defined(RC_INVOKED)
  1560. #if _MSC_VER >= 1200
  1561. #pragma warning(push)
  1562. #endif
  1563. #pragma warning(disable:4164) // disable C4164 warning so that apps that
  1564. // build with /Od don't get weird errors !
  1565. #ifdef _M_IX86
  1566. #pragma function(_enable)
  1567. #pragma function(_disable)
  1568. #endif
  1569. #if _MSC_VER >= 1200
  1570. #pragma warning(pop)
  1571. #else
  1572. #pragma warning(default:4164) // reenable C4164 warning
  1573. #endif
  1574. #endif
  1575. #endif
  1576. #if !defined(MIDL_PASS) && defined(_M_IX86)
  1577. #if _MSC_VER >= 1200
  1578. #pragma warning(push)
  1579. #endif
  1580. #pragma warning (disable:4035) // disable 4035 (function must return something)
  1581. _inline PVOID GetFiberData( void ) { __asm {
  1582. mov eax, fs:[0x10]
  1583. mov eax,[eax]
  1584. }
  1585. }
  1586. _inline PVOID GetCurrentFiber( void ) { __asm mov eax, fs:[0x10] }
  1587. #if _MSC_VER >= 1200
  1588. #pragma warning(pop)
  1589. #else
  1590. #pragma warning (default:4035) // Reenable it
  1591. #endif
  1592. #endif
  1593. // begin_ntddk begin_wx86
  1594. //
  1595. // Define the size of the 80387 save area, which is in the context frame.
  1596. //
  1597. #define SIZE_OF_80387_REGISTERS 80
  1598. //
  1599. // The following flags control the contents of the CONTEXT structure.
  1600. //
  1601. #if !defined(RC_INVOKED)
  1602. #define CONTEXT_i386 0x00010000 // this assumes that i386 and
  1603. #define CONTEXT_i486 0x00010000 // i486 have identical context records
  1604. // end_wx86
  1605. #define CONTEXT_CONTROL (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
  1606. #define CONTEXT_INTEGER (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
  1607. #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS
  1608. #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x00000008L) // 387 state
  1609. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L) // DB 0-3,6,7
  1610. #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x00000020L) // cpu specific extensions
  1611. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER |\
  1612. CONTEXT_SEGMENTS)
  1613. // begin_wx86
  1614. #endif
  1615. #define MAXIMUM_SUPPORTED_EXTENSION 512
  1616. typedef struct _FLOATING_SAVE_AREA {
  1617. DWORD ControlWord;
  1618. DWORD StatusWord;
  1619. DWORD TagWord;
  1620. DWORD ErrorOffset;
  1621. DWORD ErrorSelector;
  1622. DWORD DataOffset;
  1623. DWORD DataSelector;
  1624. BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
  1625. DWORD Cr0NpxState;
  1626. } FLOATING_SAVE_AREA;
  1627. typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
  1628. //
  1629. // Context Frame
  1630. //
  1631. // This frame has a several purposes: 1) it is used as an argument to
  1632. // NtContinue, 2) is is used to constuct a call frame for APC delivery,
  1633. // and 3) it is used in the user level thread creation routines.
  1634. //
  1635. // The layout of the record conforms to a standard call frame.
  1636. //
  1637. typedef struct _CONTEXT {
  1638. //
  1639. // The flags values within this flag control the contents of
  1640. // a CONTEXT record.
  1641. //
  1642. // If the context record is used as an input parameter, then
  1643. // for each portion of the context record controlled by a flag
  1644. // whose value is set, it is assumed that that portion of the
  1645. // context record contains valid context. If the context record
  1646. // is being used to modify a threads context, then only that
  1647. // portion of the threads context will be modified.
  1648. //
  1649. // If the context record is used as an IN OUT parameter to capture
  1650. // the context of a thread, then only those portions of the thread's
  1651. // context corresponding to set flags will be returned.
  1652. //
  1653. // The context record is never used as an OUT only parameter.
  1654. //
  1655. DWORD ContextFlags;
  1656. //
  1657. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  1658. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  1659. // included in CONTEXT_FULL.
  1660. //
  1661. DWORD Dr0;
  1662. DWORD Dr1;
  1663. DWORD Dr2;
  1664. DWORD Dr3;
  1665. DWORD Dr6;
  1666. DWORD Dr7;
  1667. //
  1668. // This section is specified/returned if the
  1669. // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  1670. //
  1671. FLOATING_SAVE_AREA FloatSave;
  1672. //
  1673. // This section is specified/returned if the
  1674. // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  1675. //
  1676. DWORD SegGs;
  1677. DWORD SegFs;
  1678. DWORD SegEs;
  1679. DWORD SegDs;
  1680. //
  1681. // This section is specified/returned if the
  1682. // ContextFlags word contians the flag CONTEXT_INTEGER.
  1683. //
  1684. DWORD Edi;
  1685. DWORD Esi;
  1686. DWORD Ebx;
  1687. DWORD Edx;
  1688. DWORD Ecx;
  1689. DWORD Eax;
  1690. //
  1691. // This section is specified/returned if the
  1692. // ContextFlags word contians the flag CONTEXT_CONTROL.
  1693. //
  1694. DWORD Ebp;
  1695. DWORD Eip;
  1696. DWORD SegCs; // MUST BE SANITIZED
  1697. DWORD EFlags; // MUST BE SANITIZED
  1698. DWORD Esp;
  1699. DWORD SegSs;
  1700. //
  1701. // This section is specified/returned if the ContextFlags word
  1702. // contains the flag CONTEXT_EXTENDED_REGISTERS.
  1703. // The format and contexts are processor specific
  1704. //
  1705. BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
  1706. } CONTEXT;
  1707. typedef CONTEXT *PCONTEXT;
  1708. // begin_ntminiport
  1709. #endif //_X86_
  1710. #ifndef _LDT_ENTRY_DEFINED
  1711. #define _LDT_ENTRY_DEFINED
  1712. typedef struct _LDT_ENTRY {
  1713. WORD LimitLow;
  1714. WORD BaseLow;
  1715. union {
  1716. struct {
  1717. BYTE BaseMid;
  1718. BYTE Flags1; // Declare as bytes to avoid alignment
  1719. BYTE Flags2; // Problems.
  1720. BYTE BaseHi;
  1721. } Bytes;
  1722. struct {
  1723. DWORD BaseMid : 8;
  1724. DWORD Type : 5;
  1725. DWORD Dpl : 2;
  1726. DWORD Pres : 1;
  1727. DWORD LimitHi : 4;
  1728. DWORD Sys : 1;
  1729. DWORD Reserved_0 : 1;
  1730. DWORD Default_Big : 1;
  1731. DWORD Granularity : 1;
  1732. DWORD BaseHi : 8;
  1733. } Bits;
  1734. } HighWord;
  1735. } LDT_ENTRY, *PLDT_ENTRY;
  1736. #endif
  1737. #if defined(_MIPS_)
  1738. //
  1739. // Define functions to get the address of the current fiber and the
  1740. // current fiber data.
  1741. //
  1742. #define GetCurrentFiber() ((*(PNT_TIB *)0x7ffff4a8)->FiberData)
  1743. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  1744. // begin_ntddk begin_nthal
  1745. //
  1746. // The following flags control the contents of the CONTEXT structure.
  1747. //
  1748. #if !defined(RC_INVOKED)
  1749. #define CONTEXT_R4000 0x00010000 // r4000 context
  1750. #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
  1751. #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
  1752. #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
  1753. #define CONTEXT_EXTENDED_FLOAT (CONTEXT_FLOATING_POINT | 0x00000008)
  1754. #define CONTEXT_EXTENDED_INTEGER (CONTEXT_INTEGER | 0x00000010)
  1755. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | \
  1756. CONTEXT_INTEGER | CONTEXT_EXTENDED_INTEGER)
  1757. #endif
  1758. //
  1759. // Context Frame
  1760. //
  1761. // N.B. This frame must be exactly a multiple of 16 bytes in length.
  1762. //
  1763. // This frame has a several purposes: 1) it is used as an argument to
  1764. // NtContinue, 2) it is used to constuct a call frame for APC delivery,
  1765. // 3) it is used to construct a call frame for exception dispatching
  1766. // in user mode, and 4) it is used in the user level thread creation
  1767. // routines.
  1768. //
  1769. // The layout of the record conforms to a standard call frame.
  1770. //
  1771. typedef struct _CONTEXT {
  1772. //
  1773. // This section is always present and is used as an argument build
  1774. // area.
  1775. //
  1776. // N.B. Context records are 0 mod 8 aligned starting with NT 4.0.
  1777. //
  1778. union {
  1779. DWORD Argument[4];
  1780. ULONGLONG Alignment;
  1781. };
  1782. //
  1783. // The following union defines the 32-bit and 64-bit register context.
  1784. //
  1785. union {
  1786. //
  1787. // 32-bit context.
  1788. //
  1789. struct {
  1790. //
  1791. // This section is specified/returned if the ContextFlags contains
  1792. // the flag CONTEXT_FLOATING_POINT.
  1793. //
  1794. // N.B. This section contains the 16 double floating registers f0,
  1795. // f2, ..., f30.
  1796. //
  1797. DWORD FltF0;
  1798. DWORD FltF1;
  1799. DWORD FltF2;
  1800. DWORD FltF3;
  1801. DWORD FltF4;
  1802. DWORD FltF5;
  1803. DWORD FltF6;
  1804. DWORD FltF7;
  1805. DWORD FltF8;
  1806. DWORD FltF9;
  1807. DWORD FltF10;
  1808. DWORD FltF11;
  1809. DWORD FltF12;
  1810. DWORD FltF13;
  1811. DWORD FltF14;
  1812. DWORD FltF15;
  1813. DWORD FltF16;
  1814. DWORD FltF17;
  1815. DWORD FltF18;
  1816. DWORD FltF19;
  1817. DWORD FltF20;
  1818. DWORD FltF21;
  1819. DWORD FltF22;
  1820. DWORD FltF23;
  1821. DWORD FltF24;
  1822. DWORD FltF25;
  1823. DWORD FltF26;
  1824. DWORD FltF27;
  1825. DWORD FltF28;
  1826. DWORD FltF29;
  1827. DWORD FltF30;
  1828. DWORD FltF31;
  1829. //
  1830. // This section is specified/returned if the ContextFlags contains
  1831. // the flag CONTEXT_INTEGER.
  1832. //
  1833. // N.B. The registers gp, sp, and ra are defined in this section,
  1834. // but are considered part of the control context rather than
  1835. // part of the integer context.
  1836. //
  1837. // N.B. Register zero is not stored in the frame.
  1838. //
  1839. DWORD IntZero;
  1840. DWORD IntAt;
  1841. DWORD IntV0;
  1842. DWORD IntV1;
  1843. DWORD IntA0;
  1844. DWORD IntA1;
  1845. DWORD IntA2;
  1846. DWORD IntA3;
  1847. DWORD IntT0;
  1848. DWORD IntT1;
  1849. DWORD IntT2;
  1850. DWORD IntT3;
  1851. DWORD IntT4;
  1852. DWORD IntT5;
  1853. DWORD IntT6;
  1854. DWORD IntT7;
  1855. DWORD IntS0;
  1856. DWORD IntS1;
  1857. DWORD IntS2;
  1858. DWORD IntS3;
  1859. DWORD IntS4;
  1860. DWORD IntS5;
  1861. DWORD IntS6;
  1862. DWORD IntS7;
  1863. DWORD IntT8;
  1864. DWORD IntT9;
  1865. DWORD IntK0;
  1866. DWORD IntK1;
  1867. DWORD IntGp;
  1868. DWORD IntSp;
  1869. DWORD IntS8;
  1870. DWORD IntRa;
  1871. DWORD IntLo;
  1872. DWORD IntHi;
  1873. //
  1874. // This section is specified/returned if the ContextFlags word contains
  1875. // the flag CONTEXT_FLOATING_POINT.
  1876. //
  1877. DWORD Fsr;
  1878. //
  1879. // This section is specified/returned if the ContextFlags word contains
  1880. // the flag CONTEXT_CONTROL.
  1881. //
  1882. // N.B. The registers gp, sp, and ra are defined in the integer section,
  1883. // but are considered part of the control context rather than part of
  1884. // the integer context.
  1885. //
  1886. DWORD Fir;
  1887. DWORD Psr;
  1888. //
  1889. // The flags values within this flag control the contents of
  1890. // a CONTEXT record.
  1891. //
  1892. // If the context record is used as an input parameter, then
  1893. // for each portion of the context record controlled by a flag
  1894. // whose value is set, it is assumed that that portion of the
  1895. // context record contains valid context. If the context record
  1896. // is being used to modify a thread's context, then only that
  1897. // portion of the threads context will be modified.
  1898. //
  1899. // If the context record is used as an IN OUT parameter to capture
  1900. // the context of a thread, then only those portions of the thread's
  1901. // context corresponding to set flags will be returned.
  1902. //
  1903. // The context record is never used as an OUT only parameter.
  1904. //
  1905. DWORD ContextFlags;
  1906. };
  1907. //
  1908. // 64-bit context.
  1909. //
  1910. struct {
  1911. //
  1912. // This section is specified/returned if the ContextFlags contains
  1913. // the flag CONTEXT_EXTENDED_FLOAT.
  1914. //
  1915. // N.B. This section contains the 32 double floating registers f0,
  1916. // f1, ..., f31.
  1917. //
  1918. ULONGLONG XFltF0;
  1919. ULONGLONG XFltF1;
  1920. ULONGLONG XFltF2;
  1921. ULONGLONG XFltF3;
  1922. ULONGLONG XFltF4;
  1923. ULONGLONG XFltF5;
  1924. ULONGLONG XFltF6;
  1925. ULONGLONG XFltF7;
  1926. ULONGLONG XFltF8;
  1927. ULONGLONG XFltF9;
  1928. ULONGLONG XFltF10;
  1929. ULONGLONG XFltF11;
  1930. ULONGLONG XFltF12;
  1931. ULONGLONG XFltF13;
  1932. ULONGLONG XFltF14;
  1933. ULONGLONG XFltF15;
  1934. ULONGLONG XFltF16;
  1935. ULONGLONG XFltF17;
  1936. ULONGLONG XFltF18;
  1937. ULONGLONG XFltF19;
  1938. ULONGLONG XFltF20;
  1939. ULONGLONG XFltF21;
  1940. ULONGLONG XFltF22;
  1941. ULONGLONG XFltF23;
  1942. ULONGLONG XFltF24;
  1943. ULONGLONG XFltF25;
  1944. ULONGLONG XFltF26;
  1945. ULONGLONG XFltF27;
  1946. ULONGLONG XFltF28;
  1947. ULONGLONG XFltF29;
  1948. ULONGLONG XFltF30;
  1949. ULONGLONG XFltF31;
  1950. //
  1951. // The following sections must exactly overlay the 32-bit context.
  1952. //
  1953. DWORD Fill1;
  1954. DWORD Fill2;
  1955. //
  1956. // This section is specified/returned if the ContextFlags contains
  1957. // the flag CONTEXT_FLOATING_POINT.
  1958. //
  1959. DWORD XFsr;
  1960. //
  1961. // This section is specified/returned if the ContextFlags contains
  1962. // the flag CONTEXT_CONTROL.
  1963. //
  1964. // N.B. The registers gp, sp, and ra are defined in the integer
  1965. // section, but are considered part of the control context
  1966. // rather than part of the integer context.
  1967. //
  1968. DWORD XFir;
  1969. DWORD XPsr;
  1970. //
  1971. // The flags values within this flag control the contents of
  1972. // a CONTEXT record.
  1973. //
  1974. // If the context record is used as an input parameter, then
  1975. // for each portion of the context record controlled by a flag
  1976. // whose value is set, it is assumed that that portion of the
  1977. // context record contains valid context. If the context record
  1978. // is being used to modify a thread's context, then only that
  1979. // portion of the threads context will be modified.
  1980. //
  1981. // If the context record is used as an IN OUT parameter to capture
  1982. // the context of a thread, then only those portions of the thread's
  1983. // context corresponding to set flags will be returned.
  1984. //
  1985. // The context record is never used as an OUT only parameter.
  1986. //
  1987. DWORD XContextFlags;
  1988. //
  1989. // This section is specified/returned if the ContextFlags contains
  1990. // the flag CONTEXT_EXTENDED_INTEGER.
  1991. //
  1992. // N.B. The registers gp, sp, and ra are defined in this section,
  1993. // but are considered part of the control context rather than
  1994. // part of the integer context.
  1995. //
  1996. // N.B. Register zero is not stored in the frame.
  1997. //
  1998. ULONGLONG XIntZero;
  1999. ULONGLONG XIntAt;
  2000. ULONGLONG XIntV0;
  2001. ULONGLONG XIntV1;
  2002. ULONGLONG XIntA0;
  2003. ULONGLONG XIntA1;
  2004. ULONGLONG XIntA2;
  2005. ULONGLONG XIntA3;
  2006. ULONGLONG XIntT0;
  2007. ULONGLONG XIntT1;
  2008. ULONGLONG XIntT2;
  2009. ULONGLONG XIntT3;
  2010. ULONGLONG XIntT4;
  2011. ULONGLONG XIntT5;
  2012. ULONGLONG XIntT6;
  2013. ULONGLONG XIntT7;
  2014. ULONGLONG XIntS0;
  2015. ULONGLONG XIntS1;
  2016. ULONGLONG XIntS2;
  2017. ULONGLONG XIntS3;
  2018. ULONGLONG XIntS4;
  2019. ULONGLONG XIntS5;
  2020. ULONGLONG XIntS6;
  2021. ULONGLONG XIntS7;
  2022. ULONGLONG XIntT8;
  2023. ULONGLONG XIntT9;
  2024. ULONGLONG XIntK0;
  2025. ULONGLONG XIntK1;
  2026. ULONGLONG XIntGp;
  2027. ULONGLONG XIntSp;
  2028. ULONGLONG XIntS8;
  2029. ULONGLONG XIntRa;
  2030. ULONGLONG XIntLo;
  2031. ULONGLONG XIntHi;
  2032. };
  2033. };
  2034. } CONTEXT, *PCONTEXT;
  2035. // end_ntddk end_nthal
  2036. #define CONTEXT32_LENGTH 0x130 // The original 32-bit Context length (pre NT 4.0)
  2037. #endif // MIPS
  2038. #if defined(_MIPS_)
  2039. VOID
  2040. __jump_unwind (
  2041. PVOID Fp,
  2042. PVOID TargetPc
  2043. );
  2044. #endif // MIPS
  2045. #if defined(_PPC_)
  2046. //
  2047. // The address of the TEB is placed into GPR 13 at context switch time
  2048. // and should never be destroyed. To get the address of the TEB use
  2049. // the compiler intrinsic to access it directly from GPR 13.
  2050. //
  2051. #if defined(_M_PPC) && defined(_MSC_VER) && (_MSC_VER>=1000)
  2052. unsigned __gregister_get( unsigned const regnum );
  2053. #define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
  2054. #elif defined(_M_PPC)
  2055. struct _TEB * __builtin_get_gpr13(VOID);
  2056. #define NtCurrentTeb() ((struct _TEB *)__builtin_get_gpr13())
  2057. #endif
  2058. //
  2059. // Define functions to get the address of the current fiber and the
  2060. // current fiber data.
  2061. //
  2062. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  2063. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  2064. // begin_ntddk begin_nthal
  2065. //
  2066. // The following flags control the contents of the CONTEXT structure.
  2067. //
  2068. #if !defined(RC_INVOKED)
  2069. #define CONTEXT_CONTROL 0x00000001L
  2070. #define CONTEXT_FLOATING_POINT 0x00000002L
  2071. #define CONTEXT_INTEGER 0x00000004L
  2072. #define CONTEXT_DEBUG_REGISTERS 0x00000008L
  2073. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  2074. #endif
  2075. //
  2076. // Context Frame
  2077. //
  2078. // N.B. This frame must be exactly a multiple of 16 bytes in length.
  2079. //
  2080. // This frame has a several purposes: 1) it is used as an argument to
  2081. // NtContinue, 2) it is used to constuct a call frame for APC delivery,
  2082. // 3) it is used to construct a call frame for exception dispatching
  2083. // in user mode, and 4) it is used in the user level thread creation
  2084. // routines.
  2085. //
  2086. // Requires at least 8-byte alignment (double)
  2087. //
  2088. typedef struct _CONTEXT {
  2089. //
  2090. // This section is specified/returned if the ContextFlags word contains
  2091. // the flag CONTEXT_FLOATING_POINT.
  2092. //
  2093. double Fpr0; // Floating registers 0..31
  2094. double Fpr1;
  2095. double Fpr2;
  2096. double Fpr3;
  2097. double Fpr4;
  2098. double Fpr5;
  2099. double Fpr6;
  2100. double Fpr7;
  2101. double Fpr8;
  2102. double Fpr9;
  2103. double Fpr10;
  2104. double Fpr11;
  2105. double Fpr12;
  2106. double Fpr13;
  2107. double Fpr14;
  2108. double Fpr15;
  2109. double Fpr16;
  2110. double Fpr17;
  2111. double Fpr18;
  2112. double Fpr19;
  2113. double Fpr20;
  2114. double Fpr21;
  2115. double Fpr22;
  2116. double Fpr23;
  2117. double Fpr24;
  2118. double Fpr25;
  2119. double Fpr26;
  2120. double Fpr27;
  2121. double Fpr28;
  2122. double Fpr29;
  2123. double Fpr30;
  2124. double Fpr31;
  2125. double Fpscr; // Floating point status/control reg
  2126. //
  2127. // This section is specified/returned if the ContextFlags word contains
  2128. // the flag CONTEXT_INTEGER.
  2129. //
  2130. DWORD Gpr0; // General registers 0..31
  2131. DWORD Gpr1;
  2132. DWORD Gpr2;
  2133. DWORD Gpr3;
  2134. DWORD Gpr4;
  2135. DWORD Gpr5;
  2136. DWORD Gpr6;
  2137. DWORD Gpr7;
  2138. DWORD Gpr8;
  2139. DWORD Gpr9;
  2140. DWORD Gpr10;
  2141. DWORD Gpr11;
  2142. DWORD Gpr12;
  2143. DWORD Gpr13;
  2144. DWORD Gpr14;
  2145. DWORD Gpr15;
  2146. DWORD Gpr16;
  2147. DWORD Gpr17;
  2148. DWORD Gpr18;
  2149. DWORD Gpr19;
  2150. DWORD Gpr20;
  2151. DWORD Gpr21;
  2152. DWORD Gpr22;
  2153. DWORD Gpr23;
  2154. DWORD Gpr24;
  2155. DWORD Gpr25;
  2156. DWORD Gpr26;
  2157. DWORD Gpr27;
  2158. DWORD Gpr28;
  2159. DWORD Gpr29;
  2160. DWORD Gpr30;
  2161. DWORD Gpr31;
  2162. DWORD Cr; // Condition register
  2163. DWORD Xer; // Fixed point exception register
  2164. //
  2165. // This section is specified/returned if the ContextFlags word contains
  2166. // the flag CONTEXT_CONTROL.
  2167. //
  2168. DWORD Msr; // Machine status register
  2169. DWORD Iar; // Instruction address register
  2170. DWORD Lr; // Link register
  2171. DWORD Ctr; // Count register
  2172. //
  2173. // The flags values within this flag control the contents of
  2174. // a CONTEXT record.
  2175. //
  2176. // If the context record is used as an input parameter, then
  2177. // for each portion of the context record controlled by a flag
  2178. // whose value is set, it is assumed that that portion of the
  2179. // context record contains valid context. If the context record
  2180. // is being used to modify a thread's context, then only that
  2181. // portion of the threads context will be modified.
  2182. //
  2183. // If the context record is used as an IN OUT parameter to capture
  2184. // the context of a thread, then only those portions of the thread's
  2185. // context corresponding to set flags will be returned.
  2186. //
  2187. // The context record is never used as an OUT only parameter.
  2188. //
  2189. DWORD ContextFlags;
  2190. DWORD Fill[3]; // Pad out to multiple of 16 bytes
  2191. //
  2192. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  2193. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  2194. // included in CONTEXT_FULL.
  2195. //
  2196. DWORD Dr0; // Breakpoint Register 1
  2197. DWORD Dr1; // Breakpoint Register 2
  2198. DWORD Dr2; // Breakpoint Register 3
  2199. DWORD Dr3; // Breakpoint Register 4
  2200. DWORD Dr4; // Breakpoint Register 5
  2201. DWORD Dr5; // Breakpoint Register 6
  2202. DWORD Dr6; // Debug Status Register
  2203. DWORD Dr7; // Debug Control Register
  2204. } CONTEXT, *PCONTEXT;
  2205. // end_ntddk end_nthal
  2206. //
  2207. // Stack frame header
  2208. //
  2209. // Order of appearance in stack frame:
  2210. // Header (six words)
  2211. // Parameters (at least eight words)
  2212. // Local variables
  2213. // Saved GPRs
  2214. // Saved FPRs
  2215. //
  2216. // Minimum alignment is 8 bytes
  2217. typedef struct _STACK_FRAME_HEADER { // GPR 1 points here
  2218. DWORD BackChain; // Addr of previous frame
  2219. DWORD GlueSaved1; // Used by glue code
  2220. DWORD GlueSaved2;
  2221. DWORD Reserved1; // Reserved
  2222. DWORD Spare1; // Used by tracing, profiling, ...
  2223. DWORD Spare2;
  2224. DWORD Parameter0; // First 8 parameter words are
  2225. DWORD Parameter1; // always present
  2226. DWORD Parameter2;
  2227. DWORD Parameter3;
  2228. DWORD Parameter4;
  2229. DWORD Parameter5;
  2230. DWORD Parameter6;
  2231. DWORD Parameter7;
  2232. } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
  2233. VOID
  2234. __jump_unwind (
  2235. PVOID Fp,
  2236. PVOID TargetPc
  2237. );
  2238. #endif // defined(_PPC_)
  2239. #if defined(_MPPC_)
  2240. //
  2241. // The address of the TEB is placed into GPR 13 at context switch time
  2242. // and should never be destroyed. To get the address of the TEB use
  2243. // the compiler intrinsic to access it directly from GPR 13.
  2244. //
  2245. #if defined(_M_PPC) && defined(_MSC_VER) && (_MSC_VER>=1000)
  2246. unsigned __gregister_get( unsigned const regnum );
  2247. #define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
  2248. #elif defined(_M_PPC)
  2249. struct _TEB * __builtin_get_gpr13(VOID);
  2250. #define NtCurrentTeb() ((struct _TEB *)__builtin_get_gpr13())
  2251. #endif
  2252. //
  2253. // Define functions to get the address of the current fiber and the
  2254. // current fiber data.
  2255. //
  2256. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  2257. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  2258. // begin_ntddk begin_nthal
  2259. //
  2260. // The following flags control the contents of the CONTEXT structure.
  2261. //
  2262. #if !defined(RC_INVOKED)
  2263. #define CONTEXT_CONTROL 0x00000001L
  2264. #define CONTEXT_FLOATING_POINT 0x00000002L
  2265. #define CONTEXT_INTEGER 0x00000004L
  2266. #define CONTEXT_DEBUG_REGISTERS 0x00000008L
  2267. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  2268. #endif
  2269. //
  2270. // Context Frame
  2271. //
  2272. // N.B. This frame must be exactly a multiple of 16 bytes in length.
  2273. //
  2274. // This frame has a several purposes: 1) it is used as an argument to
  2275. // NtContinue, 2) it is used to constuct a call frame for APC delivery,
  2276. // 3) it is used to construct a call frame for exception dispatching
  2277. // in user mode, and 4) it is used in the user level thread creation
  2278. // routines.
  2279. //
  2280. // Requires at least 8-byte alignment (double)
  2281. //
  2282. typedef struct _CONTEXT {
  2283. //
  2284. // This section is specified/returned if the ContextFlags word contains
  2285. // the flag CONTEXT_FLOATING_POINT.
  2286. //
  2287. double Fpr0; // Floating registers 0..31
  2288. double Fpr1;
  2289. double Fpr2;
  2290. double Fpr3;
  2291. double Fpr4;
  2292. double Fpr5;
  2293. double Fpr6;
  2294. double Fpr7;
  2295. double Fpr8;
  2296. double Fpr9;
  2297. double Fpr10;
  2298. double Fpr11;
  2299. double Fpr12;
  2300. double Fpr13;
  2301. double Fpr14;
  2302. double Fpr15;
  2303. double Fpr16;
  2304. double Fpr17;
  2305. double Fpr18;
  2306. double Fpr19;
  2307. double Fpr20;
  2308. double Fpr21;
  2309. double Fpr22;
  2310. double Fpr23;
  2311. double Fpr24;
  2312. double Fpr25;
  2313. double Fpr26;
  2314. double Fpr27;
  2315. double Fpr28;
  2316. double Fpr29;
  2317. double Fpr30;
  2318. double Fpr31;
  2319. double Fpscr; // Floating point status/control reg
  2320. //
  2321. // This section is specified/returned if the ContextFlags word contains
  2322. // the flag CONTEXT_INTEGER.
  2323. //
  2324. DWORD Gpr0; // General registers 0..31
  2325. DWORD Gpr1;
  2326. DWORD Gpr2;
  2327. DWORD Gpr3;
  2328. DWORD Gpr4;
  2329. DWORD Gpr5;
  2330. DWORD Gpr6;
  2331. DWORD Gpr7;
  2332. DWORD Gpr8;
  2333. DWORD Gpr9;
  2334. DWORD Gpr10;
  2335. DWORD Gpr11;
  2336. DWORD Gpr12;
  2337. DWORD Gpr13;
  2338. DWORD Gpr14;
  2339. DWORD Gpr15;
  2340. DWORD Gpr16;
  2341. DWORD Gpr17;
  2342. DWORD Gpr18;
  2343. DWORD Gpr19;
  2344. DWORD Gpr20;
  2345. DWORD Gpr21;
  2346. DWORD Gpr22;
  2347. DWORD Gpr23;
  2348. DWORD Gpr24;
  2349. DWORD Gpr25;
  2350. DWORD Gpr26;
  2351. DWORD Gpr27;
  2352. DWORD Gpr28;
  2353. DWORD Gpr29;
  2354. DWORD Gpr30;
  2355. DWORD Gpr31;
  2356. DWORD Cr; // Condition register
  2357. DWORD Xer; // Fixed point exception register
  2358. //
  2359. // This section is specified/returned if the ContextFlags word contains
  2360. // the flag CONTEXT_CONTROL.
  2361. //
  2362. DWORD Msr; // Machine status register
  2363. DWORD Iar; // Instruction address register
  2364. DWORD Lr; // Link register
  2365. DWORD Ctr; // Count register
  2366. //
  2367. // The flags values within this flag control the contents of
  2368. // a CONTEXT record.
  2369. //
  2370. // If the context record is used as an input parameter, then
  2371. // for each portion of the context record controlled by a flag
  2372. // whose value is set, it is assumed that that portion of the
  2373. // context record contains valid context. If the context record
  2374. // is being used to modify a thread's context, then only that
  2375. // portion of the threads context will be modified.
  2376. //
  2377. // If the context record is used as an IN OUT parameter to capture
  2378. // the context of a thread, then only those portions of the thread's
  2379. // context corresponding to set flags will be returned.
  2380. //
  2381. // The context record is never used as an OUT only parameter.
  2382. //
  2383. DWORD ContextFlags;
  2384. DWORD Fill[3]; // Pad out to multiple of 16 bytes
  2385. //
  2386. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  2387. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  2388. // included in CONTEXT_FULL.
  2389. //
  2390. DWORD Dr0; // Breakpoint Register 1
  2391. DWORD Dr1; // Breakpoint Register 2
  2392. DWORD Dr2; // Breakpoint Register 3
  2393. DWORD Dr3; // Breakpoint Register 4
  2394. DWORD Dr4; // Breakpoint Register 5
  2395. DWORD Dr5; // Breakpoint Register 6
  2396. DWORD Dr6; // Debug Status Register
  2397. DWORD Dr7; // Debug Control Register
  2398. } CONTEXT, *PCONTEXT;
  2399. // end_ntddk end_nthal
  2400. //
  2401. // Stack frame header
  2402. //
  2403. // Order of appearance in stack frame:
  2404. // Header (six words)
  2405. // Parameters (at least eight words)
  2406. // Local variables
  2407. // Saved GPRs
  2408. // Saved FPRs
  2409. //
  2410. // Minimum alignment is 8 bytes
  2411. typedef struct _STACK_FRAME_HEADER { // GPR 1 points here
  2412. DWORD BackChain; // Addr of previous frame
  2413. DWORD GlueSaved1; // Used by glue code
  2414. DWORD GlueSaved2;
  2415. DWORD Reserved1; // Reserved
  2416. DWORD Spare1; // Used by tracing, profiling, ...
  2417. DWORD Spare2;
  2418. DWORD Parameter0; // First 8 parameter words are
  2419. DWORD Parameter1; // always present
  2420. DWORD Parameter2;
  2421. DWORD Parameter3;
  2422. DWORD Parameter4;
  2423. DWORD Parameter5;
  2424. DWORD Parameter6;
  2425. DWORD Parameter7;
  2426. } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
  2427. VOID
  2428. __jump_unwind (
  2429. PVOID Fp,
  2430. PVOID TargetPc
  2431. );
  2432. #endif // defined(_MPPC_)
  2433. #if !defined(__midl) && !defined(GENUTIL) && !defined(_GENIA64_) && defined(_IA64_)
  2434. void * _cdecl _rdteb(void);
  2435. #if defined(_M_IA64) // winnt
  2436. #pragma intrinsic(_rdteb) // winnt
  2437. #endif // winnt
  2438. #if defined(_M_IA64)
  2439. #define NtCurrentTeb() ((struct _TEB *)_rdteb())
  2440. #else
  2441. struct _TEB *
  2442. NtCurrentTeb(void);
  2443. #endif
  2444. //
  2445. // Define functions to get the address of the current fiber and the
  2446. // current fiber data.
  2447. //
  2448. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  2449. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  2450. #endif // !defined(__midl) && !defined(GENUTIL) && !defined(_GENIA64_) && defined(_M_IA64)
  2451. #ifdef _IA64_
  2452. // begin_ntddk begin_nthal
  2453. //
  2454. // The following flags control the contents of the CONTEXT structure.
  2455. //
  2456. #if !defined(RC_INVOKED)
  2457. #define CONTEXT_IA64 0x00080000
  2458. #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001L)
  2459. #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002L)
  2460. #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004L)
  2461. #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008L)
  2462. #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010L)
  2463. #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020L) // Includes StIPSR
  2464. #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
  2465. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
  2466. #endif // !defined(RC_INVOKED)
  2467. //
  2468. // Context Frame
  2469. //
  2470. // This frame has a several purposes: 1) it is used as an argument to
  2471. // NtContinue, 2) it is used to construct a call frame for APC delivery,
  2472. // 3) it is used to construct a call frame for exception dispatching
  2473. // in user mode, 4) it is used in the user level thread creation
  2474. // routines, and 5) it is used to to pass thread state to debuggers.
  2475. //
  2476. // N.B. Because this record is used as a call frame, it must be EXACTLY
  2477. // a multiple of 16 bytes in length and aligned on a 16-byte boundary.
  2478. //
  2479. typedef struct _CONTEXT {
  2480. //
  2481. // The flags values within this flag control the contents of
  2482. // a CONTEXT record.
  2483. //
  2484. // If the context record is used as an input parameter, then
  2485. // for each portion of the context record controlled by a flag
  2486. // whose value is set, it is assumed that that portion of the
  2487. // context record contains valid context. If the context record
  2488. // is being used to modify a thread's context, then only that
  2489. // portion of the threads context will be modified.
  2490. //
  2491. // If the context record is used as an IN OUT parameter to capture
  2492. // the context of a thread, then only those portions of the thread's
  2493. // context corresponding to set flags will be returned.
  2494. //
  2495. // The context record is never used as an OUT only parameter.
  2496. //
  2497. DWORD ContextFlags;
  2498. DWORD Fill1[3]; // for alignment of following on 16-byte boundary
  2499. //
  2500. // This section is specified/returned if the ContextFlags word contains
  2501. // the flag CONTEXT_DEBUG.
  2502. //
  2503. // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
  2504. //
  2505. ULONGLONG DbI0;
  2506. ULONGLONG DbI1;
  2507. ULONGLONG DbI2;
  2508. ULONGLONG DbI3;
  2509. ULONGLONG DbI4;
  2510. ULONGLONG DbI5;
  2511. ULONGLONG DbI6;
  2512. ULONGLONG DbI7;
  2513. ULONGLONG DbD0;
  2514. ULONGLONG DbD1;
  2515. ULONGLONG DbD2;
  2516. ULONGLONG DbD3;
  2517. ULONGLONG DbD4;
  2518. ULONGLONG DbD5;
  2519. ULONGLONG DbD6;
  2520. ULONGLONG DbD7;
  2521. //
  2522. // This section is specified/returned if the ContextFlags word contains
  2523. // the flag CONTEXT_LOWER_FLOATING_POINT.
  2524. //
  2525. FLOAT128 FltS0;
  2526. FLOAT128 FltS1;
  2527. FLOAT128 FltS2;
  2528. FLOAT128 FltS3;
  2529. FLOAT128 FltT0;
  2530. FLOAT128 FltT1;
  2531. FLOAT128 FltT2;
  2532. FLOAT128 FltT3;
  2533. FLOAT128 FltT4;
  2534. FLOAT128 FltT5;
  2535. FLOAT128 FltT6;
  2536. FLOAT128 FltT7;
  2537. FLOAT128 FltT8;
  2538. FLOAT128 FltT9;
  2539. //
  2540. // This section is specified/returned if the ContextFlags word contains
  2541. // the flag CONTEXT_HIGHER_FLOATING_POINT.
  2542. //
  2543. FLOAT128 FltS4;
  2544. FLOAT128 FltS5;
  2545. FLOAT128 FltS6;
  2546. FLOAT128 FltS7;
  2547. FLOAT128 FltS8;
  2548. FLOAT128 FltS9;
  2549. FLOAT128 FltS10;
  2550. FLOAT128 FltS11;
  2551. FLOAT128 FltS12;
  2552. FLOAT128 FltS13;
  2553. FLOAT128 FltS14;
  2554. FLOAT128 FltS15;
  2555. FLOAT128 FltS16;
  2556. FLOAT128 FltS17;
  2557. FLOAT128 FltS18;
  2558. FLOAT128 FltS19;
  2559. FLOAT128 FltF32;
  2560. FLOAT128 FltF33;
  2561. FLOAT128 FltF34;
  2562. FLOAT128 FltF35;
  2563. FLOAT128 FltF36;
  2564. FLOAT128 FltF37;
  2565. FLOAT128 FltF38;
  2566. FLOAT128 FltF39;
  2567. FLOAT128 FltF40;
  2568. FLOAT128 FltF41;
  2569. FLOAT128 FltF42;
  2570. FLOAT128 FltF43;
  2571. FLOAT128 FltF44;
  2572. FLOAT128 FltF45;
  2573. FLOAT128 FltF46;
  2574. FLOAT128 FltF47;
  2575. FLOAT128 FltF48;
  2576. FLOAT128 FltF49;
  2577. FLOAT128 FltF50;
  2578. FLOAT128 FltF51;
  2579. FLOAT128 FltF52;
  2580. FLOAT128 FltF53;
  2581. FLOAT128 FltF54;
  2582. FLOAT128 FltF55;
  2583. FLOAT128 FltF56;
  2584. FLOAT128 FltF57;
  2585. FLOAT128 FltF58;
  2586. FLOAT128 FltF59;
  2587. FLOAT128 FltF60;
  2588. FLOAT128 FltF61;
  2589. FLOAT128 FltF62;
  2590. FLOAT128 FltF63;
  2591. FLOAT128 FltF64;
  2592. FLOAT128 FltF65;
  2593. FLOAT128 FltF66;
  2594. FLOAT128 FltF67;
  2595. FLOAT128 FltF68;
  2596. FLOAT128 FltF69;
  2597. FLOAT128 FltF70;
  2598. FLOAT128 FltF71;
  2599. FLOAT128 FltF72;
  2600. FLOAT128 FltF73;
  2601. FLOAT128 FltF74;
  2602. FLOAT128 FltF75;
  2603. FLOAT128 FltF76;
  2604. FLOAT128 FltF77;
  2605. FLOAT128 FltF78;
  2606. FLOAT128 FltF79;
  2607. FLOAT128 FltF80;
  2608. FLOAT128 FltF81;
  2609. FLOAT128 FltF82;
  2610. FLOAT128 FltF83;
  2611. FLOAT128 FltF84;
  2612. FLOAT128 FltF85;
  2613. FLOAT128 FltF86;
  2614. FLOAT128 FltF87;
  2615. FLOAT128 FltF88;
  2616. FLOAT128 FltF89;
  2617. FLOAT128 FltF90;
  2618. FLOAT128 FltF91;
  2619. FLOAT128 FltF92;
  2620. FLOAT128 FltF93;
  2621. FLOAT128 FltF94;
  2622. FLOAT128 FltF95;
  2623. FLOAT128 FltF96;
  2624. FLOAT128 FltF97;
  2625. FLOAT128 FltF98;
  2626. FLOAT128 FltF99;
  2627. FLOAT128 FltF100;
  2628. FLOAT128 FltF101;
  2629. FLOAT128 FltF102;
  2630. FLOAT128 FltF103;
  2631. FLOAT128 FltF104;
  2632. FLOAT128 FltF105;
  2633. FLOAT128 FltF106;
  2634. FLOAT128 FltF107;
  2635. FLOAT128 FltF108;
  2636. FLOAT128 FltF109;
  2637. FLOAT128 FltF110;
  2638. FLOAT128 FltF111;
  2639. FLOAT128 FltF112;
  2640. FLOAT128 FltF113;
  2641. FLOAT128 FltF114;
  2642. FLOAT128 FltF115;
  2643. FLOAT128 FltF116;
  2644. FLOAT128 FltF117;
  2645. FLOAT128 FltF118;
  2646. FLOAT128 FltF119;
  2647. FLOAT128 FltF120;
  2648. FLOAT128 FltF121;
  2649. FLOAT128 FltF122;
  2650. FLOAT128 FltF123;
  2651. FLOAT128 FltF124;
  2652. FLOAT128 FltF125;
  2653. FLOAT128 FltF126;
  2654. FLOAT128 FltF127;
  2655. //
  2656. // This section is specified/returned if the ContextFlags word contains
  2657. // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
  2658. //
  2659. ULONGLONG StFPSR; // FP status
  2660. //
  2661. // This section is specified/returned if the ContextFlags word contains
  2662. // the flag CONTEXT_INTEGER.
  2663. //
  2664. // N.B. The registers gp, sp, rp are part of the control context
  2665. //
  2666. ULONGLONG IntGp; // r1, volatile
  2667. ULONGLONG IntT0; // r2-r3, volatile
  2668. ULONGLONG IntT1; //
  2669. ULONGLONG IntS0; // r4-r7, preserved
  2670. ULONGLONG IntS1;
  2671. ULONGLONG IntS2;
  2672. ULONGLONG IntS3;
  2673. ULONGLONG IntV0; // r8, volatile
  2674. ULONGLONG IntT2; // r9-r11, volatile
  2675. ULONGLONG IntT3;
  2676. ULONGLONG IntT4;
  2677. ULONGLONG IntSp; // stack pointer (r12), special
  2678. ULONGLONG IntTeb; // teb (r13), special
  2679. ULONGLONG IntT5; // r14-r31, volatile
  2680. ULONGLONG IntT6;
  2681. ULONGLONG IntT7;
  2682. ULONGLONG IntT8;
  2683. ULONGLONG IntT9;
  2684. ULONGLONG IntT10;
  2685. ULONGLONG IntT11;
  2686. ULONGLONG IntT12;
  2687. ULONGLONG IntT13;
  2688. ULONGLONG IntT14;
  2689. ULONGLONG IntT15;
  2690. ULONGLONG IntT16;
  2691. ULONGLONG IntT17;
  2692. ULONGLONG IntT18;
  2693. ULONGLONG IntT19;
  2694. ULONGLONG IntT20;
  2695. ULONGLONG IntT21;
  2696. ULONGLONG IntT22;
  2697. ULONGLONG IntNats; // Nat bits for r1-r31
  2698. // r1-r31 in bits 1 thru 31.
  2699. ULONGLONG Preds; // predicates, preserved
  2700. ULONGLONG BrRp; // return pointer, b0, preserved
  2701. ULONGLONG BrS0; // b1-b5, preserved
  2702. ULONGLONG BrS1;
  2703. ULONGLONG BrS2;
  2704. ULONGLONG BrS3;
  2705. ULONGLONG BrS4;
  2706. ULONGLONG BrT0; // b6-b7, volatile
  2707. ULONGLONG BrT1;
  2708. //
  2709. // This section is specified/returned if the ContextFlags word contains
  2710. // the flag CONTEXT_CONTROL.
  2711. //
  2712. // Other application registers
  2713. ULONGLONG ApUNAT; // User Nat collection register, preserved
  2714. ULONGLONG ApLC; // Loop counter register, preserved
  2715. ULONGLONG ApEC; // Epilog counter register, preserved
  2716. ULONGLONG ApCCV; // CMPXCHG value register, volatile
  2717. ULONGLONG ApDCR; // Default control register (TBD)
  2718. // Register stack info
  2719. ULONGLONG RsPFS; // Previous function state, preserved
  2720. ULONGLONG RsBSP; // Backing store pointer, preserved
  2721. ULONGLONG RsBSPSTORE;
  2722. ULONGLONG RsRSC; // RSE configuration, volatile
  2723. ULONGLONG RsRNAT; // RSE Nat collection register, preserved
  2724. // Trap Status Information
  2725. ULONGLONG StIPSR; // Interruption Processor Status
  2726. ULONGLONG StIIP; // Interruption IP
  2727. ULONGLONG StIFS; // Interruption Function State
  2728. // iA32 related control registers
  2729. ULONGLONG StFCR; // copy of Ar21
  2730. ULONGLONG Eflag; // Eflag copy of Ar24
  2731. ULONGLONG SegCSD; // iA32 CSDescriptor (Ar25)
  2732. ULONGLONG SegSSD; // iA32 SSDescriptor (Ar26)
  2733. ULONGLONG Cflag; // Cr0+Cr4 copy of Ar27
  2734. ULONGLONG StFSR; // x86 FP status (copy of AR28)
  2735. ULONGLONG StFIR; // x86 FP status (copy of AR29)
  2736. ULONGLONG StFDR; // x86 FP status (copy of AR30)
  2737. ULONGLONG UNUSEDPACK; // added to pack StFDR to 16-bytes
  2738. } CONTEXT, *PCONTEXT;
  2739. // begin_winnt
  2740. //
  2741. // Plabel descriptor structure definition
  2742. //
  2743. typedef struct _PLABEL_DESCRIPTOR {
  2744. ULONGLONG EntryPoint;
  2745. ULONGLONG GlobalPointer;
  2746. } PLABEL_DESCRIPTOR, *PPLABEL_DESCRIPTOR;
  2747. #endif // _IA64_
  2748. #ifdef _IA64_
  2749. VOID
  2750. __jump_unwind (
  2751. ULONGLONG TargetMsFrame,
  2752. ULONGLONG TargetBsFrame,
  2753. ULONGLONG TargetPc
  2754. );
  2755. #endif // _IA64_
  2756. #define EXCEPTION_NONCONTINUABLE 0x1 // Noncontinuable exception
  2757. #define EXCEPTION_MAXIMUM_PARAMETERS 15 // maximum number of exception parameters
  2758. //
  2759. // Exception record definition.
  2760. //
  2761. typedef struct _EXCEPTION_RECORD {
  2762. DWORD ExceptionCode;
  2763. DWORD ExceptionFlags;
  2764. struct _EXCEPTION_RECORD *ExceptionRecord;
  2765. PVOID ExceptionAddress;
  2766. DWORD NumberParameters;
  2767. ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  2768. } EXCEPTION_RECORD;
  2769. typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
  2770. typedef struct _EXCEPTION_RECORD32 {
  2771. DWORD ExceptionCode;
  2772. DWORD ExceptionFlags;
  2773. DWORD ExceptionRecord;
  2774. DWORD ExceptionAddress;
  2775. DWORD NumberParameters;
  2776. DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  2777. } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
  2778. typedef struct _EXCEPTION_RECORD64 {
  2779. DWORD ExceptionCode;
  2780. DWORD ExceptionFlags;
  2781. DWORD64 ExceptionRecord;
  2782. DWORD64 ExceptionAddress;
  2783. DWORD NumberParameters;
  2784. DWORD __unusedAlignment;
  2785. DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  2786. } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
  2787. //
  2788. // Typedef for pointer returned by exception_info()
  2789. //
  2790. typedef struct _EXCEPTION_POINTERS {
  2791. PEXCEPTION_RECORD ExceptionRecord;
  2792. PCONTEXT ContextRecord;
  2793. } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
  2794. typedef PVOID PACCESS_TOKEN;
  2795. typedef PVOID PSECURITY_DESCRIPTOR;
  2796. typedef PVOID PSID;
  2797. ////////////////////////////////////////////////////////////////////////
  2798. // //
  2799. // ACCESS MASK //
  2800. // //
  2801. ////////////////////////////////////////////////////////////////////////
  2802. //
  2803. // Define the access mask as a longword sized structure divided up as
  2804. // follows:
  2805. //
  2806. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2807. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  2808. // +---------------+---------------+-------------------------------+
  2809. // |G|G|G|G|Res'd|A| StandardRights| SpecificRights |
  2810. // |R|W|E|A| |S| | |
  2811. // +-+-------------+---------------+-------------------------------+
  2812. //
  2813. // typedef struct _ACCESS_MASK {
  2814. // WORD SpecificRights;
  2815. // BYTE StandardRights;
  2816. // BYTE AccessSystemAcl : 1;
  2817. // BYTE Reserved : 3;
  2818. // BYTE GenericAll : 1;
  2819. // BYTE GenericExecute : 1;
  2820. // BYTE GenericWrite : 1;
  2821. // BYTE GenericRead : 1;
  2822. // } ACCESS_MASK;
  2823. // typedef ACCESS_MASK *PACCESS_MASK;
  2824. //
  2825. // but to make life simple for programmer's we'll allow them to specify
  2826. // a desired access mask by simply OR'ing together mulitple single rights
  2827. // and treat an access mask as a DWORD. For example
  2828. //
  2829. // DesiredAccess = DELETE | READ_CONTROL
  2830. //
  2831. // So we'll declare ACCESS_MASK as DWORD
  2832. //
  2833. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  2834. typedef DWORD ACCESS_MASK;
  2835. typedef ACCESS_MASK *PACCESS_MASK;
  2836. ////////////////////////////////////////////////////////////////////////
  2837. // //
  2838. // ACCESS TYPES //
  2839. // //
  2840. ////////////////////////////////////////////////////////////////////////
  2841. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  2842. //
  2843. // The following are masks for the predefined standard access types
  2844. //
  2845. #define DELETE (0x00010000L)
  2846. #define READ_CONTROL (0x00020000L)
  2847. #define WRITE_DAC (0x00040000L)
  2848. #define WRITE_OWNER (0x00080000L)
  2849. #define SYNCHRONIZE (0x00100000L)
  2850. #define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
  2851. #define STANDARD_RIGHTS_READ (READ_CONTROL)
  2852. #define STANDARD_RIGHTS_WRITE (READ_CONTROL)
  2853. #define STANDARD_RIGHTS_EXECUTE (READ_CONTROL)
  2854. #define STANDARD_RIGHTS_ALL (0x001F0000L)
  2855. #define SPECIFIC_RIGHTS_ALL (0x0000FFFFL)
  2856. //
  2857. // AccessSystemAcl access type
  2858. //
  2859. #define ACCESS_SYSTEM_SECURITY (0x01000000L)
  2860. //
  2861. // MaximumAllowed access type
  2862. //
  2863. #define MAXIMUM_ALLOWED (0x02000000L)
  2864. //
  2865. // These are the generic rights.
  2866. //
  2867. #define GENERIC_READ (0x80000000L)
  2868. #define GENERIC_WRITE (0x40000000L)
  2869. #define GENERIC_EXECUTE (0x20000000L)
  2870. #define GENERIC_ALL (0x10000000L)
  2871. //
  2872. // Define the generic mapping array. This is used to denote the
  2873. // mapping of each generic access right to a specific access mask.
  2874. //
  2875. typedef struct _GENERIC_MAPPING {
  2876. ACCESS_MASK GenericRead;
  2877. ACCESS_MASK GenericWrite;
  2878. ACCESS_MASK GenericExecute;
  2879. ACCESS_MASK GenericAll;
  2880. } GENERIC_MAPPING;
  2881. typedef GENERIC_MAPPING *PGENERIC_MAPPING;
  2882. ////////////////////////////////////////////////////////////////////////
  2883. // //
  2884. // LUID_AND_ATTRIBUTES //
  2885. // //
  2886. ////////////////////////////////////////////////////////////////////////
  2887. //
  2888. //
  2889. #include <pshpack4.h>
  2890. typedef struct _LUID_AND_ATTRIBUTES {
  2891. LUID Luid;
  2892. DWORD Attributes;
  2893. } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
  2894. typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
  2895. typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
  2896. #include <poppack.h>
  2897. ////////////////////////////////////////////////////////////////////////
  2898. // //
  2899. // Security Id (SID) //
  2900. // //
  2901. ////////////////////////////////////////////////////////////////////////
  2902. //
  2903. //
  2904. // Pictorially the structure of an SID is as follows:
  2905. //
  2906. // 1 1 1 1 1 1
  2907. // 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  2908. // +---------------------------------------------------------------+
  2909. // | SubAuthorityCount |Reserved1 (SBZ)| Revision |
  2910. // +---------------------------------------------------------------+
  2911. // | IdentifierAuthority[0] |
  2912. // +---------------------------------------------------------------+
  2913. // | IdentifierAuthority[1] |
  2914. // +---------------------------------------------------------------+
  2915. // | IdentifierAuthority[2] |
  2916. // +---------------------------------------------------------------+
  2917. // | |
  2918. // +- - - - - - - - SubAuthority[] - - - - - - - - -+
  2919. // | |
  2920. // +---------------------------------------------------------------+
  2921. //
  2922. //
  2923. // begin_ntifs
  2924. #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
  2925. #define SID_IDENTIFIER_AUTHORITY_DEFINED
  2926. typedef struct _SID_IDENTIFIER_AUTHORITY {
  2927. BYTE Value[6];
  2928. } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
  2929. #endif
  2930. #ifndef SID_DEFINED
  2931. #define SID_DEFINED
  2932. typedef struct _SID {
  2933. BYTE Revision;
  2934. BYTE SubAuthorityCount;
  2935. SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
  2936. #ifdef MIDL_PASS
  2937. [size_is(SubAuthorityCount)] DWORD SubAuthority[*];
  2938. #else // MIDL_PASS
  2939. DWORD SubAuthority[ANYSIZE_ARRAY];
  2940. #endif // MIDL_PASS
  2941. } SID, *PISID;
  2942. #endif
  2943. #define SID_REVISION (1) // Current revision level
  2944. #define SID_MAX_SUB_AUTHORITIES (15)
  2945. #define SID_RECOMMENDED_SUB_AUTHORITIES (1) // Will change to around 6
  2946. // in a future release.
  2947. #ifndef MIDL_PASS
  2948. #define SECURITY_MAX_SID_SIZE \
  2949. (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
  2950. #endif // MIDL_PASS
  2951. typedef enum _SID_NAME_USE {
  2952. SidTypeUser = 1,
  2953. SidTypeGroup,
  2954. SidTypeDomain,
  2955. SidTypeAlias,
  2956. SidTypeWellKnownGroup,
  2957. SidTypeDeletedAccount,
  2958. SidTypeInvalid,
  2959. SidTypeUnknown,
  2960. SidTypeComputer
  2961. } SID_NAME_USE, *PSID_NAME_USE;
  2962. typedef struct _SID_AND_ATTRIBUTES {
  2963. PSID Sid;
  2964. DWORD Attributes;
  2965. } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
  2966. typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
  2967. typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
  2968. /////////////////////////////////////////////////////////////////////////////
  2969. // //
  2970. // Universal well-known SIDs //
  2971. // //
  2972. // Null SID S-1-0-0 //
  2973. // World S-1-1-0 //
  2974. // Local S-1-2-0 //
  2975. // Creator Owner ID S-1-3-0 //
  2976. // Creator Group ID S-1-3-1 //
  2977. // Creator Owner Server ID S-1-3-2 //
  2978. // Creator Group Server ID S-1-3-3 //
  2979. // //
  2980. // (Non-unique IDs) S-1-4 //
  2981. // //
  2982. /////////////////////////////////////////////////////////////////////////////
  2983. #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
  2984. #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
  2985. #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
  2986. #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
  2987. #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
  2988. #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
  2989. #define SECURITY_NULL_RID (0x00000000L)
  2990. #define SECURITY_WORLD_RID (0x00000000L)
  2991. #define SECURITY_LOCAL_RID (0x00000000L)
  2992. #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
  2993. #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
  2994. #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
  2995. #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
  2996. /////////////////////////////////////////////////////////////////////////////
  2997. // //
  2998. // NT well-known SIDs //
  2999. // //
  3000. // NT Authority S-1-5 //
  3001. // Dialup S-1-5-1 //
  3002. // //
  3003. // Network S-1-5-2 //
  3004. // Batch S-1-5-3 //
  3005. // Interactive S-1-5-4 //
  3006. // Service S-1-5-6 //
  3007. // AnonymousLogon S-1-5-7 (aka null logon session) //
  3008. // Proxy S-1-5-8 //
  3009. // ServerLogon S-1-5-9 (aka domain controller account) //
  3010. // Self S-1-5-10 (self RID) //
  3011. // Authenticated User S-1-5-11 (Authenticated user somewhere) //
  3012. // Restricted Code S-1-5-12 (Running restricted code) //
  3013. // Terminal Server S-1-5-13 (Running on Terminal Server) //
  3014. // Remote Logon S-1-5-14 (Remote Interactive Logon) //
  3015. // //
  3016. // (Logon IDs) S-1-5-5-X-Y //
  3017. // //
  3018. // (NT non-unique IDs) S-1-5-0x15-... //
  3019. // //
  3020. // (Built-in domain) s-1-5-0x20 //
  3021. // //
  3022. /////////////////////////////////////////////////////////////////////////////
  3023. #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5} // ntifs
  3024. #define SECURITY_DIALUP_RID (0x00000001L)
  3025. #define SECURITY_NETWORK_RID (0x00000002L)
  3026. #define SECURITY_BATCH_RID (0x00000003L)
  3027. #define SECURITY_INTERACTIVE_RID (0x00000004L)
  3028. #define SECURITY_SERVICE_RID (0x00000006L)
  3029. #define SECURITY_ANONYMOUS_LOGON_RID (0x00000007L)
  3030. #define SECURITY_PROXY_RID (0x00000008L)
  3031. #define SECURITY_ENTERPRISE_CONTROLLERS_RID (0x00000009L)
  3032. #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
  3033. #define SECURITY_PRINCIPAL_SELF_RID (0x0000000AL)
  3034. #define SECURITY_AUTHENTICATED_USER_RID (0x0000000BL)
  3035. #define SECURITY_RESTRICTED_CODE_RID (0x0000000CL)
  3036. #define SECURITY_TERMINAL_SERVER_RID (0x0000000DL)
  3037. #define SECURITY_REMOTE_LOGON_RID (0x0000000EL)
  3038. #define SECURITY_LOGON_IDS_RID (0x00000005L)
  3039. #define SECURITY_LOGON_IDS_RID_COUNT (3L)
  3040. #define SECURITY_LOCAL_SYSTEM_RID (0x00000012L)
  3041. #define SECURITY_LOCAL_SERVICE_RID (0x00000013L)
  3042. #define SECURITY_NETWORK_SERVICE_RID (0x00000014L)
  3043. #define SECURITY_NT_NON_UNIQUE (0x00000015L)
  3044. #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT (3L)
  3045. #define SECURITY_BUILTIN_DOMAIN_RID (0x00000020L)
  3046. /////////////////////////////////////////////////////////////////////////////
  3047. // //
  3048. // well-known domain relative sub-authority values (RIDs)... //
  3049. // //
  3050. /////////////////////////////////////////////////////////////////////////////
  3051. // Well-known users ...
  3052. #define DOMAIN_USER_RID_ADMIN (0x000001F4L)
  3053. #define DOMAIN_USER_RID_GUEST (0x000001F5L)
  3054. #define DOMAIN_USER_RID_KRBTGT (0x000001F6L)
  3055. // well-known groups ...
  3056. #define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
  3057. #define DOMAIN_GROUP_RID_USERS (0x00000201L)
  3058. #define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
  3059. #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L)
  3060. #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L)
  3061. #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L)
  3062. #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L)
  3063. #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (0x00000207L)
  3064. #define DOMAIN_GROUP_RID_POLICY_ADMINS (0x00000208L)
  3065. // well-known aliases ...
  3066. #define DOMAIN_ALIAS_RID_ADMINS (0x00000220L)
  3067. #define DOMAIN_ALIAS_RID_USERS (0x00000221L)
  3068. #define DOMAIN_ALIAS_RID_GUESTS (0x00000222L)
  3069. #define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L)
  3070. #define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
  3071. #define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
  3072. #define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L)
  3073. #define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
  3074. #define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L)
  3075. #define DOMAIN_ALIAS_RID_RAS_SERVERS (0x00000229L)
  3076. #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS (0x0000022AL)
  3077. #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS (0x0000022BL)
  3078. #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS (0x0000022CL)
  3079. //
  3080. // Allocate the System Luid. The first 1000 LUIDs are reserved.
  3081. // Use #999 here (0x3E7 = 999)
  3082. //
  3083. #define SYSTEM_LUID { 0x3E7, 0x0 }
  3084. #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
  3085. #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
  3086. #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
  3087. // end_ntifs
  3088. ////////////////////////////////////////////////////////////////////////
  3089. // //
  3090. // User and Group related SID attributes //
  3091. // //
  3092. ////////////////////////////////////////////////////////////////////////
  3093. //
  3094. // Group attributes
  3095. //
  3096. #define SE_GROUP_MANDATORY (0x00000001L)
  3097. #define SE_GROUP_ENABLED_BY_DEFAULT (0x00000002L)
  3098. #define SE_GROUP_ENABLED (0x00000004L)
  3099. #define SE_GROUP_OWNER (0x00000008L)
  3100. #define SE_GROUP_USE_FOR_DENY_ONLY (0x00000010L)
  3101. #define SE_GROUP_LOGON_ID (0xC0000000L)
  3102. #define SE_GROUP_RESOURCE (0x20000000L)
  3103. //
  3104. // User attributes
  3105. //
  3106. // (None yet defined.)
  3107. ////////////////////////////////////////////////////////////////////////
  3108. // //
  3109. // ACL and ACE //
  3110. // //
  3111. ////////////////////////////////////////////////////////////////////////
  3112. //
  3113. // Define an ACL and the ACE format. The structure of an ACL header
  3114. // followed by one or more ACEs. Pictorally the structure of an ACL header
  3115. // is as follows:
  3116. //
  3117. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  3118. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  3119. // +-------------------------------+---------------+---------------+
  3120. // | AclSize | Sbz1 | AclRevision |
  3121. // +-------------------------------+---------------+---------------+
  3122. // | Sbz2 | AceCount |
  3123. // +-------------------------------+-------------------------------+
  3124. //
  3125. // The current AclRevision is defined to be ACL_REVISION.
  3126. //
  3127. // AclSize is the size, in bytes, allocated for the ACL. This includes
  3128. // the ACL header, ACES, and remaining free space in the buffer.
  3129. //
  3130. // AceCount is the number of ACES in the ACL.
  3131. //
  3132. // begin_ntddk begin_wdm begin_ntifs
  3133. // This is the *current* ACL revision
  3134. #define ACL_REVISION (2)
  3135. #define ACL_REVISION_DS (4)
  3136. // This is the history of ACL revisions. Add a new one whenever
  3137. // ACL_REVISION is updated
  3138. #define ACL_REVISION1 (1)
  3139. #define MIN_ACL_REVISION ACL_REVISION2
  3140. #define ACL_REVISION2 (2)
  3141. #define ACL_REVISION3 (3)
  3142. #define ACL_REVISION4 (4)
  3143. #define MAX_ACL_REVISION ACL_REVISION4
  3144. typedef struct _ACL {
  3145. BYTE AclRevision;
  3146. BYTE Sbz1;
  3147. WORD AclSize;
  3148. WORD AceCount;
  3149. WORD Sbz2;
  3150. } ACL;
  3151. typedef ACL *PACL;
  3152. // end_ntddk end_wdm
  3153. //
  3154. // The structure of an ACE is a common ace header followed by ace type
  3155. // specific data. Pictorally the structure of the common ace header is
  3156. // as follows:
  3157. //
  3158. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  3159. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  3160. // +---------------+-------+-------+---------------+---------------+
  3161. // | AceSize | AceFlags | AceType |
  3162. // +---------------+-------+-------+---------------+---------------+
  3163. //
  3164. // AceType denotes the type of the ace, there are some predefined ace
  3165. // types
  3166. //
  3167. // AceSize is the size, in bytes, of ace.
  3168. //
  3169. // AceFlags are the Ace flags for audit and inheritance, defined shortly.
  3170. typedef struct _ACE_HEADER {
  3171. BYTE AceType;
  3172. BYTE AceFlags;
  3173. WORD AceSize;
  3174. } ACE_HEADER;
  3175. typedef ACE_HEADER *PACE_HEADER;
  3176. //
  3177. // The following are the predefined ace types that go into the AceType
  3178. // field of an Ace header.
  3179. //
  3180. #define ACCESS_MIN_MS_ACE_TYPE (0x0)
  3181. #define ACCESS_ALLOWED_ACE_TYPE (0x0)
  3182. #define ACCESS_DENIED_ACE_TYPE (0x1)
  3183. #define SYSTEM_AUDIT_ACE_TYPE (0x2)
  3184. #define SYSTEM_ALARM_ACE_TYPE (0x3)
  3185. #define ACCESS_MAX_MS_V2_ACE_TYPE (0x3)
  3186. #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE (0x4)
  3187. #define ACCESS_MAX_MS_V3_ACE_TYPE (0x4)
  3188. #define ACCESS_MIN_MS_OBJECT_ACE_TYPE (0x5)
  3189. #define ACCESS_ALLOWED_OBJECT_ACE_TYPE (0x5)
  3190. #define ACCESS_DENIED_OBJECT_ACE_TYPE (0x6)
  3191. #define SYSTEM_AUDIT_OBJECT_ACE_TYPE (0x7)
  3192. #define SYSTEM_ALARM_OBJECT_ACE_TYPE (0x8)
  3193. #define ACCESS_MAX_MS_OBJECT_ACE_TYPE (0x8)
  3194. #define ACCESS_MAX_MS_V4_ACE_TYPE (0x8)
  3195. #define ACCESS_MAX_MS_ACE_TYPE (0x8)
  3196. #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE (0x9)
  3197. #define ACCESS_DENIED_CALLBACK_ACE_TYPE (0xA)
  3198. #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE (0xB)
  3199. #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE (0xC)
  3200. #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE (0xD)
  3201. #define SYSTEM_ALARM_CALLBACK_ACE_TYPE (0xE)
  3202. #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE (0xF)
  3203. #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE (0x10)
  3204. #define ACCESS_MAX_MS_V5_ACE_TYPE (0x10)
  3205. //
  3206. // The following are the inherit flags that go into the AceFlags field
  3207. // of an Ace header.
  3208. //
  3209. #define OBJECT_INHERIT_ACE (0x1)
  3210. #define CONTAINER_INHERIT_ACE (0x2)
  3211. #define NO_PROPAGATE_INHERIT_ACE (0x4)
  3212. #define INHERIT_ONLY_ACE (0x8)
  3213. #define INHERITED_ACE (0x10)
  3214. #define VALID_INHERIT_FLAGS (0x1F)
  3215. // The following are the currently defined ACE flags that go into the
  3216. // AceFlags field of an ACE header. Each ACE type has its own set of
  3217. // AceFlags.
  3218. //
  3219. // SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE
  3220. // types to indicate that a message is generated for successful accesses.
  3221. //
  3222. // FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types
  3223. // to indicate that a message is generated for failed accesses.
  3224. //
  3225. //
  3226. // SYSTEM_AUDIT and SYSTEM_ALARM AceFlags
  3227. //
  3228. // These control the signaling of audit and alarms for success or failure.
  3229. //
  3230. #define SUCCESSFUL_ACCESS_ACE_FLAG (0x40)
  3231. #define FAILED_ACCESS_ACE_FLAG (0x80)
  3232. //
  3233. // We'll define the structure of the predefined ACE types. Pictorally
  3234. // the structure of the predefined ACE's is as follows:
  3235. //
  3236. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  3237. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  3238. // +---------------+-------+-------+---------------+---------------+
  3239. // | AceFlags | Resd |Inherit| AceSize | AceType |
  3240. // +---------------+-------+-------+---------------+---------------+
  3241. // | Mask |
  3242. // +---------------------------------------------------------------+
  3243. // | |
  3244. // + +
  3245. // | |
  3246. // + Sid +
  3247. // | |
  3248. // + +
  3249. // | |
  3250. // +---------------------------------------------------------------+
  3251. //
  3252. // Mask is the access mask associated with the ACE. This is either the
  3253. // access allowed, access denied, audit, or alarm mask.
  3254. //
  3255. // Sid is the Sid associated with the ACE.
  3256. //
  3257. // The following are the four predefined ACE types.
  3258. // Examine the AceType field in the Header to determine
  3259. // which structure is appropriate to use for casting.
  3260. typedef struct _ACCESS_ALLOWED_ACE {
  3261. ACE_HEADER Header;
  3262. ACCESS_MASK Mask;
  3263. DWORD SidStart;
  3264. } ACCESS_ALLOWED_ACE;
  3265. typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
  3266. typedef struct _ACCESS_DENIED_ACE {
  3267. ACE_HEADER Header;
  3268. ACCESS_MASK Mask;
  3269. DWORD SidStart;
  3270. } ACCESS_DENIED_ACE;
  3271. typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
  3272. typedef struct _SYSTEM_AUDIT_ACE {
  3273. ACE_HEADER Header;
  3274. ACCESS_MASK Mask;
  3275. DWORD SidStart;
  3276. } SYSTEM_AUDIT_ACE;
  3277. typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
  3278. typedef struct _SYSTEM_ALARM_ACE {
  3279. ACE_HEADER Header;
  3280. ACCESS_MASK Mask;
  3281. DWORD SidStart;
  3282. } SYSTEM_ALARM_ACE;
  3283. typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
  3284. // end_ntifs
  3285. typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
  3286. ACE_HEADER Header;
  3287. ACCESS_MASK Mask;
  3288. DWORD Flags;
  3289. GUID ObjectType;
  3290. GUID InheritedObjectType;
  3291. DWORD SidStart;
  3292. } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
  3293. typedef struct _ACCESS_DENIED_OBJECT_ACE {
  3294. ACE_HEADER Header;
  3295. ACCESS_MASK Mask;
  3296. DWORD Flags;
  3297. GUID ObjectType;
  3298. GUID InheritedObjectType;
  3299. DWORD SidStart;
  3300. } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
  3301. typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
  3302. ACE_HEADER Header;
  3303. ACCESS_MASK Mask;
  3304. DWORD Flags;
  3305. GUID ObjectType;
  3306. GUID InheritedObjectType;
  3307. DWORD SidStart;
  3308. } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
  3309. typedef struct _SYSTEM_ALARM_OBJECT_ACE {
  3310. ACE_HEADER Header;
  3311. ACCESS_MASK Mask;
  3312. DWORD Flags;
  3313. GUID ObjectType;
  3314. GUID InheritedObjectType;
  3315. DWORD SidStart;
  3316. } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_ACE;
  3317. //
  3318. // Callback ace support in post Win2000.
  3319. // Resource managers can put their own data after Sidstart + Length of the sid
  3320. //
  3321. typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
  3322. ACE_HEADER Header;
  3323. ACCESS_MASK Mask;
  3324. DWORD SidStart;
  3325. // Opaque resouce manager specific data
  3326. } ACCESS_ALLOWED_CALLBACK_ACE, *PACCESS_ALLOWED_CALLBACK_ACE;
  3327. typedef struct _ACCESS_DENIED_CALLBACK_ACE {
  3328. ACE_HEADER Header;
  3329. ACCESS_MASK Mask;
  3330. DWORD SidStart;
  3331. // Opaque resouce manager specific data
  3332. } ACCESS_DENIED_CALLBACK_ACE, *PACCESS_DENIED_CALLBACK_ACE;
  3333. typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
  3334. ACE_HEADER Header;
  3335. ACCESS_MASK Mask;
  3336. DWORD SidStart;
  3337. // Opaque resouce manager specific data
  3338. } SYSTEM_AUDIT_CALLBACK_ACE, *PSYSTEM_AUDIT_CALLBACK_ACE;
  3339. typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
  3340. ACE_HEADER Header;
  3341. ACCESS_MASK Mask;
  3342. DWORD SidStart;
  3343. // Opaque resouce manager specific data
  3344. } SYSTEM_ALARM_CALLBACK_ACE, *PSYSTEM_ALARM_CALLBACK_ACE;
  3345. typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
  3346. ACE_HEADER Header;
  3347. ACCESS_MASK Mask;
  3348. DWORD Flags;
  3349. GUID ObjectType;
  3350. GUID InheritedObjectType;
  3351. DWORD SidStart;
  3352. // Opaque resouce manager specific data
  3353. } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  3354. typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
  3355. ACE_HEADER Header;
  3356. ACCESS_MASK Mask;
  3357. DWORD Flags;
  3358. GUID ObjectType;
  3359. GUID InheritedObjectType;
  3360. DWORD SidStart;
  3361. // Opaque resouce manager specific data
  3362. } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
  3363. typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
  3364. ACE_HEADER Header;
  3365. ACCESS_MASK Mask;
  3366. DWORD Flags;
  3367. GUID ObjectType;
  3368. GUID InheritedObjectType;
  3369. DWORD SidStart;
  3370. // Opaque resouce manager specific data
  3371. } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  3372. typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
  3373. ACE_HEADER Header;
  3374. ACCESS_MASK Mask;
  3375. DWORD Flags;
  3376. GUID ObjectType;
  3377. GUID InheritedObjectType;
  3378. DWORD SidStart;
  3379. // Opaque resouce manager specific data
  3380. } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  3381. //
  3382. // Currently define Flags for "OBJECT" ACE types.
  3383. //
  3384. #define ACE_OBJECT_TYPE_PRESENT 0x1
  3385. #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
  3386. //
  3387. // The following declarations are used for setting and querying information
  3388. // about and ACL. First are the various information classes available to
  3389. // the user.
  3390. //
  3391. typedef enum _ACL_INFORMATION_CLASS {
  3392. AclRevisionInformation = 1,
  3393. AclSizeInformation
  3394. } ACL_INFORMATION_CLASS;
  3395. //
  3396. // This record is returned/sent if the user is requesting/setting the
  3397. // AclRevisionInformation
  3398. //
  3399. typedef struct _ACL_REVISION_INFORMATION {
  3400. DWORD AclRevision;
  3401. } ACL_REVISION_INFORMATION;
  3402. typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
  3403. //
  3404. // This record is returned if the user is requesting AclSizeInformation
  3405. //
  3406. typedef struct _ACL_SIZE_INFORMATION {
  3407. DWORD AceCount;
  3408. DWORD AclBytesInUse;
  3409. DWORD AclBytesFree;
  3410. } ACL_SIZE_INFORMATION;
  3411. typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
  3412. ////////////////////////////////////////////////////////////////////////
  3413. // //
  3414. // SECURITY_DESCRIPTOR //
  3415. // //
  3416. ////////////////////////////////////////////////////////////////////////
  3417. //
  3418. // Define the Security Descriptor and related data types.
  3419. // This is an opaque data structure.
  3420. //
  3421. // begin_wdm begin_ntddk begin_ntifs
  3422. //
  3423. // Current security descriptor revision value
  3424. //
  3425. #define SECURITY_DESCRIPTOR_REVISION (1)
  3426. #define SECURITY_DESCRIPTOR_REVISION1 (1)
  3427. // end_wdm end_ntddk
  3428. #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
  3429. typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
  3430. #define SE_OWNER_DEFAULTED (0x0001)
  3431. #define SE_GROUP_DEFAULTED (0x0002)
  3432. #define SE_DACL_PRESENT (0x0004)
  3433. #define SE_DACL_DEFAULTED (0x0008)
  3434. #define SE_SACL_PRESENT (0x0010)
  3435. #define SE_SACL_DEFAULTED (0x0020)
  3436. #define SE_DACL_AUTO_INHERIT_REQ (0x0100)
  3437. #define SE_SACL_AUTO_INHERIT_REQ (0x0200)
  3438. #define SE_DACL_AUTO_INHERITED (0x0400)
  3439. #define SE_SACL_AUTO_INHERITED (0x0800)
  3440. #define SE_DACL_PROTECTED (0x1000)
  3441. #define SE_SACL_PROTECTED (0x2000)
  3442. #define SE_RM_CONTROL_VALID (0x4000)
  3443. #define SE_SELF_RELATIVE (0x8000)
  3444. //
  3445. // Where:
  3446. //
  3447. // SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
  3448. // SID pointed to by the Owner field was provided by a
  3449. // defaulting mechanism rather than explicitly provided by the
  3450. // original provider of the security descriptor. This may
  3451. // affect the treatment of the SID with respect to inheritence
  3452. // of an owner.
  3453. //
  3454. // SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
  3455. // SID in the Group field was provided by a defaulting mechanism
  3456. // rather than explicitly provided by the original provider of
  3457. // the security descriptor. This may affect the treatment of
  3458. // the SID with respect to inheritence of a primary group.
  3459. //
  3460. // SE_DACL_PRESENT - This boolean flag, when set, indicates that the
  3461. // security descriptor contains a discretionary ACL. If this
  3462. // flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
  3463. // null, then a null ACL is explicitly being specified.
  3464. //
  3465. // SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
  3466. // ACL pointed to by the Dacl field was provided by a defaulting
  3467. // mechanism rather than explicitly provided by the original
  3468. // provider of the security descriptor. This may affect the
  3469. // treatment of the ACL with respect to inheritence of an ACL.
  3470. // This flag is ignored if the DaclPresent flag is not set.
  3471. //
  3472. // SE_SACL_PRESENT - This boolean flag, when set, indicates that the
  3473. // security descriptor contains a system ACL pointed to by the
  3474. // Sacl field. If this flag is set and the Sacl field of the
  3475. // SECURITY_DESCRIPTOR is null, then an empty (but present)
  3476. // ACL is being specified.
  3477. //
  3478. // SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
  3479. // ACL pointed to by the Sacl field was provided by a defaulting
  3480. // mechanism rather than explicitly provided by the original
  3481. // provider of the security descriptor. This may affect the
  3482. // treatment of the ACL with respect to inheritence of an ACL.
  3483. // This flag is ignored if the SaclPresent flag is not set.
  3484. //
  3485. // SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
  3486. // security descriptor is in self-relative form. In this form,
  3487. // all fields of the security descriptor are contiguous in memory
  3488. // and all pointer fields are expressed as offsets from the
  3489. // beginning of the security descriptor. This form is useful
  3490. // for treating security descriptors as opaque data structures
  3491. // for transmission in communication protocol or for storage on
  3492. // secondary media.
  3493. //
  3494. //
  3495. //
  3496. // Pictorially the structure of a security descriptor is as follows:
  3497. //
  3498. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  3499. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  3500. // +---------------------------------------------------------------+
  3501. // | Control |Reserved1 (SBZ)| Revision |
  3502. // +---------------------------------------------------------------+
  3503. // | Owner |
  3504. // +---------------------------------------------------------------+
  3505. // | Group |
  3506. // +---------------------------------------------------------------+
  3507. // | Sacl |
  3508. // +---------------------------------------------------------------+
  3509. // | Dacl |
  3510. // +---------------------------------------------------------------+
  3511. //
  3512. // In general, this data structure should be treated opaquely to ensure future
  3513. // compatibility.
  3514. //
  3515. //
  3516. typedef struct _SECURITY_DESCRIPTOR_RELATIVE {
  3517. BYTE Revision;
  3518. BYTE Sbz1;
  3519. SECURITY_DESCRIPTOR_CONTROL Control;
  3520. DWORD Owner;
  3521. DWORD Group;
  3522. DWORD Sacl;
  3523. DWORD Dacl;
  3524. } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
  3525. typedef struct _SECURITY_DESCRIPTOR {
  3526. BYTE Revision;
  3527. BYTE Sbz1;
  3528. SECURITY_DESCRIPTOR_CONTROL Control;
  3529. PSID Owner;
  3530. PSID Group;
  3531. PACL Sacl;
  3532. PACL Dacl;
  3533. } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
  3534. // end_ntifs
  3535. // Where:
  3536. //
  3537. // Revision - Contains the revision level of the security
  3538. // descriptor. This allows this structure to be passed between
  3539. // systems or stored on disk even though it is expected to
  3540. // change in the future.
  3541. //
  3542. // Control - A set of flags which qualify the meaning of the
  3543. // security descriptor or individual fields of the security
  3544. // descriptor.
  3545. //
  3546. // Owner - is a pointer to an SID representing an object's owner.
  3547. // If this field is null, then no owner SID is present in the
  3548. // security descriptor. If the security descriptor is in
  3549. // self-relative form, then this field contains an offset to
  3550. // the SID, rather than a pointer.
  3551. //
  3552. // Group - is a pointer to an SID representing an object's primary
  3553. // group. If this field is null, then no primary group SID is
  3554. // present in the security descriptor. If the security descriptor
  3555. // is in self-relative form, then this field contains an offset to
  3556. // the SID, rather than a pointer.
  3557. //
  3558. // Sacl - is a pointer to a system ACL. This field value is only
  3559. // valid if the DaclPresent control flag is set. If the
  3560. // SaclPresent flag is set and this field is null, then a null
  3561. // ACL is specified. If the security descriptor is in
  3562. // self-relative form, then this field contains an offset to
  3563. // the ACL, rather than a pointer.
  3564. //
  3565. // Dacl - is a pointer to a discretionary ACL. This field value is
  3566. // only valid if the DaclPresent control flag is set. If the
  3567. // DaclPresent flag is set and this field is null, then a null
  3568. // ACL (unconditionally granting access) is specified. If the
  3569. // security descriptor is in self-relative form, then this field
  3570. // contains an offset to the ACL, rather than a pointer.
  3571. //
  3572. ////////////////////////////////////////////////////////////////////////
  3573. // //
  3574. // Object Type list for AccessCheckByType //
  3575. // //
  3576. ////////////////////////////////////////////////////////////////////////
  3577. typedef struct _OBJECT_TYPE_LIST {
  3578. WORD Level;
  3579. WORD Sbz;
  3580. GUID *ObjectType;
  3581. } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
  3582. //
  3583. // DS values for Level
  3584. //
  3585. #define ACCESS_OBJECT_GUID 0
  3586. #define ACCESS_PROPERTY_SET_GUID 1
  3587. #define ACCESS_PROPERTY_GUID 2
  3588. #define ACCESS_MAX_LEVEL 4
  3589. //
  3590. // Parameters to NtAccessCheckByTypeAndAditAlarm
  3591. //
  3592. typedef enum _AUDIT_EVENT_TYPE {
  3593. AuditEventObjectAccess,
  3594. AuditEventDirectoryServiceAccess
  3595. } AUDIT_EVENT_TYPE, *PAUDIT_EVENT_TYPE;
  3596. #define AUDIT_ALLOW_NO_PRIVILEGE 0x1
  3597. //
  3598. // DS values for Source and ObjectTypeName
  3599. //
  3600. #define ACCESS_DS_SOURCE_A "DS"
  3601. #define ACCESS_DS_SOURCE_W L"DS"
  3602. #define ACCESS_DS_OBJECT_TYPE_NAME_A "Directory Service Object"
  3603. #define ACCESS_DS_OBJECT_TYPE_NAME_W L"Directory Service Object"
  3604. ////////////////////////////////////////////////////////////////////////
  3605. // //
  3606. // Privilege Related Data Structures //
  3607. // //
  3608. ////////////////////////////////////////////////////////////////////////
  3609. // begin_wdm begin_ntddk begin_nthal
  3610. //
  3611. // Privilege attributes
  3612. //
  3613. #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
  3614. #define SE_PRIVILEGE_ENABLED (0x00000002L)
  3615. #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
  3616. //
  3617. // Privilege Set Control flags
  3618. //
  3619. #define PRIVILEGE_SET_ALL_NECESSARY (1)
  3620. //
  3621. // Privilege Set - This is defined for a privilege set of one.
  3622. // If more than one privilege is needed, then this structure
  3623. // will need to be allocated with more space.
  3624. //
  3625. // Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
  3626. // structure (defined in se.h)
  3627. //
  3628. typedef struct _PRIVILEGE_SET {
  3629. DWORD PrivilegeCount;
  3630. DWORD Control;
  3631. LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
  3632. } PRIVILEGE_SET, * PPRIVILEGE_SET;
  3633. ////////////////////////////////////////////////////////////////////////
  3634. // //
  3635. // NT Defined Privileges //
  3636. // //
  3637. ////////////////////////////////////////////////////////////////////////
  3638. #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
  3639. #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
  3640. #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
  3641. #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
  3642. #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
  3643. #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
  3644. #define SE_TCB_NAME TEXT("SeTcbPrivilege")
  3645. #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
  3646. #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
  3647. #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
  3648. #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
  3649. #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
  3650. #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
  3651. #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
  3652. #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
  3653. #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
  3654. #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
  3655. #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
  3656. #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
  3657. #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
  3658. #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
  3659. #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
  3660. #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
  3661. #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
  3662. #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
  3663. #define SE_SYNC_AGENT_NAME TEXT("SeSyncAgentPrivilege")
  3664. #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
  3665. #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
  3666. ////////////////////////////////////////////////////////////////////
  3667. // //
  3668. // Security Quality Of Service //
  3669. // //
  3670. // //
  3671. ////////////////////////////////////////////////////////////////////
  3672. // begin_wdm begin_ntddk begin_nthal begin_ntifs
  3673. //
  3674. // Impersonation Level
  3675. //
  3676. // Impersonation level is represented by a pair of bits in Windows.
  3677. // If a new impersonation level is added or lowest value is changed from
  3678. // 0 to something else, fix the Windows CreateFile call.
  3679. //
  3680. typedef enum _SECURITY_IMPERSONATION_LEVEL {
  3681. SecurityAnonymous,
  3682. SecurityIdentification,
  3683. SecurityImpersonation,
  3684. SecurityDelegation
  3685. } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
  3686. #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
  3687. #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
  3688. #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
  3689. #define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
  3690. ////////////////////////////////////////////////////////////////////
  3691. // //
  3692. // Token Object Definitions //
  3693. // //
  3694. // //
  3695. ////////////////////////////////////////////////////////////////////
  3696. //
  3697. // Token Specific Access Rights.
  3698. //
  3699. #define TOKEN_ASSIGN_PRIMARY (0x0001)
  3700. #define TOKEN_DUPLICATE (0x0002)
  3701. #define TOKEN_IMPERSONATE (0x0004)
  3702. #define TOKEN_QUERY (0x0008)
  3703. #define TOKEN_QUERY_SOURCE (0x0010)
  3704. #define TOKEN_ADJUST_PRIVILEGES (0x0020)
  3705. #define TOKEN_ADJUST_GROUPS (0x0040)
  3706. #define TOKEN_ADJUST_DEFAULT (0x0080)
  3707. #define TOKEN_ADJUST_SESSIONID (0x0100)
  3708. #define TOKEN_ALL_ACCESS_P (STANDARD_RIGHTS_REQUIRED |\
  3709. TOKEN_ASSIGN_PRIMARY |\
  3710. TOKEN_DUPLICATE |\
  3711. TOKEN_IMPERSONATE |\
  3712. TOKEN_QUERY |\
  3713. TOKEN_QUERY_SOURCE |\
  3714. TOKEN_ADJUST_PRIVILEGES |\
  3715. TOKEN_ADJUST_GROUPS |\
  3716. TOKEN_ADJUST_DEFAULT )
  3717. #if ((defined(_WIN32_WINNT) && (_WIN32_WINNT > 0x0400)) || (!defined(_WIN32_WINNT)))
  3718. #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P |\
  3719. TOKEN_ADJUST_SESSIONID )
  3720. #else
  3721. #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P)
  3722. #endif
  3723. #define TOKEN_READ (STANDARD_RIGHTS_READ |\
  3724. TOKEN_QUERY)
  3725. #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE |\
  3726. TOKEN_ADJUST_PRIVILEGES |\
  3727. TOKEN_ADJUST_GROUPS |\
  3728. TOKEN_ADJUST_DEFAULT)
  3729. #define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
  3730. //
  3731. //
  3732. // Token Types
  3733. //
  3734. typedef enum _TOKEN_TYPE {
  3735. TokenPrimary = 1,
  3736. TokenImpersonation
  3737. } TOKEN_TYPE;
  3738. typedef TOKEN_TYPE *PTOKEN_TYPE;
  3739. //
  3740. // Token Information Classes.
  3741. //
  3742. typedef enum _TOKEN_INFORMATION_CLASS {
  3743. TokenUser = 1,
  3744. TokenGroups,
  3745. TokenPrivileges,
  3746. TokenOwner,
  3747. TokenPrimaryGroup,
  3748. TokenDefaultDacl,
  3749. TokenSource,
  3750. TokenType,
  3751. TokenImpersonationLevel,
  3752. TokenStatistics,
  3753. TokenRestrictedSids,
  3754. TokenSessionId,
  3755. TokenGroupsAndPrivileges,
  3756. TokenSessionReference,
  3757. TokenSandBoxInert
  3758. } TOKEN_INFORMATION_CLASS, *PTOKEN_INFORMATION_CLASS;
  3759. //
  3760. // Token information class structures
  3761. //
  3762. typedef struct _TOKEN_USER {
  3763. SID_AND_ATTRIBUTES User;
  3764. } TOKEN_USER, *PTOKEN_USER;
  3765. typedef struct _TOKEN_GROUPS {
  3766. DWORD GroupCount;
  3767. SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
  3768. } TOKEN_GROUPS, *PTOKEN_GROUPS;
  3769. typedef struct _TOKEN_PRIVILEGES {
  3770. DWORD PrivilegeCount;
  3771. LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
  3772. } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
  3773. typedef struct _TOKEN_OWNER {
  3774. PSID Owner;
  3775. } TOKEN_OWNER, *PTOKEN_OWNER;
  3776. typedef struct _TOKEN_PRIMARY_GROUP {
  3777. PSID PrimaryGroup;
  3778. } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
  3779. typedef struct _TOKEN_DEFAULT_DACL {
  3780. PACL DefaultDacl;
  3781. } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
  3782. typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
  3783. DWORD SidCount;
  3784. DWORD SidLength;
  3785. PSID_AND_ATTRIBUTES Sids;
  3786. DWORD RestrictedSidCount;
  3787. DWORD RestrictedSidLength;
  3788. PSID_AND_ATTRIBUTES RestrictedSids;
  3789. DWORD PrivilegeCount;
  3790. DWORD PrivilegeLength;
  3791. PLUID_AND_ATTRIBUTES Privileges;
  3792. LUID AuthenticationId;
  3793. } TOKEN_GROUPS_AND_PRIVILEGES, *PTOKEN_GROUPS_AND_PRIVILEGES;
  3794. #define TOKEN_SOURCE_LENGTH 8
  3795. typedef struct _TOKEN_SOURCE {
  3796. CHAR SourceName[TOKEN_SOURCE_LENGTH];
  3797. LUID SourceIdentifier;
  3798. } TOKEN_SOURCE, *PTOKEN_SOURCE;
  3799. typedef struct _TOKEN_STATISTICS {
  3800. LUID TokenId;
  3801. LUID AuthenticationId;
  3802. LARGE_INTEGER ExpirationTime;
  3803. TOKEN_TYPE TokenType;
  3804. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  3805. DWORD DynamicCharged;
  3806. DWORD DynamicAvailable;
  3807. DWORD GroupCount;
  3808. DWORD PrivilegeCount;
  3809. LUID ModifiedId;
  3810. } TOKEN_STATISTICS, *PTOKEN_STATISTICS;
  3811. typedef struct _TOKEN_CONTROL {
  3812. LUID TokenId;
  3813. LUID AuthenticationId;
  3814. LUID ModifiedId;
  3815. TOKEN_SOURCE TokenSource;
  3816. } TOKEN_CONTROL, *PTOKEN_CONTROL;
  3817. //
  3818. // Security Tracking Mode
  3819. //
  3820. #define SECURITY_DYNAMIC_TRACKING (TRUE)
  3821. #define SECURITY_STATIC_TRACKING (FALSE)
  3822. typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
  3823. * PSECURITY_CONTEXT_TRACKING_MODE;
  3824. //
  3825. // Quality Of Service
  3826. //
  3827. typedef struct _SECURITY_QUALITY_OF_SERVICE {
  3828. DWORD Length;
  3829. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  3830. SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
  3831. BOOLEAN EffectiveOnly;
  3832. } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE;
  3833. //
  3834. // Used to represent information related to a thread impersonation
  3835. //
  3836. typedef struct _SE_IMPERSONATION_STATE {
  3837. PACCESS_TOKEN Token;
  3838. BOOLEAN CopyOnOpen;
  3839. BOOLEAN EffectiveOnly;
  3840. SECURITY_IMPERSONATION_LEVEL Level;
  3841. } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
  3842. #define DISABLE_MAX_PRIVILEGE 0x1
  3843. #define SANDBOX_INERT 0x2
  3844. typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  3845. #define OWNER_SECURITY_INFORMATION (0x00000001L)
  3846. #define GROUP_SECURITY_INFORMATION (0x00000002L)
  3847. #define DACL_SECURITY_INFORMATION (0x00000004L)
  3848. #define SACL_SECURITY_INFORMATION (0x00000008L)
  3849. #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
  3850. #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
  3851. #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
  3852. #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
  3853. #define PROCESS_TERMINATE (0x0001)
  3854. #define PROCESS_CREATE_THREAD (0x0002)
  3855. #define PROCESS_SET_SESSIONID (0x0004)
  3856. #define PROCESS_VM_OPERATION (0x0008)
  3857. #define PROCESS_VM_READ (0x0010)
  3858. #define PROCESS_VM_WRITE (0x0020)
  3859. #define PROCESS_DUP_HANDLE (0x0040)
  3860. #define PROCESS_CREATE_PROCESS (0x0080)
  3861. #define PROCESS_SET_QUOTA (0x0100)
  3862. #define PROCESS_SET_INFORMATION (0x0200)
  3863. #define PROCESS_QUERY_INFORMATION (0x0400)
  3864. #define PROCESS_SUSPEND_RESUME (0x0800)
  3865. #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  3866. 0xFFF)
  3867. // begin_nthal
  3868. #if defined(_WIN64)
  3869. #define MAXIMUM_PROCESSORS 64
  3870. #else
  3871. #define MAXIMUM_PROCESSORS 32
  3872. #endif
  3873. // end_nthal
  3874. #define THREAD_TERMINATE (0x0001)
  3875. #define THREAD_SUSPEND_RESUME (0x0002)
  3876. #define THREAD_GET_CONTEXT (0x0008)
  3877. #define THREAD_SET_CONTEXT (0x0010)
  3878. #define THREAD_SET_INFORMATION (0x0020)
  3879. #define THREAD_QUERY_INFORMATION (0x0040)
  3880. #define THREAD_SET_THREAD_TOKEN (0x0080)
  3881. #define THREAD_IMPERSONATE (0x0100)
  3882. #define THREAD_DIRECT_IMPERSONATION (0x0200)
  3883. // begin_ntddk begin_wdm begin_ntifs
  3884. #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  3885. 0x3FF)
  3886. // end_ntddk end_wdm end_ntifs
  3887. #define JOB_OBJECT_ASSIGN_PROCESS (0x0001)
  3888. #define JOB_OBJECT_SET_ATTRIBUTES (0x0002)
  3889. #define JOB_OBJECT_QUERY (0x0004)
  3890. #define JOB_OBJECT_TERMINATE (0x0008)
  3891. #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES (0x0010)
  3892. #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  3893. 0x1F )
  3894. typedef struct _JOB_SET_ARRAY {
  3895. HANDLE JobHandle; // Handle to job object to insert
  3896. DWORD MemberLevel; // Level of this job in the set. Must be > 0. Can be sparse.
  3897. DWORD Flags; // Unused. Must be zero
  3898. } JOB_SET_ARRAY, *PJOB_SET_ARRAY;
  3899. #define TLS_MINIMUM_AVAILABLE 64
  3900. typedef struct _NT_TIB {
  3901. struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
  3902. PVOID StackBase;
  3903. PVOID StackLimit;
  3904. PVOID SubSystemTib;
  3905. union {
  3906. PVOID FiberData;
  3907. DWORD Version;
  3908. };
  3909. PVOID ArbitraryUserPointer;
  3910. struct _NT_TIB *Self;
  3911. } NT_TIB;
  3912. typedef NT_TIB *PNT_TIB;
  3913. //
  3914. // 32 and 64 bit specific version for wow64 and the debugger
  3915. //
  3916. typedef struct _NT_TIB32 {
  3917. DWORD ExceptionList;
  3918. DWORD StackBase;
  3919. DWORD StackLimit;
  3920. DWORD SubSystemTib;
  3921. union {
  3922. DWORD FiberData;
  3923. DWORD Version;
  3924. };
  3925. DWORD ArbitraryUserPointer;
  3926. DWORD Self;
  3927. } NT_TIB32, *PNT_TIB32;
  3928. typedef struct _NT_TIB64 {
  3929. DWORD64 ExceptionList;
  3930. DWORD64 StackBase;
  3931. DWORD64 StackLimit;
  3932. DWORD64 SubSystemTib;
  3933. union {
  3934. DWORD64 FiberData;
  3935. DWORD Version;
  3936. };
  3937. DWORD64 ArbitraryUserPointer;
  3938. DWORD64 Self;
  3939. } NT_TIB64, *PNT_TIB64;
  3940. #if !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_)
  3941. #define WX86
  3942. #endif
  3943. #define THREAD_BASE_PRIORITY_LOWRT 15 // value that gets a thread to LowRealtime-1
  3944. #define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
  3945. #define THREAD_BASE_PRIORITY_MIN (-2) // minimum thread base priority boost
  3946. #define THREAD_BASE_PRIORITY_IDLE (-15) // value that gets a thread to idle
  3947. typedef struct _QUOTA_LIMITS {
  3948. SIZE_T PagedPoolLimit;
  3949. SIZE_T NonPagedPoolLimit;
  3950. SIZE_T MinimumWorkingSetSize;
  3951. SIZE_T MaximumWorkingSetSize;
  3952. SIZE_T PagefileLimit;
  3953. LARGE_INTEGER TimeLimit;
  3954. } QUOTA_LIMITS;
  3955. typedef QUOTA_LIMITS *PQUOTA_LIMITS;
  3956. typedef struct _IO_COUNTERS {
  3957. ULONGLONG ReadOperationCount;
  3958. ULONGLONG WriteOperationCount;
  3959. ULONGLONG OtherOperationCount;
  3960. ULONGLONG ReadTransferCount;
  3961. ULONGLONG WriteTransferCount;
  3962. ULONGLONG OtherTransferCount;
  3963. } IO_COUNTERS;
  3964. typedef IO_COUNTERS *PIO_COUNTERS;
  3965. typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
  3966. LARGE_INTEGER TotalUserTime;
  3967. LARGE_INTEGER TotalKernelTime;
  3968. LARGE_INTEGER ThisPeriodTotalUserTime;
  3969. LARGE_INTEGER ThisPeriodTotalKernelTime;
  3970. DWORD TotalPageFaultCount;
  3971. DWORD TotalProcesses;
  3972. DWORD ActiveProcesses;
  3973. DWORD TotalTerminatedProcesses;
  3974. } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
  3975. typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
  3976. LARGE_INTEGER PerProcessUserTimeLimit;
  3977. LARGE_INTEGER PerJobUserTimeLimit;
  3978. DWORD LimitFlags;
  3979. SIZE_T MinimumWorkingSetSize;
  3980. SIZE_T MaximumWorkingSetSize;
  3981. DWORD ActiveProcessLimit;
  3982. ULONG_PTR Affinity;
  3983. DWORD PriorityClass;
  3984. DWORD SchedulingClass;
  3985. } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
  3986. typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
  3987. JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
  3988. IO_COUNTERS IoInfo;
  3989. SIZE_T ProcessMemoryLimit;
  3990. SIZE_T JobMemoryLimit;
  3991. SIZE_T PeakProcessMemoryUsed;
  3992. SIZE_T PeakJobMemoryUsed;
  3993. } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
  3994. typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
  3995. DWORD NumberOfAssignedProcesses;
  3996. DWORD NumberOfProcessIdsInList;
  3997. ULONG_PTR ProcessIdList[1];
  3998. } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
  3999. typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
  4000. DWORD UIRestrictionsClass;
  4001. } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
  4002. typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
  4003. DWORD SecurityLimitFlags ;
  4004. HANDLE JobToken ;
  4005. PTOKEN_GROUPS SidsToDisable ;
  4006. PTOKEN_PRIVILEGES PrivilegesToDelete ;
  4007. PTOKEN_GROUPS RestrictedSids ;
  4008. } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION ;
  4009. typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
  4010. DWORD EndOfJobTimeAction;
  4011. } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, *PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
  4012. typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
  4013. PVOID CompletionKey;
  4014. HANDLE CompletionPort;
  4015. } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
  4016. typedef struct _JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
  4017. JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
  4018. IO_COUNTERS IoInfo;
  4019. } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
  4020. typedef struct _JOBOBJECT_JOBSET_INFORMATION {
  4021. DWORD MemberLevel;
  4022. } JOBOBJECT_JOBSET_INFORMATION, *PJOBOBJECT_JOBSET_INFORMATION;
  4023. #define JOB_OBJECT_TERMINATE_AT_END_OF_JOB 0
  4024. #define JOB_OBJECT_POST_AT_END_OF_JOB 1
  4025. //
  4026. // Completion Port Messages for job objects
  4027. //
  4028. // These values are returned via the lpNumberOfBytesTransferred parameter
  4029. //
  4030. #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
  4031. #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
  4032. #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
  4033. #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
  4034. #define JOB_OBJECT_MSG_NEW_PROCESS 6
  4035. #define JOB_OBJECT_MSG_EXIT_PROCESS 7
  4036. #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
  4037. #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
  4038. #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
  4039. //
  4040. // Basic Limits
  4041. //
  4042. #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
  4043. #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
  4044. #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
  4045. #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
  4046. #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
  4047. #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
  4048. #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
  4049. #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
  4050. //
  4051. // Extended Limits
  4052. //
  4053. #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
  4054. #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
  4055. #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
  4056. #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
  4057. #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
  4058. #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
  4059. #define JOB_OBJECT_LIMIT_RESERVED2 0x00004000
  4060. #define JOB_OBJECT_LIMIT_RESERVED3 0x00008000
  4061. #define JOB_OBJECT_LIMIT_RESERVED4 0x00010000
  4062. #define JOB_OBJECT_LIMIT_RESERVED5 0x00020000
  4063. #define JOB_OBJECT_LIMIT_RESERVED6 0x00040000
  4064. #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
  4065. #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
  4066. #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00003fff
  4067. #define JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS 0x0007ffff
  4068. //
  4069. // UI restrictions for jobs
  4070. //
  4071. #define JOB_OBJECT_UILIMIT_NONE 0x00000000
  4072. #define JOB_OBJECT_UILIMIT_HANDLES 0x00000001
  4073. #define JOB_OBJECT_UILIMIT_READCLIPBOARD 0x00000002
  4074. #define JOB_OBJECT_UILIMIT_WRITECLIPBOARD 0x00000004
  4075. #define JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS 0x00000008
  4076. #define JOB_OBJECT_UILIMIT_DISPLAYSETTINGS 0x00000010
  4077. #define JOB_OBJECT_UILIMIT_GLOBALATOMS 0x00000020
  4078. #define JOB_OBJECT_UILIMIT_DESKTOP 0x00000040
  4079. #define JOB_OBJECT_UILIMIT_EXITWINDOWS 0x00000080
  4080. #define JOB_OBJECT_UILIMIT_ALL 0x000000FF
  4081. #define JOB_OBJECT_UI_VALID_FLAGS 0x000000FF
  4082. #define JOB_OBJECT_SECURITY_NO_ADMIN 0x00000001
  4083. #define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN 0x00000002
  4084. #define JOB_OBJECT_SECURITY_ONLY_TOKEN 0x00000004
  4085. #define JOB_OBJECT_SECURITY_FILTER_TOKENS 0x00000008
  4086. #define JOB_OBJECT_SECURITY_VALID_FLAGS 0x0000000f
  4087. typedef enum _JOBOBJECTINFOCLASS {
  4088. JobObjectBasicAccountingInformation = 1,
  4089. JobObjectBasicLimitInformation,
  4090. JobObjectBasicProcessIdList,
  4091. JobObjectBasicUIRestrictions,
  4092. JobObjectSecurityLimitInformation,
  4093. JobObjectEndOfJobTimeInformation,
  4094. JobObjectAssociateCompletionPortInformation,
  4095. JobObjectBasicAndIoAccountingInformation,
  4096. JobObjectExtendedLimitInformation,
  4097. JobObjectJobSetInformation,
  4098. MaxJobObjectInfoClass
  4099. } JOBOBJECTINFOCLASS;
  4100. //
  4101. #define EVENT_MODIFY_STATE 0x0002
  4102. #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
  4103. #define MUTANT_QUERY_STATE 0x0001
  4104. #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|\
  4105. MUTANT_QUERY_STATE)
  4106. #define SEMAPHORE_MODIFY_STATE 0x0002
  4107. #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
  4108. //
  4109. // Timer Specific Access Rights.
  4110. //
  4111. #define TIMER_QUERY_STATE 0x0001
  4112. #define TIMER_MODIFY_STATE 0x0002
  4113. #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|\
  4114. TIMER_QUERY_STATE|TIMER_MODIFY_STATE)
  4115. #define TIME_ZONE_ID_UNKNOWN 0
  4116. #define TIME_ZONE_ID_STANDARD 1
  4117. #define TIME_ZONE_ID_DAYLIGHT 2
  4118. #define MAXIMUM_NUMA_NODES 16
  4119. typedef struct _SYSTEM_NUMA_INFORMATION {
  4120. DWORD HighestNodeNumber;
  4121. DWORD Reserved;
  4122. union {
  4123. ULONGLONG ActiveProcessorsAffinityMask[MAXIMUM_NUMA_NODES];
  4124. ULONGLONG AvailableMemory[MAXIMUM_NUMA_NODES];
  4125. };
  4126. } SYSTEM_NUMA_INFORMATION, *PSYSTEM_NUMA_INFORMATION;
  4127. #define PROCESSOR_INTEL_386 386
  4128. #define PROCESSOR_INTEL_486 486
  4129. #define PROCESSOR_INTEL_PENTIUM 586
  4130. #define PROCESSOR_INTEL_IA64 2200
  4131. #define PROCESSOR_MIPS_R4000 4000 // incl R4101 & R3910 for Windows CE
  4132. #define PROCESSOR_ALPHA_21064 21064
  4133. #define PROCESSOR_PPC_601 601
  4134. #define PROCESSOR_PPC_603 603
  4135. #define PROCESSOR_PPC_604 604
  4136. #define PROCESSOR_PPC_620 620
  4137. #define PROCESSOR_HITACHI_SH3 10003 // Windows CE
  4138. #define PROCESSOR_HITACHI_SH3E 10004 // Windows CE
  4139. #define PROCESSOR_HITACHI_SH4 10005 // Windows CE
  4140. #define PROCESSOR_MOTOROLA_821 821 // Windows CE
  4141. #define PROCESSOR_SHx_SH3 103 // Windows CE
  4142. #define PROCESSOR_SHx_SH4 104 // Windows CE
  4143. #define PROCESSOR_STRONGARM 2577 // Windows CE - 0xA11
  4144. #define PROCESSOR_ARM720 1824 // Windows CE - 0x720
  4145. #define PROCESSOR_ARM820 2080 // Windows CE - 0x820
  4146. #define PROCESSOR_ARM920 2336 // Windows CE - 0x920
  4147. #define PROCESSOR_ARM_7TDMI 70001 // Windows CE
  4148. #define PROCESSOR_OPTIL 0x494f // MSIL
  4149. #define PROCESSOR_ARCHITECTURE_INTEL 0
  4150. #define PROCESSOR_ARCHITECTURE_MIPS 1
  4151. #define PROCESSOR_ARCHITECTURE_ALPHA 2
  4152. #define PROCESSOR_ARCHITECTURE_PPC 3
  4153. #define PROCESSOR_ARCHITECTURE_SHX 4
  4154. #define PROCESSOR_ARCHITECTURE_ARM 5
  4155. #define PROCESSOR_ARCHITECTURE_IA64 6
  4156. #define PROCESSOR_ARCHITECTURE_ALPHA64 7
  4157. #define PROCESSOR_ARCHITECTURE_MSIL 8
  4158. #define PROCESSOR_ARCHITECTURE_AMD64 9
  4159. #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
  4160. #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
  4161. #define PF_FLOATING_POINT_PRECISION_ERRATA 0
  4162. #define PF_FLOATING_POINT_EMULATED 1
  4163. #define PF_COMPARE_EXCHANGE_DOUBLE 2
  4164. #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
  4165. #define PF_PPC_MOVEMEM_64BIT_OK 4
  4166. #define PF_ALPHA_BYTE_INSTRUCTIONS 5
  4167. #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
  4168. #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
  4169. #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
  4170. #define PF_PAE_ENABLED 9
  4171. #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
  4172. typedef struct _MEMORY_BASIC_INFORMATION {
  4173. PVOID BaseAddress;
  4174. PVOID AllocationBase;
  4175. DWORD AllocationProtect;
  4176. SIZE_T RegionSize;
  4177. DWORD State;
  4178. DWORD Protect;
  4179. DWORD Type;
  4180. } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
  4181. typedef struct _MEMORY_BASIC_INFORMATION32 {
  4182. DWORD BaseAddress;
  4183. DWORD AllocationBase;
  4184. DWORD AllocationProtect;
  4185. DWORD RegionSize;
  4186. DWORD State;
  4187. DWORD Protect;
  4188. DWORD Type;
  4189. } MEMORY_BASIC_INFORMATION32, *PMEMORY_BASIC_INFORMATION32;
  4190. typedef struct _MEMORY_BASIC_INFORMATION64 {
  4191. ULONGLONG BaseAddress;
  4192. ULONGLONG AllocationBase;
  4193. DWORD AllocationProtect;
  4194. DWORD __alignment1;
  4195. ULONGLONG RegionSize;
  4196. DWORD State;
  4197. DWORD Protect;
  4198. DWORD Type;
  4199. DWORD __alignment2;
  4200. } MEMORY_BASIC_INFORMATION64, *PMEMORY_BASIC_INFORMATION64;
  4201. #define SECTION_QUERY 0x0001
  4202. #define SECTION_MAP_WRITE 0x0002
  4203. #define SECTION_MAP_READ 0x0004
  4204. #define SECTION_MAP_EXECUTE 0x0008
  4205. #define SECTION_EXTEND_SIZE 0x0010
  4206. #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
  4207. SECTION_MAP_WRITE | \
  4208. SECTION_MAP_READ | \
  4209. SECTION_MAP_EXECUTE | \
  4210. SECTION_EXTEND_SIZE)
  4211. #define PAGE_NOACCESS 0x01
  4212. #define PAGE_READONLY 0x02
  4213. #define PAGE_READWRITE 0x04
  4214. #define PAGE_WRITECOPY 0x08
  4215. #define PAGE_EXECUTE 0x10
  4216. #define PAGE_EXECUTE_READ 0x20
  4217. #define PAGE_EXECUTE_READWRITE 0x40
  4218. #define PAGE_EXECUTE_WRITECOPY 0x80
  4219. #define PAGE_GUARD 0x100
  4220. #define PAGE_NOCACHE 0x200
  4221. #define PAGE_WRITECOMBINE 0x400
  4222. #define MEM_COMMIT 0x1000
  4223. #define MEM_RESERVE 0x2000
  4224. #define MEM_DECOMMIT 0x4000
  4225. #define MEM_RELEASE 0x8000
  4226. #define MEM_FREE 0x10000
  4227. #define MEM_PRIVATE 0x20000
  4228. #define MEM_MAPPED 0x40000
  4229. #define MEM_RESET 0x80000
  4230. #define MEM_TOP_DOWN 0x100000
  4231. #define MEM_WRITE_WATCH 0x200000
  4232. #define MEM_PHYSICAL 0x400000
  4233. #define MEM_4MB_PAGES 0x80000000
  4234. #define SEC_FILE 0x800000
  4235. #define SEC_IMAGE 0x1000000
  4236. #define SEC_RESERVE 0x4000000
  4237. #define SEC_COMMIT 0x8000000
  4238. #define SEC_NOCACHE 0x10000000
  4239. #define MEM_IMAGE SEC_IMAGE
  4240. #define WRITE_WATCH_FLAG_RESET 0x01
  4241. //
  4242. // Define access rights to files and directories
  4243. //
  4244. //
  4245. // The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
  4246. // devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
  4247. // constants *MUST* always be in sync.
  4248. // The values are redefined in devioctl.h because they must be available to
  4249. // both DOS and NT.
  4250. //
  4251. #define FILE_READ_DATA ( 0x0001 ) // file & pipe
  4252. #define FILE_LIST_DIRECTORY ( 0x0001 ) // directory
  4253. #define FILE_WRITE_DATA ( 0x0002 ) // file & pipe
  4254. #define FILE_ADD_FILE ( 0x0002 ) // directory
  4255. #define FILE_APPEND_DATA ( 0x0004 ) // file
  4256. #define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory
  4257. #define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe
  4258. #define FILE_READ_EA ( 0x0008 ) // file & directory
  4259. #define FILE_WRITE_EA ( 0x0010 ) // file & directory
  4260. #define FILE_EXECUTE ( 0x0020 ) // file
  4261. #define FILE_TRAVERSE ( 0x0020 ) // directory
  4262. #define FILE_DELETE_CHILD ( 0x0040 ) // directory
  4263. #define FILE_READ_ATTRIBUTES ( 0x0080 ) // all
  4264. #define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all
  4265. #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
  4266. #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
  4267. FILE_READ_DATA |\
  4268. FILE_READ_ATTRIBUTES |\
  4269. FILE_READ_EA |\
  4270. SYNCHRONIZE)
  4271. #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
  4272. FILE_WRITE_DATA |\
  4273. FILE_WRITE_ATTRIBUTES |\
  4274. FILE_WRITE_EA |\
  4275. FILE_APPEND_DATA |\
  4276. SYNCHRONIZE)
  4277. #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  4278. FILE_READ_ATTRIBUTES |\
  4279. FILE_EXECUTE |\
  4280. SYNCHRONIZE)
  4281. #define FILE_SHARE_READ 0x00000001
  4282. #define FILE_SHARE_WRITE 0x00000002
  4283. #define FILE_SHARE_DELETE 0x00000004
  4284. #define FILE_ATTRIBUTE_READONLY 0x00000001
  4285. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  4286. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  4287. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  4288. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  4289. #define FILE_ATTRIBUTE_DEVICE 0x00000040
  4290. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  4291. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
  4292. #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
  4293. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
  4294. #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
  4295. #define FILE_ATTRIBUTE_OFFLINE 0x00001000
  4296. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
  4297. #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
  4298. #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
  4299. #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
  4300. #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
  4301. #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
  4302. #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
  4303. #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
  4304. #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
  4305. #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
  4306. #define FILE_ACTION_ADDED 0x00000001
  4307. #define FILE_ACTION_REMOVED 0x00000002
  4308. #define FILE_ACTION_MODIFIED 0x00000003
  4309. #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
  4310. #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
  4311. #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
  4312. #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
  4313. #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
  4314. #define FILE_CASE_PRESERVED_NAMES 0x00000002
  4315. #define FILE_UNICODE_ON_DISK 0x00000004
  4316. #define FILE_PERSISTENT_ACLS 0x00000008
  4317. #define FILE_FILE_COMPRESSION 0x00000010
  4318. #define FILE_VOLUME_QUOTAS 0x00000020
  4319. #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
  4320. #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
  4321. #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
  4322. #define FILE_VOLUME_IS_COMPRESSED 0x00008000
  4323. #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
  4324. #define FILE_SUPPORTS_ENCRYPTION 0x00020000
  4325. #define FILE_NAMED_STREAMS 0x00040000
  4326. #define FILE_READ_ONLY_VOLUME 0x00080000
  4327. //
  4328. // Define the file notification information structure
  4329. //
  4330. typedef struct _FILE_NOTIFY_INFORMATION {
  4331. DWORD NextEntryOffset;
  4332. DWORD Action;
  4333. DWORD FileNameLength;
  4334. WCHAR FileName[1];
  4335. } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
  4336. //
  4337. // Define segement buffer structure for scatter/gather read/write.
  4338. //
  4339. typedef union _FILE_SEGMENT_ELEMENT {
  4340. PVOID64 Buffer;
  4341. ULONGLONG Alignment;
  4342. }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
  4343. //
  4344. // The reparse GUID structure is used by all 3rd party layered drivers to
  4345. // store data in a reparse point. For non-Microsoft tags, The GUID field
  4346. // cannot be GUID_NULL.
  4347. // The constraints on reparse tags are defined below.
  4348. // Microsoft tags can also be used with this format of the reparse point buffer.
  4349. //
  4350. typedef struct _REPARSE_GUID_DATA_BUFFER {
  4351. DWORD ReparseTag;
  4352. WORD ReparseDataLength;
  4353. WORD Reserved;
  4354. GUID ReparseGuid;
  4355. struct {
  4356. BYTE DataBuffer[1];
  4357. } GenericReparseBuffer;
  4358. } REPARSE_GUID_DATA_BUFFER, *PREPARSE_GUID_DATA_BUFFER;
  4359. #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer)
  4360. //
  4361. // Maximum allowed size of the reparse data.
  4362. //
  4363. #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
  4364. //
  4365. // Predefined reparse tags.
  4366. // These tags need to avoid conflicting with IO_REMOUNT defined in ntos\inc\io.h
  4367. //
  4368. #define IO_REPARSE_TAG_RESERVED_ZERO (0)
  4369. #define IO_REPARSE_TAG_RESERVED_ONE (1)
  4370. //
  4371. // The value of the following constant needs to satisfy the following conditions:
  4372. // (1) Be at least as large as the largest of the reserved tags.
  4373. // (2) Be strictly smaller than all the tags in use.
  4374. //
  4375. #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_ONE
  4376. //
  4377. // The reparse tags are a DWORD. The 32 bits are laid out as follows:
  4378. //
  4379. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  4380. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  4381. // +-+-+-+-+-----------------------+-------------------------------+
  4382. // |M|R|N|R| Reserved bits | Reparse Tag Value |
  4383. // +-+-+-+-+-----------------------+-------------------------------+
  4384. //
  4385. // M is the Microsoft bit. When set to 1, it denotes a tag owned by Microsoft.
  4386. // All ISVs must use a tag with a 0 in this position.
  4387. // Note: If a Microsoft tag is used by non-Microsoft software, the
  4388. // behavior is not defined.
  4389. //
  4390. // R is reserved. Must be zero for non-Microsoft tags.
  4391. //
  4392. // N is name surrogate. When set to 1, the file represents another named
  4393. // entity in the system.
  4394. //
  4395. // The M and N bits are OR-able.
  4396. // The following macros check for the M and N bit values:
  4397. //
  4398. //
  4399. // Macro to determine whether a reparse point tag corresponds to a tag
  4400. // owned by Microsoft.
  4401. //
  4402. #define IsReparseTagMicrosoft(_tag) ( \
  4403. ((_tag) & 0x80000000) \
  4404. )
  4405. //
  4406. // Macro to determine whether a reparse point tag is a name surrogate
  4407. //
  4408. #define IsReparseTagNameSurrogate(_tag) ( \
  4409. ((_tag) & 0x20000000) \
  4410. )
  4411. #define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L)
  4412. #define IO_REPARSE_TAG_HSM (0xC0000004L)
  4413. #define IO_REPARSE_TAG_SIS (0x80000007L)
  4414. #define IO_REPARSE_TAG_FILTER_MANAGER (0x8000000BL)
  4415. #define IO_COMPLETION_MODIFY_STATE 0x0002
  4416. #define IO_COMPLETION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
  4417. #define DUPLICATE_CLOSE_SOURCE 0x00000001
  4418. #define DUPLICATE_SAME_ACCESS 0x00000002
  4419. typedef enum _SYSTEM_POWER_STATE {
  4420. PowerSystemUnspecified = 0,
  4421. PowerSystemWorking = 1,
  4422. PowerSystemSleeping1 = 2,
  4423. PowerSystemSleeping2 = 3,
  4424. PowerSystemSleeping3 = 4,
  4425. PowerSystemHibernate = 5,
  4426. PowerSystemShutdown = 6,
  4427. PowerSystemMaximum = 7
  4428. } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
  4429. #define POWER_SYSTEM_MAXIMUM 7
  4430. typedef enum {
  4431. PowerActionNone = 0,
  4432. PowerActionReserved,
  4433. PowerActionSleep,
  4434. PowerActionHibernate,
  4435. PowerActionShutdown,
  4436. PowerActionShutdownReset,
  4437. PowerActionShutdownOff,
  4438. PowerActionWarmEject
  4439. } POWER_ACTION, *PPOWER_ACTION;
  4440. typedef enum _DEVICE_POWER_STATE {
  4441. PowerDeviceUnspecified = 0,
  4442. PowerDeviceD0,
  4443. PowerDeviceD1,
  4444. PowerDeviceD2,
  4445. PowerDeviceD3,
  4446. PowerDeviceMaximum
  4447. } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
  4448. #define ES_SYSTEM_REQUIRED ((DWORD)0x00000001)
  4449. #define ES_DISPLAY_REQUIRED ((DWORD)0x00000002)
  4450. #define ES_USER_PRESENT ((DWORD)0x00000004)
  4451. #define ES_CONTINUOUS ((DWORD)0x80000000)
  4452. typedef DWORD EXECUTION_STATE;
  4453. typedef enum {
  4454. LT_DONT_CARE,
  4455. LT_LOWEST_LATENCY
  4456. } LATENCY_TIME;
  4457. // end_ntminiport end_ntifs end_wdm end_ntddk
  4458. //-----------------------------------------------------------------------------
  4459. // Device Power Information
  4460. // Accessable via CM_Get_DevInst_Registry_Property_Ex(CM_DRP_DEVICE_POWER_DATA)
  4461. //-----------------------------------------------------------------------------
  4462. #define PDCAP_D0_SUPPORTED 0x00000001
  4463. #define PDCAP_D1_SUPPORTED 0x00000002
  4464. #define PDCAP_D2_SUPPORTED 0x00000004
  4465. #define PDCAP_D3_SUPPORTED 0x00000008
  4466. #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
  4467. #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
  4468. #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
  4469. #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
  4470. #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
  4471. typedef struct CM_Power_Data_s {
  4472. DWORD PD_Size;
  4473. DEVICE_POWER_STATE PD_MostRecentPowerState;
  4474. DWORD PD_Capabilities;
  4475. DWORD PD_D1Latency;
  4476. DWORD PD_D2Latency;
  4477. DWORD PD_D3Latency;
  4478. DEVICE_POWER_STATE PD_PowerStateMapping[POWER_SYSTEM_MAXIMUM];
  4479. SYSTEM_POWER_STATE PD_DeepestSystemWake;
  4480. } CM_POWER_DATA, *PCM_POWER_DATA;
  4481. // begin_ntddk
  4482. typedef enum {
  4483. SystemPowerPolicyAc,
  4484. SystemPowerPolicyDc,
  4485. VerifySystemPolicyAc,
  4486. VerifySystemPolicyDc,
  4487. SystemPowerCapabilities,
  4488. SystemBatteryState,
  4489. SystemPowerStateHandler,
  4490. ProcessorStateHandler,
  4491. SystemPowerPolicyCurrent,
  4492. AdministratorPowerPolicy,
  4493. SystemReserveHiberFile,
  4494. ProcessorInformation,
  4495. SystemPowerInformation,
  4496. ProcessorStateHandler2,
  4497. LastWakeTime, // Compare with KeQueryInterruptTime()
  4498. LastSleepTime, // Compare with KeQueryInterruptTime()
  4499. SystemExecutionState,
  4500. SystemPowerStateNotifyHandler,
  4501. ProcessorPowerPolicyAc,
  4502. ProcessorPowerPolicyDc,
  4503. VerifyProcessorPowerPolicyAc,
  4504. VerifyProcessorPowerPolicyDc,
  4505. ProcessorPowerPolicyCurrent
  4506. } POWER_INFORMATION_LEVEL;
  4507. // begin_wdm
  4508. //
  4509. // System power manager capabilities
  4510. //
  4511. typedef struct {
  4512. DWORD Granularity;
  4513. DWORD Capacity;
  4514. } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
  4515. //
  4516. // Power Policy Management interfaces
  4517. //
  4518. typedef struct {
  4519. POWER_ACTION Action;
  4520. DWORD Flags;
  4521. DWORD EventCode;
  4522. } POWER_ACTION_POLICY, *PPOWER_ACTION_POLICY;
  4523. // POWER_ACTION_POLICY->Flags:
  4524. #define POWER_ACTION_QUERY_ALLOWED 0x00000001
  4525. #define POWER_ACTION_UI_ALLOWED 0x00000002
  4526. #define POWER_ACTION_OVERRIDE_APPS 0x00000004
  4527. #define POWER_ACTION_LIGHTEST_FIRST 0x10000000
  4528. #define POWER_ACTION_LOCK_CONSOLE 0x20000000
  4529. #define POWER_ACTION_DISABLE_WAKES 0x40000000
  4530. #define POWER_ACTION_CRITICAL 0x80000000
  4531. // POWER_ACTION_POLICY->EventCode flags
  4532. #define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
  4533. #define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
  4534. #define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
  4535. #define POWER_USER_NOTIFY_BUTTON 0x00000008
  4536. #define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
  4537. #define POWER_FORCE_TRIGGER_RESET 0x80000000
  4538. // system battery drain policies
  4539. typedef struct {
  4540. BOOLEAN Enable;
  4541. BYTE Spare[3];
  4542. DWORD BatteryLevel;
  4543. POWER_ACTION_POLICY PowerPolicy;
  4544. SYSTEM_POWER_STATE MinSystemState;
  4545. } SYSTEM_POWER_LEVEL, *PSYSTEM_POWER_LEVEL;
  4546. // Discharge policy constants
  4547. #define NUM_DISCHARGE_POLICIES 4
  4548. #define DISCHARGE_POLICY_CRITICAL 0
  4549. #define DISCHARGE_POLICY_LOW 1
  4550. //
  4551. // Throttling policies
  4552. //
  4553. #define PO_THROTTLE_NONE 0
  4554. #define PO_THROTTLE_CONSTANT 1
  4555. #define PO_THROTTLE_DEGRADE 2
  4556. #define PO_THROTTLE_ADAPTIVE 3
  4557. #define PO_THROTTLE_MAXIMUM 4 // not a policy, just a limit
  4558. // system power policies
  4559. typedef struct _SYSTEM_POWER_POLICY {
  4560. DWORD Revision; // 1
  4561. // events
  4562. POWER_ACTION_POLICY PowerButton;
  4563. POWER_ACTION_POLICY SleepButton;
  4564. POWER_ACTION_POLICY LidClose;
  4565. SYSTEM_POWER_STATE LidOpenWake;
  4566. DWORD Reserved;
  4567. // "system idle" detection
  4568. POWER_ACTION_POLICY Idle;
  4569. DWORD IdleTimeout;
  4570. BYTE IdleSensitivity;
  4571. // dynamic throttling policy
  4572. // PO_THROTTLE_NONE, PO_THROTTLE_CONSTANT, PO_THROTTLE_DEGRADE, or PO_THROTTLE_ADAPTIVE
  4573. BYTE DynamicThrottle;
  4574. BYTE Spare2[2];
  4575. // meaning of power action "sleep"
  4576. SYSTEM_POWER_STATE MinSleep;
  4577. SYSTEM_POWER_STATE MaxSleep;
  4578. SYSTEM_POWER_STATE ReducedLatencySleep;
  4579. DWORD WinLogonFlags;
  4580. // parameters for dozing
  4581. DWORD Spare3;
  4582. DWORD DozeS4Timeout;
  4583. // battery policies
  4584. DWORD BroadcastCapacityResolution;
  4585. SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
  4586. // video policies
  4587. DWORD VideoTimeout;
  4588. BOOLEAN VideoDimDisplay;
  4589. DWORD VideoReserved[3];
  4590. // hard disk policies
  4591. DWORD SpindownTimeout;
  4592. // processor policies
  4593. BOOLEAN OptimizeForPower;
  4594. BYTE FanThrottleTolerance;
  4595. BYTE ForcedThrottle;
  4596. BYTE MinThrottle;
  4597. POWER_ACTION_POLICY OverThrottled;
  4598. } SYSTEM_POWER_POLICY, *PSYSTEM_POWER_POLICY;
  4599. // processor power policy state
  4600. typedef struct _PROCESSOR_POWER_POLICY_INFO {
  4601. // Time based information (will be converted to kernel units)
  4602. DWORD TimeCheck; // in US
  4603. DWORD DemoteLimit; // in US
  4604. DWORD PromoteLimit; // in US
  4605. // Percentage based information
  4606. BYTE DemotePercent;
  4607. BYTE PromotePercent;
  4608. BYTE Spare[2];
  4609. // Flags
  4610. DWORD AllowDemotion:1;
  4611. DWORD AllowPromotion:1;
  4612. DWORD Reserved:30;
  4613. } PROCESSOR_POWER_POLICY_INFO, *PPROCESSOR_POWER_POLICY_INFO;
  4614. // processor power policy
  4615. typedef struct _PROCESSOR_POWER_POLICY {
  4616. DWORD Revision; // 1
  4617. // Dynamic Throttling Policy
  4618. BYTE DynamicThrottle;
  4619. BYTE Spare[3];
  4620. // Flags
  4621. DWORD Reserved;
  4622. // System policy information
  4623. // The Array is last, in case it needs to be grown and the structure
  4624. // revision incremented.
  4625. DWORD PolicyCount;
  4626. PROCESSOR_POWER_POLICY_INFO Policy[3];
  4627. } PROCESSOR_POWER_POLICY, *PPROCESSOR_POWER_POLICY;
  4628. // administrator power policy overrides
  4629. typedef struct _ADMINISTRATOR_POWER_POLICY {
  4630. // meaning of power action "sleep"
  4631. SYSTEM_POWER_STATE MinSleep;
  4632. SYSTEM_POWER_STATE MaxSleep;
  4633. // video policies
  4634. DWORD MinVideoTimeout;
  4635. DWORD MaxVideoTimeout;
  4636. // disk policies
  4637. DWORD MinSpindownTimeout;
  4638. DWORD MaxSpindownTimeout;
  4639. } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
  4640. typedef struct {
  4641. // Misc supported system features
  4642. BOOLEAN PowerButtonPresent;
  4643. BOOLEAN SleepButtonPresent;
  4644. BOOLEAN LidPresent;
  4645. BOOLEAN SystemS1;
  4646. BOOLEAN SystemS2;
  4647. BOOLEAN SystemS3;
  4648. BOOLEAN SystemS4; // hibernate
  4649. BOOLEAN SystemS5; // off
  4650. BOOLEAN HiberFilePresent;
  4651. BOOLEAN FullWake;
  4652. BOOLEAN VideoDimPresent;
  4653. BOOLEAN ApmPresent;
  4654. BOOLEAN UpsPresent;
  4655. // Processors
  4656. BOOLEAN ThermalControl;
  4657. BOOLEAN ProcessorThrottle;
  4658. BYTE ProcessorMinThrottle;
  4659. BYTE ProcessorMaxThrottle;
  4660. BYTE spare2[4];
  4661. // Disk
  4662. BOOLEAN DiskSpinDown;
  4663. BYTE spare3[8];
  4664. // System Battery
  4665. BOOLEAN SystemBatteriesPresent;
  4666. BOOLEAN BatteriesAreShortTerm;
  4667. BATTERY_REPORTING_SCALE BatteryScale[3];
  4668. // Wake
  4669. SYSTEM_POWER_STATE AcOnLineWake;
  4670. SYSTEM_POWER_STATE SoftLidWake;
  4671. SYSTEM_POWER_STATE RtcWake;
  4672. SYSTEM_POWER_STATE MinDeviceWakeState; // note this may change on driver load
  4673. SYSTEM_POWER_STATE DefaultLowLatencyWake;
  4674. } SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
  4675. typedef struct {
  4676. BOOLEAN AcOnLine;
  4677. BOOLEAN BatteryPresent;
  4678. BOOLEAN Charging;
  4679. BOOLEAN Discharging;
  4680. BOOLEAN Spare1[4];
  4681. DWORD MaxCapacity;
  4682. DWORD RemainingCapacity;
  4683. DWORD Rate;
  4684. DWORD EstimatedTime;
  4685. DWORD DefaultAlert1;
  4686. DWORD DefaultAlert2;
  4687. } SYSTEM_BATTERY_STATE, *PSYSTEM_BATTERY_STATE;
  4688. //
  4689. // Image Format
  4690. //
  4691. #ifndef _MAC
  4692. #include "pshpack4.h" // 4 byte packing is the default
  4693. #define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
  4694. #define IMAGE_OS2_SIGNATURE 0x454E // NE
  4695. #define IMAGE_OS2_SIGNATURE_LE 0x454C // LE
  4696. #define IMAGE_VXD_SIGNATURE 0x454C // LE
  4697. #define IMAGE_NT_SIGNATURE 0x00004550 // PE00
  4698. #include "pshpack2.h" // 16 bit headers are 2 byte packed
  4699. #else
  4700. #include "pshpack1.h"
  4701. #define IMAGE_DOS_SIGNATURE 0x4D5A // MZ
  4702. #define IMAGE_OS2_SIGNATURE 0x4E45 // NE
  4703. #define IMAGE_OS2_SIGNATURE_LE 0x4C45 // LE
  4704. #define IMAGE_NT_SIGNATURE 0x50450000 // PE00
  4705. #endif
  4706. typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header
  4707. WORD e_magic; // Magic number
  4708. WORD e_cblp; // Bytes on last page of file
  4709. WORD e_cp; // Pages in file
  4710. WORD e_crlc; // Relocations
  4711. WORD e_cparhdr; // Size of header in paragraphs
  4712. WORD e_minalloc; // Minimum extra paragraphs needed
  4713. WORD e_maxalloc; // Maximum extra paragraphs needed
  4714. WORD e_ss; // Initial (relative) SS value
  4715. WORD e_sp; // Initial SP value
  4716. WORD e_csum; // Checksum
  4717. WORD e_ip; // Initial IP value
  4718. WORD e_cs; // Initial (relative) CS value
  4719. WORD e_lfarlc; // File address of relocation table
  4720. WORD e_ovno; // Overlay number
  4721. WORD e_res[4]; // Reserved words
  4722. WORD e_oemid; // OEM identifier (for e_oeminfo)
  4723. WORD e_oeminfo; // OEM information; e_oemid specific
  4724. WORD e_res2[10]; // Reserved words
  4725. LONG e_lfanew; // File address of new exe header
  4726. } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
  4727. typedef struct _IMAGE_OS2_HEADER { // OS/2 .EXE header
  4728. WORD ne_magic; // Magic number
  4729. CHAR ne_ver; // Version number
  4730. CHAR ne_rev; // Revision number
  4731. WORD ne_enttab; // Offset of Entry Table
  4732. WORD ne_cbenttab; // Number of bytes in Entry Table
  4733. LONG ne_crc; // Checksum of whole file
  4734. WORD ne_flags; // Flag word
  4735. WORD ne_autodata; // Automatic data segment number
  4736. WORD ne_heap; // Initial heap allocation
  4737. WORD ne_stack; // Initial stack allocation
  4738. LONG ne_csip; // Initial CS:IP setting
  4739. LONG ne_sssp; // Initial SS:SP setting
  4740. WORD ne_cseg; // Count of file segments
  4741. WORD ne_cmod; // Entries in Module Reference Table
  4742. WORD ne_cbnrestab; // Size of non-resident name table
  4743. WORD ne_segtab; // Offset of Segment Table
  4744. WORD ne_rsrctab; // Offset of Resource Table
  4745. WORD ne_restab; // Offset of resident name table
  4746. WORD ne_modtab; // Offset of Module Reference Table
  4747. WORD ne_imptab; // Offset of Imported Names Table
  4748. LONG ne_nrestab; // Offset of Non-resident Names Table
  4749. WORD ne_cmovent; // Count of movable entries
  4750. WORD ne_align; // Segment alignment shift count
  4751. WORD ne_cres; // Count of resource segments
  4752. BYTE ne_exetyp; // Target Operating system
  4753. BYTE ne_flagsothers; // Other .EXE flags
  4754. WORD ne_pretthunks; // offset to return thunks
  4755. WORD ne_psegrefbytes; // offset to segment ref. bytes
  4756. WORD ne_swaparea; // Minimum code swap area size
  4757. WORD ne_expver; // Expected Windows version number
  4758. } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
  4759. typedef struct _IMAGE_VXD_HEADER { // Windows VXD header
  4760. WORD e32_magic; // Magic number
  4761. BYTE e32_border; // The byte ordering for the VXD
  4762. BYTE e32_worder; // The word ordering for the VXD
  4763. DWORD e32_level; // The EXE format level for now = 0
  4764. WORD e32_cpu; // The CPU type
  4765. WORD e32_os; // The OS type
  4766. DWORD e32_ver; // Module version
  4767. DWORD e32_mflags; // Module flags
  4768. DWORD e32_mpages; // Module # pages
  4769. DWORD e32_startobj; // Object # for instruction pointer
  4770. DWORD e32_eip; // Extended instruction pointer
  4771. DWORD e32_stackobj; // Object # for stack pointer
  4772. DWORD e32_esp; // Extended stack pointer
  4773. DWORD e32_pagesize; // VXD page size
  4774. DWORD e32_lastpagesize; // Last page size in VXD
  4775. DWORD e32_fixupsize; // Fixup section size
  4776. DWORD e32_fixupsum; // Fixup section checksum
  4777. DWORD e32_ldrsize; // Loader section size
  4778. DWORD e32_ldrsum; // Loader section checksum
  4779. DWORD e32_objtab; // Object table offset
  4780. DWORD e32_objcnt; // Number of objects in module
  4781. DWORD e32_objmap; // Object page map offset
  4782. DWORD e32_itermap; // Object iterated data map offset
  4783. DWORD e32_rsrctab; // Offset of Resource Table
  4784. DWORD e32_rsrccnt; // Number of resource entries
  4785. DWORD e32_restab; // Offset of resident name table
  4786. DWORD e32_enttab; // Offset of Entry Table
  4787. DWORD e32_dirtab; // Offset of Module Directive Table
  4788. DWORD e32_dircnt; // Number of module directives
  4789. DWORD e32_fpagetab; // Offset of Fixup Page Table
  4790. DWORD e32_frectab; // Offset of Fixup Record Table
  4791. DWORD e32_impmod; // Offset of Import Module Name Table
  4792. DWORD e32_impmodcnt; // Number of entries in Import Module Name Table
  4793. DWORD e32_impproc; // Offset of Import Procedure Name Table
  4794. DWORD e32_pagesum; // Offset of Per-Page Checksum Table
  4795. DWORD e32_datapage; // Offset of Enumerated Data Pages
  4796. DWORD e32_preload; // Number of preload pages
  4797. DWORD e32_nrestab; // Offset of Non-resident Names Table
  4798. DWORD e32_cbnrestab; // Size of Non-resident Name Table
  4799. DWORD e32_nressum; // Non-resident Name Table Checksum
  4800. DWORD e32_autodata; // Object # for automatic data object
  4801. DWORD e32_debuginfo; // Offset of the debugging information
  4802. DWORD e32_debuglen; // The length of the debugging info. in bytes
  4803. DWORD e32_instpreload; // Number of instance pages in preload section of VXD file
  4804. DWORD e32_instdemand; // Number of instance pages in demand load section of VXD file
  4805. DWORD e32_heapsize; // Size of heap - for 16-bit apps
  4806. BYTE e32_res3[12]; // Reserved words
  4807. DWORD e32_winresoff;
  4808. DWORD e32_winreslen;
  4809. WORD e32_devid; // Device ID for VxD
  4810. WORD e32_ddkver; // DDK version for VxD
  4811. } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
  4812. #ifndef _MAC
  4813. #include "poppack.h" // Back to 4 byte packing
  4814. #endif
  4815. //
  4816. // File header format.
  4817. //
  4818. typedef struct _IMAGE_FILE_HEADER {
  4819. WORD Machine;
  4820. WORD NumberOfSections;
  4821. DWORD TimeDateStamp;
  4822. DWORD PointerToSymbolTable;
  4823. DWORD NumberOfSymbols;
  4824. WORD SizeOfOptionalHeader;
  4825. WORD Characteristics;
  4826. } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
  4827. #define IMAGE_SIZEOF_FILE_HEADER 20
  4828. #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file.
  4829. #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references).
  4830. #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file.
  4831. #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file.
  4832. #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010 // Agressively trim working set
  4833. #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 // App can handle >2gb addresses
  4834. #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed.
  4835. #define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.
  4836. #define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file
  4837. #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 // If Image is on removable media, copy and run from the swap file.
  4838. #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 // If Image is on Net, copy and run from the swap file.
  4839. #define IMAGE_FILE_SYSTEM 0x1000 // System File.
  4840. #define IMAGE_FILE_DLL 0x2000 // File is a DLL.
  4841. #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 // File should only be run on a UP machine
  4842. #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed.
  4843. #define IMAGE_FILE_MACHINE_UNKNOWN 0
  4844. #define IMAGE_FILE_MACHINE_I386 0x014c // Intel 386.
  4845. #define IMAGE_FILE_MACHINE_R3000 0x0162 // MIPS little-endian, 0x160 big-endian
  4846. #define IMAGE_FILE_MACHINE_R4000 0x0166 // MIPS little-endian
  4847. #define IMAGE_FILE_MACHINE_R10000 0x0168 // MIPS little-endian
  4848. #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169 // MIPS little-endian WCE v2
  4849. #define IMAGE_FILE_MACHINE_ALPHA 0x0184 // Alpha_AXP
  4850. #define IMAGE_FILE_MACHINE_SH3 0x01a2 // SH3 little-endian
  4851. #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
  4852. #define IMAGE_FILE_MACHINE_SH3E 0x01a4 // SH3E little-endian
  4853. #define IMAGE_FILE_MACHINE_SH4 0x01a6 // SH4 little-endian
  4854. #define IMAGE_FILE_MACHINE_SH5 0x01a8 // SH5
  4855. #define IMAGE_FILE_MACHINE_ARM 0x01c0 // ARM Little-Endian
  4856. #define IMAGE_FILE_MACHINE_THUMB 0x01c2
  4857. #define IMAGE_FILE_MACHINE_AM33 0x01d3
  4858. #define IMAGE_FILE_MACHINE_POWERPC 0x01F0 // IBM PowerPC Little-Endian
  4859. #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
  4860. #define IMAGE_FILE_MACHINE_IA64 0x0200 // Intel 64
  4861. #define IMAGE_FILE_MACHINE_MIPS16 0x0266 // MIPS
  4862. #define IMAGE_FILE_MACHINE_ALPHA64 0x0284 // ALPHA64
  4863. #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366 // MIPS
  4864. #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466 // MIPS
  4865. #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
  4866. #define IMAGE_FILE_MACHINE_TRICORE 0x0520 // Infineon
  4867. #define IMAGE_FILE_MACHINE_CEF 0x0CEF
  4868. #define IMAGE_FILE_MACHINE_EBC 0x0EBC // EFI Byte Code
  4869. #define IMAGE_FILE_MACHINE_AMD64 0x8664 // AMD64 (K8)
  4870. #define IMAGE_FILE_MACHINE_M32R 0x9041 // M32R little-endian
  4871. #define IMAGE_FILE_MACHINE_CEE 0xC0EE
  4872. //
  4873. // Directory format.
  4874. //
  4875. typedef struct _IMAGE_DATA_DIRECTORY {
  4876. DWORD VirtualAddress;
  4877. DWORD Size;
  4878. } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
  4879. #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
  4880. //
  4881. // Optional header format.
  4882. //
  4883. typedef struct _IMAGE_OPTIONAL_HEADER {
  4884. //
  4885. // Standard fields.
  4886. //
  4887. WORD Magic;
  4888. BYTE MajorLinkerVersion;
  4889. BYTE MinorLinkerVersion;
  4890. DWORD SizeOfCode;
  4891. DWORD SizeOfInitializedData;
  4892. DWORD SizeOfUninitializedData;
  4893. DWORD AddressOfEntryPoint;
  4894. DWORD BaseOfCode;
  4895. DWORD BaseOfData;
  4896. //
  4897. // NT additional fields.
  4898. //
  4899. DWORD ImageBase;
  4900. DWORD SectionAlignment;
  4901. DWORD FileAlignment;
  4902. WORD MajorOperatingSystemVersion;
  4903. WORD MinorOperatingSystemVersion;
  4904. WORD MajorImageVersion;
  4905. WORD MinorImageVersion;
  4906. WORD MajorSubsystemVersion;
  4907. WORD MinorSubsystemVersion;
  4908. DWORD Win32VersionValue;
  4909. DWORD SizeOfImage;
  4910. DWORD SizeOfHeaders;
  4911. DWORD CheckSum;
  4912. WORD Subsystem;
  4913. WORD DllCharacteristics;
  4914. DWORD SizeOfStackReserve;
  4915. DWORD SizeOfStackCommit;
  4916. DWORD SizeOfHeapReserve;
  4917. DWORD SizeOfHeapCommit;
  4918. DWORD LoaderFlags;
  4919. DWORD NumberOfRvaAndSizes;
  4920. IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
  4921. } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
  4922. typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
  4923. WORD Magic;
  4924. BYTE MajorLinkerVersion;
  4925. BYTE MinorLinkerVersion;
  4926. DWORD SizeOfCode;
  4927. DWORD SizeOfInitializedData;
  4928. DWORD SizeOfUninitializedData;
  4929. DWORD AddressOfEntryPoint;
  4930. DWORD BaseOfCode;
  4931. DWORD BaseOfData;
  4932. DWORD BaseOfBss;
  4933. DWORD GprMask;
  4934. DWORD CprMask[4];
  4935. DWORD GpValue;
  4936. } IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER;
  4937. typedef struct _IMAGE_OPTIONAL_HEADER64 {
  4938. WORD Magic;
  4939. BYTE MajorLinkerVersion;
  4940. BYTE MinorLinkerVersion;
  4941. DWORD SizeOfCode;
  4942. DWORD SizeOfInitializedData;
  4943. DWORD SizeOfUninitializedData;
  4944. DWORD AddressOfEntryPoint;
  4945. DWORD BaseOfCode;
  4946. ULONGLONG ImageBase;
  4947. DWORD SectionAlignment;
  4948. DWORD FileAlignment;
  4949. WORD MajorOperatingSystemVersion;
  4950. WORD MinorOperatingSystemVersion;
  4951. WORD MajorImageVersion;
  4952. WORD MinorImageVersion;
  4953. WORD MajorSubsystemVersion;
  4954. WORD MinorSubsystemVersion;
  4955. DWORD Win32VersionValue;
  4956. DWORD SizeOfImage;
  4957. DWORD SizeOfHeaders;
  4958. DWORD CheckSum;
  4959. WORD Subsystem;
  4960. WORD DllCharacteristics;
  4961. ULONGLONG SizeOfStackReserve;
  4962. ULONGLONG SizeOfStackCommit;
  4963. ULONGLONG SizeOfHeapReserve;
  4964. ULONGLONG SizeOfHeapCommit;
  4965. DWORD LoaderFlags;
  4966. DWORD NumberOfRvaAndSizes;
  4967. IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
  4968. } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
  4969. #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
  4970. #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
  4971. #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
  4972. #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
  4973. #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
  4974. #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
  4975. #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
  4976. #ifdef _WIN64
  4977. typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
  4978. typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
  4979. #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
  4980. #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
  4981. #else
  4982. typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
  4983. typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
  4984. #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
  4985. #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
  4986. #endif
  4987. typedef struct _IMAGE_NT_HEADERS64 {
  4988. DWORD Signature;
  4989. IMAGE_FILE_HEADER FileHeader;
  4990. IMAGE_OPTIONAL_HEADER64 OptionalHeader;
  4991. } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
  4992. typedef struct _IMAGE_NT_HEADERS {
  4993. DWORD Signature;
  4994. IMAGE_FILE_HEADER FileHeader;
  4995. IMAGE_OPTIONAL_HEADER32 OptionalHeader;
  4996. } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
  4997. typedef struct _IMAGE_ROM_HEADERS {
  4998. IMAGE_FILE_HEADER FileHeader;
  4999. IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
  5000. } IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS;
  5001. #ifdef _WIN64
  5002. typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
  5003. typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
  5004. #else
  5005. typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
  5006. typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
  5007. #endif
  5008. // IMAGE_FIRST_SECTION doesn't need 32/64 versions since the file header is the same either way.
  5009. #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \
  5010. ((ULONG_PTR)ntheader + \
  5011. FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) + \
  5012. ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \
  5013. ))
  5014. // Subsystem Values
  5015. #define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem.
  5016. #define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem.
  5017. #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem.
  5018. #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem.
  5019. #define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem.
  5020. #define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image runs in the Posix character subsystem.
  5021. #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 // image is a native Win9x driver.
  5022. #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 // Image runs in the Windows CE subsystem.
  5023. #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 //
  5024. #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 //
  5025. #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 //
  5026. #define IMAGE_SUBSYSTEM_EFI_ROM 13
  5027. #define IMAGE_SUBSYSTEM_XBOX 14
  5028. // DllCharacteristics Entries
  5029. // IMAGE_LIBRARY_PROCESS_INIT 0x0001 // Reserved.
  5030. // IMAGE_LIBRARY_PROCESS_TERM 0x0002 // Reserved.
  5031. // IMAGE_LIBRARY_THREAD_INIT 0x0004 // Reserved.
  5032. // IMAGE_LIBRARY_THREAD_TERM 0x0008 // Reserved.
  5033. #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800 // Do not bind this image.
  5034. // 0x1000 // Reserved.
  5035. #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000 // Driver uses WDM model
  5036. // 0x4000 // Reserved.
  5037. #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
  5038. // Directory Entries
  5039. #define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory
  5040. #define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory
  5041. #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory
  5042. #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory
  5043. #define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory
  5044. #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table
  5045. #define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory
  5046. // IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // (X86 usage)
  5047. #define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7 // Architecture Specific Data
  5048. #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // RVA of GP
  5049. #define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory
  5050. #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory
  5051. #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers
  5052. #define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table
  5053. #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13 // Delay Load Import Descriptors
  5054. #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14 // COM Runtime descriptor
  5055. //
  5056. // Non-COFF Object file header
  5057. //
  5058. typedef struct ANON_OBJECT_HEADER {
  5059. WORD Sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN
  5060. WORD Sig2; // Must be 0xffff
  5061. WORD Version; // >= 1 (implies the CLSID field is present)
  5062. WORD Machine;
  5063. DWORD TimeDateStamp;
  5064. CLSID ClassID; // Used to invoke CoCreateInstance
  5065. DWORD SizeOfData; // Size of data that follows the header
  5066. } ANON_OBJECT_HEADER;
  5067. //
  5068. // Section header format.
  5069. //
  5070. #define IMAGE_SIZEOF_SHORT_NAME 8
  5071. typedef struct _IMAGE_SECTION_HEADER {
  5072. BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
  5073. union {
  5074. DWORD PhysicalAddress;
  5075. DWORD VirtualSize;
  5076. } Misc;
  5077. DWORD VirtualAddress;
  5078. DWORD SizeOfRawData;
  5079. DWORD PointerToRawData;
  5080. DWORD PointerToRelocations;
  5081. DWORD PointerToLinenumbers;
  5082. WORD NumberOfRelocations;
  5083. WORD NumberOfLinenumbers;
  5084. DWORD Characteristics;
  5085. } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
  5086. #define IMAGE_SIZEOF_SECTION_HEADER 40
  5087. //
  5088. // Section characteristics.
  5089. //
  5090. // IMAGE_SCN_TYPE_REG 0x00000000 // Reserved.
  5091. // IMAGE_SCN_TYPE_DSECT 0x00000001 // Reserved.
  5092. // IMAGE_SCN_TYPE_NOLOAD 0x00000002 // Reserved.
  5093. // IMAGE_SCN_TYPE_GROUP 0x00000004 // Reserved.
  5094. #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved.
  5095. // IMAGE_SCN_TYPE_COPY 0x00000010 // Reserved.
  5096. #define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code.
  5097. #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data.
  5098. #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data.
  5099. #define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved.
  5100. #define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information.
  5101. // IMAGE_SCN_TYPE_OVER 0x00000400 // Reserved.
  5102. #define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image.
  5103. #define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat.
  5104. // 0x00002000 // Reserved.
  5105. // IMAGE_SCN_MEM_PROTECTED - Obsolete 0x00004000
  5106. #define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000 // Reset speculative exceptions handling bits in the TLB entries for this section.
  5107. #define IMAGE_SCN_GPREL 0x00008000 // Section content can be accessed relative to GP
  5108. #define IMAGE_SCN_MEM_FARDATA 0x00008000
  5109. // IMAGE_SCN_MEM_SYSHEAP - Obsolete 0x00010000
  5110. #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
  5111. #define IMAGE_SCN_MEM_16BIT 0x00020000
  5112. #define IMAGE_SCN_MEM_LOCKED 0x00040000
  5113. #define IMAGE_SCN_MEM_PRELOAD 0x00080000
  5114. #define IMAGE_SCN_ALIGN_1BYTES 0x00100000 //
  5115. #define IMAGE_SCN_ALIGN_2BYTES 0x00200000 //
  5116. #define IMAGE_SCN_ALIGN_4BYTES 0x00300000 //
  5117. #define IMAGE_SCN_ALIGN_8BYTES 0x00400000 //
  5118. #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified.
  5119. #define IMAGE_SCN_ALIGN_32BYTES 0x00600000 //
  5120. #define IMAGE_SCN_ALIGN_64BYTES 0x00700000 //
  5121. #define IMAGE_SCN_ALIGN_128BYTES 0x00800000 //
  5122. #define IMAGE_SCN_ALIGN_256BYTES 0x00900000 //
  5123. #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000 //
  5124. #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000 //
  5125. #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000 //
  5126. #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000 //
  5127. #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000 //
  5128. // Unused 0x00F00000
  5129. #define IMAGE_SCN_ALIGN_MASK 0x00F00000
  5130. #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 // Section contains extended relocations.
  5131. #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded.
  5132. #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable.
  5133. #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable.
  5134. #define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable.
  5135. #define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable.
  5136. #define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable.
  5137. #define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable.
  5138. //
  5139. // TLS Chaacteristic Flags
  5140. //
  5141. #define IMAGE_SCN_SCALE_INDEX 0x00000001 // Tls index is scaled
  5142. #ifndef _MAC
  5143. #include "pshpack2.h" // Symbols, relocs, and linenumbers are 2 byte packed
  5144. #endif
  5145. //
  5146. // Symbol format.
  5147. //
  5148. typedef struct _IMAGE_SYMBOL {
  5149. union {
  5150. BYTE ShortName[8];
  5151. struct {
  5152. DWORD Short; // if 0, use LongName
  5153. DWORD Long; // offset into string table
  5154. } Name;
  5155. DWORD LongName[2]; // PBYTE [2]
  5156. } N;
  5157. DWORD Value;
  5158. SHORT SectionNumber;
  5159. WORD Type;
  5160. BYTE StorageClass;
  5161. BYTE NumberOfAuxSymbols;
  5162. } IMAGE_SYMBOL;
  5163. typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
  5164. #define IMAGE_SIZEOF_SYMBOL 18
  5165. //
  5166. // Section values.
  5167. //
  5168. // Symbols have a section number of the section in which they are
  5169. // defined. Otherwise, section numbers have the following meanings:
  5170. //
  5171. #define IMAGE_SYM_UNDEFINED (SHORT)0 // Symbol is undefined or is common.
  5172. #define IMAGE_SYM_ABSOLUTE (SHORT)-1 // Symbol is an absolute value.
  5173. #define IMAGE_SYM_DEBUG (SHORT)-2 // Symbol is a special debug item.
  5174. #define IMAGE_SYM_SECTION_MAX 0xFEFF // Values 0xFF00-0xFFFF are special
  5175. //
  5176. // Type (fundamental) values.
  5177. //
  5178. #define IMAGE_SYM_TYPE_NULL 0x0000 // no type.
  5179. #define IMAGE_SYM_TYPE_VOID 0x0001 //
  5180. #define IMAGE_SYM_TYPE_CHAR 0x0002 // type character.
  5181. #define IMAGE_SYM_TYPE_SHORT 0x0003 // type short integer.
  5182. #define IMAGE_SYM_TYPE_INT 0x0004 //
  5183. #define IMAGE_SYM_TYPE_LONG 0x0005 //
  5184. #define IMAGE_SYM_TYPE_FLOAT 0x0006 //
  5185. #define IMAGE_SYM_TYPE_DOUBLE 0x0007 //
  5186. #define IMAGE_SYM_TYPE_STRUCT 0x0008 //
  5187. #define IMAGE_SYM_TYPE_UNION 0x0009 //
  5188. #define IMAGE_SYM_TYPE_ENUM 0x000A // enumeration.
  5189. #define IMAGE_SYM_TYPE_MOE 0x000B // member of enumeration.
  5190. #define IMAGE_SYM_TYPE_BYTE 0x000C //
  5191. #define IMAGE_SYM_TYPE_WORD 0x000D //
  5192. #define IMAGE_SYM_TYPE_UINT 0x000E //
  5193. #define IMAGE_SYM_TYPE_DWORD 0x000F //
  5194. #define IMAGE_SYM_TYPE_PCODE 0x8000 //
  5195. //
  5196. // Type (derived) values.
  5197. //
  5198. #define IMAGE_SYM_DTYPE_NULL 0 // no derived type.
  5199. #define IMAGE_SYM_DTYPE_POINTER 1 // pointer.
  5200. #define IMAGE_SYM_DTYPE_FUNCTION 2 // function.
  5201. #define IMAGE_SYM_DTYPE_ARRAY 3 // array.
  5202. //
  5203. // Storage classes.
  5204. //
  5205. #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
  5206. #define IMAGE_SYM_CLASS_NULL 0x0000
  5207. #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
  5208. #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
  5209. #define IMAGE_SYM_CLASS_STATIC 0x0003
  5210. #define IMAGE_SYM_CLASS_REGISTER 0x0004
  5211. #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
  5212. #define IMAGE_SYM_CLASS_LABEL 0x0006
  5213. #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
  5214. #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
  5215. #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
  5216. #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
  5217. #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
  5218. #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
  5219. #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
  5220. #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
  5221. #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
  5222. #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
  5223. #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
  5224. #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
  5225. #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044 //
  5226. #define IMAGE_SYM_CLASS_BLOCK 0x0064
  5227. #define IMAGE_SYM_CLASS_FUNCTION 0x0065
  5228. #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
  5229. #define IMAGE_SYM_CLASS_FILE 0x0067
  5230. // new
  5231. #define IMAGE_SYM_CLASS_SECTION 0x0068
  5232. #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
  5233. #define IMAGE_SYM_CLASS_CLR_TOKEN 0x006B
  5234. // type packing constants
  5235. #define N_BTMASK 0x000F
  5236. #define N_TMASK 0x0030
  5237. #define N_TMASK1 0x00C0
  5238. #define N_TMASK2 0x00F0
  5239. #define N_BTSHFT 4
  5240. #define N_TSHIFT 2
  5241. // MACROS
  5242. // Basic Type of x
  5243. #define BTYPE(x) ((x) & N_BTMASK)
  5244. // Is x a pointer?
  5245. #ifndef ISPTR
  5246. #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
  5247. #endif
  5248. // Is x a function?
  5249. #ifndef ISFCN
  5250. #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
  5251. #endif
  5252. // Is x an array?
  5253. #ifndef ISARY
  5254. #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
  5255. #endif
  5256. // Is x a structure, union, or enumeration TAG?
  5257. #ifndef ISTAG
  5258. #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
  5259. #endif
  5260. #ifndef INCREF
  5261. #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
  5262. #endif
  5263. #ifndef DECREF
  5264. #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
  5265. #endif
  5266. //
  5267. // Auxiliary entry format.
  5268. //
  5269. typedef union _IMAGE_AUX_SYMBOL {
  5270. struct {
  5271. DWORD TagIndex; // struct, union, or enum tag index
  5272. union {
  5273. struct {
  5274. WORD Linenumber; // declaration line number
  5275. WORD Size; // size of struct, union, or enum
  5276. } LnSz;
  5277. DWORD TotalSize;
  5278. } Misc;
  5279. union {
  5280. struct { // if ISFCN, tag, or .bb
  5281. DWORD PointerToLinenumber;
  5282. DWORD PointerToNextFunction;
  5283. } Function;
  5284. struct { // if ISARY, up to 4 dimen.
  5285. WORD Dimension[4];
  5286. } Array;
  5287. } FcnAry;
  5288. WORD TvIndex; // tv index
  5289. } Sym;
  5290. struct {
  5291. BYTE Name[IMAGE_SIZEOF_SYMBOL];
  5292. } File;
  5293. struct {
  5294. DWORD Length; // section length
  5295. WORD NumberOfRelocations; // number of relocation entries
  5296. WORD NumberOfLinenumbers; // number of line numbers
  5297. DWORD CheckSum; // checksum for communal
  5298. SHORT Number; // section number to associate with
  5299. BYTE Selection; // communal selection type
  5300. } Section;
  5301. } IMAGE_AUX_SYMBOL;
  5302. typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL;
  5303. #define IMAGE_SIZEOF_AUX_SYMBOL 18
  5304. typedef enum IMAGE_AUX_SYMBOL_TYPE {
  5305. IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1,
  5306. } IMAGE_AUX_SYMBOL_TYPE;
  5307. #include <pshpack2.h>
  5308. typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF {
  5309. BYTE bAuxType; // IMAGE_AUX_SYMBOL_TYPE
  5310. BYTE bReserved; // Must be 0
  5311. DWORD SymbolTableIndex;
  5312. BYTE rgbReserved[12]; // Must be 0
  5313. } IMAGE_AUX_SYMBOL_TOKEN_DEF;
  5314. typedef IMAGE_AUX_SYMBOL_TOKEN_DEF UNALIGNED *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
  5315. #include <poppack.h>
  5316. //
  5317. // Communal selection types.
  5318. //
  5319. #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
  5320. #define IMAGE_COMDAT_SELECT_ANY 2
  5321. #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
  5322. #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
  5323. #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
  5324. #define IMAGE_COMDAT_SELECT_LARGEST 6
  5325. #define IMAGE_COMDAT_SELECT_NEWEST 7
  5326. #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
  5327. #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
  5328. #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
  5329. //
  5330. // Relocation format.
  5331. //
  5332. typedef struct _IMAGE_RELOCATION {
  5333. union {
  5334. DWORD VirtualAddress;
  5335. DWORD RelocCount; // Set to the real count when IMAGE_SCN_LNK_NRELOC_OVFL is set
  5336. };
  5337. DWORD SymbolTableIndex;
  5338. WORD Type;
  5339. } IMAGE_RELOCATION;
  5340. typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
  5341. #define IMAGE_SIZEOF_RELOCATION 10
  5342. //
  5343. // I386 relocation types.
  5344. //
  5345. #define IMAGE_REL_I386_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
  5346. #define IMAGE_REL_I386_DIR16 0x0001 // Direct 16-bit reference to the symbols virtual address
  5347. #define IMAGE_REL_I386_REL16 0x0002 // PC-relative 16-bit reference to the symbols virtual address
  5348. #define IMAGE_REL_I386_DIR32 0x0006 // Direct 32-bit reference to the symbols virtual address
  5349. #define IMAGE_REL_I386_DIR32NB 0x0007 // Direct 32-bit reference to the symbols virtual address, base not included
  5350. #define IMAGE_REL_I386_SEG12 0x0009 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
  5351. #define IMAGE_REL_I386_SECTION 0x000A
  5352. #define IMAGE_REL_I386_SECREL 0x000B
  5353. #define IMAGE_REL_I386_TOKEN 0x000C // clr token
  5354. #define IMAGE_REL_I386_SECREL7 0x000D // 7 bit offset from base of section containing target
  5355. #define IMAGE_REL_I386_REL32 0x0014 // PC-relative 32-bit reference to the symbols virtual address
  5356. //
  5357. // MIPS relocation types.
  5358. //
  5359. #define IMAGE_REL_MIPS_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
  5360. #define IMAGE_REL_MIPS_REFHALF 0x0001
  5361. #define IMAGE_REL_MIPS_REFWORD 0x0002
  5362. #define IMAGE_REL_MIPS_JMPADDR 0x0003
  5363. #define IMAGE_REL_MIPS_REFHI 0x0004
  5364. #define IMAGE_REL_MIPS_REFLO 0x0005
  5365. #define IMAGE_REL_MIPS_GPREL 0x0006
  5366. #define IMAGE_REL_MIPS_LITERAL 0x0007
  5367. #define IMAGE_REL_MIPS_SECTION 0x000A
  5368. #define IMAGE_REL_MIPS_SECREL 0x000B
  5369. #define IMAGE_REL_MIPS_SECRELLO 0x000C // Low 16-bit section relative referemce (used for >32k TLS)
  5370. #define IMAGE_REL_MIPS_SECRELHI 0x000D // High 16-bit section relative reference (used for >32k TLS)
  5371. #define IMAGE_REL_MIPS_TOKEN 0x000E // clr token
  5372. #define IMAGE_REL_MIPS_JMPADDR16 0x0010
  5373. #define IMAGE_REL_MIPS_REFWORDNB 0x0022
  5374. #define IMAGE_REL_MIPS_PAIR 0x0025
  5375. //
  5376. // Alpha Relocation types.
  5377. //
  5378. #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
  5379. #define IMAGE_REL_ALPHA_REFLONG 0x0001
  5380. #define IMAGE_REL_ALPHA_REFQUAD 0x0002
  5381. #define IMAGE_REL_ALPHA_GPREL32 0x0003
  5382. #define IMAGE_REL_ALPHA_LITERAL 0x0004
  5383. #define IMAGE_REL_ALPHA_LITUSE 0x0005
  5384. #define IMAGE_REL_ALPHA_GPDISP 0x0006
  5385. #define IMAGE_REL_ALPHA_BRADDR 0x0007
  5386. #define IMAGE_REL_ALPHA_HINT 0x0008
  5387. #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
  5388. #define IMAGE_REL_ALPHA_REFHI 0x000A
  5389. #define IMAGE_REL_ALPHA_REFLO 0x000B
  5390. #define IMAGE_REL_ALPHA_PAIR 0x000C
  5391. #define IMAGE_REL_ALPHA_MATCH 0x000D
  5392. #define IMAGE_REL_ALPHA_SECTION 0x000E
  5393. #define IMAGE_REL_ALPHA_SECREL 0x000F
  5394. #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
  5395. #define IMAGE_REL_ALPHA_SECRELLO 0x0011 // Low 16-bit section relative reference
  5396. #define IMAGE_REL_ALPHA_SECRELHI 0x0012 // High 16-bit section relative reference
  5397. #define IMAGE_REL_ALPHA_REFQ3 0x0013 // High 16 bits of 48 bit reference
  5398. #define IMAGE_REL_ALPHA_REFQ2 0x0014 // Middle 16 bits of 48 bit reference
  5399. #define IMAGE_REL_ALPHA_REFQ1 0x0015 // Low 16 bits of 48 bit reference
  5400. #define IMAGE_REL_ALPHA_GPRELLO 0x0016 // Low 16-bit GP relative reference
  5401. #define IMAGE_REL_ALPHA_GPRELHI 0x0017 // High 16-bit GP relative reference
  5402. //
  5403. // IBM PowerPC relocation types.
  5404. //
  5405. #define IMAGE_REL_PPC_ABSOLUTE 0x0000 // NOP
  5406. #define IMAGE_REL_PPC_ADDR64 0x0001 // 64-bit address
  5407. #define IMAGE_REL_PPC_ADDR32 0x0002 // 32-bit address
  5408. #define IMAGE_REL_PPC_ADDR24 0x0003 // 26-bit address, shifted left 2 (branch absolute)
  5409. #define IMAGE_REL_PPC_ADDR16 0x0004 // 16-bit address
  5410. #define IMAGE_REL_PPC_ADDR14 0x0005 // 16-bit address, shifted left 2 (load doubleword)
  5411. #define IMAGE_REL_PPC_REL24 0x0006 // 26-bit PC-relative offset, shifted left 2 (branch relative)
  5412. #define IMAGE_REL_PPC_REL14 0x0007 // 16-bit PC-relative offset, shifted left 2 (br cond relative)
  5413. #define IMAGE_REL_PPC_TOCREL16 0x0008 // 16-bit offset from TOC base
  5414. #define IMAGE_REL_PPC_TOCREL14 0x0009 // 16-bit offset from TOC base, shifted left 2 (load doubleword)
  5415. #define IMAGE_REL_PPC_ADDR32NB 0x000A // 32-bit addr w/o image base
  5416. #define IMAGE_REL_PPC_SECREL 0x000B // va of containing section (as in an image sectionhdr)
  5417. #define IMAGE_REL_PPC_SECTION 0x000C // sectionheader number
  5418. #define IMAGE_REL_PPC_IFGLUE 0x000D // substitute TOC restore instruction iff symbol is glue code
  5419. #define IMAGE_REL_PPC_IMGLUE 0x000E // symbol is glue code; virtual address is TOC restore instruction
  5420. #define IMAGE_REL_PPC_SECREL16 0x000F // va of containing section (limited to 16 bits)
  5421. #define IMAGE_REL_PPC_REFHI 0x0010
  5422. #define IMAGE_REL_PPC_REFLO 0x0011
  5423. #define IMAGE_REL_PPC_PAIR 0x0012
  5424. #define IMAGE_REL_PPC_SECRELLO 0x0013 // Low 16-bit section relative reference (used for >32k TLS)
  5425. #define IMAGE_REL_PPC_SECRELHI 0x0014 // High 16-bit section relative reference (used for >32k TLS)
  5426. #define IMAGE_REL_PPC_GPREL 0x0015
  5427. #define IMAGE_REL_PPC_TOKEN 0x0016 // clr token
  5428. #define IMAGE_REL_PPC_TYPEMASK 0x00FF // mask to isolate above values in IMAGE_RELOCATION.Type
  5429. // Flag bits in IMAGE_RELOCATION.TYPE
  5430. #define IMAGE_REL_PPC_NEG 0x0100 // subtract reloc value rather than adding it
  5431. #define IMAGE_REL_PPC_BRTAKEN 0x0200 // fix branch prediction bit to predict branch taken
  5432. #define IMAGE_REL_PPC_BRNTAKEN 0x0400 // fix branch prediction bit to predict branch not taken
  5433. #define IMAGE_REL_PPC_TOCDEFN 0x0800 // toc slot defined in file (or, data in toc)
  5434. //
  5435. // Hitachi SH3 relocation types.
  5436. //
  5437. #define IMAGE_REL_SH3_ABSOLUTE 0x0000 // No relocation
  5438. #define IMAGE_REL_SH3_DIRECT16 0x0001 // 16 bit direct
  5439. #define IMAGE_REL_SH3_DIRECT32 0x0002 // 32 bit direct
  5440. #define IMAGE_REL_SH3_DIRECT8 0x0003 // 8 bit direct, -128..255
  5441. #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004 // 8 bit direct .W (0 ext.)
  5442. #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005 // 8 bit direct .L (0 ext.)
  5443. #define IMAGE_REL_SH3_DIRECT4 0x0006 // 4 bit direct (0 ext.)
  5444. #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007 // 4 bit direct .W (0 ext.)
  5445. #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008 // 4 bit direct .L (0 ext.)
  5446. #define IMAGE_REL_SH3_PCREL8_WORD 0x0009 // 8 bit PC relative .W
  5447. #define IMAGE_REL_SH3_PCREL8_LONG 0x000A // 8 bit PC relative .L
  5448. #define IMAGE_REL_SH3_PCREL12_WORD 0x000B // 12 LSB PC relative .W
  5449. #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C // Start of EXE section
  5450. #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D // Size of EXE section
  5451. #define IMAGE_REL_SH3_SECTION 0x000E // Section table index
  5452. #define IMAGE_REL_SH3_SECREL 0x000F // Offset within section
  5453. #define IMAGE_REL_SH3_DIRECT32_NB 0x0010 // 32 bit direct not based
  5454. #define IMAGE_REL_SH3_GPREL4_LONG 0x0011 // GP-relative addressing
  5455. #define IMAGE_REL_SH3_TOKEN 0x0012 // clr token
  5456. #define IMAGE_REL_ARM_ABSOLUTE 0x0000 // No relocation required
  5457. #define IMAGE_REL_ARM_ADDR32 0x0001 // 32 bit address
  5458. #define IMAGE_REL_ARM_ADDR32NB 0x0002 // 32 bit address w/o image base
  5459. #define IMAGE_REL_ARM_BRANCH24 0x0003 // 24 bit offset << 2 & sign ext.
  5460. #define IMAGE_REL_ARM_BRANCH11 0x0004 // Thumb: 2 11 bit offsets
  5461. #define IMAGE_REL_ARM_TOKEN 0x0005 // clr token
  5462. #define IMAGE_REL_ARM_GPREL12 0x0006 // GP-relative addressing (ARM)
  5463. #define IMAGE_REL_ARM_GPREL7 0x0007 // GP-relative addressing (Thumb)
  5464. #define IMAGE_REL_ARM_BLX24 0x0008
  5465. #define IMAGE_REL_ARM_BLX11 0x0009
  5466. #define IMAGE_REL_ARM_SECTION 0x000E // Section table index
  5467. #define IMAGE_REL_ARM_SECREL 0x000F // Offset within section
  5468. #define IMAGE_REL_AM_ABSOLUTE 0x0000
  5469. #define IMAGE_REL_AM_ADDR32 0x0001
  5470. #define IMAGE_REL_AM_ADDR32NB 0x0002
  5471. #define IMAGE_REL_AM_CALL32 0x0003
  5472. #define IMAGE_REL_AM_FUNCINFO 0x0004
  5473. #define IMAGE_REL_AM_REL32_1 0x0005
  5474. #define IMAGE_REL_AM_REL32_2 0x0006
  5475. #define IMAGE_REL_AM_SECREL 0x0007
  5476. #define IMAGE_REL_AM_SECTION 0x0008
  5477. #define IMAGE_REL_AM_TOKEN 0x0009
  5478. //
  5479. // X86-64 relocations
  5480. //
  5481. #define IMAGE_REL_AMD64_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
  5482. #define IMAGE_REL_AMD64_ADDR64 0x0001 // 64-bit address (VA).
  5483. #define IMAGE_REL_AMD64_ADDR32 0x0002 // 32-bit address (VA).
  5484. #define IMAGE_REL_AMD64_ADDR32NB 0x0003 // 32-bit address w/o image base (RVA).
  5485. #define IMAGE_REL_AMD64_REL32 0x0004 // 32-bit relative address from byte following reloc
  5486. #define IMAGE_REL_AMD64_REL32_1 0x0005 // 32-bit relative address from byte distance 1 from reloc
  5487. #define IMAGE_REL_AMD64_REL32_2 0x0006 // 32-bit relative address from byte distance 2 from reloc
  5488. #define IMAGE_REL_AMD64_REL32_3 0x0007 // 32-bit relative address from byte distance 3 from reloc
  5489. #define IMAGE_REL_AMD64_REL32_4 0x0008 // 32-bit relative address from byte distance 4 from reloc
  5490. #define IMAGE_REL_AMD64_REL32_5 0x0009 // 32-bit relative address from byte distance 5 from reloc
  5491. #define IMAGE_REL_AMD64_SECTION 0x000A // Section index
  5492. #define IMAGE_REL_AMD64_SECREL 0x000B // 32 bit offset from base of section containing target
  5493. #define IMAGE_REL_AMD64_SECREL7 0x000C // 7 bit unsigned offset from base of section containing target
  5494. #define IMAGE_REL_AMD64_TOKEN 0x000D // 32 bit metadata token
  5495. //
  5496. // IA64 relocation types.
  5497. //
  5498. #define IMAGE_REL_IA64_ABSOLUTE 0x0000
  5499. #define IMAGE_REL_IA64_IMM14 0x0001
  5500. #define IMAGE_REL_IA64_IMM22 0x0002
  5501. #define IMAGE_REL_IA64_IMM64 0x0003
  5502. #define IMAGE_REL_IA64_DIR32 0x0004
  5503. #define IMAGE_REL_IA64_DIR64 0x0005
  5504. #define IMAGE_REL_IA64_PCREL21B 0x0006
  5505. #define IMAGE_REL_IA64_PCREL21M 0x0007
  5506. #define IMAGE_REL_IA64_PCREL21F 0x0008
  5507. #define IMAGE_REL_IA64_GPREL22 0x0009
  5508. #define IMAGE_REL_IA64_LTOFF22 0x000A
  5509. #define IMAGE_REL_IA64_SECTION 0x000B
  5510. #define IMAGE_REL_IA64_SECREL22 0x000C
  5511. #define IMAGE_REL_IA64_SECREL64I 0x000D
  5512. #define IMAGE_REL_IA64_SECREL32 0x000E
  5513. //
  5514. #define IMAGE_REL_IA64_DIR32NB 0x0010
  5515. #define IMAGE_REL_IA64_SREL14 0x0011
  5516. #define IMAGE_REL_IA64_SREL22 0x0012
  5517. #define IMAGE_REL_IA64_SREL32 0x0013
  5518. #define IMAGE_REL_IA64_UREL32 0x0014
  5519. #define IMAGE_REL_IA64_PCREL60X 0x0015 // This is always a BRL and never converted
  5520. #define IMAGE_REL_IA64_PCREL60B 0x0016 // If possible, convert to MBB bundle with NOP.B in slot 1
  5521. #define IMAGE_REL_IA64_PCREL60F 0x0017 // If possible, convert to MFB bundle with NOP.F in slot 1
  5522. #define IMAGE_REL_IA64_PCREL60I 0x0018 // If possible, convert to MIB bundle with NOP.I in slot 1
  5523. #define IMAGE_REL_IA64_PCREL60M 0x0019 // If possible, convert to MMB bundle with NOP.M in slot 1
  5524. #define IMAGE_REL_IA64_IMMGPREL64 0x001A
  5525. #define IMAGE_REL_IA64_TOKEN 0x001B // clr token
  5526. #define IMAGE_REL_IA64_GPREL32 0x001C
  5527. #define IMAGE_REL_IA64_ADDEND 0x001F
  5528. //
  5529. // CEF relocation types.
  5530. //
  5531. #define IMAGE_REL_CEF_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
  5532. #define IMAGE_REL_CEF_ADDR32 0x0001 // 32-bit address (VA).
  5533. #define IMAGE_REL_CEF_ADDR64 0x0002 // 64-bit address (VA).
  5534. #define IMAGE_REL_CEF_ADDR32NB 0x0003 // 32-bit address w/o image base (RVA).
  5535. #define IMAGE_REL_CEF_SECTION 0x0004 // Section index
  5536. #define IMAGE_REL_CEF_SECREL 0x0005 // 32 bit offset from base of section containing target
  5537. #define IMAGE_REL_CEF_TOKEN 0x0006 // 32 bit metadata token
  5538. //
  5539. // clr relocation types.
  5540. //
  5541. #define IMAGE_REL_CEE_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
  5542. #define IMAGE_REL_CEE_ADDR32 0x0001 // 32-bit address (VA).
  5543. #define IMAGE_REL_CEE_ADDR64 0x0002 // 64-bit address (VA).
  5544. #define IMAGE_REL_CEE_ADDR32NB 0x0003 // 32-bit address w/o image base (RVA).
  5545. #define IMAGE_REL_CEE_SECTION 0x0004 // Section index
  5546. #define IMAGE_REL_CEE_SECREL 0x0005 // 32 bit offset from base of section containing target
  5547. #define IMAGE_REL_CEE_TOKEN 0x0006 // 32 bit metadata token
  5548. #define IMAGE_REL_M32R_ABSOLUTE 0x0000 // No relocation required
  5549. #define IMAGE_REL_M32R_ADDR32 0x0001 // 32 bit address
  5550. #define IMAGE_REL_M32R_ADDR32NB 0x0002 // 32 bit address w/o image base
  5551. #define IMAGE_REL_M32R_ADDR24 0x0003 // 24 bit address
  5552. #define IMAGE_REL_M32R_GPREL16 0x0004 // GP relative addressing
  5553. #define IMAGE_REL_M32R_PCREL24 0x0005 // 24 bit offset << 2 & sign ext.
  5554. #define IMAGE_REL_M32R_PCREL16 0x0006 // 16 bit offset << 2 & sign ext.
  5555. #define IMAGE_REL_M32R_PCREL8 0x0007 // 8 bit offset << 2 & sign ext.
  5556. #define IMAGE_REL_M32R_REFHALF 0x0008 // 16 MSBs
  5557. #define IMAGE_REL_M32R_REFHI 0x0009 // 16 MSBs; adj for LSB sign ext.
  5558. #define IMAGE_REL_M32R_REFLO 0x000A // 16 LSBs
  5559. #define IMAGE_REL_M32R_PAIR 0x000B // Link HI and LO
  5560. #define IMAGE_REL_M32R_SECTION 0x000C // Section table index
  5561. #define IMAGE_REL_M32R_SECREL32 0x000D // 32 bit section relative reference
  5562. #define IMAGE_REL_M32R_TOKEN 0x000E // clr token
  5563. #define EXT_IMM64(Value, Address, Size, InstPos, ValPos) /* Intel-IA64-Filler */ \
  5564. Value |= (((ULONGLONG)((*(Address) >> InstPos) & (((ULONGLONG)1 << Size) - 1))) << ValPos) // Intel-IA64-Filler
  5565. #define INS_IMM64(Value, Address, Size, InstPos, ValPos) /* Intel-IA64-Filler */\
  5566. *(PDWORD)Address = (*(PDWORD)Address & ~(((1 << Size) - 1) << InstPos)) | /* Intel-IA64-Filler */\
  5567. ((DWORD)((((ULONGLONG)Value >> ValPos) & (((ULONGLONG)1 << Size) - 1))) << InstPos) // Intel-IA64-Filler
  5568. #define EMARCH_ENC_I17_IMM7B_INST_WORD_X 3 // Intel-IA64-Filler
  5569. #define EMARCH_ENC_I17_IMM7B_SIZE_X 7 // Intel-IA64-Filler
  5570. #define EMARCH_ENC_I17_IMM7B_INST_WORD_POS_X 4 // Intel-IA64-Filler
  5571. #define EMARCH_ENC_I17_IMM7B_VAL_POS_X 0 // Intel-IA64-Filler
  5572. #define EMARCH_ENC_I17_IMM9D_INST_WORD_X 3 // Intel-IA64-Filler
  5573. #define EMARCH_ENC_I17_IMM9D_SIZE_X 9 // Intel-IA64-Filler
  5574. #define EMARCH_ENC_I17_IMM9D_INST_WORD_POS_X 18 // Intel-IA64-Filler
  5575. #define EMARCH_ENC_I17_IMM9D_VAL_POS_X 7 // Intel-IA64-Filler
  5576. #define EMARCH_ENC_I17_IMM5C_INST_WORD_X 3 // Intel-IA64-Filler
  5577. #define EMARCH_ENC_I17_IMM5C_SIZE_X 5 // Intel-IA64-Filler
  5578. #define EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X 13 // Intel-IA64-Filler
  5579. #define EMARCH_ENC_I17_IMM5C_VAL_POS_X 16 // Intel-IA64-Filler
  5580. #define EMARCH_ENC_I17_IC_INST_WORD_X 3 // Intel-IA64-Filler
  5581. #define EMARCH_ENC_I17_IC_SIZE_X 1 // Intel-IA64-Filler
  5582. #define EMARCH_ENC_I17_IC_INST_WORD_POS_X 12 // Intel-IA64-Filler
  5583. #define EMARCH_ENC_I17_IC_VAL_POS_X 21 // Intel-IA64-Filler
  5584. #define EMARCH_ENC_I17_IMM41a_INST_WORD_X 1 // Intel-IA64-Filler
  5585. #define EMARCH_ENC_I17_IMM41a_SIZE_X 10 // Intel-IA64-Filler
  5586. #define EMARCH_ENC_I17_IMM41a_INST_WORD_POS_X 14 // Intel-IA64-Filler
  5587. #define EMARCH_ENC_I17_IMM41a_VAL_POS_X 22 // Intel-IA64-Filler
  5588. #define EMARCH_ENC_I17_IMM41b_INST_WORD_X 1 // Intel-IA64-Filler
  5589. #define EMARCH_ENC_I17_IMM41b_SIZE_X 8 // Intel-IA64-Filler
  5590. #define EMARCH_ENC_I17_IMM41b_INST_WORD_POS_X 24 // Intel-IA64-Filler
  5591. #define EMARCH_ENC_I17_IMM41b_VAL_POS_X 32 // Intel-IA64-Filler
  5592. #define EMARCH_ENC_I17_IMM41c_INST_WORD_X 2 // Intel-IA64-Filler
  5593. #define EMARCH_ENC_I17_IMM41c_SIZE_X 23 // Intel-IA64-Filler
  5594. #define EMARCH_ENC_I17_IMM41c_INST_WORD_POS_X 0 // Intel-IA64-Filler
  5595. #define EMARCH_ENC_I17_IMM41c_VAL_POS_X 40 // Intel-IA64-Filler
  5596. #define EMARCH_ENC_I17_SIGN_INST_WORD_X 3 // Intel-IA64-Filler
  5597. #define EMARCH_ENC_I17_SIGN_SIZE_X 1 // Intel-IA64-Filler
  5598. #define EMARCH_ENC_I17_SIGN_INST_WORD_POS_X 27 // Intel-IA64-Filler
  5599. #define EMARCH_ENC_I17_SIGN_VAL_POS_X 63 // Intel-IA64-Filler
  5600. //
  5601. // Line number format.
  5602. //
  5603. typedef struct _IMAGE_LINENUMBER {
  5604. union {
  5605. DWORD SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.
  5606. DWORD VirtualAddress; // Virtual address of line number.
  5607. } Type;
  5608. WORD Linenumber; // Line number.
  5609. } IMAGE_LINENUMBER;
  5610. typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER;
  5611. #define IMAGE_SIZEOF_LINENUMBER 6
  5612. #ifndef _MAC
  5613. #include "poppack.h" // Back to 4 byte packing
  5614. #endif
  5615. //
  5616. // Based relocation format.
  5617. //
  5618. typedef struct _IMAGE_BASE_RELOCATION {
  5619. DWORD VirtualAddress;
  5620. DWORD SizeOfBlock;
  5621. // WORD TypeOffset[1];
  5622. } IMAGE_BASE_RELOCATION;
  5623. typedef IMAGE_BASE_RELOCATION UNALIGNED * PIMAGE_BASE_RELOCATION;
  5624. #define IMAGE_SIZEOF_BASE_RELOCATION 8
  5625. //
  5626. // Based relocation types.
  5627. //
  5628. #define IMAGE_REL_BASED_ABSOLUTE 0
  5629. #define IMAGE_REL_BASED_HIGH 1
  5630. #define IMAGE_REL_BASED_LOW 2
  5631. #define IMAGE_REL_BASED_HIGHLOW 3
  5632. #define IMAGE_REL_BASED_HIGHADJ 4
  5633. #define IMAGE_REL_BASED_MIPS_JMPADDR 5
  5634. #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
  5635. #define IMAGE_REL_BASED_IA64_IMM64 9
  5636. #define IMAGE_REL_BASED_DIR64 10
  5637. //
  5638. // Archive format.
  5639. //
  5640. #define IMAGE_ARCHIVE_START_SIZE 8
  5641. #define IMAGE_ARCHIVE_START "!<arch>\n"
  5642. #define IMAGE_ARCHIVE_END "`\n"
  5643. #define IMAGE_ARCHIVE_PAD "\n"
  5644. #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
  5645. #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
  5646. typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
  5647. BYTE Name[16]; // File member name - `/' terminated.
  5648. BYTE Date[12]; // File member date - decimal.
  5649. BYTE UserID[6]; // File member user id - decimal.
  5650. BYTE GroupID[6]; // File member group id - decimal.
  5651. BYTE Mode[8]; // File member mode - octal.
  5652. BYTE Size[10]; // File member size - decimal.
  5653. BYTE EndHeader[2]; // String to end header.
  5654. } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
  5655. #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
  5656. //
  5657. // DLL support.
  5658. //
  5659. //
  5660. // Export Format
  5661. //
  5662. typedef struct _IMAGE_EXPORT_DIRECTORY {
  5663. DWORD Characteristics;
  5664. DWORD TimeDateStamp;
  5665. WORD MajorVersion;
  5666. WORD MinorVersion;
  5667. DWORD Name;
  5668. DWORD Base;
  5669. DWORD NumberOfFunctions;
  5670. DWORD NumberOfNames;
  5671. DWORD AddressOfFunctions; // RVA from base of image
  5672. DWORD AddressOfNames; // RVA from base of image
  5673. DWORD AddressOfNameOrdinals; // RVA from base of image
  5674. } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
  5675. //
  5676. // Import Format
  5677. //
  5678. typedef struct _IMAGE_IMPORT_BY_NAME {
  5679. WORD Hint;
  5680. BYTE Name[1];
  5681. } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
  5682. #include "pshpack8.h" // Use align 8 for the 64-bit IAT.
  5683. typedef struct _IMAGE_THUNK_DATA64 {
  5684. union {
  5685. ULONGLONG ForwarderString; // PBYTE
  5686. ULONGLONG Function; // PDWORD
  5687. ULONGLONG Ordinal;
  5688. ULONGLONG AddressOfData; // PIMAGE_IMPORT_BY_NAME
  5689. } u1;
  5690. } IMAGE_THUNK_DATA64;
  5691. typedef IMAGE_THUNK_DATA64 * PIMAGE_THUNK_DATA64;
  5692. #include "poppack.h" // Back to 4 byte packing
  5693. typedef struct _IMAGE_THUNK_DATA32 {
  5694. union {
  5695. DWORD ForwarderString; // PBYTE
  5696. DWORD Function; // PDWORD
  5697. DWORD Ordinal;
  5698. DWORD AddressOfData; // PIMAGE_IMPORT_BY_NAME
  5699. } u1;
  5700. } IMAGE_THUNK_DATA32;
  5701. typedef IMAGE_THUNK_DATA32 * PIMAGE_THUNK_DATA32;
  5702. #define IMAGE_ORDINAL_FLAG64 0x8000000000000000
  5703. #define IMAGE_ORDINAL_FLAG32 0x80000000
  5704. #define IMAGE_ORDINAL64(Ordinal) (Ordinal & 0xffff)
  5705. #define IMAGE_ORDINAL32(Ordinal) (Ordinal & 0xffff)
  5706. #define IMAGE_SNAP_BY_ORDINAL64(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG64) != 0)
  5707. #define IMAGE_SNAP_BY_ORDINAL32(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG32) != 0)
  5708. //
  5709. // Thread Local Storage
  5710. //
  5711. typedef VOID
  5712. (NTAPI *PIMAGE_TLS_CALLBACK) (
  5713. PVOID DllHandle,
  5714. DWORD Reason,
  5715. PVOID Reserved
  5716. );
  5717. typedef struct _IMAGE_TLS_DIRECTORY64 {
  5718. ULONGLONG StartAddressOfRawData;
  5719. ULONGLONG EndAddressOfRawData;
  5720. ULONGLONG AddressOfIndex; // PDWORD
  5721. ULONGLONG AddressOfCallBacks; // PIMAGE_TLS_CALLBACK *;
  5722. DWORD SizeOfZeroFill;
  5723. DWORD Characteristics;
  5724. } IMAGE_TLS_DIRECTORY64;
  5725. typedef IMAGE_TLS_DIRECTORY64 * PIMAGE_TLS_DIRECTORY64;
  5726. typedef struct _IMAGE_TLS_DIRECTORY32 {
  5727. DWORD StartAddressOfRawData;
  5728. DWORD EndAddressOfRawData;
  5729. DWORD AddressOfIndex; // PDWORD
  5730. DWORD AddressOfCallBacks; // PIMAGE_TLS_CALLBACK *
  5731. DWORD SizeOfZeroFill;
  5732. DWORD Characteristics;
  5733. } IMAGE_TLS_DIRECTORY32;
  5734. typedef IMAGE_TLS_DIRECTORY32 * PIMAGE_TLS_DIRECTORY32;
  5735. #ifdef _WIN64
  5736. #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
  5737. #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
  5738. typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
  5739. typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
  5740. #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
  5741. typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
  5742. typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
  5743. #else
  5744. #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
  5745. #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
  5746. typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
  5747. typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
  5748. #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
  5749. typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
  5750. typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
  5751. #endif
  5752. typedef struct _IMAGE_IMPORT_DESCRIPTOR {
  5753. union {
  5754. DWORD Characteristics; // 0 for terminating null import descriptor
  5755. DWORD OriginalFirstThunk; // RVA to original unbound IAT (PIMAGE_THUNK_DATA)
  5756. };
  5757. DWORD TimeDateStamp; // 0 if not bound,
  5758. // -1 if bound, and real date\time stamp
  5759. // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND)
  5760. // O.W. date/time stamp of DLL bound to (Old BIND)
  5761. DWORD ForwarderChain; // -1 if no forwarders
  5762. DWORD Name;
  5763. DWORD FirstThunk; // RVA to IAT (if bound this IAT has actual addresses)
  5764. } IMAGE_IMPORT_DESCRIPTOR;
  5765. typedef IMAGE_IMPORT_DESCRIPTOR UNALIGNED *PIMAGE_IMPORT_DESCRIPTOR;
  5766. //
  5767. // New format import descriptors pointed to by DataDirectory[ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT ]
  5768. //
  5769. typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR {
  5770. DWORD TimeDateStamp;
  5771. WORD OffsetModuleName;
  5772. WORD NumberOfModuleForwarderRefs;
  5773. // Array of zero or more IMAGE_BOUND_FORWARDER_REF follows
  5774. } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
  5775. typedef struct _IMAGE_BOUND_FORWARDER_REF {
  5776. DWORD TimeDateStamp;
  5777. WORD OffsetModuleName;
  5778. WORD Reserved;
  5779. } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
  5780. //
  5781. // Resource Format.
  5782. //
  5783. //
  5784. // Resource directory consists of two counts, following by a variable length
  5785. // array of directory entries. The first count is the number of entries at
  5786. // beginning of the array that have actual names associated with each entry.
  5787. // The entries are in ascending order, case insensitive strings. The second
  5788. // count is the number of entries that immediately follow the named entries.
  5789. // This second count identifies the number of entries that have 16-bit integer
  5790. // Ids as their name. These entries are also sorted in ascending order.
  5791. //
  5792. // This structure allows fast lookup by either name or number, but for any
  5793. // given resource entry only one form of lookup is supported, not both.
  5794. // This is consistant with the syntax of the .RC file and the .RES file.
  5795. //
  5796. typedef struct _IMAGE_RESOURCE_DIRECTORY {
  5797. DWORD Characteristics;
  5798. DWORD TimeDateStamp;
  5799. WORD MajorVersion;
  5800. WORD MinorVersion;
  5801. WORD NumberOfNamedEntries;
  5802. WORD NumberOfIdEntries;
  5803. // IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
  5804. } IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
  5805. #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
  5806. #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
  5807. //
  5808. // Each directory contains the 32-bit Name of the entry and an offset,
  5809. // relative to the beginning of the resource directory of the data associated
  5810. // with this directory entry. If the name of the entry is an actual text
  5811. // string instead of an integer Id, then the high order bit of the name field
  5812. // is set to one and the low order 31-bits are an offset, relative to the
  5813. // beginning of the resource directory of the string, which is of type
  5814. // IMAGE_RESOURCE_DIRECTORY_STRING. Otherwise the high bit is clear and the
  5815. // low-order 16-bits are the integer Id that identify this resource directory
  5816. // entry. If the directory entry is yet another resource directory (i.e. a
  5817. // subdirectory), then the high order bit of the offset field will be
  5818. // set to indicate this. Otherwise the high bit is clear and the offset
  5819. // field points to a resource data entry.
  5820. //
  5821. typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
  5822. union {
  5823. struct {
  5824. DWORD NameOffset:31;
  5825. DWORD NameIsString:1;
  5826. };
  5827. DWORD Name;
  5828. WORD Id;
  5829. };
  5830. union {
  5831. DWORD OffsetToData;
  5832. struct {
  5833. DWORD OffsetToDirectory:31;
  5834. DWORD DataIsDirectory:1;
  5835. };
  5836. };
  5837. } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
  5838. //
  5839. // For resource directory entries that have actual string names, the Name
  5840. // field of the directory entry points to an object of the following type.
  5841. // All of these string objects are stored together after the last resource
  5842. // directory entry and before the first resource data object. This minimizes
  5843. // the impact of these variable length objects on the alignment of the fixed
  5844. // size directory entry objects.
  5845. //
  5846. typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
  5847. WORD Length;
  5848. CHAR NameString[ 1 ];
  5849. } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;
  5850. typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
  5851. WORD Length;
  5852. WCHAR NameString[ 1 ];
  5853. } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;
  5854. //
  5855. // Each resource data entry describes a leaf node in the resource directory
  5856. // tree. It contains an offset, relative to the beginning of the resource
  5857. // directory of the data for the resource, a size field that gives the number
  5858. // of bytes of data at that offset, a CodePage that should be used when
  5859. // decoding code point values within the resource data. Typically for new
  5860. // applications the code page would be the unicode code page.
  5861. //
  5862. typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
  5863. DWORD OffsetToData;
  5864. DWORD Size;
  5865. DWORD CodePage;
  5866. DWORD Reserved;
  5867. } IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;
  5868. //
  5869. // Load Configuration Directory Entry
  5870. //
  5871. typedef struct {
  5872. DWORD Characteristics;
  5873. DWORD TimeDateStamp;
  5874. WORD MajorVersion;
  5875. WORD MinorVersion;
  5876. DWORD GlobalFlagsClear;
  5877. DWORD GlobalFlagsSet;
  5878. DWORD CriticalSectionDefaultTimeout;
  5879. DWORD DeCommitFreeBlockThreshold;
  5880. DWORD DeCommitTotalFreeThreshold;
  5881. DWORD LockPrefixTable; // VA
  5882. DWORD MaximumAllocationSize;
  5883. DWORD VirtualMemoryThreshold;
  5884. DWORD ProcessHeapFlags;
  5885. DWORD ProcessAffinityMask;
  5886. WORD CSDVersion;
  5887. WORD Reserved1;
  5888. DWORD EditList; // VA
  5889. DWORD Reserved[ 1 ];
  5890. } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
  5891. typedef struct {
  5892. DWORD Characteristics;
  5893. DWORD TimeDateStamp;
  5894. WORD MajorVersion;
  5895. WORD MinorVersion;
  5896. DWORD GlobalFlagsClear;
  5897. DWORD GlobalFlagsSet;
  5898. DWORD CriticalSectionDefaultTimeout;
  5899. ULONGLONG DeCommitFreeBlockThreshold;
  5900. ULONGLONG DeCommitTotalFreeThreshold;
  5901. ULONGLONG LockPrefixTable; // VA
  5902. ULONGLONG MaximumAllocationSize;
  5903. ULONGLONG VirtualMemoryThreshold;
  5904. ULONGLONG ProcessAffinityMask;
  5905. DWORD ProcessHeapFlags;
  5906. WORD CSDVersion;
  5907. WORD Reserved1;
  5908. ULONGLONG EditList; // VA
  5909. DWORD Reserved[ 2 ];
  5910. } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
  5911. #ifdef _WIN64
  5912. typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
  5913. typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
  5914. #else
  5915. typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
  5916. typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
  5917. #endif
  5918. //
  5919. // WIN CE Exception table format
  5920. //
  5921. //
  5922. // Function table entry format. Function table is pointed to by the
  5923. // IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry.
  5924. //
  5925. typedef struct _IMAGE_CE_RUNTIME_FUNCTION_ENTRY {
  5926. DWORD FuncStart;
  5927. DWORD PrologLen : 8;
  5928. DWORD FuncLen : 22;
  5929. DWORD ThirtyTwoBit : 1;
  5930. DWORD ExceptionFlag : 1;
  5931. } IMAGE_CE_RUNTIME_FUNCTION_ENTRY, * PIMAGE_CE_RUNTIME_FUNCTION_ENTRY;
  5932. typedef struct _IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY {
  5933. ULONGLONG BeginAddress;
  5934. ULONGLONG EndAddress;
  5935. ULONGLONG ExceptionHandler;
  5936. ULONGLONG HandlerData;
  5937. ULONGLONG PrologEndAddress;
  5938. } IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY;
  5939. typedef struct _IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY {
  5940. DWORD BeginAddress;
  5941. DWORD EndAddress;
  5942. DWORD ExceptionHandler;
  5943. DWORD HandlerData;
  5944. DWORD PrologEndAddress;
  5945. } IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY;
  5946. typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY {
  5947. DWORD BeginAddress;
  5948. DWORD EndAddress;
  5949. DWORD UnwindInfoAddress;
  5950. } _IMAGE_RUNTIME_FUNCTION_ENTRY, *_PIMAGE_RUNTIME_FUNCTION_ENTRY;
  5951. typedef _IMAGE_RUNTIME_FUNCTION_ENTRY IMAGE_IA64_RUNTIME_FUNCTION_ENTRY;
  5952. typedef _PIMAGE_RUNTIME_FUNCTION_ENTRY PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY;
  5953. #if defined(_AXP64_)
  5954. typedef IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY IMAGE_AXP64_RUNTIME_FUNCTION_ENTRY;
  5955. typedef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY PIMAGE_AXP64_RUNTIME_FUNCTION_ENTRY;
  5956. typedef IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
  5957. typedef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
  5958. #elif defined(_ALPHA_)
  5959. typedef IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
  5960. typedef PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
  5961. #else
  5962. typedef _IMAGE_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
  5963. typedef _PIMAGE_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
  5964. #endif
  5965. //
  5966. // Debug Format
  5967. //
  5968. typedef struct _IMAGE_DEBUG_DIRECTORY {
  5969. DWORD Characteristics;
  5970. DWORD TimeDateStamp;
  5971. WORD MajorVersion;
  5972. WORD MinorVersion;
  5973. DWORD Type;
  5974. DWORD SizeOfData;
  5975. DWORD AddressOfRawData;
  5976. DWORD PointerToRawData;
  5977. } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
  5978. #define IMAGE_DEBUG_TYPE_UNKNOWN 0
  5979. #define IMAGE_DEBUG_TYPE_COFF 1
  5980. #define IMAGE_DEBUG_TYPE_CODEVIEW 2
  5981. #define IMAGE_DEBUG_TYPE_FPO 3
  5982. #define IMAGE_DEBUG_TYPE_MISC 4
  5983. #define IMAGE_DEBUG_TYPE_EXCEPTION 5
  5984. #define IMAGE_DEBUG_TYPE_FIXUP 6
  5985. #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
  5986. #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
  5987. #define IMAGE_DEBUG_TYPE_BORLAND 9
  5988. #define IMAGE_DEBUG_TYPE_RESERVED10 10
  5989. #define IMAGE_DEBUG_TYPE_CLSID 11
  5990. typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
  5991. DWORD NumberOfSymbols;
  5992. DWORD LvaToFirstSymbol;
  5993. DWORD NumberOfLinenumbers;
  5994. DWORD LvaToFirstLinenumber;
  5995. DWORD RvaToFirstByteOfCode;
  5996. DWORD RvaToLastByteOfCode;
  5997. DWORD RvaToFirstByteOfData;
  5998. DWORD RvaToLastByteOfData;
  5999. } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
  6000. #define FRAME_FPO 0
  6001. #define FRAME_TRAP 1
  6002. #define FRAME_TSS 2
  6003. #define FRAME_NONFPO 3
  6004. typedef struct _FPO_DATA {
  6005. DWORD ulOffStart; // offset 1st byte of function code
  6006. DWORD cbProcSize; // # bytes in function
  6007. DWORD cdwLocals; // # bytes in locals/4
  6008. WORD cdwParams; // # bytes in params/4
  6009. WORD cbProlog : 8; // # bytes in prolog
  6010. WORD cbRegs : 3; // # regs saved
  6011. WORD fHasSEH : 1; // TRUE if SEH in func
  6012. WORD fUseBP : 1; // TRUE if EBP has been allocated
  6013. WORD reserved : 1; // reserved for future use
  6014. WORD cbFrame : 2; // frame type
  6015. } FPO_DATA, *PFPO_DATA;
  6016. #define SIZEOF_RFPO_DATA 16
  6017. #define IMAGE_DEBUG_MISC_EXENAME 1
  6018. typedef struct _IMAGE_DEBUG_MISC {
  6019. DWORD DataType; // type of misc data, see defines
  6020. DWORD Length; // total length of record, rounded to four
  6021. // byte multiple.
  6022. BOOLEAN Unicode; // TRUE if data is unicode string
  6023. BYTE Reserved[ 3 ];
  6024. BYTE Data[ 1 ]; // Actual data
  6025. } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
  6026. //
  6027. // Function table extracted from MIPS/ALPHA/IA64 images. Does not contain
  6028. // information needed only for runtime support. Just those fields for
  6029. // each entry needed by a debugger.
  6030. //
  6031. typedef struct _IMAGE_FUNCTION_ENTRY {
  6032. DWORD StartingAddress;
  6033. DWORD EndingAddress;
  6034. DWORD EndOfPrologue;
  6035. } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
  6036. typedef struct _IMAGE_FUNCTION_ENTRY64 {
  6037. ULONGLONG StartingAddress;
  6038. ULONGLONG EndingAddress;
  6039. union {
  6040. ULONGLONG EndOfPrologue;
  6041. ULONGLONG UnwindInfoAddress;
  6042. };
  6043. } IMAGE_FUNCTION_ENTRY64, *PIMAGE_FUNCTION_ENTRY64;
  6044. //
  6045. // Debugging information can be stripped from an image file and placed
  6046. // in a separate .DBG file, whose file name part is the same as the
  6047. // image file name part (e.g. symbols for CMD.EXE could be stripped
  6048. // and placed in CMD.DBG). This is indicated by the IMAGE_FILE_DEBUG_STRIPPED
  6049. // flag in the Characteristics field of the file header. The beginning of
  6050. // the .DBG file contains the following structure which captures certain
  6051. // information from the image file. This allows a debug to proceed even if
  6052. // the original image file is not accessable. This header is followed by
  6053. // zero of more IMAGE_SECTION_HEADER structures, followed by zero or more
  6054. // IMAGE_DEBUG_DIRECTORY structures. The latter structures and those in
  6055. // the image file contain file offsets relative to the beginning of the
  6056. // .DBG file.
  6057. //
  6058. // If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure
  6059. // is left in the image file, but not mapped. This allows a debugger to
  6060. // compute the name of the .DBG file, from the name of the image in the
  6061. // IMAGE_DEBUG_MISC structure.
  6062. //
  6063. typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
  6064. WORD Signature;
  6065. WORD Flags;
  6066. WORD Machine;
  6067. WORD Characteristics;
  6068. DWORD TimeDateStamp;
  6069. DWORD CheckSum;
  6070. DWORD ImageBase;
  6071. DWORD SizeOfImage;
  6072. DWORD NumberOfSections;
  6073. DWORD ExportedNamesSize;
  6074. DWORD DebugDirectorySize;
  6075. DWORD SectionAlignment;
  6076. DWORD Reserved[2];
  6077. } IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER;
  6078. typedef struct _NON_PAGED_DEBUG_INFO {
  6079. WORD Signature;
  6080. WORD Flags;
  6081. DWORD Size;
  6082. WORD Machine;
  6083. WORD Characteristics;
  6084. DWORD TimeDateStamp;
  6085. DWORD CheckSum;
  6086. DWORD SizeOfImage;
  6087. ULONGLONG ImageBase;
  6088. //DebugDirectorySize
  6089. //IMAGE_DEBUG_DIRECTORY
  6090. } NON_PAGED_DEBUG_INFO, *PNON_PAGED_DEBUG_INFO;
  6091. #ifndef _MAC
  6092. #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
  6093. #define NON_PAGED_DEBUG_SIGNATURE 0x494E
  6094. #else
  6095. #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4449 // DI
  6096. #define NON_PAGED_DEBUG_SIGNATURE 0x4E49 // NI
  6097. #endif
  6098. #define IMAGE_SEPARATE_DEBUG_FLAGS_MASK 0x8000
  6099. #define IMAGE_SEPARATE_DEBUG_MISMATCH 0x8000 // when DBG was updated, the
  6100. // old checksum didn't match.
  6101. //
  6102. // The .arch section is made up of headers, each describing an amask position/value
  6103. // pointing to an array of IMAGE_ARCHITECTURE_ENTRY's. Each "array" (both the header
  6104. // and entry arrays) are terminiated by a quadword of 0xffffffffL.
  6105. //
  6106. // NOTE: There may be quadwords of 0 sprinkled around and must be skipped.
  6107. //
  6108. typedef struct _ImageArchitectureHeader {
  6109. unsigned int AmaskValue: 1; // 1 -> code section depends on mask bit
  6110. // 0 -> new instruction depends on mask bit
  6111. int :7; // MBZ
  6112. unsigned int AmaskShift: 8; // Amask bit in question for this fixup
  6113. int :16; // MBZ
  6114. DWORD FirstEntryRVA; // RVA into .arch section to array of ARCHITECTURE_ENTRY's
  6115. } IMAGE_ARCHITECTURE_HEADER, *PIMAGE_ARCHITECTURE_HEADER;
  6116. typedef struct _ImageArchitectureEntry {
  6117. DWORD FixupInstRVA; // RVA of instruction to fixup
  6118. DWORD NewInst; // fixup instruction (see alphaops.h)
  6119. } IMAGE_ARCHITECTURE_ENTRY, *PIMAGE_ARCHITECTURE_ENTRY;
  6120. #include "poppack.h" // Back to the initial value
  6121. // The following structure defines the new import object. Note the values of the first two fields,
  6122. // which must be set as stated in order to differentiate old and new import members.
  6123. // Following this structure, the linker emits two null-terminated strings used to recreate the
  6124. // import at the time of use. The first string is the import's name, the second is the dll's name.
  6125. #define IMPORT_OBJECT_HDR_SIG2 0xffff
  6126. typedef struct IMPORT_OBJECT_HEADER {
  6127. WORD Sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN
  6128. WORD Sig2; // Must be IMPORT_OBJECT_HDR_SIG2.
  6129. WORD Version;
  6130. WORD Machine;
  6131. DWORD TimeDateStamp; // Time/date stamp
  6132. DWORD SizeOfData; // particularly useful for incremental links
  6133. union {
  6134. WORD Ordinal; // if grf & IMPORT_OBJECT_ORDINAL
  6135. WORD Hint;
  6136. };
  6137. WORD Type : 2; // IMPORT_TYPE
  6138. WORD NameType : 3; // IMPORT_NAME_TYPE
  6139. WORD Reserved : 11; // Reserved. Must be zero.
  6140. } IMPORT_OBJECT_HEADER;
  6141. typedef enum IMPORT_OBJECT_TYPE
  6142. {
  6143. IMPORT_OBJECT_CODE = 0,
  6144. IMPORT_OBJECT_DATA = 1,
  6145. IMPORT_OBJECT_CONST = 2,
  6146. } IMPORT_OBJECT_TYPE;
  6147. typedef enum IMPORT_OBJECT_NAME_TYPE
  6148. {
  6149. IMPORT_OBJECT_ORDINAL = 0, // Import by ordinal
  6150. IMPORT_OBJECT_NAME = 1, // Import name == public symbol name.
  6151. IMPORT_OBJECT_NAME_NO_PREFIX = 2, // Import name == public symbol name skipping leading ?, @, or optionally _.
  6152. IMPORT_OBJECT_NAME_UNDECORATE = 3, // Import name == public symbol name skipping leading ?, @, or optionally _
  6153. // and truncating at first @
  6154. } IMPORT_OBJECT_NAME_TYPE;
  6155. #ifndef __IMAGE_COR20_HEADER_DEFINED__
  6156. #define __IMAGE_COR20_HEADER_DEFINED__
  6157. typedef enum ReplacesCorHdrNumericDefines
  6158. {
  6159. // COM+ Header entry point flags.
  6160. COMIMAGE_FLAGS_ILONLY =0x00000001,
  6161. COMIMAGE_FLAGS_32BITREQUIRED =0x00000002,
  6162. COMIMAGE_FLAGS_IL_LIBRARY =0x00000004,
  6163. COMIMAGE_FLAGS_TRACKDEBUGDATA =0x00010000,
  6164. // Version flags for image.
  6165. COR_VERSION_MAJOR_V2 =2,
  6166. COR_VERSION_MAJOR =COR_VERSION_MAJOR_V2,
  6167. COR_VERSION_MINOR =0,
  6168. COR_DELETED_NAME_LENGTH =8,
  6169. COR_VTABLEGAP_NAME_LENGTH =8,
  6170. // Maximum size of a NativeType descriptor.
  6171. NATIVE_TYPE_MAX_CB =1,
  6172. COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE=0xFF,
  6173. // #defines for the MIH FLAGS
  6174. IMAGE_COR_MIH_METHODRVA =0x01,
  6175. IMAGE_COR_MIH_EHRVA =0x02,
  6176. IMAGE_COR_MIH_BASICBLOCK =0x08,
  6177. // V-table constants
  6178. COR_VTABLE_32BIT =0x01, // V-table slots are 32-bits in size.
  6179. COR_VTABLE_64BIT =0x02, // V-table slots are 64-bits in size.
  6180. COR_VTABLE_FROM_UNMANAGED =0x04, // If set, transition from unmanaged.
  6181. COR_VTABLE_CALL_MOST_DERIVED =0x10, // Call most derived method described by
  6182. // EATJ constants
  6183. IMAGE_COR_EATJ_THUNK_SIZE =32, // Size of a jump thunk reserved range.
  6184. // Max name lengths
  6185. //@todo: Change to unlimited name lengths.
  6186. MAX_CLASS_NAME =1024,
  6187. MAX_PACKAGE_NAME =1024,
  6188. } ReplacesCorHdrNumericDefines;
  6189. // COM+ 2.0 header structure.
  6190. typedef struct IMAGE_COR20_HEADER
  6191. {
  6192. // Header versioning
  6193. DWORD cb;
  6194. WORD MajorRuntimeVersion;
  6195. WORD MinorRuntimeVersion;
  6196. // Symbol table and startup information
  6197. IMAGE_DATA_DIRECTORY MetaData;
  6198. DWORD Flags;
  6199. DWORD EntryPointToken;
  6200. // Binding information
  6201. IMAGE_DATA_DIRECTORY Resources;
  6202. IMAGE_DATA_DIRECTORY StrongNameSignature;
  6203. // Regular fixup and binding information
  6204. IMAGE_DATA_DIRECTORY CodeManagerTable;
  6205. IMAGE_DATA_DIRECTORY VTableFixups;
  6206. IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
  6207. // Precompiled image info (internal use only - set to zero)
  6208. IMAGE_DATA_DIRECTORY ManagedNativeHeader;
  6209. } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
  6210. #endif // __IMAGE_COR20_HEADER_DEFINED__
  6211. //
  6212. // End Image Format
  6213. //
  6214. //
  6215. // for move macros
  6216. //
  6217. #ifdef _MAC
  6218. #ifndef _INC_STRING
  6219. #include <string.h>
  6220. #endif /* _INC_STRING */
  6221. #else
  6222. #include <string.h>
  6223. #endif // _MAC
  6224. #ifndef _SLIST_HEADER_
  6225. #define _SLIST_HEADER_
  6226. #define SLIST_ENTRY SINGLE_LIST_ENTRY
  6227. #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
  6228. #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
  6229. #if defined(_WIN64)
  6230. typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER {
  6231. ULONGLONG Alignment;
  6232. ULONGLONG Region;
  6233. } SLIST_HEADER;
  6234. typedef struct _SLIST_HEADER *PSLIST_HEADER;
  6235. #else
  6236. typedef union _SLIST_HEADER {
  6237. ULONGLONG Alignment;
  6238. struct {
  6239. SLIST_ENTRY Next;
  6240. WORD Depth;
  6241. WORD Sequence;
  6242. };
  6243. } SLIST_HEADER, *PSLIST_HEADER;
  6244. #endif
  6245. #endif
  6246. NTSYSAPI
  6247. VOID
  6248. NTAPI
  6249. RtlInitializeSListHead (
  6250. IN PSLIST_HEADER ListHead
  6251. );
  6252. NTSYSAPI
  6253. PSLIST_ENTRY
  6254. RtlFirstEntrySList (
  6255. IN const SLIST_HEADER *ListHead
  6256. );
  6257. NTSYSAPI
  6258. PSLIST_ENTRY
  6259. NTAPI
  6260. RtlInterlockedPopEntrySList (
  6261. IN PSLIST_HEADER ListHead
  6262. );
  6263. NTSYSAPI
  6264. PSLIST_ENTRY
  6265. NTAPI
  6266. RtlInterlockedPushEntrySList (
  6267. IN PSLIST_HEADER ListHead,
  6268. IN PSLIST_ENTRY ListEntry
  6269. );
  6270. NTSYSAPI
  6271. PSLIST_ENTRY
  6272. NTAPI
  6273. RtlInterlockedFlushSList (
  6274. IN PSLIST_HEADER ListHead
  6275. );
  6276. NTSYSAPI
  6277. WORD
  6278. NTAPI
  6279. RtlQueryDepthSList (
  6280. IN PSLIST_HEADER ListHead
  6281. );
  6282. #define HEAP_NO_SERIALIZE 0x00000001
  6283. #define HEAP_GROWABLE 0x00000002
  6284. #define HEAP_GENERATE_EXCEPTIONS 0x00000004
  6285. #define HEAP_ZERO_MEMORY 0x00000008
  6286. #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
  6287. #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
  6288. #define HEAP_FREE_CHECKING_ENABLED 0x00000040
  6289. #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
  6290. #define HEAP_CREATE_ALIGN_16 0x00010000
  6291. #define HEAP_CREATE_ENABLE_TRACING 0x00020000
  6292. #define HEAP_MAXIMUM_TAG 0x0FFF
  6293. #define HEAP_PSEUDO_TAG_FLAG 0x8000
  6294. #define HEAP_TAG_SHIFT 18
  6295. #define HEAP_MAKE_TAG_FLAGS( b, o ) ((DWORD)((b) + ((o) << 18)))
  6296. #define IS_TEXT_UNICODE_ASCII16 0x0001
  6297. #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
  6298. #define IS_TEXT_UNICODE_STATISTICS 0x0002
  6299. #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
  6300. #define IS_TEXT_UNICODE_CONTROLS 0x0004
  6301. #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
  6302. #define IS_TEXT_UNICODE_SIGNATURE 0x0008
  6303. #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
  6304. #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
  6305. #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
  6306. #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
  6307. #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
  6308. #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
  6309. #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
  6310. #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
  6311. #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
  6312. #define COMPRESSION_FORMAT_NONE (0x0000)
  6313. #define COMPRESSION_FORMAT_DEFAULT (0x0001)
  6314. #define COMPRESSION_FORMAT_LZNT1 (0x0002)
  6315. #define COMPRESSION_ENGINE_STANDARD (0x0000)
  6316. #define COMPRESSION_ENGINE_MAXIMUM (0x0100)
  6317. #define COMPRESSION_ENGINE_HIBER (0x0200)
  6318. NTSYSAPI
  6319. SIZE_T
  6320. NTAPI
  6321. RtlCompareMemory (
  6322. const VOID *Source1,
  6323. const VOID *Source2,
  6324. SIZE_T Length
  6325. );
  6326. #if defined(_M_AMD64) || defined(_M_IA64)
  6327. #define RtlEqualMemory(Source1, Source2, Length) \
  6328. ((Length) == RtlCompareMemory(Source1, Source2, Length))
  6329. NTSYSAPI
  6330. VOID
  6331. NTAPI
  6332. RtlCopyMemory (
  6333. VOID UNALIGNED *Destination,
  6334. CONST VOID UNALIGNED *Source,
  6335. SIZE_T Length
  6336. );
  6337. #if !defined(_M_AMD64)
  6338. NTSYSAPI
  6339. VOID
  6340. NTAPI
  6341. RtlCopyMemory32 (
  6342. VOID UNALIGNED *Destination,
  6343. CONST VOID UNALIGNED *Source,
  6344. DWORD Length
  6345. );
  6346. #endif
  6347. NTSYSAPI
  6348. VOID
  6349. NTAPI
  6350. RtlMoveMemory (
  6351. VOID UNALIGNED *Destination,
  6352. CONST VOID UNALIGNED *Source,
  6353. SIZE_T Length
  6354. );
  6355. NTSYSAPI
  6356. VOID
  6357. NTAPI
  6358. RtlFillMemory (
  6359. VOID UNALIGNED *Destination,
  6360. SIZE_T Length,
  6361. BYTE Fill
  6362. );
  6363. NTSYSAPI
  6364. VOID
  6365. NTAPI
  6366. RtlZeroMemory (
  6367. VOID UNALIGNED *Destination,
  6368. SIZE_T Length
  6369. );
  6370. #else
  6371. #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
  6372. #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
  6373. #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
  6374. #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
  6375. #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
  6376. #endif
  6377. #if !defined(MIDL_PASS)
  6378. FORCEINLINE
  6379. PVOID
  6380. RtlSecureZeroMemory(
  6381. IN PVOID ptr,
  6382. IN SIZE_T cnt
  6383. )
  6384. {
  6385. volatile char *vptr = (volatile char *)ptr;
  6386. while (cnt) {
  6387. *vptr = 0;
  6388. vptr++;
  6389. cnt--;
  6390. }
  6391. return ptr;
  6392. }
  6393. #endif
  6394. typedef struct _MESSAGE_RESOURCE_ENTRY {
  6395. WORD Length;
  6396. WORD Flags;
  6397. BYTE Text[ 1 ];
  6398. } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
  6399. #define MESSAGE_RESOURCE_UNICODE 0x0001
  6400. typedef struct _MESSAGE_RESOURCE_BLOCK {
  6401. DWORD LowId;
  6402. DWORD HighId;
  6403. DWORD OffsetToEntries;
  6404. } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
  6405. typedef struct _MESSAGE_RESOURCE_DATA {
  6406. DWORD NumberOfBlocks;
  6407. MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
  6408. } MESSAGE_RESOURCE_DATA, *PMESSAGE_RESOURCE_DATA;
  6409. typedef struct _OSVERSIONINFOA {
  6410. DWORD dwOSVersionInfoSize;
  6411. DWORD dwMajorVersion;
  6412. DWORD dwMinorVersion;
  6413. DWORD dwBuildNumber;
  6414. DWORD dwPlatformId;
  6415. CHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
  6416. } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
  6417. typedef struct _OSVERSIONINFOW {
  6418. DWORD dwOSVersionInfoSize;
  6419. DWORD dwMajorVersion;
  6420. DWORD dwMinorVersion;
  6421. DWORD dwBuildNumber;
  6422. DWORD dwPlatformId;
  6423. WCHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
  6424. } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
  6425. #ifdef UNICODE
  6426. typedef OSVERSIONINFOW OSVERSIONINFO;
  6427. typedef POSVERSIONINFOW POSVERSIONINFO;
  6428. typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
  6429. #else
  6430. typedef OSVERSIONINFOA OSVERSIONINFO;
  6431. typedef POSVERSIONINFOA POSVERSIONINFO;
  6432. typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
  6433. #endif // UNICODE
  6434. typedef struct _OSVERSIONINFOEXA {
  6435. DWORD dwOSVersionInfoSize;
  6436. DWORD dwMajorVersion;
  6437. DWORD dwMinorVersion;
  6438. DWORD dwBuildNumber;
  6439. DWORD dwPlatformId;
  6440. CHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
  6441. WORD wServicePackMajor;
  6442. WORD wServicePackMinor;
  6443. WORD wSuiteMask;
  6444. BYTE wProductType;
  6445. BYTE wReserved;
  6446. } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
  6447. typedef struct _OSVERSIONINFOEXW {
  6448. DWORD dwOSVersionInfoSize;
  6449. DWORD dwMajorVersion;
  6450. DWORD dwMinorVersion;
  6451. DWORD dwBuildNumber;
  6452. DWORD dwPlatformId;
  6453. WCHAR szCSDVersion[ 128 ]; // Maintenance string for PSS usage
  6454. WORD wServicePackMajor;
  6455. WORD wServicePackMinor;
  6456. WORD wSuiteMask;
  6457. BYTE wProductType;
  6458. BYTE wReserved;
  6459. } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
  6460. #ifdef UNICODE
  6461. typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
  6462. typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
  6463. typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
  6464. #else
  6465. typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
  6466. typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
  6467. typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
  6468. #endif // UNICODE
  6469. //
  6470. // RtlVerifyVersionInfo() conditions
  6471. //
  6472. #define VER_EQUAL 1
  6473. #define VER_GREATER 2
  6474. #define VER_GREATER_EQUAL 3
  6475. #define VER_LESS 4
  6476. #define VER_LESS_EQUAL 5
  6477. #define VER_AND 6
  6478. #define VER_OR 7
  6479. #define VER_CONDITION_MASK 7
  6480. #define VER_NUM_BITS_PER_CONDITION_MASK 3
  6481. //
  6482. // RtlVerifyVersionInfo() type mask bits
  6483. //
  6484. #define VER_MINORVERSION 0x0000001
  6485. #define VER_MAJORVERSION 0x0000002
  6486. #define VER_BUILDNUMBER 0x0000004
  6487. #define VER_PLATFORMID 0x0000008
  6488. #define VER_SERVICEPACKMINOR 0x0000010
  6489. #define VER_SERVICEPACKMAJOR 0x0000020
  6490. #define VER_SUITENAME 0x0000040
  6491. #define VER_PRODUCT_TYPE 0x0000080
  6492. //
  6493. // RtlVerifyVersionInfo() os product type values
  6494. //
  6495. #define VER_NT_WORKSTATION 0x0000001
  6496. #define VER_NT_DOMAIN_CONTROLLER 0x0000002
  6497. #define VER_NT_SERVER 0x0000003
  6498. //
  6499. // dwPlatformId defines:
  6500. //
  6501. #define VER_PLATFORM_WIN32s 0
  6502. #define VER_PLATFORM_WIN32_WINDOWS 1
  6503. #define VER_PLATFORM_WIN32_NT 2
  6504. //
  6505. //
  6506. // VerifyVersionInfo() macro to set the condition mask
  6507. //
  6508. // For documentation sakes here's the old version of the macro that got
  6509. // changed to call an API
  6510. // #define VER_SET_CONDITION(_m_,_t_,_c_) _m_=(_m_|(_c_<<(1<<_t_)))
  6511. //
  6512. #define VER_SET_CONDITION(_m_,_t_,_c_) \
  6513. ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
  6514. ULONGLONG
  6515. NTAPI
  6516. VerSetConditionMask(
  6517. IN ULONGLONG ConditionMask,
  6518. IN DWORD TypeMask,
  6519. IN BYTE Condition
  6520. );
  6521. //
  6522. typedef struct _RTL_CRITICAL_SECTION_DEBUG {
  6523. WORD Type;
  6524. WORD CreatorBackTraceIndex;
  6525. struct _RTL_CRITICAL_SECTION *CriticalSection;
  6526. LIST_ENTRY ProcessLocksList;
  6527. DWORD EntryCount;
  6528. DWORD ContentionCount;
  6529. DWORD Spare[ 2 ];
  6530. } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
  6531. #define RTL_CRITSECT_TYPE 0
  6532. #define RTL_RESOURCE_TYPE 1
  6533. typedef struct _RTL_CRITICAL_SECTION {
  6534. PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
  6535. //
  6536. // The following three fields control entering and exiting the critical
  6537. // section for the resource
  6538. //
  6539. LONG LockCount;
  6540. LONG RecursionCount;
  6541. HANDLE OwningThread; // from the thread's ClientId->UniqueThread
  6542. HANDLE LockSemaphore;
  6543. ULONG_PTR SpinCount; // force size on 64-bit systems when packed
  6544. } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
  6545. typedef VOID (* RTL_VERIFIER_DLL_LOAD_CALLBACK) (
  6546. PWSTR DllName,
  6547. PVOID DllBase,
  6548. SIZE_T DllSize,
  6549. PVOID Reserved
  6550. );
  6551. typedef VOID (* RTL_VERIFIER_DLL_UNLOAD_CALLBACK) (
  6552. PWSTR DllName,
  6553. PVOID DllBase,
  6554. SIZE_T DllSize,
  6555. PVOID Reserved
  6556. );
  6557. typedef struct _RTL_VERIFIER_THUNK_DESCRIPTOR {
  6558. PCHAR ThunkName;
  6559. PVOID ThunkOldAddress;
  6560. PVOID ThunkNewAddress;
  6561. } RTL_VERIFIER_THUNK_DESCRIPTOR, *PRTL_VERIFIER_THUNK_DESCRIPTOR;
  6562. typedef struct _RTL_VERIFIER_DLL_DESCRIPTOR {
  6563. PWCHAR DllName;
  6564. DWORD DllFlags;
  6565. PVOID DllAddress;
  6566. PRTL_VERIFIER_THUNK_DESCRIPTOR DllThunks;
  6567. } RTL_VERIFIER_DLL_DESCRIPTOR, *PRTL_VERIFIER_DLL_DESCRIPTOR;
  6568. typedef struct _RTL_VERIFIER_PROVIDER_DESCRIPTOR {
  6569. //
  6570. // Filled by verifier provider DLL
  6571. //
  6572. DWORD Length;
  6573. PRTL_VERIFIER_DLL_DESCRIPTOR ProviderDlls;
  6574. RTL_VERIFIER_DLL_LOAD_CALLBACK ProviderDllLoadCallback;
  6575. RTL_VERIFIER_DLL_UNLOAD_CALLBACK ProviderDllUnloadCallback;
  6576. //
  6577. // Filled by verifier engine
  6578. //
  6579. PWSTR VerifierImage;
  6580. DWORD VerifierFlags;
  6581. DWORD VerifierDebug;
  6582. } RTL_VERIFIER_PROVIDER_DESCRIPTOR, *PRTL_VERIFIER_PROVIDER_DESCRIPTOR;
  6583. //
  6584. // Application verifier standard flags
  6585. //
  6586. #define RTL_VRF_FLG_FULL_PAGE_HEAP 0x0001
  6587. #define RTL_VRF_FLG_LOCK_CHECKS 0x0002
  6588. #define RTL_VRF_FLG_HANDLE_CHECKS 0x0004
  6589. #define RTL_VRF_FLG_STACK_CHECKS 0x0008
  6590. #define RTL_VRF_FLG_APPCOMPAT_CHECKS 0x0010
  6591. //
  6592. // Application verifier standard stop codes
  6593. //
  6594. #define APPLICATION_VERIFIER_INTERNAL_ERROR 0x80000000
  6595. #define APPLICATION_VERIFIER_INTERNAL_WARNING 0x40000000
  6596. #define APPLICATION_VERIFIER_NO_BREAK 0x20000000
  6597. #define APPLICATION_VERIFIER_RESERVED_BIT_28 0x10000000
  6598. #define APPLICATION_VERIFIER_UNKNOWN_ERROR 0x0001
  6599. #define APPLICATION_VERIFIER_ACCESS_VIOLATION 0x0002
  6600. #define APPLICATION_VERIFIER_UNSYNCHRONIZED_ACCESS 0x0003
  6601. #define APPLICATION_VERIFIER_EXTREME_SIZE_REQUEST 0x0004
  6602. #define APPLICATION_VERIFIER_BAD_HEAP_HANDLE 0x0005
  6603. #define APPLICATION_VERIFIER_SWITCHED_HEAP_HANDLE 0x0006
  6604. #define APPLICATION_VERIFIER_DOUBLE_FREE 0x0007
  6605. #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK 0x0008
  6606. #define APPLICATION_VERIFIER_DESTROY_PROCESS_HEAP 0x0009
  6607. #define APPLICATION_VERIFIER_UNEXPECTED_EXCEPTION 0x000A
  6608. #define APPLICATION_VERIFIER_STACK_OVERFLOW 0x000B
  6609. #define APPLICATION_VERIFIER_TERMINATE_THREAD_CALL 0x0100
  6610. #define APPLICATION_VERIFIER_EXIT_THREAD_OWNS_LOCK 0x0200
  6611. #define APPLICATION_VERIFIER_LOCK_IN_UNLOADED_DLL 0x0201
  6612. #define APPLICATION_VERIFIER_LOCK_IN_FREED_HEAP 0x0202
  6613. #define APPLICATION_VERIFIER_LOCK_DOUBLE_INITIALIZE 0x0203
  6614. #define APPLICATION_VERIFIER_LOCK_IN_FREED_MEMORY 0x0204
  6615. #define APPLICATION_VERIFIER_LOCK_CORRUPTED 0x0205
  6616. #define APPLICATION_VERIFIER_LOCK_INVALID_OWNER 0x0206
  6617. #define APPLICATION_VERIFIER_LOCK_INVALID_RECURSION_COUNT 0x0207
  6618. #define APPLICATION_VERIFIER_LOCK_INVALID_LOCK_COUNT 0x0208
  6619. #define APPLICATION_VERIFIER_LOCK_OVER_RELEASED 0x0209
  6620. #define APPLICATION_VERIFIER_LOCK_NOT_INITIALIZED 0x0210
  6621. #define APPLICATION_VERIFIER_INVALID_HANDLE 0x0300
  6622. #define VERIFIER_STOP(Code, Msg, P1, S1, P2, S2, P3, S3, P4, S4) { \
  6623. RtlApplicationVerifierStop ((Code), \
  6624. (Msg), \
  6625. (ULONG_PTR)(P1),(S1), \
  6626. (ULONG_PTR)(P2),(S2), \
  6627. (ULONG_PTR)(P3),(S3), \
  6628. (ULONG_PTR)(P4),(S4)); \
  6629. }
  6630. VOID
  6631. RtlApplicationVerifierStop (
  6632. ULONG_PTR Code,
  6633. PCHAR Message,
  6634. ULONG_PTR Param1, PCHAR Description1,
  6635. ULONG_PTR Param2, PCHAR Description2,
  6636. ULONG_PTR Param3, PCHAR Description3,
  6637. ULONG_PTR Param4, PCHAR Description4
  6638. );
  6639. typedef LONG (NTAPI *PVECTORED_EXCEPTION_HANDLER)(
  6640. struct _EXCEPTION_POINTERS *ExceptionInfo
  6641. );
  6642. #define SEF_DACL_AUTO_INHERIT 0x01
  6643. #define SEF_SACL_AUTO_INHERIT 0x02
  6644. #define SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT 0x04
  6645. #define SEF_AVOID_PRIVILEGE_CHECK 0x08
  6646. #define SEF_AVOID_OWNER_CHECK 0x10
  6647. #define SEF_DEFAULT_OWNER_FROM_PARENT 0x20
  6648. #define SEF_DEFAULT_GROUP_FROM_PARENT 0x40
  6649. typedef enum _HEAP_INFORMATION_CLASS {
  6650. HeapCompatibilityInformation
  6651. } HEAP_INFORMATION_CLASS;
  6652. DWORD
  6653. RtlSetHeapInformation (
  6654. IN PVOID HeapHandle,
  6655. IN HEAP_INFORMATION_CLASS HeapInformationClass,
  6656. IN PVOID HeapInformation OPTIONAL,
  6657. IN SIZE_T HeapInformationLength OPTIONAL
  6658. );
  6659. DWORD
  6660. RtlQueryHeapInformation (
  6661. IN PVOID HeapHandle,
  6662. IN HEAP_INFORMATION_CLASS HeapInformationClass,
  6663. OUT PVOID HeapInformation OPTIONAL,
  6664. IN SIZE_T HeapInformationLength OPTIONAL,
  6665. OUT PSIZE_T ReturnLength OPTIONAL
  6666. );
  6667. #define WT_EXECUTEDEFAULT 0x00000000
  6668. #define WT_EXECUTEINIOTHREAD 0x00000001
  6669. #define WT_EXECUTEINUITHREAD 0x00000002
  6670. #define WT_EXECUTEINWAITTHREAD 0x00000004
  6671. #define WT_EXECUTEONLYONCE 0x00000008
  6672. #define WT_EXECUTEINTIMERTHREAD 0x00000020
  6673. #define WT_EXECUTELONGFUNCTION 0x00000010
  6674. #define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040
  6675. #define WT_EXECUTEINPERSISTENTTHREAD 0x00000080
  6676. #define WT_SET_MAX_THREADPOOL_THREADS(Flags, Limit) ((Flags) |= (Limit)<<16)
  6677. typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
  6678. typedef VOID (NTAPI * WORKERCALLBACKFUNC) (PVOID );
  6679. typedef VOID (NTAPI * APC_CALLBACK_FUNCTION) (DWORD , PVOID, PVOID);
  6680. #define WT_EXECUTEINLONGTHREAD 0x00000010
  6681. #define WT_EXECUTEDELETEWAIT 0x00000008
  6682. typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
  6683. ActivationContextBasicInformation = 1,
  6684. ActivationContextDetailedInformation = 2,
  6685. AssemblyDetailedInformationInActivationContext = 3,
  6686. FileInformationInAssemblyOfAssemblyInActivationContext = 4,
  6687. MaxActivationContextInfoClass,
  6688. //
  6689. // compatibility with old names
  6690. //
  6691. AssemblyDetailedInformationInActivationContxt = 3,
  6692. FileInformationInAssemblyOfAssemblyInActivationContxt = 4
  6693. } ACTIVATION_CONTEXT_INFO_CLASS;
  6694. #define ACTIVATIONCONTEXTINFOCLASS ACTIVATION_CONTEXT_INFO_CLASS
  6695. typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
  6696. DWORD ulAssemblyIndex;
  6697. DWORD ulFileIndexInAssembly;
  6698. } ACTIVATION_CONTEXT_QUERY_INDEX, * PACTIVATION_CONTEXT_QUERY_INDEX;
  6699. typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX * PCACTIVATION_CONTEXT_QUERY_INDEX;
  6700. #define ACTIVATION_CONTEXT_PATH_TYPE_NONE (1)
  6701. #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE (2)
  6702. #define ACTIVATION_CONTEXT_PATH_TYPE_URL (3)
  6703. #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF (4)
  6704. typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
  6705. DWORD ulFlags;
  6706. DWORD ulFilenameLength;
  6707. DWORD ulPathLength;
  6708. PCWSTR lpFileName;
  6709. PCWSTR lpFilePath;
  6710. } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
  6711. typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
  6712. //
  6713. // compatibility with old names
  6714. // The new names use "file" consistently.
  6715. //
  6716. #define _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION _ASSEMBLY_FILE_DETAILED_INFORMATION
  6717. #define ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION ASSEMBLY_FILE_DETAILED_INFORMATION
  6718. #define PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PASSEMBLY_FILE_DETAILED_INFORMATION
  6719. #define PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PCASSEMBLY_FILE_DETAILED_INFORMATION
  6720. typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
  6721. DWORD ulFlags;
  6722. DWORD ulEncodedAssemblyIdentityLength; // in bytes
  6723. DWORD ulManifestPathType; // ACTIVATION_CONTEXT_PATH_TYPE_*
  6724. DWORD ulManifestPathLength; // in bytes
  6725. LARGE_INTEGER liManifestLastWriteTime; // FILETIME
  6726. DWORD ulPolicyPathType; // ACTIVATION_CONTEXT_PATH_TYPE_*
  6727. DWORD ulPolicyPathLength; // in bytes
  6728. LARGE_INTEGER liPolicyLastWriteTime; // FILETIME
  6729. DWORD ulMetadataSatelliteRosterIndex;
  6730. DWORD ulManifestVersionMajor; // 1
  6731. DWORD ulManifestVersionMinor; // 0
  6732. DWORD ulPolicyVersionMajor; // 0
  6733. DWORD ulPolicyVersionMinor; // 0
  6734. DWORD ulAssemblyDirectoryNameLength; // in bytes
  6735. PCWSTR lpAssemblyEncodedAssemblyIdentity;
  6736. PCWSTR lpAssemblyManifestPath;
  6737. PCWSTR lpAssemblyPolicyPath;
  6738. PCWSTR lpAssemblyDirectoryName;
  6739. DWORD ulFileCount;
  6740. } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, * PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
  6741. typedef const struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION * PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION ;
  6742. typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
  6743. DWORD dwFlags;
  6744. DWORD ulFormatVersion;
  6745. DWORD ulAssemblyCount;
  6746. DWORD ulRootManifestPathType;
  6747. DWORD ulRootManifestPathChars;
  6748. DWORD ulRootConfigurationPathType;
  6749. DWORD ulRootConfigurationPathChars;
  6750. DWORD ulAppDirPathType;
  6751. DWORD ulAppDirPathChars;
  6752. PCWSTR lpRootManifestPath;
  6753. PCWSTR lpRootConfigurationPath;
  6754. PCWSTR lpAppDirPath;
  6755. } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
  6756. typedef const struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_DETAILED_INFORMATION;
  6757. #define DLL_PROCESS_ATTACH 1
  6758. #define DLL_THREAD_ATTACH 2
  6759. #define DLL_THREAD_DETACH 3
  6760. #define DLL_PROCESS_DETACH 0
  6761. #define DLL_PROCESS_VERIFIER 4
  6762. //
  6763. // Defines for the READ flags for Eventlogging
  6764. //
  6765. #define EVENTLOG_SEQUENTIAL_READ 0x0001
  6766. #define EVENTLOG_SEEK_READ 0x0002
  6767. #define EVENTLOG_FORWARDS_READ 0x0004
  6768. #define EVENTLOG_BACKWARDS_READ 0x0008
  6769. //
  6770. // The types of events that can be logged.
  6771. //
  6772. #define EVENTLOG_SUCCESS 0x0000
  6773. #define EVENTLOG_ERROR_TYPE 0x0001
  6774. #define EVENTLOG_WARNING_TYPE 0x0002
  6775. #define EVENTLOG_INFORMATION_TYPE 0x0004
  6776. #define EVENTLOG_AUDIT_SUCCESS 0x0008
  6777. #define EVENTLOG_AUDIT_FAILURE 0x0010
  6778. //
  6779. // Defines for the WRITE flags used by Auditing for paired events
  6780. // These are not implemented in Product 1
  6781. //
  6782. #define EVENTLOG_START_PAIRED_EVENT 0x0001
  6783. #define EVENTLOG_END_PAIRED_EVENT 0x0002
  6784. #define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004
  6785. #define EVENTLOG_PAIRED_EVENT_ACTIVE 0x0008
  6786. #define EVENTLOG_PAIRED_EVENT_INACTIVE 0x0010
  6787. //
  6788. // Structure that defines the header of the Eventlog record. This is the
  6789. // fixed-sized portion before all the variable-length strings, binary
  6790. // data and pad bytes.
  6791. //
  6792. // TimeGenerated is the time it was generated at the client.
  6793. // TimeWritten is the time it was put into the log at the server end.
  6794. //
  6795. typedef struct _EVENTLOGRECORD {
  6796. DWORD Length; // Length of full record
  6797. DWORD Reserved; // Used by the service
  6798. DWORD RecordNumber; // Absolute record number
  6799. DWORD TimeGenerated; // Seconds since 1-1-1970
  6800. DWORD TimeWritten; // Seconds since 1-1-1970
  6801. DWORD EventID;
  6802. WORD EventType;
  6803. WORD NumStrings;
  6804. WORD EventCategory;
  6805. WORD ReservedFlags; // For use with paired events (auditing)
  6806. DWORD ClosingRecordNumber; // For use with paired events (auditing)
  6807. DWORD StringOffset; // Offset from beginning of record
  6808. DWORD UserSidLength;
  6809. DWORD UserSidOffset;
  6810. DWORD DataLength;
  6811. DWORD DataOffset; // Offset from beginning of record
  6812. //
  6813. // Then follow:
  6814. //
  6815. // WCHAR SourceName[]
  6816. // WCHAR Computername[]
  6817. // SID UserSid
  6818. // WCHAR Strings[]
  6819. // BYTE Data[]
  6820. // CHAR Pad[]
  6821. // DWORD Length;
  6822. //
  6823. } EVENTLOGRECORD, *PEVENTLOGRECORD;
  6824. //SS: start of changes to support clustering
  6825. //SS: ideally the
  6826. #define MAXLOGICALLOGNAMESIZE 256
  6827. #if _MSC_VER >= 1200
  6828. #pragma warning(push)
  6829. #endif
  6830. #pragma warning(disable : 4200)
  6831. typedef struct _EVENTSFORLOGFILE{
  6832. DWORD ulSize;
  6833. WCHAR szLogicalLogFile[MAXLOGICALLOGNAMESIZE]; //name of the logical file-security/application/system
  6834. DWORD ulNumRecords;
  6835. EVENTLOGRECORD pEventLogRecords[];
  6836. }EVENTSFORLOGFILE, *PEVENTSFORLOGFILE;
  6837. typedef struct _PACKEDEVENTINFO{
  6838. DWORD ulSize; //total size of the structure
  6839. DWORD ulNumEventsForLogFile; //number of EventsForLogFile structure that follow
  6840. DWORD ulOffsets[]; //the offsets from the start of this structure to the EVENTSFORLOGFILE structure
  6841. }PACKEDEVENTINFO, *PPACKEDEVENTINFO;
  6842. #if _MSC_VER >= 1200
  6843. #pragma warning(pop)
  6844. #else
  6845. #pragma warning(default : 4200)
  6846. #endif
  6847. //SS: end of changes to support clustering
  6848. //
  6849. // begin_ntddk begin_wdm begin_nthal
  6850. //
  6851. // Registry Specific Access Rights.
  6852. //
  6853. #define KEY_QUERY_VALUE (0x0001)
  6854. #define KEY_SET_VALUE (0x0002)
  6855. #define KEY_CREATE_SUB_KEY (0x0004)
  6856. #define KEY_ENUMERATE_SUB_KEYS (0x0008)
  6857. #define KEY_NOTIFY (0x0010)
  6858. #define KEY_CREATE_LINK (0x0020)
  6859. #define KEY_WOW64_32KEY (0x0200)
  6860. #define KEY_WOW64_64KEY (0x0100)
  6861. #define KEY_WOW64_RES (0x0300)
  6862. #define KEY_READ ((STANDARD_RIGHTS_READ |\
  6863. KEY_QUERY_VALUE |\
  6864. KEY_ENUMERATE_SUB_KEYS |\
  6865. KEY_NOTIFY) \
  6866. & \
  6867. (~SYNCHRONIZE))
  6868. #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
  6869. KEY_SET_VALUE |\
  6870. KEY_CREATE_SUB_KEY) \
  6871. & \
  6872. (~SYNCHRONIZE))
  6873. #define KEY_EXECUTE ((KEY_READ) \
  6874. & \
  6875. (~SYNCHRONIZE))
  6876. #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
  6877. KEY_QUERY_VALUE |\
  6878. KEY_SET_VALUE |\
  6879. KEY_CREATE_SUB_KEY |\
  6880. KEY_ENUMERATE_SUB_KEYS |\
  6881. KEY_NOTIFY |\
  6882. KEY_CREATE_LINK) \
  6883. & \
  6884. (~SYNCHRONIZE))
  6885. //
  6886. // Open/Create Options
  6887. //
  6888. #define REG_OPTION_RESERVED (0x00000000L) // Parameter is reserved
  6889. #define REG_OPTION_NON_VOLATILE (0x00000000L) // Key is preserved
  6890. // when system is rebooted
  6891. #define REG_OPTION_VOLATILE (0x00000001L) // Key is not preserved
  6892. // when system is rebooted
  6893. #define REG_OPTION_CREATE_LINK (0x00000002L) // Created key is a
  6894. // symbolic link
  6895. #define REG_OPTION_BACKUP_RESTORE (0x00000004L) // open for backup or restore
  6896. // special access rules
  6897. // privilege required
  6898. #define REG_OPTION_OPEN_LINK (0x00000008L) // Open symbolic link
  6899. #define REG_LEGAL_OPTION \
  6900. (REG_OPTION_RESERVED |\
  6901. REG_OPTION_NON_VOLATILE |\
  6902. REG_OPTION_VOLATILE |\
  6903. REG_OPTION_CREATE_LINK |\
  6904. REG_OPTION_BACKUP_RESTORE |\
  6905. REG_OPTION_OPEN_LINK)
  6906. //
  6907. // Key creation/open disposition
  6908. //
  6909. #define REG_CREATED_NEW_KEY (0x00000001L) // New Registry Key created
  6910. #define REG_OPENED_EXISTING_KEY (0x00000002L) // Existing Key opened
  6911. //
  6912. // hive format to be used by Reg(Nt)SaveKeyEx
  6913. //
  6914. #define REG_STANDARD_FORMAT 1
  6915. #define REG_LATEST_FORMAT 2
  6916. #define REG_NO_COMPRESSION 4
  6917. //
  6918. // Key restore flags
  6919. //
  6920. #define REG_WHOLE_HIVE_VOLATILE (0x00000001L) // Restore whole hive volatile
  6921. #define REG_REFRESH_HIVE (0x00000002L) // Unwind changes to last flush
  6922. #define REG_NO_LAZY_FLUSH (0x00000004L) // Never lazy flush this hive
  6923. #define REG_FORCE_RESTORE (0x00000008L) // Force the restore process even when we have open handles on subkeys
  6924. // end_ntddk end_wdm end_nthal
  6925. //
  6926. // Notify filter values
  6927. //
  6928. #define REG_NOTIFY_CHANGE_NAME (0x00000001L) // Create or delete (child)
  6929. #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
  6930. #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L) // time stamp
  6931. #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
  6932. #define REG_LEGAL_CHANGE_FILTER \
  6933. (REG_NOTIFY_CHANGE_NAME |\
  6934. REG_NOTIFY_CHANGE_ATTRIBUTES |\
  6935. REG_NOTIFY_CHANGE_LAST_SET |\
  6936. REG_NOTIFY_CHANGE_SECURITY)
  6937. //
  6938. //
  6939. // Predefined Value Types.
  6940. //
  6941. #define REG_NONE ( 0 ) // No value type
  6942. #define REG_SZ ( 1 ) // Unicode nul terminated string
  6943. #define REG_EXPAND_SZ ( 2 ) // Unicode nul terminated string
  6944. // (with environment variable references)
  6945. #define REG_BINARY ( 3 ) // Free form binary
  6946. #define REG_DWORD ( 4 ) // 32-bit number
  6947. #define REG_DWORD_LITTLE_ENDIAN ( 4 ) // 32-bit number (same as REG_DWORD)
  6948. #define REG_DWORD_BIG_ENDIAN ( 5 ) // 32-bit number
  6949. #define REG_LINK ( 6 ) // Symbolic Link (unicode)
  6950. #define REG_MULTI_SZ ( 7 ) // Multiple Unicode strings
  6951. #define REG_RESOURCE_LIST ( 8 ) // Resource list in the resource map
  6952. #define REG_FULL_RESOURCE_DESCRIPTOR ( 9 ) // Resource list in the hardware description
  6953. #define REG_RESOURCE_REQUIREMENTS_LIST ( 10 )
  6954. #define REG_QWORD ( 11 ) // 64-bit number
  6955. #define REG_QWORD_LITTLE_ENDIAN ( 11 ) // 64-bit number (same as REG_QWORD)
  6956. // end_ntddk end_wdm end_nthal
  6957. // begin_ntddk begin_wdm begin_nthal
  6958. //
  6959. // Service Types (Bit Mask)
  6960. //
  6961. #define SERVICE_KERNEL_DRIVER 0x00000001
  6962. #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
  6963. #define SERVICE_ADAPTER 0x00000004
  6964. #define SERVICE_RECOGNIZER_DRIVER 0x00000008
  6965. #define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \
  6966. SERVICE_FILE_SYSTEM_DRIVER | \
  6967. SERVICE_RECOGNIZER_DRIVER)
  6968. #define SERVICE_WIN32_OWN_PROCESS 0x00000010
  6969. #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
  6970. #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \
  6971. SERVICE_WIN32_SHARE_PROCESS)
  6972. #define SERVICE_INTERACTIVE_PROCESS 0x00000100
  6973. #define SERVICE_TYPE_ALL (SERVICE_WIN32 | \
  6974. SERVICE_ADAPTER | \
  6975. SERVICE_DRIVER | \
  6976. SERVICE_INTERACTIVE_PROCESS)
  6977. //
  6978. // Start Type
  6979. //
  6980. #define SERVICE_BOOT_START 0x00000000
  6981. #define SERVICE_SYSTEM_START 0x00000001
  6982. #define SERVICE_AUTO_START 0x00000002
  6983. #define SERVICE_DEMAND_START 0x00000003
  6984. #define SERVICE_DISABLED 0x00000004
  6985. //
  6986. // Error control type
  6987. //
  6988. #define SERVICE_ERROR_IGNORE 0x00000000
  6989. #define SERVICE_ERROR_NORMAL 0x00000001
  6990. #define SERVICE_ERROR_SEVERE 0x00000002
  6991. #define SERVICE_ERROR_CRITICAL 0x00000003
  6992. //
  6993. //
  6994. // Define the registry driver node enumerations
  6995. //
  6996. typedef enum _CM_SERVICE_NODE_TYPE {
  6997. DriverType = SERVICE_KERNEL_DRIVER,
  6998. FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
  6999. Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
  7000. Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
  7001. AdapterType = SERVICE_ADAPTER,
  7002. RecognizerType = SERVICE_RECOGNIZER_DRIVER
  7003. } SERVICE_NODE_TYPE;
  7004. typedef enum _CM_SERVICE_LOAD_TYPE {
  7005. BootLoad = SERVICE_BOOT_START,
  7006. SystemLoad = SERVICE_SYSTEM_START,
  7007. AutoLoad = SERVICE_AUTO_START,
  7008. DemandLoad = SERVICE_DEMAND_START,
  7009. DisableLoad = SERVICE_DISABLED
  7010. } SERVICE_LOAD_TYPE;
  7011. typedef enum _CM_ERROR_CONTROL_TYPE {
  7012. IgnoreError = SERVICE_ERROR_IGNORE,
  7013. NormalError = SERVICE_ERROR_NORMAL,
  7014. SevereError = SERVICE_ERROR_SEVERE,
  7015. CriticalError = SERVICE_ERROR_CRITICAL
  7016. } SERVICE_ERROR_TYPE;
  7017. //
  7018. // IOCTL_TAPE_ERASE definitions
  7019. //
  7020. #define TAPE_ERASE_SHORT 0L
  7021. #define TAPE_ERASE_LONG 1L
  7022. typedef struct _TAPE_ERASE {
  7023. DWORD Type;
  7024. BOOLEAN Immediate;
  7025. } TAPE_ERASE, *PTAPE_ERASE;
  7026. //
  7027. // IOCTL_TAPE_PREPARE definitions
  7028. //
  7029. #define TAPE_LOAD 0L
  7030. #define TAPE_UNLOAD 1L
  7031. #define TAPE_TENSION 2L
  7032. #define TAPE_LOCK 3L
  7033. #define TAPE_UNLOCK 4L
  7034. #define TAPE_FORMAT 5L
  7035. typedef struct _TAPE_PREPARE {
  7036. DWORD Operation;
  7037. BOOLEAN Immediate;
  7038. } TAPE_PREPARE, *PTAPE_PREPARE;
  7039. //
  7040. // IOCTL_TAPE_WRITE_MARKS definitions
  7041. //
  7042. #define TAPE_SETMARKS 0L
  7043. #define TAPE_FILEMARKS 1L
  7044. #define TAPE_SHORT_FILEMARKS 2L
  7045. #define TAPE_LONG_FILEMARKS 3L
  7046. typedef struct _TAPE_WRITE_MARKS {
  7047. DWORD Type;
  7048. DWORD Count;
  7049. BOOLEAN Immediate;
  7050. } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
  7051. //
  7052. // IOCTL_TAPE_GET_POSITION definitions
  7053. //
  7054. #define TAPE_ABSOLUTE_POSITION 0L
  7055. #define TAPE_LOGICAL_POSITION 1L
  7056. #define TAPE_PSEUDO_LOGICAL_POSITION 2L
  7057. typedef struct _TAPE_GET_POSITION {
  7058. DWORD Type;
  7059. DWORD Partition;
  7060. LARGE_INTEGER Offset;
  7061. } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
  7062. //
  7063. // IOCTL_TAPE_SET_POSITION definitions
  7064. //
  7065. #define TAPE_REWIND 0L
  7066. #define TAPE_ABSOLUTE_BLOCK 1L
  7067. #define TAPE_LOGICAL_BLOCK 2L
  7068. #define TAPE_PSEUDO_LOGICAL_BLOCK 3L
  7069. #define TAPE_SPACE_END_OF_DATA 4L
  7070. #define TAPE_SPACE_RELATIVE_BLOCKS 5L
  7071. #define TAPE_SPACE_FILEMARKS 6L
  7072. #define TAPE_SPACE_SEQUENTIAL_FMKS 7L
  7073. #define TAPE_SPACE_SETMARKS 8L
  7074. #define TAPE_SPACE_SEQUENTIAL_SMKS 9L
  7075. typedef struct _TAPE_SET_POSITION {
  7076. DWORD Method;
  7077. DWORD Partition;
  7078. LARGE_INTEGER Offset;
  7079. BOOLEAN Immediate;
  7080. } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
  7081. //
  7082. // IOCTL_TAPE_GET_DRIVE_PARAMS definitions
  7083. //
  7084. //
  7085. // Definitions for FeaturesLow parameter
  7086. //
  7087. #define TAPE_DRIVE_FIXED 0x00000001
  7088. #define TAPE_DRIVE_SELECT 0x00000002
  7089. #define TAPE_DRIVE_INITIATOR 0x00000004
  7090. #define TAPE_DRIVE_ERASE_SHORT 0x00000010
  7091. #define TAPE_DRIVE_ERASE_LONG 0x00000020
  7092. #define TAPE_DRIVE_ERASE_BOP_ONLY 0x00000040
  7093. #define TAPE_DRIVE_ERASE_IMMEDIATE 0x00000080
  7094. #define TAPE_DRIVE_TAPE_CAPACITY 0x00000100
  7095. #define TAPE_DRIVE_TAPE_REMAINING 0x00000200
  7096. #define TAPE_DRIVE_FIXED_BLOCK 0x00000400
  7097. #define TAPE_DRIVE_VARIABLE_BLOCK 0x00000800
  7098. #define TAPE_DRIVE_WRITE_PROTECT 0x00001000
  7099. #define TAPE_DRIVE_EOT_WZ_SIZE 0x00002000
  7100. #define TAPE_DRIVE_ECC 0x00010000
  7101. #define TAPE_DRIVE_COMPRESSION 0x00020000
  7102. #define TAPE_DRIVE_PADDING 0x00040000
  7103. #define TAPE_DRIVE_REPORT_SMKS 0x00080000
  7104. #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000
  7105. #define TAPE_DRIVE_GET_LOGICAL_BLK 0x00200000
  7106. #define TAPE_DRIVE_SET_EOT_WZ_SIZE 0x00400000
  7107. #define TAPE_DRIVE_EJECT_MEDIA 0x01000000
  7108. #define TAPE_DRIVE_CLEAN_REQUESTS 0x02000000
  7109. #define TAPE_DRIVE_SET_CMP_BOP_ONLY 0x04000000
  7110. #define TAPE_DRIVE_RESERVED_BIT 0x80000000 //don't use this bit!
  7111. // //can't be a low features bit!
  7112. // //reserved; high features only
  7113. //
  7114. // Definitions for FeaturesHigh parameter
  7115. //
  7116. #define TAPE_DRIVE_LOAD_UNLOAD 0x80000001
  7117. #define TAPE_DRIVE_TENSION 0x80000002
  7118. #define TAPE_DRIVE_LOCK_UNLOCK 0x80000004
  7119. #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
  7120. #define TAPE_DRIVE_SET_BLOCK_SIZE 0x80000010
  7121. #define TAPE_DRIVE_LOAD_UNLD_IMMED 0x80000020
  7122. #define TAPE_DRIVE_TENSION_IMMED 0x80000040
  7123. #define TAPE_DRIVE_LOCK_UNLK_IMMED 0x80000080
  7124. #define TAPE_DRIVE_SET_ECC 0x80000100
  7125. #define TAPE_DRIVE_SET_COMPRESSION 0x80000200
  7126. #define TAPE_DRIVE_SET_PADDING 0x80000400
  7127. #define TAPE_DRIVE_SET_REPORT_SMKS 0x80000800
  7128. #define TAPE_DRIVE_ABSOLUTE_BLK 0x80001000
  7129. #define TAPE_DRIVE_ABS_BLK_IMMED 0x80002000
  7130. #define TAPE_DRIVE_LOGICAL_BLK 0x80004000
  7131. #define TAPE_DRIVE_LOG_BLK_IMMED 0x80008000
  7132. #define TAPE_DRIVE_END_OF_DATA 0x80010000
  7133. #define TAPE_DRIVE_RELATIVE_BLKS 0x80020000
  7134. #define TAPE_DRIVE_FILEMARKS 0x80040000
  7135. #define TAPE_DRIVE_SEQUENTIAL_FMKS 0x80080000
  7136. #define TAPE_DRIVE_SETMARKS 0x80100000
  7137. #define TAPE_DRIVE_SEQUENTIAL_SMKS 0x80200000
  7138. #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
  7139. #define TAPE_DRIVE_SPACE_IMMEDIATE 0x80800000
  7140. #define TAPE_DRIVE_WRITE_SETMARKS 0x81000000
  7141. #define TAPE_DRIVE_WRITE_FILEMARKS 0x82000000
  7142. #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
  7143. #define TAPE_DRIVE_WRITE_LONG_FMKS 0x88000000
  7144. #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
  7145. #define TAPE_DRIVE_FORMAT 0xA0000000
  7146. #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
  7147. #define TAPE_DRIVE_HIGH_FEATURES 0x80000000 //mask for high features flag
  7148. typedef struct _TAPE_GET_DRIVE_PARAMETERS {
  7149. BOOLEAN ECC;
  7150. BOOLEAN Compression;
  7151. BOOLEAN DataPadding;
  7152. BOOLEAN ReportSetmarks;
  7153. DWORD DefaultBlockSize;
  7154. DWORD MaximumBlockSize;
  7155. DWORD MinimumBlockSize;
  7156. DWORD MaximumPartitionCount;
  7157. DWORD FeaturesLow;
  7158. DWORD FeaturesHigh;
  7159. DWORD EOTWarningZoneSize;
  7160. } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
  7161. //
  7162. // IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions
  7163. //
  7164. typedef struct _TAPE_SET_DRIVE_PARAMETERS {
  7165. BOOLEAN ECC;
  7166. BOOLEAN Compression;
  7167. BOOLEAN DataPadding;
  7168. BOOLEAN ReportSetmarks;
  7169. DWORD EOTWarningZoneSize;
  7170. } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
  7171. //
  7172. // IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions
  7173. //
  7174. typedef struct _TAPE_GET_MEDIA_PARAMETERS {
  7175. LARGE_INTEGER Capacity;
  7176. LARGE_INTEGER Remaining;
  7177. DWORD BlockSize;
  7178. DWORD PartitionCount;
  7179. BOOLEAN WriteProtected;
  7180. } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
  7181. //
  7182. // IOCTL_TAPE_SET_MEDIA_PARAMETERS definitions
  7183. //
  7184. typedef struct _TAPE_SET_MEDIA_PARAMETERS {
  7185. DWORD BlockSize;
  7186. } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
  7187. //
  7188. // IOCTL_TAPE_CREATE_PARTITION definitions
  7189. //
  7190. #define TAPE_FIXED_PARTITIONS 0L
  7191. #define TAPE_SELECT_PARTITIONS 1L
  7192. #define TAPE_INITIATOR_PARTITIONS 2L
  7193. typedef struct _TAPE_CREATE_PARTITION {
  7194. DWORD Method;
  7195. DWORD Count;
  7196. DWORD Size;
  7197. } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
  7198. //
  7199. // WMI Methods
  7200. //
  7201. #define TAPE_QUERY_DRIVE_PARAMETERS 0L
  7202. #define TAPE_QUERY_MEDIA_CAPACITY 1L
  7203. #define TAPE_CHECK_FOR_DRIVE_PROBLEM 2L
  7204. #define TAPE_QUERY_IO_ERROR_DATA 3L
  7205. #define TAPE_QUERY_DEVICE_ERROR_DATA 4L
  7206. typedef struct _TAPE_WMI_OPERATIONS {
  7207. DWORD Method;
  7208. DWORD DataBufferSize;
  7209. PVOID DataBuffer;
  7210. } TAPE_WMI_OPERATIONS, *PTAPE_WMI_OPERATIONS;
  7211. //
  7212. // Type of drive errors
  7213. //
  7214. typedef enum _TAPE_DRIVE_PROBLEM_TYPE {
  7215. TapeDriveProblemNone, TapeDriveReadWriteWarning,
  7216. TapeDriveReadWriteError, TapeDriveReadWarning,
  7217. TapeDriveWriteWarning, TapeDriveReadError,
  7218. TapeDriveWriteError, TapeDriveHardwareError,
  7219. TapeDriveUnsupportedMedia, TapeDriveScsiConnectionError,
  7220. TapeDriveTimetoClean, TapeDriveCleanDriveNow,
  7221. TapeDriveMediaLifeExpired, TapeDriveSnappedTape
  7222. } TAPE_DRIVE_PROBLEM_TYPE;
  7223. #if defined(_M_AMD64) && !defined(__midl)
  7224. __forceinline
  7225. PVOID
  7226. GetCurrentFiber (
  7227. VOID
  7228. )
  7229. {
  7230. return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, FiberData));
  7231. }
  7232. __forceinline
  7233. PVOID
  7234. GetFiberData (
  7235. VOID
  7236. )
  7237. {
  7238. return *(PVOID *)GetCurrentFiber();
  7239. }
  7240. #endif // _M_AMD64 && !defined(__midl)
  7241. #if (_WIN32_WINNT > 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED // winnt_only
  7242. #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION (1)
  7243. #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION (2)
  7244. #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION (3)
  7245. #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION (4)
  7246. #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION (5)
  7247. #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION (6)
  7248. #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION (7)
  7249. #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE (8)
  7250. #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES (9)
  7251. #endif // winnt_only
  7252. #ifdef __cplusplus
  7253. }
  7254. #endif
  7255. #endif /* _WINNT_ */