2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include <winapifamily.h>
27 #include <specstrings.h>
36 #if defined(_MSC_VER) && (defined(__arm__) || defined(__aarch64__))
45 #if defined(_NTSYSTEM_) || defined(WINE_UNIX_LIB)
48 #define NTSYSAPI DECLSPEC_IMPORT
51 #define NTAPI __stdcall
52 #define FASTCALL __fastcall
55 # if defined(_MSC_VER)
56 # define DECLSPEC_IMPORT __declspec(dllimport)
57 # elif defined(__MINGW32__) || defined(__CYGWIN__)
58 # define DECLSPEC_IMPORT __attribute__((dllimport))
60 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
63 # define DECLSPEC_IMPORT
66 #ifndef DECLSPEC_NORETURN
67 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
68 # define DECLSPEC_NORETURN __declspec(noreturn)
69 # elif defined(__GNUC__)
70 # define DECLSPEC_NORETURN __attribute__((noreturn))
72 # define DECLSPEC_NORETURN
76 #ifndef DECLSPEC_ALIGN
77 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
78 # define DECLSPEC_ALIGN(x) __declspec(align(x))
79 # elif defined(__GNUC__)
80 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
82 # define DECLSPEC_ALIGN(x)
86 #ifndef DECLSPEC_NOTHROW
87 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
88 # define DECLSPEC_NOTHROW __declspec(nothrow)
89 # elif defined(__GNUC__)
90 # define DECLSPEC_NOTHROW __attribute__((nothrow))
92 # define DECLSPEC_NOTHROW
96 #ifndef DECLSPEC_CACHEALIGN
97 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
100 #ifndef DECLSPEC_UUID
101 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
102 # define DECLSPEC_UUID(x) __declspec(uuid(x))
104 # define DECLSPEC_UUID(x)
108 #ifndef DECLSPEC_NOVTABLE
109 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
110 # define DECLSPEC_NOVTABLE __declspec(novtable)
112 # define DECLSPEC_NOVTABLE
116 #ifndef DECLSPEC_SELECTANY
117 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
118 #define DECLSPEC_SELECTANY __declspec(selectany)
119 #elif defined(__MINGW32__)
120 #define DECLSPEC_SELECTANY __attribute__((selectany))
122 #define DECLSPEC_SELECTANY
127 # if defined(_MSC_VER)
128 # if (_MSC_VER >= 1210)
129 # define NOP_FUNCTION __noop
131 # define NOP_FUNCTION (void)0
134 # define NOP_FUNCTION(...)
138 #ifndef DECLSPEC_ADDRSAFE
139 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
140 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
142 # define DECLSPEC_ADDRSAFE
147 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
148 # define FORCEINLINE __forceinline
149 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
150 # define FORCEINLINE inline __attribute__((always_inline))
152 # define FORCEINLINE inline
156 #ifndef DECLSPEC_DEPRECATED
157 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
158 # define DECLSPEC_DEPRECATED __declspec(deprecated)
159 # define DEPRECATE_SUPPORTED
160 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
161 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
162 # define DEPRECATE_SUPPORTED
164 # define DECLSPEC_DEPRECATED
165 # undef DEPRECATE_SUPPORTED
169 /* a couple of useful Wine extensions */
172 # define DECLSPEC_EXPORT __declspec(dllexport)
173 #elif defined(__MINGW32__)
174 # define DECLSPEC_EXPORT __attribute__((dllexport))
175 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) && !defined(__sun)
176 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
178 # define DECLSPEC_EXPORT
181 #ifndef DECLSPEC_HIDDEN
182 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || defined(__sun)
183 # define DECLSPEC_HIDDEN
184 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
185 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
187 # define DECLSPEC_HIDDEN
191 #ifndef __has_attribute
192 # define __has_attribute(x) 0
195 #if ((defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)))) || __has_attribute(ms_hook_prologue)) && (defined(__i386__) || defined(__x86_64__))
196 #define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__))
198 #define DECLSPEC_HOTPATCH
201 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
202 #define __WINE_ALLOC_SIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
204 #define __WINE_ALLOC_SIZE(...)
207 #if defined(__GNUC__) && (__GNUC__ > 10)
208 #define __WINE_DEALLOC(...) __attribute__((malloc (__VA_ARGS__)))
210 #define __WINE_DEALLOC(...)
213 #if defined(__GNUC__) && (__GNUC__ > 2)
214 #define __WINE_MALLOC __attribute__((malloc))
216 #define __WINE_MALLOC
219 /* Anonymous union/struct handling */
221 #ifndef NONAMELESSSTRUCT
223 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
224 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
225 # define NONAMELESSSTRUCT
227 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
228 # define NONAMELESSSTRUCT
230 #endif /* NONAMELESSSTRUCT */
232 #ifndef NONAMELESSUNION
234 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
235 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
236 # define NONAMELESSUNION
238 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
239 # define NONAMELESSUNION
241 #endif /* NONAMELESSUNION */
243 #undef DUMMYSTRUCTNAME
244 #undef DUMMYSTRUCTNAME1
245 #undef DUMMYSTRUCTNAME2
246 #undef DUMMYSTRUCTNAME3
247 #undef DUMMYSTRUCTNAME4
248 #undef DUMMYSTRUCTNAME5
249 #ifndef NONAMELESSSTRUCT
250 #define DUMMYSTRUCTNAME
251 #define DUMMYSTRUCTNAME1
252 #define DUMMYSTRUCTNAME2
253 #define DUMMYSTRUCTNAME3
254 #define DUMMYSTRUCTNAME4
255 #define DUMMYSTRUCTNAME5
256 #else /* !defined(NONAMELESSSTRUCT) */
257 #define DUMMYSTRUCTNAME s
258 #define DUMMYSTRUCTNAME1 s1
259 #define DUMMYSTRUCTNAME2 s2
260 #define DUMMYSTRUCTNAME3 s3
261 #define DUMMYSTRUCTNAME4 s4
262 #define DUMMYSTRUCTNAME5 s5
263 #endif /* !defined(NONAMELESSSTRUCT) */
265 #undef DUMMYUNIONNAME
266 #undef DUMMYUNIONNAME1
267 #undef DUMMYUNIONNAME2
268 #undef DUMMYUNIONNAME3
269 #undef DUMMYUNIONNAME4
270 #undef DUMMYUNIONNAME5
271 #undef DUMMYUNIONNAME6
272 #undef DUMMYUNIONNAME7
273 #undef DUMMYUNIONNAME8
274 #ifndef NONAMELESSUNION
275 #define DUMMYUNIONNAME
276 #define DUMMYUNIONNAME1
277 #define DUMMYUNIONNAME2
278 #define DUMMYUNIONNAME3
279 #define DUMMYUNIONNAME4
280 #define DUMMYUNIONNAME5
281 #define DUMMYUNIONNAME6
282 #define DUMMYUNIONNAME7
283 #define DUMMYUNIONNAME8
284 #else /* !defined(NONAMELESSUNION) */
285 #define DUMMYUNIONNAME u
286 #define DUMMYUNIONNAME1 u1
287 #define DUMMYUNIONNAME2 u2
288 #define DUMMYUNIONNAME3 u3
289 #define DUMMYUNIONNAME4 u4
290 #define DUMMYUNIONNAME5 u5
291 #define DUMMYUNIONNAME6 u6
292 #define DUMMYUNIONNAME7 u7
293 #define DUMMYUNIONNAME8 u8
294 #endif /* !defined(NONAMELESSUNION) */
296 #undef __C89_NAMELESS
297 #undef __C89_NAMELESSSTRUCTNAME
298 #undef __C89_NAMELESSSTRUCTNAME1
299 #undef __C89_NAMELESSSTRUCTNAME2
300 #undef __C89_NAMELESSSTRUCTNAME3
301 #undef __C89_NAMELESSSTRUCTNAME4
302 #undef __C89_NAMELESSSTRUCTNAME5
303 #undef __C89_NAMELESSUNIONNAME
304 #undef __C89_NAMELESSUNIONNAME1
305 #undef __C89_NAMELESSUNIONNAME2
306 #undef __C89_NAMELESSUNIONNAME3
307 #undef __C89_NAMELESSUNIONNAME4
308 #undef __C89_NAMELESSUNIONNAME5
309 #undef __C89_NAMELESSUNIONNAME6
310 #undef __C89_NAMELESSUNIONNAME7
311 #undef __C89_NAMELESSUNIONNAME8
313 #if !defined(WINE_NO_NAMELESS_EXTENSION)
315 /* Anonymous structs support starts with gcc 2.96/g++ 2.95 */
316 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ > 95) || ((__GNUC_MINOR__ == 95) && defined(__cplusplus))))
317 # define __C89_NAMELESS __extension__
319 # elif defined(_MSC_VER)
320 # define __C89_NAMELESS
324 #ifdef __C89_NAMELESS
325 # define __C89_NAMELESSSTRUCTNAME
326 # define __C89_NAMELESSSTRUCTNAME1
327 # define __C89_NAMELESSSTRUCTNAME2
328 # define __C89_NAMELESSSTRUCTNAME3
329 # define __C89_NAMELESSSTRUCTNAME4
330 # define __C89_NAMELESSSTRUCTNAME5
331 # define __C89_NAMELESSUNIONNAME
332 # define __C89_NAMELESSUNIONNAME1
333 # define __C89_NAMELESSUNIONNAME2
334 # define __C89_NAMELESSUNIONNAME3
335 # define __C89_NAMELESSUNIONNAME4
336 # define __C89_NAMELESSUNIONNAME5
337 # define __C89_NAMELESSUNIONNAME6
338 # define __C89_NAMELESSUNIONNAME7
339 # define __C89_NAMELESSUNIONNAME8
341 # define __C89_NAMELESS
342 # define __C89_NAMELESSSTRUCTNAME DUMMYSTRUCTNAME
343 # define __C89_NAMELESSSTRUCTNAME1 DUMMYSTRUCTNAME1
344 # define __C89_NAMELESSSTRUCTNAME2 DUMMYSTRUCTNAME2
345 # define __C89_NAMELESSSTRUCTNAME3 DUMMYSTRUCTNAME3
346 # define __C89_NAMELESSSTRUCTNAME4 DUMMYSTRUCTNAME4
347 # define __C89_NAMELESSSTRUCTNAME5 DUMMYSTRUCTNAME5
348 # define __C89_NAMELESSUNIONNAME DUMMYUNIONNAME
349 # define __C89_NAMELESSUNIONNAME1 DUMMYUNIONNAME1
350 # define __C89_NAMELESSUNIONNAME2 DUMMYUNIONNAME2
351 # define __C89_NAMELESSUNIONNAME3 DUMMYUNIONNAME3
352 # define __C89_NAMELESSUNIONNAME4 DUMMYUNIONNAME4
353 # define __C89_NAMELESSUNIONNAME5 DUMMYUNIONNAME5
354 # define __C89_NAMELESSUNIONNAME6 DUMMYUNIONNAME6
355 # define __C89_NAMELESSUNIONNAME7 DUMMYUNIONNAME7
356 # define __C89_NAMELESSUNIONNAME8 DUMMYUNIONNAME8
359 /* C99 restrict support */
361 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
362 # if defined(_MSC_VER) && defined(_M_MRX000)
363 # define RESTRICTED_POINTER __restrict
364 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
365 # define RESTRICTED_POINTER __restrict
367 # define RESTRICTED_POINTER
370 # define RESTRICTED_POINTER
373 /* C99 unaligned support */
376 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
377 # define UNALIGNED __unaligned
379 # define UNALIGNED64 __unaligned
389 /* Alignment macros */
392 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
393 #define MEMORY_ALLOCATION_ALIGNMENT 16
395 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
396 #define MEMORY_ALLOCATION_ALIGNMENT 8
399 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
400 # define TYPE_ALIGNMENT(t) __alignof(t)
401 #elif defined(__GNUC__)
402 # define TYPE_ALIGNMENT(t) __alignof__(t)
404 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
408 # define PROBE_ALIGNMENT(_s) \
409 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
410 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
411 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
413 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
416 /* Compile time assertion */
418 #define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
420 /* Eliminate Microsoft C/C++ compiler warning 4715 */
421 #if defined(_MSC_VER) && (_MSC_VER > 1200)
422 # define DEFAULT_UNREACHABLE default: __assume(0)
423 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
424 # define DEFAULT_UNREACHABLE default: __builtin_unreachable()
426 # define DEFAULT_UNREACHABLE default:
430 #define APPLICATION_ERROR_MASK 0x20000000
431 #define ERROR_SEVERITY_SUCCESS 0x00000000
432 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
433 #define ERROR_SEVERITY_WARNING 0x80000000
434 #define ERROR_SEVERITY_ERROR 0xC0000000
437 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
439 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
440 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
441 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \
442 inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
443 inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \
444 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \
445 inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
448 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
451 /* Microsoft's macros for declaring functions */
454 # define EXTERN_C extern "C"
456 # define EXTERN_C extern
459 #define STDMETHODCALLTYPE WINAPI
460 #define STDMETHODVCALLTYPE WINAPIV
461 #define STDAPICALLTYPE WINAPI
462 #define STDAPIVCALLTYPE WINAPIV
464 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
465 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
466 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
467 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
468 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
469 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
470 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
471 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
473 /* Define the basic types */
478 typedef VOID
*PVOID64
;
479 typedef BYTE BOOLEAN
, *PBOOLEAN
;
480 typedef char CHAR
, *PCHAR
;
481 typedef short SHORT
, *PSHORT
;
482 #if !defined(__LP64__) && !defined(WINE_NO_LONG_TYPES)
483 typedef long LONG
, *PLONG
;
485 typedef int LONG
, *PLONG
;
488 /* Some systems might have wchar_t, but we really need 16 bit characters */
489 #if defined(WINE_UNICODE_NATIVE)
490 typedef wchar_t WCHAR
;
491 #elif __cpp_unicode_literals >= 200710
492 typedef char16_t WCHAR
;
494 typedef unsigned short WCHAR
;
496 typedef WCHAR
*PWCHAR
;
498 typedef ULONG UCSCHAR
;
499 #define MIN_UCSCHAR (0)
500 #define MAX_UCSCHAR (0x0010ffff)
501 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
503 /* 'Extended/Wide' numerical types */
507 typedef signed __int64 LONGLONG
, *PLONGLONG
;
508 typedef unsigned __int64 ULONGLONG
, *PULONGLONG
;
510 typedef signed __int64
DECLSPEC_ALIGN(8) LONGLONG
, *PLONGLONG
;
511 typedef unsigned __int64
DECLSPEC_ALIGN(8) ULONGLONG
, *PULONGLONG
;
518 typedef ULONGLONG DWORDLONG
, *PDWORDLONG
;
520 typedef ULONGLONG
DECLSPEC_ALIGN(8) DWORDLONG
, *PDWORDLONG
;
524 /* ANSI string types */
525 typedef CHAR
*PCH
, *LPCH
, *PNZCH
;
526 typedef const CHAR
*PCCH
, *LPCCH
, *PCNZCH
;
527 typedef CHAR
*PSTR
, *LPSTR
, *NPSTR
;
528 typedef const CHAR
*PCSTR
, *LPCSTR
;
529 typedef CHAR
*PZZSTR
;
530 typedef const CHAR
*PCZZSTR
;
532 /* Unicode string types */
533 typedef const WCHAR
*PCWCHAR
, *LPCUWCHAR
, *PCUWCHAR
;
534 typedef WCHAR
*PWCH
, *LPWCH
;
535 typedef const WCHAR
*PCWCH
, *LPCWCH
;
536 typedef WCHAR
*PNZWCH
, *PUNZWCH
;
537 typedef const WCHAR
*PCNZWCH
, *PCUNZWCH
;
538 typedef WCHAR
*PWSTR
, *LPWSTR
, *NWPSTR
;
539 typedef const WCHAR
*PCWSTR
, *LPCWSTR
;
540 typedef WCHAR
*PZZWSTR
, *PUZZWSTR
;
541 typedef const WCHAR
*PCZZWSTR
, *PCUZZWSTR
;
542 typedef PWSTR
*PZPWSTR
;
543 typedef PCWSTR
*PZPCWSTR
;
545 /* Neutral character and string types */
546 /* These are only defined for Winelib, i.e. _not_ defined for
547 * the emulator. The reason is they depend on the UNICODE
548 * macro which only exists in the user's code.
550 #ifndef WINE_NO_UNICODE_MACROS
552 # ifndef _TCHAR_DEFINED
553 typedef WCHAR TCHAR
, *PTCHAR
;
554 # define _TCHAR_DEFINED
556 typedef LPWCH PTCH
, LPTCH
;
557 typedef LPCWCH PCTCH
, LPCTCH
;
558 typedef LPWSTR PTSTR
, LPTSTR
;
559 typedef LPCWSTR PCTSTR
, LPCTSTR
;
560 typedef LPWSTR PUTSTR
, LPUTSTR
;
561 typedef LPCWSTR PCUTSTR
, LPCUTSTR
;
562 typedef PNZWCH PNZTCH
;
563 typedef PUNZWCH PUNZTCH
;
564 typedef PCNZWCH PCNZTCH
;
565 typedef PCUNZWCH PCUNZTCH
;
566 typedef PZZWSTR PZZTSTR
;
567 typedef PCZZWSTR PCZZTSTR
;
568 typedef PUZZWSTR PUZZTSTR
;
569 typedef PCUZZWSTR PCUZZTSTR
;
571 # ifndef _TCHAR_DEFINED
572 typedef CHAR TCHAR
, *PTCHAR
;
573 # define _TCHAR_DEFINED
575 typedef LPCH PTCH
, LPTCH
;
576 typedef LPCCH PCTCH
, LPCTCH
;
577 typedef LPSTR PTSTR
, LPTSTR
;
578 typedef LPCSTR PCTSTR
, LPCTSTR
;
579 typedef PNZCH PNZTCH
, PUNZTCH
;
580 typedef PCNZCH PCNZTCH
, PCUNZTCH
;
581 typedef PZZSTR PZZTSTR
, PUZZTSTR
;
582 typedef PCZZSTR PCZZTSTR
, PCUZZTSTR
;
583 # endif /* UNICODE */
584 #endif /* WINE_NO_UNICODE_MACROS */
586 /* UCS string types */
587 typedef UCSCHAR
*PUCSCHAR
, *PUUCSCHAR
;
588 typedef const UCSCHAR
*PCUCSCHAR
, *PCUUCSCHAR
;
589 typedef UCSCHAR
*PUCSSTR
, *PUUCSSTR
;
590 typedef const UCSCHAR
*PCUCSSTR
, *PCUUCSSTR
;
592 /* Misc common WIN32 types */
594 typedef DWORD LCID
, *PLCID
;
596 typedef DWORD EXECUTION_STATE
;
597 #ifndef _HRESULT_DEFINED
598 #define _HRESULT_DEFINED
599 typedef LONG HRESULT
;
604 typedef void *HANDLE
;
605 typedef HANDLE
*PHANDLE
, *LPHANDLE
;
608 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
610 #define DECLARE_HANDLE(a) typedef HANDLE a
617 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
619 #if !defined(__LP64__) && !defined(WINE_NO_LONG_TYPES)
620 # define __MSABI_LONG(x) x ## l
622 # define __MSABI_LONG(x) x
628 #ifndef WIN32_NO_STATUS
630 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
631 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
632 #define STATUS_USER_APC ((DWORD) 0x000000C0)
633 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
634 #define STATUS_PENDING ((DWORD) 0x00000103)
635 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
636 #define STATUS_FATAL_APP_EXIT ((DWORD) 0x40000015)
637 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
638 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
639 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
640 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
641 #define STATUS_LONGJUMP ((DWORD) 0x80000026)
642 #define STATUS_UNWIND_CONSOLIDATE ((DWORD) 0x80000029)
643 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
644 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
645 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
646 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
647 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
648 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
649 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
650 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
651 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
652 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
653 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
654 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
655 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
656 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
657 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
658 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
659 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
660 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
661 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
662 #define STATUS_DLL_NOT_FOUND ((DWORD) 0xC0000135)
663 #define STATUS_ORDINAL_NOT_FOUND ((DWORD) 0xC0000138)
664 #define STATUS_ENTRYPOINT_NOT_FOUND ((DWORD) 0xC0000139)
665 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
666 #define STATUS_DLL_INIT_FAILED ((DWORD) 0xC0000142)
667 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
668 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
669 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
670 #define STATUS_HEAP_CORRUPTION ((DWORD) 0xC0000374)
671 #define STATUS_STACK_BUFFER_OVERRUN ((DWORD) 0xC0000409)
672 #define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD) 0xC0000417)
673 #define STATUS_ASSERTION_FAILURE ((DWORD) 0xC0000420)
674 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
675 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
677 /* status values for ContinueDebugEvent */
678 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
679 #define DBG_CONTINUE ((DWORD) 0x00010002)
680 #define DBG_REPLY_LATER ((DWORD) 0x40010001)
681 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
682 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
683 #define DBG_CONTROL_C ((DWORD) 0x40010005)
684 #define DBG_PRINTEXCEPTION_C ((DWORD) 0x40010006)
685 #define DBG_RIPEXCEPTION ((DWORD) 0x40010007)
686 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
687 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
688 #define DBG_PRINTEXCEPTION_WIDE_C ((DWORD) 0x4001000A)
689 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
691 #endif /* WIN32_NO_STATUS */
693 /* Argument 1 passed to the DllEntryProc. */
694 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
695 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
696 #define DLL_THREAD_ATTACH 2 /* attach new thread */
697 #define DLL_THREAD_DETACH 3 /* detach thread */
699 /* u.x.wProcessorArchitecture (NT) */
700 #define PROCESSOR_ARCHITECTURE_INTEL 0
701 #define PROCESSOR_ARCHITECTURE_MIPS 1
702 #define PROCESSOR_ARCHITECTURE_ALPHA 2
703 #define PROCESSOR_ARCHITECTURE_PPC 3
704 #define PROCESSOR_ARCHITECTURE_SHX 4
705 #define PROCESSOR_ARCHITECTURE_ARM 5
706 #define PROCESSOR_ARCHITECTURE_IA64 6
707 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
708 #define PROCESSOR_ARCHITECTURE_MSIL 8
709 #define PROCESSOR_ARCHITECTURE_AMD64 9
710 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
711 #define PROCESSOR_ARCHITECTURE_NEUTRAL 11
712 #define PROCESSOR_ARCHITECTURE_ARM64 12
713 #define PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64 13
714 #define PROCESSOR_ARCHITECTURE_IA32_ON_ARM64 14
715 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
717 /* dwProcessorType */
718 #define PROCESSOR_INTEL_386 386
719 #define PROCESSOR_INTEL_486 486
720 #define PROCESSOR_INTEL_PENTIUM 586
721 #define PROCESSOR_INTEL_860 860
722 #define PROCESSOR_INTEL_IA64 2200
723 #define PROCESSOR_AMD_X8664 8664
724 #define PROCESSOR_MIPS_R2000 2000
725 #define PROCESSOR_MIPS_R3000 3000
726 #define PROCESSOR_MIPS_R4000 4000
727 #define PROCESSOR_ALPHA_21064 21064
728 #define PROCESSOR_PPC_601 601
729 #define PROCESSOR_PPC_603 603
730 #define PROCESSOR_PPC_604 604
731 #define PROCESSOR_PPC_620 620
732 #define PROCESSOR_HITACHI_SH3 10003
733 #define PROCESSOR_HITACHI_SH3E 10004
734 #define PROCESSOR_HITACHI_SH4 10005
735 #define PROCESSOR_MOTOROLA_821 821
736 #define PROCESSOR_SHx_SH3 103
737 #define PROCESSOR_SHx_SH4 104
738 #define PROCESSOR_STRONGARM 2577
739 #define PROCESSOR_ARM720 1824 /* 0x720 */
740 #define PROCESSOR_ARM820 2080 /* 0x820 */
741 #define PROCESSOR_ARM920 2336 /* 0x920 */
742 #define PROCESSOR_ARM_7TDMI 70001
743 #define PROCESSOR_OPTIL 18767
746 #define MAXIMUM_PROCESSORS 64
748 #define MAXIMUM_PROCESSORS 32
751 typedef struct _MEMORY_BASIC_INFORMATION
754 LPVOID AllocationBase
;
755 DWORD AllocationProtect
;
760 } MEMORY_BASIC_INFORMATION
, *PMEMORY_BASIC_INFORMATION
;
762 #define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
764 typedef enum MEM_EXTENDED_PARAMETER_TYPE
{
765 MemExtendedParameterInvalidType
= 0,
766 MemExtendedParameterAddressRequirements
,
767 MemExtendedParameterNumaNode
,
768 MemExtendedParameterPartitionHandle
,
769 MemExtendedParameterUserPhysicalHandle
,
770 MemExtendedParameterAttributeFlags
,
771 MemExtendedParameterMax
772 } MEM_EXTENDED_PARAMETER_TYPE
, *PMEM_EXTENDED_PARAMETER_TYPE
;
774 typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER
{
777 DWORD64 Type
: MEM_EXTENDED_PARAMETER_TYPE_BITS
;
778 DWORD64 Reserved
: 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS
;
789 } MEM_EXTENDED_PARAMETER
, *PMEM_EXTENDED_PARAMETER
;
791 typedef struct _WIN32_MEMORY_RANGE_ENTRY
793 PVOID VirtualAddress
;
794 SIZE_T NumberOfBytes
;
795 } WIN32_MEMORY_RANGE_ENTRY
, *PWIN32_MEMORY_RANGE_ENTRY
;
797 #define PAGE_NOACCESS 0x01
798 #define PAGE_READONLY 0x02
799 #define PAGE_READWRITE 0x04
800 #define PAGE_WRITECOPY 0x08
801 #define PAGE_EXECUTE 0x10
802 #define PAGE_EXECUTE_READ 0x20
803 #define PAGE_EXECUTE_READWRITE 0x40
804 #define PAGE_EXECUTE_WRITECOPY 0x80
805 #define PAGE_GUARD 0x100
806 #define PAGE_NOCACHE 0x200
807 #define PAGE_WRITECOMBINE 0x400
809 #define MEM_COMMIT 0x00001000
810 #define MEM_RESERVE 0x00002000
811 #define MEM_REPLACE_PLACEHOLDER 0x00004000
812 #define MEM_RESERVE_PLACEHOLDER 0x00040000
813 #define MEM_RESET 0x00080000
814 #define MEM_TOP_DOWN 0x00100000
815 #define MEM_PHYSICAL 0x00400000
816 #define MEM_RESET_UNDO 0x10000000
817 #define MEM_LARGE_PAGES 0x20000000
819 #define MEM_COALESCE_PLACEHOLDERS 0x00000001
820 #define MEM_PRESERVE_PLACEHOLDER 0x00000002
821 #define MEM_DECOMMIT 0x00004000
822 #define MEM_RELEASE 0x00008000
824 #define MEM_FREE 0x00010000
825 #define MEM_PRIVATE 0x00020000
826 #define MEM_MAPPED 0x00040000
827 #define MEM_WRITE_WATCH 0x00200000
828 #define MEM_4MB_PAGES 0x80000000
830 #define SEC_FILE 0x00800000
831 #define SEC_IMAGE 0x01000000
832 #define SEC_PROTECTED_IMAGE 0x02000000
833 #define SEC_RESERVE 0x04000000
834 #define SEC_COMMIT 0x08000000
835 #define SEC_NOCACHE 0x10000000
836 #define SEC_WRITECOMBINE 0x40000000
837 #define SEC_LARGE_PAGES 0x80000000
838 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
839 #define MEM_IMAGE SEC_IMAGE
841 #define WRITE_WATCH_FLAG_RESET 0x00000001
843 #define AT_ROUND_TO_PAGE 0x40000000
847 #define MINSHORT 0x8000
848 #define MAXSHORT 0x7fff
849 #define MINLONG 0x80000000
850 #define MAXLONG 0x7fffffff
852 #define MAXWORD 0xffff
853 #define MAXDWORD 0xffffffff
854 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
856 #define UNICODE_STRING_MAX_CHARS 32767
858 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
859 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
860 #define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
862 #define CONTAINING_RECORD(address, type, field) \
863 ((type *)((PCHAR)(address) - offsetof(type, field)))
865 #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
867 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
872 typedef struct _LIST_ENTRY
{
873 struct _LIST_ENTRY
*Flink
;
874 struct _LIST_ENTRY
*Blink
;
875 } LIST_ENTRY
, *PLIST_ENTRY
, * RESTRICTED_POINTER PRLIST_ENTRY
;
877 typedef struct _SINGLE_LIST_ENTRY
{
878 struct _SINGLE_LIST_ENTRY
*Next
;
879 } SINGLE_LIST_ENTRY
, *PSINGLE_LIST_ENTRY
;
883 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
{
884 struct _SLIST_ENTRY
*Next
;
885 } SLIST_ENTRY
, *PSLIST_ENTRY
;
887 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
{
894 ULONGLONG Sequence
:9;
895 ULONGLONG NextEntry
:39;
896 ULONGLONG HeaderType
:1;
898 ULONGLONG Reserved
:59;
903 ULONGLONG Sequence
:48;
904 ULONGLONG HeaderType
:1;
906 ULONGLONG Reserved
:2;
907 ULONGLONG NextEntry
:60;
909 } SLIST_HEADER
, *PSLIST_HEADER
;
913 #undef SLIST_ENTRY /* for Mac OS */
914 #define SLIST_ENTRY SINGLE_LIST_ENTRY
915 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
916 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
918 typedef union _SLIST_HEADER
{
925 } SLIST_HEADER
, *PSLIST_HEADER
;
929 NTSYSAPI PSLIST_ENTRY WINAPI
RtlFirstEntrySList(const SLIST_HEADER
*);
930 NTSYSAPI VOID WINAPI
RtlInitializeSListHead(PSLIST_HEADER
);
931 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedFlushSList(PSLIST_HEADER
);
932 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedPopEntrySList(PSLIST_HEADER
);
933 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedPushEntrySList(PSLIST_HEADER
, PSLIST_ENTRY
);
934 NTSYSAPI WORD WINAPI
RtlQueryDepthSList(PSLIST_HEADER
);
937 /* Fast fail (__fastfail) codes */
939 #define FAST_FAIL_LEGACY_GS_VIOLATION 0
940 #define FAST_FAIL_VTGUARD_CHECK_FAILURE 1
941 #define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2
942 #define FAST_FAIL_CORRUPT_LIST_ENTRY 3
943 #define FAST_FAIL_INCORRECT_STACK 4
944 #define FAST_FAIL_INVALID_ARG 5
945 #define FAST_FAIL_GS_COOKIE_INIT 6
946 #define FAST_FAIL_FATAL_APP_EXIT 7
947 #define FAST_FAIL_RANGE_CHECK_FAILURE 8
948 #define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9
949 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10
950 #define FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11
951 #define FAST_FAIL_INVALID_FIBER_SWITCH 12
952 #define FAST_FAIL_INVALID_SET_OF_CONTEXT 13
953 #define FAST_FAIL_INVALID_REFERENCE_COUNT 14
954 #define FAST_FAIL_INVALID_JUMP_BUFFER 18
955 #define FAST_FAIL_MRDATA_MODIFIED 19
956 #define FAST_FAIL_CERTIFICATION_FAILURE 20
957 #define FAST_FAIL_INVALID_EXCEPTION_CHAIN 21
958 #define FAST_FAIL_CRYPTO_LIBRARY 22
959 #define FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT 23
960 #define FAST_FAIL_INVALID_IMAGE_BASE 24
961 #define FAST_FAIL_DLOAD_PROTECTION_FAILURE 25
962 #define FAST_FAIL_UNSAFE_EXTENSION_CALL 26
963 #define FAST_FAIL_DEPRECATED_SERVICE_INVOKED 27
964 #define FAST_FAIL_INVALID_BUFFER_ACCESS 28
965 #define FAST_FAIL_INVALID_BALANCED_TREE 29
966 #define FAST_FAIL_INVALID_NEXT_THREAD 30
967 #define FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED 31
968 #define FAST_FAIL_APCS_DISABLED 32
969 #define FAST_FAIL_INVALID_IDLE_STATE 33
970 #define FAST_FAIL_MRDATA_PROTECTION_FAILURE 34
971 #define FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION 35
972 #define FAST_FAIL_INVALID_LOCK_STATE 36
973 #define FAST_FAIL_GUARD_JUMPTABLE 37
974 #define FAST_FAIL_INVALID_LONGJUMP_TARGET 38
975 #define FAST_FAIL_INVALID_DISPATCH_CONTEXT 39
976 #define FAST_FAIL_INVALID_THREAD 40
977 #define FAST_FAIL_INVALID_SYSCALL_NUMBER 41
978 #define FAST_FAIL_INVALID_FILE_OPERATION 42
979 #define FAST_FAIL_LPAC_ACCESS_DENIED 43
980 #define FAST_FAIL_GUARD_SS_FAILURE 44
981 #define FAST_FAIL_LOADER_CONTINUITY_FAILURE 45
982 #define FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE 46
983 #define FAST_FAIL_INVALID_CONTROL_STACK 47
984 #define FAST_FAIL_SET_CONTEXT_DENIED 48
985 #define FAST_FAIL_INVALID_IAT 49
986 #define FAST_FAIL_HEAP_METADATA_CORRUPTION 50
987 #define FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION 51
988 #define FAST_FAIL_LOW_LABEL_ACCESS_DENIED 52
989 #define FAST_FAIL_ENCLAVE_CALL_FAILURE 53
990 #define FAST_FAIL_UNHANDLED_LSS_EXCEPTON 54
991 #define FAST_FAIL_ADMINLESS_ACCESS_DENIED 55
992 #define FAST_FAIL_UNEXPECTED_CALL 56
993 #define FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS 57
994 #define FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR 58
995 #define FAST_FAIL_FLAGS_CORRUPTION 59
996 #define FAST_FAIL_VEH_CORRUPTION 60
997 #define FAST_FAIL_ETW_CORRUPTION 61
998 #define FAST_FAIL_RIO_ABORT 62
999 #define FAST_FAIL_INVALID_PFN 63
1000 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE_XFG 64
1001 #define FAST_FAIL_CAST_GUARD 65
1002 #define FAST_FAIL_HOST_VISIBILITY_CHANGE 66
1003 #define FAST_FAIL_KERNEL_CET_SHADOW_STACK_ASSIST 67
1004 #define FAST_FAIL_PATCH_CALLBACK_FAILED 68
1005 #define FAST_FAIL_NTDLL_PATCH_FAILED 69
1006 #define FAST_FAIL_INVALID_FLS_DATA 70
1007 #define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xFFFFFFFF
1011 #define HEAP_NO_SERIALIZE 0x00000001
1012 #define HEAP_GROWABLE 0x00000002
1013 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
1014 #define HEAP_ZERO_MEMORY 0x00000008
1015 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
1016 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
1017 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
1018 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
1019 #define HEAP_CREATE_ALIGN_16 0x00010000
1020 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
1021 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
1023 /* This flag allows it to create heaps shared by all processes under win95,
1024 FIXME: correct name */
1025 #define HEAP_SHARED 0x04000000
1027 typedef enum _HEAP_INFORMATION_CLASS
{
1028 HeapCompatibilityInformation
,
1029 } HEAP_INFORMATION_CLASS
;
1031 /* Processor feature flags. */
1032 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
1033 #define PF_FLOATING_POINT_EMULATED 1
1034 #define PF_COMPARE_EXCHANGE_DOUBLE 2
1035 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
1036 #define PF_PPC_MOVEMEM_64BIT_OK 4
1037 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
1038 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
1039 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
1040 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
1041 #define PF_PAE_ENABLED 9
1042 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
1043 #define PF_SSE_DAZ_MODE_AVAILABLE 11
1044 #define PF_NX_ENABLED 12
1045 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
1046 #define PF_COMPARE_EXCHANGE128 14
1047 #define PF_COMPARE64_EXCHANGE128 15
1048 #define PF_CHANNELS_ENABLED 16
1049 #define PF_XSAVE_ENABLED 17
1050 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
1051 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
1052 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
1053 #define PF_VIRT_FIRMWARE_ENABLED 21
1054 #define PF_RDWRFSGSBASE_AVAILABLE 22
1055 #define PF_FASTFAIL_AVAILABLE 23
1056 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
1057 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
1058 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
1059 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
1060 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
1061 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
1062 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
1063 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
1064 #define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
1065 #define PF_RDPID_INSTRUCTION_AVAILABLE 33
1066 #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
1067 #define PF_MONITORX_INSTRUCTION_AVAILABLE 35
1068 #define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
1069 #define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
1070 #define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
1071 #define PF_AVX_INSTRUCTIONS_AVAILABLE 39
1072 #define PF_AVX2_INSTRUCTIONS_AVAILABLE 40
1073 #define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
1076 /* Execution state flags */
1077 #define ES_SYSTEM_REQUIRED 0x00000001
1078 #define ES_DISPLAY_REQUIRED 0x00000002
1079 #define ES_USER_PRESENT 0x00000004
1080 #define ES_CONTINUOUS 0x80000000
1084 /* The Win32 register context */
1086 /* i386 context definitions */
1088 #define I386_SIZE_OF_80387_REGISTERS 80
1090 typedef struct _I386_FLOATING_SAVE_AREA
1096 DWORD ErrorSelector
;
1099 BYTE RegisterArea
[I386_SIZE_OF_80387_REGISTERS
];
1101 } I386_FLOATING_SAVE_AREA
, WOW64_FLOATING_SAVE_AREA
, *PWOW64_FLOATING_SAVE_AREA
;
1103 #define I386_MAXIMUM_SUPPORTED_EXTENSION 512
1105 #include "pshpack4.h"
1106 typedef struct _I386_CONTEXT
1108 DWORD ContextFlags
; /* 000 */
1110 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1111 DWORD Dr0
; /* 004 */
1112 DWORD Dr1
; /* 008 */
1113 DWORD Dr2
; /* 00c */
1114 DWORD Dr3
; /* 010 */
1115 DWORD Dr6
; /* 014 */
1116 DWORD Dr7
; /* 018 */
1118 /* These are selected by CONTEXT_FLOATING_POINT */
1119 I386_FLOATING_SAVE_AREA FloatSave
; /* 01c */
1121 /* These are selected by CONTEXT_SEGMENTS */
1122 DWORD SegGs
; /* 08c */
1123 DWORD SegFs
; /* 090 */
1124 DWORD SegEs
; /* 094 */
1125 DWORD SegDs
; /* 098 */
1127 /* These are selected by CONTEXT_INTEGER */
1128 DWORD Edi
; /* 09c */
1129 DWORD Esi
; /* 0a0 */
1130 DWORD Ebx
; /* 0a4 */
1131 DWORD Edx
; /* 0a8 */
1132 DWORD Ecx
; /* 0ac */
1133 DWORD Eax
; /* 0b0 */
1135 /* These are selected by CONTEXT_CONTROL */
1136 DWORD Ebp
; /* 0b4 */
1137 DWORD Eip
; /* 0b8 */
1138 DWORD SegCs
; /* 0bc */
1139 DWORD EFlags
; /* 0c0 */
1140 DWORD Esp
; /* 0c4 */
1141 DWORD SegSs
; /* 0c8 */
1143 BYTE ExtendedRegisters
[I386_MAXIMUM_SUPPORTED_EXTENSION
]; /* 0xcc */
1144 } I386_CONTEXT
, WOW64_CONTEXT
, *PWOW64_CONTEXT
;
1145 #include "poppack.h"
1147 #define CONTEXT_i386 0x00010000
1148 #define CONTEXT_i486 0x00010000
1150 #define CONTEXT_I386_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1151 #define CONTEXT_I386_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1152 #define CONTEXT_I386_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1153 #define CONTEXT_I386_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1154 #define CONTEXT_I386_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1155 #define CONTEXT_I386_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1156 #define CONTEXT_I386_XSTATE (CONTEXT_i386 | 0x0040)
1157 #define CONTEXT_I386_FULL (CONTEXT_I386_CONTROL | CONTEXT_I386_INTEGER | CONTEXT_I386_SEGMENTS)
1158 #define CONTEXT_I386_ALL (CONTEXT_I386_FULL | CONTEXT_I386_FLOATING_POINT | CONTEXT_I386_DEBUG_REGISTERS | CONTEXT_I386_EXTENDED_REGISTERS)
1162 #define CONTEXT_CONTROL CONTEXT_I386_CONTROL
1163 #define CONTEXT_INTEGER CONTEXT_I386_INTEGER
1164 #define CONTEXT_SEGMENTS CONTEXT_I386_SEGMENTS
1165 #define CONTEXT_FLOATING_POINT CONTEXT_I386_FLOATING_POINT
1166 #define CONTEXT_DEBUG_REGISTERS CONTEXT_I386_DEBUG_REGISTERS
1167 #define CONTEXT_EXTENDED_REGISTERS CONTEXT_I386_EXTENDED_REGISTERS
1168 #define CONTEXT_XSTATE CONTEXT_I386_XSTATE
1169 #define CONTEXT_FULL CONTEXT_I386_FULL
1170 #define CONTEXT_ALL CONTEXT_I386_ALL
1171 #define SIZE_OF_80387_REGISTERS I386_SIZE_OF_80387_REGISTERS
1172 #define MAXIMUM_SUPPORTED_EXTENSION I386_MAXIMUM_SUPPORTED_EXTENSION
1174 typedef I386_FLOATING_SAVE_AREA FLOATING_SAVE_AREA
, *PFLOATING_SAVE_AREA
;
1175 typedef I386_CONTEXT CONTEXT
, *PCONTEXT
;
1177 #endif /* __i386__ */
1179 typedef struct _LDT_ENTRY
{
1190 unsigned BaseMid
: 8;
1194 unsigned LimitHi
: 4;
1196 unsigned Reserved_0
: 1;
1197 unsigned Default_Big
: 1;
1198 unsigned Granularity
: 1;
1199 unsigned BaseHi
: 8;
1202 } LDT_ENTRY
, *PLDT_ENTRY
, WOW64_LDT_ENTRY
, *PWOW64_LDT_ENTRY
;
1204 typedef struct DECLSPEC_ALIGN(16) _M128A
{
1209 typedef struct _XSAVE_FORMAT
{
1210 WORD ControlWord
; /* 000 */
1211 WORD StatusWord
; /* 002 */
1212 BYTE TagWord
; /* 004 */
1213 BYTE Reserved1
; /* 005 */
1214 WORD ErrorOpcode
; /* 006 */
1215 DWORD ErrorOffset
; /* 008 */
1216 WORD ErrorSelector
; /* 00c */
1217 WORD Reserved2
; /* 00e */
1218 DWORD DataOffset
; /* 010 */
1219 WORD DataSelector
; /* 014 */
1220 WORD Reserved3
; /* 016 */
1221 DWORD MxCsr
; /* 018 */
1222 DWORD MxCsr_Mask
; /* 01c */
1223 M128A FloatRegisters
[8]; /* 020 */
1224 M128A XmmRegisters
[16]; /* 0a0 */
1225 BYTE Reserved4
[96]; /* 1a0 */
1226 } XSAVE_FORMAT
, *PXSAVE_FORMAT
;
1228 /* x86-64 context definitions */
1230 typedef struct _AMD64_RUNTIME_FUNCTION
1235 } AMD64_RUNTIME_FUNCTION
;
1237 #define CONTEXT_AMD64 0x00100000
1239 #define CONTEXT_AMD64_CONTROL (CONTEXT_AMD64 | 0x0001)
1240 #define CONTEXT_AMD64_INTEGER (CONTEXT_AMD64 | 0x0002)
1241 #define CONTEXT_AMD64_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1242 #define CONTEXT_AMD64_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1243 #define CONTEXT_AMD64_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1244 #define CONTEXT_AMD64_XSTATE (CONTEXT_AMD64 | 0x0040)
1245 #define CONTEXT_AMD64_FULL (CONTEXT_AMD64_CONTROL | CONTEXT_AMD64_INTEGER | CONTEXT_AMD64_FLOATING_POINT)
1246 #define CONTEXT_AMD64_ALL (CONTEXT_AMD64_CONTROL | CONTEXT_AMD64_INTEGER | CONTEXT_AMD64_SEGMENTS | CONTEXT_AMD64_FLOATING_POINT | CONTEXT_AMD64_DEBUG_REGISTERS)
1248 typedef XSAVE_FORMAT XMM_SAVE_AREA32
, *PXMM_SAVE_AREA32
;
1250 typedef struct DECLSPEC_ALIGN(16) _AMD64_CONTEXT
{
1251 DWORD64 P1Home
; /* 000 */
1252 DWORD64 P2Home
; /* 008 */
1253 DWORD64 P3Home
; /* 010 */
1254 DWORD64 P4Home
; /* 018 */
1255 DWORD64 P5Home
; /* 020 */
1256 DWORD64 P6Home
; /* 028 */
1259 DWORD ContextFlags
; /* 030 */
1260 DWORD MxCsr
; /* 034 */
1263 WORD SegCs
; /* 038 */
1264 WORD SegDs
; /* 03a */
1265 WORD SegEs
; /* 03c */
1266 WORD SegFs
; /* 03e */
1267 WORD SegGs
; /* 040 */
1268 WORD SegSs
; /* 042 */
1269 DWORD EFlags
; /* 044 */
1272 DWORD64 Dr0
; /* 048 */
1273 DWORD64 Dr1
; /* 050 */
1274 DWORD64 Dr2
; /* 058 */
1275 DWORD64 Dr3
; /* 060 */
1276 DWORD64 Dr6
; /* 068 */
1277 DWORD64 Dr7
; /* 070 */
1280 DWORD64 Rax
; /* 078 */
1281 DWORD64 Rcx
; /* 080 */
1282 DWORD64 Rdx
; /* 088 */
1283 DWORD64 Rbx
; /* 090 */
1284 DWORD64 Rsp
; /* 098 */
1285 DWORD64 Rbp
; /* 0a0 */
1286 DWORD64 Rsi
; /* 0a8 */
1287 DWORD64 Rdi
; /* 0b0 */
1288 DWORD64 R8
; /* 0b8 */
1289 DWORD64 R9
; /* 0c0 */
1290 DWORD64 R10
; /* 0c8 */
1291 DWORD64 R11
; /* 0d0 */
1292 DWORD64 R12
; /* 0d8 */
1293 DWORD64 R13
; /* 0e0 */
1294 DWORD64 R14
; /* 0e8 */
1295 DWORD64 R15
; /* 0f0 */
1298 DWORD64 Rip
; /* 0f8 */
1300 /* Floating point */
1302 XMM_SAVE_AREA32 FltSave
; /* 100 */
1304 M128A Header
[2]; /* 100 */
1305 M128A Legacy
[8]; /* 120 */
1306 M128A Xmm0
; /* 1a0 */
1307 M128A Xmm1
; /* 1b0 */
1308 M128A Xmm2
; /* 1c0 */
1309 M128A Xmm3
; /* 1d0 */
1310 M128A Xmm4
; /* 1e0 */
1311 M128A Xmm5
; /* 1f0 */
1312 M128A Xmm6
; /* 200 */
1313 M128A Xmm7
; /* 210 */
1314 M128A Xmm8
; /* 220 */
1315 M128A Xmm9
; /* 230 */
1316 M128A Xmm10
; /* 240 */
1317 M128A Xmm11
; /* 250 */
1318 M128A Xmm12
; /* 260 */
1319 M128A Xmm13
; /* 270 */
1320 M128A Xmm14
; /* 280 */
1321 M128A Xmm15
; /* 290 */
1326 M128A VectorRegister
[26]; /* 300 */
1327 DWORD64 VectorControl
; /* 4a0 */
1330 DWORD64 DebugControl
; /* 4a8 */
1331 DWORD64 LastBranchToRip
; /* 4b0 */
1332 DWORD64 LastBranchFromRip
; /* 4b8 */
1333 DWORD64 LastExceptionToRip
; /* 4c0 */
1334 DWORD64 LastExceptionFromRip
; /* 4c8 */
1339 #define CONTEXT_CONTROL CONTEXT_AMD64_CONTROL
1340 #define CONTEXT_INTEGER CONTEXT_AMD64_INTEGER
1341 #define CONTEXT_SEGMENTS CONTEXT_AMD64_SEGMENTS
1342 #define CONTEXT_FLOATING_POINT CONTEXT_AMD64_FLOATING_POINT
1343 #define CONTEXT_DEBUG_REGISTERS CONTEXT_AMD64_DEBUG_REGISTERS
1344 #define CONTEXT_XSTATE CONTEXT_AMD64_XSTATE
1345 #define CONTEXT_FULL CONTEXT_AMD64_FULL
1346 #define CONTEXT_ALL CONTEXT_AMD64_ALL
1348 typedef AMD64_CONTEXT CONTEXT
, *PCONTEXT
;
1349 typedef AMD64_RUNTIME_FUNCTION RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1351 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1355 PM128A FloatingContext
[16];
1379 PULONG64 IntegerContext
[16];
1400 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1402 #endif /* __x86_64__ */
1404 #define XSTATE_LEGACY_FLOATING_POINT 0
1405 #define XSTATE_LEGACY_SSE 1
1406 #define XSTATE_GSSE 2
1407 #define XSTATE_AVX XSTATE_GSSE
1408 #define XSTATE_MPX_BNDREGS 3
1409 #define XSTATE_MPX_BNDCSR 4
1410 #define XSTATE_AVX512_KMASK 5
1411 #define XSTATE_AVX512_ZMM_H 6
1412 #define XSTATE_AVX512_ZMM 7
1413 #define XSTATE_IPT 8
1414 #define XSTATE_CET_U 11
1415 #define XSTATE_LWP 62
1416 #define MAXIMUM_XSTATE_FEATURES 64
1418 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1 << XSTATE_LEGACY_FLOATING_POINT)
1419 #define XSTATE_MASK_LEGACY_SSE (1 << XSTATE_LEGACY_SSE)
1420 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1421 #define XSTATE_MASK_GSSE (1 << XSTATE_GSSE)
1423 typedef struct _XSTATE_FEATURE
1427 } XSTATE_FEATURE
, *PXSTATE_FEATURE
;
1429 typedef struct _XSTATE_CONFIGURATION
1431 ULONG64 EnabledFeatures
;
1432 ULONG64 EnabledVolatileFeatures
;
1434 ULONG OptimizedSave
:1;
1435 ULONG CompactionEnabled
:1;
1436 XSTATE_FEATURE Features
[MAXIMUM_XSTATE_FEATURES
];
1438 ULONG64 EnabledSupervisorFeatures
;
1439 ULONG64 AlignedFeatures
;
1440 ULONG AllFeatureSize
;
1441 ULONG AllFeatures
[MAXIMUM_XSTATE_FEATURES
];
1442 ULONG64 EnabledUserVisibleSupervisorFeatures
;
1443 } XSTATE_CONFIGURATION
, *PXSTATE_CONFIGURATION
;
1445 typedef struct _YMMCONTEXT
1464 YMMCONTEXT
, *PYMMCONTEXT
;
1466 typedef struct _XSTATE
1469 ULONG64 CompactionMask
;
1470 ULONG64 Reserved
[6];
1471 YMMCONTEXT YmmContext
;
1474 typedef struct _CONTEXT_CHUNK
1478 } CONTEXT_CHUNK
, *PCONTEXT_CHUNK
;
1480 typedef struct _CONTEXT_EX
1483 CONTEXT_CHUNK Legacy
;
1484 CONTEXT_CHUNK XState
;
1488 } CONTEXT_EX
, *PCONTEXT_EX
;
1490 #define CONTEXT_ARM 0x0200000
1491 #define CONTEXT_ARM_CONTROL (CONTEXT_ARM | 0x00000001)
1492 #define CONTEXT_ARM_INTEGER (CONTEXT_ARM | 0x00000002)
1493 #define CONTEXT_ARM_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1494 #define CONTEXT_ARM_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1495 #define CONTEXT_ARM_FULL (CONTEXT_ARM_CONTROL | CONTEXT_ARM_INTEGER)
1496 #define CONTEXT_ARM_ALL (CONTEXT_ARM_FULL | CONTEXT_ARM_FLOATING_POINT | CONTEXT_ARM_DEBUG_REGISTERS)
1498 #define ARM_MAX_BREAKPOINTS 8
1499 #define ARM_MAX_WATCHPOINTS 1
1501 typedef struct _IMAGE_ARM_RUNTIME_FUNCTION
1508 DWORD FunctionLength
: 11;
1515 DWORD StackAdjust
: 10;
1518 } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY
, *PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY
;
1520 typedef struct _ARM_NEON128
1526 typedef struct _ARM_CONTEXT
1528 ULONG ContextFlags
; /* 000 */
1529 /* CONTEXT_INTEGER */
1540 ULONG R10
; /* 02c */
1541 ULONG R11
; /* 030 */
1542 ULONG R12
; /* 034 */
1543 /* CONTEXT_CONTROL */
1547 ULONG Cpsr
; /* 044 */
1548 /* CONTEXT_FLOATING_POINT */
1549 ULONG Fpscr
; /* 048 */
1550 ULONG Padding
; /* 04c */
1556 } DUMMYUNIONNAME
; /* 050 */
1557 /* CONTEXT_DEBUG_REGISTERS */
1558 ULONG Bvr
[ARM_MAX_BREAKPOINTS
]; /* 150 */
1559 ULONG Bcr
[ARM_MAX_BREAKPOINTS
]; /* 170 */
1560 ULONG Wvr
[ARM_MAX_WATCHPOINTS
]; /* 190 */
1561 ULONG Wcr
[ARM_MAX_WATCHPOINTS
]; /* 194 */
1562 ULONG Padding2
[2]; /* 198 */
1567 #define CONTEXT_CONTROL CONTEXT_ARM_CONTROL
1568 #define CONTEXT_INTEGER CONTEXT_ARM_INTEGER
1569 #define CONTEXT_FLOATING_POINT CONTEXT_ARM_FLOATING_POINT
1570 #define CONTEXT_DEBUG_REGISTERS CONTEXT_ARM_DEBUG_REGISTERS
1571 #define CONTEXT_FULL CONTEXT_ARM_FULL
1572 #define CONTEXT_ALL CONTEXT_ARM_ALL
1574 typedef IMAGE_ARM_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1575 typedef ARM_NEON128 NEON128
, *PNEON128
;
1576 typedef ARM_CONTEXT CONTEXT
, *PCONTEXT
;
1578 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1597 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1599 #endif /* __arm__ */
1601 #define CONTEXT_ARM64 0x400000
1602 #define CONTEXT_ARM64_CONTROL (CONTEXT_ARM64 | 0x00000001)
1603 #define CONTEXT_ARM64_INTEGER (CONTEXT_ARM64 | 0x00000002)
1604 #define CONTEXT_ARM64_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1605 #define CONTEXT_ARM64_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1606 #define CONTEXT_ARM64_X18 (CONTEXT_ARM64 | 0x00000010)
1607 #define CONTEXT_ARM64_FULL (CONTEXT_ARM64_CONTROL | CONTEXT_ARM64_INTEGER | CONTEXT_ARM64_FLOATING_POINT)
1608 #define CONTEXT_ARM64_ALL (CONTEXT_ARM64_FULL | CONTEXT_ARM64_DEBUG_REGISTERS | CONTEXT_ARM64_X18)
1610 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1612 #define ARM64_MAX_BREAKPOINTS 8
1613 #define ARM64_MAX_WATCHPOINTS 2
1615 typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY
1624 DWORD FunctionLength
: 11;
1629 DWORD FrameSize
: 9;
1632 } IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY
, *PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY
;
1634 typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY ARM64_RUNTIME_FUNCTION
, *PARM64_RUNTIME_FUNCTION
;
1636 typedef union _ARM64_NT_NEON128
1647 } ARM64_NT_NEON128
, *PARM64_NT_NEON128
;
1649 typedef struct DECLSPEC_ALIGN(16) _ARM64_NT_CONTEXT
1651 ULONG ContextFlags
; /* 000 */
1652 /* CONTEXT_INTEGER */
1653 ULONG Cpsr
; /* 004 */
1658 DWORD64 X0
; /* 008 */
1659 DWORD64 X1
; /* 010 */
1660 DWORD64 X2
; /* 018 */
1661 DWORD64 X3
; /* 020 */
1662 DWORD64 X4
; /* 028 */
1663 DWORD64 X5
; /* 030 */
1664 DWORD64 X6
; /* 038 */
1665 DWORD64 X7
; /* 040 */
1666 DWORD64 X8
; /* 048 */
1667 DWORD64 X9
; /* 050 */
1668 DWORD64 X10
; /* 058 */
1669 DWORD64 X11
; /* 060 */
1670 DWORD64 X12
; /* 068 */
1671 DWORD64 X13
; /* 070 */
1672 DWORD64 X14
; /* 078 */
1673 DWORD64 X15
; /* 080 */
1674 DWORD64 X16
; /* 088 */
1675 DWORD64 X17
; /* 090 */
1676 DWORD64 X18
; /* 098 */
1677 DWORD64 X19
; /* 0a0 */
1678 DWORD64 X20
; /* 0a8 */
1679 DWORD64 X21
; /* 0b0 */
1680 DWORD64 X22
; /* 0b8 */
1681 DWORD64 X23
; /* 0c0 */
1682 DWORD64 X24
; /* 0c8 */
1683 DWORD64 X25
; /* 0d0 */
1684 DWORD64 X26
; /* 0d8 */
1685 DWORD64 X27
; /* 0e0 */
1686 DWORD64 X28
; /* 0e8 */
1687 DWORD64 Fp
; /* 0f0 */
1688 DWORD64 Lr
; /* 0f8 */
1690 DWORD64 X
[31]; /* 008 */
1692 /* CONTEXT_CONTROL */
1693 DWORD64 Sp
; /* 100 */
1694 DWORD64 Pc
; /* 108 */
1695 /* CONTEXT_FLOATING_POINT */
1696 ARM64_NT_NEON128 V
[32]; /* 110 */
1697 DWORD Fpcr
; /* 310 */
1698 DWORD Fpsr
; /* 314 */
1699 /* CONTEXT_DEBUG_REGISTERS */
1700 DWORD Bcr
[ARM64_MAX_BREAKPOINTS
]; /* 318 */
1701 DWORD64 Bvr
[ARM64_MAX_BREAKPOINTS
]; /* 338 */
1702 DWORD Wcr
[ARM64_MAX_WATCHPOINTS
]; /* 378 */
1703 DWORD64 Wvr
[ARM64_MAX_WATCHPOINTS
]; /* 380 */
1704 } ARM64_NT_CONTEXT
, *PARM64_NT_CONTEXT
;
1708 #define CONTEXT_CONTROL CONTEXT_ARM64_CONTROL
1709 #define CONTEXT_INTEGER CONTEXT_ARM64_INTEGER
1710 #define CONTEXT_FLOATING_POINT CONTEXT_ARM64_FLOATING_POINT
1711 #define CONTEXT_DEBUG_REGISTERS CONTEXT_ARM64_DEBUG_REGISTERS
1712 #define CONTEXT_FULL CONTEXT_ARM64_FULL
1713 #define CONTEXT_ALL CONTEXT_ARM64_ALL
1715 typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1716 typedef ARM64_NT_NEON128 NEON128
, *PNEON128
;
1717 typedef ARM64_NT_CONTEXT CONTEXT
, *PCONTEXT
;
1719 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1741 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1743 #endif /* __aarch64__ */
1745 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1746 #error You need to define a CONTEXT for your CPU
1749 NTSYSAPI
void WINAPI
RtlCaptureContext(CONTEXT
*);
1751 #define WOW64_CONTEXT_i386 0x00010000
1752 #define WOW64_CONTEXT_i486 0x00010000
1753 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
1754 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
1755 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
1756 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
1757 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
1758 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
1759 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
1760 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
1761 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
1762 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
1763 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
1765 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
1766 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
1767 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
1768 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
1770 #define WOW64_SIZE_OF_80387_REGISTERS 80
1771 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
1773 /* Exception definitions */
1775 #define EXCEPTION_READ_FAULT 0
1776 #define EXCEPTION_WRITE_FAULT 1
1777 #define EXCEPTION_EXECUTE_FAULT 8
1779 struct _EXCEPTION_POINTERS
;
1780 struct _EXCEPTION_RECORD
;
1782 typedef EXCEPTION_DISPOSITION WINAPI
EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD
*,PVOID
,CONTEXT
*,PVOID
);
1783 typedef EXCEPTION_ROUTINE
*PEXCEPTION_ROUTINE
;
1787 #define UNWIND_HISTORY_TABLE_SIZE 12
1789 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1792 PRUNTIME_FUNCTION FunctionEntry
;
1793 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1795 #define UNWIND_HISTORY_TABLE_NONE 0
1796 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1797 #define UNWIND_HISTORY_TABLE_LOCAL 2
1799 typedef struct _UNWIND_HISTORY_TABLE
1804 ULONG64 HighAddress
;
1805 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1806 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1808 typedef struct _DISPATCHER_CONTEXT
1812 PRUNTIME_FUNCTION FunctionEntry
;
1813 ULONG64 EstablisherFrame
;
1815 PCONTEXT ContextRecord
;
1816 PEXCEPTION_ROUTINE LanguageHandler
;
1818 PUNWIND_HISTORY_TABLE HistoryTable
;
1821 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1823 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,PVOID
);
1824 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,PVOID
);
1826 #define UNW_FLAG_NHANDLER 0
1827 #define UNW_FLAG_EHANDLER 1
1828 #define UNW_FLAG_UHANDLER 2
1829 #define UNW_FLAG_CHAININFO 4
1831 #elif defined(__arm__)
1833 #define UNWIND_HISTORY_TABLE_SIZE 12
1835 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1838 PRUNTIME_FUNCTION FunctionEntry
;
1839 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1841 typedef struct _UNWIND_HISTORY_TABLE
1850 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1851 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1853 typedef struct _DISPATCHER_CONTEXT
1857 PRUNTIME_FUNCTION FunctionEntry
;
1858 DWORD EstablisherFrame
;
1860 PCONTEXT ContextRecord
;
1861 PEXCEPTION_ROUTINE LanguageHandler
;
1863 PUNWIND_HISTORY_TABLE HistoryTable
;
1865 BOOLEAN ControlPcIsUnwound
;
1866 PBYTE NonVolatileRegisters
;
1868 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1870 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD
);
1871 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD
);
1873 #define UNW_FLAG_NHANDLER 0
1874 #define UNW_FLAG_EHANDLER 1
1875 #define UNW_FLAG_UHANDLER 2
1877 #elif defined(__aarch64__)
1879 #define UNWIND_HISTORY_TABLE_SIZE 12
1881 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1884 PRUNTIME_FUNCTION FunctionEntry
;
1885 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1887 typedef struct _UNWIND_HISTORY_TABLE
1895 DWORD64 HighAddress
;
1896 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1897 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1899 typedef struct _DISPATCHER_CONTEXT
1901 ULONG_PTR ControlPc
;
1902 ULONG_PTR ImageBase
;
1903 PRUNTIME_FUNCTION FunctionEntry
;
1904 ULONG_PTR EstablisherFrame
;
1906 PCONTEXT ContextRecord
;
1907 PEXCEPTION_ROUTINE LanguageHandler
;
1909 PUNWIND_HISTORY_TABLE HistoryTable
;
1911 BOOLEAN ControlPcIsUnwound
;
1912 PBYTE NonVolatileRegisters
;
1913 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1915 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD64
);
1916 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD64
);
1918 #define UNW_FLAG_NHANDLER 0
1919 #define UNW_FLAG_EHANDLER 1
1920 #define UNW_FLAG_UHANDLER 2
1922 #endif /* __aarch64__ */
1924 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
1926 typedef PRUNTIME_FUNCTION (CALLBACK
*PGET_RUNTIME_FUNCTION_CALLBACK
)(DWORD_PTR
,PVOID
);
1928 NTSYSAPI BOOLEAN CDECL
RtlAddFunctionTable(RUNTIME_FUNCTION
*,DWORD
,DWORD_PTR
);
1929 NTSYSAPI DWORD WINAPI
RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION
,DWORD
,DWORD
,ULONG_PTR
,ULONG_PTR
);
1930 NTSYSAPI BOOLEAN CDECL
RtlDeleteFunctionTable(RUNTIME_FUNCTION
*);
1931 NTSYSAPI
void WINAPI
RtlDeleteGrowableFunctionTable(void*);
1932 NTSYSAPI
void WINAPI
RtlGrowFunctionTable(void*,DWORD
);
1933 NTSYSAPI BOOLEAN CDECL
RtlInstallFunctionTableCallback(DWORD_PTR
,DWORD_PTR
,DWORD
,PGET_RUNTIME_FUNCTION_CALLBACK
,PVOID
,PCWSTR
);
1934 NTSYSAPI PRUNTIME_FUNCTION WINAPI
RtlLookupFunctionEntry(DWORD_PTR
,DWORD_PTR
*,UNWIND_HISTORY_TABLE
*);
1935 NTSYSAPI
void WINAPI
RtlUnwindEx(PVOID
,PVOID
,struct _EXCEPTION_RECORD
*,PVOID
,CONTEXT
*,UNWIND_HISTORY_TABLE
*);
1936 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,ULONG_PTR
,ULONG_PTR
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,ULONG_PTR
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1943 #define PRODUCT_UNDEFINED 0x00000000
1944 #define PRODUCT_ULTIMATE 0x00000001
1945 #define PRODUCT_HOME_BASIC 0x00000002
1946 #define PRODUCT_HOME_PREMIUM 0x00000003
1947 #define PRODUCT_ENTERPRISE 0x00000004
1948 #define PRODUCT_HOME_BASIC_N 0x00000005
1949 #define PRODUCT_BUSINESS 0x00000006
1950 #define PRODUCT_STANDARD_SERVER 0x00000007
1951 #define PRODUCT_DATACENTER_SERVER 0x00000008
1952 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
1953 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
1954 #define PRODUCT_STARTER 0x0000000B
1955 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
1956 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
1957 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
1958 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
1959 #define PRODUCT_BUSINESS_N 0x00000010
1960 #define PRODUCT_WEB_SERVER 0x00000011
1961 #define PRODUCT_CLUSTER_SERVER 0x00000012
1962 #define PRODUCT_HOME_SERVER 0x00000013
1963 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
1964 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
1965 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
1966 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
1967 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
1968 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
1969 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
1970 #define PRODUCT_ENTERPRISE_N 0x0000001B
1971 #define PRODUCT_ULTIMATE_N 0x0000001C
1972 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
1973 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
1974 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
1975 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
1976 #define PRODUCT_SERVER_FOUNDATION 0x00000021
1977 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
1978 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
1979 #define PRODUCT_STANDARD_SERVER_V 0x00000024
1980 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
1981 #define PRODUCT_SERVER_V 0x00000025
1982 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
1983 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
1984 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
1985 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
1986 #define PRODUCT_HYPERV 0x0000002A
1987 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
1988 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
1989 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
1990 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
1991 #define PRODUCT_STARTER_N 0x0000002F
1992 #define PRODUCT_PROFESSIONAL 0x00000030
1993 #define PRODUCT_PROFESSIONAL_N 0x00000031
1994 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
1995 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
1996 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
1997 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
1998 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
1999 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2000 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2001 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2002 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2003 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2004 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2005 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2006 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2007 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2008 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2009 #define PRODUCT_EMBEDDED 0x00000041
2010 #define PRODUCT_STARTER_E 0x00000042
2011 #define PRODUCT_HOME_BASIC_E 0x00000043
2012 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2013 #define PRODUCT_PROFESSIONAL_E 0x00000045
2014 #define PRODUCT_ENTERPRISE_E 0x00000046
2015 #define PRODUCT_ULTIMATE_E 0x00000047
2016 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2017 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2018 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2019 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2020 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2021 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2022 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2023 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2024 #define PRODUCT_THINPC 0x00000057
2025 #define PRODUCT_EMBEDDED_A 0x00000058
2026 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2027 #define PRODUCT_EMBEDDED_E 0x0000005A
2028 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2029 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2030 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2031 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2032 #define PRODUCT_CORE_ARM 0x00000061
2033 #define PRODUCT_CORE_N 0x00000062
2034 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2035 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2036 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2037 #define PRODUCT_CORE 0x00000065
2038 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2039 #define PRODUCT_MOBILE_CORE 0x00000068
2040 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2041 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2042 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2043 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2044 #define PRODUCT_NANO_SERVER 0x0000006D
2045 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2046 #define PRODUCT_CORE_CONNECTED 0x0000006F
2047 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2048 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2049 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2050 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2051 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2052 #define PRODUCT_CONNECTED_CAR 0x00000075
2053 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2054 #define PRODUCT_PPI_PRO 0x00000077
2055 #define PRODUCT_ARM64_SERVER 0x00000078
2056 #define PRODUCT_EDUCATION 0x00000079
2057 #define PRODUCT_EDUCATION_N 0x0000007A
2058 #define PRODUCT_IOTUAP 0x0000007B
2059 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2060 #define PRODUCT_ENTERPRISE_S 0x0000007D
2061 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2062 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2063 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2064 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2065 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2066 #define PRODUCT_UNLICENSED 0xABCDABCD
2073 #define MAKELCID(l, s) (MAKELONG(l, s))
2075 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2076 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2077 #define SUBLANGID(l) ((WORD)(l) >> 10)
2079 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2080 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2082 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2083 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2084 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2085 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2086 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2087 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2088 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2089 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2090 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2091 #define LOCALE_NAME_MAX_LENGTH 85
2094 #define UNREFERENCED_PARAMETER(u) (void)(u)
2095 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2096 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2102 * Definitions for IsTextUnicode()
2105 #define IS_TEXT_UNICODE_ASCII16 0x0001
2106 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2107 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2108 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2109 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2110 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2111 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2112 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2113 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2114 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2115 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2116 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2117 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2118 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2119 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2120 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2122 #define MAXIMUM_WAIT_OBJECTS 64
2123 #define MAXIMUM_SUSPEND_COUNT 127
2125 #define WT_EXECUTEDEFAULT 0x00
2126 #define WT_EXECUTEINIOTHREAD 0x01
2127 #define WT_EXECUTEINUITHREAD 0x02
2128 #define WT_EXECUTEINWAITTHREAD 0x04
2129 #define WT_EXECUTEONLYONCE 0x08
2130 #define WT_EXECUTELONGFUNCTION 0x10
2131 #define WT_EXECUTEINTIMERTHREAD 0x20
2132 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2133 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2134 #define WT_EXECUTEINLONGTHREAD 0x10
2135 #define WT_EXECUTEDELETEWAIT 0x08
2136 #define WT_TRANSFER_IMPERSONATION 0x0100
2139 #define EXCEPTION_CONTINUABLE 0
2140 #define EXCEPTION_NONCONTINUABLE 0x01
2143 * The exception record used by Win32 to give additional information
2144 * about exception to exception handlers.
2147 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2149 typedef struct _EXCEPTION_RECORD
2151 DWORD ExceptionCode
;
2152 DWORD ExceptionFlags
;
2153 struct _EXCEPTION_RECORD
*ExceptionRecord
;
2155 PVOID ExceptionAddress
;
2156 DWORD NumberParameters
;
2157 ULONG_PTR ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2158 } EXCEPTION_RECORD
, *PEXCEPTION_RECORD
;
2160 typedef struct _EXCEPTION_RECORD32
2162 DWORD ExceptionCode
;
2163 DWORD ExceptionFlags
;
2164 DWORD ExceptionRecord
;
2165 DWORD ExceptionAddress
;
2166 DWORD NumberParameters
;
2167 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2168 } EXCEPTION_RECORD32
, *PEXCEPTION_RECORD32
;
2170 typedef struct _EXCEPTION_RECORD64
2172 DWORD ExceptionCode
;
2173 DWORD ExceptionFlags
;
2174 DWORD64 ExceptionRecord
;
2175 DWORD64 ExceptionAddress
;
2176 DWORD NumberParameters
;
2177 DWORD __unusedAlignment
;
2178 DWORD64 ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2179 } EXCEPTION_RECORD64
, *PEXCEPTION_RECORD64
;
2182 * The exception pointers structure passed to exception filters
2183 * in except() and the UnhandledExceptionFilter().
2186 typedef struct _EXCEPTION_POINTERS
2188 PEXCEPTION_RECORD ExceptionRecord
;
2189 PCONTEXT ContextRecord
;
2190 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
;
2194 * The exception frame, used for registering exception handlers
2195 * Win32 cares only about this, but compilers generally emit
2196 * larger exception frames for their own use.
2199 struct _EXCEPTION_REGISTRATION_RECORD
;
2201 typedef DWORD (CDECL
*PEXCEPTION_HANDLER
)(PEXCEPTION_RECORD
,struct _EXCEPTION_REGISTRATION_RECORD
*,
2202 PCONTEXT
,struct _EXCEPTION_REGISTRATION_RECORD
**);
2204 typedef struct _EXCEPTION_REGISTRATION_RECORD
2206 struct _EXCEPTION_REGISTRATION_RECORD
*Prev
;
2207 PEXCEPTION_HANDLER Handler
;
2208 } EXCEPTION_REGISTRATION_RECORD
;
2211 * function pointer to an exception filter
2214 typedef LONG (CALLBACK
*PVECTORED_EXCEPTION_HANDLER
)(PEXCEPTION_POINTERS ExceptionInfo
);
2216 typedef struct _NT_TIB
2218 struct _EXCEPTION_REGISTRATION_RECORD
*ExceptionList
;
2226 PVOID ArbitraryUserPointer
;
2227 struct _NT_TIB
*Self
;
2232 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2233 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2236 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb
));
2239 #elif defined(__i386__) && defined(_MSC_VER)
2240 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2243 __asm mov eax
, fs
:[0x18];
2247 #elif defined(__x86_64__) && defined(__GNUC__)
2248 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2251 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb
));
2254 #elif defined(__x86_64__) && defined(_MSC_VER)
2255 unsigned __int64
__readgsqword(unsigned long);
2256 #pragma intrinsic(__readgsqword)
2257 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2259 return (struct _TEB
*)__readgsqword(FIELD_OFFSET(NT_TIB
, Self
));
2261 #elif defined(__arm__) && defined(__GNUC__)
2262 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2265 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb
));
2268 #elif defined(__arm__) && defined(_MSC_VER)
2269 #pragma intrinsic(_MoveFromCoprocessor)
2270 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2272 return (struct _TEB
*)(ULONG_PTR
)_MoveFromCoprocessor(15, 0, 13, 0, 2);
2275 extern struct _TEB
* WINAPI
NtCurrentTeb(void);
2278 #ifdef NONAMELESSUNION
2279 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2281 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2283 #define GetFiberData() (*(void **)GetCurrentFiber())
2285 #define TLS_MINIMUM_AVAILABLE 64
2287 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2289 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2290 #define IO_REPARSE_TAG_RESERVED_ONE 1
2291 #define IO_REPARSE_TAG_RESERVED_TWO 2
2293 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2295 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2296 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2297 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2298 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2299 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2300 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2301 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2302 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2303 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2304 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2305 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2306 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2307 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2308 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2309 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2310 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2311 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2312 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2313 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2314 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2315 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2316 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2317 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2318 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2319 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2320 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2321 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2322 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2323 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2324 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2325 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2326 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2327 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2328 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2329 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2330 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2331 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2332 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2333 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2334 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2335 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2336 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2337 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2340 * File formats definitions
2343 #include <pshpack2.h>
2344 typedef struct _IMAGE_DOS_HEADER
{
2345 WORD e_magic
; /* 00: MZ Header signature */
2346 WORD e_cblp
; /* 02: Bytes on last page of file */
2347 WORD e_cp
; /* 04: Pages in file */
2348 WORD e_crlc
; /* 06: Relocations */
2349 WORD e_cparhdr
; /* 08: Size of header in paragraphs */
2350 WORD e_minalloc
; /* 0a: Minimum extra paragraphs needed */
2351 WORD e_maxalloc
; /* 0c: Maximum extra paragraphs needed */
2352 WORD e_ss
; /* 0e: Initial (relative) SS value */
2353 WORD e_sp
; /* 10: Initial SP value */
2354 WORD e_csum
; /* 12: Checksum */
2355 WORD e_ip
; /* 14: Initial IP value */
2356 WORD e_cs
; /* 16: Initial (relative) CS value */
2357 WORD e_lfarlc
; /* 18: File address of relocation table */
2358 WORD e_ovno
; /* 1a: Overlay number */
2359 WORD e_res
[4]; /* 1c: Reserved words */
2360 WORD e_oemid
; /* 24: OEM identifier (for e_oeminfo) */
2361 WORD e_oeminfo
; /* 26: OEM information; e_oemid specific */
2362 WORD e_res2
[10]; /* 28: Reserved words */
2363 DWORD e_lfanew
; /* 3c: Offset to extended header */
2364 } IMAGE_DOS_HEADER
, *PIMAGE_DOS_HEADER
;
2365 #include <poppack.h>
2367 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2368 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2369 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2370 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2371 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2372 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2375 * This is the Windows executable (NE) header.
2376 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2378 #include <pshpack2.h>
2381 WORD ne_magic
; /* 00 NE signature 'NE' */
2382 BYTE ne_ver
; /* 02 Linker version number */
2383 BYTE ne_rev
; /* 03 Linker revision number */
2384 WORD ne_enttab
; /* 04 Offset to entry table relative to NE */
2385 WORD ne_cbenttab
; /* 06 Length of entry table in bytes */
2386 LONG ne_crc
; /* 08 Checksum */
2387 WORD ne_flags
; /* 0c Flags about segments in this file */
2388 WORD ne_autodata
; /* 0e Automatic data segment number */
2389 WORD ne_heap
; /* 10 Initial size of local heap */
2390 WORD ne_stack
; /* 12 Initial size of stack */
2391 DWORD ne_csip
; /* 14 Initial CS:IP */
2392 DWORD ne_sssp
; /* 18 Initial SS:SP */
2393 WORD ne_cseg
; /* 1c # of entries in segment table */
2394 WORD ne_cmod
; /* 1e # of entries in module reference tab. */
2395 WORD ne_cbnrestab
; /* 20 Length of nonresident-name table */
2396 WORD ne_segtab
; /* 22 Offset to segment table */
2397 WORD ne_rsrctab
; /* 24 Offset to resource table */
2398 WORD ne_restab
; /* 26 Offset to resident-name table */
2399 WORD ne_modtab
; /* 28 Offset to module reference table */
2400 WORD ne_imptab
; /* 2a Offset to imported name table */
2401 DWORD ne_nrestab
; /* 2c Offset to nonresident-name table */
2402 WORD ne_cmovent
; /* 30 # of movable entry points */
2403 WORD ne_align
; /* 32 Logical sector alignment shift count */
2404 WORD ne_cres
; /* 34 # of resource segments */
2405 BYTE ne_exetyp
; /* 36 Flags indicating target OS */
2406 BYTE ne_flagsothers
; /* 37 Additional information flags */
2407 WORD ne_pretthunks
; /* 38 Offset to return thunks */
2408 WORD ne_psegrefbytes
; /* 3a Offset to segment ref. bytes */
2409 WORD ne_swaparea
; /* 3c Reserved by Microsoft */
2410 WORD ne_expver
; /* 3e Expected Windows version number */
2411 } IMAGE_OS2_HEADER
, *PIMAGE_OS2_HEADER
;
2412 #include <poppack.h>
2414 #include <pshpack2.h>
2415 typedef struct _IMAGE_VXD_HEADER
{
2430 DWORD e32_lastpagesize
;
2431 DWORD e32_fixupsize
;
2448 DWORD e32_impmodcnt
;
2454 DWORD e32_cbnrestab
;
2457 DWORD e32_debuginfo
;
2459 DWORD e32_instpreload
;
2460 DWORD e32_instdemand
;
2463 DWORD e32_winresoff
;
2464 DWORD e32_winreslen
;
2467 } IMAGE_VXD_HEADER
, *PIMAGE_VXD_HEADER
;
2468 #include <poppack.h>
2470 /* These defines describe the meanings of the bits in the Characteristics
2473 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2474 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2475 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2476 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2477 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2478 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2479 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2480 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2481 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2482 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2483 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2484 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2485 #define IMAGE_FILE_SYSTEM 0x1000
2486 #define IMAGE_FILE_DLL 0x2000
2487 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2488 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2490 /* These are the settings of the Machine field. */
2491 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2492 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
2493 #define IMAGE_FILE_MACHINE_I860 0x014d
2494 #define IMAGE_FILE_MACHINE_I386 0x014c
2495 #define IMAGE_FILE_MACHINE_R3000 0x0162
2496 #define IMAGE_FILE_MACHINE_R4000 0x0166
2497 #define IMAGE_FILE_MACHINE_R10000 0x0168
2498 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2499 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2500 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2501 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2502 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2503 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2504 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2505 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2506 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2507 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2508 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2509 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2510 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2511 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2512 #define IMAGE_FILE_MACHINE_IA64 0x0200
2513 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2514 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2515 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2516 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2517 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2518 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2519 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2520 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2521 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2522 #define IMAGE_FILE_MACHINE_M32R 0x9041
2523 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2525 #define IMAGE_SIZEOF_FILE_HEADER 20
2526 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2527 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2528 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2529 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2530 #define IMAGE_SIZEOF_SHORT_NAME 8
2531 #define IMAGE_SIZEOF_SECTION_HEADER 40
2532 #define IMAGE_SIZEOF_SYMBOL 18
2533 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2534 #define IMAGE_SIZEOF_RELOCATION 10
2535 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2536 #define IMAGE_SIZEOF_LINENUMBER 6
2537 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2539 /* Possible Magic values */
2540 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2541 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2542 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2545 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2546 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2548 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2549 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2552 /* These are indexes into the DataDirectory array */
2553 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2554 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2555 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2556 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2557 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2558 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2559 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2560 #define IMAGE_FILE_DESCRIPTION_STRING 7
2561 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2562 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2563 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2565 /* Directory Entries, indices into the DataDirectory array */
2567 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2568 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2569 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2570 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2571 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2572 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2573 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2574 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2575 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2576 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2577 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2578 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2579 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2580 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2581 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2583 /* Subsystem Values */
2585 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2586 #define IMAGE_SUBSYSTEM_NATIVE 1
2587 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2588 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2589 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2590 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2591 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2592 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2593 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2594 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2595 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2596 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2597 #define IMAGE_SUBSYSTEM_XBOX 14
2598 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2600 /* DLL Characteristics */
2601 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
2602 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2603 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2604 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2605 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2606 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2607 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2608 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
2609 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2610 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
2611 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2613 typedef struct _IMAGE_FILE_HEADER
{
2615 WORD NumberOfSections
;
2616 DWORD TimeDateStamp
;
2617 DWORD PointerToSymbolTable
;
2618 DWORD NumberOfSymbols
;
2619 WORD SizeOfOptionalHeader
;
2620 WORD Characteristics
;
2621 } IMAGE_FILE_HEADER
, *PIMAGE_FILE_HEADER
;
2623 typedef struct _IMAGE_DATA_DIRECTORY
{
2624 DWORD VirtualAddress
;
2626 } IMAGE_DATA_DIRECTORY
, *PIMAGE_DATA_DIRECTORY
;
2628 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2630 typedef struct _IMAGE_OPTIONAL_HEADER64
{
2631 WORD Magic
; /* 0x20b */
2632 BYTE MajorLinkerVersion
;
2633 BYTE MinorLinkerVersion
;
2635 DWORD SizeOfInitializedData
;
2636 DWORD SizeOfUninitializedData
;
2637 DWORD AddressOfEntryPoint
;
2639 ULONGLONG ImageBase
;
2640 DWORD SectionAlignment
;
2641 DWORD FileAlignment
;
2642 WORD MajorOperatingSystemVersion
;
2643 WORD MinorOperatingSystemVersion
;
2644 WORD MajorImageVersion
;
2645 WORD MinorImageVersion
;
2646 WORD MajorSubsystemVersion
;
2647 WORD MinorSubsystemVersion
;
2648 DWORD Win32VersionValue
;
2650 DWORD SizeOfHeaders
;
2653 WORD DllCharacteristics
;
2654 ULONGLONG SizeOfStackReserve
;
2655 ULONGLONG SizeOfStackCommit
;
2656 ULONGLONG SizeOfHeapReserve
;
2657 ULONGLONG SizeOfHeapCommit
;
2659 DWORD NumberOfRvaAndSizes
;
2660 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
];
2661 } IMAGE_OPTIONAL_HEADER64
, *PIMAGE_OPTIONAL_HEADER64
;
2663 typedef struct _IMAGE_NT_HEADERS64
{
2665 IMAGE_FILE_HEADER FileHeader
;
2666 IMAGE_OPTIONAL_HEADER64 OptionalHeader
;
2667 } IMAGE_NT_HEADERS64
, *PIMAGE_NT_HEADERS64
;
2669 typedef struct _IMAGE_OPTIONAL_HEADER
{
2671 /* Standard fields */
2673 WORD Magic
; /* 0x10b or 0x107 */ /* 0x00 */
2674 BYTE MajorLinkerVersion
;
2675 BYTE MinorLinkerVersion
;
2677 DWORD SizeOfInitializedData
;
2678 DWORD SizeOfUninitializedData
;
2679 DWORD AddressOfEntryPoint
; /* 0x10 */
2683 /* NT additional fields */
2686 DWORD SectionAlignment
; /* 0x20 */
2687 DWORD FileAlignment
;
2688 WORD MajorOperatingSystemVersion
;
2689 WORD MinorOperatingSystemVersion
;
2690 WORD MajorImageVersion
;
2691 WORD MinorImageVersion
;
2692 WORD MajorSubsystemVersion
; /* 0x30 */
2693 WORD MinorSubsystemVersion
;
2694 DWORD Win32VersionValue
;
2696 DWORD SizeOfHeaders
;
2697 DWORD CheckSum
; /* 0x40 */
2699 WORD DllCharacteristics
;
2700 DWORD SizeOfStackReserve
;
2701 DWORD SizeOfStackCommit
;
2702 DWORD SizeOfHeapReserve
; /* 0x50 */
2703 DWORD SizeOfHeapCommit
;
2705 DWORD NumberOfRvaAndSizes
;
2706 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
]; /* 0x60 */
2708 } IMAGE_OPTIONAL_HEADER32
, *PIMAGE_OPTIONAL_HEADER32
;
2710 typedef struct _IMAGE_NT_HEADERS
{
2711 DWORD Signature
; /* "PE"\0\0 */ /* 0x00 */
2712 IMAGE_FILE_HEADER FileHeader
; /* 0x04 */
2713 IMAGE_OPTIONAL_HEADER32 OptionalHeader
; /* 0x18 */
2714 } IMAGE_NT_HEADERS32
, *PIMAGE_NT_HEADERS32
;
2717 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS
;
2718 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS
;
2719 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER
;
2720 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER
;
2722 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS
;
2723 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
;
2724 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
;
2725 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER
;
2728 #define IMAGE_SIZEOF_SHORT_NAME 8
2730 typedef struct _IMAGE_SECTION_HEADER
{
2731 BYTE Name
[IMAGE_SIZEOF_SHORT_NAME
];
2733 DWORD PhysicalAddress
;
2736 DWORD VirtualAddress
;
2737 DWORD SizeOfRawData
;
2738 DWORD PointerToRawData
;
2739 DWORD PointerToRelocations
;
2740 DWORD PointerToLinenumbers
;
2741 WORD NumberOfRelocations
;
2742 WORD NumberOfLinenumbers
;
2743 DWORD Characteristics
;
2744 } IMAGE_SECTION_HEADER
, *PIMAGE_SECTION_HEADER
;
2746 #define IMAGE_SIZEOF_SECTION_HEADER 40
2748 #define IMAGE_FIRST_SECTION(ntheader) \
2749 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2750 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2752 /* These defines are for the Characteristics bitfield. */
2753 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2754 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2755 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2756 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2757 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2758 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2760 #define IMAGE_SCN_CNT_CODE 0x00000020
2761 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2762 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2764 #define IMAGE_SCN_LNK_OTHER 0x00000100
2765 #define IMAGE_SCN_LNK_INFO 0x00000200
2766 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2767 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2768 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2770 /* 0x00002000 - Reserved */
2771 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2772 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2774 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2775 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2776 #define IMAGE_SCN_MEM_16BIT 0x00020000
2777 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2778 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2780 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2781 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2782 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2783 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2784 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2785 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2786 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2787 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2788 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2789 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2790 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2791 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2792 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2793 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2794 /* 0x00F00000 - Unused */
2795 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2797 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2800 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2801 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2802 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2803 #define IMAGE_SCN_MEM_SHARED 0x10000000
2804 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2805 #define IMAGE_SCN_MEM_READ 0x40000000
2806 #define IMAGE_SCN_MEM_WRITE 0x80000000
2808 #include <pshpack2.h>
2810 typedef struct _IMAGE_SYMBOL
{
2820 SHORT SectionNumber
;
2823 BYTE NumberOfAuxSymbols
;
2825 typedef IMAGE_SYMBOL
*PIMAGE_SYMBOL
;
2827 #define IMAGE_SIZEOF_SYMBOL 18
2829 typedef struct _IMAGE_LINENUMBER
{
2831 DWORD SymbolTableIndex
;
2832 DWORD VirtualAddress
;
2836 typedef IMAGE_LINENUMBER
*PIMAGE_LINENUMBER
;
2838 #define IMAGE_SIZEOF_LINENUMBER 6
2840 typedef union _IMAGE_AUX_SYMBOL
{
2852 DWORD PointerToLinenumber
;
2853 DWORD PointerToNextFunction
;
2862 BYTE Name
[IMAGE_SIZEOF_SYMBOL
];
2866 WORD NumberOfRelocations
;
2867 WORD NumberOfLinenumbers
;
2873 typedef IMAGE_AUX_SYMBOL
*PIMAGE_AUX_SYMBOL
;
2875 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2877 #include <poppack.h>
2879 #define IMAGE_SYM_UNDEFINED (SHORT)0
2880 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2881 #define IMAGE_SYM_DEBUG (SHORT)-2
2883 #define IMAGE_SYM_TYPE_NULL 0x0000
2884 #define IMAGE_SYM_TYPE_VOID 0x0001
2885 #define IMAGE_SYM_TYPE_CHAR 0x0002
2886 #define IMAGE_SYM_TYPE_SHORT 0x0003
2887 #define IMAGE_SYM_TYPE_INT 0x0004
2888 #define IMAGE_SYM_TYPE_LONG 0x0005
2889 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2890 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2891 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2892 #define IMAGE_SYM_TYPE_UNION 0x0009
2893 #define IMAGE_SYM_TYPE_ENUM 0x000A
2894 #define IMAGE_SYM_TYPE_MOE 0x000B
2895 #define IMAGE_SYM_TYPE_BYTE 0x000C
2896 #define IMAGE_SYM_TYPE_WORD 0x000D
2897 #define IMAGE_SYM_TYPE_UINT 0x000E
2898 #define IMAGE_SYM_TYPE_DWORD 0x000F
2899 #define IMAGE_SYM_TYPE_PCODE 0x8000
2901 #define IMAGE_SYM_DTYPE_NULL 0
2902 #define IMAGE_SYM_DTYPE_POINTER 1
2903 #define IMAGE_SYM_DTYPE_FUNCTION 2
2904 #define IMAGE_SYM_DTYPE_ARRAY 3
2906 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2907 #define IMAGE_SYM_CLASS_NULL 0x0000
2908 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2909 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2910 #define IMAGE_SYM_CLASS_STATIC 0x0003
2911 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2912 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2913 #define IMAGE_SYM_CLASS_LABEL 0x0006
2914 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2915 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2916 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2917 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2918 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2919 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2920 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2921 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2922 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2923 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2924 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2925 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2927 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2928 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2929 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2930 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2931 #define IMAGE_SYM_CLASS_FILE 0x0067
2932 #define IMAGE_SYM_CLASS_SECTION 0x0068
2933 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2935 #define N_BTMASK 0x000F
2936 #define N_TMASK 0x0030
2937 #define N_TMASK1 0x00C0
2938 #define N_TMASK2 0x00F0
2942 #define BTYPE(x) ((x) & N_BTMASK)
2945 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2949 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2953 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2957 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2961 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2964 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2967 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2968 #define IMAGE_COMDAT_SELECT_ANY 2
2969 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2970 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2971 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2972 #define IMAGE_COMDAT_SELECT_LARGEST 6
2973 #define IMAGE_COMDAT_SELECT_NEWEST 7
2975 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2976 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2977 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2979 /* Export module directory */
2981 typedef struct _IMAGE_EXPORT_DIRECTORY
{
2982 DWORD Characteristics
;
2983 DWORD TimeDateStamp
;
2988 DWORD NumberOfFunctions
;
2989 DWORD NumberOfNames
;
2990 DWORD AddressOfFunctions
;
2991 DWORD AddressOfNames
;
2992 DWORD AddressOfNameOrdinals
;
2993 } IMAGE_EXPORT_DIRECTORY
,*PIMAGE_EXPORT_DIRECTORY
;
2995 /* Import name entry */
2996 typedef struct _IMAGE_IMPORT_BY_NAME
{
2999 } IMAGE_IMPORT_BY_NAME
,*PIMAGE_IMPORT_BY_NAME
;
3001 #include <pshpack8.h>
3003 typedef struct _IMAGE_THUNK_DATA64
{
3005 ULONGLONG ForwarderString
;
3008 ULONGLONG AddressOfData
;
3010 } IMAGE_THUNK_DATA64
,*PIMAGE_THUNK_DATA64
;
3011 #include <poppack.h>
3013 typedef struct _IMAGE_THUNK_DATA32
{
3015 DWORD ForwarderString
;
3018 DWORD AddressOfData
;
3020 } IMAGE_THUNK_DATA32
,*PIMAGE_THUNK_DATA32
;
3022 /* Import module directory */
3024 typedef struct _IMAGE_IMPORT_DESCRIPTOR
{
3026 DWORD Characteristics
; /* 0 for terminating null import descriptor */
3027 DWORD OriginalFirstThunk
; /* RVA to original unbound IAT */
3029 DWORD TimeDateStamp
; /* 0 if not bound,
3030 * -1 if bound, and real date\time stamp
3031 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3033 * otherwise date/time stamp of DLL bound to
3036 DWORD ForwarderChain
; /* -1 if no forwarders */
3038 /* RVA to IAT (if bound this IAT has actual addresses) */
3040 } IMAGE_IMPORT_DESCRIPTOR
,*PIMAGE_IMPORT_DESCRIPTOR
;
3042 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3043 #define IMAGE_ORDINAL_FLAG32 0x80000000
3044 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3045 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3046 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3047 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3050 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3051 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3052 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3053 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA
;
3054 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA
;
3056 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3057 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3058 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3059 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA
;
3060 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
;
3063 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3065 DWORD TimeDateStamp
;
3066 WORD OffsetModuleName
;
3067 WORD NumberOfModuleForwarderRefs
;
3068 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3069 } IMAGE_BOUND_IMPORT_DESCRIPTOR
, *PIMAGE_BOUND_IMPORT_DESCRIPTOR
;
3071 typedef struct _IMAGE_BOUND_FORWARDER_REF
3073 DWORD TimeDateStamp
;
3074 WORD OffsetModuleName
;
3076 } IMAGE_BOUND_FORWARDER_REF
, *PIMAGE_BOUND_FORWARDER_REF
;
3078 typedef struct _IMAGE_BASE_RELOCATION
3080 DWORD VirtualAddress
;
3082 /* WORD TypeOffset[1]; */
3083 } IMAGE_BASE_RELOCATION
,*PIMAGE_BASE_RELOCATION
;
3085 #include <pshpack2.h>
3087 typedef struct _IMAGE_RELOCATION
3090 DWORD VirtualAddress
;
3093 DWORD SymbolTableIndex
;
3095 } IMAGE_RELOCATION
, *PIMAGE_RELOCATION
;
3097 #include <poppack.h>
3099 #define IMAGE_SIZEOF_RELOCATION 10
3101 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3105 DWORD AllAttributes
;
3109 DWORD ReservedAttributes
:31;
3114 DWORD ModuleHandleRVA
;
3115 DWORD ImportAddressTableRVA
;
3116 DWORD ImportNameTableRVA
;
3117 DWORD BoundImportAddressTableRVA
;
3118 DWORD UnloadInformationTableRVA
;
3119 DWORD TimeDateStamp
;
3120 } IMAGE_DELAYLOAD_DESCRIPTOR
, *PIMAGE_DELAYLOAD_DESCRIPTOR
;
3121 typedef const IMAGE_DELAYLOAD_DESCRIPTOR
*PCIMAGE_DELAYLOAD_DESCRIPTOR
;
3123 /* generic relocation types */
3124 #define IMAGE_REL_BASED_ABSOLUTE 0
3125 #define IMAGE_REL_BASED_HIGH 1
3126 #define IMAGE_REL_BASED_LOW 2
3127 #define IMAGE_REL_BASED_HIGHLOW 3
3128 #define IMAGE_REL_BASED_HIGHADJ 4
3129 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3130 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3131 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3132 #define IMAGE_REL_BASED_SECTION 6
3133 #define IMAGE_REL_BASED_REL 7
3134 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3135 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3136 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3137 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3138 #define IMAGE_REL_BASED_DIR64 10
3139 #define IMAGE_REL_BASED_HIGH3ADJ 11
3141 /* I386 relocation types */
3142 #define IMAGE_REL_I386_ABSOLUTE 0
3143 #define IMAGE_REL_I386_DIR16 1
3144 #define IMAGE_REL_I386_REL16 2
3145 #define IMAGE_REL_I386_DIR32 6
3146 #define IMAGE_REL_I386_DIR32NB 7
3147 #define IMAGE_REL_I386_SEG12 9
3148 #define IMAGE_REL_I386_SECTION 10
3149 #define IMAGE_REL_I386_SECREL 11
3150 #define IMAGE_REL_I386_TOKEN 12
3151 #define IMAGE_REL_I386_SECREL7 13
3152 #define IMAGE_REL_I386_REL32 20
3154 /* MIPS relocation types */
3155 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3156 #define IMAGE_REL_MIPS_REFHALF 0x0001
3157 #define IMAGE_REL_MIPS_REFWORD 0x0002
3158 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3159 #define IMAGE_REL_MIPS_REFHI 0x0004
3160 #define IMAGE_REL_MIPS_REFLO 0x0005
3161 #define IMAGE_REL_MIPS_GPREL 0x0006
3162 #define IMAGE_REL_MIPS_LITERAL 0x0007
3163 #define IMAGE_REL_MIPS_SECTION 0x000A
3164 #define IMAGE_REL_MIPS_SECREL 0x000B
3165 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3166 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3167 #define IMAGE_REL_MIPS_TOKEN 0x000E
3168 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3169 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3170 #define IMAGE_REL_MIPS_PAIR 0x0025
3172 /* ALPHA relocation types */
3173 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3174 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3175 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3176 #define IMAGE_REL_ALPHA_GPREL 0x0003
3177 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3178 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3179 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3180 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3181 #define IMAGE_REL_ALPHA_HINT 0x0008
3182 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3183 #define IMAGE_REL_ALPHA_REFHI 0x000A
3184 #define IMAGE_REL_ALPHA_REFLO 0x000B
3185 #define IMAGE_REL_ALPHA_PAIR 0x000C
3186 #define IMAGE_REL_ALPHA_MATCH 0x000D
3187 #define IMAGE_REL_ALPHA_SECTION 0x000E
3188 #define IMAGE_REL_ALPHA_SECREL 0x000F
3189 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3190 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3191 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3192 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3193 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3194 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3195 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3196 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3198 /* PowerPC relocation types */
3199 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3200 #define IMAGE_REL_PPC_ADDR64 0x0001
3201 #define IMAGE_REL_PPC_ADDR 0x0002
3202 #define IMAGE_REL_PPC_ADDR24 0x0003
3203 #define IMAGE_REL_PPC_ADDR16 0x0004
3204 #define IMAGE_REL_PPC_ADDR14 0x0005
3205 #define IMAGE_REL_PPC_REL24 0x0006
3206 #define IMAGE_REL_PPC_REL14 0x0007
3207 #define IMAGE_REL_PPC_TOCREL16 0x0008
3208 #define IMAGE_REL_PPC_TOCREL14 0x0009
3209 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3210 #define IMAGE_REL_PPC_SECREL 0x000B
3211 #define IMAGE_REL_PPC_SECTION 0x000C
3212 #define IMAGE_REL_PPC_IFGLUE 0x000D
3213 #define IMAGE_REL_PPC_IMGLUE 0x000E
3214 #define IMAGE_REL_PPC_SECREL16 0x000F
3215 #define IMAGE_REL_PPC_REFHI 0x0010
3216 #define IMAGE_REL_PPC_REFLO 0x0011
3217 #define IMAGE_REL_PPC_PAIR 0x0012
3218 #define IMAGE_REL_PPC_SECRELLO 0x0013
3219 #define IMAGE_REL_PPC_SECRELHI 0x0014
3220 #define IMAGE_REL_PPC_GPREL 0x0015
3221 #define IMAGE_REL_PPC_TOKEN 0x0016
3222 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3224 #define IMAGE_REL_PPC_NEG 0x0100
3225 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3226 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3227 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3229 /* SH3 relocation types */
3230 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3231 #define IMAGE_REL_SH3_DIRECT16 0x0001
3232 #define IMAGE_REL_SH3_DIRECT 0x0002
3233 #define IMAGE_REL_SH3_DIRECT8 0x0003
3234 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3235 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3236 #define IMAGE_REL_SH3_DIRECT4 0x0006
3237 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3238 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3239 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3240 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3241 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3242 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3243 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3244 #define IMAGE_REL_SH3_SECTION 0x000E
3245 #define IMAGE_REL_SH3_SECREL 0x000F
3246 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3247 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3248 #define IMAGE_REL_SH3_TOKEN 0x0012
3250 /* ARM relocation types */
3251 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3252 #define IMAGE_REL_ARM_ADDR 0x0001
3253 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3254 #define IMAGE_REL_ARM_BRANCH24 0x0003
3255 #define IMAGE_REL_ARM_BRANCH11 0x0004
3256 #define IMAGE_REL_ARM_TOKEN 0x0005
3257 #define IMAGE_REL_ARM_GPREL12 0x0006
3258 #define IMAGE_REL_ARM_GPREL7 0x0007
3259 #define IMAGE_REL_ARM_BLX24 0x0008
3260 #define IMAGE_REL_ARM_BLX11 0x0009
3261 #define IMAGE_REL_ARM_SECTION 0x000E
3262 #define IMAGE_REL_ARM_SECREL 0x000F
3263 #define IMAGE_REL_ARM_MOV32A 0x0010
3264 #define IMAGE_REL_ARM_MOV32T 0x0011
3265 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3266 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3267 #define IMAGE_REL_ARM_BLX23T 0x0015
3269 /* ARM64 relocation types */
3270 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3271 #define IMAGE_REL_ARM64_ADDR32 0x0001
3272 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3273 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3274 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3275 #define IMAGE_REL_ARM64_REL21 0x0005
3276 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3277 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3278 #define IMAGE_REL_ARM64_SECREL 0x0008
3279 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3280 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3281 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3282 #define IMAGE_REL_ARM64_TOKEN 0x000C
3283 #define IMAGE_REL_ARM64_SECTION 0x000D
3284 #define IMAGE_REL_ARM64_ADDR64 0x000E
3285 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3287 /* IA64 relocation types */
3288 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3289 #define IMAGE_REL_IA64_IMM14 0x0001
3290 #define IMAGE_REL_IA64_IMM22 0x0002
3291 #define IMAGE_REL_IA64_IMM64 0x0003
3292 #define IMAGE_REL_IA64_DIR 0x0004
3293 #define IMAGE_REL_IA64_DIR64 0x0005
3294 #define IMAGE_REL_IA64_PCREL21B 0x0006
3295 #define IMAGE_REL_IA64_PCREL21M 0x0007
3296 #define IMAGE_REL_IA64_PCREL21F 0x0008
3297 #define IMAGE_REL_IA64_GPREL22 0x0009
3298 #define IMAGE_REL_IA64_LTOFF22 0x000A
3299 #define IMAGE_REL_IA64_SECTION 0x000B
3300 #define IMAGE_REL_IA64_SECREL22 0x000C
3301 #define IMAGE_REL_IA64_SECREL64I 0x000D
3302 #define IMAGE_REL_IA64_SECREL 0x000E
3303 #define IMAGE_REL_IA64_LTOFF64 0x000F
3304 #define IMAGE_REL_IA64_DIR32NB 0x0010
3305 #define IMAGE_REL_IA64_SREL14 0x0011
3306 #define IMAGE_REL_IA64_SREL22 0x0012
3307 #define IMAGE_REL_IA64_SREL32 0x0013
3308 #define IMAGE_REL_IA64_UREL32 0x0014
3309 #define IMAGE_REL_IA64_PCREL60X 0x0015
3310 #define IMAGE_REL_IA64_PCREL60B 0x0016
3311 #define IMAGE_REL_IA64_PCREL60F 0x0017
3312 #define IMAGE_REL_IA64_PCREL60I 0x0018
3313 #define IMAGE_REL_IA64_PCREL60M 0x0019
3314 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3315 #define IMAGE_REL_IA64_TOKEN 0x001B
3316 #define IMAGE_REL_IA64_GPREL32 0x001C
3317 #define IMAGE_REL_IA64_ADDEND 0x001F
3319 /* AMD64 relocation types */
3320 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3321 #define IMAGE_REL_AMD64_ADDR64 0x0001
3322 #define IMAGE_REL_AMD64_ADDR32 0x0002
3323 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3324 #define IMAGE_REL_AMD64_REL32 0x0004
3325 #define IMAGE_REL_AMD64_REL32_1 0x0005
3326 #define IMAGE_REL_AMD64_REL32_2 0x0006
3327 #define IMAGE_REL_AMD64_REL32_3 0x0007
3328 #define IMAGE_REL_AMD64_REL32_4 0x0008
3329 #define IMAGE_REL_AMD64_REL32_5 0x0009
3330 #define IMAGE_REL_AMD64_SECTION 0x000A
3331 #define IMAGE_REL_AMD64_SECREL 0x000B
3332 #define IMAGE_REL_AMD64_SECREL7 0x000C
3333 #define IMAGE_REL_AMD64_TOKEN 0x000D
3334 #define IMAGE_REL_AMD64_SREL32 0x000E
3335 #define IMAGE_REL_AMD64_PAIR 0x000F
3336 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3338 /* archive format */
3340 #define IMAGE_ARCHIVE_START_SIZE 8
3341 #define IMAGE_ARCHIVE_START "!<arch>\n"
3342 #define IMAGE_ARCHIVE_END "`\n"
3343 #define IMAGE_ARCHIVE_PAD "\n"
3344 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3345 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3347 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3356 } IMAGE_ARCHIVE_MEMBER_HEADER
, *PIMAGE_ARCHIVE_MEMBER_HEADER
;
3358 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3360 typedef struct _IMPORT_OBJECT_HEADER
3366 DWORD TimeDateStamp
;
3376 } IMPORT_OBJECT_HEADER
;
3378 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3380 typedef enum IMPORT_OBJECT_TYPE
3382 IMPORT_OBJECT_CODE
= 0,
3383 IMPORT_OBJECT_DATA
= 1,
3384 IMPORT_OBJECT_CONST
= 2
3385 } IMPORT_OBJECT_TYPE
;
3387 typedef enum IMPORT_OBJECT_NAME_TYPE
3389 IMPORT_OBJECT_ORDINAL
= 0,
3390 IMPORT_OBJECT_NAME
= 1,
3391 IMPORT_OBJECT_NAME_NO_PREFIX
= 2,
3392 IMPORT_OBJECT_NAME_UNDECORATE
= 3
3393 } IMPORT_OBJECT_NAME_TYPE
;
3395 typedef struct _ANON_OBJECT_HEADER
3401 DWORD TimeDateStamp
;
3404 } ANON_OBJECT_HEADER
;
3407 * Resource directory stuff
3409 typedef struct _IMAGE_RESOURCE_DIRECTORY
{
3410 DWORD Characteristics
;
3411 DWORD TimeDateStamp
;
3414 WORD NumberOfNamedEntries
;
3415 WORD NumberOfIdEntries
;
3416 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3417 } IMAGE_RESOURCE_DIRECTORY
,*PIMAGE_RESOURCE_DIRECTORY
;
3419 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3420 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3422 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
{
3425 unsigned NameOffset
:31;
3426 unsigned NameIsString
:1;
3434 unsigned OffsetToDirectory
:31;
3435 unsigned DataIsDirectory
:1;
3438 } IMAGE_RESOURCE_DIRECTORY_ENTRY
,*PIMAGE_RESOURCE_DIRECTORY_ENTRY
;
3441 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
{
3443 CHAR NameString
[ 1 ];
3444 } IMAGE_RESOURCE_DIRECTORY_STRING
,*PIMAGE_RESOURCE_DIRECTORY_STRING
;
3446 typedef struct _IMAGE_RESOURCE_DIR_STRING_U
{
3448 WCHAR NameString
[ 1 ];
3449 } IMAGE_RESOURCE_DIR_STRING_U
,*PIMAGE_RESOURCE_DIR_STRING_U
;
3451 typedef struct _IMAGE_RESOURCE_DATA_ENTRY
{
3456 } IMAGE_RESOURCE_DATA_ENTRY
,*PIMAGE_RESOURCE_DATA_ENTRY
;
3459 typedef VOID (CALLBACK
*PIMAGE_TLS_CALLBACK
)(
3460 LPVOID DllHandle
,DWORD Reason
,LPVOID Reserved
3463 typedef struct _IMAGE_TLS_DIRECTORY64
{
3464 ULONGLONG StartAddressOfRawData
;
3465 ULONGLONG EndAddressOfRawData
;
3466 ULONGLONG AddressOfIndex
;
3467 ULONGLONG AddressOfCallBacks
;
3468 DWORD SizeOfZeroFill
;
3469 DWORD Characteristics
;
3470 } IMAGE_TLS_DIRECTORY64
, *PIMAGE_TLS_DIRECTORY64
;
3472 typedef struct _IMAGE_TLS_DIRECTORY32
{
3473 DWORD StartAddressOfRawData
;
3474 DWORD EndAddressOfRawData
;
3475 DWORD AddressOfIndex
;
3476 DWORD AddressOfCallBacks
;
3477 DWORD SizeOfZeroFill
;
3478 DWORD Characteristics
;
3479 } IMAGE_TLS_DIRECTORY32
, *PIMAGE_TLS_DIRECTORY32
;
3482 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY
;
3483 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY
;
3485 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY
;
3486 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY
;
3489 typedef struct _IMAGE_DEBUG_DIRECTORY
{
3490 DWORD Characteristics
;
3491 DWORD TimeDateStamp
;
3496 DWORD AddressOfRawData
;
3497 DWORD PointerToRawData
;
3498 } IMAGE_DEBUG_DIRECTORY
, *PIMAGE_DEBUG_DIRECTORY
;
3500 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3501 #define IMAGE_DEBUG_TYPE_COFF 1
3502 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3503 #define IMAGE_DEBUG_TYPE_FPO 3
3504 #define IMAGE_DEBUG_TYPE_MISC 4
3505 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3506 #define IMAGE_DEBUG_TYPE_FIXUP 6
3507 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3508 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3509 #define IMAGE_DEBUG_TYPE_BORLAND 9
3510 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3511 #define IMAGE_DEBUG_TYPE_CLSID 11
3512 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3513 #define IMAGE_DEBUG_TYPE_POGO 13
3514 #define IMAGE_DEBUG_TYPE_ILTCG 14
3515 #define IMAGE_DEBUG_TYPE_MPX 15
3516 #define IMAGE_DEBUG_TYPE_REPRO 16
3518 typedef enum ReplacesCorHdrNumericDefines
3520 COMIMAGE_FLAGS_ILONLY
= 0x00000001,
3521 COMIMAGE_FLAGS_32BITREQUIRED
= 0x00000002,
3522 COMIMAGE_FLAGS_IL_LIBRARY
= 0x00000004,
3523 COMIMAGE_FLAGS_STRONGNAMESIGNED
= 0x00000008,
3524 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT
= 0x00000010,
3525 COMIMAGE_FLAGS_TRACKDEBUGDATA
= 0x00010000,
3526 COMIMAGE_FLAGS_32BITPREFERRED
= 0x00020000,
3528 COR_VERSION_MAJOR_V2
= 2,
3529 COR_VERSION_MAJOR
= COR_VERSION_MAJOR_V2
,
3530 COR_VERSION_MINOR
= 5,
3531 COR_DELETED_NAME_LENGTH
= 8,
3532 COR_VTABLEGAP_NAME_LENGTH
= 8,
3534 NATIVE_TYPE_MAX_CB
= 1,
3535 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE
= 0xff,
3537 IMAGE_COR_MIH_METHODRVA
= 0x01,
3538 IMAGE_COR_MIH_EHRVA
= 0x02,
3539 IMAGE_COR_MIH_BASICBLOCK
= 0x08,
3541 COR_VTABLE_32BIT
= 0x01,
3542 COR_VTABLE_64BIT
= 0x02,
3543 COR_VTABLE_FROM_UNMANAGED
= 0x04,
3544 COR_VTABLE_CALL_MOST_DERIVED
= 0x10,
3546 IMAGE_COR_EATJ_THUNK_SIZE
= 32,
3548 MAX_CLASS_NAME
= 1024,
3549 MAX_PACKAGE_NAME
= 1024,
3550 } ReplacesCorHdrNumericDefines
;
3552 typedef struct IMAGE_COR20_HEADER
3555 WORD MajorRuntimeVersion
;
3556 WORD MinorRuntimeVersion
;
3558 IMAGE_DATA_DIRECTORY MetaData
;
3561 DWORD EntryPointToken
;
3562 DWORD EntryPointRVA
;
3565 IMAGE_DATA_DIRECTORY Resources
;
3566 IMAGE_DATA_DIRECTORY StrongNameSignature
;
3567 IMAGE_DATA_DIRECTORY CodeManagerTable
;
3568 IMAGE_DATA_DIRECTORY VTableFixups
;
3569 IMAGE_DATA_DIRECTORY ExportAddressTableJumps
;
3570 IMAGE_DATA_DIRECTORY ManagedNativeHeader
;
3572 } IMAGE_COR20_HEADER
, *PIMAGE_COR20_HEADER
;
3574 typedef struct _IMAGE_COFF_SYMBOLS_HEADER
{
3575 DWORD NumberOfSymbols
;
3576 DWORD LvaToFirstSymbol
;
3577 DWORD NumberOfLinenumbers
;
3578 DWORD LvaToFirstLinenumber
;
3579 DWORD RvaToFirstByteOfCode
;
3580 DWORD RvaToLastByteOfCode
;
3581 DWORD RvaToFirstByteOfData
;
3582 DWORD RvaToLastByteOfData
;
3583 } IMAGE_COFF_SYMBOLS_HEADER
, *PIMAGE_COFF_SYMBOLS_HEADER
;
3586 #define FRAME_TRAP 1
3588 #define FRAME_NONFPO 3
3590 typedef struct _FPO_DATA
{
3601 } FPO_DATA
, *PFPO_DATA
;
3603 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
{
3605 DWORD TimeDateStamp
;
3608 DWORD GlobalFlagsClear
;
3609 DWORD GlobalFlagsSet
;
3610 DWORD CriticalSectionDefaultTimeout
;
3611 ULONGLONG DeCommitFreeBlockThreshold
;
3612 ULONGLONG DeCommitTotalFreeThreshold
;
3613 ULONGLONG LockPrefixTable
;
3614 ULONGLONG MaximumAllocationSize
;
3615 ULONGLONG VirtualMemoryThreshold
;
3616 ULONGLONG ProcessAffinityMask
;
3617 DWORD ProcessHeapFlags
;
3621 ULONGLONG SecurityCookie
;
3622 ULONGLONG SEHandlerTable
;
3623 ULONGLONG SEHandlerCount
;
3624 } IMAGE_LOAD_CONFIG_DIRECTORY64
, *PIMAGE_LOAD_CONFIG_DIRECTORY64
;
3626 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
{
3628 DWORD TimeDateStamp
;
3631 DWORD GlobalFlagsClear
;
3632 DWORD GlobalFlagsSet
;
3633 DWORD CriticalSectionDefaultTimeout
;
3634 DWORD DeCommitFreeBlockThreshold
;
3635 DWORD DeCommitTotalFreeThreshold
;
3636 PVOID LockPrefixTable
;
3637 DWORD MaximumAllocationSize
;
3638 DWORD VirtualMemoryThreshold
;
3639 DWORD ProcessHeapFlags
;
3640 DWORD ProcessAffinityMask
;
3644 DWORD SecurityCookie
;
3645 DWORD SEHandlerTable
;
3646 DWORD SEHandlerCount
;
3647 } IMAGE_LOAD_CONFIG_DIRECTORY32
, *PIMAGE_LOAD_CONFIG_DIRECTORY32
;
3650 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY
;
3651 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY
;
3653 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY
;
3654 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY
;
3657 typedef struct _IMAGE_FUNCTION_ENTRY
{
3658 DWORD StartingAddress
;
3659 DWORD EndingAddress
;
3660 DWORD EndOfPrologue
;
3661 } IMAGE_FUNCTION_ENTRY
, *PIMAGE_FUNCTION_ENTRY
;
3663 #define IMAGE_DEBUG_MISC_EXENAME 1
3665 typedef struct _IMAGE_DEBUG_MISC
{
3671 } IMAGE_DEBUG_MISC
, *PIMAGE_DEBUG_MISC
;
3673 /* This is the structure that appears at the very start of a .DBG file. */
3675 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
{
3679 WORD Characteristics
;
3680 DWORD TimeDateStamp
;
3684 DWORD NumberOfSections
;
3685 DWORD ExportedNamesSize
;
3686 DWORD DebugDirectorySize
;
3687 DWORD SectionAlignment
;
3688 DWORD Reserved
[ 2 ];
3689 } IMAGE_SEPARATE_DEBUG_HEADER
,*PIMAGE_SEPARATE_DEBUG_HEADER
;
3691 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3694 typedef struct tagMESSAGE_RESOURCE_ENTRY
{
3698 } MESSAGE_RESOURCE_ENTRY
,*PMESSAGE_RESOURCE_ENTRY
;
3699 #define MESSAGE_RESOURCE_UNICODE 0x0001
3701 typedef struct tagMESSAGE_RESOURCE_BLOCK
{
3704 DWORD OffsetToEntries
;
3705 } MESSAGE_RESOURCE_BLOCK
,*PMESSAGE_RESOURCE_BLOCK
;
3707 typedef struct tagMESSAGE_RESOURCE_DATA
{
3708 DWORD NumberOfBlocks
;
3709 MESSAGE_RESOURCE_BLOCK Blocks
[ 1 ];
3710 } MESSAGE_RESOURCE_DATA
,*PMESSAGE_RESOURCE_DATA
;
3713 * Here follows typedefs for security and tokens.
3717 * First a constant for the following typedefs.
3720 #define ANYSIZE_ARRAY 1
3722 /* FIXME: Orphan. What does it point to? */
3723 typedef PVOID PACCESS_TOKEN
;
3724 typedef PVOID PSECURITY_DESCRIPTOR
;
3727 typedef enum _TOKEN_ELEVATION_TYPE
{
3728 TokenElevationTypeDefault
= 1,
3729 TokenElevationTypeFull
,
3730 TokenElevationTypeLimited
3731 } TOKEN_ELEVATION_TYPE
, *PTOKEN_ELEVATION_TYPE
;
3734 * TOKEN_INFORMATION_CLASS
3737 typedef enum _TOKEN_INFORMATION_CLASS
{
3746 TokenImpersonationLevel
,
3748 TokenRestrictedSids
,
3750 TokenGroupsAndPrivileges
,
3751 TokenSessionReference
,
3758 TokenHasRestrictions
,
3759 TokenAccessInformation
,
3760 TokenVirtualizationAllowed
,
3761 TokenVirtualizationEnabled
,
3762 TokenIntegrityLevel
,
3764 TokenMandatoryPolicy
,
3766 TokenIsAppContainer
,
3768 TokenAppContainerSid
,
3769 TokenAppContainerNumber
,
3770 TokenUserClaimAttributes
,
3771 TokenDeviceClaimAttributes
,
3772 TokenRestrictedUserClaimAttributes
,
3773 TokenRestrictedDeviceClaimAttributes
,
3775 TokenRestrictedDeviceGroups
,
3776 TokenSecurityAttributes
,
3778 TokenProcessTrustLevel
,
3780 } TOKEN_INFORMATION_CLASS
;
3782 #define DISABLE_MAX_PRIVILEGE 0x1
3783 #define SANDBOX_INERT 0x2
3784 #define LUA_TOKEN 0x4
3785 #define WRITE_RESTRICTED 0x8
3787 #define TOKEN_ASSIGN_PRIMARY 0x0001
3788 #define TOKEN_DUPLICATE 0x0002
3789 #define TOKEN_IMPERSONATE 0x0004
3790 #define TOKEN_QUERY 0x0008
3791 #define TOKEN_QUERY_SOURCE 0x0010
3792 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3793 #define TOKEN_ADJUST_GROUPS 0x0040
3794 #define TOKEN_ADJUST_DEFAULT 0x0080
3795 #define TOKEN_ADJUST_SESSIONID 0x0100
3796 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3797 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3798 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3799 TOKEN_ADJUST_PRIVILEGES | \
3800 TOKEN_ADJUST_GROUPS | \
3801 TOKEN_ADJUST_DEFAULT )
3802 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3803 TOKEN_ASSIGN_PRIMARY | \
3805 TOKEN_IMPERSONATE | \
3807 TOKEN_QUERY_SOURCE | \
3808 TOKEN_ADJUST_PRIVILEGES | \
3809 TOKEN_ADJUST_GROUPS | \
3810 TOKEN_ADJUST_SESSIONID | \
3811 TOKEN_ADJUST_DEFAULT )
3813 #ifndef _SECURITY_DEFINED
3814 #define _SECURITY_DEFINED
3816 typedef DWORD ACCESS_MASK
, *PACCESS_MASK
;
3818 typedef struct _GENERIC_MAPPING
{
3819 ACCESS_MASK GenericRead
;
3820 ACCESS_MASK GenericWrite
;
3821 ACCESS_MASK GenericExecute
;
3822 ACCESS_MASK GenericAll
;
3823 } GENERIC_MAPPING
, *PGENERIC_MAPPING
;
3825 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3826 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3829 } SID_IDENTIFIER_AUTHORITY
, *PSID_IDENTIFIER_AUTHORITY
;
3830 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3834 typedef struct _SID
{
3836 BYTE SubAuthorityCount
;
3837 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
3838 DWORD SubAuthority
[1];
3840 #endif /* !defined(SID_DEFINED) */
3842 #define CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID 0x01
3844 #define SID_REVISION (1) /* Current revision */
3845 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3846 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3848 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3854 #define ACL_REVISION1 1
3855 #define ACL_REVISION2 2
3856 #define ACL_REVISION3 3
3857 #define ACL_REVISION4 4
3859 #define MIN_ACL_REVISION ACL_REVISION2
3860 #define MAX_ACL_REVISION ACL_REVISION4
3862 #define ACL_REVISION 2
3864 typedef struct _ACL
{
3872 typedef enum _ACL_INFORMATION_CLASS
3874 AclRevisionInformation
= 1,
3876 } ACL_INFORMATION_CLASS
;
3878 typedef struct _ACL_REVISION_INFORMATION
3881 } ACL_REVISION_INFORMATION
, *PACL_REVISION_INFORMATION
;
3883 typedef struct _ACL_SIZE_INFORMATION
3886 DWORD AclBytesInUse
;
3888 } ACL_SIZE_INFORMATION
, *PACL_SIZE_INFORMATION
;
3890 /* SECURITY_DESCRIPTOR */
3891 #define SECURITY_DESCRIPTOR_REVISION 1
3892 #define SECURITY_DESCRIPTOR_REVISION1 1
3899 #if defined(_MSC_VER) || defined(__MINGW32__)
3900 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
3901 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
3902 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
3903 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
3904 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
3905 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
3906 #define SE_TCB_NAME L"SeTcbPrivilege"
3907 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
3908 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
3909 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
3910 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
3911 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
3912 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
3913 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
3914 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
3915 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
3916 #define SE_BACKUP_NAME L"SeBackupPrivilege"
3917 #define SE_RESTORE_NAME L"SeRestorePrivilege"
3918 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
3919 #define SE_DEBUG_NAME L"SeDebugPrivilege"
3920 #define SE_AUDIT_NAME L"SeAuditPrivilege"
3921 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
3922 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
3923 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
3924 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
3925 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
3926 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
3927 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
3928 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
3929 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
3930 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
3931 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
3932 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
3933 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
3934 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
3935 #else /* _MSC_VER/__MINGW32__ */
3936 static const WCHAR SE_CREATE_TOKEN_NAME
[] = { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
3937 static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME
[] = { 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
3938 static const WCHAR SE_LOCK_MEMORY_NAME
[] = { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
3939 static const WCHAR SE_INCREASE_QUOTA_NAME
[] = { 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
3940 static const WCHAR SE_UNSOLICITED_INPUT_NAME
[] = { 'S','e','U','n','s','o','l','i','c','i','t','e','d','I','n','p','u','t','P','r','i','v','i','l','e','g','e',0 };
3941 static const WCHAR SE_MACHINE_ACCOUNT_NAME
[] = { 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
3942 static const WCHAR SE_TCB_NAME
[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
3943 static const WCHAR SE_SECURITY_NAME
[] = { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
3944 static const WCHAR SE_TAKE_OWNERSHIP_NAME
[] = { 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
3945 static const WCHAR SE_LOAD_DRIVER_NAME
[] = { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
3946 static const WCHAR SE_SYSTEM_PROFILE_NAME
[] = { 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
3947 static const WCHAR SE_SYSTEMTIME_NAME
[] = { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
3948 static const WCHAR SE_PROF_SINGLE_PROCESS_NAME
[] = { 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
3949 static const WCHAR SE_INC_BASE_PRIORITY_NAME
[] = { 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
3950 static const WCHAR SE_CREATE_PAGEFILE_NAME
[] = { 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
3951 static const WCHAR SE_CREATE_PERMANENT_NAME
[] = { 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
3952 static const WCHAR SE_BACKUP_NAME
[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
3953 static const WCHAR SE_RESTORE_NAME
[] = { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
3954 static const WCHAR SE_SHUTDOWN_NAME
[] = { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
3955 static const WCHAR SE_DEBUG_NAME
[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
3956 static const WCHAR SE_AUDIT_NAME
[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
3957 static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME
[] = { 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
3958 static const WCHAR SE_CHANGE_NOTIFY_NAME
[] = { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
3959 static const WCHAR SE_REMOTE_SHUTDOWN_NAME
[] = { 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
3960 static const WCHAR SE_UNDOCK_NAME
[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
3961 static const WCHAR SE_ENABLE_DELEGATION_NAME
[] = { 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
3962 static const WCHAR SE_MANAGE_VOLUME_NAME
[] = { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
3963 static const WCHAR SE_IMPERSONATE_NAME
[] = { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
3964 static const WCHAR SE_CREATE_GLOBAL_NAME
[] = { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
3965 static const WCHAR SE_TRUSTED_CREDMAN_ACCESS_NAME
[] = { 'S','e','T','r','u','s','t','e','d','C','r','e','d','M','a','n','A','c','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
3966 static const WCHAR SE_RELABEL_NAME
[] = { 'S','e','R','e','l','a','b','e','l','P','r','i','v','i','l','e','g','e',0 };
3967 static const WCHAR SE_INC_WORKING_SET_NAME
[] = { 'S','e','I','n','c','r','e','a','s','e','W','o','r','k','i','n','g','S','e','t','P','r','i','v','i','l','e','g','e',0 };
3968 static const WCHAR SE_TIME_ZONE_NAME
[] = { 'S','e','T','i','m','e','Z','o','n','e','P','r','i','v','i','l','e','g','e',0 };
3969 static const WCHAR SE_CREATE_SYMBOLIC_LINK_NAME
[] = { 'S','e','C','r','e','a','t','e','S','y','m','b','o','l','i','c','L','i','n','k','P','r','i','v','i','l','e','g','e',0 };
3970 static const WCHAR SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME
[] = { 'S','e','D','e','l','e','g','a','t','e','S','e','s','s','i','o','n','U','s','e','r','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
3973 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
3974 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
3975 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
3976 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
3977 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
3978 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
3979 #define SE_TCB_NAME "SeTcbPrivilege"
3980 #define SE_SECURITY_NAME "SeSecurityPrivilege"
3981 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
3982 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
3983 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
3984 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
3985 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
3986 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
3987 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
3988 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
3989 #define SE_BACKUP_NAME "SeBackupPrivilege"
3990 #define SE_RESTORE_NAME "SeRestorePrivilege"
3991 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
3992 #define SE_DEBUG_NAME "SeDebugPrivilege"
3993 #define SE_AUDIT_NAME "SeAuditPrivilege"
3994 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
3995 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
3996 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
3997 #define SE_UNDOCK_NAME "SeUndockPrivilege"
3998 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
3999 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4000 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4001 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4002 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4003 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4004 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4005 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4006 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4007 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4010 #define SE_GROUP_MANDATORY 0x00000001
4011 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4012 #define SE_GROUP_ENABLED 0x00000004
4013 #define SE_GROUP_OWNER 0x00000008
4014 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4015 #define SE_GROUP_INTEGRITY 0x00000020
4016 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4017 #define SE_GROUP_LOGON_ID 0xC0000000
4018 #define SE_GROUP_RESOURCE 0x20000000
4019 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4021 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4022 #define SE_PRIVILEGE_ENABLED 0x00000002
4023 #define SE_PRIVILEGE_REMOVED 0x00000004
4024 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4025 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4027 #define PRIVILEGE_SET_ALL_NECESSARY 1
4029 #define SE_OWNER_DEFAULTED 0x00000001
4030 #define SE_GROUP_DEFAULTED 0x00000002
4031 #define SE_DACL_PRESENT 0x00000004
4032 #define SE_DACL_DEFAULTED 0x00000008
4033 #define SE_SACL_PRESENT 0x00000010
4034 #define SE_SACL_DEFAULTED 0x00000020
4035 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4036 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4037 #define SE_DACL_AUTO_INHERITED 0x00000400
4038 #define SE_SACL_AUTO_INHERITED 0x00000800
4039 #define SE_DACL_PROTECTED 0x00001000
4040 #define SE_SACL_PROTECTED 0x00002000
4041 #define SE_RM_CONTROL_VALID 0x00004000
4042 #define SE_SELF_RELATIVE 0x00008000
4044 typedef DWORD SECURITY_INFORMATION
, *PSECURITY_INFORMATION
;
4045 typedef WORD SECURITY_DESCRIPTOR_CONTROL
, *PSECURITY_DESCRIPTOR_CONTROL
;
4047 /* The security descriptor structure */
4051 SECURITY_DESCRIPTOR_CONTROL Control
;
4056 } SECURITY_DESCRIPTOR_RELATIVE
, *PISECURITY_DESCRIPTOR_RELATIVE
;
4061 SECURITY_DESCRIPTOR_CONTROL Control
;
4066 } SECURITY_DESCRIPTOR
, *PISECURITY_DESCRIPTOR
;
4068 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4070 #endif /* _SECURITY_DEFINED */
4073 * SID_AND_ATTRIBUTES
4076 typedef struct _SID_AND_ATTRIBUTES
{
4079 } SID_AND_ATTRIBUTES
, *PSID_AND_ATTRIBUTES
;
4081 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY
[ANYSIZE_ARRAY
];
4082 typedef SID_AND_ATTRIBUTES_ARRAY
*PSID_AND_ATTRIBUTES_ARRAY
;
4084 #define SID_HASH_SIZE 32
4086 typedef ULONG_PTR SID_HASH_ENTRY
, *PSID_HASH_ENTRY
;
4088 typedef struct _SID_AND_ATTRIBUTES_HASH
{
4090 PSID_AND_ATTRIBUTES SidAttr
;
4091 SID_HASH_ENTRY Hash
[SID_HASH_SIZE
];
4092 } SID_AND_ATTRIBUTES_HASH
, *PSID_AND_ATTRIBUTES_HASH
;
4094 /* security entities */
4095 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4096 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4097 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4099 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4102 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4105 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4106 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4109 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4110 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4111 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4112 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4113 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4114 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4117 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4120 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4121 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4122 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4123 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4124 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4125 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4126 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4127 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4128 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4129 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4130 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4131 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4132 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4133 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4134 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4135 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4136 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4137 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4138 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4139 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4140 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4141 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4142 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4143 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4145 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4146 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4147 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4148 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4149 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4150 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4151 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4152 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4153 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4154 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4155 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4156 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4157 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4158 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4159 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4160 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4161 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4162 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4163 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4164 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4165 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4166 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4168 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4170 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4171 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4172 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4173 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4174 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4176 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4177 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4178 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4179 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4180 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4181 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4182 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4183 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4184 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4185 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4187 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4189 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4190 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4191 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4192 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4193 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4194 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4195 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4196 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4197 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4198 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4199 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4201 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4202 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4203 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4204 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4205 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4206 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4207 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4208 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4209 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4211 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4213 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4214 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4215 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4216 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4218 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4219 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4220 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4221 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4223 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4224 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4225 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4226 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4227 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4228 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4230 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4231 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4232 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4233 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4234 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4235 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4236 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4237 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4238 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4239 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4240 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4242 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4244 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4245 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4246 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4247 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4248 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4249 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4250 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4251 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4252 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4253 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4254 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4256 #define SYSTEM_LUID { 0x3e7, 0x0 }
4257 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4258 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4259 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4260 #define IUSER_LUID { 0x3e3, 0x0 }
4266 WinCreatorOwnerSid
= 3,
4267 WinCreatorGroupSid
= 4,
4268 WinCreatorOwnerServerSid
= 5,
4269 WinCreatorGroupServerSid
= 6,
4270 WinNtAuthoritySid
= 7,
4274 WinInteractiveSid
= 11,
4276 WinAnonymousSid
= 13,
4278 WinEnterpriseControllersSid
= 15,
4280 WinAuthenticatedUserSid
= 17,
4281 WinRestrictedCodeSid
= 18,
4282 WinTerminalServerSid
= 19,
4283 WinRemoteLogonIdSid
= 20,
4284 WinLogonIdsSid
= 21,
4285 WinLocalSystemSid
= 22,
4286 WinLocalServiceSid
= 23,
4287 WinNetworkServiceSid
= 24,
4288 WinBuiltinDomainSid
= 25,
4289 WinBuiltinAdministratorsSid
= 26,
4290 WinBuiltinUsersSid
= 27,
4291 WinBuiltinGuestsSid
= 28,
4292 WinBuiltinPowerUsersSid
= 29,
4293 WinBuiltinAccountOperatorsSid
= 30,
4294 WinBuiltinSystemOperatorsSid
= 31,
4295 WinBuiltinPrintOperatorsSid
= 32,
4296 WinBuiltinBackupOperatorsSid
= 33,
4297 WinBuiltinReplicatorSid
= 34,
4298 WinBuiltinPreWindows2000CompatibleAccessSid
= 35,
4299 WinBuiltinRemoteDesktopUsersSid
= 36,
4300 WinBuiltinNetworkConfigurationOperatorsSid
= 37,
4301 WinAccountAdministratorSid
= 38,
4302 WinAccountGuestSid
= 39,
4303 WinAccountKrbtgtSid
= 40,
4304 WinAccountDomainAdminsSid
= 41,
4305 WinAccountDomainUsersSid
= 42,
4306 WinAccountDomainGuestsSid
= 43,
4307 WinAccountComputersSid
= 44,
4308 WinAccountControllersSid
= 45,
4309 WinAccountCertAdminsSid
= 46,
4310 WinAccountSchemaAdminsSid
= 47,
4311 WinAccountEnterpriseAdminsSid
= 48,
4312 WinAccountPolicyAdminsSid
= 49,
4313 WinAccountRasAndIasServersSid
= 50,
4314 WinNTLMAuthenticationSid
= 51,
4315 WinDigestAuthenticationSid
= 52,
4316 WinSChannelAuthenticationSid
= 53,
4317 WinThisOrganizationSid
= 54,
4318 WinOtherOrganizationSid
= 55,
4319 WinBuiltinIncomingForestTrustBuildersSid
= 56,
4320 WinBuiltinPerfMonitoringUsersSid
= 57,
4321 WinBuiltinPerfLoggingUsersSid
= 58,
4322 WinBuiltinAuthorizationAccessSid
= 59,
4323 WinBuiltinTerminalServerLicenseServersSid
= 60,
4324 WinBuiltinDCOMUsersSid
= 61,
4325 WinBuiltinIUsersSid
= 62,
4327 WinBuiltinCryptoOperatorsSid
= 64,
4328 WinUntrustedLabelSid
= 65,
4329 WinLowLabelSid
= 66,
4330 WinMediumLabelSid
= 67,
4331 WinHighLabelSid
= 68,
4332 WinSystemLabelSid
= 69,
4333 WinWriteRestrictedCodeSid
= 70,
4334 WinCreatorOwnerRightsSid
= 71,
4335 WinCacheablePrincipalsGroupSid
= 72,
4336 WinNonCacheablePrincipalsGroupSid
= 73,
4337 WinEnterpriseReadonlyControllersSid
= 74,
4338 WinAccountReadonlyControllersSid
= 75,
4339 WinBuiltinEventLogReadersGroup
= 76,
4340 WinNewEnterpriseReadonlyControllersSid
= 77,
4341 WinBuiltinCertSvcDComAccessGroup
= 78,
4342 WinMediumPlusLabelSid
= 79,
4343 WinLocalLogonSid
= 80,
4344 WinConsoleLogonSid
= 81,
4345 WinThisOrganizationCertificateSid
= 82,
4346 WinApplicationPackageAuthoritySid
= 83,
4347 WinBuiltinAnyPackageSid
= 84,
4348 WinCapabilityInternetClientSid
= 85,
4349 WinCapabilityInternetClientServerSid
= 86,
4350 WinCapabilityPrivateNetworkClientServerSid
= 87,
4351 WinCapabilityPicturesLibrarySid
= 88,
4352 WinCapabilityVideosLibrarySid
= 89,
4353 WinCapabilityMusicLibrarySid
= 90,
4354 WinCapabilityDocumentsLibrarySid
= 91,
4355 WinCapabilitySharedUserCertificatesSid
= 92,
4356 WinCapabilityEnterpriseAuthenticationSid
= 93,
4357 WinCapabilityRemovableStorageSid
= 94,
4358 WinBuiltinRDSRemoteAccessServersSid
= 95,
4359 WinBuiltinRDSEndpointServersSid
= 96,
4360 WinBuiltinRDSManagementServersSid
= 97,
4361 WinUserModeDriversSid
= 98,
4362 WinBuiltinHyperVAdminsSid
= 99,
4363 WinAccountCloneableControllersSid
= 100,
4364 WinBuiltinAccessControlAssistanceOperatorsSid
= 101,
4365 WinBuiltinRemoteManagementUsersSid
= 102,
4366 WinAuthenticationAuthorityAssertedSid
= 103,
4367 WinAuthenticationServiceAssertedSid
= 104,
4368 WinLocalAccountSid
= 105,
4369 WinLocalAccountAndAdministratorSid
= 106,
4370 WinAccountProtectedUsersSid
= 107,
4371 } WELL_KNOWN_SID_TYPE
;
4377 typedef struct _TOKEN_USER
{
4378 SID_AND_ATTRIBUTES User
;
4379 } TOKEN_USER
, *PTOKEN_USER
;
4385 typedef struct _TOKEN_GROUPS
{
4387 SID_AND_ATTRIBUTES Groups
[ANYSIZE_ARRAY
];
4388 } TOKEN_GROUPS
, *PTOKEN_GROUPS
;
4391 * LUID_AND_ATTRIBUTES
4394 typedef union _LARGE_INTEGER
{
4396 #ifdef WORDS_BIGENDIAN
4404 #ifndef NONAMELESSSTRUCT
4406 #ifdef WORDS_BIGENDIAN
4416 } LARGE_INTEGER
, *PLARGE_INTEGER
;
4418 typedef union _ULARGE_INTEGER
{
4420 #ifdef WORDS_BIGENDIAN
4428 #ifndef NONAMELESSSTRUCT
4430 #ifdef WORDS_BIGENDIAN
4440 } ULARGE_INTEGER
, *PULARGE_INTEGER
;
4443 * Locally Unique Identifier
4446 typedef struct _LUID
{
4451 #include <pshpack4.h>
4452 typedef struct _LUID_AND_ATTRIBUTES
{
4455 } LUID_AND_ATTRIBUTES
, *PLUID_AND_ATTRIBUTES
;
4456 #include <poppack.h>
4462 typedef struct _PRIVILEGE_SET
{
4463 DWORD PrivilegeCount
;
4465 LUID_AND_ATTRIBUTES Privilege
[ANYSIZE_ARRAY
];
4466 } PRIVILEGE_SET
, *PPRIVILEGE_SET
;
4472 typedef struct _TOKEN_PRIVILEGES
{
4473 DWORD PrivilegeCount
;
4474 LUID_AND_ATTRIBUTES Privileges
[ANYSIZE_ARRAY
];
4475 } TOKEN_PRIVILEGES
, *PTOKEN_PRIVILEGES
;
4481 typedef struct _TOKEN_OWNER
{
4483 } TOKEN_OWNER
, *PTOKEN_OWNER
;
4486 * TOKEN_PRIMARY_GROUP
4489 typedef struct _TOKEN_PRIMARY_GROUP
{
4491 } TOKEN_PRIMARY_GROUP
, *PTOKEN_PRIMARY_GROUP
;
4495 * TOKEN_DEFAULT_DACL
4498 typedef struct _TOKEN_DEFAULT_DACL
{
4500 } TOKEN_DEFAULT_DACL
, *PTOKEN_DEFAULT_DACL
;
4506 #define TOKEN_SOURCE_LENGTH 8
4508 typedef struct _TOKEN_SOURCE
{
4509 char SourceName
[TOKEN_SOURCE_LENGTH
];
4510 LUID SourceIdentifier
;
4511 } TOKEN_SOURCE
, *PTOKEN_SOURCE
;
4517 typedef enum tagTOKEN_TYPE
{
4523 * SECURITY_IMPERSONATION_LEVEL
4526 typedef enum _SECURITY_IMPERSONATION_LEVEL
{
4528 SecurityIdentification
,
4529 SecurityImpersonation
,
4531 } SECURITY_IMPERSONATION_LEVEL
, *PSECURITY_IMPERSONATION_LEVEL
;
4533 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4534 #define SECURITY_STATIC_TRACKING (FALSE)
4536 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE
,
4537 * PSECURITY_CONTEXT_TRACKING_MODE
;
4539 * Quality of Service
4542 typedef struct _SECURITY_QUALITY_OF_SERVICE
{
4544 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
4545 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
;
4546 BOOLEAN EffectiveOnly
;
4547 } SECURITY_QUALITY_OF_SERVICE
, *PSECURITY_QUALITY_OF_SERVICE
;
4553 #include <pshpack4.h>
4554 typedef struct _TOKEN_STATISTICS
{
4556 LUID AuthenticationId
;
4557 LARGE_INTEGER ExpirationTime
;
4558 TOKEN_TYPE TokenType
;
4559 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
4560 DWORD DynamicCharged
;
4561 DWORD DynamicAvailable
;
4563 DWORD PrivilegeCount
;
4566 #include <poppack.h>
4568 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES
{
4571 PSID_AND_ATTRIBUTES Sids
;
4572 DWORD RestrictedSidCount
;
4573 DWORD RestrictedSidLength
;
4574 PSID_AND_ATTRIBUTES RestrictedSids
;
4575 DWORD PrivilegeCount
;
4576 DWORD PrivilegeLength
;
4577 PLUID_AND_ATTRIBUTES Privileges
;
4578 LUID AuthenticationId
;
4579 } TOKEN_GROUPS_AND_PRIVILEGES
, * PTOKEN_GROUPS_AND_PRIVILEGES
;
4581 typedef struct _TOKEN_ORIGIN
{
4582 LUID OriginatingLogonSession
;
4583 } TOKEN_ORIGIN
, * PTOKEN_ORIGIN
;
4585 typedef struct _TOKEN_LINKED_TOKEN
{
4587 } TOKEN_LINKED_TOKEN
, * PTOKEN_LINKED_TOKEN
;
4589 typedef struct _TOKEN_ELEVATION
{
4590 DWORD TokenIsElevated
;
4591 } TOKEN_ELEVATION
, * PTOKEN_ELEVATION
;
4593 typedef struct _TOKEN_MANDATORY_LABEL
{
4594 SID_AND_ATTRIBUTES Label
;
4595 } TOKEN_MANDATORY_LABEL
, * PTOKEN_MANDATORY_LABEL
;
4597 #define TOKEN_MANDATORY_POLICY_OFF 0x0
4598 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
4599 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
4600 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
4602 typedef struct _TOKEN_MANDATORY_POLICY
{
4604 } TOKEN_MANDATORY_POLICY
, *PTOKEN_MANDATORY_POLICY
;
4606 typedef struct _TOKEN_APPCONTAINER_INFORMATION
{
4607 PSID TokenAppContainer
;
4608 } TOKEN_APPCONTAINER_INFORMATION
, * PTOKEN_APPCONTAINER_INFORMATION
;
4610 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
4612 typedef struct _TOKEN_AUDIT_POLICY
{
4613 BYTE PerUserPolicy
[((POLICY_AUDIT_SUBCATEGORY_COUNT
) >> 1) + 1];
4614 } TOKEN_AUDIT_POLICY
, *PTOKEN_AUDIT_POLICY
;
4616 typedef struct _TOKEN_ACCESS_INFORMATION
{
4617 PSID_AND_ATTRIBUTES_HASH SidHash
;
4618 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash
;
4619 PTOKEN_PRIVILEGES Privileges
;
4620 LUID AuthenticationId
;
4621 TOKEN_TYPE TokenType
;
4622 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
4623 TOKEN_MANDATORY_POLICY MandatoryPolicy
;
4625 } TOKEN_ACCESS_INFORMATION
, *PTOKEN_ACCESS_INFORMATION
;
4627 typedef struct _TOKEN_CONTROL
{
4629 LUID AuthenticationId
;
4631 TOKEN_SOURCE TokenSource
;
4632 } TOKEN_CONTROL
, *PTOKEN_CONTROL
;
4638 /* ACEs, directly starting after an ACL */
4639 typedef struct _ACE_HEADER
{
4643 } ACE_HEADER
,*PACE_HEADER
;
4646 #define ACCESS_MIN_MS_ACE_TYPE 0x0
4647 #define ACCESS_ALLOWED_ACE_TYPE 0x0
4648 #define ACCESS_DENIED_ACE_TYPE 0x1
4649 #define SYSTEM_AUDIT_ACE_TYPE 0x2
4650 #define SYSTEM_ALARM_ACE_TYPE 0x3
4651 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
4652 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
4653 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
4654 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
4655 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
4656 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
4657 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
4658 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
4659 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
4660 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
4661 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
4662 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
4663 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
4664 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
4665 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
4666 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
4667 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
4668 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
4669 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
4670 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
4671 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
4672 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
4674 /* inherit AceFlags */
4675 #define OBJECT_INHERIT_ACE 0x01
4676 #define CONTAINER_INHERIT_ACE 0x02
4677 #define NO_PROPAGATE_INHERIT_ACE 0x04
4678 #define INHERIT_ONLY_ACE 0x08
4679 #define INHERITED_ACE 0x10
4680 #define VALID_INHERIT_FLAGS 0x1F
4682 /* AceFlags mask for what events we (should) audit */
4683 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4684 #define FAILED_ACCESS_ACE_FLAG 0x80
4686 /* different ACEs depending on AceType
4687 * SidStart marks the begin of a SID
4688 * so the thing finally looks like this:
4693 typedef struct _ACCESS_ALLOWED_ACE
{
4697 } ACCESS_ALLOWED_ACE
,*PACCESS_ALLOWED_ACE
;
4699 typedef struct _ACCESS_DENIED_ACE
{
4703 } ACCESS_DENIED_ACE
,*PACCESS_DENIED_ACE
;
4705 typedef struct _SYSTEM_AUDIT_ACE
{
4709 } SYSTEM_AUDIT_ACE
,*PSYSTEM_AUDIT_ACE
;
4711 typedef struct _SYSTEM_ALARM_ACE
{
4715 } SYSTEM_ALARM_ACE
,*PSYSTEM_ALARM_ACE
;
4717 typedef struct _SYSTEM_MANDATORY_LABEL_ACE
{
4721 } SYSTEM_MANDATORY_LABEL_ACE
,*PSYSTEM_MANDATORY_LABEL_ACE
;
4723 typedef struct _ACCESS_ALLOWED_OBJECT_ACE
{
4728 GUID InheritedObjectType
;
4730 } ACCESS_ALLOWED_OBJECT_ACE
, *PACCESS_ALLOWED_OBJECT_ACE
;
4732 typedef struct _ACCESS_DENIED_OBJECT_ACE
{
4737 GUID InheritedObjectType
;
4739 } ACCESS_DENIED_OBJECT_ACE
, *PACCESS_DENIED_OBJECT_ACE
;
4741 typedef struct _SYSTEM_AUDIT_OBJECT_ACE
{
4746 GUID InheritedObjectType
;
4748 } SYSTEM_AUDIT_OBJECT_ACE
, *PSYSTEM_AUDIT_OBJECT_ACE
;
4750 typedef struct _SYSTEM_ALARM_OBJECT_ACE
{
4755 GUID InheritedObjectType
;
4757 } SYSTEM_ALARM_OBJECT_ACE
, *PSYSTEM_ALARM_OBJECT_aCE
;
4759 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE
{
4763 } ACCESS_ALLOWED_CALLBACK_ACE
,*PACCESS_ALLOWED_CALLBACK_ACE
;
4765 typedef struct _ACCESS_DENIED_CALLBACK_ACE
{
4769 } ACCESS_DENIED_CALLBACK_ACE
,*PACCESS_DENIED_CALLBACK_ACE
;
4771 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE
{
4775 } SYSTEM_AUDIT_CALLBACK_ACE
,*PSYSTEM_AUDIT_CALLBACK_ACE
;
4777 typedef struct _SYSTEM_ALARM_CALLBACK_ACE
{
4781 } SYSTEM_ALARM_CALLBACK_ACE
,*PSYSTEM_ALARM_CALLBACK_ACE
;
4783 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
{
4788 GUID InheritedObjectType
;
4790 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE
;
4792 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE
{
4797 GUID InheritedObjectType
;
4799 } ACCESS_DENIED_CALLBACK_OBJECT_ACE
, *PACCESS_DENIED_CALLBACK_OBJECT_ACE
;
4801 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
{
4806 GUID InheritedObjectType
;
4808 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE
;
4810 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE
{
4815 GUID InheritedObjectType
;
4817 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE
, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE
;
4819 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
4820 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
4821 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
4822 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
4824 typedef enum tagSID_NAME_USE
{
4829 SidTypeWellKnownGroup
,
4830 SidTypeDeletedAccount
,
4833 } SID_NAME_USE
,*PSID_NAME_USE
;
4835 #define ACE_OBJECT_TYPE_PRESENT 0x1
4836 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4840 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4842 #define DELETE 0x00010000
4843 #define READ_CONTROL 0x00020000
4844 #define WRITE_DAC 0x00040000
4845 #define WRITE_OWNER 0x00080000
4846 #define SYNCHRONIZE 0x00100000
4847 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4849 #define STANDARD_RIGHTS_READ READ_CONTROL
4850 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4851 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4853 #define STANDARD_RIGHTS_ALL 0x001f0000
4855 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4857 #define GENERIC_READ 0x80000000
4858 #define GENERIC_WRITE 0x40000000
4859 #define GENERIC_EXECUTE 0x20000000
4860 #define GENERIC_ALL 0x10000000
4862 #define MAXIMUM_ALLOWED 0x02000000
4863 #define ACCESS_SYSTEM_SECURITY 0x01000000
4865 #define EVENT_QUERY_STATE 0x0001
4866 #define EVENT_MODIFY_STATE 0x0002
4867 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4869 #define SEMAPHORE_QUERY_STATE 0x0001
4870 #define SEMAPHORE_MODIFY_STATE 0x0002
4871 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4873 #define MUTANT_QUERY_STATE 0x0001
4874 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
4876 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
4877 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
4878 #define JOB_OBJECT_QUERY 0x0004
4879 #define JOB_OBJECT_TERMINATE 0x0008
4880 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
4881 #define JOB_OBJECT_IMPERSONATE 0x0020
4882 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3f)
4884 #define TIMER_QUERY_STATE 0x0001
4885 #define TIMER_MODIFY_STATE 0x0002
4886 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4888 #define PROCESS_TERMINATE 0x0001
4889 #define PROCESS_CREATE_THREAD 0x0002
4890 #define PROCESS_VM_OPERATION 0x0008
4891 #define PROCESS_VM_READ 0x0010
4892 #define PROCESS_VM_WRITE 0x0020
4893 #define PROCESS_DUP_HANDLE 0x0040
4894 #define PROCESS_CREATE_PROCESS 0x0080
4895 #define PROCESS_SET_QUOTA 0x0100
4896 #define PROCESS_SET_INFORMATION 0x0200
4897 #define PROCESS_QUERY_INFORMATION 0x0400
4898 #define PROCESS_SUSPEND_RESUME 0x0800
4899 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
4900 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
4901 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
4903 #define THREAD_TERMINATE 0x0001
4904 #define THREAD_SUSPEND_RESUME 0x0002
4905 #define THREAD_GET_CONTEXT 0x0008
4906 #define THREAD_SET_CONTEXT 0x0010
4907 #define THREAD_SET_INFORMATION 0x0020
4908 #define THREAD_QUERY_INFORMATION 0x0040
4909 #define THREAD_SET_THREAD_TOKEN 0x0080
4910 #define THREAD_IMPERSONATE 0x0100
4911 #define THREAD_DIRECT_IMPERSONATION 0x0200
4912 #define THREAD_SET_LIMITED_INFORMATION 0x0400
4913 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
4914 #define THREAD_RESUME 0x1000
4915 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
4917 #define THREAD_BASE_PRIORITY_LOWRT 15
4918 #define THREAD_BASE_PRIORITY_MAX 2
4919 #define THREAD_BASE_PRIORITY_MIN -2
4920 #define THREAD_BASE_PRIORITY_IDLE -15
4922 typedef struct _QUOTA_LIMITS
{
4923 SIZE_T PagedPoolLimit
;
4924 SIZE_T NonPagedPoolLimit
;
4925 SIZE_T MinimumWorkingSetSize
;
4926 SIZE_T MaximumWorkingSetSize
;
4927 SIZE_T PagefileLimit
;
4928 LARGE_INTEGER TimeLimit
;
4929 } QUOTA_LIMITS
, *PQUOTA_LIMITS
;
4931 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
4932 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
4933 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
4934 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
4935 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
4937 typedef union _RATE_QUOTA_LIMIT
{
4940 DWORD RatePercent
:7;
4943 } RATE_QUOTA_LIMIT
, *PRATE_QUOTA_LIMIT
;
4945 typedef struct _QUOTA_LIMITS_EX
{
4946 SIZE_T PagedPoolLimit
;
4947 SIZE_T NonPagedPoolLimit
;
4948 SIZE_T MinimumWorkingSetSize
;
4949 SIZE_T MaximumWorkingSetSize
;
4950 SIZE_T PagefileLimit
;
4951 LARGE_INTEGER TimeLimit
;
4952 SIZE_T WorkingSetLimit
;
4957 RATE_QUOTA_LIMIT CpuRateLimit
;
4958 } QUOTA_LIMITS_EX
, *PQUOTA_LIMITS_EX
;
4960 #define SECTION_QUERY 0x0001
4961 #define SECTION_MAP_WRITE 0x0002
4962 #define SECTION_MAP_READ 0x0004
4963 #define SECTION_MAP_EXECUTE 0x0008
4964 #define SECTION_EXTEND_SIZE 0x0010
4965 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
4966 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
4968 #define FILE_READ_DATA 0x0001 /* file & pipe */
4969 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
4970 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
4971 #define FILE_ADD_FILE 0x0002 /* directory */
4972 #define FILE_APPEND_DATA 0x0004 /* file */
4973 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
4974 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
4975 #define FILE_READ_EA 0x0008 /* file & directory */
4976 #define FILE_READ_PROPERTIES FILE_READ_EA
4977 #define FILE_WRITE_EA 0x0010 /* file & directory */
4978 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
4979 #define FILE_EXECUTE 0x0020 /* file */
4980 #define FILE_TRAVERSE 0x0020 /* directory */
4981 #define FILE_DELETE_CHILD 0x0040 /* directory */
4982 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
4983 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
4984 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
4986 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
4987 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
4989 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
4990 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
4991 FILE_APPEND_DATA | SYNCHRONIZE)
4992 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
4993 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
4995 #define DUPLICATE_CLOSE_SOURCE 0x00000001
4996 #define DUPLICATE_SAME_ACCESS 0x00000002
4998 #define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
5001 /* File attribute flags */
5002 #define FILE_SHARE_READ 0x00000001
5003 #define FILE_SHARE_WRITE 0x00000002
5004 #define FILE_SHARE_DELETE 0x00000004
5006 #define FILE_ATTRIBUTE_READONLY 0x00000001
5007 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5008 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5009 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5010 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5011 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5012 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5013 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5014 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5015 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5016 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5017 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5018 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5019 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5020 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5021 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5022 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5023 #define FILE_ATTRIBUTE_EA 0x00040000
5025 /* File notification flags */
5026 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5027 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5028 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5029 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5030 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5031 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5032 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5033 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5034 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5035 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5036 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5037 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5038 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5040 #define FILE_ACTION_ADDED 0x00000001
5041 #define FILE_ACTION_REMOVED 0x00000002
5042 #define FILE_ACTION_MODIFIED 0x00000003
5043 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5044 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5045 #define FILE_ACTION_ADDED_STREAM 0x00000006
5046 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5047 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5048 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5049 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5050 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5052 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5053 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5054 #define FILE_UNICODE_ON_DISK 0x00000004
5055 #define FILE_PERSISTENT_ACLS 0x00000008
5056 #define FILE_FILE_COMPRESSION 0x00000010
5057 #define FILE_VOLUME_QUOTAS 0x00000020
5058 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5059 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5060 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5061 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5062 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5063 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5064 #define FILE_NAMED_STREAMS 0x00040000
5065 #define FILE_READ_ONLY_VOLUME 0x00080000
5066 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5067 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5068 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5069 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5070 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5071 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5072 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5073 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5074 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5075 #define FILE_DAX_VOLUME 0x20000000
5076 #define FILE_SUPPORTS_GHOSTING 0x40000000
5078 /* File alignments (NT) */
5079 #define FILE_BYTE_ALIGNMENT 0x00000000
5080 #define FILE_WORD_ALIGNMENT 0x00000001
5081 #define FILE_LONG_ALIGNMENT 0x00000003
5082 #define FILE_QUAD_ALIGNMENT 0x00000007
5083 #define FILE_OCTA_ALIGNMENT 0x0000000f
5084 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5085 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5086 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5087 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5088 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5090 #define COMPRESSION_FORMAT_NONE 0
5091 #define COMPRESSION_FORMAT_DEFAULT 1
5092 #define COMPRESSION_FORMAT_LZNT1 2
5093 #define COMPRESSION_ENGINE_STANDARD 0
5094 #define COMPRESSION_ENGINE_MAXIMUM 256
5096 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5097 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5099 #define REG_NONE 0 /* no type */
5100 #define REG_SZ 1 /* string type (ASCII) */
5101 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5102 #define REG_BINARY 3 /* binary format, callerspecific */
5103 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5104 #define REG_DWORD 4 /* DWORD in little endian format */
5105 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5106 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5107 #define REG_LINK 6 /* symbolic link (UNICODE) */
5108 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5109 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5110 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5111 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5112 #define REG_QWORD 11 /* QWORD in little endian format */
5113 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5115 /* ----------------------------- begin power management --------------------- */
5117 typedef enum _LATENCY_TIME
{
5120 } LATENCY_TIME
, *PLATENCY_TIME
;
5122 #define DISCHARGE_POLICY_CRITICAL 0
5123 #define DISCHARGE_POLICY_LOW 1
5124 #define NUM_DISCHARGE_POLICIES 4
5126 #define PO_THROTTLE_NONE 0
5127 #define PO_THROTTLE_CONSTANT 1
5128 #define PO_THROTTLE_DEGRADE 2
5129 #define PO_THROTTLE_ADAPTIVE 3
5131 typedef enum _POWER_ACTION
{
5132 PowerActionNone
= 0,
5133 PowerActionReserved
,
5135 PowerActionHibernate
,
5136 PowerActionShutdown
,
5137 PowerActionShutdownReset
,
5138 PowerActionShutdownOff
,
5139 PowerActionWarmEject
5143 typedef enum _POWER_PLATFORM_ROLE
{
5144 PlatformRoleUnspecified
,
5145 PlatformRoleDesktop
,
5147 PlatformRoleWorkstation
,
5148 PlatformRoleEnterpriseServer
,
5149 PlatformRoleSOHOServer
,
5150 PlatformRoleAppliancePC
,
5151 PlatformRolePerformanceServer
,
5154 } POWER_PLATFORM_ROLE
, *PPOWER_PLATFORM_ROLE
;
5156 typedef enum _SYSTEM_POWER_STATE
{
5157 PowerSystemUnspecified
= 0,
5158 PowerSystemWorking
= 1,
5159 PowerSystemSleeping1
= 2,
5160 PowerSystemSleeping2
= 3,
5161 PowerSystemSleeping3
= 4,
5162 PowerSystemHibernate
= 5,
5163 PowerSystemShutdown
= 6,
5164 PowerSystemMaximum
= 7
5165 } SYSTEM_POWER_STATE
,
5166 *PSYSTEM_POWER_STATE
;
5168 typedef enum _DEVICE_POWER_STATE
{
5169 PowerDeviceUnspecified
,
5175 } DEVICE_POWER_STATE
, *PDEVICE_POWER_STATE
;
5177 typedef enum _POWER_INFORMATION_LEVEL
{
5178 SystemPowerPolicyAc
,
5179 SystemPowerPolicyDc
,
5180 VerifySystemPolicyAc
,
5181 VerifySystemPolicyDc
,
5182 SystemPowerCapabilities
,
5184 SystemPowerStateHandler
,
5185 ProcessorStateHandler
,
5186 SystemPowerPolicyCurrent
,
5187 AdministratorPowerPolicy
,
5188 SystemReserveHiberFile
,
5189 ProcessorInformation
,
5190 SystemPowerInformation
,
5191 ProcessorStateHandler2
,
5194 SystemExecutionState
,
5195 SystemPowerStateNotifyHandler
,
5196 ProcessorPowerPolicyAc
,
5197 ProcessorPowerPolicyDc
,
5198 VerifyProcessorPowerPolicyAc
,
5199 VerifyProcessorPowerPolicyDc
,
5200 ProcessorPowerPolicyCurrent
5201 } POWER_INFORMATION_LEVEL
;
5203 typedef struct _ADMINISTRATOR_POWER_POLICY
{
5204 SYSTEM_POWER_STATE MinSleep
;
5205 SYSTEM_POWER_STATE MaxSleep
;
5206 ULONG MinVideoTimeout
;
5207 ULONG MaxVideoTimeout
;
5208 ULONG MinSpindownTimeout
;
5209 ULONG MaxSpindownTimeout
;
5210 } ADMINISTRATOR_POWER_POLICY
, *PADMINISTRATOR_POWER_POLICY
;
5215 } BATTERY_REPORTING_SCALE
,
5216 *PBATTERY_REPORTING_SCALE
;
5219 POWER_ACTION Action
;
5222 } POWER_ACTION_POLICY
,
5223 *PPOWER_ACTION_POLICY
;
5225 typedef struct _PROCESSOR_POWER_INFORMATION
{
5231 ULONG CurrentIdleState
;
5232 } PROCESSOR_POWER_INFORMATION
,
5233 *PPROCESSOR_POWER_INFORMATION
;
5235 typedef struct _PROCESSOR_POWER_POLICY_INFO
{
5239 UCHAR DemotePercent
;
5240 UCHAR PromotePercent
;
5242 ULONG AllowDemotion
:1;
5243 ULONG AllowPromotion
:1;
5245 } PROCESSOR_POWER_POLICY_INFO
,
5246 *PPROCESSOR_POWER_POLICY_INFO
;
5248 typedef struct _PROCESSOR_POWER_POLICY
{
5250 BYTE DynamicThrottle
;
5252 DWORD DisableCStates
:1;
5255 PROCESSOR_POWER_POLICY_INFO Policy
[3];
5256 } PROCESSOR_POWER_POLICY
,
5257 *PPROCESSOR_POWER_POLICY
;
5261 BOOLEAN BatteryPresent
;
5263 BOOLEAN Discharging
;
5267 ULONG RemainingCapacity
;
5269 ULONG EstimatedTime
;
5270 ULONG DefaultAlert1
;
5271 ULONG DefaultAlert2
;
5272 } SYSTEM_BATTERY_STATE
,
5273 *PSYSTEM_BATTERY_STATE
;
5276 BOOLEAN PowerButtonPresent
;
5277 BOOLEAN SleepButtonPresent
;
5284 BOOLEAN HiberFilePresent
;
5286 BOOLEAN VideoDimPresent
;
5289 BOOLEAN ThermalControl
;
5290 BOOLEAN ProcessorThrottle
;
5291 UCHAR ProcessorMinThrottle
;
5292 UCHAR ProcessorMaxThrottle
;
5294 BOOLEAN DiskSpinDown
;
5296 BOOLEAN SystemBatteriesPresent
;
5297 BOOLEAN BatteriesAreShortTerm
;
5298 BATTERY_REPORTING_SCALE BatteryScale
[3];
5299 SYSTEM_POWER_STATE AcOnLineWake
;
5300 SYSTEM_POWER_STATE SoftLidWake
;
5301 SYSTEM_POWER_STATE RtcWake
;
5302 SYSTEM_POWER_STATE MinDeviceWakeState
;
5303 SYSTEM_POWER_STATE DefaultLowLatencyWake
;
5304 } SYSTEM_POWER_CAPABILITIES
,
5305 *PSYSTEM_POWER_CAPABILITIES
;
5307 typedef struct _SYSTEM_POWER_INFORMATION
{
5308 ULONG MaxIdlenessAllowed
;
5310 ULONG TimeRemaining
;
5312 } SYSTEM_POWER_INFORMATION
,
5313 *PSYSTEM_POWER_INFORMATION
;
5315 typedef struct _SYSTEM_POWER_LEVEL
{
5319 POWER_ACTION_POLICY PowerPolicy
;
5320 SYSTEM_POWER_STATE MinSystemState
;
5321 } SYSTEM_POWER_LEVEL
,
5322 *PSYSTEM_POWER_LEVEL
;
5324 typedef struct _SYSTEM_POWER_POLICY
{
5326 POWER_ACTION_POLICY PowerButton
;
5327 POWER_ACTION_POLICY SleepButton
;
5328 POWER_ACTION_POLICY LidClose
;
5329 SYSTEM_POWER_STATE LidOpenWake
;
5331 POWER_ACTION_POLICY Idle
;
5333 UCHAR IdleSensitivity
;
5334 UCHAR DynamicThrottle
;
5336 SYSTEM_POWER_STATE MinSleep
;
5337 SYSTEM_POWER_STATE MaxSleep
;
5338 SYSTEM_POWER_STATE ReducedLatencySleep
;
5339 ULONG WinLogonFlags
;
5341 ULONG DozeS4Timeout
;
5342 ULONG BroadcastCapacityResolution
;
5343 SYSTEM_POWER_LEVEL DischargePolicy
[NUM_DISCHARGE_POLICIES
];
5345 BOOLEAN VideoDimDisplay
;
5346 ULONG VideoReserved
[3];
5347 ULONG SpindownTimeout
;
5348 BOOLEAN OptimizeForPower
;
5349 UCHAR FanThrottleTolerance
;
5350 UCHAR ForcedThrottle
;
5352 POWER_ACTION_POLICY OverThrottled
;
5353 } SYSTEM_POWER_POLICY
,
5354 *PSYSTEM_POWER_POLICY
;
5356 typedef enum _POWER_REQUEST_TYPE
5358 PowerRequestDisplayRequired
,
5359 PowerRequestSystemRequired
,
5360 PowerRequestAwayModeRequired
5361 } POWER_REQUEST_TYPE
, *PPOWER_REQUEST_TYPE
;
5363 #define POWER_REQUEST_CONTEXT_VERSION 0
5365 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5366 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5368 typedef union _FILE_SEGMENT_ELEMENT
{
5370 ULONGLONG Alignment
;
5371 } FILE_SEGMENT_ELEMENT
, *PFILE_SEGMENT_ELEMENT
;
5373 typedef struct _FILE_NOTIFY_INFORMATION
{
5374 DWORD NextEntryOffset
;
5376 DWORD FileNameLength
;
5378 } FILE_NOTIFY_INFORMATION
, *PFILE_NOTIFY_INFORMATION
;
5380 /* ----------------------------- begin tape storage --------------------- */
5382 #define TAPE_FIXED_PARTITIONS 0
5383 #define TAPE_SELECT_PARTITIONS 1
5384 #define TAPE_INITIATOR_PARTITIONS 2
5385 #define TAPE_ERASE_SHORT 0
5386 #define TAPE_ERASE_LONG 1
5388 #define TAPE_UNLOAD 1
5389 #define TAPE_TENSION 2
5391 #define TAPE_UNLOCK 4
5392 #define TAPE_FORMAT 5
5393 #define TAPE_SETMARKS 0
5394 #define TAPE_FILEMARKS 1
5395 #define TAPE_SHORT_FILEMARKS 2
5396 #define TAPE_LONG_FILEMARKS 3
5397 #define TAPE_REWIND 0
5398 #define TAPE_ABSOLUTE_BLOCK 1
5399 #define TAPE_LOGICAL_BLOCK 2
5400 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5401 #define TAPE_SPACE_END_OF_DATA 4
5402 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5403 #define TAPE_SPACE_FILEMARKS 6
5404 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5405 #define TAPE_SPACE_SETMARKS 8
5406 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5408 typedef struct _TAPE_CREATE_PARTITION
{
5412 } TAPE_CREATE_PARTITION
, *PTAPE_CREATE_PARTITION
;
5414 typedef struct _TAPE_ERASE
{
5417 } TAPE_ERASE
, *PTAPE_ERASE
;
5419 typedef struct _TAPE_PREPARE
{
5422 } TAPE_PREPARE
, *PTAPE_PREPARE
;
5424 typedef struct _TAPE_SET_DRIVE_PARAMETERS
{
5426 BOOLEAN Compression
;
5427 BOOLEAN DataPadding
;
5428 BOOLEAN ReportSetmarks
;
5429 ULONG EOTWarningZoneSize
;
5430 } TAPE_SET_DRIVE_PARAMETERS
, *PTAPE_SET_DRIVE_PARAMETERS
;
5432 typedef struct _TAPE_SET_MEDIA_PARAMETERS
{
5434 } TAPE_SET_MEDIA_PARAMETERS
, *PTAPE_SET_MEDIA_PARAMETERS
;
5436 typedef struct _TAPE_WRITE_MARKS
{
5440 } TAPE_WRITE_MARKS
, *PTAPE_WRITE_MARKS
;
5442 typedef struct _TAPE_GET_POSITION
{
5447 } TAPE_GET_POSITION
, *PTAPE_GET_POSITION
;
5449 typedef struct _TAPE_SET_POSITION
{
5452 LARGE_INTEGER Offset
;
5454 } TAPE_SET_POSITION
, *PTAPE_SET_POSITION
;
5456 typedef struct _TAPE_GET_DRIVE_PARAMETERS
{
5458 BOOLEAN Compression
;
5459 BOOLEAN DataPadding
;
5460 BOOLEAN ReportSetmarks
;
5461 DWORD DefaultBlockSize
;
5462 DWORD MaximumBlockSize
;
5463 DWORD MinimumBlockSize
;
5464 DWORD MaximumPartitionCount
;
5467 DWORD EOTWarningZoneSize
;
5468 } TAPE_GET_DRIVE_PARAMETERS
, *PTAPE_GET_DRIVE_PARAMETERS
;
5470 typedef struct _TAPE_GET_MEDIA_PARAMETERS
{
5471 LARGE_INTEGER Capacity
;
5472 LARGE_INTEGER Remaining
;
5474 DWORD PartitionCount
;
5475 BOOLEAN WriteProtected
;
5476 } TAPE_GET_MEDIA_PARAMETERS
, *PTAPE_GET_MEDIA_PARAMETERS
;
5478 /* ----------------------------- begin registry ----------------------------- */
5480 /* Registry security values */
5481 #define OWNER_SECURITY_INFORMATION 0x00000001
5482 #define GROUP_SECURITY_INFORMATION 0x00000002
5483 #define DACL_SECURITY_INFORMATION 0x00000004
5484 #define SACL_SECURITY_INFORMATION 0x00000008
5485 #define LABEL_SECURITY_INFORMATION 0x00000010
5487 #define REG_OPTION_RESERVED 0x00000000
5488 #define REG_OPTION_NON_VOLATILE 0x00000000
5489 #define REG_OPTION_VOLATILE 0x00000001
5490 #define REG_OPTION_CREATE_LINK 0x00000002
5491 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5492 #define REG_OPTION_OPEN_LINK 0x00000008
5493 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
5494 REG_OPTION_NON_VOLATILE | \
5495 REG_OPTION_VOLATILE | \
5496 REG_OPTION_CREATE_LINK | \
5497 REG_OPTION_BACKUP_RESTORE | \
5498 REG_OPTION_OPEN_LINK)
5501 #define REG_CREATED_NEW_KEY 0x00000001
5502 #define REG_OPENED_EXISTING_KEY 0x00000002
5504 /* For RegNotifyChangeKeyValue */
5505 #define REG_NOTIFY_CHANGE_NAME 0x01
5506 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5507 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5508 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5509 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
5511 #define KEY_QUERY_VALUE 0x00000001
5512 #define KEY_SET_VALUE 0x00000002
5513 #define KEY_CREATE_SUB_KEY 0x00000004
5514 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5515 #define KEY_NOTIFY 0x00000010
5516 #define KEY_CREATE_LINK 0x00000020
5517 #define KEY_WOW64_64KEY 0x00000100
5518 #define KEY_WOW64_32KEY 0x00000200
5519 #define KEY_WOW64_RES 0x00000300
5521 /* for RegKeyRestore flags */
5522 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5523 #define REG_REFRESH_HIVE 0x00000002
5524 #define REG_NO_LAZY_FLUSH 0x00000004
5525 #define REG_FORCE_RESTORE 0x00000008
5527 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5529 KEY_ENUMERATE_SUB_KEYS| \
5533 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5535 KEY_CREATE_SUB_KEY) \
5538 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5539 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5542 KEY_CREATE_SUB_KEY| \
5543 KEY_ENUMERATE_SUB_KEYS| \
5548 /* ------------------------------ end registry ------------------------------ */
5551 #define EVENTLOG_SUCCESS 0x0000
5552 #define EVENTLOG_ERROR_TYPE 0x0001
5553 #define EVENTLOG_WARNING_TYPE 0x0002
5554 #define EVENTLOG_INFORMATION_TYPE 0x0004
5555 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5556 #define EVENTLOG_AUDIT_FAILURE 0x0010
5558 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5559 #define EVENTLOG_SEEK_READ 0x0002
5560 #define EVENTLOG_FORWARDS_READ 0x0004
5561 #define EVENTLOG_BACKWARDS_READ 0x0008
5563 typedef struct _EVENTLOGRECORD
{
5567 DWORD TimeGenerated
;
5574 DWORD ClosingRecordNumber
;
5576 DWORD UserSidLength
;
5577 DWORD UserSidOffset
;
5580 } EVENTLOGRECORD
, *PEVENTLOGRECORD
;
5582 #define SERVICE_BOOT_START 0x00000000
5583 #define SERVICE_SYSTEM_START 0x00000001
5584 #define SERVICE_AUTO_START 0x00000002
5585 #define SERVICE_DEMAND_START 0x00000003
5586 #define SERVICE_DISABLED 0x00000004
5588 #define SERVICE_ERROR_IGNORE 0x00000000
5589 #define SERVICE_ERROR_NORMAL 0x00000001
5590 #define SERVICE_ERROR_SEVERE 0x00000002
5591 #define SERVICE_ERROR_CRITICAL 0x00000003
5594 #define SERVICE_KERNEL_DRIVER 0x00000001
5595 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5596 #define SERVICE_ADAPTER 0x00000004
5597 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5599 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5600 SERVICE_RECOGNIZER_DRIVER )
5602 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5603 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5604 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5606 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5608 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5609 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5612 typedef enum _CM_SERVICE_NODE_TYPE
5614 DriverType
= SERVICE_KERNEL_DRIVER
,
5615 FileSystemType
= SERVICE_FILE_SYSTEM_DRIVER
,
5616 Win32ServiceOwnProcess
= SERVICE_WIN32_OWN_PROCESS
,
5617 Win32ServiceShareProcess
= SERVICE_WIN32_SHARE_PROCESS
,
5618 AdapterType
= SERVICE_ADAPTER
,
5619 RecognizerType
= SERVICE_RECOGNIZER_DRIVER
5620 } SERVICE_NODE_TYPE
;
5622 typedef enum _CM_SERVICE_LOAD_TYPE
5624 BootLoad
= SERVICE_BOOT_START
,
5625 SystemLoad
= SERVICE_SYSTEM_START
,
5626 AutoLoad
= SERVICE_AUTO_START
,
5627 DemandLoad
= SERVICE_DEMAND_START
,
5628 DisableLoad
= SERVICE_DISABLED
5629 } SERVICE_LOAD_TYPE
;
5631 typedef enum _CM_ERROR_CONTROL_TYPE
5633 IgnoreError
= SERVICE_ERROR_IGNORE
,
5634 NormalError
= SERVICE_ERROR_NORMAL
,
5635 SevereError
= SERVICE_ERROR_SEVERE
,
5636 CriticalError
= SERVICE_ERROR_CRITICAL
5637 } SERVICE_ERROR_TYPE
;
5639 NTSYSAPI SIZE_T WINAPI
RtlCompareMemory(const VOID
*, const VOID
*, SIZE_T
);
5640 NTSYSAPI SIZE_T WINAPI
RtlCompareMemoryUlong(VOID
*, SIZE_T
, ULONG
);
5642 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5643 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5644 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5645 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5646 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5648 static FORCEINLINE
void *RtlSecureZeroMemory(void *buffer
, SIZE_T length
)
5650 volatile char *ptr
= (volatile char *)buffer
;
5652 while (length
--) *ptr
++ = 0;
5656 #include <guiddef.h>
5658 typedef struct _OBJECT_TYPE_LIST
{
5662 } OBJECT_TYPE_LIST
, *POBJECT_TYPE_LIST
;
5664 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5667 WORD CreatorBackTraceIndex
;
5668 struct _RTL_CRITICAL_SECTION
*CriticalSection
;
5669 LIST_ENTRY ProcessLocksList
;
5671 DWORD ContentionCount
;
5672 #ifdef __WINESRC__ /* in Wine we store the name here */
5673 DWORD_PTR Spare
[8/sizeof(DWORD_PTR
)];
5677 } RTL_CRITICAL_SECTION_DEBUG
, *PRTL_CRITICAL_SECTION_DEBUG
, RTL_RESOURCE_DEBUG
, *PRTL_RESOURCE_DEBUG
;
5679 typedef struct _RTL_CRITICAL_SECTION
{
5680 PRTL_CRITICAL_SECTION_DEBUG DebugInfo
;
5682 LONG RecursionCount
;
5683 HANDLE OwningThread
;
5684 HANDLE LockSemaphore
;
5685 ULONG_PTR SpinCount
;
5686 } RTL_CRITICAL_SECTION
, *PRTL_CRITICAL_SECTION
;
5688 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5689 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5690 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5691 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5692 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5694 typedef struct _RTL_SRWLOCK
{
5696 } RTL_SRWLOCK
, *PRTL_SRWLOCK
;
5698 #define RTL_SRWLOCK_INIT {0}
5700 typedef struct _RTL_CONDITION_VARIABLE
{
5702 } RTL_CONDITION_VARIABLE
, *PRTL_CONDITION_VARIABLE
;
5703 #define RTL_CONDITION_VARIABLE_INIT {0}
5704 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
5706 typedef VOID (NTAPI
* WAITORTIMERCALLBACKFUNC
) (PVOID
, BOOLEAN
);
5707 typedef VOID (NTAPI
* PFLS_CALLBACK_FUNCTION
) ( PVOID
);
5709 #define RTL_RUN_ONCE_INIT {0}
5710 typedef union _RTL_RUN_ONCE
{
5712 } RTL_RUN_ONCE
, *PRTL_RUN_ONCE
;
5714 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
5715 #define RTL_RUN_ONCE_ASYNC 0x00000002
5716 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
5718 typedef DWORD WINAPI
RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE
, PVOID
, PVOID
*);
5719 typedef RTL_RUN_ONCE_INIT_FN
*PRTL_RUN_ONCE_INIT_FN
;
5720 NTSYSAPI VOID WINAPI
RtlRunOnceInitialize(PRTL_RUN_ONCE
);
5721 NTSYSAPI DWORD WINAPI
RtlRunOnceExecuteOnce(PRTL_RUN_ONCE
,PRTL_RUN_ONCE_INIT_FN
,PVOID
,PVOID
*);
5722 NTSYSAPI DWORD WINAPI
RtlRunOnceBeginInitialize(PRTL_RUN_ONCE
, DWORD
, PVOID
*);
5723 NTSYSAPI DWORD WINAPI
RtlRunOnceComplete(PRTL_RUN_ONCE
, DWORD
, PVOID
);
5725 #include <pshpack8.h>
5726 typedef struct _IO_COUNTERS
{
5727 ULONGLONG
DECLSPEC_ALIGN(8) ReadOperationCount
;
5728 ULONGLONG
DECLSPEC_ALIGN(8) WriteOperationCount
;
5729 ULONGLONG
DECLSPEC_ALIGN(8) OtherOperationCount
;
5730 ULONGLONG
DECLSPEC_ALIGN(8) ReadTransferCount
;
5731 ULONGLONG
DECLSPEC_ALIGN(8) WriteTransferCount
;
5732 ULONGLONG
DECLSPEC_ALIGN(8) OtherTransferCount
;
5733 } IO_COUNTERS
, *PIO_COUNTERS
;
5734 #include <poppack.h>
5737 DWORD dwOSVersionInfoSize
;
5738 DWORD dwMajorVersion
;
5739 DWORD dwMinorVersion
;
5740 DWORD dwBuildNumber
;
5742 CHAR szCSDVersion
[128];
5743 } OSVERSIONINFOA
, *POSVERSIONINFOA
, *LPOSVERSIONINFOA
;
5746 DWORD dwOSVersionInfoSize
;
5747 DWORD dwMajorVersion
;
5748 DWORD dwMinorVersion
;
5749 DWORD dwBuildNumber
;
5751 WCHAR szCSDVersion
[128];
5752 } OSVERSIONINFOW
, *POSVERSIONINFOW
, *LPOSVERSIONINFOW
, RTL_OSVERSIONINFOW
, *PRTL_OSVERSIONINFOW
;
5754 DECL_WINELIB_TYPE_AW(OSVERSIONINFO
)
5755 DECL_WINELIB_TYPE_AW(POSVERSIONINFO
)
5756 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO
)
5759 DWORD dwOSVersionInfoSize
;
5760 DWORD dwMajorVersion
;
5761 DWORD dwMinorVersion
;
5762 DWORD dwBuildNumber
;
5764 CHAR szCSDVersion
[128];
5765 WORD wServicePackMajor
;
5766 WORD wServicePackMinor
;
5770 } OSVERSIONINFOEXA
, *POSVERSIONINFOEXA
, *LPOSVERSIONINFOEXA
;
5773 DWORD dwOSVersionInfoSize
;
5774 DWORD dwMajorVersion
;
5775 DWORD dwMinorVersion
;
5776 DWORD dwBuildNumber
;
5778 WCHAR szCSDVersion
[128];
5779 WORD wServicePackMajor
;
5780 WORD wServicePackMinor
;
5784 } OSVERSIONINFOEXW
, *POSVERSIONINFOEXW
, *LPOSVERSIONINFOEXW
, RTL_OSVERSIONINFOEXW
, *PRTL_OSVERSIONINFOEXW
;
5786 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX
)
5787 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX
)
5788 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX
)
5790 NTSYSAPI ULONGLONG WINAPI
VerSetConditionMask(ULONGLONG
,DWORD
,BYTE
);
5792 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5794 #define VER_PLATFORM_WIN32s 0
5795 #define VER_PLATFORM_WIN32_WINDOWS 1
5796 #define VER_PLATFORM_WIN32_NT 2
5798 #define VER_MINORVERSION 0x00000001
5799 #define VER_MAJORVERSION 0x00000002
5800 #define VER_BUILDNUMBER 0x00000004
5801 #define VER_PLATFORMID 0x00000008
5802 #define VER_SERVICEPACKMINOR 0x00000010
5803 #define VER_SERVICEPACKMAJOR 0x00000020
5804 #define VER_SUITENAME 0x00000040
5805 #define VER_PRODUCT_TYPE 0x00000080
5807 #define VER_NT_WORKSTATION 1
5808 #define VER_NT_DOMAIN_CONTROLLER 2
5809 #define VER_NT_SERVER 3
5811 #define VER_SUITE_SMALLBUSINESS 0x00000001
5812 #define VER_SUITE_ENTERPRISE 0x00000002
5813 #define VER_SUITE_BACKOFFICE 0x00000004
5814 #define VER_SUITE_COMMUNICATIONS 0x00000008
5815 #define VER_SUITE_TERMINAL 0x00000010
5816 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5817 #define VER_SUITE_EMBEDDEDNT 0x00000040
5818 #define VER_SUITE_DATACENTER 0x00000080
5819 #define VER_SUITE_SINGLEUSERTS 0x00000100
5820 #define VER_SUITE_PERSONAL 0x00000200
5821 #define VER_SUITE_BLADE 0x00000400
5822 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
5823 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
5824 #define VER_SUITE_STORAGE_SERVER 0x00002000
5825 #define VER_SUITE_COMPUTE_SERVER 0x00004000
5826 #define VER_SUITE_WH_SERVER 0x00008000
5829 #define VER_GREATER 2
5830 #define VER_GREATER_EQUAL 3
5832 #define VER_LESS_EQUAL 5
5836 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION
{
5838 DWORD ulFormatVersion
;
5839 DWORD ulAssemblyCount
;
5840 DWORD ulRootManifestPathType
;
5841 DWORD ulRootManifestPathChars
;
5842 DWORD ulRootConfigurationPathType
;
5843 DWORD ulRootConfigurationPathChars
;
5844 DWORD ulAppDirPathType
;
5845 DWORD ulAppDirPathChars
;
5846 PCWSTR lpRootManifestPath
;
5847 PCWSTR lpRootConfigurationPath
;
5848 PCWSTR lpAppDirPath
;
5849 } ACTIVATION_CONTEXT_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_DETAILED_INFORMATION
;
5851 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
{
5853 DWORD ulEncodedAssemblyIdentityLength
;
5854 DWORD ulManifestPathType
;
5855 DWORD ulManifestPathLength
;
5856 LARGE_INTEGER liManifestLastWriteTime
;
5857 DWORD ulPolicyPathType
;
5858 DWORD ulPolicyPathLength
;
5859 LARGE_INTEGER liPolicyLastWriteTime
;
5860 DWORD ulMetadataSatelliteRosterIndex
;
5861 DWORD ulManifestVersionMajor
;
5862 DWORD ulManifestVersionMinor
;
5863 DWORD ulPolicyVersionMajor
;
5864 DWORD ulPolicyVersionMinor
;
5865 DWORD ulAssemblyDirectoryNameLength
;
5866 PCWSTR lpAssemblyEncodedAssemblyIdentity
;
5867 PCWSTR lpAssemblyManifestPath
;
5868 PCWSTR lpAssemblyPolicyPath
;
5869 PCWSTR lpAssemblyDirectoryName
;
5871 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
;
5873 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX
{
5874 DWORD ulAssemblyIndex
;
5875 DWORD ulFileIndexInAssembly
;
5876 } ACTIVATION_CONTEXT_QUERY_INDEX
, *PACTIVATION_CONTEXT_QUERY_INDEX
;
5878 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX
*PCACTIVATION_CONTEXT_QUERY_INDEX
;
5880 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION
{
5882 DWORD ulFilenameLength
;
5886 } ASSEMBLY_FILE_DETAILED_INFORMATION
, *PASSEMBLY_FILE_DETAILED_INFORMATION
;
5888 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION
*PCASSEMBLY_FILE_DETAILED_INFORMATION
;
5891 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN
= 0,
5892 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
5893 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION
,
5894 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
5895 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE
;
5897 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT
{
5899 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type
;
5900 ULONGLONG MaxVersionTested
;
5901 } COMPATIBILITY_CONTEXT_ELEMENT
, *PCOMPATIBILITY_CONTEXT_ELEMENT
;
5903 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
5904 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
{
5906 COMPATIBILITY_CONTEXT_ELEMENT Elements
[];
5907 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
;
5911 ACTCTX_RUN_LEVEL_UNSPECIFIED
= 0,
5912 ACTCTX_RUN_LEVEL_AS_INVOKER
,
5913 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE
,
5914 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
,
5915 ACTCTX_RUN_LEVEL_NUMBERS
5916 } ACTCTX_REQUESTED_RUN_LEVEL
;
5918 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
{
5920 ACTCTX_REQUESTED_RUN_LEVEL RunLevel
;
5922 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
5924 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
*PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
5926 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS
{
5927 ActivationContextBasicInformation
= 1,
5928 ActivationContextDetailedInformation
= 2,
5929 AssemblyDetailedInformationInActivationContext
= 3,
5930 FileInformationInAssemblyOfAssemblyInActivationContext
= 4,
5931 RunlevelInformationInActivationContext
= 5,
5932 CompatibilityInformationInActivationContext
= 6,
5933 ActivationContextManifestResourceName
= 7,
5934 MaxActivationContextInfoClass
,
5935 AssemblyDetailedInformationInActivationContxt
= AssemblyDetailedInformationInActivationContext
,
5936 FileInformationInAssemblyOfAssemblyInActivationContxt
= FileInformationInAssemblyOfAssemblyInActivationContext
5937 } ACTIVATION_CONTEXT_INFO_CLASS
;
5939 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
5940 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
5941 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
5942 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
5944 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
5945 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
5946 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
5947 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
5948 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
5949 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
5950 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
5951 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
5952 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
5953 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
5954 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
5955 #define ACTIVATION_CONTEXT_SECTION_WINRT_ACTIVATABLE_CLASSES 12
5957 typedef enum _JOBOBJECTINFOCLASS
5959 JobObjectBasicAccountingInformation
= 1,
5960 JobObjectBasicLimitInformation
,
5961 JobObjectBasicProcessIdList
,
5962 JobObjectBasicUIRestrictions
,
5963 JobObjectSecurityLimitInformation
,
5964 JobObjectEndOfJobTimeInformation
,
5965 JobObjectAssociateCompletionPortInformation
,
5966 JobObjectBasicAndIoAccountingInformation
,
5967 JobObjectExtendedLimitInformation
,
5968 JobObjectJobSetInformation
,
5969 MaxJobObjectInfoClass
5970 } JOBOBJECTINFOCLASS
;
5972 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
{
5973 LARGE_INTEGER TotalUserTime
;
5974 LARGE_INTEGER TotalKernelTime
;
5975 LARGE_INTEGER ThisPeriodTotalUserTime
;
5976 LARGE_INTEGER ThisPeriodTotalKernelTime
;
5977 DWORD TotalPageFaultCount
;
5978 DWORD TotalProcesses
;
5979 DWORD ActiveProcesses
;
5980 DWORD TotalTerminatedProcesses
;
5981 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION
;
5983 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION
{
5984 LARGE_INTEGER PerProcessUserTimeLimit
;
5985 LARGE_INTEGER PerJobUserTimeLimit
;
5987 SIZE_T MinimumWorkingSetSize
;
5988 SIZE_T MaximumWorkingSetSize
;
5989 DWORD ActiveProcessLimit
;
5991 DWORD PriorityClass
;
5992 DWORD SchedulingClass
;
5993 } JOBOBJECT_BASIC_LIMIT_INFORMATION
, *PJOBOBJECT_BASIC_LIMIT_INFORMATION
;
5995 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST
{
5996 DWORD NumberOfAssignedProcesses
;
5997 DWORD NumberOfProcessIdsInList
;
5998 ULONG_PTR ProcessIdList
[1];
5999 } JOBOBJECT_BASIC_PROCESS_ID_LIST
, *PJOBOBJECT_BASIC_PROCESS_ID_LIST
;
6001 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS
{
6002 DWORD UIRestrictionsClass
;
6003 } JOBOBJECT_BASIC_UI_RESTRICTIONS
, *PJOBOBJECT_BASIC_UI_RESTRICTIONS
;
6005 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION
{
6006 DWORD SecurityLimitFlags
;
6008 PTOKEN_GROUPS SidsToDisable
;
6009 PTOKEN_PRIVILEGES PrivilegesToDelete
;
6010 PTOKEN_GROUPS RestrictedSids
;
6011 } JOBOBJECT_SECURITY_LIMIT_INFORMATION
, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION
;
6013 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION
{
6014 DWORD EndOfJobTimeAction
;
6015 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION
, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION
;
6017 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT
{
6018 PVOID CompletionKey
;
6019 HANDLE CompletionPort
;
6020 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT
, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT
;
6022 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6023 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6024 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6025 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6026 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6027 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6028 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6029 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6030 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6032 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
{
6033 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo
;
6035 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
;
6037 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION
{
6038 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation
;
6040 SIZE_T ProcessMemoryLimit
;
6041 SIZE_T JobMemoryLimit
;
6042 SIZE_T PeakProcessMemoryUsed
;
6043 SIZE_T PeakJobMemoryUsed
;
6044 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION
, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION
;
6046 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6047 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6048 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6049 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6050 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6051 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6052 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6053 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6054 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6055 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6056 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6057 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6058 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6059 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6060 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6062 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6063 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6064 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6066 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6068 RelationProcessorCore
= 0,
6069 RelationNumaNode
= 1,
6071 RelationProcessorPackage
= 3,
6073 RelationAll
= 0xffff
6074 } LOGICAL_PROCESSOR_RELATIONSHIP
;
6076 #define LTP_PC_SMT 0x1
6078 typedef enum _PROCESSOR_CACHE_TYPE
6084 } PROCESSOR_CACHE_TYPE
;
6086 typedef struct _PROCESSOR_GROUP_INFO
6088 BYTE MaximumProcessorCount
;
6089 BYTE ActiveProcessorCount
;
6091 KAFFINITY ActiveProcessorMask
;
6092 } PROCESSOR_GROUP_INFO
, *PPROCESSOR_GROUP_INFO
;
6094 typedef struct _CACHE_DESCRIPTOR
6100 PROCESSOR_CACHE_TYPE Type
;
6101 } CACHE_DESCRIPTOR
, *PCACHE_DESCRIPTOR
;
6103 typedef struct _GROUP_AFFINITY
6108 } GROUP_AFFINITY
, *PGROUP_AFFINITY
;
6110 #define ALL_PROCESSOR_GROUPS 0xffff
6112 typedef struct _PROCESSOR_NUMBER
6117 } PROCESSOR_NUMBER
, *PPROCESSOR_NUMBER
;
6119 typedef struct _PROCESSOR_RELATIONSHIP
6122 BYTE EfficiencyClass
;
6125 GROUP_AFFINITY GroupMask
[ANYSIZE_ARRAY
];
6126 } PROCESSOR_RELATIONSHIP
, *PPROCESSOR_RELATIONSHIP
;
6128 typedef struct _NUMA_NODE_RELATIONSHIP
6132 GROUP_AFFINITY GroupMask
;
6133 } NUMA_NODE_RELATIONSHIP
, *PNUMA_NODE_RELATIONSHIP
;
6135 typedef struct _CACHE_RELATIONSHIP
6141 PROCESSOR_CACHE_TYPE Type
;
6143 GROUP_AFFINITY GroupMask
;
6144 } CACHE_RELATIONSHIP
, *PCACHE_RELATIONSHIP
;
6146 typedef struct _GROUP_RELATIONSHIP
6148 WORD MaximumGroupCount
;
6149 WORD ActiveGroupCount
;
6151 PROCESSOR_GROUP_INFO GroupInfo
[ANYSIZE_ARRAY
];
6152 } GROUP_RELATIONSHIP
, *PGROUP_RELATIONSHIP
;
6154 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6156 ULONG_PTR ProcessorMask
;
6157 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6168 CACHE_DESCRIPTOR Cache
;
6169 ULONGLONG Reserved
[2];
6171 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION
;
6173 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6175 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6179 PROCESSOR_RELATIONSHIP Processor
;
6180 NUMA_NODE_RELATIONSHIP NumaNode
;
6181 CACHE_RELATIONSHIP Cache
;
6182 GROUP_RELATIONSHIP Group
;
6184 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
;
6186 typedef enum _CPU_SET_INFORMATION_TYPE
6189 } CPU_SET_INFORMATION_TYPE
, *PCPU_SET_INFORMATION_TYPE
;
6191 typedef struct _SYSTEM_CPU_SET_INFORMATION
6194 CPU_SET_INFORMATION_TYPE Type
;
6201 BYTE LogicalProcessorIndex
;
6203 BYTE LastLevelCacheIndex
;
6205 BYTE EfficiencyClass
;
6213 BYTE AllocatedToTargetProcess
: 1;
6215 BYTE ReservedFlags
: 4;
6220 BYTE SchedulingClass
;
6222 DWORD64 AllocationTag
;
6225 } SYSTEM_CPU_SET_INFORMATION
, *PSYSTEM_CPU_SET_INFORMATION
;
6227 /* Threadpool things */
6228 typedef DWORD TP_VERSION
,*PTP_VERSION
;
6230 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE
,*PTP_CALLBACK_INSTANCE
;
6232 typedef VOID (CALLBACK
*PTP_SIMPLE_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
);
6234 typedef struct _TP_POOL TP_POOL
,*PTP_POOL
;
6236 typedef enum _TP_CALLBACK_PRIORITY
6238 TP_CALLBACK_PRIORITY_HIGH
,
6239 TP_CALLBACK_PRIORITY_NORMAL
,
6240 TP_CALLBACK_PRIORITY_LOW
,
6241 TP_CALLBACK_PRIORITY_INVALID
,
6242 TP_CALLBACK_PRIORITY_COUNT
= TP_CALLBACK_PRIORITY_INVALID
6243 } TP_CALLBACK_PRIORITY
;
6245 typedef struct _TP_POOL_STACK_INFORMATION
6247 SIZE_T StackReserve
;
6249 } TP_POOL_STACK_INFORMATION
,*PTP_POOL_STACK_INFORMATION
;
6251 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP
,*PTP_CLEANUP_GROUP
;
6253 typedef VOID (CALLBACK
*PTP_CLEANUP_GROUP_CANCEL_CALLBACK
)(PVOID
,PVOID
);
6255 typedef struct _TP_CALLBACK_ENVIRON_V1
6259 PTP_CLEANUP_GROUP CleanupGroup
;
6260 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6262 struct _ACTIVATION_CONTEXT
* ActivationContext
;
6263 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6269 DWORD LongFunction
:1;
6274 } TP_CALLBACK_ENVIRON_V1
;
6276 typedef struct _TP_CALLBACK_ENVIRON_V3
6280 PTP_CLEANUP_GROUP CleanupGroup
;
6281 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6283 struct _ACTIVATION_CONTEXT
*ActivationContext
;
6284 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6290 DWORD LongFunction
:1;
6295 TP_CALLBACK_PRIORITY CallbackPriority
;
6297 } TP_CALLBACK_ENVIRON_V3
;
6299 typedef struct _TP_WORK TP_WORK
, *PTP_WORK
;
6300 typedef struct _TP_TIMER TP_TIMER
, *PTP_TIMER
;
6302 typedef DWORD TP_WAIT_RESULT
;
6303 typedef struct _TP_WAIT TP_WAIT
, *PTP_WAIT
;
6305 typedef struct _TP_IO TP_IO
, *PTP_IO
;
6307 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON
, *PTP_CALLBACK_ENVIRON
;
6309 typedef VOID (CALLBACK
*PTP_WORK_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WORK
);
6310 typedef VOID (CALLBACK
*PTP_TIMER_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_TIMER
);
6311 typedef VOID (CALLBACK
*PTP_WAIT_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WAIT
,TP_WAIT_RESULT
);
6314 NTSYSAPI BOOLEAN NTAPI
RtlGetProductInfo(DWORD
,DWORD
,DWORD
,DWORD
,PDWORD
);
6316 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6318 UmsThreadInvalidInfoClass
,
6319 UmsThreadUserContext
,
6323 UmsThreadIsSuspended
,
6324 UmsThreadIsTerminated
,
6325 UmsThreadMaxInfoClass
6326 } RTL_UMS_THREAD_INFO_CLASS
, *PRTL_UMS_THREAD_INFO_CLASS
;
6328 typedef enum _RTL_UMS_SCHEDULER_REASON
6330 UmsSchedulerStartup
,
6331 UmsSchedulerThreadBlocked
,
6332 UmsSchedulerThreadYield
,
6333 } RTL_UMS_SCHEDULER_REASON
, *PRTL_UMS_SCHEDULER_REASON
;
6335 typedef void (CALLBACK
*PRTL_UMS_SCHEDULER_ENTRY_POINT
)(RTL_UMS_SCHEDULER_REASON
,ULONG_PTR
,PVOID
);
6337 typedef enum _PROCESS_MITIGATION_POLICY
6341 ProcessDynamicCodePolicy
,
6342 ProcessStrictHandleCheckPolicy
,
6343 ProcessSystemCallDisablePolicy
,
6344 ProcessMitigationOptionsMask
,
6345 ProcessExtensionPointDisablePolicy
,
6346 ProcessControlFlowGuardPolicy
,
6347 ProcessSignaturePolicy
,
6348 ProcessFontDisablePolicy
,
6349 ProcessImageLoadPolicy
,
6350 ProcessSystemCallFilterPolicy
,
6351 ProcessPayloadRestrictionPolicy
,
6352 ProcessChildProcessPolicy
,
6353 ProcessSideChannelIsolationPolicy
,
6354 MaxProcessMitigationPolicy
6355 } PROCESS_MITIGATION_POLICY
, *PPROCESS_MITIGATION_POLICY
;
6358 /* Intrinsic functions */
6360 #define BitScanForward _BitScanForward
6361 #define BitScanReverse _BitScanReverse
6362 #define InterlockedAdd _InlineInterlockedAdd
6363 #define InterlockedAnd _InterlockedAnd
6364 #define InterlockedCompareExchange _InterlockedCompareExchange
6365 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
6366 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
6367 #define InterlockedDecrement _InterlockedDecrement
6368 #define InterlockedDecrement16 _InterlockedDecrement16
6369 #define InterlockedExchange _InterlockedExchange
6370 #define InterlockedExchangeAdd _InterlockedExchangeAdd
6371 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
6372 #define InterlockedExchangePointer _InterlockedExchangePointer
6373 #define InterlockedIncrement _InterlockedIncrement
6374 #define InterlockedIncrement16 _InterlockedIncrement16
6375 #define InterlockedOr _InterlockedOr
6376 #define InterlockedXor _InterlockedXor
6380 #pragma intrinsic(_BitScanForward)
6381 #pragma intrinsic(_BitScanReverse)
6382 #pragma intrinsic(_InterlockedAnd)
6383 #pragma intrinsic(_InterlockedCompareExchange)
6384 #pragma intrinsic(_InterlockedCompareExchange64)
6385 #pragma intrinsic(_InterlockedExchange)
6386 #pragma intrinsic(_InterlockedExchangeAdd)
6387 #pragma intrinsic(_InterlockedIncrement)
6388 #pragma intrinsic(_InterlockedIncrement16)
6389 #pragma intrinsic(_InterlockedDecrement)
6390 #pragma intrinsic(_InterlockedDecrement16)
6391 #pragma intrinsic(_InterlockedOr)
6392 #pragma intrinsic(_InterlockedXor)
6393 #pragma intrinsic(__fastfail)
6395 BOOLEAN
_BitScanForward(unsigned long*,unsigned long);
6396 BOOLEAN
_BitScanReverse(unsigned long*,unsigned long);
6397 long _InterlockedAnd(long volatile *,long);
6398 long _InterlockedCompareExchange(long volatile*,long,long);
6399 long long _InterlockedCompareExchange64(long long volatile*,long long,long long);
6400 long _InterlockedDecrement(long volatile*);
6401 short _InterlockedDecrement16(short volatile*);
6402 long _InterlockedExchange(long volatile*,long);
6403 long _InterlockedExchangeAdd(long volatile*,long);
6404 long _InterlockedIncrement(long volatile*);
6405 short _InterlockedIncrement16(short volatile*);
6406 long _InterlockedOr(long volatile *,long);
6407 long _InterlockedXor(long volatile *,long);
6408 DECLSPEC_NORETURN
void __fastfail(unsigned int);
6410 static FORCEINLINE
long InterlockedAdd( long volatile *dest
, long val
)
6412 return InterlockedExchangeAdd( dest
, val
) + val
;
6415 #if !defined(__i386__) || _MSC_VER >= 1600
6417 #pragma intrinsic(_InterlockedCompareExchangePointer)
6418 #pragma intrinsic(_InterlockedExchangePointer)
6420 void *_InterlockedCompareExchangePointer(void *volatile*,void*,void*);
6421 void *_InterlockedExchangePointer(void *volatile*,void*);
6425 static FORCEINLINE
void * WINAPI
InterlockedCompareExchangePointer( void *volatile *dest
, void *xchg
, void *compare
)
6427 return (void *)_InterlockedCompareExchange( (long volatile*)dest
, (long)xchg
, (long)compare
);
6430 static FORCEINLINE
void * WINAPI
InterlockedExchangePointer( void *volatile *dest
, void *val
)
6432 return (void *)_InterlockedExchange( (long volatile*)dest
, (long)val
);
6435 #endif /* __i386__ */
6439 static FORCEINLINE
void MemoryBarrier(void)
6442 InterlockedOr(&dummy
, 0);
6445 #elif defined(__x86_64__)
6447 #pragma intrinsic(_InterlockedExchangeAdd64)
6448 #pragma intrinsic(__faststorefence)
6450 long long _InterlockedExchangeAdd64(long long volatile *, long long);
6451 void __faststorefence(void);
6453 static FORCEINLINE
void MemoryBarrier(void)
6458 #elif defined(__arm__)
6460 static FORCEINLINE
void MemoryBarrier(void)
6462 __dmb(_ARM_BARRIER_SY
);
6465 #elif defined(__aarch64__)
6467 #pragma intrinsic(_InterlockedExchangeAdd64)
6469 long long _InterlockedExchangeAdd64(long long volatile *, long long);
6471 static FORCEINLINE
void MemoryBarrier(void)
6473 __dmb(_ARM64_BARRIER_SY
);
6476 #endif /* __i386__ */
6478 #elif defined(__GNUC__)
6480 static FORCEINLINE BOOLEAN WINAPI
BitScanForward(DWORD
*index
, DWORD mask
)
6482 *index
= __builtin_ctz( mask
);
6486 static FORCEINLINE BOOLEAN WINAPI
BitScanReverse(DWORD
*index
, DWORD mask
)
6488 *index
= 31 - __builtin_clz( mask
);
6492 static FORCEINLINE LONG WINAPI
InterlockedAdd( LONG
volatile *dest
, LONG val
)
6494 return __sync_add_and_fetch( dest
, val
);
6497 static FORCEINLINE LONG WINAPI
InterlockedAnd( LONG
volatile *dest
, LONG val
)
6499 return __sync_fetch_and_and( dest
, val
);
6502 static FORCEINLINE LONG WINAPI
InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
6504 return __sync_val_compare_and_swap( dest
, compare
, xchg
);
6507 static FORCEINLINE
void * WINAPI
InterlockedCompareExchangePointer( void *volatile *dest
, void *xchg
, void *compare
)
6509 return __sync_val_compare_and_swap( dest
, compare
, xchg
);
6512 static FORCEINLINE LONGLONG WINAPI
InterlockedCompareExchange64( LONGLONG
volatile *dest
, LONGLONG xchg
, LONGLONG compare
)
6514 return __sync_val_compare_and_swap( dest
, compare
, xchg
);
6517 static FORCEINLINE LONG WINAPI
InterlockedExchange( LONG
volatile *dest
, LONG val
)
6520 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
6521 ret
= __atomic_exchange_n( dest
, val
, __ATOMIC_SEQ_CST
);
6522 #elif defined(__i386__) || defined(__x86_64__)
6523 __asm__
__volatile__( "lock; xchgl %0,(%1)"
6524 : "=r" (ret
) :"r" (dest
), "0" (val
) : "memory" );
6526 do ret
= *dest
; while (!__sync_bool_compare_and_swap( dest
, ret
, val
));
6531 static FORCEINLINE LONG WINAPI
InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
6533 return __sync_fetch_and_add( dest
, incr
);
6536 static FORCEINLINE LONGLONG WINAPI
InterlockedExchangeAdd64( LONGLONG
volatile *dest
, LONGLONG incr
)
6538 return __sync_fetch_and_add( dest
, incr
);
6541 static FORCEINLINE LONG WINAPI
InterlockedIncrement( LONG
volatile *dest
)
6543 return __sync_add_and_fetch( dest
, 1 );
6546 static FORCEINLINE
short WINAPI
InterlockedIncrement16( short volatile *dest
)
6548 return __sync_add_and_fetch( dest
, 1 );
6551 static FORCEINLINE LONG WINAPI
InterlockedDecrement( LONG
volatile *dest
)
6553 return __sync_add_and_fetch( dest
, -1 );
6556 static FORCEINLINE
short WINAPI
InterlockedDecrement16( short volatile *dest
)
6558 return __sync_add_and_fetch( dest
, -1 );
6561 static FORCEINLINE
void * WINAPI
InterlockedExchangePointer( void *volatile *dest
, void *val
)
6564 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
6565 ret
= __atomic_exchange_n( dest
, val
, __ATOMIC_SEQ_CST
);
6566 #elif defined(__x86_64__)
6567 __asm__
__volatile__( "lock; xchgq %0,(%1)" : "=r" (ret
) :"r" (dest
), "0" (val
) : "memory" );
6568 #elif defined(__i386__)
6569 __asm__
__volatile__( "lock; xchgl %0,(%1)" : "=r" (ret
) :"r" (dest
), "0" (val
) : "memory" );
6571 do ret
= *dest
; while (!__sync_bool_compare_and_swap( dest
, ret
, val
));
6576 static FORCEINLINE LONG WINAPI
InterlockedOr( LONG
volatile *dest
, LONG val
)
6578 return __sync_fetch_and_or( dest
, val
);
6581 static FORCEINLINE LONG WINAPI
InterlockedXor( LONG
volatile *dest
, LONG val
)
6583 return __sync_fetch_and_xor( dest
, val
);
6586 static FORCEINLINE
void MemoryBarrier(void)
6588 __sync_synchronize();
6591 static FORCEINLINE DECLSPEC_NORETURN
void __fastfail(unsigned int code
)
6593 #if defined(__x86_64__) || defined(__i386__)
6594 for (;;) __asm__
__volatile__( "int $0x29" :: "c" ((ULONG_PTR
)code
) : "memory" );
6595 #elif defined(__aarch64__)
6596 register ULONG_PTR val
__asm__("x0") = code
;
6597 for (;;) __asm__
__volatile__( "brk #0xf003" :: "r" (val
) : "memory" );
6598 #elif defined(__arm__)
6599 register ULONG_PTR val
__asm__("r0") = code
;
6600 for (;;) __asm__
__volatile__( "udf #0xfb" :: "r" (val
) : "memory" );
6604 #endif /* __GNUC__ */
6608 #define InterlockedCompareExchange128 _InterlockedCompareExchange128
6610 #if defined(_MSC_VER) && !defined(__clang__)
6612 #pragma intrinsic(_InterlockedCompareExchange128)
6613 unsigned char _InterlockedCompareExchange128(volatile __int64
*, __int64
, __int64
, __int64
*);
6617 static FORCEINLINE
unsigned char InterlockedCompareExchange128( volatile __int64
*dest
, __int64 xchg_high
, __int64 xchg_low
, __int64
*compare
)
6621 __asm__
__volatile__( "lock cmpxchg16b %0; setz %b2"
6622 : "=m" (dest
[0]), "=m" (dest
[1]), "=r" (ret
),
6623 "=a" (compare
[0]), "=d" (compare
[1])
6624 : "m" (dest
[0]), "m" (dest
[1]), "3" (compare
[0]), "4" (compare
[1]),
6625 "c" (xchg_high
), "b" (xchg_low
) );
6628 return __sync_bool_compare_and_swap( (__int128
*)dest
, *(__int128
*)compare
, ((__int128
)xchg_high
<< 64) | xchg_low
);
6634 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)(a), (b))
6638 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)(a), (b))
6642 static FORCEINLINE
void YieldProcessor(void)
6645 #if defined(__i386__) || defined(__x86_64__)
6646 __asm__
__volatile__( "rep; nop" : : : "memory" );
6647 #elif defined(__arm__) || defined(__aarch64__)
6648 __asm__
__volatile__( "dmb ishst\n\tyield" : : : "memory" );
6650 __asm__
__volatile__( "" : : : "memory" );
6659 #endif /* _WINNT_ */