home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / WINNT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  206.7 KB  |  6,070 lines

  1. /*++ BUILD Version: 0094     Increment this if a change has global effects
  2.  
  3. Copyright 1990 - 1998 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     winnt.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the 32-Bit Windows types and constants that are
  12.     defined by NT, but exposed through the Win32 API.
  13.  
  14. Revision History:
  15.  
  16. --*/
  17.  
  18. #ifndef _WINNT_
  19. #pragma option push -b -a8 -pc -A- /*P_O_Push_S*/
  20. #define _WINNT_
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. #include <ctype.h>  
  27. #define ANYSIZE_ARRAY 1       
  28.  
  29. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  30. #define RESTRICTED_POINTER __restrict
  31. #else
  32. #define RESTRICTED_POINTER
  33. #endif
  34.  
  35. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC)
  36. #define UNALIGNED __unaligned
  37. #else
  38. #define UNALIGNED
  39. #endif
  40.  
  41. #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_ALPHA)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  42. #define POINTER_64 __ptr64
  43. typedef unsigned __int64 POINTER_64_INT;
  44. #else
  45. #if defined(_MAC) && defined(_MAC_INT_64)
  46. #define POINTER_64 __ptr64
  47. typedef unsigned __int64 POINTER_64_INT;
  48. #else
  49. #define POINTER_64
  50. typedef unsigned long POINTER_64_INT;
  51. #endif
  52. #endif
  53.  
  54.  
  55. #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
  56. #define DECLSPEC_IMPORT __declspec(dllimport)
  57. #else
  58. #define DECLSPEC_IMPORT
  59. #endif
  60.  
  61.  
  62. typedef void *PVOID;
  63. typedef void * POINTER_64 PVOID64;
  64.  
  65.  
  66. #if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
  67. #define NTAPI __stdcall
  68. #else
  69. #define _cdecl
  70. #define NTAPI
  71. #endif
  72.  
  73. //
  74. // Define API decoration for direct importing system DLL references.
  75. //
  76.  
  77. #if !defined(_NTSYSTEM_)
  78. #define NTSYSAPI DECLSPEC_IMPORT
  79. #else
  80. #define NTSYSAPI
  81. #endif
  82.  
  83.  
  84. //
  85. // Basics
  86. //
  87.  
  88. #ifndef VOID
  89. #define VOID void
  90. typedef char CHAR;
  91. typedef short SHORT;
  92. typedef long LONG;
  93. #endif
  94.  
  95. //
  96. // UNICODE (Wide Character) types
  97. //
  98.  
  99. #ifndef _MAC
  100. typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
  101. #else
  102. // some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
  103. typedef unsigned short WCHAR;    // wc,   16-bit UNICODE character
  104. #endif
  105.  
  106. typedef WCHAR *PWCHAR;
  107. typedef WCHAR *LPWCH, *PWCH;
  108. typedef CONST WCHAR *LPCWCH, *PCWCH;
  109. typedef WCHAR *NWPSTR;
  110. typedef WCHAR *LPWSTR, *PWSTR;
  111.  
  112. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  113.  
  114. //
  115. // ANSI (Multi-byte Character) types
  116. //
  117. typedef CHAR *PCHAR;
  118. typedef CHAR *LPCH, *PCH;
  119.  
  120. typedef CONST CHAR *LPCCH, *PCCH;
  121. typedef CHAR *NPSTR;
  122. typedef CHAR *LPSTR, *PSTR;
  123. typedef CONST CHAR *LPCSTR, *PCSTR;
  124.  
  125. //
  126. // Neutral ANSI/UNICODE types and macros
  127. //
  128. #ifdef  UNICODE                     // r_winnt
  129.  
  130. #ifndef _TCHAR_DEFINED
  131. typedef WCHAR TCHAR, *PTCHAR;
  132. typedef WCHAR TBYTE , *PTBYTE ;
  133. #define _TCHAR_DEFINED
  134. #endif /* !_TCHAR_DEFINED */
  135.  
  136. typedef LPWSTR LPTCH, PTCH;
  137. typedef LPWSTR PTSTR, LPTSTR;
  138. typedef LPCWSTR LPCTSTR;
  139. typedef LPWSTR LP;
  140. #define __TEXT(quote) L##quote      // r_winnt
  141.  
  142. #else   /* UNICODE */               // r_winnt
  143.  
  144. #ifndef _TCHAR_DEFINED
  145. typedef char TCHAR, *PTCHAR;
  146. typedef unsigned char TBYTE , *PTBYTE ;
  147. #define _TCHAR_DEFINED
  148. #endif /* !_TCHAR_DEFINED */
  149.  
  150. typedef LPSTR LPTCH, PTCH;
  151. typedef LPSTR PTSTR, LPTSTR;
  152. typedef LPCSTR LPCTSTR;
  153. #define __TEXT(quote) quote         // r_winnt
  154.  
  155. #endif /* UNICODE */                // r_winnt
  156. #define TEXT(quote) __TEXT(quote)   // r_winnt
  157.  
  158.  
  159. typedef SHORT *PSHORT;  
  160. typedef LONG *PLONG;    
  161.  
  162. #ifdef STRICT
  163. typedef void *HANDLE;
  164. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  165. #else
  166. typedef PVOID HANDLE;
  167. #define DECLARE_HANDLE(name) typedef HANDLE name
  168. #endif
  169. typedef HANDLE *PHANDLE;
  170.  
  171. //
  172. // Flag (bit) fields
  173. //
  174.  
  175. typedef BYTE   FCHAR;
  176. typedef WORD   FSHORT;
  177. typedef DWORD  FLONG;
  178.  
  179. // Component Object Model defines, and macros
  180.  
  181. #ifndef _HRESULT_DEFINED
  182. #define _HRESULT_DEFINED
  183. typedef LONG HRESULT;
  184.  
  185. #endif // !_HRESULT_DEFINED
  186.  
  187. #ifdef __cplusplus
  188.     #define EXTERN_C    extern "C"
  189. #else
  190.     #define EXTERN_C    extern
  191. #endif
  192.  
  193. #if defined(_WIN32) || defined(_MPPC_)
  194.  
  195. // Win32 doesn't support __export
  196.  
  197. #ifdef _68K_
  198. #define STDMETHODCALLTYPE       __cdecl
  199. #else
  200. #define STDMETHODCALLTYPE       __stdcall
  201. #endif
  202. #define STDMETHODVCALLTYPE      __cdecl
  203.  
  204. #define STDAPICALLTYPE          __stdcall
  205. #define STDAPIVCALLTYPE         __cdecl
  206.  
  207. #else
  208.  
  209. #define STDMETHODCALLTYPE       __export __stdcall
  210. #define STDMETHODVCALLTYPE      __export __cdecl
  211.  
  212. #define STDAPICALLTYPE          __export __stdcall
  213. #define STDAPIVCALLTYPE         __export __cdecl
  214.  
  215. #endif
  216.  
  217.  
  218. #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
  219. #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
  220.  
  221. #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
  222. #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
  223.  
  224. // The 'V' versions allow Variable Argument lists.
  225.  
  226. #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
  227. #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
  228.  
  229. #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
  230. #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
  231.  
  232. typedef char CCHAR;          
  233. typedef DWORD LCID;         
  234. typedef PDWORD PLCID;       
  235. typedef WORD   LANGID;      
  236. /*lint -e624 */  
  237. /*lint +e624 */  
  238. #define APPLICATION_ERROR_MASK       0x20000000
  239. #define ERROR_SEVERITY_SUCCESS       0x00000000
  240. #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
  241. #define ERROR_SEVERITY_WARNING       0x80000000
  242. #define ERROR_SEVERITY_ERROR         0xC0000000
  243.  
  244. //
  245. // __int64 is only supported by 2.0 and later midl.
  246. // __midl is set by the 2.0 midl and not by 1.0 midl.
  247. //
  248.  
  249. #define _DWORDLONG_
  250. #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64)))
  251. typedef __int64 LONGLONG;
  252. typedef unsigned __int64 DWORDLONG;
  253.  
  254. #define MAXLONGLONG                      (0x7fffffffffffffff)
  255. #else
  256.  
  257. #if defined(_MAC) && defined(_MAC_INT_64)
  258. typedef __int64 LONGLONG;
  259. typedef unsigned __int64 DWORDLONG;
  260.  
  261. #define MAXLONGLONG                      (0x7fffffffffffffff)
  262. #else
  263. typedef double LONGLONG;
  264. typedef double DWORDLONG;
  265. #endif //_MAC and int64
  266.  
  267. #endif
  268.  
  269. typedef LONGLONG *PLONGLONG;
  270. typedef DWORDLONG *PDWORDLONG;
  271.  
  272. // Update Sequence Number
  273.  
  274. typedef LONGLONG USN;
  275.  
  276. #if defined(MIDL_PASS)
  277. typedef struct _LARGE_INTEGER {
  278. #else // MIDL_PASS
  279. typedef union _LARGE_INTEGER {
  280.     struct {
  281.         DWORD LowPart;
  282.         LONG HighPart;
  283.     };
  284.     struct {
  285.         DWORD LowPart;
  286.         LONG HighPart;
  287.     } u;
  288. #endif //MIDL_PASS
  289.     LONGLONG QuadPart;
  290. } LARGE_INTEGER;
  291.  
  292. typedef LARGE_INTEGER *PLARGE_INTEGER;
  293.  
  294.  
  295. #if defined(MIDL_PASS)
  296. typedef struct _ULARGE_INTEGER {
  297. #else // MIDL_PASS
  298. typedef union _ULARGE_INTEGER {
  299.     struct {
  300.         DWORD LowPart;
  301.         DWORD HighPart;
  302.     };
  303.     struct {
  304.         DWORD LowPart;
  305.         DWORD HighPart;
  306.     } u;
  307. #endif //MIDL_PASS
  308.     DWORDLONG QuadPart;
  309. } ULARGE_INTEGER;
  310.  
  311. typedef ULARGE_INTEGER *PULARGE_INTEGER;
  312.  
  313. // end_ntminiport end_ntndis end_ntminitape
  314.  
  315.  
  316. //
  317. // Locally Unique Identifier
  318. //
  319.  
  320. typedef struct _LUID {
  321.     DWORD LowPart;
  322.     LONG HighPart;
  323. } LUID, *PLUID;
  324.  
  325.  
  326. //
  327. // Define operations to logically shift an int64 by 0..31 bits and to multiply
  328. // 32-bits by 32-bits to form a 64-bit product.
  329. //
  330.  
  331. #if defined(MIDL_PASS) || defined(RC_INVOKED)
  332.  
  333. //
  334. // Midl does not understand inline assembler. Therefore, the Rtl functions
  335. // are used for shifts by 0.31 and multiplies of 32-bits times 32-bits to
  336. // form a 64-bit product.
  337. //
  338.  
  339. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  340. #define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b)))
  341.  
  342. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  343. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  344. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  345.  
  346. #elif defined(_M_MRX000)
  347.  
  348. //
  349. // MIPS uses intrinsic functions to perform shifts by 0..31 and multiplies of
  350. // 32-bits times 32-bits to 64-bits.
  351. //
  352.  
  353. #define Int32x32To64 __emul
  354. #define UInt32x32To64 __emulu
  355.  
  356. #define Int64ShllMod32 __ll_lshift
  357. #define Int64ShraMod32 __ll_rshift
  358. #define Int64ShrlMod32 __ull_rshift
  359.  
  360. #if defined (__cplusplus)
  361. extern "C" {
  362. #endif
  363.  
  364. LONGLONG
  365. NTAPI
  366. Int32x32To64 (
  367.     LONG Multiplier,
  368.     LONG Multiplicand
  369.     );
  370.  
  371. DWORDLONG
  372. NTAPI
  373. UInt32x32To64 (
  374.     DWORD Multiplier,
  375.     DWORD Multiplicand
  376.     );
  377.  
  378. DWORDLONG
  379. NTAPI
  380. Int64ShllMod32 (
  381.     DWORDLONG Value,
  382.     DWORD ShiftCount
  383.     );
  384.  
  385. LONGLONG
  386. NTAPI
  387. Int64ShraMod32 (
  388.     LONGLONG Value,
  389.     DWORD ShiftCount
  390.     );
  391.  
  392. DWORDLONG
  393. NTAPI
  394. Int64ShrlMod32 (
  395.     DWORDLONG Value,
  396.     DWORD ShiftCount
  397.     );
  398.  
  399. #if defined (__cplusplus)
  400. };
  401. #endif
  402.  
  403. #pragma intrinsic(__emul)
  404. #pragma intrinsic(__emulu)
  405.  
  406. #pragma intrinsic(__ll_lshift)
  407. #pragma intrinsic(__ll_rshift)
  408. #pragma intrinsic(__ull_rshift)
  409.  
  410. #elif defined(_M_IX86)
  411.  
  412. //
  413. // The x86 C compiler understands inline assembler. Therefore, inline functions
  414. // that employ inline assembler are used for shifts of 0..31.  The multiplies
  415. // rely on the compiler recognizing the cast of the multiplicand to int64 to
  416. // generate the optimal code inline.
  417. //
  418.  
  419. #define Int32x32To64( a, b ) (LONGLONG)((LONGLONG)(LONG)(a) * (LONG)(b))
  420. #define UInt32x32To64( a, b ) (DWORDLONG)((DWORDLONG)(DWORD)(a) * (DWORD)(b))
  421.  
  422. #if !defined (__BORLANDC__)
  423.  
  424. DWORDLONG
  425. NTAPI
  426. Int64ShllMod32 (
  427.     DWORDLONG Value,
  428.     DWORD ShiftCount
  429.     );
  430.  
  431. LONGLONG
  432. NTAPI
  433. Int64ShraMod32 (
  434.     LONGLONG Value,
  435.     DWORD ShiftCount
  436.     );
  437.  
  438. DWORDLONG
  439. NTAPI
  440. Int64ShrlMod32 (
  441.     DWORDLONG Value,
  442.     DWORD ShiftCount
  443.     );
  444.  
  445. #pragma warning(disable:4035)               // re-enable below
  446.  
  447. __inline DWORDLONG
  448. NTAPI
  449. Int64ShllMod32 (
  450.     DWORDLONG Value,
  451.     DWORD ShiftCount
  452.     )
  453. {
  454.     __asm    {
  455.         mov     ecx, ShiftCount
  456.         mov     eax, dword ptr [Value]
  457.         mov     edx, dword ptr [Value+4]
  458.         shld    edx, eax, cl
  459.         shl     eax, cl
  460.     }
  461. }
  462.  
  463. __inline LONGLONG
  464. NTAPI
  465. Int64ShraMod32 (
  466.     LONGLONG Value,
  467.     DWORD ShiftCount
  468.     )
  469. {
  470.     __asm {
  471.         mov     ecx, ShiftCount
  472.         mov     eax, dword ptr [Value]
  473.         mov     edx, dword ptr [Value+4]
  474.         shrd    eax, edx, cl
  475.         sar     edx, cl
  476.     }
  477. }
  478.  
  479. __inline DWORDLONG
  480. NTAPI
  481. Int64ShrlMod32 (
  482.     DWORDLONG Value,
  483.     DWORD ShiftCount
  484.     )
  485. {
  486.     __asm    {
  487.         mov     ecx, ShiftCount
  488.         mov     eax, dword ptr [Value]
  489.         mov     edx, dword ptr [Value+4]
  490.         shrd    eax, edx, cl
  491.         shr     edx, cl
  492.     }
  493. }
  494.  
  495. #pragma warning(default:4035)
  496.  
  497. #else
  498. /* For Borland, let the compiler generate calls to __int64 helper functions */
  499.  
  500. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  501. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  502. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  503.  
  504. #endif /* !defined (__BORLANDC__) */
  505.  
  506.  
  507.  
  508. #elif defined(_M_ALPHA)
  509.  
  510. //
  511. // Alpha has native 64-bit operations that are just as fast as their 32-bit
  512. // counter parts. Therefore, the int64 data type is used directly to form
  513. // shifts of 0..31 and multiplies of 32-bits times 32-bits to form a 64-bit
  514. // product.
  515. //
  516.  
  517. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  518. #define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b)))
  519.  
  520. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  521. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  522. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  523.  
  524.  
  525. #elif defined(_M_PPC)
  526.  
  527. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  528. #define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b)))
  529.  
  530. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  531. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  532. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  533.  
  534. #elif defined(_68K_) || defined(_MPPC_)
  535.  
  536. //
  537. // The Macintosh 68K and PowerPC compilers do not currently support int64.
  538. //
  539.  
  540. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  541. #define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b)))
  542.  
  543. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  544. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  545. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  546.  
  547. #else
  548.  
  549. #error Must define a target architecture.
  550.  
  551. #endif
  552.  
  553. #define UNICODE_NULL ((WCHAR)0) 
  554. typedef BYTE  BOOLEAN;           
  555. typedef BOOLEAN *PBOOLEAN;       
  556. //
  557. //  Doubly linked list structure.  Can be used as either a list head, or
  558. //  as link words.
  559. //
  560.  
  561. typedef struct _LIST_ENTRY {
  562.    struct _LIST_ENTRY * volatile Flink;
  563.    struct _LIST_ENTRY * volatile Blink;
  564. } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
  565.  
  566. //
  567. //  Singly linked list structure. Can be used as either a list head, or
  568. //  as link words.
  569. //
  570.  
  571. typedef struct _SINGLE_LIST_ENTRY {
  572.     struct _SINGLE_LIST_ENTRY *Next;
  573. } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
  574.  
  575. //
  576. // Base data structures for OLE support
  577. //
  578.  
  579. #ifndef GUID_DEFINED
  580. #define GUID_DEFINED
  581.  
  582. typedef struct _GUID {          // size is 16
  583.     DWORD Data1;
  584.     WORD   Data2;
  585.     WORD   Data3;
  586.     BYTE  Data4[8];
  587. } GUID;
  588.  
  589. #endif // !GUID_DEFINED
  590.  
  591. #ifndef __OBJECTID_DEFINED
  592. #define __OBJECTID_DEFINED
  593.  
  594. typedef struct  _OBJECTID {     // size is 20
  595.     GUID Lineage;
  596.     DWORD Uniquifier;
  597. } OBJECTID;
  598. #endif // !_OBJECTID_DEFINED
  599.  
  600. #define MINCHAR     0x80        
  601. #define MAXCHAR     0x7f        
  602. #define MINSHORT    0x8000      
  603. #define MAXSHORT    0x7fff      
  604. #define MINLONG     0x80000000  
  605. #define MAXLONG     0x7fffffff  
  606. #define MAXBYTE     0xff        
  607. #define MAXWORD     0xffff      
  608. #define MAXDWORD    0xffffffff  
  609. //
  610. // Calculate the byte offset of a field in a structure of type type.
  611. //
  612.  
  613. #define FIELD_OFFSET(type, field)    ((LONG)&(((type *)0)->field))
  614.  
  615.  
  616. //
  617. // Calculate the address of the base of the structure given its type, and an
  618. // address of a field within the structure.
  619. //
  620.  
  621. #define CONTAINING_RECORD(address, type, field) ((type *)( \
  622.                                                   (PCHAR)(address) - \
  623.                                                   (PCHAR)(&((type *)0)->field)))
  624.  
  625. //
  626. //  Language IDs.
  627. //
  628. //  The following two combinations of primary language ID and
  629. //  sublanguage ID have special semantics:
  630. //
  631. //    Primary Language ID   Sublanguage ID      Result
  632. //    -------------------   ---------------     ------------------------
  633. //    LANG_NEUTRAL          SUBLANG_NEUTRAL     Language neutral
  634. //    LANG_NEUTRAL          SUBLANG_DEFAULT     User default language
  635. //    LANG_NEUTRAL          SUBLANG_SYS_DEFAULT System default language
  636. //
  637.  
  638. //
  639. //  Primary language IDs.
  640. //
  641.  
  642. #define LANG_NEUTRAL                     0x00
  643.  
  644. #define LANG_AFRIKAANS                   0x36
  645. #define LANG_ALBANIAN                    0x1c
  646. #define LANG_ARABIC                      0x01
  647. #define LANG_BASQUE                      0x2d
  648. #define LANG_BELARUSIAN                  0x23
  649. #define LANG_BULGARIAN                   0x02
  650. #define LANG_CATALAN                     0x03
  651. #define LANG_CHINESE                     0x04
  652. #define LANG_CROATIAN                    0x1a
  653. #define LANG_CZECH                       0x05
  654. #define LANG_DANISH                      0x06
  655. #define LANG_DUTCH                       0x13
  656. #define LANG_ENGLISH                     0x09
  657. #define LANG_ESTONIAN                    0x25
  658. #define LANG_FAEROESE                    0x38
  659. #define LANG_FARSI                       0x29
  660. #define LANG_FINNISH                     0x0b
  661. #define LANG_FRENCH                      0x0c
  662. #define LANG_GERMAN                      0x07
  663. #define LANG_GREEK                       0x08
  664. #define LANG_HEBREW                      0x0d
  665. #define LANG_HINDI                       0x39
  666. #define LANG_HUNGARIAN                   0x0e
  667. #define LANG_ICELANDIC                   0x0f
  668. #define LANG_INDONESIAN                  0x21
  669. #define LANG_ITALIAN                     0x10
  670. #define LANG_JAPANESE                    0x11
  671. #define LANG_KOREAN                      0x12
  672. #define LANG_LATVIAN                     0x26
  673. #define LANG_LITHUANIAN                  0x27
  674. #define LANG_MACEDONIAN                  0x2f
  675. #define LANG_MALAY                       0x3e
  676. #define LANG_NORWEGIAN                   0x14
  677. #define LANG_POLISH                      0x15
  678. #define LANG_PORTUGUESE                  0x16
  679. #define LANG_ROMANIAN                    0x18
  680. #define LANG_RUSSIAN                     0x19
  681. #define LANG_SERBIAN                     0x1a
  682. #define LANG_SLOVAK                      0x1b
  683. #define LANG_SLOVENIAN                   0x24
  684. #define LANG_SPANISH                     0x0a
  685. #define LANG_SWAHILI                     0x41
  686. #define LANG_SWEDISH                     0x1d
  687. #define LANG_THAI                        0x1e
  688. #define LANG_TURKISH                     0x1f
  689. #define LANG_UKRAINIAN                   0x22
  690. #define LANG_VIETNAMESE                  0x2a
  691.  
  692. //
  693. //  Sublanguage IDs.
  694. //
  695. //  The name immediately following SUBLANG_ dictates which primary
  696. //  language ID that sublanguage ID can be combined with to form a
  697. //  valid language ID.
  698. //
  699.  
  700. #define SUBLANG_NEUTRAL                  0x00    // language neutral
  701. #define SUBLANG_DEFAULT                  0x01    // user default
  702. #define SUBLANG_SYS_DEFAULT              0x02    // system default
  703.  
  704. #define SUBLANG_ARABIC_SAUDI_ARABIA      0x01    // Arabic (Saudi Arabia)
  705. #define SUBLANG_ARABIC_IRAQ              0x02    // Arabic (Iraq)
  706. #define SUBLANG_ARABIC_EGYPT             0x03    // Arabic (Egypt)
  707. #define SUBLANG_ARABIC_LIBYA             0x04    // Arabic (Libya)
  708. #define SUBLANG_ARABIC_ALGERIA           0x05    // Arabic (Algeria)
  709. #define SUBLANG_ARABIC_MOROCCO           0x06    // Arabic (Morocco)
  710. #define SUBLANG_ARABIC_TUNISIA           0x07    // Arabic (Tunisia)
  711. #define SUBLANG_ARABIC_OMAN              0x08    // Arabic (Oman)
  712. #define SUBLANG_ARABIC_YEMEN             0x09    // Arabic (Yemen)
  713. #define SUBLANG_ARABIC_SYRIA             0x0a    // Arabic (Syria)
  714. #define SUBLANG_ARABIC_JORDAN            0x0b    // Arabic (Jordan)
  715. #define SUBLANG_ARABIC_LEBANON           0x0c    // Arabic (Lebanon)
  716. #define SUBLANG_ARABIC_KUWAIT            0x0d    // Arabic (Kuwait)
  717. #define SUBLANG_ARABIC_UAE               0x0e    // Arabic (U.A.E)
  718. #define SUBLANG_ARABIC_BAHRAIN           0x0f    // Arabic (Bahrain)
  719. #define SUBLANG_ARABIC_QATAR             0x10    // Arabic (Qatar)
  720. #define SUBLANG_CHINESE_TRADITIONAL      0x01    // Chinese (Taiwan)
  721. #define SUBLANG_CHINESE_SIMPLIFIED       0x02    // Chinese (PR China)
  722. #define SUBLANG_CHINESE_HONGKONG         0x03    // Chinese (Hong Kong)
  723. #define SUBLANG_CHINESE_SINGAPORE        0x04    // Chinese (Singapore)
  724. #define SUBLANG_CHINESE_MACAU            0x05    // Chinese (Macau)
  725. #define SUBLANG_DUTCH                    0x01    // Dutch
  726. #define SUBLANG_DUTCH_BELGIAN            0x02    // Dutch (Belgian)
  727. #define SUBLANG_ENGLISH_US               0x01    // English (USA)
  728. #define SUBLANG_ENGLISH_UK               0x02    // English (UK)
  729. #define SUBLANG_ENGLISH_AUS              0x03    // English (Australian)
  730. #define SUBLANG_ENGLISH_CAN              0x04    // English (Canadian)
  731. #define SUBLANG_ENGLISH_NZ               0x05    // English (New Zealand)
  732. #define SUBLANG_ENGLISH_EIRE             0x06    // English (Irish)
  733. #define SUBLANG_ENGLISH_SOUTH_AFRICA     0x07    // English (South Africa)
  734. #define SUBLANG_ENGLISH_JAMAICA          0x08    // English (Jamaica)
  735. #define SUBLANG_ENGLISH_CARIBBEAN        0x09    // English (Caribbean)
  736. #define SUBLANG_ENGLISH_BELIZE           0x0a    // English (Belize)
  737. #define SUBLANG_ENGLISH_TRINIDAD         0x0b    // English (Trinidad)
  738. #define SUBLANG_ENGLISH_ZIMBABWE         0x0c    // English (Zimbabwe)
  739. #define SUBLANG_ENGLISH_PHILIPPINES      0x0d    // English (Philippines)
  740. #define SUBLANG_FRENCH                   0x01    // French
  741. #define SUBLANG_FRENCH_BELGIAN           0x02    // French (Belgian)
  742. #define SUBLANG_FRENCH_CANADIAN          0x03    // French (Canadian)
  743. #define SUBLANG_FRENCH_SWISS             0x04    // French (Swiss)
  744. #define SUBLANG_FRENCH_LUXEMBOURG        0x05    // French (Luxembourg)
  745. #define SUBLANG_FRENCH_MONACO            0x06    // French (Monaco)
  746. #define SUBLANG_GERMAN                   0x01    // German
  747. #define SUBLANG_GERMAN_SWISS             0x02    // German (Swiss)
  748. #define SUBLANG_GERMAN_AUSTRIAN          0x03    // German (Austrian)
  749. #define SUBLANG_GERMAN_LUXEMBOURG        0x04    // German (Luxembourg)
  750. #define SUBLANG_GERMAN_LIECHTENSTEIN     0x05    // German (Liechtenstein)
  751. #define SUBLANG_ITALIAN                  0x01    // Italian
  752. #define SUBLANG_ITALIAN_SWISS            0x02    // Italian (Swiss)
  753. #define SUBLANG_KOREAN                   0x01    // Korean (Extended Wansung)
  754. #define SUBLANG_KOREAN_JOHAB             0x02    // Korean (Johab)
  755. #define SUBLANG_LITHUANIAN               0x01    // Lithuanian
  756. #define SUBLANG_LITHUANIAN_CLASSIC       0x02    // Lithuanian (Classic)
  757. #define SUBLANG_MALAY_MALAYSIA           0x01    // Malay (Malaysia)
  758. #define SUBLANG_MALAY_BRUNEI_DARUSSALAM  0x02    // Malay (Brunei Darussalam)
  759. #define SUBLANG_NORWEGIAN_BOKMAL         0x01    // Norwegian (Bokmal)
  760. #define SUBLANG_NORWEGIAN_NYNORSK        0x02    // Norwegian (Nynorsk)
  761. #define SUBLANG_PORTUGUESE               0x02    // Portuguese
  762. #define SUBLANG_PORTUGUESE_BRAZILIAN     0x01    // Portuguese (Brazilian)
  763. #define SUBLANG_SERBIAN_LATIN            0x02    // Serbian (Latin)
  764. #define SUBLANG_SERBIAN_CYRILLIC         0x03    // Serbian (Cyrillic)
  765. #define SUBLANG_SPANISH                  0x01    // Spanish (Castilian)
  766. #define SUBLANG_SPANISH_MEXICAN          0x02    // Spanish (Mexican)
  767. #define SUBLANG_SPANISH_MODERN           0x03    // Spanish (Modern)
  768. #define SUBLANG_SPANISH_GUATEMALA        0x04    // Spanish (Guatemala)
  769. #define SUBLANG_SPANISH_COSTA_RICA       0x05    // Spanish (Costa Rica)
  770. #define SUBLANG_SPANISH_PANAMA           0x06    // Spanish (Panama)
  771. #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07  // Spanish (Dominican Republic)
  772. #define SUBLANG_SPANISH_VENEZUELA        0x08    // Spanish (Venezuela)
  773. #define SUBLANG_SPANISH_COLOMBIA         0x09    // Spanish (Colombia)
  774. #define SUBLANG_SPANISH_PERU             0x0a    // Spanish (Peru)
  775. #define SUBLANG_SPANISH_ARGENTINA        0x0b    // Spanish (Argentina)
  776. #define SUBLANG_SPANISH_ECUADOR          0x0c    // Spanish (Ecuador)
  777. #define SUBLANG_SPANISH_CHILE            0x0d    // Spanish (Chile)
  778. #define SUBLANG_SPANISH_URUGUAY          0x0e    // Spanish (Uruguay)
  779. #define SUBLANG_SPANISH_PARAGUAY         0x0f    // Spanish (Paraguay)
  780. #define SUBLANG_SPANISH_BOLIVIA          0x10    // Spanish (Bolivia)
  781. #define SUBLANG_SPANISH_EL_SALVADOR      0x11    // Spanish (El Salvador)
  782. #define SUBLANG_SPANISH_HONDURAS         0x12    // Spanish (Honduras)
  783. #define SUBLANG_SPANISH_NICARAGUA        0x13    // Spanish (Nicaragua)
  784. #define SUBLANG_SPANISH_PUERTO_RICO      0x14    // Spanish (Puerto Rico)
  785. #define SUBLANG_SWEDISH                  0x01    // Swedish
  786. #define SUBLANG_SWEDISH_FINLAND          0x02    // Swedish (Finland)
  787.  
  788. //
  789. //  Sorting IDs.
  790. //
  791.  
  792. #define SORT_DEFAULT                     0x0     // sorting default
  793.  
  794. #define SORT_JAPANESE_XJIS               0x0     // Japanese XJIS order
  795. #define SORT_JAPANESE_UNICODE            0x1     // Japanese Unicode order
  796.  
  797. #define SORT_CHINESE_BIG5                0x0     // Chinese BIG5 order
  798. #define SORT_CHINESE_PRCP                0x0     // PRC Chinese Phonetic order
  799. #define SORT_CHINESE_UNICODE             0x1     // Chinese Unicode order
  800. #define SORT_CHINESE_PRC                 0x2     // PRC Chinese Stroke Count order
  801.  
  802. #define SORT_KOREAN_KSC                  0x0     // Korean KSC order
  803. #define SORT_KOREAN_UNICODE              0x1     // Korean Unicode order
  804.  
  805. #define SORT_GERMAN_PHONE_BOOK           0x1     // German Phone Book order
  806.  
  807. // end_r_winnt
  808.  
  809. //
  810. //  A language ID is a 16 bit value which is the combination of a
  811. //  primary language ID and a secondary language ID.  The bits are
  812. //  allocated as follows:
  813. //
  814. //       +-----------------------+-------------------------+
  815. //       |     Sublanguage ID    |   Primary Language ID   |
  816. //       +-----------------------+-------------------------+
  817. //        15                   10 9                       0   bit
  818. //
  819. //
  820. //  Language ID creation/extraction macros:
  821. //
  822. //    MAKELANGID    - construct language id from a primary language id and
  823. //                    a sublanguage id.
  824. //    PRIMARYLANGID - extract primary language id from a language id.
  825. //    SUBLANGID     - extract sublanguage id from a language id.
  826. //
  827.  
  828. #define MAKELANGID(p, s)       ((((WORD  )(s)) << 10) | (WORD  )(p))
  829. #define PRIMARYLANGID(lgid)    ((WORD  )(lgid) & 0x3ff)
  830. #define SUBLANGID(lgid)        ((WORD  )(lgid) >> 10)
  831.  
  832.  
  833. //
  834. //  A locale ID is a 32 bit value which is the combination of a
  835. //  language ID, a sort ID, and a reserved area.  The bits are
  836. //  allocated as follows:
  837. //
  838. //       +-------------+---------+-------------------------+
  839. //       |   Reserved  | Sort ID |      Language ID        |
  840. //       +-------------+---------+-------------------------+
  841. //        31         20 19     16 15                      0   bit
  842. //
  843. //
  844. //  Locale ID creation/extraction macros:
  845. //
  846. //    MAKELCID            - construct the locale id from a language id and a sort id.
  847. //    MAKESORTLCID        - construct the locale id from a language id, sort id, and sort version.
  848. //    LANGIDFROMLCID      - extract the language id from a locale id.
  849. //    SORTIDFROMLCID      - extract the sort id from a locale id.
  850. //    SORTVERSIONFROMLCID - extract the sort version from a locale id.
  851. //
  852.  
  853. #define NLS_VALID_LOCALE_MASK  0x000fffff
  854.  
  855. #define MAKELCID(lgid, srtid)  ((DWORD)((((DWORD)((WORD  )(srtid))) << 16) |  \
  856.                                          ((DWORD)((WORD  )(lgid)))))
  857. #define MAKESORTLCID(lgid, srtid, ver)                                            \
  858.                                ((DWORD)((MAKELCID(lgid, srtid)) |             \
  859.                                     (((DWORD)((WORD  )(ver))) << 20)))
  860. #define LANGIDFROMLCID(lcid)   ((WORD  )(lcid))
  861. #define SORTIDFROMLCID(lcid)   ((WORD  )((((DWORD)(lcid)) >> 16) & 0xf))
  862. #define SORTVERSIONFROMLCID(lcid)  ((WORD  )((((DWORD)(lcid)) >> 20) & 0xf))
  863.  
  864.  
  865. //
  866. //  Default System and User IDs for language and locale.
  867. //
  868.  
  869. #define LANG_SYSTEM_DEFAULT    (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
  870. #define LANG_USER_DEFAULT      (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
  871.  
  872. #define LOCALE_SYSTEM_DEFAULT  (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
  873. #define LOCALE_USER_DEFAULT    (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
  874.  
  875. #define LOCALE_NEUTRAL                                                        \
  876.           (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
  877.  
  878.  
  879. // begin_ntminiport begin_ntndis begin_ntminitape
  880.  
  881. //
  882. // Macros used to eliminate compiler warning generated when formal
  883. // parameters or local variables are not declared.
  884. //
  885. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  886. // referenced but will be once the module is completely developed.
  887. //
  888. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  889. // referenced but will be once the module is completely developed.
  890. //
  891. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  892. //
  893. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  894. // eventually be made into a null macro to help determine whether there
  895. // is unfinished work.
  896. //
  897.  
  898. #if ! (defined(lint) || defined(_lint))
  899. #define UNREFERENCED_PARAMETER(P)          (P)
  900. #define DBG_UNREFERENCED_PARAMETER(P)      (P)
  901. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  902.  
  903. #else // lint or _lint
  904.  
  905. // Note: lint -e530 says don't complain about uninitialized variables for
  906. // this.  line +e530 turns that checking back on.  Error 527 has to do with
  907. // unreachable code.
  908.  
  909. #define UNREFERENCED_PARAMETER(P)          \
  910.     /*lint -e527 -e530 */ \
  911.     { \
  912.         (P) = (P); \
  913.     } \
  914.     /*lint +e527 +e530 */
  915. #define DBG_UNREFERENCED_PARAMETER(P)      \
  916.     /*lint -e527 -e530 */ \
  917.     { \
  918.         (P) = (P); \
  919.     } \
  920.     /*lint +e527 +e530 */
  921. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  922.     /*lint -e527 -e530 */ \
  923.     { \
  924.         (V) = (V); \
  925.     } \
  926.     /*lint +e527 +e530 */
  927.  
  928. #endif // lint or _lint
  929.  
  930.  
  931. #ifndef WIN32_NO_STATUS 
  932. /*lint -save -e767 */  
  933. #define STATUS_WAIT_0                    ((DWORD   )0x00000000L)    
  934. #define STATUS_ABANDONED_WAIT_0          ((DWORD   )0x00000080L)    
  935. #define STATUS_USER_APC                  ((DWORD   )0x000000C0L)    
  936. #define STATUS_TIMEOUT                   ((DWORD   )0x00000102L)    
  937. #define STATUS_PENDING                   ((DWORD   )0x00000103L)    
  938. #define STATUS_SEGMENT_NOTIFICATION      ((DWORD   )0x40000005L)    
  939. #define STATUS_GUARD_PAGE_VIOLATION      ((DWORD   )0x80000001L)    
  940. #define STATUS_DATATYPE_MISALIGNMENT     ((DWORD   )0x80000002L)    
  941. #define STATUS_BREAKPOINT                ((DWORD   )0x80000003L)    
  942. #define STATUS_SINGLE_STEP               ((DWORD   )0x80000004L)    
  943. #define STATUS_ACCESS_VIOLATION          ((DWORD   )0xC0000005L)    
  944. #define STATUS_IN_PAGE_ERROR             ((DWORD   )0xC0000006L)    
  945. #define STATUS_INVALID_HANDLE            ((DWORD   )0xC0000008L)    
  946. #define STATUS_NO_MEMORY                 ((DWORD   )0xC0000017L)    
  947. #define STATUS_ILLEGAL_INSTRUCTION       ((DWORD   )0xC000001DL)    
  948. #define STATUS_NONCONTINUABLE_EXCEPTION  ((DWORD   )0xC0000025L)    
  949. #define STATUS_INVALID_DISPOSITION       ((DWORD   )0xC0000026L)    
  950. #define STATUS_ARRAY_BOUNDS_EXCEEDED     ((DWORD   )0xC000008CL)    
  951. #define STATUS_FLOAT_DENORMAL_OPERAND    ((DWORD   )0xC000008DL)    
  952. #define STATUS_FLOAT_DIVIDE_BY_ZERO      ((DWORD   )0xC000008EL)    
  953. #define STATUS_FLOAT_INEXACT_RESULT      ((DWORD   )0xC000008FL)    
  954. #define STATUS_FLOAT_INVALID_OPERATION   ((DWORD   )0xC0000090L)    
  955. #define STATUS_FLOAT_OVERFLOW            ((DWORD   )0xC0000091L)    
  956. #define STATUS_FLOAT_STACK_CHECK         ((DWORD   )0xC0000092L)    
  957. #define STATUS_FLOAT_UNDERFLOW           ((DWORD   )0xC0000093L)    
  958. #define STATUS_INTEGER_DIVIDE_BY_ZERO    ((DWORD   )0xC0000094L)    
  959. #define STATUS_INTEGER_OVERFLOW          ((DWORD   )0xC0000095L)    
  960. #define STATUS_PRIVILEGED_INSTRUCTION    ((DWORD   )0xC0000096L)    
  961. #define STATUS_STACK_OVERFLOW            ((DWORD   )0xC00000FDL)    
  962. #define STATUS_CONTROL_C_EXIT            ((DWORD   )0xC000013AL)    
  963. /*lint -restore */  
  964. #endif 
  965. #define MAXIMUM_WAIT_OBJECTS 64     // Maximum number of wait objects
  966.  
  967. #define MAXIMUM_SUSPEND_COUNT MAXCHAR // Maximum times thread can be suspended
  968. typedef DWORD KSPIN_LOCK;
  969.  
  970. typedef KSPIN_LOCK *PKSPIN_LOCK;
  971.  
  972. #ifdef _ALPHA_                          // winnt
  973. void *_rdteb(void);                     // winnt
  974. #if defined(_M_ALPHA)                   // winnt
  975. #pragma intrinsic(_rdteb)               // winnt
  976. #endif                                  // winnt
  977. #endif                                  // winnt
  978.  
  979. #if defined(_M_ALPHA)
  980. #define NtCurrentTeb() ((struct _TEB *)_rdteb())
  981. #else
  982. struct _TEB *
  983. NtCurrentTeb(void);
  984. #endif
  985.  
  986. //
  987. // Define function to return the current Thread Environment Block
  988. //
  989.  
  990. #ifdef _ALPHA_
  991.  
  992.  
  993.  
  994. //
  995. // Define functions to get the address of the current fiber and the
  996. // current fiber data.
  997. //
  998.  
  999. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  1000. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  1001.  
  1002. // begin_ntddk begin_nthal
  1003. //
  1004. // The following flags control the contents of the CONTEXT structure.
  1005. //
  1006.  
  1007. #if !defined(RC_INVOKED)
  1008.  
  1009. #define CONTEXT_PORTABLE_32BIT     0x00100000
  1010. #define CONTEXT_ALPHA              0x00020000
  1011.  
  1012. #define CONTEXT_CONTROL         (CONTEXT_ALPHA | 0x00000001L)
  1013. #define CONTEXT_FLOATING_POINT  (CONTEXT_ALPHA | 0x00000002L)
  1014. #define CONTEXT_INTEGER         (CONTEXT_ALPHA | 0x00000004L)
  1015.  
  1016. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  1017.  
  1018. #endif
  1019.  
  1020. #ifndef _PORTABLE_32BIT_CONTEXT
  1021.  
  1022. //
  1023. // Context Frame
  1024. //
  1025. //  This frame has a several purposes: 1) it is used as an argument to
  1026. //  NtContinue, 2) it is used to construct a call frame for APC delivery,
  1027. //  3) it is used to construct a call frame for exception dispatching
  1028. //  in user mode, 4) it is used in the user level thread creation
  1029. //  routines, and 5) it is used to to pass thread state to debuggers.
  1030. //
  1031. //  N.B. Because this record is used as a call frame, it must be EXACTLY
  1032. //  a multiple of 16 bytes in length.
  1033. //
  1034. //  There are two variations of the context structure. This is the real one.
  1035. //
  1036.  
  1037. typedef struct _CONTEXT {
  1038.  
  1039.     //
  1040.     // This section is specified/returned if the ContextFlags word contains
  1041.     // the flag CONTEXT_FLOATING_POINT.
  1042.     //
  1043.  
  1044.     DWORDLONG FltF0;
  1045.     DWORDLONG FltF1;
  1046.     DWORDLONG FltF2;
  1047.     DWORDLONG FltF3;
  1048.     DWORDLONG FltF4;
  1049.     DWORDLONG FltF5;
  1050.     DWORDLONG FltF6;
  1051.     DWORDLONG FltF7;
  1052.     DWORDLONG FltF8;
  1053.     DWORDLONG FltF9;
  1054.     DWORDLONG FltF10;
  1055.     DWORDLONG FltF11;
  1056.     DWORDLONG FltF12;
  1057.     DWORDLONG FltF13;
  1058.     DWORDLONG FltF14;
  1059.     DWORDLONG FltF15;
  1060.     DWORDLONG FltF16;
  1061.     DWORDLONG FltF17;
  1062.     DWORDLONG FltF18;
  1063.     DWORDLONG FltF19;
  1064.     DWORDLONG FltF20;
  1065.     DWORDLONG FltF21;
  1066.     DWORDLONG FltF22;
  1067.     DWORDLONG FltF23;
  1068.     DWORDLONG FltF24;
  1069.     DWORDLONG FltF25;
  1070.     DWORDLONG FltF26;
  1071.     DWORDLONG FltF27;
  1072.     DWORDLONG FltF28;
  1073.     DWORDLONG FltF29;
  1074.     DWORDLONG FltF30;
  1075.     DWORDLONG FltF31;
  1076.  
  1077.     //
  1078.     // This section is specified/returned if the ContextFlags word contains
  1079.     // the flag CONTEXT_INTEGER.
  1080.     //
  1081.     // N.B. The registers gp, sp, and ra are defined in this section, but are
  1082.     //  considered part of the control context rather than part of the integer
  1083.     //  context.
  1084.     //
  1085.  
  1086.     DWORDLONG IntV0;    //  $0: return value register, v0
  1087.     DWORDLONG IntT0;    //  $1: temporary registers, t0 - t7
  1088.     DWORDLONG IntT1;    //  $2:
  1089.     DWORDLONG IntT2;    //  $3:
  1090.     DWORDLONG IntT3;    //  $4:
  1091.     DWORDLONG IntT4;    //  $5:
  1092.     DWORDLONG IntT5;    //  $6:
  1093.     DWORDLONG IntT6;    //  $7:
  1094.     DWORDLONG IntT7;    //  $8:
  1095.     DWORDLONG IntS0;    //  $9: nonvolatile registers, s0 - s5
  1096.     DWORDLONG IntS1;    // $10:
  1097.     DWORDLONG IntS2;    // $11:
  1098.     DWORDLONG IntS3;    // $12:
  1099.     DWORDLONG IntS4;    // $13:
  1100.     DWORDLONG IntS5;    // $14:
  1101.     DWORDLONG IntFp;    // $15: frame pointer register, fp/s6
  1102.     DWORDLONG IntA0;    // $16: argument registers, a0 - a5
  1103.     DWORDLONG IntA1;    // $17:
  1104.     DWORDLONG IntA2;    // $18:
  1105.     DWORDLONG IntA3;    // $19:
  1106.     DWORDLONG IntA4;    // $20:
  1107.     DWORDLONG IntA5;    // $21:
  1108.     DWORDLONG IntT8;    // $22: temporary registers, t8 - t11
  1109.     DWORDLONG IntT9;    // $23:
  1110.     DWORDLONG IntT10;   // $24:
  1111.     DWORDLONG IntT11;   // $25:
  1112.     DWORDLONG IntRa;    // $26: return address register, ra
  1113.     DWORDLONG IntT12;   // $27: temporary register, t12
  1114.     DWORDLONG IntAt;    // $28: assembler temp register, at
  1115.     DWORDLONG IntGp;    // $29: global pointer register, gp
  1116.     DWORDLONG IntSp;    // $30: stack pointer register, sp
  1117.     DWORDLONG IntZero;  // $31: zero register, zero
  1118.  
  1119.     //
  1120.     // This section is specified/returned if the ContextFlags word contains
  1121.     // the flag CONTEXT_FLOATING_POINT.
  1122.     //
  1123.  
  1124.     DWORDLONG Fpcr;     // floating point control register
  1125.     DWORDLONG SoftFpcr; // software extension to FPCR
  1126.  
  1127.     //
  1128.     // This section is specified/returned if the ContextFlags word contains
  1129.     // the flag CONTEXT_CONTROL.
  1130.     //
  1131.     // N.B. The registers gp, sp, and ra are defined in the integer section,
  1132.     //   but are considered part of the control context rather than part of
  1133.     //   the integer context.
  1134.     //
  1135.  
  1136.     DWORDLONG Fir;      // (fault instruction) continuation address
  1137.     DWORD Psr;          // processor status
  1138.  
  1139.     //
  1140.     // The flags values within this flag control the contents of
  1141.     // a CONTEXT record.
  1142.     //
  1143.     // If the context record is used as an input parameter, then
  1144.     // for each portion of the context record controlled by a flag
  1145.     // whose value is set, it is assumed that that portion of the
  1146.     // context record contains valid context. If the context record
  1147.     // is being used to modify a thread's context, then only that
  1148.     // portion of the threads context will be modified.
  1149.     //
  1150.     // If the context record is used as an IN OUT parameter to capture
  1151.     // the context of a thread, then only those portions of the thread's
  1152.     // context corresponding to set flags will be returned.
  1153.     //
  1154.     // The context record is never used as an OUT only parameter.
  1155.     //
  1156.  
  1157.     DWORD ContextFlags;
  1158.     DWORD Fill[4];      // padding for 16-byte stack frame alignment
  1159.  
  1160. } CONTEXT, *PCONTEXT;
  1161.  
  1162. #else
  1163.  
  1164. //
  1165. // 32-bit Context Frame
  1166. //
  1167. //  This alternate version of the Alpha context structure parallels that
  1168. //  of MIPS and IX86 in style for the first 64 entries: 32-bit machines
  1169. //  can operate on the fields, and a value declared as a pointer to an
  1170. //  array of int's can be used to index into the fields.  This makes life
  1171. //  with windbg and ntsd vastly easier.
  1172. //
  1173. //  There are two parts: the first contains the lower 32-bits of each
  1174. //  element in the 64-bit definition above.  The second part contains
  1175. //  the upper 32-bits of each 64-bit element above.
  1176. //
  1177. //  The names in the first part are identical to the 64-bit names.
  1178. //  The second part names are prefixed with "High".
  1179. //
  1180. //  1st half: at 32 bits each, (containing the low parts of 64-bit values)
  1181. //      32 floats, 32 ints, fpcrs, fir, psr, contextflags
  1182. //  2nd half: at 32 bits each
  1183. //      32 floats, 32 ints, fpcrs, fir, fill
  1184. //
  1185. //  There is no external support for the 32-bit version of the context
  1186. //  structure.  It is only used internally by windbg and ntsd.
  1187. //
  1188. //  This structure must be the same size as the 64-bit version above.
  1189. //
  1190.  
  1191. typedef struct _CONTEXT {
  1192.  
  1193.     DWORD FltF0;
  1194.     DWORD FltF1;
  1195.     DWORD FltF2;
  1196.     DWORD FltF3;
  1197.     DWORD FltF4;
  1198.     DWORD FltF5;
  1199.     DWORD FltF6;
  1200.     DWORD FltF7;
  1201.     DWORD FltF8;
  1202.     DWORD FltF9;
  1203.     DWORD FltF10;
  1204.     DWORD FltF11;
  1205.     DWORD FltF12;
  1206.     DWORD FltF13;
  1207.     DWORD FltF14;
  1208.     DWORD FltF15;
  1209.     DWORD FltF16;
  1210.     DWORD FltF17;
  1211.     DWORD FltF18;
  1212.     DWORD FltF19;
  1213.     DWORD FltF20;
  1214.     DWORD FltF21;
  1215.     DWORD FltF22;
  1216.     DWORD FltF23;
  1217.     DWORD FltF24;
  1218.     DWORD FltF25;
  1219.     DWORD FltF26;
  1220.     DWORD FltF27;
  1221.     DWORD FltF28;
  1222.     DWORD FltF29;
  1223.     DWORD FltF30;
  1224.     DWORD FltF31;
  1225.  
  1226.     DWORD IntV0;        //  $0: return value register, v0
  1227.     DWORD IntT0;        //  $1: temporary registers, t0 - t7
  1228.     DWORD IntT1;        //  $2:
  1229.     DWORD IntT2;        //  $3:
  1230.     DWORD IntT3;        //  $4:
  1231.     DWORD IntT4;        //  $5:
  1232.     DWORD IntT5;        //  $6:
  1233.     DWORD IntT6;        //  $7:
  1234.     DWORD IntT7;        //  $8:
  1235.     DWORD IntS0;        //  $9: nonvolatile registers, s0 - s5
  1236.     DWORD IntS1;        // $10:
  1237.     DWORD IntS2;        // $11:
  1238.     DWORD IntS3;        // $12:
  1239.     DWORD IntS4;        // $13:
  1240.     DWORD IntS5;        // $14:
  1241.     DWORD IntFp;        // $15: frame pointer register, fp/s6
  1242.     DWORD IntA0;        // $16: argument registers, a0 - a5
  1243.     DWORD IntA1;        // $17:
  1244.     DWORD IntA2;        // $18:
  1245.     DWORD IntA3;        // $19:
  1246.     DWORD IntA4;        // $20:
  1247.     DWORD IntA5;        // $21:
  1248.     DWORD IntT8;        // $22: temporary registers, t8 - t11
  1249.     DWORD IntT9;        // $23:
  1250.     DWORD IntT10;       // $24:
  1251.     DWORD IntT11;       // $25:
  1252.     DWORD IntRa;        // $26: return address register, ra
  1253.     DWORD IntT12;       // $27: temporary register, t12
  1254.     DWORD IntAt;        // $28: assembler temp register, at
  1255.     DWORD IntGp;        // $29: global pointer register, gp
  1256.     DWORD IntSp;        // $30: stack pointer register, sp
  1257.     DWORD IntZero;      // $31: zero register, zero
  1258.  
  1259.     DWORD Fpcr;         // floating point control register
  1260.     DWORD SoftFpcr;     // software extension to FPCR
  1261.  
  1262.     DWORD Fir;          // (fault instruction) continuation address
  1263.  
  1264.     DWORD Psr;          // processor status
  1265.     DWORD ContextFlags;
  1266.  
  1267.     //
  1268.     // Beginning of the "second half".
  1269.     // The name "High" parallels the HighPart of a LargeInteger.
  1270.     //
  1271.  
  1272.     DWORD HighFltF0;
  1273.     DWORD HighFltF1;
  1274.     DWORD HighFltF2;
  1275.     DWORD HighFltF3;
  1276.     DWORD HighFltF4;
  1277.     DWORD HighFltF5;
  1278.     DWORD HighFltF6;
  1279.     DWORD HighFltF7;
  1280.     DWORD HighFltF8;
  1281.     DWORD HighFltF9;
  1282.     DWORD HighFltF10;
  1283.     DWORD HighFltF11;
  1284.     DWORD HighFltF12;
  1285.     DWORD HighFltF13;
  1286.     DWORD HighFltF14;
  1287.     DWORD HighFltF15;
  1288.     DWORD HighFltF16;
  1289.     DWORD HighFltF17;
  1290.     DWORD HighFltF18;
  1291.     DWORD HighFltF19;
  1292.     DWORD HighFltF20;
  1293.     DWORD HighFltF21;
  1294.     DWORD HighFltF22;
  1295.     DWORD HighFltF23;
  1296.     DWORD HighFltF24;
  1297.     DWORD HighFltF25;
  1298.     DWORD HighFltF26;
  1299.     DWORD HighFltF27;
  1300.     DWORD HighFltF28;
  1301.     DWORD HighFltF29;
  1302.     DWORD HighFltF30;
  1303.     DWORD HighFltF31;
  1304.  
  1305.     DWORD HighIntV0;        //  $0: return value register, v0
  1306.     DWORD HighIntT0;        //  $1: temporary registers, t0 - t7
  1307.     DWORD HighIntT1;        //  $2:
  1308.     DWORD HighIntT2;        //  $3:
  1309.     DWORD HighIntT3;        //  $4:
  1310.     DWORD HighIntT4;        //  $5:
  1311.     DWORD HighIntT5;        //  $6:
  1312.     DWORD HighIntT6;        //  $7:
  1313.     DWORD HighIntT7;        //  $8:
  1314.     DWORD HighIntS0;        //  $9: nonvolatile registers, s0 - s5
  1315.     DWORD HighIntS1;        // $10:
  1316.     DWORD HighIntS2;        // $11:
  1317.     DWORD HighIntS3;        // $12:
  1318.     DWORD HighIntS4;        // $13:
  1319.     DWORD HighIntS5;        // $14:
  1320.     DWORD HighIntFp;        // $15: frame pointer register, fp/s6
  1321.     DWORD HighIntA0;        // $16: argument registers, a0 - a5
  1322.     DWORD HighIntA1;        // $17:
  1323.     DWORD HighIntA2;        // $18:
  1324.     DWORD HighIntA3;        // $19:
  1325.     DWORD HighIntA4;        // $20:
  1326.     DWORD HighIntA5;        // $21:
  1327.     DWORD HighIntT8;        // $22: temporary registers, t8 - t11
  1328.     DWORD HighIntT9;        // $23:
  1329.     DWORD HighIntT10;       // $24:
  1330.     DWORD HighIntT11;       // $25:
  1331.     DWORD HighIntRa;        // $26: return address register, ra
  1332.     DWORD HighIntT12;       // $27: temporary register, t12
  1333.     DWORD HighIntAt;        // $28: assembler temp register, at
  1334.     DWORD HighIntGp;        // $29: global pointer register, gp
  1335.     DWORD HighIntSp;        // $30: stack pointer register, sp
  1336.     DWORD HighIntZero;      // $31: zero register, zero
  1337.  
  1338.     DWORD HighFpcr;         // floating point control register
  1339.     DWORD HighSoftFpcr;     // software extension to FPCR
  1340.     DWORD HighFir;          // processor status
  1341.  
  1342.     double DoNotUseThisField; // to force quadword structure alignment
  1343.     DWORD HighFill[2];      // padding for 16-byte stack frame alignment
  1344.  
  1345. } CONTEXT, *PCONTEXT;
  1346.  
  1347. //
  1348. // These should name the fields in the _PORTABLE_32BIT structure
  1349. // that overlay the Psr and ContextFlags in the normal structure.
  1350. //
  1351.  
  1352. #define _QUAD_PSR_OFFSET   HighSoftFpcr
  1353. #define _QUAD_FLAGS_OFFSET HighFir
  1354.  
  1355. #endif // _PORTABLE_32BIT_CONTEXT
  1356.  
  1357. // end_ntddk end_nthal
  1358.  
  1359. #endif // _ALPHA_
  1360.  
  1361.  
  1362. #ifdef _ALPHA_
  1363.  
  1364. VOID
  1365. __jump_unwind (
  1366.     PVOID VirtualFramePointer,
  1367.     PVOID TargetPc
  1368.     );
  1369.  
  1370. #endif // _ALPHA_
  1371.  
  1372.  
  1373. #ifdef _X86_
  1374.  
  1375. //
  1376. // Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver
  1377. // writers to not leave them inadvertantly in their code.
  1378. //
  1379.  
  1380. #if !defined(MIDL_PASS)
  1381. #if !defined(RC_INVOKED)
  1382.  
  1383. #pragma warning(disable:4164)   // disable C4164 warning so that apps that
  1384.                                 // build with /Od don't get weird errors !
  1385. #ifdef _M_IX86
  1386. #pragma function(_enable)
  1387. #pragma function(_disable)
  1388. #endif
  1389.  
  1390. #pragma warning(default:4164)   // reenable C4164 warning
  1391.  
  1392. #endif
  1393. #endif
  1394.  
  1395.  
  1396. #if !defined(MIDL_PASS) && defined(_M_IX86)
  1397. #ifdef __BORLANDC__
  1398. /* Since Microsoft wants these to be inline even in "C" programs, we have
  1399.    added simple prototypes here and moved the real functions into the RTL.
  1400.    At least until we support inline functions in "C".
  1401. */
  1402. #ifdef __MT__ /* Force no prototype unless in MT mode */
  1403. PVOID GetFiberData( void );
  1404. PVOID GetCurrentFiber( void );
  1405. #endif /* __MT__ */
  1406. #else  /* __BORLANDC__ */
  1407. #pragma warning (disable:4035)        // disable 4035 (function must return something)
  1408. _inline PVOID GetFiberData( void ) { __asm {
  1409.                                         mov eax, fs:[0x10]
  1410.                                         mov eax,[eax]
  1411.                                         }
  1412.                                      }
  1413. _inline PVOID GetCurrentFiber( void ) { __asm mov eax, fs:[0x10] }
  1414.  
  1415. #pragma warning (default:4035)        // Reenable it
  1416. #endif /* __BORLANDC__ */
  1417. #endif
  1418.  
  1419. // begin_ntddk begin_wx86
  1420.  
  1421. //
  1422. //  Define the size of the 80387 save area, which is in the context frame.
  1423. //
  1424.  
  1425. #define SIZE_OF_80387_REGISTERS      80
  1426.  
  1427. //
  1428. // The following flags control the contents of the CONTEXT structure.
  1429. //
  1430.  
  1431. #if !defined(RC_INVOKED)
  1432.  
  1433. #define CONTEXT_i386    0x00010000    // this assumes that i386 and
  1434. #define CONTEXT_i486    0x00010000    // i486 have identical context records
  1435.  
  1436. // end_wx86
  1437.  
  1438. #define CONTEXT_CONTROL         (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
  1439. #define CONTEXT_INTEGER         (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
  1440. #define CONTEXT_SEGMENTS        (CONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS
  1441. #define CONTEXT_FLOATING_POINT  (CONTEXT_i386 | 0x00000008L) // 387 state
  1442. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L) // DB 0-3,6,7
  1443.  
  1444. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER |\
  1445.                       CONTEXT_SEGMENTS)
  1446.  
  1447. // begin_wx86
  1448.  
  1449. #endif
  1450.  
  1451. typedef struct _FLOATING_SAVE_AREA {
  1452.     DWORD   ControlWord;
  1453.     DWORD   StatusWord;
  1454.     DWORD   TagWord;
  1455.     DWORD   ErrorOffset;
  1456.     DWORD   ErrorSelector;
  1457.     DWORD   DataOffset;
  1458.     DWORD   DataSelector;
  1459.     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
  1460.     DWORD   Cr0NpxState;
  1461. } FLOATING_SAVE_AREA;
  1462.  
  1463. typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
  1464.  
  1465. //
  1466. // Context Frame
  1467. //
  1468. //  This frame has a several purposes: 1) it is used as an argument to
  1469. //  NtContinue, 2) is is used to constuct a call frame for APC delivery,
  1470. //  and 3) it is used in the user level thread creation routines.
  1471. //
  1472. //  The layout of the record conforms to a standard call frame.
  1473. //
  1474.  
  1475. typedef struct _CONTEXT {
  1476.  
  1477.     //
  1478.     // The flags values within this flag control the contents of
  1479.     // a CONTEXT record.
  1480.     //
  1481.     // If the context record is used as an input parameter, then
  1482.     // for each portion of the context record controlled by a flag
  1483.     // whose value is set, it is assumed that that portion of the
  1484.     // context record contains valid context. If the context record
  1485.     // is being used to modify a threads context, then only that
  1486.     // portion of the threads context will be modified.
  1487.     //
  1488.     // If the context record is used as an IN OUT parameter to capture
  1489.     // the context of a thread, then only those portions of the thread's
  1490.     // context corresponding to set flags will be returned.
  1491.     //
  1492.     // The context record is never used as an OUT only parameter.
  1493.     //
  1494.  
  1495.     DWORD ContextFlags;
  1496.  
  1497.     //
  1498.     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  1499.     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
  1500.     // included in CONTEXT_FULL.
  1501.     //
  1502.  
  1503.     DWORD   Dr0;
  1504.     DWORD   Dr1;
  1505.     DWORD   Dr2;
  1506.     DWORD   Dr3;
  1507.     DWORD   Dr6;
  1508.     DWORD   Dr7;
  1509.  
  1510.     //
  1511.     // This section is specified/returned if the
  1512.     // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  1513.     //
  1514.  
  1515.     FLOATING_SAVE_AREA FloatSave;
  1516.  
  1517.     //
  1518.     // This section is specified/returned if the
  1519.     // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  1520.     //
  1521.  
  1522.     DWORD   SegGs;
  1523.     DWORD   SegFs;
  1524.     DWORD   SegEs;
  1525.     DWORD   SegDs;
  1526.  
  1527.     //
  1528.     // This section is specified/returned if the
  1529.     // ContextFlags word contians the flag CONTEXT_INTEGER.
  1530.     //
  1531.  
  1532.     DWORD   Edi;
  1533.     DWORD   Esi;
  1534.     DWORD   Ebx;
  1535.     DWORD   Edx;
  1536.     DWORD   Ecx;
  1537.     DWORD   Eax;
  1538.  
  1539.     //
  1540.     // This section is specified/returned if the
  1541.     // ContextFlags word contians the flag CONTEXT_CONTROL.
  1542.     //
  1543.  
  1544.     DWORD   Ebp;
  1545.     DWORD   Eip;
  1546.     DWORD   SegCs;              // MUST BE SANITIZED
  1547.     DWORD   EFlags;             // MUST BE SANITIZED
  1548.     DWORD   Esp;
  1549.     DWORD   SegSs;
  1550.  
  1551. } CONTEXT;
  1552.  
  1553.  
  1554.  
  1555. typedef CONTEXT *PCONTEXT;
  1556.  
  1557. // begin_ntminiport
  1558.  
  1559. #endif //_X86_
  1560.  
  1561.  
  1562. typedef struct _LDT_ENTRY {
  1563.     WORD    LimitLow;
  1564.     WORD    BaseLow;
  1565.     union {
  1566.         struct {
  1567.             BYTE    BaseMid;
  1568.             BYTE    Flags1;     // Declare as bytes to avoid alignment
  1569.             BYTE    Flags2;     // Problems.
  1570.             BYTE    BaseHi;
  1571.         } Bytes;
  1572.         struct {
  1573.             DWORD   BaseMid : 8;
  1574.             DWORD   Type : 5;
  1575.             DWORD   Dpl : 2;
  1576.             DWORD   Pres : 1;
  1577.             DWORD   LimitHi : 4;
  1578.             DWORD   Sys : 1;
  1579.             DWORD   Reserved_0 : 1;
  1580.             DWORD   Default_Big : 1;
  1581.             DWORD   Granularity : 1;
  1582.             DWORD   BaseHi : 8;
  1583.         } Bits;
  1584.     } HighWord;
  1585. } LDT_ENTRY, *PLDT_ENTRY;
  1586.  
  1587.  
  1588. #if defined(_MIPS_)
  1589.  
  1590. //
  1591. // Define functions to get the address of the current fiber and the
  1592. // current fiber data.
  1593. //
  1594.  
  1595. #define GetCurrentFiber() ((*(PNT_TIB *)0x7ffff4a8)->FiberData)
  1596. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  1597.  
  1598. // begin_ntddk begin_nthal
  1599. //
  1600. // The following flags control the contents of the CONTEXT structure.
  1601. //
  1602.  
  1603. #if !defined(RC_INVOKED)
  1604.  
  1605. #define CONTEXT_R4000   0x00010000    // r4000 context
  1606.  
  1607. #define CONTEXT_CONTROL          (CONTEXT_R4000 | 0x00000001)
  1608. #define CONTEXT_FLOATING_POINT   (CONTEXT_R4000 | 0x00000002)
  1609. #define CONTEXT_INTEGER          (CONTEXT_R4000 | 0x00000004)
  1610. #define CONTEXT_EXTENDED_FLOAT   (CONTEXT_FLOATING_POINT | 0x00000008)
  1611. #define CONTEXT_EXTENDED_INTEGER (CONTEXT_INTEGER | 0x00000010)
  1612.  
  1613. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | \
  1614.                       CONTEXT_INTEGER | CONTEXT_EXTENDED_INTEGER)
  1615.  
  1616. #endif
  1617.  
  1618. //
  1619. // Context Frame
  1620. //
  1621. //  N.B. This frame must be exactly a multiple of 16 bytes in length.
  1622. //
  1623. //  This frame has a several purposes: 1) it is used as an argument to
  1624. //  NtContinue, 2) it is used to constuct a call frame for APC delivery,
  1625. //  3) it is used to construct a call frame for exception dispatching
  1626. //  in user mode, and 4) it is used in the user level thread creation
  1627. //  routines.
  1628. //
  1629. //  The layout of the record conforms to a standard call frame.
  1630. //
  1631.  
  1632. typedef struct _CONTEXT {
  1633.  
  1634.     //
  1635.     // This section is always present and is used as an argument build
  1636.     // area.
  1637.     //
  1638.     // N.B. Context records are 0 mod 8 aligned starting with NT 4.0.
  1639.     //
  1640.  
  1641.     union {
  1642.         DWORD Argument[4];
  1643.         DWORDLONG Alignment;
  1644.     };
  1645.  
  1646.     //
  1647.     // The following union defines the 32-bit and 64-bit register context.
  1648.     //
  1649.  
  1650.     union {
  1651.  
  1652.         //
  1653.         // 32-bit context.
  1654.         //
  1655.  
  1656.         struct {
  1657.  
  1658.             //
  1659.             // This section is specified/returned if the ContextFlags contains
  1660.             // the flag CONTEXT_FLOATING_POINT.
  1661.             //
  1662.             // N.B. This section contains the 16 double floating registers f0,
  1663.             //      f2, ..., f30.
  1664.             //
  1665.  
  1666.             DWORD FltF0;
  1667.             DWORD FltF1;
  1668.             DWORD FltF2;
  1669.             DWORD FltF3;
  1670.             DWORD FltF4;
  1671.             DWORD FltF5;
  1672.             DWORD FltF6;
  1673.             DWORD FltF7;
  1674.             DWORD FltF8;
  1675.             DWORD FltF9;
  1676.             DWORD FltF10;
  1677.             DWORD FltF11;
  1678.             DWORD FltF12;
  1679.             DWORD FltF13;
  1680.             DWORD FltF14;
  1681.             DWORD FltF15;
  1682.             DWORD FltF16;
  1683.             DWORD FltF17;
  1684.             DWORD FltF18;
  1685.             DWORD FltF19;
  1686.             DWORD FltF20;
  1687.             DWORD FltF21;
  1688.             DWORD FltF22;
  1689.             DWORD FltF23;
  1690.             DWORD FltF24;
  1691.             DWORD FltF25;
  1692.             DWORD FltF26;
  1693.             DWORD FltF27;
  1694.             DWORD FltF28;
  1695.             DWORD FltF29;
  1696.             DWORD FltF30;
  1697.             DWORD FltF31;
  1698.  
  1699.             //
  1700.             // This section is specified/returned if the ContextFlags contains
  1701.             // the flag CONTEXT_INTEGER.
  1702.             //
  1703.             // N.B. The registers gp, sp, and ra are defined in this section,
  1704.             //      but are considered part of the control context rather than
  1705.             //      part of the integer context.
  1706.             //
  1707.             // N.B. Register zero is not stored in the frame.
  1708.             //
  1709.  
  1710.             DWORD IntZero;
  1711.             DWORD IntAt;
  1712.             DWORD IntV0;
  1713.             DWORD IntV1;
  1714.             DWORD IntA0;
  1715.             DWORD IntA1;
  1716.             DWORD IntA2;
  1717.             DWORD IntA3;
  1718.             DWORD IntT0;
  1719.             DWORD IntT1;
  1720.             DWORD IntT2;
  1721.             DWORD IntT3;
  1722.             DWORD IntT4;
  1723.             DWORD IntT5;
  1724.             DWORD IntT6;
  1725.             DWORD IntT7;
  1726.             DWORD IntS0;
  1727.             DWORD IntS1;
  1728.             DWORD IntS2;
  1729.             DWORD IntS3;
  1730.             DWORD IntS4;
  1731.             DWORD IntS5;
  1732.             DWORD IntS6;
  1733.             DWORD IntS7;
  1734.             DWORD IntT8;
  1735.             DWORD IntT9;
  1736.             DWORD IntK0;
  1737.             DWORD IntK1;
  1738.             DWORD IntGp;
  1739.             DWORD IntSp;
  1740.             DWORD IntS8;
  1741.             DWORD IntRa;
  1742.             DWORD IntLo;
  1743.             DWORD IntHi;
  1744.  
  1745.             //
  1746.             // This section is specified/returned if the ContextFlags word contains
  1747.             // the flag CONTEXT_FLOATING_POINT.
  1748.             //
  1749.  
  1750.             DWORD Fsr;
  1751.  
  1752.             //
  1753.             // This section is specified/returned if the ContextFlags word contains
  1754.             // the flag CONTEXT_CONTROL.
  1755.             //
  1756.             // N.B. The registers gp, sp, and ra are defined in the integer section,
  1757.             //   but are considered part of the control context rather than part of
  1758.             //   the integer context.
  1759.             //
  1760.  
  1761.             DWORD Fir;
  1762.             DWORD Psr;
  1763.  
  1764.             //
  1765.             // The flags values within this flag control the contents of
  1766.             // a CONTEXT record.
  1767.             //
  1768.             // If the context record is used as an input parameter, then
  1769.             // for each portion of the context record controlled by a flag
  1770.             // whose value is set, it is assumed that that portion of the
  1771.             // context record contains valid context. If the context record
  1772.             // is being used to modify a thread's context, then only that
  1773.             // portion of the threads context will be modified.
  1774.             //
  1775.             // If the context record is used as an IN OUT parameter to capture
  1776.             // the context of a thread, then only those portions of the thread's
  1777.             // context corresponding to set flags will be returned.
  1778.             //
  1779.             // The context record is never used as an OUT only parameter.
  1780.             //
  1781.  
  1782.             DWORD ContextFlags;
  1783.         };
  1784.  
  1785.         //
  1786.         // 64-bit context.
  1787.         //
  1788.  
  1789.         struct {
  1790.  
  1791.             //
  1792.             // This section is specified/returned if the ContextFlags contains
  1793.             // the flag CONTEXT_EXTENDED_FLOAT.
  1794.             //
  1795.             // N.B. This section contains the 32 double floating registers f0,
  1796.             //      f1, ..., f31.
  1797.             //
  1798.  
  1799.             DWORDLONG XFltF0;
  1800.             DWORDLONG XFltF1;
  1801.             DWORDLONG XFltF2;
  1802.             DWORDLONG XFltF3;
  1803.             DWORDLONG XFltF4;
  1804.             DWORDLONG XFltF5;
  1805.             DWORDLONG XFltF6;
  1806.             DWORDLONG XFltF7;
  1807.             DWORDLONG XFltF8;
  1808.             DWORDLONG XFltF9;
  1809.             DWORDLONG XFltF10;
  1810.             DWORDLONG XFltF11;
  1811.             DWORDLONG XFltF12;
  1812.             DWORDLONG XFltF13;
  1813.             DWORDLONG XFltF14;
  1814.             DWORDLONG XFltF15;
  1815.             DWORDLONG XFltF16;
  1816.             DWORDLONG XFltF17;
  1817.             DWORDLONG XFltF18;
  1818.             DWORDLONG XFltF19;
  1819.             DWORDLONG XFltF20;
  1820.             DWORDLONG XFltF21;
  1821.             DWORDLONG XFltF22;
  1822.             DWORDLONG XFltF23;
  1823.             DWORDLONG XFltF24;
  1824.             DWORDLONG XFltF25;
  1825.             DWORDLONG XFltF26;
  1826.             DWORDLONG XFltF27;
  1827.             DWORDLONG XFltF28;
  1828.             DWORDLONG XFltF29;
  1829.             DWORDLONG XFltF30;
  1830.             DWORDLONG XFltF31;
  1831.  
  1832.             //
  1833.             // The following sections must exactly overlay the 32-bit context.
  1834.             //
  1835.  
  1836.             DWORD Fill1;
  1837.             DWORD Fill2;
  1838.  
  1839.             //
  1840.             // This section is specified/returned if the ContextFlags contains
  1841.             // the flag CONTEXT_FLOATING_POINT.
  1842.             //
  1843.  
  1844.             DWORD XFsr;
  1845.  
  1846.             //
  1847.             // This section is specified/returned if the ContextFlags contains
  1848.             // the flag CONTEXT_CONTROL.
  1849.             //
  1850.             // N.B. The registers gp, sp, and ra are defined in the integer
  1851.             //      section, but are considered part of the control context
  1852.             //      rather than part of the integer context.
  1853.             //
  1854.  
  1855.             DWORD XFir;
  1856.             DWORD XPsr;
  1857.  
  1858.             //
  1859.             // The flags values within this flag control the contents of
  1860.             // a CONTEXT record.
  1861.             //
  1862.             // If the context record is used as an input parameter, then
  1863.             // for each portion of the context record controlled by a flag
  1864.             // whose value is set, it is assumed that that portion of the
  1865.             // context record contains valid context. If the context record
  1866.             // is being used to modify a thread's context, then only that
  1867.             // portion of the threads context will be modified.
  1868.             //
  1869.             // If the context record is used as an IN OUT parameter to capture
  1870.             // the context of a thread, then only those portions of the thread's
  1871.             // context corresponding to set flags will be returned.
  1872.             //
  1873.             // The context record is never used as an OUT only parameter.
  1874.             //
  1875.  
  1876.             DWORD XContextFlags;
  1877.  
  1878.             //
  1879.             // This section is specified/returned if the ContextFlags contains
  1880.             // the flag CONTEXT_EXTENDED_INTEGER.
  1881.             //
  1882.             // N.B. The registers gp, sp, and ra are defined in this section,
  1883.             //      but are considered part of the control context rather than
  1884.             //      part of the integer  context.
  1885.             //
  1886.             // N.B. Register zero is not stored in the frame.
  1887.             //
  1888.  
  1889.             DWORDLONG XIntZero;
  1890.             DWORDLONG XIntAt;
  1891.             DWORDLONG XIntV0;
  1892.             DWORDLONG XIntV1;
  1893.             DWORDLONG XIntA0;
  1894.             DWORDLONG XIntA1;
  1895.             DWORDLONG XIntA2;
  1896.             DWORDLONG XIntA3;
  1897.             DWORDLONG XIntT0;
  1898.             DWORDLONG XIntT1;
  1899.             DWORDLONG XIntT2;
  1900.             DWORDLONG XIntT3;
  1901.             DWORDLONG XIntT4;
  1902.             DWORDLONG XIntT5;
  1903.             DWORDLONG XIntT6;
  1904.             DWORDLONG XIntT7;
  1905.             DWORDLONG XIntS0;
  1906.             DWORDLONG XIntS1;
  1907.             DWORDLONG XIntS2;
  1908.             DWORDLONG XIntS3;
  1909.             DWORDLONG XIntS4;
  1910.             DWORDLONG XIntS5;
  1911.             DWORDLONG XIntS6;
  1912.             DWORDLONG XIntS7;
  1913.             DWORDLONG XIntT8;
  1914.             DWORDLONG XIntT9;
  1915.             DWORDLONG XIntK0;
  1916.             DWORDLONG XIntK1;
  1917.             DWORDLONG XIntGp;
  1918.             DWORDLONG XIntSp;
  1919.             DWORDLONG XIntS8;
  1920.             DWORDLONG XIntRa;
  1921.             DWORDLONG XIntLo;
  1922.             DWORDLONG XIntHi;
  1923.         };
  1924.     };
  1925. } CONTEXT, *PCONTEXT;
  1926.  
  1927. // end_ntddk end_nthal
  1928.  
  1929. #define CONTEXT32_LENGTH 0x130          // The original 32-bit Context length (pre NT 4.0)
  1930.  
  1931. #endif // MIPS
  1932.  
  1933.  
  1934. #if defined(_MIPS_)
  1935.  
  1936. VOID
  1937. __jump_unwind (
  1938.     PVOID Fp,
  1939.     PVOID TargetPc
  1940.     );
  1941.  
  1942. #endif // MIPS
  1943.  
  1944.  
  1945. #if defined(_PPC_)
  1946.  
  1947.  
  1948. //
  1949. // The address of the TEB is placed into GPR 13 at context switch time
  1950. // and should never be destroyed.  To get the address of the TEB use
  1951. // the compiler intrinsic to access it directly from GPR 13.
  1952. //
  1953.  
  1954. #if defined(_M_PPC) && defined(_MSC_VER) && (_MSC_VER>=1000)
  1955. unsigned __gregister_get( unsigned const regnum );
  1956. #define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
  1957. #elif defined(_M_PPC)
  1958. struct _TEB * __builtin_get_gpr13(VOID);
  1959. #define NtCurrentTeb() ((struct _TEB *)__builtin_get_gpr13())
  1960. #endif
  1961.  
  1962.  
  1963. //
  1964. // Define functions to get the address of the current fiber and the
  1965. // current fiber data.
  1966. //
  1967.  
  1968. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  1969. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  1970.  
  1971. // begin_ntddk begin_nthal
  1972. //
  1973. // The following flags control the contents of the CONTEXT structure.
  1974. //
  1975.  
  1976. #if !defined(RC_INVOKED)
  1977.  
  1978. #define CONTEXT_CONTROL         0x00000001L
  1979. #define CONTEXT_FLOATING_POINT  0x00000002L
  1980. #define CONTEXT_INTEGER         0x00000004L
  1981. #define CONTEXT_DEBUG_REGISTERS 0x00000008L
  1982.  
  1983. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  1984.  
  1985. #endif
  1986.  
  1987. //
  1988. // Context Frame
  1989. //
  1990. //  N.B. This frame must be exactly a multiple of 16 bytes in length.
  1991. //
  1992. //  This frame has a several purposes: 1) it is used as an argument to
  1993. //  NtContinue, 2) it is used to constuct a call frame for APC delivery,
  1994. //  3) it is used to construct a call frame for exception dispatching
  1995. //  in user mode, and 4) it is used in the user level thread creation
  1996. //  routines.
  1997. //
  1998. //  Requires at least 8-byte alignment (double)
  1999. //
  2000.  
  2001. typedef struct _CONTEXT {
  2002.  
  2003.     //
  2004.     // This section is specified/returned if the ContextFlags word contains
  2005.     // the flag CONTEXT_FLOATING_POINT.
  2006.     //
  2007.  
  2008.     double Fpr0;                        // Floating registers 0..31
  2009.     double Fpr1;
  2010.     double Fpr2;
  2011.     double Fpr3;
  2012.     double Fpr4;
  2013.     double Fpr5;
  2014.     double Fpr6;
  2015.     double Fpr7;
  2016.     double Fpr8;
  2017.     double Fpr9;
  2018.     double Fpr10;
  2019.     double Fpr11;
  2020.     double Fpr12;
  2021.     double Fpr13;
  2022.     double Fpr14;
  2023.     double Fpr15;
  2024.     double Fpr16;
  2025.     double Fpr17;
  2026.     double Fpr18;
  2027.     double Fpr19;
  2028.     double Fpr20;
  2029.     double Fpr21;
  2030.     double Fpr22;
  2031.     double Fpr23;
  2032.     double Fpr24;
  2033.     double Fpr25;
  2034.     double Fpr26;
  2035.     double Fpr27;
  2036.     double Fpr28;
  2037.     double Fpr29;
  2038.     double Fpr30;
  2039.     double Fpr31;
  2040.     double Fpscr;                       // Floating point status/control reg
  2041.  
  2042.     //
  2043.     // This section is specified/returned if the ContextFlags word contains
  2044.     // the flag CONTEXT_INTEGER.
  2045.     //
  2046.  
  2047.     DWORD Gpr0;                         // General registers 0..31
  2048.     DWORD Gpr1;
  2049.     DWORD Gpr2;
  2050.     DWORD Gpr3;
  2051.     DWORD Gpr4;
  2052.     DWORD Gpr5;
  2053.     DWORD Gpr6;
  2054.     DWORD Gpr7;
  2055.     DWORD Gpr8;
  2056.     DWORD Gpr9;
  2057.     DWORD Gpr10;
  2058.     DWORD Gpr11;
  2059.     DWORD Gpr12;
  2060.     DWORD Gpr13;
  2061.     DWORD Gpr14;
  2062.     DWORD Gpr15;
  2063.     DWORD Gpr16;
  2064.     DWORD Gpr17;
  2065.     DWORD Gpr18;
  2066.     DWORD Gpr19;
  2067.     DWORD Gpr20;
  2068.     DWORD Gpr21;
  2069.     DWORD Gpr22;
  2070.     DWORD Gpr23;
  2071.     DWORD Gpr24;
  2072.     DWORD Gpr25;
  2073.     DWORD Gpr26;
  2074.     DWORD Gpr27;
  2075.     DWORD Gpr28;
  2076.     DWORD Gpr29;
  2077.     DWORD Gpr30;
  2078.     DWORD Gpr31;
  2079.  
  2080.     DWORD Cr;                           // Condition register
  2081.     DWORD Xer;                          // Fixed point exception register
  2082.  
  2083.     //
  2084.     // This section is specified/returned if the ContextFlags word contains
  2085.     // the flag CONTEXT_CONTROL.
  2086.     //
  2087.  
  2088.     DWORD Msr;                          // Machine status register
  2089.     DWORD Iar;                          // Instruction address register
  2090.     DWORD Lr;                           // Link register
  2091.     DWORD Ctr;                          // Count register
  2092.  
  2093.     //
  2094.     // The flags values within this flag control the contents of
  2095.     // a CONTEXT record.
  2096.     //
  2097.     // If the context record is used as an input parameter, then
  2098.     // for each portion of the context record controlled by a flag
  2099.     // whose value is set, it is assumed that that portion of the
  2100.     // context record contains valid context. If the context record
  2101.     // is being used to modify a thread's context, then only that
  2102.     // portion of the threads context will be modified.
  2103.     //
  2104.     // If the context record is used as an IN OUT parameter to capture
  2105.     // the context of a thread, then only those portions of the thread's
  2106.     // context corresponding to set flags will be returned.
  2107.     //
  2108.     // The context record is never used as an OUT only parameter.
  2109.     //
  2110.  
  2111.     DWORD ContextFlags;
  2112.  
  2113.     DWORD Fill[3];                      // Pad out to multiple of 16 bytes
  2114.  
  2115.     //
  2116.     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  2117.     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
  2118.     // included in CONTEXT_FULL.
  2119.     //
  2120.     DWORD Dr0;                          // Breakpoint Register 1
  2121.     DWORD Dr1;                          // Breakpoint Register 2
  2122.     DWORD Dr2;                          // Breakpoint Register 3
  2123.     DWORD Dr3;                          // Breakpoint Register 4
  2124.     DWORD Dr4;                          // Breakpoint Register 5
  2125.     DWORD Dr5;                          // Breakpoint Register 6
  2126.     DWORD Dr6;                          // Debug Status Register
  2127.     DWORD Dr7;                          // Debug Control Register
  2128.  
  2129. } CONTEXT, *PCONTEXT;
  2130.  
  2131. // end_ntddk end_nthal
  2132.  
  2133.  
  2134. //
  2135. // Stack frame header
  2136. //
  2137. //   Order of appearance in stack frame:
  2138. //      Header (six words)
  2139. //      Parameters (at least eight words)
  2140. //      Local variables
  2141. //      Saved GPRs
  2142. //      Saved FPRs
  2143. //
  2144. //   Minimum alignment is 8 bytes
  2145.  
  2146. typedef struct _STACK_FRAME_HEADER {    // GPR 1 points here
  2147.     DWORD BackChain;                    // Addr of previous frame
  2148.     DWORD GlueSaved1;                   // Used by glue code
  2149.     DWORD GlueSaved2;
  2150.     DWORD Reserved1;                    // Reserved
  2151.     DWORD Spare1;                       // Used by tracing, profiling, ...
  2152.     DWORD Spare2;
  2153.  
  2154.     DWORD Parameter0;                   // First 8 parameter words are
  2155.     DWORD Parameter1;                   //   always present
  2156.     DWORD Parameter2;
  2157.     DWORD Parameter3;
  2158.     DWORD Parameter4;
  2159.     DWORD Parameter5;
  2160.     DWORD Parameter6;
  2161.     DWORD Parameter7;
  2162.  
  2163. } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
  2164.  
  2165.  
  2166. VOID
  2167. __jump_unwind (
  2168.     PVOID Fp,
  2169.     PVOID TargetPc
  2170.     );
  2171.  
  2172. #endif // defined(_PPC_)
  2173.  
  2174. #if defined(_MPPC_)
  2175.  
  2176.  
  2177. //
  2178. // The address of the TEB is placed into GPR 13 at context switch time
  2179. // and should never be destroyed.  To get the address of the TEB use
  2180. // the compiler intrinsic to access it directly from GPR 13.
  2181. //
  2182.  
  2183. #if defined(_M_PPC) && defined(_MSC_VER) && (_MSC_VER>=1000)
  2184. unsigned __gregister_get( unsigned const regnum );
  2185. #define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
  2186. #elif defined(_M_PPC)
  2187. struct _TEB * __builtin_get_gpr13(VOID);
  2188. #define NtCurrentTeb() ((struct _TEB *)__builtin_get_gpr13())
  2189. #endif
  2190.  
  2191.  
  2192. //
  2193. // Define functions to get the address of the current fiber and the
  2194. // current fiber data.
  2195. //
  2196.  
  2197. #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
  2198. #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
  2199.  
  2200. // begin_ntddk begin_nthal
  2201. //
  2202. // The following flags control the contents of the CONTEXT structure.
  2203. //
  2204.  
  2205. #if !defined(RC_INVOKED)
  2206.  
  2207. #define CONTEXT_CONTROL         0x00000001L
  2208. #define CONTEXT_FLOATING_POINT  0x00000002L
  2209. #define CONTEXT_INTEGER         0x00000004L
  2210. #define CONTEXT_DEBUG_REGISTERS 0x00000008L
  2211.  
  2212. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  2213.  
  2214. #endif
  2215.  
  2216. //
  2217. // Context Frame
  2218. //
  2219. //  N.B. This frame must be exactly a multiple of 16 bytes in length.
  2220. //
  2221. //  This frame has a several purposes: 1) it is used as an argument to
  2222. //  NtContinue, 2) it is used to constuct a call frame for APC delivery,
  2223. //  3) it is used to construct a call frame for exception dispatching
  2224. //  in user mode, and 4) it is used in the user level thread creation
  2225. //  routines.
  2226. //
  2227. //  Requires at least 8-byte alignment (double)
  2228. //
  2229.  
  2230. typedef struct _CONTEXT {
  2231.  
  2232.     //
  2233.     // This section is specified/returned if the ContextFlags word contains
  2234.     // the flag CONTEXT_FLOATING_POINT.
  2235.     //
  2236.  
  2237.     double Fpr0;                        // Floating registers 0..31
  2238.     double Fpr1;
  2239.     double Fpr2;
  2240.     double Fpr3;
  2241.     double Fpr4;
  2242.     double Fpr5;
  2243.     double Fpr6;
  2244.     double Fpr7;
  2245.     double Fpr8;
  2246.     double Fpr9;
  2247.     double Fpr10;
  2248.     double Fpr11;
  2249.     double Fpr12;
  2250.     double Fpr13;
  2251.     double Fpr14;
  2252.     double Fpr15;
  2253.     double Fpr16;
  2254.     double Fpr17;
  2255.     double Fpr18;
  2256.     double Fpr19;
  2257.     double Fpr20;
  2258.     double Fpr21;
  2259.     double Fpr22;
  2260.     double Fpr23;
  2261.     double Fpr24;
  2262.     double Fpr25;
  2263.     double Fpr26;
  2264.     double Fpr27;
  2265.     double Fpr28;
  2266.     double Fpr29;
  2267.     double Fpr30;
  2268.     double Fpr31;
  2269.     double Fpscr;                       // Floating point status/control reg
  2270.  
  2271.     //
  2272.     // This section is specified/returned if the ContextFlags word contains
  2273.     // the flag CONTEXT_INTEGER.
  2274.     //
  2275.  
  2276.     DWORD Gpr0;                         // General registers 0..31
  2277.     DWORD Gpr1;
  2278.     DWORD Gpr2;
  2279.     DWORD Gpr3;
  2280.     DWORD Gpr4;
  2281.     DWORD Gpr5;
  2282.     DWORD Gpr6;
  2283.     DWORD Gpr7;
  2284.     DWORD Gpr8;
  2285.     DWORD Gpr9;
  2286.     DWORD Gpr10;
  2287.     DWORD Gpr11;
  2288.     DWORD Gpr12;
  2289.     DWORD Gpr13;
  2290.     DWORD Gpr14;
  2291.     DWORD Gpr15;
  2292.     DWORD Gpr16;
  2293.     DWORD Gpr17;
  2294.     DWORD Gpr18;
  2295.     DWORD Gpr19;
  2296.     DWORD Gpr20;
  2297.     DWORD Gpr21;
  2298.     DWORD Gpr22;
  2299.     DWORD Gpr23;
  2300.     DWORD Gpr24;
  2301.     DWORD Gpr25;
  2302.     DWORD Gpr26;
  2303.     DWORD Gpr27;
  2304.     DWORD Gpr28;
  2305.     DWORD Gpr29;
  2306.     DWORD Gpr30;
  2307.     DWORD Gpr31;
  2308.  
  2309.     DWORD Cr;                           // Condition register
  2310.     DWORD Xer;                          // Fixed point exception register
  2311.  
  2312.     //
  2313.     // This section is specified/returned if the ContextFlags word contains
  2314.     // the flag CONTEXT_CONTROL.
  2315.     //
  2316.  
  2317.     DWORD Msr;                          // Machine status register
  2318.     DWORD Iar;                          // Instruction address register
  2319.     DWORD Lr;                           // Link register
  2320.     DWORD Ctr;                          // Count register
  2321.  
  2322.     //
  2323.     // The flags values within this flag control the contents of
  2324.     // a CONTEXT record.
  2325.     //
  2326.     // If the context record is used as an input parameter, then
  2327.     // for each portion of the context record controlled by a flag
  2328.     // whose value is set, it is assumed that that portion of the
  2329.     // context record contains valid context. If the context record
  2330.     // is being used to modify a thread's context, then only that
  2331.     // portion of the threads context will be modified.
  2332.     //
  2333.     // If the context record is used as an IN OUT parameter to capture
  2334.     // the context of a thread, then only those portions of the thread's
  2335.     // context corresponding to set flags will be returned.
  2336.     //
  2337.     // The context record is never used as an OUT only parameter.
  2338.     //
  2339.  
  2340.     DWORD ContextFlags;
  2341.  
  2342.     DWORD Fill[3];                      // Pad out to multiple of 16 bytes
  2343.  
  2344.     //
  2345.     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  2346.     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
  2347.     // included in CONTEXT_FULL.
  2348.     //
  2349.     DWORD Dr0;                          // Breakpoint Register 1
  2350.     DWORD Dr1;                          // Breakpoint Register 2
  2351.     DWORD Dr2;                          // Breakpoint Register 3
  2352.     DWORD Dr3;                          // Breakpoint Register 4
  2353.     DWORD Dr4;                          // Breakpoint Register 5
  2354.     DWORD Dr5;                          // Breakpoint Register 6
  2355.     DWORD Dr6;                          // Debug Status Register
  2356.     DWORD Dr7;                          // Debug Control Register
  2357.  
  2358. } CONTEXT, *PCONTEXT;
  2359.  
  2360. // end_ntddk end_nthal
  2361.  
  2362.  
  2363. //
  2364. // Stack frame header
  2365. //
  2366. //   Order of appearance in stack frame:
  2367. //      Header (six words)
  2368. //      Parameters (at least eight words)
  2369. //      Local variables
  2370. //      Saved GPRs
  2371. //      Saved FPRs
  2372. //
  2373. //   Minimum alignment is 8 bytes
  2374.  
  2375. typedef struct _STACK_FRAME_HEADER {    // GPR 1 points here
  2376.     DWORD BackChain;                    // Addr of previous frame
  2377.     DWORD GlueSaved1;                   // Used by glue code
  2378.     DWORD GlueSaved2;
  2379.     DWORD Reserved1;                    // Reserved
  2380.     DWORD Spare1;                       // Used by tracing, profiling, ...
  2381.     DWORD Spare2;
  2382.  
  2383.     DWORD Parameter0;                   // First 8 parameter words are
  2384.     DWORD Parameter1;                   //   always present
  2385.     DWORD Parameter2;
  2386.     DWORD Parameter3;
  2387.     DWORD Parameter4;
  2388.     DWORD Parameter5;
  2389.     DWORD Parameter6;
  2390.     DWORD Parameter7;
  2391.  
  2392. } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
  2393.  
  2394.  
  2395. VOID
  2396. __jump_unwind (
  2397.     PVOID Fp,
  2398.     PVOID TargetPc
  2399.     );
  2400.  
  2401. #endif // defined(_MPPC_)
  2402. #define EXCEPTION_NONCONTINUABLE 0x1    // Noncontinuable exception
  2403. #define EXCEPTION_MAXIMUM_PARAMETERS 15 // maximum number of exception parameters
  2404.  
  2405. //
  2406. // Exception record definition.
  2407. //
  2408.  
  2409. typedef struct _EXCEPTION_RECORD {
  2410.     /*lint -e18 */  // Don't complain about different definitions
  2411.     DWORD    ExceptionCode;
  2412.     /*lint +e18 */  // Resume checking for different definitions
  2413.     DWORD ExceptionFlags;
  2414.     struct _EXCEPTION_RECORD *ExceptionRecord;
  2415.     PVOID ExceptionAddress;
  2416.     DWORD NumberParameters;
  2417.     DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  2418.     } EXCEPTION_RECORD;
  2419.  
  2420. typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
  2421.  
  2422. //
  2423. // Typedef for pointer returned by exception_info()
  2424. //
  2425.  
  2426. typedef struct _EXCEPTION_POINTERS {
  2427.     PEXCEPTION_RECORD ExceptionRecord;
  2428.     PCONTEXT ContextRecord;
  2429. } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
  2430. typedef PVOID PACCESS_TOKEN;            
  2431. typedef PVOID PSECURITY_DESCRIPTOR;     
  2432. typedef PVOID PSID;     
  2433. ////////////////////////////////////////////////////////////////////////
  2434. //                                                                    //
  2435. //                             ACCESS MASK                            //
  2436. //                                                                    //
  2437. ////////////////////////////////////////////////////////////////////////
  2438.  
  2439. //
  2440. //  Define the access mask as a longword sized structure divided up as
  2441. //  follows:
  2442. //
  2443. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2444. //       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
  2445. //      +---------------+---------------+-------------------------------+
  2446. //      |G|G|G|G|Res'd|A| StandardRights|         SpecificRights        |
  2447. //      |R|W|E|A|     |S|               |                               |
  2448. //      +-+-------------+---------------+-------------------------------+
  2449. //
  2450. //      typedef struct _ACCESS_MASK {
  2451. //          WORD   SpecificRights;
  2452. //          BYTE  StandardRights;
  2453. //          BYTE  AccessSystemAcl : 1;
  2454. //          BYTE  Reserved : 3;
  2455. //          BYTE  GenericAll : 1;
  2456. //          BYTE  GenericExecute : 1;
  2457. //          BYTE  GenericWrite : 1;
  2458. //          BYTE  GenericRead : 1;
  2459. //      } ACCESS_MASK;
  2460. //      typedef ACCESS_MASK *PACCESS_MASK;
  2461. //
  2462. //  but to make life simple for programmer's we'll allow them to specify
  2463. //  a desired access mask by simply OR'ing together mulitple single rights
  2464. //  and treat an access mask as a DWORD.  For example
  2465. //
  2466. //      DesiredAccess = DELETE | READ_CONTROL
  2467. //
  2468. //  So we'll declare ACCESS_MASK as DWORD
  2469. //
  2470.  
  2471. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  2472. typedef DWORD ACCESS_MASK;
  2473. typedef ACCESS_MASK *PACCESS_MASK;
  2474.  
  2475. ////////////////////////////////////////////////////////////////////////
  2476. //                                                                    //
  2477. //                             ACCESS TYPES                           //
  2478. //                                                                    //
  2479. ////////////////////////////////////////////////////////////////////////
  2480.  
  2481.  
  2482. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  2483. //
  2484. //  The following are masks for the predefined standard access types
  2485. //
  2486.  
  2487. #define DELETE                           (0x00010000L)
  2488. #define READ_CONTROL                     (0x00020000L)
  2489. #define WRITE_DAC                        (0x00040000L)
  2490. #define WRITE_OWNER                      (0x00080000L)
  2491. #define SYNCHRONIZE                      (0x00100000L)
  2492.  
  2493. #define STANDARD_RIGHTS_REQUIRED         (0x000F0000L)
  2494.  
  2495. #define STANDARD_RIGHTS_READ             (READ_CONTROL)
  2496. #define STANDARD_RIGHTS_WRITE            (READ_CONTROL)
  2497. #define STANDARD_RIGHTS_EXECUTE          (READ_CONTROL)
  2498.  
  2499. #define STANDARD_RIGHTS_ALL              (0x001F0000L)
  2500.  
  2501. #define SPECIFIC_RIGHTS_ALL              (0x0000FFFFL)
  2502.  
  2503. //
  2504. // AccessSystemAcl access type
  2505. //
  2506.  
  2507. #define ACCESS_SYSTEM_SECURITY           (0x01000000L)
  2508.  
  2509. //
  2510. // MaximumAllowed access type
  2511. //
  2512.  
  2513. #define MAXIMUM_ALLOWED                  (0x02000000L)
  2514.  
  2515. //
  2516. //  These are the generic rights.
  2517. //
  2518.  
  2519. #define GENERIC_READ                     (0x80000000L)
  2520. #define GENERIC_WRITE                    (0x40000000L)
  2521. #define GENERIC_EXECUTE                  (0x20000000L)
  2522. #define GENERIC_ALL                      (0x10000000L)
  2523.  
  2524.  
  2525. //
  2526. //  Define the generic mapping array.  This is used to denote the
  2527. //  mapping of each generic access right to a specific access mask.
  2528. //
  2529.  
  2530. typedef struct _GENERIC_MAPPING {
  2531.     ACCESS_MASK GenericRead;
  2532.     ACCESS_MASK GenericWrite;
  2533.     ACCESS_MASK GenericExecute;
  2534.     ACCESS_MASK GenericAll;
  2535. } GENERIC_MAPPING;
  2536. typedef GENERIC_MAPPING *PGENERIC_MAPPING;
  2537.  
  2538.  
  2539.  
  2540. ////////////////////////////////////////////////////////////////////////
  2541. //                                                                    //
  2542. //                        LUID_AND_ATTRIBUTES                         //
  2543. //                                                                    //
  2544. ////////////////////////////////////////////////////////////////////////
  2545. //
  2546. //
  2547.  
  2548.  
  2549. #include <pshpack4.h>
  2550.  
  2551. typedef struct _LUID_AND_ATTRIBUTES {
  2552.     LUID Luid;
  2553.     DWORD Attributes;
  2554.     } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
  2555. typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
  2556. typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
  2557.  
  2558. #include <poppack.h>
  2559.  
  2560.  
  2561. ////////////////////////////////////////////////////////////////////////
  2562. //                                                                    //
  2563. //              Security Id     (SID)                                 //
  2564. //                                                                    //
  2565. ////////////////////////////////////////////////////////////////////////
  2566. //
  2567. //
  2568. // Pictorially the structure of an SID is as follows:
  2569. //
  2570. //         1   1   1   1   1   1
  2571. //         5   4   3   2   1   0   9   8   7   6   5   4   3   2   1   0
  2572. //      +---------------------------------------------------------------+
  2573. //      |      SubAuthorityCount        |Reserved1 (SBZ)|   Revision    |
  2574. //      +---------------------------------------------------------------+
  2575. //      |                   IdentifierAuthority[0]                      |
  2576. //      +---------------------------------------------------------------+
  2577. //      |                   IdentifierAuthority[1]                      |
  2578. //      +---------------------------------------------------------------+
  2579. //      |                   IdentifierAuthority[2]                      |
  2580. //      +---------------------------------------------------------------+
  2581. //      |                                                               |
  2582. //      +- -  -  -  -  -  -  -  SubAuthority[]  -  -  -  -  -  -  -  - -+
  2583. //      |                                                               |
  2584. //      +---------------------------------------------------------------+
  2585. //
  2586. //
  2587.  
  2588.  
  2589. // begin_ntifs
  2590.  
  2591. #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
  2592. #define SID_IDENTIFIER_AUTHORITY_DEFINED
  2593. typedef struct _SID_IDENTIFIER_AUTHORITY {
  2594.     BYTE  Value[6];
  2595. } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
  2596. #endif
  2597.  
  2598.  
  2599. #ifndef SID_DEFINED
  2600. #define SID_DEFINED
  2601. typedef struct _SID {
  2602.    BYTE  Revision;
  2603.    BYTE  SubAuthorityCount;
  2604.    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
  2605. #ifdef MIDL_PASS
  2606.    [size_is(SubAuthorityCount)] DWORD SubAuthority[*];
  2607. #else // MIDL_PASS
  2608.    DWORD SubAuthority[ANYSIZE_ARRAY];
  2609. #endif // MIDL_PASS
  2610. } SID, *PISID;
  2611. #endif
  2612.  
  2613. #define SID_REVISION                     (1)    // Current revision level
  2614. #define SID_MAX_SUB_AUTHORITIES          (15)
  2615. #define SID_RECOMMENDED_SUB_AUTHORITIES  (1)    // Will change to around 6
  2616.                                                 // in a future release.
  2617.  
  2618. typedef enum _SID_NAME_USE {
  2619.     SidTypeUser = 1,
  2620.     SidTypeGroup,
  2621.     SidTypeDomain,
  2622.     SidTypeAlias,
  2623.     SidTypeWellKnownGroup,
  2624.     SidTypeDeletedAccount,
  2625.     SidTypeInvalid,
  2626.     SidTypeUnknown
  2627. } SID_NAME_USE, *PSID_NAME_USE;
  2628.  
  2629. typedef struct _SID_AND_ATTRIBUTES {
  2630.     PSID Sid;
  2631.     DWORD Attributes;
  2632.     } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
  2633.  
  2634. typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
  2635. typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
  2636.  
  2637.  
  2638.  
  2639. /////////////////////////////////////////////////////////////////////////////
  2640. //                                                                         //
  2641. // Universal well-known SIDs                                               //
  2642. //                                                                         //
  2643. //     Null SID                     S-1-0-0                                //
  2644. //     World                        S-1-1-0                                //
  2645. //     Local                        S-1-2-0                                //
  2646. //     Creator Owner ID             S-1-3-0                                //
  2647. //     Creator Group ID             S-1-3-1                                //
  2648. //     Creator Owner Server ID      S-1-3-2                                //
  2649. //     Creator Group Server ID      S-1-3-3                                //
  2650. //                                                                         //
  2651. //     (Non-unique IDs)             S-1-4                                  //
  2652. //                                                                         //
  2653. /////////////////////////////////////////////////////////////////////////////
  2654.  
  2655. #define SECURITY_NULL_SID_AUTHORITY       {0,0,0,0,0,0}
  2656. #define SECURITY_WORLD_SID_AUTHORITY      {0,0,0,0,0,1}
  2657. #define SECURITY_LOCAL_SID_AUTHORITY      {0,0,0,0,0,2}
  2658. #define SECURITY_CREATOR_SID_AUTHORITY    {0,0,0,0,0,3}
  2659. #define SECURITY_NON_UNIQUE_AUTHORITY     {0,0,0,0,0,4}
  2660.  
  2661. #define SECURITY_NULL_RID                 (0x00000000L)
  2662. #define SECURITY_WORLD_RID                (0x00000000L)
  2663. #define SECURITY_LOCAL_RID                (0X00000000L)
  2664.  
  2665. #define SECURITY_CREATOR_OWNER_RID        (0x00000000L)
  2666. #define SECURITY_CREATOR_GROUP_RID        (0x00000001L)
  2667.  
  2668. #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
  2669. #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
  2670.  
  2671.  
  2672. /////////////////////////////////////////////////////////////////////////////
  2673. //                                                                         //
  2674. // NT well-known SIDs                                                      //
  2675. //                                                                         //
  2676. //     NT Authority          S-1-5                                         //
  2677. //     Dialup                S-1-5-1                                       //
  2678. //                                                                         //
  2679. //     Network               S-1-5-2                                       //
  2680. //     Batch                 S-1-5-3                                       //
  2681. //     Interactive           S-1-5-4                                       //
  2682. //     Service               S-1-5-6                                       //
  2683. //     AnonymousLogon        S-1-5-7       (aka null logon session)        //
  2684. //     Proxy                 S-1-5-8                                       //
  2685. //     ServerLogon           S-1-5-9       (aka domain controller account) //
  2686. //     Self                  S-1-5-10      (self RID)                      //
  2687. //     Authenticated User    S-1-5-11      (Authenticated user somewhere)  //
  2688. //     Restricted Code       S-1-5-12      (Running restricted code)       //
  2689. //                                                                         //
  2690. //     (Logon IDs)           S-1-5-5-X-Y                                   //
  2691. //                                                                         //
  2692. //     (NT non-unique IDs)   S-1-5-0x15-...                                //
  2693. //                                                                         //
  2694. //     (Built-in domain)     s-1-5-0x20                                    //
  2695. //                                                                         //
  2696. /////////////////////////////////////////////////////////////////////////////
  2697.  
  2698.  
  2699. #define SECURITY_NT_AUTHORITY           {0,0,0,0,0,5}   // ntifs
  2700.  
  2701. #define SECURITY_DIALUP_RID             (0x00000001L)
  2702. #define SECURITY_NETWORK_RID            (0x00000002L)
  2703. #define SECURITY_BATCH_RID              (0x00000003L)
  2704. #define SECURITY_INTERACTIVE_RID        (0x00000004L)
  2705. #define SECURITY_SERVICE_RID            (0x00000006L)
  2706. #define SECURITY_ANONYMOUS_LOGON_RID    (0x00000007L)
  2707. #define SECURITY_PROXY_RID              (0x00000008L)
  2708. #define SECURITY_SERVER_LOGON_RID       (0x00000009L)
  2709. #define SECURITY_PRINCIPAL_SELF_RID     (0x0000000AL)
  2710. #define SECURITY_AUTHENTICATED_USER_RID (0x0000000BL)
  2711. #define SECURITY_RESTRICTED_CODE_RID    (0x0000000CL)
  2712.  
  2713. #define SECURITY_LOGON_IDS_RID          (0x00000005L)
  2714. #define SECURITY_LOGON_IDS_RID_COUNT    (3L)
  2715.  
  2716. #define SECURITY_LOCAL_SYSTEM_RID       (0x00000012L)
  2717.  
  2718. #define SECURITY_NT_NON_UNIQUE          (0x00000015L)
  2719.  
  2720. #define SECURITY_BUILTIN_DOMAIN_RID     (0x00000020L)
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726. /////////////////////////////////////////////////////////////////////////////
  2727. //                                                                         //
  2728. // well-known domain relative sub-authority values (RIDs)...               //
  2729. //                                                                         //
  2730. /////////////////////////////////////////////////////////////////////////////
  2731.  
  2732. // Well-known users ...
  2733.  
  2734. #define DOMAIN_USER_RID_ADMIN          (0x000001F4L)
  2735. #define DOMAIN_USER_RID_GUEST          (0x000001F5L)
  2736. #define DOMAIN_USER_RID_KRBTGT         (0x000001F6L)
  2737.  
  2738.  
  2739.  
  2740. // well-known groups ...
  2741.  
  2742. #define DOMAIN_GROUP_RID_ADMINS        (0x00000200L)
  2743. #define DOMAIN_GROUP_RID_USERS         (0x00000201L)
  2744. #define DOMAIN_GROUP_RID_GUESTS        (0x00000202L)
  2745.  
  2746.  
  2747.  
  2748.  
  2749. // well-known aliases ...
  2750.  
  2751. #define DOMAIN_ALIAS_RID_ADMINS        (0x00000220L)
  2752. #define DOMAIN_ALIAS_RID_USERS         (0x00000221L)
  2753. #define DOMAIN_ALIAS_RID_GUESTS        (0x00000222L)
  2754. #define DOMAIN_ALIAS_RID_POWER_USERS   (0x00000223L)
  2755.  
  2756. #define DOMAIN_ALIAS_RID_ACCOUNT_OPS   (0x00000224L)
  2757. #define DOMAIN_ALIAS_RID_SYSTEM_OPS    (0x00000225L)
  2758. #define DOMAIN_ALIAS_RID_PRINT_OPS     (0x00000226L)
  2759. #define DOMAIN_ALIAS_RID_BACKUP_OPS    (0x00000227L)
  2760.  
  2761. #define DOMAIN_ALIAS_RID_REPLICATOR    (0x00000228L)
  2762.  
  2763.  
  2764. //
  2765. // Allocate the System Luid.  The first 1000 LUIDs are reserved.
  2766. // Use #999 here (0x3E7 = 999)
  2767. //
  2768.  
  2769. #define SYSTEM_LUID                     { 0x3E7, 0x0 }
  2770.  
  2771. // end_ntifs
  2772.  
  2773. ////////////////////////////////////////////////////////////////////////
  2774. //                                                                    //
  2775. //                          User and Group related SID attributes     //
  2776. //                                                                    //
  2777. ////////////////////////////////////////////////////////////////////////
  2778.  
  2779. //
  2780. // Group attributes
  2781. //
  2782.  
  2783. #define SE_GROUP_MANDATORY              (0x00000001L)
  2784. #define SE_GROUP_ENABLED_BY_DEFAULT     (0x00000002L)
  2785. #define SE_GROUP_ENABLED                (0x00000004L)
  2786. #define SE_GROUP_OWNER                  (0x00000008L)
  2787. #define SE_GROUP_USE_FOR_DENY_ONLY      (0x00000010L)
  2788. #define SE_GROUP_LOGON_ID               (0xC0000000L)
  2789.  
  2790.  
  2791.  
  2792. //
  2793. // User attributes
  2794. //
  2795.  
  2796. // (None yet defined.)
  2797.  
  2798.  
  2799.  
  2800.  
  2801. ////////////////////////////////////////////////////////////////////////
  2802. //                                                                    //
  2803. //                         ACL  and  ACE                              //
  2804. //                                                                    //
  2805. ////////////////////////////////////////////////////////////////////////
  2806.  
  2807. //
  2808. //  Define an ACL and the ACE format.  The structure of an ACL header
  2809. //  followed by one or more ACEs.  Pictorally the structure of an ACL header
  2810. //  is as follows:
  2811. //
  2812. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2813. //       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
  2814. //      +-------------------------------+---------------+---------------+
  2815. //      |            AclSize            |      Sbz1     |  AclRevision  |
  2816. //      +-------------------------------+---------------+---------------+
  2817. //      |              Sbz2             |           AceCount            |
  2818. //      +-------------------------------+-------------------------------+
  2819. //
  2820. //  The current AclRevision is defined to be ACL_REVISION.
  2821. //
  2822. //  AclSize is the size, in bytes, allocated for the ACL.  This includes
  2823. //  the ACL header, ACES, and remaining free space in the buffer.
  2824. //
  2825. //  AceCount is the number of ACES in the ACL.
  2826. //
  2827.  
  2828. // begin_ntddk begin_ntifs
  2829. // This is the *current* ACL revision
  2830.  
  2831. #define ACL_REVISION     (2)
  2832. #define ACL_REVISION_DS  (4)
  2833.  
  2834. // This is the history of ACL revisions.  Add a new one whenever
  2835. // ACL_REVISION is updated
  2836.  
  2837. #define ACL_REVISION1   (1)
  2838. #define MIN_ACL_REVISION ACL_REVISION2
  2839. #define ACL_REVISION2   (2)
  2840. #define ACL_REVISION3   (3)
  2841. #define ACL_REVISION4   (4)
  2842. #define MAX_ACL_REVISION ACL_REVISION4
  2843.  
  2844. typedef struct _ACL {
  2845.     BYTE  AclRevision;
  2846.     BYTE  Sbz1;
  2847.     WORD   AclSize;
  2848.     WORD   AceCount;
  2849.     WORD   Sbz2;
  2850. } ACL;
  2851. typedef ACL *PACL;
  2852.  
  2853. // end_ntddk
  2854.  
  2855. //
  2856. //  The structure of an ACE is a common ace header followed by ace type
  2857. //  specific data.  Pictorally the structure of the common ace header is
  2858. //  as follows:
  2859. //
  2860. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2861. //       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
  2862. //      +---------------+-------+-------+---------------+---------------+
  2863. //      |            AceSize            |    AceFlags   |     AceType   |
  2864. //      +---------------+-------+-------+---------------+---------------+
  2865. //
  2866. //  AceType denotes the type of the ace, there are some predefined ace
  2867. //  types
  2868. //
  2869. //  AceSize is the size, in bytes, of ace.
  2870. //
  2871. //  AceFlags are the Ace flags for audit and inheritance, defined shortly.
  2872.  
  2873. typedef struct _ACE_HEADER {
  2874.     BYTE  AceType;
  2875.     BYTE  AceFlags;
  2876.     WORD   AceSize;
  2877. } ACE_HEADER;
  2878. typedef ACE_HEADER *PACE_HEADER;
  2879.  
  2880. //
  2881. //  The following are the predefined ace types that go into the AceType
  2882. //  field of an Ace header.
  2883. //
  2884.  
  2885. #define ACCESS_MIN_MS_ACE_TYPE                  (0x0)
  2886. #define ACCESS_ALLOWED_ACE_TYPE                 (0x0)
  2887. #define ACCESS_DENIED_ACE_TYPE                  (0x1)
  2888. #define SYSTEM_AUDIT_ACE_TYPE                   (0x2)
  2889. #define SYSTEM_ALARM_ACE_TYPE                   (0x3)
  2890. #define ACCESS_MAX_MS_V2_ACE_TYPE               (0x3)
  2891.  
  2892. #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE        (0x4)
  2893. #define ACCESS_MAX_MS_V3_ACE_TYPE               (0x4)
  2894.  
  2895. #define ACCESS_MIN_MS_OBJECT_ACE_TYPE           (0x5)
  2896. #define ACCESS_ALLOWED_OBJECT_ACE_TYPE          (0x5)
  2897. #define ACCESS_DENIED_OBJECT_ACE_TYPE           (0x6)
  2898. #define SYSTEM_AUDIT_OBJECT_ACE_TYPE            (0x7)
  2899. #define SYSTEM_ALARM_OBJECT_ACE_TYPE            (0x8)
  2900. #define ACCESS_MAX_MS_OBJECT_ACE_TYPE           (0x8)
  2901.  
  2902. #define ACCESS_MAX_MS_V4_ACE_TYPE               (0x8)
  2903. #define ACCESS_MAX_MS_ACE_TYPE                  (0x8)
  2904.  
  2905. //
  2906. //  The following are the inherit flags that go into the AceFlags field
  2907. //  of an Ace header.
  2908. //
  2909.  
  2910. #define OBJECT_INHERIT_ACE                (0x1)
  2911. #define CONTAINER_INHERIT_ACE             (0x2)
  2912. #define NO_PROPAGATE_INHERIT_ACE          (0x4)
  2913. #define INHERIT_ONLY_ACE                  (0x8)
  2914. #define INHERITED_ACE                     (0x10)
  2915. #define VALID_INHERIT_FLAGS               (0x1F)
  2916.  
  2917.  
  2918. //  The following are the currently defined ACE flags that go into the
  2919. //  AceFlags field of an ACE header.  Each ACE type has its own set of
  2920. //  AceFlags.
  2921. //
  2922. //  SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE
  2923. //  types to indicate that a message is generated for successful accesses.
  2924. //
  2925. //  FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types
  2926. //  to indicate that a message is generated for failed accesses.
  2927. //
  2928.  
  2929. //
  2930. //  SYSTEM_AUDIT and SYSTEM_ALARM AceFlags
  2931. //
  2932. //  These control the signaling of audit and alarms for success or failure.
  2933. //
  2934.  
  2935. #define SUCCESSFUL_ACCESS_ACE_FLAG       (0x40)
  2936. #define FAILED_ACCESS_ACE_FLAG           (0x80)
  2937.  
  2938.  
  2939. //
  2940. //  We'll define the structure of the predefined ACE types.  Pictorally
  2941. //  the structure of the predefined ACE's is as follows:
  2942. //
  2943. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2944. //       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
  2945. //      +---------------+-------+-------+---------------+---------------+
  2946. //      |    AceFlags   | Resd  |Inherit|    AceSize    |     AceType   |
  2947. //      +---------------+-------+-------+---------------+---------------+
  2948. //      |                              Mask                             |
  2949. //      +---------------------------------------------------------------+
  2950. //      |                                                               |
  2951. //      +                                                               +
  2952. //      |                                                               |
  2953. //      +                              Sid                              +
  2954. //      |                                                               |
  2955. //      +                                                               +
  2956. //      |                                                               |
  2957. //      +---------------------------------------------------------------+
  2958. //
  2959. //  Mask is the access mask associated with the ACE.  This is either the
  2960. //  access allowed, access denied, audit, or alarm mask.
  2961. //
  2962. //  Sid is the Sid associated with the ACE.
  2963. //
  2964.  
  2965. //  The following are the four predefined ACE types.
  2966.  
  2967. //  Examine the AceType field in the Header to determine
  2968. //  which structure is appropriate to use for casting.
  2969.  
  2970.  
  2971. typedef struct _ACCESS_ALLOWED_ACE {
  2972.     ACE_HEADER Header;
  2973.     ACCESS_MASK Mask;
  2974.     DWORD SidStart;
  2975. } ACCESS_ALLOWED_ACE;
  2976.  
  2977. typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
  2978.  
  2979. typedef struct _ACCESS_DENIED_ACE {
  2980.     ACE_HEADER Header;
  2981.     ACCESS_MASK Mask;
  2982.     DWORD SidStart;
  2983. } ACCESS_DENIED_ACE;
  2984. typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
  2985.  
  2986. typedef struct _SYSTEM_AUDIT_ACE {
  2987.     ACE_HEADER Header;
  2988.     ACCESS_MASK Mask;
  2989.     DWORD SidStart;
  2990. } SYSTEM_AUDIT_ACE;
  2991. typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
  2992.  
  2993. typedef struct _SYSTEM_ALARM_ACE {
  2994.     ACE_HEADER Header;
  2995.     ACCESS_MASK Mask;
  2996.     DWORD SidStart;
  2997. } SYSTEM_ALARM_ACE;
  2998. typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
  2999.  
  3000. // end_ntifs
  3001.  
  3002.  
  3003. typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
  3004.     ACE_HEADER Header;
  3005.     ACCESS_MASK Mask;
  3006.     DWORD Flags;
  3007.     GUID ObjectType;
  3008.     GUID InheritedObjectType;
  3009.     DWORD SidStart;
  3010. } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
  3011.  
  3012. typedef struct _ACCESS_DENIED_OBJECT_ACE {
  3013.     ACE_HEADER Header;
  3014.     ACCESS_MASK Mask;
  3015.     DWORD Flags;
  3016.     GUID ObjectType;
  3017.     GUID InheritedObjectType;
  3018.     DWORD SidStart;
  3019. } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
  3020.  
  3021. typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
  3022.     ACE_HEADER Header;
  3023.     ACCESS_MASK Mask;
  3024.     DWORD Flags;
  3025.     GUID ObjectType;
  3026.     GUID InheritedObjectType;
  3027.     DWORD SidStart;
  3028. } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
  3029.  
  3030. typedef struct _SYSTEM_ALARM_OBJECT_ACE {
  3031.     ACE_HEADER Header;
  3032.     ACCESS_MASK Mask;
  3033.     DWORD Flags;
  3034.     GUID ObjectType;
  3035.     GUID InheritedObjectType;
  3036.     DWORD SidStart;
  3037. } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_ACE;
  3038.  
  3039. //
  3040. // Currently define Flags for "OBJECT" ACE types.
  3041. //
  3042.  
  3043. #define ACE_OBJECT_TYPE_PRESENT           0x1
  3044. #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
  3045.  
  3046.  
  3047. //
  3048. //  The following declarations are used for setting and querying information
  3049. //  about and ACL.  First are the various information classes available to
  3050. //  the user.
  3051. //
  3052.  
  3053. typedef enum _ACL_INFORMATION_CLASS {
  3054.     AclRevisionInformation = 1,
  3055.     AclSizeInformation
  3056. } ACL_INFORMATION_CLASS;
  3057.  
  3058. //
  3059. //  This record is returned/sent if the user is requesting/setting the
  3060. //  AclRevisionInformation
  3061. //
  3062.  
  3063. typedef struct _ACL_REVISION_INFORMATION {
  3064.     DWORD AclRevision;
  3065. } ACL_REVISION_INFORMATION;
  3066. typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
  3067.  
  3068. //
  3069. //  This record is returned if the user is requesting AclSizeInformation
  3070. //
  3071.  
  3072. typedef struct _ACL_SIZE_INFORMATION {
  3073.     DWORD AceCount;
  3074.     DWORD AclBytesInUse;
  3075.     DWORD AclBytesFree;
  3076. } ACL_SIZE_INFORMATION;
  3077. typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
  3078.  
  3079.  
  3080. ////////////////////////////////////////////////////////////////////////
  3081. //                                                                    //
  3082. //                             SECURITY_DESCRIPTOR                    //
  3083. //                                                                    //
  3084. ////////////////////////////////////////////////////////////////////////
  3085. //
  3086. //  Define the Security Descriptor and related data types.
  3087. //  This is an opaque data structure.
  3088. //
  3089.  
  3090. // begin_ntddk begin_ntifs
  3091. //
  3092. // Current security descriptor revision value
  3093. //
  3094.  
  3095. #define SECURITY_DESCRIPTOR_REVISION     (1)
  3096. #define SECURITY_DESCRIPTOR_REVISION1    (1)
  3097.  
  3098. // end_ntddk
  3099.  
  3100. //
  3101. // Minimum length, in bytes, needed to build a security descriptor
  3102. // (NOTE: This must manually be kept consistent with the)
  3103. // (sizeof(SECURITY_DESCRIPTOR)                         )
  3104. //
  3105.  
  3106. #define SECURITY_DESCRIPTOR_MIN_LENGTH   (20)
  3107.  
  3108.  
  3109. typedef WORD   SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
  3110.  
  3111. #define SE_OWNER_DEFAULTED               (0x0001)
  3112. #define SE_GROUP_DEFAULTED               (0x0002)
  3113. #define SE_DACL_PRESENT                  (0x0004)
  3114. #define SE_DACL_DEFAULTED                (0x0008)
  3115. #define SE_SACL_PRESENT                  (0x0010)
  3116. #define SE_SACL_DEFAULTED                (0x0020)
  3117. #define SE_DACL_AUTO_INHERIT_REQ         (0x0100)
  3118. #define SE_SACL_AUTO_INHERIT_REQ         (0x0200)
  3119. #define SE_DACL_AUTO_INHERITED           (0x0400)
  3120. #define SE_SACL_AUTO_INHERITED           (0x0800)
  3121. #define SE_DACL_PROTECTED                (0x1000)
  3122. #define SE_SACL_PROTECTED                (0x2000)
  3123. #define SE_SELF_RELATIVE                 (0x8000)
  3124.  
  3125. //
  3126. //  Where:
  3127. //
  3128. //      SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
  3129. //          SID pointed to by the Owner field was provided by a
  3130. //          defaulting mechanism rather than explicitly provided by the
  3131. //          original provider of the security descriptor.  This may
  3132. //          affect the treatment of the SID with respect to inheritence
  3133. //          of an owner.
  3134. //
  3135. //      SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
  3136. //          SID in the Group field was provided by a defaulting mechanism
  3137. //          rather than explicitly provided by the original provider of
  3138. //          the security descriptor.  This may affect the treatment of
  3139. //          the SID with respect to inheritence of a primary group.
  3140. //
  3141. //      SE_DACL_PRESENT - This boolean flag, when set, indicates that the
  3142. //          security descriptor contains a discretionary ACL.  If this
  3143. //          flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
  3144. //          null, then a null ACL is explicitly being specified.
  3145. //
  3146. //      SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
  3147. //          ACL pointed to by the Dacl field was provided by a defaulting
  3148. //          mechanism rather than explicitly provided by the original
  3149. //          provider of the security descriptor.  This may affect the
  3150. //          treatment of the ACL with respect to inheritence of an ACL.
  3151. //          This flag is ignored if the DaclPresent flag is not set.
  3152. //
  3153. //      SE_SACL_PRESENT - This boolean flag, when set,  indicates that the
  3154. //          security descriptor contains a system ACL pointed to by the
  3155. //          Sacl field.  If this flag is set and the Sacl field of the
  3156. //          SECURITY_DESCRIPTOR is null, then an empty (but present)
  3157. //          ACL is being specified.
  3158. //
  3159. //      SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
  3160. //          ACL pointed to by the Sacl field was provided by a defaulting
  3161. //          mechanism rather than explicitly provided by the original
  3162. //          provider of the security descriptor.  This may affect the
  3163. //          treatment of the ACL with respect to inheritence of an ACL.
  3164. //          This flag is ignored if the SaclPresent flag is not set.
  3165. //
  3166. //      SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
  3167. //          security descriptor is in self-relative form.  In this form,
  3168. //          all fields of the security descriptor are contiguous in memory
  3169. //          and all pointer fields are expressed as offsets from the
  3170. //          beginning of the security descriptor.  This form is useful
  3171. //          for treating security descriptors as opaque data structures
  3172. //          for transmission in communication protocol or for storage on
  3173. //          secondary media.
  3174. //
  3175. //
  3176. //
  3177. // Pictorially the structure of a security descriptor is as follows:
  3178. //
  3179. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  3180. //       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
  3181. //      +---------------------------------------------------------------+
  3182. //      |            Control            |Reserved1 (SBZ)|   Revision    |
  3183. //      +---------------------------------------------------------------+
  3184. //      |                            Owner                              |
  3185. //      +---------------------------------------------------------------+
  3186. //      |                            Group                              |
  3187. //      +---------------------------------------------------------------+
  3188. //      |                            Sacl                               |
  3189. //      +---------------------------------------------------------------+
  3190. //      |                            Dacl                               |
  3191. //      +---------------------------------------------------------------+
  3192. //
  3193. // In general, this data structure should be treated opaquely to ensure future
  3194. // compatibility.
  3195. //
  3196. //
  3197.  
  3198. typedef struct _SECURITY_DESCRIPTOR {
  3199.    BYTE  Revision;
  3200.    BYTE  Sbz1;
  3201.    SECURITY_DESCRIPTOR_CONTROL Control;
  3202.    PSID Owner;
  3203.    PSID Group;
  3204.    PACL Sacl;
  3205.    PACL Dacl;
  3206.    } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
  3207.  
  3208. // end_ntifs
  3209.  
  3210. // Where:
  3211. //
  3212. //     Revision - Contains the revision level of the security
  3213. //         descriptor.  This allows this structure to be passed between
  3214. //         systems or stored on disk even though it is expected to
  3215. //         change in the future.
  3216. //
  3217. //     Control - A set of flags which qualify the meaning of the
  3218. //         security descriptor or individual fields of the security
  3219. //         descriptor.
  3220. //
  3221. //     Owner - is a pointer to an SID representing an object's owner.
  3222. //         If this field is null, then no owner SID is present in the
  3223. //         security descriptor.  If the security descriptor is in
  3224. //         self-relative form, then this field contains an offset to
  3225. //         the SID, rather than a pointer.
  3226. //
  3227. //     Group - is a pointer to an SID representing an object's primary
  3228. //         group.  If this field is null, then no primary group SID is
  3229. //         present in the security descriptor.  If the security descriptor
  3230. //         is in self-relative form, then this field contains an offset to
  3231. //         the SID, rather than a pointer.
  3232. //
  3233. //     Sacl - is a pointer to a system ACL.  This field value is only
  3234. //         valid if the DaclPresent control flag is set.  If the
  3235. //         SaclPresent flag is set and this field is null, then a null
  3236. //         ACL  is specified.  If the security descriptor is in
  3237. //         self-relative form, then this field contains an offset to
  3238. //         the ACL, rather than a pointer.
  3239. //
  3240. //     Dacl - is a pointer to a discretionary ACL.  This field value is
  3241. //         only valid if the DaclPresent control flag is set.  If the
  3242. //         DaclPresent flag is set and this field is null, then a null
  3243. //         ACL (unconditionally granting access) is specified.  If the
  3244. //         security descriptor is in self-relative form, then this field
  3245. //         contains an offset to the ACL, rather than a pointer.
  3246. //
  3247.  
  3248.  
  3249.  
  3250. ////////////////////////////////////////////////////////////////////////
  3251. //                                                                    //
  3252. //               Object Type list for AccessCheckByType               //
  3253. //                                                                    //
  3254. ////////////////////////////////////////////////////////////////////////
  3255.  
  3256. typedef struct _OBJECT_TYPE_LIST {
  3257.     WORD   Level;
  3258.     WORD   Sbz;
  3259.     GUID *ObjectType;
  3260. } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
  3261.  
  3262. //
  3263. // DS values for Level
  3264. //
  3265.  
  3266. #define ACCESS_OBJECT_GUID       0
  3267. #define ACCESS_PROPERTY_SET_GUID 1
  3268. #define ACCESS_PROPERTY_GUID     2
  3269.  
  3270. #define ACCESS_MAX_LEVEL         4
  3271.  
  3272. //
  3273. // Parameters to NtAccessCheckByTypeAndAditAlarm
  3274. //
  3275.  
  3276. typedef enum _AUDIT_EVENT_TYPE {
  3277.     AuditEventObjectAccess,
  3278.     AuditEventDirectoryServiceAccess
  3279. } AUDIT_EVENT_TYPE, *PAUDIT_EVENT_TYPE;
  3280.  
  3281. #define AUDIT_ALLOW_NO_PRIVILEGE 0x1
  3282.  
  3283. //
  3284. // DS values for Source and ObjectTypeName
  3285. //
  3286.  
  3287. #define ACCESS_DS_SOURCE_A "Directory Service"
  3288. #define ACCESS_DS_SOURCE_W L"Directory Service"
  3289. #define ACCESS_DS_OBJECT_TYPE_NAME_A "Directory Service Object"
  3290. #define ACCESS_DS_OBJECT_TYPE_NAME_W L"Directory Service Object"
  3291.  
  3292.  
  3293. ////////////////////////////////////////////////////////////////////////
  3294. //                                                                    //
  3295. //               Privilege Related Data Structures                    //
  3296. //                                                                    //
  3297. ////////////////////////////////////////////////////////////////////////
  3298.  
  3299.  
  3300. // begin_ntddk begin_nthal begin_ntifs
  3301. //
  3302. // Privilege attributes
  3303. //
  3304.  
  3305. #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
  3306. #define SE_PRIVILEGE_ENABLED            (0x00000002L)
  3307. #define SE_PRIVILEGE_USED_FOR_ACCESS    (0x80000000L)
  3308.  
  3309. //
  3310. // Privilege Set Control flags
  3311. //
  3312.  
  3313. #define PRIVILEGE_SET_ALL_NECESSARY    (1)
  3314.  
  3315. //
  3316. //  Privilege Set - This is defined for a privilege set of one.
  3317. //                  If more than one privilege is needed, then this structure
  3318. //                  will need to be allocated with more space.
  3319. //
  3320. //  Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
  3321. //  structure (defined in se.h)
  3322. //
  3323.  
  3324. typedef struct _PRIVILEGE_SET {
  3325.     DWORD PrivilegeCount;
  3326.     DWORD Control;
  3327.     LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
  3328.     } PRIVILEGE_SET, * PPRIVILEGE_SET;
  3329.  
  3330.  
  3331. ////////////////////////////////////////////////////////////////////////
  3332. //                                                                    //
  3333. //               NT Defined Privileges                                //
  3334. //                                                                    //
  3335. ////////////////////////////////////////////////////////////////////////
  3336.  
  3337. #define SE_CREATE_TOKEN_NAME              TEXT("SeCreateTokenPrivilege")
  3338. #define SE_ASSIGNPRIMARYTOKEN_NAME        TEXT("SeAssignPrimaryTokenPrivilege")
  3339. #define SE_LOCK_MEMORY_NAME               TEXT("SeLockMemoryPrivilege")
  3340. #define SE_INCREASE_QUOTA_NAME            TEXT("SeIncreaseQuotaPrivilege")
  3341. #define SE_UNSOLICITED_INPUT_NAME         TEXT("SeUnsolicitedInputPrivilege")
  3342. #define SE_MACHINE_ACCOUNT_NAME           TEXT("SeMachineAccountPrivilege")
  3343. #define SE_TCB_NAME                       TEXT("SeTcbPrivilege")
  3344. #define SE_SECURITY_NAME                  TEXT("SeSecurityPrivilege")
  3345. #define SE_TAKE_OWNERSHIP_NAME            TEXT("SeTakeOwnershipPrivilege")
  3346. #define SE_LOAD_DRIVER_NAME               TEXT("SeLoadDriverPrivilege")
  3347. #define SE_SYSTEM_PROFILE_NAME            TEXT("SeSystemProfilePrivilege")
  3348. #define SE_SYSTEMTIME_NAME                TEXT("SeSystemtimePrivilege")
  3349. #define SE_PROF_SINGLE_PROCESS_NAME       TEXT("SeProfileSingleProcessPrivilege")
  3350. #define SE_INC_BASE_PRIORITY_NAME         TEXT("SeIncreaseBasePriorityPrivilege")
  3351. #define SE_CREATE_PAGEFILE_NAME           TEXT("SeCreatePagefilePrivilege")
  3352. #define SE_CREATE_PERMANENT_NAME          TEXT("SeCreatePermanentPrivilege")
  3353. #define SE_BACKUP_NAME                    TEXT("SeBackupPrivilege")
  3354. #define SE_RESTORE_NAME                   TEXT("SeRestorePrivilege")
  3355. #define SE_SHUTDOWN_NAME                  TEXT("SeShutdownPrivilege")
  3356. #define SE_DEBUG_NAME                     TEXT("SeDebugPrivilege")
  3357. #define SE_AUDIT_NAME                     TEXT("SeAuditPrivilege")
  3358. #define SE_SYSTEM_ENVIRONMENT_NAME        TEXT("SeSystemEnvironmentPrivilege")
  3359. #define SE_CHANGE_NOTIFY_NAME             TEXT("SeChangeNotifyPrivilege")
  3360. #define SE_REMOTE_SHUTDOWN_NAME           TEXT("SeRemoteShutdownPrivilege")
  3361.  
  3362.  
  3363. ////////////////////////////////////////////////////////////////////
  3364. //                                                                //
  3365. //           Security Quality Of Service                          //
  3366. //                                                                //
  3367. //                                                                //
  3368. ////////////////////////////////////////////////////////////////////
  3369.  
  3370. // begin_ntddk begin_nthal begin_ntifs
  3371. //
  3372. // Impersonation Level
  3373. //
  3374. // Impersonation level is represented by a pair of bits in Windows.
  3375. // If a new impersonation level is added or lowest value is changed from
  3376. // 0 to something else, fix the Windows CreateFile call.
  3377. //
  3378.  
  3379. typedef enum _SECURITY_IMPERSONATION_LEVEL {
  3380.     SecurityAnonymous,
  3381.     SecurityIdentification,
  3382.     SecurityImpersonation,
  3383.     SecurityDelegation
  3384.     } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
  3385.  
  3386. #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
  3387.  
  3388. #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
  3389.  
  3390.  
  3391. ////////////////////////////////////////////////////////////////////
  3392. //                                                                //
  3393. //           Token Object Definitions                             //
  3394. //                                                                //
  3395. //                                                                //
  3396. ////////////////////////////////////////////////////////////////////
  3397.  
  3398.  
  3399. //
  3400. // Token Specific Access Rights.
  3401. //
  3402.  
  3403. #define TOKEN_ASSIGN_PRIMARY    (0x0001)
  3404. #define TOKEN_DUPLICATE         (0x0002)
  3405. #define TOKEN_IMPERSONATE       (0x0004)
  3406. #define TOKEN_QUERY             (0x0008)
  3407. #define TOKEN_QUERY_SOURCE      (0x0010)
  3408. #define TOKEN_ADJUST_PRIVILEGES (0x0020)
  3409. #define TOKEN_ADJUST_GROUPS     (0x0040)
  3410. #define TOKEN_ADJUST_DEFAULT    (0x0080)
  3411.  
  3412. #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED  |\
  3413.                           TOKEN_ASSIGN_PRIMARY      |\
  3414.                           TOKEN_DUPLICATE           |\
  3415.                           TOKEN_IMPERSONATE         |\
  3416.                           TOKEN_QUERY               |\
  3417.                           TOKEN_QUERY_SOURCE        |\
  3418.                           TOKEN_ADJUST_PRIVILEGES   |\
  3419.                           TOKEN_ADJUST_GROUPS       |\
  3420.                           TOKEN_ADJUST_DEFAULT)
  3421.  
  3422.  
  3423. #define TOKEN_READ       (STANDARD_RIGHTS_READ      |\
  3424.                           TOKEN_QUERY)
  3425.  
  3426.  
  3427. #define TOKEN_WRITE      (STANDARD_RIGHTS_WRITE     |\
  3428.                           TOKEN_ADJUST_PRIVILEGES   |\
  3429.                           TOKEN_ADJUST_GROUPS       |\
  3430.                           TOKEN_ADJUST_DEFAULT)
  3431.  
  3432. #define TOKEN_EXECUTE    (STANDARD_RIGHTS_EXECUTE)
  3433.  
  3434.  
  3435. //
  3436. //
  3437. // Token Types
  3438. //
  3439.  
  3440. typedef enum _TOKEN_TYPE {
  3441.     TokenPrimary = 1,
  3442.     TokenImpersonation
  3443.     } TOKEN_TYPE;
  3444. typedef TOKEN_TYPE *PTOKEN_TYPE;
  3445.  
  3446.  
  3447. //
  3448. // Token Information Classes.
  3449. //
  3450.  
  3451.  
  3452. typedef enum _TOKEN_INFORMATION_CLASS {
  3453.     TokenUser = 1,
  3454.     TokenGroups,
  3455.     TokenPrivileges,
  3456.     TokenOwner,
  3457.     TokenPrimaryGroup,
  3458.     TokenDefaultDacl,
  3459.     TokenSource,
  3460.     TokenType,
  3461.     TokenImpersonationLevel,
  3462.     TokenStatistics,
  3463.     TokenRestrictedSids
  3464. } TOKEN_INFORMATION_CLASS, *PTOKEN_INFORMATION_CLASS;
  3465.  
  3466. //
  3467. // Token information class structures
  3468. //
  3469.  
  3470.  
  3471. typedef struct _TOKEN_USER {
  3472.     SID_AND_ATTRIBUTES User;
  3473. } TOKEN_USER, *PTOKEN_USER;
  3474.  
  3475. typedef struct _TOKEN_GROUPS {
  3476.     DWORD GroupCount;
  3477.     SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
  3478. } TOKEN_GROUPS, *PTOKEN_GROUPS;
  3479.  
  3480.  
  3481. typedef struct _TOKEN_PRIVILEGES {
  3482.     DWORD PrivilegeCount;
  3483.     LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
  3484. } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
  3485.  
  3486.  
  3487. typedef struct _TOKEN_OWNER {
  3488.     PSID Owner;
  3489. } TOKEN_OWNER, *PTOKEN_OWNER;
  3490.  
  3491.  
  3492. typedef struct _TOKEN_PRIMARY_GROUP {
  3493.     PSID PrimaryGroup;
  3494. } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
  3495.  
  3496.  
  3497. typedef struct _TOKEN_DEFAULT_DACL {
  3498.     PACL DefaultDacl;
  3499. } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
  3500.  
  3501.  
  3502.  
  3503. #define TOKEN_SOURCE_LENGTH 8
  3504.  
  3505. typedef struct _TOKEN_SOURCE {
  3506.     CHAR SourceName[TOKEN_SOURCE_LENGTH];
  3507.     LUID SourceIdentifier;
  3508. } TOKEN_SOURCE, *PTOKEN_SOURCE;
  3509.  
  3510.  
  3511. typedef struct _TOKEN_STATISTICS {
  3512.     LUID TokenId;
  3513.     LUID AuthenticationId;
  3514.     LARGE_INTEGER ExpirationTime;
  3515.     TOKEN_TYPE TokenType;
  3516.     SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  3517.     DWORD DynamicCharged;
  3518.     DWORD DynamicAvailable;
  3519.     DWORD GroupCount;
  3520.     DWORD PrivilegeCount;
  3521.     LUID ModifiedId;
  3522. } TOKEN_STATISTICS, *PTOKEN_STATISTICS;
  3523.  
  3524.  
  3525.  
  3526. typedef struct _TOKEN_CONTROL {
  3527.     LUID TokenId;
  3528.     LUID AuthenticationId;
  3529.     LUID ModifiedId;
  3530.     TOKEN_SOURCE TokenSource;
  3531.     } TOKEN_CONTROL, *PTOKEN_CONTROL;
  3532.  
  3533. //
  3534. // Security Tracking Mode
  3535. //
  3536.  
  3537. #define SECURITY_DYNAMIC_TRACKING      (TRUE)
  3538. #define SECURITY_STATIC_TRACKING       (FALSE)
  3539.  
  3540. typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
  3541.                     * PSECURITY_CONTEXT_TRACKING_MODE;
  3542.  
  3543.  
  3544.  
  3545. //
  3546. // Quality Of Service
  3547. //
  3548.  
  3549. typedef struct _SECURITY_QUALITY_OF_SERVICE {
  3550.     DWORD Length;
  3551.     SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
  3552.     SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
  3553.     BOOLEAN EffectiveOnly;
  3554.     } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE;
  3555.  
  3556.  
  3557. //
  3558. // Used to represent information related to a thread impersonation
  3559. //
  3560.  
  3561. typedef struct _SE_IMPERSONATION_STATE {
  3562.     PACCESS_TOKEN Token;
  3563.     BOOLEAN CopyOnOpen;
  3564.     BOOLEAN EffectiveOnly;
  3565.     SECURITY_IMPERSONATION_LEVEL Level;
  3566. } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
  3567.  
  3568.  
  3569. typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  3570.  
  3571. #define OWNER_SECURITY_INFORMATION       (0X00000001L)
  3572. #define GROUP_SECURITY_INFORMATION       (0X00000002L)
  3573. #define DACL_SECURITY_INFORMATION        (0X00000004L)
  3574. #define SACL_SECURITY_INFORMATION        (0X00000008L)
  3575. #define PROCESS_TERMINATE         (0x0001)  
  3576. #define PROCESS_CREATE_THREAD     (0x0002)  
  3577. #define PROCESS_VM_OPERATION      (0x0008)  
  3578. #define PROCESS_VM_READ           (0x0010)  
  3579. #define PROCESS_VM_WRITE          (0x0020)  
  3580. #define PROCESS_DUP_HANDLE        (0x0040)  
  3581. #define PROCESS_CREATE_PROCESS    (0x0080)  
  3582. #define PROCESS_SET_QUOTA         (0x0100)  
  3583. #define PROCESS_SET_INFORMATION   (0x0200)  
  3584. #define PROCESS_QUERY_INFORMATION (0x0400)  
  3585. #define PROCESS_ALL_ACCESS        (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  3586.                                    0xFFF)
  3587.  
  3588.  
  3589. #define MAXIMUM_PROCESSORS 32
  3590.  
  3591. #define THREAD_TERMINATE               (0x0001)  
  3592. #define THREAD_SUSPEND_RESUME          (0x0002)  
  3593. #define THREAD_GET_CONTEXT             (0x0008)  
  3594. #define THREAD_SET_CONTEXT             (0x0010)  
  3595. #define THREAD_SET_INFORMATION         (0x0020)  
  3596. #define THREAD_QUERY_INFORMATION       (0x0040)  
  3597. #define THREAD_SET_THREAD_TOKEN        (0x0080)
  3598. #define THREAD_IMPERSONATE             (0x0100)
  3599. #define THREAD_DIRECT_IMPERSONATION    (0x0200)
  3600. // begin_ntddk begin_wdm
  3601.  
  3602. #define THREAD_ALL_ACCESS         (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  3603.                                    0x3FF)
  3604.  
  3605. // end_ntddk end_wdm
  3606. #define JOB_OBJECT_ASSIGN_PROCESS           (0x0001)
  3607. #define JOB_OBJECT_SET_ATTRIBUTES           (0x0002)
  3608. #define JOB_OBJECT_QUERY                    (0x0004)
  3609. #define JOB_OBJECT_TERMINATE                (0x0008)
  3610. #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES  (0x0010)
  3611. #define JOB_OBJECT_ALL_ACCESS       (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  3612.                                         0x1F )
  3613. #define TLS_MINIMUM_AVAILABLE 64    
  3614.  
  3615. typedef struct _NT_TIB {
  3616.     struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
  3617.     PVOID StackBase;
  3618.     PVOID StackLimit;
  3619.     PVOID SubSystemTib;
  3620.     union {
  3621.         PVOID FiberData;
  3622.         DWORD Version;
  3623.     };
  3624.     PVOID ArbitraryUserPointer;
  3625.     struct _NT_TIB *Self;
  3626. } NT_TIB;
  3627. typedef NT_TIB *PNT_TIB;
  3628. #define THREAD_BASE_PRIORITY_LOWRT  15  // value that gets a thread to LowRealtime-1
  3629. #define THREAD_BASE_PRIORITY_MAX    2   // maximum thread base priority boost
  3630. #define THREAD_BASE_PRIORITY_MIN    -2  // minimum thread base priority boost
  3631. #define THREAD_BASE_PRIORITY_IDLE   -15 // value that gets a thread to idle
  3632.  
  3633. typedef struct _QUOTA_LIMITS {
  3634.     DWORD PagedPoolLimit;
  3635.     DWORD NonPagedPoolLimit;
  3636.     DWORD MinimumWorkingSetSize;
  3637.     DWORD MaximumWorkingSetSize;
  3638.     DWORD PagefileLimit;
  3639.     LARGE_INTEGER TimeLimit;
  3640. } QUOTA_LIMITS;
  3641. typedef QUOTA_LIMITS *PQUOTA_LIMITS;
  3642.  
  3643. //
  3644.  
  3645. typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
  3646.     LARGE_INTEGER TotalUserTime;
  3647.     LARGE_INTEGER TotalKernelTime;
  3648.     LARGE_INTEGER ThisPeriodTotalUserTime;
  3649.     LARGE_INTEGER ThisPeriodTotalKernelTime;
  3650.     DWORD TotalPageFaultCount;
  3651.     DWORD TotalProcesses;
  3652.     DWORD ActiveProcesses;
  3653.     DWORD TotalTerminatedProcesses;
  3654. } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
  3655.  
  3656. typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
  3657.     LARGE_INTEGER PerProcessUserTimeLimit;
  3658.     LARGE_INTEGER PerJobUserTimeLimit;
  3659.     DWORD LimitFlags;
  3660.     DWORD MinimumWorkingSetSize;
  3661.     DWORD MaximumWorkingSetSize;
  3662.     DWORD ActiveProcessLimit;
  3663.     DWORD Affinity;
  3664.     DWORD PriorityClass;
  3665. } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
  3666.  
  3667. typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
  3668.     DWORD NumberOfAssignedProcesses;
  3669.     DWORD NumberOfProcessIdsInList;
  3670.     DWORD ProcessIdList[1];
  3671. } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
  3672.  
  3673. typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
  3674.     DWORD UIRestrictionsClass;
  3675. } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
  3676.  
  3677. typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
  3678.     DWORD SecurityLimitFlags ;
  3679.     HANDLE JobToken ;
  3680.     PTOKEN_GROUPS SidsToDisable ;
  3681.     PTOKEN_PRIVILEGES PrivilegesToDelete ;
  3682.     PTOKEN_GROUPS RestrictedSids ;
  3683. } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION ;
  3684.  
  3685.  
  3686. #define JOB_OBJECT_LIMIT_WORKINGSET         0x00000001
  3687. #define JOB_OBJECT_LIMIT_PROCESS_TIME       0x00000002
  3688. #define JOB_OBJECT_LIMIT_JOB_TIME           0x00000004
  3689. #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS     0x00000008
  3690. #define JOB_OBJECT_LIMIT_AFFINITY           0x00000010
  3691. #define JOB_OBJECT_LIMIT_PRIORITY_CLASS     0x00000020
  3692. #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME  0x00000040
  3693.  
  3694. #define JOB_OBJECT_LIMIT_VALID_FLAGS        0x0000007f
  3695.  
  3696. //
  3697. // UI restrictions for jobs
  3698. //
  3699.  
  3700. #define JOB_OBJECT_UILIMIT_NONE             0x00000000
  3701.  
  3702. #define JOB_OBJECT_UILIMIT_HANDLES          0x00000001
  3703. #define JOB_OBJECT_UILIMIT_READCLIPBOARD    0x00000002
  3704. #define JOB_OBJECT_UILIMIT_WRITECLIPBOARD   0x00000004
  3705. #define JOB_OBJECT_UILIMIT_EXITWINDOWS      0x00000008
  3706. #define JOB_OBJECT_UILIMIT_SYSTEMPARAMTERS  0x00000010
  3707.  
  3708. #define JOB_OBJECT_UILIMIT_ALL              0x0000001F
  3709.  
  3710. #define JOB_OBJECT_UI_VALID_FLAGS           0x0000001F
  3711.  
  3712. #define JOB_OBJECT_SECURITY_NO_ADMIN            0x00000001
  3713. #define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN    0x00000002
  3714. #define JOB_OBJECT_SECURITY_ONLY_TOKEN          0x00000004
  3715. #define JOB_OBJECT_SECURITY_FILTER_TOKENS       0x00000008
  3716.  
  3717. #define JOB_OBJECT_SECURITY_VALID_FLAGS         0x0000000f
  3718.  
  3719. typedef enum _JOBOBJECTINFOCLASS {
  3720.     JobObjectBasicAccountingInformation = 1,
  3721.     JobObjectBasicLimitInformation,
  3722.     JobObjectBasicProcessIdList,
  3723.     JobObjectBasicUIRestrictions,
  3724.     JobObjectSecurityLimitInformation,
  3725.     MaxJobObjectInfoClass
  3726.     } JOBOBJECTINFOCLASS;
  3727. //
  3728. #define EVENT_MODIFY_STATE      0x0002  
  3729. #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) 
  3730. #define MUTANT_QUERY_STATE      0x0001
  3731.  
  3732. #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|\
  3733.                           MUTANT_QUERY_STATE)
  3734. #define SEMAPHORE_MODIFY_STATE      0x0002  
  3735. #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) 
  3736. #define TIME_ZONE_ID_UNKNOWN  0
  3737. #define TIME_ZONE_ID_STANDARD 1
  3738. #define TIME_ZONE_ID_DAYLIGHT 2
  3739.  
  3740. #define PROCESSOR_INTEL_386     386
  3741. #define PROCESSOR_INTEL_486     486
  3742. #define PROCESSOR_INTEL_PENTIUM 586
  3743. #define PROCESSOR_INTEL_860     860
  3744. #define PROCESSOR_MIPS_R2000    2000
  3745. #define PROCESSOR_MIPS_R3000    3000
  3746. #define PROCESSOR_MIPS_R4000    4000    // incl R4101 & R3910 for Windows CE
  3747. #define PROCESSOR_ALPHA_21064   21064
  3748. #define PROCESSOR_PPC_601       601
  3749. #define PROCESSOR_PPC_603       603
  3750. #define PROCESSOR_PPC_604       604
  3751. #define PROCESSOR_PPC_620       620
  3752. #define PROCESSOR_HITACHI_SH3   10003   // Windows CE
  3753. #define PROCESSOR_HITACHI_SH3E  10004   // Windows CE
  3754. #define PROCESSOR_HITACHI_SH4   10005   // Windows CE
  3755. #define PROCESSOR_MOTOROLA_821  821         // Windows CE
  3756. #define PROCESSOR_SHx_SH3       103
  3757. #define PROCESSOR_SHx_SH4       104
  3758. #define PROCESSOR_STRONGARM     2577    // 0xA11
  3759. #define PROCESSOR_ARM720        1824    // 0x720
  3760. #define PROCESSOR_ARM820        2080    // 0x820
  3761. #define PROCESSOR_ARM920        2336    // 0x920
  3762. #define PROCESSOR_ARM_7TDMI     70001   // Windows CE
  3763.  
  3764. #define PROCESSOR_ARCHITECTURE_INTEL 0
  3765. #define PROCESSOR_ARCHITECTURE_MIPS  1
  3766. #define PROCESSOR_ARCHITECTURE_ALPHA 2
  3767. #define PROCESSOR_ARCHITECTURE_PPC   3
  3768. #define PROCESSOR_ARCHITECTURE_SHX   4
  3769. #define PROCESSOR_ARCHITECTURE_ARM   5
  3770. #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
  3771.  
  3772. #define PF_FLOATING_POINT_PRECISION_ERRATA  0   
  3773. #define PF_FLOATING_POINT_EMULATED          1   
  3774. #define PF_COMPARE_EXCHANGE_DOUBLE          2   
  3775. #define PF_MMX_INSTRUCTIONS_AVAILABLE       3   
  3776. #define PF_PPC_MOVEMEM_64BIT_OK             4   
  3777. #define PF_ALPHA_BYTE_INSTRUCTIONS          5   
  3778. typedef struct _MEMORY_BASIC_INFORMATION {
  3779.     PVOID BaseAddress;
  3780.     PVOID AllocationBase;
  3781.     DWORD AllocationProtect;
  3782.     DWORD RegionSize;
  3783.     DWORD State;
  3784.     DWORD Protect;
  3785.     DWORD Type;
  3786. } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
  3787.  
  3788. typedef struct _MEMORY_BASIC_INFORMATION_VLM {
  3789.     union {
  3790.         PVOID64 BaseAddress;
  3791.         DWORDLONG BaseAddressAsUlongLong;
  3792.     };
  3793.     union {
  3794.         PVOID64 AllocationBase;
  3795.         DWORDLONG AllocationBaseAsUlongLong;
  3796.     };
  3797.     DWORDLONG RegionSize;
  3798.     DWORD AllocationProtect;
  3799.     DWORD State;
  3800.     DWORD Protect;
  3801.     DWORD Type;
  3802. } MEMORY_BASIC_INFORMATION_VLM, *PMEMORY_BASIC_INFORMATION_VLM;
  3803. #define SECTION_QUERY       0x0001
  3804. #define SECTION_MAP_WRITE   0x0002
  3805. #define SECTION_MAP_READ    0x0004
  3806. #define SECTION_MAP_EXECUTE 0x0008
  3807. #define SECTION_EXTEND_SIZE 0x0010
  3808.  
  3809. #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
  3810.                             SECTION_MAP_WRITE |      \
  3811.                             SECTION_MAP_READ |       \
  3812.                             SECTION_MAP_EXECUTE |    \
  3813.                             SECTION_EXTEND_SIZE)
  3814. #define PAGE_NOACCESS          0x01     
  3815. #define PAGE_READONLY          0x02     
  3816. #define PAGE_READWRITE         0x04     
  3817. #define PAGE_WRITECOPY         0x08     
  3818. #define PAGE_EXECUTE           0x10     
  3819. #define PAGE_EXECUTE_READ      0x20     
  3820. #define PAGE_EXECUTE_READWRITE 0x40     
  3821. #define PAGE_EXECUTE_WRITECOPY 0x80     
  3822. #define PAGE_GUARD            0x100     
  3823. #define PAGE_NOCACHE          0x200     
  3824. #define MEM_COMMIT           0x1000     
  3825. #define MEM_RESERVE          0x2000     
  3826. #define MEM_DECOMMIT         0x4000     
  3827. #define MEM_RELEASE          0x8000     
  3828. #define MEM_FREE            0x10000     
  3829. #define MEM_PRIVATE         0x20000     
  3830. #define MEM_MAPPED          0x40000     
  3831. #define MEM_RESET           0x80000     
  3832. #define MEM_TOP_DOWN       0x100000     
  3833. #define MEM_4MB_PAGES    0x80000000     
  3834. #define SEC_FILE           0x800000     
  3835. #define SEC_IMAGE         0x1000000     
  3836. #define SEC_VLM           0x2000000     
  3837. #define SEC_RESERVE       0x4000000     
  3838. #define SEC_COMMIT        0x8000000     
  3839. #define SEC_NOCACHE      0x10000000     
  3840. #define MEM_IMAGE         SEC_IMAGE     
  3841.  
  3842. //
  3843. // Define access rights to files and directories
  3844. //
  3845.  
  3846. //
  3847. // The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
  3848. // devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
  3849. // constants *MUST* always be in sync.
  3850. // The values are redefined in devioctl.h because they must be available to
  3851. // both DOS and NT.
  3852. //
  3853.  
  3854. #define FILE_READ_DATA            ( 0x0001 )    // file & pipe
  3855. #define FILE_LIST_DIRECTORY       ( 0x0001 )    // directory
  3856.  
  3857. #define FILE_WRITE_DATA           ( 0x0002 )    // file & pipe
  3858. #define FILE_ADD_FILE             ( 0x0002 )    // directory
  3859.  
  3860. #define FILE_APPEND_DATA          ( 0x0004 )    // file
  3861. #define FILE_ADD_SUBDIRECTORY     ( 0x0004 )    // directory
  3862. #define FILE_CREATE_PIPE_INSTANCE ( 0x0004 )    // named pipe
  3863.  
  3864. #define FILE_READ_EA              ( 0x0008 )    // file & directory
  3865.  
  3866. #define FILE_WRITE_EA             ( 0x0010 )    // file & directory
  3867.  
  3868. #define FILE_EXECUTE              ( 0x0020 )    // file
  3869. #define FILE_TRAVERSE             ( 0x0020 )    // directory
  3870.  
  3871. #define FILE_DELETE_CHILD         ( 0x0040 )    // directory
  3872.  
  3873. #define FILE_READ_ATTRIBUTES      ( 0x0080 )    // all
  3874.  
  3875. #define FILE_WRITE_ATTRIBUTES     ( 0x0100 )    // all
  3876.  
  3877. #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
  3878.  
  3879. #define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ     |\
  3880.                                    FILE_READ_DATA           |\
  3881.                                    FILE_READ_ATTRIBUTES     |\
  3882.                                    FILE_READ_EA             |\
  3883.                                    SYNCHRONIZE)
  3884.  
  3885.  
  3886. #define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE    |\
  3887.                                    FILE_WRITE_DATA          |\
  3888.                                    FILE_WRITE_ATTRIBUTES    |\
  3889.                                    FILE_WRITE_EA            |\
  3890.                                    FILE_APPEND_DATA         |\
  3891.                                    SYNCHRONIZE)
  3892.  
  3893.  
  3894. #define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE  |\
  3895.                                    FILE_READ_ATTRIBUTES     |\
  3896.                                    FILE_EXECUTE             |\
  3897.                                    SYNCHRONIZE)
  3898.  
  3899. #define FILE_SHARE_READ                 0x00000001  
  3900. #define FILE_SHARE_WRITE                0x00000002  
  3901. #define FILE_SHARE_DELETE               0x00000004  
  3902. #define FILE_ATTRIBUTE_READONLY         0x00000001  
  3903. #define FILE_ATTRIBUTE_HIDDEN           0x00000002  
  3904. #define FILE_ATTRIBUTE_SYSTEM           0x00000004  
  3905. #define FILE_ATTRIBUTE_DIRECTORY        0x00000010  
  3906. #define FILE_ATTRIBUTE_ARCHIVE          0x00000020  
  3907. #define FILE_ATTRIBUTE_ENCRYPTED        0x00000040  
  3908. #define FILE_ATTRIBUTE_NORMAL           0x00000080  
  3909. #define FILE_ATTRIBUTE_TEMPORARY        0x00000100  
  3910. #define FILE_ATTRIBUTE_SPARSE_FILE      0x00000200  
  3911. #define FILE_ATTRIBUTE_REPARSE_POINT    0x00000400  
  3912. #define FILE_ATTRIBUTE_COMPRESSED       0x00000800  
  3913. #define FILE_ATTRIBUTE_OFFLINE          0x00001000  
  3914. #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001   
  3915. #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002   
  3916. #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004   
  3917. #define FILE_NOTIFY_CHANGE_SIZE         0x00000008   
  3918. #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010   
  3919. #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020   
  3920. #define FILE_NOTIFY_CHANGE_CREATION     0x00000040   
  3921. #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100   
  3922. #define FILE_ACTION_ADDED               0x00000001   
  3923. #define FILE_ACTION_REMOVED             0x00000002   
  3924. #define FILE_ACTION_MODIFIED            0x00000003   
  3925. #define FILE_ACTION_RENAMED_OLD_NAME    0x00000004   
  3926. #define FILE_ACTION_RENAMED_NEW_NAME    0x00000005   
  3927. #define MAILSLOT_NO_MESSAGE             ((DWORD)-1) 
  3928. #define MAILSLOT_WAIT_FOREVER           ((DWORD)-1) 
  3929. #define FILE_CASE_SENSITIVE_SEARCH      0x00000001  
  3930. #define FILE_CASE_PRESERVED_NAMES       0x00000002  
  3931. #define FILE_UNICODE_ON_DISK            0x00000004  
  3932. #define FILE_PERSISTENT_ACLS            0x00000008  
  3933. #define FILE_FILE_COMPRESSION           0x00000010  
  3934. #define FILE_VOLUME_QUOTAS              0x00000020  
  3935. #define FILE_SUPPORTS_SPARSE_FILES      0x00000040  
  3936. #define FILE_SUPPORTS_REPARSE_POINTS    0x00000080  
  3937. #define FILE_SUPPORTS_REMOTE_STORAGE    0x00000100  
  3938. #define FILE_VOLUME_IS_COMPRESSED       0x00008000  
  3939. #define FILE_SUPPORTS_OBJECT_IDS        0x00010000  
  3940. #define FILE_SUPPORTS_ENCRYPTION        0x00020000  
  3941.  
  3942. //
  3943. // Define the file notification information structure
  3944. //
  3945.  
  3946. typedef struct _FILE_NOTIFY_INFORMATION {
  3947.     DWORD NextEntryOffset;
  3948.     DWORD Action;
  3949.     DWORD FileNameLength;
  3950.     WCHAR FileName[1];
  3951. } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
  3952.  
  3953.  
  3954. //
  3955. // Define segement buffer structure for scatter/gather read/write.
  3956. //
  3957.  
  3958. typedef union _FILE_SEGMENT_ELEMENT {
  3959.     PVOID64 Buffer;
  3960.     DWORDLONG Alignment;
  3961. }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
  3962.  
  3963. //
  3964. // Structures for FSCTL_SET_REPARSE_POINT, FSCTL_GET_REPARSE_POINT, and FSCTL_DELETE_REPARSE_POINT
  3965. //
  3966.  
  3967. //
  3968. // The reparse structure is used by layered drivers to store data in a
  3969. // reparse point. The constraints on reparse tags are defined below.
  3970. //
  3971.  
  3972. typedef struct _REPARSE_DATA_BUFFER {
  3973.     DWORD  ReparseTag;
  3974.     WORD   ReparseDataLength;
  3975.     WORD   Reserved;
  3976.     union {
  3977.         struct {
  3978.             WORD   SubstituteNameOffset;
  3979.             WORD   SubstituteNameLength;
  3980.             WORD   PrintNameOffset;
  3981.             WORD   PrintNameLength;
  3982.             WCHAR PathBuffer[1];
  3983.         } SymbolicLinkReparseBuffer;
  3984.         struct {
  3985.             WORD   SubstituteNameOffset;
  3986.             WORD   SubstituteNameLength;
  3987.             WORD   PrintNameOffset;
  3988.             WORD   PrintNameLength;
  3989.             WCHAR PathBuffer[1];
  3990.         } MountPointReparseBuffer;
  3991.         struct {
  3992.             BYTE   DataBuffer[1];
  3993.         } GenericReparseBuffer;
  3994.     };
  3995. } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
  3996.  
  3997.  
  3998. #define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
  3999.  
  4000. //
  4001. // The reparse information structure is used to return information about
  4002. // a reparse point to the caller.
  4003. //
  4004.  
  4005. typedef struct _REPARSE_POINT_INFORMATION {
  4006.     WORD   ReparseDataLength;
  4007.     WORD   UnparsedNameLength;
  4008. } REPARSE_POINT_INFORMATION, *PREPARSE_POINT_INFORMATION;
  4009.  
  4010. //
  4011. // Maximum allowed size of the reparse data.
  4012. //
  4013.  
  4014. #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE      ( 16 * 1024 )
  4015.  
  4016. //
  4017. // Predefined reparse tags.
  4018. // These tags need to avoid conflicting with IO_REMOUNT defined in ntos\inc\io.h
  4019. //
  4020.  
  4021. #define IO_REPARSE_TAG_RESERVED_ZERO             (0)
  4022. #define IO_REPARSE_TAG_RESERVED_ONE              (1)
  4023.  
  4024. //
  4025. // The value of the following constant needs to satisfy the following conditions:
  4026. //  (1) Be at least as large as the largest of the reserved tags.
  4027. //  (2) Be strictly smaller than all the tags in use.
  4028. //
  4029.  
  4030. #define IO_REPARSE_TAG_RESERVED_RANGE            IO_REPARSE_TAG_RESERVED_ONE
  4031.  
  4032. //
  4033. // The reparse tags are a DWORD. The 32 bits are laid out as follows:
  4034. //
  4035. //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  4036. //   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
  4037. //  +-+-+-+-------------------------+-------------------------------+
  4038. //  |M|L|N|   Reserved bits         |       Reparse Tag Value       |
  4039. //  +-+-+-+-------------------------+-------------------------------+
  4040. //
  4041. // M is the Microsoft bit. When set to 1, it denotes a tag owned by Microsoft.
  4042. //   All ISVs must use a tag with a 0 in this position.
  4043. //   Note: If a Microsoft tag is used by non-Microsoft software, the
  4044. //   behavior is not defined.
  4045. //
  4046. // L is the high-latency bit. When set to 1, a file with this tag is
  4047. //   expected to have a long latency to retrieve the first byte of data.
  4048. //
  4049. // N is name surrogate. When set to 1, the file represents another named
  4050. //   entity in the system.
  4051. //
  4052. // The M, L, and N bits are OR-able.
  4053. // The following macros check for the M, L and N bit values:
  4054. //
  4055.  
  4056. //
  4057. // Macro to determine whether a reparse point tag corresponds to a tag
  4058. // owned by Microsoft.
  4059. //
  4060.  
  4061. #define IsReparseTagMicrosoft(_tag) (              \
  4062.                            ((_tag) & 0x80000000)   \
  4063.                            )
  4064.  
  4065. //
  4066. // Macro to determine whether a reparse point tag corresponds to a file
  4067. // that is to be displayed with the slow icon overlay.
  4068. //
  4069.  
  4070. #define IsReparseTagHighLatency(_tag) (            \
  4071.                            ((_tag) & 0x40000000)   \
  4072.                            )
  4073.  
  4074. //
  4075. // Macro to determine whether a reparse point tag corresponds to a file
  4076. // that is to be displayed with the slow icon overlay.
  4077. //
  4078.  
  4079. #define IsReparseTagNameSurrogate(_tag) (          \
  4080.                            ((_tag) & 0x20000000)   \
  4081.                            )
  4082.  
  4083. //
  4084. // The following constant represents the bits that are valid to use in
  4085. // reparse tags.
  4086. //
  4087.  
  4088. #define IO_REPARSE_TAG_VALID_VALUES     (0xE000FFFF)
  4089.  
  4090. //
  4091. // Macro to determine whether a reparse tag is a valid tag.
  4092. //
  4093.  
  4094. #define IsReparseTagValid(_tag) (                               \
  4095.                  (!((_tag) & ~IO_REPARSE_TAG_VALID_VALUES) &&   \
  4096.                   ((_tag) > IO_REPARSE_TAG_RESERVED_RANGE)      \
  4097.                  )
  4098.  
  4099. //
  4100. // Microsoft tags for reparse points.
  4101. //
  4102.  
  4103. #define IO_REPARSE_TAG_SYMBOLIC_LINK             (0xA0000002)
  4104. #define IO_REPARSE_TAG_MOUNT_POINT               (0xA0000003)
  4105. #define IO_REPARSE_TAG_HSM                       (0xC0000004)
  4106. #define IO_REPARSE_TAG_NSS                       (0x80000005)
  4107. #define IO_REPARSE_TAG_NSSRECOVER                (0x80000006)
  4108. #define IO_REPARSE_TAG_SIS                       (0x80000007)
  4109. #define IO_REPARSE_TAG_DFS                       (0x80000008)
  4110.  
  4111. #define IO_COMPLETION_MODIFY_STATE  0x0002  
  4112. #define IO_COMPLETION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) 
  4113. #define DUPLICATE_CLOSE_SOURCE      0x00000001  
  4114. #define DUPLICATE_SAME_ACCESS       0x00000002  
  4115.  
  4116. #define ES_SYSTEM_REQUIRED  ((DWORD)0x00000001)
  4117. #define ES_DISPLAY_REQUIRED ((DWORD)0x00000002)
  4118. #define ES_USER_PRESENT     ((DWORD)0x00000004)
  4119. #define ES_CONTINUOUS       ((DWORD)0x80000000)
  4120.  
  4121. typedef DWORD EXECUTION_STATE;
  4122.  
  4123. typedef enum {
  4124.     LT_DONT_CARE,
  4125.     LT_LOWEST_LATENCY
  4126. } LATENCY_TIME;
  4127.  
  4128. // wmi
  4129. typedef struct _POWER_DEVICE_TIMEOUTS {
  4130.     DWORD   ConservationIdleTime;
  4131.     DWORD   PerformanceIdleTime;
  4132. } POWER_DEVICE_TIMOUTS, *PPOWER_DEVICE_TIMEOUTS;
  4133.  
  4134.  
  4135.  
  4136. //
  4137. // Image Format
  4138. //
  4139.  
  4140.  
  4141. #ifndef _MAC
  4142.  
  4143. #include "pshpack4.h"                   // 4 byte packing is the default
  4144.  
  4145. #define IMAGE_DOS_SIGNATURE                 0x5A4D      // MZ
  4146. #define IMAGE_OS2_SIGNATURE                 0x454E      // NE
  4147. #define IMAGE_OS2_SIGNATURE_LE              0x454C      // LE
  4148. #define IMAGE_VXD_SIGNATURE                 0x454C      // LE
  4149. #define IMAGE_NT_SIGNATURE                  0x00004550  // PE00
  4150.  
  4151. #include "pshpack2.h"                   // 16 bit headers are 2 byte packed
  4152.  
  4153. #else
  4154.  
  4155. #include "pshpack1.h"
  4156.  
  4157. #define IMAGE_DOS_SIGNATURE                 0x4D5A      // MZ
  4158. #define IMAGE_OS2_SIGNATURE                 0x4E45      // NE
  4159. #define IMAGE_OS2_SIGNATURE_LE              0x4C45      // LE
  4160. #define IMAGE_NT_SIGNATURE                  0x50450000  // PE00
  4161. #endif
  4162.  
  4163. typedef struct _IMAGE_DOS_HEADER {      // DOS .EXE header
  4164.     WORD   e_magic;                     // Magic number
  4165.     WORD   e_cblp;                      // Bytes on last page of file
  4166.     WORD   e_cp;                        // Pages in file
  4167.     WORD   e_crlc;                      // Relocations
  4168.     WORD   e_cparhdr;                   // Size of header in paragraphs
  4169.     WORD   e_minalloc;                  // Minimum extra paragraphs needed
  4170.     WORD   e_maxalloc;                  // Maximum extra paragraphs needed
  4171.     WORD   e_ss;                        // Initial (relative) SS value
  4172.     WORD   e_sp;                        // Initial SP value
  4173.     WORD   e_csum;                      // Checksum
  4174.     WORD   e_ip;                        // Initial IP value
  4175.     WORD   e_cs;                        // Initial (relative) CS value
  4176.     WORD   e_lfarlc;                    // File address of relocation table
  4177.     WORD   e_ovno;                      // Overlay number
  4178.     WORD   e_res[4];                    // Reserved words
  4179.     WORD   e_oemid;                     // OEM identifier (for e_oeminfo)
  4180.     WORD   e_oeminfo;                   // OEM information; e_oemid specific
  4181.     WORD   e_res2[10];                  // Reserved words
  4182.     LONG   e_lfanew;                    // File address of new exe header
  4183.   } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
  4184.  
  4185. typedef struct _IMAGE_OS2_HEADER {      // OS/2 .EXE header
  4186.     WORD   ne_magic;                    // Magic number
  4187.     CHAR   ne_ver;                      // Version number
  4188.     CHAR   ne_rev;                      // Revision number
  4189.     WORD   ne_enttab;                   // Offset of Entry Table
  4190.     WORD   ne_cbenttab;                 // Number of bytes in Entry Table
  4191.     LONG   ne_crc;                      // Checksum of whole file
  4192.     WORD   ne_flags;                    // Flag word
  4193.     WORD   ne_autodata;                 // Automatic data segment number
  4194.     WORD   ne_heap;                     // Initial heap allocation
  4195.     WORD   ne_stack;                    // Initial stack allocation
  4196.     LONG   ne_csip;                     // Initial CS:IP setting
  4197.     LONG   ne_sssp;                     // Initial SS:SP setting
  4198.     WORD   ne_cseg;                     // Count of file segments
  4199.     WORD   ne_cmod;                     // Entries in Module Reference Table
  4200.     WORD   ne_cbnrestab;                // Size of non-resident name table
  4201.     WORD   ne_segtab;                   // Offset of Segment Table
  4202.     WORD   ne_rsrctab;                  // Offset of Resource Table
  4203.     WORD   ne_restab;                   // Offset of resident name table
  4204.     WORD   ne_modtab;                   // Offset of Module Reference Table
  4205.     WORD   ne_imptab;                   // Offset of Imported Names Table
  4206.     LONG   ne_nrestab;                  // Offset of Non-resident Names Table
  4207.     WORD   ne_cmovent;                  // Count of movable entries
  4208.     WORD   ne_align;                    // Segment alignment shift count
  4209.     WORD   ne_cres;                     // Count of resource segments
  4210.     BYTE   ne_exetyp;                   // Target Operating system
  4211.     BYTE   ne_flagsothers;              // Other .EXE flags
  4212.     WORD   ne_pretthunks;               // offset to return thunks
  4213.     WORD   ne_psegrefbytes;             // offset to segment ref. bytes
  4214.     WORD   ne_swaparea;                 // Minimum code swap area size
  4215.     WORD   ne_expver;                   // Expected Windows version number
  4216.   } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
  4217.  
  4218. typedef struct _IMAGE_VXD_HEADER {      // Windows VXD header
  4219.     WORD   e32_magic;                   // Magic number
  4220.     BYTE   e32_border;                  // The byte ordering for the VXD
  4221.     BYTE   e32_worder;                  // The word ordering for the VXD
  4222.     DWORD  e32_level;                   // The EXE format level for now = 0
  4223.     WORD   e32_cpu;                     // The CPU type
  4224.     WORD   e32_os;                      // The OS type
  4225.     DWORD  e32_ver;                     // Module version
  4226.     DWORD  e32_mflags;                  // Module flags
  4227.     DWORD  e32_mpages;                  // Module # pages
  4228.     DWORD  e32_startobj;                // Object # for instruction pointer
  4229.     DWORD  e32_eip;                     // Extended instruction pointer
  4230.     DWORD  e32_stackobj;                // Object # for stack pointer
  4231.     DWORD  e32_esp;                     // Extended stack pointer
  4232.     DWORD  e32_pagesize;                // VXD page size
  4233.     DWORD  e32_lastpagesize;            // Last page size in VXD
  4234.     DWORD  e32_fixupsize;               // Fixup section size
  4235.     DWORD  e32_fixupsum;                // Fixup section checksum
  4236.     DWORD  e32_ldrsize;                 // Loader section size
  4237.     DWORD  e32_ldrsum;                  // Loader section checksum
  4238.     DWORD  e32_objtab;                  // Object table offset
  4239.     DWORD  e32_objcnt;                  // Number of objects in module
  4240.     DWORD  e32_objmap;                  // Object page map offset
  4241.     DWORD  e32_itermap;                 // Object iterated data map offset
  4242.     DWORD  e32_rsrctab;                 // Offset of Resource Table
  4243.     DWORD  e32_rsrccnt;                 // Number of resource entries
  4244.     DWORD  e32_restab;                  // Offset of resident name table
  4245.     DWORD  e32_enttab;                  // Offset of Entry Table
  4246.     DWORD  e32_dirtab;                  // Offset of Module Directive Table
  4247.     DWORD  e32_dircnt;                  // Number of module directives
  4248.     DWORD  e32_fpagetab;                // Offset of Fixup Page Table
  4249.     DWORD  e32_frectab;                 // Offset of Fixup Record Table
  4250.     DWORD  e32_impmod;                  // Offset of Import Module Name Table
  4251.     DWORD  e32_impmodcnt;               // Number of entries in Import Module Name Table
  4252.     DWORD  e32_impproc;                 // Offset of Import Procedure Name Table
  4253.     DWORD  e32_pagesum;                 // Offset of Per-Page Checksum Table
  4254.     DWORD  e32_datapage;                // Offset of Enumerated Data Pages
  4255.     DWORD  e32_preload;                 // Number of preload pages
  4256.     DWORD  e32_nrestab;                 // Offset of Non-resident Names Table
  4257.     DWORD  e32_cbnrestab;               // Size of Non-resident Name Table
  4258.     DWORD  e32_nressum;                 // Non-resident Name Table Checksum
  4259.     DWORD  e32_autodata;                // Object # for automatic data object
  4260.     DWORD  e32_debuginfo;               // Offset of the debugging information
  4261.     DWORD  e32_debuglen;                // The length of the debugging info. in bytes
  4262.     DWORD  e32_instpreload;             // Number of instance pages in preload section of VXD file
  4263.     DWORD  e32_instdemand;              // Number of instance pages in demand load section of VXD file
  4264.     DWORD  e32_heapsize;                // Size of heap - for 16-bit apps
  4265.     BYTE   e32_res3[12];                // Reserved words
  4266.     DWORD  e32_winresoff;
  4267.     DWORD  e32_winreslen;
  4268.     WORD   e32_devid;                   // Device ID for VxD
  4269.     WORD   e32_ddkver;                  // DDK version for VxD
  4270.   } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
  4271.  
  4272. #ifndef _MAC
  4273. #include "poppack.h"                    // Back to 4 byte packing
  4274. #endif
  4275.  
  4276. //
  4277. // File header format.
  4278. //
  4279.  
  4280. typedef struct _IMAGE_FILE_HEADER {
  4281.     WORD    Machine;
  4282.     WORD    NumberOfSections;
  4283.     DWORD   TimeDateStamp;
  4284.     DWORD   PointerToSymbolTable;
  4285.     DWORD   NumberOfSymbols;
  4286.     WORD    SizeOfOptionalHeader;
  4287.     WORD    Characteristics;
  4288. } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
  4289.  
  4290.  
  4291. #define IMAGE_SIZEOF_FILE_HEADER             20
  4292.  
  4293.  
  4294. #define IMAGE_FILE_RELOCS_STRIPPED           0x0001  // Relocation info stripped from file.
  4295. #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002  // File is executable  (i.e. no unresolved externel references).
  4296. #define IMAGE_FILE_LINE_NUMS_STRIPPED        0x0004  // Line nunbers stripped from file.
  4297. #define IMAGE_FILE_LOCAL_SYMS_STRIPPED       0x0008  // Local symbols stripped from file.
  4298. #define IMAGE_FILE_AGGRESIVE_WS_TRIM         0x0010  // Agressively trim working set
  4299. #define IMAGE_FILE_LARGE_ADDRESS_AWARE       0x0020  // App can handle >2gb addresses
  4300. #define IMAGE_FILE_BYTES_REVERSED_LO         0x0080  // Bytes of machine word are reversed.
  4301. #define IMAGE_FILE_32BIT_MACHINE             0x0100  // 32 bit word machine.
  4302. #define IMAGE_FILE_DEBUG_STRIPPED            0x0200  // Debugging info stripped from file in .DBG file
  4303. #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP   0x0400  // If Image is on removable media, copy and run from the swap file.
  4304. #define IMAGE_FILE_NET_RUN_FROM_SWAP         0x0800  // If Image is on Net, copy and run from the swap file.
  4305. #define IMAGE_FILE_SYSTEM                    0x1000  // System File.
  4306. #define IMAGE_FILE_DLL                       0x2000  // File is a DLL.
  4307. #define IMAGE_FILE_UP_SYSTEM_ONLY            0x4000  // File should only be run on a UP machine
  4308. #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000  // Bytes of machine word are reversed.
  4309.  
  4310. #define IMAGE_FILE_MACHINE_UNKNOWN           0
  4311. #define IMAGE_FILE_MACHINE_I386              0x014c  // Intel 386.
  4312. #define IMAGE_FILE_MACHINE_R3000             0x0162  // MIPS little-endian, 0x160 big-endian
  4313. #define IMAGE_FILE_MACHINE_R4000             0x0166  // MIPS little-endian
  4314. #define IMAGE_FILE_MACHINE_R10000            0x0168  // MIPS little-endian
  4315. #define IMAGE_FILE_MACHINE_WCEMIPSV2         0x0169  // MIPS little-endian WCE v2
  4316. #define IMAGE_FILE_MACHINE_ALPHA             0x0184  // Alpha_AXP
  4317. #define IMAGE_FILE_MACHINE_POWERPC           0x01F0  // IBM PowerPC Little-Endian
  4318. #define IMAGE_FILE_MACHINE_SH3               0x01a2  // SH3 little-endian
  4319. #define IMAGE_FILE_MACHINE_SH3E              0x01a4  // SH3E little-endian
  4320. #define IMAGE_FILE_MACHINE_SH4               0x01a6  // SH4 little-endian
  4321. #define IMAGE_FILE_MACHINE_ARM               0x01c0  // ARM Little-Endian
  4322. #define IMAGE_FILE_MACHINE_IA64              0x0200  // Intel 64
  4323.  
  4324. //
  4325. // Directory format.
  4326. //
  4327.  
  4328. typedef struct _IMAGE_DATA_DIRECTORY {
  4329.     DWORD   VirtualAddress;
  4330.     DWORD   Size;
  4331. } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
  4332.  
  4333. #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES    16
  4334.  
  4335. //
  4336. // Optional header format.
  4337. //
  4338.  
  4339. typedef struct _IMAGE_OPTIONAL_HEADER {
  4340.     //
  4341.     // Standard fields.
  4342.     //
  4343.  
  4344.     WORD    Magic;
  4345.     BYTE    MajorLinkerVersion;
  4346.     BYTE    MinorLinkerVersion;
  4347.     DWORD   SizeOfCode;
  4348.     DWORD   SizeOfInitializedData;
  4349.     DWORD   SizeOfUninitializedData;
  4350.     DWORD   AddressOfEntryPoint;
  4351.     DWORD   BaseOfCode;
  4352.     DWORD   BaseOfData;
  4353.  
  4354.     //
  4355.     // NT additional fields.
  4356.     //
  4357.  
  4358.     DWORD   ImageBase;
  4359.     DWORD   SectionAlignment;
  4360.     DWORD   FileAlignment;
  4361.     WORD    MajorOperatingSystemVersion;
  4362.     WORD    MinorOperatingSystemVersion;
  4363.     WORD    MajorImageVersion;
  4364.     WORD    MinorImageVersion;
  4365.     WORD    MajorSubsystemVersion;
  4366.     WORD    MinorSubsystemVersion;
  4367.     DWORD   Win32VersionValue;
  4368.     DWORD   SizeOfImage;
  4369.     DWORD   SizeOfHeaders;
  4370.     DWORD   CheckSum;
  4371.     WORD    Subsystem;
  4372.     WORD    DllCharacteristics;
  4373.     DWORD   SizeOfStackReserve;
  4374.     DWORD   SizeOfStackCommit;
  4375.     DWORD   SizeOfHeapReserve;
  4376.     DWORD   SizeOfHeapCommit;
  4377.     DWORD   LoaderFlags;
  4378.     DWORD   NumberOfRvaAndSizes;
  4379.     IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
  4380. } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
  4381.  
  4382. typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
  4383.     WORD   Magic;
  4384.     BYTE   MajorLinkerVersion;
  4385.     BYTE   MinorLinkerVersion;
  4386.     DWORD  SizeOfCode;
  4387.     DWORD  SizeOfInitializedData;
  4388.     DWORD  SizeOfUninitializedData;
  4389.     DWORD  AddressOfEntryPoint;
  4390.     DWORD  BaseOfCode;
  4391.     DWORD  BaseOfData;
  4392.     DWORD  BaseOfBss;
  4393.     DWORD  GprMask;
  4394.     DWORD  CprMask[4];
  4395.     DWORD  GpValue;
  4396. } IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER;
  4397.  
  4398. #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER      56
  4399. #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER      28
  4400. #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER      224
  4401.  
  4402. #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
  4403. #define IMAGE_ROM_OPTIONAL_HDR_MAGIC       0x107
  4404.  
  4405. typedef struct _IMAGE_NT_HEADERS {
  4406.     DWORD Signature;
  4407.     IMAGE_FILE_HEADER FileHeader;
  4408.     IMAGE_OPTIONAL_HEADER OptionalHeader;
  4409. } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
  4410.  
  4411. typedef struct _IMAGE_ROM_HEADERS {
  4412.     IMAGE_FILE_HEADER FileHeader;
  4413.     IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
  4414. } IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS;
  4415.  
  4416. #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER)        \
  4417.     ((DWORD)ntheader +                                                  \
  4418.      FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) +                 \
  4419.      ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader   \
  4420.     ))
  4421.  
  4422.  
  4423. // Subsystem Values
  4424.  
  4425. #define IMAGE_SUBSYSTEM_UNKNOWN              0   // Unknown subsystem.
  4426. #define IMAGE_SUBSYSTEM_NATIVE               1   // Image doesn't require a subsystem.
  4427. #define IMAGE_SUBSYSTEM_WINDOWS_GUI          2   // Image runs in the Windows GUI subsystem.
  4428. #define IMAGE_SUBSYSTEM_WINDOWS_CUI          3   // Image runs in the Windows character subsystem.
  4429. #define IMAGE_SUBSYSTEM_OS2_CUI              5   // image runs in the OS/2 character subsystem.
  4430. #define IMAGE_SUBSYSTEM_POSIX_CUI            7   // image runs in the Posix character subsystem.
  4431. #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS       8   // image is a native Win9x driver.
  4432. #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI       9   // Image runs in the Windows CE subsystem.
  4433.  
  4434. // DllCharacteristics Entries
  4435.  
  4436. //      IMAGE_LIBRARY_PROCESS_INIT           0x0001     // Reserved.
  4437. //      IMAGE_LIBRARY_PROCESS_TERM           0x0002     // Reserved.
  4438. //      IMAGE_LIBRARY_THREAD_INIT            0x0004     // Reserved.
  4439. //      IMAGE_LIBRARY_THREAD_TERM            0x0008     // Reserved.
  4440. #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER  0x2000     // Driver uses WDM model
  4441.  
  4442. // Directory Entries
  4443.  
  4444. #define IMAGE_DIRECTORY_ENTRY_EXPORT         0   // Export Directory
  4445. #define IMAGE_DIRECTORY_ENTRY_IMPORT         1   // Import Directory
  4446. #define IMAGE_DIRECTORY_ENTRY_RESOURCE       2   // Resource Directory
  4447. #define IMAGE_DIRECTORY_ENTRY_EXCEPTION      3   // Exception Directory
  4448. #define IMAGE_DIRECTORY_ENTRY_SECURITY       4   // Security Directory
  4449. #define IMAGE_DIRECTORY_ENTRY_BASERELOC      5   // Base Relocation Table
  4450. #define IMAGE_DIRECTORY_ENTRY_DEBUG          6   // Debug Directory
  4451. #define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE   7   // Architecture Specific Data
  4452. #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR      8   // RVA of GP
  4453. #define IMAGE_DIRECTORY_ENTRY_TLS            9   // TLS Directory
  4454. #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG   10   // Load Configuration Directory
  4455. #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT  11   // Bound Import Directory in headers
  4456. #define IMAGE_DIRECTORY_ENTRY_IAT           12   // Import Address Table
  4457. #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT  13   // Delay Load Import Descriptors
  4458.  
  4459. //
  4460. // Section header format.
  4461. //
  4462.  
  4463. #define IMAGE_SIZEOF_SHORT_NAME              8
  4464.  
  4465. typedef struct _IMAGE_SECTION_HEADER {
  4466.     BYTE    Name[IMAGE_SIZEOF_SHORT_NAME];
  4467.     union {
  4468.             DWORD   PhysicalAddress;
  4469.             DWORD   VirtualSize;
  4470.     } Misc;
  4471.     DWORD   VirtualAddress;
  4472.     DWORD   SizeOfRawData;
  4473.     DWORD   PointerToRawData;
  4474.     DWORD   PointerToRelocations;
  4475.     DWORD   PointerToLinenumbers;
  4476.     WORD    NumberOfRelocations;
  4477.     WORD    NumberOfLinenumbers;
  4478.     DWORD   Characteristics;
  4479. } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
  4480.  
  4481. #define IMAGE_SIZEOF_SECTION_HEADER          40
  4482.  
  4483. //
  4484. // Section characteristics.
  4485. //
  4486. //      IMAGE_SCN_TYPE_REG                   0x00000000  // Reserved.
  4487. //      IMAGE_SCN_TYPE_DSECT                 0x00000001  // Reserved.
  4488. //      IMAGE_SCN_TYPE_NOLOAD                0x00000002  // Reserved.
  4489. //      IMAGE_SCN_TYPE_GROUP                 0x00000004  // Reserved.
  4490. #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  // Reserved.
  4491. //      IMAGE_SCN_TYPE_COPY                  0x00000010  // Reserved.
  4492.  
  4493. #define IMAGE_SCN_CNT_CODE                   0x00000020  // Section contains code.
  4494. #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  // Section contains initialized data.
  4495. #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  // Section contains uninitialized data.
  4496.  
  4497. #define IMAGE_SCN_LNK_OTHER                  0x00000100  // Reserved.
  4498. #define IMAGE_SCN_LNK_INFO                   0x00000200  // Section contains comments or some other type of information.
  4499. //      IMAGE_SCN_TYPE_OVER                  0x00000400  // Reserved.
  4500. #define IMAGE_SCN_LNK_REMOVE                 0x00000800  // Section contents will not become part of image.
  4501. #define IMAGE_SCN_LNK_COMDAT                 0x00001000  // Section contents comdat.
  4502. //                                           0x00002000  // Reserved.
  4503.  
  4504. //      IMAGE_SCN_MEM_PROTECTED - Obsolete   0x00004000
  4505. #define IMAGE_SCN_MEM_FARDATA                0x00008000
  4506. //      IMAGE_SCN_MEM_SYSHEAP  - Obsolete    0x00010000
  4507. #define IMAGE_SCN_MEM_PURGEABLE              0x00020000
  4508. #define IMAGE_SCN_MEM_16BIT                  0x00020000
  4509. #define IMAGE_SCN_MEM_LOCKED                 0x00040000
  4510. #define IMAGE_SCN_MEM_PRELOAD                0x00080000
  4511.  
  4512. #define IMAGE_SCN_ALIGN_1BYTES               0x00100000  //
  4513. #define IMAGE_SCN_ALIGN_2BYTES               0x00200000  //
  4514. #define IMAGE_SCN_ALIGN_4BYTES               0x00300000  //
  4515. #define IMAGE_SCN_ALIGN_8BYTES               0x00400000  //
  4516. #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  // Default alignment if no others are specified.
  4517. #define IMAGE_SCN_ALIGN_32BYTES              0x00600000  //
  4518. #define IMAGE_SCN_ALIGN_64BYTES              0x00700000  //
  4519. // Unused                                    0x00800000
  4520.  
  4521. #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  // Section contains extended relocations.
  4522. #define IMAGE_SCN_MEM_DISCARDABLE            0x02000000  // Section can be discarded.
  4523. #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  // Section is not cachable.
  4524. #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  // Section is not pageable.
  4525. #define IMAGE_SCN_MEM_SHARED                 0x10000000  // Section is shareable.
  4526. #define IMAGE_SCN_MEM_EXECUTE                0x20000000  // Section is executable.
  4527. #define IMAGE_SCN_MEM_READ                   0x40000000  // Section is readable.
  4528. #define IMAGE_SCN_MEM_WRITE                  0x80000000  // Section is writeable.
  4529.  
  4530. //
  4531. // TLS Chaacteristic Flags
  4532. //
  4533. #define IMAGE_SCN_SCALE_INDEX                0x00000001  // Tls index is scaled
  4534.  
  4535. #ifndef _MAC
  4536. #include "pshpack2.h"                       // Symbols, relocs, and linenumbers are 2 byte packed
  4537. #endif
  4538.  
  4539. //
  4540. // Symbol format.
  4541. //
  4542.  
  4543. typedef struct _IMAGE_SYMBOL {
  4544.     union {
  4545.         BYTE    ShortName[8];
  4546.         struct {
  4547.             DWORD   Short;     // if 0, use LongName
  4548.             DWORD   Long;      // offset into string table
  4549.         } Name;
  4550.         PBYTE   LongName[2];
  4551.     } N;
  4552.     DWORD   Value;
  4553.     SHORT   SectionNumber;
  4554.     WORD    Type;
  4555.     BYTE    StorageClass;
  4556.     BYTE    NumberOfAuxSymbols;
  4557. } IMAGE_SYMBOL;
  4558. typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
  4559.  
  4560.  
  4561. #define IMAGE_SIZEOF_SYMBOL                  18
  4562.  
  4563. //
  4564. // Section values.
  4565. //
  4566. // Symbols have a section number of the section in which they are
  4567. // defined. Otherwise, section numbers have the following meanings:
  4568. //
  4569.  
  4570. #define IMAGE_SYM_UNDEFINED           (SHORT)0          // Symbol is undefined or is common.
  4571. #define IMAGE_SYM_ABSOLUTE            (SHORT)-1         // Symbol is an absolute value.
  4572. #define IMAGE_SYM_DEBUG               (SHORT)-2         // Symbol is a special debug item.
  4573.  
  4574. //
  4575. // Type (fundamental) values.
  4576. //
  4577.  
  4578. #define IMAGE_SYM_TYPE_NULL                 0x0000  // no type.
  4579. #define IMAGE_SYM_TYPE_VOID                 0x0001  //
  4580. #define IMAGE_SYM_TYPE_CHAR                 0x0002  // type character.
  4581. #define IMAGE_SYM_TYPE_SHORT                0x0003  // type short integer.
  4582. #define IMAGE_SYM_TYPE_INT                  0x0004  //
  4583. #define IMAGE_SYM_TYPE_LONG                 0x0005  //
  4584. #define IMAGE_SYM_TYPE_FLOAT                0x0006  //
  4585. #define IMAGE_SYM_TYPE_DOUBLE               0x0007  //
  4586. #define IMAGE_SYM_TYPE_STRUCT               0x0008  //
  4587. #define IMAGE_SYM_TYPE_UNION                0x0009  //
  4588. #define IMAGE_SYM_TYPE_ENUM                 0x000A  // enumeration.
  4589. #define IMAGE_SYM_TYPE_MOE                  0x000B  // member of enumeration.
  4590. #define IMAGE_SYM_TYPE_BYTE                 0x000C  //
  4591. #define IMAGE_SYM_TYPE_WORD                 0x000D  //
  4592. #define IMAGE_SYM_TYPE_UINT                 0x000E  //
  4593. #define IMAGE_SYM_TYPE_DWORD                0x000F  //
  4594. #define IMAGE_SYM_TYPE_PCODE                0x8000  //
  4595. //
  4596. // Type (derived) values.
  4597. //
  4598.  
  4599. #define IMAGE_SYM_DTYPE_NULL                0       // no derived type.
  4600. #define IMAGE_SYM_DTYPE_POINTER             1       // pointer.
  4601. #define IMAGE_SYM_DTYPE_FUNCTION            2       // function.
  4602. #define IMAGE_SYM_DTYPE_ARRAY               3       // array.
  4603.  
  4604. //
  4605. // Storage classes.
  4606. //
  4607. #define IMAGE_SYM_CLASS_END_OF_FUNCTION     (BYTE )-1
  4608. #define IMAGE_SYM_CLASS_NULL                0x0000
  4609. #define IMAGE_SYM_CLASS_AUTOMATIC           0x0001
  4610. #define IMAGE_SYM_CLASS_EXTERNAL            0x0002
  4611. #define IMAGE_SYM_CLASS_STATIC              0x0003
  4612. #define IMAGE_SYM_CLASS_REGISTER            0x0004
  4613. #define IMAGE_SYM_CLASS_EXTERNAL_DEF        0x0005
  4614. #define IMAGE_SYM_CLASS_LABEL               0x0006
  4615. #define IMAGE_SYM_CLASS_UNDEFINED_LABEL     0x0007
  4616. #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT    0x0008
  4617. #define IMAGE_SYM_CLASS_ARGUMENT            0x0009
  4618. #define IMAGE_SYM_CLASS_STRUCT_TAG          0x000A
  4619. #define IMAGE_SYM_CLASS_MEMBER_OF_UNION     0x000B
  4620. #define IMAGE_SYM_CLASS_UNION_TAG           0x000C
  4621. #define IMAGE_SYM_CLASS_TYPE_DEFINITION     0x000D
  4622. #define IMAGE_SYM_CLASS_UNDEFINED_STATIC    0x000E
  4623. #define IMAGE_SYM_CLASS_ENUM_TAG            0x000F
  4624. #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM      0x0010
  4625. #define IMAGE_SYM_CLASS_REGISTER_PARAM      0x0011
  4626. #define IMAGE_SYM_CLASS_BIT_FIELD           0x0012
  4627.  
  4628. #define IMAGE_SYM_CLASS_FAR_EXTERNAL        0x0044  //
  4629.  
  4630. #define IMAGE_SYM_CLASS_BLOCK               0x0064
  4631. #define IMAGE_SYM_CLASS_FUNCTION            0x0065
  4632. #define IMAGE_SYM_CLASS_END_OF_STRUCT       0x0066
  4633. #define IMAGE_SYM_CLASS_FILE                0x0067
  4634. // new
  4635. #define IMAGE_SYM_CLASS_SECTION             0x0068
  4636. #define IMAGE_SYM_CLASS_WEAK_EXTERNAL       0x0069
  4637.  
  4638. // type packing constants
  4639.  
  4640. #define N_BTMASK                            0x000F
  4641. #define N_TMASK                             0x0030
  4642. #define N_TMASK1                            0x00C0
  4643. #define N_TMASK2                            0x00F0
  4644. #define N_BTSHFT                            4
  4645. #define N_TSHIFT                            2
  4646. // MACROS
  4647.  
  4648. // Basic Type of  x
  4649. #define BTYPE(x) ((x) & N_BTMASK)
  4650.  
  4651. // Is x a pointer?
  4652. #ifndef ISPTR
  4653. #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
  4654. #endif
  4655.  
  4656. // Is x a function?
  4657. #ifndef ISFCN
  4658. #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
  4659. #endif
  4660.  
  4661. // Is x an array?
  4662.  
  4663. #ifndef ISARY
  4664. #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
  4665. #endif
  4666.  
  4667. // Is x a structure, union, or enumeration TAG?
  4668. #ifndef ISTAG
  4669. #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
  4670. #endif
  4671.  
  4672. #ifndef INCREF
  4673. #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
  4674. #endif
  4675. #ifndef DECREF
  4676. #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
  4677. #endif
  4678.  
  4679. //
  4680. // Auxiliary entry format.
  4681. //
  4682.  
  4683. typedef union _IMAGE_AUX_SYMBOL {
  4684.     struct {
  4685.         DWORD    TagIndex;                      // struct, union, or enum tag index
  4686.         union {
  4687.             struct {
  4688.                 WORD    Linenumber;             // declaration line number
  4689.                 WORD    Size;                   // size of struct, union, or enum
  4690.             } LnSz;
  4691.            DWORD    TotalSize;
  4692.         } Misc;
  4693.         union {
  4694.             struct {                            // if ISFCN, tag, or .bb
  4695.                 DWORD    PointerToLinenumber;
  4696.                 DWORD    PointerToNextFunction;
  4697.             } Function;
  4698.             struct {                            // if ISARY, up to 4 dimen.
  4699.                 WORD     Dimension[4];
  4700.             } Array;
  4701.         } FcnAry;
  4702.         WORD    TvIndex;                        // tv index
  4703.     } Sym;
  4704.     struct {
  4705.         BYTE    Name[IMAGE_SIZEOF_SYMBOL];
  4706.     } File;
  4707.     struct {
  4708.         DWORD   Length;                         // section length
  4709.         WORD    NumberOfRelocations;            // number of relocation entries
  4710.         WORD    NumberOfLinenumbers;            // number of line numbers
  4711.         DWORD   CheckSum;                       // checksum for communal
  4712.         SHORT   Number;                         // section number to associate with
  4713.         BYTE    Selection;                      // communal selection type
  4714.     } Section;
  4715. } IMAGE_AUX_SYMBOL;
  4716. typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL;
  4717.  
  4718. #define IMAGE_SIZEOF_AUX_SYMBOL             18
  4719.  
  4720. //
  4721. // Communal selection types.
  4722. //
  4723.  
  4724. #define IMAGE_COMDAT_SELECT_NODUPLICATES    1
  4725. #define IMAGE_COMDAT_SELECT_ANY             2
  4726. #define IMAGE_COMDAT_SELECT_SAME_SIZE       3
  4727. #define IMAGE_COMDAT_SELECT_EXACT_MATCH     4
  4728. #define IMAGE_COMDAT_SELECT_ASSOCIATIVE     5
  4729. #define IMAGE_COMDAT_SELECT_LARGEST         6
  4730. #define IMAGE_COMDAT_SELECT_NEWEST          7
  4731.  
  4732. #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1
  4733. #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2
  4734. #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3
  4735.  
  4736. //
  4737. // Relocation format.
  4738. //
  4739.  
  4740. typedef struct _IMAGE_RELOCATION {
  4741.     union {
  4742.         DWORD   VirtualAddress;
  4743.         DWORD   RelocCount;             // Set to the real count when IMAGE_SCN_LNK_NRELOC_OVFL is set
  4744.     };
  4745.     DWORD   SymbolTableIndex;
  4746.     WORD    Type;
  4747. } IMAGE_RELOCATION;
  4748. typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
  4749.  
  4750. #define IMAGE_SIZEOF_RELOCATION         10
  4751.  
  4752. //
  4753. // I386 relocation types.
  4754. //
  4755. #define IMAGE_REL_I386_ABSOLUTE         0x0000  // Reference is absolute, no relocation is necessary
  4756. #define IMAGE_REL_I386_DIR16            0x0001  // Direct 16-bit reference to the symbols virtual address
  4757. #define IMAGE_REL_I386_REL16            0x0002  // PC-relative 16-bit reference to the symbols virtual address
  4758. #define IMAGE_REL_I386_DIR32            0x0006  // Direct 32-bit reference to the symbols virtual address
  4759. #define IMAGE_REL_I386_DIR32NB          0x0007  // Direct 32-bit reference to the symbols virtual address, base not included
  4760. #define IMAGE_REL_I386_SEG12            0x0009  // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
  4761. #define IMAGE_REL_I386_SECTION          0x000A
  4762. #define IMAGE_REL_I386_SECREL           0x000B
  4763. #define IMAGE_REL_I386_REL32            0x0014  // PC-relative 32-bit reference to the symbols virtual address
  4764.  
  4765. //
  4766. // MIPS relocation types.
  4767. //
  4768.  
  4769. #define IMAGE_REL_MIPS_ABSOLUTE         0x0000  // Reference is absolute, no relocation is necessary
  4770. #define IMAGE_REL_MIPS_REFHALF          0x0001
  4771. #define IMAGE_REL_MIPS_REFWORD          0x0002
  4772. #define IMAGE_REL_MIPS_JMPADDR          0x0003
  4773. #define IMAGE_REL_MIPS_REFHI            0x0004
  4774. #define IMAGE_REL_MIPS_REFLO            0x0005
  4775. #define IMAGE_REL_MIPS_GPREL            0x0006
  4776. #define IMAGE_REL_MIPS_LITERAL          0x0007
  4777. #define IMAGE_REL_MIPS_SECTION          0x000A
  4778. #define IMAGE_REL_MIPS_SECREL           0x000B
  4779. #define IMAGE_REL_MIPS_SECRELLO         0x000C  // Low 16-bit section relative referemce (used for >32k TLS)
  4780. #define IMAGE_REL_MIPS_SECRELHI         0x000D  // High 16-bit section relative reference (used for >32k TLS)
  4781. #define IMAGE_REL_MIPS_REFWORDNB        0x0022
  4782. #define IMAGE_REL_MIPS_PAIR             0x0025
  4783.  
  4784. //
  4785. // Alpha Relocation types.
  4786. //
  4787.  
  4788. #define IMAGE_REL_ALPHA_ABSOLUTE        0x0000
  4789. #define IMAGE_REL_ALPHA_REFLONG         0x0001
  4790. #define IMAGE_REL_ALPHA_REFQUAD         0x0002
  4791. #define IMAGE_REL_ALPHA_GPREL32         0x0003
  4792. #define IMAGE_REL_ALPHA_LITERAL         0x0004
  4793. #define IMAGE_REL_ALPHA_LITUSE          0x0005
  4794. #define IMAGE_REL_ALPHA_GPDISP          0x0006
  4795. #define IMAGE_REL_ALPHA_BRADDR          0x0007
  4796. #define IMAGE_REL_ALPHA_HINT            0x0008
  4797. #define IMAGE_REL_ALPHA_INLINE_REFLONG  0x0009
  4798. #define IMAGE_REL_ALPHA_REFHI           0x000A
  4799. #define IMAGE_REL_ALPHA_REFLO           0x000B
  4800. #define IMAGE_REL_ALPHA_PAIR            0x000C
  4801. #define IMAGE_REL_ALPHA_MATCH           0x000D
  4802. #define IMAGE_REL_ALPHA_SECTION         0x000E
  4803. #define IMAGE_REL_ALPHA_SECREL          0x000F
  4804. #define IMAGE_REL_ALPHA_REFLONGNB       0x0010
  4805. #define IMAGE_REL_ALPHA_SECRELLO        0x0011  // Low 16-bit section relative reference
  4806. #define IMAGE_REL_ALPHA_SECRELHI        0x0012  // High 16-bit section relative reference
  4807.  
  4808. //
  4809. // IBM PowerPC relocation types.
  4810. //
  4811.  
  4812. #define IMAGE_REL_PPC_ABSOLUTE          0x0000  // NOP
  4813. #define IMAGE_REL_PPC_ADDR64            0x0001  // 64-bit address
  4814. #define IMAGE_REL_PPC_ADDR32            0x0002  // 32-bit address
  4815. #define IMAGE_REL_PPC_ADDR24            0x0003  // 26-bit address, shifted left 2 (branch absolute)
  4816. #define IMAGE_REL_PPC_ADDR16            0x0004  // 16-bit address
  4817. #define IMAGE_REL_PPC_ADDR14            0x0005  // 16-bit address, shifted left 2 (load doubleword)
  4818. #define IMAGE_REL_PPC_REL24             0x0006  // 26-bit PC-relative offset, shifted left 2 (branch relative)
  4819. #define IMAGE_REL_PPC_REL14             0x0007  // 16-bit PC-relative offset, shifted left 2 (br cond relative)
  4820. #define IMAGE_REL_PPC_TOCREL16          0x0008  // 16-bit offset from TOC base
  4821. #define IMAGE_REL_PPC_TOCREL14          0x0009  // 16-bit offset from TOC base, shifted left 2 (load doubleword)
  4822.  
  4823. #define IMAGE_REL_PPC_ADDR32NB          0x000A  // 32-bit addr w/o image base
  4824. #define IMAGE_REL_PPC_SECREL            0x000B  // va of containing section (as in an image sectionhdr)
  4825. #define IMAGE_REL_PPC_SECTION           0x000C  // sectionheader number
  4826. #define IMAGE_REL_PPC_IFGLUE            0x000D  // substitute TOC restore instruction iff symbol is glue code
  4827. #define IMAGE_REL_PPC_IMGLUE            0x000E  // symbol is glue code; virtual address is TOC restore instruction
  4828. #define IMAGE_REL_PPC_SECREL16          0x000F  // va of containing section (limited to 16 bits)
  4829. #define IMAGE_REL_PPC_REFHI             0x0010
  4830. #define IMAGE_REL_PPC_REFLO             0x0011
  4831. #define IMAGE_REL_PPC_PAIR              0x0012
  4832. #define IMAGE_REL_PPC_SECRELLO          0x0013  // Low 16-bit section relative reference (used for >32k TLS)
  4833. #define IMAGE_REL_PPC_SECRELHI          0x0014  // High 16-bit section relative reference (used for >32k TLS)
  4834.  
  4835. #define IMAGE_REL_PPC_TYPEMASK          0x00FF  // mask to isolate above values in IMAGE_RELOCATION.Type
  4836.  
  4837. // Flag bits in IMAGE_RELOCATION.TYPE
  4838.  
  4839. #define IMAGE_REL_PPC_NEG               0x0100  // subtract reloc value rather than adding it
  4840. #define IMAGE_REL_PPC_BRTAKEN           0x0200  // fix branch prediction bit to predict branch taken
  4841. #define IMAGE_REL_PPC_BRNTAKEN          0x0400  // fix branch prediction bit to predict branch not taken
  4842. #define IMAGE_REL_PPC_TOCDEFN           0x0800  // toc slot defined in file (or, data in toc)
  4843. //
  4844. // Hitachi SH3 relocation types.
  4845. //
  4846.  
  4847. #define IMAGE_REL_SH3_ABSOLUTE          0x0000  // No relocation
  4848. #define IMAGE_REL_SH3_DIRECT16          0x0001  // 16 bit direct
  4849. #define IMAGE_REL_SH3_DIRECT32          0x0002  // 32 bit direct
  4850. #define IMAGE_REL_SH3_DIRECT8           0x0003  // 8 bit direct, -128..255
  4851. #define IMAGE_REL_SH3_DIRECT8_WORD      0x0004  // 8 bit direct .W (0 ext.)
  4852. #define IMAGE_REL_SH3_DIRECT8_LONG      0x0005  // 8 bit direct .L (0 ext.)
  4853. #define IMAGE_REL_SH3_DIRECT4           0x0006  // 4 bit direct (0 ext.)
  4854. #define IMAGE_REL_SH3_DIRECT4_WORD      0x0007  // 4 bit direct .W (0 ext.)
  4855. #define IMAGE_REL_SH3_DIRECT4_LONG      0x0008  // 4 bit direct .L (0 ext.)
  4856. #define IMAGE_REL_SH3_PCREL8_WORD       0x0009  // 8 bit PC relative .W
  4857. #define IMAGE_REL_SH3_PCREL8_LONG       0x000A  // 8 bit PC relative .L
  4858. #define IMAGE_REL_SH3_PCREL12_WORD      0x000B  // 12 LSB PC relative .W
  4859. #define IMAGE_REL_SH3_STARTOF_SECTION   0x000C  // Start of EXE section
  4860. #define IMAGE_REL_SH3_SIZEOF_SECTION    0x000D  // Size of EXE section
  4861. #define IMAGE_REL_SH3_SECTION           0x000E  // Section table index
  4862. #define IMAGE_REL_SH3_SECREL            0x000F  // Offset within section
  4863. #define IMAGE_REL_SH3_DIRECT32_NB       0x0010  // 32 bit direct not based
  4864.  
  4865. //
  4866. // Line number format.
  4867. //
  4868.  
  4869. typedef struct _IMAGE_LINENUMBER {
  4870.     union {
  4871.         DWORD   SymbolTableIndex;               // Symbol table index of function name if Linenumber is 0.
  4872.         DWORD   VirtualAddress;                 // Virtual address of line number.
  4873.     } Type;
  4874.     WORD    Linenumber;                         // Line number.
  4875. } IMAGE_LINENUMBER;
  4876. typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER;
  4877.  
  4878. #define IMAGE_SIZEOF_LINENUMBER              6
  4879.  
  4880. #ifndef _MAC
  4881. #include "poppack.h"                        // Back to 4 byte packing
  4882. #endif
  4883.  
  4884. //
  4885. // Based relocation format.
  4886. //
  4887.  
  4888. typedef struct _IMAGE_BASE_RELOCATION {
  4889.     DWORD   VirtualAddress;
  4890.     DWORD   SizeOfBlock;
  4891. //  WORD    TypeOffset[1];
  4892. } IMAGE_BASE_RELOCATION;
  4893. typedef IMAGE_BASE_RELOCATION UNALIGNED * PIMAGE_BASE_RELOCATION;
  4894.  
  4895. #define IMAGE_SIZEOF_BASE_RELOCATION         8
  4896.  
  4897. //
  4898. // Based relocation types.
  4899. //
  4900.  
  4901. #define IMAGE_REL_BASED_ABSOLUTE              0
  4902. #define IMAGE_REL_BASED_HIGH                  1
  4903. #define IMAGE_REL_BASED_LOW                   2
  4904. #define IMAGE_REL_BASED_HIGHLOW               3
  4905. #define IMAGE_REL_BASED_HIGHADJ               4
  4906. #define IMAGE_REL_BASED_MIPS_JMPADDR          5
  4907. #define IMAGE_REL_BASED_SECTION               6
  4908. #define IMAGE_REL_BASED_REL32                 7
  4909.  
  4910. //
  4911. // Archive format.
  4912. //
  4913.  
  4914. #define IMAGE_ARCHIVE_START_SIZE             8
  4915. #define IMAGE_ARCHIVE_START                  "!<arch>\n"
  4916. #define IMAGE_ARCHIVE_END                    "`\n"
  4917. #define IMAGE_ARCHIVE_PAD                    "\n"
  4918. #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
  4919. #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
  4920.  
  4921. typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
  4922.     BYTE     Name[16];                          // File member name - `/' terminated.
  4923.     BYTE     Date[12];                          // File member date - decimal.
  4924.     BYTE     UserID[6];                         // File member user id - decimal.
  4925.     BYTE     GroupID[6];                        // File member group id - decimal.
  4926.     BYTE     Mode[8];                           // File member mode - octal.
  4927.     BYTE     Size[10];                          // File member size - decimal.
  4928.     BYTE     EndHeader[2];                      // String to end header.
  4929. } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
  4930.  
  4931. #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR      60
  4932.  
  4933. //
  4934. // DLL support.
  4935. //
  4936.  
  4937. //
  4938. // Export Format
  4939. //
  4940.  
  4941. typedef struct _IMAGE_EXPORT_DIRECTORY {
  4942.     DWORD   Characteristics;
  4943.     DWORD   TimeDateStamp;
  4944.     WORD    MajorVersion;
  4945.     WORD    MinorVersion;
  4946.     DWORD   Name;
  4947.     DWORD   Base;
  4948.     DWORD   NumberOfFunctions;
  4949.     DWORD   NumberOfNames;
  4950.     PDWORD  *AddressOfFunctions;
  4951.     PDWORD  *AddressOfNames;
  4952.     PWORD   *AddressOfNameOrdinals;
  4953. } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
  4954.  
  4955. //
  4956. // Import Format
  4957. //
  4958.  
  4959. typedef struct _IMAGE_IMPORT_BY_NAME {
  4960.     WORD    Hint;
  4961.     BYTE    Name[1];
  4962. } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
  4963.  
  4964. typedef struct _IMAGE_THUNK_DATA {
  4965.     union {
  4966.         PBYTE  ForwarderString;
  4967.         PDWORD Function;
  4968.         DWORD Ordinal;
  4969.         PIMAGE_IMPORT_BY_NAME AddressOfData;
  4970.     } u1;
  4971. } IMAGE_THUNK_DATA;
  4972. typedef IMAGE_THUNK_DATA * PIMAGE_THUNK_DATA;
  4973.  
  4974. #define IMAGE_ORDINAL_FLAG 0x80000000
  4975. #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
  4976. #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
  4977.  
  4978. typedef struct _IMAGE_IMPORT_DESCRIPTOR {
  4979.     union {
  4980.         DWORD   Characteristics;                // 0 for terminating null import descriptor
  4981.         PIMAGE_THUNK_DATA OriginalFirstThunk;   // RVA to original unbound IAT
  4982.     };
  4983.     DWORD   TimeDateStamp;                  // 0 if not bound,
  4984.                                             // -1 if bound, and real date\time stamp
  4985.                                             //     in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND)
  4986.                                             // O.W. date/time stamp of DLL bound to (Old BIND)
  4987.  
  4988.     DWORD   ForwarderChain;                 // -1 if no forwarders
  4989.     DWORD   Name;
  4990.     PIMAGE_THUNK_DATA FirstThunk;           // RVA to IAT (if bound this IAT has actual addresses)
  4991. } IMAGE_IMPORT_DESCRIPTOR;
  4992. typedef IMAGE_IMPORT_DESCRIPTOR UNALIGNED *PIMAGE_IMPORT_DESCRIPTOR;
  4993.  
  4994. //
  4995. // New format import descriptors pointed to by DataDirectory[ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT ]
  4996. //
  4997.  
  4998. typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR {
  4999.     DWORD   TimeDateStamp;
  5000.     WORD    OffsetModuleName;
  5001.     WORD    NumberOfModuleForwarderRefs;
  5002. // Array of zero or more IMAGE_BOUND_FORWARDER_REF follows
  5003. } IMAGE_BOUND_IMPORT_DESCRIPTOR,  *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
  5004.  
  5005. typedef struct _IMAGE_BOUND_FORWARDER_REF {
  5006.     DWORD   TimeDateStamp;
  5007.     WORD    OffsetModuleName;
  5008.     WORD    Reserved;
  5009. } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
  5010.  
  5011.  
  5012. //
  5013. // Thread Local Storage
  5014. //
  5015.  
  5016. typedef VOID
  5017. (NTAPI *PIMAGE_TLS_CALLBACK) (
  5018.     PVOID DllHandle,
  5019.     DWORD Reason,
  5020.     PVOID Reserved
  5021.     );
  5022.  
  5023. typedef struct _IMAGE_TLS_DIRECTORY {
  5024.     DWORD   StartAddressOfRawData;
  5025.     DWORD   EndAddressOfRawData;
  5026.     PDWORD  AddressOfIndex;
  5027.     PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
  5028.     DWORD   SizeOfZeroFill;
  5029.     DWORD   Characteristics;
  5030. } IMAGE_TLS_DIRECTORY, *PIMAGE_TLS_DIRECTORY;
  5031.  
  5032.  
  5033. //
  5034. // Resource Format.
  5035. //
  5036.  
  5037. //
  5038. // Resource directory consists of two counts, following by a variable length
  5039. // array of directory entries.  The first count is the number of entries at
  5040. // beginning of the array that have actual names associated with each entry.
  5041. // The entries are in ascending order, case insensitive strings.  The second
  5042. // count is the number of entries that immediately follow the named entries.
  5043. // This second count identifies the number of entries that have 16-bit integer
  5044. // Ids as their name.  These entries are also sorted in ascending order.
  5045. //
  5046. // This structure allows fast lookup by either name or number, but for any
  5047. // given resource entry only one form of lookup is supported, not both.
  5048. // This is consistant with the syntax of the .RC file and the .RES file.
  5049. //
  5050.  
  5051. typedef struct _IMAGE_RESOURCE_DIRECTORY {
  5052.     DWORD   Characteristics;
  5053.     DWORD   TimeDateStamp;
  5054.     WORD    MajorVersion;
  5055.     WORD    MinorVersion;
  5056.     WORD    NumberOfNamedEntries;
  5057.     WORD    NumberOfIdEntries;
  5058. //  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
  5059. } IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
  5060.  
  5061. #define IMAGE_RESOURCE_NAME_IS_STRING        0x80000000
  5062. #define IMAGE_RESOURCE_DATA_IS_DIRECTORY     0x80000000
  5063. //
  5064. // Each directory contains the 32-bit Name of the entry and an offset,
  5065. // relative to the beginning of the resource directory of the data associated
  5066. // with this directory entry.  If the name of the entry is an actual text
  5067. // string instead of an integer Id, then the high order bit of the name field
  5068. // is set to one and the low order 31-bits are an offset, relative to the
  5069. // beginning of the resource directory of the string, which is of type
  5070. // IMAGE_RESOURCE_DIRECTORY_STRING.  Otherwise the high bit is clear and the
  5071. // low-order 16-bits are the integer Id that identify this resource directory
  5072. // entry. If the directory entry is yet another resource directory (i.e. a
  5073. // subdirectory), then the high order bit of the offset field will be
  5074. // set to indicate this.  Otherwise the high bit is clear and the offset
  5075. // field points to a resource data entry.
  5076. //
  5077.  
  5078. typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
  5079.     union {
  5080.         struct {
  5081.             DWORD NameOffset:31;
  5082.             DWORD NameIsString:1;
  5083.         };
  5084.         DWORD   Name;
  5085.         WORD    Id;
  5086.     };
  5087.     union {
  5088.         DWORD   OffsetToData;
  5089.         struct {
  5090.             DWORD   OffsetToDirectory:31;
  5091.             DWORD   DataIsDirectory:1;
  5092.         };
  5093.     };
  5094. } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
  5095.  
  5096. //
  5097. // For resource directory entries that have actual string names, the Name
  5098. // field of the directory entry points to an object of the following type.
  5099. // All of these string objects are stored together after the last resource
  5100. // directory entry and before the first resource data object.  This minimizes
  5101. // the impact of these variable length objects on the alignment of the fixed
  5102. // size directory entry objects.
  5103. //
  5104.  
  5105. typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
  5106.     WORD    Length;
  5107.     CHAR    NameString[ 1 ];
  5108. } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;
  5109.  
  5110.  
  5111. typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
  5112.     WORD    Length;
  5113.     WCHAR   NameString[ 1 ];
  5114. } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;
  5115.  
  5116.  
  5117. //
  5118. // Each resource data entry describes a leaf node in the resource directory
  5119. // tree.  It contains an offset, relative to the beginning of the resource
  5120. // directory of the data for the resource, a size field that gives the number
  5121. // of bytes of data at that offset, a CodePage that should be used when
  5122. // decoding code point values within the resource data.  Typically for new
  5123. // applications the code page would be the unicode code page.
  5124. //
  5125.  
  5126. typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
  5127.     DWORD   OffsetToData;
  5128.     DWORD   Size;
  5129.     DWORD   CodePage;
  5130.     DWORD   Reserved;
  5131. } IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;
  5132.  
  5133. //
  5134. // Load Configuration Directory Entry
  5135. //
  5136.  
  5137. typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
  5138.     DWORD   Characteristics;
  5139.     DWORD   TimeDateStamp;
  5140.     WORD    MajorVersion;
  5141.     WORD    MinorVersion;
  5142.     DWORD   GlobalFlagsClear;
  5143.     DWORD   GlobalFlagsSet;
  5144.     DWORD   CriticalSectionDefaultTimeout;
  5145.     DWORD   DeCommitFreeBlockThreshold;
  5146.     DWORD   DeCommitTotalFreeThreshold;
  5147.     PVOID   LockPrefixTable;
  5148.     DWORD   MaximumAllocationSize;
  5149.     DWORD   VirtualMemoryThreshold;
  5150.     DWORD   ProcessHeapFlags;
  5151.     DWORD   ProcessAffinityMask;
  5152.     WORD    CSDVersion;
  5153.     WORD    Reserved1;
  5154.     DWORD   Reserved[ 2 ];
  5155. } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
  5156.  
  5157.  
  5158. //
  5159. // Function table entry format for MIPS/ALPHA images.  Function table is
  5160. // pointed to by the IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry.
  5161. // This definition duplicates ones in ntmips.h and ntalpha.h for use
  5162. // by portable image file mungers.
  5163. //
  5164.  
  5165. typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY {
  5166.     DWORD BeginAddress;
  5167.     DWORD EndAddress;
  5168.     PVOID ExceptionHandler;
  5169.     PVOID HandlerData;
  5170.     DWORD PrologEndAddress;
  5171. } IMAGE_RUNTIME_FUNCTION_ENTRY, *PIMAGE_RUNTIME_FUNCTION_ENTRY;
  5172.  
  5173. //
  5174. // WIN CE Exception table format
  5175. //
  5176.  
  5177. typedef struct _IMAGE_CRUNTIME_FUNCTION_ENTRY {
  5178.     DWORD FuncStart : 32;
  5179.     DWORD PrologLen : 8;
  5180.     DWORD FuncLen : 23;
  5181.     DWORD ExceptionFlag : 1;
  5182. } IMAGE_CRUNTIME_FUNCTION_ENTRY, *PIMAGE_CRUNTIME_FUNCTION_ENTRY;
  5183.  
  5184. //
  5185. // Debug Format
  5186. //
  5187.  
  5188. typedef struct _IMAGE_DEBUG_DIRECTORY {
  5189.     DWORD   Characteristics;
  5190.     DWORD   TimeDateStamp;
  5191.     WORD    MajorVersion;
  5192.     WORD    MinorVersion;
  5193.     DWORD   Type;
  5194.     DWORD   SizeOfData;
  5195.     DWORD   AddressOfRawData;
  5196.     DWORD   PointerToRawData;
  5197. } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
  5198.  
  5199. #define IMAGE_DEBUG_TYPE_UNKNOWN          0
  5200. #define IMAGE_DEBUG_TYPE_COFF             1
  5201. #define IMAGE_DEBUG_TYPE_CODEVIEW         2
  5202. #define IMAGE_DEBUG_TYPE_FPO              3
  5203. #define IMAGE_DEBUG_TYPE_MISC             4
  5204. #define IMAGE_DEBUG_TYPE_EXCEPTION        5
  5205. #define IMAGE_DEBUG_TYPE_FIXUP            6
  5206. #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC      7
  5207. #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC    8
  5208. #define IMAGE_DEBUG_TYPE_BORLAND          9
  5209.  
  5210.  
  5211. typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
  5212.     DWORD   NumberOfSymbols;
  5213.     DWORD   LvaToFirstSymbol;
  5214.     DWORD   NumberOfLinenumbers;
  5215.     DWORD   LvaToFirstLinenumber;
  5216.     DWORD   RvaToFirstByteOfCode;
  5217.     DWORD   RvaToLastByteOfCode;
  5218.     DWORD   RvaToFirstByteOfData;
  5219.     DWORD   RvaToLastByteOfData;
  5220. } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
  5221.  
  5222. #define FRAME_FPO       0
  5223. #define FRAME_TRAP      1
  5224. #define FRAME_TSS       2
  5225. #define FRAME_NONFPO    3
  5226.  
  5227. typedef struct _FPO_DATA {
  5228.     DWORD       ulOffStart;             // offset 1st byte of function code
  5229.     DWORD       cbProcSize;             // # bytes in function
  5230.     DWORD       cdwLocals;              // # bytes in locals/4
  5231.     WORD        cdwParams;              // # bytes in params/4
  5232.     WORD        cbProlog : 8;           // # bytes in prolog
  5233.     WORD        cbRegs   : 3;           // # regs saved
  5234.     WORD        fHasSEH  : 1;           // TRUE if SEH in func
  5235.     WORD        fUseBP   : 1;           // TRUE if EBP has been allocated
  5236.     WORD        reserved : 1;           // reserved for future use
  5237.     WORD        cbFrame  : 2;           // frame type
  5238. } FPO_DATA, *PFPO_DATA;
  5239. #define SIZEOF_RFPO_DATA 16
  5240.  
  5241.  
  5242. #define IMAGE_DEBUG_MISC_EXENAME    1
  5243.  
  5244. typedef struct _IMAGE_DEBUG_MISC {
  5245.     DWORD       DataType;               // type of misc data, see defines
  5246.     DWORD       Length;                 // total length of record, rounded to four
  5247.                                         // byte multiple.
  5248.     BOOLEAN     Unicode;                // TRUE if data is unicode string
  5249.     BYTE        Reserved[ 3 ];
  5250.     BYTE        Data[ 1 ];              // Actual data
  5251. } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
  5252.  
  5253.  
  5254. //
  5255. // Function table extracted from MIPS/ALPHA images.  Does not contain
  5256. // information needed only for runtime support.  Just those fields for
  5257. // each entry needed by a debugger.
  5258. //
  5259.  
  5260. typedef struct _IMAGE_FUNCTION_ENTRY {
  5261.     DWORD   StartingAddress;
  5262.     DWORD   EndingAddress;
  5263.     DWORD   EndOfPrologue;
  5264. } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
  5265.  
  5266. //
  5267. // Debugging information can be stripped from an image file and placed
  5268. // in a separate .DBG file, whose file name part is the same as the
  5269. // image file name part (e.g. symbols for CMD.EXE could be stripped
  5270. // and placed in CMD.DBG).  This is indicated by the IMAGE_FILE_DEBUG_STRIPPED
  5271. // flag in the Characteristics field of the file header.  The beginning of
  5272. // the .DBG file contains the following structure which captures certain
  5273. // information from the image file.  This allows a debug to proceed even if
  5274. // the original image file is not accessable.  This header is followed by
  5275. // zero of more IMAGE_SECTION_HEADER structures, followed by zero or more
  5276. // IMAGE_DEBUG_DIRECTORY structures.  The latter structures and those in
  5277. // the image file contain file offsets relative to the beginning of the
  5278. // .DBG file.
  5279. //
  5280. // If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure
  5281. // is left in the image file, but not mapped.  This allows a debugger to
  5282. // compute the name of the .DBG file, from the name of the image in the
  5283. // IMAGE_DEBUG_MISC structure.
  5284. //
  5285.  
  5286. typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
  5287.     WORD        Signature;
  5288.     WORD        Flags;
  5289.     WORD        Machine;
  5290.     WORD        Characteristics;
  5291.     DWORD       TimeDateStamp;
  5292.     DWORD       CheckSum;
  5293.     DWORD       ImageBase;
  5294.     DWORD       SizeOfImage;
  5295.     DWORD       NumberOfSections;
  5296.     DWORD       ExportedNamesSize;
  5297.     DWORD       DebugDirectorySize;
  5298.     DWORD       SectionAlignment;
  5299.     DWORD       Reserved[2];
  5300. } IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER;
  5301.  
  5302. #ifndef _MAC
  5303. #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
  5304. #else
  5305. #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4449
  5306. #endif
  5307.  
  5308. #define IMAGE_SEPARATE_DEBUG_FLAGS_MASK 0x8000
  5309. #define IMAGE_SEPARATE_DEBUG_MISMATCH   0x8000  // when DBG was updated, the
  5310.                                                 // old checksum didn't match.
  5311.  
  5312. //
  5313. //  The .arch section is made up of headers, each describing an amask position/value
  5314. //  pointing to an array of IMAGE_ARCHITECTURE_ENTRY's.  Each "array" (both the header
  5315. //  and entry arrays) are terminiated by a quadword of 0xffffffffL.
  5316. //
  5317. //  NOTE: There may be quadwords of 0 sprinkled around and must be skipped.
  5318. //
  5319.  
  5320. typedef struct _ImageArchitectureHeader {
  5321.     unsigned int AmaskValue: 1;                 // 1 -> code section depends on mask bit
  5322.                                                 // 0 -> new instruction depends on mask bit
  5323.     int :7;                                     // MBZ
  5324.     unsigned int AmaskShift: 8;                 // Amask bit in question for this fixup
  5325.     int :16;                                    // MBZ
  5326.     DWORD FirstEntryRVA;                        // RVA into .arch section to array of ARCHITECTURE_ENTRY's
  5327. } IMAGE_ARCHITECTURE_HEADER, *PIMAGE_ARCHITECTURE_HEADER;
  5328.  
  5329. typedef struct _ImageArchitectureEntry {
  5330.     DWORD FixupInstRVA;                         // RVA of instruction to fixup
  5331.     DWORD NewInst;                              // fixup instruction (see alphaops.h)
  5332. } IMAGE_ARCHITECTURE_ENTRY, *PIMAGE_ARCHITECTURE_ENTRY;
  5333.  
  5334. #include "poppack.h"                // Back to the initial value
  5335.  
  5336. //
  5337. // End Image Format
  5338. //
  5339.  
  5340. //
  5341. // for move macros
  5342. //
  5343. #ifdef _MAC
  5344. #ifndef _INC_STRING
  5345. #include <string.h>
  5346. #endif /* _INC_STRING */
  5347. #else
  5348. #include <string.h>
  5349. #endif // _MAC
  5350.  
  5351. #define HEAP_NO_SERIALIZE               0x00000001      
  5352. #define HEAP_GROWABLE                   0x00000002      
  5353. #define HEAP_GENERATE_EXCEPTIONS        0x00000004      
  5354. #define HEAP_ZERO_MEMORY                0x00000008      
  5355. #define HEAP_REALLOC_IN_PLACE_ONLY      0x00000010      
  5356. #define HEAP_TAIL_CHECKING_ENABLED      0x00000020      
  5357. #define HEAP_FREE_CHECKING_ENABLED      0x00000040      
  5358. #define HEAP_DISABLE_COALESCE_ON_FREE   0x00000080      
  5359. #define HEAP_CREATE_ALIGN_16            0x00010000      
  5360. #define HEAP_CREATE_ENABLE_TRACING      0x00020000      
  5361. #define HEAP_MAXIMUM_TAG                0x0FFF              
  5362. #define HEAP_PSEUDO_TAG_FLAG            0x8000              
  5363. #define HEAP_TAG_SHIFT                  16                  
  5364. #define HEAP_MAKE_TAG_FLAGS( b, o ) ((DWORD)((b) + ((o) << 16)))  
  5365.  
  5366. #define IS_TEXT_UNICODE_ASCII16               0x0001
  5367. #define IS_TEXT_UNICODE_REVERSE_ASCII16       0x0010
  5368.  
  5369. #define IS_TEXT_UNICODE_STATISTICS            0x0002
  5370. #define IS_TEXT_UNICODE_REVERSE_STATISTICS    0x0020
  5371.  
  5372. #define IS_TEXT_UNICODE_CONTROLS              0x0004
  5373. #define IS_TEXT_UNICODE_REVERSE_CONTROLS      0x0040
  5374.  
  5375. #define IS_TEXT_UNICODE_SIGNATURE             0x0008
  5376. #define IS_TEXT_UNICODE_REVERSE_SIGNATURE     0x0080
  5377.  
  5378. #define IS_TEXT_UNICODE_ILLEGAL_CHARS         0x0100
  5379. #define IS_TEXT_UNICODE_ODD_LENGTH            0x0200
  5380. #define IS_TEXT_UNICODE_DBCS_LEADBYTE         0x0400
  5381. #define IS_TEXT_UNICODE_NULL_BYTES            0x1000
  5382.  
  5383. #define IS_TEXT_UNICODE_UNICODE_MASK          0x000F
  5384. #define IS_TEXT_UNICODE_REVERSE_MASK          0x00F0
  5385. #define IS_TEXT_UNICODE_NOT_UNICODE_MASK      0x0F00
  5386. #define IS_TEXT_UNICODE_NOT_ASCII_MASK        0xF000
  5387.  
  5388. #define COMPRESSION_FORMAT_NONE          (0x0000)   
  5389. #define COMPRESSION_FORMAT_DEFAULT       (0x0001)   
  5390. #define COMPRESSION_FORMAT_LZNT1         (0x0002)   
  5391. #define COMPRESSION_ENGINE_STANDARD      (0x0000)   
  5392. #define COMPRESSION_ENGINE_MAXIMUM       (0x0100)   
  5393. #if defined(_M_IX86) || defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_M68K) || defined(_M_MPPC) || defined(__MRC__)
  5394. // end_ntddk
  5395.  
  5396. #if (defined(_M_MRX000) || defined(_ALPHA_)) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  5397.  
  5398. NTSYSAPI
  5399. VOID
  5400. NTAPI
  5401. RtlMoveMemory64 (
  5402.    IN PVOID64 Destination,
  5403.    IN PVOID64 Source,
  5404.    IN DWORDLONG Length
  5405.    );
  5406.  
  5407. NTSYSAPI
  5408. VOID
  5409. NTAPI
  5410. RtlFillMemory64 (
  5411.    IN PVOID64 Destination,
  5412.    IN DWORDLONG Length,
  5413.    IN BYTE  Fill
  5414.    );
  5415.  
  5416. NTSYSAPI
  5417. VOID
  5418. NTAPI
  5419. RtlZeroMemory64 (
  5420.    IN PVOID64 Destination,
  5421.    IN DWORDLONG Length
  5422.    );
  5423.  
  5424. #endif
  5425.  
  5426. //  begin_ntddk begin_wdm
  5427.  
  5428. #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
  5429. #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
  5430. #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
  5431. #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
  5432. #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
  5433.  
  5434. //end_wdm
  5435.  
  5436. #else // _M_PPC
  5437.  
  5438. NTSYSAPI
  5439. DWORD
  5440. NTAPI
  5441. RtlEqualMemory (
  5442.     CONST VOID *Source1,
  5443.     CONST VOID *Source2,
  5444.     DWORD Length
  5445.     );
  5446.  
  5447. NTSYSAPI
  5448. VOID
  5449. NTAPI
  5450. RtlCopyMemory (
  5451.    VOID UNALIGNED *Destination,
  5452.    CONST VOID UNALIGNED *Source,
  5453.    DWORD Length
  5454.    );
  5455.  
  5456. NTSYSAPI
  5457. VOID
  5458. NTAPI
  5459. RtlCopyMemory32 (
  5460.    VOID UNALIGNED *Destination,
  5461.    CONST VOID UNALIGNED *Source,
  5462.    DWORD Length
  5463.    );
  5464.  
  5465. NTSYSAPI
  5466. VOID
  5467. NTAPI
  5468. RtlMoveMemory (
  5469.    VOID UNALIGNED *Destination,
  5470.    CONST VOID UNALIGNED *Source,
  5471.    DWORD Length
  5472.    );
  5473.  
  5474. NTSYSAPI
  5475. VOID
  5476. NTAPI
  5477. RtlFillMemory (
  5478.    VOID UNALIGNED *Destination,
  5479.    DWORD Length,
  5480.    BYTE  Fill
  5481.    );
  5482.  
  5483. NTSYSAPI
  5484. VOID
  5485. NTAPI
  5486. RtlZeroMemory (
  5487.    VOID UNALIGNED *Destination,
  5488.    DWORD Length
  5489.    );
  5490. #endif
  5491.  
  5492. typedef struct _MESSAGE_RESOURCE_ENTRY {
  5493.     WORD   Length;
  5494.     WORD   Flags;
  5495.     BYTE  Text[ 1 ];
  5496. } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
  5497.  
  5498. #define MESSAGE_RESOURCE_UNICODE 0x0001
  5499.  
  5500. typedef struct _MESSAGE_RESOURCE_BLOCK {
  5501.     DWORD LowId;
  5502.     DWORD HighId;
  5503.     DWORD OffsetToEntries;
  5504. } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
  5505.  
  5506. typedef struct _MESSAGE_RESOURCE_DATA {
  5507.     DWORD NumberOfBlocks;
  5508.     MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
  5509. } MESSAGE_RESOURCE_DATA, *PMESSAGE_RESOURCE_DATA;
  5510.  
  5511.  
  5512. typedef struct _RTL_CRITICAL_SECTION_DEBUG {
  5513.     WORD   Type;
  5514.     WORD   CreatorBackTraceIndex;
  5515.     struct _RTL_CRITICAL_SECTION *CriticalSection;
  5516.     LIST_ENTRY ProcessLocksList;
  5517.     DWORD EntryCount;
  5518.     DWORD ContentionCount;
  5519.     DWORD Spare[ 2 ];
  5520. } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG;
  5521.  
  5522. #define RTL_CRITSECT_TYPE 0
  5523. #define RTL_RESOURCE_TYPE 1
  5524.  
  5525. typedef struct _RTL_CRITICAL_SECTION {
  5526.     PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
  5527.  
  5528.     //
  5529.     //  The following three fields control entering and exiting the critical
  5530.     //  section for the resource
  5531.     //
  5532.  
  5533.     LONG LockCount;
  5534.     LONG RecursionCount;
  5535.     HANDLE OwningThread;        // from the thread's ClientId->UniqueThread
  5536.     HANDLE LockSemaphore;
  5537.     DWORD SpinCount;
  5538. } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
  5539. #define SEF_DACL_AUTO_INHERIT             0x1
  5540. #define SEF_SACL_AUTO_INHERIT             0x2
  5541. #define SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT 0x4
  5542. #define SEF_AVOID_PRIVILEGE_CHECK         0x8
  5543. #define DLL_PROCESS_ATTACH 1    
  5544. #define DLL_THREAD_ATTACH  2    
  5545. #define DLL_THREAD_DETACH  3    
  5546. #define DLL_PROCESS_DETACH 0    
  5547.  
  5548. //
  5549. // Defines for the READ flags for Eventlogging
  5550. //
  5551. #define EVENTLOG_SEQUENTIAL_READ        0X0001
  5552. #define EVENTLOG_SEEK_READ              0X0002
  5553. #define EVENTLOG_FORWARDS_READ          0X0004
  5554. #define EVENTLOG_BACKWARDS_READ         0X0008
  5555.  
  5556. //
  5557. // The types of events that can be logged.
  5558. //
  5559. #define EVENTLOG_SUCCESS                0X0000
  5560. #define EVENTLOG_ERROR_TYPE             0x0001
  5561. #define EVENTLOG_WARNING_TYPE           0x0002
  5562. #define EVENTLOG_INFORMATION_TYPE       0x0004
  5563. #define EVENTLOG_AUDIT_SUCCESS          0x0008
  5564. #define EVENTLOG_AUDIT_FAILURE          0x0010
  5565.  
  5566. //
  5567. // Defines for the WRITE flags used by Auditing for paired events
  5568. // These are not implemented in Product 1
  5569. //
  5570.  
  5571. #define EVENTLOG_START_PAIRED_EVENT    0x0001
  5572. #define EVENTLOG_END_PAIRED_EVENT      0x0002
  5573. #define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004
  5574. #define EVENTLOG_PAIRED_EVENT_ACTIVE   0x0008
  5575. #define EVENTLOG_PAIRED_EVENT_INACTIVE 0x0010
  5576.  
  5577. //
  5578. // Structure that defines the header of the Eventlog record. This is the
  5579. // fixed-sized portion before all the variable-length strings, binary
  5580. // data and pad bytes.
  5581. //
  5582. // TimeGenerated is the time it was generated at the client.
  5583. // TimeWritten is the time it was put into the log at the server end.
  5584. //
  5585.  
  5586. typedef struct _EVENTLOGRECORD {
  5587.     DWORD  Length;        // Length of full record
  5588.     DWORD  Reserved;      // Used by the service
  5589.     DWORD  RecordNumber;  // Absolute record number
  5590.     DWORD  TimeGenerated; // Seconds since 1-1-1970
  5591.     DWORD  TimeWritten;   // Seconds since 1-1-1970
  5592.     DWORD  EventID;
  5593.     WORD   EventType;
  5594.     WORD   NumStrings;
  5595.     WORD   EventCategory;
  5596.     WORD   ReservedFlags; // For use with paired events (auditing)
  5597.     DWORD  ClosingRecordNumber; // For use with paired events (auditing)
  5598.     DWORD  StringOffset;  // Offset from beginning of record
  5599.     DWORD  UserSidLength;
  5600.     DWORD  UserSidOffset;
  5601.     DWORD  DataLength;
  5602.     DWORD  DataOffset;    // Offset from beginning of record
  5603.     //
  5604.     // Then follow:
  5605.     //
  5606.     // WCHAR SourceName[]
  5607.     // WCHAR Computername[]
  5608.     // SID   UserSid
  5609.     // WCHAR Strings[]
  5610.     // BYTE  Data[]
  5611.     // CHAR  Pad[]
  5612.     // DWORD Length;
  5613.     //
  5614. } EVENTLOGRECORD, *PEVENTLOGRECORD;
  5615.  
  5616. //SS: start of changes to support clustering
  5617. //SS: ideally the
  5618. #define MAXLOGICALLOGNAMESIZE   256
  5619.  
  5620. #pragma warning(disable : 4200)
  5621. typedef struct _EVENTSFORLOGFILE{
  5622.     DWORD            ulSize;    
  5623.     WCHAR           szLogicalLogFile[MAXLOGICALLOGNAMESIZE];        //name of the logical file-security/application/system
  5624.     DWORD            ulNumRecords;
  5625.     EVENTLOGRECORD     pEventLogRecords[];
  5626. }EVENTSFORLOGFILE, *PEVENTSFORLOGFILE;    
  5627.  
  5628. typedef struct _PACKEDEVENTINFO{
  5629.     DWORD               ulSize;  //total size of the structure 
  5630.     DWORD               ulNumEventsForLogFile; //number of EventsForLogFile structure that follow
  5631.     DWORD                 ulOffsets[];           //the offsets from the start of this structure to the EVENTSFORLOGFILE structure
  5632. }PACKEDEVENTINFO, *PPACKEDEVENTINFO;
  5633.  
  5634. #pragma warning(default : 4200)
  5635. //SS: end of changes to support clustering
  5636. #define DBG_CONTINUE                    ((DWORD   )0x00010002L) 
  5637. #define DBG_TERMINATE_THREAD            ((DWORD   )0x40010003L) 
  5638. #define DBG_TERMINATE_PROCESS           ((DWORD   )0x40010004L) 
  5639. #define DBG_CONTROL_C                   ((DWORD   )0x40010005L) 
  5640. #define DBG_CONTROL_BREAK               ((DWORD   )0x40010008L) 
  5641. #define DBG_EXCEPTION_NOT_HANDLED       ((DWORD   )0x80010001L) 
  5642. //
  5643.  
  5644. // begin_ntddk begin_wdm begin_nthal
  5645. //
  5646. // Registry Specific Access Rights.
  5647. //
  5648.  
  5649. #define KEY_QUERY_VALUE         (0x0001)
  5650. #define KEY_SET_VALUE           (0x0002)
  5651. #define KEY_CREATE_SUB_KEY      (0x0004)
  5652. #define KEY_ENUMERATE_SUB_KEYS  (0x0008)
  5653. #define KEY_NOTIFY              (0x0010)
  5654. #define KEY_CREATE_LINK         (0x0020)
  5655.  
  5656. #define KEY_READ                ((STANDARD_RIGHTS_READ       |\
  5657.                                   KEY_QUERY_VALUE            |\
  5658.                                   KEY_ENUMERATE_SUB_KEYS     |\
  5659.                                   KEY_NOTIFY)                 \
  5660.                                   &                           \
  5661.                                  (~SYNCHRONIZE))
  5662.  
  5663.  
  5664. #define KEY_WRITE               ((STANDARD_RIGHTS_WRITE      |\
  5665.                                   KEY_SET_VALUE              |\
  5666.                                   KEY_CREATE_SUB_KEY)         \
  5667.                                   &                           \
  5668.                                  (~SYNCHRONIZE))
  5669.  
  5670. #define KEY_EXECUTE             ((KEY_READ)                   \
  5671.                                   &                           \
  5672.                                  (~SYNCHRONIZE))
  5673.  
  5674. #define KEY_ALL_ACCESS          ((STANDARD_RIGHTS_ALL        |\
  5675.                                   KEY_QUERY_VALUE            |\
  5676.                                   KEY_SET_VALUE              |\
  5677.                                   KEY_CREATE_SUB_KEY         |\
  5678.                                   KEY_ENUMERATE_SUB_KEYS     |\
  5679.                                   KEY_NOTIFY                 |\
  5680.                                   KEY_CREATE_LINK)            \
  5681.                                   &                           \
  5682.                                  (~SYNCHRONIZE))
  5683.  
  5684. //
  5685. // Open/Create Options
  5686. //
  5687.  
  5688. #define REG_OPTION_RESERVED         (0x00000000L)   // Parameter is reserved
  5689.  
  5690. #define REG_OPTION_NON_VOLATILE     (0x00000000L)   // Key is preserved
  5691.                                                     // when system is rebooted
  5692.  
  5693. #define REG_OPTION_VOLATILE         (0x00000001L)   // Key is not preserved
  5694.                                                     // when system is rebooted
  5695.  
  5696. #define REG_OPTION_CREATE_LINK      (0x00000002L)   // Created key is a
  5697.                                                     // symbolic link
  5698.  
  5699. #define REG_OPTION_BACKUP_RESTORE   (0x00000004L)   // open for backup or restore
  5700.                                                     // special access rules
  5701.                                                     // privilege required
  5702.  
  5703. #define REG_OPTION_OPEN_LINK        (0x00000008L)   // Open symbolic link
  5704.  
  5705. #define REG_LEGAL_OPTION            \
  5706.                 (REG_OPTION_RESERVED            |\
  5707.                  REG_OPTION_NON_VOLATILE        |\
  5708.                  REG_OPTION_VOLATILE            |\
  5709.                  REG_OPTION_CREATE_LINK         |\
  5710.                  REG_OPTION_BACKUP_RESTORE      |\
  5711.                  REG_OPTION_OPEN_LINK)
  5712.  
  5713. //
  5714. // Key creation/open disposition
  5715. //
  5716.  
  5717. #define REG_CREATED_NEW_KEY         (0x00000001L)   // New Registry Key created
  5718. #define REG_OPENED_EXISTING_KEY     (0x00000002L)   // Existing Key opened
  5719.  
  5720. //
  5721. // Key restore flags
  5722. //
  5723.  
  5724. #define REG_WHOLE_HIVE_VOLATILE     (0x00000001L)   // Restore whole hive volatile
  5725. #define REG_REFRESH_HIVE            (0x00000002L)   // Unwind changes to last flush
  5726. #define REG_NO_LAZY_FLUSH           (0x00000004L)   // Never lazy flush this hive
  5727.  
  5728. // end_ntddk end_wdm end_nthal
  5729.  
  5730. //
  5731. // Notify filter values
  5732. //
  5733. #define REG_NOTIFY_CHANGE_NAME          (0x00000001L) // Create or delete (child)
  5734. #define REG_NOTIFY_CHANGE_ATTRIBUTES    (0x00000002L)
  5735. #define REG_NOTIFY_CHANGE_LAST_SET      (0x00000004L) // time stamp
  5736. #define REG_NOTIFY_CHANGE_SECURITY      (0x00000008L)
  5737.  
  5738. #define REG_LEGAL_CHANGE_FILTER                 \
  5739.                 (REG_NOTIFY_CHANGE_NAME          |\
  5740.                  REG_NOTIFY_CHANGE_ATTRIBUTES    |\
  5741.                  REG_NOTIFY_CHANGE_LAST_SET      |\
  5742.                  REG_NOTIFY_CHANGE_SECURITY)
  5743.  
  5744. //
  5745. //
  5746. // Predefined Value Types.
  5747. //
  5748.  
  5749. #define REG_NONE                    ( 0 )   // No value type
  5750. #define REG_SZ                      ( 1 )   // Unicode nul terminated string
  5751. #define REG_EXPAND_SZ               ( 2 )   // Unicode nul terminated string
  5752.                                             // (with environment variable references)
  5753. #define REG_BINARY                  ( 3 )   // Free form binary
  5754. #define REG_DWORD                   ( 4 )   // 32-bit number
  5755. #define REG_DWORD_LITTLE_ENDIAN     ( 4 )   // 32-bit number (same as REG_DWORD)
  5756. #define REG_DWORD_BIG_ENDIAN        ( 5 )   // 32-bit number
  5757. #define REG_LINK                    ( 6 )   // Symbolic Link (unicode)
  5758. #define REG_MULTI_SZ                ( 7 )   // Multiple Unicode strings
  5759. #define REG_RESOURCE_LIST           ( 8 )   // Resource list in the resource map
  5760. #define REG_FULL_RESOURCE_DESCRIPTOR ( 9 )  // Resource list in the hardware description
  5761. #define REG_RESOURCE_REQUIREMENTS_LIST ( 10 )
  5762.  
  5763. // end_ntddk end_wdm end_nthal
  5764.  
  5765. // begin_ntddk begin_wdm begin_nthal
  5766. //
  5767. // Service Types (Bit Mask)
  5768. //
  5769. #define SERVICE_KERNEL_DRIVER          0x00000001
  5770. #define SERVICE_FILE_SYSTEM_DRIVER     0x00000002
  5771. #define SERVICE_ADAPTER                0x00000004
  5772. #define SERVICE_RECOGNIZER_DRIVER      0x00000008
  5773.  
  5774. #define SERVICE_DRIVER                 (SERVICE_KERNEL_DRIVER | \
  5775.                                         SERVICE_FILE_SYSTEM_DRIVER | \
  5776.                                         SERVICE_RECOGNIZER_DRIVER)
  5777.  
  5778. #define SERVICE_WIN32_OWN_PROCESS      0x00000010
  5779. #define SERVICE_WIN32_SHARE_PROCESS    0x00000020
  5780. #define SERVICE_WIN32                  (SERVICE_WIN32_OWN_PROCESS | \
  5781.                                         SERVICE_WIN32_SHARE_PROCESS)
  5782.  
  5783. #define SERVICE_INTERACTIVE_PROCESS    0x00000100
  5784.  
  5785. #define SERVICE_TYPE_ALL               (SERVICE_WIN32  | \
  5786.                                         SERVICE_ADAPTER | \
  5787.                                         SERVICE_DRIVER  | \
  5788.                                         SERVICE_INTERACTIVE_PROCESS)
  5789.  
  5790. //
  5791. // Start Type
  5792. //
  5793.  
  5794. #define SERVICE_BOOT_START             0x00000000
  5795. #define SERVICE_SYSTEM_START           0x00000001
  5796. #define SERVICE_AUTO_START             0x00000002
  5797. #define SERVICE_DEMAND_START           0x00000003
  5798. #define SERVICE_DISABLED               0x00000004
  5799.  
  5800. //
  5801. // Error control type
  5802. //
  5803. #define SERVICE_ERROR_IGNORE           0x00000000
  5804. #define SERVICE_ERROR_NORMAL           0x00000001
  5805. #define SERVICE_ERROR_SEVERE           0x00000002
  5806. #define SERVICE_ERROR_CRITICAL         0x00000003
  5807.  
  5808. //
  5809. //
  5810. // Define the registry driver node enumerations
  5811. //
  5812.  
  5813. typedef enum _CM_SERVICE_NODE_TYPE {
  5814.     DriverType               = SERVICE_KERNEL_DRIVER,
  5815.     FileSystemType           = SERVICE_FILE_SYSTEM_DRIVER,
  5816.     Win32ServiceOwnProcess   = SERVICE_WIN32_OWN_PROCESS,
  5817.     Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
  5818.     AdapterType              = SERVICE_ADAPTER,
  5819.     RecognizerType           = SERVICE_RECOGNIZER_DRIVER
  5820. } SERVICE_NODE_TYPE;
  5821.  
  5822. typedef enum _CM_SERVICE_LOAD_TYPE {
  5823.     BootLoad    = SERVICE_BOOT_START,
  5824.     SystemLoad  = SERVICE_SYSTEM_START,
  5825.     AutoLoad    = SERVICE_AUTO_START,
  5826.     DemandLoad  = SERVICE_DEMAND_START,
  5827.     DisableLoad = SERVICE_DISABLED
  5828. } SERVICE_LOAD_TYPE;
  5829.  
  5830. typedef enum _CM_ERROR_CONTROL_TYPE {
  5831.     IgnoreError   = SERVICE_ERROR_IGNORE,
  5832.     NormalError   = SERVICE_ERROR_NORMAL,
  5833.     SevereError   = SERVICE_ERROR_SEVERE,
  5834.     CriticalError = SERVICE_ERROR_CRITICAL
  5835. } SERVICE_ERROR_TYPE;
  5836.  
  5837.  
  5838.  
  5839. //
  5840. // IOCTL_TAPE_ERASE definitions
  5841. //
  5842.  
  5843. #define TAPE_ERASE_SHORT            0L
  5844. #define TAPE_ERASE_LONG             1L
  5845.  
  5846. typedef struct _TAPE_ERASE {
  5847.     DWORD Type;
  5848.     BOOLEAN Immediate;
  5849. } TAPE_ERASE, *PTAPE_ERASE;
  5850.  
  5851. //
  5852. // IOCTL_TAPE_PREPARE definitions
  5853. //
  5854.  
  5855. #define TAPE_LOAD                   0L
  5856. #define TAPE_UNLOAD                 1L
  5857. #define TAPE_TENSION                2L
  5858. #define TAPE_LOCK                   3L
  5859. #define TAPE_UNLOCK                 4L
  5860. #define TAPE_FORMAT                 5L
  5861.  
  5862. typedef struct _TAPE_PREPARE {
  5863.     DWORD Operation;
  5864.     BOOLEAN Immediate;
  5865. } TAPE_PREPARE, *PTAPE_PREPARE;
  5866.  
  5867. //
  5868. // IOCTL_TAPE_WRITE_MARKS definitions
  5869. //
  5870.  
  5871. #define TAPE_SETMARKS               0L
  5872. #define TAPE_FILEMARKS              1L
  5873. #define TAPE_SHORT_FILEMARKS        2L
  5874. #define TAPE_LONG_FILEMARKS         3L
  5875.  
  5876. typedef struct _TAPE_WRITE_MARKS {
  5877.     DWORD Type;
  5878.     DWORD Count;
  5879.     BOOLEAN Immediate;
  5880. } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
  5881.  
  5882. //
  5883. // IOCTL_TAPE_GET_POSITION definitions
  5884. //
  5885.  
  5886. #define TAPE_ABSOLUTE_POSITION       0L
  5887. #define TAPE_LOGICAL_POSITION        1L
  5888. #define TAPE_PSEUDO_LOGICAL_POSITION 2L
  5889.  
  5890. typedef struct _TAPE_GET_POSITION {
  5891.     DWORD Type;
  5892.     DWORD Partition;
  5893.     LARGE_INTEGER Offset;
  5894. } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
  5895.  
  5896. //
  5897. // IOCTL_TAPE_SET_POSITION definitions
  5898. //
  5899.  
  5900. #define TAPE_REWIND                 0L
  5901. #define TAPE_ABSOLUTE_BLOCK         1L
  5902. #define TAPE_LOGICAL_BLOCK          2L
  5903. #define TAPE_PSEUDO_LOGICAL_BLOCK   3L
  5904. #define TAPE_SPACE_END_OF_DATA      4L
  5905. #define TAPE_SPACE_RELATIVE_BLOCKS  5L
  5906. #define TAPE_SPACE_FILEMARKS        6L
  5907. #define TAPE_SPACE_SEQUENTIAL_FMKS  7L
  5908. #define TAPE_SPACE_SETMARKS         8L
  5909. #define TAPE_SPACE_SEQUENTIAL_SMKS  9L
  5910.  
  5911. typedef struct _TAPE_SET_POSITION {
  5912.     DWORD Method;
  5913.     DWORD Partition;
  5914.     LARGE_INTEGER Offset;
  5915.     BOOLEAN Immediate;
  5916. } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
  5917.  
  5918. //
  5919. // IOCTL_TAPE_GET_DRIVE_PARAMS definitions
  5920. //
  5921.  
  5922. //
  5923. // Definitions for FeaturesLow parameter
  5924. //
  5925.  
  5926. #define TAPE_DRIVE_FIXED            0x00000001
  5927. #define TAPE_DRIVE_SELECT           0x00000002
  5928. #define TAPE_DRIVE_INITIATOR        0x00000004
  5929.  
  5930. #define TAPE_DRIVE_ERASE_SHORT      0x00000010
  5931. #define TAPE_DRIVE_ERASE_LONG       0x00000020
  5932. #define TAPE_DRIVE_ERASE_BOP_ONLY   0x00000040
  5933. #define TAPE_DRIVE_ERASE_IMMEDIATE  0x00000080
  5934.  
  5935. #define TAPE_DRIVE_TAPE_CAPACITY    0x00000100
  5936. #define TAPE_DRIVE_TAPE_REMAINING   0x00000200
  5937. #define TAPE_DRIVE_FIXED_BLOCK      0x00000400
  5938. #define TAPE_DRIVE_VARIABLE_BLOCK   0x00000800
  5939.  
  5940. #define TAPE_DRIVE_WRITE_PROTECT    0x00001000
  5941. #define TAPE_DRIVE_EOT_WZ_SIZE      0x00002000
  5942.  
  5943. #define TAPE_DRIVE_ECC              0x00010000
  5944. #define TAPE_DRIVE_COMPRESSION      0x00020000
  5945. #define TAPE_DRIVE_PADDING          0x00040000
  5946. #define TAPE_DRIVE_REPORT_SMKS      0x00080000
  5947.  
  5948. #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000
  5949. #define TAPE_DRIVE_GET_LOGICAL_BLK  0x00200000
  5950. #define TAPE_DRIVE_SET_EOT_WZ_SIZE  0x00400000
  5951.  
  5952. #define TAPE_DRIVE_EJECT_MEDIA      0x01000000
  5953. #define TAPE_DRIVE_CLEAN_REQUESTS   0x02000000
  5954.  
  5955. #define TAPE_DRIVE_RESERVED_BIT     0x80000000  //don't use this bit!
  5956. //                                              //can't be a low features bit!
  5957. //                                              //reserved; high features only
  5958.  
  5959. //
  5960. // Definitions for FeaturesHigh parameter
  5961. //
  5962.  
  5963. #define TAPE_DRIVE_LOAD_UNLOAD      0x80000001
  5964. #define TAPE_DRIVE_TENSION          0x80000002
  5965. #define TAPE_DRIVE_LOCK_UNLOCK      0x80000004
  5966. #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
  5967.  
  5968. #define TAPE_DRIVE_SET_BLOCK_SIZE   0x80000010
  5969. #define TAPE_DRIVE_LOAD_UNLD_IMMED  0x80000020
  5970. #define TAPE_DRIVE_TENSION_IMMED    0x80000040
  5971. #define TAPE_DRIVE_LOCK_UNLK_IMMED  0x80000080
  5972.  
  5973. #define TAPE_DRIVE_SET_ECC          0x80000100
  5974. #define TAPE_DRIVE_SET_COMPRESSION  0x80000200
  5975. #define TAPE_DRIVE_SET_PADDING      0x80000400
  5976. #define TAPE_DRIVE_SET_REPORT_SMKS  0x80000800
  5977.  
  5978. #define TAPE_DRIVE_ABSOLUTE_BLK     0x80001000
  5979. #define TAPE_DRIVE_ABS_BLK_IMMED    0x80002000
  5980. #define TAPE_DRIVE_LOGICAL_BLK      0x80004000
  5981. #define TAPE_DRIVE_LOG_BLK_IMMED    0x80008000
  5982.  
  5983. #define TAPE_DRIVE_END_OF_DATA      0x80010000
  5984. #define TAPE_DRIVE_RELATIVE_BLKS    0x80020000
  5985. #define TAPE_DRIVE_FILEMARKS        0x80040000
  5986. #define TAPE_DRIVE_SEQUENTIAL_FMKS  0x80080000
  5987.  
  5988. #define TAPE_DRIVE_SETMARKS         0x80100000
  5989. #define TAPE_DRIVE_SEQUENTIAL_SMKS  0x80200000
  5990. #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
  5991. #define TAPE_DRIVE_SPACE_IMMEDIATE  0x80800000
  5992.  
  5993. #define TAPE_DRIVE_WRITE_SETMARKS   0x81000000
  5994. #define TAPE_DRIVE_WRITE_FILEMARKS  0x82000000
  5995. #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
  5996. #define TAPE_DRIVE_WRITE_LONG_FMKS  0x88000000
  5997.  
  5998. #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
  5999. #define TAPE_DRIVE_FORMAT           0xA0000000
  6000. #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
  6001. #define TAPE_DRIVE_HIGH_FEATURES    0x80000000  //mask for high features flag
  6002.  
  6003. typedef struct _TAPE_GET_DRIVE_PARAMETERS {
  6004.     BOOLEAN ECC;
  6005.     BOOLEAN Compression;
  6006.     BOOLEAN DataPadding;
  6007.     BOOLEAN ReportSetmarks;
  6008.     DWORD DefaultBlockSize;
  6009.     DWORD MaximumBlockSize;
  6010.     DWORD MinimumBlockSize;
  6011.     DWORD MaximumPartitionCount;
  6012.     DWORD FeaturesLow;
  6013.     DWORD FeaturesHigh;
  6014.     DWORD EOTWarningZoneSize;
  6015. } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
  6016.  
  6017. //
  6018. // IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions
  6019. //
  6020.  
  6021. typedef struct _TAPE_SET_DRIVE_PARAMETERS {
  6022.     BOOLEAN ECC;
  6023.     BOOLEAN Compression;
  6024.     BOOLEAN DataPadding;
  6025.     BOOLEAN ReportSetmarks;
  6026.     DWORD EOTWarningZoneSize;
  6027. } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
  6028.  
  6029. //
  6030. // IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions
  6031. //
  6032.  
  6033. typedef struct _TAPE_GET_MEDIA_PARAMETERS {
  6034.     LARGE_INTEGER Capacity;
  6035.     LARGE_INTEGER Remaining;
  6036.     DWORD BlockSize;
  6037.     DWORD PartitionCount;
  6038.     BOOLEAN WriteProtected;
  6039. } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
  6040.  
  6041. //
  6042. // IOCTL_TAPE_SET_MEDIA_PARAMETERS definitions
  6043. //
  6044.  
  6045. typedef struct _TAPE_SET_MEDIA_PARAMETERS {
  6046.     DWORD BlockSize;
  6047. } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
  6048.  
  6049. //
  6050. // IOCTL_TAPE_CREATE_PARTITION definitions
  6051. //
  6052.  
  6053. #define TAPE_FIXED_PARTITIONS       0L
  6054. #define TAPE_SELECT_PARTITIONS      1L
  6055. #define TAPE_INITIATOR_PARTITIONS   2L
  6056.  
  6057. typedef struct _TAPE_CREATE_PARTITION {
  6058.     DWORD Method;
  6059.     DWORD Count;
  6060.     DWORD Size;
  6061. } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
  6062.  
  6063.  
  6064. #ifdef __cplusplus
  6065. }
  6066. #endif
  6067.  
  6068. #pragma option pop /*P_O_Pop*/
  6069. #endif /* _WINNT_ */
  6070.