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