Home | History | Annotate | Download | only in include
      1 /**
      2  * This file is part of the mingw-w64 runtime package.
      3  * No warranty is given; refer to the file DISCLAIMER within this package.
      4  */
      5 
      6 #ifndef _WINNT_
      7 #define _WINNT_
      8 
      9 #include <_mingw_unicode.h>
     10 
     11 #ifdef __cplusplus
     12 extern "C" {
     13 #endif
     14 
     15 #include <_mingw.h>
     16 #include <ctype.h>
     17 #include <excpt.h>
     18 #include <winapifamily.h>
     19 #include <apiset.h>
     20 
     21 #define ANYSIZE_ARRAY 1
     22 
     23 #include <specstrings.h>
     24 
     25 #ifndef __WIDL__
     26 #define __INTRINSIC_GROUP_WINNT /* only define the intrinsics in this file */
     27 #include <psdk_inc/intrin-impl.h>
     28 #endif
     29 
     30 #if defined(__x86_64) && \
     31   !(defined(_X86_) || defined(__i386__) || defined(_IA64_) || defined (__arm__))
     32 #if !defined(_AMD64_)
     33 #define _AMD64_
     34 #endif
     35 #endif /* _AMD64_ */
     36 
     37 #if defined(__arm__) && \
     38   !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined (__ia64__))
     39 #if !defined(_ARM_)
     40 #define _ARM_
     41 #endif
     42 #endif /* _ARM_ */
     43 
     44 #if defined(__ia64__) && \
     45   !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined (__arm__))
     46 #if !defined(_IA64_)
     47 #define _IA64_
     48 #endif
     49 #endif /* _IA64_ */
     50 
     51 #include <sdkddkver.h>
     52 
     53 #ifndef DUMMYUNIONNAME
     54 #if defined (NONAMELESSUNION)
     55 #define DUMMYUNIONNAME u
     56 #define DUMMYUNIONNAME2 u2
     57 #define DUMMYUNIONNAME3 u3
     58 #define DUMMYUNIONNAME4 u4
     59 #define DUMMYUNIONNAME5 u5
     60 #define DUMMYUNIONNAME6 u6
     61 #define DUMMYUNIONNAME7 u7
     62 #define DUMMYUNIONNAME8 u8
     63 #define DUMMYUNIONNAME9 u9
     64 #else
     65 #define DUMMYUNIONNAME
     66 #define DUMMYUNIONNAME2
     67 #define DUMMYUNIONNAME3
     68 #define DUMMYUNIONNAME4
     69 #define DUMMYUNIONNAME5
     70 #define DUMMYUNIONNAME6
     71 #define DUMMYUNIONNAME7
     72 #define DUMMYUNIONNAME8
     73 #define DUMMYUNIONNAME9
     74 #endif
     75 #endif
     76 
     77 #ifndef DUMMYSTRUCTNAME
     78 #if defined (NONAMELESSUNION)
     79 #define DUMMYSTRUCTNAME s
     80 #define DUMMYSTRUCTNAME2 s2
     81 #define DUMMYSTRUCTNAME3 s3
     82 #define DUMMYSTRUCTNAME4 s4
     83 #define DUMMYSTRUCTNAME5 s5
     84 #else
     85 #define DUMMYSTRUCTNAME
     86 #define DUMMYSTRUCTNAME2
     87 #define DUMMYSTRUCTNAME3
     88 #define DUMMYSTRUCTNAME4
     89 #define DUMMYSTRUCTNAME5
     90 #endif
     91 #endif
     92 
     93 #define RESTRICTED_POINTER
     94 
     95 #undef  UNALIGNED	/* avoid redefinition warnings vs _mingw.h */
     96 #undef  UNALIGNED64
     97 #if defined (__ia64__) || defined (__x86_64__) || defined (__arm__)
     98 #define ALIGNMENT_MACHINE
     99 #define UNALIGNED __unaligned
    100 #if defined (_WIN64)
    101 #define UNALIGNED64 __unaligned
    102 #else
    103 #define UNALIGNED64
    104 #endif
    105 #else
    106 #undef ALIGNMENT_MACHINE
    107 #define UNALIGNED
    108 #define UNALIGNED64
    109 #endif
    110 
    111 #ifdef _WIN64
    112 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
    113 #define MEMORY_ALLOCATION_ALIGNMENT 16
    114 #else
    115 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
    116 #define MEMORY_ALLOCATION_ALIGNMENT 8
    117 #endif
    118 
    119 #ifdef __cplusplus
    120 #define TYPE_ALIGNMENT(t) __alignof__ (t)
    121 #else
    122 #define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
    123 #endif
    124 
    125 #if defined (__x86_64__) || defined (__i386__)
    126 #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT (DWORD)
    127 #elif defined (__ia64__) || defined (__arm__)
    128 #define PROBE_ALIGNMENT(_s) (TYPE_ALIGNMENT (_s) > TYPE_ALIGNMENT (DWORD) ? TYPE_ALIGNMENT (_s) : TYPE_ALIGNMENT (DWORD))
    129 #elif !defined (RC_INVOKED) && !defined (__WIDL__)
    130 #error No supported target architecture.
    131 #endif
    132 
    133 #ifdef _WIN64
    134 #define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT (DWORD)
    135 #endif
    136 
    137 #if defined(_MSC_VER)
    138 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
    139 #else
    140 # define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
    141 #endif
    142 
    143 #include <basetsd.h>
    144 
    145 #ifndef DECLSPEC_IMPORT
    146 #if (defined (__i386__) || defined (__ia64__) || defined (__x86_64__) || defined (__arm__)) && !defined (__WIDL__)
    147 #define DECLSPEC_IMPORT __declspec (dllimport)
    148 #else
    149 #define DECLSPEC_IMPORT
    150 #endif
    151 #endif
    152 
    153 #ifndef DECLSPEC_NORETURN
    154 #ifndef __WIDL__
    155 #define DECLSPEC_NORETURN __declspec (noreturn)
    156 #else
    157 #define DECLSPEC_NORETURN
    158 #endif
    159 #endif
    160 
    161 #ifndef DECLSPEC_NOTHROW
    162 #ifndef __WIDL__
    163 #define DECLSPEC_NOTHROW __declspec (nothrow)
    164 #else
    165 #define DECLSPEC_NOTHROW
    166 #endif
    167 #endif
    168 
    169 #ifndef DECLSPEC_ALIGN
    170 #ifndef __WIDL__
    171 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
    172 #define DECLSPEC_ALIGN(x) __declspec(align(x))
    173 #elif defined(__GNUC__)
    174 #define DECLSPEC_ALIGN(x) __attribute__ ((__aligned__ (x)))
    175 #else
    176 #define DECLSPEC_ALIGN(x) /*__declspec (align (x))*/
    177 #endif
    178 #else
    179 #define DECLSPEC_ALIGN(x)
    180 #endif
    181 #endif /* DECLSPEC_ALIGN */
    182 
    183 #ifndef SYSTEM_CACHE_ALIGNMENT_SIZE
    184 #if defined(__x86_64__) || defined(__i386__)
    185 #define SYSTEM_CACHE_ALIGNMENT_SIZE 64
    186 #else
    187 #define SYSTEM_CACHE_ALIGNMENT_SIZE 128
    188 #endif
    189 #endif
    190 
    191 #ifndef DECLSPEC_CACHEALIGN
    192 #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(SYSTEM_CACHE_ALIGNMENT_SIZE)
    193 #endif
    194 
    195 #ifndef DECLSPEC_UUID
    196 #define DECLSPEC_UUID(x)
    197 #endif
    198 
    199 #ifndef DECLSPEC_NOVTABLE
    200 #define DECLSPEC_NOVTABLE
    201 #endif
    202 
    203 #ifndef DECLSPEC_SELECTANY
    204 #define DECLSPEC_SELECTANY __declspec(selectany)
    205 #endif
    206 
    207 #ifndef NOP_FUNCTION
    208 #if (_MSC_VER >= 1210)
    209 #define NOP_FUNCTION __noop
    210 #else
    211 #define NOP_FUNCTION (void)0
    212 #endif
    213 #endif
    214 
    215 #ifndef DECLSPEC_ADDRSAFE
    216 #define DECLSPEC_ADDRSAFE
    217 #endif
    218 
    219 #ifndef DECLSPEC_NOINLINE
    220 #if (_MSC_VER >= 1300)
    221 #define DECLSPEC_NOINLINE  __declspec(noinline)
    222 #elif defined(__GNUC__)
    223 #define DECLSPEC_NOINLINE __attribute__((noinline))
    224 #else
    225 #define DECLSPEC_NOINLINE
    226 #endif
    227 #endif /* DECLSPEC_NOINLINE */
    228 
    229 #ifndef FORCEINLINE
    230 #if !defined(_MSC_VER) || (_MSC_VER >=1200)
    231 #define FORCEINLINE __forceinline
    232 #else
    233 #define FORCEINLINE __inline
    234 #endif
    235 #endif /* FORCEINLINE */
    236 
    237 #ifndef DECLSPEC_DEPRECATED
    238 #if !defined (__WIDL__)
    239 #define DECLSPEC_DEPRECATED __declspec(deprecated)
    240 #define DEPRECATE_SUPPORTED
    241 #else
    242 #define DECLSPEC_DEPRECATED
    243 #undef DEPRECATE_SUPPORTED
    244 #endif
    245 #endif
    246 
    247 #define DECLSPEC_DEPRECATED_DDK
    248 #define PRAGMA_DEPRECATED_DDK 0
    249 
    250   typedef void *PVOID;
    251   typedef void *PVOID64;
    252 
    253 #ifndef FASTCALL
    254 #if defined (__i386__) && !defined (__WIDL__)
    255 #define FASTCALL __fastcall
    256 #else
    257 #define FASTCALL
    258 #endif
    259 #endif /* FASTCALL */
    260 
    261 #if defined(_ARM_)
    262 #define NTAPI
    263 #else
    264 #define NTAPI __stdcall
    265 #endif
    266 #define NTAPI_INLINE NTAPI
    267 
    268 #if !defined(_NTSYSTEM_)
    269 #define NTSYSAPI DECLSPEC_IMPORT
    270 #define NTSYSCALLAPI DECLSPEC_IMPORT
    271 #else
    272 #define NTSYSAPI
    273 #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
    274 #endif
    275 
    276 #ifndef VOID
    277 #define VOID void
    278   typedef char CHAR;
    279   typedef short SHORT;
    280   typedef __LONG32 LONG;
    281 #if !defined (__WIDL__)
    282   typedef int INT;
    283 #endif
    284 #endif
    285 
    286 #ifndef __WCHAR_DEFINED
    287 #define __WCHAR_DEFINED
    288   typedef wchar_t WCHAR;
    289 #endif
    290   typedef WCHAR *PWCHAR,*LPWCH,*PWCH;
    291   typedef CONST WCHAR *LPCWCH,*PCWCH;
    292   typedef WCHAR *NWPSTR,*LPWSTR,*PWSTR;
    293   typedef PWSTR *PZPWSTR;
    294   typedef CONST PWSTR *PCZPWSTR;
    295   typedef WCHAR UNALIGNED *LPUWSTR,*PUWSTR;
    296   typedef CONST WCHAR *LPCWSTR,*PCWSTR;
    297   typedef PCWSTR *PZPCWSTR;
    298   typedef CONST WCHAR UNALIGNED *LPCUWSTR,*PCUWSTR;
    299   typedef WCHAR *PZZWSTR;
    300   typedef CONST WCHAR *PCZZWSTR;
    301   typedef WCHAR UNALIGNED *PUZZWSTR;
    302   typedef CONST WCHAR UNALIGNED *PCUZZWSTR;
    303   typedef WCHAR *PNZWCH;
    304   typedef CONST WCHAR *PCNZWCH;
    305   typedef WCHAR UNALIGNED *PUNZWCH;
    306   typedef CONST WCHAR UNALIGNED *PCUNZWCH;
    307 
    308 #if _WIN32_WINNT >= 0x0600 || (defined (__cplusplus) && defined (WINDOWS_ENABLE_CPLUSPLUS))
    309   typedef CONST WCHAR *LPCWCHAR,*PCWCHAR;
    310   typedef CONST WCHAR UNALIGNED *LPCUWCHAR,*PCUWCHAR;
    311   typedef unsigned long UCSCHAR;
    312 
    313 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
    314 #define MIN_UCSCHAR (0)
    315 #define MAX_UCSCHAR (0x0010ffff)
    316 
    317   typedef UCSCHAR *PUCSCHAR;
    318   typedef const UCSCHAR *PCUCSCHAR;
    319   typedef UCSCHAR *PUCSSTR;
    320   typedef UCSCHAR UNALIGNED *PUUCSSTR;
    321   typedef const UCSCHAR *PCUCSSTR;
    322   typedef const UCSCHAR UNALIGNED *PCUUCSSTR;
    323   typedef UCSCHAR UNALIGNED *PUUCSCHAR;
    324   typedef const UCSCHAR UNALIGNED *PCUUCSCHAR;
    325 #endif
    326 
    327   typedef CHAR *PCHAR,*LPCH,*PCH;
    328   typedef CONST CHAR *LPCCH,*PCCH;
    329   typedef CHAR *NPSTR,*LPSTR,*PSTR;
    330   typedef PSTR *PZPSTR;
    331   typedef CONST PSTR *PCZPSTR;
    332   typedef CONST CHAR *LPCSTR,*PCSTR;
    333   typedef PCSTR *PZPCSTR;
    334   typedef CHAR *PZZSTR;
    335   typedef CONST CHAR *PCZZSTR;
    336   typedef CHAR *PNZCH;
    337   typedef CONST CHAR *PCNZCH;
    338 
    339 #ifdef UNICODE
    340 #ifndef _TCHAR_DEFINED
    341 #define _TCHAR_DEFINED
    342   typedef WCHAR TCHAR, *PTCHAR;
    343   typedef WCHAR TBYTE, *PTBYTE;
    344 #endif
    345 
    346   typedef LPWSTR LPTCH,PTCH;
    347   typedef LPWSTR PTSTR,LPTSTR;
    348   typedef LPCWSTR PCTSTR,LPCTSTR;
    349   typedef LPUWSTR PUTSTR,LPUTSTR;
    350   typedef LPCUWSTR PCUTSTR,LPCUTSTR;
    351   typedef LPWSTR LP;
    352   typedef PZZWSTR PZZTSTR;
    353   typedef PCZZWSTR PCZZTSTR;
    354   typedef PUZZWSTR PUZZTSTR;
    355   typedef PCUZZWSTR PCUZZTSTR;
    356   typedef PZPWSTR PZPTSTR;
    357   typedef PNZWCH PNZTCH;
    358   typedef PCNZWCH PCNZTCH;
    359   typedef PUNZWCH PUNZTCH;
    360   typedef PCUNZWCH PCUNZTCH;
    361 
    362 #define __TEXT(quote) L##quote
    363 #else
    364 #ifndef _TCHAR_DEFINED
    365 #define _TCHAR_DEFINED
    366   typedef char TCHAR, *PTCHAR;
    367   typedef unsigned char TBYTE, *PTBYTE;
    368 #endif
    369 
    370   typedef LPSTR LPTCH,PTCH;
    371   typedef LPCCH LPCTCH,PCTCH;
    372   typedef LPSTR PTSTR,LPTSTR,PUTSTR,LPUTSTR;
    373   typedef LPCSTR PCTSTR,LPCTSTR,PCUTSTR,LPCUTSTR;
    374   typedef PZZSTR PZZTSTR, PUZZTSTR;
    375   typedef PCZZSTR PCZZTSTR, PCUZZTSTR;
    376   typedef PZPSTR PZPTSTR;
    377   typedef PNZCH PNZTCH, PUNZTCH;
    378   typedef PCNZCH PCNZTCH, PCUNZTCH;
    379 
    380 #define __TEXT(quote) quote
    381 #endif
    382 
    383 #define TEXT(quote) __TEXT(quote)
    384 
    385   typedef SHORT *PSHORT;
    386   typedef LONG *PLONG;
    387 
    388 #ifndef ___GROUP_AFFINITY_DEFINED
    389 #define ___GROUP_AFFINITY_DEFINED
    390 typedef struct _GROUP_AFFINITY {
    391   KAFFINITY Mask;
    392   WORD      Group;
    393   WORD      Reserved[3];
    394 } GROUP_AFFINITY, *PGROUP_AFFINITY;
    395 #endif /* !___GROUP_AFFINITY_DEFINED */
    396 
    397 #ifdef STRICT
    398   typedef void *HANDLE;
    399 #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
    400 #else
    401 typedef PVOID HANDLE;
    402 #define DECLARE_HANDLE(name) typedef HANDLE name
    403 #endif
    404 
    405   typedef HANDLE *PHANDLE;
    406   typedef BYTE FCHAR;
    407   typedef WORD FSHORT;
    408   typedef DWORD FLONG;
    409 
    410 #ifndef _HRESULT_DEFINED
    411 #define _HRESULT_DEFINED
    412   typedef LONG HRESULT;
    413 #endif
    414 
    415 #ifdef __cplusplus
    416 #define EXTERN_C extern "C"
    417 #else
    418 #define EXTERN_C extern
    419 #endif
    420 
    421 /* Keep in sync with basetyps.h header.  */
    422 #ifndef STDMETHODCALLTYPE
    423 #define STDMETHODCALLTYPE WINAPI
    424 #define STDMETHODVCALLTYPE __cdecl
    425 #define STDAPICALLTYPE WINAPI
    426 #define STDAPIVCALLTYPE __cdecl
    427 
    428 #define STDAPI EXTERN_C HRESULT WINAPI
    429 #define STDAPI_(type) EXTERN_C type WINAPI
    430 
    431 #define STDMETHODIMP HRESULT WINAPI
    432 #define STDMETHODIMP_(type) type WINAPI
    433 
    434 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
    435 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
    436 
    437 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
    438 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
    439 #endif
    440 
    441 #define IFACEMETHODIMP STDMETHODIMP
    442 #define IFACEMETHODIMP_(type) STDMETHODIMP_(type)
    443 #define IFACEMETHODIMPV STDMETHODIMPV
    444 #define IFACEMETHODIMPV_(type) STDMETHODIMPV_(type)
    445 
    446   typedef char CCHAR;
    447 #ifndef _LCID_DEFINED
    448 #define _LCID_DEFINED
    449 typedef DWORD LCID;
    450 #endif
    451   typedef PDWORD PLCID;
    452 #ifndef _LANGID_DEFINED
    453 #define _LANGID_DEFINED
    454   typedef WORD LANGID;
    455 #endif
    456 
    457 #ifndef __COMPARTMENT_ID_DEFINED__
    458 #define __COMPARTMENT_ID_DEFINED__
    459 
    460 typedef enum {
    461   UNSPECIFIED_COMPARTMENT_ID = 0,
    462   DEFAULT_COMPARTMENT_ID
    463 } COMPARTMENT_ID,*PCOMPARTMENT_ID;
    464 #endif
    465 
    466 #define APPLICATION_ERROR_MASK 0x20000000
    467 #define ERROR_SEVERITY_SUCCESS 0x00000000
    468 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
    469 #define ERROR_SEVERITY_WARNING 0x80000000
    470 #define ERROR_SEVERITY_ERROR 0xC0000000
    471 
    472 #if defined (__ia64__) && !defined (__WIDL__)
    473   __declspec(align(16))
    474 #endif
    475     typedef struct _FLOAT128 {
    476       __MINGW_EXTENSION __int64 LowPart;
    477       __MINGW_EXTENSION __int64 HighPart;
    478   } FLOAT128;
    479 
    480   typedef FLOAT128 *PFLOAT128;
    481 
    482 #define _ULONGLONG_
    483   __MINGW_EXTENSION typedef __int64 LONGLONG;
    484   __MINGW_EXTENSION typedef unsigned __int64 ULONGLONG;
    485 
    486 #define MAXLONGLONG (0x7fffffffffffffffll)
    487 
    488   typedef LONGLONG *PLONGLONG;
    489   typedef ULONGLONG *PULONGLONG;
    490   typedef LONGLONG USN;
    491 
    492 #ifndef _LARGE_INTEGER_DEFINED
    493 #define _LARGE_INTEGER_DEFINED
    494 
    495 #if defined (__WIDL__)
    496 typedef struct _LARGE_INTEGER {
    497 #else
    498   typedef union _LARGE_INTEGER {
    499     __C89_NAMELESS struct {
    500       DWORD LowPart;
    501       LONG HighPart;
    502     } DUMMYSTRUCTNAME;
    503     struct {
    504       DWORD LowPart;
    505       LONG HighPart;
    506     } u;
    507 #endif
    508     LONGLONG QuadPart;
    509   } LARGE_INTEGER;
    510 
    511   typedef LARGE_INTEGER *PLARGE_INTEGER;
    512 
    513 #if defined (__WIDL__)
    514   typedef struct _ULARGE_INTEGER {
    515 #else
    516   typedef union _ULARGE_INTEGER {
    517     __C89_NAMELESS struct {
    518       DWORD LowPart;
    519       DWORD HighPart;
    520     } DUMMYSTRUCTNAME;
    521     struct {
    522       DWORD LowPart;
    523       DWORD HighPart;
    524     } u;
    525 #endif
    526     ULONGLONG QuadPart;
    527   } ULARGE_INTEGER;
    528 
    529   typedef ULARGE_INTEGER *PULARGE_INTEGER;
    530 
    531   typedef struct _LUID {
    532     DWORD LowPart;
    533     LONG HighPart;
    534   } LUID,*PLUID;
    535 
    536 #endif /* _LARGE_INTEGER_DEFINED */
    537 
    538 #define _DWORDLONG_
    539   typedef ULONGLONG DWORDLONG;
    540   typedef DWORDLONG *PDWORDLONG;
    541 
    542 #define Int32x32To64(a, b) (((LONGLONG) ((LONG) (a))) * ((LONGLONG) ((LONG) (b))))
    543 #define UInt32x32To64(a, b) (((ULONGLONG) ((unsigned int) (a))) *((ULONGLONG) ((unsigned int) (b))))
    544 #define Int64ShllMod32(a, b) (((ULONGLONG) (a)) << (b))
    545 #define Int64ShraMod32(a, b) (((LONGLONG) (a)) >> (b))
    546 #define Int64ShrlMod32(a, b) (((ULONGLONG) (a)) >> (b))
    547 
    548 #ifdef __cplusplus
    549   extern "C" {
    550 #endif
    551 
    552 #ifdef __x86_64
    553 
    554 #define RotateLeft8 _rotl8
    555 #define RotateLeft16 _rotl16
    556 #define RotateRight8 _rotr8
    557 #define RotateRight16 _rotr16
    558 
    559     unsigned char __cdecl _rotl8(unsigned char Value,unsigned char Shift);
    560     unsigned short __cdecl _rotl16(unsigned short Value,unsigned char Shift);
    561     unsigned char __cdecl _rotr8(unsigned char Value,unsigned char Shift);
    562     unsigned short __cdecl _rotr16(unsigned short Value,unsigned char Shift);
    563 #endif /* __x86_64 */
    564 
    565 #define RotateLeft32 _rotl
    566 #define RotateLeft64 _rotl64
    567 #define RotateRight32 _rotr
    568 #define RotateRight64 _rotr64
    569 
    570 #pragma push_macro ("_rotl")
    571 #pragma push_macro ("_rotr")
    572 #undef _rotl
    573 #undef _rotr
    574     unsigned int __cdecl _rotl(unsigned int Value,int Shift);
    575     unsigned int __cdecl _rotr(unsigned int Value,int Shift);
    576 #pragma pop_macro ("_rotr")
    577 #pragma pop_macro ("_rotl")
    578 #pragma push_macro ("_rotr64")
    579 #pragma push_macro ("_rotl64")
    580 #undef _rotl64
    581 #undef _rotr64
    582     __MINGW_EXTENSION unsigned __int64 __cdecl _rotl64(unsigned __int64 Value,int Shift);
    583     __MINGW_EXTENSION unsigned __int64 __cdecl _rotr64(unsigned __int64 Value,int Shift);
    584 #pragma pop_macro ("_rotl64")
    585 #pragma pop_macro ("_rotr64")
    586 
    587 #ifdef __cplusplus
    588   }
    589 #endif
    590 
    591 #define ANSI_NULL ((CHAR)0)
    592 #define UNICODE_NULL ((WCHAR)0)
    593 #define UNICODE_STRING_MAX_BYTES ((WORD) 65534)
    594 #define UNICODE_STRING_MAX_CHARS (32767)
    595 
    596 #ifndef _BOOLEAN_
    597 #define _BOOLEAN_
    598   typedef BYTE BOOLEAN;
    599 #endif
    600   typedef BOOLEAN *PBOOLEAN;
    601 
    602 #ifndef _LIST_ENTRY_DEFINED
    603 #define _LIST_ENTRY_DEFINED
    604 
    605   typedef struct _LIST_ENTRY {
    606     struct _LIST_ENTRY *Flink;
    607     struct _LIST_ENTRY *Blink;
    608   } LIST_ENTRY,*PLIST_ENTRY,*RESTRICTED_POINTER PRLIST_ENTRY;
    609 
    610   typedef struct _SINGLE_LIST_ENTRY {
    611     struct _SINGLE_LIST_ENTRY *Next;
    612   } SINGLE_LIST_ENTRY,*PSINGLE_LIST_ENTRY;
    613 
    614   typedef struct LIST_ENTRY32 {
    615     DWORD Flink;
    616     DWORD Blink;
    617   } LIST_ENTRY32;
    618   typedef LIST_ENTRY32 *PLIST_ENTRY32;
    619 
    620   typedef struct LIST_ENTRY64 {
    621     ULONGLONG Flink;
    622     ULONGLONG Blink;
    623   } LIST_ENTRY64;
    624   typedef LIST_ENTRY64 *PLIST_ENTRY64;
    625 
    626 #endif /* _LIST_ENTRY_DEFINED */
    627 
    628 #include <guiddef.h>
    629 
    630 #ifndef __OBJECTID_DEFINED
    631 #define __OBJECTID_DEFINED
    632   typedef struct _OBJECTID {
    633     GUID Lineage;
    634     DWORD Uniquifier;
    635   } OBJECTID;
    636 #endif
    637 
    638 #define MINCHAR 0x80
    639 #define MAXCHAR 0x7f
    640 #define MINSHORT 0x8000
    641 #define MAXSHORT 0x7fff
    642 #define MINLONG 0x80000000
    643 #define MAXLONG 0x7fffffff
    644 #define MAXBYTE 0xff
    645 #define MAXWORD 0xffff
    646 #define MAXDWORD 0xffffffff
    647 
    648 #define FIELD_OFFSET(Type, Field) ((LONG) __builtin_offsetof(Type, Field))
    649 #define RTL_FIELD_SIZE(type,field) (sizeof(((type *)0)->field))
    650 #define RTL_SIZEOF_THROUGH_FIELD(type,field) (FIELD_OFFSET(type,field) + RTL_FIELD_SIZE(type,field))
    651 #define RTL_CONTAINS_FIELD(Struct,Size,Field) ((((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)))
    652 #define RTL_NUMBER_OF_V1(A) (sizeof(A)/sizeof((A)[0]))
    653 #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)
    654 
    655 #ifdef ENABLE_RTL_NUMBER_OF_V2
    656 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V2(A)
    657 #else
    658 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A)
    659 #endif
    660 
    661 #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A)
    662 #define _ARRAYSIZE(A) RTL_NUMBER_OF_V1(A)
    663 
    664 #define RTL_FIELD_TYPE(type,field) (((type*)0)->field)
    665 #define RTL_NUMBER_OF_FIELD(type,field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type,field)))
    666 #define RTL_PADDING_BETWEEN_FIELDS(T,F1,F2) ((FIELD_OFFSET(T,F2) > FIELD_OFFSET(T,F1)) ? (FIELD_OFFSET(T,F2) - FIELD_OFFSET(T,F1) - RTL_FIELD_SIZE(T,F1)) : (FIELD_OFFSET(T,F1) - FIELD_OFFSET(T,F2) - RTL_FIELD_SIZE(T,F2)))
    667 
    668 #ifdef __cplusplus
    669 #define RTL_CONST_CAST(type) const_cast<type>
    670 #else
    671 #define RTL_CONST_CAST(type) (type)
    672 #endif
    673 
    674 #ifdef __cplusplus
    675 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
    676 extern "C++" { \
    677 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) | ((int)b)); } \
    678 inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
    679 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) & ((int)b)); } \
    680 inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
    681 inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((int)a)); } \
    682 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) ^ ((int)b)); } \
    683 inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
    684 }
    685 #else
    686 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
    687 #endif
    688 
    689 #define COMPILETIME_OR_2FLAGS(a, b) ((UINT) (a) | (UINT) (b))
    690 #define COMPILETIME_OR_3FLAGS(a, b, c) ((UINT) (a) | (UINT) (b) | (UINT) (c))
    691 #define COMPILETIME_OR_4FLAGS(a, b, c, d) ((UINT) (a) | (UINT) (b) | (UINT) (c) | (UINT) (d))
    692 #define COMPILETIME_OR_5FLAGS(a, b, c, d, e) ((UINT) (a) | (UINT) (b) | (UINT) (c) | (UINT) (d) | (UINT) (e))
    693 
    694 
    695 #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8)
    696 #define RTL_BITS_OF_FIELD(type,field) (RTL_BITS_OF(RTL_FIELD_TYPE(type,field)))
    697 #define CONTAINING_RECORD(address,type,field) ((type *)((PCHAR)(address) - (ULONG_PTR)(&((type *)0)->field)))
    698 
    699     typedef EXCEPTION_DISPOSITION NTAPI EXCEPTION_ROUTINE (struct _EXCEPTION_RECORD *ExceptionRecord, PVOID EstablisherFrame, struct _CONTEXT *ContextRecord, PVOID DispatcherContext);
    700 #ifndef __PEXCEPTION_ROUTINE_DEFINED
    701 #define __PEXCEPTION_ROUTINE_DEFINED
    702     typedef EXCEPTION_ROUTINE *PEXCEPTION_ROUTINE;
    703 #endif
    704 
    705 #define VER_WORKSTATION_NT                  0x40000000
    706 #define VER_SERVER_NT                       0x80000000
    707 #define VER_SUITE_SMALLBUSINESS             0x00000001
    708 #define VER_SUITE_ENTERPRISE                0x00000002
    709 #define VER_SUITE_BACKOFFICE                0x00000004
    710 #define VER_SUITE_COMMUNICATIONS            0x00000008
    711 #define VER_SUITE_TERMINAL                  0x00000010
    712 #define VER_SUITE_SMALLBUSINESS_RESTRICTED  0x00000020
    713 #define VER_SUITE_EMBEDDEDNT                0x00000040
    714 #define VER_SUITE_DATACENTER                0x00000080
    715 #define VER_SUITE_SINGLEUSERTS              0x00000100
    716 #define VER_SUITE_PERSONAL                  0x00000200
    717 #define VER_SUITE_BLADE                     0x00000400
    718 #define VER_SUITE_EMBEDDED_RESTRICTED       0x00000800
    719 #define VER_SUITE_SECURITY_APPLIANCE        0x00001000
    720 #define VER_SUITE_STORAGE_SERVER            0x00002000
    721 #define VER_SUITE_COMPUTE_SERVER            0x00004000
    722 #define VER_SUITE_WH_SERVER                 0x00008000
    723 
    724 #define PRODUCT_UNDEFINED                         0x0
    725 
    726 #define PRODUCT_ULTIMATE                          0x1
    727 #define PRODUCT_HOME_BASIC                        0x2
    728 #define PRODUCT_HOME_PREMIUM                      0x3
    729 #define PRODUCT_ENTERPRISE                        0x4
    730 #define PRODUCT_HOME_BASIC_N                      0x5
    731 #define PRODUCT_BUSINESS                          0x6
    732 #define PRODUCT_STANDARD_SERVER                   0x7
    733 #define PRODUCT_DATACENTER_SERVER                 0x8
    734 #define PRODUCT_SMALLBUSINESS_SERVER              0x9
    735 #define PRODUCT_ENTERPRISE_SERVER                 0xa
    736 #define PRODUCT_STARTER                           0xb
    737 #define PRODUCT_DATACENTER_SERVER_CORE            0xc
    738 #define PRODUCT_STANDARD_SERVER_CORE              0xd
    739 #define PRODUCT_ENTERPRISE_SERVER_CORE            0xe
    740 #define PRODUCT_ENTERPRISE_SERVER_IA64            0xf
    741 #define PRODUCT_BUSINESS_N                        0x10
    742 #define PRODUCT_WEB_SERVER                        0x11
    743 #define PRODUCT_CLUSTER_SERVER                    0x12
    744 #define PRODUCT_HOME_SERVER                       0x13
    745 #define PRODUCT_STORAGE_EXPRESS_SERVER            0x14
    746 #define PRODUCT_STORAGE_STANDARD_SERVER           0x15
    747 #define PRODUCT_STORAGE_WORKGROUP_SERVER          0x16
    748 #define PRODUCT_STORAGE_ENTERPRISE_SERVER         0x17
    749 #define PRODUCT_SERVER_FOR_SMALLBUSINESS          0x18
    750 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM      0x19
    751 #define PRODUCT_HOME_PREMIUM_N                    0x1a
    752 #define PRODUCT_ENTERPRISE_N                      0x1b
    753 #define PRODUCT_ULTIMATE_N                        0x1c
    754 #define PRODUCT_WEB_SERVER_CORE                   0x1d
    755 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT  0x1e
    756 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY    0x1f
    757 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING   0x20
    758 #define PRODUCT_SERVER_FOUNDATION                 0x21
    759 #define PRODUCT_HOME_PREMIUM_SERVER               0x22
    760 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V        0x23
    761 #define PRODUCT_STANDARD_SERVER_V                 0x24
    762 #define PRODUCT_DATACENTER_SERVER_V               0x25
    763 #define PRODUCT_ENTERPRISE_SERVER_V               0x26
    764 #define PRODUCT_DATACENTER_SERVER_CORE_V          0x27
    765 #define PRODUCT_STANDARD_SERVER_CORE_V            0x28
    766 #define PRODUCT_ENTERPRISE_SERVER_CORE_V          0x29
    767 #define PRODUCT_HYPERV                            0x2a
    768 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE       0x2b
    769 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE      0x2c
    770 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE     0x2d
    771 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE    0x2e
    772 #define PRODUCT_STARTER_N                         0x2f
    773 #define PRODUCT_PROFESSIONAL                      0x30
    774 #define PRODUCT_PROFESSIONAL_N                    0x31
    775 #define PRODUCT_SB_SOLUTION_SERVER                0x32
    776 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS           0x33
    777 #define PRODUCT_STANDARD_SERVER_SOLUTIONS         0x34
    778 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE    0x35
    779 #define PRODUCT_SB_SOLUTION_SERVER_EM             0x36
    780 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM        0x37
    781 #define PRODUCT_SOLUTION_EMBEDDEDSERVER           0x38
    782 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE      0x39
    783 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT     0x3B
    784 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL     0x3C
    785 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC  0x3D
    786 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC  0x3E
    787 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x3f
    788 #define PRODUCT_CLUSTER_SERVER_V                  0x40
    789 #define PRODUCT_EMBEDDED                          0x41
    790 #define PRODUCT_STARTER_E                         0x42
    791 #define PRODUCT_HOME_BASIC_E                      0x43
    792 #define PRODUCT_HOME_PREMIUM_E                    0x44
    793 #define PRODUCT_PROFESSIONAL_E                    0x45
    794 #define PRODUCT_ENTERPRISE_E                      0x46
    795 #define PRODUCT_ULTIMATE_E                        0x47
    796 #define PRODUCT_ENTERPRISE_EVALUATION             0x48
    797 #define PRODUCT_MULTIPOINT_STANDARD_SERVER        0x4C
    798 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER         0x4D
    799 #define PRODUCT_STANDARD_EVALUATION_SERVER        0x4F
    800 #define PRODUCT_DATACENTER_EVALUATION_SERVER      0x50
    801 #define PRODUCT_ENTERPRISE_N_EVALUATION           0x54
    802 #define PRODUCT_EMBEDDED_AUTOMOTIVE               0x55
    803 #define PRODUCT_EMBEDDED_INDUSTRY_A               0x56
    804 #define PRODUCT_THINPC                            0x57
    805 #define PRODUCT_EMBEDDED_A                        0x58
    806 #define PRODUCT_EMBEDDED_INDUSTRY                 0x59
    807 #define PRODUCT_EMBEDDED_E                        0x5A
    808 #define PRODUCT_EMBEDDED_INDUSTRY_E               0x5B
    809 #define PRODUCT_EMBEDDED_INDUSTRY_A_E             0x5C
    810 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x5F
    811 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x60
    812 #define PRODUCT_CORE_ARM                          0x61
    813 #define PRODUCT_CORE_N                            0x62
    814 #define PRODUCT_CORE_COUNTRYSPECIFIC              0x63
    815 #define PRODUCT_CORE_SINGLELANGUAGE               0x64
    816 #define PRODUCT_CORE                              0x65
    817 #define PRODUCT_PROFESSIONAL_WMC                  0x67
    818 #define PRODUCT_MOBILE_CORE                       0x68
    819 #define PRODUCT_EDUCATION                         0x79
    820 #define PRODUCT_EDUCATION_N                       0x7a
    821 #define PRODUCT_MOBILE_ENTERPRISE                 0x85
    822 
    823 #define PRODUCT_UNLICENSED                        0xabcdabcd
    824 
    825 #define LANG_NEUTRAL                              0x00
    826 #define LANG_INVARIANT                            0x7f
    827 
    828 #define LANG_AFRIKAANS                            0x36
    829 #define LANG_ALBANIAN                             0x1c
    830 #define LANG_ALSATIAN                             0x84
    831 #define LANG_AMHARIC                              0x5e
    832 #define LANG_ARABIC                               0x01
    833 #define LANG_ARMENIAN                             0x2b
    834 #define LANG_ASSAMESE                             0x4d
    835 #define LANG_AZERI                                0x2c
    836 #define LANG_AZERBAIJANI			  0x2c
    837 #define LANG_BANGLA				  0x45
    838 #define LANG_BASHKIR                              0x6d
    839 #define LANG_BASQUE                               0x2d
    840 #define LANG_BELARUSIAN                           0x23
    841 #define LANG_BENGALI                              0x45
    842 #define LANG_BRETON                               0x7e
    843 #define LANG_BOSNIAN                              0x1a
    844 #define LANG_BOSNIAN_NEUTRAL                    0x781a
    845 #define LANG_BULGARIAN                            0x02
    846 #define LANG_CATALAN                              0x03
    847 #define LANG_CENTRAL_KURDISH			  0x92
    848 #define LANG_CHEROKEE				  0x5c
    849 #define LANG_CHINESE                              0x04
    850 #define LANG_CHINESE_SIMPLIFIED                   0x04
    851 #define LANG_CHINESE_TRADITIONAL                0x7c04
    852 #define LANG_CORSICAN                             0x83
    853 #define LANG_CROATIAN                             0x1a
    854 #define LANG_CZECH                                0x05
    855 #define LANG_DANISH                               0x06
    856 #define LANG_DARI                                 0x8c
    857 #define LANG_DIVEHI                               0x65
    858 #define LANG_DUTCH                                0x13
    859 #define LANG_ENGLISH                              0x09
    860 #define LANG_ESTONIAN                             0x25
    861 #define LANG_FAEROESE                             0x38
    862 #define LANG_FARSI                                0x29
    863 #define LANG_FILIPINO                             0x64
    864 #define LANG_FINNISH                              0x0b
    865 #define LANG_FRENCH                               0x0c
    866 #define LANG_FRISIAN                              0x62
    867 #define LANG_FULAH				  0x67
    868 #define LANG_GALICIAN                             0x56
    869 #define LANG_GEORGIAN                             0x37
    870 #define LANG_GERMAN                               0x07
    871 #define LANG_GREEK                                0x08
    872 #define LANG_GREENLANDIC                          0x6f
    873 #define LANG_GUJARATI                             0x47
    874 #define LANG_HAUSA                                0x68
    875 #define LANG_HEBREW                               0x0d
    876 #define LANG_HINDI                                0x39
    877 #define LANG_HUNGARIAN                            0x0e
    878 #define LANG_ICELANDIC                            0x0f
    879 #define LANG_IGBO                                 0x70
    880 #define LANG_INDONESIAN                           0x21
    881 #define LANG_INUKTITUT                            0x5d
    882 #define LANG_IRISH                                0x3c
    883 #define LANG_ITALIAN                              0x10
    884 #define LANG_JAPANESE                             0x11
    885 #define LANG_KANNADA                              0x4b
    886 #define LANG_KASHMIRI                             0x60
    887 #define LANG_KAZAK                                0x3f
    888 #define LANG_KHMER                                0x53
    889 #define LANG_KICHE                                0x86
    890 #define LANG_KINYARWANDA                          0x87
    891 #define LANG_KONKANI                              0x57
    892 #define LANG_KOREAN                               0x12
    893 #define LANG_KYRGYZ                               0x40
    894 #define LANG_LAO                                  0x54
    895 #define LANG_LATVIAN                              0x26
    896 #define LANG_LITHUANIAN                           0x27
    897 #define LANG_LOWER_SORBIAN                        0x2e
    898 #define LANG_LUXEMBOURGISH                        0x6e
    899 #define LANG_MACEDONIAN                           0x2f
    900 #define LANG_MALAY                                0x3e
    901 #define LANG_MALAYALAM                            0x4c
    902 #define LANG_MALTESE                              0x3a
    903 #define LANG_MANIPURI                             0x58
    904 #define LANG_MAORI                                0x81
    905 #define LANG_MAPUDUNGUN                           0x7a
    906 #define LANG_MARATHI                              0x4e
    907 #define LANG_MOHAWK                               0x7c
    908 #define LANG_MONGOLIAN                            0x50
    909 #define LANG_NEPALI                               0x61
    910 #define LANG_NORWEGIAN                            0x14
    911 #define LANG_OCCITAN                              0x82
    912 #define LANG_ODIA				  0x48
    913 #define LANG_ORIYA                                0x48
    914 #define LANG_PASHTO                               0x63
    915 #define LANG_PERSIAN                              0x29
    916 #define LANG_POLISH                               0x15
    917 #define LANG_PORTUGUESE                           0x16
    918 #define LANG_PULAR				  0x67
    919 #define LANG_PUNJABI                              0x46
    920 #define LANG_QUECHUA                              0x6b
    921 #define LANG_ROMANIAN                             0x18
    922 #define LANG_ROMANSH                              0x17
    923 #define LANG_RUSSIAN                              0x19
    924 #define LANG_SAKHA				  0x85
    925 #define LANG_SAMI                                 0x3b
    926 #define LANG_SANSKRIT                             0x4f
    927 #define LANG_SCOTTISH_GAELIC			  0x91
    928 #define LANG_SERBIAN                              0x1a
    929 #define LANG_SERBIAN_NEUTRAL                    0x7c1a
    930 #define LANG_SINDHI                               0x59
    931 #define LANG_SINHALESE                            0x5b
    932 #define LANG_SLOVAK                               0x1b
    933 #define LANG_SLOVENIAN                            0x24
    934 #define LANG_SOTHO                                0x6c
    935 #define LANG_SPANISH                              0x0a
    936 #define LANG_SWAHILI                              0x41
    937 #define LANG_SWEDISH                              0x1d
    938 #define LANG_SYRIAC                               0x5a
    939 #define LANG_TAJIK                                0x28
    940 #define LANG_TAMAZIGHT                            0x5f
    941 #define LANG_TAMIL                                0x49
    942 #define LANG_TATAR                                0x44
    943 #define LANG_TELUGU                               0x4a
    944 #define LANG_THAI                                 0x1e
    945 #define LANG_TIBETAN                              0x51
    946 #define LANG_TIGRIGNA                             0x73
    947 #define LANG_TIGRINYA				  0x73
    948 #define LANG_TSWANA                               0x32
    949 #define LANG_TURKISH                              0x1f
    950 #define LANG_TURKMEN                              0x42
    951 #define LANG_UIGHUR                               0x80
    952 #define LANG_UKRAINIAN                            0x22
    953 #define LANG_UPPER_SORBIAN                        0x2e
    954 #define LANG_URDU                                 0x20
    955 #define LANG_UZBEK                                0x43
    956 #define LANG_VALENCIAN				  0x03
    957 #define LANG_VIETNAMESE                           0x2a
    958 #define LANG_WELSH                                0x52
    959 #define LANG_WOLOF                                0x88
    960 #define LANG_XHOSA                                0x34
    961 #define LANG_YAKUT                                0x85
    962 #define LANG_YI                                   0x78
    963 #define LANG_YORUBA                               0x6a
    964 #define LANG_ZULU                                 0x35
    965 
    966 #define SUBLANG_NEUTRAL                           0x00
    967 #define SUBLANG_DEFAULT                           0x01
    968 #define SUBLANG_SYS_DEFAULT                       0x02
    969 #define SUBLANG_CUSTOM_DEFAULT                    0x03
    970 #define SUBLANG_CUSTOM_UNSPECIFIED                0x04
    971 #define SUBLANG_UI_CUSTOM_DEFAULT                 0x05
    972 
    973 #define SUBLANG_AFRIKAANS_SOUTH_AFRICA            0x01
    974 #define SUBLANG_ALBANIAN_ALBANIA                  0x01
    975 #define SUBLANG_ALSATIAN_FRANCE                   0x01
    976 #define SUBLANG_AMHARIC_ETHIOPIA                  0x01
    977 #define SUBLANG_ARABIC_SAUDI_ARABIA               0x01
    978 #define SUBLANG_ARABIC_IRAQ                       0x02
    979 #define SUBLANG_ARABIC_EGYPT                      0x03
    980 #define SUBLANG_ARABIC_LIBYA                      0x04
    981 #define SUBLANG_ARABIC_ALGERIA                    0x05
    982 #define SUBLANG_ARABIC_MOROCCO                    0x06
    983 #define SUBLANG_ARABIC_TUNISIA                    0x07
    984 #define SUBLANG_ARABIC_OMAN                       0x08
    985 #define SUBLANG_ARABIC_YEMEN                      0x09
    986 #define SUBLANG_ARABIC_SYRIA                      0x0a
    987 #define SUBLANG_ARABIC_JORDAN                     0x0b
    988 #define SUBLANG_ARABIC_LEBANON                    0x0c
    989 #define SUBLANG_ARABIC_KUWAIT                     0x0d
    990 #define SUBLANG_ARABIC_UAE                        0x0e
    991 #define SUBLANG_ARABIC_BAHRAIN                    0x0f
    992 #define SUBLANG_ARABIC_QATAR                      0x10
    993 #define SUBLANG_ARMENIAN_ARMENIA                  0x01
    994 #define SUBLANG_ASSAMESE_INDIA                    0x01
    995 #define SUBLANG_AZERI_LATIN                       0x01
    996 #define SUBLANG_AZERI_CYRILLIC                    0x02
    997 #define SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN      0x01
    998 #define SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC   0x02
    999 #define SUBLANG_BANGLA_INDIA                      0x01
   1000 #define SUBLANG_BANGLA_BANGLADESH                 0x02
   1001 #define SUBLANG_BASHKIR_RUSSIA                    0x01
   1002 #define SUBLANG_BASQUE_BASQUE                     0x01
   1003 #define SUBLANG_BELARUSIAN_BELARUS                0x01
   1004 #define SUBLANG_BENGALI_INDIA                     0x01
   1005 #define SUBLANG_BENGALI_BANGLADESH                0x02
   1006 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN  0x05
   1007 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
   1008 #define SUBLANG_BRETON_FRANCE                     0x01
   1009 #define SUBLANG_BULGARIAN_BULGARIA                0x01
   1010 #define SUBLANG_CATALAN_CATALAN                   0x01
   1011 #define SUBLANG_CENTRAL_KURDISH_IRAQ              0x01
   1012 #define SUBLANG_CHEROKEE_CHEROKEE                 0x01
   1013 #define SUBLANG_CHINESE_TRADITIONAL               0x01
   1014 #define SUBLANG_CHINESE_SIMPLIFIED                0x02
   1015 #define SUBLANG_CHINESE_HONGKONG                  0x03
   1016 #define SUBLANG_CHINESE_SINGAPORE                 0x04
   1017 #define SUBLANG_CHINESE_MACAU                     0x05
   1018 #define SUBLANG_CORSICAN_FRANCE                   0x01
   1019 #define SUBLANG_CZECH_CZECH_REPUBLIC              0x01
   1020 #define SUBLANG_CROATIAN_CROATIA                  0x01
   1021 #define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
   1022 #define SUBLANG_DANISH_DENMARK                    0x01
   1023 #define SUBLANG_DARI_AFGHANISTAN                  0x01
   1024 #define SUBLANG_DIVEHI_MALDIVES                   0x01
   1025 #define SUBLANG_DUTCH                             0x01
   1026 #define SUBLANG_DUTCH_BELGIAN                     0x02
   1027 #define SUBLANG_ENGLISH_US                        0x01
   1028 #define SUBLANG_ENGLISH_UK                        0x02
   1029 #define SUBLANG_ENGLISH_AUS                       0x03
   1030 #define SUBLANG_ENGLISH_CAN                       0x04
   1031 #define SUBLANG_ENGLISH_NZ                        0x05
   1032 #define SUBLANG_ENGLISH_IRELAND                   0x06
   1033 #define SUBLANG_ENGLISH_EIRE                      0x06
   1034 #define SUBLANG_ENGLISH_SOUTH_AFRICA              0x07
   1035 #define SUBLANG_ENGLISH_JAMAICA                   0x08
   1036 #define SUBLANG_ENGLISH_CARIBBEAN                 0x09
   1037 #define SUBLANG_ENGLISH_BELIZE                    0x0a
   1038 #define SUBLANG_ENGLISH_TRINIDAD                  0x0b
   1039 #define SUBLANG_ENGLISH_ZIMBABWE                  0x0c
   1040 #define SUBLANG_ENGLISH_PHILIPPINES               0x0d
   1041 #define SUBLANG_ENGLISH_INDIA                     0x10
   1042 #define SUBLANG_ENGLISH_MALAYSIA                  0x11
   1043 #define SUBLANG_ENGLISH_SINGAPORE                 0x12
   1044 #define SUBLANG_ESTONIAN_ESTONIA                  0x01
   1045 #define SUBLANG_FAEROESE_FAROE_ISLANDS            0x01
   1046 #define SUBLANG_FILIPINO_PHILIPPINES              0x01
   1047 #define SUBLANG_FINNISH_FINLAND                   0x01
   1048 #define SUBLANG_FRENCH                            0x01
   1049 #define SUBLANG_FRENCH_BELGIAN                    0x02
   1050 #define SUBLANG_FRENCH_CANADIAN                   0x03
   1051 #define SUBLANG_FRENCH_SWISS                      0x04
   1052 #define SUBLANG_FRENCH_LUXEMBOURG                 0x05
   1053 #define SUBLANG_FRENCH_MONACO                     0x06
   1054 #define SUBLANG_FRISIAN_NETHERLANDS               0x01
   1055 #define SUBLANG_FULAH_SENEGAL                     0x02
   1056 #define SUBLANG_GALICIAN_GALICIAN                 0x01
   1057 #define SUBLANG_GEORGIAN_GEORGIA                  0x01
   1058 #define SUBLANG_GERMAN                            0x01
   1059 #define SUBLANG_GERMAN_SWISS                      0x02
   1060 #define SUBLANG_GERMAN_AUSTRIAN                   0x03
   1061 #define SUBLANG_GERMAN_LUXEMBOURG                 0x04
   1062 #define SUBLANG_GERMAN_LIECHTENSTEIN              0x05
   1063 #define SUBLANG_GREEK_GREECE                      0x01
   1064 #define SUBLANG_GREENLANDIC_GREENLAND             0x01
   1065 #define SUBLANG_GUJARATI_INDIA                    0x01
   1066 #define SUBLANG_HAUSA_NIGERIA_LATIN               0x01
   1067 #define SUBLANG_HAUSA_NIGERIA    SUBLANG_HAUSA_NIGERIA_LATIN	/* SUBLANG_HAUSA_NIGERIA_LATIN is what MS defines */
   1068 #define SUBLANG_HAWAIIAN_US                       0x01
   1069 #define SUBLANG_HEBREW_ISRAEL                     0x01
   1070 #define SUBLANG_HINDI_INDIA                       0x01
   1071 #define SUBLANG_HUNGARIAN_HUNGARY                 0x01
   1072 #define SUBLANG_ICELANDIC_ICELAND                 0x01
   1073 #define SUBLANG_IGBO_NIGERIA                      0x01
   1074 #define SUBLANG_INDONESIAN_INDONESIA              0x01
   1075 #define SUBLANG_INUKTITUT_CANADA                  0x01
   1076 #define SUBLANG_INUKTITUT_CANADA_LATIN            0x02
   1077 #define SUBLANG_IRISH_IRELAND                     0x02
   1078 #define SUBLANG_ITALIAN                           0x01
   1079 #define SUBLANG_ITALIAN_SWISS                     0x02
   1080 #define SUBLANG_JAPANESE_JAPAN                    0x01
   1081 #define SUBLANG_KANNADA_INDIA                     0x01
   1082 #define SUBLANG_KASHMIRI_INDIA                    0x02
   1083 #define SUBLANG_KASHMIRI_SASIA                    0x02
   1084 #define SUBLANG_KAZAK_KAZAKHSTAN                  0x01
   1085 #define SUBLANG_KHMER_CAMBODIA                    0x01
   1086 #define SUBLANG_KICHE_GUATEMALA                   0x01
   1087 #define SUBLANG_KINYARWANDA_RWANDA                0x01
   1088 #define SUBLANG_KONKANI_INDIA                     0x01
   1089 #define SUBLANG_KOREAN                            0x01
   1090 #define SUBLANG_KYRGYZ_KYRGYZSTAN                 0x01
   1091 #define SUBLANG_LAO_LAO                           0x01
   1092 #define SUBLANG_LAO_LAO_PDR            SUBLANG_LAO_LAO		/* SUBLANG_LAO_LAO is what MS defines */
   1093 #define SUBLANG_LATVIAN_LATVIA                    0x01
   1094 #if (WINVER >= 0x0600)
   1095 #define SUBLANG_LITHUANIAN_LITHUANIA              0x01
   1096 #endif /* WINVER >= 0x0600 */
   1097 #define SUBLANG_LITHUANIAN                        0x01
   1098 #define SUBLANG_LOWER_SORBIAN_GERMANY             0x02
   1099 #define SUBLANG_LUXEMBOURGISH_LUXEMBOURG          0x01
   1100 #define SUBLANG_MACEDONIAN_MACEDONIA              0x01
   1101 #define SUBLANG_MALAY_MALAYSIA                    0x01
   1102 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM           0x02
   1103 #define SUBLANG_MALAYALAM_INDIA                   0x01
   1104 #define SUBLANG_MALTESE_MALTA                     0x01
   1105 #define SUBLANG_MAORI_NEW_ZEALAND                 0x01
   1106 #define SUBLANG_MAPUDUNGUN_CHILE                  0x01
   1107 #define SUBLANG_MARATHI_INDIA                     0x01
   1108 #define SUBLANG_MOHAWK_MOHAWK                     0x01
   1109 #define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA       0x01
   1110 #define SUBLANG_MONGOLIAN_PRC                     0x02
   1111 #define SUBLANG_NEPALI_NEPAL                      0x01
   1112 #define SUBLANG_NEPALI_INDIA                      0x02
   1113 #define SUBLANG_NORWEGIAN_BOKMAL                  0x01
   1114 #define SUBLANG_NORWEGIAN_NYNORSK                 0x02
   1115 #define SUBLANG_OCCITAN_FRANCE                    0x01
   1116 #define SUBLANG_ORIYA_INDIA                       0x01
   1117 #define SUBLANG_PASHTO_AFGHANISTAN                0x01
   1118 #define SUBLANG_PERSIAN_IRAN                      0x01
   1119 #define SUBLANG_POLISH_POLAND                     0x01
   1120 #define SUBLANG_PORTUGUESE_BRAZILIAN              0x01
   1121 #if (WINVER >= 0x0600)
   1122 #define SUBLANG_PORTUGUESE_PORTUGAL               0x02
   1123 #endif /* WINVER >= 0x0600 */
   1124 #define SUBLANG_PORTUGUESE                        0x02
   1125 #define SUBLANG_PULAR_SENEGAL                     0x02
   1126 #define SUBLANG_PUNJABI_INDIA                     0x01
   1127 #define SUBLANG_PUNJABI_PAKISTAN                  0x02
   1128 #define SUBLANG_QUECHUA_BOLIVIA                   0x01
   1129 #define SUBLANG_QUECHUA_ECUADOR                   0x02
   1130 #define SUBLANG_QUECHUA_PERU                      0x03
   1131 #define SUBLANG_ROMANIAN_ROMANIA                  0x01
   1132 /* ??? #define SUBLANG_ROMANIAN_MOLDOVA                  0x01 ??? */
   1133 #define SUBLANG_ROMANSH_SWITZERLAND               0x01
   1134 #define SUBLANG_RUSSIAN_RUSSIA                    0x01
   1135 #define SUBLANG_SAKHA_RUSSIA                      0x01
   1136 #define SUBLANG_SAMI_NORTHERN_NORWAY              0x01
   1137 #define SUBLANG_SAMI_NORTHERN_SWEDEN              0x02
   1138 #define SUBLANG_SAMI_NORTHERN_FINLAND             0x03
   1139 #define SUBLANG_SAMI_LULE_NORWAY                  0x04
   1140 #define SUBLANG_SAMI_LULE_SWEDEN                  0x05
   1141 #define SUBLANG_SAMI_SOUTHERN_NORWAY              0x06
   1142 #define SUBLANG_SAMI_SOUTHERN_SWEDEN              0x07
   1143 #define SUBLANG_SAMI_SKOLT_FINLAND                0x08
   1144 #define SUBLANG_SAMI_INARI_FINLAND                0x09
   1145 #define SUBLANG_SANSKRIT_INDIA                    0x01
   1146 #define SUBLANG_SCOTTISH_GAELIC                    0x01
   1147 #define SUBLANG_SERBIAN_LATIN                     0x02
   1148 #define SUBLANG_SERBIAN_CYRILLIC                  0x03
   1149 #define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN  0x06
   1150 #define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x07
   1151 #define SUBLANG_SERBIAN_MONTENEGRO_LATIN          0x0b
   1152 #define SUBLANG_SERBIAN_MONTENEGRO_CYRILLIC       0x0c
   1153 #define SUBLANG_SERBIAN_SERBIA_LATIN              0x09
   1154 #define SUBLANG_SERBIAN_SERBIA_CYRILLIC           0x0a
   1155 #define SUBLANG_SINDHI_INDIA                      0x01
   1156 #define SUBLANG_SINDHI_AFGHANISTAN                0x02
   1157 #define SUBLANG_SINDHI_PAKISTAN                   0x02
   1158 #define SUBLANG_SINHALESE_SRI_LANKA               0x01
   1159 #define SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA       0x01
   1160 #define SUBLANG_SLOVAK_SLOVAKIA                   0x01
   1161 #define SUBLANG_SLOVENIAN_SLOVENIA                0x01
   1162 #define SUBLANG_SPANISH                           0x01
   1163 #define SUBLANG_SPANISH_MEXICAN                   0x02
   1164 #define SUBLANG_SPANISH_MODERN                    0x03
   1165 #define SUBLANG_SPANISH_GUATEMALA                 0x04
   1166 #define SUBLANG_SPANISH_COSTA_RICA                0x05
   1167 #define SUBLANG_SPANISH_PANAMA                    0x06
   1168 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC        0x07
   1169 #define SUBLANG_SPANISH_VENEZUELA                 0x08
   1170 #define SUBLANG_SPANISH_COLOMBIA                  0x09
   1171 #define SUBLANG_SPANISH_PERU                      0x0a
   1172 #define SUBLANG_SPANISH_ARGENTINA                 0x0b
   1173 #define SUBLANG_SPANISH_ECUADOR                   0x0c
   1174 #define SUBLANG_SPANISH_CHILE                     0x0d
   1175 #define SUBLANG_SPANISH_URUGUAY                   0x0e
   1176 #define SUBLANG_SPANISH_PARAGUAY                  0x0f
   1177 #define SUBLANG_SPANISH_BOLIVIA                   0x10
   1178 #define SUBLANG_SPANISH_EL_SALVADOR               0x11
   1179 #define SUBLANG_SPANISH_HONDURAS                  0x12
   1180 #define SUBLANG_SPANISH_NICARAGUA                 0x13
   1181 #define SUBLANG_SPANISH_PUERTO_RICO               0x14
   1182 #define SUBLANG_SPANISH_US                        0x15
   1183 #define SUBLANG_SWAHILI_KENYA                     0x01
   1184 #if (WINVER >= 0x0600)
   1185 #define SUBLANG_SWEDISH_SWEDEN                    0x01
   1186 #endif /* WINVER >= 0x0600 */
   1187 #define SUBLANG_SWEDISH                           0x01
   1188 #define SUBLANG_SWEDISH_FINLAND                   0x02
   1189 #define SUBLANG_SYRIAC                            0x01
   1190 #define SUBLANG_SYRIAC_SYRIA            SUBLANG_SYRIAC		/* SUBLANG_SYRIAC_SYRIA is what MSDN mentions */
   1191 #define SUBLANG_TAJIK_TAJIKISTAN                  0x01
   1192 #define SUBLANG_TAMAZIGHT_ALGERIA_LATIN           0x02
   1193 #define SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH        0x04
   1194 #define SUBLANG_TAMIL_INDIA                       0x01
   1195 #define SUBLANG_TAMIL_SRI_LANKA                   0x02
   1196 #define SUBLANG_TATAR_RUSSIA                      0x01
   1197 #define SUBLANG_TELUGU_INDIA                      0x01
   1198 #define SUBLANG_THAI_THAILAND                     0x01
   1199 #define SUBLANG_TIBETAN_PRC                       0x01
   1200 #define SUBLANG_TIBETAN_BHUTAN                    0x02
   1201 #define SUBLANG_TIGRIGNA_ERITREA                  0x02
   1202 #define SUBLANG_TIGRINYA_ERITREA                  0x02
   1203 #define SUBLANG_TIGRINYA_ETHIOPIA                 0x01
   1204 #define SUBLANG_TSWANA_BOTSWANA                   0x02
   1205 #define SUBLANG_TSWANA_SOUTH_AFRICA               0x01
   1206 #define SUBLANG_TURKISH_TURKEY                    0x01
   1207 #define SUBLANG_TURKMEN_TURKMENISTAN              0x01
   1208 #define SUBLANG_UIGHUR_PRC                        0x01
   1209 #define SUBLANG_UKRAINIAN_UKRAINE                 0x01
   1210 #define SUBLANG_UPPER_SORBIAN_GERMANY             0x01
   1211 #define SUBLANG_URDU_PAKISTAN                     0x01
   1212 #define SUBLANG_URDU_INDIA                        0x02
   1213 #define SUBLANG_UZBEK_LATIN                       0x01
   1214 #define SUBLANG_UZBEK_CYRILLIC                    0x02
   1215 #define SUBLANG_VALENCIAN_VALENCIA                0x02
   1216 #define SUBLANG_VIETNAMESE_VIETNAM                0x01
   1217 #define SUBLANG_WELSH_UNITED_KINGDOM              0x01
   1218 #define SUBLANG_WOLOF_SENEGAL                     0x01
   1219 #define SUBLANG_YORUBA_NIGERIA                    0x01
   1220 #define SUBLANG_XHOSA_SOUTH_AFRICA                0x01
   1221 #define SUBLANG_YAKUT_RUSSIA                      0x01
   1222 #define SUBLANG_YI_PRC                            0x01
   1223 #define SUBLANG_ZULU_SOUTH_AFRICA                 0x01
   1224 
   1225 #define SORT_DEFAULT                              0x0
   1226 #define SORT_INVARIANT_MATH                       0x1
   1227 
   1228 #define SORT_JAPANESE_XJIS                        0x0
   1229 #define SORT_JAPANESE_UNICODE                     0x1
   1230 #define SORT_JAPANESE_RADICALSTROKE               0x4
   1231 
   1232 #define SORT_CHINESE_BIG5                         0x0
   1233 #define SORT_CHINESE_PRCP                         0x0
   1234 #define SORT_CHINESE_UNICODE                      0x1
   1235 #define SORT_CHINESE_PRC                          0x2
   1236 #define SORT_CHINESE_BOPOMOFO                     0x3
   1237 #define SORT_CHINESE_RADICALSTROKE		  0x4
   1238 
   1239 #define SORT_KOREAN_KSC                           0x0
   1240 #define SORT_KOREAN_UNICODE                       0x1
   1241 
   1242 #define SORT_GERMAN_PHONE_BOOK                    0x1
   1243 
   1244 #define SORT_HUNGARIAN_DEFAULT                    0x0
   1245 #define SORT_HUNGARIAN_TECHNICAL                  0x1
   1246 
   1247 #define SORT_GEORGIAN_TRADITIONAL                 0x0
   1248 #define SORT_GEORGIAN_MODERN                      0x1
   1249 
   1250 #define MAKELANGID(p,s) ((((WORD)(s)) << 10) | (WORD)(p))
   1251 #define PRIMARYLANGID(lgid) ((WORD)(lgid) & 0x3ff)
   1252 #define SUBLANGID(lgid) ((WORD)(lgid) >> 10)
   1253 
   1254 #define NLS_VALID_LOCALE_MASK 0x000fffff
   1255 
   1256 #define MAKELCID(lgid,srtid) ((DWORD)((((DWORD)((WORD)(srtid))) << 16) | ((DWORD)((WORD)(lgid)))))
   1257 #define MAKESORTLCID(lgid,srtid,ver) ((DWORD)((MAKELCID(lgid,srtid)) | (((DWORD)((WORD)(ver))) << 20)))
   1258 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
   1259 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0xf))
   1260 #define SORTVERSIONFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 20) & 0xf))
   1261 
   1262 #define LOCALE_NAME_MAX_LENGTH 85
   1263 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT))
   1264 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT))
   1265 
   1266 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT,SORT_DEFAULT))
   1267 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT,SORT_DEFAULT))
   1268 
   1269 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
   1270 
   1271 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT))
   1272 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT))
   1273 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT), SORT_DEFAULT))
   1274 
   1275 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
   1276 
   1277 #define UNREFERENCED_PARAMETER(P) {(P) = (P);}
   1278 #define UNREFERENCED_LOCAL_VARIABLE(V) {(V) = (V);}
   1279 #define DBG_UNREFERENCED_PARAMETER(P) (P)
   1280 #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
   1281 
   1282 #define DEFAULT_UNREACHABLE
   1283 
   1284 #ifndef UMDF_USING_NTSTATUS
   1285 #ifndef WIN32_NO_STATUS
   1286 #define STATUS_WAIT_0 ((DWORD)0x00000000)
   1287 #define STATUS_ABANDONED_WAIT_0 ((DWORD)0x00000080)
   1288 #define STATUS_USER_APC ((DWORD)0x000000C0)
   1289 #define STATUS_TIMEOUT ((DWORD)0x00000102)
   1290 #define STATUS_PENDING ((DWORD)0x00000103)
   1291 #define DBG_EXCEPTION_HANDLED ((DWORD)0x00010001)
   1292 #define DBG_CONTINUE ((DWORD)0x00010002)
   1293 #define STATUS_SEGMENT_NOTIFICATION ((DWORD)0x40000005)
   1294 #define STATUS_FATAL_APP_EXIT ((DWORD)0x40000015)
   1295 #define DBG_TERMINATE_THREAD ((DWORD)0x40010003)
   1296 #define DBG_TERMINATE_PROCESS ((DWORD)0x40010004)
   1297 #define DBG_CONTROL_C ((DWORD)0x40010005)
   1298 #define DBG_PRINTEXCEPTION_C ((DWORD)0x40010006)
   1299 #define DBG_RIPEXCEPTION ((DWORD)0x40010007)
   1300 #define DBG_CONTROL_BREAK ((DWORD)0x40010008)
   1301 #define DBG_COMMAND_EXCEPTION ((DWORD)0x40010009)
   1302 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD)0x80000001)
   1303 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD)0x80000002)
   1304 #define STATUS_BREAKPOINT ((DWORD)0x80000003)
   1305 #define STATUS_SINGLE_STEP ((DWORD)0x80000004)
   1306 #define STATUS_LONGJUMP ((DWORD)0x80000026)
   1307 #define STATUS_UNWIND_CONSOLIDATE ((DWORD)0x80000029)
   1308 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD)0x80010001)
   1309 #define STATUS_ACCESS_VIOLATION ((DWORD)0xC0000005)
   1310 #define STATUS_IN_PAGE_ERROR ((DWORD)0xC0000006)
   1311 #define STATUS_INVALID_HANDLE ((DWORD)0xC0000008)
   1312 #define STATUS_INVALID_PARAMETER ((DWORD)0xC000000D)
   1313 #define STATUS_NO_MEMORY ((DWORD)0xC0000017)
   1314 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD)0xC000001D)
   1315 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD)0xC0000025)
   1316 #define STATUS_INVALID_DISPOSITION ((DWORD)0xC0000026)
   1317 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD)0xC000008C)
   1318 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD)0xC000008D)
   1319 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD)0xC000008E)
   1320 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD)0xC000008F)
   1321 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD)0xC0000090)
   1322 #define STATUS_FLOAT_OVERFLOW ((DWORD)0xC0000091)
   1323 #define STATUS_FLOAT_STACK_CHECK ((DWORD)0xC0000092)
   1324 #define STATUS_FLOAT_UNDERFLOW ((DWORD)0xC0000093)
   1325 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD)0xC0000094)
   1326 #define STATUS_INTEGER_OVERFLOW ((DWORD)0xC0000095)
   1327 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD)0xC0000096)
   1328 #define STATUS_STACK_OVERFLOW ((DWORD)0xC00000FD)
   1329 #define STATUS_DLL_NOT_FOUND ((DWORD)0xC0000135)
   1330 #define STATUS_ORDINAL_NOT_FOUND ((DWORD)0xC0000138)
   1331 #define STATUS_ENTRYPOINT_NOT_FOUND ((DWORD)0xC0000139)
   1332 #define STATUS_CONTROL_C_EXIT ((DWORD)0xC000013A)
   1333 #define STATUS_DLL_INIT_FAILED ((DWORD)0xC0000142)
   1334 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD)0xC00002B4)
   1335 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD)0xC00002B5)
   1336 #define STATUS_REG_NAT_CONSUMPTION ((DWORD)0xC00002C9)
   1337 #define STATUS_STACK_BUFFER_OVERRUN ((DWORD)0xC0000409)
   1338 #define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD)0xC0000417)
   1339 #define STATUS_ASSERTION_FAILURE ((DWORD)0xC0000420)
   1340 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD)0xC015000F)
   1341 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD)0xC0150010)
   1342 #endif
   1343 #endif
   1344 
   1345 #define MAXIMUM_WAIT_OBJECTS 64
   1346 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
   1347 
   1348   typedef ULONG_PTR KSPIN_LOCK;
   1349   typedef KSPIN_LOCK *PKSPIN_LOCK;
   1350 
   1351     typedef struct DECLSPEC_ALIGN (16) _M128A {
   1352       ULONGLONG Low;
   1353       LONGLONG High;
   1354     } M128A,*PM128A;
   1355 
   1356     typedef struct DECLSPEC_ALIGN (16) _XSAVE_FORMAT {
   1357       WORD ControlWord;
   1358       WORD StatusWord;
   1359       BYTE TagWord;
   1360       BYTE Reserved1;
   1361       WORD ErrorOpcode;
   1362       DWORD ErrorOffset;
   1363       WORD ErrorSelector;
   1364       WORD Reserved2;
   1365       DWORD DataOffset;
   1366       WORD DataSelector;
   1367       WORD Reserved3;
   1368       DWORD MxCsr;
   1369       DWORD MxCsr_Mask;
   1370       M128A FloatRegisters[8];
   1371 #ifdef _WIN64
   1372       M128A XmmRegisters[16];
   1373       BYTE Reserved4[96];
   1374 #else
   1375       M128A XmmRegisters[8];
   1376       BYTE Reserved4[220];
   1377       DWORD Cr0NpxState;
   1378 #endif
   1379     } XSAVE_FORMAT,*PXSAVE_FORMAT;
   1380 
   1381     typedef struct DECLSPEC_ALIGN (8) _XSAVE_AREA_HEADER {
   1382       DWORD64 Mask;
   1383       DWORD64 Reserved[7];
   1384     } XSAVE_AREA_HEADER,*PXSAVE_AREA_HEADER;
   1385 
   1386     typedef struct DECLSPEC_ALIGN (16) _XSAVE_AREA {
   1387       XSAVE_FORMAT LegacyState;
   1388       XSAVE_AREA_HEADER Header;
   1389     } XSAVE_AREA,*PXSAVE_AREA;
   1390 
   1391     typedef struct _XSTATE_CONTEXT {
   1392       DWORD64 Mask;
   1393       DWORD Length;
   1394       DWORD Reserved1;
   1395       PXSAVE_AREA Area;
   1396 #if defined (__i386__)
   1397       DWORD Reserved2;
   1398 #endif
   1399       PVOID Buffer;
   1400 #if defined (__i386__)
   1401       DWORD Reserved3;
   1402 #endif
   1403     } XSTATE_CONTEXT,*PXSTATE_CONTEXT;
   1404 
   1405     typedef struct _SCOPE_TABLE_AMD64 {
   1406       DWORD Count;
   1407       struct {
   1408 	DWORD BeginAddress;
   1409 	DWORD EndAddress;
   1410 	DWORD HandlerAddress;
   1411 	DWORD JumpTarget;
   1412       } ScopeRecord[1];
   1413     } SCOPE_TABLE_AMD64,*PSCOPE_TABLE_AMD64;
   1414 
   1415 #ifdef _AMD64_
   1416 
   1417 #if defined(__x86_64) && !defined(RC_INVOKED)
   1418 
   1419 #ifdef __cplusplus
   1420   extern "C" {
   1421 #endif
   1422 
   1423 #define BitTest _bittest
   1424 #define BitTestAndComplement _bittestandcomplement
   1425 #define BitTestAndSet _bittestandset
   1426 #define BitTestAndReset _bittestandreset
   1427 #define BitTest64 _bittest64
   1428 #define BitTestAndComplement64 _bittestandcomplement64
   1429 #define BitTestAndSet64 _bittestandset64
   1430 #define BitTestAndReset64 _bittestandreset64
   1431 
   1432     /* BOOLEAN _bittest(LONG const *Base,LONG Offset);  moved to psdk_inc/intrin-impl.h */
   1433     /* BOOLEAN _bittestandcomplement(LONG *Base,LONG Offset); moved to psdk_inc/intrin-impl.h */
   1434     /* BOOLEAN _bittestandset(LONG *Base,LONG Offset); moved to psdk_inc/intrin-impl.h */
   1435     /* BOOLEAN _bittestandreset(LONG *Base,LONG Offset); moved to psdk_inc/intrin-impl.h */
   1436     /* BOOLEAN _bittest64(LONG64 const *Base,LONG64 Offset); moved to psdk_inc/intrin-impl.h */
   1437     /* BOOLEAN _bittestandcomplement64(LONG64 *Base,LONG64 Offset); moved to psdk_inc/intrin-impl.h */
   1438     /* BOOLEAN _bittestandset64(LONG64 *Base,LONG64 Offset); moved to psdk_inc/intrin-impl.h */
   1439     /* BOOLEAN _bittestandreset64(LONG64 *Base,LONG64 Offset); moved to psdk_inc/intrin-impl.h */
   1440 
   1441 #define BitScanForward _BitScanForward
   1442 #define BitScanReverse _BitScanReverse
   1443 #define BitScanForward64 _BitScanForward64
   1444 #define BitScanReverse64 _BitScanReverse64
   1445 
   1446     /* BOOLEAN _BitScanForward(DWORD *Index,DWORD Mask); moved to psdk_inc/intrin-impl.h */
   1447     /* BOOLEAN _BitScanReverse(DWORD *Index,DWORD Mask); moved to psdk_inc/intrin-impl.h */
   1448     /* BOOLEAN _BitScanForward64(DWORD *Index,DWORD64 Mask); moved to psdk_inc/intrin-impl.h */
   1449     /* BOOLEAN _BitScanReverse64(DWORD *Index,DWORD64 Mask); moved to psdk_inc/intrin-impl.h */
   1450 
   1451 #define InterlockedIncrement16 _InterlockedIncrement16
   1452 #define InterlockedDecrement16 _InterlockedDecrement16
   1453 #define InterlockedCompareExchange16 _InterlockedCompareExchange16
   1454 
   1455 #define InterlockedAnd _InterlockedAnd
   1456 #define InterlockedOr _InterlockedOr
   1457 #define InterlockedXor _InterlockedXor
   1458 #define InterlockedIncrement _InterlockedIncrement
   1459 #define InterlockedIncrementAcquire InterlockedIncrement
   1460 #define InterlockedIncrementRelease InterlockedIncrement
   1461 #define InterlockedDecrement _InterlockedDecrement
   1462 #define InterlockedDecrementAcquire InterlockedDecrement
   1463 #define InterlockedDecrementRelease InterlockedDecrement
   1464 #define InterlockedAdd _InterlockedAdd
   1465 #define InterlockedExchange _InterlockedExchange
   1466 #define InterlockedExchangeAdd _InterlockedExchangeAdd
   1467 #define InterlockedCompareExchange _InterlockedCompareExchange
   1468 #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
   1469 #define InterlockedCompareExchangeRelease InterlockedCompareExchange
   1470 
   1471 #define InterlockedAnd64 _InterlockedAnd64
   1472 #define InterlockedAndAffinity InterlockedAnd64
   1473 #define InterlockedOr64 _InterlockedOr64
   1474 #define InterlockedOrAffinity InterlockedOr64
   1475 #define InterlockedXor64 _InterlockedXor64
   1476 #define InterlockedIncrement64 _InterlockedIncrement64
   1477 #define InterlockedDecrement64 _InterlockedDecrement64
   1478 #define InterlockedAdd64 _InterlockedAdd64
   1479 #define InterlockedExchange64 _InterlockedExchange64
   1480 #define InterlockedExchangeAcquire64 InterlockedExchange64
   1481 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
   1482 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
   1483 #define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
   1484 #define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
   1485 
   1486 #define InterlockedExchangePointer _InterlockedExchangePointer
   1487 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
   1488 #define InterlockedCompareExchangePointerAcquire _InterlockedCompareExchangePointer
   1489 #define InterlockedCompareExchangePointerRelease _InterlockedCompareExchangePointer
   1490 
   1491 #define InterlockedExchangeAddSizeT(a,b) InterlockedExchangeAdd64((LONG64 *)a,b)
   1492 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONG64 *)a)
   1493 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONG64 *)a)
   1494 
   1495     /* SHORT InterlockedIncrement16(SHORT volatile *Addend); moved to psdk_inc/intrin-impl.h */
   1496     /* SHORT InterlockedDecrement16(SHORT volatile *Addend); moved to psdk_inc/intrin-impl.h */
   1497     /* SHORT InterlockedCompareExchange16(SHORT volatile *Destination,SHORT ExChange,SHORT Comperand); moved to psdk_inc/intrin-impl.h */
   1498     /* LONG InterlockedIncrement(LONG volatile *Addend); moved to psdk_inc/intrin-impl.h */
   1499     /* LONG InterlockedDecrement(LONG volatile *Addend); moved to psdk_inc/intrin-impl.h */
   1500     /* LONG InterlockedExchange(LONG volatile *Target,LONG Value); moved to psdk_inc/intrin-impl.h */
   1501 
   1502     /* LONG InterlockedExchangeAdd(LONG volatile *Addend,LONG Value); moved to psdk_inc/intrin-impl.h */
   1503     /* LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange,LONG Comperand); moved to psdk_inc/intrin-impl.h */
   1504     /* LONG InterlockedAdd(LONG volatile *Addend,LONG Value); moved to psdk_inc/intrin-impl.h */
   1505     /* LONG64 InterlockedIncrement64(LONG64 volatile *Addend); moved to psdk_inc/intrin-impl.h */
   1506     /* LONG64 InterlockedDecrement64(LONG64 volatile *Addend); moved to psdk_inc/intrin-impl.h */
   1507     /* LONG64 InterlockedExchange64(LONG64 volatile *Target,LONG64 Value); moved to psdk_inc/intrin-impl.h */
   1508     /* LONG64 InterlockedExchangeAdd64(LONG64 volatile *Addend,LONG64 Value); moved to psdk_inc/intrin-impl.h */
   1509     /* LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value); moved to psdk_inc/intrin-impl.h */
   1510     /* LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination,LONG64 ExChange,LONG64 Comperand); moved to psdk_inc/intrin-impl.h */
   1511     /* PVOID InterlockedCompareExchangePointer(PVOID volatile *Destination,PVOID ExChange,PVOID Comperand); moved to psdk_inc/intrin-impl.h */
   1512     /* PVOID InterlockedExchangePointer(PVOID volatile *Target,PVOID Value); moved to psdk_inc/intrin-impl.h */
   1513 
   1514 #define CacheLineFlush(Address) _mm_clflush(Address)
   1515 
   1516 # if defined(__cplusplus)
   1517 extern "C" {
   1518 # endif
   1519 # include <x86intrin.h>
   1520 # if defined(__cplusplus)
   1521 }
   1522 # endif
   1523 
   1524 #define FastFence __faststorefence
   1525 #define LoadFence _mm_lfence
   1526 #define MemoryFence _mm_mfence
   1527 #define StoreFence _mm_sfence
   1528 
   1529 #define YieldProcessor _mm_pause
   1530 #define MemoryBarrier _mm_mfence
   1531 #define PreFetchCacheLine(l,a) _mm_prefetch((CHAR CONST *) a,l)
   1532 #define PrefetchForWrite(p) _m_prefetchw(p)
   1533 #define ReadForWriteAccess(p) (_m_prefetchw(p),*(p))
   1534 
   1535 #define PF_TEMPORAL_LEVEL_1 _MM_HINT_T0
   1536 #define PF_TEMPORAL_LEVEL_2 _MM_HINT_T1
   1537 #define PF_TEMPORAL_LEVEL_3 _MM_HINT_T2
   1538 #define PF_NON_TEMPORAL_LEVEL_ALL _MM_HINT_NTA
   1539 
   1540 #define ReadMxCsr _mm_getcsr
   1541 #define WriteMxCsr _mm_setcsr
   1542 
   1543 #define DbgRaiseAssertionFailure __int2c
   1544 #define GetCallersEflags() __getcallerseflags()
   1545 
   1546     unsigned __int32 __getcallerseflags(VOID);
   1547 
   1548 #define GetSegmentLimit __segmentlimit
   1549 
   1550     DWORD __segmentlimit(DWORD Selector);
   1551 
   1552 #define ReadTimeStampCounter() __rdtsc()
   1553 
   1554     /* VOID __movsb(PBYTE Destination,BYTE const *Source,SIZE_T Count); moved to psdk_inc/intrin-impl.h */
   1555     /* VOID __movsw(PWORD Destination,WORD const *Source,SIZE_T Count); moved to psdk_inc/intrin-impl.h */
   1556     /* VOID __movsd(PDWORD Destination,DWORD const *Source,SIZE_T Count); moved to psdk_inc/intrin-impl.h */
   1557     /* VOID __movsq(PDWORD64 Destination,DWORD64 const *Source,SIZE_T Count); moved to psdk_inc/intrin-impl.h */
   1558 
   1559 #define MultiplyHigh __mulh
   1560 #define UnsignedMultiplyHigh __umulh
   1561 
   1562     LONGLONG MultiplyHigh(LONGLONG Multiplier,LONGLONG Multiplicand);
   1563     ULONGLONG UnsignedMultiplyHigh(ULONGLONG Multiplier,ULONGLONG Multiplicand);
   1564 
   1565 #define ShiftLeft128 __shiftleft128
   1566 #define ShiftRight128 __shiftright128
   1567 
   1568     DWORD64 ShiftLeft128(DWORD64 LowPart,DWORD64 HighPart,BYTE Shift);
   1569     DWORD64 ShiftRight128(DWORD64 LowPart,DWORD64 HighPart,BYTE Shift);
   1570 
   1571 #define Multiply128 _mul128
   1572 
   1573     LONG64 Multiply128(LONG64 Multiplier,LONG64 Multiplicand,LONG64 *HighProduct);
   1574 
   1575 #define UnsignedMultiply128 _umul128
   1576 
   1577     DWORD64 UnsignedMultiply128(DWORD64 Multiplier,DWORD64 Multiplicand,DWORD64 *HighProduct);
   1578 
   1579     LONG64 MultiplyExtract128(LONG64 Multiplier,LONG64 Multiplicand,BYTE Shift);
   1580     DWORD64 UnsignedMultiplyExtract128(DWORD64 Multiplier,DWORD64 Multiplicand,BYTE Shift);
   1581 
   1582 #ifndef __CRT__NO_INLINE
   1583     __CRT_INLINE LONG64 MultiplyExtract128(LONG64 Multiplier,LONG64 Multiplicand,BYTE Shift) {
   1584       LONG64 extractedProduct;
   1585       LONG64 highProduct;
   1586       LONG64 lowProduct;
   1587       lowProduct = Multiply128(Multiplier,Multiplicand,&highProduct);
   1588       extractedProduct = (LONG64)ShiftRight128((LONG64)lowProduct,(LONG64)highProduct,Shift);
   1589       return extractedProduct;
   1590     }
   1591 
   1592     __CRT_INLINE DWORD64 UnsignedMultiplyExtract128(DWORD64 Multiplier,DWORD64 Multiplicand,BYTE Shift) {
   1593       DWORD64 extractedProduct;
   1594       DWORD64 highProduct;
   1595       DWORD64 lowProduct;
   1596       lowProduct = UnsignedMultiply128(Multiplier,Multiplicand,&highProduct);
   1597       extractedProduct = ShiftRight128(lowProduct,highProduct,Shift);
   1598       return extractedProduct;
   1599     }
   1600 #endif
   1601 
   1602     /* unsigned char __readgsbyte(unsigned __LONG32 Offset); moved to psdk_inc/intrin-impl.h */
   1603     /* unsigned short __readgsword(unsigned __LONG32 Offset); moved to psdk_inc/intrin-impl.h */
   1604     /* unsigned __LONG32 __readgsdword(unsigned __LONG32 Offset); moved to psdk_inc/intrin-impl.h */
   1605     /* __MINGW_EXTENSION unsigned __int64 __readgsqword(unsigned __LONG32 Offset); moved to psdk_inc/intrin-impl.h */
   1606 
   1607     /* void __writegsbyte(unsigned __LONG32 Offset,unsigned char Data); moved to psdk_inc/intrin-impl.h */
   1608     /* void __writegsword(unsigned __LONG32 Offset,unsigned short Data); moved to psdk_inc/intrin-impl.h */
   1609     /* void __writegsdword(unsigned __LONG32 Offset,unsigned __LONG32 Data); moved to psdk_inc/intrin-impl.h */
   1610 
   1611 #ifdef __cplusplus
   1612   }
   1613 #endif
   1614 #endif /* defined(__x86_64) && !defined(RC_INVOKED) */
   1615 
   1616 #define EXCEPTION_READ_FAULT 0
   1617 #define EXCEPTION_WRITE_FAULT 1
   1618 #define EXCEPTION_EXECUTE_FAULT 8
   1619 
   1620 #if !defined(RC_INVOKED)
   1621 
   1622 #define CONTEXT_AMD64 0x100000
   1623 
   1624 #define CONTEXT_CONTROL (CONTEXT_AMD64 | __MSABI_LONG(0x1))
   1625 #define CONTEXT_INTEGER (CONTEXT_AMD64 | __MSABI_LONG(0x2))
   1626 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | __MSABI_LONG(0x4))
   1627 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | __MSABI_LONG(0x8))
   1628 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | __MSABI_LONG(0x10))
   1629 
   1630 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
   1631 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
   1632 
   1633 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
   1634 #define CONTEXT_SERVICE_ACTIVE 0x10000000
   1635 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
   1636 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
   1637 #endif /* !defined(RC_INVOKED) */
   1638 
   1639 #define INITIAL_MXCSR 0x1f80
   1640 #define INITIAL_FPCSR 0x027f
   1641 
   1642   typedef struct _XMM_SAVE_AREA32 {
   1643     WORD ControlWord;
   1644     WORD StatusWord;
   1645     BYTE TagWord;
   1646     BYTE Reserved1;
   1647     WORD ErrorOpcode;
   1648     DWORD ErrorOffset;
   1649     WORD ErrorSelector;
   1650     WORD Reserved2;
   1651     DWORD DataOffset;
   1652     WORD DataSelector;
   1653     WORD Reserved3;
   1654     DWORD MxCsr;
   1655     DWORD MxCsr_Mask;
   1656     M128A FloatRegisters[8];
   1657     M128A XmmRegisters[16];
   1658     BYTE Reserved4[96];
   1659   } XMM_SAVE_AREA32,*PXMM_SAVE_AREA32;
   1660 
   1661 #define LEGACY_SAVE_AREA_LENGTH sizeof(XMM_SAVE_AREA32)
   1662 
   1663   typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
   1664     DWORD64 P1Home;
   1665     DWORD64 P2Home;
   1666     DWORD64 P3Home;
   1667     DWORD64 P4Home;
   1668     DWORD64 P5Home;
   1669     DWORD64 P6Home;
   1670     DWORD ContextFlags;
   1671     DWORD MxCsr;
   1672     WORD SegCs;
   1673     WORD SegDs;
   1674     WORD SegEs;
   1675     WORD SegFs;
   1676     WORD SegGs;
   1677     WORD SegSs;
   1678     DWORD EFlags;
   1679     DWORD64 Dr0;
   1680     DWORD64 Dr1;
   1681     DWORD64 Dr2;
   1682     DWORD64 Dr3;
   1683     DWORD64 Dr6;
   1684     DWORD64 Dr7;
   1685     DWORD64 Rax;
   1686     DWORD64 Rcx;
   1687     DWORD64 Rdx;
   1688     DWORD64 Rbx;
   1689     DWORD64 Rsp;
   1690     DWORD64 Rbp;
   1691     DWORD64 Rsi;
   1692     DWORD64 Rdi;
   1693     DWORD64 R8;
   1694     DWORD64 R9;
   1695     DWORD64 R10;
   1696     DWORD64 R11;
   1697     DWORD64 R12;
   1698     DWORD64 R13;
   1699     DWORD64 R14;
   1700     DWORD64 R15;
   1701     DWORD64 Rip;
   1702     __C89_NAMELESS union {
   1703       XMM_SAVE_AREA32 FltSave;
   1704       XMM_SAVE_AREA32 FloatSave;
   1705       __C89_NAMELESS struct {
   1706 	M128A Header[2];
   1707 	M128A Legacy[8];
   1708 	M128A Xmm0;
   1709 	M128A Xmm1;
   1710 	M128A Xmm2;
   1711 	M128A Xmm3;
   1712 	M128A Xmm4;
   1713 	M128A Xmm5;
   1714 	M128A Xmm6;
   1715 	M128A Xmm7;
   1716 	M128A Xmm8;
   1717 	M128A Xmm9;
   1718 	M128A Xmm10;
   1719 	M128A Xmm11;
   1720 	M128A Xmm12;
   1721 	M128A Xmm13;
   1722 	M128A Xmm14;
   1723 	M128A Xmm15;
   1724       };
   1725     };
   1726     M128A VectorRegister[26];
   1727     DWORD64 VectorControl;
   1728     DWORD64 DebugControl;
   1729     DWORD64 LastBranchToRip;
   1730     DWORD64 LastBranchFromRip;
   1731     DWORD64 LastExceptionToRip;
   1732     DWORD64 LastExceptionFromRip;
   1733   } CONTEXT,*PCONTEXT;
   1734 
   1735 #define RUNTIME_FUNCTION_INDIRECT 0x1
   1736 
   1737   typedef struct _RUNTIME_FUNCTION {
   1738     DWORD BeginAddress;
   1739     DWORD EndAddress;
   1740     DWORD UnwindData;
   1741   } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
   1742 
   1743   typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
   1744   typedef DWORD (*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)(HANDLE Process,PVOID TableAddress,PDWORD Entries,PRUNTIME_FUNCTION *Functions);
   1745 
   1746 #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
   1747 
   1748 #define UNW_FLAG_NHANDLER   0x00
   1749 #define UNW_FLAG_EHANDLER   0x01
   1750 #define UNW_FLAG_UHANDLER   0x02
   1751 #define UNW_FLAG_CHAININFO  0x04
   1752 
   1753 #endif /* end of _AMD64_ */
   1754 
   1755 
   1756 #ifdef _ARM_
   1757 
   1758 #if defined(__arm__) && !defined(RC_INVOKED)
   1759 
   1760 #ifdef __cplusplus
   1761   extern "C" {
   1762 #endif
   1763 
   1764 #define BitTest _bittest
   1765 #define BitTestAndComplement _bittestandcomplement
   1766 #define BitTestAndSet _bittestandset
   1767 #define BitTestAndReset _bittestandreset
   1768 
   1769 #define BitScanForward _BitScanForward
   1770 #define BitScanReverse _BitScanReverse
   1771 
   1772 #define InterlockedIncrement16 _InterlockedIncrement16
   1773 #define InterlockedDecrement16 _InterlockedDecrement16
   1774 #define InterlockedCompareExchange16 _InterlockedCompareExchange16
   1775 
   1776 #define InterlockedAnd _InterlockedAnd
   1777 #define InterlockedOr _InterlockedOr
   1778 #define InterlockedXor _InterlockedXor
   1779 #define InterlockedIncrement _InterlockedIncrement
   1780 #define InterlockedIncrementAcquire InterlockedIncrement
   1781 #define InterlockedIncrementRelease InterlockedIncrement
   1782 #define InterlockedDecrement _InterlockedDecrement
   1783 #define InterlockedDecrementAcquire InterlockedDecrement
   1784 #define InterlockedDecrementRelease InterlockedDecrement
   1785 #define InterlockedAdd _InterlockedAdd
   1786 #define InterlockedExchange _InterlockedExchange
   1787 #define InterlockedExchangeAdd _InterlockedExchangeAdd
   1788 #define InterlockedCompareExchange _InterlockedCompareExchange
   1789 #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
   1790 #define InterlockedCompareExchangeRelease InterlockedCompareExchange
   1791 
   1792 #define InterlockedAnd64 _InterlockedAnd64
   1793 #define InterlockedAndAffinity InterlockedAnd64
   1794 #define InterlockedOr64 _InterlockedOr64
   1795 #define InterlockedOrAffinity InterlockedOr64
   1796 #define InterlockedXor64 _InterlockedXor64
   1797 #define InterlockedIncrement64 _InterlockedIncrement64
   1798 #define InterlockedDecrement64 _InterlockedDecrement64
   1799 #define InterlockedAdd64 _InterlockedAdd64
   1800 #define InterlockedExchange64 _InterlockedExchange64
   1801 #define InterlockedExchangeAcquire64 InterlockedExchange64
   1802 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
   1803 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
   1804 #define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
   1805 #define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
   1806 
   1807 #define InterlockedExchangePointer _InterlockedExchangePointer
   1808 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
   1809 #define InterlockedCompareExchangePointerAcquire _InterlockedCompareExchangePointer
   1810 #define InterlockedCompareExchangePointerRelease _InterlockedCompareExchangePointer
   1811 
   1812 #ifdef __cplusplus
   1813   }
   1814 #endif
   1815 #endif /* defined(__arm__) && !defined(RC_INVOKED) */
   1816 
   1817 #define EXCEPTION_READ_FAULT    0
   1818 #define EXCEPTION_WRITE_FAULT   1
   1819 #define EXCEPTION_EXECUTE_FAULT 8
   1820 
   1821 #if !defined(RC_INVOKED)
   1822 
   1823 #define CONTEXT_ARM    0x0200000
   1824 
   1825 #define CONTEXT_CONTROL         (CONTEXT_ARM | 0x00000001)
   1826 #define CONTEXT_INTEGER         (CONTEXT_ARM | 0x00000002)
   1827 #define CONTEXT_FLOATING_POINT  (CONTEXT_ARM | 0x00000004)
   1828 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
   1829 
   1830 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
   1831 
   1832 #define CONTEXT_ALL  (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
   1833 
   1834 #define CONTEXT_EXCEPTION_ACTIVE    0x08000000
   1835 #define CONTEXT_SERVICE_ACTIVE      0x10000000
   1836 #define CONTEXT_EXCEPTION_REQUEST   0x40000000
   1837 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
   1838 
   1839 #define CONTEXT_UNWOUND_TO_CALL     0x20000000
   1840 
   1841 #endif /* !defined(RC_INVOKED) */
   1842 
   1843 #define INITIAL_CPSR  0x10
   1844 #define INITIAL_FPSCR 0x00
   1845 
   1846 #define ARM_MAX_BREAKPOINTS 8
   1847 #define ARM_MAX_WATCHPOINTS 1
   1848 
   1849 
   1850   typedef struct _NEON128 {
   1851     ULONGLONG Low;
   1852     LONGLONG High;
   1853   } NEON128, *PNEON128;
   1854 
   1855   typedef struct _CONTEXT {
   1856     DWORD ContextFlags;
   1857 
   1858     DWORD R0;
   1859     DWORD R1;
   1860     DWORD R2;
   1861     DWORD R3;
   1862     DWORD R4;
   1863     DWORD R5;
   1864     DWORD R6;
   1865     DWORD R7;
   1866     DWORD R8;
   1867     DWORD R9;
   1868     DWORD R10;
   1869     DWORD R11;
   1870     DWORD R12;
   1871 
   1872     DWORD Sp;
   1873     DWORD Lr;
   1874     DWORD Pc;
   1875     DWORD Cpsr;
   1876 
   1877     DWORD Fpscr;
   1878     DWORD Padding;
   1879     union {
   1880         NEON128   Q[16];
   1881         ULONGLONG D[32];
   1882         DWORD     S[32];
   1883     } DUMMYUNIONNAME;
   1884 
   1885     DWORD Bvr[ARM_MAX_BREAKPOINTS];
   1886     DWORD Bcr[ARM_MAX_BREAKPOINTS];
   1887     DWORD Wvr[ARM_MAX_WATCHPOINTS];
   1888     DWORD Wcr[ARM_MAX_WATCHPOINTS];
   1889 
   1890     DWORD Padding2[2];
   1891   } CONTEXT, *PCONTEXT;
   1892 
   1893   typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
   1894   typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
   1895 
   1896 #define UNW_FLAG_NHANDLER   0x0
   1897 #define UNW_FLAG_EHANDLER   0x1
   1898 #define UNW_FLAG_UHANDLER   0x2
   1899 
   1900 #define UNWIND_HISTORY_TABLE_SIZE 12
   1901 
   1902   typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
   1903     DWORD ImageBase;
   1904     PRUNTIME_FUNCTION FunctionEntry;
   1905   } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
   1906 
   1907   typedef struct _UNWIND_HISTORY_TABLE {
   1908     DWORD Count;
   1909     BYTE  LocalHint;
   1910     BYTE  GlobalHint;
   1911     BYTE  Search;
   1912     BYTE  Once;
   1913     DWORD LowAddress;
   1914     DWORD HighAddress;
   1915     UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
   1916   } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
   1917 
   1918   typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
   1919     PDWORD R4;
   1920     PDWORD R5;
   1921     PDWORD R6;
   1922     PDWORD R7;
   1923     PDWORD R8;
   1924     PDWORD R9;
   1925     PDWORD R10;
   1926     PDWORD R11;
   1927     PDWORD Lr;
   1928     PULONGLONG D8;
   1929     PULONGLONG D9;
   1930     PULONGLONG D10;
   1931     PULONGLONG D11;
   1932     PULONGLONG D12;
   1933     PULONGLONG D13;
   1934     PULONGLONG D14;
   1935     PULONGLONG D15;
   1936   } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
   1937 
   1938 #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
   1939 
   1940 #endif /* _ARM_ */
   1941 
   1942 
   1943 #ifdef _X86_
   1944 
   1945 #if defined(__i386__) && !defined(__x86_64) && !defined(RC_INVOKED)
   1946 #ifdef __cplusplus
   1947   extern "C" {
   1948 #endif
   1949 
   1950 #define BitTest _bittest
   1951 #define BitTestAndComplement _bittestandcomplement
   1952 #define BitTestAndSet _bittestandset
   1953 #define BitTestAndReset _bittestandreset
   1954 
   1955 #define BitScanForward _BitScanForward
   1956 #define BitScanReverse _BitScanReverse
   1957 
   1958 #define InterlockedCompareExchange16 _InterlockedCompareExchange16
   1959 #define InterlockedAdd _InterlockedAdd
   1960 #define InterlockedAdd64 _InterlockedAdd64
   1961 
   1962 #ifdef _PREFIX_
   1963     /* BYTE __readfsbyte(DWORD Offset); moved to psdk_inc/intrin-impl.h */
   1964     /* WORD __readfsword(DWORD Offset); moved to psdk_inc/intrin-impl.h */
   1965     /* DWORD __readfsdword(DWORD Offset); moved to psdk_inc/intrin-impl.h */
   1966     /* VOID __writefsbyte(DWORD Offset,BYTE Data); moved to psdk_inc/intrin-impl.h */
   1967     /* VOID __writefsword(DWORD Offset,WORD Data); moved to psdk_inc/intrin-impl.h */
   1968     /* VOID __writefsdword(DWORD Offset,DWORD Data); moved to psdk_inc/intrin-impl.h */
   1969 #endif
   1970 
   1971 #ifdef __cplusplus
   1972   }
   1973 #endif
   1974 #endif /* defined(__i386__) && !defined(__x86_64) && !defined(RC_INVOKED) */
   1975 
   1976 #if defined(__i386__) && !defined(__x86_64)
   1977 
   1978 #ifdef __SSE2__
   1979 #define YieldProcessor _mm_pause
   1980 #define MemoryBarrier _mm_mfence
   1981 #else
   1982 #define YieldProcessor __buildpause
   1983 VOID MemoryBarrier(VOID);
   1984 FORCEINLINE VOID MemoryBarrier(VOID)
   1985 __buildmemorybarrier()
   1986 #endif
   1987 
   1988 #define PreFetchCacheLine(l,a)
   1989 #define ReadForWriteAccess(p) (*(p))
   1990 
   1991 #define PF_TEMPORAL_LEVEL_1
   1992 #define PF_NON_TEMPORAL_LEVEL_ALL
   1993 
   1994 #define PcTeb 0x18
   1995   struct _TEB *NtCurrentTeb(void);
   1996   PVOID GetCurrentFiber(void);
   1997   PVOID GetFiberData(void);
   1998 
   1999 #define DbgRaiseAssertionFailure __int2c
   2000 
   2001   FORCEINLINE struct _TEB *NtCurrentTeb(void)
   2002   {
   2003     return (struct _TEB *)__readfsdword(PcTeb);
   2004   }
   2005   FORCEINLINE PVOID GetCurrentFiber(void)
   2006   {
   2007     return(PVOID)__readfsdword(0x10);
   2008   }
   2009   FORCEINLINE PVOID GetFiberData(void)
   2010   {
   2011       return *(PVOID *)GetCurrentFiber();
   2012   }
   2013 #endif /* defined(__i386__) && !defined(__x86_64) */
   2014 
   2015 #define EXCEPTION_READ_FAULT 0
   2016 #define EXCEPTION_WRITE_FAULT 1
   2017 #define EXCEPTION_EXECUTE_FAULT 8
   2018 
   2019 #define SIZE_OF_80387_REGISTERS 80
   2020 
   2021 #if !defined(RC_INVOKED)
   2022 
   2023 #define CONTEXT_i386 0x00010000
   2024 #define CONTEXT_i486 0x00010000
   2025 
   2026 #define CONTEXT_CONTROL (CONTEXT_i386 | __MSABI_LONG(0x00000001))
   2027 #define CONTEXT_INTEGER (CONTEXT_i386 | __MSABI_LONG(0x00000002))
   2028 #define CONTEXT_SEGMENTS (CONTEXT_i386 | __MSABI_LONG(0x00000004))
   2029 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | __MSABI_LONG(0x00000008))
   2030 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | __MSABI_LONG(0x00000010))
   2031 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | __MSABI_LONG(0x00000020))
   2032 
   2033 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
   2034 
   2035 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
   2036 #endif /* !defined(RC_INVOKED) */
   2037 
   2038 #define MAXIMUM_SUPPORTED_EXTENSION 512
   2039 
   2040     typedef struct _FLOATING_SAVE_AREA {
   2041       DWORD ControlWord;
   2042       DWORD StatusWord;
   2043       DWORD TagWord;
   2044       DWORD ErrorOffset;
   2045       DWORD ErrorSelector;
   2046       DWORD DataOffset;
   2047       DWORD DataSelector;
   2048       BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
   2049       DWORD Cr0NpxState;
   2050     } FLOATING_SAVE_AREA;
   2051 
   2052     typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
   2053 
   2054     typedef struct _CONTEXT {
   2055       DWORD ContextFlags;
   2056       DWORD Dr0;
   2057       DWORD Dr1;
   2058       DWORD Dr2;
   2059       DWORD Dr3;
   2060       DWORD Dr6;
   2061       DWORD Dr7;
   2062       FLOATING_SAVE_AREA FloatSave;
   2063       DWORD SegGs;
   2064       DWORD SegFs;
   2065       DWORD SegEs;
   2066       DWORD SegDs;
   2067 
   2068       DWORD Edi;
   2069       DWORD Esi;
   2070       DWORD Ebx;
   2071       DWORD Edx;
   2072       DWORD Ecx;
   2073       DWORD Eax;
   2074       DWORD Ebp;
   2075       DWORD Eip;
   2076       DWORD SegCs;
   2077       DWORD EFlags;
   2078       DWORD Esp;
   2079       DWORD SegSs;
   2080       BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
   2081     } CONTEXT;
   2082 
   2083     typedef CONTEXT *PCONTEXT;
   2084 
   2085 #endif /* end of _X86_ */
   2086 
   2087   /* LONG WINAPI InterlockedIncrement(LONG volatile *); moved to psdk_inc/intrin-impl.h */
   2088   /* LONG WINAPI InterlockedDecrement(LONG volatile *); moved to psdk_inc/intrin-impl.h */
   2089   /* LONG WINAPI InterlockedExchange(LONG volatile *, LONG); moved to psdk_inc/intrin-impl.h */
   2090 
   2091 #ifndef _LDT_ENTRY_DEFINED
   2092 #define _LDT_ENTRY_DEFINED
   2093 
   2094     typedef struct _LDT_ENTRY {
   2095       WORD LimitLow;
   2096       WORD BaseLow;
   2097       union {
   2098 	struct {
   2099 	  BYTE BaseMid;
   2100 	  BYTE Flags1;
   2101 	  BYTE Flags2;
   2102 	  BYTE BaseHi;
   2103 	} Bytes;
   2104 	struct {
   2105 	  DWORD BaseMid : 8;
   2106 	  DWORD Type : 5;
   2107 	  DWORD Dpl : 2;
   2108 	  DWORD Pres : 1;
   2109 	  DWORD LimitHi : 4;
   2110 	  DWORD Sys : 1;
   2111 	  DWORD Reserved_0 : 1;
   2112 	  DWORD Default_Big : 1;
   2113 	  DWORD Granularity : 1;
   2114 	  DWORD BaseHi : 8;
   2115 	} Bits;
   2116       } HighWord;
   2117     } LDT_ENTRY,*PLDT_ENTRY;
   2118 #endif /* _LDT_ENTRY_DEFINED */
   2119 
   2120 #if defined(__ia64__) && !defined(RC_INVOKED)
   2121 
   2122 #ifdef __cplusplus
   2123     extern "C" {
   2124 #endif
   2125 
   2126       BOOLEAN BitScanForward64(DWORD *Index,DWORD64 Mask);
   2127       BOOLEAN BitScanReverse64(DWORD *Index,DWORD64 Mask);
   2128 
   2129 #ifdef __cplusplus
   2130     }
   2131 #endif
   2132 #endif /* defined(__ia64__) && !defined(RC_INVOKED) */
   2133 
   2134 #if !defined(GENUTIL) && !defined(_GENIA64_) && defined(_IA64_)
   2135 
   2136     void *_cdecl _rdteb(void);
   2137 
   2138 #ifdef __ia64__
   2139 #define NtCurrentTeb() ((struct _TEB *)_rdteb())
   2140 #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
   2141 #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
   2142 
   2143 #ifdef __cplusplus
   2144     extern "C" {
   2145 #endif
   2146 
   2147       void __break(int);
   2148       void __yield(void);
   2149       void __mf(void);
   2150       void __lfetch(int Level,VOID CONST *Address);
   2151       void __lfetchfault(int Level,VOID CONST *Address);
   2152       void __lfetch_excl(int Level,VOID CONST *Address);
   2153       void __lfetchfault_excl(int Level,VOID CONST *Address);
   2154 
   2155 #define MD_LFHINT_NONE 0x00
   2156 #define MD_LFHINT_NT1 0x01
   2157 #define MD_LFHINT_NT2 0x02
   2158 #define MD_LFHINT_NTA 0x03
   2159 
   2160 #ifdef __cplusplus
   2161     }
   2162 #endif
   2163 
   2164 #define YieldProcessor __yield
   2165 #define MemoryBarrier __mf
   2166 #define PreFetchCacheLine __lfetch
   2167 #define ReadForWriteAccess(p) (*(p))
   2168 #define DbgRaiseAssertionFailure() __break(ASSERT_BREAKPOINT)
   2169 
   2170 #define PF_TEMPORAL_LEVEL_1 MD_LFHINT_NONE
   2171 #define PF_NON_TEMPORAL_LEVEL_ALL MD_LFHINT_NTA
   2172 
   2173 #define UnsignedMultiplyHigh __UMULH
   2174 
   2175     ULONGLONG UnsignedMultiplyHigh(ULONGLONG Multiplier,ULONGLONG Multiplicand);
   2176 #else  /* __ia64__ */
   2177     struct _TEB *NtCurrentTeb(void);
   2178 #endif /* __ia64__ */
   2179 #endif /* !defined(GENUTIL) && !defined(_GENIA64_) && defined(_IA64_) */
   2180 
   2181 #ifdef _IA64_
   2182 
   2183 #define EXCEPTION_READ_FAULT 0
   2184 #define EXCEPTION_WRITE_FAULT 1
   2185 #define EXCEPTION_EXECUTE_FAULT 2
   2186 
   2187 #if !defined(RC_INVOKED)
   2188 
   2189 #define CONTEXT_IA64 0x00080000
   2190 
   2191 #define CONTEXT_CONTROL (CONTEXT_IA64 | __MSABI_LONG(0x00000001))
   2192 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | __MSABI_LONG(0x00000002))
   2193 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | __MSABI_LONG(0x00000004))
   2194 #define CONTEXT_INTEGER (CONTEXT_IA64 | __MSABI_LONG(0x00000008))
   2195 #define CONTEXT_DEBUG (CONTEXT_IA64 | __MSABI_LONG(0x00000010))
   2196 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | __MSABI_LONG(0x00000020))
   2197 
   2198 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
   2199 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
   2200 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
   2201 
   2202 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
   2203 #define CONTEXT_SERVICE_ACTIVE 0x10000000
   2204 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
   2205 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
   2206 #endif /* !defined(RC_INVOKED) */
   2207 
   2208     typedef struct _CONTEXT {
   2209       DWORD ContextFlags;
   2210       DWORD Fill1[3];
   2211       ULONGLONG DbI0;
   2212       ULONGLONG DbI1;
   2213       ULONGLONG DbI2;
   2214       ULONGLONG DbI3;
   2215       ULONGLONG DbI4;
   2216       ULONGLONG DbI5;
   2217       ULONGLONG DbI6;
   2218       ULONGLONG DbI7;
   2219       ULONGLONG DbD0;
   2220       ULONGLONG DbD1;
   2221       ULONGLONG DbD2;
   2222       ULONGLONG DbD3;
   2223       ULONGLONG DbD4;
   2224       ULONGLONG DbD5;
   2225       ULONGLONG DbD6;
   2226       ULONGLONG DbD7;
   2227       FLOAT128 FltS0;
   2228       FLOAT128 FltS1;
   2229       FLOAT128 FltS2;
   2230       FLOAT128 FltS3;
   2231       FLOAT128 FltT0;
   2232       FLOAT128 FltT1;
   2233       FLOAT128 FltT2;
   2234       FLOAT128 FltT3;
   2235       FLOAT128 FltT4;
   2236       FLOAT128 FltT5;
   2237       FLOAT128 FltT6;
   2238       FLOAT128 FltT7;
   2239       FLOAT128 FltT8;
   2240       FLOAT128 FltT9;
   2241       FLOAT128 FltS4;
   2242       FLOAT128 FltS5;
   2243       FLOAT128 FltS6;
   2244       FLOAT128 FltS7;
   2245       FLOAT128 FltS8;
   2246       FLOAT128 FltS9;
   2247       FLOAT128 FltS10;
   2248       FLOAT128 FltS11;
   2249       FLOAT128 FltS12;
   2250       FLOAT128 FltS13;
   2251       FLOAT128 FltS14;
   2252       FLOAT128 FltS15;
   2253       FLOAT128 FltS16;
   2254       FLOAT128 FltS17;
   2255       FLOAT128 FltS18;
   2256       FLOAT128 FltS19;
   2257       FLOAT128 FltF32;
   2258       FLOAT128 FltF33;
   2259       FLOAT128 FltF34;
   2260       FLOAT128 FltF35;
   2261       FLOAT128 FltF36;
   2262       FLOAT128 FltF37;
   2263       FLOAT128 FltF38;
   2264       FLOAT128 FltF39;
   2265       FLOAT128 FltF40;
   2266       FLOAT128 FltF41;
   2267       FLOAT128 FltF42;
   2268       FLOAT128 FltF43;
   2269       FLOAT128 FltF44;
   2270       FLOAT128 FltF45;
   2271       FLOAT128 FltF46;
   2272       FLOAT128 FltF47;
   2273       FLOAT128 FltF48;
   2274       FLOAT128 FltF49;
   2275       FLOAT128 FltF50;
   2276       FLOAT128 FltF51;
   2277       FLOAT128 FltF52;
   2278       FLOAT128 FltF53;
   2279       FLOAT128 FltF54;
   2280       FLOAT128 FltF55;
   2281       FLOAT128 FltF56;
   2282       FLOAT128 FltF57;
   2283       FLOAT128 FltF58;
   2284       FLOAT128 FltF59;
   2285       FLOAT128 FltF60;
   2286       FLOAT128 FltF61;
   2287       FLOAT128 FltF62;
   2288       FLOAT128 FltF63;
   2289       FLOAT128 FltF64;
   2290       FLOAT128 FltF65;
   2291       FLOAT128 FltF66;
   2292       FLOAT128 FltF67;
   2293       FLOAT128 FltF68;
   2294       FLOAT128 FltF69;
   2295       FLOAT128 FltF70;
   2296       FLOAT128 FltF71;
   2297       FLOAT128 FltF72;
   2298       FLOAT128 FltF73;
   2299       FLOAT128 FltF74;
   2300       FLOAT128 FltF75;
   2301       FLOAT128 FltF76;
   2302       FLOAT128 FltF77;
   2303       FLOAT128 FltF78;
   2304       FLOAT128 FltF79;
   2305       FLOAT128 FltF80;
   2306       FLOAT128 FltF81;
   2307       FLOAT128 FltF82;
   2308       FLOAT128 FltF83;
   2309       FLOAT128 FltF84;
   2310       FLOAT128 FltF85;
   2311       FLOAT128 FltF86;
   2312       FLOAT128 FltF87;
   2313       FLOAT128 FltF88;
   2314       FLOAT128 FltF89;
   2315       FLOAT128 FltF90;
   2316       FLOAT128 FltF91;
   2317       FLOAT128 FltF92;
   2318       FLOAT128 FltF93;
   2319       FLOAT128 FltF94;
   2320       FLOAT128 FltF95;
   2321       FLOAT128 FltF96;
   2322       FLOAT128 FltF97;
   2323       FLOAT128 FltF98;
   2324       FLOAT128 FltF99;
   2325       FLOAT128 FltF100;
   2326       FLOAT128 FltF101;
   2327       FLOAT128 FltF102;
   2328       FLOAT128 FltF103;
   2329       FLOAT128 FltF104;
   2330       FLOAT128 FltF105;
   2331       FLOAT128 FltF106;
   2332       FLOAT128 FltF107;
   2333       FLOAT128 FltF108;
   2334       FLOAT128 FltF109;
   2335       FLOAT128 FltF110;
   2336       FLOAT128 FltF111;
   2337       FLOAT128 FltF112;
   2338       FLOAT128 FltF113;
   2339       FLOAT128 FltF114;
   2340       FLOAT128 FltF115;
   2341       FLOAT128 FltF116;
   2342       FLOAT128 FltF117;
   2343       FLOAT128 FltF118;
   2344       FLOAT128 FltF119;
   2345       FLOAT128 FltF120;
   2346       FLOAT128 FltF121;
   2347       FLOAT128 FltF122;
   2348       FLOAT128 FltF123;
   2349       FLOAT128 FltF124;
   2350       FLOAT128 FltF125;
   2351       FLOAT128 FltF126;
   2352       FLOAT128 FltF127;
   2353       ULONGLONG StFPSR;
   2354       ULONGLONG IntGp;
   2355       ULONGLONG IntT0;
   2356       ULONGLONG IntT1;
   2357       ULONGLONG IntS0;
   2358       ULONGLONG IntS1;
   2359       ULONGLONG IntS2;
   2360       ULONGLONG IntS3;
   2361       ULONGLONG IntV0;
   2362       ULONGLONG IntT2;
   2363       ULONGLONG IntT3;
   2364       ULONGLONG IntT4;
   2365       ULONGLONG IntSp;
   2366       ULONGLONG IntTeb;
   2367       ULONGLONG IntT5;
   2368       ULONGLONG IntT6;
   2369       ULONGLONG IntT7;
   2370       ULONGLONG IntT8;
   2371       ULONGLONG IntT9;
   2372       ULONGLONG IntT10;
   2373       ULONGLONG IntT11;
   2374       ULONGLONG IntT12;
   2375       ULONGLONG IntT13;
   2376       ULONGLONG IntT14;
   2377       ULONGLONG IntT15;
   2378       ULONGLONG IntT16;
   2379       ULONGLONG IntT17;
   2380       ULONGLONG IntT18;
   2381       ULONGLONG IntT19;
   2382       ULONGLONG IntT20;
   2383       ULONGLONG IntT21;
   2384       ULONGLONG IntT22;
   2385       ULONGLONG IntNats;
   2386       ULONGLONG Preds;
   2387       ULONGLONG BrRp;
   2388       ULONGLONG BrS0;
   2389       ULONGLONG BrS1;
   2390       ULONGLONG BrS2;
   2391       ULONGLONG BrS3;
   2392       ULONGLONG BrS4;
   2393       ULONGLONG BrT0;
   2394       ULONGLONG BrT1;
   2395       ULONGLONG ApUNAT;
   2396       ULONGLONG ApLC;
   2397       ULONGLONG ApEC;
   2398       ULONGLONG ApCCV;
   2399       ULONGLONG ApDCR;
   2400       ULONGLONG RsPFS;
   2401       ULONGLONG RsBSP;
   2402       ULONGLONG RsBSPSTORE;
   2403       ULONGLONG RsRSC;
   2404       ULONGLONG RsRNAT;
   2405       ULONGLONG StIPSR;
   2406       ULONGLONG StIIP;
   2407       ULONGLONG StIFS;
   2408       ULONGLONG StFCR;
   2409       ULONGLONG Eflag;
   2410       ULONGLONG SegCSD;
   2411       ULONGLONG SegSSD;
   2412       ULONGLONG Cflag;
   2413       ULONGLONG StFSR;
   2414       ULONGLONG StFIR;
   2415       ULONGLONG StFDR;
   2416       ULONGLONG UNUSEDPACK;
   2417     } CONTEXT,*PCONTEXT;
   2418 
   2419     typedef struct _PLABEL_DESCRIPTOR {
   2420       ULONGLONG EntryPoint;
   2421       ULONGLONG GlobalPointer;
   2422     } PLABEL_DESCRIPTOR,*PPLABEL_DESCRIPTOR;
   2423 
   2424     typedef struct _RUNTIME_FUNCTION {
   2425       DWORD BeginAddress;
   2426       DWORD EndAddress;
   2427       DWORD UnwindInfoAddress;
   2428     } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
   2429 
   2430     typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
   2431     typedef DWORD (*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)(HANDLE Process,PVOID TableAddress,PDWORD Entries,PRUNTIME_FUNCTION *Functions);
   2432 
   2433 #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
   2434 
   2435     VOID __jump_unwind(ULONGLONG TargetMsFrame,ULONGLONG TargetBsFrame,ULONGLONG TargetPc);
   2436 #endif /* end of _IA64_ */
   2437 
   2438 /* http://www.nynaeve.net/?p=99 */
   2439 
   2440 #define EXCEPTION_NONCONTINUABLE 0x1
   2441 #define EXCEPTION_UNWINDING	   0x2
   2442 #define EXCEPTION_EXIT_UNWIND      0x4
   2443 #define EXCEPTION_STACK_INVALID    0x8
   2444 #define EXCEPTION_NESTED_CALL      0x10
   2445 #define EXCEPTION_TARGET_UNWIND    0x20
   2446 #define EXCEPTION_COLLIDED_UNWIND  0x40
   2447 #define EXCEPTION_UNWIND           0x66
   2448 
   2449 #define IS_UNWINDING(f) ((f & EXCEPTION_UNWIND) != 0)
   2450 #define IS_DISPATCHING(f) ((f & EXCEPTION_UNWIND) == 0)
   2451 #define IS_TARGET_UNWIND(f) ((f & EXCEPTION_TARGET_UNWIND) != 0)
   2452 
   2453 #define EXCEPTION_MAXIMUM_PARAMETERS 15
   2454 
   2455     typedef struct _EXCEPTION_RECORD {
   2456       DWORD ExceptionCode;
   2457       DWORD ExceptionFlags;
   2458       struct _EXCEPTION_RECORD *ExceptionRecord;
   2459       PVOID ExceptionAddress;
   2460       DWORD NumberParameters;
   2461       ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
   2462     } EXCEPTION_RECORD;
   2463 
   2464     typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
   2465 
   2466     typedef struct _EXCEPTION_RECORD32 {
   2467       DWORD ExceptionCode;
   2468       DWORD ExceptionFlags;
   2469       DWORD ExceptionRecord;
   2470       DWORD ExceptionAddress;
   2471       DWORD NumberParameters;
   2472       DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
   2473     } EXCEPTION_RECORD32,*PEXCEPTION_RECORD32;
   2474 
   2475     typedef struct _EXCEPTION_RECORD64 {
   2476       DWORD ExceptionCode;
   2477       DWORD ExceptionFlags;
   2478       DWORD64 ExceptionRecord;
   2479       DWORD64 ExceptionAddress;
   2480       DWORD NumberParameters;
   2481       DWORD __unusedAlignment;
   2482       DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
   2483     } EXCEPTION_RECORD64,*PEXCEPTION_RECORD64;
   2484 
   2485     typedef struct _EXCEPTION_POINTERS {
   2486       PEXCEPTION_RECORD ExceptionRecord;
   2487       PCONTEXT ContextRecord;
   2488     } EXCEPTION_POINTERS,*PEXCEPTION_POINTERS;
   2489 
   2490 #ifdef __ia64__
   2491     NTSYSAPI VOID NTAPI RtlUnwind2 (FRAME_POINTERS TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT ContextRecord);
   2492 #endif
   2493 
   2494 #ifdef __x86_64__
   2495 
   2496     /* http://msdn.microsoft.com/en-us/library/ms680597(VS.85).aspx */
   2497 
   2498 #define UNWIND_HISTORY_TABLE_SIZE 12
   2499 
   2500   typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
   2501     ULONG64 ImageBase;
   2502     PRUNTIME_FUNCTION FunctionEntry;
   2503   } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
   2504 
   2505 #define UNWIND_HISTORY_TABLE_NONE    0
   2506 #define UNWIND_HISTORY_TABLE_GLOBAL  1
   2507 #define UNWIND_HISTORY_TABLE_LOCAL   2
   2508 
   2509   typedef struct _UNWIND_HISTORY_TABLE {
   2510     ULONG Count;
   2511     UCHAR Search;
   2512     ULONG64 LowAddress;
   2513     ULONG64 HighAddress;
   2514     UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
   2515   } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
   2516 
   2517   /* http://msdn.microsoft.com/en-us/library/b6sf5kbd(VS.80).aspx */
   2518 
   2519   struct _DISPATCHER_CONTEXT;
   2520   typedef struct _DISPATCHER_CONTEXT DISPATCHER_CONTEXT;
   2521   typedef struct _DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT;
   2522 
   2523   struct _DISPATCHER_CONTEXT {
   2524     ULONG64 ControlPc;
   2525     ULONG64 ImageBase;
   2526     PRUNTIME_FUNCTION FunctionEntry;
   2527     ULONG64 EstablisherFrame;
   2528     ULONG64 TargetIp;
   2529     PCONTEXT ContextRecord;
   2530     PEXCEPTION_ROUTINE LanguageHandler;
   2531     PVOID HandlerData;
   2532     /* http://www.nynaeve.net/?p=99 */
   2533     PUNWIND_HISTORY_TABLE HistoryTable;
   2534     ULONG ScopeIndex;
   2535     ULONG Fill0;
   2536   };
   2537 
   2538   /* http://msdn.microsoft.com/en-us/library/ms680617(VS.85).aspx */
   2539 
   2540   typedef struct _KNONVOLATILE_CONTEXT_POINTERS
   2541   {
   2542     PM128A FloatingContext[16];
   2543     PULONG64 IntegerContext[16];
   2544   } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
   2545 #endif /* defined(__x86_64__) */
   2546 
   2547     typedef PVOID PACCESS_TOKEN;
   2548     typedef PVOID PSECURITY_DESCRIPTOR;
   2549     typedef PVOID PSID;
   2550     typedef PVOID PCLAIMS_BLOB;
   2551     typedef DWORD ACCESS_MASK;
   2552     typedef ACCESS_MASK *PACCESS_MASK;
   2553 
   2554 #define DELETE (__MSABI_LONG(0x00010000))
   2555 #define READ_CONTROL (__MSABI_LONG(0x00020000))
   2556 #define WRITE_DAC (__MSABI_LONG(0x00040000))
   2557 #define WRITE_OWNER (__MSABI_LONG(0x00080000))
   2558 #define SYNCHRONIZE (__MSABI_LONG(0x00100000))
   2559 
   2560 #define STANDARD_RIGHTS_REQUIRED (__MSABI_LONG(0x000F0000))
   2561 
   2562 #define STANDARD_RIGHTS_READ (READ_CONTROL)
   2563 #define STANDARD_RIGHTS_WRITE (READ_CONTROL)
   2564 #define STANDARD_RIGHTS_EXECUTE (READ_CONTROL)
   2565 
   2566 #define STANDARD_RIGHTS_ALL (__MSABI_LONG(0x001F0000))
   2567 
   2568 #define SPECIFIC_RIGHTS_ALL (__MSABI_LONG(0x0000FFFF))
   2569 
   2570 #define ACCESS_SYSTEM_SECURITY (__MSABI_LONG(0x01000000))
   2571 #define MAXIMUM_ALLOWED (__MSABI_LONG(0x02000000))
   2572 
   2573 #define GENERIC_READ (__MSABI_LONG(0x80000000))
   2574 #define GENERIC_WRITE (__MSABI_LONG(0x40000000))
   2575 #define GENERIC_EXECUTE (__MSABI_LONG(0x20000000))
   2576 #define GENERIC_ALL (__MSABI_LONG(0x10000000))
   2577 
   2578     typedef struct _GENERIC_MAPPING {
   2579       ACCESS_MASK GenericRead;
   2580       ACCESS_MASK GenericWrite;
   2581       ACCESS_MASK GenericExecute;
   2582       ACCESS_MASK GenericAll;
   2583     } GENERIC_MAPPING;
   2584     typedef GENERIC_MAPPING *PGENERIC_MAPPING;
   2585 
   2586 #include <pshpack4.h>
   2587     typedef struct _LUID_AND_ATTRIBUTES {
   2588       LUID Luid;
   2589       DWORD Attributes;
   2590     } LUID_AND_ATTRIBUTES,*PLUID_AND_ATTRIBUTES;
   2591     typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
   2592     typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
   2593 #include <poppack.h>
   2594 
   2595 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
   2596 #define SID_IDENTIFIER_AUTHORITY_DEFINED
   2597     typedef struct _SID_IDENTIFIER_AUTHORITY {
   2598       BYTE Value[6];
   2599     } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY;
   2600 #endif /* SID_IDENTIFIER_AUTHORITY_DEFINED */
   2601 
   2602 #ifndef SID_DEFINED
   2603 #define SID_DEFINED
   2604     typedef struct _SID {
   2605       BYTE Revision;
   2606       BYTE SubAuthorityCount;
   2607       SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
   2608       DWORD SubAuthority[ANYSIZE_ARRAY];
   2609     } SID,*PISID;
   2610 #endif /* SID_DEFINED */
   2611 
   2612 #define SID_REVISION (1)
   2613 #define SID_MAX_SUB_AUTHORITIES (15)
   2614 #define SID_RECOMMENDED_SUB_AUTHORITIES (1)
   2615 #ifndef __WIDL__
   2616 #define SECURITY_MAX_SID_SIZE (sizeof (SID) - sizeof (DWORD) + (SID_MAX_SUB_AUTHORITIES *sizeof (DWORD)))
   2617 #endif
   2618 
   2619 #define SID_HASH_SIZE 32
   2620 
   2621     typedef enum _SID_NAME_USE {
   2622       SidTypeUser = 1,SidTypeGroup,SidTypeDomain,SidTypeAlias,SidTypeWellKnownGroup,SidTypeDeletedAccount,SidTypeInvalid,SidTypeUnknown,SidTypeComputer,SidTypeLabel
   2623     } SID_NAME_USE,*PSID_NAME_USE;
   2624 
   2625     typedef struct _SID_AND_ATTRIBUTES {
   2626 #ifdef __WIDL__
   2627       PISID Sid;
   2628 #else
   2629       PSID Sid;
   2630 #endif
   2631       DWORD Attributes;
   2632     } SID_AND_ATTRIBUTES,*PSID_AND_ATTRIBUTES;
   2633 
   2634     typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
   2635     typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
   2636 
   2637     typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
   2638 
   2639     typedef struct _SID_AND_ATTRIBUTES_HASH {
   2640       DWORD SidCount;
   2641       PSID_AND_ATTRIBUTES SidAttr;
   2642       SID_HASH_ENTRY Hash[SID_HASH_SIZE];
   2643     } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
   2644 
   2645 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
   2646 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
   2647 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
   2648 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
   2649 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
   2650 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
   2651 
   2652 #define SECURITY_NULL_RID (__MSABI_LONG(0x00000000))
   2653 #define SECURITY_WORLD_RID (__MSABI_LONG(0x00000000))
   2654 #define SECURITY_LOCAL_RID (__MSABI_LONG(0x00000000))
   2655 #define SECURITY_LOCAL_LOGON_RID (__MSABI_LONG(0x00000001))
   2656 
   2657 #define SECURITY_CREATOR_OWNER_RID (__MSABI_LONG(0x00000000))
   2658 #define SECURITY_CREATOR_GROUP_RID (__MSABI_LONG(0x00000001))
   2659 #define SECURITY_CREATOR_OWNER_SERVER_RID (__MSABI_LONG(0x00000002))
   2660 #define SECURITY_CREATOR_GROUP_SERVER_RID (__MSABI_LONG(0x00000003))
   2661 #define SECURITY_CREATOR_OWNER_RIGHTS_RID (__MSABI_LONG(0x00000004))
   2662 
   2663 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
   2664 
   2665 #define SECURITY_DIALUP_RID (__MSABI_LONG(0x00000001))
   2666 #define SECURITY_NETWORK_RID (__MSABI_LONG(0x00000002))
   2667 #define SECURITY_BATCH_RID (__MSABI_LONG(0x00000003))
   2668 #define SECURITY_INTERACTIVE_RID (__MSABI_LONG(0x00000004))
   2669 #define SECURITY_LOGON_IDS_RID (__MSABI_LONG(0x00000005))
   2670 #define SECURITY_LOGON_IDS_RID_COUNT (__MSABI_LONG(3))
   2671 #define SECURITY_SERVICE_RID (__MSABI_LONG(0x00000006))
   2672 #define SECURITY_ANONYMOUS_LOGON_RID (__MSABI_LONG(0x00000007))
   2673 #define SECURITY_PROXY_RID (__MSABI_LONG(0x00000008))
   2674 #define SECURITY_ENTERPRISE_CONTROLLERS_RID (__MSABI_LONG(0x00000009))
   2675 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
   2676 #define SECURITY_PRINCIPAL_SELF_RID (__MSABI_LONG(0x0000000A))
   2677 #define SECURITY_AUTHENTICATED_USER_RID (__MSABI_LONG(0x0000000B))
   2678 #define SECURITY_RESTRICTED_CODE_RID (__MSABI_LONG(0x0000000C))
   2679 #define SECURITY_TERMINAL_SERVER_RID (__MSABI_LONG(0x0000000D))
   2680 #define SECURITY_REMOTE_LOGON_RID (__MSABI_LONG(0x0000000E))
   2681 #define SECURITY_THIS_ORGANIZATION_RID (__MSABI_LONG(0x0000000F))
   2682 #define SECURITY_IUSER_RID (__MSABI_LONG(0x00000011))
   2683 #define SECURITY_LOCAL_SYSTEM_RID (__MSABI_LONG(0x00000012))
   2684 #define SECURITY_LOCAL_SERVICE_RID (__MSABI_LONG(0x00000013))
   2685 #define SECURITY_NETWORK_SERVICE_RID (__MSABI_LONG(0x00000014))
   2686 
   2687 #define SECURITY_NT_NON_UNIQUE (__MSABI_LONG(0x00000015))
   2688 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT (__MSABI_LONG(3))
   2689 
   2690 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID (__MSABI_LONG(0x00000016))
   2691 
   2692 #define SECURITY_BUILTIN_DOMAIN_RID (__MSABI_LONG(0x00000020))
   2693 #define SECURITY_WRITE_RESTRICTED_CODE_RID (__MSABI_LONG(0x00000021))
   2694 
   2695 #define SECURITY_PACKAGE_BASE_RID (__MSABI_LONG(0x00000040))
   2696 #define SECURITY_PACKAGE_RID_COUNT (__MSABI_LONG(2))
   2697 #define SECURITY_PACKAGE_NTLM_RID (__MSABI_LONG(0x0000000A))
   2698 #define SECURITY_PACKAGE_SCHANNEL_RID (__MSABI_LONG(0x0000000E))
   2699 #define SECURITY_PACKAGE_DIGEST_RID (__MSABI_LONG(0x00000015))
   2700 
   2701 #define SECURITY_CRED_TYPE_BASE_RID (__MSABI_LONG(0x00000041))
   2702 #define SECURITY_CRED_TYPE_RID_COUNT (__MSABI_LONG(2))
   2703 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID (__MSABI_LONG(0x00000001))
   2704 
   2705 #define SECURITY_MIN_BASE_RID (__MSABI_LONG(0x00000050))
   2706 
   2707 #define SECURITY_SERVICE_ID_BASE_RID (__MSABI_LONG(0x00000050))
   2708 #define SECURITY_SERVICE_ID_RID_COUNT (__MSABI_LONG(6))
   2709 
   2710 #define SECURITY_RESERVED_ID_BASE_RID (__MSABI_LONG(0x00000051))
   2711 
   2712 #define SECURITY_APPPOOL_ID_BASE_RID (__MSABI_LONG(0x00000052))
   2713 #define SECURITY_APPPOOL_ID_RID_COUNT (__MSABI_LONG(6))
   2714 
   2715 #define SECURITY_VIRTUALSERVER_ID_BASE_RID (__MSABI_LONG(0x00000053))
   2716 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT (__MSABI_LONG(6))
   2717 
   2718 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID (__MSABI_LONG(0x00000054))
   2719 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT (__MSABI_LONG(6))
   2720 
   2721 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID (__MSABI_LONG(0x00000055))
   2722 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT (__MSABI_LONG(6))
   2723 
   2724 #define SECURITY_WMIHOST_ID_BASE_RID (__MSABI_LONG(0x00000056))
   2725 #define SECURITY_WMIHOST_ID_RID_COUNT (__MSABI_LONG(6))
   2726 
   2727 #define SECURITY_TASK_ID_BASE_RID (__MSABI_LONG(0x00000057))
   2728 
   2729 #define SECURITY_NFS_ID_BASE_RID (__MSABI_LONG(0x00000058))
   2730 
   2731 #define SECURITY_COM_ID_BASE_RID (__MSABI_LONG(0x00000059))
   2732 
   2733 #define SECURITY_WINDOW_MANAGER_BASE_RID (__MSABI_LONG(0x0000005a))
   2734 
   2735 #define SECURITY_RDV_GFX_BASE_RID (__MSABI_LONG(0x0000005b))
   2736 
   2737 #define SECURITY_DASHOST_ID_BASE_RID (__MSABI_LONG(0x0000005c))
   2738 #define SECURITY_DASHOST_ID_RID_COUNT (__MSABI_LONG(6))
   2739 
   2740 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT (__MSABI_LONG(6))
   2741 
   2742 #define SECURITY_MAX_BASE_RID (__MSABI_LONG(0x0000006f))
   2743 
   2744 #define SECURITY_MAX_ALWAYS_FILTERED (__MSABI_LONG(0x000003E7))
   2745 #define SECURITY_MIN_NEVER_FILTERED (__MSABI_LONG(0x000003E8))
   2746 
   2747 #define SECURITY_OTHER_ORGANIZATION_RID (__MSABI_LONG(0x000003E8))
   2748 
   2749 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID (__MSABI_LONG(0x00000070))
   2750 
   2751 #define DOMAIN_GROUP_RID_AUTHORIZATION_DATA_IS_COMPOUNDED (__MSABI_LONG(0x000001f0))
   2752 #define DOMAIN_GROUP_RID_AUTHORIZATION_DATA_CONTAINS_CLAIMS (__MSABI_LONG(0x000001f1))
   2753 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS (__MSABI_LONG(0x000001f2))
   2754 
   2755 #define FOREST_USER_RID_MAX (__MSABI_LONG(0x000001F3))
   2756 
   2757 #define DOMAIN_USER_RID_ADMIN (__MSABI_LONG(0x000001F4))
   2758 #define DOMAIN_USER_RID_GUEST (__MSABI_LONG(0x000001F5))
   2759 #define DOMAIN_USER_RID_KRBTGT (__MSABI_LONG(0x000001F6))
   2760 
   2761 #define DOMAIN_USER_RID_MAX (__MSABI_LONG(0x000003E7))
   2762 
   2763 #define DOMAIN_GROUP_RID_ADMINS (__MSABI_LONG(0x00000200))
   2764 #define DOMAIN_GROUP_RID_USERS (__MSABI_LONG(0x00000201))
   2765 #define DOMAIN_GROUP_RID_GUESTS (__MSABI_LONG(0x00000202))
   2766 #define DOMAIN_GROUP_RID_COMPUTERS (__MSABI_LONG(0x00000203))
   2767 #define DOMAIN_GROUP_RID_CONTROLLERS (__MSABI_LONG(0x00000204))
   2768 #define DOMAIN_GROUP_RID_CERT_ADMINS (__MSABI_LONG(0x00000205))
   2769 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (__MSABI_LONG(0x00000206))
   2770 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (__MSABI_LONG(0x00000207))
   2771 #define DOMAIN_GROUP_RID_POLICY_ADMINS (__MSABI_LONG(0x00000208))
   2772 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS (__MSABI_LONG(0x00000209))
   2773 #define DOMAIN_GROUP_RID_CLONEABLE_CONTROLLERS (__MSABI_LONG(0x0000020a))
   2774 
   2775 #define DOMAIN_ALIAS_RID_ADMINS (__MSABI_LONG(0x00000220))
   2776 #define DOMAIN_ALIAS_RID_USERS (__MSABI_LONG(0x00000221))
   2777 #define DOMAIN_ALIAS_RID_GUESTS (__MSABI_LONG(0x00000222))
   2778 #define DOMAIN_ALIAS_RID_POWER_USERS (__MSABI_LONG(0x00000223))
   2779 
   2780 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS (__MSABI_LONG(0x00000224))
   2781 #define DOMAIN_ALIAS_RID_SYSTEM_OPS (__MSABI_LONG(0x00000225))
   2782 #define DOMAIN_ALIAS_RID_PRINT_OPS (__MSABI_LONG(0x00000226))
   2783 #define DOMAIN_ALIAS_RID_BACKUP_OPS (__MSABI_LONG(0x00000227))
   2784 
   2785 #define DOMAIN_ALIAS_RID_REPLICATOR (__MSABI_LONG(0x00000228))
   2786 #define DOMAIN_ALIAS_RID_RAS_SERVERS (__MSABI_LONG(0x00000229))
   2787 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS (__MSABI_LONG(0x0000022A))
   2788 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS (__MSABI_LONG(0x0000022B))
   2789 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS (__MSABI_LONG(0x0000022C))
   2790 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS (__MSABI_LONG(0x0000022D))
   2791 
   2792 #define DOMAIN_ALIAS_RID_MONITORING_USERS (__MSABI_LONG(0x0000022E))
   2793 #define DOMAIN_ALIAS_RID_LOGGING_USERS (__MSABI_LONG(0x0000022F))
   2794 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS (__MSABI_LONG(0x00000230))
   2795 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS (__MSABI_LONG(0x00000231))
   2796 #define DOMAIN_ALIAS_RID_DCOM_USERS (__MSABI_LONG(0x00000232))
   2797 
   2798 #define DOMAIN_ALIAS_RID_IUSERS (__MSABI_LONG(0x00000238))
   2799 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS (__MSABI_LONG(0x00000239))
   2800 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP (__MSABI_LONG(0x0000023B))
   2801 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP (__MSABI_LONG(0x0000023C))
   2802 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP (__MSABI_LONG(0x0000023D))
   2803 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP (__MSABI_LONG(0x0000023e))
   2804 #define DOMAIN_ALIAS_RID_RDS_REMOTE_ACCESS_SERVERS (__MSABI_LONG(0x0000023f))
   2805 #define DOMAIN_ALIAS_RID_RDS_ENDPOINT_SERVERS (__MSABI_LONG(0x00000240))
   2806 #define DOMAIN_ALIAS_RID_RDS_MANAGEMENT_SERVERS (__MSABI_LONG(0x00000241))
   2807 #define DOMAIN_ALIAS_RID_HYPER_V_ADMINS (__MSABI_LONG(0x00000242))
   2808 #define DOMAIN_ALIAS_RID_ACCESS_CONTROL_ASSISTANCE_OPS (__MSABI_LONG(0x00000243))
   2809 #define DOMAIN_ALIAS_RID_REMOTE_MANAGEMENT_USERS (__MSABI_LONG(0x00000244))
   2810 
   2811 #define SECURITY_APP_PACKAGE_AUTHORITY {0, 0, 0, 0, 0, 15}
   2812 
   2813 #define SECURITY_APP_PACKAGE_BASE_RID (__MSABI_LONG(0x00000002))
   2814 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT (__MSABI_LONG(2))
   2815 #define SECURITY_APP_PACKAGE_RID_COUNT (__MSABI_LONG(8))
   2816 #define SECURITY_CAPABILITY_BASE_RID (__MSABI_LONG(0x00000003))
   2817 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT (__MSABI_LONG(2))
   2818 #define SECURITY_CAPABILITY_RID_COUNT (__MSABI_LONG(5))
   2819 
   2820 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE (__MSABI_LONG(0x00000001))
   2821 
   2822 #define SECURITY_CAPABILITY_INTERNET_CLIENT (__MSABI_LONG(0x00000001))
   2823 #define SECURITY_CAPABILITY_INTERNET_CLIENT_SERVER (__MSABI_LONG(0x00000002))
   2824 #define SECURITY_CAPABILITY_PRIVATE_NETWORK_CLIENT_SERVER (__MSABI_LONG(0x00000003))
   2825 #define SECURITY_CAPABILITY_PICTURES_LIBRARY (__MSABI_LONG(0x00000004))
   2826 #define SECURITY_CAPABILITY_VIDEOS_LIBRARY (__MSABI_LONG(0x00000005))
   2827 #define SECURITY_CAPABILITY_MUSIC_LIBRARY (__MSABI_LONG(0x00000006))
   2828 #define SECURITY_CAPABILITY_DOCUMENTS_LIBRARY (__MSABI_LONG(0x00000007))
   2829 #define SECURITY_CAPABILITY_ENTERPRISE_AUTHENTICATION (__MSABI_LONG(0x00000008))
   2830 #define SECURITY_CAPABILITY_SHARED_USER_CERTIFICATES (__MSABI_LONG(0x00000009))
   2831 #define SECURITY_CAPABILITY_REMOVABLE_STORAGE (__MSABI_LONG(0x0000000a))
   2832 
   2833 #define SECURITY_CAPABILITY_INTERNET_EXPLORER (__MSABI_LONG(0x00001000))
   2834 
   2835 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
   2836 #define SECURITY_MANDATORY_UNTRUSTED_RID (__MSABI_LONG(0x00000000))
   2837 #define SECURITY_MANDATORY_LOW_RID (__MSABI_LONG(0x00001000))
   2838 #define SECURITY_MANDATORY_MEDIUM_RID (__MSABI_LONG(0x00002000))
   2839 #define SECURITY_MANDATORY_HIGH_RID (__MSABI_LONG(0x00003000))
   2840 #define SECURITY_MANDATORY_SYSTEM_RID (__MSABI_LONG(0x00004000))
   2841 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID (__MSABI_LONG(0x00005000))
   2842 
   2843 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
   2844 
   2845 #define MANDATORY_LEVEL_TO_MANDATORY_RID(IL) (IL * 0x1000)
   2846 
   2847 #define SECURITY_SCOPED_POLICY_ID_AUTHORITY {0, 0, 0, 0, 0, 17}
   2848 
   2849 #define SECURITY_AUTHENTICATION_AUTHORITY {0, 0, 0, 0, 0, 18}
   2850 #define SECURITY_AUTHENTICATION_AUTHORITY_RID_COUNT (__MSABI_LONG(1))
   2851 #define SECURITY_AUTHENTICATION_AUTHORITY_ASSERTED_RID (__MSABI_LONG(0x00000001))
   2852 #define SECURITY_AUTHENTICATION_SERVICE_ASSERTED_RID (__MSABI_LONG(0x00000002))
   2853 
   2854 #define SECURITY_TRUSTED_INSTALLER_RID1 956008885
   2855 #define SECURITY_TRUSTED_INSTALLER_RID2 3418522649
   2856 #define SECURITY_TRUSTED_INSTALLER_RID3 1831038044
   2857 #define SECURITY_TRUSTED_INSTALLER_RID4 1853292631
   2858 #define SECURITY_TRUSTED_INSTALLER_RID5 2271478464
   2859 
   2860     typedef enum {
   2861       WinNullSid = 0,WinWorldSid = 1,WinLocalSid = 2,WinCreatorOwnerSid = 3,
   2862       WinCreatorGroupSid = 4,WinCreatorOwnerServerSid = 5,
   2863       WinCreatorGroupServerSid = 6,WinNtAuthoritySid = 7,WinDialupSid = 8,
   2864       WinNetworkSid = 9,WinBatchSid = 10,WinInteractiveSid = 11,
   2865       WinServiceSid = 12,WinAnonymousSid = 13,WinProxySid = 14,
   2866       WinEnterpriseControllersSid = 15,WinSelfSid = 16,
   2867       WinAuthenticatedUserSid = 17,WinRestrictedCodeSid = 18,
   2868       WinTerminalServerSid = 19,WinRemoteLogonIdSid = 20,WinLogonIdsSid = 21,
   2869       WinLocalSystemSid = 22,WinLocalServiceSid = 23,WinNetworkServiceSid = 24,
   2870       WinBuiltinDomainSid = 25,WinBuiltinAdministratorsSid = 26,
   2871       WinBuiltinUsersSid = 27,WinBuiltinGuestsSid = 28,
   2872       WinBuiltinPowerUsersSid = 29,WinBuiltinAccountOperatorsSid = 30,
   2873       WinBuiltinSystemOperatorsSid = 31,WinBuiltinPrintOperatorsSid = 32,
   2874       WinBuiltinBackupOperatorsSid = 33,WinBuiltinReplicatorSid = 34,
   2875       WinBuiltinPreWindows2000CompatibleAccessSid = 35,
   2876       WinBuiltinRemoteDesktopUsersSid = 36,
   2877       WinBuiltinNetworkConfigurationOperatorsSid = 37,
   2878       WinAccountAdministratorSid = 38,WinAccountGuestSid = 39,
   2879       WinAccountKrbtgtSid = 40,WinAccountDomainAdminsSid = 41,
   2880       WinAccountDomainUsersSid = 42,WinAccountDomainGuestsSid = 43,
   2881       WinAccountComputersSid = 44,WinAccountControllersSid = 45,
   2882       WinAccountCertAdminsSid = 46,WinAccountSchemaAdminsSid = 47,
   2883       WinAccountEnterpriseAdminsSid = 48,WinAccountPolicyAdminsSid = 49,
   2884       WinAccountRasAndIasServersSid = 50,WinNTLMAuthenticationSid = 51,
   2885       WinDigestAuthenticationSid = 52,WinSChannelAuthenticationSid = 53,
   2886       WinThisOrganizationSid = 54,WinOtherOrganizationSid = 55,
   2887       WinBuiltinIncomingForestTrustBuildersSid = 56,
   2888       WinBuiltinPerfMonitoringUsersSid = 57,WinBuiltinPerfLoggingUsersSid = 58,
   2889       WinBuiltinAuthorizationAccessSid = 59,
   2890       WinBuiltinTerminalServerLicenseServersSid = 60,
   2891       WinBuiltinDCOMUsersSid = 61,WinBuiltinIUsersSid = 62,
   2892       WinIUserSid = 63, WinBuiltinCryptoOperatorsSid = 64,
   2893       WinUntrustedLabelSid = 65, WinLowLabelSid = 66, WinMediumLabelSid = 67,
   2894       WinHighLabelSid = 68, WinSystemLabelSid = 69, WinWriteRestrictedCodeSid = 70,
   2895       WinCreatorOwnerRightsSid = 71, WinCacheablePrincipalsGroupSid = 72,
   2896       WinNonCacheablePrincipalsGroupSid = 73, WinEnterpriseReadonlyControllersSid = 74,
   2897       WinAccountReadonlyControllersSid = 75, WinBuiltinEventLogReadersGroup = 76,
   2898       WinNewEnterpriseReadonlyControllersSid = 77, WinBuiltinCertSvcDComAccessGroup = 78,
   2899       WinMediumPlusLabelSid = 79, WinLocalLogonSid = 80, WinConsoleLogonSid = 81,
   2900       WinThisOrganizationCertificateSid = 82, WinApplicationPackageAuthoritySid = 83,
   2901       WinBuiltinAnyPackageSid = 84, WinCapabilityInternetClientSid = 85,
   2902       WinCapabilityInternetClientServerSid = 86,
   2903       WinCapabilityPrivateNetworkClientServerSid = 87,
   2904       WinCapabilityPicturesLibrarySid = 88, WinCapabilityVideosLibrarySid = 89,
   2905       WinCapabilityMusicLibrarySid = 90, WinCapabilityDocumentsLibrarySid = 91,
   2906       WinCapabilitySharedUserCertificatesSid = 92, WinCapabilityEnterpriseAuthenticationSid = 93,
   2907       WinCapabilityRemovableStorageSid = 94, WinBuiltinRDSRemoteAccessServersSid = 95,
   2908       WinBuiltinRDSEndpointServersSid = 96, WinBuiltinRDSManagementServersSid = 97,
   2909       WinUserModeDriversSid = 98, WinBuiltinHyperVAdminsSid = 99,
   2910       WinAccountCloneableControllersSid = 100,
   2911       WinBuiltinAccessControlAssistanceOperatorsSid = 101,
   2912       WinBuiltinRemoteManagementUsersSid = 102, WinAuthenticationAuthorityAssertedSid = 103,
   2913       WinAuthenticationServiceAssertedSid = 104
   2914 } WELL_KNOWN_SID_TYPE;
   2915 
   2916 #define SYSTEM_LUID { 0x3e7, 0x0 }
   2917 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
   2918 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
   2919 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
   2920 #define IUSER_LUID { 0x3e3, 0x0 }
   2921 
   2922 #define SE_GROUP_MANDATORY (__MSABI_LONG(0x00000001))
   2923 #define SE_GROUP_ENABLED_BY_DEFAULT (__MSABI_LONG(0x00000002))
   2924 #define SE_GROUP_ENABLED (__MSABI_LONG(0x00000004))
   2925 #define SE_GROUP_OWNER (__MSABI_LONG(0x00000008))
   2926 #define SE_GROUP_USE_FOR_DENY_ONLY (__MSABI_LONG(0x00000010))
   2927 #define SE_GROUP_INTEGRITY (__MSABI_LONG(0x00000020))
   2928 #define SE_GROUP_INTEGRITY_ENABLED (__MSABI_LONG(0x00000040))
   2929 #define SE_GROUP_LOGON_ID (__MSABI_LONG(0xC0000000))
   2930 #define SE_GROUP_RESOURCE (__MSABI_LONG(0x20000000))
   2931 
   2932 #define SE_GROUP_VALID_ATTRIBUTES (SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED | SE_GROUP_OWNER | SE_GROUP_USE_FOR_DENY_ONLY | SE_GROUP_LOGON_ID | SE_GROUP_RESOURCE | SE_GROUP_INTEGRITY | SE_GROUP_INTEGRITY_ENABLED)
   2933 
   2934 #define ACL_REVISION (2)
   2935 #define ACL_REVISION_DS (4)
   2936 
   2937 #define ACL_REVISION1 (1)
   2938 #define MIN_ACL_REVISION ACL_REVISION2
   2939 #define ACL_REVISION2 (2)
   2940 #define ACL_REVISION3 (3)
   2941 #define ACL_REVISION4 (4)
   2942 #define MAX_ACL_REVISION ACL_REVISION4
   2943 
   2944     typedef struct _ACL {
   2945       BYTE AclRevision;
   2946       BYTE Sbz1;
   2947       WORD AclSize;
   2948       WORD AceCount;
   2949       WORD Sbz2;
   2950     } ACL;
   2951     typedef ACL *PACL;
   2952 
   2953     typedef struct _ACE_HEADER {
   2954       BYTE AceType;
   2955       BYTE AceFlags;
   2956       WORD AceSize;
   2957     } ACE_HEADER;
   2958     typedef ACE_HEADER *PACE_HEADER;
   2959 
   2960 #define ACCESS_MIN_MS_ACE_TYPE (0x0)
   2961 #define ACCESS_ALLOWED_ACE_TYPE (0x0)
   2962 #define ACCESS_DENIED_ACE_TYPE (0x1)
   2963 #define SYSTEM_AUDIT_ACE_TYPE (0x2)
   2964 #define SYSTEM_ALARM_ACE_TYPE (0x3)
   2965 #define ACCESS_MAX_MS_V2_ACE_TYPE (0x3)
   2966 
   2967 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE (0x4)
   2968 #define ACCESS_MAX_MS_V3_ACE_TYPE (0x4)
   2969 
   2970 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE (0x5)
   2971 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE (0x5)
   2972 #define ACCESS_DENIED_OBJECT_ACE_TYPE (0x6)
   2973 #define SYSTEM_AUDIT_OBJECT_ACE_TYPE (0x7)
   2974 #define SYSTEM_ALARM_OBJECT_ACE_TYPE (0x8)
   2975 #define ACCESS_MAX_MS_OBJECT_ACE_TYPE (0x8)
   2976 
   2977 #define ACCESS_MAX_MS_V4_ACE_TYPE (0x8)
   2978 #define ACCESS_MAX_MS_ACE_TYPE (0x8)
   2979 
   2980 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE (0x9)
   2981 #define ACCESS_DENIED_CALLBACK_ACE_TYPE (0xA)
   2982 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE (0xB)
   2983 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE (0xC)
   2984 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE (0xD)
   2985 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE (0xE)
   2986 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE (0xF)
   2987 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE (0x10)
   2988 
   2989 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE (0x11)
   2990 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE (0x12)
   2991 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE (0x13)
   2992 #define ACCESS_MAX_MS_V5_ACE_TYPE (0x13)
   2993 
   2994 #define OBJECT_INHERIT_ACE (0x1)
   2995 #define CONTAINER_INHERIT_ACE (0x2)
   2996 #define NO_PROPAGATE_INHERIT_ACE (0x4)
   2997 #define INHERIT_ONLY_ACE (0x8)
   2998 #define INHERITED_ACE (0x10)
   2999 #define VALID_INHERIT_FLAGS (0x1F)
   3000 
   3001 #define SUCCESSFUL_ACCESS_ACE_FLAG (0x40)
   3002 #define FAILED_ACCESS_ACE_FLAG (0x80)
   3003 
   3004     typedef struct _ACCESS_ALLOWED_ACE {
   3005       ACE_HEADER Header;
   3006       ACCESS_MASK Mask;
   3007       DWORD SidStart;
   3008     } ACCESS_ALLOWED_ACE;
   3009 
   3010     typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
   3011 
   3012     typedef struct _ACCESS_DENIED_ACE {
   3013       ACE_HEADER Header;
   3014       ACCESS_MASK Mask;
   3015       DWORD SidStart;
   3016     } ACCESS_DENIED_ACE;
   3017     typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
   3018 
   3019     typedef struct _SYSTEM_AUDIT_ACE {
   3020       ACE_HEADER Header;
   3021       ACCESS_MASK Mask;
   3022       DWORD SidStart;
   3023     } SYSTEM_AUDIT_ACE;
   3024     typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
   3025 
   3026     typedef struct _SYSTEM_ALARM_ACE {
   3027       ACE_HEADER Header;
   3028       ACCESS_MASK Mask;
   3029       DWORD SidStart;
   3030     } SYSTEM_ALARM_ACE;
   3031     typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
   3032 
   3033     typedef struct _SYSTEM_RESOURCE_ATTRIBUTE_ACE {
   3034       ACE_HEADER Header;
   3035       ACCESS_MASK Mask;
   3036       DWORD SidStart;
   3037     } SYSTEM_RESOURCE_ATTRIBUTE_ACE,*PSYSTEM_RESOURCE_ATTRIBUTE_ACE;
   3038 
   3039     typedef struct _SYSTEM_SCOPED_POLICY_ID_ACE {
   3040       ACE_HEADER Header;
   3041       ACCESS_MASK Mask;
   3042       DWORD SidStart;
   3043     } SYSTEM_SCOPED_POLICY_ID_ACE,*PSYSTEM_SCOPED_POLICY_ID_ACE;
   3044 
   3045     typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
   3046       ACE_HEADER Header;
   3047       ACCESS_MASK Mask;
   3048       DWORD SidStart;
   3049     } SYSTEM_MANDATORY_LABEL_ACE, *PSYSTEM_MANDATORY_LABEL_ACE;
   3050 
   3051 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
   3052 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
   3053 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
   3054 
   3055 #define SYSTEM_MANDATORY_LABEL_VALID_MASK (SYSTEM_MANDATORY_LABEL_NO_WRITE_UP | SYSTEM_MANDATORY_LABEL_NO_READ_UP | SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP)
   3056 
   3057     typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
   3058       ACE_HEADER Header;
   3059       ACCESS_MASK Mask;
   3060       DWORD Flags;
   3061       GUID ObjectType;
   3062       GUID InheritedObjectType;
   3063       DWORD SidStart;
   3064     } ACCESS_ALLOWED_OBJECT_ACE,*PACCESS_ALLOWED_OBJECT_ACE;
   3065 
   3066     typedef struct _ACCESS_DENIED_OBJECT_ACE {
   3067       ACE_HEADER Header;
   3068       ACCESS_MASK Mask;
   3069       DWORD Flags;
   3070       GUID ObjectType;
   3071       GUID InheritedObjectType;
   3072       DWORD SidStart;
   3073     } ACCESS_DENIED_OBJECT_ACE,*PACCESS_DENIED_OBJECT_ACE;
   3074 
   3075     typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
   3076       ACE_HEADER Header;
   3077       ACCESS_MASK Mask;
   3078       DWORD Flags;
   3079       GUID ObjectType;
   3080       GUID InheritedObjectType;
   3081       DWORD SidStart;
   3082     } SYSTEM_AUDIT_OBJECT_ACE,*PSYSTEM_AUDIT_OBJECT_ACE;
   3083 
   3084     typedef struct _SYSTEM_ALARM_OBJECT_ACE {
   3085       ACE_HEADER Header;
   3086       ACCESS_MASK Mask;
   3087       DWORD Flags;
   3088       GUID ObjectType;
   3089       GUID InheritedObjectType;
   3090       DWORD SidStart;
   3091     } SYSTEM_ALARM_OBJECT_ACE,*PSYSTEM_ALARM_OBJECT_ACE;
   3092 
   3093     typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
   3094       ACE_HEADER Header;
   3095       ACCESS_MASK Mask;
   3096       DWORD SidStart;
   3097     } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
   3098 
   3099     typedef struct _ACCESS_DENIED_CALLBACK_ACE {
   3100       ACE_HEADER Header;
   3101       ACCESS_MASK Mask;
   3102       DWORD SidStart;
   3103     } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
   3104 
   3105     typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
   3106       ACE_HEADER Header;
   3107       ACCESS_MASK Mask;
   3108       DWORD SidStart;
   3109     } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
   3110 
   3111     typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
   3112       ACE_HEADER Header;
   3113       ACCESS_MASK Mask;
   3114       DWORD SidStart;
   3115     } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
   3116 
   3117     typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
   3118       ACE_HEADER Header;
   3119       ACCESS_MASK Mask;
   3120       DWORD Flags;
   3121       GUID ObjectType;
   3122       GUID InheritedObjectType;
   3123       DWORD SidStart;
   3124 
   3125     } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE,*PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
   3126 
   3127     typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
   3128       ACE_HEADER Header;
   3129       ACCESS_MASK Mask;
   3130       DWORD Flags;
   3131       GUID ObjectType;
   3132       GUID InheritedObjectType;
   3133       DWORD SidStart;
   3134     } ACCESS_DENIED_CALLBACK_OBJECT_ACE,*PACCESS_DENIED_CALLBACK_OBJECT_ACE;
   3135 
   3136     typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
   3137       ACE_HEADER Header;
   3138       ACCESS_MASK Mask;
   3139       DWORD Flags;
   3140       GUID ObjectType;
   3141       GUID InheritedObjectType;
   3142       DWORD SidStart;
   3143     } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE,*PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
   3144 
   3145     typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
   3146       ACE_HEADER Header;
   3147       ACCESS_MASK Mask;
   3148       DWORD Flags;
   3149       GUID ObjectType;
   3150       GUID InheritedObjectType;
   3151       DWORD SidStart;
   3152 
   3153     } SYSTEM_ALARM_CALLBACK_OBJECT_ACE,*PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
   3154 
   3155 #define ACE_OBJECT_TYPE_PRESENT 0x1
   3156 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
   3157 
   3158     typedef enum _ACL_INFORMATION_CLASS {
   3159       AclRevisionInformation = 1,AclSizeInformation
   3160     } ACL_INFORMATION_CLASS;
   3161 
   3162     typedef struct _ACL_REVISION_INFORMATION {
   3163       DWORD AclRevision;
   3164     } ACL_REVISION_INFORMATION;
   3165     typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
   3166 
   3167     typedef struct _ACL_SIZE_INFORMATION {
   3168       DWORD AceCount;
   3169       DWORD AclBytesInUse;
   3170       DWORD AclBytesFree;
   3171     } ACL_SIZE_INFORMATION;
   3172     typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
   3173 
   3174 #define SECURITY_DESCRIPTOR_REVISION (1)
   3175 #define SECURITY_DESCRIPTOR_REVISION1 (1)
   3176 
   3177 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
   3178 
   3179     typedef WORD SECURITY_DESCRIPTOR_CONTROL,*PSECURITY_DESCRIPTOR_CONTROL;
   3180 
   3181 #define SE_OWNER_DEFAULTED (0x0001)
   3182 #define SE_GROUP_DEFAULTED (0x0002)
   3183 #define SE_DACL_PRESENT (0x0004)
   3184 #define SE_DACL_DEFAULTED (0x0008)
   3185 #define SE_SACL_PRESENT (0x0010)
   3186 #define SE_SACL_DEFAULTED (0x0020)
   3187 #define SE_DACL_AUTO_INHERIT_REQ (0x0100)
   3188 #define SE_SACL_AUTO_INHERIT_REQ (0x0200)
   3189 #define SE_DACL_AUTO_INHERITED (0x0400)
   3190 #define SE_SACL_AUTO_INHERITED (0x0800)
   3191 #define SE_DACL_PROTECTED (0x1000)
   3192 #define SE_SACL_PROTECTED (0x2000)
   3193 #define SE_RM_CONTROL_VALID (0x4000)
   3194 #define SE_SELF_RELATIVE (0x8000)
   3195 
   3196     typedef struct _SECURITY_DESCRIPTOR_RELATIVE {
   3197       BYTE Revision;
   3198       BYTE Sbz1;
   3199       SECURITY_DESCRIPTOR_CONTROL Control;
   3200       DWORD Owner;
   3201       DWORD Group;
   3202       DWORD Sacl;
   3203       DWORD Dacl;
   3204     } SECURITY_DESCRIPTOR_RELATIVE,*PISECURITY_DESCRIPTOR_RELATIVE;
   3205 
   3206     typedef struct _SECURITY_DESCRIPTOR {
   3207       BYTE Revision;
   3208       BYTE Sbz1;
   3209       SECURITY_DESCRIPTOR_CONTROL Control;
   3210       PSID Owner;
   3211       PSID Group;
   3212       PACL Sacl;
   3213       PACL Dacl;
   3214     } SECURITY_DESCRIPTOR,*PISECURITY_DESCRIPTOR;
   3215 
   3216     typedef struct _OBJECT_TYPE_LIST {
   3217       WORD Level;
   3218       WORD Sbz;
   3219       GUID *ObjectType;
   3220     } OBJECT_TYPE_LIST,*POBJECT_TYPE_LIST;
   3221 
   3222 #define ACCESS_OBJECT_GUID 0
   3223 #define ACCESS_PROPERTY_SET_GUID 1
   3224 #define ACCESS_PROPERTY_GUID 2
   3225 
   3226 #define ACCESS_MAX_LEVEL 4
   3227 
   3228     typedef enum _AUDIT_EVENT_TYPE {
   3229       AuditEventObjectAccess,AuditEventDirectoryServiceAccess
   3230     } AUDIT_EVENT_TYPE,*PAUDIT_EVENT_TYPE;
   3231 
   3232 #define AUDIT_ALLOW_NO_PRIVILEGE 0x1
   3233 
   3234 #define ACCESS_DS_SOURCE_A "DS"
   3235 #define ACCESS_DS_SOURCE_W L"DS"
   3236 #define ACCESS_DS_OBJECT_TYPE_NAME_A "Directory Service Object"
   3237 #define ACCESS_DS_OBJECT_TYPE_NAME_W L"Directory Service Object"
   3238 
   3239 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (__MSABI_LONG(0x00000001))
   3240 #define SE_PRIVILEGE_ENABLED (__MSABI_LONG(0x00000002))
   3241 #define SE_PRIVILEGE_REMOVED (0X00000004L)
   3242 #define SE_PRIVILEGE_USED_FOR_ACCESS (__MSABI_LONG(0x80000000))
   3243 
   3244 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_REMOVED | SE_PRIVILEGE_USED_FOR_ACCESS)
   3245 
   3246 #define PRIVILEGE_SET_ALL_NECESSARY (1)
   3247 
   3248     typedef struct _PRIVILEGE_SET {
   3249       DWORD PrivilegeCount;
   3250       DWORD Control;
   3251       LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
   3252     } PRIVILEGE_SET,*PPRIVILEGE_SET;
   3253 
   3254 #define ACCESS_REASON_TYPE_MASK 0x00ff0000
   3255 #define ACCESS_REASON_DATA_MASK 0x0000ffff
   3256 
   3257 #define ACCESS_REASON_STAGING_MASK 0x80000000
   3258 #define ACCESS_REASON_EXDATA_MASK 0x7f000000
   3259 
   3260     typedef enum _ACCESS_REASON_TYPE {
   3261       AccessReasonNone = 0x00000000,
   3262       AccessReasonAllowedAce = 0x00010000,
   3263       AccessReasonDeniedAce = 0x00020000,
   3264       AccessReasonAllowedParentAce = 0x00030000,
   3265       AccessReasonDeniedParentAce = 0x00040000,
   3266       AccessReasonNotGrantedByCape = 0x00050000,
   3267       AccessReasonNotGrantedByParentCape = 0x00060000,
   3268       AccessReasonNotGrantedToAppContainer = 0x00070000,
   3269       AccessReasonMissingPrivilege = 0x00100000,
   3270       AccessReasonFromPrivilege = 0x00200000,
   3271       AccessReasonIntegrityLevel = 0x00300000,
   3272       AccessReasonOwnership = 0x00400000,
   3273       AccessReasonNullDacl = 0x00500000,
   3274       AccessReasonEmptyDacl = 0x00600000,
   3275       AccessReasonNoSD = 0x00700000,
   3276       AccessReasonNoGrant = 0x00800000
   3277     } ACCESS_REASON_TYPE;
   3278     typedef DWORD ACCESS_REASON;
   3279 
   3280     typedef struct _ACCESS_REASONS {
   3281       ACCESS_REASON Data[32];
   3282     } ACCESS_REASONS,*PACCESS_REASONS;
   3283 
   3284 #define SE_SECURITY_DESCRIPTOR_FLAG_NO_OWNER_ACE 0x00000001
   3285 #define SE_SECURITY_DESCRIPTOR_FLAG_NO_LABEL_ACE 0x00000002
   3286 #define SE_SECURITY_DESCRIPTOR_VALID_FLAGS 0x00000003
   3287 
   3288     typedef struct _SE_SECURITY_DESCRIPTOR {
   3289       DWORD Size;
   3290       DWORD Flags;
   3291       PSECURITY_DESCRIPTOR SecurityDescriptor;
   3292     } SE_SECURITY_DESCRIPTOR,*PSE_SECURITY_DESCRIPTOR;
   3293 
   3294     typedef struct _SE_ACCESS_REQUEST {
   3295       DWORD Size;
   3296       PSE_SECURITY_DESCRIPTOR SeSecurityDescriptor;
   3297       ACCESS_MASK DesiredAccess;
   3298       ACCESS_MASK PreviouslyGrantedAccess;
   3299       PSID PrincipalSelfSid;
   3300       PGENERIC_MAPPING GenericMapping;
   3301       DWORD ObjectTypeListCount;
   3302       POBJECT_TYPE_LIST ObjectTypeList;
   3303     } SE_ACCESS_REQUEST,*PSE_ACCESS_REQUEST;
   3304 
   3305     typedef struct _SE_ACCESS_REPLY {
   3306       DWORD Size;
   3307       DWORD ResultListCount;
   3308       PACCESS_MASK GrantedAccess;
   3309       PDWORD AccessStatus;
   3310       PACCESS_REASONS AccessReason;
   3311       PPRIVILEGE_SET *Privileges;
   3312     } SE_ACCESS_REPLY,*PSE_ACCESS_REPLY;
   3313 
   3314 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
   3315 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
   3316 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
   3317 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
   3318 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
   3319 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
   3320 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
   3321 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
   3322 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
   3323 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
   3324 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
   3325 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
   3326 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
   3327 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
   3328 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
   3329 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
   3330 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
   3331 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
   3332 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
   3333 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
   3334 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
   3335 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
   3336 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
   3337 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
   3338 #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
   3339 #define SE_SYNC_AGENT_NAME TEXT("SeSyncAgentPrivilege")
   3340 #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
   3341 #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
   3342 #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
   3343 #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
   3344 #define SE_TRUSTED_CREDMAN_ACCESS_NAME TEXT("SeTrustedCredManAccessPrivilege")
   3345 #define SE_RELABEL_NAME TEXT("SeRelabelPrivilege")
   3346 #define SE_INC_WORKING_SET_NAME TEXT("SeIncreaseWorkingSetPrivilege")
   3347 #define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege")
   3348 #define SE_CREATE_SYMBOLIC_LINK_NAME TEXT("SeCreateSymbolicLinkPrivilege")
   3349 
   3350     typedef enum _SECURITY_IMPERSONATION_LEVEL {
   3351       SecurityAnonymous,SecurityIdentification,SecurityImpersonation,SecurityDelegation
   3352     } SECURITY_IMPERSONATION_LEVEL,*PSECURITY_IMPERSONATION_LEVEL;
   3353 
   3354 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
   3355 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
   3356 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
   3357 #define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
   3358 
   3359 #define TOKEN_ASSIGN_PRIMARY (0x0001)
   3360 #define TOKEN_DUPLICATE (0x0002)
   3361 #define TOKEN_IMPERSONATE (0x0004)
   3362 #define TOKEN_QUERY (0x0008)
   3363 #define TOKEN_QUERY_SOURCE (0x0010)
   3364 #define TOKEN_ADJUST_PRIVILEGES (0x0020)
   3365 #define TOKEN_ADJUST_GROUPS (0x0040)
   3366 #define TOKEN_ADJUST_DEFAULT (0x0080)
   3367 #define TOKEN_ADJUST_SESSIONID (0x0100)
   3368 
   3369 #define TOKEN_ALL_ACCESS_P (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
   3370 #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID)
   3371 #define TOKEN_READ (STANDARD_RIGHTS_READ | TOKEN_QUERY)
   3372 
   3373 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
   3374 
   3375 #define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
   3376 
   3377     typedef enum _TOKEN_TYPE {
   3378       TokenPrimary = 1,TokenImpersonation
   3379     } TOKEN_TYPE;
   3380     typedef TOKEN_TYPE *PTOKEN_TYPE;
   3381 
   3382     typedef enum _TOKEN_ELEVATION_TYPE {
   3383       TokenElevationTypeDefault   = 1,
   3384       TokenElevationTypeFull,
   3385       TokenElevationTypeLimited
   3386     } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
   3387 
   3388     typedef enum _TOKEN_INFORMATION_CLASS {
   3389       TokenUser = 1,
   3390       TokenGroups,
   3391       TokenPrivileges,
   3392       TokenOwner,
   3393       TokenPrimaryGroup,
   3394       TokenDefaultDacl,
   3395       TokenSource,
   3396       TokenType,
   3397       TokenImpersonationLevel,
   3398       TokenStatistics,
   3399       TokenRestrictedSids,
   3400       TokenSessionId,
   3401       TokenGroupsAndPrivileges,
   3402       TokenSessionReference,
   3403       TokenSandBoxInert,
   3404       TokenAuditPolicy,
   3405       TokenOrigin,
   3406       TokenElevationType,
   3407       TokenLinkedToken,
   3408       TokenElevation,
   3409       TokenHasRestrictions,
   3410       TokenAccessInformation,
   3411       TokenVirtualizationAllowed,
   3412       TokenVirtualizationEnabled,
   3413       TokenIntegrityLevel,
   3414       TokenUIAccess,
   3415       TokenMandatoryPolicy,
   3416       TokenLogonSid,
   3417       TokenIsAppContainer,
   3418       TokenCapabilities,
   3419       TokenAppContainerSid,
   3420       TokenAppContainerNumber,
   3421       TokenUserClaimAttributes,
   3422       TokenDeviceClaimAttributes,
   3423       TokenRestrictedUserClaimAttributes,
   3424       TokenRestrictedDeviceClaimAttributes,
   3425       TokenDeviceGroups,
   3426       TokenRestrictedDeviceGroups,
   3427       TokenSecurityAttributes,
   3428       TokenIsRestricted,
   3429       MaxTokenInfoClass
   3430     } TOKEN_INFORMATION_CLASS,*PTOKEN_INFORMATION_CLASS;
   3431 
   3432     typedef struct _TOKEN_USER {
   3433       SID_AND_ATTRIBUTES User;
   3434     } TOKEN_USER,*PTOKEN_USER;
   3435 
   3436     typedef struct _TOKEN_GROUPS {
   3437       DWORD GroupCount;
   3438 #ifdef __WIDL__
   3439       [size_is (GroupCount)] SID_AND_ATTRIBUTES Groups[*];
   3440 #else
   3441       SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
   3442 #endif
   3443     } TOKEN_GROUPS,*PTOKEN_GROUPS;
   3444 
   3445     typedef struct _TOKEN_PRIVILEGES {
   3446       DWORD PrivilegeCount;
   3447       LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
   3448     } TOKEN_PRIVILEGES,*PTOKEN_PRIVILEGES;
   3449 
   3450     typedef struct _TOKEN_OWNER {
   3451       PSID Owner;
   3452     } TOKEN_OWNER,*PTOKEN_OWNER;
   3453 
   3454     typedef struct _TOKEN_PRIMARY_GROUP {
   3455       PSID PrimaryGroup;
   3456     } TOKEN_PRIMARY_GROUP,*PTOKEN_PRIMARY_GROUP;
   3457 
   3458     typedef struct _TOKEN_DEFAULT_DACL {
   3459       PACL DefaultDacl;
   3460     } TOKEN_DEFAULT_DACL,*PTOKEN_DEFAULT_DACL;
   3461 
   3462     typedef struct _TOKEN_USER_CLAIMS {
   3463       PCLAIMS_BLOB UserClaims;
   3464     } TOKEN_USER_CLAIMS,*PTOKEN_USER_CLAIMS;
   3465 
   3466     typedef struct _TOKEN_DEVICE_CLAIMS {
   3467       PCLAIMS_BLOB DeviceClaims;
   3468     } TOKEN_DEVICE_CLAIMS,*PTOKEN_DEVICE_CLAIMS;
   3469 
   3470     typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
   3471       DWORD SidCount;
   3472       DWORD SidLength;
   3473       PSID_AND_ATTRIBUTES Sids;
   3474       DWORD RestrictedSidCount;
   3475       DWORD RestrictedSidLength;
   3476       PSID_AND_ATTRIBUTES RestrictedSids;
   3477       DWORD PrivilegeCount;
   3478       DWORD PrivilegeLength;
   3479       PLUID_AND_ATTRIBUTES Privileges;
   3480       LUID AuthenticationId;
   3481     } TOKEN_GROUPS_AND_PRIVILEGES,*PTOKEN_GROUPS_AND_PRIVILEGES;
   3482 
   3483     typedef struct _TOKEN_LINKED_TOKEN {
   3484       HANDLE LinkedToken;
   3485     } TOKEN_LINKED_TOKEN,*PTOKEN_LINKED_TOKEN;
   3486 
   3487     typedef struct _TOKEN_ELEVATION {
   3488       DWORD TokenIsElevated;
   3489     } TOKEN_ELEVATION,*PTOKEN_ELEVATION;
   3490 
   3491     typedef struct _TOKEN_MANDATORY_LABEL {
   3492       SID_AND_ATTRIBUTES Label;
   3493     } TOKEN_MANDATORY_LABEL,*PTOKEN_MANDATORY_LABEL;
   3494 
   3495 #define TOKEN_MANDATORY_POLICY_OFF 0x0
   3496 #define TOKEN_MANDATORY_POLICY_NO_WRITE_UP 0x1
   3497 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
   3498 
   3499 #define TOKEN_MANDATORY_POLICY_VALID_MASK (TOKEN_MANDATORY_POLICY_NO_WRITE_UP | TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN)
   3500 
   3501     typedef struct _TOKEN_MANDATORY_POLICY {
   3502       DWORD Policy;
   3503     } TOKEN_MANDATORY_POLICY,*PTOKEN_MANDATORY_POLICY;
   3504 
   3505     typedef struct _TOKEN_ACCESS_INFORMATION {
   3506       PSID_AND_ATTRIBUTES_HASH SidHash;
   3507       PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
   3508       PTOKEN_PRIVILEGES Privileges;
   3509       LUID AuthenticationId;
   3510       TOKEN_TYPE TokenType;
   3511       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   3512       TOKEN_MANDATORY_POLICY MandatoryPolicy;
   3513       DWORD Flags;
   3514       DWORD AppContainerNumber;
   3515       PSID PackageSid;
   3516       PSID_AND_ATTRIBUTES_HASH CapabilitiesHash;
   3517     } TOKEN_ACCESS_INFORMATION,*PTOKEN_ACCESS_INFORMATION;
   3518 
   3519 #define POLICY_AUDIT_SUBCATEGORY_COUNT (56)
   3520 
   3521     typedef struct _TOKEN_AUDIT_POLICY {
   3522       UCHAR PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
   3523     } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
   3524 
   3525 #define TOKEN_SOURCE_LENGTH 8
   3526 
   3527     typedef struct _TOKEN_SOURCE {
   3528       CHAR SourceName[TOKEN_SOURCE_LENGTH];
   3529       LUID SourceIdentifier;
   3530     } TOKEN_SOURCE,*PTOKEN_SOURCE;
   3531 
   3532     typedef struct _TOKEN_STATISTICS {
   3533       LUID TokenId;
   3534       LUID AuthenticationId;
   3535       LARGE_INTEGER ExpirationTime;
   3536       TOKEN_TYPE TokenType;
   3537       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   3538       DWORD DynamicCharged;
   3539       DWORD DynamicAvailable;
   3540       DWORD GroupCount;
   3541       DWORD PrivilegeCount;
   3542       LUID ModifiedId;
   3543     } TOKEN_STATISTICS,*PTOKEN_STATISTICS;
   3544 
   3545     typedef struct _TOKEN_CONTROL {
   3546       LUID TokenId;
   3547       LUID AuthenticationId;
   3548       LUID ModifiedId;
   3549       TOKEN_SOURCE TokenSource;
   3550     } TOKEN_CONTROL,*PTOKEN_CONTROL;
   3551 
   3552     typedef struct _TOKEN_ORIGIN {
   3553       LUID OriginatingLogonSession;
   3554     } TOKEN_ORIGIN,*PTOKEN_ORIGIN;
   3555 
   3556     typedef enum _MANDATORY_LEVEL {
   3557       MandatoryLevelUntrusted = 0,
   3558       MandatoryLevelLow,
   3559       MandatoryLevelMedium,
   3560       MandatoryLevelHigh,
   3561       MandatoryLevelSystem,
   3562       MandatoryLevelSecureProcess,
   3563       MandatoryLevelCount
   3564     } MANDATORY_LEVEL,*PMANDATORY_LEVEL;
   3565 
   3566     typedef struct _TOKEN_APPCONTAINER_INFORMATION {
   3567       PSID TokenAppContainer;
   3568     } TOKEN_APPCONTAINER_INFORMATION,*PTOKEN_APPCONTAINER_INFORMATION;
   3569 
   3570 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_INVALID 0x00
   3571 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_INT64 0x01
   3572 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_UINT64 0x02
   3573 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_STRING 0x03
   3574 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_FQBN 0x04
   3575 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_SID 0x05
   3576 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_BOOLEAN 0x06
   3577 
   3578     typedef struct _CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE {
   3579       DWORD64 Version;
   3580       PWSTR Name;
   3581     } CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE,*PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE;
   3582 
   3583     typedef struct _CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE {
   3584       PVOID pValue;
   3585       DWORD ValueLength;
   3586     } CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE, *PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE;
   3587 
   3588 #define CLAIM_SECURITY_ATTRIBUTE_TYPE_OCTET_STRING 0x10
   3589 #define CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE 0x0001
   3590 #define CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE 0x0002
   3591 #define CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY 0x0004
   3592 #define CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT 0x0008
   3593 #define CLAIM_SECURITY_ATTRIBUTE_DISABLED 0x0010
   3594 #define CLAIM_SECURITY_ATTRIBUTE_MANDATORY 0x0020
   3595 
   3596 #define CLAIM_SECURITY_ATTRIBUTE_VALID_FLAGS (CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE | CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE | CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY | CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT | CLAIM_SECURITY_ATTRIBUTE_DISABLED | CLAIM_SECURITY_ATTRIBUTE_MANDATORY)
   3597 #define CLAIM_SECURITY_ATTRIBUTE_CUSTOM_FLAGS 0xffff0000
   3598 
   3599     typedef struct _CLAIM_SECURITY_ATTRIBUTE_V1 {
   3600       PWSTR Name;
   3601       WORD ValueType;
   3602       WORD Reserved;
   3603       DWORD Flags;
   3604       DWORD ValueCount;
   3605       union {
   3606 	PLONG64 pInt64;
   3607 	PDWORD64 pUint64;
   3608 	PWSTR *ppString;
   3609 	PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE pFqbn;
   3610 	PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE pOctetString;
   3611       } Values;
   3612     } CLAIM_SECURITY_ATTRIBUTE_V1,*PCLAIM_SECURITY_ATTRIBUTE_V1;
   3613 
   3614     typedef struct _CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 {
   3615       DWORD Name;
   3616       WORD ValueType;
   3617       WORD Reserved;
   3618       DWORD Flags;
   3619       DWORD ValueCount;
   3620       union {
   3621 	DWORD pInt64[ANYSIZE_ARRAY];
   3622 	DWORD pUint64[ANYSIZE_ARRAY];
   3623 	DWORD ppString[ANYSIZE_ARRAY];
   3624 	DWORD pFqbn[ANYSIZE_ARRAY];
   3625 	DWORD pOctetString[ANYSIZE_ARRAY];
   3626       } Values;
   3627     } CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1,*PCLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1;
   3628 
   3629 #define CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1 1
   3630 
   3631 #define CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1
   3632 
   3633     typedef struct _CLAIM_SECURITY_ATTRIBUTES_INFORMATION {
   3634       WORD Version;
   3635       WORD Reserved;
   3636       DWORD AttributeCount;
   3637       union {
   3638 	PCLAIM_SECURITY_ATTRIBUTE_V1 pAttributeV1;
   3639       } Attribute;
   3640     } CLAIM_SECURITY_ATTRIBUTES_INFORMATION,*PCLAIM_SECURITY_ATTRIBUTES_INFORMATION;
   3641 
   3642 #define SECURITY_DYNAMIC_TRACKING (TRUE)
   3643 #define SECURITY_STATIC_TRACKING (FALSE)
   3644 
   3645     typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,*PSECURITY_CONTEXT_TRACKING_MODE;
   3646 
   3647     typedef struct _SECURITY_QUALITY_OF_SERVICE {
   3648       DWORD Length;
   3649       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   3650       SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
   3651       BOOLEAN EffectiveOnly;
   3652     } SECURITY_QUALITY_OF_SERVICE,*PSECURITY_QUALITY_OF_SERVICE;
   3653 
   3654     typedef struct _SE_IMPERSONATION_STATE {
   3655       PACCESS_TOKEN Token;
   3656       BOOLEAN CopyOnOpen;
   3657       BOOLEAN EffectiveOnly;
   3658       SECURITY_IMPERSONATION_LEVEL Level;
   3659     } SE_IMPERSONATION_STATE,*PSE_IMPERSONATION_STATE;
   3660 
   3661 #define DISABLE_MAX_PRIVILEGE 0x1
   3662 #define SANDBOX_INERT 0x2
   3663 #define LUA_TOKEN 0x4
   3664 #define WRITE_RESTRICTED 0x8
   3665 
   3666     typedef DWORD SECURITY_INFORMATION,*PSECURITY_INFORMATION;
   3667 
   3668 #define OWNER_SECURITY_INFORMATION (__MSABI_LONG(0x00000001))
   3669 #define GROUP_SECURITY_INFORMATION (__MSABI_LONG(0x00000002))
   3670 #define DACL_SECURITY_INFORMATION (__MSABI_LONG(0x00000004))
   3671 #define SACL_SECURITY_INFORMATION (__MSABI_LONG(0x00000008))
   3672 #define LABEL_SECURITY_INFORMATION (__MSABI_LONG(0x00000010))
   3673 #define ATTRIBUTE_SECURITY_INFORMATION (__MSABI_LONG(0x00000020))
   3674 #define SCOPE_SECURITY_INFORMATION (__MSABI_LONG(0x00000040))
   3675 #define BACKUP_SECURITY_INFORMATION (__MSABI_LONG(0x00010000))
   3676 
   3677 #define PROTECTED_DACL_SECURITY_INFORMATION (__MSABI_LONG(0x80000000))
   3678 #define PROTECTED_SACL_SECURITY_INFORMATION (__MSABI_LONG(0x40000000))
   3679 #define UNPROTECTED_DACL_SECURITY_INFORMATION (__MSABI_LONG(0x20000000))
   3680 #define UNPROTECTED_SACL_SECURITY_INFORMATION (__MSABI_LONG(0x10000000))
   3681 
   3682     typedef enum _SE_LEARNING_MODE_DATA_TYPE {
   3683       SeLearningModeInvalidType = 0,
   3684       SeLearningModeSettings,
   3685       SeLearningModeMax
   3686     } SE_LEARNING_MODE_DATA_TYPE;
   3687 
   3688 #define SE_LEARNING_MODE_FLAG_PERMISSIVE 0x00000001
   3689 
   3690     typedef struct _SECURITY_CAPABILITIES {
   3691       PSID AppContainerSid;
   3692       PSID_AND_ATTRIBUTES Capabilities;
   3693       DWORD CapabilityCount;
   3694       DWORD Reserved;
   3695     } SECURITY_CAPABILITIES,*PSECURITY_CAPABILITIES,*LPSECURITY_CAPABILITIES;
   3696 
   3697 #define PROCESS_TERMINATE (0x0001)
   3698 #define PROCESS_CREATE_THREAD (0x0002)
   3699 #define PROCESS_SET_SESSIONID (0x0004)
   3700 #define PROCESS_VM_OPERATION (0x0008)
   3701 #define PROCESS_VM_READ (0x0010)
   3702 #define PROCESS_VM_WRITE (0x0020)
   3703 #define PROCESS_DUP_HANDLE (0x0040)
   3704 #define PROCESS_CREATE_PROCESS (0x0080)
   3705 #define PROCESS_SET_QUOTA (0x0100)
   3706 #define PROCESS_SET_INFORMATION (0x0200)
   3707 #define PROCESS_QUERY_INFORMATION (0x0400)
   3708 #define PROCESS_SUSPEND_RESUME (0x0800)
   3709 #define PROCESS_QUERY_LIMITED_INFORMATION (0x1000)
   3710 
   3711 #if NTDDI_VERSION >= 0x06000000
   3712 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xffff)
   3713 #else
   3714 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xfff)
   3715 #endif
   3716 
   3717 #ifdef _WIN64
   3718 #define MAXIMUM_PROC_PER_GROUP 64
   3719 #else
   3720 #define MAXIMUM_PROC_PER_GROUP 32
   3721 #endif
   3722 
   3723 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP
   3724 
   3725 #define THREAD_TERMINATE (0x0001)
   3726 #define THREAD_SUSPEND_RESUME (0x0002)
   3727 #define THREAD_GET_CONTEXT (0x0008)
   3728 #define THREAD_SET_CONTEXT (0x0010)
   3729 #define THREAD_SET_INFORMATION (0x0020)
   3730 #define THREAD_QUERY_INFORMATION (0x0040)
   3731 #define THREAD_SET_THREAD_TOKEN (0x0080)
   3732 #define THREAD_IMPERSONATE (0x0100)
   3733 #define THREAD_DIRECT_IMPERSONATION (0x0200)
   3734 #define THREAD_SET_LIMITED_INFORMATION (0x0400)
   3735 #define THREAD_QUERY_LIMITED_INFORMATION (0x0800)
   3736 
   3737 #if NTDDI_VERSION >= 0x06000000
   3738 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xffff)
   3739 #else
   3740 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3ff)
   3741 #endif
   3742 
   3743 #define JOB_OBJECT_ASSIGN_PROCESS (0x0001)
   3744 #define JOB_OBJECT_SET_ATTRIBUTES (0x0002)
   3745 #define JOB_OBJECT_QUERY (0x0004)
   3746 #define JOB_OBJECT_TERMINATE (0x0008)
   3747 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES (0x0010)
   3748 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1F)
   3749 
   3750     typedef struct _JOB_SET_ARRAY {
   3751       HANDLE JobHandle;
   3752       DWORD MemberLevel;
   3753       DWORD Flags;
   3754     } JOB_SET_ARRAY,*PJOB_SET_ARRAY;
   3755 
   3756 #define FLS_MAXIMUM_AVAILABLE 128
   3757 #define TLS_MINIMUM_AVAILABLE 64
   3758 
   3759 #ifndef __MINGW_EXCPT_DEFINE_PSDK
   3760     typedef struct _EXCEPTION_REGISTRATION_RECORD {
   3761       __C89_NAMELESS union {
   3762         struct _EXCEPTION_REGISTRATION_RECORD *Next;
   3763         struct _EXCEPTION_REGISTRATION_RECORD *prev;
   3764       };
   3765       __C89_NAMELESS union {
   3766         PEXCEPTION_ROUTINE Handler;
   3767         PEXCEPTION_ROUTINE handler;
   3768       };
   3769     } EXCEPTION_REGISTRATION_RECORD;
   3770 
   3771     typedef EXCEPTION_REGISTRATION_RECORD *PEXCEPTION_REGISTRATION_RECORD;
   3772 
   3773     typedef EXCEPTION_REGISTRATION_RECORD EXCEPTION_REGISTRATION;
   3774     typedef PEXCEPTION_REGISTRATION_RECORD PEXCEPTION_REGISTRATION;
   3775 #endif
   3776 
   3777 #ifndef _NT_TIB_DEFINED
   3778 #define _NT_TIB_DEFINED
   3779     __C89_NAMELESS typedef struct _NT_TIB {
   3780       struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
   3781       PVOID StackBase;
   3782       PVOID StackLimit;
   3783       PVOID SubSystemTib;
   3784       __C89_NAMELESS union {
   3785 	PVOID FiberData;
   3786 	DWORD Version;
   3787       };
   3788       PVOID ArbitraryUserPointer;
   3789       struct _NT_TIB *Self;
   3790     } NT_TIB;
   3791     typedef NT_TIB *PNT_TIB;
   3792 #endif /* _NT_TIB_DEFINED */
   3793 
   3794     __C89_NAMELESS typedef struct _NT_TIB32 {
   3795       DWORD ExceptionList;
   3796       DWORD StackBase;
   3797       DWORD StackLimit;
   3798       DWORD SubSystemTib;
   3799       __C89_NAMELESS union {
   3800 	DWORD FiberData;
   3801 	DWORD Version;
   3802       };
   3803       DWORD ArbitraryUserPointer;
   3804       DWORD Self;
   3805     } NT_TIB32,*PNT_TIB32;
   3806 
   3807     __C89_NAMELESS typedef struct _NT_TIB64 {
   3808       DWORD64 ExceptionList;
   3809       DWORD64 StackBase;
   3810       DWORD64 StackLimit;
   3811       DWORD64 SubSystemTib;
   3812       __C89_NAMELESS union {
   3813 	DWORD64 FiberData;
   3814 	DWORD Version;
   3815       };
   3816       DWORD64 ArbitraryUserPointer;
   3817       DWORD64 Self;
   3818     } NT_TIB64,*PNT_TIB64;
   3819 
   3820 #if !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_)
   3821 #define WX86
   3822 #endif
   3823 
   3824 #define THREAD_BASE_PRIORITY_LOWRT 15
   3825 #define THREAD_BASE_PRIORITY_MAX 2
   3826 #define THREAD_BASE_PRIORITY_MIN (-2)
   3827 #define THREAD_BASE_PRIORITY_IDLE (-15)
   3828 
   3829     typedef struct _UMS_CREATE_THREAD_ATTRIBUTES {
   3830       DWORD UmsVersion;
   3831       PVOID UmsContext;
   3832       PVOID UmsCompletionList;
   3833     } UMS_CREATE_THREAD_ATTRIBUTES,*PUMS_CREATE_THREAD_ATTRIBUTES;
   3834 
   3835     typedef struct _QUOTA_LIMITS {
   3836       SIZE_T PagedPoolLimit;
   3837       SIZE_T NonPagedPoolLimit;
   3838       SIZE_T MinimumWorkingSetSize;
   3839       SIZE_T MaximumWorkingSetSize;
   3840       SIZE_T PagefileLimit;
   3841       LARGE_INTEGER TimeLimit;
   3842     } QUOTA_LIMITS,*PQUOTA_LIMITS;
   3843 
   3844 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
   3845 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
   3846 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
   3847 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
   3848 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
   3849 
   3850     typedef union _RATE_QUOTA_LIMIT {
   3851       DWORD RateData;
   3852       __C89_NAMELESS struct {
   3853         DWORD RatePercent : 7;
   3854         DWORD Reserved0   : 25;
   3855       } DUMMYSTRUCTNAME;
   3856     } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
   3857 
   3858     typedef struct _QUOTA_LIMITS_EX {
   3859       SIZE_T PagedPoolLimit;
   3860       SIZE_T NonPagedPoolLimit;
   3861       SIZE_T MinimumWorkingSetSize;
   3862       SIZE_T MaximumWorkingSetSize;
   3863       SIZE_T PagefileLimit;
   3864       LARGE_INTEGER TimeLimit;
   3865       SIZE_T WorkingSetLimit;
   3866       SIZE_T Reserved2;
   3867       SIZE_T Reserved3;
   3868       SIZE_T Reserved4;
   3869       DWORD Flags;
   3870       RATE_QUOTA_LIMIT CpuRateLimit;
   3871     } QUOTA_LIMITS_EX,*PQUOTA_LIMITS_EX;
   3872 
   3873     typedef struct _IO_COUNTERS {
   3874       ULONGLONG ReadOperationCount;
   3875       ULONGLONG WriteOperationCount;
   3876       ULONGLONG OtherOperationCount;
   3877       ULONGLONG ReadTransferCount;
   3878       ULONGLONG WriteTransferCount;
   3879       ULONGLONG OtherTransferCount;
   3880     } IO_COUNTERS;
   3881     typedef IO_COUNTERS *PIO_COUNTERS;
   3882 
   3883 #define MAX_HW_COUNTERS 16
   3884 #define THREAD_PROFILING_FLAG_DISPATCH 0x1
   3885 
   3886     typedef enum _HARDWARE_COUNTER_TYPE {
   3887       PMCCounter,
   3888       MaxHardwareCounterType
   3889     } HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
   3890 
   3891     typedef enum _PROCESS_MITIGATION_POLICY {
   3892       ProcessDEPPolicy,
   3893       ProcessASLRPolicy,
   3894       ProcessReserved1MitigationPolicy,
   3895       ProcessStrictHandleCheckPolicy,
   3896       ProcessSystemCallDisablePolicy,
   3897       ProcessMitigationOptionsMask,
   3898       ProcessExtensionPointDisablePolicy,
   3899       MaxProcessMitigationPolicy
   3900     } PROCESS_MITIGATION_POLICY,*PPROCESS_MITIGATION_POLICY;
   3901 
   3902     typedef struct _PROCESS_MITIGATION_ASLR_POLICY {
   3903       __C89_NAMELESS union {
   3904 	DWORD Flags;
   3905 	__C89_NAMELESS struct {
   3906 	  DWORD EnableBottomUpRandomization : 1;
   3907 	  DWORD EnableForceRelocateImages : 1;
   3908 	  DWORD EnableHighEntropy : 1;
   3909 	  DWORD DisallowStrippedImages : 1;
   3910 	  DWORD ReservedFlags : 28;
   3911 	};
   3912       };
   3913     } PROCESS_MITIGATION_ASLR_POLICY,*PPROCESS_MITIGATION_ASLR_POLICY;
   3914 
   3915     typedef struct _PROCESS_MITIGATION_DEP_POLICY {
   3916       __C89_NAMELESS union {
   3917 	DWORD Flags;
   3918 	__C89_NAMELESS struct {
   3919 	  DWORD Enable : 1;
   3920 	  DWORD DisableAtlThunkEmulation : 1;
   3921 	  DWORD ReservedFlags : 30;
   3922 	};
   3923       };
   3924       BOOLEAN Permanent;
   3925     } PROCESS_MITIGATION_DEP_POLICY,*PPROCESS_MITIGATION_DEP_POLICY;
   3926 
   3927     typedef struct _PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY {
   3928       __C89_NAMELESS union {
   3929 	DWORD Flags;
   3930 	__C89_NAMELESS struct {
   3931 	  DWORD RaiseExceptionOnInvalidHandleReference : 1;
   3932 	  DWORD HandleExceptionsPermanentlyEnabled : 1;
   3933 	  DWORD ReservedFlags : 30;
   3934 	};
   3935       };
   3936     } PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY,*PPROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY;
   3937 
   3938     typedef struct _PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY {
   3939       __C89_NAMELESS union {
   3940 	DWORD Flags;
   3941 	__C89_NAMELESS struct {
   3942 	  DWORD DisallowWin32kSystemCalls : 1;
   3943 	  DWORD ReservedFlags : 31;
   3944 	};
   3945       };
   3946     } PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY,*PPROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY;
   3947 
   3948     typedef struct _PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY {
   3949       __C89_NAMELESS union {
   3950 	DWORD Flags;
   3951 	__C89_NAMELESS struct {
   3952 	  DWORD DisableExtensionPoints : 1;
   3953 	  DWORD ReservedFlags : 31;
   3954 	};
   3955       };
   3956     } PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY,*PPROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY;
   3957 
   3958     typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
   3959       LARGE_INTEGER TotalUserTime;
   3960       LARGE_INTEGER TotalKernelTime;
   3961       LARGE_INTEGER ThisPeriodTotalUserTime;
   3962       LARGE_INTEGER ThisPeriodTotalKernelTime;
   3963       DWORD TotalPageFaultCount;
   3964       DWORD TotalProcesses;
   3965       DWORD ActiveProcesses;
   3966       DWORD TotalTerminatedProcesses;
   3967     } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION,*PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
   3968 
   3969     typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
   3970       LARGE_INTEGER PerProcessUserTimeLimit;
   3971       LARGE_INTEGER PerJobUserTimeLimit;
   3972       DWORD LimitFlags;
   3973       SIZE_T MinimumWorkingSetSize;
   3974       SIZE_T MaximumWorkingSetSize;
   3975       DWORD ActiveProcessLimit;
   3976       ULONG_PTR Affinity;
   3977       DWORD PriorityClass;
   3978       DWORD SchedulingClass;
   3979     } JOBOBJECT_BASIC_LIMIT_INFORMATION,*PJOBOBJECT_BASIC_LIMIT_INFORMATION;
   3980 
   3981     typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
   3982       JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
   3983       IO_COUNTERS IoInfo;
   3984       SIZE_T ProcessMemoryLimit;
   3985       SIZE_T JobMemoryLimit;
   3986       SIZE_T PeakProcessMemoryUsed;
   3987       SIZE_T PeakJobMemoryUsed;
   3988     } JOBOBJECT_EXTENDED_LIMIT_INFORMATION,*PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
   3989 
   3990     typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
   3991       DWORD NumberOfAssignedProcesses;
   3992       DWORD NumberOfProcessIdsInList;
   3993       ULONG_PTR ProcessIdList[1];
   3994     } JOBOBJECT_BASIC_PROCESS_ID_LIST,*PJOBOBJECT_BASIC_PROCESS_ID_LIST;
   3995 
   3996     typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
   3997       DWORD UIRestrictionsClass;
   3998     } JOBOBJECT_BASIC_UI_RESTRICTIONS,*PJOBOBJECT_BASIC_UI_RESTRICTIONS;
   3999 
   4000     typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
   4001       DWORD SecurityLimitFlags;
   4002       HANDLE JobToken;
   4003       PTOKEN_GROUPS SidsToDisable;
   4004       PTOKEN_PRIVILEGES PrivilegesToDelete;
   4005       PTOKEN_GROUPS RestrictedSids;
   4006     } JOBOBJECT_SECURITY_LIMIT_INFORMATION,*PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
   4007 
   4008     typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
   4009       DWORD EndOfJobTimeAction;
   4010     } JOBOBJECT_END_OF_JOB_TIME_INFORMATION,*PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
   4011 
   4012     typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
   4013       PVOID CompletionKey;
   4014       HANDLE CompletionPort;
   4015     } JOBOBJECT_ASSOCIATE_COMPLETION_PORT,*PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
   4016 
   4017     typedef struct _JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
   4018       JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
   4019       IO_COUNTERS IoInfo;
   4020     } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION,*PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
   4021 
   4022     typedef struct _JOBOBJECT_JOBSET_INFORMATION {
   4023       DWORD MemberLevel;
   4024     } JOBOBJECT_JOBSET_INFORMATION,*PJOBOBJECT_JOBSET_INFORMATION;
   4025 
   4026     typedef enum _JOBOBJECT_RATE_CONTROL_TOLERANCE {
   4027       ToleranceLow = 1,
   4028       ToleranceMedium,
   4029       ToleranceHigh
   4030     } JOBOBJECT_RATE_CONTROL_TOLERANCE;
   4031 
   4032     typedef enum _JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL {
   4033       ToleranceIntervalShort = 1,
   4034       ToleranceIntervalMedium,
   4035       ToleranceIntervalLong
   4036     } JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL;
   4037 
   4038     typedef struct _JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION {
   4039       DWORD64 IoReadBytesLimit;
   4040       DWORD64 IoWriteBytesLimit;
   4041       LARGE_INTEGER PerJobUserTimeLimit;
   4042       DWORD64 JobMemoryLimit;
   4043       JOBOBJECT_RATE_CONTROL_TOLERANCE RateControlTolerance;
   4044       JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL RateControlToleranceInterval;
   4045       DWORD LimitFlags;
   4046     } JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION,*PJOBOBJECT_NOTIFICATION_LIMIT_INFORMATION;
   4047 
   4048     typedef struct _JOBOBJECT_LIMIT_VIOLATION_INFORMATION {
   4049       DWORD LimitFlags;
   4050       DWORD ViolationLimitFlags;
   4051       DWORD64 IoReadBytes;
   4052       DWORD64 IoReadBytesLimit;
   4053       DWORD64 IoWriteBytes;
   4054       DWORD64 IoWriteBytesLimit;
   4055       LARGE_INTEGER PerJobUserTime;
   4056       LARGE_INTEGER PerJobUserTimeLimit;
   4057       DWORD64 JobMemory;
   4058       DWORD64 JobMemoryLimit;
   4059       JOBOBJECT_RATE_CONTROL_TOLERANCE RateControlTolerance;
   4060       JOBOBJECT_RATE_CONTROL_TOLERANCE_INTERVAL RateControlToleranceLimit;
   4061     } JOBOBJECT_LIMIT_VIOLATION_INFORMATION,*PJOBOBJECT_LIMIT_VIOLATION_INFORMATION;
   4062 
   4063     typedef struct _JOBOBJECT_CPU_RATE_CONTROL_INFORMATION {
   4064       DWORD ControlFlags;
   4065       __C89_NAMELESS union {
   4066 	DWORD CpuRate;
   4067 	DWORD Weight;
   4068       };
   4069     } JOBOBJECT_CPU_RATE_CONTROL_INFORMATION,*PJOBOBJECT_CPU_RATE_CONTROL_INFORMATION;
   4070 
   4071 #define JOB_OBJECT_TERMINATE_AT_END_OF_JOB 0
   4072 #define JOB_OBJECT_POST_AT_END_OF_JOB 1
   4073 
   4074 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
   4075 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
   4076 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
   4077 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
   4078 #define JOB_OBJECT_MSG_NEW_PROCESS 6
   4079 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
   4080 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
   4081 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
   4082 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
   4083 #define JOB_OBJECT_MSG_NOTIFICATION_LIMIT 11
   4084 #define JOB_OBJECT_MSG_JOB_CYCLE_TIME_LIMIT 12
   4085 
   4086 #define JOB_OBJECT_MSG_MINIMUM 1
   4087 #define JOB_OBJECT_MSG_MAXIMUM 12
   4088 
   4089 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
   4090 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
   4091 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
   4092 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
   4093 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
   4094 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
   4095 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
   4096 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
   4097 
   4098 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
   4099 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
   4100 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
   4101 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
   4102 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
   4103 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
   4104 
   4105 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
   4106 #define JOB_OBJECT_LIMIT_RESERVED3 0x00008000
   4107 #define JOB_OBJECT_LIMIT_JOB_READ_BYTES 0x00010000
   4108 #define JOB_OBJECT_LIMIT_JOB_WRITE_BYTES 0x00020000
   4109 #define JOB_OBJECT_LIMIT_RATE_CONTROL 0x00040000
   4110 
   4111 #define JOB_OBJECT_LIMIT_RESERVED3 0x00008000
   4112 #define JOB_OBJECT_LIMIT_RESERVED4 0x00010000
   4113 #define JOB_OBJECT_LIMIT_RESERVED5 0x00020000
   4114 #define JOB_OBJECT_LIMIT_RESERVED6 0x00040000
   4115 
   4116 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
   4117 
   4118 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
   4119 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
   4120 #define JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS 0x0007ffff
   4121 #define JOB_OBJECT_NOTIFICATION_LIMIT_VALID_FLAGS 0x00070204
   4122 
   4123 #define JOB_OBJECT_UILIMIT_NONE 0x00000000
   4124 
   4125 #define JOB_OBJECT_UILIMIT_HANDLES 0x00000001
   4126 #define JOB_OBJECT_UILIMIT_READCLIPBOARD 0x00000002
   4127 #define JOB_OBJECT_UILIMIT_WRITECLIPBOARD 0x00000004
   4128 #define JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS 0x00000008
   4129 #define JOB_OBJECT_UILIMIT_DISPLAYSETTINGS 0x00000010
   4130 #define JOB_OBJECT_UILIMIT_GLOBALATOMS 0x00000020
   4131 #define JOB_OBJECT_UILIMIT_DESKTOP 0x00000040
   4132 #define JOB_OBJECT_UILIMIT_EXITWINDOWS 0x00000080
   4133 
   4134 #define JOB_OBJECT_UILIMIT_ALL 0x000000FF
   4135 
   4136 #define JOB_OBJECT_UI_VALID_FLAGS 0x000000FF
   4137 
   4138 #define JOB_OBJECT_SECURITY_NO_ADMIN 0x00000001
   4139 #define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN 0x00000002
   4140 #define JOB_OBJECT_SECURITY_ONLY_TOKEN 0x00000004
   4141 #define JOB_OBJECT_SECURITY_FILTER_TOKENS 0x00000008
   4142 
   4143 #define JOB_OBJECT_SECURITY_VALID_FLAGS 0x0000000f
   4144 
   4145 #define JOB_OBJECT_CPU_RATE_CONTROL_ENABLE 0x1
   4146 #define JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED 0x2
   4147 #define JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP 0x4
   4148 #define JOB_OBJECT_CPU_RATE_CONTROL_NOTIFY 0x8
   4149 #define JOB_OBJECT_CPU_RATE_CONTROL_VALID_FLAGS 0xf
   4150 
   4151     typedef enum _JOBOBJECTINFOCLASS {
   4152       JobObjectBasicAccountingInformation = 1, JobObjectBasicLimitInformation,
   4153       JobObjectBasicProcessIdList, JobObjectBasicUIRestrictions,
   4154       JobObjectSecurityLimitInformation, JobObjectEndOfJobTimeInformation,
   4155       JobObjectAssociateCompletionPortInformation, JobObjectBasicAndIoAccountingInformation,
   4156       JobObjectExtendedLimitInformation, JobObjectJobSetInformation,
   4157       JobObjectGroupInformation,
   4158       JobObjectNotificationLimitInformation,
   4159       JobObjectLimitViolationInformation,
   4160       JobObjectGroupInformationEx,
   4161       JobObjectCpuRateControlInformation,
   4162       JobObjectCompletionFilter,
   4163       JobObjectCompletionCounter,
   4164       JobObjectReserved1Information = 18,
   4165       JobObjectReserved2Information,
   4166       JobObjectReserved3Information,
   4167       JobObjectReserved4Information,
   4168       JobObjectReserved5Information,
   4169       JobObjectReserved6Information,
   4170       JobObjectReserved7Information,
   4171       JobObjectReserved8Information,
   4172       MaxJobObjectInfoClass
   4173     } JOBOBJECTINFOCLASS;
   4174 
   4175     typedef enum _FIRMWARE_TYPE {
   4176       FirmwareTypeUnknown,
   4177       FirmwareTypeBios,
   4178       FirmwareTypeUefi,
   4179       FirmwareTypeMax
   4180     } FIRMWARE_TYPE,*PFIRMWARE_TYPE;
   4181 
   4182 #define EVENT_MODIFY_STATE 0x0002
   4183 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
   4184 
   4185 #define MUTANT_QUERY_STATE 0x0001
   4186 
   4187 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE| MUTANT_QUERY_STATE)
   4188 #define SEMAPHORE_MODIFY_STATE 0x0002
   4189 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
   4190 
   4191 #define TIMER_QUERY_STATE 0x0001
   4192 #define TIMER_MODIFY_STATE 0x0002
   4193 
   4194 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE| TIMER_QUERY_STATE|TIMER_MODIFY_STATE)
   4195 
   4196 #define TIME_ZONE_ID_UNKNOWN 0
   4197 #define TIME_ZONE_ID_STANDARD 1
   4198 #define TIME_ZONE_ID_DAYLIGHT 2
   4199 
   4200     typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
   4201       RelationProcessorCore,RelationNumaNode,RelationCache,
   4202       RelationProcessorPackage,RelationGroup,RelationAll=0xffff
   4203     } LOGICAL_PROCESSOR_RELATIONSHIP;
   4204 
   4205 #define LTP_PC_SMT 0x1
   4206 
   4207     typedef enum _PROCESSOR_CACHE_TYPE {
   4208       CacheUnified,CacheInstruction,CacheData,CacheTrace
   4209     } PROCESSOR_CACHE_TYPE;
   4210 
   4211 #define CACHE_FULLY_ASSOCIATIVE 0xFF
   4212 
   4213     typedef struct _CACHE_DESCRIPTOR {
   4214       BYTE Level;
   4215       BYTE Associativity;
   4216       WORD LineSize;
   4217       DWORD Size;
   4218       PROCESSOR_CACHE_TYPE Type;
   4219     } CACHE_DESCRIPTOR,*PCACHE_DESCRIPTOR;
   4220 
   4221     typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
   4222       ULONG_PTR ProcessorMask;
   4223       LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
   4224       __C89_NAMELESS union {
   4225 	struct {
   4226 	  BYTE Flags;
   4227 	} ProcessorCore;
   4228 	struct {
   4229 	  DWORD NodeNumber;
   4230 	} NumaNode;
   4231 	CACHE_DESCRIPTOR Cache;
   4232 	ULONGLONG Reserved[2];
   4233       } DUMMYUNIONNAME;
   4234     } SYSTEM_LOGICAL_PROCESSOR_INFORMATION,*PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
   4235 
   4236     typedef struct _PROCESSOR_RELATIONSHIP {
   4237       BYTE Flags;
   4238       BYTE Reserved[21];
   4239       WORD GroupCount;
   4240       GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
   4241     } PROCESSOR_RELATIONSHIP,*PPROCESSOR_RELATIONSHIP;
   4242 
   4243     typedef struct _NUMA_NODE_RELATIONSHIP {
   4244       DWORD NodeNumber;
   4245       BYTE Reserved[20];
   4246       GROUP_AFFINITY GroupMask;
   4247     } NUMA_NODE_RELATIONSHIP,*PNUMA_NODE_RELATIONSHIP;
   4248 
   4249     typedef struct _CACHE_RELATIONSHIP {
   4250       BYTE Level;
   4251       BYTE Associativity;
   4252       WORD LineSize;
   4253       DWORD CacheSize;
   4254       PROCESSOR_CACHE_TYPE Type;
   4255       BYTE Reserved[20];
   4256       GROUP_AFFINITY GroupMask;
   4257     } CACHE_RELATIONSHIP,*PCACHE_RELATIONSHIP;
   4258 
   4259     typedef struct _PROCESSOR_GROUP_INFO {
   4260       BYTE MaximumProcessorCount;
   4261       BYTE ActiveProcessorCount;
   4262       BYTE Reserved[38];
   4263       KAFFINITY ActiveProcessorMask;
   4264     } PROCESSOR_GROUP_INFO,*PPROCESSOR_GROUP_INFO;
   4265 
   4266     typedef struct _GROUP_RELATIONSHIP {
   4267       WORD MaximumGroupCount;
   4268       WORD ActiveGroupCount;
   4269       BYTE Reserved[20];
   4270       PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
   4271     } GROUP_RELATIONSHIP,*PGROUP_RELATIONSHIP;
   4272 
   4273     struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
   4274       LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
   4275       DWORD Size;
   4276       __C89_NAMELESS union {
   4277 	PROCESSOR_RELATIONSHIP Processor;
   4278 	NUMA_NODE_RELATIONSHIP NumaNode;
   4279 	CACHE_RELATIONSHIP Cache;
   4280 	GROUP_RELATIONSHIP Group;
   4281       } DUMMYUNIONNAME;
   4282     };
   4283 
   4284     typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX,*PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
   4285 
   4286     typedef struct _SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION {
   4287       DWORD64 CycleTime;
   4288     } SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION,*PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION;
   4289 
   4290 #define PROCESSOR_INTEL_386 386
   4291 #define PROCESSOR_INTEL_486 486
   4292 #define PROCESSOR_INTEL_PENTIUM 586
   4293 #define PROCESSOR_INTEL_IA64 2200
   4294 #define PROCESSOR_AMD_X8664 8664
   4295 #define PROCESSOR_MIPS_R4000 4000
   4296 #define PROCESSOR_ALPHA_21064 21064
   4297 #define PROCESSOR_PPC_601 601
   4298 #define PROCESSOR_PPC_603 603
   4299 #define PROCESSOR_PPC_604 604
   4300 #define PROCESSOR_PPC_620 620
   4301 #define PROCESSOR_HITACHI_SH3 10003
   4302 #define PROCESSOR_HITACHI_SH3E 10004
   4303 #define PROCESSOR_HITACHI_SH4 10005
   4304 #define PROCESSOR_MOTOROLA_821 821
   4305 #define PROCESSOR_SHx_SH3 103
   4306 #define PROCESSOR_SHx_SH4 104
   4307 #define PROCESSOR_STRONGARM 2577
   4308 #define PROCESSOR_ARM720 1824
   4309 #define PROCESSOR_ARM820 2080
   4310 #define PROCESSOR_ARM920 2336
   4311 #define PROCESSOR_ARM_7TDMI 70001
   4312 #define PROCESSOR_OPTIL 0x494f
   4313 
   4314 #define PROCESSOR_ARCHITECTURE_INTEL 0
   4315 #define PROCESSOR_ARCHITECTURE_MIPS 1
   4316 #define PROCESSOR_ARCHITECTURE_ALPHA 2
   4317 #define PROCESSOR_ARCHITECTURE_PPC 3
   4318 #define PROCESSOR_ARCHITECTURE_SHX 4
   4319 #define PROCESSOR_ARCHITECTURE_ARM 5
   4320 #define PROCESSOR_ARCHITECTURE_IA64 6
   4321 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
   4322 #define PROCESSOR_ARCHITECTURE_MSIL 8
   4323 #define PROCESSOR_ARCHITECTURE_AMD64 9
   4324 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
   4325 #define PROCESSOR_ARCHITECTURE_NEUTRAL 11
   4326 
   4327 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xffff
   4328 
   4329 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
   4330 #define PF_FLOATING_POINT_EMULATED 1
   4331 #define PF_COMPARE_EXCHANGE_DOUBLE 2
   4332 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
   4333 #define PF_PPC_MOVEMEM_64BIT_OK 4
   4334 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
   4335 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
   4336 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
   4337 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
   4338 #define PF_PAE_ENABLED 9
   4339 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
   4340 #define PF_SSE_DAZ_MODE_AVAILABLE 11
   4341 #define PF_NX_ENABLED 12
   4342 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
   4343 #define PF_COMPARE_EXCHANGE128 14
   4344 #define PF_COMPARE64_EXCHANGE128 15
   4345 #define PF_CHANNELS_ENABLED 16
   4346 #define PF_XSAVE_ENABLED 17
   4347 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
   4348 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
   4349 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
   4350 #define PF_VIRT_FIRMWARE_ENABLED 21
   4351 #define PF_RDWRFSGSBASE_AVAILABLE 22
   4352 #define PF_FASTFAIL_AVAILABLE 23
   4353 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
   4354 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
   4355 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
   4356 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
   4357 
   4358 #define XSTATE_LEGACY_FLOATING_POINT (0)
   4359 #define XSTATE_LEGACY_SSE (1)
   4360 #define XSTATE_GSSE (2)
   4361 #define XSTATE_AVX (XSTATE_GSSE)
   4362 
   4363 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1ULL << (XSTATE_LEGACY_FLOATING_POINT))
   4364 #define XSTATE_MASK_LEGACY_SSE (1ULL << (XSTATE_LEGACY_SSE))
   4365 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
   4366 #define XSTATE_MASK_GSSE (1LLU << (XSTATE_GSSE))
   4367 #define XSTATE_MASK_AVX (XSTATE_MASK_GSSE)
   4368 
   4369 #define MAXIMUM_XSTATE_FEATURES (64)
   4370 
   4371     typedef struct _XSTATE_FEATURE {
   4372       DWORD Offset;
   4373       DWORD Size;
   4374     } XSTATE_FEATURE,*PXSTATE_FEATURE;
   4375 
   4376     typedef struct _XSTATE_CONFIGURATION {
   4377       DWORD64 EnabledFeatures;
   4378       DWORD64 EnabledVolatileFeatures;
   4379       DWORD Size;
   4380       DWORD OptimizedSave : 1;
   4381       XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
   4382     } XSTATE_CONFIGURATION,*PXSTATE_CONFIGURATION;
   4383 
   4384     typedef struct _MEMORY_BASIC_INFORMATION {
   4385       PVOID BaseAddress;
   4386       PVOID AllocationBase;
   4387       DWORD AllocationProtect;
   4388       SIZE_T RegionSize;
   4389       DWORD State;
   4390       DWORD Protect;
   4391       DWORD Type;
   4392     } MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
   4393 
   4394     typedef struct _MEMORY_BASIC_INFORMATION32 {
   4395       DWORD BaseAddress;
   4396       DWORD AllocationBase;
   4397       DWORD AllocationProtect;
   4398       DWORD RegionSize;
   4399       DWORD State;
   4400       DWORD Protect;
   4401       DWORD Type;
   4402     } MEMORY_BASIC_INFORMATION32,*PMEMORY_BASIC_INFORMATION32;
   4403 
   4404     typedef struct DECLSPEC_ALIGN(16) _MEMORY_BASIC_INFORMATION64 {
   4405       ULONGLONG BaseAddress;
   4406       ULONGLONG AllocationBase;
   4407       DWORD AllocationProtect;
   4408       DWORD __alignment1;
   4409       ULONGLONG RegionSize;
   4410       DWORD State;
   4411       DWORD Protect;
   4412       DWORD Type;
   4413       DWORD __alignment2;
   4414     } MEMORY_BASIC_INFORMATION64,*PMEMORY_BASIC_INFORMATION64;
   4415 
   4416 #define SECTION_QUERY 0x0001
   4417 #define SECTION_MAP_WRITE 0x0002
   4418 #define SECTION_MAP_READ 0x0004
   4419 #define SECTION_MAP_EXECUTE 0x0008
   4420 #define SECTION_EXTEND_SIZE 0x0010
   4421 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
   4422 
   4423 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE)
   4424 
   4425 #define SESSION_QUERY_ACCESS 0x1
   4426 #define SESSION_MODIFY_ACCESS 0x2
   4427 
   4428 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SESSION_QUERY_ACCESS | SESSION_MODIFY_ACCESS)
   4429 
   4430 #define PAGE_NOACCESS 0x01
   4431 #define PAGE_READONLY 0x02
   4432 #define PAGE_READWRITE 0x04
   4433 #define PAGE_WRITECOPY 0x08
   4434 #define PAGE_EXECUTE 0x10
   4435 #define PAGE_EXECUTE_READ 0x20
   4436 #define PAGE_EXECUTE_READWRITE 0x40
   4437 #define PAGE_EXECUTE_WRITECOPY 0x80
   4438 #define PAGE_GUARD 0x100
   4439 #define PAGE_NOCACHE 0x200
   4440 #define PAGE_WRITECOMBINE 0x400
   4441 #define MEM_COMMIT 0x1000
   4442 #define MEM_RESERVE 0x2000
   4443 #define MEM_DECOMMIT 0x4000
   4444 #define MEM_RELEASE 0x8000
   4445 #define MEM_FREE 0x10000
   4446 #define MEM_PRIVATE 0x20000
   4447 #define MEM_MAPPED 0x40000
   4448 #define MEM_RESET 0x80000
   4449 #define MEM_TOP_DOWN 0x100000
   4450 #define MEM_WRITE_WATCH 0x200000
   4451 #define MEM_PHYSICAL 0x400000
   4452 #define MEM_ROTATE 0x800000
   4453 #define MEM_LARGE_PAGES 0x20000000
   4454 #define MEM_4MB_PAGES 0x80000000
   4455 #define SEC_FILE 0x800000
   4456 #define SEC_IMAGE 0x1000000
   4457 #define SEC_PROTECTED_IMAGE 0x2000000
   4458 #define SEC_RESERVE 0x4000000
   4459 #define SEC_COMMIT 0x8000000
   4460 #define SEC_NOCACHE 0x10000000
   4461 #define SEC_WRITECOMBINE 0x40000000
   4462 #define SEC_LARGE_PAGES 0x80000000
   4463 
   4464 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
   4465 #define MEM_IMAGE SEC_IMAGE
   4466 #define WRITE_WATCH_FLAG_RESET 0x01
   4467 #define MEM_UNMAP_WITH_TRANSIENT_BOOST 0x01
   4468 
   4469 #define FILE_READ_DATA (0x0001)
   4470 #define FILE_LIST_DIRECTORY (0x0001)
   4471 
   4472 #define FILE_WRITE_DATA (0x0002)
   4473 #define FILE_ADD_FILE (0x0002)
   4474 
   4475 #define FILE_APPEND_DATA (0x0004)
   4476 #define FILE_ADD_SUBDIRECTORY (0x0004)
   4477 #define FILE_CREATE_PIPE_INSTANCE (0x0004)
   4478 
   4479 #define FILE_READ_EA (0x0008)
   4480 #define FILE_WRITE_EA (0x0010)
   4481 #define FILE_EXECUTE (0x0020)
   4482 #define FILE_TRAVERSE (0x0020)
   4483 #define FILE_DELETE_CHILD (0x0040)
   4484 #define FILE_READ_ATTRIBUTES (0x0080)
   4485 #define FILE_WRITE_ATTRIBUTES (0x0100)
   4486 
   4487 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
   4488 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE)
   4489 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE)
   4490 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE)
   4491 
   4492 #define FILE_SUPERSEDE                    0x00000000
   4493 #define FILE_OPEN                         0x00000001
   4494 #define FILE_CREATE                       0x00000002
   4495 #define FILE_OPEN_IF                      0x00000003
   4496 #define FILE_OVERWRITE                    0x00000004
   4497 #define FILE_OVERWRITE_IF                 0x00000005
   4498 #define FILE_MAXIMUM_DISPOSITION          0x00000005
   4499 
   4500 #define FILE_DIRECTORY_FILE               0x00000001
   4501 #define FILE_WRITE_THROUGH                0x00000002
   4502 #define FILE_SEQUENTIAL_ONLY              0x00000004
   4503 #define FILE_NO_INTERMEDIATE_BUFFERING    0x00000008
   4504 #define FILE_SYNCHRONOUS_IO_ALERT         0x00000010
   4505 #define FILE_SYNCHRONOUS_IO_NONALERT      0x00000020
   4506 #define FILE_NON_DIRECTORY_FILE           0x00000040
   4507 #define FILE_CREATE_TREE_CONNECTION       0x00000080
   4508 #define FILE_COMPLETE_IF_OPLOCKED         0x00000100
   4509 #define FILE_NO_EA_KNOWLEDGE              0x00000200
   4510 #define FILE_OPEN_REMOTE_INSTANCE         0x00000400
   4511 #define FILE_RANDOM_ACCESS                0x00000800
   4512 #define FILE_DELETE_ON_CLOSE              0x00001000
   4513 #define FILE_OPEN_BY_FILE_ID              0x00002000
   4514 #define FILE_OPEN_FOR_BACKUP_INTENT       0x00004000
   4515 #define FILE_NO_COMPRESSION               0x00008000
   4516 #if (NTDDI_VERSION >= NTDDI_WIN7)
   4517 #define FILE_OPEN_REQUIRING_OPLOCK        0x00010000
   4518 #define FILE_DISALLOW_EXCLUSIVE           0x00020000
   4519 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   4520 #define FILE_RESERVE_OPFILTER             0x00100000
   4521 #define FILE_OPEN_REPARSE_POINT           0x00200000
   4522 #define FILE_OPEN_NO_RECALL               0x00400000
   4523 #define FILE_OPEN_FOR_FREE_SPACE_QUERY    0x00800000
   4524 
   4525 #define FILE_SHARE_READ 0x00000001
   4526 #define FILE_SHARE_WRITE 0x00000002
   4527 #define FILE_SHARE_DELETE 0x00000004
   4528 #define FILE_SHARE_VALID_FLAGS 0x00000007
   4529 #define FILE_ATTRIBUTE_READONLY 0x00000001
   4530 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
   4531 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
   4532 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
   4533 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
   4534 #define FILE_ATTRIBUTE_DEVICE 0x00000040
   4535 #define FILE_ATTRIBUTE_NORMAL 0x00000080
   4536 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
   4537 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
   4538 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
   4539 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
   4540 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
   4541 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
   4542 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
   4543 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
   4544 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
   4545 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
   4546 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
   4547 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
   4548 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
   4549 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
   4550 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
   4551 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
   4552 #define FILE_ACTION_ADDED 0x00000001
   4553 #define FILE_ACTION_REMOVED 0x00000002
   4554 #define FILE_ACTION_MODIFIED 0x00000003
   4555 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
   4556 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
   4557 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
   4558 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
   4559 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
   4560 #define FILE_CASE_PRESERVED_NAMES 0x00000002
   4561 #define FILE_UNICODE_ON_DISK 0x00000004
   4562 #define FILE_PERSISTENT_ACLS 0x00000008
   4563 #define FILE_FILE_COMPRESSION 0x00000010
   4564 #define FILE_VOLUME_QUOTAS 0x00000020
   4565 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
   4566 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
   4567 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
   4568 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
   4569 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
   4570 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
   4571 #define FILE_NAMED_STREAMS 0x00040000
   4572 #define FILE_READ_ONLY_VOLUME 0x00080000
   4573 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
   4574 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
   4575 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
   4576 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
   4577 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
   4578 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
   4579 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
   4580 
   4581     typedef struct FILE_ID_128 {
   4582       ULONGLONG LowPart;
   4583       ULONGLONG HighPart;
   4584     } FILE_ID_128, *PFILE_ID_128;
   4585 
   4586     typedef struct _FILE_NOTIFY_INFORMATION {
   4587       DWORD NextEntryOffset;
   4588       DWORD Action;
   4589       DWORD FileNameLength;
   4590       WCHAR FileName[1];
   4591     } FILE_NOTIFY_INFORMATION,*PFILE_NOTIFY_INFORMATION;
   4592 
   4593     typedef union _FILE_SEGMENT_ELEMENT {
   4594       PVOID64 Buffer;
   4595       ULONGLONG Alignment;
   4596     } FILE_SEGMENT_ELEMENT,*PFILE_SEGMENT_ELEMENT;
   4597 
   4598     typedef struct _REPARSE_GUID_DATA_BUFFER {
   4599       DWORD ReparseTag;
   4600       WORD ReparseDataLength;
   4601       WORD Reserved;
   4602       GUID ReparseGuid;
   4603       struct {
   4604 	BYTE DataBuffer[1];
   4605       } GenericReparseBuffer;
   4606     } REPARSE_GUID_DATA_BUFFER,*PREPARSE_GUID_DATA_BUFFER;
   4607 
   4608 #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER,GenericReparseBuffer)
   4609 
   4610 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 *1024)
   4611 
   4612 #define SYMLINK_FLAG_RELATIVE   1
   4613 
   4614 #define IO_REPARSE_TAG_RESERVED_ZERO (0)
   4615 #define IO_REPARSE_TAG_RESERVED_ONE (1)
   4616 
   4617 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_ONE
   4618 
   4619 #define IsReparseTagMicrosoft(_tag) (((_tag) & 0x80000000))
   4620 #define IsReparseTagNameSurrogate(_tag) (((_tag) & 0x20000000))
   4621 
   4622 #define IO_REPARSE_TAG_MOUNT_POINT (__MSABI_LONG(0xA0000003))
   4623 #define IO_REPARSE_TAG_HSM (__MSABI_LONG(0xC0000004))
   4624 #define IO_REPARSE_TAG_HSM2 (__MSABI_LONG(0x80000006))
   4625 #define IO_REPARSE_TAG_SIS (__MSABI_LONG(0x80000007))
   4626 #define IO_REPARSE_TAG_WIM (__MSABI_LONG(0x80000008))
   4627 #define IO_REPARSE_TAG_CSV (__MSABI_LONG(0x80000009))
   4628 #define IO_REPARSE_TAG_DFS (__MSABI_LONG(0x8000000A))
   4629 #define IO_REPARSE_TAG_FILTER_MANAGER (__MSABI_LONG(0x8000000B))
   4630 #define IO_REPARSE_TAG_DFSR (__MSABI_LONG(0x80000012))
   4631 #define IO_REPARSE_TAG_SYMLINK (__MSABI_LONG(0xA000000C))
   4632 #define IO_REPARSE_TAG_IIS_CACHE (__MSABI_LONG(0xA0000010))
   4633 #define IO_REPARSE_TAG_DRIVE_EXTENDER (__MSABI_LONG(0x80000005))
   4634 #define IO_REPARSE_TAG_DEDUP (__MSABI_LONG(0x80000013))
   4635 #define IO_REPARSE_TAG_NFS (__MSABI_LONG(0x80000014))
   4636 
   4637 #if _WIN32_WINNT >= 0x0602
   4638 #define SCRUB_DATA_INPUT_FLAG_RESUME 0x00000001
   4639 #define SCRUB_DATA_INPUT_FLAG_SKIP_IN_SYNC 0x00000002
   4640 #define SCRUB_DATA_INPUT_FLAG_SKIP_NON_INTEGRITY_DATA 0x00000004
   4641 
   4642 #define SCRUB_DATA_OUTPUT_FLAG_INCOMPLETE 0x00000001
   4643 #define SCRUB_DATA_OUTPUT_FLAG_NON_USER_DATA_RANGE 0x00010000
   4644 
   4645     typedef struct _SCRUB_DATA_INPUT {
   4646       DWORD Size;
   4647       DWORD Flags;
   4648       DWORD MaximumIos;
   4649       DWORD Reserved[17];
   4650       BYTE ResumeContext[816];
   4651     } SCRUB_DATA_INPUT,*PSCRUB_DATA_INPUT;
   4652 
   4653     typedef struct _SCRUB_DATA_OUTPUT {
   4654       DWORD Size;
   4655       DWORD Flags;
   4656       DWORD Status;
   4657       ULONGLONG ErrorFileOffset;
   4658       ULONGLONG ErrorLength;
   4659       ULONGLONG NumberOfBytesRepaired;
   4660       ULONGLONG NumberOfBytesFailed;
   4661       ULONGLONG InternalFileReference;
   4662       DWORD Reserved[6];
   4663       BYTE ResumeContext[816];
   4664     } SCRUB_DATA_OUTPUT,*PSCRUB_DATA_OUTPUT;
   4665 #endif
   4666 
   4667 #define IO_COMPLETION_MODIFY_STATE 0x0002
   4668 #define IO_COMPLETION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
   4669 #define DUPLICATE_CLOSE_SOURCE 0x00000001
   4670 #define DUPLICATE_SAME_ACCESS 0x00000002
   4671 
   4672 #define POWERBUTTON_ACTION_INDEX_NOTHING 0
   4673 #define POWERBUTTON_ACTION_INDEX_SLEEP 1
   4674 #define POWERBUTTON_ACTION_INDEX_HIBERNATE 2
   4675 #define POWERBUTTON_ACTION_INDEX_SHUTDOWN 3
   4676 
   4677 #define POWERBUTTON_ACTION_VALUE_NOTHING 0
   4678 #define POWERBUTTON_ACTION_VALUE_SLEEP 2
   4679 #define POWERBUTTON_ACTION_VALUE_HIBERNATE 3
   4680 #define POWERBUTTON_ACTION_VALUE_SHUTDOWN 6
   4681 
   4682 #define PERFSTATE_POLICY_CHANGE_IDEAL 0
   4683 #define PERFSTATE_POLICY_CHANGE_SINGLE 1
   4684 #define PERFSTATE_POLICY_CHANGE_ROCKET 2
   4685 #define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET
   4686 
   4687 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0
   4688 #define PROCESSOR_PERF_BOOST_POLICY_MAX 100
   4689 
   4690 #define PROCESSOR_PERF_BOOST_MODE_DISABLED 0
   4691 #define PROCESSOR_PERF_BOOST_MODE_ENABLED 1
   4692 #define PROCESSOR_PERF_BOOST_MODE_AGGRESSIVE 2
   4693 #define PROCESSOR_PERF_BOOST_MODE_EFFICIENT_ENABLED 3
   4694 #define PROCESSOR_PERF_BOOST_MODE_EFFICIENT_AGGRESSIVE 4
   4695 #define PROCESSOR_PERF_BOOST_MODE_MAX PROCESSOR_PERF_BOOST_MODE_EFFICIENT_AGGRESSIVE
   4696 
   4697 #define CORE_PARKING_POLICY_CHANGE_IDEAL 0
   4698 #define CORE_PARKING_POLICY_CHANGE_SINGLE 1
   4699 #define CORE_PARKING_POLICY_CHANGE_ROCKET 2
   4700 #define CORE_PARKING_POLICY_CHANGE_MULTISTEP 3
   4701 #define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_MULTISTEP
   4702 
   4703 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0
   4704 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1
   4705 
   4706     DEFINE_GUID (GUID_MAX_POWER_SAVINGS, 0xa1841308, 0x3541, 0x4fab, 0xbc, 0x81, 0xf7, 0x15, 0x56, 0xf2, 0x0b, 0x4a);
   4707     DEFINE_GUID (GUID_MIN_POWER_SAVINGS, 0x8c5e7fda, 0xe8bf, 0x4a96, 0x9a, 0x85, 0xa6, 0xe2, 0x3a, 0x8c, 0x63, 0x5c);
   4708     DEFINE_GUID (GUID_TYPICAL_POWER_SAVINGS, 0x381b4222, 0xf694, 0x41f0, 0x96, 0x85, 0xff, 0x5b, 0xb2, 0x60, 0xdf, 0x2e);
   4709     DEFINE_GUID (NO_SUBGROUP_GUID, 0xfea3413e, 0x7e05, 0x4911, 0x9a, 0x71, 0x70, 0x03, 0x31, 0xf1, 0xc2, 0x94);
   4710     DEFINE_GUID (ALL_POWERSCHEMES_GUID, 0x68a1e95e, 0x13ea, 0x41e1, 0x80, 0x11, 0x0c, 0x49, 0x6c, 0xa4, 0x90, 0xb0);
   4711     DEFINE_GUID (GUID_POWERSCHEME_PERSONALITY, 0x245d8541, 0x3943, 0x4422, 0xb0, 0x25, 0x13, 0xa7, 0x84, 0xf6, 0x79, 0xb7);
   4712     DEFINE_GUID (GUID_ACTIVE_POWERSCHEME, 0x31f9f286, 0x5084, 0x42fe, 0xb7, 0x20, 0x2b, 0x02, 0x64, 0x99, 0x37, 0x63);
   4713     DEFINE_GUID (GUID_IDLE_RESILIENCY_SUBGROUP, 0x2e601130, 0x5351, 0x4d9d, 0x8e, 0x4, 0x25, 0x29, 0x66, 0xba, 0xd0, 0x54);
   4714     DEFINE_GUID (GUID_IDLE_RESILIENCY_PERIOD, 0xc42b79aa, 0xaa3a, 0x484b, 0xa9, 0x8f, 0x2c, 0xf3, 0x2a, 0xa9, 0xa, 0x28);
   4715     DEFINE_GUID (GUID_DISK_COALESCING_POWERDOWN_TIMEOUT, 0xc36f0eb4, 0x2988, 0x4a70, 0x8e, 0xee, 0x8, 0x84, 0xfc, 0x2c, 0x24, 0x33);
   4716     DEFINE_GUID (GUID_EXECUTION_REQUIRED_REQUEST_TIMEOUT, 0x3166bc41, 0x7e98, 0x4e03, 0xb3, 0x4e, 0xec, 0xf, 0x5f, 0x2b, 0x21, 0x8e);
   4717     DEFINE_GUID (GUID_VIDEO_SUBGROUP, 0x7516b95f, 0xf776, 0x4464, 0x8c, 0x53, 0x06, 0x16, 0x7f, 0x40, 0xcc, 0x99);
   4718     DEFINE_GUID (GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3c0bc021, 0xc8a8, 0x4e07, 0xa9, 0x73, 0x6b, 0x14, 0xcb, 0xcb, 0x2b, 0x7e);
   4719     DEFINE_GUID (GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82dbcf2d, 0xcd67, 0x40c5, 0xbf, 0xdc, 0x9f, 0x1a, 0x5c, 0xcd, 0x46, 0x63);
   4720     DEFINE_GUID (GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xeed904df, 0xb142, 0x4183, 0xb1, 0x0b, 0x5a, 0x11, 0x97, 0xa3, 0x78, 0x64);
   4721     DEFINE_GUID (GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee);
   4722     DEFINE_GUID (GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959d22, 0xd6a1, 0x49b9, 0xaf, 0x93, 0xbc, 0xe8, 0x85, 0xad, 0x33, 0x5b);
   4723     DEFINE_GUID (GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xe6, 0xe5, 0xa1, 0x7e, 0xbd, 0x1a, 0xea);
   4724     DEFINE_GUID (GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, __MSABI_LONG(0xaded5e82), 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb);
   4725     DEFINE_GUID (GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96);
   4726     DEFINE_GUID (GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff);
   4727     DEFINE_GUID (GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xfbd9aa66, 0x9553, 0x4097, 0xba, 0x44, 0xed, 0x6e, 0x9d, 0x65, 0xea, 0xb8);
   4728     DEFINE_GUID (GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47);
   4729     DEFINE_GUID (GUID_ALLOW_DISPLAY_REQUIRED, 0xa9ceb8da, 0xcd46, 0x44fb, 0xa9, 0x8b, 0x02, 0xaf, 0x69, 0xde, 0x46, 0x23);
   4730     DEFINE_GUID (GUID_VIDEO_CONSOLE_LOCK_TIMEOUT, 0x8ec4b3a5, 0x6868, 0x48c2, 0xbe, 0x75, 0x4f, 0x30, 0x44, 0xbe, 0x88, 0xa7);
   4731     DEFINE_GUID (GUID_ADAPTIVE_POWER_BEHAVIOR_SUBGROUP, 0x8619b916, 0xe004, 0x4dd8, 0x9b, 0x66, 0xda, 0xe8, 0x6f, 0x80, 0x66, 0x98);
   4732     DEFINE_GUID (GUID_NON_ADAPTIVE_INPUT_TIMEOUT, 0x5adbbfbc, 0x74e, 0x4da1, 0xba, 0x38, 0xdb, 0x8b, 0x36, 0xb2, 0xc8, 0xf3);
   4733     DEFINE_GUID (GUID_DISK_SUBGROUP, 0x0012ee47, 0x9041, 0x4b5d, 0x9b, 0x77, 0x53, 0x5f, 0xba, 0x8b, 0x14, 0x42);
   4734     DEFINE_GUID (GUID_DISK_POWERDOWN_TIMEOUT, 0x6738e2c4, 0xe8a5, 0x4a42, 0xb1, 0x6a, 0xe0, 0x40, 0xe7, 0x69, 0x75, 0x6e);
   4735     DEFINE_GUID (GUID_DISK_IDLE_TIMEOUT, 0x58e39ba8, 0xb8e6, 0x4ef6, 0x90, 0xd0, 0x89, 0xae, 0x32, 0xb2, 0x58, 0xd6);
   4736     DEFINE_GUID (GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63);
   4737     DEFINE_GUID (GUID_DISK_ADAPTIVE_POWERDOWN, 0x396a32e1, 0x499a, 0x40b2, 0x91, 0x24, 0xa9, 0x6a, 0xfe, 0x70, 0x76, 0x67);
   4738     DEFINE_GUID (GUID_SLEEP_SUBGROUP, 0x238c9fa8, 0x0aad, 0x41ed, 0x83, 0xf4, 0x97, 0xbe, 0x24, 0x2c, 0x8f, 0x20);
   4739     DEFINE_GUID (GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70);
   4740     DEFINE_GUID (GUID_STANDBY_TIMEOUT, 0x29f6c1db, 0x86da, 0x48c5, 0x9f, 0xdb, 0xf2, 0xb6, 0x7b, 0x1f, 0x44, 0xda);
   4741     DEFINE_GUID (GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0);
   4742     DEFINE_GUID (GUID_HIBERNATE_TIMEOUT, 0x9d7815a6, 0x7ee4, 0x497e, 0x88, 0x88, 0x51, 0x5a, 0x05, 0xf0, 0x23, 0x64);
   4743     DEFINE_GUID (GUID_HIBERNATE_FASTS4_POLICY, 0x94ac6d29, 0x73ce, 0x41a6, 0x80, 0x9f, 0x63, 0x63, 0xba, 0x21, 0xb4, 0x7e);
   4744     DEFINE_GUID (GUID_CRITICAL_POWER_TRANSITION, 0xb7a27025, 0xe569, 0x46c2, 0xa5, 0x04, 0x2b, 0x96, 0xca, 0xd2, 0x25, 0xa1);
   4745     DEFINE_GUID (GUID_SYSTEM_AWAYMODE, 0x98a7f580, 0x01f7, 0x48aa, 0x9c, 0x0f, 0x44, 0x35, 0x2c, 0x29, 0xe5, 0xc0);
   4746     DEFINE_GUID (GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87);
   4747     DEFINE_GUID (GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab);
   4748     DEFINE_GUID (GUID_ALLOW_RTC_WAKE, 0xbd3b718a, 0x0680, 0x4d9d, 0x8a, 0xb2, 0xe1, 0xd2, 0xb4, 0xac, 0x80, 0x6d);
   4749     DEFINE_GUID (GUID_ALLOW_SYSTEM_REQUIRED, 0xa4b195f5, 0x8225, 0x47d8, 0x80, 0x12, 0x9d, 0x41, 0x36, 0x97, 0x86, 0xe2);
   4750     DEFINE_GUID (GUID_SYSTEM_BUTTON_SUBGROUP, 0x4f971e89, 0xeebd, 0x4455, 0xa8, 0xde, 0x9e, 0x59, 0x04, 0x0e, 0x73, 0x47);
   4751     DEFINE_GUID (GUID_POWERBUTTON_ACTION, 0x7648efa3, 0xdd9c, 0x4e3e, 0xb5, 0x66, 0x50, 0xf9, 0x29, 0x38, 0x62, 0x80);
   4752     DEFINE_GUID (GUID_SLEEPBUTTON_ACTION, 0x96996bc0, 0xad50, 0x47ec, 0x92, 0x3b, 0x6f, 0x41, 0x87, 0x4d, 0xd9, 0xeb);
   4753     DEFINE_GUID (GUID_USERINTERFACEBUTTON_ACTION, 0xa7066653, 0x8d6c, 0x40a8, 0x91, 0x0e, 0xa1, 0xf5, 0x4b, 0x84, 0xc7, 0xe5);
   4754     DEFINE_GUID (GUID_LIDCLOSE_ACTION, 0x5ca83367, 0x6e45, 0x459f, 0xa2, 0x7b, 0x47, 0x6b, 0x1d, 0x01, 0xc9, 0x36);
   4755     DEFINE_GUID (GUID_LIDOPEN_POWERSTATE, 0x99ff10e7, 0x23b1, 0x4c07, 0xa9, 0xd1, 0x5c, 0x32, 0x06, 0xd7, 0x41, 0xb4);
   4756     DEFINE_GUID (GUID_BATTERY_SUBGROUP, 0xe73a048d, 0xbf27, 0x4f12, 0x97, 0x31, 0x8b, 0x20, 0x76, 0xe8, 0x89, 0x1f);
   4757     DEFINE_GUID (GUID_BATTERY_DISCHARGE_ACTION_0, 0x637ea02f, 0xbbcb, 0x4015, 0x8e, 0x2c, 0xa1, 0xc7, 0xb9, 0xc0, 0xb5, 0x46);
   4758     DEFINE_GUID (GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9a66d8d7, 0x4ff7, 0x4ef9, 0xb5, 0xa2, 0x5a, 0x32, 0x6c, 0xa2, 0xa4, 0x69);
   4759     DEFINE_GUID (GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f);
   4760     DEFINE_GUID (GUID_BATTERY_DISCHARGE_ACTION_1, 0xd8742dcb, 0x3e6a, 0x4b3c, 0xb3, 0xfe, 0x37, 0x46, 0x23, 0xcd, 0xcf, 0x06);
   4761     DEFINE_GUID (GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183ba9a, 0xe910, 0x48da, 0x87, 0x69, 0x14, 0xae, 0x6d, 0xc1, 0x17, 0x0a);
   4762     DEFINE_GUID (GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58);
   4763     DEFINE_GUID (GUID_BATTERY_DISCHARGE_ACTION_2, 0x421cba38, 0x1a8e, 0x4881, 0xac, 0x89, 0xe3, 0x3a, 0x8b, 0x04, 0xec, 0xe4);
   4764     DEFINE_GUID (GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07a07ca2, 0xadaf, 0x40d7, 0xb0, 0x77, 0x53, 0x3a, 0xad, 0xed, 0x1b, 0xfa);
   4765     DEFINE_GUID (GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82);
   4766     DEFINE_GUID (GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455e, 0xb3, 0x08, 0x72, 0xd3, 0x00, 0x3c, 0xf2, 0xf8);
   4767     DEFINE_GUID (GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58afd5a6, 0xc2dd, 0x47d2, 0x9f, 0xbf, 0xef, 0x70, 0xcc, 0x5c, 0x59, 0x65);
   4768     DEFINE_GUID (GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3);
   4769     DEFINE_GUID (GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82be, 0x4824, 0x96, 0xc1, 0x47, 0xb6, 0x0b, 0x74, 0x0d, 0x00);
   4770     DEFINE_GUID (GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4af6, 0x4104, 0x92, 0x60, 0xe3, 0xd9, 0x52, 0x48, 0xfc, 0x36);
   4771     DEFINE_GUID (GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xbc5038f7, 0x23e0, 0x4960, 0x96, 0xda, 0x33, 0xab, 0xaf, 0x59, 0x35, 0xec);
   4772     DEFINE_GUID (GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893dee8e, 0x2bef, 0x41e0, 0x89, 0xc6, 0xb5, 0x5d, 0x09, 0x29, 0x96, 0x4c);
   4773     DEFINE_GUID (GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb);
   4774     DEFINE_GUID (GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c);
   4775     DEFINE_GUID (GUID_PROCESSOR_PERFSTATE_POLICY, 0xbbdc3814, 0x18e9, 0x4463, 0x8a, 0x55, 0xd1, 0x97, 0x32, 0x7c, 0x45, 0xc0);
   4776     DEFINE_GUID (GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d);
   4777     DEFINE_GUID (GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6);
   4778     DEFINE_GUID (GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18);
   4779     DEFINE_GUID (GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6);
   4780     DEFINE_GUID (GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa);
   4781     DEFINE_GUID (GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8);
   4782     DEFINE_GUID (GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5);
   4783     DEFINE_GUID (GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59);
   4784     DEFINE_GUID (GUID_PROCESSOR_PERF_BOOST_MODE, 0xbe337238, 0xd82, 0x4146, 0xa9, 0x60, 0x4f, 0x37, 0x49, 0xd4, 0x70, 0xc7);
   4785     DEFINE_GUID (GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6);
   4786     DEFINE_GUID (GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad);
   4787     DEFINE_GUID (GUID_PROCESSOR_IDLE_STATE_MAXIMUM, 0x9943e905, 0x9a30, 0x4ec1, 0x9b, 0x99, 0x44, 0xdd, 0x3b, 0x76, 0xf7, 0xa2);
   4788     DEFINE_GUID (GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b);
   4789     DEFINE_GUID (GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19);
   4790     DEFINE_GUID (GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c);
   4791     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1);
   4792     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa);
   4793     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6);
   4794     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b);
   4795     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28);
   4796     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83);
   4797     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32);
   4798     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82);
   4799     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82);
   4800     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9);
   4801     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20);
   4802     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d);
   4803     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29);
   4804     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb);
   4805     DEFINE_GUID (GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1);
   4806     DEFINE_GUID (GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f);
   4807     DEFINE_GUID (GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b);
   4808     DEFINE_GUID (GUID_PROCESSOR_PARKING_CONCURRENCY_THRESHOLD, 0x2430ab6f, 0xa520, 0x44a2, 0x96, 0x01, 0xf7, 0xf2, 0x3b, 0x51, 0x34, 0xb1);
   4809     DEFINE_GUID (GUID_PROCESSOR_PARKING_HEADROOM_THRESHOLD, 0xf735a673, 0x2066, 0x4f80, 0xa0, 0xc5, 0xdd, 0xee, 0x0c, 0xf1, 0xbf, 0x5d);
   4810     DEFINE_GUID (GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f);
   4811     DEFINE_GUID (GUID_PROCESSOR_PERF_LATENCY_HINT, 0x0822df31, 0x9c83, 0x441c, 0xa0, 0x79, 0x0d, 0xe4, 0xcf, 0x00, 0x9c, 0x7b);
   4812     DEFINE_GUID (GUID_PROCESSOR_DISTRIBUTE_UTILITY, 0xe0007330, 0xf589, 0x42ed, 0xa4, 0x01, 0x5d, 0xdb, 0x10, 0xe7, 0x85, 0xd3);
   4813     DEFINE_GUID (GUID_SYSTEM_COOLING_POLICY, 0x94d3a615, 0xa899, 0x4ac5, 0xae, 0x2b, 0xe4, 0xd8, 0xf6, 0x34, 0x36, 0x7f);
   4814     DEFINE_GUID (GUID_LOCK_CONSOLE_ON_WAKE, 0x0e796bdb, 0x100d, 0x47d6, 0xa2, 0xd5, 0xf7, 0xd2, 0xda, 0xa5, 0x1f, 0x51);
   4815     DEFINE_GUID (GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19);
   4816     DEFINE_GUID (GUID_ACDC_POWER_SOURCE, 0x5d3e9a59, 0xe9d5, 0x4b00, 0xa6, 0xbd, 0xff, 0x34, 0xff, 0x51, 0x65, 0x48);
   4817     DEFINE_GUID (GUID_LIDSWITCH_STATE_CHANGE, 0xba3e0f4d, 0xb817, 0x4094, 0xa2, 0xd1, 0xd5, 0x63, 0x79, 0xe6, 0xa0, 0xf3);
   4818     DEFINE_GUID (GUID_BATTERY_PERCENTAGE_REMAINING, 0xa7ad8041, 0xb45a, 0x4cae, 0x87, 0xa3, 0xee, 0xcb, 0xb4, 0x68, 0xa9, 0xe1);
   4819     DEFINE_GUID (GUID_GLOBAL_USER_PRESENCE, 0x786e8a1d, 0xb427, 0x4344, 0x92, 0x7, 0x9, 0xe7, 0xb, 0xdc, 0xbe, 0xa9);
   4820     DEFINE_GUID (GUID_SESSION_DISPLAY_STATUS, 0x2b84c20e, 0xad23, 0x4ddf, 0x93, 0xdb, 0x5, 0xff, 0xbd, 0x7e, 0xfc, 0xa5);
   4821     DEFINE_GUID (GUID_SESSION_USER_PRESENCE, 0x3c0f4548, 0xc03f, 0x4c4d, 0xb9, 0xf2, 0x23, 0x7e, 0xde, 0x68, 0x63, 0x76);
   4822     DEFINE_GUID (GUID_IDLE_BACKGROUND_TASK, 0x515c31d8, 0xf734, 0x163d, 0xa0, 0xfd, 0x11, 0xa0, 0x8c, 0x91, 0xe8, 0xf1);
   4823     DEFINE_GUID (GUID_BACKGROUND_TASK_NOTIFICATION, 0xcf23f240, 0x2a54, 0x48d8, 0xb1, 0x14, 0xde, 0x15, 0x18, 0xff, 0x05, 0x2e);
   4824     DEFINE_GUID (GUID_APPLAUNCH_BUTTON, 0x1a689231, 0x7399, 0x4e9a, 0x8f, 0x99, 0xb7, 0x1f, 0x99, 0x9d, 0xb3, 0xfa);
   4825     DEFINE_GUID (GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af, 0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20);
   4826     DEFINE_GUID (GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5);
   4827     DEFINE_GUID (GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6);
   4828 
   4829   typedef enum _SYSTEM_POWER_STATE {
   4830     PowerSystemUnspecified = 0,PowerSystemWorking = 1,PowerSystemSleeping1 = 2,PowerSystemSleeping2 = 3,PowerSystemSleeping3 = 4,PowerSystemHibernate = 5,PowerSystemShutdown = 6,PowerSystemMaximum = 7
   4831   } SYSTEM_POWER_STATE,*PSYSTEM_POWER_STATE;
   4832 
   4833 #define POWER_SYSTEM_MAXIMUM 7
   4834 
   4835   typedef enum {
   4836     PowerActionNone = 0, PowerActionReserved, PowerActionSleep, PowerActionHibernate,
   4837     PowerActionShutdown, PowerActionShutdownReset, PowerActionShutdownOff,
   4838     PowerActionWarmEject
   4839   } POWER_ACTION,*PPOWER_ACTION;
   4840 
   4841   typedef enum _DEVICE_POWER_STATE {
   4842     PowerDeviceUnspecified = 0, PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, PowerDeviceD3,
   4843     PowerDeviceMaximum
   4844   } DEVICE_POWER_STATE,*PDEVICE_POWER_STATE;
   4845 
   4846   typedef enum _MONITOR_DISPLAY_STATE {
   4847     PowerMonitorOff = 0, PowerMonitorOn, PowerMonitorDim
   4848   } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
   4849 
   4850   typedef enum _USER_ACTIVITY_PRESENCE {
   4851     PowerUserPresent = 0,
   4852     PowerUserNotPresent,
   4853     PowerUserInactive,
   4854     PowerUserMaximum,
   4855     PowerUserInvalid = PowerUserMaximum
   4856   } USER_ACTIVITY_PRESENCE,*PUSER_ACTIVITY_PRESENCE;
   4857 
   4858 #define ES_SYSTEM_REQUIRED ((DWORD)0x00000001)
   4859 #define ES_DISPLAY_REQUIRED ((DWORD)0x00000002)
   4860 #define ES_USER_PRESENT ((DWORD)0x00000004)
   4861 #define ES_AWAYMODE_REQUIRED ((DWORD)0x00000040)
   4862 #define ES_CONTINUOUS ((DWORD)0x80000000)
   4863 
   4864   typedef DWORD EXECUTION_STATE, *PEXECUTION_STATE;
   4865 
   4866   typedef enum {
   4867     LT_DONT_CARE,LT_LOWEST_LATENCY
   4868   } LATENCY_TIME;
   4869 
   4870 #define DIAGNOSTIC_REASON_VERSION 0
   4871 #define POWER_REQUEST_CONTEXT_VERSION 0
   4872 
   4873 #define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001
   4874 #define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002
   4875 #define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000
   4876 #define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003)
   4877 
   4878 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
   4879 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
   4880 
   4881   typedef enum _POWER_REQUEST_TYPE {
   4882     PowerRequestDisplayRequired,
   4883     PowerRequestSystemRequired,
   4884     PowerRequestAwayModeRequired,
   4885     PowerRequestExecutionRequired
   4886   } POWER_REQUEST_TYPE,*PPOWER_REQUEST_TYPE;
   4887 
   4888 #define PDCAP_D0_SUPPORTED 0x00000001
   4889 #define PDCAP_D1_SUPPORTED 0x00000002
   4890 #define PDCAP_D2_SUPPORTED 0x00000004
   4891 #define PDCAP_D3_SUPPORTED 0x00000008
   4892 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
   4893 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
   4894 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
   4895 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
   4896 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
   4897 
   4898     typedef struct CM_Power_Data_s {
   4899       DWORD PD_Size;
   4900       DEVICE_POWER_STATE PD_MostRecentPowerState;
   4901       DWORD PD_Capabilities;
   4902       DWORD PD_D1Latency;
   4903       DWORD PD_D2Latency;
   4904       DWORD PD_D3Latency;
   4905       DEVICE_POWER_STATE PD_PowerStateMapping[POWER_SYSTEM_MAXIMUM];
   4906       SYSTEM_POWER_STATE PD_DeepestSystemWake;
   4907     } CM_POWER_DATA,*PCM_POWER_DATA;
   4908 
   4909     typedef enum {
   4910       SystemPowerPolicyAc,
   4911       SystemPowerPolicyDc,
   4912       VerifySystemPolicyAc,
   4913       VerifySystemPolicyDc,
   4914       SystemPowerCapabilities,
   4915       SystemBatteryState,
   4916       SystemPowerStateHandler,
   4917       ProcessorStateHandler,
   4918       SystemPowerPolicyCurrent,
   4919       AdministratorPowerPolicy,
   4920       SystemReserveHiberFile,
   4921       ProcessorInformation,
   4922       SystemPowerInformation,
   4923       ProcessorStateHandler2,
   4924       LastWakeTime,
   4925       LastSleepTime,
   4926       SystemExecutionState,
   4927       SystemPowerStateNotifyHandler,
   4928       ProcessorPowerPolicyAc,
   4929       ProcessorPowerPolicyDc,
   4930       VerifyProcessorPowerPolicyAc,
   4931       VerifyProcessorPowerPolicyDc,
   4932       ProcessorPowerPolicyCurrent,
   4933       SystemPowerStateLogging,
   4934       SystemPowerLoggingEntry,
   4935       SetPowerSettingValue,
   4936       NotifyUserPowerSetting,
   4937       PowerInformationLevelUnused0,
   4938       SystemMonitorHiberBootPowerOff,
   4939       SystemVideoState,
   4940       TraceApplicationPowerMessage,
   4941       TraceApplicationPowerMessageEnd,
   4942       ProcessorPerfStates,
   4943       ProcessorIdleStates,
   4944       ProcessorCap,
   4945       SystemWakeSource,
   4946       SystemHiberFileInformation,
   4947       TraceServicePowerMessage,
   4948       ProcessorLoad,
   4949       PowerShutdownNotification,
   4950       MonitorCapabilities,
   4951       SessionPowerInit,
   4952       SessionDisplayState,
   4953       PowerRequestCreate,
   4954       PowerRequestAction,
   4955       GetPowerRequestList,
   4956       ProcessorInformationEx,
   4957       NotifyUserModeLegacyPowerEvent,
   4958       GroupPark,
   4959       ProcessorIdleDomains,
   4960       WakeTimerList,
   4961       SystemHiberFileSize,
   4962       ProcessorIdleStatesHv,
   4963       ProcessorPerfStatesHv,
   4964       ProcessorPerfCapHv,
   4965       ProcessorSetIdle,
   4966       LogicalProcessorIdling,
   4967       UserPresence,
   4968       PowerSettingNotificationName,
   4969       GetPowerSettingValue,
   4970       IdleResiliency,
   4971       SessionRITState,
   4972       SessionConnectNotification,
   4973       SessionPowerCleanup,
   4974       SessionLockState,
   4975       SystemHiberbootState,
   4976       PlatformInformation,
   4977       PdcInvocation,
   4978       MonitorInvocation,
   4979       FirmwareTableInformationRegistered,
   4980       SetShutdownSelectedTime,
   4981       SuspendResumeInvocation,
   4982       PlmPowerRequestCreate,
   4983       ScreenOff,
   4984       CsDeviceNotification,
   4985       PlatformRole,
   4986       LastResumePerformance,
   4987       DisplayBurst,
   4988       ExitLatencySamplingPercentage,
   4989       ApplyLowPowerScenarioSettings,
   4990       PowerInformationLevelMaximum
   4991     } POWER_INFORMATION_LEVEL;
   4992 
   4993     typedef enum {
   4994       UserNotPresent = 0,
   4995       UserPresent = 1,
   4996       UserUnknown = 0xff
   4997     } POWER_USER_PRESENCE_TYPE,*PPOWER_USER_PRESENCE_TYPE;
   4998 
   4999     typedef struct _POWER_USER_PRESENCE {
   5000       POWER_USER_PRESENCE_TYPE UserPresence;
   5001     } POWER_USER_PRESENCE,*PPOWER_USER_PRESENCE;
   5002 
   5003     typedef struct _POWER_SESSION_CONNECT {
   5004       BOOLEAN Connected;
   5005       BOOLEAN Console;
   5006     } POWER_SESSION_CONNECT,*PPOWER_SESSION_CONNECT;
   5007 
   5008     typedef struct _POWER_SESSION_TIMEOUTS {
   5009       DWORD InputTimeout;
   5010       DWORD DisplayTimeout;
   5011     } POWER_SESSION_TIMEOUTS,*PPOWER_SESSION_TIMEOUTS;
   5012 
   5013     typedef struct _POWER_SESSION_RIT_STATE {
   5014       BOOLEAN Active;
   5015       DWORD LastInputTime;
   5016     } POWER_SESSION_RIT_STATE,*PPOWER_SESSION_RIT_STATE;
   5017 
   5018     typedef struct _POWER_SESSION_WINLOGON {
   5019       DWORD SessionId;
   5020       BOOLEAN Console;
   5021       BOOLEAN Locked;
   5022     } POWER_SESSION_WINLOGON,*PPOWER_SESSION_WINLOGON;
   5023 
   5024     typedef struct _POWER_IDLE_RESILIENCY {
   5025       DWORD CoalescingTimeout;
   5026       DWORD IdleResiliencyPeriod;
   5027     } POWER_IDLE_RESILIENCY,*PPOWER_IDLE_RESILIENCY;
   5028 
   5029     typedef enum {
   5030       MonitorRequestReasonUnknown,
   5031       MonitorRequestReasonPowerButton,
   5032       MonitorRequestReasonRemoteConnection,
   5033       MonitorRequestReasonScMonitorpower,
   5034       MonitorRequestReasonUserInput,
   5035       MonitorRequestReasonAcDcDisplayBurst,
   5036       MonitorRequestReasonUserDisplayBurst,
   5037       MonitorRequestReasonPoSetSystemState,
   5038       MonitorRequestReasonSetThreadExecutionState,
   5039       MonitorRequestReasonFullWake,
   5040       MonitorRequestReasonSessionUnlock,
   5041       MonitorRequestReasonScreenOffRequest,
   5042       MonitorRequestReasonIdleTimeout,
   5043       MonitorRequestReasonPolicyChange,
   5044       MonitorRequestReasonMax
   5045     } POWER_MONITOR_REQUEST_REASON;
   5046 
   5047     typedef struct _POWER_MONITOR_INVOCATION {
   5048       BOOLEAN On;
   5049       BOOLEAN Console;
   5050       POWER_MONITOR_REQUEST_REASON RequestReason;
   5051     } POWER_MONITOR_INVOCATION,*PPOWER_MONITOR_INVOCATION;
   5052 
   5053     typedef struct _RESUME_PERFORMANCE {
   5054       DWORD PostTimeMs;
   5055       ULONGLONG TotalResumeTimeMs;
   5056       ULONGLONG ResumeCompleteTimestamp;
   5057     } RESUME_PERFORMANCE,*PRESUME_PERFORMANCE;
   5058 
   5059     typedef enum {
   5060       PoAc,
   5061       PoDc,
   5062       PoHot,
   5063       PoConditionMaximum
   5064     } SYSTEM_POWER_CONDITION;
   5065 
   5066     typedef struct {
   5067       DWORD Version;
   5068       GUID Guid;
   5069       SYSTEM_POWER_CONDITION PowerCondition;
   5070       DWORD DataLength;
   5071       BYTE Data[ANYSIZE_ARRAY];
   5072     } SET_POWER_SETTING_VALUE,*PSET_POWER_SETTING_VALUE;
   5073 
   5074 #define POWER_SETTING_VALUE_VERSION (0x1)
   5075 
   5076     typedef struct {
   5077       GUID Guid;
   5078     } NOTIFY_USER_POWER_SETTING,*PNOTIFY_USER_POWER_SETTING;
   5079 
   5080     typedef struct _APPLICATIONLAUNCH_SETTING_VALUE {
   5081       LARGE_INTEGER ActivationTime;
   5082       DWORD Flags;
   5083       DWORD ButtonInstanceID;
   5084     } APPLICATIONLAUNCH_SETTING_VALUE,*PAPPLICATIONLAUNCH_SETTING_VALUE;
   5085 
   5086     typedef enum _POWER_PLATFORM_ROLE {
   5087       PlatformRoleUnspecified = 0,
   5088       PlatformRoleDesktop,
   5089       PlatformRoleMobile,
   5090       PlatformRoleWorkstation,
   5091       PlatformRoleEnterpriseServer,
   5092       PlatformRoleSOHOServer,
   5093       PlatformRoleAppliancePC,
   5094       PlatformRolePerformanceServer,
   5095       PlatformRoleSlate,
   5096       PlatformRoleMaximum
   5097     } POWER_PLATFORM_ROLE,*PPOWER_PLATFORM_ROLE;
   5098 
   5099     typedef struct _POWER_PLATFORM_INFORMATION {
   5100       BOOLEAN AoAc;
   5101     } POWER_PLATFORM_INFORMATION,*PPOWER_PLATFORM_INFORMATION;
   5102 
   5103 #define POWER_PLATFORM_ROLE_V1 (0x00000001)
   5104 #define POWER_PLATFORM_ROLE_V1_MAX (PlatformRolePerformanceServer + 1)
   5105 
   5106 #define POWER_PLATFORM_ROLE_V2 (0x00000002)
   5107 #define POWER_PLATFORM_ROLE_V2_MAX (PlatformRoleSlate + 1)
   5108 
   5109 #if _WIN32_WINNT >= 0x0602
   5110 #define POWER_PLATFORM_ROLE_VERSION POWER_PLATFORM_ROLE_V2
   5111 #define POWER_PLATFORM_ROLE_VERSION_MAX POWER_PLATFORM_ROLE_V2_MAX
   5112 #else
   5113 #define POWER_PLATFORM_ROLE_VERSION POWER_PLATFORM_ROLE_V1
   5114 #define POWER_PLATFORM_ROLE_VERSION_MAX POWER_PLATFORM_ROLE_V1_MAX
   5115 #endif
   5116 
   5117     typedef struct {
   5118       DWORD Granularity;
   5119       DWORD Capacity;
   5120     } BATTERY_REPORTING_SCALE,*PBATTERY_REPORTING_SCALE;
   5121 
   5122     typedef struct {
   5123       DWORD Frequency;
   5124       DWORD Flags;
   5125       DWORD PercentFrequency;
   5126     } PPM_WMI_LEGACY_PERFSTATE,*PPPM_WMI_LEGACY_PERFSTATE;
   5127 
   5128     typedef struct {
   5129       DWORD Latency;
   5130       DWORD Power;
   5131       DWORD TimeCheck;
   5132       BYTE PromotePercent;
   5133       BYTE DemotePercent;
   5134       BYTE StateType;
   5135       BYTE Reserved;
   5136       DWORD StateFlags;
   5137       DWORD Context;
   5138       DWORD IdleHandler;
   5139       DWORD Reserved1;
   5140     } PPM_WMI_IDLE_STATE,*PPPM_WMI_IDLE_STATE;
   5141 
   5142     typedef struct {
   5143       DWORD Type;
   5144       DWORD Count;
   5145       DWORD TargetState;
   5146       DWORD OldState;
   5147       DWORD64 TargetProcessors;
   5148       PPM_WMI_IDLE_STATE State[ANYSIZE_ARRAY];
   5149     } PPM_WMI_IDLE_STATES,*PPPM_WMI_IDLE_STATES;
   5150 
   5151     typedef struct {
   5152       DWORD Type;
   5153       DWORD Count;
   5154       DWORD TargetState;
   5155       DWORD OldState;
   5156       PVOID TargetProcessors;
   5157       PPM_WMI_IDLE_STATE State[ANYSIZE_ARRAY];
   5158     } PPM_WMI_IDLE_STATES_EX,*PPPM_WMI_IDLE_STATES_EX;
   5159 
   5160     typedef struct {
   5161       DWORD Frequency;
   5162       DWORD Power;
   5163       BYTE PercentFrequency;
   5164       BYTE IncreaseLevel;
   5165       BYTE DecreaseLevel;
   5166       BYTE Type;
   5167       DWORD IncreaseTime;
   5168       DWORD DecreaseTime;
   5169       DWORD64 Control;
   5170       DWORD64 Status;
   5171       DWORD HitCount;
   5172       DWORD Reserved1;
   5173       DWORD64 Reserved2;
   5174       DWORD64 Reserved3;
   5175     } PPM_WMI_PERF_STATE,*PPPM_WMI_PERF_STATE;
   5176 
   5177     typedef struct {
   5178       DWORD Count;
   5179       DWORD MaxFrequency;
   5180       DWORD CurrentState;
   5181       DWORD MaxPerfState;
   5182       DWORD MinPerfState;
   5183       DWORD LowestPerfState;
   5184       DWORD ThermalConstraint;
   5185       BYTE BusyAdjThreshold;
   5186       BYTE PolicyType;
   5187       BYTE Type;
   5188       BYTE Reserved;
   5189       DWORD TimerInterval;
   5190       DWORD64 TargetProcessors;
   5191       DWORD PStateHandler;
   5192       DWORD PStateContext;
   5193       DWORD TStateHandler;
   5194       DWORD TStateContext;
   5195       DWORD FeedbackHandler;
   5196       DWORD Reserved1;
   5197       DWORD64 Reserved2;
   5198       PPM_WMI_PERF_STATE State[ANYSIZE_ARRAY];
   5199     } PPM_WMI_PERF_STATES,*PPPM_WMI_PERF_STATES;
   5200 
   5201     typedef struct {
   5202       DWORD Count;
   5203       DWORD MaxFrequency;
   5204       DWORD CurrentState;
   5205       DWORD MaxPerfState;
   5206       DWORD MinPerfState;
   5207       DWORD LowestPerfState;
   5208       DWORD ThermalConstraint;
   5209       BYTE BusyAdjThreshold;
   5210       BYTE PolicyType;
   5211       BYTE Type;
   5212       BYTE Reserved;
   5213       DWORD TimerInterval;
   5214       PVOID TargetProcessors;
   5215       DWORD PStateHandler;
   5216       DWORD PStateContext;
   5217       DWORD TStateHandler;
   5218       DWORD TStateContext;
   5219       DWORD FeedbackHandler;
   5220       DWORD Reserved1;
   5221       DWORD64 Reserved2;
   5222       PPM_WMI_PERF_STATE State[ANYSIZE_ARRAY];
   5223     } PPM_WMI_PERF_STATES_EX,*PPPM_WMI_PERF_STATES_EX;
   5224 
   5225 #define PROC_IDLE_BUCKET_COUNT 6
   5226 #define PROC_IDLE_BUCKET_COUNT_EX 16
   5227 
   5228     typedef struct {
   5229       DWORD IdleTransitions;
   5230       DWORD FailedTransitions;
   5231       DWORD InvalidBucketIndex;
   5232       DWORD64 TotalTime;
   5233       DWORD IdleTimeBuckets[PROC_IDLE_BUCKET_COUNT];
   5234     } PPM_IDLE_STATE_ACCOUNTING,*PPPM_IDLE_STATE_ACCOUNTING;
   5235 
   5236     typedef struct {
   5237       DWORD StateCount;
   5238       DWORD TotalTransitions;
   5239       DWORD ResetCount;
   5240       DWORD64 StartTime;
   5241       PPM_IDLE_STATE_ACCOUNTING State[ANYSIZE_ARRAY];
   5242     } PPM_IDLE_ACCOUNTING,*PPPM_IDLE_ACCOUNTING;
   5243 
   5244     typedef struct {
   5245       DWORD64 TotalTimeUs;
   5246       DWORD MinTimeUs;
   5247       DWORD MaxTimeUs;
   5248       DWORD Count;
   5249     } PPM_IDLE_STATE_BUCKET_EX,*PPPM_IDLE_STATE_BUCKET_EX;
   5250 
   5251     typedef struct {
   5252       DWORD64 TotalTime;
   5253       DWORD IdleTransitions;
   5254       DWORD FailedTransitions;
   5255       DWORD InvalidBucketIndex;
   5256       DWORD MinTimeUs;
   5257       DWORD MaxTimeUs;
   5258       DWORD CancelledTransitions;
   5259       PPM_IDLE_STATE_BUCKET_EX IdleTimeBuckets[PROC_IDLE_BUCKET_COUNT_EX];
   5260     } PPM_IDLE_STATE_ACCOUNTING_EX,*PPPM_IDLE_STATE_ACCOUNTING_EX;
   5261 
   5262     typedef struct {
   5263       DWORD StateCount;
   5264       DWORD TotalTransitions;
   5265       DWORD ResetCount;
   5266       DWORD AbortCount;
   5267       DWORD64 StartTime;
   5268       PPM_IDLE_STATE_ACCOUNTING_EX State[ANYSIZE_ARRAY];
   5269     } PPM_IDLE_ACCOUNTING_EX,*PPPM_IDLE_ACCOUNTING_EX;
   5270 
   5271 #define ACPI_PPM_SOFTWARE_ALL 0xfc
   5272 #define ACPI_PPM_SOFTWARE_ANY 0xfd
   5273 #define ACPI_PPM_HARDWARE_ALL 0xfe
   5274 
   5275 #define MS_PPM_SOFTWARE_ALL 0x1
   5276 
   5277 #define PPM_FIRMWARE_ACPI1C2 0x1
   5278 #define PPM_FIRMWARE_ACPI1C3 0x2
   5279 #define PPM_FIRMWARE_ACPI1TSTATES 0x4
   5280 #define PPM_FIRMWARE_CST 0x8
   5281 #define PPM_FIRMWARE_CSD 0x10
   5282 #define PPM_FIRMWARE_PCT 0x20
   5283 #define PPM_FIRMWARE_PSS 0x40
   5284 #define PPM_FIRMWARE_XPSS 0x80
   5285 #define PPM_FIRMWARE_PPC 0x100
   5286 #define PPM_FIRMWARE_PSD 0x200
   5287 #define PPM_FIRMWARE_PTC 0x400
   5288 #define PPM_FIRMWARE_TSS 0x800
   5289 #define PPM_FIRMWARE_TPC 0x1000
   5290 #define PPM_FIRMWARE_TSD 0x2000
   5291 #define PPM_FIRMWARE_PCCH 0x4000
   5292 #define PPM_FIRMWARE_PCCP 0x8000
   5293 #define PPM_FIRMWARE_OSC 0x10000
   5294 #define PPM_FIRMWARE_PDC 0x20000
   5295 #define PPM_FIRMWARE_CPC 0x40000
   5296 
   5297 #define PPM_PERFORMANCE_IMPLEMENTATION_NONE 0
   5298 #define PPM_PERFORMANCE_IMPLEMENTATION_PSTATES 1
   5299 #define PPM_PERFORMANCE_IMPLEMENTATION_PCCV1 2
   5300 #define PPM_PERFORMANCE_IMPLEMENTATION_CPPC 3
   5301 #define PPM_PERFORMANCE_IMPLEMENTATION_PEP 4
   5302 
   5303 #define PPM_IDLE_IMPLEMENTATION_NONE 0x0
   5304 #define PPM_IDLE_IMPLEMENTATION_CSTATES 0x1
   5305 #define PPM_IDLE_IMPLEMENTATION_PEP 0x2
   5306 
   5307     typedef struct {
   5308       DWORD State;
   5309       DWORD Status;
   5310       DWORD Latency;
   5311       DWORD Speed;
   5312       DWORD Processor;
   5313     } PPM_PERFSTATE_EVENT,*PPPM_PERFSTATE_EVENT;
   5314 
   5315     typedef struct {
   5316       DWORD State;
   5317       DWORD Latency;
   5318       DWORD Speed;
   5319       DWORD64 Processors;
   5320     } PPM_PERFSTATE_DOMAIN_EVENT,*PPPM_PERFSTATE_DOMAIN_EVENT;
   5321 
   5322     typedef struct {
   5323       DWORD NewState;
   5324       DWORD OldState;
   5325       DWORD64 Processors;
   5326     } PPM_IDLESTATE_EVENT,*PPPM_IDLESTATE_EVENT;
   5327 
   5328     typedef struct {
   5329       DWORD ThermalConstraint;
   5330       DWORD64 Processors;
   5331     } PPM_THERMALCHANGE_EVENT,*PPPM_THERMALCHANGE_EVENT;
   5332     typedef struct {
   5333       BYTE Mode;
   5334       DWORD64 Processors;
   5335     } PPM_THERMAL_POLICY_EVENT,*PPPM_THERMAL_POLICY_EVENT;
   5336 
   5337     DEFINE_GUID (PPM_PERFSTATE_CHANGE_GUID, 0xa5b32ddd, 0x7f39, 0x4abc, 0xb8, 0x92, 0x90, 0xe, 0x43, 0xb5, 0x9e, 0xbb);
   5338     DEFINE_GUID (PPM_PERFSTATE_DOMAIN_CHANGE_GUID, 0x995e6b7f, 0xd653, 0x497a, 0xb9, 0x78, 0x36, 0xa3, 0xc, 0x29, 0xbf, 0x1);
   5339     DEFINE_GUID (PPM_IDLESTATE_CHANGE_GUID, 0x4838fe4f, 0xf71c, 0x4e51, 0x9e, 0xcc, 0x84, 0x30, 0xa7, 0xac, 0x4c, 0x6c);
   5340     DEFINE_GUID (PPM_PERFSTATES_DATA_GUID, 0x5708cc20, 0x7d40, 0x4bf4, 0xb4, 0xaa, 0x2b, 0x01, 0x33, 0x8d, 0x01, 0x26);
   5341     DEFINE_GUID (PPM_IDLESTATES_DATA_GUID, 0xba138e10, 0xe250, 0x4ad7, 0x86, 0x16, 0xcf, 0x1a, 0x7a, 0xd4, 0x10, 0xe7);
   5342     DEFINE_GUID (PPM_IDLE_ACCOUNTING_GUID, 0xe2a26f78, 0xae07, 0x4ee0, 0xa3, 0x0f, 0xce, 0x54, 0xf5, 0x5a, 0x94, 0xcd);
   5343     DEFINE_GUID (PPM_IDLE_ACCOUNTING_EX_GUID, 0xd67abd39, 0x81f8, 0x4a5e, 0x81, 0x52, 0x72, 0xe3, 0x1e, 0xc9, 0x12, 0xee);
   5344     DEFINE_GUID (PPM_THERMALCONSTRAINT_GUID, 0xa852c2c8, 0x1a4c, 0x423b, 0x8c, 0x2c, 0xf3, 0x0d, 0x82, 0x93, 0x1a, 0x88);
   5345     DEFINE_GUID (PPM_PERFMON_PERFSTATE_GUID, 0x7fd18652, 0xcfe, 0x40d2, 0xb0, 0xa1, 0xb, 0x6, 0x6a, 0x87, 0x75, 0x9e);
   5346     DEFINE_GUID (PPM_THERMAL_POLICY_CHANGE_GUID, 0x48f377b8, 0x6880, 0x4c7b, 0x8b, 0xdc, 0x38, 0x1, 0x76, 0xc6, 0x65, 0x4d);
   5347 
   5348     typedef struct {
   5349       POWER_ACTION Action;
   5350       DWORD Flags;
   5351       DWORD EventCode;
   5352     } POWER_ACTION_POLICY,*PPOWER_ACTION_POLICY;
   5353 
   5354 #define POWER_ACTION_QUERY_ALLOWED 0x00000001
   5355 #define POWER_ACTION_UI_ALLOWED 0x00000002
   5356 #define POWER_ACTION_OVERRIDE_APPS 0x00000004
   5357 #define POWER_ACTION_HIBERBOOT 0x00000008
   5358 #define POWER_ACTION_PSEUDO_TRANSITION 0x08000000
   5359 #define POWER_ACTION_LIGHTEST_FIRST 0x10000000
   5360 #define POWER_ACTION_LOCK_CONSOLE 0x20000000
   5361 #define POWER_ACTION_DISABLE_WAKES 0x40000000
   5362 #define POWER_ACTION_CRITICAL 0x80000000
   5363 
   5364 #define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
   5365 #define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
   5366 #define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
   5367 #define POWER_USER_NOTIFY_BUTTON 0x00000008
   5368 #define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
   5369 #define POWER_USER_NOTIFY_FORCED_SHUTDOWN 0x00000020
   5370 #define POWER_FORCE_TRIGGER_RESET 0x80000000
   5371 
   5372 #define BATTERY_DISCHARGE_FLAGS_EVENTCODE_MASK 0x00000007
   5373 #define BATTERY_DISCHARGE_FLAGS_ENABLE 0x80000000
   5374 
   5375 #define DISCHARGE_POLICY_CRITICAL 0
   5376 #define DISCHARGE_POLICY_LOW 1
   5377 
   5378 #define NUM_DISCHARGE_POLICIES 4
   5379 
   5380 #define PROCESSOR_IDLESTATE_POLICY_COUNT 0x3
   5381 
   5382     typedef struct {
   5383       DWORD TimeCheck;
   5384       BYTE DemotePercent;
   5385       BYTE PromotePercent;
   5386       BYTE Spare[2];
   5387     } PROCESSOR_IDLESTATE_INFO,*PPROCESSOR_IDLESTATE_INFO;
   5388 
   5389     typedef struct {
   5390       BOOLEAN Enable;
   5391       BYTE Spare[3];
   5392       DWORD BatteryLevel;
   5393       POWER_ACTION_POLICY PowerPolicy;
   5394       SYSTEM_POWER_STATE MinSystemState;
   5395     } SYSTEM_POWER_LEVEL,*PSYSTEM_POWER_LEVEL;
   5396 
   5397     typedef struct _SYSTEM_POWER_POLICY {
   5398       DWORD Revision;
   5399       POWER_ACTION_POLICY PowerButton;
   5400       POWER_ACTION_POLICY SleepButton;
   5401       POWER_ACTION_POLICY LidClose;
   5402       SYSTEM_POWER_STATE LidOpenWake;
   5403       DWORD Reserved;
   5404       POWER_ACTION_POLICY Idle;
   5405       DWORD IdleTimeout;
   5406       BYTE IdleSensitivity;
   5407       BYTE DynamicThrottle;
   5408       BYTE Spare2[2];
   5409       SYSTEM_POWER_STATE MinSleep;
   5410       SYSTEM_POWER_STATE MaxSleep;
   5411       SYSTEM_POWER_STATE ReducedLatencySleep;
   5412       DWORD WinLogonFlags;
   5413       DWORD Spare3;
   5414       DWORD DozeS4Timeout;
   5415       DWORD BroadcastCapacityResolution;
   5416       SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
   5417       DWORD VideoTimeout;
   5418       BOOLEAN VideoDimDisplay;
   5419       DWORD VideoReserved[3];
   5420       DWORD SpindownTimeout;
   5421       BOOLEAN OptimizeForPower;
   5422       BYTE FanThrottleTolerance;
   5423       BYTE ForcedThrottle;
   5424       BYTE MinThrottle;
   5425       POWER_ACTION_POLICY OverThrottled;
   5426     } SYSTEM_POWER_POLICY,*PSYSTEM_POWER_POLICY;
   5427 
   5428 #define PO_THROTTLE_NONE 0
   5429 #define PO_THROTTLE_CONSTANT 1
   5430 #define PO_THROTTLE_DEGRADE 2
   5431 #define PO_THROTTLE_ADAPTIVE 3
   5432 #define PO_THROTTLE_MAXIMUM 4
   5433 
   5434     typedef struct {
   5435       WORD Revision;
   5436       union {
   5437 	WORD AsWORD;
   5438 	__C89_NAMELESS struct {
   5439 	  WORD AllowScaling : 1;
   5440 	  WORD Disabled : 1;
   5441 	  WORD Reserved : 14;
   5442 	} DUMMYSTRUCTNAME;
   5443       } Flags;
   5444       DWORD PolicyCount;
   5445       PROCESSOR_IDLESTATE_INFO Policy[PROCESSOR_IDLESTATE_POLICY_COUNT];
   5446     } PROCESSOR_IDLESTATE_POLICY,*PPROCESSOR_IDLESTATE_POLICY;
   5447 
   5448     typedef struct _PROCESSOR_POWER_POLICY_INFO {
   5449       DWORD TimeCheck;
   5450       DWORD DemoteLimit;
   5451       DWORD PromoteLimit;
   5452       BYTE DemotePercent;
   5453       BYTE PromotePercent;
   5454       BYTE Spare[2];
   5455       DWORD AllowDemotion:1;
   5456       DWORD AllowPromotion:1;
   5457       DWORD Reserved:30;
   5458     } PROCESSOR_POWER_POLICY_INFO,*PPROCESSOR_POWER_POLICY_INFO;
   5459 
   5460     typedef struct _PROCESSOR_POWER_POLICY {
   5461       DWORD Revision;
   5462       BYTE DynamicThrottle;
   5463       BYTE Spare[3];
   5464       DWORD DisableCStates:1;
   5465       DWORD Reserved:31;
   5466       DWORD PolicyCount;
   5467       PROCESSOR_POWER_POLICY_INFO Policy[3];
   5468     } PROCESSOR_POWER_POLICY,*PPROCESSOR_POWER_POLICY;
   5469 
   5470     typedef struct {
   5471       DWORD Revision;
   5472       BYTE MaxThrottle;
   5473       BYTE MinThrottle;
   5474       BYTE BusyAdjThreshold;
   5475       __C89_NAMELESS union {
   5476 	BYTE Spare;
   5477 	union {
   5478 	  BYTE AsBYTE;
   5479 	  __C89_NAMELESS struct {
   5480 	    BYTE NoDomainAccounting : 1;
   5481 	    BYTE IncreasePolicy: 2;
   5482 	    BYTE DecreasePolicy: 2;
   5483 	    BYTE Reserved : 3;
   5484 	  } DUMMYSTRUCTNAME;
   5485 	} Flags;
   5486       } DUMMYUNIONNAME;
   5487       DWORD TimeCheck;
   5488       DWORD IncreaseTime;
   5489       DWORD DecreaseTime;
   5490       DWORD IncreasePercent;
   5491       DWORD DecreasePercent;
   5492     } PROCESSOR_PERFSTATE_POLICY,*PPROCESSOR_PERFSTATE_POLICY;
   5493 
   5494     typedef struct _ADMINISTRATOR_POWER_POLICY {
   5495       SYSTEM_POWER_STATE MinSleep;
   5496       SYSTEM_POWER_STATE MaxSleep;
   5497       DWORD MinVideoTimeout;
   5498       DWORD MaxVideoTimeout;
   5499       DWORD MinSpindownTimeout;
   5500       DWORD MaxSpindownTimeout;
   5501     } ADMINISTRATOR_POWER_POLICY,*PADMINISTRATOR_POWER_POLICY;
   5502 
   5503     typedef struct {
   5504       BOOLEAN PowerButtonPresent;
   5505       BOOLEAN SleepButtonPresent;
   5506       BOOLEAN LidPresent;
   5507       BOOLEAN SystemS1;
   5508       BOOLEAN SystemS2;
   5509       BOOLEAN SystemS3;
   5510       BOOLEAN SystemS4;
   5511       BOOLEAN SystemS5;
   5512       BOOLEAN HiberFilePresent;
   5513       BOOLEAN FullWake;
   5514       BOOLEAN VideoDimPresent;
   5515       BOOLEAN ApmPresent;
   5516       BOOLEAN UpsPresent;
   5517       BOOLEAN ThermalControl;
   5518       BOOLEAN ProcessorThrottle;
   5519       BYTE ProcessorMinThrottle;
   5520       BYTE ProcessorMaxThrottle;
   5521       BOOLEAN FastSystemS4;
   5522       BYTE spare2[3];
   5523       BOOLEAN DiskSpinDown;
   5524       BYTE spare3[8];
   5525       BOOLEAN SystemBatteriesPresent;
   5526       BOOLEAN BatteriesAreShortTerm;
   5527       BATTERY_REPORTING_SCALE BatteryScale[3];
   5528       SYSTEM_POWER_STATE AcOnLineWake;
   5529       SYSTEM_POWER_STATE SoftLidWake;
   5530       SYSTEM_POWER_STATE RtcWake;
   5531       SYSTEM_POWER_STATE MinDeviceWakeState;
   5532       SYSTEM_POWER_STATE DefaultLowLatencyWake;
   5533     } SYSTEM_POWER_CAPABILITIES,*PSYSTEM_POWER_CAPABILITIES;
   5534 
   5535     typedef struct {
   5536       BOOLEAN AcOnLine;
   5537       BOOLEAN BatteryPresent;
   5538       BOOLEAN Charging;
   5539       BOOLEAN Discharging;
   5540       BOOLEAN Spare1[4];
   5541       DWORD MaxCapacity;
   5542       DWORD RemainingCapacity;
   5543       DWORD Rate;
   5544       DWORD EstimatedTime;
   5545       DWORD DefaultAlert1;
   5546       DWORD DefaultAlert2;
   5547     } SYSTEM_BATTERY_STATE,*PSYSTEM_BATTERY_STATE;
   5548 
   5549 #include "pshpack4.h"
   5550 
   5551 #define IMAGE_DOS_SIGNATURE 0x5A4D
   5552 #define IMAGE_OS2_SIGNATURE 0x454E
   5553 #define IMAGE_OS2_SIGNATURE_LE 0x454C
   5554 #define IMAGE_VXD_SIGNATURE 0x454C
   5555 #define IMAGE_NT_SIGNATURE 0x00004550
   5556 
   5557 #include "pshpack2.h"
   5558 
   5559     typedef struct _IMAGE_DOS_HEADER {
   5560       WORD e_magic;
   5561       WORD e_cblp;
   5562       WORD e_cp;
   5563       WORD e_crlc;
   5564       WORD e_cparhdr;
   5565       WORD e_minalloc;
   5566       WORD e_maxalloc;
   5567       WORD e_ss;
   5568       WORD e_sp;
   5569       WORD e_csum;
   5570       WORD e_ip;
   5571       WORD e_cs;
   5572       WORD e_lfarlc;
   5573       WORD e_ovno;
   5574       WORD e_res[4];
   5575       WORD e_oemid;
   5576       WORD e_oeminfo;
   5577       WORD e_res2[10];
   5578       LONG e_lfanew;
   5579     } IMAGE_DOS_HEADER,*PIMAGE_DOS_HEADER;
   5580 
   5581     typedef struct _IMAGE_OS2_HEADER {
   5582       WORD ne_magic;
   5583       CHAR ne_ver;
   5584       CHAR ne_rev;
   5585       WORD ne_enttab;
   5586       WORD ne_cbenttab;
   5587       LONG ne_crc;
   5588       WORD ne_flags;
   5589       WORD ne_autodata;
   5590       WORD ne_heap;
   5591       WORD ne_stack;
   5592       LONG ne_csip;
   5593       LONG ne_sssp;
   5594       WORD ne_cseg;
   5595       WORD ne_cmod;
   5596       WORD ne_cbnrestab;
   5597       WORD ne_segtab;
   5598       WORD ne_rsrctab;
   5599       WORD ne_restab;
   5600       WORD ne_modtab;
   5601       WORD ne_imptab;
   5602       LONG ne_nrestab;
   5603       WORD ne_cmovent;
   5604       WORD ne_align;
   5605       WORD ne_cres;
   5606       BYTE ne_exetyp;
   5607       BYTE ne_flagsothers;
   5608       WORD ne_pretthunks;
   5609       WORD ne_psegrefbytes;
   5610       WORD ne_swaparea;
   5611       WORD ne_expver;
   5612     } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
   5613 
   5614     typedef struct _IMAGE_VXD_HEADER {
   5615       WORD e32_magic;
   5616       BYTE e32_border;
   5617       BYTE e32_worder;
   5618       DWORD e32_level;
   5619       WORD e32_cpu;
   5620       WORD e32_os;
   5621       DWORD e32_ver;
   5622       DWORD e32_mflags;
   5623       DWORD e32_mpages;
   5624       DWORD e32_startobj;
   5625       DWORD e32_eip;
   5626       DWORD e32_stackobj;
   5627       DWORD e32_esp;
   5628       DWORD e32_pagesize;
   5629       DWORD e32_lastpagesize;
   5630       DWORD e32_fixupsize;
   5631       DWORD e32_fixupsum;
   5632       DWORD e32_ldrsize;
   5633       DWORD e32_ldrsum;
   5634       DWORD e32_objtab;
   5635       DWORD e32_objcnt;
   5636       DWORD e32_objmap;
   5637       DWORD e32_itermap;
   5638       DWORD e32_rsrctab;
   5639       DWORD e32_rsrccnt;
   5640       DWORD e32_restab;
   5641       DWORD e32_enttab;
   5642       DWORD e32_dirtab;
   5643       DWORD e32_dircnt;
   5644       DWORD e32_fpagetab;
   5645       DWORD e32_frectab;
   5646       DWORD e32_impmod;
   5647       DWORD e32_impmodcnt;
   5648       DWORD e32_impproc;
   5649       DWORD e32_pagesum;
   5650       DWORD e32_datapage;
   5651       DWORD e32_preload;
   5652       DWORD e32_nrestab;
   5653       DWORD e32_cbnrestab;
   5654       DWORD e32_nressum;
   5655       DWORD e32_autodata;
   5656       DWORD e32_debuginfo;
   5657       DWORD e32_debuglen;
   5658       DWORD e32_instpreload;
   5659       DWORD e32_instdemand;
   5660       DWORD e32_heapsize;
   5661       BYTE e32_res3[12];
   5662       DWORD e32_winresoff;
   5663       DWORD e32_winreslen;
   5664       WORD e32_devid;
   5665       WORD e32_ddkver;
   5666     } IMAGE_VXD_HEADER,*PIMAGE_VXD_HEADER;
   5667 
   5668 #include "poppack.h"
   5669 
   5670     typedef struct _IMAGE_FILE_HEADER {
   5671       WORD Machine;
   5672       WORD NumberOfSections;
   5673       DWORD TimeDateStamp;
   5674       DWORD PointerToSymbolTable;
   5675       DWORD NumberOfSymbols;
   5676       WORD SizeOfOptionalHeader;
   5677       WORD Characteristics;
   5678     } IMAGE_FILE_HEADER,*PIMAGE_FILE_HEADER;
   5679 
   5680 #define IMAGE_SIZEOF_FILE_HEADER 20
   5681 
   5682 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001
   5683 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
   5684 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
   5685 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
   5686 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
   5687 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
   5688 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
   5689 #define IMAGE_FILE_32BIT_MACHINE 0x0100
   5690 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
   5691 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
   5692 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
   5693 #define IMAGE_FILE_SYSTEM 0x1000
   5694 #define IMAGE_FILE_DLL 0x2000
   5695 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
   5696 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
   5697 
   5698 #define IMAGE_FILE_MACHINE_UNKNOWN 0
   5699 #define IMAGE_FILE_MACHINE_I386 0x014c
   5700 #define IMAGE_FILE_MACHINE_R3000 0x0162
   5701 #define IMAGE_FILE_MACHINE_R4000 0x0166
   5702 #define IMAGE_FILE_MACHINE_R10000 0x0168
   5703 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
   5704 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
   5705 #define IMAGE_FILE_MACHINE_SH3 0x01a2
   5706 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
   5707 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
   5708 #define IMAGE_FILE_MACHINE_SH4 0x01a6
   5709 #define IMAGE_FILE_MACHINE_SH5 0x01a8
   5710 #define IMAGE_FILE_MACHINE_ARM 0x01c0
   5711 #define IMAGE_FILE_MACHINE_ARMV7 0x01c4
   5712 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
   5713 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
   5714 #define IMAGE_FILE_MACHINE_AM33 0x01d3
   5715 #define IMAGE_FILE_MACHINE_POWERPC 0x01F0
   5716 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
   5717 #define IMAGE_FILE_MACHINE_IA64 0x0200
   5718 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
   5719 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
   5720 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
   5721 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
   5722 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
   5723 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
   5724 #define IMAGE_FILE_MACHINE_CEF 0x0CEF
   5725 #define IMAGE_FILE_MACHINE_EBC 0x0EBC
   5726 #define IMAGE_FILE_MACHINE_AMD64 0x8664
   5727 #define IMAGE_FILE_MACHINE_M32R 0x9041
   5728 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
   5729 
   5730     typedef struct _IMAGE_DATA_DIRECTORY {
   5731       DWORD VirtualAddress;
   5732       DWORD Size;
   5733     } IMAGE_DATA_DIRECTORY,*PIMAGE_DATA_DIRECTORY;
   5734 
   5735 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
   5736 
   5737     typedef struct _IMAGE_OPTIONAL_HEADER {
   5738 
   5739       WORD Magic;
   5740       BYTE MajorLinkerVersion;
   5741       BYTE MinorLinkerVersion;
   5742       DWORD SizeOfCode;
   5743       DWORD SizeOfInitializedData;
   5744       DWORD SizeOfUninitializedData;
   5745       DWORD AddressOfEntryPoint;
   5746       DWORD BaseOfCode;
   5747       DWORD BaseOfData;
   5748       DWORD ImageBase;
   5749       DWORD SectionAlignment;
   5750       DWORD FileAlignment;
   5751       WORD MajorOperatingSystemVersion;
   5752       WORD MinorOperatingSystemVersion;
   5753       WORD MajorImageVersion;
   5754       WORD MinorImageVersion;
   5755       WORD MajorSubsystemVersion;
   5756       WORD MinorSubsystemVersion;
   5757       DWORD Win32VersionValue;
   5758       DWORD SizeOfImage;
   5759       DWORD SizeOfHeaders;
   5760       DWORD CheckSum;
   5761       WORD Subsystem;
   5762       WORD DllCharacteristics;
   5763       DWORD SizeOfStackReserve;
   5764       DWORD SizeOfStackCommit;
   5765       DWORD SizeOfHeapReserve;
   5766       DWORD SizeOfHeapCommit;
   5767       DWORD LoaderFlags;
   5768       DWORD NumberOfRvaAndSizes;
   5769       IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
   5770     } IMAGE_OPTIONAL_HEADER32,*PIMAGE_OPTIONAL_HEADER32;
   5771 
   5772     typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
   5773       WORD Magic;
   5774       BYTE MajorLinkerVersion;
   5775       BYTE MinorLinkerVersion;
   5776       DWORD SizeOfCode;
   5777       DWORD SizeOfInitializedData;
   5778       DWORD SizeOfUninitializedData;
   5779       DWORD AddressOfEntryPoint;
   5780       DWORD BaseOfCode;
   5781       DWORD BaseOfData;
   5782       DWORD BaseOfBss;
   5783       DWORD GprMask;
   5784       DWORD CprMask[4];
   5785       DWORD GpValue;
   5786     } IMAGE_ROM_OPTIONAL_HEADER,*PIMAGE_ROM_OPTIONAL_HEADER;
   5787 
   5788     typedef struct _IMAGE_OPTIONAL_HEADER64 {
   5789       WORD Magic;
   5790       BYTE MajorLinkerVersion;
   5791       BYTE MinorLinkerVersion;
   5792       DWORD SizeOfCode;
   5793       DWORD SizeOfInitializedData;
   5794       DWORD SizeOfUninitializedData;
   5795       DWORD AddressOfEntryPoint;
   5796       DWORD BaseOfCode;
   5797       ULONGLONG ImageBase;
   5798       DWORD SectionAlignment;
   5799       DWORD FileAlignment;
   5800       WORD MajorOperatingSystemVersion;
   5801       WORD MinorOperatingSystemVersion;
   5802       WORD MajorImageVersion;
   5803       WORD MinorImageVersion;
   5804       WORD MajorSubsystemVersion;
   5805       WORD MinorSubsystemVersion;
   5806       DWORD Win32VersionValue;
   5807       DWORD SizeOfImage;
   5808       DWORD SizeOfHeaders;
   5809       DWORD CheckSum;
   5810       WORD Subsystem;
   5811       WORD DllCharacteristics;
   5812       ULONGLONG SizeOfStackReserve;
   5813       ULONGLONG SizeOfStackCommit;
   5814       ULONGLONG SizeOfHeapReserve;
   5815       ULONGLONG SizeOfHeapCommit;
   5816       DWORD LoaderFlags;
   5817       DWORD NumberOfRvaAndSizes;
   5818       IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
   5819     } IMAGE_OPTIONAL_HEADER64,*PIMAGE_OPTIONAL_HEADER64;
   5820 
   5821 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
   5822 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
   5823 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
   5824 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
   5825 
   5826 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
   5827 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
   5828 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
   5829 
   5830 #ifdef _WIN64
   5831     typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
   5832     typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
   5833 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
   5834 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
   5835 #else  /* _WIN64 */
   5836     typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
   5837     typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
   5838 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
   5839 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
   5840 #endif /* _WIN64 */
   5841 
   5842     typedef struct _IMAGE_NT_HEADERS64 {
   5843       DWORD Signature;
   5844       IMAGE_FILE_HEADER FileHeader;
   5845       IMAGE_OPTIONAL_HEADER64 OptionalHeader;
   5846     } IMAGE_NT_HEADERS64,*PIMAGE_NT_HEADERS64;
   5847 
   5848     typedef struct _IMAGE_NT_HEADERS {
   5849       DWORD Signature;
   5850       IMAGE_FILE_HEADER FileHeader;
   5851       IMAGE_OPTIONAL_HEADER32 OptionalHeader;
   5852     } IMAGE_NT_HEADERS32,*PIMAGE_NT_HEADERS32;
   5853 
   5854     typedef struct _IMAGE_ROM_HEADERS {
   5855       IMAGE_FILE_HEADER FileHeader;
   5856       IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
   5857     } IMAGE_ROM_HEADERS,*PIMAGE_ROM_HEADERS;
   5858 
   5859 #ifdef _WIN64
   5860     typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
   5861     typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
   5862 #else  /* _WIN64 */
   5863     typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
   5864     typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
   5865 #endif /* _WIN64 */
   5866 
   5867 #define IMAGE_FIRST_SECTION(ntheader) ((PIMAGE_SECTION_HEADER) ((ULONG_PTR)ntheader + FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader) + ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
   5868 
   5869 #define IMAGE_SUBSYSTEM_UNKNOWN 0
   5870 #define IMAGE_SUBSYSTEM_NATIVE 1
   5871 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
   5872 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
   5873 #define IMAGE_SUBSYSTEM_OS2_CUI 5
   5874 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
   5875 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8
   5876 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
   5877 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
   5878 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
   5879 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
   5880 #define IMAGE_SUBSYSTEM_EFI_ROM 13
   5881 #define IMAGE_SUBSYSTEM_XBOX 14
   5882 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
   5883 
   5884 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
   5885 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
   5886 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
   5887 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
   5888 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
   5889 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
   5890 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
   5891 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
   5892 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
   5893 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
   5894 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
   5895 
   5896 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
   5897 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
   5898 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
   5899 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
   5900 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
   5901 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
   5902 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
   5903 #define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7
   5904 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
   5905 #define IMAGE_DIRECTORY_ENTRY_TLS 9
   5906 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
   5907 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
   5908 #define IMAGE_DIRECTORY_ENTRY_IAT 12
   5909 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
   5910 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
   5911 
   5912     typedef struct ANON_OBJECT_HEADER {
   5913       WORD Sig1;
   5914       WORD Sig2;
   5915       WORD Version;
   5916       WORD Machine;
   5917       DWORD TimeDateStamp;
   5918       CLSID ClassID;
   5919       DWORD SizeOfData;
   5920     } ANON_OBJECT_HEADER;
   5921 
   5922     typedef struct ANON_OBJECT_HEADER_V2 {
   5923       WORD Sig1;
   5924       WORD Sig2;
   5925       WORD Version;
   5926       WORD Machine;
   5927       DWORD TimeDateStamp;
   5928       CLSID ClassID;
   5929       DWORD SizeOfData;
   5930       DWORD Flags;
   5931       DWORD MetaDataSize;
   5932       DWORD MetaDataOffset;
   5933     } ANON_OBJECT_HEADER_V2;
   5934 
   5935     typedef struct ANON_OBJECT_HEADER_BIGOBJ {
   5936       WORD Sig1;
   5937       WORD Sig2;
   5938       WORD Version;
   5939       WORD Machine;
   5940       DWORD TimeDateStamp;
   5941       CLSID ClassID;
   5942       DWORD SizeOfData;
   5943       DWORD Flags;
   5944       DWORD MetaDataSize;
   5945       DWORD MetaDataOffset;
   5946       DWORD NumberOfSections;
   5947       DWORD PointerToSymbolTable;
   5948       DWORD NumberOfSymbols;
   5949     } ANON_OBJECT_HEADER_BIGOBJ;
   5950 
   5951 #define IMAGE_SIZEOF_SHORT_NAME 8
   5952 
   5953     typedef struct _IMAGE_SECTION_HEADER {
   5954       BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
   5955       union {
   5956 	DWORD PhysicalAddress;
   5957 	DWORD VirtualSize;
   5958       } Misc;
   5959       DWORD VirtualAddress;
   5960       DWORD SizeOfRawData;
   5961       DWORD PointerToRawData;
   5962       DWORD PointerToRelocations;
   5963       DWORD PointerToLinenumbers;
   5964       WORD NumberOfRelocations;
   5965       WORD NumberOfLinenumbers;
   5966       DWORD Characteristics;
   5967     } IMAGE_SECTION_HEADER,*PIMAGE_SECTION_HEADER;
   5968 
   5969 #define IMAGE_SIZEOF_SECTION_HEADER 40
   5970 
   5971 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008
   5972 
   5973 #define IMAGE_SCN_CNT_CODE 0x00000020
   5974 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
   5975 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
   5976 #define IMAGE_SCN_LNK_OTHER 0x00000100
   5977 #define IMAGE_SCN_LNK_INFO 0x00000200
   5978 #define IMAGE_SCN_LNK_REMOVE 0x00000800
   5979 #define IMAGE_SCN_LNK_COMDAT 0x00001000
   5980 #define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000
   5981 #define IMAGE_SCN_GPREL 0x00008000
   5982 #define IMAGE_SCN_MEM_FARDATA 0x00008000
   5983 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
   5984 #define IMAGE_SCN_MEM_16BIT 0x00020000
   5985 #define IMAGE_SCN_MEM_LOCKED 0x00040000
   5986 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
   5987 
   5988 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
   5989 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
   5990 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
   5991 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
   5992 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000
   5993 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
   5994 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
   5995 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
   5996 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
   5997 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
   5998 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
   5999 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
   6000 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
   6001 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
   6002 
   6003 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
   6004 
   6005 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
   6006 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
   6007 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
   6008 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
   6009 #define IMAGE_SCN_MEM_SHARED 0x10000000
   6010 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
   6011 #define IMAGE_SCN_MEM_READ 0x40000000
   6012 #define IMAGE_SCN_MEM_WRITE 0x80000000
   6013 
   6014 #define IMAGE_SCN_SCALE_INDEX 0x00000001
   6015 
   6016 #include "pshpack2.h"
   6017     typedef struct _IMAGE_SYMBOL {
   6018       union {
   6019 	BYTE ShortName[8];
   6020 	struct {
   6021 	  DWORD Short;
   6022 	  DWORD Long;
   6023 	} Name;
   6024 	DWORD LongName[2];
   6025       } N;
   6026       DWORD Value;
   6027       SHORT SectionNumber;
   6028       WORD Type;
   6029       BYTE StorageClass;
   6030       BYTE NumberOfAuxSymbols;
   6031     } IMAGE_SYMBOL;
   6032     typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
   6033 
   6034 #define IMAGE_SIZEOF_SYMBOL 18
   6035 
   6036     typedef struct _IMAGE_SYMBOL_EX {
   6037       union {
   6038 	BYTE ShortName[8];
   6039 	struct {
   6040 	  DWORD Short;
   6041 	  DWORD Long;
   6042 	} Name;
   6043 	DWORD LongName[2];
   6044       } N;
   6045       DWORD Value;
   6046       LONG SectionNumber;
   6047       WORD Type;
   6048       BYTE StorageClass;
   6049       BYTE NumberOfAuxSymbols;
   6050     } IMAGE_SYMBOL_EX,UNALIGNED *PIMAGE_SYMBOL_EX;
   6051 
   6052 #define IMAGE_SYM_UNDEFINED (SHORT)0
   6053 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
   6054 #define IMAGE_SYM_DEBUG (SHORT)-2
   6055 #define IMAGE_SYM_SECTION_MAX 0xFEFF
   6056 #define IMAGE_SYM_SECTION_MAX_EX MAXLONG
   6057 
   6058 #define IMAGE_SYM_TYPE_NULL 0x0000
   6059 #define IMAGE_SYM_TYPE_VOID 0x0001
   6060 #define IMAGE_SYM_TYPE_CHAR 0x0002
   6061 #define IMAGE_SYM_TYPE_SHORT 0x0003
   6062 #define IMAGE_SYM_TYPE_INT 0x0004
   6063 #define IMAGE_SYM_TYPE_LONG 0x0005
   6064 #define IMAGE_SYM_TYPE_FLOAT 0x0006
   6065 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
   6066 #define IMAGE_SYM_TYPE_STRUCT 0x0008
   6067 #define IMAGE_SYM_TYPE_UNION 0x0009
   6068 #define IMAGE_SYM_TYPE_ENUM 0x000A
   6069 #define IMAGE_SYM_TYPE_MOE 0x000B
   6070 #define IMAGE_SYM_TYPE_BYTE 0x000C
   6071 #define IMAGE_SYM_TYPE_WORD 0x000D
   6072 #define IMAGE_SYM_TYPE_UINT 0x000E
   6073 #define IMAGE_SYM_TYPE_DWORD 0x000F
   6074 #define IMAGE_SYM_TYPE_PCODE 0x8000
   6075 
   6076 #define IMAGE_SYM_DTYPE_NULL 0
   6077 #define IMAGE_SYM_DTYPE_POINTER 1
   6078 #define IMAGE_SYM_DTYPE_FUNCTION 2
   6079 #define IMAGE_SYM_DTYPE_ARRAY 3
   6080 
   6081 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE)-1
   6082 #define IMAGE_SYM_CLASS_NULL 0x0000
   6083 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
   6084 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
   6085 #define IMAGE_SYM_CLASS_STATIC 0x0003
   6086 #define IMAGE_SYM_CLASS_REGISTER 0x0004
   6087 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
   6088 #define IMAGE_SYM_CLASS_LABEL 0x0006
   6089 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
   6090 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
   6091 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
   6092 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
   6093 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
   6094 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
   6095 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
   6096 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
   6097 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
   6098 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
   6099 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
   6100 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
   6101 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
   6102 #define IMAGE_SYM_CLASS_BLOCK 0x0064
   6103 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
   6104 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
   6105 #define IMAGE_SYM_CLASS_FILE 0x0067
   6106 #define IMAGE_SYM_CLASS_SECTION 0x0068
   6107 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
   6108 #define IMAGE_SYM_CLASS_CLR_TOKEN 0x006B
   6109 
   6110 #define N_BTMASK 0x000F
   6111 #define N_TMASK 0x0030
   6112 #define N_TMASK1 0x00C0
   6113 #define N_TMASK2 0x00F0
   6114 #define N_BTSHFT 4
   6115 #define N_TSHIFT 2
   6116 
   6117 #define BTYPE(x) ((x) & N_BTMASK)
   6118 
   6119 #ifndef ISPTR
   6120 #define ISPTR(x) (((x) & N_TMASK)==(IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
   6121 #endif
   6122 
   6123 #ifndef ISFCN
   6124 #define ISFCN(x) (((x) & N_TMASK)==(IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
   6125 #endif
   6126 
   6127 #ifndef ISARY
   6128 #define ISARY(x) (((x) & N_TMASK)==(IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
   6129 #endif
   6130 
   6131 #ifndef ISTAG
   6132 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
   6133 #endif
   6134 
   6135 #ifndef INCREF
   6136 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
   6137 #endif
   6138 #ifndef DECREF
   6139 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
   6140 #endif
   6141 
   6142 #include <pshpack2.h>
   6143     typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF {
   6144       BYTE bAuxType;
   6145       BYTE bReserved;
   6146       DWORD SymbolTableIndex;
   6147       BYTE rgbReserved[12];
   6148     } IMAGE_AUX_SYMBOL_TOKEN_DEF,UNALIGNED *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
   6149 #include <poppack.h>
   6150 
   6151     typedef union _IMAGE_AUX_SYMBOL {
   6152       struct {
   6153 	DWORD TagIndex;
   6154 	union {
   6155 	  struct {
   6156 	    WORD Linenumber;
   6157 	    WORD Size;
   6158 	  } LnSz;
   6159 	  DWORD TotalSize;
   6160 	} Misc;
   6161 	union {
   6162 	  struct {
   6163 	    DWORD PointerToLinenumber;
   6164 	    DWORD PointerToNextFunction;
   6165 	  } Function;
   6166 	  struct {
   6167 	    WORD Dimension[4];
   6168 	  } Array;
   6169 	} FcnAry;
   6170 	WORD TvIndex;
   6171       } Sym;
   6172       struct {
   6173 	BYTE Name[IMAGE_SIZEOF_SYMBOL];
   6174       } File;
   6175       struct {
   6176 	DWORD Length;
   6177 	WORD NumberOfRelocations;
   6178 	WORD NumberOfLinenumbers;
   6179 	DWORD CheckSum;
   6180 	SHORT Number;
   6181 	BYTE Selection;
   6182       } Section;
   6183       IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
   6184       struct {
   6185 	DWORD crc;
   6186 	BYTE rgbReserved[14];
   6187       } CRC;
   6188     } IMAGE_AUX_SYMBOL,UNALIGNED *PIMAGE_AUX_SYMBOL;
   6189 
   6190     typedef union _IMAGE_AUX_SYMBOL_EX {
   6191       struct {
   6192 	DWORD WeakDefaultSymIndex;
   6193 	DWORD WeakSearchType;
   6194 	BYTE rgbReserved[12];
   6195       } Sym;
   6196       struct {
   6197 	BYTE Name[sizeof (IMAGE_SYMBOL_EX)];
   6198       } File;
   6199       struct {
   6200 	DWORD Length;
   6201 	WORD NumberOfRelocations;
   6202 	WORD NumberOfLinenumbers;
   6203 	DWORD CheckSum;
   6204 	SHORT Number;
   6205 	BYTE Selection;
   6206 	BYTE bReserved;
   6207 	SHORT HighNumber;
   6208 	BYTE rgbReserved[2];
   6209       } Section;
   6210       __C89_NAMELESS struct {
   6211 	IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
   6212 	BYTE rgbReserved[2];
   6213       };
   6214       struct {
   6215 	DWORD crc;
   6216 	BYTE rgbReserved[16];
   6217       } CRC;
   6218     } IMAGE_AUX_SYMBOL_EX,UNALIGNED *PIMAGE_AUX_SYMBOL_EX;
   6219 
   6220 #define IMAGE_SIZEOF_AUX_SYMBOL 18
   6221 
   6222     typedef enum IMAGE_AUX_SYMBOL_TYPE {
   6223       IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1
   6224     } IMAGE_AUX_SYMBOL_TYPE;
   6225 
   6226 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
   6227 #define IMAGE_COMDAT_SELECT_ANY 2
   6228 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
   6229 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
   6230 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
   6231 #define IMAGE_COMDAT_SELECT_LARGEST 6
   6232 #define IMAGE_COMDAT_SELECT_NEWEST 7
   6233 
   6234 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
   6235 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
   6236 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
   6237 
   6238     typedef struct _IMAGE_RELOCATION {
   6239       __C89_NAMELESS union {
   6240 	DWORD VirtualAddress;
   6241 	DWORD RelocCount;
   6242       } DUMMYUNIONNAME;
   6243       DWORD SymbolTableIndex;
   6244       WORD Type;
   6245     } IMAGE_RELOCATION;
   6246     typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
   6247 
   6248 #define IMAGE_SIZEOF_RELOCATION 10
   6249 
   6250 #define IMAGE_REL_I386_ABSOLUTE 0x0000
   6251 #define IMAGE_REL_I386_DIR16 0x0001
   6252 #define IMAGE_REL_I386_REL16 0x0002
   6253 #define IMAGE_REL_I386_DIR32 0x0006
   6254 #define IMAGE_REL_I386_DIR32NB 0x0007
   6255 #define IMAGE_REL_I386_SEG12 0x0009
   6256 #define IMAGE_REL_I386_SECTION 0x000A
   6257 #define IMAGE_REL_I386_SECREL 0x000B
   6258 #define IMAGE_REL_I386_TOKEN 0x000C
   6259 #define IMAGE_REL_I386_SECREL7 0x000D
   6260 #define IMAGE_REL_I386_REL32 0x0014
   6261 
   6262 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
   6263 #define IMAGE_REL_MIPS_REFHALF 0x0001
   6264 #define IMAGE_REL_MIPS_REFWORD 0x0002
   6265 #define IMAGE_REL_MIPS_JMPADDR 0x0003
   6266 #define IMAGE_REL_MIPS_REFHI 0x0004
   6267 #define IMAGE_REL_MIPS_REFLO 0x0005
   6268 #define IMAGE_REL_MIPS_GPREL 0x0006
   6269 #define IMAGE_REL_MIPS_LITERAL 0x0007
   6270 #define IMAGE_REL_MIPS_SECTION 0x000A
   6271 #define IMAGE_REL_MIPS_SECREL 0x000B
   6272 #define IMAGE_REL_MIPS_SECRELLO 0x000C
   6273 #define IMAGE_REL_MIPS_SECRELHI 0x000D
   6274 #define IMAGE_REL_MIPS_TOKEN 0x000E
   6275 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
   6276 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
   6277 #define IMAGE_REL_MIPS_PAIR 0x0025
   6278 
   6279 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
   6280 #define IMAGE_REL_ALPHA_REFLONG 0x0001
   6281 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
   6282 #define IMAGE_REL_ALPHA_GPREL32 0x0003
   6283 #define IMAGE_REL_ALPHA_LITERAL 0x0004
   6284 #define IMAGE_REL_ALPHA_LITUSE 0x0005
   6285 #define IMAGE_REL_ALPHA_GPDISP 0x0006
   6286 #define IMAGE_REL_ALPHA_BRADDR 0x0007
   6287 #define IMAGE_REL_ALPHA_HINT 0x0008
   6288 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
   6289 #define IMAGE_REL_ALPHA_REFHI 0x000A
   6290 #define IMAGE_REL_ALPHA_REFLO 0x000B
   6291 #define IMAGE_REL_ALPHA_PAIR 0x000C
   6292 #define IMAGE_REL_ALPHA_MATCH 0x000D
   6293 #define IMAGE_REL_ALPHA_SECTION 0x000E
   6294 #define IMAGE_REL_ALPHA_SECREL 0x000F
   6295 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
   6296 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
   6297 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
   6298 #define IMAGE_REL_ALPHA_REFQ3 0x0013
   6299 #define IMAGE_REL_ALPHA_REFQ2 0x0014
   6300 #define IMAGE_REL_ALPHA_REFQ1 0x0015
   6301 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
   6302 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
   6303 
   6304 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
   6305 #define IMAGE_REL_PPC_ADDR64 0x0001
   6306 #define IMAGE_REL_PPC_ADDR32 0x0002
   6307 #define IMAGE_REL_PPC_ADDR24 0x0003
   6308 #define IMAGE_REL_PPC_ADDR16 0x0004
   6309 #define IMAGE_REL_PPC_ADDR14 0x0005
   6310 #define IMAGE_REL_PPC_REL24 0x0006
   6311 #define IMAGE_REL_PPC_REL14 0x0007
   6312 #define IMAGE_REL_PPC_TOCREL16 0x0008
   6313 #define IMAGE_REL_PPC_TOCREL14 0x0009
   6314 #define IMAGE_REL_PPC_ADDR32NB 0x000A
   6315 #define IMAGE_REL_PPC_SECREL 0x000B
   6316 #define IMAGE_REL_PPC_SECTION 0x000C
   6317 #define IMAGE_REL_PPC_IFGLUE 0x000D
   6318 #define IMAGE_REL_PPC_IMGLUE 0x000E
   6319 #define IMAGE_REL_PPC_SECREL16 0x000F
   6320 #define IMAGE_REL_PPC_REFHI 0x0010
   6321 #define IMAGE_REL_PPC_REFLO 0x0011
   6322 #define IMAGE_REL_PPC_PAIR 0x0012
   6323 #define IMAGE_REL_PPC_SECRELLO 0x0013
   6324 #define IMAGE_REL_PPC_SECRELHI 0x0014
   6325 #define IMAGE_REL_PPC_GPREL 0x0015
   6326 #define IMAGE_REL_PPC_TOKEN 0x0016
   6327 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
   6328 #define IMAGE_REL_PPC_NEG 0x0100
   6329 #define IMAGE_REL_PPC_BRTAKEN 0x0200
   6330 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
   6331 #define IMAGE_REL_PPC_TOCDEFN 0x0800
   6332 
   6333 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
   6334 #define IMAGE_REL_SH3_DIRECT16 0x0001
   6335 #define IMAGE_REL_SH3_DIRECT32 0x0002
   6336 #define IMAGE_REL_SH3_DIRECT8 0x0003
   6337 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
   6338 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
   6339 #define IMAGE_REL_SH3_DIRECT4 0x0006
   6340 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
   6341 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
   6342 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
   6343 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
   6344 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
   6345 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
   6346 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
   6347 #define IMAGE_REL_SH3_SECTION 0x000E
   6348 #define IMAGE_REL_SH3_SECREL 0x000F
   6349 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
   6350 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
   6351 #define IMAGE_REL_SH3_TOKEN 0x0012
   6352 
   6353 #define IMAGE_REL_SHM_PCRELPT 0x0013
   6354 #define IMAGE_REL_SHM_REFLO 0x0014
   6355 #define IMAGE_REL_SHM_REFHALF 0x0015
   6356 #define IMAGE_REL_SHM_RELLO 0x0016
   6357 #define IMAGE_REL_SHM_RELHALF 0x0017
   6358 #define IMAGE_REL_SHM_PAIR 0x0018
   6359 
   6360 #define IMAGE_REL_SH_NOMODE 0x8000
   6361 
   6362 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
   6363 #define IMAGE_REL_ARM_ADDR32 0x0001
   6364 #define IMAGE_REL_ARM_ADDR32NB 0x0002
   6365 #define IMAGE_REL_ARM_BRANCH24 0x0003
   6366 #define IMAGE_REL_ARM_BRANCH11 0x0004
   6367 #define IMAGE_REL_ARM_TOKEN 0x0005
   6368 #define IMAGE_REL_ARM_GPREL12 0x0006
   6369 #define IMAGE_REL_ARM_GPREL7 0x0007
   6370 #define IMAGE_REL_ARM_BLX24 0x0008
   6371 #define IMAGE_REL_ARM_BLX11 0x0009
   6372 #define IMAGE_REL_ARM_SECTION 0x000E
   6373 #define IMAGE_REL_ARM_SECREL 0x000F
   6374 #define IMAGE_REL_ARM_MOV32A 0x0010
   6375 #define IMAGE_REL_ARM_MOV32 0x0010
   6376 #define IMAGE_REL_ARM_MOV32T 0x0011
   6377 #define IMAGE_REL_THUMB_MOV32 0x0011
   6378 #define IMAGE_REL_ARM_BRANCH20T 0x0012
   6379 #define IMAGE_REL_THUMB_BRANCH20 0x0012
   6380 #define IMAGE_REL_ARM_BRANCH24T 0x0014
   6381 #define IMAGE_REL_THUMB_BRANCH24 0x0014
   6382 #define IMAGE_REL_ARM_BLX23T 0x0015
   6383 #define IMAGE_REL_THUMB_BLX23 0x0015
   6384 
   6385 #define IMAGE_REL_AM_ABSOLUTE 0x0000
   6386 #define IMAGE_REL_AM_ADDR32 0x0001
   6387 #define IMAGE_REL_AM_ADDR32NB 0x0002
   6388 #define IMAGE_REL_AM_CALL32 0x0003
   6389 #define IMAGE_REL_AM_FUNCINFO 0x0004
   6390 #define IMAGE_REL_AM_REL32_1 0x0005
   6391 #define IMAGE_REL_AM_REL32_2 0x0006
   6392 #define IMAGE_REL_AM_SECREL 0x0007
   6393 #define IMAGE_REL_AM_SECTION 0x0008
   6394 #define IMAGE_REL_AM_TOKEN 0x0009
   6395 
   6396 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
   6397 #define IMAGE_REL_AMD64_ADDR64 0x0001
   6398 #define IMAGE_REL_AMD64_ADDR32 0x0002
   6399 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
   6400 #define IMAGE_REL_AMD64_REL32 0x0004
   6401 #define IMAGE_REL_AMD64_REL32_1 0x0005
   6402 #define IMAGE_REL_AMD64_REL32_2 0x0006
   6403 #define IMAGE_REL_AMD64_REL32_3 0x0007
   6404 #define IMAGE_REL_AMD64_REL32_4 0x0008
   6405 #define IMAGE_REL_AMD64_REL32_5 0x0009
   6406 #define IMAGE_REL_AMD64_SECTION 0x000A
   6407 #define IMAGE_REL_AMD64_SECREL 0x000B
   6408 #define IMAGE_REL_AMD64_SECREL7 0x000C
   6409 #define IMAGE_REL_AMD64_TOKEN 0x000D
   6410 #define IMAGE_REL_AMD64_SREL32 0x000E
   6411 #define IMAGE_REL_AMD64_PAIR 0x000F
   6412 #define IMAGE_REL_AMD64_SSPAN32 0x0010
   6413 
   6414 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
   6415 #define IMAGE_REL_IA64_IMM14 0x0001
   6416 #define IMAGE_REL_IA64_IMM22 0x0002
   6417 #define IMAGE_REL_IA64_IMM64 0x0003
   6418 #define IMAGE_REL_IA64_DIR32 0x0004
   6419 #define IMAGE_REL_IA64_DIR64 0x0005
   6420 #define IMAGE_REL_IA64_PCREL21B 0x0006
   6421 #define IMAGE_REL_IA64_PCREL21M 0x0007
   6422 #define IMAGE_REL_IA64_PCREL21F 0x0008
   6423 #define IMAGE_REL_IA64_GPREL22 0x0009
   6424 #define IMAGE_REL_IA64_LTOFF22 0x000A
   6425 #define IMAGE_REL_IA64_SECTION 0x000B
   6426 #define IMAGE_REL_IA64_SECREL22 0x000C
   6427 #define IMAGE_REL_IA64_SECREL64I 0x000D
   6428 #define IMAGE_REL_IA64_SECREL32 0x000E
   6429 
   6430 #define IMAGE_REL_IA64_DIR32NB 0x0010
   6431 #define IMAGE_REL_IA64_SREL14 0x0011
   6432 #define IMAGE_REL_IA64_SREL22 0x0012
   6433 #define IMAGE_REL_IA64_SREL32 0x0013
   6434 #define IMAGE_REL_IA64_UREL32 0x0014
   6435 #define IMAGE_REL_IA64_PCREL60X 0x0015
   6436 #define IMAGE_REL_IA64_PCREL60B 0x0016
   6437 #define IMAGE_REL_IA64_PCREL60F 0x0017
   6438 #define IMAGE_REL_IA64_PCREL60I 0x0018
   6439 #define IMAGE_REL_IA64_PCREL60M 0x0019
   6440 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
   6441 #define IMAGE_REL_IA64_TOKEN 0x001B
   6442 #define IMAGE_REL_IA64_GPREL32 0x001C
   6443 #define IMAGE_REL_IA64_ADDEND 0x001F
   6444 
   6445 #define IMAGE_REL_CEF_ABSOLUTE 0x0000
   6446 #define IMAGE_REL_CEF_ADDR32 0x0001
   6447 #define IMAGE_REL_CEF_ADDR64 0x0002
   6448 #define IMAGE_REL_CEF_ADDR32NB 0x0003
   6449 #define IMAGE_REL_CEF_SECTION 0x0004
   6450 #define IMAGE_REL_CEF_SECREL 0x0005
   6451 #define IMAGE_REL_CEF_TOKEN 0x0006
   6452 
   6453 #define IMAGE_REL_CEE_ABSOLUTE 0x0000
   6454 #define IMAGE_REL_CEE_ADDR32 0x0001
   6455 #define IMAGE_REL_CEE_ADDR64 0x0002
   6456 #define IMAGE_REL_CEE_ADDR32NB 0x0003
   6457 #define IMAGE_REL_CEE_SECTION 0x0004
   6458 #define IMAGE_REL_CEE_SECREL 0x0005
   6459 #define IMAGE_REL_CEE_TOKEN 0x0006
   6460 
   6461 #define IMAGE_REL_M32R_ABSOLUTE 0x0000
   6462 #define IMAGE_REL_M32R_ADDR32 0x0001
   6463 #define IMAGE_REL_M32R_ADDR32NB 0x0002
   6464 #define IMAGE_REL_M32R_ADDR24 0x0003
   6465 #define IMAGE_REL_M32R_GPREL16 0x0004
   6466 #define IMAGE_REL_M32R_PCREL24 0x0005
   6467 #define IMAGE_REL_M32R_PCREL16 0x0006
   6468 #define IMAGE_REL_M32R_PCREL8 0x0007
   6469 #define IMAGE_REL_M32R_REFHALF 0x0008
   6470 #define IMAGE_REL_M32R_REFHI 0x0009
   6471 #define IMAGE_REL_M32R_REFLO 0x000A
   6472 #define IMAGE_REL_M32R_PAIR 0x000B
   6473 #define IMAGE_REL_M32R_SECTION 0x000C
   6474 #define IMAGE_REL_M32R_SECREL32 0x000D
   6475 #define IMAGE_REL_M32R_TOKEN 0x000E
   6476 
   6477 #define IMAGE_REL_EBC_ABSOLUTE 0x0000
   6478 #define IMAGE_REL_EBC_ADDR32NB 0x0001
   6479 #define IMAGE_REL_EBC_REL32 0x0002
   6480 #define IMAGE_REL_EBC_SECTION 0x0003
   6481 #define IMAGE_REL_EBC_SECREL 0x0004
   6482 
   6483 #define EXT_IMM64(Value,Address,Size,InstPos,ValPos) Value |= (((ULONGLONG)((*(Address) >> InstPos) & (((ULONGLONG)1 << Size) - 1))) << ValPos)
   6484 #define INS_IMM64(Value,Address,Size,InstPos,ValPos) *(PDWORD)Address = (*(PDWORD)Address & ~(((1 << Size) - 1) << InstPos)) | ((DWORD)((((ULONGLONG)Value >> ValPos) & (((ULONGLONG)1 << Size) - 1))) << InstPos)
   6485 
   6486 #define EMARCH_ENC_I17_IMM7B_INST_WORD_X 3
   6487 #define EMARCH_ENC_I17_IMM7B_SIZE_X 7
   6488 #define EMARCH_ENC_I17_IMM7B_INST_WORD_POS_X 4
   6489 #define EMARCH_ENC_I17_IMM7B_VAL_POS_X 0
   6490 
   6491 #define EMARCH_ENC_I17_IMM9D_INST_WORD_X 3
   6492 #define EMARCH_ENC_I17_IMM9D_SIZE_X 9
   6493 #define EMARCH_ENC_I17_IMM9D_INST_WORD_POS_X 18
   6494 #define EMARCH_ENC_I17_IMM9D_VAL_POS_X 7
   6495 
   6496 #define EMARCH_ENC_I17_IMM5C_INST_WORD_X 3
   6497 #define EMARCH_ENC_I17_IMM5C_SIZE_X 5
   6498 #define EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X 13
   6499 #define EMARCH_ENC_I17_IMM5C_VAL_POS_X 16
   6500 
   6501 #define EMARCH_ENC_I17_IC_INST_WORD_X 3
   6502 #define EMARCH_ENC_I17_IC_SIZE_X 1
   6503 #define EMARCH_ENC_I17_IC_INST_WORD_POS_X 12
   6504 #define EMARCH_ENC_I17_IC_VAL_POS_X 21
   6505 
   6506 #define EMARCH_ENC_I17_IMM41a_INST_WORD_X 1
   6507 #define EMARCH_ENC_I17_IMM41a_SIZE_X 10
   6508 #define EMARCH_ENC_I17_IMM41a_INST_WORD_POS_X 14
   6509 #define EMARCH_ENC_I17_IMM41a_VAL_POS_X 22
   6510 
   6511 #define EMARCH_ENC_I17_IMM41b_INST_WORD_X 1
   6512 #define EMARCH_ENC_I17_IMM41b_SIZE_X 8
   6513 #define EMARCH_ENC_I17_IMM41b_INST_WORD_POS_X 24
   6514 #define EMARCH_ENC_I17_IMM41b_VAL_POS_X 32
   6515 
   6516 #define EMARCH_ENC_I17_IMM41c_INST_WORD_X 2
   6517 #define EMARCH_ENC_I17_IMM41c_SIZE_X 23
   6518 #define EMARCH_ENC_I17_IMM41c_INST_WORD_POS_X 0
   6519 #define EMARCH_ENC_I17_IMM41c_VAL_POS_X 40
   6520 
   6521 #define EMARCH_ENC_I17_SIGN_INST_WORD_X 3
   6522 #define EMARCH_ENC_I17_SIGN_SIZE_X 1
   6523 #define EMARCH_ENC_I17_SIGN_INST_WORD_POS_X 27
   6524 #define EMARCH_ENC_I17_SIGN_VAL_POS_X 63
   6525 
   6526 #define X3_OPCODE_INST_WORD_X 3
   6527 #define X3_OPCODE_SIZE_X 4
   6528 #define X3_OPCODE_INST_WORD_POS_X 28
   6529 #define X3_OPCODE_SIGN_VAL_POS_X 0
   6530 
   6531 #define X3_I_INST_WORD_X 3
   6532 #define X3_I_SIZE_X 1
   6533 #define X3_I_INST_WORD_POS_X 27
   6534 #define X3_I_SIGN_VAL_POS_X 59
   6535 
   6536 #define X3_D_WH_INST_WORD_X 3
   6537 #define X3_D_WH_SIZE_X 3
   6538 #define X3_D_WH_INST_WORD_POS_X 24
   6539 #define X3_D_WH_SIGN_VAL_POS_X 0
   6540 
   6541 #define X3_IMM20_INST_WORD_X 3
   6542 #define X3_IMM20_SIZE_X 20
   6543 #define X3_IMM20_INST_WORD_POS_X 4
   6544 #define X3_IMM20_SIGN_VAL_POS_X 0
   6545 
   6546 #define X3_IMM39_1_INST_WORD_X 2
   6547 #define X3_IMM39_1_SIZE_X 23
   6548 #define X3_IMM39_1_INST_WORD_POS_X 0
   6549 #define X3_IMM39_1_SIGN_VAL_POS_X 36
   6550 
   6551 #define X3_IMM39_2_INST_WORD_X 1
   6552 #define X3_IMM39_2_SIZE_X 16
   6553 #define X3_IMM39_2_INST_WORD_POS_X 16
   6554 #define X3_IMM39_2_SIGN_VAL_POS_X 20
   6555 
   6556 #define X3_P_INST_WORD_X 3
   6557 #define X3_P_SIZE_X 4
   6558 #define X3_P_INST_WORD_POS_X 0
   6559 #define X3_P_SIGN_VAL_POS_X 0
   6560 
   6561 #define X3_TMPLT_INST_WORD_X 0
   6562 #define X3_TMPLT_SIZE_X 4
   6563 #define X3_TMPLT_INST_WORD_POS_X 0
   6564 #define X3_TMPLT_SIGN_VAL_POS_X 0
   6565 
   6566 #define X3_BTYPE_QP_INST_WORD_X 2
   6567 #define X3_BTYPE_QP_SIZE_X 9
   6568 #define X3_BTYPE_QP_INST_WORD_POS_X 23
   6569 #define X3_BTYPE_QP_INST_VAL_POS_X 0
   6570 
   6571 #define X3_EMPTY_INST_WORD_X 1
   6572 #define X3_EMPTY_SIZE_X 2
   6573 #define X3_EMPTY_INST_WORD_POS_X 14
   6574 #define X3_EMPTY_INST_VAL_POS_X 0
   6575 
   6576     typedef struct _IMAGE_LINENUMBER {
   6577       union {
   6578 	DWORD SymbolTableIndex;
   6579 	DWORD VirtualAddress;
   6580       } Type;
   6581       WORD Linenumber;
   6582     } IMAGE_LINENUMBER;
   6583     typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER;
   6584 
   6585 #define IMAGE_SIZEOF_LINENUMBER 6
   6586 
   6587 #include "poppack.h"
   6588 
   6589     typedef struct _IMAGE_BASE_RELOCATION {
   6590       DWORD VirtualAddress;
   6591       DWORD SizeOfBlock;
   6592     } IMAGE_BASE_RELOCATION;
   6593     typedef IMAGE_BASE_RELOCATION UNALIGNED *PIMAGE_BASE_RELOCATION;
   6594 
   6595 #define IMAGE_SIZEOF_BASE_RELOCATION 8
   6596 
   6597 #define IMAGE_REL_BASED_ABSOLUTE 0
   6598 #define IMAGE_REL_BASED_HIGH 1
   6599 #define IMAGE_REL_BASED_LOW 2
   6600 #define IMAGE_REL_BASED_HIGHLOW 3
   6601 #define IMAGE_REL_BASED_HIGHADJ 4
   6602 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
   6603 #define IMAGE_REL_BASED_ARM_MOV32 5
   6604 #define IMAGE_REL_BASED_THUMB_MOV32 7
   6605 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
   6606 #define IMAGE_REL_BASED_IA64_IMM64 9
   6607 #define IMAGE_REL_BASED_DIR64 10
   6608 
   6609 #define IMAGE_ARCHIVE_START_SIZE 8
   6610 #define IMAGE_ARCHIVE_START "!<arch>\n"
   6611 #define IMAGE_ARCHIVE_END "`\n"
   6612 #define IMAGE_ARCHIVE_PAD "\n"
   6613 #define IMAGE_ARCHIVE_LINKER_MEMBER "/               "
   6614 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "//              "
   6615 
   6616     typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
   6617       BYTE Name[16];
   6618       BYTE Date[12];
   6619       BYTE UserID[6];
   6620       BYTE GroupID[6];
   6621       BYTE Mode[8];
   6622       BYTE Size[10];
   6623       BYTE EndHeader[2];
   6624     } IMAGE_ARCHIVE_MEMBER_HEADER,*PIMAGE_ARCHIVE_MEMBER_HEADER;
   6625 
   6626 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
   6627 
   6628     typedef struct _IMAGE_EXPORT_DIRECTORY {
   6629       DWORD Characteristics;
   6630       DWORD TimeDateStamp;
   6631       WORD MajorVersion;
   6632       WORD MinorVersion;
   6633       DWORD Name;
   6634       DWORD Base;
   6635       DWORD NumberOfFunctions;
   6636       DWORD NumberOfNames;
   6637       DWORD AddressOfFunctions;
   6638       DWORD AddressOfNames;
   6639       DWORD AddressOfNameOrdinals;
   6640     } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
   6641 
   6642     typedef struct _IMAGE_IMPORT_BY_NAME {
   6643       WORD Hint;
   6644       BYTE Name[1];
   6645     } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
   6646 
   6647 #include "pshpack8.h"
   6648 
   6649     typedef struct _IMAGE_THUNK_DATA64 {
   6650       union {
   6651 	ULONGLONG ForwarderString;
   6652 	ULONGLONG Function;
   6653 	ULONGLONG Ordinal;
   6654 	ULONGLONG AddressOfData;
   6655       } u1;
   6656     } IMAGE_THUNK_DATA64;
   6657     typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
   6658 
   6659 #include "poppack.h"
   6660 
   6661     typedef struct _IMAGE_THUNK_DATA32 {
   6662       union {
   6663 	DWORD ForwarderString;
   6664 	DWORD Function;
   6665 	DWORD Ordinal;
   6666 	DWORD AddressOfData;
   6667       } u1;
   6668     } IMAGE_THUNK_DATA32;
   6669     typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
   6670 
   6671 #define IMAGE_ORDINAL_FLAG64 0x8000000000000000ull
   6672 #define IMAGE_ORDINAL_FLAG32 0x80000000
   6673 #define IMAGE_ORDINAL64(Ordinal) (Ordinal & 0xffffull)
   6674 #define IMAGE_ORDINAL32(Ordinal) (Ordinal & 0xffff)
   6675 #define IMAGE_SNAP_BY_ORDINAL64(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG64)!=0)
   6676 #define IMAGE_SNAP_BY_ORDINAL32(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG32)!=0)
   6677 
   6678     typedef VOID (NTAPI *PIMAGE_TLS_CALLBACK)(PVOID DllHandle,DWORD Reason,PVOID Reserved);
   6679 
   6680     typedef struct _IMAGE_TLS_DIRECTORY64 {
   6681       ULONGLONG StartAddressOfRawData;
   6682       ULONGLONG EndAddressOfRawData;
   6683       ULONGLONG AddressOfIndex;
   6684       ULONGLONG AddressOfCallBacks;
   6685       DWORD SizeOfZeroFill;
   6686       DWORD Characteristics;
   6687     } IMAGE_TLS_DIRECTORY64;
   6688     typedef IMAGE_TLS_DIRECTORY64 *PIMAGE_TLS_DIRECTORY64;
   6689 
   6690     typedef struct _IMAGE_TLS_DIRECTORY32 {
   6691       DWORD StartAddressOfRawData;
   6692       DWORD EndAddressOfRawData;
   6693       DWORD AddressOfIndex;
   6694       DWORD AddressOfCallBacks;
   6695       DWORD SizeOfZeroFill;
   6696       DWORD Characteristics;
   6697     } IMAGE_TLS_DIRECTORY32;
   6698     typedef IMAGE_TLS_DIRECTORY32 *PIMAGE_TLS_DIRECTORY32;
   6699 
   6700 #ifdef _WIN64
   6701 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
   6702 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
   6703     typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
   6704     typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
   6705 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
   6706     typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
   6707     typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
   6708 #else  /* _WIN64 */
   6709 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
   6710 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
   6711     typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
   6712     typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
   6713 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
   6714     typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
   6715     typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
   6716 #endif /* _WIN64 */
   6717 
   6718     typedef struct _IMAGE_IMPORT_DESCRIPTOR {
   6719       __C89_NAMELESS union {
   6720 	DWORD Characteristics;
   6721 	DWORD OriginalFirstThunk;
   6722       } DUMMYUNIONNAME;
   6723       DWORD TimeDateStamp;
   6724 
   6725       DWORD ForwarderChain;
   6726       DWORD Name;
   6727       DWORD FirstThunk;
   6728     } IMAGE_IMPORT_DESCRIPTOR;
   6729     typedef IMAGE_IMPORT_DESCRIPTOR UNALIGNED *PIMAGE_IMPORT_DESCRIPTOR;
   6730 
   6731     typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR {
   6732       DWORD TimeDateStamp;
   6733       WORD OffsetModuleName;
   6734       WORD NumberOfModuleForwarderRefs;
   6735     } IMAGE_BOUND_IMPORT_DESCRIPTOR,*PIMAGE_BOUND_IMPORT_DESCRIPTOR;
   6736 
   6737     typedef struct _IMAGE_BOUND_FORWARDER_REF {
   6738       DWORD TimeDateStamp;
   6739       WORD OffsetModuleName;
   6740       WORD Reserved;
   6741     } IMAGE_BOUND_FORWARDER_REF,*PIMAGE_BOUND_FORWARDER_REF;
   6742 
   6743     typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR {
   6744       union {
   6745 	DWORD AllAttributes;
   6746 	__C89_NAMELESS struct {
   6747 	  DWORD RvaBased : 1;
   6748 	  DWORD ReservedAttributes : 31;
   6749 	};
   6750       } Attributes;
   6751       DWORD DllNameRVA;
   6752       DWORD ModuleHandleRVA;
   6753       DWORD ImportAddressTableRVA;
   6754       DWORD ImportNameTableRVA;
   6755       DWORD BoundImportAddressTableRVA;
   6756       DWORD UnloadInformationTableRVA;
   6757       DWORD TimeDateStamp;
   6758     } IMAGE_DELAYLOAD_DESCRIPTOR,*PIMAGE_DELAYLOAD_DESCRIPTOR;
   6759     typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
   6760 
   6761     typedef struct _IMAGE_RESOURCE_DIRECTORY {
   6762       DWORD Characteristics;
   6763       DWORD TimeDateStamp;
   6764       WORD MajorVersion;
   6765       WORD MinorVersion;
   6766       WORD NumberOfNamedEntries;
   6767       WORD NumberOfIdEntries;
   6768     } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
   6769 
   6770 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
   6771 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
   6772 
   6773     typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
   6774       __C89_NAMELESS union {
   6775 	__C89_NAMELESS struct {
   6776 	  DWORD NameOffset:31;
   6777 	  DWORD NameIsString:1;
   6778 	} DUMMYSTRUCTNAME;
   6779 	DWORD Name;
   6780 	WORD Id;
   6781       } DUMMYUNIONNAME;
   6782       __C89_NAMELESS union {
   6783 	DWORD OffsetToData;
   6784 	__C89_NAMELESS struct {
   6785 	  DWORD OffsetToDirectory:31;
   6786 	  DWORD DataIsDirectory:1;
   6787 	} DUMMYSTRUCTNAME2;
   6788       } DUMMYUNIONNAME2;
   6789     } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
   6790 
   6791     typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
   6792       WORD Length;
   6793       CHAR NameString[1];
   6794     } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
   6795 
   6796     typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
   6797       WORD Length;
   6798       WCHAR NameString[1];
   6799     } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
   6800 
   6801     typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
   6802       DWORD OffsetToData;
   6803       DWORD Size;
   6804       DWORD CodePage;
   6805       DWORD Reserved;
   6806     } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
   6807 
   6808     typedef struct {
   6809       DWORD Size;
   6810       DWORD TimeDateStamp;
   6811       WORD MajorVersion;
   6812       WORD MinorVersion;
   6813       DWORD GlobalFlagsClear;
   6814       DWORD GlobalFlagsSet;
   6815       DWORD CriticalSectionDefaultTimeout;
   6816       DWORD DeCommitFreeBlockThreshold;
   6817       DWORD DeCommitTotalFreeThreshold;
   6818       DWORD LockPrefixTable;
   6819       DWORD MaximumAllocationSize;
   6820       DWORD VirtualMemoryThreshold;
   6821       DWORD ProcessHeapFlags;
   6822       DWORD ProcessAffinityMask;
   6823       WORD CSDVersion;
   6824       WORD Reserved1;
   6825       DWORD EditList;
   6826       DWORD SecurityCookie;
   6827       DWORD SEHandlerTable;
   6828       DWORD SEHandlerCount;
   6829     } IMAGE_LOAD_CONFIG_DIRECTORY32,*PIMAGE_LOAD_CONFIG_DIRECTORY32;
   6830 
   6831     typedef struct {
   6832       DWORD Size;
   6833       DWORD TimeDateStamp;
   6834       WORD MajorVersion;
   6835       WORD MinorVersion;
   6836       DWORD GlobalFlagsClear;
   6837       DWORD GlobalFlagsSet;
   6838       DWORD CriticalSectionDefaultTimeout;
   6839       ULONGLONG DeCommitFreeBlockThreshold;
   6840       ULONGLONG DeCommitTotalFreeThreshold;
   6841       ULONGLONG LockPrefixTable;
   6842       ULONGLONG MaximumAllocationSize;
   6843       ULONGLONG VirtualMemoryThreshold;
   6844       ULONGLONG ProcessAffinityMask;
   6845       DWORD ProcessHeapFlags;
   6846       WORD CSDVersion;
   6847       WORD Reserved1;
   6848       ULONGLONG EditList;
   6849       ULONGLONG SecurityCookie;
   6850       ULONGLONG SEHandlerTable;
   6851       ULONGLONG SEHandlerCount;
   6852     } IMAGE_LOAD_CONFIG_DIRECTORY64,*PIMAGE_LOAD_CONFIG_DIRECTORY64;
   6853 
   6854 #ifdef _WIN64
   6855     typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
   6856     typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
   6857 #else  /* _WIN64 */
   6858     typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
   6859     typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
   6860 #endif /* _WIN64 */
   6861 
   6862     typedef struct _IMAGE_CE_RUNTIME_FUNCTION_ENTRY {
   6863       DWORD FuncStart;
   6864       DWORD PrologLen : 8;
   6865       DWORD FuncLen : 22;
   6866       DWORD ThirtyTwoBit : 1;
   6867       DWORD ExceptionFlag : 1;
   6868     } IMAGE_CE_RUNTIME_FUNCTION_ENTRY,*PIMAGE_CE_RUNTIME_FUNCTION_ENTRY;
   6869 
   6870     typedef struct _IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY {
   6871       ULONGLONG BeginAddress;
   6872       ULONGLONG EndAddress;
   6873       ULONGLONG ExceptionHandler;
   6874       ULONGLONG HandlerData;
   6875       ULONGLONG PrologEndAddress;
   6876     } IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY,*PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY;
   6877 
   6878     typedef struct _IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY {
   6879       DWORD BeginAddress;
   6880       DWORD EndAddress;
   6881       DWORD ExceptionHandler;
   6882       DWORD HandlerData;
   6883       DWORD PrologEndAddress;
   6884     } IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY,*PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY;
   6885 
   6886     typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY {
   6887       DWORD BeginAddress;
   6888       __C89_NAMELESS union {
   6889 	DWORD UnwindData;
   6890 	__C89_NAMELESS struct {
   6891 	  DWORD Flag : 2;
   6892 	  DWORD FunctionLength : 11;
   6893 	  DWORD Ret : 2;
   6894 	  DWORD H : 1;
   6895 	  DWORD Reg : 3;
   6896 	  DWORD R : 1;
   6897 	  DWORD L : 1;
   6898 	  DWORD C : 1;
   6899 	  DWORD StackAdjust : 10;
   6900 	} DUMMYSTRUCTNAME;
   6901       } DUMMYUNIONNAME;
   6902     } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY,*PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY;
   6903 
   6904     typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY {
   6905       DWORD BeginAddress;
   6906       DWORD EndAddress;
   6907       __C89_NAMELESS union {
   6908 	DWORD UnwindInfoAddress;
   6909 	DWORD UnwindData;
   6910       } DUMMYUNIONNAME;
   6911     } _IMAGE_RUNTIME_FUNCTION_ENTRY,*_PIMAGE_RUNTIME_FUNCTION_ENTRY;
   6912 
   6913     typedef _IMAGE_RUNTIME_FUNCTION_ENTRY IMAGE_IA64_RUNTIME_FUNCTION_ENTRY;
   6914     typedef _PIMAGE_RUNTIME_FUNCTION_ENTRY PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY;
   6915 
   6916 #if defined (_AXP64_)
   6917     typedef IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY IMAGE_AXP64_RUNTIME_FUNCTION_ENTRY;
   6918     typedef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY PIMAGE_AXP64_RUNTIME_FUNCTION_ENTRY;
   6919     typedef IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
   6920     typedef PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
   6921 #elif defined (_ALPHA_)
   6922     typedef IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
   6923     typedef PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
   6924 #elif defined (__arm__)
   6925     typedef IMAGE_ARM_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
   6926     typedef PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
   6927 #else
   6928     typedef _IMAGE_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
   6929     typedef _PIMAGE_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
   6930 #endif
   6931 
   6932     typedef struct _IMAGE_DEBUG_DIRECTORY {
   6933       DWORD Characteristics;
   6934       DWORD TimeDateStamp;
   6935       WORD MajorVersion;
   6936       WORD MinorVersion;
   6937       DWORD Type;
   6938       DWORD SizeOfData;
   6939       DWORD AddressOfRawData;
   6940       DWORD PointerToRawData;
   6941     } IMAGE_DEBUG_DIRECTORY,*PIMAGE_DEBUG_DIRECTORY;
   6942 
   6943 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
   6944 #define IMAGE_DEBUG_TYPE_COFF 1
   6945 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
   6946 #define IMAGE_DEBUG_TYPE_FPO 3
   6947 #define IMAGE_DEBUG_TYPE_MISC 4
   6948 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
   6949 #define IMAGE_DEBUG_TYPE_FIXUP 6
   6950 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
   6951 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
   6952 #define IMAGE_DEBUG_TYPE_BORLAND 9
   6953 #define IMAGE_DEBUG_TYPE_RESERVED10 10
   6954 #define IMAGE_DEBUG_TYPE_CLSID 11
   6955 
   6956     typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
   6957       DWORD NumberOfSymbols;
   6958       DWORD LvaToFirstSymbol;
   6959       DWORD NumberOfLinenumbers;
   6960       DWORD LvaToFirstLinenumber;
   6961       DWORD RvaToFirstByteOfCode;
   6962       DWORD RvaToLastByteOfCode;
   6963       DWORD RvaToFirstByteOfData;
   6964       DWORD RvaToLastByteOfData;
   6965     } IMAGE_COFF_SYMBOLS_HEADER,*PIMAGE_COFF_SYMBOLS_HEADER;
   6966 
   6967 #define FRAME_FPO 0
   6968 #define FRAME_TRAP 1
   6969 #define FRAME_TSS 2
   6970 #define FRAME_NONFPO 3
   6971 
   6972     typedef struct _FPO_DATA {
   6973       DWORD ulOffStart;
   6974       DWORD cbProcSize;
   6975       DWORD cdwLocals;
   6976       WORD cdwParams;
   6977       WORD cbProlog : 8;
   6978       WORD cbRegs : 3;
   6979       WORD fHasSEH : 1;
   6980       WORD fUseBP : 1;
   6981       WORD reserved : 1;
   6982       WORD cbFrame : 2;
   6983     } FPO_DATA,*PFPO_DATA;
   6984 #define SIZEOF_RFPO_DATA 16
   6985 
   6986 #define IMAGE_DEBUG_MISC_EXENAME 1
   6987 
   6988     typedef struct _IMAGE_DEBUG_MISC {
   6989       DWORD DataType;
   6990       DWORD Length;
   6991       BOOLEAN Unicode;
   6992       BYTE Reserved[3];
   6993       BYTE Data[1];
   6994     } IMAGE_DEBUG_MISC,*PIMAGE_DEBUG_MISC;
   6995 
   6996     typedef struct _IMAGE_FUNCTION_ENTRY {
   6997       DWORD StartingAddress;
   6998       DWORD EndingAddress;
   6999       DWORD EndOfPrologue;
   7000     } IMAGE_FUNCTION_ENTRY,*PIMAGE_FUNCTION_ENTRY;
   7001 
   7002     typedef struct _IMAGE_FUNCTION_ENTRY64 {
   7003       ULONGLONG StartingAddress;
   7004       ULONGLONG EndingAddress;
   7005       __C89_NAMELESS union {
   7006 	ULONGLONG EndOfPrologue;
   7007 	ULONGLONG UnwindInfoAddress;
   7008       } DUMMYUNIONNAME;
   7009     } IMAGE_FUNCTION_ENTRY64,*PIMAGE_FUNCTION_ENTRY64;
   7010 
   7011     typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
   7012       WORD Signature;
   7013       WORD Flags;
   7014       WORD Machine;
   7015       WORD Characteristics;
   7016       DWORD TimeDateStamp;
   7017       DWORD CheckSum;
   7018       DWORD ImageBase;
   7019       DWORD SizeOfImage;
   7020       DWORD NumberOfSections;
   7021       DWORD ExportedNamesSize;
   7022       DWORD DebugDirectorySize;
   7023       DWORD SectionAlignment;
   7024       DWORD Reserved[2];
   7025     } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
   7026 
   7027     typedef struct _NON_PAGED_DEBUG_INFO {
   7028       WORD Signature;
   7029       WORD Flags;
   7030       DWORD Size;
   7031       WORD Machine;
   7032       WORD Characteristics;
   7033       DWORD TimeDateStamp;
   7034       DWORD CheckSum;
   7035       DWORD SizeOfImage;
   7036       ULONGLONG ImageBase;
   7037     } NON_PAGED_DEBUG_INFO,*PNON_PAGED_DEBUG_INFO;
   7038 
   7039 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
   7040 #define NON_PAGED_DEBUG_SIGNATURE 0x494E
   7041 
   7042 #define IMAGE_SEPARATE_DEBUG_FLAGS_MASK 0x8000
   7043 #define IMAGE_SEPARATE_DEBUG_MISMATCH 0x8000
   7044 
   7045     typedef struct _ImageArchitectureHeader {
   7046       unsigned int AmaskValue: 1;
   7047       int Adummy1 : 7;
   7048       unsigned int AmaskShift : 8;
   7049       int Adummy2 : 16;
   7050       DWORD FirstEntryRVA;
   7051     } IMAGE_ARCHITECTURE_HEADER,*PIMAGE_ARCHITECTURE_HEADER;
   7052 
   7053     typedef struct _ImageArchitectureEntry {
   7054       DWORD FixupInstRVA;
   7055       DWORD NewInst;
   7056     } IMAGE_ARCHITECTURE_ENTRY,*PIMAGE_ARCHITECTURE_ENTRY;
   7057 #include "poppack.h"
   7058 
   7059 #define IMPORT_OBJECT_HDR_SIG2 0xffff
   7060 
   7061     typedef struct IMPORT_OBJECT_HEADER {
   7062       WORD Sig1;
   7063       WORD Sig2;
   7064       WORD Version;
   7065       WORD Machine;
   7066       DWORD TimeDateStamp;
   7067       DWORD SizeOfData;
   7068       __C89_NAMELESS union {
   7069 	WORD Ordinal;
   7070 	WORD Hint;
   7071       };
   7072       WORD Type : 2;
   7073       WORD NameType : 3;
   7074       WORD Reserved : 11;
   7075     } IMPORT_OBJECT_HEADER;
   7076 
   7077     typedef enum IMPORT_OBJECT_TYPE {
   7078       IMPORT_OBJECT_CODE = 0,IMPORT_OBJECT_DATA = 1,IMPORT_OBJECT_CONST = 2
   7079     } IMPORT_OBJECT_TYPE;
   7080 
   7081     typedef enum IMPORT_OBJECT_NAME_TYPE {
   7082       IMPORT_OBJECT_ORDINAL = 0,IMPORT_OBJECT_NAME = 1,IMPORT_OBJECT_NAME_NO_PREFIX = 2,IMPORT_OBJECT_NAME_UNDECORATE = 3
   7083     } IMPORT_OBJECT_NAME_TYPE;
   7084 
   7085 #ifndef __IMAGE_COR20_HEADER_DEFINED__
   7086 #define __IMAGE_COR20_HEADER_DEFINED__
   7087     typedef enum ReplacesCorHdrNumericDefines {
   7088       COMIMAGE_FLAGS_ILONLY = 0x00000001,COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
   7089       COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,COR_VERSION_MAJOR_V2 = 2,
   7090       COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,COR_VERSION_MINOR = 0,COR_DELETED_NAME_LENGTH = 8,COR_VTABLEGAP_NAME_LENGTH = 8,
   7091       NATIVE_TYPE_MAX_CB = 1,COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE= 0xFF,IMAGE_COR_MIH_METHODRVA = 0x01,IMAGE_COR_MIH_EHRVA = 0x02,
   7092       IMAGE_COR_MIH_BASICBLOCK = 0x08,COR_VTABLE_32BIT =0x01,COR_VTABLE_64BIT =0x02,COR_VTABLE_FROM_UNMANAGED = 0x04,
   7093       COR_VTABLE_CALL_MOST_DERIVED = 0x10,IMAGE_COR_EATJ_THUNK_SIZE = 32,MAX_CLASS_NAME =1024,MAX_PACKAGE_NAME = 1024
   7094     } ReplacesCorHdrNumericDefines;
   7095 
   7096     typedef struct IMAGE_COR20_HEADER {
   7097       DWORD cb;
   7098       WORD MajorRuntimeVersion;
   7099       WORD MinorRuntimeVersion;
   7100       IMAGE_DATA_DIRECTORY MetaData;
   7101       DWORD Flags;
   7102       __C89_NAMELESS union {
   7103 	DWORD EntryPointToken;
   7104 	DWORD EntryPointRVA;
   7105       } DUMMYUNIONNAME;
   7106       IMAGE_DATA_DIRECTORY Resources;
   7107       IMAGE_DATA_DIRECTORY StrongNameSignature;
   7108       IMAGE_DATA_DIRECTORY CodeManagerTable;
   7109       IMAGE_DATA_DIRECTORY VTableFixups;
   7110       IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
   7111       IMAGE_DATA_DIRECTORY ManagedNativeHeader;
   7112     } IMAGE_COR20_HEADER,*PIMAGE_COR20_HEADER;
   7113 #endif
   7114 
   7115 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
   7116     NTSYSAPI WORD NTAPI RtlCaptureStackBackTrace (DWORD FramesToSkip, DWORD FramesToCapture, PVOID *BackTrace, PDWORD BackTraceHash);
   7117     NTSYSAPI VOID NTAPI RtlCaptureContext (PCONTEXT ContextRecord);
   7118     NTSYSAPI SIZE_T NTAPI RtlCompareMemory (const VOID *Source1, const VOID *Source2, SIZE_T Length);
   7119 #if defined (__x86_64__)
   7120 #if _WIN32_WINNT >= 0x0602
   7121     NTSYSAPI DWORD NTAPI RtlAddGrowableFunctionTable (PVOID *DynamicTable, PRUNTIME_FUNCTION FunctionTable, DWORD EntryCount, DWORD MaximumEntryCount, ULONG_PTR RangeBase, ULONG_PTR RangeEnd);
   7122     NTSYSAPI VOID NTAPI RtlGrowFunctionTable (PVOID DynamicTable, DWORD NewEntryCount);
   7123     NTSYSAPI VOID NTAPI RtlDeleteGrowableFunctionTable (PVOID DynamicTable);
   7124 #endif
   7125     NTSYSAPI BOOLEAN __cdecl RtlAddFunctionTable (PRUNTIME_FUNCTION FunctionTable, DWORD EntryCount, DWORD64 BaseAddress);
   7126     NTSYSAPI BOOLEAN __cdecl RtlDeleteFunctionTable (PRUNTIME_FUNCTION FunctionTable);
   7127     NTSYSAPI BOOLEAN __cdecl RtlInstallFunctionTableCallback (DWORD64 TableIdentifier, DWORD64 BaseAddress, DWORD Length, PGET_RUNTIME_FUNCTION_CALLBACK Callback, PVOID Context, PCWSTR OutOfProcessCallbackDll);
   7128     NTSYSAPI VOID __cdecl RtlRestoreContext (PCONTEXT ContextRecord, struct _EXCEPTION_RECORD *ExceptionRecord);
   7129     NTSYSAPI PEXCEPTION_ROUTINE NTAPI RtlVirtualUnwind (DWORD HandlerType, DWORD64 ImageBase, DWORD64 ControlPc, PRUNTIME_FUNCTION FunctionEntry, PCONTEXT ContextRecord, PVOID *HandlerData, PDWORD64 EstablisherFrame, PKNONVOLATILE_CONTEXT_POINTERS ContextPointers);
   7130 #endif
   7131 #if defined (__arm__)
   7132 #if _WIN32_WINNT >= 0x0602
   7133     NTSYSAPI DWORD NTAPI RtlAddGrowableFunctionTable (PVOID *DynamicTable, PRUNTIME_FUNCTION FunctionTable, DWORD EntryCount, DWORD MaximumEntryCount, ULONG_PTR RangeBase, ULONG_PTR RangeEnd);
   7134     NTSYSAPI VOID NTAPI RtlGrowFunctionTable (PVOID DynamicTable, DWORD NewEntryCount);
   7135     NTSYSAPI VOID NTAPI RtlDeleteGrowableFunctionTable (PVOID DynamicTable);
   7136 #endif
   7137     NTSYSAPI BOOLEAN __cdecl RtlAddFunctionTable (PRUNTIME_FUNCTION FunctionTable, DWORD EntryCount, DWORD BaseAddress);
   7138     NTSYSAPI BOOLEAN __cdecl RtlDeleteFunctionTable (PRUNTIME_FUNCTION FunctionTable);
   7139     NTSYSAPI BOOLEAN __cdecl RtlInstallFunctionTableCallback (DWORD TableIdentifier, DWORD BaseAddress, DWORD Length, PGET_RUNTIME_FUNCTION_CALLBACK Callback, PVOID Context, PCWSTR OutOfProcessCallbackDll);
   7140     NTSYSAPI VOID __cdecl RtlRestoreContext (PCONTEXT ContextRecord, struct _EXCEPTION_RECORD *ExceptionRecord);
   7141     NTSYSAPI PEXCEPTION_ROUTINE NTAPI RtlVirtualUnwind (DWORD HandlerType, DWORD ImageBase, DWORD ControlPc, PRUNTIME_FUNCTION FunctionEntry, PCONTEXT ContextRecord, PVOID *HandlerData, PDWORD EstablisherFrame, PKNONVOLATILE_CONTEXT_POINTERS ContextPointers);
   7142 #endif
   7143 #if defined (__ia64__)
   7144     NTSYSAPI BOOLEAN NTAPI RtlAddFunctionTable (PRUNTIME_FUNCTION FunctionTable, DWORD EntryCount, ULONGLONG BaseAddress, ULONGLONG TargetGp);
   7145     NTSYSAPI BOOLEAN NTAPI RtlDeleteFunctionTable (PRUNTIME_FUNCTION FunctionTable);
   7146     NTSYSAPI BOOLEAN NTAPI RtlInstallFunctionTableCallback (DWORD64 TableIdentifier, DWORD64 BaseAddress, DWORD Length, DWORD64 TargetGp, PGET_RUNTIME_FUNCTION_CALLBACK Callback, PVOID Context, PCWSTR OutOfProcessCallbackDll);
   7147     NTSYSAPI VOID NTAPI RtlRestoreContext (PCONTEXT ContextRecord, struct _EXCEPTION_RECORD *ExceptionRecord);
   7148     NTSYSAPI ULONGLONG NTAPI RtlVirtualUnwind (ULONGLONG ImageBase, ULONGLONG ControlPc, PRUNTIME_FUNCTION FunctionEntry, PCONTEXT ContextRecord, PBOOLEAN InFunction, PFRAME_POINTERS EstablisherFrame, PKNONVOLATILE_CONTEXT_POINTERS ContextPointers);
   7149 #endif
   7150 
   7151 #endif
   7152 
   7153 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
   7154     NTSYSAPI VOID NTAPI RtlUnwind (PVOID TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue);
   7155     NTSYSAPI PVOID NTAPI RtlPcToFileHeader (PVOID PcValue, PVOID *BaseOfImage);
   7156 #if defined (__x86_64__)
   7157     NTSYSAPI PRUNTIME_FUNCTION NTAPI RtlLookupFunctionEntry (DWORD64 ControlPc, PDWORD64 ImageBase, PUNWIND_HISTORY_TABLE HistoryTable);
   7158     NTSYSAPI VOID NTAPI RtlUnwindEx (PVOID TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT ContextRecord, PUNWIND_HISTORY_TABLE HistoryTable);
   7159 #endif
   7160 #if defined (__arm__)
   7161     NTSYSAPI PRUNTIME_FUNCTION NTAPI RtlLookupFunctionEntry (ULONG_PTR ControlPc, PDWORD ImageBase, PUNWIND_HISTORY_TABLE HistoryTable);
   7162     NTSYSAPI VOID NTAPI RtlUnwindEx (PVOID TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT ContextRecord, PUNWIND_HISTORY_TABLE HistoryTable);
   7163 #endif
   7164 #if defined (__ia64__)
   7165     NTSYSAPI PRUNTIME_FUNCTION NTAPI RtlLookupFunctionEntry (ULONGLONG ControlPc, PULONGLONG ImageBase, PULONGLONG TargetGp);
   7166     NTSYSAPI VOID NTAPI RtlUnwindEx (FRAME_POINTERS TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT ContextRecord, PUNWIND_HISTORY_TABLE HistoryTable);
   7167 #endif
   7168 #endif
   7169 
   7170 #include <string.h>
   7171 
   7172 #ifndef _SLIST_HEADER_
   7173 #define _SLIST_HEADER_
   7174 
   7175 #if defined (_WIN64)
   7176     typedef struct DECLSPEC_ALIGN (16) _SLIST_ENTRY {
   7177       struct _SLIST_ENTRY *Next;
   7178     } SLIST_ENTRY,*PSLIST_ENTRY;
   7179 
   7180     typedef union DECLSPEC_ALIGN (16) _SLIST_HEADER {
   7181       __C89_NAMELESS struct {
   7182 	ULONGLONG Alignment;
   7183 	ULONGLONG Region;
   7184       } DUMMYSTRUCTNAME;
   7185       struct {
   7186 	ULONGLONG Depth:16;
   7187 	ULONGLONG Sequence:9;
   7188 	ULONGLONG NextEntry:39;
   7189 	ULONGLONG HeaderType:1;
   7190 	ULONGLONG Init:1;
   7191 	ULONGLONG Reserved:59;
   7192 	ULONGLONG Region:3;
   7193       } Header8;
   7194       struct {
   7195 	ULONGLONG Depth:16;
   7196 	ULONGLONG Sequence:48;
   7197 	ULONGLONG HeaderType:1;
   7198 	ULONGLONG Reserved:3;
   7199 	ULONGLONG NextEntry:60;
   7200       } HeaderX64;
   7201     } SLIST_HEADER,*PSLIST_HEADER;
   7202 #else  /* _WIN64 */
   7203     typedef struct _SINGLE_LIST_ENTRY SLIST_ENTRY,*PSLIST_ENTRY;
   7204 
   7205     typedef union _SLIST_HEADER {
   7206       ULONGLONG Alignment;
   7207       __C89_NAMELESS struct {
   7208 	SLIST_ENTRY Next;
   7209 	WORD Depth;
   7210 	WORD Sequence;
   7211       } DUMMYSTRUCTNAME;
   7212     } SLIST_HEADER,*PSLIST_HEADER;
   7213 #endif /* _WIN64 */
   7214 
   7215 #endif /* _SLIST_HEADER_ */
   7216 
   7217 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
   7218     NTSYSAPI VOID NTAPI RtlInitializeSListHead (PSLIST_HEADER ListHead);
   7219     NTSYSAPI PSLIST_ENTRY NTAPI RtlFirstEntrySList (const SLIST_HEADER *ListHead);
   7220     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedPopEntrySList (PSLIST_HEADER ListHead);
   7221     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedPushEntrySList (PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry);
   7222     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedPushListSListEx (PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, DWORD Count);
   7223     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedFlushSList (PSLIST_HEADER ListHead);
   7224     NTSYSAPI WORD NTAPI RtlQueryDepthSList (PSLIST_HEADER ListHead);
   7225 #endif
   7226 
   7227 #ifndef _RTL_RUN_ONCE_DEF
   7228 #define _RTL_RUN_ONCE_DEF 1
   7229 
   7230 typedef struct _RTL_RUN_ONCE { PVOID Ptr; } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
   7231 typedef DWORD (WINAPI *PRTL_RUN_ONCE_INIT_FN)(PRTL_RUN_ONCE, PVOID, PVOID *);
   7232 
   7233 #define RTL_RUN_ONCE_INIT {0}
   7234 #define RTL_RUN_ONCE_CHECK_ONLY __MSABI_LONG(1U)
   7235 #define RTL_RUN_ONCE_ASYNC __MSABI_LONG(2U)
   7236 #define RTL_RUN_ONCE_INIT_FAILED __MSABI_LONG(4U)
   7237 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
   7238 #endif
   7239 
   7240   typedef struct _RTL_BARRIER {
   7241     DWORD Reserved1;
   7242     DWORD Reserved2;
   7243     ULONG_PTR Reserved3[2];
   7244     DWORD Reserved4;
   7245     DWORD Reserved5;
   7246   } RTL_BARRIER,*PRTL_BARRIER;
   7247 
   7248 #define FAST_FAIL_LEGACY_GS_VIOLATION 0
   7249 #define FAST_FAIL_VTGUARD_CHECK_FAILURE 1
   7250 #define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2
   7251 #define FAST_FAIL_CORRUPT_LIST_ENTRY 3
   7252 #define FAST_FAIL_INCORRECT_STACK 4
   7253 #define FAST_FAIL_INVALID_ARG 5
   7254 #define FAST_FAIL_GS_COOKIE_INIT 6
   7255 #define FAST_FAIL_FATAL_APP_EXIT 7
   7256 #define FAST_FAIL_RANGE_CHECK_FAILURE 8
   7257 #define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9
   7258 #define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xffffffff
   7259 
   7260 /* TODO: Check implementation of
   7261    DECLSPEC_NORETURN VOID __fastfail (unsigned int); */
   7262 
   7263 #define HEAP_NO_SERIALIZE 0x00000001
   7264 #define HEAP_GROWABLE 0x00000002
   7265 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
   7266 #define HEAP_ZERO_MEMORY 0x00000008
   7267 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
   7268 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
   7269 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
   7270 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
   7271 #define HEAP_CREATE_ALIGN_16 0x00010000
   7272 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
   7273 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
   7274 #define HEAP_MAXIMUM_TAG 0x0FFF
   7275 #define HEAP_PSEUDO_TAG_FLAG 0x8000
   7276 #define HEAP_TAG_SHIFT 18
   7277 /* Let this macro fail for non-desktop mode.  AFAIU this should be better an inline-function ... */
   7278 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
   7279 #define HEAP_MAKE_TAG_FLAGS(b,o) ((DWORD)((b) + ((o) << 18)))
   7280 #endif
   7281 
   7282 #define IS_TEXT_UNICODE_ASCII16 0x0001
   7283 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
   7284 
   7285 #define IS_TEXT_UNICODE_STATISTICS 0x0002
   7286 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
   7287 
   7288 #define IS_TEXT_UNICODE_CONTROLS 0x0004
   7289 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
   7290 
   7291 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
   7292 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
   7293 
   7294 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
   7295 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
   7296 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
   7297 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
   7298 
   7299 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
   7300 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
   7301 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
   7302 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
   7303 
   7304 #define COMPRESSION_FORMAT_NONE (0x0000)
   7305 #define COMPRESSION_FORMAT_DEFAULT (0x0001)
   7306 #define COMPRESSION_FORMAT_LZNT1 (0x0002)
   7307 #define COMPRESSION_FORMAT_XPRESS (0x0003)
   7308 #define COMPRESSION_FORMAT_XPRESS_HUFF (0x0004)
   7309 #define COMPRESSION_ENGINE_STANDARD (0x0000)
   7310 #define COMPRESSION_ENGINE_MAXIMUM (0x0100)
   7311 #define COMPRESSION_ENGINE_HIBER (0x0200)
   7312 
   7313 #ifndef __CRT__NO_INLINE
   7314 #if _DBG_MEMCPY_INLINE_ && !defined(_MEMCPY_INLINE_) && !defined(_CRTBLD)
   7315 #define _MEMCPY_INLINE_
   7316     __CRT_INLINE PVOID __cdecl memcpy_inline(void *dst,const void *src,size_t size) {
   7317       if(((char *)dst > (char *)src) && ((char *)dst < ((char *)src + size))) {
   7318 	__debugbreak();
   7319       }
   7320       return memcpy(dst,src,size);
   7321     }
   7322 #define memcpy memcpy_inline
   7323 #endif /* _DBG_MEMCPY_INLINE_ && !defined(_MEMCPY_INLINE_) && !defined(_CRTBLD) */
   7324 #endif /* !__CRT__NO_INLINE */
   7325 
   7326 #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
   7327 #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
   7328 #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
   7329 #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
   7330 #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
   7331 
   7332     PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt);
   7333 
   7334 #if !defined (__CRT__NO_INLINE) && !defined (__WIDL__)
   7335     __CRT_INLINE PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt) {
   7336       volatile char *vptr =(volatile char *)ptr;
   7337 #ifdef __x86_64
   7338       __stosb((PBYTE)((DWORD64)vptr),0,cnt);
   7339 #else
   7340       while(cnt) {
   7341 	*vptr++ = 0;
   7342 	cnt--;
   7343       }
   7344 #endif /* __x86_64 */
   7345       return ptr;
   7346     }
   7347 #endif /* !__CRT__NO_INLINE // !__WIDL__ */
   7348 
   7349     typedef struct _MESSAGE_RESOURCE_ENTRY {
   7350       WORD Length;
   7351       WORD Flags;
   7352       BYTE Text[1];
   7353     } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
   7354 
   7355 #define SEF_DACL_AUTO_INHERIT 0x01
   7356 #define SEF_SACL_AUTO_INHERIT 0x02
   7357 #define SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT 0x04
   7358 #define SEF_AVOID_PRIVILEGE_CHECK 0x08
   7359 #define SEF_AVOID_OWNER_CHECK 0x10
   7360 #define SEF_DEFAULT_OWNER_FROM_PARENT 0x20
   7361 #define SEF_DEFAULT_GROUP_FROM_PARENT 0x40
   7362 #define SEF_MACL_NO_WRITE_UP 0x100
   7363 #define SEF_MACL_NO_READ_UP 0x200
   7364 #define SEF_MACL_NO_EXECUTE_UP 0x400
   7365 #define SEF_AVOID_OWNER_RESTRICTION 0x1000
   7366 
   7367 #define SEF_MACL_VALID_FLAGS (SEF_MACL_NO_WRITE_UP | SEF_MACL_NO_READ_UP | SEF_MACL_NO_EXECUTE_UP)
   7368 
   7369 #define MESSAGE_RESOURCE_UNICODE 0x0001
   7370 
   7371     typedef struct _MESSAGE_RESOURCE_BLOCK {
   7372       DWORD LowId;
   7373       DWORD HighId;
   7374       DWORD OffsetToEntries;
   7375     } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
   7376 
   7377     typedef struct _MESSAGE_RESOURCE_DATA {
   7378       DWORD NumberOfBlocks;
   7379       MESSAGE_RESOURCE_BLOCK Blocks[1];
   7380     } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
   7381 
   7382     typedef struct _OSVERSIONINFOA {
   7383       DWORD dwOSVersionInfoSize;
   7384       DWORD dwMajorVersion;
   7385       DWORD dwMinorVersion;
   7386       DWORD dwBuildNumber;
   7387       DWORD dwPlatformId;
   7388       CHAR szCSDVersion[128];
   7389     } OSVERSIONINFOA,*POSVERSIONINFOA,*LPOSVERSIONINFOA;
   7390 
   7391     typedef struct _OSVERSIONINFOW {
   7392       DWORD dwOSVersionInfoSize;
   7393       DWORD dwMajorVersion;
   7394       DWORD dwMinorVersion;
   7395       DWORD dwBuildNumber;
   7396       DWORD dwPlatformId;
   7397       WCHAR szCSDVersion[128];
   7398     } OSVERSIONINFOW,*POSVERSIONINFOW,*LPOSVERSIONINFOW,RTL_OSVERSIONINFOW,*PRTL_OSVERSIONINFOW;
   7399 
   7400     __MINGW_TYPEDEF_AW(OSVERSIONINFO)
   7401     __MINGW_TYPEDEF_AW(POSVERSIONINFO)
   7402     __MINGW_TYPEDEF_AW(LPOSVERSIONINFO)
   7403 
   7404     typedef struct _OSVERSIONINFOEXA {
   7405       DWORD dwOSVersionInfoSize;
   7406       DWORD dwMajorVersion;
   7407       DWORD dwMinorVersion;
   7408       DWORD dwBuildNumber;
   7409       DWORD dwPlatformId;
   7410       CHAR szCSDVersion[128];
   7411       WORD wServicePackMajor;
   7412       WORD wServicePackMinor;
   7413       WORD wSuiteMask;
   7414       BYTE wProductType;
   7415       BYTE wReserved;
   7416     } OSVERSIONINFOEXA,*POSVERSIONINFOEXA,*LPOSVERSIONINFOEXA;
   7417 
   7418     typedef struct _OSVERSIONINFOEXW {
   7419       DWORD dwOSVersionInfoSize;
   7420       DWORD dwMajorVersion;
   7421       DWORD dwMinorVersion;
   7422       DWORD dwBuildNumber;
   7423       DWORD dwPlatformId;
   7424       WCHAR szCSDVersion[128];
   7425       WORD wServicePackMajor;
   7426       WORD wServicePackMinor;
   7427       WORD wSuiteMask;
   7428       BYTE wProductType;
   7429       BYTE wReserved;
   7430     } OSVERSIONINFOEXW,*POSVERSIONINFOEXW,*LPOSVERSIONINFOEXW,RTL_OSVERSIONINFOEXW,*PRTL_OSVERSIONINFOEXW;
   7431 
   7432     __MINGW_TYPEDEF_AW(OSVERSIONINFOEX)
   7433     __MINGW_TYPEDEF_AW(POSVERSIONINFOEX)
   7434     __MINGW_TYPEDEF_AW(LPOSVERSIONINFOEX)
   7435 
   7436 #define VER_EQUAL 1
   7437 #define VER_GREATER 2
   7438 #define VER_GREATER_EQUAL 3
   7439 #define VER_LESS 4
   7440 #define VER_LESS_EQUAL 5
   7441 #define VER_AND 6
   7442 #define VER_OR 7
   7443 
   7444 #define VER_CONDITION_MASK 7
   7445 #define VER_NUM_BITS_PER_CONDITION_MASK 3
   7446 
   7447 #define VER_MINORVERSION 0x0000001
   7448 #define VER_MAJORVERSION 0x0000002
   7449 #define VER_BUILDNUMBER 0x0000004
   7450 #define VER_PLATFORMID 0x0000008
   7451 #define VER_SERVICEPACKMINOR 0x0000010
   7452 #define VER_SERVICEPACKMAJOR 0x0000020
   7453 #define VER_SUITENAME 0x0000040
   7454 #define VER_PRODUCT_TYPE 0x0000080
   7455 
   7456 #define VER_NT_WORKSTATION 0x0000001
   7457 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
   7458 #define VER_NT_SERVER 0x0000003
   7459 
   7460 #define VER_PLATFORM_WIN32s 0
   7461 #define VER_PLATFORM_WIN32_WINDOWS 1
   7462 #define VER_PLATFORM_WIN32_NT 2
   7463 
   7464 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
   7465 #if !defined (_WINBASE_) && !defined (__WIDL__)
   7466     NTSYSAPI ULONGLONG NTAPI VerSetConditionMask (ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition);
   7467 #endif
   7468 
   7469 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_) = VerSetConditionMask((_m_),(_t_),(_c_)))
   7470 
   7471 #if _WIN32_WINNT >= 0x0600 && !defined (__WIDL__)
   7472     NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo (DWORD OSMajorVersion, DWORD OSMinorVersion, DWORD SpMajorVersion, DWORD SpMinorVersion, PDWORD ReturnedProductType);
   7473 #endif
   7474 #endif
   7475 
   7476 #define RTL_UMS_VERSION (0x0100)
   7477 
   7478     typedef enum _RTL_UMS_THREAD_INFO_CLASS {
   7479       UmsThreadInvalidInfoClass = 0,
   7480       UmsThreadUserContext,
   7481       UmsThreadPriority,
   7482       UmsThreadAffinity,
   7483       UmsThreadTeb,
   7484       UmsThreadIsSuspended,
   7485       UmsThreadIsTerminated,
   7486       UmsThreadMaxInfoClass
   7487     } RTL_UMS_THREAD_INFO_CLASS,*PRTL_UMS_THREAD_INFO_CLASS;
   7488 
   7489     typedef enum _RTL_UMS_SCHEDULER_REASON {
   7490       UmsSchedulerStartup = 0,
   7491       UmsSchedulerThreadBlocked,
   7492       UmsSchedulerThreadYield,
   7493     } RTL_UMS_SCHEDULER_REASON,*PRTL_UMS_SCHEDULER_REASON;
   7494 
   7495     typedef VOID NTAPI RTL_UMS_SCHEDULER_ENTRY_POINT (RTL_UMS_SCHEDULER_REASON Reason, ULONG_PTR ActivationPayload, PVOID SchedulerParam);
   7496     typedef RTL_UMS_SCHEDULER_ENTRY_POINT *PRTL_UMS_SCHEDULER_ENTRY_POINT;
   7497 
   7498 #if _WIN32_WINNT >= 0x0602
   7499 #ifndef IS_VALIDATION_ENABLED
   7500 #define IS_VALIDATION_ENABLED(C, L) ((L) & (C))
   7501 #define VRL_PREDEFINED_CLASS_BEGIN (1)
   7502 #define VRL_CUSTOM_CLASS_BEGIN (1 << 8)
   7503 #define VRL_CLASS_CONSISTENCY (VRL_PREDEFINED_CLASS_BEGIN)
   7504 #define VRL_ENABLE_KERNEL_BREAKS (1 << 31)
   7505 #endif
   7506 
   7507 #define CTMF_INCLUDE_APPCONTAINER __MSABI_LONG(0x1U)
   7508 #define CTMF_VALID_FLAGS (CTMF_INCLUDE_APPCONTAINER)
   7509 
   7510 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
   7511     NTSYSAPI DWORD NTAPI RtlCrc32 (const void *Buffer, size_t Size, DWORD InitialCrc);
   7512     NTSYSAPI ULONGLONG NTAPI RtlCrc64 (const void *Buffer, size_t Size, ULONGLONG InitialCrc);
   7513 #endif
   7514 #endif
   7515 
   7516     typedef struct _RTL_CRITICAL_SECTION_DEBUG {
   7517       WORD Type;
   7518       WORD CreatorBackTraceIndex;
   7519       struct _RTL_CRITICAL_SECTION *CriticalSection;
   7520       LIST_ENTRY ProcessLocksList;
   7521       DWORD EntryCount;
   7522       DWORD ContentionCount;
   7523       DWORD Flags;
   7524       WORD CreatorBackTraceIndexHigh;
   7525       WORD SpareWORD;
   7526     } RTL_CRITICAL_SECTION_DEBUG,*PRTL_CRITICAL_SECTION_DEBUG,RTL_RESOURCE_DEBUG,*PRTL_RESOURCE_DEBUG;
   7527 
   7528 #define RTL_CRITSECT_TYPE 0
   7529 #define RTL_RESOURCE_TYPE 1
   7530 
   7531 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x01000000
   7532 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x02000000
   7533 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x04000000
   7534 #define RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE 0x08000000
   7535 #define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO 0x10000000
   7536 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xff000000
   7537 
   7538 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & (~(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO | RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN | RTL_CRITICAL_SECTION_FLAG_STATIC_INIT | RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE | RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO)))
   7539 
   7540 #define RTL_CRITICAL_SECTION_DEBUG_FLAG_STATIC_INIT 0x00000001
   7541 
   7542 #include <pshpack8.h>
   7543     typedef struct _RTL_CRITICAL_SECTION {
   7544       PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
   7545       LONG LockCount;
   7546       LONG RecursionCount;
   7547       HANDLE OwningThread;
   7548       HANDLE LockSemaphore;
   7549       ULONG_PTR SpinCount;
   7550     } RTL_CRITICAL_SECTION,*PRTL_CRITICAL_SECTION;
   7551 #include <poppack.h>
   7552 
   7553     typedef struct _RTL_SRWLOCK { PVOID Ptr; } RTL_SRWLOCK,*PRTL_SRWLOCK;
   7554     typedef struct _RTL_CONDITION_VARIABLE { PVOID Ptr; } RTL_CONDITION_VARIABLE,*PRTL_CONDITION_VARIABLE;
   7555 
   7556 #define RTL_SRWLOCK_INIT {0}
   7557 #define RTL_CONDITION_VARIABLE_INIT {0}
   7558 
   7559 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
   7560 
   7561     typedef VOID (NTAPI *PAPCFUNC) (ULONG_PTR Parameter);
   7562     typedef LONG (NTAPI *PVECTORED_EXCEPTION_HANDLER) (struct _EXCEPTION_POINTERS *ExceptionInfo);
   7563 
   7564     typedef enum _HEAP_INFORMATION_CLASS {
   7565       HeapCompatibilityInformation,
   7566       HeapEnableTerminationOnCorruption
   7567     } HEAP_INFORMATION_CLASS;
   7568 
   7569     typedef VOID (NTAPI *WORKERCALLBACKFUNC) (PVOID);
   7570     typedef VOID (NTAPI *APC_CALLBACK_FUNCTION) (DWORD, PVOID, PVOID);
   7571     typedef VOID (NTAPI *WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN);
   7572     typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK;
   7573     typedef VOID (NTAPI *PFLS_CALLBACK_FUNCTION) (PVOID lpFlsData);
   7574     typedef BOOLEAN (NTAPI *PSECURE_MEMORY_CACHE_CALLBACK) (PVOID Addr, SIZE_T Range);
   7575 
   7576 #define WT_EXECUTEDEFAULT 0x00000000
   7577 #define WT_EXECUTEINIOTHREAD 0x00000001
   7578 #define WT_EXECUTEINUITHREAD 0x00000002
   7579 #define WT_EXECUTEINWAITTHREAD 0x00000004
   7580 #define WT_EXECUTEONLYONCE 0x00000008
   7581 #define WT_EXECUTEINTIMERTHREAD 0x00000020
   7582 #define WT_EXECUTELONGFUNCTION 0x00000010
   7583 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040
   7584 #define WT_EXECUTEINPERSISTENTTHREAD 0x00000080
   7585 #define WT_TRANSFER_IMPERSONATION 0x00000100
   7586 
   7587 #define WT_SET_MAX_THREADPOOL_THREADS(Flags, Limit) ((Flags) |= (Limit) << 16)
   7588 
   7589 #define WT_EXECUTEDELETEWAIT 0x00000008
   7590 #define WT_EXECUTEINLONGTHREAD 0x00000010
   7591 
   7592     typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
   7593       ActivationContextBasicInformation = 1,
   7594       ActivationContextDetailedInformation = 2,
   7595       AssemblyDetailedInformationInActivationContext = 3,
   7596       FileInformationInAssemblyOfAssemblyInActivationContext = 4,
   7597       RunlevelInformationInActivationContext = 5,
   7598       CompatibilityInformationInActivationContext = 6,
   7599       ActivationContextManifestResourceName = 7,
   7600       MaxActivationContextInfoClass,
   7601       AssemblyDetailedInformationInActivationContxt = 3,
   7602       FileInformationInAssemblyOfAssemblyInActivationContxt = 4
   7603     } ACTIVATION_CONTEXT_INFO_CLASS;
   7604 
   7605     typedef enum {
   7606       ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
   7607       ACTCTX_RUN_LEVEL_AS_INVOKER,
   7608       ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
   7609       ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
   7610       ACTCTX_RUN_LEVEL_NUMBERS
   7611     } ACTCTX_REQUESTED_RUN_LEVEL;
   7612 
   7613     typedef enum {
   7614       ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
   7615       ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
   7616       ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION
   7617     } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
   7618 
   7619     typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
   7620       DWORD ulAssemblyIndex;
   7621       DWORD ulFileIndexInAssembly;
   7622     } ACTIVATION_CONTEXT_QUERY_INDEX,*PACTIVATION_CONTEXT_QUERY_INDEX;
   7623 
   7624     typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
   7625       DWORD ulFlags;
   7626       DWORD ulFilenameLength;
   7627       DWORD ulPathLength;
   7628       PCWSTR lpFileName;
   7629       PCWSTR lpFilePath;
   7630     } ASSEMBLY_FILE_DETAILED_INFORMATION,*PASSEMBLY_FILE_DETAILED_INFORMATION;
   7631 
   7632     typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
   7633       DWORD ulFlags;
   7634       DWORD ulEncodedAssemblyIdentityLength;
   7635       DWORD ulManifestPathType;
   7636       DWORD ulManifestPathLength;
   7637       LARGE_INTEGER liManifestLastWriteTime;
   7638       DWORD ulPolicyPathType;
   7639       DWORD ulPolicyPathLength;
   7640       LARGE_INTEGER liPolicyLastWriteTime;
   7641       DWORD ulMetadataSatelliteRosterIndex;
   7642       DWORD ulManifestVersionMajor;
   7643       DWORD ulManifestVersionMinor;
   7644       DWORD ulPolicyVersionMajor;
   7645       DWORD ulPolicyVersionMinor;
   7646       DWORD ulAssemblyDirectoryNameLength;
   7647       PCWSTR lpAssemblyEncodedAssemblyIdentity;
   7648       PCWSTR lpAssemblyManifestPath;
   7649       PCWSTR lpAssemblyPolicyPath;
   7650       PCWSTR lpAssemblyDirectoryName;
   7651       DWORD ulFileCount;
   7652     } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION,*PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
   7653 
   7654     typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
   7655       DWORD ulFlags;
   7656       ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
   7657       DWORD UiAccess;
   7658     } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION,*PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
   7659 
   7660     typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
   7661       GUID Id;
   7662       ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
   7663     } COMPATIBILITY_CONTEXT_ELEMENT,*PCOMPATIBILITY_CONTEXT_ELEMENT;
   7664 
   7665 /*Vista: {e2011457-1546-43c5-a5fe-008deee3d3f0}*/
   7666 /*Seven: {35138b9a-5d96-4fbd-8e2d-a2440225f93a}*/
   7667     typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
   7668       DWORD ElementCount;
   7669       COMPATIBILITY_CONTEXT_ELEMENT Elements[];
   7670     } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION,*PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
   7671 
   7672 #define MAX_SUPPORTED_OS_NUM (4)
   7673 
   7674     typedef struct _SUPPORTED_OS_INFO {
   7675       WORD OsCount;
   7676       WORD MitigationExist;
   7677       WORD OsList[MAX_SUPPORTED_OS_NUM];
   7678     } SUPPORTED_OS_INFO,*PSUPPORTED_OS_INFO;
   7679 
   7680     typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
   7681       DWORD dwFlags;
   7682       DWORD ulFormatVersion;
   7683       DWORD ulAssemblyCount;
   7684       DWORD ulRootManifestPathType;
   7685       DWORD ulRootManifestPathChars;
   7686       DWORD ulRootConfigurationPathType;
   7687       DWORD ulRootConfigurationPathChars;
   7688       DWORD ulAppDirPathType;
   7689       DWORD ulAppDirPathChars;
   7690       PCWSTR lpRootManifestPath;
   7691       PCWSTR lpRootConfigurationPath;
   7692       PCWSTR lpAppDirPath;
   7693     } ACTIVATION_CONTEXT_DETAILED_INFORMATION,*PACTIVATION_CONTEXT_DETAILED_INFORMATION;
   7694 
   7695     typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
   7696     typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
   7697     typedef const struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
   7698     typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION *PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
   7699     typedef const struct _COMPATIBILITY_CONTEXT_ELEMENT *PCCOMPATIBILITY_CONTEXT_ELEMENT;
   7700     typedef const struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION *PCACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
   7701     typedef const struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_DETAILED_INFORMATION;
   7702 
   7703 #define ACTIVATIONCONTEXTINFOCLASS ACTIVATION_CONTEXT_INFO_CLASS
   7704 
   7705 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE (1)
   7706 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE (2)
   7707 #define ACTIVATION_CONTEXT_PATH_TYPE_URL (3)
   7708 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF (4)
   7709 
   7710 #define _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION _ASSEMBLY_FILE_DETAILED_INFORMATION
   7711 #define ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION ASSEMBLY_FILE_DETAILED_INFORMATION
   7712 #define PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PASSEMBLY_FILE_DETAILED_INFORMATION
   7713 #define PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PCASSEMBLY_FILE_DETAILED_INFORMATION
   7714 #define INVALID_OS_COUNT (0xffff)
   7715 
   7716 #define CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID 0x1
   7717 
   7718     typedef VOID (NTAPI *RTL_VERIFIER_DLL_LOAD_CALLBACK) (PWSTR DllName,PVOID DllBase,SIZE_T DllSize,PVOID Reserved);
   7719     typedef VOID (NTAPI *RTL_VERIFIER_DLL_UNLOAD_CALLBACK) (PWSTR DllName,PVOID DllBase,SIZE_T DllSize,PVOID Reserved);
   7720     typedef VOID (NTAPI *RTL_VERIFIER_NTDLLHEAPFREE_CALLBACK)(PVOID AllocationBase,SIZE_T AllocationSize);
   7721 
   7722     typedef struct _RTL_VERIFIER_THUNK_DESCRIPTOR {
   7723       PCHAR ThunkName;
   7724       PVOID ThunkOldAddress;
   7725       PVOID ThunkNewAddress;
   7726     } RTL_VERIFIER_THUNK_DESCRIPTOR,*PRTL_VERIFIER_THUNK_DESCRIPTOR;
   7727 
   7728     typedef struct _RTL_VERIFIER_DLL_DESCRIPTOR {
   7729       PWCHAR DllName;
   7730       DWORD DllFlags;
   7731       PVOID DllAddress;
   7732       PRTL_VERIFIER_THUNK_DESCRIPTOR DllThunks;
   7733     } RTL_VERIFIER_DLL_DESCRIPTOR,*PRTL_VERIFIER_DLL_DESCRIPTOR;
   7734 
   7735     typedef struct _RTL_VERIFIER_PROVIDER_DESCRIPTOR {
   7736       DWORD Length;
   7737       PRTL_VERIFIER_DLL_DESCRIPTOR ProviderDlls;
   7738       RTL_VERIFIER_DLL_LOAD_CALLBACK ProviderDllLoadCallback;
   7739       RTL_VERIFIER_DLL_UNLOAD_CALLBACK ProviderDllUnloadCallback;
   7740       PWSTR VerifierImage;
   7741       DWORD VerifierFlags;
   7742       DWORD VerifierDebug;
   7743       PVOID RtlpGetStackTraceAddress;
   7744       PVOID RtlpDebugPageHeapCreate;
   7745       PVOID RtlpDebugPageHeapDestroy;
   7746       RTL_VERIFIER_NTDLLHEAPFREE_CALLBACK ProviderNtdllHeapFreeCallback;
   7747     } RTL_VERIFIER_PROVIDER_DESCRIPTOR,*PRTL_VERIFIER_PROVIDER_DESCRIPTOR;
   7748 
   7749 #define RTL_VRF_FLG_FULL_PAGE_HEAP 0x00000001
   7750 #define RTL_VRF_FLG_RESERVED_DONOTUSE 0x00000002
   7751 #define RTL_VRF_FLG_HANDLE_CHECKS 0x00000004
   7752 #define RTL_VRF_FLG_STACK_CHECKS 0x00000008
   7753 #define RTL_VRF_FLG_APPCOMPAT_CHECKS 0x00000010
   7754 #define RTL_VRF_FLG_TLS_CHECKS 0x00000020
   7755 #define RTL_VRF_FLG_DIRTY_STACKS 0x00000040
   7756 #define RTL_VRF_FLG_RPC_CHECKS 0x00000080
   7757 #define RTL_VRF_FLG_COM_CHECKS 0x00000100
   7758 #define RTL_VRF_FLG_DANGEROUS_APIS 0x00000200
   7759 #define RTL_VRF_FLG_RACE_CHECKS 0x00000400
   7760 #define RTL_VRF_FLG_DEADLOCK_CHECKS 0x00000800
   7761 #define RTL_VRF_FLG_FIRST_CHANCE_EXCEPTION_CHECKS 0x00001000
   7762 #define RTL_VRF_FLG_VIRTUAL_MEM_CHECKS 0x00002000
   7763 #define RTL_VRF_FLG_ENABLE_LOGGING 0x00004000
   7764 #define RTL_VRF_FLG_FAST_FILL_HEAP 0x00008000
   7765 #define RTL_VRF_FLG_VIRTUAL_SPACE_TRACKING 0x00010000
   7766 #define RTL_VRF_FLG_ENABLED_SYSTEM_WIDE 0x00020000
   7767 #define RTL_VRF_FLG_MISCELLANEOUS_CHECKS 0x00020000
   7768 #define RTL_VRF_FLG_LOCK_CHECKS 0x00040000
   7769 
   7770 #define APPLICATION_VERIFIER_INTERNAL_ERROR 0x80000000
   7771 #define APPLICATION_VERIFIER_INTERNAL_WARNING 0x40000000
   7772 #define APPLICATION_VERIFIER_NO_BREAK 0x20000000
   7773 #define APPLICATION_VERIFIER_CONTINUABLE_BREAK 0x10000000
   7774 
   7775 #define APPLICATION_VERIFIER_UNKNOWN_ERROR 0x0001
   7776 #define APPLICATION_VERIFIER_ACCESS_VIOLATION 0x0002
   7777 #define APPLICATION_VERIFIER_UNSYNCHRONIZED_ACCESS 0x0003
   7778 #define APPLICATION_VERIFIER_EXTREME_SIZE_REQUEST 0x0004
   7779 #define APPLICATION_VERIFIER_BAD_HEAP_HANDLE 0x0005
   7780 #define APPLICATION_VERIFIER_SWITCHED_HEAP_HANDLE 0x0006
   7781 #define APPLICATION_VERIFIER_DOUBLE_FREE 0x0007
   7782 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK 0x0008
   7783 #define APPLICATION_VERIFIER_DESTROY_PROCESS_HEAP 0x0009
   7784 #define APPLICATION_VERIFIER_UNEXPECTED_EXCEPTION 0x000A
   7785 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_EXCEPTION_RAISED_FOR_HEADER 0x000B
   7786 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_EXCEPTION_RAISED_FOR_PROBING 0x000C
   7787 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_HEADER 0x000D
   7788 #define APPLICATION_VERIFIER_CORRUPTED_FREED_HEAP_BLOCK 0x000E
   7789 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_SUFFIX 0x000F
   7790 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_START_STAMP 0x0010
   7791 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_END_STAMP 0x0011
   7792 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_PREFIX 0x0012
   7793 #define APPLICATION_VERIFIER_FIRST_CHANCE_ACCESS_VIOLATION 0x0013
   7794 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_LIST 0x0014
   7795 
   7796 #define APPLICATION_VERIFIER_TERMINATE_THREAD_CALL 0x0100
   7797 #define APPLICATION_VERIFIER_STACK_OVERFLOW 0x0101
   7798 #define APPLICATION_VERIFIER_INVALID_EXIT_PROCESS_CALL 0x0102
   7799 
   7800 #define APPLICATION_VERIFIER_EXIT_THREAD_OWNS_LOCK 0x0200
   7801 #define APPLICATION_VERIFIER_LOCK_IN_UNLOADED_DLL 0x0201
   7802 #define APPLICATION_VERIFIER_LOCK_IN_FREED_HEAP 0x0202
   7803 #define APPLICATION_VERIFIER_LOCK_DOUBLE_INITIALIZE 0x0203
   7804 #define APPLICATION_VERIFIER_LOCK_IN_FREED_MEMORY 0x0204
   7805 #define APPLICATION_VERIFIER_LOCK_CORRUPTED 0x0205
   7806 #define APPLICATION_VERIFIER_LOCK_INVALID_OWNER 0x0206
   7807 #define APPLICATION_VERIFIER_LOCK_INVALID_RECURSION_COUNT 0x0207
   7808 #define APPLICATION_VERIFIER_LOCK_INVALID_LOCK_COUNT 0x0208
   7809 #define APPLICATION_VERIFIER_LOCK_OVER_RELEASED 0x0209
   7810 #define APPLICATION_VERIFIER_LOCK_NOT_INITIALIZED 0x0210
   7811 #define APPLICATION_VERIFIER_LOCK_ALREADY_INITIALIZED 0x0211
   7812 #define APPLICATION_VERIFIER_LOCK_IN_FREED_VMEM 0x0212
   7813 #define APPLICATION_VERIFIER_LOCK_IN_UNMAPPED_MEM 0x0213
   7814 #define APPLICATION_VERIFIER_THREAD_NOT_LOCK_OWNER 0x0214
   7815 
   7816 #define APPLICATION_VERIFIER_INVALID_HANDLE 0x0300
   7817 #define APPLICATION_VERIFIER_INVALID_TLS_VALUE 0x0301
   7818 #define APPLICATION_VERIFIER_INCORRECT_WAIT_CALL 0x0302
   7819 #define APPLICATION_VERIFIER_NULL_HANDLE 0x0303
   7820 #define APPLICATION_VERIFIER_WAIT_IN_DLLMAIN 0x0304
   7821 
   7822 #define APPLICATION_VERIFIER_COM_ERROR 0x0400
   7823 #define APPLICATION_VERIFIER_COM_API_IN_DLLMAIN 0x0401
   7824 #define APPLICATION_VERIFIER_COM_UNHANDLED_EXCEPTION 0x0402
   7825 #define APPLICATION_VERIFIER_COM_UNBALANCED_COINIT 0x0403
   7826 #define APPLICATION_VERIFIER_COM_UNBALANCED_OLEINIT 0x0404
   7827 #define APPLICATION_VERIFIER_COM_UNBALANCED_SWC 0x0405
   7828 #define APPLICATION_VERIFIER_COM_NULL_DACL 0x0406
   7829 #define APPLICATION_VERIFIER_COM_UNSAFE_IMPERSONATION 0x0407
   7830 #define APPLICATION_VERIFIER_COM_SMUGGLED_WRAPPER 0x0408
   7831 #define APPLICATION_VERIFIER_COM_SMUGGLED_PROXY 0x0409
   7832 #define APPLICATION_VERIFIER_COM_CF_SUCCESS_WITH_NULL 0x040A
   7833 #define APPLICATION_VERIFIER_COM_GCO_SUCCESS_WITH_NULL 0x040B
   7834 #define APPLICATION_VERIFIER_COM_OBJECT_IN_FREED_MEMORY 0x040C
   7835 #define APPLICATION_VERIFIER_COM_OBJECT_IN_UNLOADED_DLL 0x040D
   7836 #define APPLICATION_VERIFIER_COM_VTBL_IN_FREED_MEMORY 0x040E
   7837 #define APPLICATION_VERIFIER_COM_VTBL_IN_UNLOADED_DLL 0x040F
   7838 #define APPLICATION_VERIFIER_COM_HOLDING_LOCKS_ON_CALL 0x0410
   7839 
   7840 #define APPLICATION_VERIFIER_RPC_ERROR 0x0500
   7841 
   7842 #define APPLICATION_VERIFIER_INVALID_FREEMEM 0x0600
   7843 #define APPLICATION_VERIFIER_INVALID_ALLOCMEM 0x0601
   7844 #define APPLICATION_VERIFIER_INVALID_MAPVIEW 0x0602
   7845 #define APPLICATION_VERIFIER_PROBE_INVALID_ADDRESS 0x0603
   7846 #define APPLICATION_VERIFIER_PROBE_FREE_MEM 0x0604
   7847 #define APPLICATION_VERIFIER_PROBE_GUARD_PAGE 0x0605
   7848 #define APPLICATION_VERIFIER_PROBE_NULL 0x0606
   7849 #define APPLICATION_VERIFIER_PROBE_INVALID_START_OR_SIZE 0x0607
   7850 #define APPLICATION_VERIFIER_SIZE_HEAP_UNEXPECTED_EXCEPTION 0x0618
   7851 
   7852 #define VERIFIER_STOP(Code,Msg,P1,S1,P2,S2,P3,S3,P4,S4) { RtlApplicationVerifierStop ((Code),(Msg),(ULONG_PTR)(P1),(S1),(ULONG_PTR)(P2),(S2),(ULONG_PTR)(P3),(S3),(ULONG_PTR)(P4),(S4)); }
   7853 
   7854     VOID NTAPI RtlApplicationVerifierStop(ULONG_PTR Code,PSTR Message,ULONG_PTR Param1,PSTR Description1,ULONG_PTR Param2,PSTR Description2,ULONG_PTR Param3,PSTR Description3,ULONG_PTR Param4,PSTR Description4);
   7855     NTSYSAPI DWORD NTAPI RtlSetHeapInformation(PVOID HeapHandle,HEAP_INFORMATION_CLASS HeapInformationClass,PVOID HeapInformation,SIZE_T HeapInformationLength);
   7856     NTSYSAPI DWORD NTAPI RtlQueryHeapInformation(PVOID HeapHandle,HEAP_INFORMATION_CLASS HeapInformationClass,PVOID HeapInformation,SIZE_T HeapInformationLength,PSIZE_T ReturnLength);
   7857     DWORD NTAPI RtlMultipleAllocateHeap(PVOID HeapHandle,DWORD Flags,SIZE_T Size,DWORD Count,PVOID *Array);
   7858     DWORD NTAPI RtlMultipleFreeHeap(PVOID HeapHandle,DWORD Flags,DWORD Count,PVOID *Array);
   7859 
   7860     typedef struct _HARDWARE_COUNTER_DATA {
   7861       HARDWARE_COUNTER_TYPE Type;
   7862       DWORD Reserved;
   7863       DWORD64 Value;
   7864     } HARDWARE_COUNTER_DATA,*PHARDWARE_COUNTER_DATA;
   7865 
   7866     typedef struct _PERFORMANCE_DATA {
   7867       WORD Size;
   7868       BYTE Version;
   7869       BYTE HwCountersCount;
   7870       DWORD ContextSwitchCount;
   7871       DWORD64 WaitReasonBitMap;
   7872       DWORD64 CycleTime;
   7873       DWORD RetryCount;
   7874       DWORD Reserved;
   7875       HARDWARE_COUNTER_DATA HwCounters[MAX_HW_COUNTERS];
   7876     } PERFORMANCE_DATA,*PPERFORMANCE_DATA;
   7877 
   7878 #define PERFORMANCE_DATA_VERSION 1
   7879 
   7880 #define READ_THREAD_PROFILING_FLAG_DISPATCHING 0x00000001
   7881 #define READ_THREAD_PROFILING_FLAG_HARDWARE_COUNTERS 0x00000002
   7882 
   7883 #define DLL_PROCESS_ATTACH 1
   7884 #define DLL_THREAD_ATTACH 2
   7885 #define DLL_THREAD_DETACH 3
   7886 #define DLL_PROCESS_DETACH 0
   7887 #define DLL_PROCESS_VERIFIER 4
   7888 
   7889 #define EVENTLOG_SEQUENTIAL_READ 0x0001
   7890 #define EVENTLOG_SEEK_READ 0x0002
   7891 #define EVENTLOG_FORWARDS_READ 0x0004
   7892 #define EVENTLOG_BACKWARDS_READ 0x0008
   7893 
   7894 #define EVENTLOG_SUCCESS 0x0000
   7895 #define EVENTLOG_ERROR_TYPE 0x0001
   7896 #define EVENTLOG_WARNING_TYPE 0x0002
   7897 #define EVENTLOG_INFORMATION_TYPE 0x0004
   7898 #define EVENTLOG_AUDIT_SUCCESS 0x0008
   7899 #define EVENTLOG_AUDIT_FAILURE 0x0010
   7900 
   7901 #define EVENTLOG_START_PAIRED_EVENT 0x0001
   7902 #define EVENTLOG_END_PAIRED_EVENT 0x0002
   7903 #define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004
   7904 #define EVENTLOG_PAIRED_EVENT_ACTIVE 0x0008
   7905 #define EVENTLOG_PAIRED_EVENT_INACTIVE 0x0010
   7906 
   7907     typedef struct _EVENTLOGRECORD {
   7908       DWORD Length;
   7909       DWORD Reserved;
   7910       DWORD RecordNumber;
   7911       DWORD TimeGenerated;
   7912       DWORD TimeWritten;
   7913       DWORD EventID;
   7914       WORD EventType;
   7915       WORD NumStrings;
   7916       WORD EventCategory;
   7917       WORD ReservedFlags;
   7918       DWORD ClosingRecordNumber;
   7919       DWORD StringOffset;
   7920       DWORD UserSidLength;
   7921       DWORD UserSidOffset;
   7922       DWORD DataLength;
   7923       DWORD DataOffset;
   7924     } EVENTLOGRECORD,*PEVENTLOGRECORD;
   7925 
   7926 #define MAXLOGICALLOGNAMESIZE 256
   7927 
   7928     typedef struct _EVENTSFORLOGFILE {
   7929       DWORD ulSize;
   7930       WCHAR szLogicalLogFile[MAXLOGICALLOGNAMESIZE];
   7931       DWORD ulNumRecords;
   7932       EVENTLOGRECORD pEventLogRecords[];
   7933     } EVENTSFORLOGFILE,*PEVENTSFORLOGFILE;
   7934 
   7935     typedef struct _PACKEDEVENTINFO {
   7936       DWORD ulSize;
   7937       DWORD ulNumEventsForLogFile;
   7938       DWORD ulOffsets[];
   7939     } PACKEDEVENTINFO,*PPACKEDEVENTINFO;
   7940 
   7941 #define KEY_QUERY_VALUE (0x0001)
   7942 #define KEY_SET_VALUE (0x0002)
   7943 #define KEY_CREATE_SUB_KEY (0x0004)
   7944 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
   7945 #define KEY_NOTIFY (0x0010)
   7946 #define KEY_CREATE_LINK (0x0020)
   7947 #define KEY_WOW64_64KEY (0x0100)
   7948 #define KEY_WOW64_32KEY (0x0200)
   7949 #define KEY_WOW64_RES (0x0300)
   7950 
   7951 #define KEY_READ ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE))
   7952 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE))
   7953 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
   7954 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & (~SYNCHRONIZE))
   7955 #define REG_OPTION_RESERVED (__MSABI_LONG(0x00000000))
   7956 
   7957 #define REG_OPTION_NON_VOLATILE (__MSABI_LONG(0x00000000))
   7958 #define REG_OPTION_VOLATILE (__MSABI_LONG(0x00000001))
   7959 #define REG_OPTION_CREATE_LINK (__MSABI_LONG(0x00000002))
   7960 #define REG_OPTION_BACKUP_RESTORE (__MSABI_LONG(0x00000004))
   7961 #define REG_OPTION_OPEN_LINK (__MSABI_LONG(0x00000008))
   7962 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK)
   7963 
   7964 #define REG_CREATED_NEW_KEY (__MSABI_LONG(0x00000001))
   7965 #define REG_OPENED_EXISTING_KEY (__MSABI_LONG(0x00000002))
   7966 
   7967 #define REG_STANDARD_FORMAT 1
   7968 #define REG_LATEST_FORMAT 2
   7969 #define REG_NO_COMPRESSION 4
   7970 
   7971 #define REG_WHOLE_HIVE_VOLATILE (__MSABI_LONG(0x00000001))
   7972 #define REG_REFRESH_HIVE (__MSABI_LONG(0x00000002))
   7973 #define REG_NO_LAZY_FLUSH (__MSABI_LONG(0x00000004))
   7974 #define REG_FORCE_RESTORE (__MSABI_LONG(0x00000008))
   7975 #define REG_APP_HIVE (__MSABI_LONG(0x00000010))
   7976 #define REG_PROCESS_PRIVATE (__MSABI_LONG(0x00000020))
   7977 #define REG_START_JOURNAL (__MSABI_LONG(0x00000040))
   7978 #define REG_HIVE_EXACT_FILE_GROWTH (__MSABI_LONG(0x00000080))
   7979 #define REG_HIVE_NO_RM (__MSABI_LONG(0x00000100))
   7980 #define REG_HIVE_SINGLE_LOG (__MSABI_LONG(0x00000200))
   7981 #define REG_BOOT_HIVE (__MSABI_LONG(0x00000400))
   7982 
   7983 #define REG_FORCE_UNLOAD 1
   7984 
   7985 #define REG_NOTIFY_CHANGE_NAME (__MSABI_LONG(0x00000001))
   7986 #define REG_NOTIFY_CHANGE_ATTRIBUTES (__MSABI_LONG(0x00000002))
   7987 #define REG_NOTIFY_CHANGE_LAST_SET (__MSABI_LONG(0x00000004))
   7988 #define REG_NOTIFY_CHANGE_SECURITY (__MSABI_LONG(0x00000008))
   7989 #define REG_NOTIFY_THREAD_AGNOSTIC (__MSABI_LONG(0x10000000))
   7990 
   7991 #define REG_LEGAL_CHANGE_FILTER (REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY | REG_NOTIFY_THREAD_AGNOSTIC)
   7992 
   7993 #define REG_NONE (0)
   7994 #define REG_SZ (1)
   7995 #define REG_EXPAND_SZ (2)
   7996 #define REG_BINARY (3)
   7997 #define REG_DWORD (4)
   7998 #define REG_DWORD_LITTLE_ENDIAN (4)
   7999 #define REG_DWORD_BIG_ENDIAN (5)
   8000 #define REG_LINK (6)
   8001 #define REG_MULTI_SZ (7)
   8002 #define REG_RESOURCE_LIST (8)
   8003 #define REG_FULL_RESOURCE_DESCRIPTOR (9)
   8004 #define REG_RESOURCE_REQUIREMENTS_LIST (10)
   8005 #define REG_QWORD (11)
   8006 #define REG_QWORD_LITTLE_ENDIAN (11)
   8007 
   8008 #define SERVICE_KERNEL_DRIVER 0x00000001
   8009 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
   8010 #define SERVICE_ADAPTER 0x00000004
   8011 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
   8012 
   8013 #define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER)
   8014 
   8015 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
   8016 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
   8017 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
   8018 
   8019 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
   8020 
   8021 #define SERVICE_TYPE_ALL (SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS)
   8022 
   8023 #define SERVICE_BOOT_START 0x00000000
   8024 #define SERVICE_SYSTEM_START 0x00000001
   8025 #define SERVICE_AUTO_START 0x00000002
   8026 #define SERVICE_DEMAND_START 0x00000003
   8027 #define SERVICE_DISABLED 0x00000004
   8028 
   8029 #define SERVICE_ERROR_IGNORE 0x00000000
   8030 #define SERVICE_ERROR_NORMAL 0x00000001
   8031 #define SERVICE_ERROR_SEVERE 0x00000002
   8032 #define SERVICE_ERROR_CRITICAL 0x00000003
   8033 
   8034     typedef enum _CM_SERVICE_NODE_TYPE {
   8035       DriverType = SERVICE_KERNEL_DRIVER,FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
   8036       Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,AdapterType = SERVICE_ADAPTER,RecognizerType = SERVICE_RECOGNIZER_DRIVER
   8037     } SERVICE_NODE_TYPE;
   8038 
   8039     typedef enum _CM_SERVICE_LOAD_TYPE {
   8040       BootLoad = SERVICE_BOOT_START,SystemLoad = SERVICE_SYSTEM_START,AutoLoad = SERVICE_AUTO_START,DemandLoad = SERVICE_DEMAND_START,
   8041       DisableLoad = SERVICE_DISABLED
   8042     } SERVICE_LOAD_TYPE;
   8043 
   8044     typedef enum _CM_ERROR_CONTROL_TYPE {
   8045       IgnoreError = SERVICE_ERROR_IGNORE,NormalError = SERVICE_ERROR_NORMAL,SevereError = SERVICE_ERROR_SEVERE,CriticalError = SERVICE_ERROR_CRITICAL
   8046     } SERVICE_ERROR_TYPE;
   8047 
   8048 #define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001
   8049 #define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002
   8050 #define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004
   8051 #define CM_SERVICE_SD_DISK_BOOT_LOAD 0x00000008
   8052 #define CM_SERVICE_USB3_DISK_BOOT_LOAD 0x00000010
   8053 #define CM_SERVICE_MEASURED_BOOT_LOAD 0x00000020
   8054 #define CM_SERVICE_VERIFIER_BOOT_LOAD 0x00000040
   8055 #define CM_SERVICE_WINPE_BOOT_LOAD 0x00000080
   8056 
   8057 #define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | CM_SERVICE_USB_DISK_BOOT_LOAD | CM_SERVICE_SD_DISK_BOOT_LOAD | CM_SERVICE_USB3_DISK_BOOT_LOAD | CM_SERVICE_MEASURED_BOOT_LOAD | CM_SERVICE_VERIFIER_BOOT_LOAD | CM_SERVICE_WINPE_BOOT_LOAD)
   8058 
   8059 #ifndef _NTDDTAPE_WINNT_
   8060 #define _NTDDTAPE_WINNT_
   8061 
   8062 #define TAPE_ERASE_SHORT __MSABI_LONG(0)
   8063 #define TAPE_ERASE_LONG __MSABI_LONG(1)
   8064 
   8065     typedef struct _TAPE_ERASE {
   8066       DWORD Type;
   8067       BOOLEAN Immediate;
   8068     } TAPE_ERASE,*PTAPE_ERASE;
   8069 
   8070 #define TAPE_LOAD __MSABI_LONG(0)
   8071 #define TAPE_UNLOAD __MSABI_LONG(1)
   8072 #define TAPE_TENSION __MSABI_LONG(2)
   8073 #define TAPE_LOCK __MSABI_LONG(3)
   8074 #define TAPE_UNLOCK __MSABI_LONG(4)
   8075 #define TAPE_FORMAT __MSABI_LONG(5)
   8076 
   8077     typedef struct _TAPE_PREPARE {
   8078       DWORD Operation;
   8079       BOOLEAN Immediate;
   8080     } TAPE_PREPARE,*PTAPE_PREPARE;
   8081 
   8082 #define TAPE_SETMARKS __MSABI_LONG(0)
   8083 #define TAPE_FILEMARKS __MSABI_LONG(1)
   8084 #define TAPE_SHORT_FILEMARKS __MSABI_LONG(2)
   8085 #define TAPE_LONG_FILEMARKS __MSABI_LONG(3)
   8086 
   8087     typedef struct _TAPE_WRITE_MARKS {
   8088       DWORD Type;
   8089       DWORD Count;
   8090       BOOLEAN Immediate;
   8091     } TAPE_WRITE_MARKS,*PTAPE_WRITE_MARKS;
   8092 
   8093 #define TAPE_ABSOLUTE_POSITION __MSABI_LONG(0)
   8094 #define TAPE_LOGICAL_POSITION __MSABI_LONG(1)
   8095 #define TAPE_PSEUDO_LOGICAL_POSITION __MSABI_LONG(2)
   8096 
   8097     typedef struct _TAPE_GET_POSITION {
   8098       DWORD Type;
   8099       DWORD Partition;
   8100       LARGE_INTEGER Offset;
   8101     } TAPE_GET_POSITION,*PTAPE_GET_POSITION;
   8102 
   8103 #define TAPE_REWIND __MSABI_LONG(0)
   8104 #define TAPE_ABSOLUTE_BLOCK __MSABI_LONG(1)
   8105 #define TAPE_LOGICAL_BLOCK __MSABI_LONG(2)
   8106 #define TAPE_PSEUDO_LOGICAL_BLOCK __MSABI_LONG(3)
   8107 #define TAPE_SPACE_END_OF_DATA __MSABI_LONG(4)
   8108 #define TAPE_SPACE_RELATIVE_BLOCKS __MSABI_LONG(5)
   8109 #define TAPE_SPACE_FILEMARKS __MSABI_LONG(6)
   8110 #define TAPE_SPACE_SEQUENTIAL_FMKS __MSABI_LONG(7)
   8111 #define TAPE_SPACE_SETMARKS __MSABI_LONG(8)
   8112 #define TAPE_SPACE_SEQUENTIAL_SMKS __MSABI_LONG(9)
   8113 
   8114     typedef struct _TAPE_SET_POSITION {
   8115       DWORD Method;
   8116       DWORD Partition;
   8117       LARGE_INTEGER Offset;
   8118       BOOLEAN Immediate;
   8119     } TAPE_SET_POSITION,*PTAPE_SET_POSITION;
   8120 
   8121 #define TAPE_DRIVE_FIXED 0x00000001
   8122 #define TAPE_DRIVE_SELECT 0x00000002
   8123 #define TAPE_DRIVE_INITIATOR 0x00000004
   8124 
   8125 #define TAPE_DRIVE_ERASE_SHORT 0x00000010
   8126 #define TAPE_DRIVE_ERASE_LONG 0x00000020
   8127 #define TAPE_DRIVE_ERASE_BOP_ONLY 0x00000040
   8128 #define TAPE_DRIVE_ERASE_IMMEDIATE 0x00000080
   8129 #define TAPE_DRIVE_TAPE_CAPACITY 0x00000100
   8130 #define TAPE_DRIVE_TAPE_REMAINING 0x00000200
   8131 #define TAPE_DRIVE_FIXED_BLOCK 0x00000400
   8132 #define TAPE_DRIVE_VARIABLE_BLOCK 0x00000800
   8133 #define TAPE_DRIVE_WRITE_PROTECT 0x00001000
   8134 #define TAPE_DRIVE_EOT_WZ_SIZE 0x00002000
   8135 #define TAPE_DRIVE_ECC 0x00010000
   8136 #define TAPE_DRIVE_COMPRESSION 0x00020000
   8137 #define TAPE_DRIVE_PADDING 0x00040000
   8138 #define TAPE_DRIVE_REPORT_SMKS 0x00080000
   8139 #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000
   8140 #define TAPE_DRIVE_GET_LOGICAL_BLK 0x00200000
   8141 #define TAPE_DRIVE_SET_EOT_WZ_SIZE 0x00400000
   8142 #define TAPE_DRIVE_EJECT_MEDIA 0x01000000
   8143 #define TAPE_DRIVE_CLEAN_REQUESTS 0x02000000
   8144 #define TAPE_DRIVE_SET_CMP_BOP_ONLY 0x04000000
   8145 
   8146 #define TAPE_DRIVE_RESERVED_BIT 0x80000000
   8147 
   8148 #define TAPE_DRIVE_LOAD_UNLOAD 0x80000001
   8149 #define TAPE_DRIVE_TENSION 0x80000002
   8150 #define TAPE_DRIVE_LOCK_UNLOCK 0x80000004
   8151 #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
   8152 #define TAPE_DRIVE_SET_BLOCK_SIZE 0x80000010
   8153 
   8154 #define TAPE_DRIVE_LOAD_UNLD_IMMED 0x80000020
   8155 #define TAPE_DRIVE_TENSION_IMMED 0x80000040
   8156 #define TAPE_DRIVE_LOCK_UNLK_IMMED 0x80000080
   8157 
   8158 #define TAPE_DRIVE_SET_ECC 0x80000100
   8159 #define TAPE_DRIVE_SET_COMPRESSION 0x80000200
   8160 #define TAPE_DRIVE_SET_PADDING 0x80000400
   8161 #define TAPE_DRIVE_SET_REPORT_SMKS 0x80000800
   8162 
   8163 #define TAPE_DRIVE_ABSOLUTE_BLK 0x80001000
   8164 #define TAPE_DRIVE_ABS_BLK_IMMED 0x80002000
   8165 #define TAPE_DRIVE_LOGICAL_BLK 0x80004000
   8166 #define TAPE_DRIVE_LOG_BLK_IMMED 0x80008000
   8167 
   8168 #define TAPE_DRIVE_END_OF_DATA 0x80010000
   8169 #define TAPE_DRIVE_RELATIVE_BLKS 0x80020000
   8170 #define TAPE_DRIVE_FILEMARKS 0x80040000
   8171 #define TAPE_DRIVE_SEQUENTIAL_FMKS 0x80080000
   8172 
   8173 #define TAPE_DRIVE_SETMARKS 0x80100000
   8174 #define TAPE_DRIVE_SEQUENTIAL_SMKS 0x80200000
   8175 #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
   8176 #define TAPE_DRIVE_SPACE_IMMEDIATE 0x80800000
   8177 
   8178 #define TAPE_DRIVE_WRITE_SETMARKS 0x81000000
   8179 #define TAPE_DRIVE_WRITE_FILEMARKS 0x82000000
   8180 #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
   8181 #define TAPE_DRIVE_WRITE_LONG_FMKS 0x88000000
   8182 
   8183 #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
   8184 #define TAPE_DRIVE_FORMAT 0xA0000000
   8185 #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
   8186 #define TAPE_DRIVE_HIGH_FEATURES 0x80000000
   8187 
   8188     typedef struct _TAPE_GET_DRIVE_PARAMETERS {
   8189       BOOLEAN ECC;
   8190       BOOLEAN Compression;
   8191       BOOLEAN DataPadding;
   8192       BOOLEAN ReportSetmarks;
   8193       DWORD DefaultBlockSize;
   8194       DWORD MaximumBlockSize;
   8195       DWORD MinimumBlockSize;
   8196       DWORD MaximumPartitionCount;
   8197       DWORD FeaturesLow;
   8198       DWORD FeaturesHigh;
   8199       DWORD EOTWarningZoneSize;
   8200     } TAPE_GET_DRIVE_PARAMETERS,*PTAPE_GET_DRIVE_PARAMETERS;
   8201 
   8202     typedef struct _TAPE_SET_DRIVE_PARAMETERS {
   8203       BOOLEAN ECC;
   8204       BOOLEAN Compression;
   8205       BOOLEAN DataPadding;
   8206       BOOLEAN ReportSetmarks;
   8207       DWORD EOTWarningZoneSize;
   8208     } TAPE_SET_DRIVE_PARAMETERS,*PTAPE_SET_DRIVE_PARAMETERS;
   8209 
   8210     typedef struct _TAPE_GET_MEDIA_PARAMETERS {
   8211       LARGE_INTEGER Capacity;
   8212       LARGE_INTEGER Remaining;
   8213       DWORD BlockSize;
   8214       DWORD PartitionCount;
   8215       BOOLEAN WriteProtected;
   8216     } TAPE_GET_MEDIA_PARAMETERS,*PTAPE_GET_MEDIA_PARAMETERS;
   8217 
   8218     typedef struct _TAPE_SET_MEDIA_PARAMETERS {
   8219       DWORD BlockSize;
   8220     } TAPE_SET_MEDIA_PARAMETERS,*PTAPE_SET_MEDIA_PARAMETERS;
   8221 
   8222 #define TAPE_FIXED_PARTITIONS __MSABI_LONG(0)
   8223 #define TAPE_SELECT_PARTITIONS __MSABI_LONG(1)
   8224 #define TAPE_INITIATOR_PARTITIONS __MSABI_LONG(2)
   8225 
   8226     typedef struct _TAPE_CREATE_PARTITION {
   8227       DWORD Method;
   8228       DWORD Count;
   8229       DWORD Size;
   8230     } TAPE_CREATE_PARTITION,*PTAPE_CREATE_PARTITION;
   8231 
   8232 #define TAPE_QUERY_DRIVE_PARAMETERS __MSABI_LONG(0)
   8233 #define TAPE_QUERY_MEDIA_CAPACITY __MSABI_LONG(1)
   8234 #define TAPE_CHECK_FOR_DRIVE_PROBLEM __MSABI_LONG(2)
   8235 #define TAPE_QUERY_IO_ERROR_DATA __MSABI_LONG(3)
   8236 #define TAPE_QUERY_DEVICE_ERROR_DATA __MSABI_LONG(4)
   8237 
   8238     typedef struct _TAPE_WMI_OPERATIONS {
   8239       DWORD Method;
   8240       DWORD DataBufferSize;
   8241       PVOID DataBuffer;
   8242     } TAPE_WMI_OPERATIONS,*PTAPE_WMI_OPERATIONS;
   8243 
   8244     typedef enum _TAPE_DRIVE_PROBLEM_TYPE {
   8245       TapeDriveProblemNone,TapeDriveReadWriteWarning,TapeDriveReadWriteError,TapeDriveReadWarning,TapeDriveWriteWarning,TapeDriveReadError,TapeDriveWriteError,TapeDriveHardwareError,TapeDriveUnsupportedMedia,TapeDriveScsiConnectionError,TapeDriveTimetoClean,TapeDriveCleanDriveNow,TapeDriveMediaLifeExpired,TapeDriveSnappedTape
   8246     } TAPE_DRIVE_PROBLEM_TYPE;
   8247 #endif
   8248 
   8249   typedef DWORD TP_VERSION,*PTP_VERSION;
   8250   typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
   8251   typedef VOID (NTAPI *PTP_SIMPLE_CALLBACK) (PTP_CALLBACK_INSTANCE Instance, PVOID Context);
   8252   typedef struct _TP_POOL TP_POOL,*PTP_POOL;
   8253 
   8254   typedef enum _TP_CALLBACK_PRIORITY {
   8255     TP_CALLBACK_PRIORITY_HIGH,
   8256     TP_CALLBACK_PRIORITY_NORMAL,
   8257     TP_CALLBACK_PRIORITY_LOW,
   8258     TP_CALLBACK_PRIORITY_INVALID,
   8259     TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
   8260   } TP_CALLBACK_PRIORITY;
   8261 
   8262   typedef struct _TP_POOL_STACK_INFORMATION {
   8263     SIZE_T StackReserve;
   8264     SIZE_T StackCommit;
   8265   } TP_POOL_STACK_INFORMATION, *PTP_POOL_STACK_INFORMATION;
   8266 
   8267   typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
   8268   typedef VOID (NTAPI *PTP_CLEANUP_GROUP_CANCEL_CALLBACK) (PVOID ObjectContext, PVOID CleanupContext);
   8269 
   8270 #if _WIN32_WINNT >= 0x0601
   8271   typedef struct _TP_CALLBACK_ENVIRON_V3 {
   8272     TP_VERSION Version;
   8273     PTP_POOL Pool;
   8274     PTP_CLEANUP_GROUP CleanupGroup;
   8275     PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
   8276     PVOID RaceDll;
   8277     struct _ACTIVATION_CONTEXT *ActivationContext;
   8278     PTP_SIMPLE_CALLBACK FinalizationCallback;
   8279     union {
   8280       DWORD Flags;
   8281       struct {
   8282         DWORD LongFunction : 1;
   8283         DWORD Persistent : 1;
   8284         DWORD Private : 30;
   8285       } s;
   8286     } u;
   8287     TP_CALLBACK_PRIORITY CallbackPriority;
   8288     DWORD Size;
   8289   } TP_CALLBACK_ENVIRON_V3;
   8290   typedef TP_CALLBACK_ENVIRON_V3 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
   8291 #else
   8292   typedef struct _TP_CALLBACK_ENVIRON_V1 {
   8293     TP_VERSION Version;
   8294     PTP_POOL Pool;
   8295     PTP_CLEANUP_GROUP CleanupGroup;
   8296     PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
   8297     PVOID RaceDll;
   8298     struct _ACTIVATION_CONTEXT *ActivationContext;
   8299     PTP_SIMPLE_CALLBACK FinalizationCallback;
   8300     union {
   8301       DWORD Flags;
   8302       struct {
   8303 	DWORD LongFunction : 1;
   8304 	DWORD Persistent : 1;
   8305 	DWORD Private : 30;
   8306       } s;
   8307     } u;
   8308   } TP_CALLBACK_ENVIRON_V1;
   8309   typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON,*PTP_CALLBACK_ENVIRON;
   8310 #endif
   8311 
   8312   typedef struct _TP_WORK TP_WORK,*PTP_WORK;
   8313   typedef VOID (NTAPI *PTP_WORK_CALLBACK) (PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work);
   8314   typedef struct _TP_TIMER TP_TIMER,*PTP_TIMER;
   8315   typedef VOID (NTAPI *PTP_TIMER_CALLBACK) (PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_TIMER Timer);
   8316   typedef DWORD TP_WAIT_RESULT;
   8317   typedef struct _TP_WAIT TP_WAIT,*PTP_WAIT;
   8318   typedef VOID (NTAPI *PTP_WAIT_CALLBACK) (PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WAIT Wait, TP_WAIT_RESULT WaitResult);
   8319   typedef struct _TP_IO TP_IO,*PTP_IO;
   8320 
   8321 #if !defined (__WIDL__)
   8322     FORCEINLINE VOID TpInitializeCallbackEnviron (PTP_CALLBACK_ENVIRON cbe) {
   8323       cbe->Pool = NULL;
   8324       cbe->CleanupGroup = NULL;
   8325       cbe->CleanupGroupCancelCallback = NULL;
   8326       cbe->RaceDll = NULL;
   8327       cbe->ActivationContext = NULL;
   8328       cbe->FinalizationCallback = NULL;
   8329       cbe->u.Flags = 0;
   8330 #if _WIN32_WINNT < 0x0601
   8331       cbe->Version = 1;
   8332 #else
   8333       cbe->Version = 3;
   8334       cbe->CallbackPriority = TP_CALLBACK_PRIORITY_NORMAL;
   8335       cbe->Size = sizeof (TP_CALLBACK_ENVIRON);
   8336 #endif
   8337     }
   8338     FORCEINLINE VOID TpSetCallbackThreadpool (PTP_CALLBACK_ENVIRON cbe, PTP_POOL pool) { cbe->Pool = pool; }
   8339     FORCEINLINE VOID TpSetCallbackCleanupGroup (PTP_CALLBACK_ENVIRON cbe, PTP_CLEANUP_GROUP cleanup_group, PTP_CLEANUP_GROUP_CANCEL_CALLBACK cleanup_group_cb) {
   8340       cbe->CleanupGroup = cleanup_group;
   8341       cbe->CleanupGroupCancelCallback = cleanup_group_cb;
   8342     }
   8343     FORCEINLINE VOID TpSetCallbackActivationContext (PTP_CALLBACK_ENVIRON cbe, struct _ACTIVATION_CONTEXT *actx) { cbe->ActivationContext = actx; }
   8344     FORCEINLINE VOID TpSetCallbackNoActivationContext (PTP_CALLBACK_ENVIRON cbe) { cbe->ActivationContext = (struct _ACTIVATION_CONTEXT *) (LONG_PTR) -1; }
   8345     FORCEINLINE VOID TpSetCallbackLongFunction (PTP_CALLBACK_ENVIRON cbe) { cbe->u.s.LongFunction = 1; }
   8346     FORCEINLINE VOID TpSetCallbackRaceWithDll (PTP_CALLBACK_ENVIRON cbe, PVOID h) { cbe->RaceDll = h; }
   8347     FORCEINLINE VOID TpSetCallbackFinalizationCallback (PTP_CALLBACK_ENVIRON cbe, PTP_SIMPLE_CALLBACK fini_cb) { cbe->FinalizationCallback = fini_cb; }
   8348 #if _WIN32_WINNT >= 0x0601
   8349     FORCEINLINE VOID TpSetCallbackPriority (PTP_CALLBACK_ENVIRON cbe, TP_CALLBACK_PRIORITY prio) { cbe->CallbackPriority = prio; }
   8350 #endif
   8351     FORCEINLINE VOID TpSetCallbackPersistent (PTP_CALLBACK_ENVIRON cbe) { cbe->u.s.Persistent = 1; }
   8352     FORCEINLINE VOID TpDestroyCallbackEnviron (PTP_CALLBACK_ENVIRON cbe) { UNREFERENCED_PARAMETER (cbe); }
   8353 #endif
   8354 
   8355 #if defined(__x86_64) && !defined (__WIDL__)
   8356     struct _TEB *NtCurrentTeb(VOID);
   8357     PVOID GetCurrentFiber(VOID);
   8358     PVOID GetFiberData(VOID);
   8359     FORCEINLINE struct _TEB *NtCurrentTeb(VOID) { return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB,Self)); }
   8360     FORCEINLINE PVOID GetCurrentFiber(VOID) { return(PVOID)__readgsqword(FIELD_OFFSET(NT_TIB,FiberData)); }
   8361     FORCEINLINE PVOID GetFiberData(VOID) {
   8362       return *(PVOID *)GetCurrentFiber();
   8363     }
   8364 #endif /* __x86_64 */
   8365 
   8366 #if defined (__arm__) && !defined (__WIDL__)
   8367     struct _TEB *NtCurrentTeb (VOID);
   8368     PVOID GetCurrentFiber (VOID);
   8369     PVOID GetFiberData (VOID);
   8370     FORCEINLINE struct _TEB *NtCurrentTeb(VOID) { struct _TEB *teb;
   8371     __asm ("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb));
   8372     return teb; }
   8373     FORCEINLINE PVOID GetCurrentFiber(VOID) { return (PVOID)(((PNT_TIB)NtCurrentTeb())->FiberData); }
   8374     FORCEINLINE PVOID GetFiberData (VOID) { return *(PVOID *)GetCurrentFiber (); }
   8375 #endif /* arm */
   8376 
   8377 #ifndef _NTTMAPI_
   8378 #define _NTTMAPI_
   8379 
   8380 #ifdef __cplusplus
   8381     extern "C" {
   8382 #endif
   8383 
   8384 #include <ktmtypes.h>
   8385 
   8386 #define TRANSACTIONMANAGER_QUERY_INFORMATION 0x00001
   8387 #define TRANSACTIONMANAGER_SET_INFORMATION 0x00002
   8388 #define TRANSACTIONMANAGER_RECOVER 0x00004
   8389 #define TRANSACTIONMANAGER_RENAME 0x00008
   8390 #define TRANSACTIONMANAGER_CREATE_RM 0x00010
   8391 #define TRANSACTIONMANAGER_BIND_TRANSACTION 0x00020
   8392 
   8393 #define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ | TRANSACTIONMANAGER_QUERY_INFORMATION)
   8394 #define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | TRANSACTIONMANAGER_SET_INFORMATION | TRANSACTIONMANAGER_RECOVER | TRANSACTIONMANAGER_RENAME | TRANSACTIONMANAGER_CREATE_RM)
   8395 #define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE)
   8396 #define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | TRANSACTIONMANAGER_GENERIC_READ | TRANSACTIONMANAGER_GENERIC_WRITE | TRANSACTIONMANAGER_GENERIC_EXECUTE | TRANSACTIONMANAGER_BIND_TRANSACTION)
   8397 
   8398 #define TRANSACTION_QUERY_INFORMATION (0x0001)
   8399 #define TRANSACTION_SET_INFORMATION (0x0002)
   8400 #define TRANSACTION_ENLIST (0x0004)
   8401 #define TRANSACTION_COMMIT (0x0008)
   8402 #define TRANSACTION_ROLLBACK (0x0010)
   8403 #define TRANSACTION_PROPAGATE (0x0020)
   8404 #define TRANSACTION_RIGHT_RESERVED1 (0x0040)
   8405 
   8406 #define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ | TRANSACTION_QUERY_INFORMATION | SYNCHRONIZE)
   8407 #define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | TRANSACTION_SET_INFORMATION | TRANSACTION_COMMIT | TRANSACTION_ENLIST | TRANSACTION_ROLLBACK | TRANSACTION_PROPAGATE | SYNCHRONIZE)
   8408 #define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | TRANSACTION_COMMIT | TRANSACTION_ROLLBACK | SYNCHRONIZE)
   8409 #define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | TRANSACTION_GENERIC_READ | TRANSACTION_GENERIC_WRITE | TRANSACTION_GENERIC_EXECUTE)
   8410 #define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ | STANDARD_RIGHTS_WRITE | TRANSACTION_SET_INFORMATION | TRANSACTION_ENLIST | TRANSACTION_ROLLBACK | TRANSACTION_PROPAGATE | SYNCHRONIZE)
   8411 
   8412 #define RESOURCEMANAGER_QUERY_INFORMATION (0x0001)
   8413 #define RESOURCEMANAGER_SET_INFORMATION (0x0002)
   8414 #define RESOURCEMANAGER_RECOVER (0x0004)
   8415 #define RESOURCEMANAGER_ENLIST (0x0008)
   8416 #define RESOURCEMANAGER_GET_NOTIFICATION (0x0010)
   8417 #define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020)
   8418 #define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040)
   8419 
   8420 #define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ | RESOURCEMANAGER_QUERY_INFORMATION | SYNCHRONIZE)
   8421 #define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | RESOURCEMANAGER_SET_INFORMATION | RESOURCEMANAGER_RECOVER | RESOURCEMANAGER_ENLIST | RESOURCEMANAGER_GET_NOTIFICATION | RESOURCEMANAGER_REGISTER_PROTOCOL | RESOURCEMANAGER_COMPLETE_PROPAGATION | SYNCHRONIZE)
   8422 #define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | RESOURCEMANAGER_RECOVER | RESOURCEMANAGER_ENLIST | RESOURCEMANAGER_GET_NOTIFICATION | RESOURCEMANAGER_COMPLETE_PROPAGATION | SYNCHRONIZE)
   8423 #define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | RESOURCEMANAGER_GENERIC_READ | RESOURCEMANAGER_GENERIC_WRITE | RESOURCEMANAGER_GENERIC_EXECUTE)
   8424 
   8425 #define ENLISTMENT_QUERY_INFORMATION 1
   8426 #define ENLISTMENT_SET_INFORMATION 2
   8427 #define ENLISTMENT_RECOVER 4
   8428 #define ENLISTMENT_SUBORDINATE_RIGHTS 8
   8429 #define ENLISTMENT_SUPERIOR_RIGHTS 0x10
   8430 
   8431 #define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ | ENLISTMENT_QUERY_INFORMATION)
   8432 #define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | ENLISTMENT_SET_INFORMATION | ENLISTMENT_RECOVER | ENLISTMENT_SUBORDINATE_RIGHTS | ENLISTMENT_SUPERIOR_RIGHTS)
   8433 #define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | ENLISTMENT_RECOVER | ENLISTMENT_SUBORDINATE_RIGHTS | ENLISTMENT_SUPERIOR_RIGHTS)
   8434 #define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | ENLISTMENT_GENERIC_READ | ENLISTMENT_GENERIC_WRITE | ENLISTMENT_GENERIC_EXECUTE)
   8435 
   8436       typedef enum _TRANSACTION_OUTCOME {
   8437 	TransactionOutcomeUndetermined = 1,
   8438 	TransactionOutcomeCommitted,
   8439 	TransactionOutcomeAborted,
   8440       } TRANSACTION_OUTCOME;
   8441 
   8442       typedef enum _TRANSACTION_STATE {
   8443 	TransactionStateNormal = 1,
   8444 	TransactionStateIndoubt,
   8445 	TransactionStateCommittedNotify,
   8446       } TRANSACTION_STATE;
   8447 
   8448       typedef struct _TRANSACTION_BASIC_INFORMATION {
   8449 	GUID TransactionId;
   8450 	DWORD State;
   8451 	DWORD Outcome;
   8452       } TRANSACTION_BASIC_INFORMATION,*PTRANSACTION_BASIC_INFORMATION;
   8453 
   8454       typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION {
   8455 	GUID TmIdentity;
   8456 	LARGE_INTEGER VirtualClock;
   8457       } TRANSACTIONMANAGER_BASIC_INFORMATION,*PTRANSACTIONMANAGER_BASIC_INFORMATION;
   8458 
   8459       typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION {
   8460 	GUID LogIdentity;
   8461       } TRANSACTIONMANAGER_LOG_INFORMATION,*PTRANSACTIONMANAGER_LOG_INFORMATION;
   8462 
   8463       typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION {
   8464 	DWORD LogPathLength;
   8465 	WCHAR LogPath[1];
   8466       } TRANSACTIONMANAGER_LOGPATH_INFORMATION,*PTRANSACTIONMANAGER_LOGPATH_INFORMATION;
   8467 
   8468       typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION {
   8469 	ULONGLONG LastRecoveredLsn;
   8470       } TRANSACTIONMANAGER_RECOVERY_INFORMATION,*PTRANSACTIONMANAGER_RECOVERY_INFORMATION;
   8471 
   8472       typedef struct _TRANSACTIONMANAGER_OLDEST_INFORMATION {
   8473 	GUID OldestTransactionGuid;
   8474       } TRANSACTIONMANAGER_OLDEST_INFORMATION,*PTRANSACTIONMANAGER_OLDEST_INFORMATION;
   8475 
   8476       typedef struct _TRANSACTION_PROPERTIES_INFORMATION {
   8477 	DWORD IsolationLevel;
   8478 	DWORD IsolationFlags;
   8479 	LARGE_INTEGER Timeout;
   8480 	DWORD Outcome;
   8481 	DWORD DescriptionLength;
   8482 	WCHAR Description[1];
   8483       } TRANSACTION_PROPERTIES_INFORMATION,*PTRANSACTION_PROPERTIES_INFORMATION;
   8484 
   8485       typedef struct _TRANSACTION_BIND_INFORMATION {
   8486 	HANDLE TmHandle;
   8487       } TRANSACTION_BIND_INFORMATION,*PTRANSACTION_BIND_INFORMATION;
   8488 
   8489       typedef struct _TRANSACTION_ENLISTMENT_PAIR {
   8490 	GUID EnlistmentId;
   8491 	GUID ResourceManagerId;
   8492       } TRANSACTION_ENLISTMENT_PAIR,*PTRANSACTION_ENLISTMENT_PAIR;
   8493 
   8494       typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION {
   8495 	DWORD NumberOfEnlistments;
   8496 	TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1];
   8497       } TRANSACTION_ENLISTMENTS_INFORMATION,*PTRANSACTION_ENLISTMENTS_INFORMATION;
   8498 
   8499       typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION {
   8500 	TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair;
   8501       } TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION,*PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION;
   8502 
   8503       typedef struct _RESOURCEMANAGER_BASIC_INFORMATION {
   8504 	GUID ResourceManagerId;
   8505 	DWORD DescriptionLength;
   8506 	WCHAR Description[1];
   8507       } RESOURCEMANAGER_BASIC_INFORMATION,*PRESOURCEMANAGER_BASIC_INFORMATION;
   8508 
   8509       typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION {
   8510 	HANDLE IoCompletionPortHandle;
   8511 	ULONG_PTR CompletionKey;
   8512       } RESOURCEMANAGER_COMPLETION_INFORMATION,*PRESOURCEMANAGER_COMPLETION_INFORMATION;
   8513 
   8514       typedef enum _TRANSACTION_INFORMATION_CLASS {
   8515 	TransactionBasicInformation,
   8516 	TransactionPropertiesInformation,
   8517 	TransactionEnlistmentInformation,
   8518 	TransactionSuperiorEnlistmentInformation,
   8519 	TransactionBindInformation,
   8520 	TransactionDTCPrivateInformation
   8521       } TRANSACTION_INFORMATION_CLASS;
   8522 
   8523       typedef enum _TRANSACTIONMANAGER_INFORMATION_CLASS {
   8524 	TransactionManagerBasicInformation,
   8525 	TransactionManagerLogInformation,
   8526 	TransactionManagerLogPathInformation,
   8527 	TransactionManagerOnlineProbeInformation = 3,
   8528 	TransactionManagerRecoveryInformation = 4,
   8529 	TransactionManagerOldestTransactionInformation = 5
   8530       } TRANSACTIONMANAGER_INFORMATION_CLASS;
   8531 
   8532       typedef enum _RESOURCEMANAGER_INFORMATION_CLASS {
   8533 	ResourceManagerBasicInformation,
   8534 	ResourceManagerCompletionInformation
   8535       } RESOURCEMANAGER_INFORMATION_CLASS;
   8536 
   8537       typedef struct _ENLISTMENT_BASIC_INFORMATION {
   8538 	GUID EnlistmentId;
   8539 	GUID TransactionId;
   8540 	GUID ResourceManagerId;
   8541       } ENLISTMENT_BASIC_INFORMATION,*PENLISTMENT_BASIC_INFORMATION;
   8542 
   8543       typedef struct _ENLISTMENT_CRM_INFORMATION {
   8544 	GUID CrmTransactionManagerId;
   8545 	GUID CrmResourceManagerId;
   8546 	GUID CrmEnlistmentId;
   8547       } ENLISTMENT_CRM_INFORMATION,*PENLISTMENT_CRM_INFORMATION;
   8548 
   8549       typedef enum _ENLISTMENT_INFORMATION_CLASS {
   8550 	EnlistmentBasicInformation,
   8551 	EnlistmentRecoveryInformation,
   8552 	EnlistmentCrmInformation
   8553       } ENLISTMENT_INFORMATION_CLASS;
   8554 
   8555       typedef struct _TRANSACTION_LIST_ENTRY {
   8556 	/*UOW*/ GUID UOW;
   8557       } TRANSACTION_LIST_ENTRY,*PTRANSACTION_LIST_ENTRY;
   8558 
   8559       typedef struct _TRANSACTION_LIST_INFORMATION {
   8560 	DWORD NumberOfTransactions;
   8561 	TRANSACTION_LIST_ENTRY TransactionInformation[1];
   8562       } TRANSACTION_LIST_INFORMATION,*PTRANSACTION_LIST_INFORMATION;
   8563 
   8564       typedef enum _KTMOBJECT_TYPE {
   8565 	KTMOBJECT_TRANSACTION,
   8566 	KTMOBJECT_TRANSACTION_MANAGER,
   8567 	KTMOBJECT_RESOURCE_MANAGER,
   8568 	KTMOBJECT_ENLISTMENT,
   8569 	KTMOBJECT_INVALID
   8570       } KTMOBJECT_TYPE,*PKTMOBJECT_TYPE;
   8571 
   8572       typedef struct _KTMOBJECT_CURSOR {
   8573 	GUID LastQuery;
   8574 	DWORD ObjectIdCount;
   8575 	GUID ObjectIds[1];
   8576       } KTMOBJECT_CURSOR,*PKTMOBJECT_CURSOR;
   8577 
   8578 #ifdef __cplusplus
   8579     }
   8580 #endif
   8581 
   8582 #endif
   8583 
   8584 /* Field Names From (See _fields_ section)
   8585  * FIXME: Verify these against documentation
   8586  * -- These documentation describes Win32 Constants and Structures in Python --
   8587  * Constants - http://packages.python.org/winappdbg/winappdbg.win32.context_i386-pysrc.html
   8588  * WOW64_FLOATING_SAVE_AREA - http://packages.python.org/winappdbg/winappdbg.win32.context_amd64.WOW64_FLOATING_SAVE_AREA-class.html
   8589  * WOW64_CONTEXT - http://packages.python.org/winappdbg/winappdbg.win32.context_amd64.WOW64_CONTEXT-class.html
   8590  */
   8591 
   8592 #define WOW64_CONTEXT_i386 0x00010000
   8593 #define WOW64_CONTEXT_i486 0x00010000
   8594 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
   8595 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
   8596 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
   8597 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
   8598 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
   8599 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
   8600 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
   8601 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
   8602 
   8603 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
   8604 
   8605 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
   8606 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
   8607 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
   8608 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
   8609 
   8610 #define WOW64_SIZE_OF_80387_REGISTERS 80
   8611 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
   8612 
   8613 typedef struct _WOW64_FLOATING_SAVE_AREA {
   8614   DWORD   ControlWord;
   8615   DWORD   StatusWord;
   8616   DWORD   TagWord;
   8617   DWORD   ErrorOffset;
   8618   DWORD   ErrorSelector;
   8619   DWORD   DataOffset;
   8620   DWORD   DataSelector;
   8621   BYTE    RegisterArea[WOW64_SIZE_OF_80387_REGISTERS];
   8622   DWORD   Cr0NpxState;
   8623 } WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
   8624 
   8625 #include "pshpack4.h"
   8626 typedef struct _WOW64_CONTEXT {
   8627   DWORD ContextFlags;
   8628   DWORD Dr0;
   8629   DWORD Dr1;
   8630   DWORD Dr2;
   8631   DWORD Dr3;
   8632   DWORD Dr6;
   8633   DWORD Dr7;
   8634   WOW64_FLOATING_SAVE_AREA FloatSave;
   8635   DWORD SegGs;
   8636   DWORD SegFs;
   8637   DWORD SegEs;
   8638   DWORD SegDs;
   8639   DWORD Edi;
   8640   DWORD Esi;
   8641   DWORD Ebx;
   8642   DWORD Edx;
   8643   DWORD Ecx;
   8644   DWORD Eax;
   8645   DWORD Ebp;
   8646   DWORD Eip;
   8647   DWORD SegCs;
   8648   DWORD EFlags;
   8649   DWORD Esp;
   8650   DWORD SegSs;
   8651   BYTE ExtendedRegisters[WOW64_MAXIMUM_SUPPORTED_EXTENSION];
   8652 } WOW64_CONTEXT, *PWOW64_CONTEXT;
   8653 #include "poppack.h"
   8654 
   8655 typedef struct _WOW64_LDT_ENTRY {
   8656   WORD  LimitLow;
   8657   WORD  BaseLow;
   8658   __C89_NAMELESS union {
   8659     struct {
   8660       BYTE BaseMid;
   8661       BYTE Flags1;
   8662       BYTE Flags2;
   8663       BYTE BaseHi;
   8664     } Bytes;
   8665     struct {
   8666       DWORD BaseMid  :8;
   8667       DWORD Type  :5;
   8668       DWORD Dpl  :2;
   8669       DWORD Pres  :1;
   8670       DWORD LimitHi  :4;
   8671       DWORD Sys  :1;
   8672       DWORD Reserved_0  :1;
   8673       DWORD Default_Big  :1;
   8674       DWORD Granularity  :1;
   8675       DWORD BaseHi  :8;
   8676     } Bits;
   8677   } HighWord;
   8678 } WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
   8679 
   8680     typedef struct _WOW64_DESCRIPTOR_TABLE_ENTRY {
   8681       DWORD Selector;
   8682       WOW64_LDT_ENTRY Descriptor;
   8683     } WOW64_DESCRIPTOR_TABLE_ENTRY,*PWOW64_DESCRIPTOR_TABLE_ENTRY;
   8684 
   8685 #if (_WIN32_WINNT >= 0x0601)
   8686 
   8687 #ifndef ___PROCESSOR_NUMBER_DEFINED
   8688 #define ___PROCESSOR_NUMBER_DEFINED
   8689 typedef struct _PROCESSOR_NUMBER {
   8690   WORD Group;
   8691   BYTE Number;
   8692   BYTE Reserved;
   8693 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
   8694 
   8695 #define ALL_PROCESSOR_GROUPS 0xffff
   8696 #endif /* !___PROCESSOR_NUMBER_DEFINED */
   8697 
   8698 #endif /*(_WIN32_WINNT >= 0x0601)*/
   8699 
   8700 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION (1)
   8701 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION (2)
   8702 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION (3)
   8703 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION (4)
   8704 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION (5)
   8705 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION (6)
   8706 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION (7)
   8707 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE (8)
   8708 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES (9)
   8709 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS (10)
   8710 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO (11)
   8711 
   8712 #ifdef __cplusplus
   8713 }
   8714 #endif
   8715 
   8716 #endif /* _WINNT_ */
   8717 
   8718