Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      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 #define ANYSIZE_ARRAY 1
     19 
     20 #include <specstrings.h>
     21 
     22 #if defined(__x86_64) && \
     23   !(defined(_X86_) || defined(__i386__) || defined(_IA64_))
     24 #if !defined(_AMD64_)
     25 #define _AMD64_
     26 #endif
     27 #endif /* _AMD64_ */
     28 
     29 #if defined(__ia64__) && \
     30   !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_))
     31 #if !defined(_IA64_)
     32 #define _IA64_
     33 #endif
     34 #endif /* _IA64_ */
     35 
     36 #include <sdkddkver.h>
     37 
     38 #define RESTRICTED_POINTER
     39 
     40 #undef  UNALIGNED	/* avoid redefinition warnings vs _mingw.h */
     41 #undef  UNALIGNED64
     42 #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
     43 #define ALIGNMENT_MACHINE
     44 #define UNALIGNED __unaligned
     45 #if defined(_WIN64)
     46 #define UNALIGNED64 __unaligned
     47 #else
     48 #define UNALIGNED64
     49 #endif
     50 #else
     51 #undef ALIGNMENT_MACHINE
     52 #define UNALIGNED
     53 #define UNALIGNED64
     54 #endif
     55 
     56 #ifdef _WIN64
     57 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
     58 #define MEMORY_ALLOCATION_ALIGNMENT 16
     59 #else
     60 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
     61 #define MEMORY_ALLOCATION_ALIGNMENT 8
     62 #endif
     63 
     64 #ifdef __cplusplus
     65 #define TYPE_ALIGNMENT(t) __alignof__ (t)
     66 #else
     67 #define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
     68 #endif
     69 
     70 #ifdef _WIN64
     71 #ifdef _AMD64_
     72 #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
     73 #elif defined(_IA64_)
     74 #define PROBE_ALIGNMENT(_s) (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
     75 #else
     76 #error No Target Architecture
     77 #endif
     78 #define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
     79 #else
     80 #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
     81 #endif
     82 
     83 #if defined(_MSC_VER)
     84 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
     85 #else
     86 # define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
     87 #endif
     88 
     89 #include <basetsd.h>
     90 
     91 #ifndef DECLSPEC_IMPORT
     92 #if defined(_X86_) || defined(__ia64__) || defined(__x86_64)
     93 #define DECLSPEC_IMPORT __declspec(dllimport)
     94 #else
     95 #define DECLSPEC_IMPORT
     96 #endif
     97 #endif
     98 
     99 #ifndef DECLSPEC_NORETURN
    100 #define DECLSPEC_NORETURN __declspec(noreturn)
    101 #endif
    102 
    103 #ifndef DECLSPEC_ALIGN
    104 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
    105 #define DECLSPEC_ALIGN(x) __declspec(align(x))
    106 #elif defined(__GNUC__)
    107 #define DECLSPEC_ALIGN(x) __attribute__ ((__aligned__ (x)))
    108 #else
    109 #define DECLSPEC_ALIGN(x)
    110 #endif
    111 #endif /* DECLSPEC_ALIGN */
    112 
    113 #ifndef SYSTEM_CACHE_ALIGNMENT_SIZE
    114 #if defined(_AMD64_) || defined(_X86_)
    115 #define SYSTEM_CACHE_ALIGNMENT_SIZE 64
    116 #else
    117 #define SYSTEM_CACHE_ALIGNMENT_SIZE 128
    118 #endif
    119 #endif
    120 
    121 #ifndef DECLSPEC_CACHEALIGN
    122 #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(SYSTEM_CACHE_ALIGNMENT_SIZE)
    123 #endif
    124 
    125 #ifndef DECLSPEC_UUID
    126 #define DECLSPEC_UUID(x)
    127 #endif
    128 
    129 #ifndef DECLSPEC_NOVTABLE
    130 #define DECLSPEC_NOVTABLE
    131 #endif
    132 
    133 #ifndef DECLSPEC_SELECTANY
    134 #define DECLSPEC_SELECTANY __declspec(selectany)
    135 #endif
    136 
    137 #ifndef NOP_FUNCTION
    138 #if (_MSC_VER >= 1210)
    139 #define NOP_FUNCTION __noop
    140 #else
    141 #define NOP_FUNCTION (void)0
    142 #endif
    143 #endif
    144 
    145 #ifndef DECLSPEC_NOINLINE
    146 #if (_MSC_VER >= 1300)
    147 #define DECLSPEC_NOINLINE  __declspec(noinline)
    148 #elif defined(__GNUC__)
    149 #define DECLSPEC_NOINLINE __attribute__((noinline))
    150 #else
    151 #define DECLSPEC_NOINLINE
    152 #endif
    153 #endif /* DECLSPEC_NOINLINE */
    154 
    155 #ifndef FORCEINLINE
    156 #if !defined(_MSC_VER) || (_MSC_VER >=1200)
    157 #define FORCEINLINE __forceinline
    158 #else
    159 #define FORCEINLINE __inline
    160 #endif
    161 #endif /* FORCEINLINE */
    162 
    163 #ifndef DECLSPEC_DEPRECATED
    164 #define DECLSPEC_DEPRECATED __declspec(deprecated)
    165 #define DEPRECATE_SUPPORTED
    166 #endif
    167 
    168 #define DECLSPEC_DEPRECATED_DDK
    169 #define PRAGMA_DEPRECATED_DDK 0
    170 
    171   typedef void *PVOID;
    172   typedef void *PVOID64;
    173 
    174 #if defined(_M_IX86)
    175 #define FASTCALL __fastcall
    176 #else
    177 #define FASTCALL
    178 #endif
    179 #define NTAPI __stdcall
    180 #if !defined(_NTSYSTEM_)
    181 #define NTSYSAPI DECLSPEC_IMPORT
    182 #define NTSYSCALLAPI DECLSPEC_IMPORT
    183 #else
    184 #define NTSYSAPI
    185 #define NTSYSCALLAPI
    186 #endif
    187 
    188 #ifndef VOID
    189 #define VOID void
    190   typedef char CHAR;
    191   typedef short SHORT;
    192   typedef __LONG32 LONG;
    193 #endif
    194 #ifndef __WCHAR_DEFINED
    195 #define __WCHAR_DEFINED
    196   typedef wchar_t WCHAR;
    197 #endif
    198   typedef WCHAR *PWCHAR,*LPWCH,*PWCH;
    199   typedef CONST WCHAR *LPCWCH,*PCWCH;
    200   typedef WCHAR *NWPSTR,*LPWSTR,*PWSTR;
    201   typedef PWSTR *PZPWSTR;
    202   typedef CONST PWSTR *PCZPWSTR;
    203   typedef WCHAR UNALIGNED *LPUWSTR,*PUWSTR;
    204   typedef CONST WCHAR *LPCWSTR,*PCWSTR;
    205   typedef PCWSTR *PZPCWSTR;
    206   typedef CONST WCHAR UNALIGNED *LPCUWSTR,*PCUWSTR;
    207   typedef CHAR *PCHAR,*LPCH,*PCH;
    208   typedef CONST CHAR *LPCCH,*PCCH;
    209   typedef CHAR *NPSTR,*LPSTR,*PSTR;
    210   typedef PSTR *PZPSTR;
    211   typedef CONST PSTR *PCZPSTR;
    212   typedef CONST CHAR *LPCSTR,*PCSTR;
    213   typedef PCSTR *PZPCSTR;
    214 
    215 #if defined(UNICODE)
    216 #ifndef _TCHAR_DEFINED
    217 #define _TCHAR_DEFINED
    218   typedef WCHAR TCHAR, *PTCHAR;
    219   typedef WCHAR TBYTE, *PTBYTE;
    220 #endif
    221 
    222   typedef LPWSTR LPTCH,PTCH;
    223   typedef LPWSTR PTSTR,LPTSTR;
    224   typedef LPCWSTR PCTSTR,LPCTSTR;
    225   typedef LPUWSTR PUTSTR,LPUTSTR;
    226   typedef LPCUWSTR PCUTSTR,LPCUTSTR;
    227   typedef LPWSTR LP;
    228 #define __TEXT(quote) L##quote
    229 #else
    230 #ifndef _TCHAR_DEFINED
    231 #define _TCHAR_DEFINED
    232   typedef char TCHAR, *PTCHAR;
    233   typedef unsigned char TBYTE, *PTBYTE;
    234 #endif
    235 
    236   typedef LPSTR LPTCH,PTCH;
    237   typedef LPSTR PTSTR,LPTSTR,PUTSTR,LPUTSTR;
    238   typedef LPCSTR PCTSTR,LPCTSTR,PCUTSTR,LPCUTSTR;
    239 #define __TEXT(quote) quote
    240 #endif
    241 
    242 #define TEXT(quote) __TEXT(quote)
    243 
    244   typedef SHORT *PSHORT;
    245   typedef LONG *PLONG;
    246 
    247   typedef void *HANDLE;
    248 #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
    249   typedef HANDLE *PHANDLE;
    250 
    251   typedef BYTE FCHAR;
    252   typedef WORD FSHORT;
    253   typedef DWORD FLONG;
    254 
    255 #ifndef _HRESULT_DEFINED
    256 #define _HRESULT_DEFINED
    257   typedef LONG HRESULT;
    258 #endif
    259 
    260 #ifdef __cplusplus
    261 #define EXTERN_C extern "C"
    262 #else
    263 #define EXTERN_C extern
    264 #endif
    265 
    266 #define STDMETHODCALLTYPE WINAPI
    267 #define STDMETHODVCALLTYPE __cdecl
    268 #define STDAPICALLTYPE WINAPI
    269 #define STDAPIVCALLTYPE __cdecl
    270 #define STDAPI EXTERN_C HRESULT WINAPI
    271 #define STDAPI_(type) EXTERN_C type WINAPI
    272 #define STDMETHODIMP HRESULT WINAPI
    273 #define STDMETHODIMP_(type) type WINAPI
    274 #define IFACEMETHODIMP STDMETHODIMP
    275 #define IFACEMETHODIMP_(type) STDMETHODIMP_(type)
    276 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
    277 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
    278 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
    279 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
    280 #define IFACEMETHODIMPV STDMETHODIMPV
    281 #define IFACEMETHODIMPV_(type) STDMETHODIMPV_(type)
    282 
    283   typedef char CCHAR;
    284 #ifndef _LCID_DEFINED
    285 #define _LCID_DEFINED
    286 typedef DWORD LCID;
    287 #endif
    288   typedef PDWORD PLCID;
    289 #ifndef _LANGID_DEFINED
    290 #define _LANGID_DEFINED
    291   typedef WORD LANGID;
    292 #endif
    293 #define APPLICATION_ERROR_MASK 0x20000000
    294 #define ERROR_SEVERITY_SUCCESS 0x00000000
    295 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
    296 #define ERROR_SEVERITY_WARNING 0x80000000
    297 #define ERROR_SEVERITY_ERROR 0xC0000000
    298 
    299 #ifdef __ia64__
    300   __declspec(align(16))
    301 #endif
    302     typedef struct _FLOAT128 {
    303       __MINGW_EXTENSION __int64 LowPart;
    304       __MINGW_EXTENSION __int64 HighPart;
    305   } FLOAT128;
    306 
    307   typedef FLOAT128 *PFLOAT128;
    308 
    309 #define _ULONGLONG_
    310   __MINGW_EXTENSION typedef __int64 LONGLONG;
    311   __MINGW_EXTENSION typedef unsigned __int64 ULONGLONG;
    312 
    313 #define MAXLONGLONG (0x7fffffffffffffff)
    314 
    315   typedef LONGLONG *PLONGLONG;
    316   typedef ULONGLONG *PULONGLONG;
    317 
    318   typedef LONGLONG USN;
    319 
    320 #ifndef _LARGE_INTEGER_DEFINED
    321 #define _LARGE_INTEGER_DEFINED
    322 
    323   typedef union _LARGE_INTEGER {
    324     __C89_NAMELESS struct {
    325       DWORD LowPart;
    326       LONG HighPart;
    327     } DUMMYSTRUCTNAME;
    328     struct {
    329       DWORD LowPart;
    330       LONG HighPart;
    331     } u;
    332     LONGLONG QuadPart;
    333   } LARGE_INTEGER;
    334 
    335   typedef LARGE_INTEGER *PLARGE_INTEGER;
    336 
    337   typedef union _ULARGE_INTEGER {
    338     __C89_NAMELESS struct {
    339       DWORD LowPart;
    340       DWORD HighPart;
    341     } DUMMYSTRUCTNAME;
    342     struct {
    343       DWORD LowPart;
    344       DWORD HighPart;
    345     } u;
    346     ULONGLONG QuadPart;
    347   } ULARGE_INTEGER;
    348 
    349   typedef ULARGE_INTEGER *PULARGE_INTEGER;
    350 
    351   typedef struct _LUID {
    352     DWORD LowPart;
    353     LONG HighPart;
    354   } LUID,*PLUID;
    355 
    356 #endif /* _LARGE_INTEGER_DEFINED */
    357 
    358 #define _DWORDLONG_
    359   typedef ULONGLONG DWORDLONG;
    360   typedef DWORDLONG *PDWORDLONG;
    361 
    362 #ifdef RC_INVOKED
    363 #define Int32x32To64(a,b) ((LONGLONG)((LONG)(a)) *(LONGLONG)((LONG)(b)))
    364 #define UInt32x32To64(a,b) ((ULONGLONG)((DWORD)(a)) *(ULONGLONG)((DWORD)(b)))
    365 #define Int64ShrlMod32(a,b) ((ULONGLONG)(a) >> (b))
    366 #elif (defined(_X86_) && !defined(__x86_64))
    367 #define Int32x32To64(a,b) (LONGLONG)((LONGLONG)(LONG)(a) *(LONG)(b))
    368 #define UInt32x32To64(a,b) (ULONGLONG)((ULONGLONG)(DWORD)(a) *(DWORD)(b))
    369 #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b))
    370 #elif defined(__ia64__) || defined(__x86_64)
    371 #define Int32x32To64(a,b) ((LONGLONG)((LONG)(a)) *(LONGLONG)((LONG)(b)))
    372 #define UInt32x32To64(a,b) ((ULONGLONG)((DWORD)(a)) *(ULONGLONG)((DWORD)(b)))
    373 #define Int64ShrlMod32(a,b) ((ULONGLONG)(a) >> (b))
    374 #else
    375 #error Must define a target architecture.
    376 #endif
    377 
    378 #define Int64ShraMod32(a,b) ((LONGLONG)(a) >> (b))
    379 #define Int64ShllMod32(a,b) ((ULONGLONG)(a) << (b))
    380 
    381 #ifdef __cplusplus
    382   extern "C" {
    383 #endif
    384 
    385 #ifdef __x86_64
    386 
    387 #define RotateLeft8 _rotl8
    388 #define RotateLeft16 _rotl16
    389 #define RotateRight8 _rotr8
    390 #define RotateRight16 _rotr16
    391 
    392     unsigned char __cdecl _rotl8(unsigned char Value,unsigned char Shift);
    393     unsigned short __cdecl _rotl16(unsigned short Value,unsigned char Shift);
    394     unsigned char __cdecl _rotr8(unsigned char Value,unsigned char Shift);
    395     unsigned short __cdecl _rotr16(unsigned short Value,unsigned char Shift);
    396 #endif /* __x86_64 */
    397 
    398 #define RotateLeft32 _rotl
    399 #define RotateLeft64 _rotl64
    400 #define RotateRight32 _rotr
    401 #define RotateRight64 _rotr64
    402 
    403 #pragma push_macro ("_rotl")
    404 #pragma push_macro ("_rotr")
    405 #undef _rotl
    406 #undef _rotr
    407     unsigned int __cdecl _rotl(unsigned int Value,int Shift);
    408     unsigned int __cdecl _rotr(unsigned int Value,int Shift);
    409 #pragma pop_macro ("_rotr")
    410 #pragma pop_macro ("_rotl")
    411 #pragma push_macro ("_rotr64")
    412 #pragma push_macro ("_rotl64")
    413 #undef _rotl64
    414 #undef _rotr64
    415     __MINGW_EXTENSION unsigned __int64 __cdecl _rotl64(unsigned __int64 Value,int Shift);
    416     __MINGW_EXTENSION unsigned __int64 __cdecl _rotr64(unsigned __int64 Value,int Shift);
    417 #pragma pop_macro ("_rotl64")
    418 #pragma pop_macro ("_rotr64")
    419 
    420 #ifdef __cplusplus
    421   }
    422 #endif
    423 
    424 #define ANSI_NULL ((CHAR)0)
    425 #define UNICODE_NULL ((WCHAR)0)
    426 #define UNICODE_STRING_MAX_BYTES ((WORD) 65534)
    427 #define UNICODE_STRING_MAX_CHARS (32767)
    428 
    429 #ifndef _BOOLEAN_
    430 #define _BOOLEAN_
    431   typedef BYTE BOOLEAN;
    432 #endif
    433   typedef BOOLEAN *PBOOLEAN;
    434 
    435 #ifndef _LIST_ENTRY_DEFINED
    436 #define _LIST_ENTRY_DEFINED
    437 
    438   typedef struct _LIST_ENTRY {
    439     struct _LIST_ENTRY *Flink;
    440     struct _LIST_ENTRY *Blink;
    441   } LIST_ENTRY,*PLIST_ENTRY,*RESTRICTED_POINTER PRLIST_ENTRY;
    442 
    443   typedef struct _SINGLE_LIST_ENTRY {
    444     struct _SINGLE_LIST_ENTRY *Next;
    445   } SINGLE_LIST_ENTRY,*PSINGLE_LIST_ENTRY;
    446 
    447   typedef struct LIST_ENTRY32 {
    448     DWORD Flink;
    449     DWORD Blink;
    450   } LIST_ENTRY32;
    451   typedef LIST_ENTRY32 *PLIST_ENTRY32;
    452 
    453   typedef struct LIST_ENTRY64 {
    454     ULONGLONG Flink;
    455     ULONGLONG Blink;
    456   } LIST_ENTRY64;
    457   typedef LIST_ENTRY64 *PLIST_ENTRY64;
    458 
    459 #endif /* _LIST_ENTRY_DEFINED */
    460 
    461 #include <guiddef.h>
    462 
    463 #ifndef __OBJECTID_DEFINED
    464 #define __OBJECTID_DEFINED
    465   typedef struct _OBJECTID {
    466     GUID Lineage;
    467     DWORD Uniquifier;
    468   } OBJECTID;
    469 #endif
    470 
    471 #define MINCHAR 0x80
    472 #define MAXCHAR 0x7f
    473 #define MINSHORT 0x8000
    474 #define MAXSHORT 0x7fff
    475 #define MINLONG 0x80000000
    476 #define MAXLONG 0x7fffffff
    477 #define MAXBYTE 0xff
    478 #define MAXWORD 0xffff
    479 #define MAXDWORD 0xffffffff
    480 
    481 #define FIELD_OFFSET(type,field) ((LONG)(LONG_PTR)&(((type *)0)->field))
    482 #define RTL_FIELD_SIZE(type,field) (sizeof(((type *)0)->field))
    483 #define RTL_SIZEOF_THROUGH_FIELD(type,field) (FIELD_OFFSET(type,field) + RTL_FIELD_SIZE(type,field))
    484 #define RTL_CONTAINS_FIELD(Struct,Size,Field) ((((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)))
    485 #define RTL_NUMBER_OF_V1(A) (sizeof(A)/sizeof((A)[0]))
    486 #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)
    487 
    488 #ifdef ENABLE_RTL_NUMBER_OF_V2
    489 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V2(A)
    490 #else
    491 #define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A)
    492 #endif
    493 
    494 #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A)
    495 #define _ARRAYSIZE(A) RTL_NUMBER_OF_V1(A)
    496 
    497 #define RTL_FIELD_TYPE(type,field) (((type*)0)->field)
    498 #define RTL_NUMBER_OF_FIELD(type,field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type,field)))
    499 #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)))
    500 
    501 #ifdef __cplusplus
    502 #define RTL_CONST_CAST(type) const_cast<type>
    503 #else
    504 #define RTL_CONST_CAST(type) (type)
    505 #endif
    506 
    507 #ifdef __cplusplus
    508 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
    509 extern "C++" { \
    510 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) | ((int)b)); } \
    511 inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
    512 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) & ((int)b)); } \
    513 inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
    514 inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((int)a)); } \
    515 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) ^ ((int)b)); } \
    516 inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
    517 }
    518 #else
    519 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
    520 #endif
    521 
    522 #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) *8)
    523 #define RTL_BITS_OF_FIELD(type,field) (RTL_BITS_OF(RTL_FIELD_TYPE(type,field)))
    524 #define CONTAINING_RECORD(address,type,field) ((type *)((PCHAR)(address) - (ULONG_PTR)(&((type *)0)->field)))
    525 
    526 #define VER_WORKSTATION_NT                  0x40000000
    527 #define VER_SERVER_NT                       0x80000000
    528 #define VER_SUITE_SMALLBUSINESS             0x00000001
    529 #define VER_SUITE_ENTERPRISE                0x00000002
    530 #define VER_SUITE_BACKOFFICE                0x00000004
    531 #define VER_SUITE_COMMUNICATIONS            0x00000008
    532 #define VER_SUITE_TERMINAL                  0x00000010
    533 #define VER_SUITE_SMALLBUSINESS_RESTRICTED  0x00000020
    534 #define VER_SUITE_EMBEDDEDNT                0x00000040
    535 #define VER_SUITE_DATACENTER                0x00000080
    536 #define VER_SUITE_SINGLEUSERTS              0x00000100
    537 #define VER_SUITE_PERSONAL                  0x00000200
    538 #define VER_SUITE_BLADE                     0x00000400
    539 #define VER_SUITE_EMBEDDED_RESTRICTED       0x00000800
    540 #define VER_SUITE_SECURITY_APPLIANCE        0x00001000
    541 #define VER_SUITE_STORAGE_SERVER            0x00002000
    542 #define VER_SUITE_COMPUTE_SERVER            0x00004000
    543 #define VER_SUITE_WH_SERVER                 0x00008000
    544 
    545 #define PRODUCT_UNDEFINED                         0x0
    546 
    547 #define PRODUCT_ULTIMATE                          0x1
    548 #define PRODUCT_HOME_BASIC                        0x2
    549 #define PRODUCT_HOME_PREMIUM                      0x3
    550 #define PRODUCT_ENTERPRISE                        0x4
    551 #define PRODUCT_HOME_BASIC_N                      0x5
    552 #define PRODUCT_BUSINESS                          0x6
    553 #define PRODUCT_STANDARD_SERVER                   0x7
    554 #define PRODUCT_DATACENTER_SERVER                 0x8
    555 #define PRODUCT_SMALLBUSINESS_SERVER              0x9
    556 #define PRODUCT_ENTERPRISE_SERVER                 0xa
    557 #define PRODUCT_STARTER                           0xb
    558 #define PRODUCT_DATACENTER_SERVER_CORE            0xc
    559 #define PRODUCT_STANDARD_SERVER_CORE              0xd
    560 #define PRODUCT_ENTERPRISE_SERVER_CORE            0xe
    561 #define PRODUCT_ENTERPRISE_SERVER_IA64            0xf
    562 #define PRODUCT_BUSINESS_N                        0x10
    563 #define PRODUCT_WEB_SERVER                        0x11
    564 #define PRODUCT_CLUSTER_SERVER                    0x12
    565 #define PRODUCT_HOME_SERVER                       0x13
    566 #define PRODUCT_STORAGE_EXPRESS_SERVER            0x14
    567 #define PRODUCT_STORAGE_STANDARD_SERVER           0x15
    568 #define PRODUCT_STORAGE_WORKGROUP_SERVER          0x16
    569 #define PRODUCT_STORAGE_ENTERPRISE_SERVER         0x17
    570 #define PRODUCT_SERVER_FOR_SMALLBUSINESS          0x18
    571 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM      0x19
    572 #define PRODUCT_HOME_PREMIUM_N                    0x1a
    573 #define PRODUCT_ENTERPRISE_N                      0x1b
    574 #define PRODUCT_ULTIMATE_N                        0x1c
    575 #define PRODUCT_WEB_SERVER_CORE                   0x1d
    576 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT  0x1e
    577 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY    0x1f
    578 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING   0x20
    579 #define PRODUCT_SERVER_FOUNDATION                 0x21
    580 #define PRODUCT_HOME_PREMIUM_SERVER               0x22
    581 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V        0x23
    582 #define PRODUCT_STANDARD_SERVER_V                 0x24
    583 #define PRODUCT_DATACENTER_SERVER_V               0x25
    584 #define PRODUCT_ENTERPRISE_SERVER_V               0x26
    585 #define PRODUCT_DATACENTER_SERVER_CORE_V          0x27
    586 #define PRODUCT_STANDARD_SERVER_CORE_V            0x28
    587 #define PRODUCT_ENTERPRISE_SERVER_CORE_V          0x29
    588 #define PRODUCT_HYPERV                            0x2a
    589 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE       0x2b
    590 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE      0x2c
    591 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE     0x2d
    592 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE    0x2e
    593 #define PRODUCT_STARTER_N                         0x2f
    594 #define PRODUCT_PROFESSIONAL                      0x30
    595 #define PRODUCT_PROFESSIONAL_N                    0x31
    596 #define PRODUCT_SB_SOLUTION_SERVER                0x32
    597 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS           0x33
    598 #define PRODUCT_STANDARD_SERVER_SOLUTIONS         0x34
    599 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE    0x35
    600 #define PRODUCT_SB_SOLUTION_SERVER_EM             0x36
    601 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM        0x37
    602 #define PRODUCT_SOLUTION_EMBEDDEDSERVER           0x38
    603 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE      0x39
    604 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT     0x3B
    605 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL     0x3C
    606 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC  0x3D
    607 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC  0x3E
    608 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x3f
    609 #define PRODUCT_CLUSTER_SERVER_V                  0x40
    610 #define PRODUCT_EMBEDDED                          0x41
    611 #define PRODUCT_STARTER_E                         0x42
    612 #define PRODUCT_HOME_BASIC_E                      0x43
    613 #define PRODUCT_HOME_PREMIUM_E                    0x44
    614 #define PRODUCT_PROFESSIONAL_E                    0x45
    615 #define PRODUCT_ENTERPRISE_E                      0x46
    616 #define PRODUCT_ULTIMATE_E                        0x47
    617 #define PRODUCT_ENTERPRISE_EVALUATION             0x48
    618 #define PRODUCT_MULTIPOINT_STANDARD_SERVER        0x4C
    619 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER         0x4D
    620 #define PRODUCT_STANDARD_EVALUATION_SERVER        0x4F
    621 #define PRODUCT_DATACENTER_EVALUATION_SERVER      0x50
    622 #define PRODUCT_ENTERPRISE_N_EVALUATION           0x54
    623 #define PRODUCT_EMBEDDED_AUTOMOTIVE               0x55
    624 #define PRODUCT_EMBEDDED_INDUSTRY_A               0x56
    625 #define PRODUCT_THINPC                            0x57
    626 #define PRODUCT_EMBEDDED_A                        0x58
    627 #define PRODUCT_EMBEDDED_INDUSTRY                 0x59
    628 #define PRODUCT_EMBEDDED_E                        0x5A
    629 #define PRODUCT_EMBEDDED_INDUSTRY_E               0x5B
    630 #define PRODUCT_EMBEDDED_INDUSTRY_A_E             0x5C
    631 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x5F
    632 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x60
    633 #define PRODUCT_CORE_ARM                          0x61
    634 #define PRODUCT_CORE_N                            0x62
    635 #define PRODUCT_CORE_COUNTRYSPECIFIC              0x63
    636 #define PRODUCT_CORE_SINGLELANGUAGE               0x64
    637 #define PRODUCT_CORE                              0x65
    638 #define PRODUCT_PROFESSIONAL_WMC                  0x67
    639 #define PRODUCT_MOBILE_CORE                       0x68
    640 
    641 #define PRODUCT_UNLICENSED                        0xabcdabcd
    642 
    643 #define LANG_NEUTRAL                              0x00
    644 #define LANG_INVARIANT                            0x7f
    645 
    646 #define LANG_AFRIKAANS                            0x36
    647 #define LANG_ALBANIAN                             0x1c
    648 #define LANG_ALSATIAN                             0x84
    649 #define LANG_AMHARIC                              0x5e
    650 #define LANG_ARABIC                               0x01
    651 #define LANG_ARMENIAN                             0x2b
    652 #define LANG_ASSAMESE                             0x4d
    653 #define LANG_AZERI                                0x2c
    654 #define LANG_AZERBAIJANI			  0x2c
    655 #define LANG_BANGLA				  0x45
    656 #define LANG_BASHKIR                              0x6d
    657 #define LANG_BASQUE                               0x2d
    658 #define LANG_BELARUSIAN                           0x23
    659 #define LANG_BENGALI                              0x45
    660 #define LANG_BRETON                               0x7e
    661 #define LANG_BOSNIAN                              0x1a
    662 #define LANG_BOSNIAN_NEUTRAL                    0x781a
    663 #define LANG_BULGARIAN                            0x02
    664 #define LANG_CATALAN                              0x03
    665 #define LANG_CENTRAL_KURDISH			  0x92
    666 #define LANG_CHEROKEE				  0x5c
    667 #define LANG_CHINESE                              0x04
    668 #define LANG_CHINESE_SIMPLIFIED                   0x04
    669 #define LANG_CHINESE_TRADITIONAL                0x7c04
    670 #define LANG_CORSICAN                             0x83
    671 #define LANG_CROATIAN                             0x1a
    672 #define LANG_CZECH                                0x05
    673 #define LANG_DANISH                               0x06
    674 #define LANG_DARI                                 0x8c
    675 #define LANG_DIVEHI                               0x65
    676 #define LANG_DUTCH                                0x13
    677 #define LANG_ENGLISH                              0x09
    678 #define LANG_ESTONIAN                             0x25
    679 #define LANG_FAEROESE                             0x38
    680 #define LANG_FARSI                                0x29
    681 #define LANG_FILIPINO                             0x64
    682 #define LANG_FINNISH                              0x0b
    683 #define LANG_FRENCH                               0x0c
    684 #define LANG_FRISIAN                              0x62
    685 #define LANG_FULAH				  0x67
    686 #define LANG_GALICIAN                             0x56
    687 #define LANG_GEORGIAN                             0x37
    688 #define LANG_GERMAN                               0x07
    689 #define LANG_GREEK                                0x08
    690 #define LANG_GREENLANDIC                          0x6f
    691 #define LANG_GUJARATI                             0x47
    692 #define LANG_HAUSA                                0x68
    693 #define LANG_HEBREW                               0x0d
    694 #define LANG_HINDI                                0x39
    695 #define LANG_HUNGARIAN                            0x0e
    696 #define LANG_ICELANDIC                            0x0f
    697 #define LANG_IGBO                                 0x70
    698 #define LANG_INDONESIAN                           0x21
    699 #define LANG_INUKTITUT                            0x5d
    700 #define LANG_IRISH                                0x3c
    701 #define LANG_ITALIAN                              0x10
    702 #define LANG_JAPANESE                             0x11
    703 #define LANG_KANNADA                              0x4b
    704 #define LANG_KASHMIRI                             0x60
    705 #define LANG_KAZAK                                0x3f
    706 #define LANG_KHMER                                0x53
    707 #define LANG_KICHE                                0x86
    708 #define LANG_KINYARWANDA                          0x87
    709 #define LANG_KONKANI                              0x57
    710 #define LANG_KOREAN                               0x12
    711 #define LANG_KYRGYZ                               0x40
    712 #define LANG_LAO                                  0x54
    713 #define LANG_LATVIAN                              0x26
    714 #define LANG_LITHUANIAN                           0x27
    715 #define LANG_LOWER_SORBIAN                        0x2e
    716 #define LANG_LUXEMBOURGISH                        0x6e
    717 #define LANG_MACEDONIAN                           0x2f
    718 #define LANG_MALAY                                0x3e
    719 #define LANG_MALAYALAM                            0x4c
    720 #define LANG_MALTESE                              0x3a
    721 #define LANG_MANIPURI                             0x58
    722 #define LANG_MAORI                                0x81
    723 #define LANG_MAPUDUNGUN                           0x7a
    724 #define LANG_MARATHI                              0x4e
    725 #define LANG_MOHAWK                               0x7c
    726 #define LANG_MONGOLIAN                            0x50
    727 #define LANG_NEPALI                               0x61
    728 #define LANG_NORWEGIAN                            0x14
    729 #define LANG_OCCITAN                              0x82
    730 #define LANG_ODIA				  0x48
    731 #define LANG_ORIYA                                0x48
    732 #define LANG_PASHTO                               0x63
    733 #define LANG_PERSIAN                              0x29
    734 #define LANG_POLISH                               0x15
    735 #define LANG_PORTUGUESE                           0x16
    736 #define LANG_PULAR				  0x67
    737 #define LANG_PUNJABI                              0x46
    738 #define LANG_QUECHUA                              0x6b
    739 #define LANG_ROMANIAN                             0x18
    740 #define LANG_ROMANSH                              0x17
    741 #define LANG_RUSSIAN                              0x19
    742 #define LANG_SAKHA				  0x85
    743 #define LANG_SAMI                                 0x3b
    744 #define LANG_SANSKRIT                             0x4f
    745 #define LANG_SCOTTISH_GAELIC			  0x91
    746 #define LANG_SERBIAN                              0x1a
    747 #define LANG_SERBIAN_NEUTRAL                    0x7c1a
    748 #define LANG_SINDHI                               0x59
    749 #define LANG_SINHALESE                            0x5b
    750 #define LANG_SLOVAK                               0x1b
    751 #define LANG_SLOVENIAN                            0x24
    752 #define LANG_SOTHO                                0x6c
    753 #define LANG_SPANISH                              0x0a
    754 #define LANG_SWAHILI                              0x41
    755 #define LANG_SWEDISH                              0x1d
    756 #define LANG_SYRIAC                               0x5a
    757 #define LANG_TAJIK                                0x28
    758 #define LANG_TAMAZIGHT                            0x5f
    759 #define LANG_TAMIL                                0x49
    760 #define LANG_TATAR                                0x44
    761 #define LANG_TELUGU                               0x4a
    762 #define LANG_THAI                                 0x1e
    763 #define LANG_TIBETAN                              0x51
    764 #define LANG_TIGRIGNA                             0x73
    765 #define LANG_TIGRINYA				  0x73
    766 #define LANG_TSWANA                               0x32
    767 #define LANG_TURKISH                              0x1f
    768 #define LANG_TURKMEN                              0x42
    769 #define LANG_UIGHUR                               0x80
    770 #define LANG_UKRAINIAN                            0x22
    771 #define LANG_UPPER_SORBIAN                        0x2e
    772 #define LANG_URDU                                 0x20
    773 #define LANG_UZBEK                                0x43
    774 #define LANG_VALENCIAN				  0x03
    775 #define LANG_VIETNAMESE                           0x2a
    776 #define LANG_WELSH                                0x52
    777 #define LANG_WOLOF                                0x88
    778 #define LANG_XHOSA                                0x34
    779 #define LANG_YAKUT                                0x85
    780 #define LANG_YI                                   0x78
    781 #define LANG_YORUBA                               0x6a
    782 #define LANG_ZULU                                 0x35
    783 
    784 #define SUBLANG_NEUTRAL                           0x00
    785 #define SUBLANG_DEFAULT                           0x01
    786 #define SUBLANG_SYS_DEFAULT                       0x02
    787 #define SUBLANG_CUSTOM_DEFAULT                    0x03
    788 #define SUBLANG_CUSTOM_UNSPECIFIED                0x04
    789 #define SUBLANG_UI_CUSTOM_DEFAULT                 0x05
    790 
    791 #define SUBLANG_AFRIKAANS_SOUTH_AFRICA            0x01
    792 #define SUBLANG_ALBANIAN_ALBANIA                  0x01
    793 #define SUBLANG_ALSATIAN_FRANCE                   0x01
    794 #define SUBLANG_AMHARIC_ETHIOPIA                  0x01
    795 #define SUBLANG_ARABIC_SAUDI_ARABIA               0x01
    796 #define SUBLANG_ARABIC_IRAQ                       0x02
    797 #define SUBLANG_ARABIC_EGYPT                      0x03
    798 #define SUBLANG_ARABIC_LIBYA                      0x04
    799 #define SUBLANG_ARABIC_ALGERIA                    0x05
    800 #define SUBLANG_ARABIC_MOROCCO                    0x06
    801 #define SUBLANG_ARABIC_TUNISIA                    0x07
    802 #define SUBLANG_ARABIC_OMAN                       0x08
    803 #define SUBLANG_ARABIC_YEMEN                      0x09
    804 #define SUBLANG_ARABIC_SYRIA                      0x0a
    805 #define SUBLANG_ARABIC_JORDAN                     0x0b
    806 #define SUBLANG_ARABIC_LEBANON                    0x0c
    807 #define SUBLANG_ARABIC_KUWAIT                     0x0d
    808 #define SUBLANG_ARABIC_UAE                        0x0e
    809 #define SUBLANG_ARABIC_BAHRAIN                    0x0f
    810 #define SUBLANG_ARABIC_QATAR                      0x10
    811 #define SUBLANG_ARMENIAN_ARMENIA                  0x01
    812 #define SUBLANG_ASSAMESE_INDIA                    0x01
    813 #define SUBLANG_AZERI_LATIN                       0x01
    814 #define SUBLANG_AZERI_CYRILLIC                    0x02
    815 #define SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN      0x01
    816 #define SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC   0x02
    817 #define SUBLANG_BANGLA_INDIA                      0x01
    818 #define SUBLANG_BANGLA_BANGLADESH                 0x02
    819 #define SUBLANG_BASHKIR_RUSSIA                    0x01
    820 #define SUBLANG_BASQUE_BASQUE                     0x01
    821 #define SUBLANG_BELARUSIAN_BELARUS                0x01
    822 #define SUBLANG_BENGALI_INDIA                     0x01
    823 #define SUBLANG_BENGALI_BANGLADESH                0x02
    824 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN  0x05
    825 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
    826 #define SUBLANG_BRETON_FRANCE                     0x01
    827 #define SUBLANG_BULGARIAN_BULGARIA                0x01
    828 #define SUBLANG_CATALAN_CATALAN                   0x01
    829 #define SUBLANG_CENTRAL_KURDISH_IRAQ              0x01
    830 #define SUBLANG_CHEROKEE_CHEROKEE                 0x01
    831 #define SUBLANG_CHINESE_TRADITIONAL               0x01
    832 #define SUBLANG_CHINESE_SIMPLIFIED                0x02
    833 #define SUBLANG_CHINESE_HONGKONG                  0x03
    834 #define SUBLANG_CHINESE_SINGAPORE                 0x04
    835 #define SUBLANG_CHINESE_MACAU                     0x05
    836 #define SUBLANG_CORSICAN_FRANCE                   0x01
    837 #define SUBLANG_CZECH_CZECH_REPUBLIC              0x01
    838 #define SUBLANG_CROATIAN_CROATIA                  0x01
    839 #define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
    840 #define SUBLANG_DANISH_DENMARK                    0x01
    841 #define SUBLANG_DARI_AFGHANISTAN                  0x01
    842 #define SUBLANG_DIVEHI_MALDIVES                   0x01
    843 #define SUBLANG_DUTCH                             0x01
    844 #define SUBLANG_DUTCH_BELGIAN                     0x02
    845 #define SUBLANG_ENGLISH_US                        0x01
    846 #define SUBLANG_ENGLISH_UK                        0x02
    847 #define SUBLANG_ENGLISH_AUS                       0x03
    848 #define SUBLANG_ENGLISH_CAN                       0x04
    849 #define SUBLANG_ENGLISH_NZ                        0x05
    850 #if (WINVER >= 0x0600)
    851 #define SUBLANG_ENGLISH_IRELAND                   0x06
    852 #endif /* WINVER >= 0x0600 */
    853 #define SUBLANG_ENGLISH_EIRE                      0x06
    854 #define SUBLANG_ENGLISH_SOUTH_AFRICA              0x07
    855 #define SUBLANG_ENGLISH_JAMAICA                   0x08
    856 #define SUBLANG_ENGLISH_CARIBBEAN                 0x09
    857 #define SUBLANG_ENGLISH_BELIZE                    0x0a
    858 #define SUBLANG_ENGLISH_TRINIDAD                  0x0b
    859 #define SUBLANG_ENGLISH_ZIMBABWE                  0x0c
    860 #define SUBLANG_ENGLISH_PHILIPPINES               0x0d
    861 #define SUBLANG_ENGLISH_INDIA                     0x10
    862 #define SUBLANG_ENGLISH_MALAYSIA                  0x11
    863 #define SUBLANG_ENGLISH_SINGAPORE                 0x12
    864 #define SUBLANG_ESTONIAN_ESTONIA                  0x01
    865 #define SUBLANG_FAEROESE_FAROE_ISLANDS            0x01
    866 #define SUBLANG_FILIPINO_PHILIPPINES              0x01
    867 #define SUBLANG_FINNISH_FINLAND                   0x01
    868 #define SUBLANG_FRENCH                            0x01
    869 #define SUBLANG_FRENCH_BELGIAN                    0x02
    870 #define SUBLANG_FRENCH_CANADIAN                   0x03
    871 #define SUBLANG_FRENCH_SWISS                      0x04
    872 #define SUBLANG_FRENCH_LUXEMBOURG                 0x05
    873 #define SUBLANG_FRENCH_MONACO                     0x06
    874 #define SUBLANG_FRISIAN_NETHERLANDS               0x01
    875 #define SUBLANG_FULAH_SENEGAL                     0x02
    876 #define SUBLANG_GALICIAN_GALICIAN                 0x01
    877 #define SUBLANG_GEORGIAN_GEORGIA                  0x01
    878 #define SUBLANG_GERMAN                            0x01
    879 #define SUBLANG_GERMAN_SWISS                      0x02
    880 #define SUBLANG_GERMAN_AUSTRIAN                   0x03
    881 #define SUBLANG_GERMAN_LUXEMBOURG                 0x04
    882 #define SUBLANG_GERMAN_LIECHTENSTEIN              0x05
    883 #define SUBLANG_GREEK_GREECE                      0x01
    884 #define SUBLANG_GREENLANDIC_GREENLAND             0x01
    885 #define SUBLANG_GUJARATI_INDIA                    0x01
    886 #define SUBLANG_HAUSA_NIGERIA_LATIN               0x01
    887 #define SUBLANG_HAUSA_NIGERIA    SUBLANG_HAUSA_NIGERIA_LATIN	/* SUBLANG_HAUSA_NIGERIA_LATIN is what MS defines */
    888 #define SUBLANG_HAWAIIAN_US                       0x01
    889 #define SUBLANG_HEBREW_ISRAEL                     0x01
    890 #define SUBLANG_HINDI_INDIA                       0x01
    891 #define SUBLANG_HUNGARIAN_HUNGARY                 0x01
    892 #define SUBLANG_ICELANDIC_ICELAND                 0x01
    893 #define SUBLANG_IGBO_NIGERIA                      0x01
    894 #define SUBLANG_INDONESIAN_INDONESIA              0x01
    895 #define SUBLANG_INUKTITUT_CANADA                  0x01
    896 #define SUBLANG_INUKTITUT_CANADA_LATIN            0x02
    897 #define SUBLANG_IRISH_IRELAND                     0x02
    898 #define SUBLANG_ITALIAN                           0x01
    899 #define SUBLANG_ITALIAN_SWISS                     0x02
    900 #define SUBLANG_JAPANESE_JAPAN                    0x01
    901 #define SUBLANG_KANNADA_INDIA                     0x01
    902 #define SUBLANG_KASHMIRI_INDIA                    0x02
    903 #define SUBLANG_KASHMIRI_SASIA                    0x02
    904 #define SUBLANG_KAZAK_KAZAKHSTAN                  0x01
    905 #define SUBLANG_KHMER_CAMBODIA                    0x01
    906 #define SUBLANG_KICHE_GUATEMALA                   0x01
    907 #define SUBLANG_KINYARWANDA_RWANDA                0x01
    908 #define SUBLANG_KONKANI_INDIA                     0x01
    909 #define SUBLANG_KOREAN                            0x01
    910 #define SUBLANG_KYRGYZ_KYRGYZSTAN                 0x01
    911 #define SUBLANG_LAO_LAO                           0x01
    912 #define SUBLANG_LAO_LAO_PDR            SUBLANG_LAO_LAO		/* SUBLANG_LAO_LAO is what MS defines */
    913 #define SUBLANG_LATVIAN_LATVIA                    0x01
    914 #if (WINVER >= 0x0600)
    915 #define SUBLANG_LITHUANIAN_LITHUANIA              0x01
    916 #endif /* WINVER >= 0x0600 */
    917 #define SUBLANG_LITHUANIAN                        0x01
    918 #define SUBLANG_LOWER_SORBIAN_GERMANY             0x02
    919 #define SUBLANG_LUXEMBOURGISH_LUXEMBOURG          0x01
    920 #define SUBLANG_MACEDONIAN_MACEDONIA              0x01
    921 #define SUBLANG_MALAY_MALAYSIA                    0x01
    922 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM           0x02
    923 #define SUBLANG_MALAYALAM_INDIA                   0x01
    924 #define SUBLANG_MALTESE_MALTA                     0x01
    925 #define SUBLANG_MAORI_NEW_ZEALAND                 0x01
    926 #define SUBLANG_MAPUDUNGUN_CHILE                  0x01
    927 #define SUBLANG_MARATHI_INDIA                     0x01
    928 #define SUBLANG_MOHAWK_MOHAWK                     0x01
    929 #define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA       0x01
    930 #define SUBLANG_MONGOLIAN_PRC                     0x02
    931 #define SUBLANG_NEPALI_NEPAL                      0x01
    932 #define SUBLANG_NEPALI_INDIA                      0x02
    933 #define SUBLANG_NORWEGIAN_BOKMAL                  0x01
    934 #define SUBLANG_NORWEGIAN_NYNORSK                 0x02
    935 #define SUBLANG_OCCITAN_FRANCE                    0x01
    936 #define SUBLANG_ORIYA_INDIA                       0x01
    937 #define SUBLANG_PASHTO_AFGHANISTAN                0x01
    938 #define SUBLANG_PERSIAN_IRAN                      0x01
    939 #define SUBLANG_POLISH_POLAND                     0x01
    940 #define SUBLANG_PORTUGUESE_BRAZILIAN              0x01
    941 #if (WINVER >= 0x0600)
    942 #define SUBLANG_PORTUGUESE_PORTUGAL               0x02
    943 #endif /* WINVER >= 0x0600 */
    944 #define SUBLANG_PORTUGUESE                        0x02
    945 #define SUBLANG_PULAR_SENEGAL                     0x02
    946 #define SUBLANG_PUNJABI_INDIA                     0x01
    947 #define SUBLANG_PUNJABI_PAKISTAN                  0x02
    948 #define SUBLANG_QUECHUA_BOLIVIA                   0x01
    949 #define SUBLANG_QUECHUA_ECUADOR                   0x02
    950 #define SUBLANG_QUECHUA_PERU                      0x03
    951 #define SUBLANG_ROMANIAN_ROMANIA                  0x01
    952 /* ??? #define SUBLANG_ROMANIAN_MOLDOVA                  0x01 ??? */
    953 #define SUBLANG_ROMANSH_SWITZERLAND               0x01
    954 #define SUBLANG_RUSSIAN_RUSSIA                    0x01
    955 #define SUBLANG_SAKHA_RUSSIA                      0x01
    956 #define SUBLANG_SAMI_NORTHERN_NORWAY              0x01
    957 #define SUBLANG_SAMI_NORTHERN_SWEDEN              0x02
    958 #define SUBLANG_SAMI_NORTHERN_FINLAND             0x03
    959 #define SUBLANG_SAMI_LULE_NORWAY                  0x04
    960 #define SUBLANG_SAMI_LULE_SWEDEN                  0x05
    961 #define SUBLANG_SAMI_SOUTHERN_NORWAY              0x06
    962 #define SUBLANG_SAMI_SOUTHERN_SWEDEN              0x07
    963 #define SUBLANG_SAMI_SKOLT_FINLAND                0x08
    964 #define SUBLANG_SAMI_INARI_FINLAND                0x09
    965 #define SUBLANG_SANSKRIT_INDIA                    0x01
    966 #define SUBLANG_SCOTTISH_GAELIC                    0x01
    967 #define SUBLANG_SERBIAN_LATIN                     0x02
    968 #define SUBLANG_SERBIAN_CYRILLIC                  0x03
    969 #define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN  0x06
    970 #define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x07
    971 #define SUBLANG_SERBIAN_MONTENEGRO_LATIN          0x0b
    972 #define SUBLANG_SERBIAN_MONTENEGRO_CYRILLIC       0x0c
    973 #define SUBLANG_SERBIAN_SERBIA_LATIN              0x09
    974 #define SUBLANG_SERBIAN_SERBIA_CYRILLIC           0x0a
    975 #define SUBLANG_SINDHI_INDIA                      0x01
    976 #define SUBLANG_SINDHI_AFGHANISTAN                0x02
    977 #define SUBLANG_SINDHI_PAKISTAN                   0x02
    978 #define SUBLANG_SINHALESE_SRI_LANKA               0x01
    979 #define SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA       0x01
    980 #define SUBLANG_SLOVAK_SLOVAKIA                   0x01
    981 #define SUBLANG_SLOVENIAN_SLOVENIA                0x01
    982 #define SUBLANG_SPANISH                           0x01
    983 #define SUBLANG_SPANISH_MEXICAN                   0x02
    984 #define SUBLANG_SPANISH_MODERN                    0x03
    985 #define SUBLANG_SPANISH_GUATEMALA                 0x04
    986 #define SUBLANG_SPANISH_COSTA_RICA                0x05
    987 #define SUBLANG_SPANISH_PANAMA                    0x06
    988 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC        0x07
    989 #define SUBLANG_SPANISH_VENEZUELA                 0x08
    990 #define SUBLANG_SPANISH_COLOMBIA                  0x09
    991 #define SUBLANG_SPANISH_PERU                      0x0a
    992 #define SUBLANG_SPANISH_ARGENTINA                 0x0b
    993 #define SUBLANG_SPANISH_ECUADOR                   0x0c
    994 #define SUBLANG_SPANISH_CHILE                     0x0d
    995 #define SUBLANG_SPANISH_URUGUAY                   0x0e
    996 #define SUBLANG_SPANISH_PARAGUAY                  0x0f
    997 #define SUBLANG_SPANISH_BOLIVIA                   0x10
    998 #define SUBLANG_SPANISH_EL_SALVADOR               0x11
    999 #define SUBLANG_SPANISH_HONDURAS                  0x12
   1000 #define SUBLANG_SPANISH_NICARAGUA                 0x13
   1001 #define SUBLANG_SPANISH_PUERTO_RICO               0x14
   1002 #define SUBLANG_SPANISH_US                        0x15
   1003 #define SUBLANG_SWAHILI_KENYA                     0x01
   1004 #if (WINVER >= 0x0600)
   1005 #define SUBLANG_SWEDISH_SWEDEN                    0x01
   1006 #endif /* WINVER >= 0x0600 */
   1007 #define SUBLANG_SWEDISH                           0x01
   1008 #define SUBLANG_SWEDISH_FINLAND                   0x02
   1009 #define SUBLANG_SYRIAC                            0x01
   1010 #define SUBLANG_SYRIAC_SYRIA            SUBLANG_SYRIAC		/* SUBLANG_SYRIAC_SYRIA is what MSDN mentions */
   1011 #define SUBLANG_TAJIK_TAJIKISTAN                  0x01
   1012 #define SUBLANG_TAMAZIGHT_ALGERIA_LATIN           0x02
   1013 #define SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH        0x04
   1014 #define SUBLANG_TAMIL_INDIA                       0x01
   1015 #define SUBLANG_TAMIL_SRI_LANKA                   0x02
   1016 #define SUBLANG_TATAR_RUSSIA                      0x01
   1017 #define SUBLANG_TELUGU_INDIA                      0x01
   1018 #define SUBLANG_THAI_THAILAND                     0x01
   1019 #define SUBLANG_TIBETAN_PRC                       0x01
   1020 #define SUBLANG_TIBETAN_BHUTAN                    0x02
   1021 #define SUBLANG_TIGRIGNA_ERITREA                  0x02
   1022 #define SUBLANG_TIGRINYA_ERITREA                  0x02
   1023 #define SUBLANG_TIGRINYA_ETHIOPIA                 0x01
   1024 #define SUBLANG_TSWANA_BOTSWANA                   0x02
   1025 #define SUBLANG_TSWANA_SOUTH_AFRICA               0x01
   1026 #define SUBLANG_TURKISH_TURKEY                    0x01
   1027 #define SUBLANG_TURKMEN_TURKMENISTAN              0x01
   1028 #define SUBLANG_UIGHUR_PRC                        0x01
   1029 #define SUBLANG_UKRAINIAN_UKRAINE                 0x01
   1030 #define SUBLANG_UPPER_SORBIAN_GERMANY             0x01
   1031 #define SUBLANG_URDU_PAKISTAN                     0x01
   1032 #define SUBLANG_URDU_INDIA                        0x02
   1033 #define SUBLANG_UZBEK_LATIN                       0x01
   1034 #define SUBLANG_UZBEK_CYRILLIC                    0x02
   1035 #define SUBLANG_VALENCIAN_VALENCIA                0x02
   1036 #define SUBLANG_VIETNAMESE_VIETNAM                0x01
   1037 #define SUBLANG_WELSH_UNITED_KINGDOM              0x01
   1038 #define SUBLANG_WOLOF_SENEGAL                     0x01
   1039 #define SUBLANG_YORUBA_NIGERIA                    0x01
   1040 #define SUBLANG_XHOSA_SOUTH_AFRICA                0x01
   1041 #define SUBLANG_YAKUT_RUSSIA                      0x01
   1042 #define SUBLANG_YI_PRC                            0x01
   1043 #define SUBLANG_ZULU_SOUTH_AFRICA                 0x01
   1044 
   1045 #define SORT_DEFAULT                              0x0
   1046 #define SORT_INVARIANT_MATH                       0x1
   1047 
   1048 #define SORT_JAPANESE_XJIS                        0x0
   1049 #define SORT_JAPANESE_UNICODE                     0x1
   1050 #define SORT_JAPANESE_RADICALSTROKE               0x4
   1051 
   1052 #define SORT_CHINESE_BIG5                         0x0
   1053 #define SORT_CHINESE_PRCP                         0x0
   1054 #define SORT_CHINESE_UNICODE                      0x1
   1055 #define SORT_CHINESE_PRC                          0x2
   1056 #define SORT_CHINESE_BOPOMOFO                     0x3
   1057 #define SORT_CHINESE_RADICALSTROKE		  0x4
   1058 
   1059 #define SORT_KOREAN_KSC                           0x0
   1060 #define SORT_KOREAN_UNICODE                       0x1
   1061 
   1062 #define SORT_GERMAN_PHONE_BOOK                    0x1
   1063 
   1064 #define SORT_HUNGARIAN_DEFAULT                    0x0
   1065 #define SORT_HUNGARIAN_TECHNICAL                  0x1
   1066 
   1067 #define SORT_GEORGIAN_TRADITIONAL                 0x0
   1068 #define SORT_GEORGIAN_MODERN                      0x1
   1069 
   1070 #define MAKELANGID(p,s) ((((WORD)(s)) << 10) | (WORD)(p))
   1071 #define PRIMARYLANGID(lgid) ((WORD)(lgid) & 0x3ff)
   1072 #define SUBLANGID(lgid) ((WORD)(lgid) >> 10)
   1073 
   1074 #define NLS_VALID_LOCALE_MASK 0x000fffff
   1075 
   1076 #define MAKELCID(lgid,srtid) ((DWORD)((((DWORD)((WORD)(srtid))) << 16) | ((DWORD)((WORD)(lgid)))))
   1077 #define MAKESORTLCID(lgid,srtid,ver) ((DWORD)((MAKELCID(lgid,srtid)) | (((DWORD)((WORD)(ver))) << 20)))
   1078 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
   1079 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0xf))
   1080 #define SORTVERSIONFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 20) & 0xf))
   1081 
   1082 #define LOCALE_NAME_MAX_LENGTH 85
   1083 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT))
   1084 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT))
   1085 
   1086 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT,SORT_DEFAULT))
   1087 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT,SORT_DEFAULT))
   1088 
   1089 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
   1090 
   1091 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT))
   1092 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT))
   1093 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT), SORT_DEFAULT))
   1094 
   1095 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
   1096 
   1097 #define UNREFERENCED_PARAMETER(P) {(P) = (P);}
   1098 #define UNREFERENCED_LOCAL_VARIABLE(V) {(V) = (V);}
   1099 #define DBG_UNREFERENCED_PARAMETER(P) (P)
   1100 #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
   1101 
   1102 #define DEFAULT_UNREACHABLE
   1103 
   1104 #ifndef WIN32_NO_STATUS
   1105 #define STATUS_WAIT_0 ((DWORD)0x00000000)
   1106 #define STATUS_ABANDONED_WAIT_0 ((DWORD)0x00000080)
   1107 #define STATUS_USER_APC ((DWORD)0x000000C0)
   1108 #define STATUS_TIMEOUT ((DWORD)0x00000102)
   1109 #define STATUS_PENDING ((DWORD)0x00000103)
   1110 #define DBG_EXCEPTION_HANDLED ((DWORD)0x00010001)
   1111 #define DBG_CONTINUE ((DWORD)0x00010002)
   1112 #define STATUS_SEGMENT_NOTIFICATION ((DWORD)0x40000005)
   1113 #define DBG_TERMINATE_THREAD ((DWORD)0x40010003)
   1114 #define DBG_TERMINATE_PROCESS ((DWORD)0x40010004)
   1115 #define DBG_CONTROL_C ((DWORD)0x40010005)
   1116 #define DBG_PRINTEXCEPTION_C ((DWORD)0x40010006)
   1117 #define DBG_RIPEXCEPTION ((DWORD)0x40010007)
   1118 #define DBG_CONTROL_BREAK ((DWORD)0x40010008)
   1119 #define DBG_COMMAND_EXCEPTION ((DWORD)0x40010009)
   1120 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD)0x80000001)
   1121 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD)0x80000002)
   1122 #define STATUS_BREAKPOINT ((DWORD)0x80000003)
   1123 #define STATUS_SINGLE_STEP ((DWORD)0x80000004)
   1124 #define STATUS_LONGJUMP ((DWORD)0x80000026)
   1125 #define STATUS_UNWIND_CONSOLIDATE ((DWORD)0x80000029)
   1126 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD)0x80010001)
   1127 #define STATUS_ACCESS_VIOLATION ((DWORD)0xC0000005)
   1128 #define STATUS_IN_PAGE_ERROR ((DWORD)0xC0000006)
   1129 #define STATUS_INVALID_HANDLE ((DWORD)0xC0000008)
   1130 #define STATUS_INVALID_PARAMETER ((DWORD)0xC000000D)
   1131 #define STATUS_NO_MEMORY ((DWORD)0xC0000017)
   1132 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD)0xC000001D)
   1133 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD)0xC0000025)
   1134 #define STATUS_INVALID_DISPOSITION ((DWORD)0xC0000026)
   1135 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD)0xC000008C)
   1136 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD)0xC000008D)
   1137 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD)0xC000008E)
   1138 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD)0xC000008F)
   1139 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD)0xC0000090)
   1140 #define STATUS_FLOAT_OVERFLOW ((DWORD)0xC0000091)
   1141 #define STATUS_FLOAT_STACK_CHECK ((DWORD)0xC0000092)
   1142 #define STATUS_FLOAT_UNDERFLOW ((DWORD)0xC0000093)
   1143 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD)0xC0000094)
   1144 #define STATUS_INTEGER_OVERFLOW ((DWORD)0xC0000095)
   1145 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD)0xC0000096)
   1146 #define STATUS_STACK_OVERFLOW ((DWORD)0xC00000FD)
   1147 #define STATUS_DLL_NOT_FOUND ((DWORD)0xC0000135)
   1148 #define STATUS_ORDINAL_NOT_FOUND ((DWORD)0xC0000138)
   1149 #define STATUS_ENTRYPOINT_NOT_FOUND ((DWORD)0xC0000139)
   1150 #define STATUS_CONTROL_C_EXIT ((DWORD)0xC000013A)
   1151 #define STATUS_DLL_INIT_FAILED ((DWORD)0xC0000142)
   1152 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD)0xC00002B4)
   1153 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD)0xC00002B5)
   1154 #define STATUS_REG_NAT_CONSUMPTION ((DWORD)0xC00002C9)
   1155 #define STATUS_STACK_BUFFER_OVERRUN ((DWORD)0xC0000409)
   1156 #define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD)0xC0000417)
   1157 #define STATUS_ASSERTION_FAILURE ((DWORD)0xC0000420)
   1158 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD)0xC015000F)
   1159 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD)0xC0150010)
   1160 #endif
   1161 
   1162 #define MAXIMUM_WAIT_OBJECTS 64
   1163 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
   1164 
   1165   typedef ULONG_PTR KSPIN_LOCK;
   1166   typedef KSPIN_LOCK *PKSPIN_LOCK;
   1167 
   1168 #ifdef _AMD64_
   1169 
   1170 #if defined(__x86_64) && !defined(RC_INVOKED)
   1171 
   1172 #ifdef __cplusplus
   1173   extern "C" {
   1174 #endif
   1175 
   1176 #define BitTest _bittest
   1177 #define BitTestAndComplement _bittestandcomplement
   1178 #define BitTestAndSet _bittestandset
   1179 #define BitTestAndReset _bittestandreset
   1180 #define InterlockedBitTestAndSet _interlockedbittestandset
   1181 #define InterlockedBitTestAndReset _interlockedbittestandreset
   1182 #define BitTest64 _bittest64
   1183 #define BitTestAndComplement64 _bittestandcomplement64
   1184 #define BitTestAndSet64 _bittestandset64
   1185 #define BitTestAndReset64 _bittestandreset64
   1186 #define InterlockedBitTestAndSet64 _interlockedbittestandset64
   1187 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64
   1188 
   1189     BOOLEAN _bittest(LONG const *Base,LONG Offset);
   1190     BOOLEAN _bittestandcomplement(LONG *Base,LONG Offset);
   1191 
   1192 #ifndef __CRT__NO_INLINE
   1193     __CRT_INLINE BOOLEAN _bittest(LONG const *Base,LONG Offset) {
   1194       int old = 0;
   1195       __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0 "
   1196 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1197 	:"Ir" (Offset) : "memory");
   1198       return (BOOLEAN) (old!=0);
   1199     }
   1200     __CRT_INLINE BOOLEAN _bittestandcomplement(LONG *Base,LONG Offset) {
   1201       int old = 0;
   1202       __asm__ __volatile__("btcl %2,%1\n\tsbbl %0,%0 "
   1203 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1204 	:"Ir" (Offset) : "memory");
   1205       return (BOOLEAN) (old!=0);
   1206     }
   1207 #endif /* __CRT__NO_INLINE */
   1208 
   1209     BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit);
   1210     BOOLEAN _bittestandset(LONG *Base,LONG Offset);
   1211     BOOLEAN _bittestandreset(LONG *Base,LONG Offset);
   1212     BOOLEAN _interlockedbittestandset(LONG *Base,LONG Offset);
   1213     BOOLEAN _interlockedbittestandreset(LONG *Base,LONG Offset);
   1214     BOOLEAN _bittest64(LONG64 const *Base,LONG64 Offset);
   1215     BOOLEAN _bittestandcomplement64(LONG64 *Base,LONG64 Offset);
   1216     BOOLEAN _bittestandset64(LONG64 *Base,LONG64 Offset);
   1217     BOOLEAN _bittestandreset64(LONG64 *Base,LONG64 Offset);
   1218     BOOLEAN _interlockedbittestandset64(LONG64 *Base,LONG64 Offset);
   1219     BOOLEAN _interlockedbittestandreset64(LONG64 *Base,LONG64 Offset);
   1220 #ifndef __CRT__NO_INLINE
   1221     __CRT_INLINE BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit) {
   1222       int old = 0;
   1223       __asm__ __volatile__("lock ; btcl %2,%1\n\tsbbl %0,%0 "
   1224 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1225 	:"Ir" (Bit) : "memory");
   1226       return (BOOLEAN) (old!=0);
   1227     }
   1228     __CRT_INLINE BOOLEAN _bittestandset(LONG *Base,LONG Offset) {
   1229       int old = 0;
   1230       __asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0 "
   1231 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1232 	:"Ir" (Offset) : "memory");
   1233       return (BOOLEAN) (old!=0);
   1234     }
   1235     __CRT_INLINE BOOLEAN _bittestandreset(LONG *Base,LONG Offset) {
   1236       int old = 0;
   1237       __asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0 "
   1238 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1239 	:"Ir" (Offset) : "memory");
   1240       return (BOOLEAN) (old!=0);
   1241     }
   1242     __CRT_INLINE BOOLEAN _interlockedbittestandset(LONG *Base,LONG Offset) {
   1243       int old = 0;
   1244       __asm__ __volatile__("lock ; btsl %2,%1\n\tsbbl %0,%0 "
   1245 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1246 	:"Ir" (Offset) : "memory");
   1247       return (BOOLEAN) (old!=0);
   1248     }
   1249     __CRT_INLINE BOOLEAN _interlockedbittestandreset(LONG *Base,LONG Offset) {
   1250       int old = 0;
   1251       __asm__ __volatile__("lock ; btrl %2,%1\n\tsbbl %0,%0 "
   1252 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1253 	:"Ir" (Offset) : "memory");
   1254       return (BOOLEAN) (old!=0);
   1255     }
   1256     __CRT_INLINE BOOLEAN _bittest64(LONG64 const *Base,LONG64 Offset) {
   1257       int old = 0;
   1258       __asm__ __volatile__("btq %2,%1\n\tsbbl %0,%0 "
   1259 	:"=r" (old),"=m" ((*(volatile LONG64 *) Base))
   1260 	:"Ir" (Offset) : "memory");
   1261       return (BOOLEAN) (old!=0);
   1262     }
   1263     __CRT_INLINE BOOLEAN _bittestandcomplement64(LONG64 *Base,LONG64 Offset) {
   1264       int old = 0;
   1265       __asm__ __volatile__("btcq %2,%1\n\tsbbl %0,%0 "
   1266 	:"=r" (old),"=m" ((*(volatile LONG64 *) Base))
   1267 	:"Ir" (Offset) : "memory");
   1268       return (BOOLEAN) (old!=0);
   1269     }
   1270     __CRT_INLINE BOOLEAN _bittestandset64(LONG64 *Base,LONG64 Offset) {
   1271       int old = 0;
   1272       __asm__ __volatile__("btsq %2,%1\n\tsbbl %0,%0 "
   1273 	:"=r" (old),"=m" ((*(volatile LONG64 *) Base))
   1274 	:"Ir" (Offset) : "memory");
   1275       return (BOOLEAN) (old!=0);
   1276     }
   1277     __CRT_INLINE BOOLEAN _bittestandreset64(LONG64 *Base,LONG64 Offset) {
   1278       int old = 0;
   1279       __asm__ __volatile__("btrq %2,%1\n\tsbbl %0,%0 "
   1280 	:"=r" (old),"=m" ((*(volatile LONG64 *) Base))
   1281 	:"Ir" (Offset) : "memory");
   1282       return (BOOLEAN) (old!=0);
   1283     }
   1284     __CRT_INLINE BOOLEAN _interlockedbittestandset64(LONG64 *Base,LONG64 Offset) {
   1285       int old = 0;
   1286       __asm__ __volatile__("lock ; btsq %2,%1\n\tsbbl %0,%0 "
   1287 	:"=r" (old),"=m" ((*(volatile LONG64 *) Base))
   1288 	:"Ir" (Offset) : "memory");
   1289       return (BOOLEAN) (old!=0);
   1290     }
   1291     __CRT_INLINE BOOLEAN _interlockedbittestandreset64(LONG64 *Base,LONG64 Offset) {
   1292       int old = 0;
   1293       __asm__ __volatile__("lock ; btrq %2,%1\n\tsbbl %0,%0 "
   1294 	:"=r" (old),"=m" ((*(volatile LONG64 *) Base))
   1295 	:"Ir" (Offset) : "memory");
   1296       return (BOOLEAN) (old!=0);
   1297     }
   1298 #endif /* !__CRT__NO_INLINE */
   1299 
   1300 #define BitScanForward _BitScanForward
   1301 #define BitScanReverse _BitScanReverse
   1302 #define BitScanForward64 _BitScanForward64
   1303 #define BitScanReverse64 _BitScanReverse64
   1304 
   1305     BOOLEAN _BitScanForward(DWORD *Index,DWORD Mask);
   1306     BOOLEAN _BitScanReverse(DWORD *Index,DWORD Mask);
   1307     BOOLEAN _BitScanForward64(DWORD *Index,DWORD64 Mask);
   1308     BOOLEAN _BitScanReverse64(DWORD *Index,DWORD64 Mask);
   1309 
   1310 #ifndef __CRT__NO_INLINE
   1311     __CRT_INLINE BOOLEAN _BitScanForward(DWORD *Index,DWORD Mask) {
   1312       DWORD n;
   1313       __asm__ __volatile__("bsfl %0,%1" : "+r" (Mask),"=rm" (n) : : "memory");
   1314       *Index = n;
   1315       return Mask!=0;
   1316     }
   1317     __CRT_INLINE BOOLEAN _BitScanReverse(DWORD *Index,DWORD Mask) {
   1318      DWORD n;
   1319       __asm__ __volatile__("bsrl %0,%1" : "+r" (Mask),"=rm" (n) : : "memory");
   1320       *Index = n;
   1321       return Mask!=0;
   1322     }
   1323     __CRT_INLINE BOOLEAN _BitScanForward64(DWORD *Index,DWORD64 Mask) {
   1324       DWORD64 n;
   1325       __asm__ __volatile__("bsfq %0,%1" : "+r" (Mask),"=rm" (n) : : "memory");
   1326       *Index = (DWORD) n;
   1327       return Mask!=0;
   1328     }
   1329     __CRT_INLINE BOOLEAN _BitScanReverse64(DWORD *Index,DWORD64 Mask) {
   1330       DWORD64 n;
   1331       __asm__ __volatile__("bsrq %0,%1" : "+r" (Mask),"=rm" (n) : : "memory");
   1332       *Index = (DWORD) n;
   1333       return Mask!=0;
   1334     }
   1335 #endif /* !__CRT__NO_INLINE */
   1336 
   1337 #define InterlockedIncrement16 _InterlockedIncrement16
   1338 #define InterlockedDecrement16 _InterlockedDecrement16
   1339 #define InterlockedCompareExchange16 _InterlockedCompareExchange16
   1340 
   1341 #define InterlockedAnd _InterlockedAnd
   1342 #define InterlockedOr _InterlockedOr
   1343 #define InterlockedXor _InterlockedXor
   1344 #define InterlockedIncrement _InterlockedIncrement
   1345 #define InterlockedIncrementAcquire InterlockedIncrement
   1346 #define InterlockedIncrementRelease InterlockedIncrement
   1347 #define InterlockedDecrement _InterlockedDecrement
   1348 #define InterlockedDecrementAcquire InterlockedDecrement
   1349 #define InterlockedDecrementRelease InterlockedDecrement
   1350 #define InterlockedAdd _InterlockedAdd
   1351 #define InterlockedExchange _InterlockedExchange
   1352 #define InterlockedExchangeAdd _InterlockedExchangeAdd
   1353 #define InterlockedCompareExchange _InterlockedCompareExchange
   1354 #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
   1355 #define InterlockedCompareExchangeRelease InterlockedCompareExchange
   1356 
   1357 #define InterlockedAnd64 _InterlockedAnd64
   1358 #define InterlockedAndAffinity InterlockedAnd64
   1359 #define InterlockedOr64 _InterlockedOr64
   1360 #define InterlockedOrAffinity InterlockedOr64
   1361 #define InterlockedXor64 _InterlockedXor64
   1362 #define InterlockedIncrement64 _InterlockedIncrement64
   1363 #define InterlockedDecrement64 _InterlockedDecrement64
   1364 #define InterlockedAdd64 _InterlockedAdd64
   1365 #define InterlockedExchange64 _InterlockedExchange64
   1366 #define InterlockedExchangeAcquire64 InterlockedExchange64
   1367 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
   1368 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
   1369 #define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
   1370 #define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
   1371 
   1372 #define InterlockedExchangePointer _InterlockedExchangePointer
   1373 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
   1374 #define InterlockedCompareExchangePointerAcquire _InterlockedCompareExchangePointer
   1375 #define InterlockedCompareExchangePointerRelease _InterlockedCompareExchangePointer
   1376 
   1377 #define InterlockedExchangeAddSizeT(a,b) InterlockedExchangeAdd64((LONG64 *)a,b)
   1378 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONG64 *)a)
   1379 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONG64 *)a)
   1380 
   1381     SHORT InterlockedIncrement16(SHORT volatile *Addend);
   1382     SHORT InterlockedDecrement16(SHORT volatile *Addend);
   1383     SHORT InterlockedCompareExchange16(SHORT volatile *Destination,SHORT ExChange,SHORT Comperand);
   1384     LONG InterlockedAnd(LONG volatile *Destination,LONG Value);
   1385     LONG InterlockedOr(LONG volatile *Destination,LONG Value);
   1386     LONG InterlockedXor(LONG volatile *Destination,LONG Value);
   1387     LONG InterlockedIncrement(LONG volatile *Addend);
   1388     LONG InterlockedDecrement(LONG volatile *Addend);
   1389     LONG InterlockedExchange(LONG volatile *Target,LONG Value);
   1390     LONG64 InterlockedAnd64(LONG64 volatile *Destination,LONG64 Value);
   1391     LONG64 InterlockedOr64(LONG64 volatile *Destination,LONG64 Value);
   1392     LONG64 InterlockedXor64(LONG64 volatile *Destination,LONG64 Value);
   1393 
   1394 #ifndef __CRT__NO_INLINE
   1395     __CRT_INLINE SHORT InterlockedIncrement16(SHORT volatile *Addend) {
   1396       SHORT ret = 1;
   1397       __asm__ __volatile__("lock\n\t"
   1398 		   "xaddw %0,%1"
   1399 		   : "+r" (ret), "+m" (*Addend)
   1400 		   : : "memory");
   1401       return ret + 1;
   1402     }
   1403     __CRT_INLINE SHORT InterlockedDecrement16(SHORT volatile *Addend) {
   1404       SHORT ret = -1;
   1405       __asm__ __volatile__("lock\n\t"
   1406 		   "xaddw %0,%1"
   1407 		   : "+r" (ret), "+m" (*Addend)
   1408 		   : : "memory");
   1409       return ret - 1;
   1410     }
   1411     __CRT_INLINE SHORT InterlockedCompareExchange16(SHORT volatile *Destination,SHORT ExChange,SHORT Comperand) {
   1412       SHORT prev;
   1413       __asm__ __volatile__("lock ; cmpxchgw %w1,%2"
   1414 	:"=a"(prev)
   1415 	:"q"(ExChange), "m"(*Destination), "0"(Comperand)
   1416 	: "memory");
   1417       return prev;
   1418     }
   1419     __CRT_INLINE LONG InterlockedAnd(LONG volatile *Destination,LONG Value) {
   1420       __asm__ __volatile__("lock ; andl %0,%1"
   1421 	: :"r"(Value),"m"(*Destination)
   1422 	: "memory");
   1423       return *Destination;
   1424     }
   1425     __CRT_INLINE LONG InterlockedOr(LONG volatile *Destination,LONG Value) {
   1426       __asm__ __volatile__("lock ; orl %0,%1"
   1427 	: : "r"(Value),"m"(*Destination) : "memory");
   1428       return *Destination;
   1429     }
   1430     __CRT_INLINE LONG InterlockedXor(LONG volatile *Destination,LONG Value) {
   1431       __asm__ __volatile__("lock ; xorl %0,%1"
   1432 	: : "r"(Value),"m"(*Destination) : "memory");
   1433       return *Destination;
   1434     }
   1435     __CRT_INLINE LONG64 InterlockedAnd64(LONG64 volatile *Destination,LONG64 Value) {
   1436       __asm__ __volatile__("lock ; andq %0,%1"
   1437 	: : "r"(Value),"m"(*Destination) : "memory");
   1438       return *Destination;
   1439     }
   1440     __CRT_INLINE LONG64 InterlockedOr64(LONG64 volatile *Destination,LONG64 Value) {
   1441       __asm__ __volatile__("lock ; orq %0,%1"
   1442 	: : "r"(Value),"m"(*Destination) : "memory");
   1443       return *Destination;
   1444     }
   1445     __CRT_INLINE LONG64 InterlockedXor64(LONG64 volatile *Destination,LONG64 Value) {
   1446       __asm__ __volatile__("lock ; xorq %0,%1"
   1447 	: : "r"(Value),"m"(*Destination) : "memory");
   1448       return *Destination;
   1449     }
   1450 #endif /* !__CRT__NO_INLINE */
   1451 
   1452     LONG InterlockedExchangeAdd(LONG volatile *Addend,LONG Value);
   1453     LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange,LONG Comperand);
   1454     LONG InterlockedAdd(LONG volatile *Addend,LONG Value);
   1455     LONG64 InterlockedIncrement64(LONG64 volatile *Addend);
   1456     LONG64 InterlockedDecrement64(LONG64 volatile *Addend);
   1457     LONG64 InterlockedExchange64(LONG64 volatile *Target,LONG64 Value);
   1458 
   1459 #ifndef __CRT__NO_INLINE
   1460     __CRT_INLINE LONG InterlockedAdd(LONG volatile *Addend,LONG Value) { return InterlockedExchangeAdd(Addend,Value) + Value; }
   1461     __CRT_INLINE LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange,LONG Comperand) {
   1462       LONG prev;
   1463       __asm__ __volatile__("lock ; cmpxchgl %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
   1464       return prev;
   1465     }
   1466     __CRT_INLINE LONG64 InterlockedIncrement64(LONG64 volatile *Addend) {
   1467       LONG64 ret = 1LL;
   1468       __asm__ __volatile__ ("lock\n\t"
   1469 	       "xaddq %0,%1"
   1470 	       : "+r" (ret), "+m" (*Addend)
   1471 	       : : "memory");
   1472       return ret + 1LL;
   1473     }
   1474     __CRT_INLINE LONG64 InterlockedDecrement64(LONG64 volatile *Addend) {
   1475       LONG64 ret = -1LL;
   1476       __asm__ __volatile__ ("lock\n\t"
   1477 	       "xaddq %0,%1"
   1478 	       : "+r" (ret), "+m" (*Addend)
   1479 	       : : "memory");
   1480       return ret - 1LL;
   1481     }
   1482     __CRT_INLINE LONG64 InterlockedExchange64(LONG64 volatile *Target,LONG64 Value) {
   1483       __asm__ __volatile("lock ; xchgq %0,%1"
   1484 	: "=r"(Value)
   1485 	: "m"(*Target),"0"(Value)
   1486 	: "memory");
   1487       return Value;
   1488     }
   1489 #endif /* !__CRT__NO_INLINE */
   1490 
   1491     LONG64 InterlockedExchangeAdd64(LONG64 volatile *Addend,LONG64 Value);
   1492     LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value);
   1493     LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination,LONG64 ExChange,LONG64 Comperand);
   1494     PVOID InterlockedCompareExchangePointer(PVOID volatile *Destination,PVOID ExChange,PVOID Comperand);
   1495     PVOID InterlockedExchangePointer(PVOID volatile *Target,PVOID Value);
   1496 
   1497 #ifndef __CRT__NO_INLINE
   1498     __CRT_INLINE LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value) { return InterlockedExchangeAdd64(Addend,Value) + Value; }
   1499     __CRT_INLINE LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination,LONG64 ExChange,LONG64 Comperand) {
   1500       LONG64 prev;
   1501       __asm__ __volatile__("lock ; cmpxchgq %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
   1502       return prev;
   1503     }
   1504     __CRT_INLINE PVOID InterlockedCompareExchangePointer(PVOID volatile *Destination,PVOID ExChange,PVOID Comperand) {
   1505       PVOID prev;
   1506       __asm__ __volatile__("lock ; cmpxchgq %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
   1507       return prev;
   1508     }
   1509     __CRT_INLINE PVOID InterlockedExchangePointer(PVOID volatile *Target,PVOID Value) {
   1510       __asm__ __volatile("lock ; xchgq %0,%1"
   1511 	: "=r"(Value)
   1512 	: "m"(*Target),"0"(Value)
   1513 	: "memory");
   1514       return Value;
   1515     }
   1516 #endif /* !__CRT__NO_INLINE */
   1517 
   1518 #define CacheLineFlush(Address) _mm_clflush(Address)
   1519 
   1520     VOID _ReadWriteBarrier(VOID);
   1521 
   1522 /* Don't include intrin.h on Cygwin.  It pulls in unneeded stuff. */
   1523 #ifdef __CYGWIN__
   1524 # if defined(__cplusplus)
   1525 extern "C" {
   1526 # endif
   1527 # include <x86intrin.h>
   1528 # if defined(__cplusplus)
   1529 }
   1530 # endif
   1531 #else /* !__CYGWIN__ */
   1532 # include <intrin.h>
   1533 #endif /* __CYGWIN__ */
   1534 
   1535 #define FastFence __faststorefence
   1536 #define LoadFence _mm_lfence
   1537 #define MemoryFence _mm_mfence
   1538 #define StoreFence _mm_sfence
   1539 
   1540 #ifdef __MINGW_INTRIN_INLINE
   1541     __MINGW_INTRIN_INLINE void __faststorefence(void) {
   1542       __asm__ __volatile__ ("" ::: "memory");
   1543     }
   1544 #endif
   1545 
   1546 #define YieldProcessor _mm_pause
   1547 #define MemoryBarrier __faststorefence
   1548 #define PreFetchCacheLine(l,a) _mm_prefetch((CHAR CONST *) a,l)
   1549 #define PrefetchForWrite(p) _m_prefetchw(p)
   1550 #define ReadForWriteAccess(p) (_m_prefetchw(p),*(p))
   1551 
   1552 #define PF_TEMPORAL_LEVEL_1 _MM_HINT_T0
   1553 #define PF_TEMPORAL_LEVEL_2 _MM_HINT_T1
   1554 #define PF_TEMPORAL_LEVEL_3 _MM_HINT_T2
   1555 #define PF_NON_TEMPORAL_LEVEL_ALL _MM_HINT_NTA
   1556 
   1557 #define ReadMxCsr _mm_getcsr
   1558 #define WriteMxCsr _mm_setcsr
   1559 
   1560     VOID __int2c(VOID);
   1561 
   1562 #define DbgRaiseAssertionFailure() __int2c()
   1563 #define GetCallersEflags() __getcallerseflags()
   1564 
   1565     unsigned __int32 __getcallerseflags(VOID);
   1566 
   1567 #define GetSegmentLimit __segmentlimit
   1568 
   1569     DWORD __segmentlimit(DWORD Selector);
   1570 
   1571 #define ReadTimeStampCounter() __rdtsc()
   1572 
   1573     VOID __movsb(PBYTE Destination,BYTE const *Source,SIZE_T Count);
   1574     VOID __movsw(PWORD Destination,WORD const *Source,SIZE_T Count);
   1575     VOID __movsd(PDWORD Destination,DWORD const *Source,SIZE_T Count);
   1576     VOID __movsq(PDWORD64 Destination,DWORD64 const *Source,SIZE_T Count);
   1577     VOID __stosb(PBYTE Destination,BYTE Value,SIZE_T Count);
   1578     VOID __stosw(PWORD Destination,WORD Value,SIZE_T Count);
   1579     VOID __stosd(PDWORD Destination,DWORD Value,SIZE_T Count);
   1580     VOID __stosq(PDWORD64 Destination,DWORD64 Value,SIZE_T Count);
   1581 
   1582 #ifndef __CRT__NO_INLINE
   1583     __CRT_INLINE VOID __stosb(PBYTE Dest,BYTE Data,SIZE_T Count)
   1584     {
   1585       __asm__ __volatile__
   1586       (
   1587         "rep; stosb" :
   1588         [Dest] "=D" (Dest), [Count] "=c" (Count) :
   1589         "[Dest]" (Dest), "a" (Data), "[Count]" (Count)
   1590       );
   1591     }
   1592     __CRT_INLINE VOID __stosw(PWORD Dest,WORD Data,SIZE_T Count)
   1593     {
   1594       __asm__ __volatile__
   1595       (
   1596         "rep; stosw" :
   1597         [Dest] "=D" (Dest), [Count] "=c" (Count) :
   1598         "[Dest]" (Dest), "a" (Data), "[Count]" (Count)
   1599       );
   1600     }
   1601     __CRT_INLINE VOID __stosd(PDWORD Dest,DWORD Data,SIZE_T Count)
   1602     {
   1603       __asm__ __volatile__
   1604       (
   1605         "rep; stosl" :
   1606         [Dest] "=D" (Dest), [Count] "=c" (Count) :
   1607         "[Dest]" (Dest), "a" (Data), "[Count]" (Count)
   1608       );
   1609     }
   1610     __CRT_INLINE VOID __stosq(PDWORD64 Dest,DWORD64 Data,SIZE_T Count)
   1611     {
   1612       __asm__ __volatile__
   1613       (
   1614         "rep; stosq" :
   1615         [Dest] "=D" (Dest), [Count] "=c" (Count) :
   1616         "[Dest]" (Dest), "a" (Data), "[Count]" (Count)
   1617       );
   1618     }
   1619 #endif /* __CRT__NO_INLINE */
   1620 
   1621 #define MultiplyHigh __mulh
   1622 #define UnsignedMultiplyHigh __umulh
   1623 
   1624     LONGLONG MultiplyHigh(LONGLONG Multiplier,LONGLONG Multiplicand);
   1625     ULONGLONG UnsignedMultiplyHigh(ULONGLONG Multiplier,ULONGLONG Multiplicand);
   1626 
   1627 #define ShiftLeft128 __shiftleft128
   1628 #define ShiftRight128 __shiftright128
   1629 
   1630     DWORD64 ShiftLeft128(DWORD64 LowPart,DWORD64 HighPart,BYTE Shift);
   1631     DWORD64 ShiftRight128(DWORD64 LowPart,DWORD64 HighPart,BYTE Shift);
   1632 
   1633 #define Multiply128 _mul128
   1634 
   1635     LONG64 Multiply128(LONG64 Multiplier,LONG64 Multiplicand,LONG64 *HighProduct);
   1636 
   1637 #define UnsignedMultiply128 _umul128
   1638 
   1639     DWORD64 UnsignedMultiply128(DWORD64 Multiplier,DWORD64 Multiplicand,DWORD64 *HighProduct);
   1640 
   1641     LONG64 MultiplyExtract128(LONG64 Multiplier,LONG64 Multiplicand,BYTE Shift);
   1642     DWORD64 UnsignedMultiplyExtract128(DWORD64 Multiplier,DWORD64 Multiplicand,BYTE Shift);
   1643 
   1644 #ifndef __CRT__NO_INLINE
   1645     __CRT_INLINE LONG64 MultiplyExtract128(LONG64 Multiplier,LONG64 Multiplicand,BYTE Shift) {
   1646       LONG64 extractedProduct;
   1647       LONG64 highProduct;
   1648       LONG64 lowProduct;
   1649       lowProduct = Multiply128(Multiplier,Multiplicand,&highProduct);
   1650       extractedProduct = (LONG64)ShiftRight128((LONG64)lowProduct,(LONG64)highProduct,Shift);
   1651       return extractedProduct;
   1652     }
   1653 
   1654     __CRT_INLINE DWORD64 UnsignedMultiplyExtract128(DWORD64 Multiplier,DWORD64 Multiplicand,BYTE Shift) {
   1655       DWORD64 extractedProduct;
   1656       DWORD64 highProduct;
   1657       DWORD64 lowProduct;
   1658       lowProduct = UnsignedMultiply128(Multiplier,Multiplicand,&highProduct);
   1659       extractedProduct = ShiftRight128(lowProduct,highProduct,Shift);
   1660       return extractedProduct;
   1661     }
   1662 #endif
   1663 
   1664     __CRT_INLINE BYTE __readgsbyte(DWORD Offset) {
   1665       BYTE ret;
   1666       __asm__ volatile ("movb	%%gs:%1,%0"
   1667 	: "=r" (ret) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1668       return ret;
   1669     }
   1670     __CRT_INLINE WORD __readgsword(DWORD Offset) {
   1671       WORD ret;
   1672       __asm__ volatile ("movw	%%gs:%1,%0"
   1673 	: "=r" (ret) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1674       return ret;
   1675     }
   1676     __CRT_INLINE DWORD __readgsdword(DWORD Offset) {
   1677       DWORD ret;
   1678       __asm__ volatile ("movl	%%gs:%1,%0"
   1679 	: "=r" (ret) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1680       return ret;
   1681     }
   1682     __CRT_INLINE DWORD64 __readgsqword(DWORD Offset) {
   1683       void *ret;
   1684       __asm__ volatile ("movq	%%gs:%1,%0"
   1685 	: "=r" (ret) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1686       return (DWORD64) ret;
   1687     }
   1688     __CRT_INLINE VOID __writegsbyte(DWORD Offset,BYTE Data) {
   1689       __asm__ volatile ("movb	%0,%%gs:%1"
   1690 	: "=r" (Data) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1691     }
   1692     __CRT_INLINE VOID __writegsword(DWORD Offset,WORD Data) {
   1693       __asm__ volatile ("movw	%0,%%gs:%1"
   1694 	: "=r" (Data) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1695     }
   1696     __CRT_INLINE VOID __writegsdword(DWORD Offset,DWORD Data) {
   1697       __asm__ volatile ("movl	%0,%%gs:%1"
   1698 	: "=r" (Data) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1699     }
   1700     __CRT_INLINE VOID __writegsqword(DWORD Offset,DWORD64 Data) {
   1701       __asm__ volatile ("movq	%0,%%gs:%1"
   1702 	: "=r" (Data) ,"=m" ((*(volatile __LONG32 *) (DWORD64) Offset)));
   1703     }
   1704 
   1705 #ifdef __cplusplus
   1706   }
   1707 #endif
   1708 #endif /* defined(__x86_64) && !defined(RC_INVOKED) */
   1709 
   1710 #define EXCEPTION_READ_FAULT 0
   1711 #define EXCEPTION_WRITE_FAULT 1
   1712 #define EXCEPTION_EXECUTE_FAULT 8
   1713 
   1714 #if !defined(RC_INVOKED)
   1715 
   1716 #define CONTEXT_AMD64 0x100000
   1717 
   1718 #define CONTEXT_CONTROL (CONTEXT_AMD64 | __MSABI_LONG(0x1))
   1719 #define CONTEXT_INTEGER (CONTEXT_AMD64 | __MSABI_LONG(0x2))
   1720 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | __MSABI_LONG(0x4))
   1721 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | __MSABI_LONG(0x8))
   1722 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | __MSABI_LONG(0x10))
   1723 
   1724 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
   1725 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
   1726 
   1727 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
   1728 #define CONTEXT_SERVICE_ACTIVE 0x10000000
   1729 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
   1730 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
   1731 #endif /* !defined(RC_INVOKED) */
   1732 
   1733 #define INITIAL_MXCSR 0x1f80
   1734 #define INITIAL_FPCSR 0x027f
   1735 
   1736   typedef struct DECLSPEC_ALIGN(16) _M128A {
   1737     ULONGLONG Low;
   1738     LONGLONG High;
   1739   } M128A,*PM128A;
   1740 
   1741   typedef struct _XMM_SAVE_AREA32 {
   1742     WORD ControlWord;
   1743     WORD StatusWord;
   1744     BYTE TagWord;
   1745     BYTE Reserved1;
   1746     WORD ErrorOpcode;
   1747     DWORD ErrorOffset;
   1748     WORD ErrorSelector;
   1749     WORD Reserved2;
   1750     DWORD DataOffset;
   1751     WORD DataSelector;
   1752     WORD Reserved3;
   1753     DWORD MxCsr;
   1754     DWORD MxCsr_Mask;
   1755     M128A FloatRegisters[8];
   1756     M128A XmmRegisters[16];
   1757     BYTE Reserved4[96];
   1758   } XMM_SAVE_AREA32,*PXMM_SAVE_AREA32;
   1759 
   1760 #define LEGACY_SAVE_AREA_LENGTH sizeof(XMM_SAVE_AREA32)
   1761 
   1762   typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
   1763     DWORD64 P1Home;
   1764     DWORD64 P2Home;
   1765     DWORD64 P3Home;
   1766     DWORD64 P4Home;
   1767     DWORD64 P5Home;
   1768     DWORD64 P6Home;
   1769     DWORD ContextFlags;
   1770     DWORD MxCsr;
   1771     WORD SegCs;
   1772     WORD SegDs;
   1773     WORD SegEs;
   1774     WORD SegFs;
   1775     WORD SegGs;
   1776     WORD SegSs;
   1777     DWORD EFlags;
   1778     DWORD64 Dr0;
   1779     DWORD64 Dr1;
   1780     DWORD64 Dr2;
   1781     DWORD64 Dr3;
   1782     DWORD64 Dr6;
   1783     DWORD64 Dr7;
   1784     DWORD64 Rax;
   1785     DWORD64 Rcx;
   1786     DWORD64 Rdx;
   1787     DWORD64 Rbx;
   1788     DWORD64 Rsp;
   1789     DWORD64 Rbp;
   1790     DWORD64 Rsi;
   1791     DWORD64 Rdi;
   1792     DWORD64 R8;
   1793     DWORD64 R9;
   1794     DWORD64 R10;
   1795     DWORD64 R11;
   1796     DWORD64 R12;
   1797     DWORD64 R13;
   1798     DWORD64 R14;
   1799     DWORD64 R15;
   1800     DWORD64 Rip;
   1801     __C89_NAMELESS union {
   1802       XMM_SAVE_AREA32 FltSave;
   1803       XMM_SAVE_AREA32 FloatSave;
   1804       __C89_NAMELESS struct {
   1805 	M128A Header[2];
   1806 	M128A Legacy[8];
   1807 	M128A Xmm0;
   1808 	M128A Xmm1;
   1809 	M128A Xmm2;
   1810 	M128A Xmm3;
   1811 	M128A Xmm4;
   1812 	M128A Xmm5;
   1813 	M128A Xmm6;
   1814 	M128A Xmm7;
   1815 	M128A Xmm8;
   1816 	M128A Xmm9;
   1817 	M128A Xmm10;
   1818 	M128A Xmm11;
   1819 	M128A Xmm12;
   1820 	M128A Xmm13;
   1821 	M128A Xmm14;
   1822 	M128A Xmm15;
   1823       };
   1824     };
   1825     M128A VectorRegister[26];
   1826     DWORD64 VectorControl;
   1827     DWORD64 DebugControl;
   1828     DWORD64 LastBranchToRip;
   1829     DWORD64 LastBranchFromRip;
   1830     DWORD64 LastExceptionToRip;
   1831     DWORD64 LastExceptionFromRip;
   1832   } CONTEXT,*PCONTEXT;
   1833 
   1834 #define RUNTIME_FUNCTION_INDIRECT 0x1
   1835 
   1836   typedef struct _RUNTIME_FUNCTION {
   1837     DWORD BeginAddress;
   1838     DWORD EndAddress;
   1839     DWORD UnwindData;
   1840   } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
   1841 
   1842   typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
   1843   typedef DWORD (*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)(HANDLE Process,PVOID TableAddress,PDWORD Entries,PRUNTIME_FUNCTION *Functions);
   1844 
   1845 #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
   1846 
   1847   NTSYSAPI VOID __cdecl RtlRestoreContext (PCONTEXT ContextRecord,struct _EXCEPTION_RECORD *ExceptionRecord);
   1848   NTSYSAPI BOOLEAN __cdecl RtlAddFunctionTable(PRUNTIME_FUNCTION FunctionTable,DWORD EntryCount,DWORD64 BaseAddress);
   1849   NTSYSAPI BOOLEAN __cdecl RtlInstallFunctionTableCallback(DWORD64 TableIdentifier,DWORD64 BaseAddress,DWORD Length,PGET_RUNTIME_FUNCTION_CALLBACK Callback,PVOID Context,PCWSTR OutOfProcessCallbackDll);
   1850   NTSYSAPI BOOLEAN __cdecl RtlDeleteFunctionTable(PRUNTIME_FUNCTION FunctionTable);
   1851 
   1852 #endif /* end of _AMD64_ */
   1853 
   1854 
   1855 #ifdef _X86_
   1856 
   1857 #if defined(__i386__) && !defined(__x86_64) && !defined(RC_INVOKED)
   1858 #ifdef __cplusplus
   1859   extern "C" {
   1860 #endif
   1861 
   1862 #define BitTest _bittest
   1863 #define BitTestAndComplement _bittestandcomplement
   1864 #define BitTestAndSet _bittestandset
   1865 #define BitTestAndReset _bittestandreset
   1866 #define InterlockedBitTestAndSet _interlockedbittestandset
   1867 #define InterlockedBitTestAndReset _interlockedbittestandreset
   1868 
   1869 #define BitScanForward _BitScanForward
   1870 #define BitScanReverse _BitScanReverse
   1871 
   1872 #define InterlockedIncrement16 _InterlockedIncrement16
   1873 #define InterlockedDecrement16 _InterlockedDecrement16
   1874 #define InterlockedCompareExchange16 _InterlockedCompareExchange16
   1875 
   1876 #define InterlockedIncrementAcquire InterlockedIncrement
   1877 #define InterlockedIncrementRelease InterlockedIncrement
   1878 
   1879     BOOLEAN InterlockedBitTestAndSet(LONG *Base,LONG Bit);
   1880     BOOLEAN InterlockedBitTestAndReset(LONG *Base,LONG Bit);
   1881 #ifndef __CRT__NO_INLINE
   1882     __CRT_INLINE BOOLEAN InterlockedBitTestAndSet(LONG *Base,LONG Bit) {
   1883       int old = 0;
   1884       __asm__ __volatile__("lock ; btsl %2,%1\n\tsbbl %0,%0 "
   1885 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1886 	:"Ir" (Bit) : "memory");
   1887       return (BOOLEAN) (old!=0);
   1888     }
   1889 
   1890     __CRT_INLINE BOOLEAN InterlockedBitTestAndReset(LONG *Base,LONG Bit) {
   1891       int old = 0;
   1892       __asm__ __volatile__("lock ; btrl %2,%1\n\tsbbl %0,%0 "
   1893 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1894 	:"Ir" (Bit) : "memory");
   1895       return (BOOLEAN) (old!=0);
   1896     }
   1897 #endif /* __CRT__NO_INLINE */
   1898 
   1899     BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit);
   1900 #ifndef __CRT__NO_INLINE
   1901     __CRT_INLINE BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit) {
   1902       int old = 0;
   1903       __asm__ __volatile__("lock ; btcl %2,%1\n\tsbbl %0,%0 "
   1904 	:"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
   1905 	:"Ir" (Bit));
   1906       return (BOOLEAN) (old!=0);
   1907     }
   1908 #endif /* !__CRT__NO_INLINE */
   1909 
   1910 #ifdef _PREFIX_
   1911     BYTE __readfsbyte(DWORD Offset);
   1912     WORD __readfsword(DWORD Offset);
   1913     DWORD __readfsdword(DWORD Offset);
   1914     VOID __writefsbyte(DWORD Offset,BYTE Data);
   1915     VOID __writefsword(DWORD Offset,WORD Data);
   1916     VOID __writefsdword(DWORD Offset,DWORD Data);
   1917 #endif
   1918 
   1919 #ifdef __cplusplus
   1920   }
   1921 #endif
   1922 #endif /* defined(__i386__) && !defined(__x86_64) && !defined(RC_INVOKED) */
   1923 
   1924 #if defined(__i386__) && !defined(__x86_64)
   1925 
   1926 #define YieldProcessor() __asm__ __volatile__("rep; nop");
   1927 
   1928 #define PreFetchCacheLine(l,a)
   1929 #define ReadForWriteAccess(p) (*(p))
   1930 
   1931 #define PF_TEMPORAL_LEVEL_1
   1932 #define PF_NON_TEMPORAL_LEVEL_ALL
   1933 
   1934 #define PcTeb 0x18
   1935   struct _TEB *NtCurrentTeb(void);
   1936   PVOID GetCurrentFiber(void);
   1937   PVOID GetFiberData(void);
   1938   VOID MemoryBarrier(VOID);
   1939 
   1940 #ifdef __CRT__NO_INLINE
   1941 # define DbgRaiseAssertionFailure() __asm__ __volatile__("int $0x2c");
   1942 #else
   1943   VOID DbgRaiseAssertionFailure(void);
   1944   __CRT_INLINE VOID DbgRaiseAssertionFailure(void) {
   1945     __asm__ __volatile__("int $0x2c");
   1946   }
   1947 #endif
   1948 
   1949   __CRT_INLINE VOID MemoryBarrier(VOID)
   1950   {
   1951     LONG Barrier = 0;
   1952     __asm__ __volatile__("xchgl %%eax,%0 "
   1953       :"=r" (Barrier));
   1954   }
   1955 
   1956   __CRT_INLINE struct _TEB *NtCurrentTeb(void)
   1957   {
   1958     struct _TEB *ret;
   1959     __asm__ volatile ("movl	%%fs:0x18,%0"
   1960 	: "=r" (ret));
   1961     return ret;
   1962   }
   1963   __CRT_INLINE PVOID GetCurrentFiber(void)
   1964   {
   1965     void *ret;
   1966     __asm__ volatile ("movl	%%fs:0x10,%0"
   1967 	: "=r" (ret));
   1968     return ret;
   1969   }
   1970   __CRT_INLINE PVOID GetFiberData(void)
   1971   {
   1972     void *ret;
   1973     __asm__ volatile ("movl	%%fs:0x10,%0\n"
   1974 	"movl	(%0),%0"
   1975 	: "=r" (ret));
   1976     return ret;
   1977   }
   1978 #endif /* defined(__i386__) && !defined(__x86_64) */
   1979 
   1980 #define EXCEPTION_READ_FAULT 0
   1981 #define EXCEPTION_WRITE_FAULT 1
   1982 #define EXCEPTION_EXECUTE_FAULT 8
   1983 
   1984 #define SIZE_OF_80387_REGISTERS 80
   1985 
   1986 #if !defined(RC_INVOKED)
   1987 
   1988 #define CONTEXT_i386 0x00010000
   1989 #define CONTEXT_i486 0x00010000
   1990 
   1991 #define CONTEXT_CONTROL (CONTEXT_i386 | __MSABI_LONG(0x00000001))
   1992 #define CONTEXT_INTEGER (CONTEXT_i386 | __MSABI_LONG(0x00000002))
   1993 #define CONTEXT_SEGMENTS (CONTEXT_i386 | __MSABI_LONG(0x00000004))
   1994 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | __MSABI_LONG(0x00000008))
   1995 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | __MSABI_LONG(0x00000010))
   1996 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | __MSABI_LONG(0x00000020))
   1997 
   1998 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
   1999 
   2000 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
   2001 #endif /* !defined(RC_INVOKED) */
   2002 
   2003 #define MAXIMUM_SUPPORTED_EXTENSION 512
   2004 
   2005     typedef struct _FLOATING_SAVE_AREA {
   2006       DWORD ControlWord;
   2007       DWORD StatusWord;
   2008       DWORD TagWord;
   2009       DWORD ErrorOffset;
   2010       DWORD ErrorSelector;
   2011       DWORD DataOffset;
   2012       DWORD DataSelector;
   2013       BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
   2014       DWORD Cr0NpxState;
   2015     } FLOATING_SAVE_AREA;
   2016 
   2017     typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
   2018 
   2019     typedef struct _CONTEXT {
   2020       DWORD ContextFlags;
   2021       DWORD Dr0;
   2022       DWORD Dr1;
   2023       DWORD Dr2;
   2024       DWORD Dr3;
   2025       DWORD Dr6;
   2026       DWORD Dr7;
   2027       FLOATING_SAVE_AREA FloatSave;
   2028       DWORD SegGs;
   2029       DWORD SegFs;
   2030       DWORD SegEs;
   2031       DWORD SegDs;
   2032 
   2033       DWORD Edi;
   2034       DWORD Esi;
   2035       DWORD Ebx;
   2036       DWORD Edx;
   2037       DWORD Ecx;
   2038       DWORD Eax;
   2039       DWORD Ebp;
   2040       DWORD Eip;
   2041       DWORD SegCs;
   2042       DWORD EFlags;
   2043       DWORD Esp;
   2044       DWORD SegSs;
   2045       BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
   2046     } CONTEXT;
   2047 
   2048     typedef CONTEXT *PCONTEXT;
   2049 
   2050 #endif /* end of _X86_ */
   2051 
   2052   LONG WINAPI InterlockedIncrement(LONG volatile *);
   2053   LONG WINAPI InterlockedDecrement(LONG volatile *);
   2054   LONG WINAPI InterlockedExchange(LONG volatile *, LONG);
   2055 
   2056 #if defined(__MINGW_INTRIN_INLINE) && (defined(__i386__) || defined(__x86_64))
   2057   __MINGW_INTRIN_INLINE LONG WINAPI InterlockedIncrement(LONG volatile *Addend) {
   2058     LONG ret = 1;
   2059     __asm__ __volatile__ ("lock\n\t"
   2060         "xaddl %0,%1"
   2061 	: "+r" (ret), "+m" (*Addend)
   2062 	: : "memory");
   2063     return ret + 1;
   2064   }
   2065   __MINGW_INTRIN_INLINE LONG WINAPI InterlockedDecrement(LONG volatile *Addend) {
   2066     LONG ret = -1;
   2067     __asm__ __volatile__ ("lock\n\t"
   2068         "xaddl %0,%1"
   2069         : "+r" (ret), "+m" (*Addend)
   2070         : : "memory");
   2071     return ret - 1;
   2072   }
   2073   __MINGW_INTRIN_INLINE LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value) {
   2074     __asm__ __volatile__ ("lock ; xchgl %0,%1"
   2075         : "=r"(Value)
   2076         : "m"(*Target),"0"(Value)
   2077         : "memory");
   2078     return Value;
   2079   }
   2080 #endif
   2081 
   2082 #ifndef _LDT_ENTRY_DEFINED
   2083 #define _LDT_ENTRY_DEFINED
   2084 
   2085     typedef struct _LDT_ENTRY {
   2086       WORD LimitLow;
   2087       WORD BaseLow;
   2088       union {
   2089 	struct {
   2090 	  BYTE BaseMid;
   2091 	  BYTE Flags1;
   2092 	  BYTE Flags2;
   2093 	  BYTE BaseHi;
   2094 	} Bytes;
   2095 	struct {
   2096 	  DWORD BaseMid : 8;
   2097 	  DWORD Type : 5;
   2098 	  DWORD Dpl : 2;
   2099 	  DWORD Pres : 1;
   2100 	  DWORD LimitHi : 4;
   2101 	  DWORD Sys : 1;
   2102 	  DWORD Reserved_0 : 1;
   2103 	  DWORD Default_Big : 1;
   2104 	  DWORD Granularity : 1;
   2105 	  DWORD BaseHi : 8;
   2106 	} Bits;
   2107       } HighWord;
   2108     } LDT_ENTRY,*PLDT_ENTRY;
   2109 #endif /* _LDT_ENTRY_DEFINED */
   2110 
   2111 #if defined(__ia64__) && !defined(RC_INVOKED)
   2112 
   2113 #ifdef __cplusplus
   2114     extern "C" {
   2115 #endif
   2116 
   2117       BOOLEAN BitScanForward64(DWORD *Index,DWORD64 Mask);
   2118       BOOLEAN BitScanReverse64(DWORD *Index,DWORD64 Mask);
   2119 
   2120 #ifdef __cplusplus
   2121     }
   2122 #endif
   2123 #endif /* defined(__ia64__) && !defined(RC_INVOKED) */
   2124 
   2125 #if !defined(GENUTIL) && !defined(_GENIA64_) && defined(_IA64_)
   2126 
   2127     void *_cdecl _rdteb(void);
   2128 #ifdef __ia64__
   2129 
   2130 #define NtCurrentTeb() ((struct _TEB *)_rdteb())
   2131 #define GetCurrentFiber() (((PNT_TIB)NtCurrentTeb())->FiberData)
   2132 #define GetFiberData() (*(PVOID *)(GetCurrentFiber()))
   2133 
   2134 #ifdef __cplusplus
   2135     extern "C" {
   2136 #endif
   2137 
   2138       void __break(int);
   2139       void __yield(void);
   2140       void __mf(void);
   2141       void __lfetch(int Level,VOID CONST *Address);
   2142       void __lfetchfault(int Level,VOID CONST *Address);
   2143       void __lfetch_excl(int Level,VOID CONST *Address);
   2144       void __lfetchfault_excl(int Level,VOID CONST *Address);
   2145 
   2146 #define MD_LFHINT_NONE 0x00
   2147 #define MD_LFHINT_NT1 0x01
   2148 #define MD_LFHINT_NT2 0x02
   2149 #define MD_LFHINT_NTA 0x03
   2150 
   2151 #ifdef __cplusplus
   2152     }
   2153 #endif
   2154 
   2155 #define YieldProcessor __yield
   2156 #define MemoryBarrier __mf
   2157 #define PreFetchCacheLine __lfetch
   2158 #define ReadForWriteAccess(p) (*(p))
   2159 #define DbgRaiseAssertionFailure() __break(ASSERT_BREAKPOINT)
   2160 
   2161 #define PF_TEMPORAL_LEVEL_1 MD_LFHINT_NONE
   2162 #define PF_NON_TEMPORAL_LEVEL_ALL MD_LFHINT_NTA
   2163 
   2164 #define UnsignedMultiplyHigh __UMULH
   2165 
   2166     ULONGLONG UnsignedMultiplyHigh(ULONGLONG Multiplier,ULONGLONG Multiplicand);
   2167 #else  /* __ia64__ */
   2168     struct _TEB *NtCurrentTeb(void);
   2169 #endif /* __ia64__ */
   2170 #endif /* !defined(GENUTIL) && !defined(_GENIA64_) && defined(_IA64_) */
   2171 
   2172 #ifdef _IA64_
   2173 
   2174 #define EXCEPTION_READ_FAULT 0
   2175 #define EXCEPTION_WRITE_FAULT 1
   2176 #define EXCEPTION_EXECUTE_FAULT 2
   2177 
   2178 #if !defined(RC_INVOKED)
   2179 
   2180 #define CONTEXT_IA64 0x00080000
   2181 
   2182 #define CONTEXT_CONTROL (CONTEXT_IA64 | __MSABI_LONG(0x00000001))
   2183 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | __MSABI_LONG(0x00000002))
   2184 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | __MSABI_LONG(0x00000004))
   2185 #define CONTEXT_INTEGER (CONTEXT_IA64 | __MSABI_LONG(0x00000008))
   2186 #define CONTEXT_DEBUG (CONTEXT_IA64 | __MSABI_LONG(0x00000010))
   2187 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | __MSABI_LONG(0x00000020))
   2188 
   2189 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
   2190 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
   2191 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
   2192 
   2193 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
   2194 #define CONTEXT_SERVICE_ACTIVE 0x10000000
   2195 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
   2196 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
   2197 #endif /* !defined(RC_INVOKED) */
   2198 
   2199     typedef struct _CONTEXT {
   2200       DWORD ContextFlags;
   2201       DWORD Fill1[3];
   2202       ULONGLONG DbI0;
   2203       ULONGLONG DbI1;
   2204       ULONGLONG DbI2;
   2205       ULONGLONG DbI3;
   2206       ULONGLONG DbI4;
   2207       ULONGLONG DbI5;
   2208       ULONGLONG DbI6;
   2209       ULONGLONG DbI7;
   2210       ULONGLONG DbD0;
   2211       ULONGLONG DbD1;
   2212       ULONGLONG DbD2;
   2213       ULONGLONG DbD3;
   2214       ULONGLONG DbD4;
   2215       ULONGLONG DbD5;
   2216       ULONGLONG DbD6;
   2217       ULONGLONG DbD7;
   2218       FLOAT128 FltS0;
   2219       FLOAT128 FltS1;
   2220       FLOAT128 FltS2;
   2221       FLOAT128 FltS3;
   2222       FLOAT128 FltT0;
   2223       FLOAT128 FltT1;
   2224       FLOAT128 FltT2;
   2225       FLOAT128 FltT3;
   2226       FLOAT128 FltT4;
   2227       FLOAT128 FltT5;
   2228       FLOAT128 FltT6;
   2229       FLOAT128 FltT7;
   2230       FLOAT128 FltT8;
   2231       FLOAT128 FltT9;
   2232       FLOAT128 FltS4;
   2233       FLOAT128 FltS5;
   2234       FLOAT128 FltS6;
   2235       FLOAT128 FltS7;
   2236       FLOAT128 FltS8;
   2237       FLOAT128 FltS9;
   2238       FLOAT128 FltS10;
   2239       FLOAT128 FltS11;
   2240       FLOAT128 FltS12;
   2241       FLOAT128 FltS13;
   2242       FLOAT128 FltS14;
   2243       FLOAT128 FltS15;
   2244       FLOAT128 FltS16;
   2245       FLOAT128 FltS17;
   2246       FLOAT128 FltS18;
   2247       FLOAT128 FltS19;
   2248       FLOAT128 FltF32;
   2249       FLOAT128 FltF33;
   2250       FLOAT128 FltF34;
   2251       FLOAT128 FltF35;
   2252       FLOAT128 FltF36;
   2253       FLOAT128 FltF37;
   2254       FLOAT128 FltF38;
   2255       FLOAT128 FltF39;
   2256       FLOAT128 FltF40;
   2257       FLOAT128 FltF41;
   2258       FLOAT128 FltF42;
   2259       FLOAT128 FltF43;
   2260       FLOAT128 FltF44;
   2261       FLOAT128 FltF45;
   2262       FLOAT128 FltF46;
   2263       FLOAT128 FltF47;
   2264       FLOAT128 FltF48;
   2265       FLOAT128 FltF49;
   2266       FLOAT128 FltF50;
   2267       FLOAT128 FltF51;
   2268       FLOAT128 FltF52;
   2269       FLOAT128 FltF53;
   2270       FLOAT128 FltF54;
   2271       FLOAT128 FltF55;
   2272       FLOAT128 FltF56;
   2273       FLOAT128 FltF57;
   2274       FLOAT128 FltF58;
   2275       FLOAT128 FltF59;
   2276       FLOAT128 FltF60;
   2277       FLOAT128 FltF61;
   2278       FLOAT128 FltF62;
   2279       FLOAT128 FltF63;
   2280       FLOAT128 FltF64;
   2281       FLOAT128 FltF65;
   2282       FLOAT128 FltF66;
   2283       FLOAT128 FltF67;
   2284       FLOAT128 FltF68;
   2285       FLOAT128 FltF69;
   2286       FLOAT128 FltF70;
   2287       FLOAT128 FltF71;
   2288       FLOAT128 FltF72;
   2289       FLOAT128 FltF73;
   2290       FLOAT128 FltF74;
   2291       FLOAT128 FltF75;
   2292       FLOAT128 FltF76;
   2293       FLOAT128 FltF77;
   2294       FLOAT128 FltF78;
   2295       FLOAT128 FltF79;
   2296       FLOAT128 FltF80;
   2297       FLOAT128 FltF81;
   2298       FLOAT128 FltF82;
   2299       FLOAT128 FltF83;
   2300       FLOAT128 FltF84;
   2301       FLOAT128 FltF85;
   2302       FLOAT128 FltF86;
   2303       FLOAT128 FltF87;
   2304       FLOAT128 FltF88;
   2305       FLOAT128 FltF89;
   2306       FLOAT128 FltF90;
   2307       FLOAT128 FltF91;
   2308       FLOAT128 FltF92;
   2309       FLOAT128 FltF93;
   2310       FLOAT128 FltF94;
   2311       FLOAT128 FltF95;
   2312       FLOAT128 FltF96;
   2313       FLOAT128 FltF97;
   2314       FLOAT128 FltF98;
   2315       FLOAT128 FltF99;
   2316       FLOAT128 FltF100;
   2317       FLOAT128 FltF101;
   2318       FLOAT128 FltF102;
   2319       FLOAT128 FltF103;
   2320       FLOAT128 FltF104;
   2321       FLOAT128 FltF105;
   2322       FLOAT128 FltF106;
   2323       FLOAT128 FltF107;
   2324       FLOAT128 FltF108;
   2325       FLOAT128 FltF109;
   2326       FLOAT128 FltF110;
   2327       FLOAT128 FltF111;
   2328       FLOAT128 FltF112;
   2329       FLOAT128 FltF113;
   2330       FLOAT128 FltF114;
   2331       FLOAT128 FltF115;
   2332       FLOAT128 FltF116;
   2333       FLOAT128 FltF117;
   2334       FLOAT128 FltF118;
   2335       FLOAT128 FltF119;
   2336       FLOAT128 FltF120;
   2337       FLOAT128 FltF121;
   2338       FLOAT128 FltF122;
   2339       FLOAT128 FltF123;
   2340       FLOAT128 FltF124;
   2341       FLOAT128 FltF125;
   2342       FLOAT128 FltF126;
   2343       FLOAT128 FltF127;
   2344       ULONGLONG StFPSR;
   2345       ULONGLONG IntGp;
   2346       ULONGLONG IntT0;
   2347       ULONGLONG IntT1;
   2348       ULONGLONG IntS0;
   2349       ULONGLONG IntS1;
   2350       ULONGLONG IntS2;
   2351       ULONGLONG IntS3;
   2352       ULONGLONG IntV0;
   2353       ULONGLONG IntT2;
   2354       ULONGLONG IntT3;
   2355       ULONGLONG IntT4;
   2356       ULONGLONG IntSp;
   2357       ULONGLONG IntTeb;
   2358       ULONGLONG IntT5;
   2359       ULONGLONG IntT6;
   2360       ULONGLONG IntT7;
   2361       ULONGLONG IntT8;
   2362       ULONGLONG IntT9;
   2363       ULONGLONG IntT10;
   2364       ULONGLONG IntT11;
   2365       ULONGLONG IntT12;
   2366       ULONGLONG IntT13;
   2367       ULONGLONG IntT14;
   2368       ULONGLONG IntT15;
   2369       ULONGLONG IntT16;
   2370       ULONGLONG IntT17;
   2371       ULONGLONG IntT18;
   2372       ULONGLONG IntT19;
   2373       ULONGLONG IntT20;
   2374       ULONGLONG IntT21;
   2375       ULONGLONG IntT22;
   2376       ULONGLONG IntNats;
   2377       ULONGLONG Preds;
   2378       ULONGLONG BrRp;
   2379       ULONGLONG BrS0;
   2380       ULONGLONG BrS1;
   2381       ULONGLONG BrS2;
   2382       ULONGLONG BrS3;
   2383       ULONGLONG BrS4;
   2384       ULONGLONG BrT0;
   2385       ULONGLONG BrT1;
   2386       ULONGLONG ApUNAT;
   2387       ULONGLONG ApLC;
   2388       ULONGLONG ApEC;
   2389       ULONGLONG ApCCV;
   2390       ULONGLONG ApDCR;
   2391       ULONGLONG RsPFS;
   2392       ULONGLONG RsBSP;
   2393       ULONGLONG RsBSPSTORE;
   2394       ULONGLONG RsRSC;
   2395       ULONGLONG RsRNAT;
   2396       ULONGLONG StIPSR;
   2397       ULONGLONG StIIP;
   2398       ULONGLONG StIFS;
   2399       ULONGLONG StFCR;
   2400       ULONGLONG Eflag;
   2401       ULONGLONG SegCSD;
   2402       ULONGLONG SegSSD;
   2403       ULONGLONG Cflag;
   2404       ULONGLONG StFSR;
   2405       ULONGLONG StFIR;
   2406       ULONGLONG StFDR;
   2407       ULONGLONG UNUSEDPACK;
   2408     } CONTEXT,*PCONTEXT;
   2409 
   2410     typedef struct _PLABEL_DESCRIPTOR {
   2411       ULONGLONG EntryPoint;
   2412       ULONGLONG GlobalPointer;
   2413     } PLABEL_DESCRIPTOR,*PPLABEL_DESCRIPTOR;
   2414 
   2415     typedef struct _RUNTIME_FUNCTION {
   2416       DWORD BeginAddress;
   2417       DWORD EndAddress;
   2418       DWORD UnwindInfoAddress;
   2419     } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
   2420 
   2421     typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
   2422     typedef DWORD (*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)(HANDLE Process,PVOID TableAddress,PDWORD Entries,PRUNTIME_FUNCTION *Functions);
   2423 
   2424 #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
   2425 
   2426     BOOLEAN RtlAddFunctionTable(PRUNTIME_FUNCTION FunctionTable,DWORD EntryCount,ULONGLONG BaseAddress,ULONGLONG TargetGp);
   2427     BOOLEAN RtlInstallFunctionTableCallback(DWORD64 TableIdentifier,DWORD64 BaseAddress,DWORD Length,DWORD64 TargetGp,PGET_RUNTIME_FUNCTION_CALLBACK Callback,PVOID Context,PCWSTR OutOfProcessCallbackDll);
   2428     BOOLEAN RtlDeleteFunctionTable(PRUNTIME_FUNCTION FunctionTable);
   2429     VOID RtlRestoreContext (PCONTEXT ContextRecord,struct _EXCEPTION_RECORD *ExceptionRecord);
   2430     VOID __jump_unwind(ULONGLONG TargetMsFrame,ULONGLONG TargetBsFrame,ULONGLONG TargetPc);
   2431 #endif /* end of _IA64_ */
   2432 
   2433 /* http://www.nynaeve.net/?p=99 */
   2434 
   2435 #define EXCEPTION_NONCONTINUABLE 0x1
   2436 #define EXCEPTION_UNWINDING	   0x2
   2437 #define EXCEPTION_EXIT_UNWIND      0x4
   2438 #define EXCEPTION_STACK_INVALID    0x8
   2439 #define EXCEPTION_NESTED_CALL      0x10
   2440 #define EXCEPTION_TARGET_UNWIND    0x20
   2441 #define EXCEPTION_COLLIDED_UNWIND  0x40
   2442 #define EXCEPTION_UNWIND           0x66
   2443 
   2444 #define EXCEPTION_MAXIMUM_PARAMETERS 15
   2445 
   2446     typedef struct _EXCEPTION_RECORD {
   2447       DWORD ExceptionCode;
   2448       DWORD ExceptionFlags;
   2449       struct _EXCEPTION_RECORD *ExceptionRecord;
   2450       PVOID ExceptionAddress;
   2451       DWORD NumberParameters;
   2452       ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
   2453     } EXCEPTION_RECORD;
   2454 
   2455     typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
   2456 
   2457     typedef struct _EXCEPTION_RECORD32 {
   2458       DWORD ExceptionCode;
   2459       DWORD ExceptionFlags;
   2460       DWORD ExceptionRecord;
   2461       DWORD ExceptionAddress;
   2462       DWORD NumberParameters;
   2463       DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
   2464     } EXCEPTION_RECORD32,*PEXCEPTION_RECORD32;
   2465 
   2466     typedef struct _EXCEPTION_RECORD64 {
   2467       DWORD ExceptionCode;
   2468       DWORD ExceptionFlags;
   2469       DWORD64 ExceptionRecord;
   2470       DWORD64 ExceptionAddress;
   2471       DWORD NumberParameters;
   2472       DWORD __unusedAlignment;
   2473       DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
   2474     } EXCEPTION_RECORD64,*PEXCEPTION_RECORD64;
   2475 
   2476     typedef struct _EXCEPTION_POINTERS {
   2477       PEXCEPTION_RECORD ExceptionRecord;
   2478       PCONTEXT ContextRecord;
   2479     } EXCEPTION_POINTERS,*PEXCEPTION_POINTERS;
   2480 
   2481 #ifdef __x86_64__
   2482 /* http://msdn.microsoft.com/en-us/library/ms680597(VS.85).aspx */
   2483 
   2484 #define UNWIND_HISTORY_TABLE_SIZE 12
   2485 
   2486   typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
   2487     ULONG64 ImageBase;
   2488     PRUNTIME_FUNCTION FunctionEntry;
   2489   } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
   2490 
   2491 #define UNWIND_HISTORY_TABLE_NONE    0
   2492 #define UNWIND_HISTORY_TABLE_GLOBAL  1
   2493 #define UNWIND_HISTORY_TABLE_LOCAL   2
   2494 
   2495   typedef struct _UNWIND_HISTORY_TABLE {
   2496     ULONG Count;
   2497     UCHAR Search;
   2498     ULONG64 LowAddress;
   2499     ULONG64 HighAddress;
   2500     UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
   2501   } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
   2502 
   2503   NTSYSAPI PRUNTIME_FUNCTION NTAPI RtlLookupFunctionEntry(ULONG64 ControlPc, PULONG64 ImageBase, PUNWIND_HISTORY_TABLE HistoryTable);
   2504 
   2505   /* http://msdn.microsoft.com/en-us/library/b6sf5kbd(VS.80).aspx */
   2506 
   2507   struct _DISPATCHER_CONTEXT;
   2508   typedef struct _DISPATCHER_CONTEXT DISPATCHER_CONTEXT;
   2509   typedef struct _DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT;
   2510 
   2511 #ifndef __PEXCEPTION_ROUTINE_DEFINED
   2512 #define __PEXCEPTION_ROUTINE_DEFINED
   2513 
   2514   typedef EXCEPTION_DISPOSITION (NTAPI *PEXCEPTION_ROUTINE)
   2515     (PEXCEPTION_RECORD ExceptionRecord,
   2516      ULONG64 EstablisherFrame,
   2517      PCONTEXT ContextRecord,
   2518      PDISPATCHER_CONTEXT DispatcherContext);
   2519 #endif /* __PEXCEPTION_ROUTINE_DEFINED */
   2520 
   2521   struct _DISPATCHER_CONTEXT {
   2522     ULONG64 ControlPc;
   2523     ULONG64 ImageBase;
   2524     PRUNTIME_FUNCTION FunctionEntry;
   2525     ULONG64 EstablisherFrame;
   2526     ULONG64 TargetIp;
   2527     PCONTEXT ContextRecord;
   2528     PEXCEPTION_ROUTINE LanguageHandler;
   2529     PVOID HandlerData;
   2530     /* http://www.nynaeve.net/?p=99 */
   2531     PUNWIND_HISTORY_TABLE HistoryTable;
   2532     ULONG ScopeIndex;
   2533     ULONG Fill0;
   2534   };
   2535 
   2536   /* http://msdn.microsoft.com/en-us/library/ms680617(VS.85).aspx */
   2537 
   2538   typedef struct _KNONVOLATILE_CONTEXT_POINTERS
   2539   {
   2540     PM128A FloatingContext[16];
   2541     PULONG64 IntegerContext[16];
   2542   } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
   2543 
   2544   NTSYSAPI VOID NTAPI RtlUnwindEx(PVOID TargetFrame, ULONG64 TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT OriginalContext, PUNWIND_HISTORY_TABLE HistoryTable);
   2545   NTSYSAPI PEXCEPTION_ROUTINE NTAPI RtlVirtualUnwind(ULONG HandlerType, ULONG64 ImageBase, ULONG64 ControlPc, PRUNTIME_FUNCTION FunctionEntry, PCONTEXT ContextRecord,PVOID *HandlerData, PULONG64 EstablisherFrame,PKNONVOLATILE_CONTEXT_POINTERS ContextPointers);
   2546 #endif /* defined(__x86_64__) */
   2547 
   2548     typedef PVOID PACCESS_TOKEN;
   2549     typedef PVOID PSECURITY_DESCRIPTOR;
   2550     typedef PVOID PSID;
   2551 
   2552     typedef DWORD ACCESS_MASK;
   2553     typedef ACCESS_MASK *PACCESS_MASK;
   2554 
   2555 #define DELETE (__MSABI_LONG(0x00010000))
   2556 #define READ_CONTROL (__MSABI_LONG(0x00020000))
   2557 #define WRITE_DAC (__MSABI_LONG(0x00040000))
   2558 #define WRITE_OWNER (__MSABI_LONG(0x00080000))
   2559 #define SYNCHRONIZE (__MSABI_LONG(0x00100000))
   2560 
   2561 #define STANDARD_RIGHTS_REQUIRED (__MSABI_LONG(0x000F0000))
   2562 #define STANDARD_RIGHTS_READ (READ_CONTROL)
   2563 #define STANDARD_RIGHTS_WRITE (READ_CONTROL)
   2564 #define STANDARD_RIGHTS_EXECUTE (READ_CONTROL)
   2565 #define STANDARD_RIGHTS_ALL (__MSABI_LONG(0x001F0000))
   2566 
   2567 #define SPECIFIC_RIGHTS_ALL (__MSABI_LONG(0x0000FFFF))
   2568 
   2569 #define ACCESS_SYSTEM_SECURITY (__MSABI_LONG(0x01000000))
   2570 
   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 
   2588     typedef struct _LUID_AND_ATTRIBUTES {
   2589       LUID Luid;
   2590       DWORD Attributes;
   2591     } LUID_AND_ATTRIBUTES,*PLUID_AND_ATTRIBUTES;
   2592     typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
   2593     typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
   2594 
   2595 #include <poppack.h>
   2596 
   2597 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
   2598 #define SID_IDENTIFIER_AUTHORITY_DEFINED
   2599     typedef struct _SID_IDENTIFIER_AUTHORITY {
   2600       BYTE Value[6];
   2601     } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY;
   2602 #endif /* SID_IDENTIFIER_AUTHORITY_DEFINED */
   2603 
   2604 #ifndef SID_DEFINED
   2605 #define SID_DEFINED
   2606     typedef struct _SID {
   2607       BYTE Revision;
   2608       BYTE SubAuthorityCount;
   2609       SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
   2610       DWORD SubAuthority[ANYSIZE_ARRAY];
   2611     } SID,*PISID;
   2612 #endif /* SID_DEFINED */
   2613 
   2614 #define SID_REVISION (1)
   2615 #define SID_MAX_SUB_AUTHORITIES (15)
   2616 #define SID_RECOMMENDED_SUB_AUTHORITIES (1)
   2617 #if (_WIN32_WINNT >= 0x0600)
   2618 #define SID_HASH_SIZE 32
   2619 #endif
   2620 
   2621 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES *sizeof(DWORD)))
   2622 
   2623     typedef enum _SID_NAME_USE {
   2624       SidTypeUser = 1,SidTypeGroup,SidTypeDomain,SidTypeAlias,SidTypeWellKnownGroup,SidTypeDeletedAccount,SidTypeInvalid,SidTypeUnknown,SidTypeComputer
   2625     } SID_NAME_USE,*PSID_NAME_USE;
   2626 
   2627     typedef struct _SID_AND_ATTRIBUTES {
   2628       PSID Sid;
   2629       DWORD Attributes;
   2630     } SID_AND_ATTRIBUTES,*PSID_AND_ATTRIBUTES;
   2631 
   2632     typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
   2633     typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
   2634 
   2635 #if (_WIN32_WINNT >= 0x0600)
   2636     typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
   2637     typedef struct _SID_AND_ATTRIBUTES_HASH {
   2638       DWORD SidCount;
   2639       PSID_AND_ATTRIBUTES SidAttr;
   2640       SID_HASH_ENTRY Hash[SID_HASH_SIZE];
   2641     } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
   2642 #endif
   2643 
   2644 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
   2645 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
   2646 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
   2647 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
   2648 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
   2649 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
   2650 
   2651 #define SECURITY_NULL_RID (__MSABI_LONG(0x00000000))
   2652 #define SECURITY_WORLD_RID (__MSABI_LONG(0x00000000))
   2653 #define SECURITY_LOCAL_RID (__MSABI_LONG(0x00000000))
   2654 
   2655 #define SECURITY_CREATOR_OWNER_RID (__MSABI_LONG(0x00000000))
   2656 #define SECURITY_CREATOR_GROUP_RID (__MSABI_LONG(0x00000001))
   2657 
   2658 #define SECURITY_CREATOR_OWNER_SERVER_RID (__MSABI_LONG(0x00000002))
   2659 #define SECURITY_CREATOR_GROUP_SERVER_RID (__MSABI_LONG(0x00000003))
   2660 
   2661 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
   2662 
   2663 #define SECURITY_DIALUP_RID (__MSABI_LONG(0x00000001))
   2664 #define SECURITY_NETWORK_RID (__MSABI_LONG(0x00000002))
   2665 #define SECURITY_BATCH_RID (__MSABI_LONG(0x00000003))
   2666 #define SECURITY_INTERACTIVE_RID (__MSABI_LONG(0x00000004))
   2667 #define SECURITY_LOGON_IDS_RID (__MSABI_LONG(0x00000005))
   2668 #define SECURITY_LOGON_IDS_RID_COUNT (__MSABI_LONG(3))
   2669 #define SECURITY_SERVICE_RID (__MSABI_LONG(0x00000006))
   2670 #define SECURITY_ANONYMOUS_LOGON_RID (__MSABI_LONG(0x00000007))
   2671 #define SECURITY_PROXY_RID (__MSABI_LONG(0x00000008))
   2672 #define SECURITY_ENTERPRISE_CONTROLLERS_RID (__MSABI_LONG(0x00000009))
   2673 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
   2674 #define SECURITY_PRINCIPAL_SELF_RID (__MSABI_LONG(0x0000000A))
   2675 #define SECURITY_AUTHENTICATED_USER_RID (__MSABI_LONG(0x0000000B))
   2676 #define SECURITY_RESTRICTED_CODE_RID (__MSABI_LONG(0x0000000C))
   2677 #define SECURITY_TERMINAL_SERVER_RID (__MSABI_LONG(0x0000000D))
   2678 #define SECURITY_REMOTE_LOGON_RID (__MSABI_LONG(0x0000000E))
   2679 #define SECURITY_THIS_ORGANIZATION_RID (__MSABI_LONG(0x0000000F))
   2680 #define SECURITY_IUSER_RID (__MSABI_LONG(0x00000011))
   2681 
   2682 #define SECURITY_LOCAL_SYSTEM_RID (__MSABI_LONG(0x00000012))
   2683 #define SECURITY_LOCAL_SERVICE_RID (__MSABI_LONG(0x00000013))
   2684 #define SECURITY_NETWORK_SERVICE_RID (__MSABI_LONG(0x00000014))
   2685 
   2686 #define SECURITY_NT_NON_UNIQUE (__MSABI_LONG(0x00000015))
   2687 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT (__MSABI_LONG(3))
   2688 
   2689 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID (__MSABI_LONG(0x00000016))
   2690 
   2691 #define SECURITY_BUILTIN_DOMAIN_RID (__MSABI_LONG(0x00000020))
   2692 #define SECURITY_WRITE_RESTRICTED_CODE_RID (__MSABI_LONG(0x00000021))
   2693 
   2694 #define SECURITY_PACKAGE_BASE_RID (__MSABI_LONG(0x00000040))
   2695 #define SECURITY_PACKAGE_RID_COUNT (__MSABI_LONG(2))
   2696 #define SECURITY_PACKAGE_NTLM_RID (__MSABI_LONG(0x0000000A))
   2697 #define SECURITY_PACKAGE_SCHANNEL_RID (__MSABI_LONG(0x0000000E))
   2698 #define SECURITY_PACKAGE_DIGEST_RID (__MSABI_LONG(0x00000015))
   2699 
   2700 #define SECURITY_SERVICE_ID_BASE_RID (__MSABI_LONG(0x00000050))
   2701 #define SECURITY_SERVICE_ID_RID_COUNT (__MSABI_LONG(6))
   2702 
   2703 #define SECURITY_RESERVED_ID_BASE_RID (__MSABI_LONG(0x00000051))
   2704 
   2705 #define SECURITY_MAX_ALWAYS_FILTERED (__MSABI_LONG(0x000003E7))
   2706 #define SECURITY_MIN_NEVER_FILTERED (__MSABI_LONG(0x000003E8))
   2707 
   2708 #define SECURITY_OTHER_ORGANIZATION_RID (__MSABI_LONG(0x000003E8))
   2709 
   2710 #define FOREST_USER_RID_MAX (__MSABI_LONG(0x000001F3))
   2711 
   2712 #define DOMAIN_USER_RID_ADMIN (__MSABI_LONG(0x000001F4))
   2713 #define DOMAIN_USER_RID_GUEST (__MSABI_LONG(0x000001F5))
   2714 #define DOMAIN_USER_RID_KRBTGT (__MSABI_LONG(0x000001F6))
   2715 
   2716 #define DOMAIN_USER_RID_MAX (__MSABI_LONG(0x000003E7))
   2717 
   2718 #define DOMAIN_GROUP_RID_ADMINS (__MSABI_LONG(0x00000200))
   2719 #define DOMAIN_GROUP_RID_USERS (__MSABI_LONG(0x00000201))
   2720 #define DOMAIN_GROUP_RID_GUESTS (__MSABI_LONG(0x00000202))
   2721 #define DOMAIN_GROUP_RID_COMPUTERS (__MSABI_LONG(0x00000203))
   2722 #define DOMAIN_GROUP_RID_CONTROLLERS (__MSABI_LONG(0x00000204))
   2723 #define DOMAIN_GROUP_RID_CERT_ADMINS (__MSABI_LONG(0x00000205))
   2724 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (__MSABI_LONG(0x00000206))
   2725 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (__MSABI_LONG(0x00000207))
   2726 #define DOMAIN_GROUP_RID_POLICY_ADMINS (__MSABI_LONG(0x00000208))
   2727 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS (__MSABI_LONG(0x00000209))
   2728 
   2729 #define DOMAIN_ALIAS_RID_ADMINS (__MSABI_LONG(0x00000220))
   2730 #define DOMAIN_ALIAS_RID_USERS (__MSABI_LONG(0x00000221))
   2731 #define DOMAIN_ALIAS_RID_GUESTS (__MSABI_LONG(0x00000222))
   2732 #define DOMAIN_ALIAS_RID_POWER_USERS (__MSABI_LONG(0x00000223))
   2733 
   2734 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS (__MSABI_LONG(0x00000224))
   2735 #define DOMAIN_ALIAS_RID_SYSTEM_OPS (__MSABI_LONG(0x00000225))
   2736 #define DOMAIN_ALIAS_RID_PRINT_OPS (__MSABI_LONG(0x00000226))
   2737 #define DOMAIN_ALIAS_RID_BACKUP_OPS (__MSABI_LONG(0x00000227))
   2738 
   2739 #define DOMAIN_ALIAS_RID_REPLICATOR (__MSABI_LONG(0x00000228))
   2740 #define DOMAIN_ALIAS_RID_RAS_SERVERS (__MSABI_LONG(0x00000229))
   2741 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS (__MSABI_LONG(0x0000022A))
   2742 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS (__MSABI_LONG(0x0000022B))
   2743 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS (__MSABI_LONG(0x0000022C))
   2744 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS (__MSABI_LONG(0x0000022D))
   2745 
   2746 #define DOMAIN_ALIAS_RID_MONITORING_USERS (__MSABI_LONG(0x0000022E))
   2747 #define DOMAIN_ALIAS_RID_LOGGING_USERS (__MSABI_LONG(0x0000022F))
   2748 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS (__MSABI_LONG(0x00000230))
   2749 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS (__MSABI_LONG(0x00000231))
   2750 #define DOMAIN_ALIAS_RID_DCOM_USERS (__MSABI_LONG(0x00000232))
   2751 
   2752 #define DOMAIN_ALIAS_RID_IUSERS (__MSABI_LONG(0x00000238))
   2753 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS (__MSABI_LONG(0x00000239))
   2754 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP (__MSABI_LONG(0x0000023B))
   2755 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP (__MSABI_LONG(0x0000023C))
   2756 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP (__MSABI_LONG(0x0000023D))
   2757 
   2758 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
   2759 #define SECURITY_MANDATORY_UNTRUSTED_RID (__MSABI_LONG(0x00000000))
   2760 #define SECURITY_MANDATORY_LOW_RID (__MSABI_LONG(0x00001000))
   2761 #define SECURITY_MANDATORY_MEDIUM_RID (__MSABI_LONG(0x00002000))
   2762 #define SECURITY_MANDATORY_HIGH_RID (__MSABI_LONG(0x00003000))
   2763 #define SECURITY_MANDATORY_SYSTEM_RID (__MSABI_LONG(0x00004000))
   2764 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID (__MSABI_LONG(0x00005000))
   2765 
   2766 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
   2767 
   2768 #define MANDATORY_LEVEL_TO_MANDATORY_RID(IL) (IL * 0x1000)
   2769 
   2770     typedef enum {
   2771       WinNullSid = 0,WinWorldSid = 1,WinLocalSid = 2,WinCreatorOwnerSid = 3,
   2772       WinCreatorGroupSid = 4,WinCreatorOwnerServerSid = 5,
   2773       WinCreatorGroupServerSid = 6,WinNtAuthoritySid = 7,WinDialupSid = 8,
   2774       WinNetworkSid = 9,WinBatchSid = 10,WinInteractiveSid = 11,
   2775       WinServiceSid = 12,WinAnonymousSid = 13,WinProxySid = 14,
   2776       WinEnterpriseControllersSid = 15,WinSelfSid = 16,
   2777       WinAuthenticatedUserSid = 17,WinRestrictedCodeSid = 18,
   2778       WinTerminalServerSid = 19,WinRemoteLogonIdSid = 20,WinLogonIdsSid = 21,
   2779       WinLocalSystemSid = 22,WinLocalServiceSid = 23,WinNetworkServiceSid = 24,
   2780       WinBuiltinDomainSid = 25,WinBuiltinAdministratorsSid = 26,
   2781       WinBuiltinUsersSid = 27,WinBuiltinGuestsSid = 28,
   2782       WinBuiltinPowerUsersSid = 29,WinBuiltinAccountOperatorsSid = 30,
   2783       WinBuiltinSystemOperatorsSid = 31,WinBuiltinPrintOperatorsSid = 32,
   2784       WinBuiltinBackupOperatorsSid = 33,WinBuiltinReplicatorSid = 34,
   2785       WinBuiltinPreWindows2000CompatibleAccessSid = 35,
   2786       WinBuiltinRemoteDesktopUsersSid = 36,
   2787       WinBuiltinNetworkConfigurationOperatorsSid = 37,
   2788       WinAccountAdministratorSid = 38,WinAccountGuestSid = 39,
   2789       WinAccountKrbtgtSid = 40,WinAccountDomainAdminsSid = 41,
   2790       WinAccountDomainUsersSid = 42,WinAccountDomainGuestsSid = 43,
   2791       WinAccountComputersSid = 44,WinAccountControllersSid = 45,
   2792       WinAccountCertAdminsSid = 46,WinAccountSchemaAdminsSid = 47,
   2793       WinAccountEnterpriseAdminsSid = 48,WinAccountPolicyAdminsSid = 49,
   2794       WinAccountRasAndIasServersSid = 50,WinNTLMAuthenticationSid = 51,
   2795       WinDigestAuthenticationSid = 52,WinSChannelAuthenticationSid = 53,
   2796       WinThisOrganizationSid = 54,WinOtherOrganizationSid = 55,
   2797       WinBuiltinIncomingForestTrustBuildersSid = 56,
   2798       WinBuiltinPerfMonitoringUsersSid = 57,WinBuiltinPerfLoggingUsersSid = 58,
   2799       WinBuiltinAuthorizationAccessSid = 59,
   2800       WinBuiltinTerminalServerLicenseServersSid = 60,
   2801       WinBuiltinDCOMUsersSid = 61,WinBuiltinIUsersSid = 62,
   2802       WinIUserSid = 63, WinBuiltinCryptoOperatorsSid = 64,
   2803       WinUntrustedLabelSid = 65, WinLowLabelSid = 66, WinMediumLabelSid = 67,
   2804       WinHighLabelSid = 68, WinSystemLabelSid = 69, WinWriteRestrictedCodeSid = 70,
   2805       WinCreatorOwnerRightsSid = 71, WinCacheablePrincipalsGroupSid = 72,
   2806       WinNonCacheablePrincipalsGroupSid = 73, WinEnterpriseReadonlyControllersSid = 74,
   2807       WinAccountReadonlyControllersSid = 75, WinBuiltinEventLogReadersGroup = 76,
   2808       WinNewEnterpriseReadonlyControllersSid = 77, WinBuiltinCertSvcDComAccessGroup = 78,
   2809       WinMediumPlusLabelSid = 79, WinLocalLogonSid = 80, WinConsoleLogonSid = 81,
   2810       WinThisOrganizationCertificateSid = 82, WinApplicationPackageAuthoritySid = 83,
   2811       WinBuiltinAnyPackageSid = 84, WinCapabilityInternetClientSid = 85,
   2812       WinCapabilityInternetClientServerSid = 86,
   2813       WinCapabilityPrivateNetworkClientServerSid = 87,
   2814       WinCapabilityPicturesLibrarySid = 88, WinCapabilityVideosLibrarySid = 89,
   2815       WinCapabilityMusicLibrarySid = 90, WinCapabilityDocumentsLibrarySid = 91,
   2816       WinCapabilitySharedUserCertificatesSid = 92, WinCapabilityEnterpriseAuthenticationSid = 93,
   2817       WinCapabilityRemovableStorageSid = 94, WinBuiltinRDSRemoteAccessServersSid = 95,
   2818       WinBuiltinRDSEndpointServersSid = 96, WinBuiltinRDSManagementServersSid = 97,
   2819       WinUserModeDriversSid = 98, WinBuiltinHyperVAdminsSid = 99,
   2820       WinAccountCloneableControllersSid = 100,
   2821       WinBuiltinAccessControlAssistanceOperatorsSid = 101,
   2822       WinBuiltinRemoteManagementUsersSid = 102, WinAuthenticationAuthorityAssertedSid = 103,
   2823       WinAuthenticationServiceAssertedSid = 104
   2824 } WELL_KNOWN_SID_TYPE;
   2825 
   2826 #define SECURITY_SCOPED_POLICY_ID_AUTHORITY { 0, 0, 0, 0, 0, 17 }
   2827 #define SECURITY_AUTHENTICATION_AUTHORITY   { 0, 0, 0, 0, 0, 18 }
   2828 
   2829 #define SECURITY_AUTHENTICATION_AUTHORITY_RID_COUNT    (__MSABI_LONG(1))
   2830 #define SECURITY_AUTHENTICATION_AUTHORITY_ASSERTED_RID (__MSABI_LONG(0x1))
   2831 #define SECURITY_AUTHENTICATION_SERVICE_ASSERTED_RID   (__MSABI_LONG(0x2))
   2832 
   2833 #define SECURITY_TRUSTED_INSTALLER_RID1 956008885
   2834 #define SECURITY_TRUSTED_INSTALLER_RID2 3418522649
   2835 #define SECURITY_TRUSTED_INSTALLER_RID3 1831038044
   2836 #define SECURITY_TRUSTED_INSTALLER_RID4 1853292631
   2837 #define SECURITY_TRUSTED_INSTALLER_RID5 2271478464
   2838 
   2839 #define SYSTEM_LUID { 0x3E7,0x0 }
   2840 #define ANONYMOUS_LOGON_LUID { 0x3e6,0x0 }
   2841 #define LOCALSERVICE_LUID { 0x3e5,0x0 }
   2842 #define NETWORKSERVICE_LUID { 0x3e4,0x0 }
   2843 #define IUSER_LUID { 0x3e3, 0x0 }
   2844 
   2845 #define SE_GROUP_MANDATORY (__MSABI_LONG(0x00000001))
   2846 #define SE_GROUP_ENABLED_BY_DEFAULT (__MSABI_LONG(0x00000002))
   2847 #define SE_GROUP_ENABLED (__MSABI_LONG(0x00000004))
   2848 #define SE_GROUP_OWNER (__MSABI_LONG(0x00000008))
   2849 #define SE_GROUP_USE_FOR_DENY_ONLY (__MSABI_LONG(0x00000010))
   2850 #define SE_GROUP_INTEGRITY (__MSABI_LONG(0x00000020))
   2851 #define SE_GROUP_INTEGRITY_ENABLED (__MSABI_LONG(0x00000040))
   2852 #define SE_GROUP_LOGON_ID (__MSABI_LONG(0xC0000000))
   2853 #define SE_GROUP_RESOURCE (__MSABI_LONG(0x20000000))
   2854 
   2855 #define ACL_REVISION (2)
   2856 #define ACL_REVISION_DS (4)
   2857 
   2858 #define ACL_REVISION1 (1)
   2859 #define MIN_ACL_REVISION ACL_REVISION2
   2860 #define ACL_REVISION2 (2)
   2861 #define ACL_REVISION3 (3)
   2862 #define ACL_REVISION4 (4)
   2863 #define MAX_ACL_REVISION ACL_REVISION4
   2864 
   2865     typedef struct _ACL {
   2866       BYTE AclRevision;
   2867       BYTE Sbz1;
   2868       WORD AclSize;
   2869       WORD AceCount;
   2870       WORD Sbz2;
   2871     } ACL;
   2872     typedef ACL *PACL;
   2873 
   2874     typedef struct _ACE_HEADER {
   2875       BYTE AceType;
   2876       BYTE AceFlags;
   2877       WORD AceSize;
   2878     } ACE_HEADER;
   2879     typedef ACE_HEADER *PACE_HEADER;
   2880 
   2881 #define ACCESS_MIN_MS_ACE_TYPE (0x0)
   2882 #define ACCESS_ALLOWED_ACE_TYPE (0x0)
   2883 #define ACCESS_DENIED_ACE_TYPE (0x1)
   2884 #define SYSTEM_AUDIT_ACE_TYPE (0x2)
   2885 #define SYSTEM_ALARM_ACE_TYPE (0x3)
   2886 #define ACCESS_MAX_MS_V2_ACE_TYPE (0x3)
   2887 
   2888 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE (0x4)
   2889 #define ACCESS_MAX_MS_V3_ACE_TYPE (0x4)
   2890 
   2891 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE (0x5)
   2892 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE (0x5)
   2893 #define ACCESS_DENIED_OBJECT_ACE_TYPE (0x6)
   2894 #define SYSTEM_AUDIT_OBJECT_ACE_TYPE (0x7)
   2895 #define SYSTEM_ALARM_OBJECT_ACE_TYPE (0x8)
   2896 #define ACCESS_MAX_MS_OBJECT_ACE_TYPE (0x8)
   2897 
   2898 #define ACCESS_MAX_MS_V4_ACE_TYPE (0x8)
   2899 #define ACCESS_MAX_MS_ACE_TYPE (0x8)
   2900 
   2901 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE (0x9)
   2902 #define ACCESS_DENIED_CALLBACK_ACE_TYPE (0xA)
   2903 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE (0xB)
   2904 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE (0xC)
   2905 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE (0xD)
   2906 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE (0xE)
   2907 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE (0xF)
   2908 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE (0x10)
   2909 
   2910 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE (0x11)
   2911 #define ACCESS_MAX_MS_V5_ACE_TYPE (0x11)
   2912 
   2913 #define OBJECT_INHERIT_ACE (0x1)
   2914 #define CONTAINER_INHERIT_ACE (0x2)
   2915 #define NO_PROPAGATE_INHERIT_ACE (0x4)
   2916 #define INHERIT_ONLY_ACE (0x8)
   2917 #define INHERITED_ACE (0x10)
   2918 #define VALID_INHERIT_FLAGS (0x1F)
   2919 
   2920 #define SUCCESSFUL_ACCESS_ACE_FLAG (0x40)
   2921 #define FAILED_ACCESS_ACE_FLAG (0x80)
   2922 
   2923     typedef struct _ACCESS_ALLOWED_ACE {
   2924       ACE_HEADER Header;
   2925       ACCESS_MASK Mask;
   2926       DWORD SidStart;
   2927     } ACCESS_ALLOWED_ACE;
   2928 
   2929     typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
   2930 
   2931     typedef struct _ACCESS_DENIED_ACE {
   2932       ACE_HEADER Header;
   2933       ACCESS_MASK Mask;
   2934       DWORD SidStart;
   2935     } ACCESS_DENIED_ACE;
   2936     typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
   2937 
   2938     typedef struct _SYSTEM_AUDIT_ACE {
   2939       ACE_HEADER Header;
   2940       ACCESS_MASK Mask;
   2941       DWORD SidStart;
   2942     } SYSTEM_AUDIT_ACE;
   2943     typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
   2944 
   2945     typedef struct _SYSTEM_ALARM_ACE {
   2946       ACE_HEADER Header;
   2947       ACCESS_MASK Mask;
   2948       DWORD SidStart;
   2949     } SYSTEM_ALARM_ACE;
   2950     typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
   2951 
   2952     typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
   2953       ACE_HEADER Header;
   2954       ACCESS_MASK Mask;
   2955       DWORD SidStart;
   2956     } SYSTEM_MANDATORY_LABEL_ACE, *PSYSTEM_MANDATORY_LABEL_ACE;
   2957 
   2958 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
   2959 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
   2960 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
   2961 
   2962 #define SYSTEM_MANDATORY_LABEL_VALID_MASK (SYSTEM_MANDATORY_LABEL_NO_WRITE_UP | SYSTEM_MANDATORY_LABEL_NO_READ_UP | SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP)
   2963 
   2964     typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
   2965       ACE_HEADER Header;
   2966       ACCESS_MASK Mask;
   2967       DWORD Flags;
   2968       GUID ObjectType;
   2969       GUID InheritedObjectType;
   2970       DWORD SidStart;
   2971     } ACCESS_ALLOWED_OBJECT_ACE,*PACCESS_ALLOWED_OBJECT_ACE;
   2972 
   2973     typedef struct _ACCESS_DENIED_OBJECT_ACE {
   2974       ACE_HEADER Header;
   2975       ACCESS_MASK Mask;
   2976       DWORD Flags;
   2977       GUID ObjectType;
   2978       GUID InheritedObjectType;
   2979       DWORD SidStart;
   2980     } ACCESS_DENIED_OBJECT_ACE,*PACCESS_DENIED_OBJECT_ACE;
   2981 
   2982     typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
   2983       ACE_HEADER Header;
   2984       ACCESS_MASK Mask;
   2985       DWORD Flags;
   2986       GUID ObjectType;
   2987       GUID InheritedObjectType;
   2988       DWORD SidStart;
   2989     } SYSTEM_AUDIT_OBJECT_ACE,*PSYSTEM_AUDIT_OBJECT_ACE;
   2990 
   2991     typedef struct _SYSTEM_ALARM_OBJECT_ACE {
   2992       ACE_HEADER Header;
   2993       ACCESS_MASK Mask;
   2994       DWORD Flags;
   2995       GUID ObjectType;
   2996       GUID InheritedObjectType;
   2997       DWORD SidStart;
   2998     } SYSTEM_ALARM_OBJECT_ACE,*PSYSTEM_ALARM_OBJECT_ACE;
   2999 
   3000     typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
   3001       ACE_HEADER Header;
   3002       ACCESS_MASK Mask;
   3003       DWORD SidStart;
   3004 
   3005     } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
   3006 
   3007     typedef struct _ACCESS_DENIED_CALLBACK_ACE {
   3008       ACE_HEADER Header;
   3009       ACCESS_MASK Mask;
   3010       DWORD SidStart;
   3011 
   3012     } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
   3013 
   3014     typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
   3015       ACE_HEADER Header;
   3016       ACCESS_MASK Mask;
   3017       DWORD SidStart;
   3018 
   3019     } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
   3020 
   3021     typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
   3022       ACE_HEADER Header;
   3023       ACCESS_MASK Mask;
   3024       DWORD SidStart;
   3025 
   3026     } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
   3027 
   3028     typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
   3029       ACE_HEADER Header;
   3030       ACCESS_MASK Mask;
   3031       DWORD Flags;
   3032       GUID ObjectType;
   3033       GUID InheritedObjectType;
   3034       DWORD SidStart;
   3035 
   3036     } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE,*PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
   3037 
   3038     typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
   3039       ACE_HEADER Header;
   3040       ACCESS_MASK Mask;
   3041       DWORD Flags;
   3042       GUID ObjectType;
   3043       GUID InheritedObjectType;
   3044       DWORD SidStart;
   3045 
   3046     } ACCESS_DENIED_CALLBACK_OBJECT_ACE,*PACCESS_DENIED_CALLBACK_OBJECT_ACE;
   3047 
   3048     typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
   3049       ACE_HEADER Header;
   3050       ACCESS_MASK Mask;
   3051       DWORD Flags;
   3052       GUID ObjectType;
   3053       GUID InheritedObjectType;
   3054       DWORD SidStart;
   3055 
   3056     } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE,*PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
   3057 
   3058     typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
   3059       ACE_HEADER Header;
   3060       ACCESS_MASK Mask;
   3061       DWORD Flags;
   3062       GUID ObjectType;
   3063       GUID InheritedObjectType;
   3064       DWORD SidStart;
   3065 
   3066     } SYSTEM_ALARM_CALLBACK_OBJECT_ACE,*PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
   3067 
   3068 #define ACE_OBJECT_TYPE_PRESENT 0x1
   3069 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
   3070 
   3071     typedef enum _ACL_INFORMATION_CLASS {
   3072       AclRevisionInformation = 1,AclSizeInformation
   3073     } ACL_INFORMATION_CLASS;
   3074 
   3075     typedef struct _ACL_REVISION_INFORMATION {
   3076       DWORD AclRevision;
   3077     } ACL_REVISION_INFORMATION;
   3078     typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
   3079 
   3080     typedef struct _ACL_SIZE_INFORMATION {
   3081       DWORD AceCount;
   3082       DWORD AclBytesInUse;
   3083       DWORD AclBytesFree;
   3084     } ACL_SIZE_INFORMATION;
   3085     typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
   3086 
   3087 #define SECURITY_DESCRIPTOR_REVISION (1)
   3088 #define SECURITY_DESCRIPTOR_REVISION1 (1)
   3089 
   3090 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
   3091 
   3092     typedef WORD SECURITY_DESCRIPTOR_CONTROL,*PSECURITY_DESCRIPTOR_CONTROL;
   3093 
   3094 #define SE_OWNER_DEFAULTED (0x0001)
   3095 #define SE_GROUP_DEFAULTED (0x0002)
   3096 #define SE_DACL_PRESENT (0x0004)
   3097 #define SE_DACL_DEFAULTED (0x0008)
   3098 #define SE_SACL_PRESENT (0x0010)
   3099 #define SE_SACL_DEFAULTED (0x0020)
   3100 #define SE_DACL_AUTO_INHERIT_REQ (0x0100)
   3101 #define SE_SACL_AUTO_INHERIT_REQ (0x0200)
   3102 #define SE_DACL_AUTO_INHERITED (0x0400)
   3103 #define SE_SACL_AUTO_INHERITED (0x0800)
   3104 #define SE_DACL_PROTECTED (0x1000)
   3105 #define SE_SACL_PROTECTED (0x2000)
   3106 #define SE_RM_CONTROL_VALID (0x4000)
   3107 #define SE_SELF_RELATIVE (0x8000)
   3108 
   3109     typedef struct _SECURITY_DESCRIPTOR_RELATIVE {
   3110       BYTE Revision;
   3111       BYTE Sbz1;
   3112       SECURITY_DESCRIPTOR_CONTROL Control;
   3113       DWORD Owner;
   3114       DWORD Group;
   3115       DWORD Sacl;
   3116       DWORD Dacl;
   3117     } SECURITY_DESCRIPTOR_RELATIVE,*PISECURITY_DESCRIPTOR_RELATIVE;
   3118 
   3119     typedef struct _SECURITY_DESCRIPTOR {
   3120       BYTE Revision;
   3121       BYTE Sbz1;
   3122       SECURITY_DESCRIPTOR_CONTROL Control;
   3123       PSID Owner;
   3124       PSID Group;
   3125       PACL Sacl;
   3126       PACL Dacl;
   3127 
   3128     } SECURITY_DESCRIPTOR,*PISECURITY_DESCRIPTOR;
   3129 
   3130     typedef struct _OBJECT_TYPE_LIST {
   3131       WORD Level;
   3132       WORD Sbz;
   3133       GUID *ObjectType;
   3134     } OBJECT_TYPE_LIST,*POBJECT_TYPE_LIST;
   3135 
   3136 #define ACCESS_OBJECT_GUID 0
   3137 #define ACCESS_PROPERTY_SET_GUID 1
   3138 #define ACCESS_PROPERTY_GUID 2
   3139 
   3140 #define ACCESS_MAX_LEVEL 4
   3141 
   3142     typedef enum _AUDIT_EVENT_TYPE {
   3143       AuditEventObjectAccess,AuditEventDirectoryServiceAccess
   3144     } AUDIT_EVENT_TYPE,*PAUDIT_EVENT_TYPE;
   3145 
   3146 #define AUDIT_ALLOW_NO_PRIVILEGE 0x1
   3147 
   3148 #define ACCESS_DS_SOURCE_A "DS"
   3149 #define ACCESS_DS_SOURCE_W L"DS"
   3150 #define ACCESS_DS_OBJECT_TYPE_NAME_A "Directory Service Object"
   3151 #define ACCESS_DS_OBJECT_TYPE_NAME_W L"Directory Service Object"
   3152 
   3153 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (__MSABI_LONG(0x00000001))
   3154 #define SE_PRIVILEGE_ENABLED (__MSABI_LONG(0x00000002))
   3155 #define SE_PRIVILEGE_REMOVED (0X00000004L)
   3156 #define SE_PRIVILEGE_USED_FOR_ACCESS (__MSABI_LONG(0x80000000))
   3157 
   3158 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_REMOVED | SE_PRIVILEGE_USED_FOR_ACCESS)
   3159 
   3160 #define PRIVILEGE_SET_ALL_NECESSARY (1)
   3161 
   3162     typedef struct _PRIVILEGE_SET {
   3163       DWORD PrivilegeCount;
   3164       DWORD Control;
   3165       LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
   3166     } PRIVILEGE_SET,*PPRIVILEGE_SET;
   3167 
   3168 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
   3169 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
   3170 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
   3171 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
   3172 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
   3173 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
   3174 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
   3175 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
   3176 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
   3177 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
   3178 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
   3179 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
   3180 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
   3181 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
   3182 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
   3183 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
   3184 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
   3185 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
   3186 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
   3187 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
   3188 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
   3189 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
   3190 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
   3191 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
   3192 #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
   3193 #define SE_SYNC_AGENT_NAME TEXT("SeSyncAgentPrivilege")
   3194 #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
   3195 #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
   3196 #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
   3197 #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
   3198 #define SE_TRUSTED_CREDMAN_ACCESS_NAME TEXT("SeTrustedCredManAccessPrivilege")
   3199 #define SE_RELABEL_NAME TEXT("SeRelabelPrivilege")
   3200 #define SE_INC_WORKING_SET_NAME TEXT("SeIncreaseWorkingSetPrivilege")
   3201 #define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege")
   3202 #define SE_CREATE_SYMBOLIC_LINK_NAME TEXT("SeCreateSymbolicLinkPrivilege")
   3203 
   3204     typedef enum _SECURITY_IMPERSONATION_LEVEL {
   3205       SecurityAnonymous,SecurityIdentification,SecurityImpersonation,SecurityDelegation
   3206     } SECURITY_IMPERSONATION_LEVEL,*PSECURITY_IMPERSONATION_LEVEL;
   3207 
   3208 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
   3209 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
   3210 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
   3211 #define VALID_IMPERSONATION_LEVEL(L) (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL))
   3212 
   3213 #define TOKEN_ASSIGN_PRIMARY (0x0001)
   3214 #define TOKEN_DUPLICATE (0x0002)
   3215 #define TOKEN_IMPERSONATE (0x0004)
   3216 #define TOKEN_QUERY (0x0008)
   3217 #define TOKEN_QUERY_SOURCE (0x0010)
   3218 #define TOKEN_ADJUST_PRIVILEGES (0x0020)
   3219 #define TOKEN_ADJUST_GROUPS (0x0040)
   3220 #define TOKEN_ADJUST_DEFAULT (0x0080)
   3221 #define TOKEN_ADJUST_SESSIONID (0x0100)
   3222 
   3223 #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)
   3224 #define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID)
   3225 #define TOKEN_READ (STANDARD_RIGHTS_READ | TOKEN_QUERY)
   3226 
   3227 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT)
   3228 
   3229 #define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE)
   3230 
   3231     typedef enum _TOKEN_TYPE {
   3232       TokenPrimary = 1,TokenImpersonation
   3233     } TOKEN_TYPE;
   3234     typedef TOKEN_TYPE *PTOKEN_TYPE;
   3235 
   3236     typedef enum _TOKEN_ELEVATION_TYPE {
   3237       TokenElevationTypeDefault   = 1,
   3238       TokenElevationTypeFull,
   3239       TokenElevationTypeLimited
   3240     } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
   3241 
   3242     typedef enum _TOKEN_INFORMATION_CLASS {
   3243       TokenUser = 1,
   3244       TokenGroups,
   3245       TokenPrivileges,
   3246       TokenOwner,
   3247       TokenPrimaryGroup,
   3248       TokenDefaultDacl,
   3249       TokenSource,
   3250       TokenType,
   3251       TokenImpersonationLevel,
   3252       TokenStatistics,
   3253       TokenRestrictedSids,
   3254       TokenSessionId,
   3255       TokenGroupsAndPrivileges,
   3256       TokenSessionReference,
   3257       TokenSandBoxInert,
   3258       TokenAuditPolicy,
   3259       TokenOrigin,
   3260       TokenElevationType,
   3261       TokenLinkedToken,
   3262       TokenElevation,
   3263       TokenHasRestrictions,
   3264       TokenAccessInformation,
   3265       TokenVirtualizationAllowed,
   3266       TokenVirtualizationEnabled,
   3267       TokenIntegrityLevel,
   3268       TokenUIAccess,
   3269       TokenMandatoryPolicy,
   3270       TokenLogonSid,
   3271       MaxTokenInfoClass
   3272     } TOKEN_INFORMATION_CLASS,*PTOKEN_INFORMATION_CLASS;
   3273 
   3274     typedef struct _TOKEN_USER {
   3275       SID_AND_ATTRIBUTES User;
   3276     } TOKEN_USER,*PTOKEN_USER;
   3277 
   3278     typedef struct _TOKEN_GROUPS {
   3279       DWORD GroupCount;
   3280       SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
   3281     } TOKEN_GROUPS,*PTOKEN_GROUPS;
   3282 
   3283     typedef struct _TOKEN_PRIVILEGES {
   3284       DWORD PrivilegeCount;
   3285       LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
   3286     } TOKEN_PRIVILEGES,*PTOKEN_PRIVILEGES;
   3287 
   3288     typedef struct _TOKEN_OWNER {
   3289       PSID Owner;
   3290     } TOKEN_OWNER,*PTOKEN_OWNER;
   3291 
   3292     typedef struct _TOKEN_PRIMARY_GROUP {
   3293       PSID PrimaryGroup;
   3294     } TOKEN_PRIMARY_GROUP,*PTOKEN_PRIMARY_GROUP;
   3295 
   3296     typedef struct _TOKEN_DEFAULT_DACL {
   3297       PACL DefaultDacl;
   3298     } TOKEN_DEFAULT_DACL,*PTOKEN_DEFAULT_DACL;
   3299 
   3300     typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
   3301       DWORD SidCount;
   3302       DWORD SidLength;
   3303       PSID_AND_ATTRIBUTES Sids;
   3304       DWORD RestrictedSidCount;
   3305       DWORD RestrictedSidLength;
   3306       PSID_AND_ATTRIBUTES RestrictedSids;
   3307       DWORD PrivilegeCount;
   3308       DWORD PrivilegeLength;
   3309       PLUID_AND_ATTRIBUTES Privileges;
   3310       LUID AuthenticationId;
   3311     } TOKEN_GROUPS_AND_PRIVILEGES,*PTOKEN_GROUPS_AND_PRIVILEGES;
   3312 
   3313 #define POLICY_AUDIT_SUBCATEGORY_COUNT (53)
   3314 
   3315     typedef struct _TOKEN_AUDIT_POLICY {
   3316       UCHAR PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
   3317     } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
   3318 
   3319 #define TOKEN_SOURCE_LENGTH 8
   3320 
   3321     typedef struct _TOKEN_SOURCE {
   3322       CHAR SourceName[TOKEN_SOURCE_LENGTH];
   3323       LUID SourceIdentifier;
   3324     } TOKEN_SOURCE,*PTOKEN_SOURCE;
   3325 
   3326     typedef struct _TOKEN_STATISTICS {
   3327       LUID TokenId;
   3328       LUID AuthenticationId;
   3329       LARGE_INTEGER ExpirationTime;
   3330       TOKEN_TYPE TokenType;
   3331       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   3332       DWORD DynamicCharged;
   3333       DWORD DynamicAvailable;
   3334       DWORD GroupCount;
   3335       DWORD PrivilegeCount;
   3336       LUID ModifiedId;
   3337     } TOKEN_STATISTICS,*PTOKEN_STATISTICS;
   3338 
   3339     typedef struct _TOKEN_CONTROL {
   3340       LUID TokenId;
   3341       LUID AuthenticationId;
   3342       LUID ModifiedId;
   3343       TOKEN_SOURCE TokenSource;
   3344     } TOKEN_CONTROL,*PTOKEN_CONTROL;
   3345 
   3346     typedef struct _TOKEN_ORIGIN {
   3347       LUID OriginatingLogonSession;
   3348     } TOKEN_ORIGIN,*PTOKEN_ORIGIN;
   3349 
   3350 #if (_WIN32_WINNT >= 0x0600)
   3351     typedef struct _TOKEN_LINKED_TOKEN {
   3352       HANDLE LinkedToken;
   3353     } TOKEN_LINKED_TOKEN, *PTOKEN_LINKED_TOKEN;
   3354 
   3355     typedef struct _TOKEN_MANDATORY_LABEL {
   3356       SID_AND_ATTRIBUTES Label;
   3357     } TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
   3358 
   3359 #define TOKEN_MANDATORY_POLICY_OFF 0x0
   3360 #define TOKEN_MANDATORY_POLICY_NO_WRITE_UP 0x1
   3361 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
   3362 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
   3363 
   3364     typedef struct _TOKEN_MANDATORY_POLICY {
   3365       DWORD Policy;
   3366     } TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY;
   3367 
   3368     typedef struct _TOKEN_ELEVATION {
   3369       DWORD TokenIsElevated;
   3370     } TOKEN_ELEVATION, *PTOKEN_ELEVATION;
   3371 
   3372     typedef struct _TOKEN_ACCESS_INFORMATION {
   3373       PSID_AND_ATTRIBUTES_HASH SidHash;
   3374       PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
   3375       PTOKEN_PRIVILEGES Privileges;
   3376       LUID AuthenticationId;
   3377       TOKEN_TYPE TokenType;
   3378       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   3379       TOKEN_MANDATORY_POLICY MandatoryPolicy;
   3380       DWORD Flags;
   3381     } TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION;
   3382 #endif
   3383 
   3384 #define SECURITY_DYNAMIC_TRACKING (TRUE)
   3385 #define SECURITY_STATIC_TRACKING (FALSE)
   3386 
   3387     typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,*PSECURITY_CONTEXT_TRACKING_MODE;
   3388 
   3389     typedef struct _SECURITY_QUALITY_OF_SERVICE {
   3390       DWORD Length;
   3391       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
   3392       SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
   3393       BOOLEAN EffectiveOnly;
   3394     } SECURITY_QUALITY_OF_SERVICE,*PSECURITY_QUALITY_OF_SERVICE;
   3395 
   3396     typedef struct _SE_IMPERSONATION_STATE {
   3397       PACCESS_TOKEN Token;
   3398       BOOLEAN CopyOnOpen;
   3399       BOOLEAN EffectiveOnly;
   3400       SECURITY_IMPERSONATION_LEVEL Level;
   3401     } SE_IMPERSONATION_STATE,*PSE_IMPERSONATION_STATE;
   3402 
   3403 #define DISABLE_MAX_PRIVILEGE 0x1
   3404 #define SANDBOX_INERT 0x2
   3405 #define LUA_TOKEN 0x4
   3406 #define WRITE_RESTRICTED 0x8
   3407 
   3408     typedef DWORD SECURITY_INFORMATION,*PSECURITY_INFORMATION;
   3409 
   3410 #define OWNER_SECURITY_INFORMATION (__MSABI_LONG(0x00000001))
   3411 #define GROUP_SECURITY_INFORMATION (__MSABI_LONG(0x00000002))
   3412 #define DACL_SECURITY_INFORMATION (__MSABI_LONG(0x00000004))
   3413 #define SACL_SECURITY_INFORMATION (__MSABI_LONG(0x00000008))
   3414 #define LABEL_SECURITY_INFORMATION (__MSABI_LONG(0x00000010))
   3415 
   3416 #define PROTECTED_DACL_SECURITY_INFORMATION (__MSABI_LONG(0x80000000))
   3417 #define PROTECTED_SACL_SECURITY_INFORMATION (__MSABI_LONG(0x40000000))
   3418 #define UNPROTECTED_DACL_SECURITY_INFORMATION (__MSABI_LONG(0x20000000))
   3419 #define UNPROTECTED_SACL_SECURITY_INFORMATION (__MSABI_LONG(0x10000000))
   3420 
   3421 #define PROCESS_TERMINATE (0x0001)
   3422 #define PROCESS_CREATE_THREAD (0x0002)
   3423 #define PROCESS_SET_SESSIONID (0x0004)
   3424 #define PROCESS_VM_OPERATION (0x0008)
   3425 #define PROCESS_VM_READ (0x0010)
   3426 #define PROCESS_VM_WRITE (0x0020)
   3427 #define PROCESS_DUP_HANDLE (0x0040)
   3428 #define PROCESS_CREATE_PROCESS (0x0080)
   3429 #define PROCESS_SET_QUOTA (0x0100)
   3430 #define PROCESS_SET_INFORMATION (0x0200)
   3431 #define PROCESS_QUERY_INFORMATION (0x0400)
   3432 #define PROCESS_SUSPEND_RESUME (0x0800)
   3433 #define PROCESS_QUERY_LIMITED_INFORMATION (0x1000)
   3434 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
   3435 
   3436 #ifdef _WIN64
   3437 #define MAXIMUM_PROCESSORS 64
   3438 #else
   3439 #define MAXIMUM_PROCESSORS 32
   3440 #endif
   3441 
   3442 #define THREAD_TERMINATE (0x0001)
   3443 #define THREAD_SUSPEND_RESUME (0x0002)
   3444 #define THREAD_GET_CONTEXT (0x0008)
   3445 #define THREAD_SET_CONTEXT (0x0010)
   3446 #define THREAD_SET_INFORMATION (0x0020)
   3447 #define THREAD_QUERY_INFORMATION (0x0040)
   3448 #define THREAD_SET_THREAD_TOKEN (0x0080)
   3449 #define THREAD_IMPERSONATE (0x0100)
   3450 #define THREAD_DIRECT_IMPERSONATION (0x0200)
   3451 #define THREAD_SET_LIMITED_INFORMATION (0x0400)
   3452 #define THREAD_QUERY_LIMITED_INFORMATION (0x0800)
   3453 
   3454 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
   3455 
   3456 #define JOB_OBJECT_ASSIGN_PROCESS (0x0001)
   3457 #define JOB_OBJECT_SET_ATTRIBUTES (0x0002)
   3458 #define JOB_OBJECT_QUERY (0x0004)
   3459 #define JOB_OBJECT_TERMINATE (0x0008)
   3460 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES (0x0010)
   3461 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1F)
   3462 
   3463     typedef struct _JOB_SET_ARRAY {
   3464       HANDLE JobHandle;
   3465       DWORD MemberLevel;
   3466       DWORD Flags;
   3467     } JOB_SET_ARRAY,*PJOB_SET_ARRAY;
   3468 
   3469 #define FLS_MAXIMUM_AVAILABLE 128
   3470 #define TLS_MINIMUM_AVAILABLE 64
   3471 
   3472 #ifndef _NT_TIB_DEFINED
   3473 #define _NT_TIB_DEFINED
   3474     __C89_NAMELESS typedef struct _NT_TIB {
   3475       struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
   3476       PVOID StackBase;
   3477       PVOID StackLimit;
   3478       PVOID SubSystemTib;
   3479       __C89_NAMELESS union {
   3480 	PVOID FiberData;
   3481 	DWORD Version;
   3482       };
   3483       PVOID ArbitraryUserPointer;
   3484       struct _NT_TIB *Self;
   3485     } NT_TIB;
   3486     typedef NT_TIB *PNT_TIB;
   3487 #endif /* _NT_TIB_DEFINED */
   3488 
   3489     __C89_NAMELESS typedef struct _NT_TIB32 {
   3490       DWORD ExceptionList;
   3491       DWORD StackBase;
   3492       DWORD StackLimit;
   3493       DWORD SubSystemTib;
   3494       __C89_NAMELESS union {
   3495 	DWORD FiberData;
   3496 	DWORD Version;
   3497       };
   3498       DWORD ArbitraryUserPointer;
   3499       DWORD Self;
   3500     } NT_TIB32,*PNT_TIB32;
   3501 
   3502     __C89_NAMELESS typedef struct _NT_TIB64 {
   3503       DWORD64 ExceptionList;
   3504       DWORD64 StackBase;
   3505       DWORD64 StackLimit;
   3506       DWORD64 SubSystemTib;
   3507       __C89_NAMELESS union {
   3508 	DWORD64 FiberData;
   3509 	DWORD Version;
   3510       };
   3511       DWORD64 ArbitraryUserPointer;
   3512       DWORD64 Self;
   3513     } NT_TIB64,*PNT_TIB64;
   3514 
   3515 #if !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_)
   3516 #define WX86
   3517 #endif
   3518 
   3519 #define THREAD_BASE_PRIORITY_LOWRT 15
   3520 #define THREAD_BASE_PRIORITY_MAX 2
   3521 #define THREAD_BASE_PRIORITY_MIN (-2)
   3522 #define THREAD_BASE_PRIORITY_IDLE (-15)
   3523 
   3524     typedef struct _QUOTA_LIMITS {
   3525       SIZE_T PagedPoolLimit;
   3526       SIZE_T NonPagedPoolLimit;
   3527       SIZE_T MinimumWorkingSetSize;
   3528       SIZE_T MaximumWorkingSetSize;
   3529       SIZE_T PagefileLimit;
   3530       LARGE_INTEGER TimeLimit;
   3531     } QUOTA_LIMITS,*PQUOTA_LIMITS;
   3532 
   3533 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
   3534 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
   3535 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
   3536 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
   3537 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
   3538 
   3539     typedef union _RATE_QUOTA_LIMIT {
   3540       DWORD RateData;
   3541       __C89_NAMELESS struct {
   3542         DWORD RatePercent : 7;
   3543         DWORD Reserved0   : 25;
   3544       } DUMMYSTRUCTNAME;
   3545     } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
   3546 
   3547     typedef struct _QUOTA_LIMITS_EX {
   3548       SIZE_T PagedPoolLimit;
   3549       SIZE_T NonPagedPoolLimit;
   3550       SIZE_T MinimumWorkingSetSize;
   3551       SIZE_T MaximumWorkingSetSize;
   3552       SIZE_T PagefileLimit;
   3553       LARGE_INTEGER TimeLimit;
   3554       SIZE_T WorkingSetLimit;
   3555       SIZE_T Reserved2;
   3556       SIZE_T Reserved3;
   3557       SIZE_T Reserved4;
   3558       DWORD Flags;
   3559       RATE_QUOTA_LIMIT CpuRateLimit;
   3560     } QUOTA_LIMITS_EX,*PQUOTA_LIMITS_EX;
   3561 
   3562     typedef struct _IO_COUNTERS {
   3563       ULONGLONG ReadOperationCount;
   3564       ULONGLONG WriteOperationCount;
   3565       ULONGLONG OtherOperationCount;
   3566       ULONGLONG ReadTransferCount;
   3567       ULONGLONG WriteTransferCount;
   3568       ULONGLONG OtherTransferCount;
   3569     } IO_COUNTERS;
   3570     typedef IO_COUNTERS *PIO_COUNTERS;
   3571 
   3572 #define MAX_HW_COUNTERS 16
   3573 #define THREAD_PROFILING_FLAG_DISPATCH 0x1
   3574 
   3575     typedef enum _HARDWARE_COUNTER_TYPE {
   3576       PMCCounter,
   3577       MaxHardwareCounterType
   3578     } HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
   3579 
   3580     typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
   3581       LARGE_INTEGER TotalUserTime;
   3582       LARGE_INTEGER TotalKernelTime;
   3583       LARGE_INTEGER ThisPeriodTotalUserTime;
   3584       LARGE_INTEGER ThisPeriodTotalKernelTime;
   3585       DWORD TotalPageFaultCount;
   3586       DWORD TotalProcesses;
   3587       DWORD ActiveProcesses;
   3588       DWORD TotalTerminatedProcesses;
   3589     } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION,*PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
   3590 
   3591     typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
   3592       LARGE_INTEGER PerProcessUserTimeLimit;
   3593       LARGE_INTEGER PerJobUserTimeLimit;
   3594       DWORD LimitFlags;
   3595       SIZE_T MinimumWorkingSetSize;
   3596       SIZE_T MaximumWorkingSetSize;
   3597       DWORD ActiveProcessLimit;
   3598       ULONG_PTR Affinity;
   3599       DWORD PriorityClass;
   3600       DWORD SchedulingClass;
   3601     } JOBOBJECT_BASIC_LIMIT_INFORMATION,*PJOBOBJECT_BASIC_LIMIT_INFORMATION;
   3602 
   3603     typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
   3604       JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
   3605       IO_COUNTERS IoInfo;
   3606       SIZE_T ProcessMemoryLimit;
   3607       SIZE_T JobMemoryLimit;
   3608       SIZE_T PeakProcessMemoryUsed;
   3609       SIZE_T PeakJobMemoryUsed;
   3610     } JOBOBJECT_EXTENDED_LIMIT_INFORMATION,*PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
   3611 
   3612     typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
   3613       DWORD NumberOfAssignedProcesses;
   3614       DWORD NumberOfProcessIdsInList;
   3615       ULONG_PTR ProcessIdList[1];
   3616     } JOBOBJECT_BASIC_PROCESS_ID_LIST,*PJOBOBJECT_BASIC_PROCESS_ID_LIST;
   3617 
   3618     typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
   3619       DWORD UIRestrictionsClass;
   3620     } JOBOBJECT_BASIC_UI_RESTRICTIONS,*PJOBOBJECT_BASIC_UI_RESTRICTIONS;
   3621 
   3622     typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
   3623       DWORD SecurityLimitFlags;
   3624       HANDLE JobToken;
   3625       PTOKEN_GROUPS SidsToDisable;
   3626       PTOKEN_PRIVILEGES PrivilegesToDelete;
   3627       PTOKEN_GROUPS RestrictedSids;
   3628     } JOBOBJECT_SECURITY_LIMIT_INFORMATION,*PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
   3629 
   3630     typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
   3631       DWORD EndOfJobTimeAction;
   3632     } JOBOBJECT_END_OF_JOB_TIME_INFORMATION,*PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
   3633 
   3634     typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
   3635       PVOID CompletionKey;
   3636       HANDLE CompletionPort;
   3637     } JOBOBJECT_ASSOCIATE_COMPLETION_PORT,*PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
   3638 
   3639     typedef struct _JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
   3640       JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
   3641       IO_COUNTERS IoInfo;
   3642     } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION,*PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
   3643 
   3644     typedef struct _JOBOBJECT_JOBSET_INFORMATION {
   3645       DWORD MemberLevel;
   3646     } JOBOBJECT_JOBSET_INFORMATION,*PJOBOBJECT_JOBSET_INFORMATION;
   3647 
   3648 #define JOB_OBJECT_TERMINATE_AT_END_OF_JOB 0
   3649 #define JOB_OBJECT_POST_AT_END_OF_JOB 1
   3650 
   3651 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
   3652 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
   3653 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
   3654 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
   3655 #define JOB_OBJECT_MSG_NEW_PROCESS 6
   3656 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
   3657 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
   3658 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
   3659 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
   3660 
   3661 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
   3662 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
   3663 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
   3664 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
   3665 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
   3666 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
   3667 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
   3668 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
   3669 
   3670 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
   3671 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
   3672 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
   3673 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
   3674 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
   3675 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
   3676 
   3677 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
   3678 #define JOB_OBJECT_LIMIT_RESERVED3 0x00008000
   3679 #define JOB_OBJECT_LIMIT_RESERVED4 0x00010000
   3680 #define JOB_OBJECT_LIMIT_RESERVED5 0x00020000
   3681 #define JOB_OBJECT_LIMIT_RESERVED6 0x00040000
   3682 
   3683 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
   3684 
   3685 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
   3686 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
   3687 #define JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS 0x0007ffff
   3688 
   3689 #define JOB_OBJECT_UILIMIT_NONE 0x00000000
   3690 
   3691 #define JOB_OBJECT_UILIMIT_HANDLES 0x00000001
   3692 #define JOB_OBJECT_UILIMIT_READCLIPBOARD 0x00000002
   3693 #define JOB_OBJECT_UILIMIT_WRITECLIPBOARD 0x00000004
   3694 #define JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS 0x00000008
   3695 #define JOB_OBJECT_UILIMIT_DISPLAYSETTINGS 0x00000010
   3696 #define JOB_OBJECT_UILIMIT_GLOBALATOMS 0x00000020
   3697 #define JOB_OBJECT_UILIMIT_DESKTOP 0x00000040
   3698 #define JOB_OBJECT_UILIMIT_EXITWINDOWS 0x00000080
   3699 
   3700 #define JOB_OBJECT_UILIMIT_ALL 0x000000FF
   3701 
   3702 #define JOB_OBJECT_UI_VALID_FLAGS 0x000000FF
   3703 
   3704 #define JOB_OBJECT_SECURITY_NO_ADMIN 0x00000001
   3705 #define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN 0x00000002
   3706 #define JOB_OBJECT_SECURITY_ONLY_TOKEN 0x00000004
   3707 #define JOB_OBJECT_SECURITY_FILTER_TOKENS 0x00000008
   3708 
   3709 #define JOB_OBJECT_SECURITY_VALID_FLAGS 0x0000000f
   3710 
   3711     typedef enum _JOBOBJECTINFOCLASS {
   3712       JobObjectBasicAccountingInformation = 1, JobObjectBasicLimitInformation,
   3713       JobObjectBasicProcessIdList, JobObjectBasicUIRestrictions,
   3714       JobObjectSecurityLimitInformation, JobObjectEndOfJobTimeInformation,
   3715       JobObjectAssociateCompletionPortInformation, JobObjectBasicAndIoAccountingInformation,
   3716       JobObjectExtendedLimitInformation, JobObjectJobSetInformation,
   3717       JobObjectGroupInformation,
   3718       MaxJobObjectInfoClass
   3719     } JOBOBJECTINFOCLASS;
   3720 
   3721 #define EVENT_MODIFY_STATE 0x0002
   3722 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
   3723 
   3724 #define MUTANT_QUERY_STATE 0x0001
   3725 
   3726 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE| MUTANT_QUERY_STATE)
   3727 #define SEMAPHORE_MODIFY_STATE 0x0002
   3728 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
   3729 
   3730 #define TIMER_QUERY_STATE 0x0001
   3731 #define TIMER_MODIFY_STATE 0x0002
   3732 
   3733 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE| TIMER_QUERY_STATE|TIMER_MODIFY_STATE)
   3734 
   3735 #define TIME_ZONE_ID_UNKNOWN 0
   3736 #define TIME_ZONE_ID_STANDARD 1
   3737 #define TIME_ZONE_ID_DAYLIGHT 2
   3738 
   3739     typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
   3740       RelationProcessorCore,RelationNumaNode,RelationCache,
   3741       RelationProcessorPackage,RelationGroup,RelationAll=0xffff
   3742     } LOGICAL_PROCESSOR_RELATIONSHIP;
   3743 
   3744 #define LTP_PC_SMT 0x1
   3745 
   3746     typedef enum _PROCESSOR_CACHE_TYPE {
   3747       CacheUnified,CacheInstruction,CacheData,CacheTrace
   3748     } PROCESSOR_CACHE_TYPE;
   3749 
   3750 #define CACHE_FULLY_ASSOCIATIVE 0xFF
   3751 
   3752     typedef struct _CACHE_DESCRIPTOR {
   3753       BYTE Level;
   3754       BYTE Associativity;
   3755       WORD LineSize;
   3756       DWORD Size;
   3757       PROCESSOR_CACHE_TYPE Type;
   3758     } CACHE_DESCRIPTOR,*PCACHE_DESCRIPTOR;
   3759 
   3760     typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
   3761       ULONG_PTR ProcessorMask;
   3762       LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
   3763       __C89_NAMELESS union {
   3764 	struct {
   3765 	  BYTE Flags;
   3766 	} ProcessorCore;
   3767 	struct {
   3768 	  DWORD NodeNumber;
   3769 	} NumaNode;
   3770 	CACHE_DESCRIPTOR Cache;
   3771 	ULONGLONG Reserved[2];
   3772       };
   3773     } SYSTEM_LOGICAL_PROCESSOR_INFORMATION,*PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
   3774 
   3775 #define PROCESSOR_INTEL_386 386
   3776 #define PROCESSOR_INTEL_486 486
   3777 #define PROCESSOR_INTEL_PENTIUM 586
   3778 #define PROCESSOR_INTEL_IA64 2200
   3779 #define PROCESSOR_AMD_X8664 8664
   3780 #define PROCESSOR_MIPS_R4000 4000
   3781 #define PROCESSOR_ALPHA_21064 21064
   3782 #define PROCESSOR_PPC_601 601
   3783 #define PROCESSOR_PPC_603 603
   3784 #define PROCESSOR_PPC_604 604
   3785 #define PROCESSOR_PPC_620 620
   3786 #define PROCESSOR_HITACHI_SH3 10003
   3787 #define PROCESSOR_HITACHI_SH3E 10004
   3788 #define PROCESSOR_HITACHI_SH4 10005
   3789 #define PROCESSOR_MOTOROLA_821 821
   3790 #define PROCESSOR_SHx_SH3 103
   3791 #define PROCESSOR_SHx_SH4 104
   3792 #define PROCESSOR_STRONGARM 2577
   3793 #define PROCESSOR_ARM720 1824
   3794 #define PROCESSOR_ARM820 2080
   3795 #define PROCESSOR_ARM920 2336
   3796 #define PROCESSOR_ARM_7TDMI 70001
   3797 #define PROCESSOR_OPTIL 0x494f
   3798 
   3799 #define PROCESSOR_ARCHITECTURE_INTEL 0
   3800 #define PROCESSOR_ARCHITECTURE_MIPS 1
   3801 #define PROCESSOR_ARCHITECTURE_ALPHA 2
   3802 #define PROCESSOR_ARCHITECTURE_PPC 3
   3803 #define PROCESSOR_ARCHITECTURE_SHX 4
   3804 #define PROCESSOR_ARCHITECTURE_ARM 5
   3805 #define PROCESSOR_ARCHITECTURE_IA64 6
   3806 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
   3807 #define PROCESSOR_ARCHITECTURE_MSIL 8
   3808 #define PROCESSOR_ARCHITECTURE_AMD64 9
   3809 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
   3810 
   3811 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
   3812 
   3813 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
   3814 #define PF_FLOATING_POINT_EMULATED 1
   3815 #define PF_COMPARE_EXCHANGE_DOUBLE 2
   3816 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
   3817 #define PF_PPC_MOVEMEM_64BIT_OK 4
   3818 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
   3819 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
   3820 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
   3821 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
   3822 #define PF_PAE_ENABLED 9
   3823 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
   3824 #define PF_SSE_DAZ_MODE_AVAILABLE 11
   3825 #define PF_NX_ENABLED 12
   3826 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
   3827 #define PF_COMPARE_EXCHANGE128 14
   3828 #define PF_COMPARE64_EXCHANGE128 15
   3829 #define PF_CHANNELS_ENABLED 16
   3830 #define PF_XSAVE_ENABLED 17
   3831 
   3832     typedef struct _MEMORY_BASIC_INFORMATION {
   3833       PVOID BaseAddress;
   3834       PVOID AllocationBase;
   3835       DWORD AllocationProtect;
   3836       SIZE_T RegionSize;
   3837       DWORD State;
   3838       DWORD Protect;
   3839       DWORD Type;
   3840     } MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
   3841 
   3842     typedef struct _MEMORY_BASIC_INFORMATION32 {
   3843       DWORD BaseAddress;
   3844       DWORD AllocationBase;
   3845       DWORD AllocationProtect;
   3846       DWORD RegionSize;
   3847       DWORD State;
   3848       DWORD Protect;
   3849       DWORD Type;
   3850     } MEMORY_BASIC_INFORMATION32,*PMEMORY_BASIC_INFORMATION32;
   3851 
   3852     typedef struct DECLSPEC_ALIGN(16) _MEMORY_BASIC_INFORMATION64 {
   3853       ULONGLONG BaseAddress;
   3854       ULONGLONG AllocationBase;
   3855       DWORD AllocationProtect;
   3856       DWORD __alignment1;
   3857       ULONGLONG RegionSize;
   3858       DWORD State;
   3859       DWORD Protect;
   3860       DWORD Type;
   3861       DWORD __alignment2;
   3862     } MEMORY_BASIC_INFORMATION64,*PMEMORY_BASIC_INFORMATION64;
   3863 
   3864 #define SECTION_QUERY 0x0001
   3865 #define SECTION_MAP_WRITE 0x0002
   3866 #define SECTION_MAP_READ 0x0004
   3867 #define SECTION_MAP_EXECUTE 0x0008
   3868 #define SECTION_EXTEND_SIZE 0x0010
   3869 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
   3870 
   3871 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE)
   3872 
   3873 #define SESSION_QUERY_ACCESS 0x1
   3874 #define SESSION_MODIFY_ACCESS 0x2
   3875 
   3876 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SESSION_QUERY_ACCESS | SESSION_MODIFY_ACCESS)
   3877 
   3878 #define PAGE_NOACCESS 0x01
   3879 #define PAGE_READONLY 0x02
   3880 #define PAGE_READWRITE 0x04
   3881 #define PAGE_WRITECOPY 0x08
   3882 #define PAGE_EXECUTE 0x10
   3883 #define PAGE_EXECUTE_READ 0x20
   3884 #define PAGE_EXECUTE_READWRITE 0x40
   3885 #define PAGE_EXECUTE_WRITECOPY 0x80
   3886 #define PAGE_GUARD 0x100
   3887 #define PAGE_NOCACHE 0x200
   3888 #define PAGE_WRITECOMBINE 0x400
   3889 #define MEM_COMMIT 0x1000
   3890 #define MEM_RESERVE 0x2000
   3891 #define MEM_DECOMMIT 0x4000
   3892 #define MEM_RELEASE 0x8000
   3893 #define MEM_FREE 0x10000
   3894 #define MEM_PRIVATE 0x20000
   3895 #define MEM_MAPPED 0x40000
   3896 #define MEM_RESET 0x80000
   3897 #define MEM_TOP_DOWN 0x100000
   3898 #define MEM_WRITE_WATCH 0x200000
   3899 #define MEM_PHYSICAL 0x400000
   3900 #define MEM_ROTATE 0x800000
   3901 #define MEM_LARGE_PAGES 0x20000000
   3902 #define MEM_4MB_PAGES 0x80000000
   3903 #define SEC_FILE 0x800000
   3904 #define SEC_IMAGE 0x1000000
   3905 #define SEC_PROTECTED_IMAGE 0x2000000
   3906 #define SEC_RESERVE 0x4000000
   3907 #define SEC_COMMIT 0x8000000
   3908 #define SEC_NOCACHE 0x10000000
   3909 #define SEC_WRITECOMBINE 0x40000000
   3910 #define SEC_LARGE_PAGES 0x80000000
   3911 #define MEM_IMAGE SEC_IMAGE
   3912 #define WRITE_WATCH_FLAG_RESET 0x01
   3913 
   3914 #define FILE_READ_DATA (0x0001)
   3915 #define FILE_LIST_DIRECTORY (0x0001)
   3916 
   3917 #define FILE_WRITE_DATA (0x0002)
   3918 #define FILE_ADD_FILE (0x0002)
   3919 
   3920 #define FILE_APPEND_DATA (0x0004)
   3921 #define FILE_ADD_SUBDIRECTORY (0x0004)
   3922 #define FILE_CREATE_PIPE_INSTANCE (0x0004)
   3923 
   3924 #define FILE_READ_EA (0x0008)
   3925 
   3926 #define FILE_WRITE_EA (0x0010)
   3927 
   3928 #define FILE_EXECUTE (0x0020)
   3929 #define FILE_TRAVERSE (0x0020)
   3930 
   3931 #define FILE_DELETE_CHILD (0x0040)
   3932 
   3933 #define FILE_READ_ATTRIBUTES (0x0080)
   3934 
   3935 #define FILE_WRITE_ATTRIBUTES (0x0100)
   3936 
   3937 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
   3938 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE)
   3939 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE)
   3940 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE)
   3941 
   3942 #define FILE_SUPERSEDE                    0x00000000
   3943 #define FILE_OPEN                         0x00000001
   3944 #define FILE_CREATE                       0x00000002
   3945 #define FILE_OPEN_IF                      0x00000003
   3946 #define FILE_OVERWRITE                    0x00000004
   3947 #define FILE_OVERWRITE_IF                 0x00000005
   3948 #define FILE_MAXIMUM_DISPOSITION          0x00000005
   3949 
   3950 #define FILE_DIRECTORY_FILE               0x00000001
   3951 #define FILE_WRITE_THROUGH                0x00000002
   3952 #define FILE_SEQUENTIAL_ONLY              0x00000004
   3953 #define FILE_NO_INTERMEDIATE_BUFFERING    0x00000008
   3954 #define FILE_SYNCHRONOUS_IO_ALERT         0x00000010
   3955 #define FILE_SYNCHRONOUS_IO_NONALERT      0x00000020
   3956 #define FILE_NON_DIRECTORY_FILE           0x00000040
   3957 #define FILE_CREATE_TREE_CONNECTION       0x00000080
   3958 #define FILE_COMPLETE_IF_OPLOCKED         0x00000100
   3959 #define FILE_NO_EA_KNOWLEDGE              0x00000200
   3960 #define FILE_OPEN_REMOTE_INSTANCE         0x00000400
   3961 #define FILE_RANDOM_ACCESS                0x00000800
   3962 #define FILE_DELETE_ON_CLOSE              0x00001000
   3963 #define FILE_OPEN_BY_FILE_ID              0x00002000
   3964 #define FILE_OPEN_FOR_BACKUP_INTENT       0x00004000
   3965 #define FILE_NO_COMPRESSION               0x00008000
   3966 #if (NTDDI_VERSION >= NTDDI_WIN7)
   3967 #define FILE_OPEN_REQUIRING_OPLOCK        0x00010000
   3968 #define FILE_DISALLOW_EXCLUSIVE           0x00020000
   3969 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
   3970 #define FILE_RESERVE_OPFILTER             0x00100000
   3971 #define FILE_OPEN_REPARSE_POINT           0x00200000
   3972 #define FILE_OPEN_NO_RECALL               0x00400000
   3973 #define FILE_OPEN_FOR_FREE_SPACE_QUERY    0x00800000
   3974 
   3975 #define FILE_SHARE_READ 0x00000001
   3976 #define FILE_SHARE_WRITE 0x00000002
   3977 #define FILE_SHARE_DELETE 0x00000004
   3978 #define FILE_SHARE_VALID_FLAGS 0x00000007
   3979 #define FILE_ATTRIBUTE_READONLY 0x00000001
   3980 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
   3981 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
   3982 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
   3983 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
   3984 #define FILE_ATTRIBUTE_DEVICE 0x00000040
   3985 #define FILE_ATTRIBUTE_NORMAL 0x00000080
   3986 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
   3987 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
   3988 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
   3989 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
   3990 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
   3991 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
   3992 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
   3993 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
   3994 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
   3995 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
   3996 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
   3997 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
   3998 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
   3999 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
   4000 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
   4001 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
   4002 #define FILE_ACTION_ADDED 0x00000001
   4003 #define FILE_ACTION_REMOVED 0x00000002
   4004 #define FILE_ACTION_MODIFIED 0x00000003
   4005 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
   4006 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
   4007 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
   4008 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
   4009 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
   4010 #define FILE_CASE_PRESERVED_NAMES 0x00000002
   4011 #define FILE_UNICODE_ON_DISK 0x00000004
   4012 #define FILE_PERSISTENT_ACLS 0x00000008
   4013 #define FILE_FILE_COMPRESSION 0x00000010
   4014 #define FILE_VOLUME_QUOTAS 0x00000020
   4015 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
   4016 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
   4017 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
   4018 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
   4019 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
   4020 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
   4021 #define FILE_NAMED_STREAMS 0x00040000
   4022 #define FILE_READ_ONLY_VOLUME 0x00080000
   4023 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
   4024 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
   4025 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
   4026 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
   4027 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
   4028 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
   4029 
   4030     typedef struct _FILE_NOTIFY_INFORMATION {
   4031       DWORD NextEntryOffset;
   4032       DWORD Action;
   4033       DWORD FileNameLength;
   4034       WCHAR FileName[1];
   4035     } FILE_NOTIFY_INFORMATION,*PFILE_NOTIFY_INFORMATION;
   4036 
   4037     typedef union _FILE_SEGMENT_ELEMENT {
   4038       PVOID64 Buffer;
   4039       ULONGLONG Alignment;
   4040     }FILE_SEGMENT_ELEMENT,*PFILE_SEGMENT_ELEMENT;
   4041 
   4042     typedef struct _REPARSE_GUID_DATA_BUFFER {
   4043       DWORD ReparseTag;
   4044       WORD ReparseDataLength;
   4045       WORD Reserved;
   4046       GUID ReparseGuid;
   4047       struct {
   4048 	BYTE DataBuffer[1];
   4049       } GenericReparseBuffer;
   4050     } REPARSE_GUID_DATA_BUFFER,*PREPARSE_GUID_DATA_BUFFER;
   4051 
   4052 #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER,GenericReparseBuffer)
   4053 
   4054 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 *1024)
   4055 
   4056 #define IO_REPARSE_TAG_RESERVED_ZERO (0)
   4057 #define IO_REPARSE_TAG_RESERVED_ONE (1)
   4058 
   4059 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_ONE
   4060 
   4061 #define IsReparseTagMicrosoft(_tag) (((_tag) & 0x80000000))
   4062 #define IsReparseTagNameSurrogate(_tag) (((_tag) & 0x20000000))
   4063 
   4064 #define IO_REPARSE_TAG_MOUNT_POINT (__MSABI_LONG(0xA0000003))
   4065 #define IO_REPARSE_TAG_HSM (__MSABI_LONG(0xC0000004))
   4066 #define IO_REPARSE_TAG_HSM2 (__MSABI_LONG(0x80000006))
   4067 #define IO_REPARSE_TAG_SIS (__MSABI_LONG(0x80000007))
   4068 #define IO_REPARSE_TAG_WIM (__MSABI_LONG(0x80000008))
   4069 #define IO_REPARSE_TAG_CSV (__MSABI_LONG(0x80000009))
   4070 #define IO_REPARSE_TAG_DFS (__MSABI_LONG(0x8000000A))
   4071 #define IO_REPARSE_TAG_FILTER_MANAGER (__MSABI_LONG(0x8000000B))
   4072 #define IO_REPARSE_TAG_DFSR (__MSABI_LONG(0x80000012))
   4073 #define IO_REPARSE_TAG_SYMLINK (__MSABI_LONG(0xA000000C))
   4074 
   4075 #define IO_COMPLETION_MODIFY_STATE 0x0002
   4076 #define IO_COMPLETION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
   4077 #define DUPLICATE_CLOSE_SOURCE 0x00000001
   4078 #define DUPLICATE_SAME_ACCESS 0x00000002
   4079 
   4080   typedef enum _SYSTEM_POWER_STATE {
   4081     PowerSystemUnspecified = 0,PowerSystemWorking = 1,PowerSystemSleeping1 = 2,PowerSystemSleeping2 = 3,PowerSystemSleeping3 = 4,PowerSystemHibernate = 5,PowerSystemShutdown = 6,PowerSystemMaximum = 7
   4082   } SYSTEM_POWER_STATE,*PSYSTEM_POWER_STATE;
   4083 
   4084 #define POWER_SYSTEM_MAXIMUM 7
   4085 
   4086   typedef enum {
   4087     PowerActionNone = 0, PowerActionReserved, PowerActionSleep, PowerActionHibernate,
   4088     PowerActionShutdown, PowerActionShutdownReset, PowerActionShutdownOff,
   4089     PowerActionWarmEject
   4090   } POWER_ACTION,*PPOWER_ACTION;
   4091 
   4092 #if (_WIN32_WINNT >= 0x0600)
   4093   typedef enum {
   4094     PoAc = 0,
   4095     PoDc = 1,
   4096     PoHot = 2,
   4097     PoConditionMaximum = 3
   4098   } SYSTEM_POWER_CONDITION, *PSYSTEM_POWER_CONDITION;
   4099 
   4100   typedef enum _POWER_PLATFORM_ROLE {
   4101     PlatformRoleUnspecified         = 0,
   4102     PlatformRoleDesktop             = 1,
   4103     PlatformRoleMobile              = 2,
   4104     PlatformRoleWorkstation         = 3,
   4105     PlatformRoleEnterpriseServer    = 4,
   4106     PlatformRoleSOHOServer          = 5,
   4107     PlatformRoleAppliancePC         = 6,
   4108     PlatformRolePerformanceServer   = 7,
   4109     PlatformRoleMaximum             = 8
   4110   } POWER_PLATFORM_ROLE;
   4111 #endif /* (_WIN32_WINNT >= 0x0600) */
   4112 
   4113   typedef enum _DEVICE_POWER_STATE {
   4114     PowerDeviceUnspecified = 0, PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, PowerDeviceD3,
   4115     PowerDeviceMaximum
   4116   } DEVICE_POWER_STATE,*PDEVICE_POWER_STATE;
   4117 
   4118   typedef enum _MONITOR_DISPLAY_STATE {
   4119     PowerMonitorOff = 0, PowerMonitorOn, PowerMonitorDim
   4120   } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE;
   4121 
   4122 #define ES_SYSTEM_REQUIRED ((DWORD)0x00000001)
   4123 #define ES_DISPLAY_REQUIRED ((DWORD)0x00000002)
   4124 #define ES_USER_PRESENT ((DWORD)0x00000004)
   4125 #define ES_AWAYMODE_REQUIRED ((DWORD)0x00000040)
   4126 #define ES_CONTINUOUS ((DWORD)0x80000000)
   4127 
   4128   typedef DWORD EXECUTION_STATE;
   4129 
   4130   typedef enum {
   4131     LT_DONT_CARE,LT_LOWEST_LATENCY
   4132   } LATENCY_TIME;
   4133 
   4134 #define PDCAP_D0_SUPPORTED 0x00000001
   4135 #define PDCAP_D1_SUPPORTED 0x00000002
   4136 #define PDCAP_D2_SUPPORTED 0x00000004
   4137 #define PDCAP_D3_SUPPORTED 0x00000008
   4138 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
   4139 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
   4140 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
   4141 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
   4142 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
   4143 
   4144     typedef struct CM_Power_Data_s {
   4145       DWORD PD_Size;
   4146       DEVICE_POWER_STATE PD_MostRecentPowerState;
   4147       DWORD PD_Capabilities;
   4148       DWORD PD_D1Latency;
   4149       DWORD PD_D2Latency;
   4150       DWORD PD_D3Latency;
   4151       DEVICE_POWER_STATE PD_PowerStateMapping[POWER_SYSTEM_MAXIMUM];
   4152       SYSTEM_POWER_STATE PD_DeepestSystemWake;
   4153     } CM_POWER_DATA,*PCM_POWER_DATA;
   4154 
   4155     typedef enum {
   4156       SystemPowerPolicyAc,SystemPowerPolicyDc,VerifySystemPolicyAc,VerifySystemPolicyDc,SystemPowerCapabilities,SystemBatteryState,SystemPowerStateHandler,ProcessorStateHandler,SystemPowerPolicyCurrent,AdministratorPowerPolicy,SystemReserveHiberFile,ProcessorInformation,SystemPowerInformation,ProcessorStateHandler2,LastWakeTime,LastSleepTime,SystemExecutionState,SystemPowerStateNotifyHandler,ProcessorPowerPolicyAc,ProcessorPowerPolicyDc,VerifyProcessorPowerPolicyAc,VerifyProcessorPowerPolicyDc,ProcessorPowerPolicyCurrent,SystemPowerStateLogging,SystemPowerLoggingEntry
   4157     } POWER_INFORMATION_LEVEL;
   4158 
   4159     typedef struct {
   4160       DWORD Granularity;
   4161       DWORD Capacity;
   4162     } BATTERY_REPORTING_SCALE,*PBATTERY_REPORTING_SCALE;
   4163 
   4164     typedef struct {
   4165       POWER_ACTION Action;
   4166       DWORD Flags;
   4167       DWORD EventCode;
   4168     } POWER_ACTION_POLICY,*PPOWER_ACTION_POLICY;
   4169 
   4170 #define POWER_ACTION_QUERY_ALLOWED 0x00000001
   4171 #define POWER_ACTION_UI_ALLOWED 0x00000002
   4172 #define POWER_ACTION_OVERRIDE_APPS 0x00000004
   4173 #define POWER_ACTION_PSEUDO_TRANSITION 0x08000000
   4174 #define POWER_ACTION_LIGHTEST_FIRST 0x10000000
   4175 #define POWER_ACTION_LOCK_CONSOLE 0x20000000
   4176 #define POWER_ACTION_DISABLE_WAKES 0x40000000
   4177 #define POWER_ACTION_CRITICAL 0x80000000
   4178 
   4179 #define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
   4180 #define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
   4181 #define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
   4182 #define POWER_USER_NOTIFY_BUTTON 0x00000008
   4183 #define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
   4184 #define POWER_USER_NOTIFY_FORCED_SHUTDOWN 0x00000020
   4185 #define POWER_FORCE_TRIGGER_RESET 0x80000000
   4186 
   4187     typedef struct {
   4188       BOOLEAN Enable;
   4189       BYTE Spare[3];
   4190       DWORD BatteryLevel;
   4191       POWER_ACTION_POLICY PowerPolicy;
   4192       SYSTEM_POWER_STATE MinSystemState;
   4193     } SYSTEM_POWER_LEVEL,*PSYSTEM_POWER_LEVEL;
   4194 
   4195 #define NUM_DISCHARGE_POLICIES 4
   4196 #define DISCHARGE_POLICY_CRITICAL 0
   4197 #define DISCHARGE_POLICY_LOW 1
   4198 
   4199 #define PO_THROTTLE_NONE 0
   4200 #define PO_THROTTLE_CONSTANT 1
   4201 #define PO_THROTTLE_DEGRADE 2
   4202 #define PO_THROTTLE_ADAPTIVE 3
   4203 #define PO_THROTTLE_MAXIMUM 4
   4204 
   4205     typedef struct _SYSTEM_POWER_POLICY {
   4206       DWORD Revision;
   4207       POWER_ACTION_POLICY PowerButton;
   4208       POWER_ACTION_POLICY SleepButton;
   4209       POWER_ACTION_POLICY LidClose;
   4210       SYSTEM_POWER_STATE LidOpenWake;
   4211       DWORD Reserved;
   4212       POWER_ACTION_POLICY Idle;
   4213       DWORD IdleTimeout;
   4214       BYTE IdleSensitivity;
   4215       BYTE DynamicThrottle;
   4216       BYTE Spare2[2];
   4217       SYSTEM_POWER_STATE MinSleep;
   4218       SYSTEM_POWER_STATE MaxSleep;
   4219       SYSTEM_POWER_STATE ReducedLatencySleep;
   4220       DWORD WinLogonFlags;
   4221       DWORD Spare3;
   4222       DWORD DozeS4Timeout;
   4223       DWORD BroadcastCapacityResolution;
   4224       SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
   4225       DWORD VideoTimeout;
   4226       BOOLEAN VideoDimDisplay;
   4227       DWORD VideoReserved[3];
   4228       DWORD SpindownTimeout;
   4229       BOOLEAN OptimizeForPower;
   4230       BYTE FanThrottleTolerance;
   4231       BYTE ForcedThrottle;
   4232       BYTE MinThrottle;
   4233       POWER_ACTION_POLICY OverThrottled;
   4234     } SYSTEM_POWER_POLICY,*PSYSTEM_POWER_POLICY;
   4235 
   4236     typedef struct _PROCESSOR_POWER_POLICY_INFO {
   4237       DWORD TimeCheck;
   4238       DWORD DemoteLimit;
   4239       DWORD PromoteLimit;
   4240       BYTE DemotePercent;
   4241       BYTE PromotePercent;
   4242       BYTE Spare[2];
   4243       DWORD AllowDemotion:1;
   4244       DWORD AllowPromotion:1;
   4245       DWORD Reserved:30;
   4246     } PROCESSOR_POWER_POLICY_INFO,*PPROCESSOR_POWER_POLICY_INFO;
   4247 
   4248     typedef struct _PROCESSOR_POWER_POLICY {
   4249       DWORD Revision;
   4250       BYTE DynamicThrottle;
   4251       BYTE Spare[3];
   4252       DWORD DisableCStates:1;
   4253       DWORD Reserved:31;
   4254       DWORD PolicyCount;
   4255       PROCESSOR_POWER_POLICY_INFO Policy[3];
   4256     } PROCESSOR_POWER_POLICY,*PPROCESSOR_POWER_POLICY;
   4257 
   4258     typedef struct _ADMINISTRATOR_POWER_POLICY {
   4259       SYSTEM_POWER_STATE MinSleep;
   4260       SYSTEM_POWER_STATE MaxSleep;
   4261       DWORD MinVideoTimeout;
   4262       DWORD MaxVideoTimeout;
   4263       DWORD MinSpindownTimeout;
   4264       DWORD MaxSpindownTimeout;
   4265     } ADMINISTRATOR_POWER_POLICY,*PADMINISTRATOR_POWER_POLICY;
   4266 
   4267     typedef struct {
   4268       BOOLEAN PowerButtonPresent;
   4269       BOOLEAN SleepButtonPresent;
   4270       BOOLEAN LidPresent;
   4271       BOOLEAN SystemS1;
   4272       BOOLEAN SystemS2;
   4273       BOOLEAN SystemS3;
   4274       BOOLEAN SystemS4;
   4275       BOOLEAN SystemS5;
   4276       BOOLEAN HiberFilePresent;
   4277       BOOLEAN FullWake;
   4278       BOOLEAN VideoDimPresent;
   4279       BOOLEAN ApmPresent;
   4280       BOOLEAN UpsPresent;
   4281       BOOLEAN ThermalControl;
   4282       BOOLEAN ProcessorThrottle;
   4283       BYTE ProcessorMinThrottle;
   4284       BYTE ProcessorMaxThrottle;
   4285       BOOLEAN FastSystemS4;
   4286       BYTE spare2[3];
   4287       BOOLEAN DiskSpinDown;
   4288       BYTE spare3[8];
   4289       BOOLEAN SystemBatteriesPresent;
   4290       BOOLEAN BatteriesAreShortTerm;
   4291       BATTERY_REPORTING_SCALE BatteryScale[3];
   4292       SYSTEM_POWER_STATE AcOnLineWake;
   4293       SYSTEM_POWER_STATE SoftLidWake;
   4294       SYSTEM_POWER_STATE RtcWake;
   4295       SYSTEM_POWER_STATE MinDeviceWakeState;
   4296       SYSTEM_POWER_STATE DefaultLowLatencyWake;
   4297     } SYSTEM_POWER_CAPABILITIES,*PSYSTEM_POWER_CAPABILITIES;
   4298 
   4299     typedef struct {
   4300       BOOLEAN AcOnLine;
   4301       BOOLEAN BatteryPresent;
   4302       BOOLEAN Charging;
   4303       BOOLEAN Discharging;
   4304       BOOLEAN Spare1[4];
   4305       DWORD MaxCapacity;
   4306       DWORD RemainingCapacity;
   4307       DWORD Rate;
   4308       DWORD EstimatedTime;
   4309       DWORD DefaultAlert1;
   4310       DWORD DefaultAlert2;
   4311     } SYSTEM_BATTERY_STATE,*PSYSTEM_BATTERY_STATE;
   4312 
   4313 #include "pshpack4.h"
   4314 
   4315 #define IMAGE_DOS_SIGNATURE 0x5A4D
   4316 #define IMAGE_OS2_SIGNATURE 0x454E
   4317 #define IMAGE_OS2_SIGNATURE_LE 0x454C
   4318 #define IMAGE_VXD_SIGNATURE 0x454C
   4319 #define IMAGE_NT_SIGNATURE 0x00004550
   4320 
   4321 #include "pshpack2.h"
   4322 
   4323     typedef struct _IMAGE_DOS_HEADER {
   4324       WORD e_magic;
   4325       WORD e_cblp;
   4326       WORD e_cp;
   4327       WORD e_crlc;
   4328       WORD e_cparhdr;
   4329       WORD e_minalloc;
   4330       WORD e_maxalloc;
   4331       WORD e_ss;
   4332       WORD e_sp;
   4333       WORD e_csum;
   4334       WORD e_ip;
   4335       WORD e_cs;
   4336       WORD e_lfarlc;
   4337       WORD e_ovno;
   4338       WORD e_res[4];
   4339       WORD e_oemid;
   4340       WORD e_oeminfo;
   4341       WORD e_res2[10];
   4342       LONG e_lfanew;
   4343     } IMAGE_DOS_HEADER,*PIMAGE_DOS_HEADER;
   4344 
   4345     typedef struct _IMAGE_OS2_HEADER {
   4346       WORD ne_magic;
   4347       CHAR ne_ver;
   4348       CHAR ne_rev;
   4349       WORD ne_enttab;
   4350       WORD ne_cbenttab;
   4351       LONG ne_crc;
   4352       WORD ne_flags;
   4353       WORD ne_autodata;
   4354       WORD ne_heap;
   4355       WORD ne_stack;
   4356       LONG ne_csip;
   4357       LONG ne_sssp;
   4358       WORD ne_cseg;
   4359       WORD ne_cmod;
   4360       WORD ne_cbnrestab;
   4361       WORD ne_segtab;
   4362       WORD ne_rsrctab;
   4363       WORD ne_restab;
   4364       WORD ne_modtab;
   4365       WORD ne_imptab;
   4366       LONG ne_nrestab;
   4367       WORD ne_cmovent;
   4368       WORD ne_align;
   4369       WORD ne_cres;
   4370       BYTE ne_exetyp;
   4371       BYTE ne_flagsothers;
   4372       WORD ne_pretthunks;
   4373       WORD ne_psegrefbytes;
   4374       WORD ne_swaparea;
   4375       WORD ne_expver;
   4376     } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
   4377 
   4378     typedef struct _IMAGE_VXD_HEADER {
   4379       WORD e32_magic;
   4380       BYTE e32_border;
   4381       BYTE e32_worder;
   4382       DWORD e32_level;
   4383       WORD e32_cpu;
   4384       WORD e32_os;
   4385       DWORD e32_ver;
   4386       DWORD e32_mflags;
   4387       DWORD e32_mpages;
   4388       DWORD e32_startobj;
   4389       DWORD e32_eip;
   4390       DWORD e32_stackobj;
   4391       DWORD e32_esp;
   4392       DWORD e32_pagesize;
   4393       DWORD e32_lastpagesize;
   4394       DWORD e32_fixupsize;
   4395       DWORD e32_fixupsum;
   4396       DWORD e32_ldrsize;
   4397       DWORD e32_ldrsum;
   4398       DWORD e32_objtab;
   4399       DWORD e32_objcnt;
   4400       DWORD e32_objmap;
   4401       DWORD e32_itermap;
   4402       DWORD e32_rsrctab;
   4403       DWORD e32_rsrccnt;
   4404       DWORD e32_restab;
   4405       DWORD e32_enttab;
   4406       DWORD e32_dirtab;
   4407       DWORD e32_dircnt;
   4408       DWORD e32_fpagetab;
   4409       DWORD e32_frectab;
   4410       DWORD e32_impmod;
   4411       DWORD e32_impmodcnt;
   4412       DWORD e32_impproc;
   4413       DWORD e32_pagesum;
   4414       DWORD e32_datapage;
   4415       DWORD e32_preload;
   4416       DWORD e32_nrestab;
   4417       DWORD e32_cbnrestab;
   4418       DWORD e32_nressum;
   4419       DWORD e32_autodata;
   4420       DWORD e32_debuginfo;
   4421       DWORD e32_debuglen;
   4422       DWORD e32_instpreload;
   4423       DWORD e32_instdemand;
   4424       DWORD e32_heapsize;
   4425       BYTE e32_res3[12];
   4426       DWORD e32_winresoff;
   4427       DWORD e32_winreslen;
   4428       WORD e32_devid;
   4429       WORD e32_ddkver;
   4430     } IMAGE_VXD_HEADER,*PIMAGE_VXD_HEADER;
   4431 
   4432 #include "poppack.h"
   4433 
   4434     typedef struct _IMAGE_FILE_HEADER {
   4435       WORD Machine;
   4436       WORD NumberOfSections;
   4437       DWORD TimeDateStamp;
   4438       DWORD PointerToSymbolTable;
   4439       DWORD NumberOfSymbols;
   4440       WORD SizeOfOptionalHeader;
   4441       WORD Characteristics;
   4442     } IMAGE_FILE_HEADER,*PIMAGE_FILE_HEADER;
   4443 
   4444 #define IMAGE_SIZEOF_FILE_HEADER 20
   4445 
   4446 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001
   4447 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
   4448 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
   4449 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
   4450 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
   4451 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
   4452 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
   4453 #define IMAGE_FILE_32BIT_MACHINE 0x0100
   4454 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
   4455 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
   4456 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
   4457 #define IMAGE_FILE_SYSTEM 0x1000
   4458 #define IMAGE_FILE_DLL 0x2000
   4459 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
   4460 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
   4461 
   4462 #define IMAGE_FILE_MACHINE_UNKNOWN 0
   4463 #define IMAGE_FILE_MACHINE_I386 0x014c
   4464 #define IMAGE_FILE_MACHINE_R3000 0x0162
   4465 #define IMAGE_FILE_MACHINE_R4000 0x0166
   4466 #define IMAGE_FILE_MACHINE_R10000 0x0168
   4467 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
   4468 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
   4469 #define IMAGE_FILE_MACHINE_SH3 0x01a2
   4470 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
   4471 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
   4472 #define IMAGE_FILE_MACHINE_SH4 0x01a6
   4473 #define IMAGE_FILE_MACHINE_SH5 0x01a8
   4474 #define IMAGE_FILE_MACHINE_ARM 0x01c0
   4475 #define IMAGE_FILE_MACHINE_ARMV7 0x01c4
   4476 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
   4477 #define IMAGE_FILE_MACHINE_AM33 0x01d3
   4478 #define IMAGE_FILE_MACHINE_POWERPC 0x01F0
   4479 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
   4480 #define IMAGE_FILE_MACHINE_IA64 0x0200
   4481 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
   4482 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
   4483 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
   4484 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
   4485 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
   4486 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
   4487 #define IMAGE_FILE_MACHINE_CEF 0x0CEF
   4488 #define IMAGE_FILE_MACHINE_EBC 0x0EBC
   4489 #define IMAGE_FILE_MACHINE_AMD64 0x8664
   4490 #define IMAGE_FILE_MACHINE_M32R 0x9041
   4491 #define IMAGE_FILE_MACHINE_CEE 0xC0EE
   4492 
   4493     typedef struct _IMAGE_DATA_DIRECTORY {
   4494       DWORD VirtualAddress;
   4495       DWORD Size;
   4496     } IMAGE_DATA_DIRECTORY,*PIMAGE_DATA_DIRECTORY;
   4497 
   4498 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
   4499 
   4500     typedef struct _IMAGE_OPTIONAL_HEADER {
   4501 
   4502       WORD Magic;
   4503       BYTE MajorLinkerVersion;
   4504       BYTE MinorLinkerVersion;
   4505       DWORD SizeOfCode;
   4506       DWORD SizeOfInitializedData;
   4507       DWORD SizeOfUninitializedData;
   4508       DWORD AddressOfEntryPoint;
   4509       DWORD BaseOfCode;
   4510       DWORD BaseOfData;
   4511       DWORD ImageBase;
   4512       DWORD SectionAlignment;
   4513       DWORD FileAlignment;
   4514       WORD MajorOperatingSystemVersion;
   4515       WORD MinorOperatingSystemVersion;
   4516       WORD MajorImageVersion;
   4517       WORD MinorImageVersion;
   4518       WORD MajorSubsystemVersion;
   4519       WORD MinorSubsystemVersion;
   4520       DWORD Win32VersionValue;
   4521       DWORD SizeOfImage;
   4522       DWORD SizeOfHeaders;
   4523       DWORD CheckSum;
   4524       WORD Subsystem;
   4525       WORD DllCharacteristics;
   4526       DWORD SizeOfStackReserve;
   4527       DWORD SizeOfStackCommit;
   4528       DWORD SizeOfHeapReserve;
   4529       DWORD SizeOfHeapCommit;
   4530       DWORD LoaderFlags;
   4531       DWORD NumberOfRvaAndSizes;
   4532       IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
   4533     } IMAGE_OPTIONAL_HEADER32,*PIMAGE_OPTIONAL_HEADER32;
   4534 
   4535     typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
   4536       WORD Magic;
   4537       BYTE MajorLinkerVersion;
   4538       BYTE MinorLinkerVersion;
   4539       DWORD SizeOfCode;
   4540       DWORD SizeOfInitializedData;
   4541       DWORD SizeOfUninitializedData;
   4542       DWORD AddressOfEntryPoint;
   4543       DWORD BaseOfCode;
   4544       DWORD BaseOfData;
   4545       DWORD BaseOfBss;
   4546       DWORD GprMask;
   4547       DWORD CprMask[4];
   4548       DWORD GpValue;
   4549     } IMAGE_ROM_OPTIONAL_HEADER,*PIMAGE_ROM_OPTIONAL_HEADER;
   4550 
   4551     typedef struct _IMAGE_OPTIONAL_HEADER64 {
   4552       WORD Magic;
   4553       BYTE MajorLinkerVersion;
   4554       BYTE MinorLinkerVersion;
   4555       DWORD SizeOfCode;
   4556       DWORD SizeOfInitializedData;
   4557       DWORD SizeOfUninitializedData;
   4558       DWORD AddressOfEntryPoint;
   4559       DWORD BaseOfCode;
   4560       ULONGLONG ImageBase;
   4561       DWORD SectionAlignment;
   4562       DWORD FileAlignment;
   4563       WORD MajorOperatingSystemVersion;
   4564       WORD MinorOperatingSystemVersion;
   4565       WORD MajorImageVersion;
   4566       WORD MinorImageVersion;
   4567       WORD MajorSubsystemVersion;
   4568       WORD MinorSubsystemVersion;
   4569       DWORD Win32VersionValue;
   4570       DWORD SizeOfImage;
   4571       DWORD SizeOfHeaders;
   4572       DWORD CheckSum;
   4573       WORD Subsystem;
   4574       WORD DllCharacteristics;
   4575       ULONGLONG SizeOfStackReserve;
   4576       ULONGLONG SizeOfStackCommit;
   4577       ULONGLONG SizeOfHeapReserve;
   4578       ULONGLONG SizeOfHeapCommit;
   4579       DWORD LoaderFlags;
   4580       DWORD NumberOfRvaAndSizes;
   4581       IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
   4582     } IMAGE_OPTIONAL_HEADER64,*PIMAGE_OPTIONAL_HEADER64;
   4583 
   4584 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
   4585 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
   4586 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
   4587 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
   4588 
   4589 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
   4590 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
   4591 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
   4592 
   4593 #ifdef _WIN64
   4594     typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
   4595     typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
   4596 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
   4597 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
   4598 #else  /* _WIN64 */
   4599     typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
   4600     typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
   4601 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
   4602 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
   4603 #endif /* _WIN64 */
   4604 
   4605     typedef struct _IMAGE_NT_HEADERS64 {
   4606       DWORD Signature;
   4607       IMAGE_FILE_HEADER FileHeader;
   4608       IMAGE_OPTIONAL_HEADER64 OptionalHeader;
   4609     } IMAGE_NT_HEADERS64,*PIMAGE_NT_HEADERS64;
   4610 
   4611     typedef struct _IMAGE_NT_HEADERS {
   4612       DWORD Signature;
   4613       IMAGE_FILE_HEADER FileHeader;
   4614       IMAGE_OPTIONAL_HEADER32 OptionalHeader;
   4615     } IMAGE_NT_HEADERS32,*PIMAGE_NT_HEADERS32;
   4616 
   4617     typedef struct _IMAGE_ROM_HEADERS {
   4618       IMAGE_FILE_HEADER FileHeader;
   4619       IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
   4620     } IMAGE_ROM_HEADERS,*PIMAGE_ROM_HEADERS;
   4621 
   4622 #ifdef _WIN64
   4623     typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
   4624     typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
   4625 #else  /* _WIN64 */
   4626     typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
   4627     typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
   4628 #endif /* _WIN64 */
   4629 
   4630 #define IMAGE_FIRST_SECTION(ntheader) ((PIMAGE_SECTION_HEADER) ((ULONG_PTR)ntheader + FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader) + ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
   4631 
   4632 #define IMAGE_SUBSYSTEM_UNKNOWN 0
   4633 #define IMAGE_SUBSYSTEM_NATIVE 1
   4634 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
   4635 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
   4636 #define IMAGE_SUBSYSTEM_OS2_CUI 5
   4637 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
   4638 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8
   4639 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
   4640 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
   4641 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
   4642 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
   4643 #define IMAGE_SUBSYSTEM_EFI_ROM 13
   4644 #define IMAGE_SUBSYSTEM_XBOX 14
   4645 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
   4646 
   4647 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
   4648 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
   4649 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
   4650 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
   4651 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
   4652 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
   4653 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
   4654 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
   4655 
   4656 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
   4657 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
   4658 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
   4659 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
   4660 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
   4661 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
   4662 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
   4663 
   4664 #define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7
   4665 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
   4666 #define IMAGE_DIRECTORY_ENTRY_TLS 9
   4667 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
   4668 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
   4669 #define IMAGE_DIRECTORY_ENTRY_IAT 12
   4670 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
   4671 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
   4672 
   4673     typedef struct ANON_OBJECT_HEADER {
   4674       WORD Sig1;
   4675       WORD Sig2;
   4676       WORD Version;
   4677       WORD Machine;
   4678       DWORD TimeDateStamp;
   4679       CLSID ClassID;
   4680       DWORD SizeOfData;
   4681     } ANON_OBJECT_HEADER;
   4682 
   4683 #define IMAGE_SIZEOF_SHORT_NAME 8
   4684 
   4685     typedef struct _IMAGE_SECTION_HEADER {
   4686       BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
   4687       union {
   4688 	DWORD PhysicalAddress;
   4689 	DWORD VirtualSize;
   4690       } Misc;
   4691       DWORD VirtualAddress;
   4692       DWORD SizeOfRawData;
   4693       DWORD PointerToRawData;
   4694       DWORD PointerToRelocations;
   4695       DWORD PointerToLinenumbers;
   4696       WORD NumberOfRelocations;
   4697       WORD NumberOfLinenumbers;
   4698       DWORD Characteristics;
   4699     } IMAGE_SECTION_HEADER,*PIMAGE_SECTION_HEADER;
   4700 
   4701 #define IMAGE_SIZEOF_SECTION_HEADER 40
   4702 
   4703 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008
   4704 
   4705 #define IMAGE_SCN_CNT_CODE 0x00000020
   4706 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
   4707 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
   4708 #define IMAGE_SCN_LNK_OTHER 0x00000100
   4709 #define IMAGE_SCN_LNK_INFO 0x00000200
   4710 #define IMAGE_SCN_LNK_REMOVE 0x00000800
   4711 #define IMAGE_SCN_LNK_COMDAT 0x00001000
   4712 #define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000
   4713 #define IMAGE_SCN_GPREL 0x00008000
   4714 #define IMAGE_SCN_MEM_FARDATA 0x00008000
   4715 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
   4716 #define IMAGE_SCN_MEM_16BIT 0x00020000
   4717 #define IMAGE_SCN_MEM_LOCKED 0x00040000
   4718 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
   4719 
   4720 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
   4721 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
   4722 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
   4723 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
   4724 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000
   4725 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
   4726 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
   4727 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
   4728 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
   4729 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
   4730 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
   4731 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
   4732 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
   4733 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
   4734 
   4735 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
   4736 
   4737 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
   4738 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
   4739 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
   4740 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
   4741 #define IMAGE_SCN_MEM_SHARED 0x10000000
   4742 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
   4743 #define IMAGE_SCN_MEM_READ 0x40000000
   4744 #define IMAGE_SCN_MEM_WRITE 0x80000000
   4745 
   4746 #define IMAGE_SCN_SCALE_INDEX 0x00000001
   4747 
   4748 #include "pshpack2.h"
   4749 
   4750     typedef struct _IMAGE_SYMBOL {
   4751       union {
   4752 	BYTE ShortName[8];
   4753 	struct {
   4754 	  DWORD Short;
   4755 	  DWORD Long;
   4756 	} Name;
   4757 	DWORD LongName[2];
   4758       } N;
   4759       DWORD Value;
   4760       SHORT SectionNumber;
   4761       WORD Type;
   4762       BYTE StorageClass;
   4763       BYTE NumberOfAuxSymbols;
   4764     } IMAGE_SYMBOL;
   4765     typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
   4766 
   4767 #define IMAGE_SIZEOF_SYMBOL 18
   4768 
   4769 #define IMAGE_SYM_UNDEFINED (SHORT)0
   4770 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
   4771 #define IMAGE_SYM_DEBUG (SHORT)-2
   4772 #define IMAGE_SYM_SECTION_MAX 0xFEFF
   4773 #define IMAGE_SYM_SECTION_MAX_EX MAXLONG
   4774 
   4775 #define IMAGE_SYM_TYPE_NULL 0x0000
   4776 #define IMAGE_SYM_TYPE_VOID 0x0001
   4777 #define IMAGE_SYM_TYPE_CHAR 0x0002
   4778 #define IMAGE_SYM_TYPE_SHORT 0x0003
   4779 #define IMAGE_SYM_TYPE_INT 0x0004
   4780 #define IMAGE_SYM_TYPE_LONG 0x0005
   4781 #define IMAGE_SYM_TYPE_FLOAT 0x0006
   4782 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
   4783 #define IMAGE_SYM_TYPE_STRUCT 0x0008
   4784 #define IMAGE_SYM_TYPE_UNION 0x0009
   4785 #define IMAGE_SYM_TYPE_ENUM 0x000A
   4786 #define IMAGE_SYM_TYPE_MOE 0x000B
   4787 #define IMAGE_SYM_TYPE_BYTE 0x000C
   4788 #define IMAGE_SYM_TYPE_WORD 0x000D
   4789 #define IMAGE_SYM_TYPE_UINT 0x000E
   4790 #define IMAGE_SYM_TYPE_DWORD 0x000F
   4791 #define IMAGE_SYM_TYPE_PCODE 0x8000
   4792 
   4793 #define IMAGE_SYM_DTYPE_NULL 0
   4794 #define IMAGE_SYM_DTYPE_POINTER 1
   4795 #define IMAGE_SYM_DTYPE_FUNCTION 2
   4796 #define IMAGE_SYM_DTYPE_ARRAY 3
   4797 
   4798 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE)-1
   4799 #define IMAGE_SYM_CLASS_NULL 0x0000
   4800 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
   4801 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
   4802 #define IMAGE_SYM_CLASS_STATIC 0x0003
   4803 #define IMAGE_SYM_CLASS_REGISTER 0x0004
   4804 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
   4805 #define IMAGE_SYM_CLASS_LABEL 0x0006
   4806 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
   4807 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
   4808 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
   4809 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
   4810 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
   4811 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
   4812 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
   4813 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
   4814 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
   4815 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
   4816 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
   4817 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
   4818 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
   4819 #define IMAGE_SYM_CLASS_BLOCK 0x0064
   4820 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
   4821 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
   4822 #define IMAGE_SYM_CLASS_FILE 0x0067
   4823 #define IMAGE_SYM_CLASS_SECTION 0x0068
   4824 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
   4825 #define IMAGE_SYM_CLASS_CLR_TOKEN 0x006B
   4826 
   4827 #define N_BTMASK 0x000F
   4828 #define N_TMASK 0x0030
   4829 #define N_TMASK1 0x00C0
   4830 #define N_TMASK2 0x00F0
   4831 #define N_BTSHFT 4
   4832 #define N_TSHIFT 2
   4833 
   4834 #define BTYPE(x) ((x) & N_BTMASK)
   4835 
   4836 #ifndef ISPTR
   4837 #define ISPTR(x) (((x) & N_TMASK)==(IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
   4838 #endif
   4839 
   4840 #ifndef ISFCN
   4841 #define ISFCN(x) (((x) & N_TMASK)==(IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
   4842 #endif
   4843 
   4844 #ifndef ISARY
   4845 #define ISARY(x) (((x) & N_TMASK)==(IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
   4846 #endif
   4847 
   4848 #ifndef ISTAG
   4849 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
   4850 #endif
   4851 
   4852 #ifndef INCREF
   4853 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
   4854 #endif
   4855 #ifndef DECREF
   4856 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
   4857 #endif
   4858 
   4859     typedef union _IMAGE_AUX_SYMBOL {
   4860       struct {
   4861 	DWORD TagIndex;
   4862 	union {
   4863 	  struct {
   4864 	    WORD Linenumber;
   4865 	    WORD Size;
   4866 	  } LnSz;
   4867 	  DWORD TotalSize;
   4868 	} Misc;
   4869 	union {
   4870 	  struct {
   4871 	    DWORD PointerToLinenumber;
   4872 	    DWORD PointerToNextFunction;
   4873 	  } Function;
   4874 	  struct {
   4875 	    WORD Dimension[4];
   4876 	  } Array;
   4877 	} FcnAry;
   4878 	WORD TvIndex;
   4879       } Sym;
   4880       struct {
   4881 	BYTE Name[IMAGE_SIZEOF_SYMBOL];
   4882       } File;
   4883       struct {
   4884 	DWORD Length;
   4885 	WORD NumberOfRelocations;
   4886 	WORD NumberOfLinenumbers;
   4887 	DWORD CheckSum;
   4888 	SHORT Number;
   4889 	BYTE Selection;
   4890       } Section;
   4891     } IMAGE_AUX_SYMBOL;
   4892     typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL;
   4893 
   4894 #define IMAGE_SIZEOF_AUX_SYMBOL 18
   4895 
   4896     typedef enum IMAGE_AUX_SYMBOL_TYPE {
   4897       IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1
   4898     } IMAGE_AUX_SYMBOL_TYPE;
   4899 
   4900 #include <pshpack2.h>
   4901 
   4902     typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF {
   4903       BYTE bAuxType;
   4904       BYTE bReserved;
   4905       DWORD SymbolTableIndex;
   4906       BYTE rgbReserved[12];
   4907     } IMAGE_AUX_SYMBOL_TOKEN_DEF;
   4908 
   4909     typedef IMAGE_AUX_SYMBOL_TOKEN_DEF UNALIGNED *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
   4910 
   4911 #include <poppack.h>
   4912 
   4913 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
   4914 #define IMAGE_COMDAT_SELECT_ANY 2
   4915 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
   4916 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
   4917 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
   4918 #define IMAGE_COMDAT_SELECT_LARGEST 6
   4919 #define IMAGE_COMDAT_SELECT_NEWEST 7
   4920 
   4921 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
   4922 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
   4923 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
   4924 
   4925     typedef struct _IMAGE_RELOCATION {
   4926       __C89_NAMELESS union {
   4927 	DWORD VirtualAddress;
   4928 	DWORD RelocCount;
   4929       } DUMMYUNIONNAME;
   4930       DWORD SymbolTableIndex;
   4931       WORD Type;
   4932     } IMAGE_RELOCATION;
   4933     typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
   4934 
   4935 #define IMAGE_SIZEOF_RELOCATION 10
   4936 
   4937 #define IMAGE_REL_I386_ABSOLUTE 0x0000
   4938 #define IMAGE_REL_I386_DIR16 0x0001
   4939 #define IMAGE_REL_I386_REL16 0x0002
   4940 #define IMAGE_REL_I386_DIR32 0x0006
   4941 #define IMAGE_REL_I386_DIR32NB 0x0007
   4942 #define IMAGE_REL_I386_SEG12 0x0009
   4943 #define IMAGE_REL_I386_SECTION 0x000A
   4944 #define IMAGE_REL_I386_SECREL 0x000B
   4945 #define IMAGE_REL_I386_TOKEN 0x000C
   4946 #define IMAGE_REL_I386_SECREL7 0x000D
   4947 #define IMAGE_REL_I386_REL32 0x0014
   4948 
   4949 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
   4950 #define IMAGE_REL_MIPS_REFHALF 0x0001
   4951 #define IMAGE_REL_MIPS_REFWORD 0x0002
   4952 #define IMAGE_REL_MIPS_JMPADDR 0x0003
   4953 #define IMAGE_REL_MIPS_REFHI 0x0004
   4954 #define IMAGE_REL_MIPS_REFLO 0x0005
   4955 #define IMAGE_REL_MIPS_GPREL 0x0006
   4956 #define IMAGE_REL_MIPS_LITERAL 0x0007
   4957 #define IMAGE_REL_MIPS_SECTION 0x000A
   4958 #define IMAGE_REL_MIPS_SECREL 0x000B
   4959 #define IMAGE_REL_MIPS_SECRELLO 0x000C
   4960 #define IMAGE_REL_MIPS_SECRELHI 0x000D
   4961 #define IMAGE_REL_MIPS_TOKEN 0x000E
   4962 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
   4963 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
   4964 #define IMAGE_REL_MIPS_PAIR 0x0025
   4965 
   4966 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
   4967 #define IMAGE_REL_ALPHA_REFLONG 0x0001
   4968 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
   4969 #define IMAGE_REL_ALPHA_GPREL32 0x0003
   4970 #define IMAGE_REL_ALPHA_LITERAL 0x0004
   4971 #define IMAGE_REL_ALPHA_LITUSE 0x0005
   4972 #define IMAGE_REL_ALPHA_GPDISP 0x0006
   4973 #define IMAGE_REL_ALPHA_BRADDR 0x0007
   4974 #define IMAGE_REL_ALPHA_HINT 0x0008
   4975 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
   4976 #define IMAGE_REL_ALPHA_REFHI 0x000A
   4977 #define IMAGE_REL_ALPHA_REFLO 0x000B
   4978 #define IMAGE_REL_ALPHA_PAIR 0x000C
   4979 #define IMAGE_REL_ALPHA_MATCH 0x000D
   4980 #define IMAGE_REL_ALPHA_SECTION 0x000E
   4981 #define IMAGE_REL_ALPHA_SECREL 0x000F
   4982 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
   4983 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
   4984 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
   4985 #define IMAGE_REL_ALPHA_REFQ3 0x0013
   4986 #define IMAGE_REL_ALPHA_REFQ2 0x0014
   4987 #define IMAGE_REL_ALPHA_REFQ1 0x0015
   4988 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
   4989 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
   4990 
   4991 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
   4992 #define IMAGE_REL_PPC_ADDR64 0x0001
   4993 #define IMAGE_REL_PPC_ADDR32 0x0002
   4994 #define IMAGE_REL_PPC_ADDR24 0x0003
   4995 #define IMAGE_REL_PPC_ADDR16 0x0004
   4996 #define IMAGE_REL_PPC_ADDR14 0x0005
   4997 #define IMAGE_REL_PPC_REL24 0x0006
   4998 #define IMAGE_REL_PPC_REL14 0x0007
   4999 #define IMAGE_REL_PPC_TOCREL16 0x0008
   5000 #define IMAGE_REL_PPC_TOCREL14 0x0009
   5001 #define IMAGE_REL_PPC_ADDR32NB 0x000A
   5002 #define IMAGE_REL_PPC_SECREL 0x000B
   5003 #define IMAGE_REL_PPC_SECTION 0x000C
   5004 #define IMAGE_REL_PPC_IFGLUE 0x000D
   5005 #define IMAGE_REL_PPC_IMGLUE 0x000E
   5006 #define IMAGE_REL_PPC_SECREL16 0x000F
   5007 #define IMAGE_REL_PPC_REFHI 0x0010
   5008 #define IMAGE_REL_PPC_REFLO 0x0011
   5009 #define IMAGE_REL_PPC_PAIR 0x0012
   5010 #define IMAGE_REL_PPC_SECRELLO 0x0013
   5011 #define IMAGE_REL_PPC_SECRELHI 0x0014
   5012 #define IMAGE_REL_PPC_GPREL 0x0015
   5013 #define IMAGE_REL_PPC_TOKEN 0x0016
   5014 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
   5015 #define IMAGE_REL_PPC_NEG 0x0100
   5016 #define IMAGE_REL_PPC_BRTAKEN 0x0200
   5017 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
   5018 #define IMAGE_REL_PPC_TOCDEFN 0x0800
   5019 
   5020 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
   5021 #define IMAGE_REL_SH3_DIRECT16 0x0001
   5022 #define IMAGE_REL_SH3_DIRECT32 0x0002
   5023 #define IMAGE_REL_SH3_DIRECT8 0x0003
   5024 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
   5025 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
   5026 #define IMAGE_REL_SH3_DIRECT4 0x0006
   5027 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
   5028 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
   5029 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
   5030 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
   5031 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
   5032 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
   5033 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
   5034 #define IMAGE_REL_SH3_SECTION 0x000E
   5035 #define IMAGE_REL_SH3_SECREL 0x000F
   5036 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
   5037 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
   5038 #define IMAGE_REL_SH3_TOKEN 0x0012
   5039 
   5040 #define IMAGE_REL_SHM_PCRELPT 0x0013
   5041 #define IMAGE_REL_SHM_REFLO 0x0014
   5042 #define IMAGE_REL_SHM_REFHALF 0x0015
   5043 #define IMAGE_REL_SHM_RELLO 0x0016
   5044 #define IMAGE_REL_SHM_RELHALF 0x0017
   5045 #define IMAGE_REL_SHM_PAIR 0x0018
   5046 
   5047 #define IMAGE_REL_SH_NOMODE 0x8000
   5048 
   5049 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
   5050 #define IMAGE_REL_ARM_ADDR32 0x0001
   5051 #define IMAGE_REL_ARM_ADDR32NB 0x0002
   5052 #define IMAGE_REL_ARM_BRANCH24 0x0003
   5053 #define IMAGE_REL_ARM_BRANCH11 0x0004
   5054 #define IMAGE_REL_ARM_TOKEN 0x0005
   5055 #define IMAGE_REL_ARM_GPREL12 0x0006
   5056 #define IMAGE_REL_ARM_GPREL7 0x0007
   5057 #define IMAGE_REL_ARM_BLX24 0x0008
   5058 #define IMAGE_REL_ARM_BLX11 0x0009
   5059 #define IMAGE_REL_ARM_SECTION 0x000E
   5060 #define IMAGE_REL_ARM_SECREL 0x000F
   5061 
   5062 #define IMAGE_REL_AM_ABSOLUTE 0x0000
   5063 #define IMAGE_REL_AM_ADDR32 0x0001
   5064 #define IMAGE_REL_AM_ADDR32NB 0x0002
   5065 #define IMAGE_REL_AM_CALL32 0x0003
   5066 #define IMAGE_REL_AM_FUNCINFO 0x0004
   5067 #define IMAGE_REL_AM_REL32_1 0x0005
   5068 #define IMAGE_REL_AM_REL32_2 0x0006
   5069 #define IMAGE_REL_AM_SECREL 0x0007
   5070 #define IMAGE_REL_AM_SECTION 0x0008
   5071 #define IMAGE_REL_AM_TOKEN 0x0009
   5072 
   5073 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
   5074 #define IMAGE_REL_AMD64_ADDR64 0x0001
   5075 #define IMAGE_REL_AMD64_ADDR32 0x0002
   5076 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
   5077 #define IMAGE_REL_AMD64_REL32 0x0004
   5078 #define IMAGE_REL_AMD64_REL32_1 0x0005
   5079 #define IMAGE_REL_AMD64_REL32_2 0x0006
   5080 #define IMAGE_REL_AMD64_REL32_3 0x0007
   5081 #define IMAGE_REL_AMD64_REL32_4 0x0008
   5082 #define IMAGE_REL_AMD64_REL32_5 0x0009
   5083 #define IMAGE_REL_AMD64_SECTION 0x000A
   5084 #define IMAGE_REL_AMD64_SECREL 0x000B
   5085 #define IMAGE_REL_AMD64_SECREL7 0x000C
   5086 #define IMAGE_REL_AMD64_TOKEN 0x000D
   5087 #define IMAGE_REL_AMD64_SREL32 0x000E
   5088 #define IMAGE_REL_AMD64_PAIR 0x000F
   5089 #define IMAGE_REL_AMD64_SSPAN32 0x0010
   5090 
   5091 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
   5092 #define IMAGE_REL_IA64_IMM14 0x0001
   5093 #define IMAGE_REL_IA64_IMM22 0x0002
   5094 #define IMAGE_REL_IA64_IMM64 0x0003
   5095 #define IMAGE_REL_IA64_DIR32 0x0004
   5096 #define IMAGE_REL_IA64_DIR64 0x0005
   5097 #define IMAGE_REL_IA64_PCREL21B 0x0006
   5098 #define IMAGE_REL_IA64_PCREL21M 0x0007
   5099 #define IMAGE_REL_IA64_PCREL21F 0x0008
   5100 #define IMAGE_REL_IA64_GPREL22 0x0009
   5101 #define IMAGE_REL_IA64_LTOFF22 0x000A
   5102 #define IMAGE_REL_IA64_SECTION 0x000B
   5103 #define IMAGE_REL_IA64_SECREL22 0x000C
   5104 #define IMAGE_REL_IA64_SECREL64I 0x000D
   5105 #define IMAGE_REL_IA64_SECREL32 0x000E
   5106 
   5107 #define IMAGE_REL_IA64_DIR32NB 0x0010
   5108 #define IMAGE_REL_IA64_SREL14 0x0011
   5109 #define IMAGE_REL_IA64_SREL22 0x0012
   5110 #define IMAGE_REL_IA64_SREL32 0x0013
   5111 #define IMAGE_REL_IA64_UREL32 0x0014
   5112 #define IMAGE_REL_IA64_PCREL60X 0x0015
   5113 #define IMAGE_REL_IA64_PCREL60B 0x0016
   5114 #define IMAGE_REL_IA64_PCREL60F 0x0017
   5115 #define IMAGE_REL_IA64_PCREL60I 0x0018
   5116 #define IMAGE_REL_IA64_PCREL60M 0x0019
   5117 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
   5118 #define IMAGE_REL_IA64_TOKEN 0x001B
   5119 #define IMAGE_REL_IA64_GPREL32 0x001C
   5120 #define IMAGE_REL_IA64_ADDEND 0x001F
   5121 
   5122 #define IMAGE_REL_CEF_ABSOLUTE 0x0000
   5123 #define IMAGE_REL_CEF_ADDR32 0x0001
   5124 #define IMAGE_REL_CEF_ADDR64 0x0002
   5125 #define IMAGE_REL_CEF_ADDR32NB 0x0003
   5126 #define IMAGE_REL_CEF_SECTION 0x0004
   5127 #define IMAGE_REL_CEF_SECREL 0x0005
   5128 #define IMAGE_REL_CEF_TOKEN 0x0006
   5129 
   5130 #define IMAGE_REL_CEE_ABSOLUTE 0x0000
   5131 #define IMAGE_REL_CEE_ADDR32 0x0001
   5132 #define IMAGE_REL_CEE_ADDR64 0x0002
   5133 #define IMAGE_REL_CEE_ADDR32NB 0x0003
   5134 #define IMAGE_REL_CEE_SECTION 0x0004
   5135 #define IMAGE_REL_CEE_SECREL 0x0005
   5136 #define IMAGE_REL_CEE_TOKEN 0x0006
   5137 
   5138 #define IMAGE_REL_M32R_ABSOLUTE 0x0000
   5139 #define IMAGE_REL_M32R_ADDR32 0x0001
   5140 #define IMAGE_REL_M32R_ADDR32NB 0x0002
   5141 #define IMAGE_REL_M32R_ADDR24 0x0003
   5142 #define IMAGE_REL_M32R_GPREL16 0x0004
   5143 #define IMAGE_REL_M32R_PCREL24 0x0005
   5144 #define IMAGE_REL_M32R_PCREL16 0x0006
   5145 #define IMAGE_REL_M32R_PCREL8 0x0007
   5146 #define IMAGE_REL_M32R_REFHALF 0x0008
   5147 #define IMAGE_REL_M32R_REFHI 0x0009
   5148 #define IMAGE_REL_M32R_REFLO 0x000A
   5149 #define IMAGE_REL_M32R_PAIR 0x000B
   5150 #define IMAGE_REL_M32R_SECTION 0x000C
   5151 #define IMAGE_REL_M32R_SECREL32 0x000D
   5152 #define IMAGE_REL_M32R_TOKEN 0x000E
   5153 
   5154 #define IMAGE_REL_EBC_ABSOLUTE 0x0000
   5155 #define IMAGE_REL_EBC_ADDR32NB 0x0001
   5156 #define IMAGE_REL_EBC_REL32 0x0002
   5157 #define IMAGE_REL_EBC_SECTION 0x0003
   5158 #define IMAGE_REL_EBC_SECREL 0x0004
   5159 
   5160 #define EXT_IMM64(Value,Address,Size,InstPos,ValPos) Value |= (((ULONGLONG)((*(Address) >> InstPos) & (((ULONGLONG)1 << Size) - 1))) << ValPos)
   5161 #define INS_IMM64(Value,Address,Size,InstPos,ValPos) *(PDWORD)Address = (*(PDWORD)Address & ~(((1 << Size) - 1) << InstPos)) | ((DWORD)((((ULONGLONG)Value >> ValPos) & (((ULONGLONG)1 << Size) - 1))) << InstPos)
   5162 
   5163 #define EMARCH_ENC_I17_IMM7B_INST_WORD_X 3
   5164 #define EMARCH_ENC_I17_IMM7B_SIZE_X 7
   5165 #define EMARCH_ENC_I17_IMM7B_INST_WORD_POS_X 4
   5166 #define EMARCH_ENC_I17_IMM7B_VAL_POS_X 0
   5167 
   5168 #define EMARCH_ENC_I17_IMM9D_INST_WORD_X 3
   5169 #define EMARCH_ENC_I17_IMM9D_SIZE_X 9
   5170 #define EMARCH_ENC_I17_IMM9D_INST_WORD_POS_X 18
   5171 #define EMARCH_ENC_I17_IMM9D_VAL_POS_X 7
   5172 
   5173 #define EMARCH_ENC_I17_IMM5C_INST_WORD_X 3
   5174 #define EMARCH_ENC_I17_IMM5C_SIZE_X 5
   5175 #define EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X 13
   5176 #define EMARCH_ENC_I17_IMM5C_VAL_POS_X 16
   5177 
   5178 #define EMARCH_ENC_I17_IC_INST_WORD_X 3
   5179 #define EMARCH_ENC_I17_IC_SIZE_X 1
   5180 #define EMARCH_ENC_I17_IC_INST_WORD_POS_X 12
   5181 #define EMARCH_ENC_I17_IC_VAL_POS_X 21
   5182 
   5183 #define EMARCH_ENC_I17_IMM41a_INST_WORD_X 1
   5184 #define EMARCH_ENC_I17_IMM41a_SIZE_X 10
   5185 #define EMARCH_ENC_I17_IMM41a_INST_WORD_POS_X 14
   5186 #define EMARCH_ENC_I17_IMM41a_VAL_POS_X 22
   5187 
   5188 #define EMARCH_ENC_I17_IMM41b_INST_WORD_X 1
   5189 #define EMARCH_ENC_I17_IMM41b_SIZE_X 8
   5190 #define EMARCH_ENC_I17_IMM41b_INST_WORD_POS_X 24
   5191 #define EMARCH_ENC_I17_IMM41b_VAL_POS_X 32
   5192 
   5193 #define EMARCH_ENC_I17_IMM41c_INST_WORD_X 2
   5194 #define EMARCH_ENC_I17_IMM41c_SIZE_X 23
   5195 #define EMARCH_ENC_I17_IMM41c_INST_WORD_POS_X 0
   5196 #define EMARCH_ENC_I17_IMM41c_VAL_POS_X 40
   5197 
   5198 #define EMARCH_ENC_I17_SIGN_INST_WORD_X 3
   5199 #define EMARCH_ENC_I17_SIGN_SIZE_X 1
   5200 #define EMARCH_ENC_I17_SIGN_INST_WORD_POS_X 27
   5201 #define EMARCH_ENC_I17_SIGN_VAL_POS_X 63
   5202 
   5203 #define X3_OPCODE_INST_WORD_X 3
   5204 #define X3_OPCODE_SIZE_X 4
   5205 #define X3_OPCODE_INST_WORD_POS_X 28
   5206 #define X3_OPCODE_SIGN_VAL_POS_X 0
   5207 
   5208 #define X3_I_INST_WORD_X 3
   5209 #define X3_I_SIZE_X 1
   5210 #define X3_I_INST_WORD_POS_X 27
   5211 #define X3_I_SIGN_VAL_POS_X 59
   5212 
   5213 #define X3_D_WH_INST_WORD_X 3
   5214 #define X3_D_WH_SIZE_X 3
   5215 #define X3_D_WH_INST_WORD_POS_X 24
   5216 #define X3_D_WH_SIGN_VAL_POS_X 0
   5217 
   5218 #define X3_IMM20_INST_WORD_X 3
   5219 #define X3_IMM20_SIZE_X 20
   5220 #define X3_IMM20_INST_WORD_POS_X 4
   5221 #define X3_IMM20_SIGN_VAL_POS_X 0
   5222 
   5223 #define X3_IMM39_1_INST_WORD_X 2
   5224 #define X3_IMM39_1_SIZE_X 23
   5225 #define X3_IMM39_1_INST_WORD_POS_X 0
   5226 #define X3_IMM39_1_SIGN_VAL_POS_X 36
   5227 
   5228 #define X3_IMM39_2_INST_WORD_X 1
   5229 #define X3_IMM39_2_SIZE_X 16
   5230 #define X3_IMM39_2_INST_WORD_POS_X 16
   5231 #define X3_IMM39_2_SIGN_VAL_POS_X 20
   5232 
   5233 #define X3_P_INST_WORD_X 3
   5234 #define X3_P_SIZE_X 4
   5235 #define X3_P_INST_WORD_POS_X 0
   5236 #define X3_P_SIGN_VAL_POS_X 0
   5237 
   5238 #define X3_TMPLT_INST_WORD_X 0
   5239 #define X3_TMPLT_SIZE_X 4
   5240 #define X3_TMPLT_INST_WORD_POS_X 0
   5241 #define X3_TMPLT_SIGN_VAL_POS_X 0
   5242 
   5243 #define X3_BTYPE_QP_INST_WORD_X 2
   5244 #define X3_BTYPE_QP_SIZE_X 9
   5245 #define X3_BTYPE_QP_INST_WORD_POS_X 23
   5246 #define X3_BTYPE_QP_INST_VAL_POS_X 0
   5247 
   5248 #define X3_EMPTY_INST_WORD_X 1
   5249 #define X3_EMPTY_SIZE_X 2
   5250 #define X3_EMPTY_INST_WORD_POS_X 14
   5251 #define X3_EMPTY_INST_VAL_POS_X 0
   5252 
   5253     typedef struct _IMAGE_LINENUMBER {
   5254       union {
   5255 	DWORD SymbolTableIndex;
   5256 	DWORD VirtualAddress;
   5257       } Type;
   5258       WORD Linenumber;
   5259     } IMAGE_LINENUMBER;
   5260     typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER;
   5261 
   5262 #define IMAGE_SIZEOF_LINENUMBER 6
   5263 
   5264 #include "poppack.h"
   5265 
   5266     typedef struct _IMAGE_BASE_RELOCATION {
   5267       DWORD VirtualAddress;
   5268       DWORD SizeOfBlock;
   5269 
   5270     } IMAGE_BASE_RELOCATION;
   5271     typedef IMAGE_BASE_RELOCATION UNALIGNED *PIMAGE_BASE_RELOCATION;
   5272 
   5273 #define IMAGE_SIZEOF_BASE_RELOCATION 8
   5274 
   5275 #define IMAGE_REL_BASED_ABSOLUTE 0
   5276 #define IMAGE_REL_BASED_HIGH 1
   5277 #define IMAGE_REL_BASED_LOW 2
   5278 #define IMAGE_REL_BASED_HIGHLOW 3
   5279 #define IMAGE_REL_BASED_HIGHADJ 4
   5280 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
   5281 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
   5282 #define IMAGE_REL_BASED_IA64_IMM64 9
   5283 #define IMAGE_REL_BASED_DIR64 10
   5284 
   5285 #define IMAGE_ARCHIVE_START_SIZE 8
   5286 #define IMAGE_ARCHIVE_START "!<arch>\n"
   5287 #define IMAGE_ARCHIVE_END "`\n"
   5288 #define IMAGE_ARCHIVE_PAD "\n"
   5289 #define IMAGE_ARCHIVE_LINKER_MEMBER "/               "
   5290 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "//              "
   5291 
   5292     typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
   5293       BYTE Name[16];
   5294       BYTE Date[12];
   5295       BYTE UserID[6];
   5296       BYTE GroupID[6];
   5297       BYTE Mode[8];
   5298       BYTE Size[10];
   5299       BYTE EndHeader[2];
   5300     } IMAGE_ARCHIVE_MEMBER_HEADER,*PIMAGE_ARCHIVE_MEMBER_HEADER;
   5301 
   5302 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
   5303 
   5304     typedef struct _IMAGE_EXPORT_DIRECTORY {
   5305       DWORD Characteristics;
   5306       DWORD TimeDateStamp;
   5307       WORD MajorVersion;
   5308       WORD MinorVersion;
   5309       DWORD Name;
   5310       DWORD Base;
   5311       DWORD NumberOfFunctions;
   5312       DWORD NumberOfNames;
   5313       DWORD AddressOfFunctions;
   5314       DWORD AddressOfNames;
   5315       DWORD AddressOfNameOrdinals;
   5316     } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
   5317 
   5318     typedef struct _IMAGE_IMPORT_BY_NAME {
   5319       WORD Hint;
   5320       BYTE Name[1];
   5321     } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
   5322 
   5323 #include "pshpack8.h"
   5324 
   5325     typedef struct _IMAGE_THUNK_DATA64 {
   5326       union {
   5327 	ULONGLONG ForwarderString;
   5328 	ULONGLONG Function;
   5329 	ULONGLONG Ordinal;
   5330 	ULONGLONG AddressOfData;
   5331       } u1;
   5332     } IMAGE_THUNK_DATA64;
   5333     typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
   5334 
   5335 #include "poppack.h"
   5336 
   5337     typedef struct _IMAGE_THUNK_DATA32 {
   5338       union {
   5339 	DWORD ForwarderString;
   5340 	DWORD Function;
   5341 	DWORD Ordinal;
   5342 	DWORD AddressOfData;
   5343       } u1;
   5344     } IMAGE_THUNK_DATA32;
   5345     typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
   5346 
   5347 #define IMAGE_ORDINAL_FLAG64 0x8000000000000000ull
   5348 #define IMAGE_ORDINAL_FLAG32 0x80000000
   5349 #define IMAGE_ORDINAL64(Ordinal) (Ordinal & 0xffffull)
   5350 #define IMAGE_ORDINAL32(Ordinal) (Ordinal & 0xffff)
   5351 #define IMAGE_SNAP_BY_ORDINAL64(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG64)!=0)
   5352 #define IMAGE_SNAP_BY_ORDINAL32(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG32)!=0)
   5353 
   5354     typedef VOID
   5355       (NTAPI *PIMAGE_TLS_CALLBACK)(PVOID DllHandle,DWORD Reason,PVOID Reserved);
   5356 
   5357     typedef struct _IMAGE_TLS_DIRECTORY64 {
   5358       ULONGLONG StartAddressOfRawData;
   5359       ULONGLONG EndAddressOfRawData;
   5360       ULONGLONG AddressOfIndex;
   5361       ULONGLONG AddressOfCallBacks;
   5362       DWORD SizeOfZeroFill;
   5363       DWORD Characteristics;
   5364     } IMAGE_TLS_DIRECTORY64;
   5365     typedef IMAGE_TLS_DIRECTORY64 *PIMAGE_TLS_DIRECTORY64;
   5366 
   5367     typedef struct _IMAGE_TLS_DIRECTORY32 {
   5368       DWORD StartAddressOfRawData;
   5369       DWORD EndAddressOfRawData;
   5370       DWORD AddressOfIndex;
   5371       DWORD AddressOfCallBacks;
   5372       DWORD SizeOfZeroFill;
   5373       DWORD Characteristics;
   5374     } IMAGE_TLS_DIRECTORY32;
   5375     typedef IMAGE_TLS_DIRECTORY32 *PIMAGE_TLS_DIRECTORY32;
   5376 
   5377 #ifdef _WIN64
   5378 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
   5379 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
   5380     typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
   5381     typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
   5382 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
   5383     typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
   5384     typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
   5385 #else  /* _WIN64 */
   5386 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
   5387 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
   5388     typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
   5389     typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
   5390 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
   5391     typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
   5392     typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
   5393 #endif /* _WIN64 */
   5394 
   5395     typedef struct _IMAGE_IMPORT_DESCRIPTOR {
   5396       __C89_NAMELESS union {
   5397 	DWORD Characteristics;
   5398 	DWORD OriginalFirstThunk;
   5399       } DUMMYUNIONNAME;
   5400       DWORD TimeDateStamp;
   5401 
   5402       DWORD ForwarderChain;
   5403       DWORD Name;
   5404       DWORD FirstThunk;
   5405     } IMAGE_IMPORT_DESCRIPTOR;
   5406     typedef IMAGE_IMPORT_DESCRIPTOR UNALIGNED *PIMAGE_IMPORT_DESCRIPTOR;
   5407 
   5408     typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR {
   5409       DWORD TimeDateStamp;
   5410       WORD OffsetModuleName;
   5411       WORD NumberOfModuleForwarderRefs;
   5412     } IMAGE_BOUND_IMPORT_DESCRIPTOR,*PIMAGE_BOUND_IMPORT_DESCRIPTOR;
   5413 
   5414     typedef struct _IMAGE_BOUND_FORWARDER_REF {
   5415       DWORD TimeDateStamp;
   5416       WORD OffsetModuleName;
   5417       WORD Reserved;
   5418     } IMAGE_BOUND_FORWARDER_REF,*PIMAGE_BOUND_FORWARDER_REF;
   5419 
   5420     typedef struct _IMAGE_RESOURCE_DIRECTORY {
   5421       DWORD Characteristics;
   5422       DWORD TimeDateStamp;
   5423       WORD MajorVersion;
   5424       WORD MinorVersion;
   5425       WORD NumberOfNamedEntries;
   5426       WORD NumberOfIdEntries;
   5427     } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
   5428 
   5429 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
   5430 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
   5431 
   5432     typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
   5433       __C89_NAMELESS union {
   5434 	__C89_NAMELESS struct {
   5435 	  DWORD NameOffset:31;
   5436 	  DWORD NameIsString:1;
   5437 	} DUMMYSTRUCTNAME;
   5438 	DWORD Name;
   5439 	WORD Id;
   5440       } DUMMYUNIONNAME;
   5441       __C89_NAMELESS union {
   5442 	DWORD OffsetToData;
   5443 	__C89_NAMELESS struct {
   5444 	  DWORD OffsetToDirectory:31;
   5445 	  DWORD DataIsDirectory:1;
   5446 	} DUMMYSTRUCTNAME2;
   5447       } DUMMYUNIONNAME2;
   5448     } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
   5449 
   5450     typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
   5451       WORD Length;
   5452       CHAR NameString[1];
   5453     } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
   5454 
   5455     typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
   5456       WORD Length;
   5457       WCHAR NameString[1];
   5458     } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
   5459 
   5460     typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
   5461       DWORD OffsetToData;
   5462       DWORD Size;
   5463       DWORD CodePage;
   5464       DWORD Reserved;
   5465     } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
   5466 
   5467     typedef struct {
   5468       DWORD Size;
   5469       DWORD TimeDateStamp;
   5470       WORD MajorVersion;
   5471       WORD MinorVersion;
   5472       DWORD GlobalFlagsClear;
   5473       DWORD GlobalFlagsSet;
   5474       DWORD CriticalSectionDefaultTimeout;
   5475       DWORD DeCommitFreeBlockThreshold;
   5476       DWORD DeCommitTotalFreeThreshold;
   5477       DWORD LockPrefixTable;
   5478       DWORD MaximumAllocationSize;
   5479       DWORD VirtualMemoryThreshold;
   5480       DWORD ProcessHeapFlags;
   5481       DWORD ProcessAffinityMask;
   5482       WORD CSDVersion;
   5483       WORD Reserved1;
   5484       DWORD EditList;
   5485       DWORD SecurityCookie;
   5486       DWORD SEHandlerTable;
   5487       DWORD SEHandlerCount;
   5488     } IMAGE_LOAD_CONFIG_DIRECTORY32,*PIMAGE_LOAD_CONFIG_DIRECTORY32;
   5489 
   5490     typedef struct {
   5491       DWORD Size;
   5492       DWORD TimeDateStamp;
   5493       WORD MajorVersion;
   5494       WORD MinorVersion;
   5495       DWORD GlobalFlagsClear;
   5496       DWORD GlobalFlagsSet;
   5497       DWORD CriticalSectionDefaultTimeout;
   5498       ULONGLONG DeCommitFreeBlockThreshold;
   5499       ULONGLONG DeCommitTotalFreeThreshold;
   5500       ULONGLONG LockPrefixTable;
   5501       ULONGLONG MaximumAllocationSize;
   5502       ULONGLONG VirtualMemoryThreshold;
   5503       ULONGLONG ProcessAffinityMask;
   5504       DWORD ProcessHeapFlags;
   5505       WORD CSDVersion;
   5506       WORD Reserved1;
   5507       ULONGLONG EditList;
   5508       ULONGLONG SecurityCookie;
   5509       ULONGLONG SEHandlerTable;
   5510       ULONGLONG SEHandlerCount;
   5511     } IMAGE_LOAD_CONFIG_DIRECTORY64,*PIMAGE_LOAD_CONFIG_DIRECTORY64;
   5512 
   5513 #ifdef _WIN64
   5514     typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
   5515     typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
   5516 #else  /* _WIN64 */
   5517     typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
   5518     typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
   5519 #endif /* _WIN64 */
   5520 
   5521     typedef struct _IMAGE_CE_RUNTIME_FUNCTION_ENTRY {
   5522       DWORD FuncStart;
   5523       DWORD PrologLen : 8;
   5524       DWORD FuncLen : 22;
   5525       DWORD ThirtyTwoBit : 1;
   5526       DWORD ExceptionFlag : 1;
   5527     } IMAGE_CE_RUNTIME_FUNCTION_ENTRY,*PIMAGE_CE_RUNTIME_FUNCTION_ENTRY;
   5528 
   5529     typedef struct _IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY {
   5530       ULONGLONG BeginAddress;
   5531       ULONGLONG EndAddress;
   5532       ULONGLONG ExceptionHandler;
   5533       ULONGLONG HandlerData;
   5534       ULONGLONG PrologEndAddress;
   5535     } IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY,*PIMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY;
   5536 
   5537     typedef struct _IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY {
   5538       DWORD BeginAddress;
   5539       DWORD EndAddress;
   5540       DWORD ExceptionHandler;
   5541       DWORD HandlerData;
   5542       DWORD PrologEndAddress;
   5543     } IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY,*PIMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY;
   5544 
   5545     typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY {
   5546       DWORD BeginAddress;
   5547       DWORD EndAddress;
   5548       DWORD UnwindInfoAddress;
   5549     } _IMAGE_RUNTIME_FUNCTION_ENTRY,*_PIMAGE_RUNTIME_FUNCTION_ENTRY;
   5550 
   5551     typedef _IMAGE_RUNTIME_FUNCTION_ENTRY IMAGE_IA64_RUNTIME_FUNCTION_ENTRY;
   5552     typedef _PIMAGE_RUNTIME_FUNCTION_ENTRY PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY;
   5553 
   5554     typedef _IMAGE_RUNTIME_FUNCTION_ENTRY IMAGE_RUNTIME_FUNCTION_ENTRY;
   5555     typedef _PIMAGE_RUNTIME_FUNCTION_ENTRY PIMAGE_RUNTIME_FUNCTION_ENTRY;
   5556 
   5557     typedef struct _IMAGE_DEBUG_DIRECTORY {
   5558       DWORD Characteristics;
   5559       DWORD TimeDateStamp;
   5560       WORD MajorVersion;
   5561       WORD MinorVersion;
   5562       DWORD Type;
   5563       DWORD SizeOfData;
   5564       DWORD AddressOfRawData;
   5565       DWORD PointerToRawData;
   5566     } IMAGE_DEBUG_DIRECTORY,*PIMAGE_DEBUG_DIRECTORY;
   5567 
   5568 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
   5569 #define IMAGE_DEBUG_TYPE_COFF 1
   5570 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
   5571 #define IMAGE_DEBUG_TYPE_FPO 3
   5572 #define IMAGE_DEBUG_TYPE_MISC 4
   5573 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
   5574 #define IMAGE_DEBUG_TYPE_FIXUP 6
   5575 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
   5576 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
   5577 #define IMAGE_DEBUG_TYPE_BORLAND 9
   5578 #define IMAGE_DEBUG_TYPE_RESERVED10 10
   5579 #define IMAGE_DEBUG_TYPE_CLSID 11
   5580 
   5581     typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
   5582       DWORD NumberOfSymbols;
   5583       DWORD LvaToFirstSymbol;
   5584       DWORD NumberOfLinenumbers;
   5585       DWORD LvaToFirstLinenumber;
   5586       DWORD RvaToFirstByteOfCode;
   5587       DWORD RvaToLastByteOfCode;
   5588       DWORD RvaToFirstByteOfData;
   5589       DWORD RvaToLastByteOfData;
   5590     } IMAGE_COFF_SYMBOLS_HEADER,*PIMAGE_COFF_SYMBOLS_HEADER;
   5591 
   5592 #define FRAME_FPO 0
   5593 #define FRAME_TRAP 1
   5594 #define FRAME_TSS 2
   5595 #define FRAME_NONFPO 3
   5596 
   5597     typedef struct _FPO_DATA {
   5598       DWORD ulOffStart;
   5599       DWORD cbProcSize;
   5600       DWORD cdwLocals;
   5601       WORD cdwParams;
   5602       WORD cbProlog : 8;
   5603       WORD cbRegs : 3;
   5604       WORD fHasSEH : 1;
   5605       WORD fUseBP : 1;
   5606       WORD reserved : 1;
   5607       WORD cbFrame : 2;
   5608     } FPO_DATA,*PFPO_DATA;
   5609 #define SIZEOF_RFPO_DATA 16
   5610 
   5611 #define IMAGE_DEBUG_MISC_EXENAME 1
   5612 
   5613     typedef struct _IMAGE_DEBUG_MISC {
   5614       DWORD DataType;
   5615       DWORD Length;
   5616       BOOLEAN Unicode;
   5617       BYTE Reserved[3];
   5618       BYTE Data[1];
   5619     } IMAGE_DEBUG_MISC,*PIMAGE_DEBUG_MISC;
   5620 
   5621     typedef struct _IMAGE_FUNCTION_ENTRY {
   5622       DWORD StartingAddress;
   5623       DWORD EndingAddress;
   5624       DWORD EndOfPrologue;
   5625     } IMAGE_FUNCTION_ENTRY,*PIMAGE_FUNCTION_ENTRY;
   5626 
   5627     typedef struct _IMAGE_FUNCTION_ENTRY64 {
   5628       ULONGLONG StartingAddress;
   5629       ULONGLONG EndingAddress;
   5630       __C89_NAMELESS union {
   5631 	ULONGLONG EndOfPrologue;
   5632 	ULONGLONG UnwindInfoAddress;
   5633       } DUMMYUNIONNAME;
   5634     } IMAGE_FUNCTION_ENTRY64,*PIMAGE_FUNCTION_ENTRY64;
   5635 
   5636     typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
   5637       WORD Signature;
   5638       WORD Flags;
   5639       WORD Machine;
   5640       WORD Characteristics;
   5641       DWORD TimeDateStamp;
   5642       DWORD CheckSum;
   5643       DWORD ImageBase;
   5644       DWORD SizeOfImage;
   5645       DWORD NumberOfSections;
   5646       DWORD ExportedNamesSize;
   5647       DWORD DebugDirectorySize;
   5648       DWORD SectionAlignment;
   5649       DWORD Reserved[2];
   5650     } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
   5651 
   5652     typedef struct _NON_PAGED_DEBUG_INFO {
   5653       WORD Signature;
   5654       WORD Flags;
   5655       DWORD Size;
   5656       WORD Machine;
   5657       WORD Characteristics;
   5658       DWORD TimeDateStamp;
   5659       DWORD CheckSum;
   5660       DWORD SizeOfImage;
   5661       ULONGLONG ImageBase;
   5662 
   5663     } NON_PAGED_DEBUG_INFO,*PNON_PAGED_DEBUG_INFO;
   5664 
   5665 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
   5666 #define NON_PAGED_DEBUG_SIGNATURE 0x494E
   5667 
   5668 #define IMAGE_SEPARATE_DEBUG_FLAGS_MASK 0x8000
   5669 #define IMAGE_SEPARATE_DEBUG_MISMATCH 0x8000
   5670 
   5671     typedef struct _ImageArchitectureHeader {
   5672       unsigned int AmaskValue: 1;
   5673       int Adummy1 :7;
   5674       unsigned int AmaskShift: 8;
   5675       int Adummy2 :16;
   5676       DWORD FirstEntryRVA;
   5677     } IMAGE_ARCHITECTURE_HEADER,*PIMAGE_ARCHITECTURE_HEADER;
   5678 
   5679     typedef struct _ImageArchitectureEntry {
   5680       DWORD FixupInstRVA;
   5681       DWORD NewInst;
   5682     } IMAGE_ARCHITECTURE_ENTRY,*PIMAGE_ARCHITECTURE_ENTRY;
   5683 
   5684 #include "poppack.h"
   5685 
   5686 #define IMPORT_OBJECT_HDR_SIG2 0xffff
   5687 
   5688     typedef struct IMPORT_OBJECT_HEADER {
   5689       WORD Sig1;
   5690       WORD Sig2;
   5691       WORD Version;
   5692       WORD Machine;
   5693       DWORD TimeDateStamp;
   5694       DWORD SizeOfData;
   5695       __C89_NAMELESS union {
   5696 	WORD Ordinal;
   5697 	WORD Hint;
   5698       };
   5699       WORD Type : 2;
   5700       WORD NameType : 3;
   5701       WORD Reserved : 11;
   5702     } IMPORT_OBJECT_HEADER;
   5703 
   5704     typedef enum IMPORT_OBJECT_TYPE {
   5705       IMPORT_OBJECT_CODE = 0,IMPORT_OBJECT_DATA = 1,IMPORT_OBJECT_CONST = 2
   5706     } IMPORT_OBJECT_TYPE;
   5707 
   5708     typedef enum IMPORT_OBJECT_NAME_TYPE {
   5709       IMPORT_OBJECT_ORDINAL = 0,IMPORT_OBJECT_NAME = 1,IMPORT_OBJECT_NAME_NO_PREFIX = 2,IMPORT_OBJECT_NAME_UNDECORATE = 3
   5710     } IMPORT_OBJECT_NAME_TYPE;
   5711 
   5712 #ifndef __IMAGE_COR20_HEADER_DEFINED__
   5713 #define __IMAGE_COR20_HEADER_DEFINED__
   5714     typedef enum ReplacesCorHdrNumericDefines {
   5715       COMIMAGE_FLAGS_ILONLY =0x00000001,COMIMAGE_FLAGS_32BITREQUIRED =0x00000002,COMIMAGE_FLAGS_IL_LIBRARY =0x00000004,
   5716       COMIMAGE_FLAGS_STRONGNAMESIGNED =0x00000008,COMIMAGE_FLAGS_TRACKDEBUGDATA =0x00010000,COR_VERSION_MAJOR_V2 =2,
   5717       COR_VERSION_MAJOR =COR_VERSION_MAJOR_V2,COR_VERSION_MINOR =0,COR_DELETED_NAME_LENGTH =8,COR_VTABLEGAP_NAME_LENGTH =8,
   5718       NATIVE_TYPE_MAX_CB =1,COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE=0xFF,IMAGE_COR_MIH_METHODRVA =0x01,IMAGE_COR_MIH_EHRVA =0x02,
   5719       IMAGE_COR_MIH_BASICBLOCK =0x08,COR_VTABLE_32BIT =0x01,COR_VTABLE_64BIT =0x02,COR_VTABLE_FROM_UNMANAGED =0x04,
   5720       COR_VTABLE_CALL_MOST_DERIVED =0x10,IMAGE_COR_EATJ_THUNK_SIZE =32,MAX_CLASS_NAME =1024,MAX_PACKAGE_NAME =1024
   5721     } ReplacesCorHdrNumericDefines;
   5722 
   5723     typedef struct IMAGE_COR20_HEADER {
   5724       DWORD cb;
   5725       WORD MajorRuntimeVersion;
   5726       WORD MinorRuntimeVersion;
   5727       IMAGE_DATA_DIRECTORY MetaData;
   5728       DWORD Flags;
   5729       DWORD EntryPointToken;
   5730       IMAGE_DATA_DIRECTORY Resources;
   5731       IMAGE_DATA_DIRECTORY StrongNameSignature;
   5732       IMAGE_DATA_DIRECTORY CodeManagerTable;
   5733       IMAGE_DATA_DIRECTORY VTableFixups;
   5734       IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
   5735       IMAGE_DATA_DIRECTORY ManagedNativeHeader;
   5736     } IMAGE_COR20_HEADER,*PIMAGE_COR20_HEADER;
   5737 #endif
   5738 
   5739 #include <string.h>
   5740 
   5741 #ifndef _SLIST_HEADER_
   5742 #define _SLIST_HEADER_
   5743 
   5744 #ifdef _WIN64
   5745     typedef struct _SLIST_ENTRY *PSLIST_ENTRY;
   5746     typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
   5747       PSLIST_ENTRY Next;
   5748     } SLIST_ENTRY;
   5749 #else  /* _WIN64 */
   5750 
   5751 #define SLIST_ENTRY SINGLE_LIST_ENTRY
   5752 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
   5753 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
   5754 #endif /* _WIN64 */
   5755 
   5756 #if defined(_WIN64)
   5757 
   5758     typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER {
   5759       ULONGLONG Alignment;
   5760       ULONGLONG Region;
   5761     } SLIST_HEADER;
   5762 
   5763     typedef struct _SLIST_HEADER *PSLIST_HEADER;
   5764 #else  /* _WIN64 */
   5765 
   5766     typedef union _SLIST_HEADER {
   5767       ULONGLONG Alignment;
   5768       __C89_NAMELESS struct {
   5769 	SLIST_ENTRY Next;
   5770 	WORD Depth;
   5771 	WORD Sequence;
   5772       } DUMMYSTRUCTNAME;
   5773     } SLIST_HEADER,*PSLIST_HEADER;
   5774 #endif /* _WIN64 */
   5775 #endif /* _SLIST_HEADER_ */
   5776 
   5777     NTSYSAPI VOID NTAPI RtlInitializeSListHead(PSLIST_HEADER ListHead);
   5778     NTSYSAPI PSLIST_ENTRY NTAPI RtlFirstEntrySList(const SLIST_HEADER *ListHead);
   5779     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedPopEntrySList(PSLIST_HEADER ListHead);
   5780     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedPushEntrySList(PSLIST_HEADER ListHead,PSLIST_ENTRY ListEntry);
   5781     NTSYSAPI PSLIST_ENTRY NTAPI RtlInterlockedFlushSList(PSLIST_HEADER ListHead);
   5782     NTSYSAPI WORD NTAPI RtlQueryDepthSList(PSLIST_HEADER ListHead);
   5783 
   5784 #define HEAP_NO_SERIALIZE 0x00000001
   5785 #define HEAP_GROWABLE 0x00000002
   5786 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
   5787 #define HEAP_ZERO_MEMORY 0x00000008
   5788 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
   5789 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
   5790 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
   5791 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
   5792 #define HEAP_CREATE_ALIGN_16 0x00010000
   5793 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
   5794 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
   5795 #define HEAP_MAXIMUM_TAG 0x0FFF
   5796 #define HEAP_PSEUDO_TAG_FLAG 0x8000
   5797 #define HEAP_TAG_SHIFT 18
   5798 #define HEAP_MAKE_TAG_FLAGS(b,o) ((DWORD)((b) + ((o) << 18)))
   5799 
   5800     NTSYSAPI WORD NTAPI RtlCaptureStackBackTrace(DWORD FramesToSkip, DWORD FramesToCapture, PVOID *BackTrace, PDWORD BackTraceHash);
   5801     NTSYSAPI VOID NTAPI RtlCaptureContext(PCONTEXT ContextRecord);
   5802 
   5803 #define IS_TEXT_UNICODE_ASCII16 0x0001
   5804 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
   5805 
   5806 #define IS_TEXT_UNICODE_STATISTICS 0x0002
   5807 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
   5808 
   5809 #define IS_TEXT_UNICODE_CONTROLS 0x0004
   5810 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
   5811 
   5812 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
   5813 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
   5814 
   5815 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
   5816 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
   5817 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
   5818 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
   5819 
   5820 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
   5821 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
   5822 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
   5823 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
   5824 
   5825 #define COMPRESSION_FORMAT_NONE (0x0000)
   5826 #define COMPRESSION_FORMAT_DEFAULT (0x0001)
   5827 #define COMPRESSION_FORMAT_LZNT1 (0x0002)
   5828 #define COMPRESSION_ENGINE_STANDARD (0x0000)
   5829 #define COMPRESSION_ENGINE_MAXIMUM (0x0100)
   5830 #define COMPRESSION_ENGINE_HIBER (0x0200)
   5831 
   5832 #ifndef __CRT__NO_INLINE
   5833 #if _DBG_MEMCPY_INLINE_ && !defined(_MEMCPY_INLINE_) && !defined(_CRTBLD)
   5834 #define _MEMCPY_INLINE_
   5835     __CRT_INLINE PVOID __cdecl memcpy_inline(void *dst,const void *src,size_t size) {
   5836       if(((char *)dst > (char *)src) && ((char *)dst < ((char *)src + size))) {
   5837 	__debugbreak();
   5838       }
   5839       return memcpy(dst,src,size);
   5840     }
   5841 #define memcpy memcpy_inline
   5842 #endif /* _DBG_MEMCPY_INLINE_ && !defined(_MEMCPY_INLINE_) && !defined(_CRTBLD) */
   5843 #endif /* !__CRT__NO_INLINE */
   5844 
   5845     NTSYSAPI SIZE_T NTAPI RtlCompareMemory(const VOID *Source1,const VOID *Source2,SIZE_T Length);
   5846 
   5847     void WINAPI RtlUnwind(PVOID TargetFrame,PVOID TargetIp,PEXCEPTION_RECORD ExceptionRecord,PVOID ReturnValue);
   5848 
   5849 #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
   5850 #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
   5851 #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
   5852 #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
   5853 #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
   5854 
   5855     PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt);
   5856 #ifndef __CRT__NO_INLINE
   5857     __CRT_INLINE PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt) {
   5858       volatile char *vptr =(volatile char *)ptr;
   5859 #ifdef __x86_64
   5860       __stosb((PBYTE)((DWORD64)vptr),0,cnt);
   5861 #else
   5862       while(cnt) {
   5863 	*vptr = 0;
   5864 	vptr++;
   5865 	cnt--;
   5866       }
   5867 #endif /* __x86_64 */
   5868       return ptr;
   5869     }
   5870 #endif /* !__CRT__NO_INLINE */
   5871 
   5872     typedef struct _MESSAGE_RESOURCE_ENTRY {
   5873       WORD Length;
   5874       WORD Flags;
   5875       BYTE Text[1];
   5876     } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
   5877 
   5878 #define MESSAGE_RESOURCE_UNICODE 0x0001
   5879 
   5880     typedef struct _MESSAGE_RESOURCE_BLOCK {
   5881       DWORD LowId;
   5882       DWORD HighId;
   5883       DWORD OffsetToEntries;
   5884     } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
   5885 
   5886     typedef struct _MESSAGE_RESOURCE_DATA {
   5887       DWORD NumberOfBlocks;
   5888       MESSAGE_RESOURCE_BLOCK Blocks[1];
   5889     } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
   5890 
   5891     typedef struct _OSVERSIONINFOA {
   5892       DWORD dwOSVersionInfoSize;
   5893       DWORD dwMajorVersion;
   5894       DWORD dwMinorVersion;
   5895       DWORD dwBuildNumber;
   5896       DWORD dwPlatformId;
   5897       CHAR szCSDVersion[128];
   5898     } OSVERSIONINFOA,*POSVERSIONINFOA,*LPOSVERSIONINFOA;
   5899 
   5900     typedef struct _OSVERSIONINFOW {
   5901       DWORD dwOSVersionInfoSize;
   5902       DWORD dwMajorVersion;
   5903       DWORD dwMinorVersion;
   5904       DWORD dwBuildNumber;
   5905       DWORD dwPlatformId;
   5906       WCHAR szCSDVersion[128];
   5907     } OSVERSIONINFOW,*POSVERSIONINFOW,*LPOSVERSIONINFOW,RTL_OSVERSIONINFOW,*PRTL_OSVERSIONINFOW;
   5908 
   5909     __MINGW_TYPEDEF_AW(OSVERSIONINFO)
   5910     __MINGW_TYPEDEF_AW(POSVERSIONINFO)
   5911     __MINGW_TYPEDEF_AW(LPOSVERSIONINFO)
   5912 
   5913     typedef struct _OSVERSIONINFOEXA {
   5914       DWORD dwOSVersionInfoSize;
   5915       DWORD dwMajorVersion;
   5916       DWORD dwMinorVersion;
   5917       DWORD dwBuildNumber;
   5918       DWORD dwPlatformId;
   5919       CHAR szCSDVersion[128];
   5920       WORD wServicePackMajor;
   5921       WORD wServicePackMinor;
   5922       WORD wSuiteMask;
   5923       BYTE wProductType;
   5924       BYTE wReserved;
   5925     } OSVERSIONINFOEXA,*POSVERSIONINFOEXA,*LPOSVERSIONINFOEXA;
   5926 
   5927     typedef struct _OSVERSIONINFOEXW {
   5928       DWORD dwOSVersionInfoSize;
   5929       DWORD dwMajorVersion;
   5930       DWORD dwMinorVersion;
   5931       DWORD dwBuildNumber;
   5932       DWORD dwPlatformId;
   5933       WCHAR szCSDVersion[128];
   5934       WORD wServicePackMajor;
   5935       WORD wServicePackMinor;
   5936       WORD wSuiteMask;
   5937       BYTE wProductType;
   5938       BYTE wReserved;
   5939     } OSVERSIONINFOEXW,*POSVERSIONINFOEXW,*LPOSVERSIONINFOEXW,RTL_OSVERSIONINFOEXW,*PRTL_OSVERSIONINFOEXW;
   5940 
   5941     __MINGW_TYPEDEF_AW(OSVERSIONINFOEX)
   5942     __MINGW_TYPEDEF_AW(POSVERSIONINFOEX)
   5943     __MINGW_TYPEDEF_AW(LPOSVERSIONINFOEX)
   5944 
   5945 #define VER_EQUAL 1
   5946 #define VER_GREATER 2
   5947 #define VER_GREATER_EQUAL 3
   5948 #define VER_LESS 4
   5949 #define VER_LESS_EQUAL 5
   5950 #define VER_AND 6
   5951 #define VER_OR 7
   5952 
   5953 #define VER_CONDITION_MASK 7
   5954 #define VER_NUM_BITS_PER_CONDITION_MASK 3
   5955 
   5956 #define VER_MINORVERSION 0x0000001
   5957 #define VER_MAJORVERSION 0x0000002
   5958 #define VER_BUILDNUMBER 0x0000004
   5959 #define VER_PLATFORMID 0x0000008
   5960 #define VER_SERVICEPACKMINOR 0x0000010
   5961 #define VER_SERVICEPACKMAJOR 0x0000020
   5962 #define VER_SUITENAME 0x0000040
   5963 #define VER_PRODUCT_TYPE 0x0000080
   5964 
   5965 #define VER_NT_WORKSTATION 0x0000001
   5966 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
   5967 #define VER_NT_SERVER 0x0000003
   5968 
   5969 #define VER_PLATFORM_WIN32s 0
   5970 #define VER_PLATFORM_WIN32_WINDOWS 1
   5971 #define VER_PLATFORM_WIN32_NT 2
   5972 
   5973 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
   5974 
   5975     NTSYSAPI ULONGLONG NTAPI VerSetConditionMask(ULONGLONG ConditionMask,DWORD TypeMask,BYTE Condition);
   5976 
   5977     typedef struct _RTL_CRITICAL_SECTION_DEBUG {
   5978       WORD Type;
   5979       WORD CreatorBackTraceIndex;
   5980       struct _RTL_CRITICAL_SECTION *CriticalSection;
   5981       LIST_ENTRY ProcessLocksList;
   5982       DWORD EntryCount;
   5983       DWORD ContentionCount;
   5984       DWORD Flags;
   5985       WORD CreatorBackTraceIndexHigh;
   5986       WORD SpareWORD;
   5987     } RTL_CRITICAL_SECTION_DEBUG,*PRTL_CRITICAL_SECTION_DEBUG,RTL_RESOURCE_DEBUG,*PRTL_RESOURCE_DEBUG;
   5988 
   5989 #define RTL_CRITSECT_TYPE 0
   5990 #define RTL_RESOURCE_TYPE 1
   5991 
   5992 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x01000000
   5993 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x02000000
   5994 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x04000000
   5995 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
   5996 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & (~(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO | RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN | RTL_CRITICAL_SECTION_FLAG_STATIC_INIT)))
   5997 
   5998 #define RTL_CRITICAL_SECTION_DEBUG_FLAG_STATIC_INIT 0x00000001
   5999 
   6000     typedef struct _RTL_CRITICAL_SECTION {
   6001       PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
   6002       LONG LockCount;
   6003       LONG RecursionCount;
   6004       HANDLE OwningThread;
   6005       HANDLE LockSemaphore;
   6006       ULONG_PTR SpinCount;
   6007     } RTL_CRITICAL_SECTION,*PRTL_CRITICAL_SECTION;
   6008 
   6009     typedef VOID (NTAPI *RTL_VERIFIER_DLL_LOAD_CALLBACK) (PWSTR DllName,PVOID DllBase,SIZE_T DllSize,PVOID Reserved);
   6010     typedef VOID (NTAPI *RTL_VERIFIER_DLL_UNLOAD_CALLBACK) (PWSTR DllName,PVOID DllBase,SIZE_T DllSize,PVOID Reserved);
   6011     typedef VOID (NTAPI *RTL_VERIFIER_NTDLLHEAPFREE_CALLBACK)(PVOID AllocationBase,SIZE_T AllocationSize);
   6012 
   6013     typedef struct _RTL_VERIFIER_THUNK_DESCRIPTOR {
   6014       PCHAR ThunkName;
   6015       PVOID ThunkOldAddress;
   6016       PVOID ThunkNewAddress;
   6017     } RTL_VERIFIER_THUNK_DESCRIPTOR,*PRTL_VERIFIER_THUNK_DESCRIPTOR;
   6018 
   6019     typedef struct _RTL_VERIFIER_DLL_DESCRIPTOR {
   6020       PWCHAR DllName;
   6021       DWORD DllFlags;
   6022       PVOID DllAddress;
   6023       PRTL_VERIFIER_THUNK_DESCRIPTOR DllThunks;
   6024     } RTL_VERIFIER_DLL_DESCRIPTOR,*PRTL_VERIFIER_DLL_DESCRIPTOR;
   6025 
   6026     typedef struct _RTL_VERIFIER_PROVIDER_DESCRIPTOR {
   6027       DWORD Length;
   6028       PRTL_VERIFIER_DLL_DESCRIPTOR ProviderDlls;
   6029       RTL_VERIFIER_DLL_LOAD_CALLBACK ProviderDllLoadCallback;
   6030       RTL_VERIFIER_DLL_UNLOAD_CALLBACK ProviderDllUnloadCallback;
   6031       PWSTR VerifierImage;
   6032       DWORD VerifierFlags;
   6033       DWORD VerifierDebug;
   6034       PVOID RtlpGetStackTraceAddress;
   6035       PVOID RtlpDebugPageHeapCreate;
   6036       PVOID RtlpDebugPageHeapDestroy;
   6037       RTL_VERIFIER_NTDLLHEAPFREE_CALLBACK ProviderNtdllHeapFreeCallback;
   6038     } RTL_VERIFIER_PROVIDER_DESCRIPTOR,*PRTL_VERIFIER_PROVIDER_DESCRIPTOR;
   6039 
   6040 #define RTL_VRF_FLG_FULL_PAGE_HEAP 0x00000001
   6041 #define RTL_VRF_FLG_RESERVED_DONOTUSE 0x00000002
   6042 #define RTL_VRF_FLG_HANDLE_CHECKS 0x00000004
   6043 #define RTL_VRF_FLG_STACK_CHECKS 0x00000008
   6044 #define RTL_VRF_FLG_APPCOMPAT_CHECKS 0x00000010
   6045 #define RTL_VRF_FLG_TLS_CHECKS 0x00000020
   6046 #define RTL_VRF_FLG_DIRTY_STACKS 0x00000040
   6047 #define RTL_VRF_FLG_RPC_CHECKS 0x00000080
   6048 #define RTL_VRF_FLG_COM_CHECKS 0x00000100
   6049 #define RTL_VRF_FLG_DANGEROUS_APIS 0x00000200
   6050 #define RTL_VRF_FLG_RACE_CHECKS 0x00000400
   6051 #define RTL_VRF_FLG_DEADLOCK_CHECKS 0x00000800
   6052 #define RTL_VRF_FLG_FIRST_CHANCE_EXCEPTION_CHECKS 0x00001000
   6053 #define RTL_VRF_FLG_VIRTUAL_MEM_CHECKS 0x00002000
   6054 #define RTL_VRF_FLG_ENABLE_LOGGING 0x00004000
   6055 #define RTL_VRF_FLG_FAST_FILL_HEAP 0x00008000
   6056 #define RTL_VRF_FLG_VIRTUAL_SPACE_TRACKING 0x00010000
   6057 #define RTL_VRF_FLG_ENABLED_SYSTEM_WIDE 0x00020000
   6058 #define RTL_VRF_FLG_MISCELLANEOUS_CHECKS 0x00020000
   6059 #define RTL_VRF_FLG_LOCK_CHECKS 0x00040000
   6060 
   6061 #define APPLICATION_VERIFIER_INTERNAL_ERROR 0x80000000
   6062 #define APPLICATION_VERIFIER_INTERNAL_WARNING 0x40000000
   6063 #define APPLICATION_VERIFIER_NO_BREAK 0x20000000
   6064 #define APPLICATION_VERIFIER_CONTINUABLE_BREAK 0x10000000
   6065 
   6066 #define APPLICATION_VERIFIER_UNKNOWN_ERROR 0x0001
   6067 #define APPLICATION_VERIFIER_ACCESS_VIOLATION 0x0002
   6068 #define APPLICATION_VERIFIER_UNSYNCHRONIZED_ACCESS 0x0003
   6069 #define APPLICATION_VERIFIER_EXTREME_SIZE_REQUEST 0x0004
   6070 #define APPLICATION_VERIFIER_BAD_HEAP_HANDLE 0x0005
   6071 #define APPLICATION_VERIFIER_SWITCHED_HEAP_HANDLE 0x0006
   6072 #define APPLICATION_VERIFIER_DOUBLE_FREE 0x0007
   6073 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK 0x0008
   6074 #define APPLICATION_VERIFIER_DESTROY_PROCESS_HEAP 0x0009
   6075 #define APPLICATION_VERIFIER_UNEXPECTED_EXCEPTION 0x000A
   6076 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_EXCEPTION_RAISED_FOR_HEADER 0x000B
   6077 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_EXCEPTION_RAISED_FOR_PROBING 0x000C
   6078 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_HEADER 0x000D
   6079 #define APPLICATION_VERIFIER_CORRUPTED_FREED_HEAP_BLOCK 0x000E
   6080 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_SUFFIX 0x000F
   6081 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_START_STAMP 0x0010
   6082 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_END_STAMP 0x0011
   6083 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK_PREFIX 0x0012
   6084 #define APPLICATION_VERIFIER_FIRST_CHANCE_ACCESS_VIOLATION 0x0013
   6085 #define APPLICATION_VERIFIER_CORRUPTED_HEAP_LIST 0x0014
   6086 
   6087 #define APPLICATION_VERIFIER_TERMINATE_THREAD_CALL 0x0100
   6088 #define APPLICATION_VERIFIER_STACK_OVERFLOW 0x0101
   6089 #define APPLICATION_VERIFIER_INVALID_EXIT_PROCESS_CALL 0x0102
   6090 
   6091 #define APPLICATION_VERIFIER_EXIT_THREAD_OWNS_LOCK 0x0200
   6092 #define APPLICATION_VERIFIER_LOCK_IN_UNLOADED_DLL 0x0201
   6093 #define APPLICATION_VERIFIER_LOCK_IN_FREED_HEAP 0x0202
   6094 #define APPLICATION_VERIFIER_LOCK_DOUBLE_INITIALIZE 0x0203
   6095 #define APPLICATION_VERIFIER_LOCK_IN_FREED_MEMORY 0x0204
   6096 #define APPLICATION_VERIFIER_LOCK_CORRUPTED 0x0205
   6097 #define APPLICATION_VERIFIER_LOCK_INVALID_OWNER 0x0206
   6098 #define APPLICATION_VERIFIER_LOCK_INVALID_RECURSION_COUNT 0x0207
   6099 #define APPLICATION_VERIFIER_LOCK_INVALID_LOCK_COUNT 0x0208
   6100 #define APPLICATION_VERIFIER_LOCK_OVER_RELEASED 0x0209
   6101 #define APPLICATION_VERIFIER_LOCK_NOT_INITIALIZED 0x0210
   6102 #define APPLICATION_VERIFIER_LOCK_ALREADY_INITIALIZED 0x0211
   6103 #define APPLICATION_VERIFIER_LOCK_IN_FREED_VMEM 0x0212
   6104 #define APPLICATION_VERIFIER_LOCK_IN_UNMAPPED_MEM 0x0213
   6105 #define APPLICATION_VERIFIER_THREAD_NOT_LOCK_OWNER 0x0214
   6106 
   6107 #define APPLICATION_VERIFIER_INVALID_HANDLE 0x0300
   6108 #define APPLICATION_VERIFIER_INVALID_TLS_VALUE 0x0301
   6109 #define APPLICATION_VERIFIER_INCORRECT_WAIT_CALL 0x0302
   6110 #define APPLICATION_VERIFIER_NULL_HANDLE 0x0303
   6111 #define APPLICATION_VERIFIER_WAIT_IN_DLLMAIN 0x0304
   6112 
   6113 #define APPLICATION_VERIFIER_COM_ERROR 0x0400
   6114 #define APPLICATION_VERIFIER_COM_API_IN_DLLMAIN 0x0401
   6115 #define APPLICATION_VERIFIER_COM_UNHANDLED_EXCEPTION 0x0402
   6116 #define APPLICATION_VERIFIER_COM_UNBALANCED_COINIT 0x0403
   6117 #define APPLICATION_VERIFIER_COM_UNBALANCED_OLEINIT 0x0404
   6118 #define APPLICATION_VERIFIER_COM_UNBALANCED_SWC 0x0405
   6119 #define APPLICATION_VERIFIER_COM_NULL_DACL 0x0406
   6120 #define APPLICATION_VERIFIER_COM_UNSAFE_IMPERSONATION 0x0407
   6121 #define APPLICATION_VERIFIER_COM_SMUGGLED_WRAPPER 0x0408
   6122 #define APPLICATION_VERIFIER_COM_SMUGGLED_PROXY 0x0409
   6123 #define APPLICATION_VERIFIER_COM_CF_SUCCESS_WITH_NULL 0x040A
   6124 #define APPLICATION_VERIFIER_COM_GCO_SUCCESS_WITH_NULL 0x040B
   6125 #define APPLICATION_VERIFIER_COM_OBJECT_IN_FREED_MEMORY 0x040C
   6126 #define APPLICATION_VERIFIER_COM_OBJECT_IN_UNLOADED_DLL 0x040D
   6127 #define APPLICATION_VERIFIER_COM_VTBL_IN_FREED_MEMORY 0x040E
   6128 #define APPLICATION_VERIFIER_COM_VTBL_IN_UNLOADED_DLL 0x040F
   6129 #define APPLICATION_VERIFIER_COM_HOLDING_LOCKS_ON_CALL 0x0410
   6130 
   6131 #define APPLICATION_VERIFIER_RPC_ERROR 0x0500
   6132 
   6133 #define APPLICATION_VERIFIER_INVALID_FREEMEM 0x0600
   6134 #define APPLICATION_VERIFIER_INVALID_ALLOCMEM 0x0601
   6135 #define APPLICATION_VERIFIER_INVALID_MAPVIEW 0x0602
   6136 #define APPLICATION_VERIFIER_PROBE_INVALID_ADDRESS 0x0603
   6137 #define APPLICATION_VERIFIER_PROBE_FREE_MEM 0x0604
   6138 #define APPLICATION_VERIFIER_PROBE_GUARD_PAGE 0x0605
   6139 #define APPLICATION_VERIFIER_PROBE_NULL 0x0606
   6140 #define APPLICATION_VERIFIER_PROBE_INVALID_START_OR_SIZE 0x0607
   6141 #define APPLICATION_VERIFIER_SIZE_HEAP_UNEXPECTED_EXCEPTION 0x0618
   6142 
   6143 #define VERIFIER_STOP(Code,Msg,P1,S1,P2,S2,P3,S3,P4,S4) { RtlApplicationVerifierStop ((Code),(Msg),(ULONG_PTR)(P1),(S1),(ULONG_PTR)(P2),(S2),(ULONG_PTR)(P3),(S3),(ULONG_PTR)(P4),(S4)); }
   6144 
   6145     VOID NTAPI RtlApplicationVerifierStop(ULONG_PTR Code,PSTR Message,ULONG_PTR Param1,PSTR Description1,ULONG_PTR Param2,PSTR Description2,ULONG_PTR Param3,PSTR Description3,ULONG_PTR Param4,PSTR Description4);
   6146 
   6147     typedef LONG (NTAPI *PVECTORED_EXCEPTION_HANDLER)(struct _EXCEPTION_POINTERS *ExceptionInfo);
   6148 #define SEF_DACL_AUTO_INHERIT 0x01
   6149 #define SEF_SACL_AUTO_INHERIT 0x02
   6150 #define SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT 0x04
   6151 #define SEF_AVOID_PRIVILEGE_CHECK 0x08
   6152 #define SEF_AVOID_OWNER_CHECK 0x10
   6153 #define SEF_DEFAULT_OWNER_FROM_PARENT 0x20
   6154 #define SEF_DEFAULT_GROUP_FROM_PARENT 0x40
   6155 
   6156     typedef enum _HEAP_INFORMATION_CLASS {
   6157       HeapCompatibilityInformation,
   6158       HeapEnableTerminationOnCorruption
   6159     } HEAP_INFORMATION_CLASS;
   6160 
   6161     NTSYSAPI DWORD NTAPI RtlSetHeapInformation(PVOID HeapHandle,HEAP_INFORMATION_CLASS HeapInformationClass,PVOID HeapInformation,SIZE_T HeapInformationLength);
   6162     NTSYSAPI DWORD NTAPI RtlQueryHeapInformation(PVOID HeapHandle,HEAP_INFORMATION_CLASS HeapInformationClass,PVOID HeapInformation,SIZE_T HeapInformationLength,PSIZE_T ReturnLength);
   6163     DWORD NTAPI RtlMultipleAllocateHeap(PVOID HeapHandle,DWORD Flags,SIZE_T Size,DWORD Count,PVOID *Array);
   6164     DWORD NTAPI RtlMultipleFreeHeap(PVOID HeapHandle,DWORD Flags,DWORD Count,PVOID *Array);
   6165 
   6166 #define WT_EXECUTEDEFAULT 0x00000000
   6167 #define WT_EXECUTEINIOTHREAD 0x00000001
   6168 #define WT_EXECUTEINUITHREAD 0x00000002
   6169 #define WT_EXECUTEINWAITTHREAD 0x00000004
   6170 #define WT_EXECUTEONLYONCE 0x00000008
   6171 #define WT_EXECUTEINTIMERTHREAD 0x00000020
   6172 #define WT_EXECUTELONGFUNCTION 0x00000010
   6173 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040
   6174 #define WT_EXECUTEINPERSISTENTTHREAD 0x00000080
   6175 #define WT_TRANSFER_IMPERSONATION 0x00000100
   6176 #define WT_SET_MAX_THREADPOOL_THREADS(Flags,Limit) ((Flags) |= (Limit)<<16)
   6177     typedef VOID (NTAPI *WAITORTIMERCALLBACKFUNC)(PVOID,BOOLEAN);
   6178     typedef VOID (NTAPI *WORKERCALLBACKFUNC)(PVOID);
   6179     typedef VOID (NTAPI *APC_CALLBACK_FUNCTION)(DWORD ,PVOID,PVOID);
   6180     typedef
   6181       VOID
   6182       (NTAPI *PFLS_CALLBACK_FUNCTION)(PVOID lpFlsData);
   6183 #define WT_EXECUTEINLONGTHREAD 0x00000010
   6184 #define WT_EXECUTEDELETEWAIT 0x00000008
   6185 
   6186     typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
   6187       ActivationContextBasicInformation = 1,ActivationContextDetailedInformation = 2,AssemblyDetailedInformationInActivationContext = 3,FileInformationInAssemblyOfAssemblyInActivationContext = 4,MaxActivationContextInfoClass,AssemblyDetailedInformationInActivationContxt = 3,FileInformationInAssemblyOfAssemblyInActivationContxt = 4
   6188     } ACTIVATION_CONTEXT_INFO_CLASS;
   6189 
   6190 #define ACTIVATIONCONTEXTINFOCLASS ACTIVATION_CONTEXT_INFO_CLASS
   6191 
   6192     typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
   6193       DWORD ulAssemblyIndex;
   6194       DWORD ulFileIndexInAssembly;
   6195     } ACTIVATION_CONTEXT_QUERY_INDEX,*PACTIVATION_CONTEXT_QUERY_INDEX;
   6196 
   6197     typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
   6198 
   6199 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE (1)
   6200 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE (2)
   6201 #define ACTIVATION_CONTEXT_PATH_TYPE_URL (3)
   6202 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF (4)
   6203 
   6204     typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
   6205       DWORD ulFlags;
   6206       DWORD ulFilenameLength;
   6207       DWORD ulPathLength;
   6208 
   6209       PCWSTR lpFileName;
   6210       PCWSTR lpFilePath;
   6211     } ASSEMBLY_FILE_DETAILED_INFORMATION,*PASSEMBLY_FILE_DETAILED_INFORMATION;
   6212     typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
   6213 
   6214 #define _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION _ASSEMBLY_FILE_DETAILED_INFORMATION
   6215 #define ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION ASSEMBLY_FILE_DETAILED_INFORMATION
   6216 #define PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PASSEMBLY_FILE_DETAILED_INFORMATION
   6217 #define PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION PCASSEMBLY_FILE_DETAILED_INFORMATION
   6218 
   6219     typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
   6220       DWORD ulFlags;
   6221       DWORD ulEncodedAssemblyIdentityLength;
   6222       DWORD ulManifestPathType;
   6223       DWORD ulManifestPathLength;
   6224       LARGE_INTEGER liManifestLastWriteTime;
   6225       DWORD ulPolicyPathType;
   6226       DWORD ulPolicyPathLength;
   6227       LARGE_INTEGER liPolicyLastWriteTime;
   6228       DWORD ulMetadataSatelliteRosterIndex;
   6229       DWORD ulManifestVersionMajor;
   6230       DWORD ulManifestVersionMinor;
   6231       DWORD ulPolicyVersionMajor;
   6232       DWORD ulPolicyVersionMinor;
   6233       DWORD ulAssemblyDirectoryNameLength;
   6234       PCWSTR lpAssemblyEncodedAssemblyIdentity;
   6235       PCWSTR lpAssemblyManifestPath;
   6236       PCWSTR lpAssemblyPolicyPath;
   6237       PCWSTR lpAssemblyDirectoryName;
   6238       DWORD ulFileCount;
   6239     } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION,*PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
   6240 
   6241     typedef const struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
   6242 
   6243     typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
   6244       DWORD dwFlags;
   6245       DWORD ulFormatVersion;
   6246       DWORD ulAssemblyCount;
   6247       DWORD ulRootManifestPathType;
   6248       DWORD ulRootManifestPathChars;
   6249       DWORD ulRootConfigurationPathType;
   6250       DWORD ulRootConfigurationPathChars;
   6251       DWORD ulAppDirPathType;
   6252       DWORD ulAppDirPathChars;
   6253       PCWSTR lpRootManifestPath;
   6254       PCWSTR lpRootConfigurationPath;
   6255       PCWSTR lpAppDirPath;
   6256     } ACTIVATION_CONTEXT_DETAILED_INFORMATION,*PACTIVATION_CONTEXT_DETAILED_INFORMATION;
   6257 
   6258     typedef const struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_DETAILED_INFORMATION;
   6259 
   6260 #define DLL_PROCESS_ATTACH 1
   6261 #define DLL_THREAD_ATTACH 2
   6262 #define DLL_THREAD_DETACH 3
   6263 #define DLL_PROCESS_DETACH 0
   6264 #define DLL_PROCESS_VERIFIER 4
   6265 
   6266 #define EVENTLOG_SEQUENTIAL_READ 0x0001
   6267 #define EVENTLOG_SEEK_READ 0x0002
   6268 #define EVENTLOG_FORWARDS_READ 0x0004
   6269 #define EVENTLOG_BACKWARDS_READ 0x0008
   6270 
   6271 #define EVENTLOG_SUCCESS 0x0000
   6272 #define EVENTLOG_ERROR_TYPE 0x0001
   6273 #define EVENTLOG_WARNING_TYPE 0x0002
   6274 #define EVENTLOG_INFORMATION_TYPE 0x0004
   6275 #define EVENTLOG_AUDIT_SUCCESS 0x0008
   6276 #define EVENTLOG_AUDIT_FAILURE 0x0010
   6277 
   6278 #define EVENTLOG_START_PAIRED_EVENT 0x0001
   6279 #define EVENTLOG_END_PAIRED_EVENT 0x0002
   6280 #define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004
   6281 #define EVENTLOG_PAIRED_EVENT_ACTIVE 0x0008
   6282 #define EVENTLOG_PAIRED_EVENT_INACTIVE 0x0010
   6283 
   6284     typedef struct _EVENTLOGRECORD {
   6285       DWORD Length;
   6286       DWORD Reserved;
   6287       DWORD RecordNumber;
   6288       DWORD TimeGenerated;
   6289       DWORD TimeWritten;
   6290       DWORD EventID;
   6291       WORD EventType;
   6292       WORD NumStrings;
   6293       WORD EventCategory;
   6294       WORD ReservedFlags;
   6295       DWORD ClosingRecordNumber;
   6296       DWORD StringOffset;
   6297       DWORD UserSidLength;
   6298       DWORD UserSidOffset;
   6299       DWORD DataLength;
   6300       DWORD DataOffset;
   6301     } EVENTLOGRECORD,*PEVENTLOGRECORD;
   6302 
   6303 #define MAXLOGICALLOGNAMESIZE 256
   6304 
   6305     typedef struct _EVENTSFORLOGFILE{
   6306       DWORD ulSize;
   6307       WCHAR szLogicalLogFile[MAXLOGICALLOGNAMESIZE];
   6308       DWORD ulNumRecords;
   6309       EVENTLOGRECORD pEventLogRecords[];
   6310     } EVENTSFORLOGFILE,*PEVENTSFORLOGFILE;
   6311 
   6312     typedef struct _PACKEDEVENTINFO{
   6313       DWORD ulSize;
   6314       DWORD ulNumEventsForLogFile;
   6315       DWORD ulOffsets[];
   6316     } PACKEDEVENTINFO,*PPACKEDEVENTINFO;
   6317 
   6318 #define KEY_QUERY_VALUE (0x0001)
   6319 #define KEY_SET_VALUE (0x0002)
   6320 #define KEY_CREATE_SUB_KEY (0x0004)
   6321 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
   6322 #define KEY_NOTIFY (0x0010)
   6323 #define KEY_CREATE_LINK (0x0020)
   6324 #define KEY_WOW64_32KEY (0x0200)
   6325 #define KEY_WOW64_64KEY (0x0100)
   6326 #define KEY_WOW64_RES (0x0300)
   6327 
   6328 #define KEY_READ ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE))
   6329 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE))
   6330 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
   6331 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & (~SYNCHRONIZE))
   6332 #define REG_OPTION_RESERVED (__MSABI_LONG(0x00000000))
   6333 
   6334 #define REG_OPTION_NON_VOLATILE (__MSABI_LONG(0x00000000))
   6335 #define REG_OPTION_VOLATILE (__MSABI_LONG(0x00000001))
   6336 #define REG_OPTION_CREATE_LINK (__MSABI_LONG(0x00000002))
   6337 #define REG_OPTION_BACKUP_RESTORE (__MSABI_LONG(0x00000004))
   6338 #define REG_OPTION_OPEN_LINK (__MSABI_LONG(0x00000008))
   6339 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK)
   6340 #define REG_CREATED_NEW_KEY (__MSABI_LONG(0x00000001))
   6341 #define REG_OPENED_EXISTING_KEY (__MSABI_LONG(0x00000002))
   6342 #define REG_STANDARD_FORMAT 1
   6343 #define REG_LATEST_FORMAT 2
   6344 #define REG_NO_COMPRESSION 4
   6345 #define REG_WHOLE_HIVE_VOLATILE (__MSABI_LONG(0x00000001))
   6346 #define REG_REFRESH_HIVE (__MSABI_LONG(0x00000002))
   6347 #define REG_NO_LAZY_FLUSH (__MSABI_LONG(0x00000004))
   6348 #define REG_FORCE_RESTORE (__MSABI_LONG(0x00000008))
   6349 #define REG_FORCE_UNLOAD 1
   6350 
   6351 #define REG_NOTIFY_CHANGE_NAME (__MSABI_LONG(0x00000001))
   6352 #define REG_NOTIFY_CHANGE_ATTRIBUTES (__MSABI_LONG(0x00000002))
   6353 #define REG_NOTIFY_CHANGE_LAST_SET (__MSABI_LONG(0x00000004))
   6354 #define REG_NOTIFY_CHANGE_SECURITY (__MSABI_LONG(0x00000008))
   6355 
   6356 #define REG_LEGAL_CHANGE_FILTER (REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY)
   6357 
   6358 #define REG_NONE (0)
   6359 #define REG_SZ (1)
   6360 #define REG_EXPAND_SZ (2)
   6361 
   6362 #define REG_BINARY (3)
   6363 #define REG_DWORD (4)
   6364 #define REG_DWORD_LITTLE_ENDIAN (4)
   6365 #define REG_DWORD_BIG_ENDIAN (5)
   6366 #define REG_LINK (6)
   6367 #define REG_MULTI_SZ (7)
   6368 #define REG_RESOURCE_LIST (8)
   6369 #define REG_FULL_RESOURCE_DESCRIPTOR (9)
   6370 #define REG_RESOURCE_REQUIREMENTS_LIST (10)
   6371 #define REG_QWORD (11)
   6372 #define REG_QWORD_LITTLE_ENDIAN (11)
   6373 
   6374 #define SERVICE_KERNEL_DRIVER 0x00000001
   6375 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
   6376 #define SERVICE_ADAPTER 0x00000004
   6377 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
   6378 
   6379 #define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER)
   6380 
   6381 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
   6382 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
   6383 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
   6384 
   6385 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
   6386 
   6387 #define SERVICE_TYPE_ALL (SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS)
   6388 
   6389 #define SERVICE_BOOT_START 0x00000000
   6390 #define SERVICE_SYSTEM_START 0x00000001
   6391 #define SERVICE_AUTO_START 0x00000002
   6392 #define SERVICE_DEMAND_START 0x00000003
   6393 #define SERVICE_DISABLED 0x00000004
   6394 
   6395 #define SERVICE_ERROR_IGNORE 0x00000000
   6396 #define SERVICE_ERROR_NORMAL 0x00000001
   6397 #define SERVICE_ERROR_SEVERE 0x00000002
   6398 #define SERVICE_ERROR_CRITICAL 0x00000003
   6399 
   6400     typedef enum _CM_SERVICE_NODE_TYPE {
   6401       DriverType = SERVICE_KERNEL_DRIVER,FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
   6402       Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,AdapterType = SERVICE_ADAPTER,RecognizerType = SERVICE_RECOGNIZER_DRIVER
   6403     } SERVICE_NODE_TYPE;
   6404 
   6405     typedef enum _CM_SERVICE_LOAD_TYPE {
   6406       BootLoad = SERVICE_BOOT_START,SystemLoad = SERVICE_SYSTEM_START,AutoLoad = SERVICE_AUTO_START,DemandLoad = SERVICE_DEMAND_START,
   6407       DisableLoad = SERVICE_DISABLED
   6408     } SERVICE_LOAD_TYPE;
   6409 
   6410     typedef enum _CM_ERROR_CONTROL_TYPE {
   6411       IgnoreError = SERVICE_ERROR_IGNORE,NormalError = SERVICE_ERROR_NORMAL,SevereError = SERVICE_ERROR_SEVERE,CriticalError = SERVICE_ERROR_CRITICAL
   6412     } SERVICE_ERROR_TYPE;
   6413 
   6414 #define TAPE_ERASE_SHORT __MSABI_LONG(0)
   6415 #define TAPE_ERASE_LONG __MSABI_LONG(1)
   6416 
   6417     typedef struct _TAPE_ERASE {
   6418       DWORD Type;
   6419       BOOLEAN Immediate;
   6420     } TAPE_ERASE,*PTAPE_ERASE;
   6421 
   6422 #define TAPE_LOAD __MSABI_LONG(0)
   6423 #define TAPE_UNLOAD __MSABI_LONG(1)
   6424 #define TAPE_TENSION __MSABI_LONG(2)
   6425 #define TAPE_LOCK __MSABI_LONG(3)
   6426 #define TAPE_UNLOCK __MSABI_LONG(4)
   6427 #define TAPE_FORMAT __MSABI_LONG(5)
   6428 
   6429     typedef struct _TAPE_PREPARE {
   6430       DWORD Operation;
   6431       BOOLEAN Immediate;
   6432     } TAPE_PREPARE,*PTAPE_PREPARE;
   6433 
   6434 #define TAPE_SETMARKS __MSABI_LONG(0)
   6435 #define TAPE_FILEMARKS __MSABI_LONG(1)
   6436 #define TAPE_SHORT_FILEMARKS __MSABI_LONG(2)
   6437 #define TAPE_LONG_FILEMARKS __MSABI_LONG(3)
   6438 
   6439     typedef struct _TAPE_WRITE_MARKS {
   6440       DWORD Type;
   6441       DWORD Count;
   6442       BOOLEAN Immediate;
   6443     } TAPE_WRITE_MARKS,*PTAPE_WRITE_MARKS;
   6444 
   6445 #define TAPE_ABSOLUTE_POSITION __MSABI_LONG(0)
   6446 #define TAPE_LOGICAL_POSITION __MSABI_LONG(1)
   6447 #define TAPE_PSEUDO_LOGICAL_POSITION __MSABI_LONG(2)
   6448 
   6449     typedef struct _TAPE_GET_POSITION {
   6450       DWORD Type;
   6451       DWORD Partition;
   6452       LARGE_INTEGER Offset;
   6453     } TAPE_GET_POSITION,*PTAPE_GET_POSITION;
   6454 
   6455 #define TAPE_REWIND __MSABI_LONG(0)
   6456 #define TAPE_ABSOLUTE_BLOCK __MSABI_LONG(1)
   6457 #define TAPE_LOGICAL_BLOCK __MSABI_LONG(2)
   6458 #define TAPE_PSEUDO_LOGICAL_BLOCK __MSABI_LONG(3)
   6459 #define TAPE_SPACE_END_OF_DATA __MSABI_LONG(4)
   6460 #define TAPE_SPACE_RELATIVE_BLOCKS __MSABI_LONG(5)
   6461 #define TAPE_SPACE_FILEMARKS __MSABI_LONG(6)
   6462 #define TAPE_SPACE_SEQUENTIAL_FMKS __MSABI_LONG(7)
   6463 #define TAPE_SPACE_SETMARKS __MSABI_LONG(8)
   6464 #define TAPE_SPACE_SEQUENTIAL_SMKS __MSABI_LONG(9)
   6465 
   6466     typedef struct _TAPE_SET_POSITION {
   6467       DWORD Method;
   6468       DWORD Partition;
   6469       LARGE_INTEGER Offset;
   6470       BOOLEAN Immediate;
   6471     } TAPE_SET_POSITION,*PTAPE_SET_POSITION;
   6472 
   6473 #define TAPE_DRIVE_FIXED 0x00000001
   6474 #define TAPE_DRIVE_SELECT 0x00000002
   6475 #define TAPE_DRIVE_INITIATOR 0x00000004
   6476 
   6477 #define TAPE_DRIVE_ERASE_SHORT 0x00000010
   6478 #define TAPE_DRIVE_ERASE_LONG 0x00000020
   6479 #define TAPE_DRIVE_ERASE_BOP_ONLY 0x00000040
   6480 #define TAPE_DRIVE_ERASE_IMMEDIATE 0x00000080
   6481 
   6482 #define TAPE_DRIVE_TAPE_CAPACITY 0x00000100
   6483 #define TAPE_DRIVE_TAPE_REMAINING 0x00000200
   6484 #define TAPE_DRIVE_FIXED_BLOCK 0x00000400
   6485 #define TAPE_DRIVE_VARIABLE_BLOCK 0x00000800
   6486 
   6487 #define TAPE_DRIVE_WRITE_PROTECT 0x00001000
   6488 #define TAPE_DRIVE_EOT_WZ_SIZE 0x00002000
   6489 
   6490 #define TAPE_DRIVE_ECC 0x00010000
   6491 #define TAPE_DRIVE_COMPRESSION 0x00020000
   6492 #define TAPE_DRIVE_PADDING 0x00040000
   6493 #define TAPE_DRIVE_REPORT_SMKS 0x00080000
   6494 
   6495 #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000
   6496 #define TAPE_DRIVE_GET_LOGICAL_BLK 0x00200000
   6497 #define TAPE_DRIVE_SET_EOT_WZ_SIZE 0x00400000
   6498 
   6499 #define TAPE_DRIVE_EJECT_MEDIA 0x01000000
   6500 #define TAPE_DRIVE_CLEAN_REQUESTS 0x02000000
   6501 #define TAPE_DRIVE_SET_CMP_BOP_ONLY 0x04000000
   6502 
   6503 #define TAPE_DRIVE_RESERVED_BIT 0x80000000
   6504 
   6505 #define TAPE_DRIVE_LOAD_UNLOAD 0x80000001
   6506 #define TAPE_DRIVE_TENSION 0x80000002
   6507 #define TAPE_DRIVE_LOCK_UNLOCK 0x80000004
   6508 #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
   6509 
   6510 #define TAPE_DRIVE_SET_BLOCK_SIZE 0x80000010
   6511 #define TAPE_DRIVE_LOAD_UNLD_IMMED 0x80000020
   6512 #define TAPE_DRIVE_TENSION_IMMED 0x80000040
   6513 #define TAPE_DRIVE_LOCK_UNLK_IMMED 0x80000080
   6514 
   6515 #define TAPE_DRIVE_SET_ECC 0x80000100
   6516 #define TAPE_DRIVE_SET_COMPRESSION 0x80000200
   6517 #define TAPE_DRIVE_SET_PADDING 0x80000400
   6518 #define TAPE_DRIVE_SET_REPORT_SMKS 0x80000800
   6519 
   6520 #define TAPE_DRIVE_ABSOLUTE_BLK 0x80001000
   6521 #define TAPE_DRIVE_ABS_BLK_IMMED 0x80002000
   6522 #define TAPE_DRIVE_LOGICAL_BLK 0x80004000
   6523 #define TAPE_DRIVE_LOG_BLK_IMMED 0x80008000
   6524 
   6525 #define TAPE_DRIVE_END_OF_DATA 0x80010000
   6526 #define TAPE_DRIVE_RELATIVE_BLKS 0x80020000
   6527 #define TAPE_DRIVE_FILEMARKS 0x80040000
   6528 #define TAPE_DRIVE_SEQUENTIAL_FMKS 0x80080000
   6529 
   6530 #define TAPE_DRIVE_SETMARKS 0x80100000
   6531 #define TAPE_DRIVE_SEQUENTIAL_SMKS 0x80200000
   6532 #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
   6533 #define TAPE_DRIVE_SPACE_IMMEDIATE 0x80800000
   6534 
   6535 #define TAPE_DRIVE_WRITE_SETMARKS 0x81000000
   6536 #define TAPE_DRIVE_WRITE_FILEMARKS 0x82000000
   6537 #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
   6538 #define TAPE_DRIVE_WRITE_LONG_FMKS 0x88000000
   6539 
   6540 #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
   6541 #define TAPE_DRIVE_FORMAT 0xA0000000
   6542 #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
   6543 #define TAPE_DRIVE_HIGH_FEATURES 0x80000000
   6544 
   6545     typedef struct _TAPE_GET_DRIVE_PARAMETERS {
   6546       BOOLEAN ECC;
   6547       BOOLEAN Compression;
   6548       BOOLEAN DataPadding;
   6549       BOOLEAN ReportSetmarks;
   6550       DWORD DefaultBlockSize;
   6551       DWORD MaximumBlockSize;
   6552       DWORD MinimumBlockSize;
   6553       DWORD MaximumPartitionCount;
   6554       DWORD FeaturesLow;
   6555       DWORD FeaturesHigh;
   6556       DWORD EOTWarningZoneSize;
   6557     } TAPE_GET_DRIVE_PARAMETERS,*PTAPE_GET_DRIVE_PARAMETERS;
   6558 
   6559     typedef struct _TAPE_SET_DRIVE_PARAMETERS {
   6560       BOOLEAN ECC;
   6561       BOOLEAN Compression;
   6562       BOOLEAN DataPadding;
   6563       BOOLEAN ReportSetmarks;
   6564       DWORD EOTWarningZoneSize;
   6565     } TAPE_SET_DRIVE_PARAMETERS,*PTAPE_SET_DRIVE_PARAMETERS;
   6566 
   6567     typedef struct _TAPE_GET_MEDIA_PARAMETERS {
   6568       LARGE_INTEGER Capacity;
   6569       LARGE_INTEGER Remaining;
   6570       DWORD BlockSize;
   6571       DWORD PartitionCount;
   6572       BOOLEAN WriteProtected;
   6573     } TAPE_GET_MEDIA_PARAMETERS,*PTAPE_GET_MEDIA_PARAMETERS;
   6574 
   6575     typedef struct _TAPE_SET_MEDIA_PARAMETERS {
   6576       DWORD BlockSize;
   6577     } TAPE_SET_MEDIA_PARAMETERS,*PTAPE_SET_MEDIA_PARAMETERS;
   6578 
   6579 #define TAPE_FIXED_PARTITIONS __MSABI_LONG(0)
   6580 #define TAPE_SELECT_PARTITIONS __MSABI_LONG(1)
   6581 #define TAPE_INITIATOR_PARTITIONS __MSABI_LONG(2)
   6582 
   6583     typedef struct _TAPE_CREATE_PARTITION {
   6584       DWORD Method;
   6585       DWORD Count;
   6586       DWORD Size;
   6587     } TAPE_CREATE_PARTITION,*PTAPE_CREATE_PARTITION;
   6588 
   6589 #define TAPE_QUERY_DRIVE_PARAMETERS __MSABI_LONG(0)
   6590 #define TAPE_QUERY_MEDIA_CAPACITY __MSABI_LONG(1)
   6591 #define TAPE_CHECK_FOR_DRIVE_PROBLEM __MSABI_LONG(2)
   6592 #define TAPE_QUERY_IO_ERROR_DATA __MSABI_LONG(3)
   6593 #define TAPE_QUERY_DEVICE_ERROR_DATA __MSABI_LONG(4)
   6594 
   6595     typedef struct _TAPE_WMI_OPERATIONS {
   6596       DWORD Method;
   6597       DWORD DataBufferSize;
   6598       PVOID DataBuffer;
   6599     } TAPE_WMI_OPERATIONS,*PTAPE_WMI_OPERATIONS;
   6600 
   6601     typedef enum _TAPE_DRIVE_PROBLEM_TYPE {
   6602       TapeDriveProblemNone,TapeDriveReadWriteWarning,TapeDriveReadWriteError,TapeDriveReadWarning,TapeDriveWriteWarning,TapeDriveReadError,TapeDriveWriteError,TapeDriveHardwareError,TapeDriveUnsupportedMedia,TapeDriveScsiConnectionError,TapeDriveTimetoClean,TapeDriveCleanDriveNow,TapeDriveMediaLifeExpired,TapeDriveSnappedTape
   6603     } TAPE_DRIVE_PROBLEM_TYPE;
   6604 
   6605 #if defined(__x86_64)
   6606     struct _TEB *NtCurrentTeb(VOID);
   6607     PVOID GetCurrentFiber(VOID);
   6608     PVOID GetFiberData(VOID);
   6609     __CRT_INLINE struct _TEB *NtCurrentTeb(VOID) { return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB,Self)); }
   6610     __CRT_INLINE PVOID GetCurrentFiber(VOID) { return(PVOID)__readgsqword(FIELD_OFFSET(NT_TIB,FiberData)); }
   6611     __CRT_INLINE PVOID GetFiberData(VOID) {
   6612       return *(PVOID *)GetCurrentFiber();
   6613     }
   6614 #endif /* __x86_64 */
   6615 
   6616 #if (_WIN32_WINNT >= 0x0600)
   6617 /* FIXME: Opaque structs !!! */
   6618 /* FIXME: Also see winbase.h */
   6619 typedef PVOID RTL_CONDITION_VARIABLE;
   6620 typedef PVOID RTL_SRWLOCK;
   6621 
   6622 #ifndef _RTL_RUN_ONCE_DEF
   6623 #define _RTL_RUN_ONCE_DEF 1
   6624 typedef PVOID RTL_RUN_ONCE, *PRTL_RUN_ONCE;
   6625 typedef DWORD (WINAPI *PRTL_RUN_ONCE_INIT_FN)(PRTL_RUN_ONCE, PVOID, PVOID *);
   6626 #define RTL_RUN_ONCE_INIT 0
   6627 #define RTL_RUN_ONCE_CHECK_ONLY __MSABI_LONG(1U)
   6628 #define RTL_RUN_ONCE_ASYNC __MSABI_LONG(2U)
   6629 #define RTL_RUN_ONCE_INIT_FAILED __MSABI_LONG(4U)
   6630 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
   6631 #endif /* _RTL_RUN_ONCE_DEF */
   6632 #define RTL_SRWLOCK_INIT 0
   6633 #define RTL_CONDITION_VARIABLE_INIT 0
   6634 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 1
   6635 
   6636 #define CONDITION_VARIABLE_INIT RTL_CONDITION_VARIABLE_INIT
   6637 #define CONDITION_VARIABLE_LOCKMODE_SHARED RTL_CONDITION_VARIABLE_LOCKMODE_SHARED
   6638 #define SRWLOCK_INIT RTL_SRWLOCK_INIT
   6639 
   6640 
   6641 #include <ktmtypes.h>
   6642 
   6643 #define TRANSACTIONMANAGER_QUERY_INFORMATION 0x00001
   6644 #define TRANSACTIONMANAGER_SET_INFORMATION 0x00002
   6645 #define TRANSACTIONMANAGER_RECOVER 0x00004
   6646 #define TRANSACTIONMANAGER_RENAME 0x00008
   6647 #define TRANSACTIONMANAGER_CREATE_RM 0x00010
   6648 #define TRANSACTIONMANAGER_BIND_TRANSACTION 0x00020
   6649 #define TRANSACTIONMANAGER_GENERIC_READ 0x20001
   6650 #define TRANSACTIONMANAGER_GENERIC_WRITE 0x2001E
   6651 #define TRANSACTIONMANAGER_GENERIC_EXECUTE 0x20000
   6652 #define TRANSACTIONMANAGER_ALL_ACCESS 0xF003F
   6653 
   6654   typedef enum _TRANSACTION_OUTCOME {
   6655     TransactionOutcomeUndetermined  = 1,
   6656     TransactionOutcomeCommitted     = 2,
   6657     TransactionOutcomeAborted       = 3
   6658   } TRANSACTION_OUTCOME;
   6659 
   6660   typedef enum _TRANSACTION_STATE {
   6661     TransactionStateNormal          = 1,
   6662     TransactionStateIndoubt         = 2,
   6663     TransactionStateCommittedNotify = 3
   6664   } TRANSACTION_STATE;
   6665 
   6666   typedef struct _TRANSACTION_BASIC_INFORMATION {
   6667     GUID  TransactionId;
   6668     ULONG State;
   6669     ULONG Outcome;
   6670   } TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION;
   6671 
   6672 #define ENLISTMENT_QUERY_INFORMATION 0x00001
   6673 #define ENLISTMENT_SET_INFORMATION 0x00002
   6674 #define ENLISTMENT_RECOVER 0x00004
   6675 #define ENLISTMENT_SUBORDINATE_RIGHTS 0x00008
   6676 #define ENLISTMENT_SUPERIOR_RIGHTS 0x00010
   6677 #define ENLISTMENT_GENERIC_READ 0x20001
   6678 #define ENLISTMENT_GENERIC_WRITE 0x2001E
   6679 #define ENLISTMENT_GENERIC_EXECUTE 0x2001C
   6680 #define ENLISTMENT_ALL_ACCESS 0xF001F
   6681 
   6682 
   6683   typedef enum ACTCTX_REQUESTED_RUN_LEVEL {
   6684     ACTCTX_RUN_LEVEL_UNSPECIFIED         = 0,
   6685     ACTCTX_RUN_LEVEL_AS_INVOKER,
   6686     ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
   6687     ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
   6688     ACTCTX_RUN_LEVEL_NUMBERS
   6689   } ACTCTX_REQUESTED_RUN_LEVEL, ACTCTX_REQUESTED_RUN_LEVEL_INFORMATION;
   6690 
   6691   typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
   6692     ULONG ulFlags;
   6693     ACTCTX_REQUESTED_RUN_LEVEL_INFORMATION RunLevel;
   6694     ULONG UiAccess;
   6695   } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
   6696 
   6697   typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(
   6698     PVOID ObjectContext,
   6699     PVOID CleanupContext
   6700   );
   6701 
   6702 DEFINE_GUID(NO_SUBGROUP_GUID,0xfea3413e,0x7e05,0x4911,0x9a,0x71,0x70,0x03,0x31,0xf1,0xc2,0x94);
   6703 DEFINE_GUID(GUID_DISK_SUBGROUP,0x0012ee47,0x9041,0x4b5d,0x9b,0x77,0x53,0x5f,0xba,0x8b,0x14,0x42);
   6704 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP,0x4f971e89,0xeebd,0x4455,0xa8,0xde,0x9e,0x59,0x04,0x0e,0x73,0x47);
   6705 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP,0x54533251,0x82be,0x4824,0x96,0xc1,0x47,0xb6,0x0b,0x74,0x0d,0x00);
   6706 DEFINE_GUID(GUID_VIDEO_SUBGROUP,0x7516b95f,0xf776,0x4464,0x8c,0x53,0x06,0x16,0x7f,0x40,0xcc,0x99);
   6707 DEFINE_GUID(GUID_BATTERY_SUBGROUP,0xe73a048d,0xbf27,0x4f12,0x97,0x31,0x8b,0x20,0x76,0xe8,0x89,0x1f);
   6708 DEFINE_GUID(GUID_SLEEP_SUBGROUP,0x238C9FA8,0x0AAD,0x41ED,0x83,0xF4,0x97,0xBE,0x24,0x2C,0x8F,0x20);
   6709 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP,0x501a4d13,0x42af,0x4429,0x9f,0xd1,0xa8,0x21,0x8c,0x26,0x8e,0x20);
   6710 
   6711 /* Field Names From (See _fields_ section)
   6712  * FIXME: Verify these against documentation
   6713  * -- These documentation describes Win32 Constants and Structures in Python --
   6714  * Constants - http://packages.python.org/winappdbg/winappdbg.win32.context_i386-pysrc.html
   6715  * WOW64_FLOATING_SAVE_AREA - http://packages.python.org/winappdbg/winappdbg.win32.context_amd64.WOW64_FLOATING_SAVE_AREA-class.html
   6716  * WOW64_CONTEXT - http://packages.python.org/winappdbg/winappdbg.win32.context_amd64.WOW64_CONTEXT-class.html
   6717  */
   6718 
   6719 #define WOW64_CONTEXT_i386 0x00010000
   6720 #define WOW64_CONTEXT_i486 0x00010000
   6721 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
   6722 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
   6723 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
   6724 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
   6725 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
   6726 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
   6727 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
   6728 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
   6729 #define WOW64_SIZE_OF_80387_REGISTERS 80
   6730 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
   6731 
   6732 typedef struct _WOW64_FLOATING_SAVE_AREA {
   6733   DWORD   ControlWord;
   6734   DWORD   StatusWord;
   6735   DWORD   TagWord;
   6736   DWORD   ErrorOffset;
   6737   DWORD   ErrorSelector;
   6738   DWORD   DataOffset;
   6739   DWORD   DataSelector;
   6740   BYTE    RegisterArea[WOW64_SIZE_OF_80387_REGISTERS];
   6741   DWORD   Cr0NpxState;
   6742 } WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
   6743 
   6744 typedef struct _WOW64_CONTEXT {
   6745   DWORD ContextFlags;
   6746   DWORD Dr0;
   6747   DWORD Dr1;
   6748   DWORD Dr2;
   6749   DWORD Dr3;
   6750   DWORD Dr6;
   6751   DWORD Dr7;
   6752   WOW64_FLOATING_SAVE_AREA FloatSave;
   6753   DWORD SegGs;
   6754   DWORD SegFs;
   6755   DWORD SegEs;
   6756   DWORD SegDs;
   6757   DWORD Edi;
   6758   DWORD Esi;
   6759   DWORD Ebx;
   6760   DWORD Edx;
   6761   DWORD Ecx;
   6762   DWORD Eax;
   6763   DWORD Ebp;
   6764   DWORD Eip;
   6765   DWORD SegCs;
   6766   DWORD EFlags;
   6767   DWORD Esp;
   6768   DWORD SegSs;
   6769   BYTE ExtendedRegisters[WOW64_MAXIMUM_SUPPORTED_EXTENSION];
   6770 } WOW64_CONTEXT, *PWOW64_CONTEXT;
   6771 
   6772 #endif /*(_WIN32_WINNT >= 0x0600)*/
   6773 
   6774 #if (_WIN32_WINNT >= 0x0601)
   6775 
   6776 typedef enum  {
   6777   ACTCX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN   = 0,
   6778   ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS
   6779 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
   6780 
   6781 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
   6782   GUID                              Id;
   6783   ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
   6784 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
   6785 
   6786 /*Vista: {e2011457-1546-43c5-a5fe-008deee3d3f0}*/
   6787 /*Seven: {35138b9a-5d96-4fbd-8e2d-a2440225f93a}*/
   6788 
   6789 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
   6790   DWORD                         ElementCount;
   6791   COMPATIBILITY_CONTEXT_ELEMENT Elements[];
   6792 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
   6793 
   6794 #ifndef ___PROCESSOR_NUMBER_DEFINED
   6795 #define ___PROCESSOR_NUMBER_DEFINED
   6796 typedef struct _PROCESSOR_NUMBER {
   6797   WORD Group;
   6798   BYTE Number;
   6799   BYTE Reserved;
   6800 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
   6801 #endif /* !___PROCESSOR_NUMBER_DEFINED */
   6802 
   6803 typedef struct _PROCESSOR_GROUP_INFO {
   6804   BYTE      MaximumProcessorCount;
   6805   BYTE      ActiveProcessorCount;
   6806   BYTE      Reserved[38];
   6807   KAFFINITY ActiveProcessorMask;
   6808 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
   6809 
   6810 typedef struct _GROUP_RELATIONSHIP {
   6811   WORD                 MaximumGroupCount;
   6812   WORD                 ActiveGroupCount;
   6813   BYTE                 Reserved[20];
   6814   PROCESSOR_GROUP_INFO GroupInfo[];
   6815 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
   6816 
   6817 #ifndef ___GROUP_AFFINITY_DEFINED
   6818 #define ___GROUP_AFFINITY_DEFINED
   6819 typedef struct _GROUP_AFFINITY {
   6820   KAFFINITY Mask;
   6821   WORD      Group;
   6822   WORD      Reserved[3];
   6823 } GROUP_AFFINITY, *PGROUP_AFFINITY;
   6824 #endif /* !___GROUP_AFFINITY_DEFINED */
   6825 
   6826 typedef struct _CACHE_RELATIONSHIP {
   6827   BYTE                 Level;
   6828   BYTE                 Associativity;
   6829   WORD                 LineSize;
   6830   DWORD                CacheSize;
   6831   PROCESSOR_CACHE_TYPE Type;
   6832   BYTE                 Reserved[20];
   6833   GROUP_AFFINITY       GroupMask;
   6834 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
   6835 
   6836 typedef struct _NUMA_NODE_RELATIONSHIP {
   6837   DWORD          NodeNumber;
   6838   BYTE           Reserved[20];
   6839   GROUP_AFFINITY GroupMask;
   6840 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
   6841 
   6842 typedef struct _PROCESSOR_RELATIONSHIP {
   6843   BYTE           Flags;
   6844   BYTE           Reserved[21];
   6845   WORD           GroupCount;
   6846   GROUP_AFFINITY GroupMask[];
   6847 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
   6848 
   6849 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
   6850   LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
   6851   DWORD                          Size;
   6852   __C89_NAMELESS union {
   6853     PROCESSOR_RELATIONSHIP Processor;
   6854     NUMA_NODE_RELATIONSHIP NumaNode;
   6855     CACHE_RELATIONSHIP     Cache;
   6856     GROUP_RELATIONSHIP     Group;
   6857   };
   6858 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
   6859 
   6860 typedef struct _UMS_CREATE_THREAD_ATTRIBUTES {
   6861   DWORD UmsVersion;
   6862   PVOID UmsContext;
   6863   PVOID UmsCompletionList;
   6864 } UMS_CREATE_THREAD_ATTRIBUTES, *PUMS_CREATE_THREAD_ATTRIBUTES;
   6865 
   6866 typedef struct _WOW64_LDT_ENTRY {
   6867   WORD  LimitLow;
   6868   WORD  BaseLow;
   6869   __C89_NAMELESS union {
   6870     struct {
   6871       BYTE BaseMid;
   6872       BYTE Flags1;
   6873       BYTE Flags2;
   6874       BYTE BaseHi;
   6875     } Bytes;
   6876     struct {
   6877       DWORD BaseMid  :8;
   6878       DWORD Type  :5;
   6879       DWORD Dpl  :2;
   6880       DWORD Pres  :1;
   6881       DWORD LimitHi  :4;
   6882       DWORD Sys  :1;
   6883       DWORD Reserved_0  :1;
   6884       DWORD Default_Big  :1;
   6885       DWORD Granularity  :1;
   6886       DWORD BaseHi  :8;
   6887     } Bits;
   6888   } HighWord;
   6889 } WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
   6890 
   6891 /* Retrieved from: https://kdlib.googlecode.com/svn/trunk/imports/c/windows/winnt.d */
   6892 typedef struct _SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION {
   6893   DWORD64 CycleTime;
   6894 } SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, *PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION;
   6895 
   6896 typedef struct _HARDWARE_COUNTER_DATA {
   6897   HARDWARE_COUNTER_TYPE Type;
   6898   DWORD                 Reserved;
   6899   DWORD64               Value;
   6900 } HARDWARE_COUNTER_DATA, *PHARDWARE_COUNTER_DATA;
   6901 
   6902 #define MAX_HW_COUNTERS 16
   6903 /* Fixme: PERFORMANCE_DATA_VERSION define is missing */
   6904 
   6905 typedef struct _PERFORMANCE_DATA {
   6906   WORD                  Size;
   6907   BYTE                  Version;
   6908   BYTE                  HwCountersCount;
   6909   DWORD                 ContextSwitchCount;
   6910   DWORD64               WaitReasonBitMap;
   6911   DWORD64               CycleTime;
   6912   DWORD                 RetryCount;
   6913   DWORD                 Reserved;
   6914   HARDWARE_COUNTER_DATA HwCounters[MAX_HW_COUNTERS];
   6915 } PERFORMANCE_DATA, *PPERFORMANCE_DATA;
   6916 
   6917 #endif /*(_WIN32_WINNT >= 0x0601)*/
   6918 
   6919 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION (1)
   6920 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION (2)
   6921 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION (3)
   6922 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION (4)
   6923 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION (5)
   6924 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION (6)
   6925 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION (7)
   6926 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE (8)
   6927 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES (9)
   6928 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS (10)
   6929 
   6930 #ifdef __cplusplus
   6931 }
   6932 #endif
   6933 
   6934 #endif /* _WINNT_ */
   6935 
   6936