home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / winnt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  197.9 KB  |  5,860 lines

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