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>
35 #if defined(_MSC_VER) && (defined(__arm__) || defined(__aarch64__))
47 #define NTSYSAPI DECLSPEC_IMPORT
50 #define NTAPI __stdcall
51 #define FASTCALL __fastcall
54 # if defined(_MSC_VER)
55 # define DECLSPEC_IMPORT __declspec(dllimport)
56 # elif defined(__MINGW32__) || defined(__CYGWIN__)
57 # define DECLSPEC_IMPORT __attribute__((dllimport))
59 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
62 # define DECLSPEC_IMPORT
65 #ifndef DECLSPEC_NORETURN
66 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
67 # define DECLSPEC_NORETURN __declspec(noreturn)
68 # elif defined(__GNUC__)
69 # define DECLSPEC_NORETURN __attribute__((noreturn))
71 # define DECLSPEC_NORETURN
75 #ifndef DECLSPEC_ALIGN
76 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
77 # define DECLSPEC_ALIGN(x) __declspec(align(x))
78 # elif defined(__GNUC__)
79 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
81 # define DECLSPEC_ALIGN(x)
85 #ifndef DECLSPEC_NOTHROW
86 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
87 # define DECLSPEC_NOTHROW __declspec(nothrow)
88 # elif defined(__GNUC__)
89 # define DECLSPEC_NOTHROW __attribute__((nothrow))
91 # define DECLSPEC_NOTHROW
95 #ifndef DECLSPEC_CACHEALIGN
96 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
100 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
101 # define DECLSPEC_UUID(x) __declspec(uuid(x))
103 # define DECLSPEC_UUID(x)
107 #ifndef DECLSPEC_NOVTABLE
108 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
109 # define DECLSPEC_NOVTABLE __declspec(novtable)
111 # define DECLSPEC_NOVTABLE
115 #ifndef DECLSPEC_SELECTANY
116 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
117 #define DECLSPEC_SELECTANY __declspec(selectany)
118 #elif defined(__MINGW32__)
119 #define DECLSPEC_SELECTANY __attribute__((selectany))
121 #define DECLSPEC_SELECTANY
126 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
127 # define NOP_FUNCTION __noop
129 # define NOP_FUNCTION (void)0
133 #ifndef DECLSPEC_ADDRSAFE
134 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
135 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
137 # define DECLSPEC_ADDRSAFE
142 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
143 # define FORCEINLINE __forceinline
144 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
145 # define FORCEINLINE inline __attribute__((always_inline))
147 # define FORCEINLINE inline
151 #ifndef DECLSPEC_DEPRECATED
152 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
153 # define DECLSPEC_DEPRECATED __declspec(deprecated)
154 # define DEPRECATE_SUPPORTED
155 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
156 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
157 # define DEPRECATE_SUPPORTED
159 # define DECLSPEC_DEPRECATED
160 # undef DEPRECATE_SUPPORTED
164 /* a couple of useful Wine extensions */
167 # define DECLSPEC_EXPORT __declspec(dllexport)
168 #elif defined(__MINGW32__)
169 # define DECLSPEC_EXPORT __attribute__((dllexport))
170 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) && !defined(__sun)
171 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
173 # define DECLSPEC_EXPORT
176 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || defined(__sun)
177 # define DECLSPEC_HIDDEN
178 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
179 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
181 # define DECLSPEC_HIDDEN
184 #ifndef __has_attribute
185 # define __has_attribute(x) 0
188 #if ((defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)))) || __has_attribute(ms_hook_prologue)) && (defined(__i386__) || defined(__x86_64__))
189 #define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__))
191 #define DECLSPEC_HOTPATCH
194 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
195 #define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
197 #define __WINE_ALLOC_SIZE(x)
200 /* Anonymous union/struct handling */
202 #ifndef NONAMELESSSTRUCT
204 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
205 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
206 # define NONAMELESSSTRUCT
208 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
209 # define NONAMELESSSTRUCT
211 #endif /* NONAMELESSSTRUCT */
213 #ifndef NONAMELESSUNION
215 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
216 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
217 # define NONAMELESSUNION
219 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
220 # define NONAMELESSUNION
222 #endif /* NONAMELESSUNION */
224 #undef DUMMYSTRUCTNAME
225 #undef DUMMYSTRUCTNAME1
226 #undef DUMMYSTRUCTNAME2
227 #undef DUMMYSTRUCTNAME3
228 #undef DUMMYSTRUCTNAME4
229 #undef DUMMYSTRUCTNAME5
230 #ifndef NONAMELESSSTRUCT
231 #define DUMMYSTRUCTNAME
232 #define DUMMYSTRUCTNAME1
233 #define DUMMYSTRUCTNAME2
234 #define DUMMYSTRUCTNAME3
235 #define DUMMYSTRUCTNAME4
236 #define DUMMYSTRUCTNAME5
237 #else /* !defined(NONAMELESSSTRUCT) */
238 #define DUMMYSTRUCTNAME s
239 #define DUMMYSTRUCTNAME1 s1
240 #define DUMMYSTRUCTNAME2 s2
241 #define DUMMYSTRUCTNAME3 s3
242 #define DUMMYSTRUCTNAME4 s4
243 #define DUMMYSTRUCTNAME5 s5
244 #endif /* !defined(NONAMELESSSTRUCT) */
246 #undef DUMMYUNIONNAME
247 #undef DUMMYUNIONNAME1
248 #undef DUMMYUNIONNAME2
249 #undef DUMMYUNIONNAME3
250 #undef DUMMYUNIONNAME4
251 #undef DUMMYUNIONNAME5
252 #undef DUMMYUNIONNAME6
253 #undef DUMMYUNIONNAME7
254 #undef DUMMYUNIONNAME8
255 #ifndef NONAMELESSUNION
256 #define DUMMYUNIONNAME
257 #define DUMMYUNIONNAME1
258 #define DUMMYUNIONNAME2
259 #define DUMMYUNIONNAME3
260 #define DUMMYUNIONNAME4
261 #define DUMMYUNIONNAME5
262 #define DUMMYUNIONNAME6
263 #define DUMMYUNIONNAME7
264 #define DUMMYUNIONNAME8
265 #else /* !defined(NONAMELESSUNION) */
266 #define DUMMYUNIONNAME u
267 #define DUMMYUNIONNAME1 u1
268 #define DUMMYUNIONNAME2 u2
269 #define DUMMYUNIONNAME3 u3
270 #define DUMMYUNIONNAME4 u4
271 #define DUMMYUNIONNAME5 u5
272 #define DUMMYUNIONNAME6 u6
273 #define DUMMYUNIONNAME7 u7
274 #define DUMMYUNIONNAME8 u8
275 #endif /* !defined(NONAMELESSUNION) */
277 #undef __C89_NAMELESS
278 #undef __C89_NAMELESSSTRUCTNAME
279 #undef __C89_NAMELESSSTRUCTNAME1
280 #undef __C89_NAMELESSSTRUCTNAME2
281 #undef __C89_NAMELESSSTRUCTNAME3
282 #undef __C89_NAMELESSSTRUCTNAME4
283 #undef __C89_NAMELESSSTRUCTNAME5
284 #undef __C89_NAMELESSUNIONNAME
285 #undef __C89_NAMELESSUNIONNAME1
286 #undef __C89_NAMELESSUNIONNAME2
287 #undef __C89_NAMELESSUNIONNAME3
288 #undef __C89_NAMELESSUNIONNAME4
289 #undef __C89_NAMELESSUNIONNAME5
290 #undef __C89_NAMELESSUNIONNAME6
291 #undef __C89_NAMELESSUNIONNAME7
292 #undef __C89_NAMELESSUNIONNAME8
294 #if !defined(WINE_NO_NAMELESS_EXTENSION)
296 /* Anonymous structs support starts with gcc 2.96/g++ 2.95 */
297 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ > 95) || ((__GNUC_MINOR__ == 95) && defined(__cplusplus))))
298 # define __C89_NAMELESS __extension__
300 # elif defined(_MSC_VER)
301 # define __C89_NAMELESS
305 #ifdef __C89_NAMELESS
306 # define __C89_NAMELESSSTRUCTNAME
307 # define __C89_NAMELESSSTRUCTNAME1
308 # define __C89_NAMELESSSTRUCTNAME2
309 # define __C89_NAMELESSSTRUCTNAME3
310 # define __C89_NAMELESSSTRUCTNAME4
311 # define __C89_NAMELESSSTRUCTNAME5
312 # define __C89_NAMELESSUNIONNAME
313 # define __C89_NAMELESSUNIONNAME1
314 # define __C89_NAMELESSUNIONNAME2
315 # define __C89_NAMELESSUNIONNAME3
316 # define __C89_NAMELESSUNIONNAME4
317 # define __C89_NAMELESSUNIONNAME5
318 # define __C89_NAMELESSUNIONNAME6
319 # define __C89_NAMELESSUNIONNAME7
320 # define __C89_NAMELESSUNIONNAME8
322 # define __C89_NAMELESS
323 # define __C89_NAMELESSSTRUCTNAME DUMMYSTRUCTNAME
324 # define __C89_NAMELESSSTRUCTNAME1 DUMMYSTRUCTNAME1
325 # define __C89_NAMELESSSTRUCTNAME2 DUMMYSTRUCTNAME2
326 # define __C89_NAMELESSSTRUCTNAME3 DUMMYSTRUCTNAME3
327 # define __C89_NAMELESSSTRUCTNAME4 DUMMYSTRUCTNAME4
328 # define __C89_NAMELESSSTRUCTNAME5 DUMMYSTRUCTNAME5
329 # define __C89_NAMELESSUNIONNAME DUMMYUNIONNAME
330 # define __C89_NAMELESSUNIONNAME1 DUMMYUNIONNAME1
331 # define __C89_NAMELESSUNIONNAME2 DUMMYUNIONNAME2
332 # define __C89_NAMELESSUNIONNAME3 DUMMYUNIONNAME3
333 # define __C89_NAMELESSUNIONNAME4 DUMMYUNIONNAME4
334 # define __C89_NAMELESSUNIONNAME5 DUMMYUNIONNAME5
335 # define __C89_NAMELESSUNIONNAME6 DUMMYUNIONNAME6
336 # define __C89_NAMELESSUNIONNAME7 DUMMYUNIONNAME7
337 # define __C89_NAMELESSUNIONNAME8 DUMMYUNIONNAME8
340 /* C99 restrict support */
342 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
343 # if defined(_MSC_VER) && defined(_M_MRX000)
344 # define RESTRICTED_POINTER __restrict
345 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
346 # define RESTRICTED_POINTER __restrict
348 # define RESTRICTED_POINTER
351 # define RESTRICTED_POINTER
354 /* C99 unaligned support */
357 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
358 # define UNALIGNED __unaligned
360 # define UNALIGNED64 __unaligned
370 /* Alignment macros */
372 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
373 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
374 #define MEMORY_ALLOCATION_ALIGNMENT 16
376 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
377 #define MEMORY_ALLOCATION_ALIGNMENT 8
380 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
381 # define TYPE_ALIGNMENT(t) __alignof(t)
382 #elif defined(__GNUC__)
383 # define TYPE_ALIGNMENT(t) __alignof__(t)
385 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
389 # define PROBE_ALIGNMENT(_s) \
390 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
391 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
392 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
394 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
397 /* Compile time assertion */
399 #define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
401 /* Eliminate Microsoft C/C++ compiler warning 4715 */
402 #if defined(_MSC_VER) && (_MSC_VER > 1200)
403 # define DEFAULT_UNREACHABLE default: __assume(0)
404 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
405 # define DEFAULT_UNREACHABLE default: __builtin_unreachable()
407 # define DEFAULT_UNREACHABLE default:
411 #define APPLICATION_ERROR_MASK 0x20000000
412 #define ERROR_SEVERITY_SUCCESS 0x00000000
413 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
414 #define ERROR_SEVERITY_WARNING 0x80000000
415 #define ERROR_SEVERITY_ERROR 0xC0000000
418 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
420 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
421 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
422 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \
423 inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
424 inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \
425 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \
426 inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
429 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
432 /* Microsoft's macros for declaring functions */
435 # define EXTERN_C extern "C"
437 # define EXTERN_C extern
440 #define STDMETHODCALLTYPE WINAPI
441 #define STDMETHODVCALLTYPE WINAPIV
442 #define STDAPICALLTYPE WINAPI
443 #define STDAPIVCALLTYPE WINAPIV
445 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
446 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
447 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
448 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
449 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
450 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
451 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
452 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
454 /* Define the basic types */
459 typedef VOID
*PVOID64
;
460 typedef BYTE BOOLEAN
, *PBOOLEAN
;
461 typedef char CHAR
, *PCHAR
;
462 typedef short SHORT
, *PSHORT
;
464 typedef long LONG
, *PLONG
;
466 typedef int LONG
, *PLONG
;
469 /* Some systems might have wchar_t, but we really need 16 bit characters */
470 #if defined(WINE_UNICODE_NATIVE)
471 typedef wchar_t WCHAR
;
472 #elif __cpp_unicode_literals >= 200710
473 typedef char16_t WCHAR
;
475 typedef unsigned short WCHAR
;
477 typedef WCHAR
*PWCHAR
;
479 typedef ULONG UCSCHAR
;
480 #define MIN_UCSCHAR (0)
481 #define MAX_UCSCHAR (0x0010ffff)
482 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
484 /* 'Extended/Wide' numerical types */
488 typedef signed __int64 LONGLONG
, *PLONGLONG
;
489 typedef unsigned __int64 ULONGLONG
, *PULONGLONG
;
491 typedef signed __int64
DECLSPEC_ALIGN(8) LONGLONG
, *PLONGLONG
;
492 typedef unsigned __int64
DECLSPEC_ALIGN(8) ULONGLONG
, *PULONGLONG
;
499 typedef ULONGLONG DWORDLONG
, *PDWORDLONG
;
501 typedef ULONGLONG
DECLSPEC_ALIGN(8) DWORDLONG
, *PDWORDLONG
;
505 /* ANSI string types */
506 typedef CHAR
*PCH
, *LPCH
, *PNZCH
;
507 typedef const CHAR
*PCCH
, *LPCCH
, *PCNZCH
;
508 typedef CHAR
*PSTR
, *LPSTR
, *NPSTR
;
509 typedef const CHAR
*PCSTR
, *LPCSTR
;
510 typedef CHAR
*PZZSTR
;
511 typedef const CHAR
*PCZZSTR
;
513 /* Unicode string types */
514 typedef const WCHAR
*PCWCHAR
, *LPCUWCHAR
, *PCUWCHAR
;
515 typedef WCHAR
*PWCH
, *LPWCH
;
516 typedef const WCHAR
*PCWCH
, *LPCWCH
;
517 typedef WCHAR
*PNZWCH
, *PUNZWCH
;
518 typedef const WCHAR
*PCNZWCH
, *PCUNZWCH
;
519 typedef WCHAR
*PWSTR
, *LPWSTR
, *NWPSTR
;
520 typedef const WCHAR
*PCWSTR
, *LPCWSTR
;
521 typedef WCHAR
*PZZWSTR
, *PUZZWSTR
;
522 typedef const WCHAR
*PCZZWSTR
, *PCUZZWSTR
;
523 typedef PWSTR
*PZPWSTR
;
524 typedef PCWSTR
*PZPCWSTR
;
526 /* Neutral character and string types */
527 /* These are only defined for Winelib, i.e. _not_ defined for
528 * the emulator. The reason is they depend on the UNICODE
529 * macro which only exists in the user's code.
531 #ifndef WINE_NO_UNICODE_MACROS
533 # ifndef _TCHAR_DEFINED
534 typedef WCHAR TCHAR
, *PTCHAR
;
535 # define _TCHAR_DEFINED
537 typedef LPWCH PTCH
, LPTCH
;
538 typedef LPCWCH PCTCH
, LPCTCH
;
539 typedef LPWSTR PTSTR
, LPTSTR
;
540 typedef LPCWSTR PCTSTR
, LPCTSTR
;
541 typedef LPWSTR PUTSTR
, LPUTSTR
;
542 typedef LPCWSTR PCUTSTR
, LPCUTSTR
;
543 typedef PNZWCH PNZTCH
;
544 typedef PUNZWCH PUNZTCH
;
545 typedef PCNZWCH PCNZTCH
;
546 typedef PCUNZWCH PCUNZTCH
;
547 typedef PZZWSTR PZZTSTR
;
548 typedef PCZZWSTR PCZZTSTR
;
549 typedef PUZZWSTR PUZZTSTR
;
550 typedef PCUZZWSTR PCUZZTSTR
;
552 # ifndef _TCHAR_DEFINED
553 typedef CHAR TCHAR
, *PTCHAR
;
554 # define _TCHAR_DEFINED
556 typedef LPCH PTCH
, LPTCH
;
557 typedef LPCCH PCTCH
, LPCTCH
;
558 typedef LPSTR PTSTR
, LPTSTR
;
559 typedef LPCSTR PCTSTR
, LPCTSTR
;
560 typedef PNZCH PNZTCH
, PUNZTCH
;
561 typedef PCNZCH PCNZTCH
, PCUNZTCH
;
562 typedef PZZSTR PZZTSTR
, PUZZTSTR
;
563 typedef PCZZSTR PCZZTSTR
, PCUZZTSTR
;
564 # endif /* UNICODE */
565 #endif /* WINE_NO_UNICODE_MACROS */
567 /* UCS string types */
568 typedef UCSCHAR
*PUCSCHAR
, *PUUCSCHAR
;
569 typedef const UCSCHAR
*PCUCSCHAR
, *PCUUCSCHAR
;
570 typedef UCSCHAR
*PUCSSTR
, *PUUCSSTR
;
571 typedef const UCSCHAR
*PCUCSSTR
, *PCUUCSSTR
;
573 /* Misc common WIN32 types */
575 typedef DWORD LCID
, *PLCID
;
577 typedef DWORD EXECUTION_STATE
;
578 #ifndef _HRESULT_DEFINED
579 #define _HRESULT_DEFINED
580 typedef LONG HRESULT
;
585 typedef void *HANDLE
;
586 typedef HANDLE
*PHANDLE
, *LPHANDLE
;
589 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
591 #define DECLARE_HANDLE(a) typedef HANDLE a
598 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
600 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
601 # define __MSABI_LONG(x) x ## l
603 # define __MSABI_LONG(x) x
609 #ifndef WIN32_NO_STATUS
611 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
612 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
613 #define STATUS_USER_APC ((DWORD) 0x000000C0)
614 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
615 #define STATUS_PENDING ((DWORD) 0x00000103)
616 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
617 #define STATUS_FATAL_APP_EXIT ((DWORD) 0x40000015)
618 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
619 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
620 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
621 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
622 #define STATUS_LONGJUMP ((DWORD) 0x80000026)
623 #define STATUS_UNWIND_CONSOLIDATE ((DWORD) 0x80000029)
624 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
625 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
626 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
627 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
628 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
629 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
630 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
631 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
632 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
633 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
634 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
635 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
636 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
637 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
638 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
639 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
640 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
641 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
642 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
643 #define STATUS_DLL_NOT_FOUND ((DWORD) 0xC0000135)
644 #define STATUS_ORDINAL_NOT_FOUND ((DWORD) 0xC0000138)
645 #define STATUS_ENTRYPOINT_NOT_FOUND ((DWORD) 0xC0000139)
646 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
647 #define STATUS_DLL_INIT_FAILED ((DWORD) 0xC0000142)
648 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
649 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
650 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
651 #define STATUS_HEAP_CORRUPTION ((DWORD) 0xC0000374)
652 #define STATUS_STACK_BUFFER_OVERRUN ((DWORD) 0xC0000409)
653 #define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD) 0xC0000417)
654 #define STATUS_ASSERTION_FAILURE ((DWORD) 0xC0000420)
655 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
656 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
658 /* status values for ContinueDebugEvent */
659 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
660 #define DBG_CONTINUE ((DWORD) 0x00010002)
661 #define DBG_REPLY_LATER ((DWORD) 0x40010001)
662 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
663 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
664 #define DBG_CONTROL_C ((DWORD) 0x40010005)
665 #define DBG_PRINTEXCEPTION_C ((DWORD) 0x40010006)
666 #define DBG_RIPEXCEPTION ((DWORD) 0x40010007)
667 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
668 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
669 #define DBG_PRINTEXCEPTION_WIDE_C ((DWORD) 0x4001000A)
670 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
672 #endif /* WIN32_NO_STATUS */
674 /* Argument 1 passed to the DllEntryProc. */
675 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
676 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
677 #define DLL_THREAD_ATTACH 2 /* attach new thread */
678 #define DLL_THREAD_DETACH 3 /* detach thread */
680 /* u.x.wProcessorArchitecture (NT) */
681 #define PROCESSOR_ARCHITECTURE_INTEL 0
682 #define PROCESSOR_ARCHITECTURE_MIPS 1
683 #define PROCESSOR_ARCHITECTURE_ALPHA 2
684 #define PROCESSOR_ARCHITECTURE_PPC 3
685 #define PROCESSOR_ARCHITECTURE_SHX 4
686 #define PROCESSOR_ARCHITECTURE_ARM 5
687 #define PROCESSOR_ARCHITECTURE_IA64 6
688 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
689 #define PROCESSOR_ARCHITECTURE_MSIL 8
690 #define PROCESSOR_ARCHITECTURE_AMD64 9
691 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
692 #define PROCESSOR_ARCHITECTURE_NEUTRAL 11
693 #define PROCESSOR_ARCHITECTURE_ARM64 12
694 #define PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64 13
695 #define PROCESSOR_ARCHITECTURE_IA32_ON_ARM64 14
696 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
698 /* dwProcessorType */
699 #define PROCESSOR_INTEL_386 386
700 #define PROCESSOR_INTEL_486 486
701 #define PROCESSOR_INTEL_PENTIUM 586
702 #define PROCESSOR_INTEL_860 860
703 #define PROCESSOR_INTEL_IA64 2200
704 #define PROCESSOR_AMD_X8664 8664
705 #define PROCESSOR_MIPS_R2000 2000
706 #define PROCESSOR_MIPS_R3000 3000
707 #define PROCESSOR_MIPS_R4000 4000
708 #define PROCESSOR_ALPHA_21064 21064
709 #define PROCESSOR_PPC_601 601
710 #define PROCESSOR_PPC_603 603
711 #define PROCESSOR_PPC_604 604
712 #define PROCESSOR_PPC_620 620
713 #define PROCESSOR_HITACHI_SH3 10003
714 #define PROCESSOR_HITACHI_SH3E 10004
715 #define PROCESSOR_HITACHI_SH4 10005
716 #define PROCESSOR_MOTOROLA_821 821
717 #define PROCESSOR_SHx_SH3 103
718 #define PROCESSOR_SHx_SH4 104
719 #define PROCESSOR_STRONGARM 2577
720 #define PROCESSOR_ARM720 1824 /* 0x720 */
721 #define PROCESSOR_ARM820 2080 /* 0x820 */
722 #define PROCESSOR_ARM920 2336 /* 0x920 */
723 #define PROCESSOR_ARM_7TDMI 70001
724 #define PROCESSOR_OPTIL 18767
727 #define MAXIMUM_PROCESSORS 64
729 #define MAXIMUM_PROCESSORS 32
732 typedef struct _MEMORY_BASIC_INFORMATION
735 LPVOID AllocationBase
;
736 DWORD AllocationProtect
;
741 } MEMORY_BASIC_INFORMATION
, *PMEMORY_BASIC_INFORMATION
;
743 #define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
745 typedef enum MEM_EXTENDED_PARAMETER_TYPE
{
746 MemExtendedParameterInvalidType
= 0,
747 MemExtendedParameterAddressRequirements
,
748 MemExtendedParameterNumaNode
,
749 MemExtendedParameterPartitionHandle
,
750 MemExtendedParameterUserPhysicalHandle
,
751 MemExtendedParameterAttributeFlags
,
752 MemExtendedParameterMax
753 } MEM_EXTENDED_PARAMETER_TYPE
, *PMEM_EXTENDED_PARAMETER_TYPE
;
755 typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER
{
758 DWORD64 Type
: MEM_EXTENDED_PARAMETER_TYPE_BITS
;
759 DWORD64 Reserved
: 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS
;
770 } MEM_EXTENDED_PARAMETER
, *PMEM_EXTENDED_PARAMETER
;
772 #define PAGE_NOACCESS 0x01
773 #define PAGE_READONLY 0x02
774 #define PAGE_READWRITE 0x04
775 #define PAGE_WRITECOPY 0x08
776 #define PAGE_EXECUTE 0x10
777 #define PAGE_EXECUTE_READ 0x20
778 #define PAGE_EXECUTE_READWRITE 0x40
779 #define PAGE_EXECUTE_WRITECOPY 0x80
780 #define PAGE_GUARD 0x100
781 #define PAGE_NOCACHE 0x200
782 #define PAGE_WRITECOMBINE 0x400
784 #define MEM_COMMIT 0x00001000
785 #define MEM_RESERVE 0x00002000
786 #define MEM_DECOMMIT 0x00004000
787 #define MEM_RELEASE 0x00008000
788 #define MEM_FREE 0x00010000
789 #define MEM_PRIVATE 0x00020000
790 #define MEM_MAPPED 0x00040000
791 #define MEM_RESET 0x00080000
792 #define MEM_TOP_DOWN 0x00100000
793 #define MEM_WRITE_WATCH 0x00200000
794 #define MEM_PHYSICAL 0x00400000
795 #define MEM_LARGE_PAGES 0x20000000
796 #define MEM_4MB_PAGES 0x80000000
798 #define SEC_FILE 0x00800000
799 #define SEC_IMAGE 0x01000000
800 #define SEC_PROTECTED_IMAGE 0x02000000
801 #define SEC_RESERVE 0x04000000
802 #define SEC_COMMIT 0x08000000
803 #define SEC_NOCACHE 0x10000000
804 #define SEC_WRITECOMBINE 0x40000000
805 #define SEC_LARGE_PAGES 0x80000000
806 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
807 #define MEM_IMAGE SEC_IMAGE
809 #define WRITE_WATCH_FLAG_RESET 0x00000001
811 #define AT_ROUND_TO_PAGE 0x40000000
815 #define MINSHORT 0x8000
816 #define MAXSHORT 0x7fff
817 #define MINLONG 0x80000000
818 #define MAXLONG 0x7fffffff
820 #define MAXWORD 0xffff
821 #define MAXDWORD 0xffffffff
822 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
824 #define UNICODE_STRING_MAX_CHARS 32767
826 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
827 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
828 #define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
830 #define CONTAINING_RECORD(address, type, field) \
831 ((type *)((PCHAR)(address) - offsetof(type, field)))
833 #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
835 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
840 typedef struct _LIST_ENTRY
{
841 struct _LIST_ENTRY
*Flink
;
842 struct _LIST_ENTRY
*Blink
;
843 } LIST_ENTRY
, *PLIST_ENTRY
, * RESTRICTED_POINTER PRLIST_ENTRY
;
845 typedef struct _SINGLE_LIST_ENTRY
{
846 struct _SINGLE_LIST_ENTRY
*Next
;
847 } SINGLE_LIST_ENTRY
, *PSINGLE_LIST_ENTRY
;
851 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
{
852 struct _SLIST_ENTRY
*Next
;
853 } SLIST_ENTRY
, *PSLIST_ENTRY
;
855 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
{
862 ULONGLONG Sequence
:9;
863 ULONGLONG NextEntry
:39;
864 ULONGLONG HeaderType
:1;
866 ULONGLONG Reserved
:59;
871 ULONGLONG Sequence
:48;
872 ULONGLONG HeaderType
:1;
874 ULONGLONG Reserved
:2;
875 ULONGLONG NextEntry
:60;
877 } SLIST_HEADER
, *PSLIST_HEADER
;
881 #undef SLIST_ENTRY /* for Mac OS */
882 #define SLIST_ENTRY SINGLE_LIST_ENTRY
883 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
884 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
886 typedef union _SLIST_HEADER
{
893 } SLIST_HEADER
, *PSLIST_HEADER
;
897 NTSYSAPI PSLIST_ENTRY WINAPI
RtlFirstEntrySList(const SLIST_HEADER
*);
898 NTSYSAPI VOID WINAPI
RtlInitializeSListHead(PSLIST_HEADER
);
899 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedFlushSList(PSLIST_HEADER
);
900 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedPopEntrySList(PSLIST_HEADER
);
901 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedPushEntrySList(PSLIST_HEADER
, PSLIST_ENTRY
);
902 NTSYSAPI WORD WINAPI
RtlQueryDepthSList(PSLIST_HEADER
);
907 #define HEAP_NO_SERIALIZE 0x00000001
908 #define HEAP_GROWABLE 0x00000002
909 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
910 #define HEAP_ZERO_MEMORY 0x00000008
911 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
912 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
913 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
914 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
915 #define HEAP_CREATE_ALIGN_16 0x00010000
916 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
917 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
919 /* This flag allows it to create heaps shared by all processes under win95,
920 FIXME: correct name */
921 #define HEAP_SHARED 0x04000000
923 typedef enum _HEAP_INFORMATION_CLASS
{
924 HeapCompatibilityInformation
,
925 } HEAP_INFORMATION_CLASS
;
927 /* Processor feature flags. */
928 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
929 #define PF_FLOATING_POINT_EMULATED 1
930 #define PF_COMPARE_EXCHANGE_DOUBLE 2
931 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
932 #define PF_PPC_MOVEMEM_64BIT_OK 4
933 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
934 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
935 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
936 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
937 #define PF_PAE_ENABLED 9
938 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
939 #define PF_SSE_DAZ_MODE_AVAILABLE 11
940 #define PF_NX_ENABLED 12
941 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
942 #define PF_COMPARE_EXCHANGE128 14
943 #define PF_COMPARE64_EXCHANGE128 15
944 #define PF_CHANNELS_ENABLED 16
945 #define PF_XSAVE_ENABLED 17
946 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
947 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
948 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
949 #define PF_VIRT_FIRMWARE_ENABLED 21
950 #define PF_RDWRFSGSBASE_AVAILABLE 22
951 #define PF_FASTFAIL_AVAILABLE 23
952 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
953 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
954 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
955 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
956 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
957 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
958 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
959 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
960 #define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
961 #define PF_RDPID_INSTRUCTION_AVAILABLE 33
962 #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
963 #define PF_MONITORX_INSTRUCTION_AVAILABLE 35
964 #define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
965 #define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
966 #define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
967 #define PF_AVX_INSTRUCTIONS_AVAILABLE 39
968 #define PF_AVX2_INSTRUCTIONS_AVAILABLE 40
969 #define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
972 /* Execution state flags */
973 #define ES_SYSTEM_REQUIRED 0x00000001
974 #define ES_DISPLAY_REQUIRED 0x00000002
975 #define ES_USER_PRESENT 0x00000004
976 #define ES_CONTINUOUS 0x80000000
981 struct _EXCEPTION_POINTERS
;
982 struct _EXCEPTION_RECORD
;
984 typedef EXCEPTION_DISPOSITION WINAPI
EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD
*,PVOID
,
985 struct _CONTEXT
*,PVOID
);
986 typedef EXCEPTION_ROUTINE
*PEXCEPTION_ROUTINE
;
988 /* The Win32 register context */
990 /* i386 context definitions */
993 #define SIZE_OF_80387_REGISTERS 80
995 typedef struct _FLOATING_SAVE_AREA
1001 DWORD ErrorSelector
;
1004 BYTE RegisterArea
[SIZE_OF_80387_REGISTERS
];
1006 } FLOATING_SAVE_AREA
, *PFLOATING_SAVE_AREA
;
1008 #define MAXIMUM_SUPPORTED_EXTENSION 512
1010 typedef struct _CONTEXT
1012 DWORD ContextFlags
; /* 000 */
1014 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1015 DWORD Dr0
; /* 004 */
1016 DWORD Dr1
; /* 008 */
1017 DWORD Dr2
; /* 00c */
1018 DWORD Dr3
; /* 010 */
1019 DWORD Dr6
; /* 014 */
1020 DWORD Dr7
; /* 018 */
1022 /* These are selected by CONTEXT_FLOATING_POINT */
1023 FLOATING_SAVE_AREA FloatSave
; /* 01c */
1025 /* These are selected by CONTEXT_SEGMENTS */
1026 DWORD SegGs
; /* 08c */
1027 DWORD SegFs
; /* 090 */
1028 DWORD SegEs
; /* 094 */
1029 DWORD SegDs
; /* 098 */
1031 /* These are selected by CONTEXT_INTEGER */
1032 DWORD Edi
; /* 09c */
1033 DWORD Esi
; /* 0a0 */
1034 DWORD Ebx
; /* 0a4 */
1035 DWORD Edx
; /* 0a8 */
1036 DWORD Ecx
; /* 0ac */
1037 DWORD Eax
; /* 0b0 */
1039 /* These are selected by CONTEXT_CONTROL */
1040 DWORD Ebp
; /* 0b4 */
1041 DWORD Eip
; /* 0b8 */
1042 DWORD SegCs
; /* 0bc */
1043 DWORD EFlags
; /* 0c0 */
1044 DWORD Esp
; /* 0c4 */
1045 DWORD SegSs
; /* 0c8 */
1047 BYTE ExtendedRegisters
[MAXIMUM_SUPPORTED_EXTENSION
]; /* 0xcc */
1048 } CONTEXT
, *PCONTEXT
;
1050 #define CONTEXT_X86 0x00010000
1051 #define CONTEXT_i386 CONTEXT_X86
1052 #define CONTEXT_i486 CONTEXT_X86
1054 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1055 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1056 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1057 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1058 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1059 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1060 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x0040)
1061 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
1062 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
1063 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
1065 #define EXCEPTION_READ_FAULT 0
1066 #define EXCEPTION_WRITE_FAULT 1
1067 #define EXCEPTION_EXECUTE_FAULT 8
1069 #endif /* __i386__ */
1071 typedef struct _LDT_ENTRY
{
1082 unsigned BaseMid
: 8;
1086 unsigned LimitHi
: 4;
1088 unsigned Reserved_0
: 1;
1089 unsigned Default_Big
: 1;
1090 unsigned Granularity
: 1;
1091 unsigned BaseHi
: 8;
1094 } LDT_ENTRY
, *PLDT_ENTRY
, WOW64_LDT_ENTRY
, *PWOW64_LDT_ENTRY
;
1096 typedef struct DECLSPEC_ALIGN(16) _M128A
{
1101 typedef struct _XSAVE_FORMAT
{
1102 WORD ControlWord
; /* 000 */
1103 WORD StatusWord
; /* 002 */
1104 BYTE TagWord
; /* 004 */
1105 BYTE Reserved1
; /* 005 */
1106 WORD ErrorOpcode
; /* 006 */
1107 DWORD ErrorOffset
; /* 008 */
1108 WORD ErrorSelector
; /* 00c */
1109 WORD Reserved2
; /* 00e */
1110 DWORD DataOffset
; /* 010 */
1111 WORD DataSelector
; /* 014 */
1112 WORD Reserved3
; /* 016 */
1113 DWORD MxCsr
; /* 018 */
1114 DWORD MxCsr_Mask
; /* 01c */
1115 M128A FloatRegisters
[8]; /* 020 */
1116 M128A XmmRegisters
[16]; /* 0a0 */
1117 BYTE Reserved4
[96]; /* 1a0 */
1118 } XSAVE_FORMAT
, *PXSAVE_FORMAT
;
1120 /* x86-64 context definitions */
1121 #if defined(__x86_64__)
1123 #define CONTEXT_AMD64 0x00100000
1125 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
1126 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
1127 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1128 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1129 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1130 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x0040)
1131 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1132 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1134 #define EXCEPTION_READ_FAULT 0
1135 #define EXCEPTION_WRITE_FAULT 1
1136 #define EXCEPTION_EXECUTE_FAULT 8
1138 typedef XSAVE_FORMAT XMM_SAVE_AREA32
, *PXMM_SAVE_AREA32
;
1140 typedef struct DECLSPEC_ALIGN(16) _CONTEXT
{
1141 DWORD64 P1Home
; /* 000 */
1142 DWORD64 P2Home
; /* 008 */
1143 DWORD64 P3Home
; /* 010 */
1144 DWORD64 P4Home
; /* 018 */
1145 DWORD64 P5Home
; /* 020 */
1146 DWORD64 P6Home
; /* 028 */
1149 DWORD ContextFlags
; /* 030 */
1150 DWORD MxCsr
; /* 034 */
1153 WORD SegCs
; /* 038 */
1154 WORD SegDs
; /* 03a */
1155 WORD SegEs
; /* 03c */
1156 WORD SegFs
; /* 03e */
1157 WORD SegGs
; /* 040 */
1158 WORD SegSs
; /* 042 */
1159 DWORD EFlags
; /* 044 */
1162 DWORD64 Dr0
; /* 048 */
1163 DWORD64 Dr1
; /* 050 */
1164 DWORD64 Dr2
; /* 058 */
1165 DWORD64 Dr3
; /* 060 */
1166 DWORD64 Dr6
; /* 068 */
1167 DWORD64 Dr7
; /* 070 */
1170 DWORD64 Rax
; /* 078 */
1171 DWORD64 Rcx
; /* 080 */
1172 DWORD64 Rdx
; /* 088 */
1173 DWORD64 Rbx
; /* 090 */
1174 DWORD64 Rsp
; /* 098 */
1175 DWORD64 Rbp
; /* 0a0 */
1176 DWORD64 Rsi
; /* 0a8 */
1177 DWORD64 Rdi
; /* 0b0 */
1178 DWORD64 R8
; /* 0b8 */
1179 DWORD64 R9
; /* 0c0 */
1180 DWORD64 R10
; /* 0c8 */
1181 DWORD64 R11
; /* 0d0 */
1182 DWORD64 R12
; /* 0d8 */
1183 DWORD64 R13
; /* 0e0 */
1184 DWORD64 R14
; /* 0e8 */
1185 DWORD64 R15
; /* 0f0 */
1188 DWORD64 Rip
; /* 0f8 */
1190 /* Floating point */
1192 XMM_SAVE_AREA32 FltSave
; /* 100 */
1194 M128A Header
[2]; /* 100 */
1195 M128A Legacy
[8]; /* 120 */
1196 M128A Xmm0
; /* 1a0 */
1197 M128A Xmm1
; /* 1b0 */
1198 M128A Xmm2
; /* 1c0 */
1199 M128A Xmm3
; /* 1d0 */
1200 M128A Xmm4
; /* 1e0 */
1201 M128A Xmm5
; /* 1f0 */
1202 M128A Xmm6
; /* 200 */
1203 M128A Xmm7
; /* 210 */
1204 M128A Xmm8
; /* 220 */
1205 M128A Xmm9
; /* 230 */
1206 M128A Xmm10
; /* 240 */
1207 M128A Xmm11
; /* 250 */
1208 M128A Xmm12
; /* 260 */
1209 M128A Xmm13
; /* 270 */
1210 M128A Xmm14
; /* 280 */
1211 M128A Xmm15
; /* 290 */
1216 M128A VectorRegister
[26]; /* 300 */
1217 DWORD64 VectorControl
; /* 4a0 */
1220 DWORD64 DebugControl
; /* 4a8 */
1221 DWORD64 LastBranchToRip
; /* 4b0 */
1222 DWORD64 LastBranchFromRip
; /* 4b8 */
1223 DWORD64 LastExceptionToRip
; /* 4c0 */
1224 DWORD64 LastExceptionFromRip
; /* 4c8 */
1225 } CONTEXT
, *PCONTEXT
;
1227 typedef struct _RUNTIME_FUNCTION
1232 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1234 #define UNWIND_HISTORY_TABLE_SIZE 12
1236 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1239 PRUNTIME_FUNCTION FunctionEntry
;
1240 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1242 #define UNWIND_HISTORY_TABLE_NONE 0
1243 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1244 #define UNWIND_HISTORY_TABLE_LOCAL 2
1246 typedef struct _UNWIND_HISTORY_TABLE
1251 ULONG64 HighAddress
;
1252 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1253 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1255 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1259 PM128A FloatingContext
[16];
1283 PULONG64 IntegerContext
[16];
1304 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1306 typedef struct _DISPATCHER_CONTEXT
1310 PRUNTIME_FUNCTION FunctionEntry
;
1311 ULONG64 EstablisherFrame
;
1313 PCONTEXT ContextRecord
;
1314 PEXCEPTION_ROUTINE LanguageHandler
;
1316 PUNWIND_HISTORY_TABLE HistoryTable
;
1319 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1321 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,PVOID
);
1322 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,PVOID
);
1324 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(ULONG
,ULONG64
,ULONG64
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,ULONG64
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1326 #define UNW_FLAG_NHANDLER 0
1327 #define UNW_FLAG_EHANDLER 1
1328 #define UNW_FLAG_UHANDLER 2
1329 #define UNW_FLAG_CHAININFO 4
1331 #endif /* __x86_64__ */
1333 #define XSTATE_LEGACY_FLOATING_POINT 0
1334 #define XSTATE_LEGACY_SSE 1
1335 #define XSTATE_GSSE 2
1336 #define XSTATE_AVX XSTATE_GSSE
1337 #define XSTATE_MPX_BNDREGS 3
1338 #define XSTATE_MPX_BNDCSR 4
1339 #define XSTATE_AVX512_KMASK 5
1340 #define XSTATE_AVX512_ZMM_H 6
1341 #define XSTATE_AVX512_ZMM 7
1342 #define XSTATE_IPT 8
1343 #define XSTATE_CET_U 11
1344 #define XSTATE_LWP 62
1345 #define MAXIMUM_XSTATE_FEATURES 64
1347 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1 << XSTATE_LEGACY_FLOATING_POINT)
1348 #define XSTATE_MASK_LEGACY_SSE (1 << XSTATE_LEGACY_SSE)
1349 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1350 #define XSTATE_MASK_GSSE (1 << XSTATE_GSSE)
1352 typedef struct _XSTATE_FEATURE
1356 } XSTATE_FEATURE
, *PXSTATE_FEATURE
;
1358 typedef struct _XSTATE_CONFIGURATION
1360 ULONG64 EnabledFeatures
;
1361 ULONG64 EnabledVolatileFeatures
;
1363 ULONG OptimizedSave
:1;
1364 ULONG CompactionEnabled
:1;
1365 XSTATE_FEATURE Features
[MAXIMUM_XSTATE_FEATURES
];
1367 ULONG64 EnabledSupervisorFeatures
;
1368 ULONG64 AlignedFeatures
;
1369 ULONG AllFeatureSize
;
1370 ULONG AllFeatures
[MAXIMUM_XSTATE_FEATURES
];
1371 ULONG64 EnabledUserVisibleSupervisorFeatures
;
1372 } XSTATE_CONFIGURATION
, *PXSTATE_CONFIGURATION
;
1374 typedef struct _YMMCONTEXT
1393 YMMCONTEXT
, *PYMMCONTEXT
;
1395 typedef struct _XSTATE
1398 ULONG64 CompactionMask
;
1399 ULONG64 Reserved
[6];
1400 YMMCONTEXT YmmContext
;
1403 typedef struct _CONTEXT_CHUNK
1407 } CONTEXT_CHUNK
, *PCONTEXT_CHUNK
;
1409 typedef struct _CONTEXT_EX
1412 CONTEXT_CHUNK Legacy
;
1413 CONTEXT_CHUNK XState
;
1417 } CONTEXT_EX
, *PCONTEXT_EX
;
1419 /* IA64 context definitions */
1422 #define CONTEXT_IA64 0x00080000
1423 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1424 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1425 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1426 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1427 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1428 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1429 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1430 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1431 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1433 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1434 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1435 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1436 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1438 typedef struct _CONTEXT
1633 ULONGLONG RsBSPSTORE
;
1647 ULONGLONG UNUSEDPACK
;
1648 } CONTEXT
, *PCONTEXT
;
1650 typedef struct _RUNTIME_FUNCTION
1654 ULONG UnwindInfoAddress
;
1655 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1657 typedef struct _FRAME_POINTERS
{
1658 ULONGLONG MemoryStackFp
;
1659 ULONGLONG BackingStoreFp
;
1660 } FRAME_POINTERS
, *PFRAME_POINTERS
;
1662 #define UNWIND_HISTORY_TABLE_SIZE 12
1664 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
{
1667 PRUNTIME_FUNCTION FunctionEntry
;
1668 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1670 typedef struct _UNWIND_HISTORY_TABLE
{
1674 ULONG64 HighAddress
;
1675 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1676 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1678 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1684 PFLOAT128 HighFloatingContext
[10];
1706 PULONGLONG IntS0Nat
;
1707 PULONGLONG IntS1Nat
;
1708 PULONGLONG IntS2Nat
;
1709 PULONGLONG IntS3Nat
;
1710 PULONGLONG IntSpNat
;
1726 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1728 NTSYSAPI ULONGLONG WINAPI
RtlVirtualUnwind(ULONGLONG
,ULONGLONG
,RUNTIME_FUNCTION
*,CONTEXT
*,BOOLEAN
*,FRAME_POINTERS
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1730 #endif /* __ia64__ */
1732 /* Alpha context definitions */
1733 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1735 #define CONTEXT_ALPHA 0x00020000
1737 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1738 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1739 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1740 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1742 #define EXCEPTION_READ_FAULT 0
1743 #define EXCEPTION_WRITE_FAULT 1
1744 #define EXCEPTION_EXECUTE_FAULT 8
1746 typedef struct _CONTEXT
1748 /* selected by CONTEXT_FLOATING_POINT */
1782 /* selected by CONTEXT_INTEGER */
1816 /* selected by CONTEXT_FLOATING_POINT */
1820 /* selected by CONTEXT_CONTROL */
1825 } CONTEXT
, *PCONTEXT
;
1827 #define _QUAD_PSR_OFFSET HighSoftFpcr
1828 #define _QUAD_FLAGS_OFFSET HighFir
1830 #endif /* _ALPHA_ */
1834 /* The following flags control the contents of the CONTEXT structure. */
1836 #define CONTEXT_ARM 0x0200000
1837 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1838 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1839 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1840 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1842 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1843 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1845 #define EXCEPTION_READ_FAULT 0
1846 #define EXCEPTION_WRITE_FAULT 1
1847 #define EXCEPTION_EXECUTE_FAULT 8
1849 #define ARM_MAX_BREAKPOINTS 8
1850 #define ARM_MAX_WATCHPOINTS 1
1852 typedef struct _RUNTIME_FUNCTION
1859 DWORD FunctionLength
: 11;
1866 DWORD StackAdjust
: 10;
1869 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1871 #define UNWIND_HISTORY_TABLE_SIZE 12
1873 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1876 PRUNTIME_FUNCTION FunctionEntry
;
1877 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1879 typedef struct _UNWIND_HISTORY_TABLE
1888 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1889 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1891 typedef struct _NEON128
1895 } NEON128
, *PNEON128
;
1897 typedef struct _CONTEXT
1899 ULONG ContextFlags
; /* 000 */
1900 /* CONTEXT_INTEGER */
1911 ULONG R10
; /* 02c */
1912 ULONG R11
; /* 030 */
1913 ULONG R12
; /* 034 */
1914 /* CONTEXT_CONTROL */
1918 ULONG Cpsr
; /* 044 */
1919 /* CONTEXT_FLOATING_POINT */
1920 ULONG Fpscr
; /* 048 */
1921 ULONG Padding
; /* 04c */
1927 } DUMMYUNIONNAME
; /* 050 */
1928 /* CONTEXT_DEBUG_REGISTERS */
1929 ULONG Bvr
[ARM_MAX_BREAKPOINTS
]; /* 150 */
1930 ULONG Bcr
[ARM_MAX_BREAKPOINTS
]; /* 170 */
1931 ULONG Wvr
[ARM_MAX_WATCHPOINTS
]; /* 190 */
1932 ULONG Wcr
[ARM_MAX_WATCHPOINTS
]; /* 194 */
1933 ULONG Padding2
[2]; /* 198 */
1934 } CONTEXT
, *PCONTEXT
;
1936 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1955 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1957 typedef struct _DISPATCHER_CONTEXT
1961 PRUNTIME_FUNCTION FunctionEntry
;
1962 DWORD EstablisherFrame
;
1964 PCONTEXT ContextRecord
;
1965 PEXCEPTION_ROUTINE LanguageHandler
;
1967 PUNWIND_HISTORY_TABLE HistoryTable
;
1969 BOOLEAN ControlPcIsUnwound
;
1970 PBYTE NonVolatileRegisters
;
1972 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1974 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD
);
1975 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD
);
1977 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,DWORD
,DWORD
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,DWORD
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1979 #define UNW_FLAG_NHANDLER 0
1980 #define UNW_FLAG_EHANDLER 1
1981 #define UNW_FLAG_UHANDLER 2
1983 #endif /* __arm__ */
1987 #define CONTEXT_ARM64 0x400000
1988 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1989 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1990 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1991 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1992 #define CONTEXT_ARM64_X18 (CONTEXT_ARM64 | 0x00000010)
1994 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1996 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1997 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_ARM64_X18)
1999 #define EXCEPTION_READ_FAULT 0
2000 #define EXCEPTION_WRITE_FAULT 1
2001 #define EXCEPTION_EXECUTE_FAULT 8
2003 #define ARM64_MAX_BREAKPOINTS 8
2004 #define ARM64_MAX_WATCHPOINTS 2
2006 typedef struct _RUNTIME_FUNCTION
2015 DWORD FunctionLength
: 11;
2020 DWORD FrameSize
: 9;
2023 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
2025 #define UNWIND_HISTORY_TABLE_SIZE 12
2027 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
2030 PRUNTIME_FUNCTION FunctionEntry
;
2031 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
2033 typedef struct _UNWIND_HISTORY_TABLE
2041 DWORD64 HighAddress
;
2042 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
2043 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
2045 typedef union _NEON128
2056 } NEON128
, *PNEON128
;
2058 typedef struct _CONTEXT
2060 ULONG ContextFlags
; /* 000 */
2061 /* CONTEXT_INTEGER */
2062 ULONG Cpsr
; /* 004 */
2067 DWORD64 X0
; /* 008 */
2068 DWORD64 X1
; /* 010 */
2069 DWORD64 X2
; /* 018 */
2070 DWORD64 X3
; /* 020 */
2071 DWORD64 X4
; /* 028 */
2072 DWORD64 X5
; /* 030 */
2073 DWORD64 X6
; /* 038 */
2074 DWORD64 X7
; /* 040 */
2075 DWORD64 X8
; /* 048 */
2076 DWORD64 X9
; /* 050 */
2077 DWORD64 X10
; /* 058 */
2078 DWORD64 X11
; /* 060 */
2079 DWORD64 X12
; /* 068 */
2080 DWORD64 X13
; /* 070 */
2081 DWORD64 X14
; /* 078 */
2082 DWORD64 X15
; /* 080 */
2083 DWORD64 X16
; /* 088 */
2084 DWORD64 X17
; /* 090 */
2085 DWORD64 X18
; /* 098 */
2086 DWORD64 X19
; /* 0a0 */
2087 DWORD64 X20
; /* 0a8 */
2088 DWORD64 X21
; /* 0b0 */
2089 DWORD64 X22
; /* 0b8 */
2090 DWORD64 X23
; /* 0c0 */
2091 DWORD64 X24
; /* 0c8 */
2092 DWORD64 X25
; /* 0d0 */
2093 DWORD64 X26
; /* 0d8 */
2094 DWORD64 X27
; /* 0e0 */
2095 DWORD64 X28
; /* 0e8 */
2096 DWORD64 Fp
; /* 0f0 */
2097 DWORD64 Lr
; /* 0f8 */
2099 DWORD64 X
[31]; /* 008 */
2101 /* CONTEXT_CONTROL */
2102 DWORD64 Sp
; /* 100 */
2103 DWORD64 Pc
; /* 108 */
2104 /* CONTEXT_FLOATING_POINT */
2105 NEON128 V
[32]; /* 110 */
2106 DWORD Fpcr
; /* 310 */
2107 DWORD Fpsr
; /* 314 */
2108 /* CONTEXT_DEBUG_REGISTERS */
2109 DWORD Bcr
[ARM64_MAX_BREAKPOINTS
]; /* 318 */
2110 DWORD64 Bvr
[ARM64_MAX_BREAKPOINTS
]; /* 338 */
2111 DWORD Wcr
[ARM64_MAX_WATCHPOINTS
]; /* 378 */
2112 DWORD64 Wvr
[ARM64_MAX_WATCHPOINTS
]; /* 380 */
2113 } CONTEXT
, *PCONTEXT
;
2115 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
2137 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
2139 typedef struct _DISPATCHER_CONTEXT
2141 ULONG_PTR ControlPc
;
2142 ULONG_PTR ImageBase
;
2143 PRUNTIME_FUNCTION FunctionEntry
;
2144 ULONG_PTR EstablisherFrame
;
2146 PCONTEXT ContextRecord
;
2147 PEXCEPTION_ROUTINE LanguageHandler
;
2149 PUNWIND_HISTORY_TABLE HistoryTable
;
2151 BOOLEAN ControlPcIsUnwound
;
2152 PBYTE NonVolatileRegisters
;
2153 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
2155 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD64
);
2156 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD64
);
2158 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,ULONG_PTR
,ULONG_PTR
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,ULONG_PTR
*,KNONVOLATILE_CONTEXT_POINTERS
*);
2160 #define UNW_FLAG_NHANDLER 0
2161 #define UNW_FLAG_EHANDLER 1
2162 #define UNW_FLAG_UHANDLER 2
2164 #endif /* __aarch64__ */
2167 /* Mips context definitions */
2168 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
2170 #define CONTEXT_R4000 0x00010000
2172 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
2173 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
2174 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
2176 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2178 #define EXCEPTION_READ_FAULT 0
2179 #define EXCEPTION_WRITE_FAULT 1
2180 #define EXCEPTION_EXECUTE_FAULT 8
2182 typedef struct _CONTEXT
2185 /* These are selected by CONTEXT_FLOATING_POINT */
2219 /* These are selected by CONTEXT_INTEGER */
2255 /* These are selected by CONTEXT_FLOATING_POINT */
2258 /* These are selected by CONTEXT_CONTROL */
2264 } CONTEXT
, *PCONTEXT
;
2268 /* PowerPC context definitions */
2271 #define CONTEXT_CONTROL 0x0001
2272 #define CONTEXT_FLOATING_POINT 0x0002
2273 #define CONTEXT_INTEGER 0x0004
2274 #define CONTEXT_DEBUG_REGISTERS 0x0008
2275 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2277 #define EXCEPTION_READ_FAULT 0
2278 #define EXCEPTION_WRITE_FAULT 1
2279 #define EXCEPTION_EXECUTE_FAULT 8
2283 /* These are selected by CONTEXT_FLOATING_POINT */
2318 /* These are selected by CONTEXT_INTEGER */
2355 /* These are selected by CONTEXT_CONTROL */
2357 DWORD Iar
; /* Instruction Address Register , aka PC ... */
2363 DWORD Dar
; /* Fault registers for coredump */
2365 DWORD Trap
; /* number of powerpc exception taken */
2367 /* These are selected by CONTEXT_DEBUG_REGISTERS */
2376 } CONTEXT
, *PCONTEXT
;
2378 typedef struct _STACK_FRAME_HEADER
2395 } STACK_FRAME_HEADER
,*PSTACK_FRAME_HEADER
;
2397 #endif /* __powerpc__ */
2399 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2400 #error You need to define a CONTEXT for your CPU
2403 NTSYSAPI
void WINAPI
RtlCaptureContext(CONTEXT
*);
2405 #define WOW64_CONTEXT_i386 0x00010000
2406 #define WOW64_CONTEXT_i486 0x00010000
2407 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
2408 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
2409 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
2410 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
2411 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
2412 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
2413 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2414 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
2415 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
2416 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
2417 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
2419 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2421 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
2422 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
2423 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
2424 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
2426 #define WOW64_SIZE_OF_80387_REGISTERS 80
2427 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
2429 typedef struct _WOW64_FLOATING_SAVE_AREA
2435 DWORD ErrorSelector
;
2438 BYTE RegisterArea
[WOW64_SIZE_OF_80387_REGISTERS
];
2440 } WOW64_FLOATING_SAVE_AREA
, *PWOW64_FLOATING_SAVE_AREA
;
2442 #include "pshpack4.h"
2443 typedef struct _WOW64_CONTEXT
2452 WOW64_FLOATING_SAVE_AREA FloatSave
;
2469 BYTE ExtendedRegisters
[WOW64_MAXIMUM_SUPPORTED_EXTENSION
];
2470 } WOW64_CONTEXT
, *PWOW64_CONTEXT
;
2471 #include "poppack.h"
2473 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
2475 typedef PRUNTIME_FUNCTION (CALLBACK
*PGET_RUNTIME_FUNCTION_CALLBACK
)(DWORD_PTR
,PVOID
);
2477 NTSYSAPI BOOLEAN CDECL
RtlAddFunctionTable(RUNTIME_FUNCTION
*,DWORD
,DWORD_PTR
);
2478 NTSYSAPI DWORD WINAPI
RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION
,DWORD
,DWORD
,ULONG_PTR
,ULONG_PTR
);
2479 NTSYSAPI BOOLEAN CDECL
RtlDeleteFunctionTable(RUNTIME_FUNCTION
*);
2480 NTSYSAPI
void WINAPI
RtlDeleteGrowableFunctionTable(void*);
2481 NTSYSAPI
void WINAPI
RtlGrowFunctionTable(void*,DWORD
);
2482 NTSYSAPI BOOLEAN CDECL
RtlInstallFunctionTableCallback(DWORD_PTR
,DWORD_PTR
,DWORD
,PGET_RUNTIME_FUNCTION_CALLBACK
,PVOID
,PCWSTR
);
2483 NTSYSAPI PRUNTIME_FUNCTION WINAPI
RtlLookupFunctionEntry(DWORD_PTR
,DWORD_PTR
*,UNWIND_HISTORY_TABLE
*);
2484 NTSYSAPI
void WINAPI
RtlUnwindEx(PVOID
,PVOID
,struct _EXCEPTION_RECORD
*,PVOID
,CONTEXT
*,UNWIND_HISTORY_TABLE
*);
2490 #define PRODUCT_UNDEFINED 0x00000000
2491 #define PRODUCT_ULTIMATE 0x00000001
2492 #define PRODUCT_HOME_BASIC 0x00000002
2493 #define PRODUCT_HOME_PREMIUM 0x00000003
2494 #define PRODUCT_ENTERPRISE 0x00000004
2495 #define PRODUCT_HOME_BASIC_N 0x00000005
2496 #define PRODUCT_BUSINESS 0x00000006
2497 #define PRODUCT_STANDARD_SERVER 0x00000007
2498 #define PRODUCT_DATACENTER_SERVER 0x00000008
2499 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2500 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2501 #define PRODUCT_STARTER 0x0000000B
2502 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2503 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2504 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2505 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2506 #define PRODUCT_BUSINESS_N 0x00000010
2507 #define PRODUCT_WEB_SERVER 0x00000011
2508 #define PRODUCT_CLUSTER_SERVER 0x00000012
2509 #define PRODUCT_HOME_SERVER 0x00000013
2510 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2511 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2512 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2513 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2514 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2515 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2516 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2517 #define PRODUCT_ENTERPRISE_N 0x0000001B
2518 #define PRODUCT_ULTIMATE_N 0x0000001C
2519 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2520 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2521 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2522 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2523 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2524 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2525 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2526 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2527 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2528 #define PRODUCT_SERVER_V 0x00000025
2529 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2530 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2531 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2532 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2533 #define PRODUCT_HYPERV 0x0000002A
2534 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2535 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2536 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2537 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2538 #define PRODUCT_STARTER_N 0x0000002F
2539 #define PRODUCT_PROFESSIONAL 0x00000030
2540 #define PRODUCT_PROFESSIONAL_N 0x00000031
2541 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2542 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2543 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2544 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2545 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2546 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2547 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2548 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2549 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2550 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2551 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2552 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2553 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2554 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2555 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2556 #define PRODUCT_EMBEDDED 0x00000041
2557 #define PRODUCT_STARTER_E 0x00000042
2558 #define PRODUCT_HOME_BASIC_E 0x00000043
2559 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2560 #define PRODUCT_PROFESSIONAL_E 0x00000045
2561 #define PRODUCT_ENTERPRISE_E 0x00000046
2562 #define PRODUCT_ULTIMATE_E 0x00000047
2563 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2564 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2565 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2566 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2567 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2568 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2569 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2570 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2571 #define PRODUCT_THINPC 0x00000057
2572 #define PRODUCT_EMBEDDED_A 0x00000058
2573 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2574 #define PRODUCT_EMBEDDED_E 0x0000005A
2575 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2576 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2577 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2578 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2579 #define PRODUCT_CORE_ARM 0x00000061
2580 #define PRODUCT_CORE_N 0x00000062
2581 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2582 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2583 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2584 #define PRODUCT_CORE 0x00000065
2585 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2586 #define PRODUCT_MOBILE_CORE 0x00000068
2587 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2588 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2589 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2590 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2591 #define PRODUCT_NANO_SERVER 0x0000006D
2592 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2593 #define PRODUCT_CORE_CONNECTED 0x0000006F
2594 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2595 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2596 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2597 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2598 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2599 #define PRODUCT_CONNECTED_CAR 0x00000075
2600 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2601 #define PRODUCT_PPI_PRO 0x00000077
2602 #define PRODUCT_ARM64_SERVER 0x00000078
2603 #define PRODUCT_EDUCATION 0x00000079
2604 #define PRODUCT_EDUCATION_N 0x0000007A
2605 #define PRODUCT_IOTUAP 0x0000007B
2606 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2607 #define PRODUCT_ENTERPRISE_S 0x0000007D
2608 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2609 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2610 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2611 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2612 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2613 #define PRODUCT_UNLICENSED 0xABCDABCD
2620 #define MAKELCID(l, s) (MAKELONG(l, s))
2622 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2623 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2624 #define SUBLANGID(l) ((WORD)(l) >> 10)
2626 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2627 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2629 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2630 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2631 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2632 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2633 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2634 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2635 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2636 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2637 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2638 #define LOCALE_NAME_MAX_LENGTH 85
2641 #define UNREFERENCED_PARAMETER(u) (void)(u)
2642 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2643 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2649 * Definitions for IsTextUnicode()
2652 #define IS_TEXT_UNICODE_ASCII16 0x0001
2653 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2654 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2655 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2656 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2657 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2658 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2659 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2660 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2661 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2662 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2663 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2664 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2665 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2666 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2667 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2669 #define MAXIMUM_WAIT_OBJECTS 64
2670 #define MAXIMUM_SUSPEND_COUNT 127
2672 #define WT_EXECUTEDEFAULT 0x00
2673 #define WT_EXECUTEINIOTHREAD 0x01
2674 #define WT_EXECUTEINUITHREAD 0x02
2675 #define WT_EXECUTEINWAITTHREAD 0x04
2676 #define WT_EXECUTEONLYONCE 0x08
2677 #define WT_EXECUTELONGFUNCTION 0x10
2678 #define WT_EXECUTEINTIMERTHREAD 0x20
2679 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2680 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2681 #define WT_EXECUTEINLONGTHREAD 0x10
2682 #define WT_EXECUTEDELETEWAIT 0x08
2683 #define WT_TRANSFER_IMPERSONATION 0x0100
2686 #define EXCEPTION_CONTINUABLE 0
2687 #define EXCEPTION_NONCONTINUABLE 0x01
2690 * The exception record used by Win32 to give additional information
2691 * about exception to exception handlers.
2694 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2696 typedef struct _EXCEPTION_RECORD
2698 DWORD ExceptionCode
;
2699 DWORD ExceptionFlags
;
2700 struct _EXCEPTION_RECORD
*ExceptionRecord
;
2702 PVOID ExceptionAddress
;
2703 DWORD NumberParameters
;
2704 ULONG_PTR ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2705 } EXCEPTION_RECORD
, *PEXCEPTION_RECORD
;
2707 typedef struct _EXCEPTION_RECORD32
2709 DWORD ExceptionCode
;
2710 DWORD ExceptionFlags
;
2711 DWORD ExceptionRecord
;
2712 DWORD ExceptionAddress
;
2713 DWORD NumberParameters
;
2714 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2715 } EXCEPTION_RECORD32
, *PEXCEPTION_RECORD32
;
2717 typedef struct _EXCEPTION_RECORD64
2719 DWORD ExceptionCode
;
2720 DWORD ExceptionFlags
;
2721 DWORD64 ExceptionRecord
;
2722 DWORD64 ExceptionAddress
;
2723 DWORD NumberParameters
;
2724 DWORD __unusedAlignment
;
2725 DWORD64 ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2726 } EXCEPTION_RECORD64
, *PEXCEPTION_RECORD64
;
2729 * The exception pointers structure passed to exception filters
2730 * in except() and the UnhandledExceptionFilter().
2733 typedef struct _EXCEPTION_POINTERS
2735 PEXCEPTION_RECORD ExceptionRecord
;
2736 PCONTEXT ContextRecord
;
2737 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
;
2741 * The exception frame, used for registering exception handlers
2742 * Win32 cares only about this, but compilers generally emit
2743 * larger exception frames for their own use.
2746 struct _EXCEPTION_REGISTRATION_RECORD
;
2748 typedef DWORD (CDECL
*PEXCEPTION_HANDLER
)(PEXCEPTION_RECORD
,struct _EXCEPTION_REGISTRATION_RECORD
*,
2749 PCONTEXT
,struct _EXCEPTION_REGISTRATION_RECORD
**);
2751 typedef struct _EXCEPTION_REGISTRATION_RECORD
2753 struct _EXCEPTION_REGISTRATION_RECORD
*Prev
;
2754 PEXCEPTION_HANDLER Handler
;
2755 } EXCEPTION_REGISTRATION_RECORD
;
2758 * function pointer to an exception filter
2761 typedef LONG (CALLBACK
*PVECTORED_EXCEPTION_HANDLER
)(PEXCEPTION_POINTERS ExceptionInfo
);
2763 typedef struct _NT_TIB
2765 struct _EXCEPTION_REGISTRATION_RECORD
*ExceptionList
;
2773 PVOID ArbitraryUserPointer
;
2774 struct _NT_TIB
*Self
;
2779 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2780 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2783 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb
));
2786 #elif defined(__i386__) && defined(_MSC_VER)
2787 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2790 __asm mov eax
, fs
:[0x18];
2794 #elif defined(__x86_64__) && defined(__GNUC__)
2795 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2798 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb
));
2801 #elif defined(__x86_64__) && defined(_MSC_VER)
2802 unsigned __int64
__readgsqword(unsigned long);
2803 #pragma intrinsic(__readgsqword)
2804 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2806 return (struct _TEB
*)__readgsqword(FIELD_OFFSET(NT_TIB
, Self
));
2808 #elif defined(__arm__) && defined(__GNUC__)
2809 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2812 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb
));
2815 #elif defined(__arm__) && defined(_MSC_VER)
2816 #pragma intrinsic(_MoveFromCoprocessor)
2817 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2819 return (struct _TEB
*)(ULONG_PTR
)_MoveFromCoprocessor(15, 0, 13, 0, 2);
2822 extern struct _TEB
* WINAPI
NtCurrentTeb(void);
2825 #ifdef NONAMELESSUNION
2826 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2828 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2830 #define GetFiberData() (*(void **)GetCurrentFiber())
2832 #define TLS_MINIMUM_AVAILABLE 64
2834 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2836 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2837 #define IO_REPARSE_TAG_RESERVED_ONE 1
2838 #define IO_REPARSE_TAG_RESERVED_TWO 2
2840 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2842 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2843 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2844 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2845 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2846 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2847 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2848 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2849 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2850 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2851 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2852 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2853 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2854 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2855 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2856 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2857 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2858 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2859 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2860 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2861 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2862 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2863 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2864 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2865 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2866 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2867 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2868 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2869 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2870 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2871 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2872 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2873 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2874 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2875 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2876 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2877 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2878 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2879 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2880 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2881 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2882 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2883 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2884 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2887 * File formats definitions
2890 #include <pshpack2.h>
2891 typedef struct _IMAGE_DOS_HEADER
{
2892 WORD e_magic
; /* 00: MZ Header signature */
2893 WORD e_cblp
; /* 02: Bytes on last page of file */
2894 WORD e_cp
; /* 04: Pages in file */
2895 WORD e_crlc
; /* 06: Relocations */
2896 WORD e_cparhdr
; /* 08: Size of header in paragraphs */
2897 WORD e_minalloc
; /* 0a: Minimum extra paragraphs needed */
2898 WORD e_maxalloc
; /* 0c: Maximum extra paragraphs needed */
2899 WORD e_ss
; /* 0e: Initial (relative) SS value */
2900 WORD e_sp
; /* 10: Initial SP value */
2901 WORD e_csum
; /* 12: Checksum */
2902 WORD e_ip
; /* 14: Initial IP value */
2903 WORD e_cs
; /* 16: Initial (relative) CS value */
2904 WORD e_lfarlc
; /* 18: File address of relocation table */
2905 WORD e_ovno
; /* 1a: Overlay number */
2906 WORD e_res
[4]; /* 1c: Reserved words */
2907 WORD e_oemid
; /* 24: OEM identifier (for e_oeminfo) */
2908 WORD e_oeminfo
; /* 26: OEM information; e_oemid specific */
2909 WORD e_res2
[10]; /* 28: Reserved words */
2910 DWORD e_lfanew
; /* 3c: Offset to extended header */
2911 } IMAGE_DOS_HEADER
, *PIMAGE_DOS_HEADER
;
2912 #include <poppack.h>
2914 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2915 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2916 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2917 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2918 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2919 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2922 * This is the Windows executable (NE) header.
2923 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2925 #include <pshpack2.h>
2928 WORD ne_magic
; /* 00 NE signature 'NE' */
2929 BYTE ne_ver
; /* 02 Linker version number */
2930 BYTE ne_rev
; /* 03 Linker revision number */
2931 WORD ne_enttab
; /* 04 Offset to entry table relative to NE */
2932 WORD ne_cbenttab
; /* 06 Length of entry table in bytes */
2933 LONG ne_crc
; /* 08 Checksum */
2934 WORD ne_flags
; /* 0c Flags about segments in this file */
2935 WORD ne_autodata
; /* 0e Automatic data segment number */
2936 WORD ne_heap
; /* 10 Initial size of local heap */
2937 WORD ne_stack
; /* 12 Initial size of stack */
2938 DWORD ne_csip
; /* 14 Initial CS:IP */
2939 DWORD ne_sssp
; /* 18 Initial SS:SP */
2940 WORD ne_cseg
; /* 1c # of entries in segment table */
2941 WORD ne_cmod
; /* 1e # of entries in module reference tab. */
2942 WORD ne_cbnrestab
; /* 20 Length of nonresident-name table */
2943 WORD ne_segtab
; /* 22 Offset to segment table */
2944 WORD ne_rsrctab
; /* 24 Offset to resource table */
2945 WORD ne_restab
; /* 26 Offset to resident-name table */
2946 WORD ne_modtab
; /* 28 Offset to module reference table */
2947 WORD ne_imptab
; /* 2a Offset to imported name table */
2948 DWORD ne_nrestab
; /* 2c Offset to nonresident-name table */
2949 WORD ne_cmovent
; /* 30 # of movable entry points */
2950 WORD ne_align
; /* 32 Logical sector alignment shift count */
2951 WORD ne_cres
; /* 34 # of resource segments */
2952 BYTE ne_exetyp
; /* 36 Flags indicating target OS */
2953 BYTE ne_flagsothers
; /* 37 Additional information flags */
2954 WORD ne_pretthunks
; /* 38 Offset to return thunks */
2955 WORD ne_psegrefbytes
; /* 3a Offset to segment ref. bytes */
2956 WORD ne_swaparea
; /* 3c Reserved by Microsoft */
2957 WORD ne_expver
; /* 3e Expected Windows version number */
2958 } IMAGE_OS2_HEADER
, *PIMAGE_OS2_HEADER
;
2959 #include <poppack.h>
2961 #include <pshpack2.h>
2962 typedef struct _IMAGE_VXD_HEADER
{
2977 DWORD e32_lastpagesize
;
2978 DWORD e32_fixupsize
;
2995 DWORD e32_impmodcnt
;
3001 DWORD e32_cbnrestab
;
3004 DWORD e32_debuginfo
;
3006 DWORD e32_instpreload
;
3007 DWORD e32_instdemand
;
3010 DWORD e32_winresoff
;
3011 DWORD e32_winreslen
;
3014 } IMAGE_VXD_HEADER
, *PIMAGE_VXD_HEADER
;
3015 #include <poppack.h>
3017 /* These defines describe the meanings of the bits in the Characteristics
3020 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
3021 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
3022 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
3023 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
3024 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
3025 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
3026 #define IMAGE_FILE_16BIT_MACHINE 0x0040
3027 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
3028 #define IMAGE_FILE_32BIT_MACHINE 0x0100
3029 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
3030 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
3031 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
3032 #define IMAGE_FILE_SYSTEM 0x1000
3033 #define IMAGE_FILE_DLL 0x2000
3034 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
3035 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
3037 /* These are the settings of the Machine field. */
3038 #define IMAGE_FILE_MACHINE_UNKNOWN 0
3039 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
3040 #define IMAGE_FILE_MACHINE_I860 0x014d
3041 #define IMAGE_FILE_MACHINE_I386 0x014c
3042 #define IMAGE_FILE_MACHINE_R3000 0x0162
3043 #define IMAGE_FILE_MACHINE_R4000 0x0166
3044 #define IMAGE_FILE_MACHINE_R10000 0x0168
3045 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
3046 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
3047 #define IMAGE_FILE_MACHINE_SH3 0x01a2
3048 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
3049 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
3050 #define IMAGE_FILE_MACHINE_SH4 0x01a6
3051 #define IMAGE_FILE_MACHINE_SH5 0x01a8
3052 #define IMAGE_FILE_MACHINE_ARM 0x01c0
3053 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
3054 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
3055 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
3056 #define IMAGE_FILE_MACHINE_AM33 0x01d3
3057 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
3058 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
3059 #define IMAGE_FILE_MACHINE_IA64 0x0200
3060 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
3061 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
3062 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
3063 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
3064 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
3065 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
3066 #define IMAGE_FILE_MACHINE_CEF 0x0cef
3067 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
3068 #define IMAGE_FILE_MACHINE_AMD64 0x8664
3069 #define IMAGE_FILE_MACHINE_M32R 0x9041
3070 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
3072 #define IMAGE_SIZEOF_FILE_HEADER 20
3073 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
3074 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
3075 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
3076 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
3077 #define IMAGE_SIZEOF_SHORT_NAME 8
3078 #define IMAGE_SIZEOF_SECTION_HEADER 40
3079 #define IMAGE_SIZEOF_SYMBOL 18
3080 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3081 #define IMAGE_SIZEOF_RELOCATION 10
3082 #define IMAGE_SIZEOF_BASE_RELOCATION 8
3083 #define IMAGE_SIZEOF_LINENUMBER 6
3084 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3086 /* Possible Magic values */
3087 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
3088 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
3089 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
3092 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
3093 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
3095 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
3096 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
3099 /* These are indexes into the DataDirectory array */
3100 #define IMAGE_FILE_EXPORT_DIRECTORY 0
3101 #define IMAGE_FILE_IMPORT_DIRECTORY 1
3102 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
3103 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
3104 #define IMAGE_FILE_SECURITY_DIRECTORY 4
3105 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
3106 #define IMAGE_FILE_DEBUG_DIRECTORY 6
3107 #define IMAGE_FILE_DESCRIPTION_STRING 7
3108 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
3109 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
3110 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
3112 /* Directory Entries, indices into the DataDirectory array */
3114 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
3115 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
3116 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
3117 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
3118 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
3119 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
3120 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
3121 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
3122 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
3123 #define IMAGE_DIRECTORY_ENTRY_TLS 9
3124 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
3125 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
3126 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
3127 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
3128 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
3130 /* Subsystem Values */
3132 #define IMAGE_SUBSYSTEM_UNKNOWN 0
3133 #define IMAGE_SUBSYSTEM_NATIVE 1
3134 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
3135 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
3136 #define IMAGE_SUBSYSTEM_OS2_CUI 5
3137 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
3138 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
3139 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
3140 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
3141 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
3142 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
3143 #define IMAGE_SUBSYSTEM_EFI_ROM 13
3144 #define IMAGE_SUBSYSTEM_XBOX 14
3145 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
3147 /* DLL Characteristics */
3148 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
3149 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
3150 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
3151 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
3152 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
3153 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
3154 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
3155 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
3156 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
3157 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
3158 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
3160 typedef struct _IMAGE_FILE_HEADER
{
3162 WORD NumberOfSections
;
3163 DWORD TimeDateStamp
;
3164 DWORD PointerToSymbolTable
;
3165 DWORD NumberOfSymbols
;
3166 WORD SizeOfOptionalHeader
;
3167 WORD Characteristics
;
3168 } IMAGE_FILE_HEADER
, *PIMAGE_FILE_HEADER
;
3170 typedef struct _IMAGE_DATA_DIRECTORY
{
3171 DWORD VirtualAddress
;
3173 } IMAGE_DATA_DIRECTORY
, *PIMAGE_DATA_DIRECTORY
;
3175 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
3177 typedef struct _IMAGE_OPTIONAL_HEADER64
{
3178 WORD Magic
; /* 0x20b */
3179 BYTE MajorLinkerVersion
;
3180 BYTE MinorLinkerVersion
;
3182 DWORD SizeOfInitializedData
;
3183 DWORD SizeOfUninitializedData
;
3184 DWORD AddressOfEntryPoint
;
3186 ULONGLONG ImageBase
;
3187 DWORD SectionAlignment
;
3188 DWORD FileAlignment
;
3189 WORD MajorOperatingSystemVersion
;
3190 WORD MinorOperatingSystemVersion
;
3191 WORD MajorImageVersion
;
3192 WORD MinorImageVersion
;
3193 WORD MajorSubsystemVersion
;
3194 WORD MinorSubsystemVersion
;
3195 DWORD Win32VersionValue
;
3197 DWORD SizeOfHeaders
;
3200 WORD DllCharacteristics
;
3201 ULONGLONG SizeOfStackReserve
;
3202 ULONGLONG SizeOfStackCommit
;
3203 ULONGLONG SizeOfHeapReserve
;
3204 ULONGLONG SizeOfHeapCommit
;
3206 DWORD NumberOfRvaAndSizes
;
3207 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
];
3208 } IMAGE_OPTIONAL_HEADER64
, *PIMAGE_OPTIONAL_HEADER64
;
3210 typedef struct _IMAGE_NT_HEADERS64
{
3212 IMAGE_FILE_HEADER FileHeader
;
3213 IMAGE_OPTIONAL_HEADER64 OptionalHeader
;
3214 } IMAGE_NT_HEADERS64
, *PIMAGE_NT_HEADERS64
;
3216 typedef struct _IMAGE_OPTIONAL_HEADER
{
3218 /* Standard fields */
3220 WORD Magic
; /* 0x10b or 0x107 */ /* 0x00 */
3221 BYTE MajorLinkerVersion
;
3222 BYTE MinorLinkerVersion
;
3224 DWORD SizeOfInitializedData
;
3225 DWORD SizeOfUninitializedData
;
3226 DWORD AddressOfEntryPoint
; /* 0x10 */
3230 /* NT additional fields */
3233 DWORD SectionAlignment
; /* 0x20 */
3234 DWORD FileAlignment
;
3235 WORD MajorOperatingSystemVersion
;
3236 WORD MinorOperatingSystemVersion
;
3237 WORD MajorImageVersion
;
3238 WORD MinorImageVersion
;
3239 WORD MajorSubsystemVersion
; /* 0x30 */
3240 WORD MinorSubsystemVersion
;
3241 DWORD Win32VersionValue
;
3243 DWORD SizeOfHeaders
;
3244 DWORD CheckSum
; /* 0x40 */
3246 WORD DllCharacteristics
;
3247 DWORD SizeOfStackReserve
;
3248 DWORD SizeOfStackCommit
;
3249 DWORD SizeOfHeapReserve
; /* 0x50 */
3250 DWORD SizeOfHeapCommit
;
3252 DWORD NumberOfRvaAndSizes
;
3253 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
]; /* 0x60 */
3255 } IMAGE_OPTIONAL_HEADER32
, *PIMAGE_OPTIONAL_HEADER32
;
3257 typedef struct _IMAGE_NT_HEADERS
{
3258 DWORD Signature
; /* "PE"\0\0 */ /* 0x00 */
3259 IMAGE_FILE_HEADER FileHeader
; /* 0x04 */
3260 IMAGE_OPTIONAL_HEADER32 OptionalHeader
; /* 0x18 */
3261 } IMAGE_NT_HEADERS32
, *PIMAGE_NT_HEADERS32
;
3264 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS
;
3265 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS
;
3266 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER
;
3267 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER
;
3269 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS
;
3270 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
;
3271 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
;
3272 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER
;
3275 #define IMAGE_SIZEOF_SHORT_NAME 8
3277 typedef struct _IMAGE_SECTION_HEADER
{
3278 BYTE Name
[IMAGE_SIZEOF_SHORT_NAME
];
3280 DWORD PhysicalAddress
;
3283 DWORD VirtualAddress
;
3284 DWORD SizeOfRawData
;
3285 DWORD PointerToRawData
;
3286 DWORD PointerToRelocations
;
3287 DWORD PointerToLinenumbers
;
3288 WORD NumberOfRelocations
;
3289 WORD NumberOfLinenumbers
;
3290 DWORD Characteristics
;
3291 } IMAGE_SECTION_HEADER
, *PIMAGE_SECTION_HEADER
;
3293 #define IMAGE_SIZEOF_SECTION_HEADER 40
3295 #define IMAGE_FIRST_SECTION(ntheader) \
3296 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
3297 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
3299 /* These defines are for the Characteristics bitfield. */
3300 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
3301 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
3302 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
3303 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
3304 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
3305 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
3307 #define IMAGE_SCN_CNT_CODE 0x00000020
3308 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
3309 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
3311 #define IMAGE_SCN_LNK_OTHER 0x00000100
3312 #define IMAGE_SCN_LNK_INFO 0x00000200
3313 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
3314 #define IMAGE_SCN_LNK_REMOVE 0x00000800
3315 #define IMAGE_SCN_LNK_COMDAT 0x00001000
3317 /* 0x00002000 - Reserved */
3318 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
3319 #define IMAGE_SCN_MEM_FARDATA 0x00008000
3321 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
3322 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
3323 #define IMAGE_SCN_MEM_16BIT 0x00020000
3324 #define IMAGE_SCN_MEM_LOCKED 0x00040000
3325 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
3327 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
3328 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
3329 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
3330 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
3331 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
3332 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
3333 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
3334 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
3335 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
3336 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
3337 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
3338 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
3339 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
3340 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
3341 /* 0x00F00000 - Unused */
3342 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
3344 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
3347 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
3348 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
3349 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
3350 #define IMAGE_SCN_MEM_SHARED 0x10000000
3351 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
3352 #define IMAGE_SCN_MEM_READ 0x40000000
3353 #define IMAGE_SCN_MEM_WRITE 0x80000000
3355 #include <pshpack2.h>
3357 typedef struct _IMAGE_SYMBOL
{
3367 SHORT SectionNumber
;
3370 BYTE NumberOfAuxSymbols
;
3372 typedef IMAGE_SYMBOL
*PIMAGE_SYMBOL
;
3374 #define IMAGE_SIZEOF_SYMBOL 18
3376 typedef struct _IMAGE_LINENUMBER
{
3378 DWORD SymbolTableIndex
;
3379 DWORD VirtualAddress
;
3383 typedef IMAGE_LINENUMBER
*PIMAGE_LINENUMBER
;
3385 #define IMAGE_SIZEOF_LINENUMBER 6
3387 typedef union _IMAGE_AUX_SYMBOL
{
3399 DWORD PointerToLinenumber
;
3400 DWORD PointerToNextFunction
;
3409 BYTE Name
[IMAGE_SIZEOF_SYMBOL
];
3413 WORD NumberOfRelocations
;
3414 WORD NumberOfLinenumbers
;
3420 typedef IMAGE_AUX_SYMBOL
*PIMAGE_AUX_SYMBOL
;
3422 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3424 #include <poppack.h>
3426 #define IMAGE_SYM_UNDEFINED (SHORT)0
3427 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3428 #define IMAGE_SYM_DEBUG (SHORT)-2
3430 #define IMAGE_SYM_TYPE_NULL 0x0000
3431 #define IMAGE_SYM_TYPE_VOID 0x0001
3432 #define IMAGE_SYM_TYPE_CHAR 0x0002
3433 #define IMAGE_SYM_TYPE_SHORT 0x0003
3434 #define IMAGE_SYM_TYPE_INT 0x0004
3435 #define IMAGE_SYM_TYPE_LONG 0x0005
3436 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3437 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3438 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3439 #define IMAGE_SYM_TYPE_UNION 0x0009
3440 #define IMAGE_SYM_TYPE_ENUM 0x000A
3441 #define IMAGE_SYM_TYPE_MOE 0x000B
3442 #define IMAGE_SYM_TYPE_BYTE 0x000C
3443 #define IMAGE_SYM_TYPE_WORD 0x000D
3444 #define IMAGE_SYM_TYPE_UINT 0x000E
3445 #define IMAGE_SYM_TYPE_DWORD 0x000F
3446 #define IMAGE_SYM_TYPE_PCODE 0x8000
3448 #define IMAGE_SYM_DTYPE_NULL 0
3449 #define IMAGE_SYM_DTYPE_POINTER 1
3450 #define IMAGE_SYM_DTYPE_FUNCTION 2
3451 #define IMAGE_SYM_DTYPE_ARRAY 3
3453 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3454 #define IMAGE_SYM_CLASS_NULL 0x0000
3455 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3456 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3457 #define IMAGE_SYM_CLASS_STATIC 0x0003
3458 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3459 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3460 #define IMAGE_SYM_CLASS_LABEL 0x0006
3461 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3462 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3463 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3464 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3465 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3466 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3467 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3468 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3469 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3470 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3471 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3472 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3474 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3475 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3476 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3477 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3478 #define IMAGE_SYM_CLASS_FILE 0x0067
3479 #define IMAGE_SYM_CLASS_SECTION 0x0068
3480 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3482 #define N_BTMASK 0x000F
3483 #define N_TMASK 0x0030
3484 #define N_TMASK1 0x00C0
3485 #define N_TMASK2 0x00F0
3489 #define BTYPE(x) ((x) & N_BTMASK)
3492 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3496 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3500 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3504 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3508 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3511 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3514 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3515 #define IMAGE_COMDAT_SELECT_ANY 2
3516 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3517 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3518 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3519 #define IMAGE_COMDAT_SELECT_LARGEST 6
3520 #define IMAGE_COMDAT_SELECT_NEWEST 7
3522 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3523 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3524 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3526 /* Export module directory */
3528 typedef struct _IMAGE_EXPORT_DIRECTORY
{
3529 DWORD Characteristics
;
3530 DWORD TimeDateStamp
;
3535 DWORD NumberOfFunctions
;
3536 DWORD NumberOfNames
;
3537 DWORD AddressOfFunctions
;
3538 DWORD AddressOfNames
;
3539 DWORD AddressOfNameOrdinals
;
3540 } IMAGE_EXPORT_DIRECTORY
,*PIMAGE_EXPORT_DIRECTORY
;
3542 /* Import name entry */
3543 typedef struct _IMAGE_IMPORT_BY_NAME
{
3546 } IMAGE_IMPORT_BY_NAME
,*PIMAGE_IMPORT_BY_NAME
;
3548 #include <pshpack8.h>
3550 typedef struct _IMAGE_THUNK_DATA64
{
3552 ULONGLONG ForwarderString
;
3555 ULONGLONG AddressOfData
;
3557 } IMAGE_THUNK_DATA64
,*PIMAGE_THUNK_DATA64
;
3558 #include <poppack.h>
3560 typedef struct _IMAGE_THUNK_DATA32
{
3562 DWORD ForwarderString
;
3565 DWORD AddressOfData
;
3567 } IMAGE_THUNK_DATA32
,*PIMAGE_THUNK_DATA32
;
3569 /* Import module directory */
3571 typedef struct _IMAGE_IMPORT_DESCRIPTOR
{
3573 DWORD Characteristics
; /* 0 for terminating null import descriptor */
3574 DWORD OriginalFirstThunk
; /* RVA to original unbound IAT */
3576 DWORD TimeDateStamp
; /* 0 if not bound,
3577 * -1 if bound, and real date\time stamp
3578 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3580 * otherwise date/time stamp of DLL bound to
3583 DWORD ForwarderChain
; /* -1 if no forwarders */
3585 /* RVA to IAT (if bound this IAT has actual addresses) */
3587 } IMAGE_IMPORT_DESCRIPTOR
,*PIMAGE_IMPORT_DESCRIPTOR
;
3589 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3590 #define IMAGE_ORDINAL_FLAG32 0x80000000
3591 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3592 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3593 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3594 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3597 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3598 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3599 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3600 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA
;
3601 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA
;
3603 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3604 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3605 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3606 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA
;
3607 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
;
3610 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3612 DWORD TimeDateStamp
;
3613 WORD OffsetModuleName
;
3614 WORD NumberOfModuleForwarderRefs
;
3615 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3616 } IMAGE_BOUND_IMPORT_DESCRIPTOR
, *PIMAGE_BOUND_IMPORT_DESCRIPTOR
;
3618 typedef struct _IMAGE_BOUND_FORWARDER_REF
3620 DWORD TimeDateStamp
;
3621 WORD OffsetModuleName
;
3623 } IMAGE_BOUND_FORWARDER_REF
, *PIMAGE_BOUND_FORWARDER_REF
;
3625 typedef struct _IMAGE_BASE_RELOCATION
3627 DWORD VirtualAddress
;
3629 /* WORD TypeOffset[1]; */
3630 } IMAGE_BASE_RELOCATION
,*PIMAGE_BASE_RELOCATION
;
3632 #include <pshpack2.h>
3634 typedef struct _IMAGE_RELOCATION
3637 DWORD VirtualAddress
;
3640 DWORD SymbolTableIndex
;
3642 } IMAGE_RELOCATION
, *PIMAGE_RELOCATION
;
3644 #include <poppack.h>
3646 #define IMAGE_SIZEOF_RELOCATION 10
3648 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3652 DWORD AllAttributes
;
3656 DWORD ReservedAttributes
:31;
3661 DWORD ModuleHandleRVA
;
3662 DWORD ImportAddressTableRVA
;
3663 DWORD ImportNameTableRVA
;
3664 DWORD BoundImportAddressTableRVA
;
3665 DWORD UnloadInformationTableRVA
;
3666 DWORD TimeDateStamp
;
3667 } IMAGE_DELAYLOAD_DESCRIPTOR
, *PIMAGE_DELAYLOAD_DESCRIPTOR
;
3668 typedef const IMAGE_DELAYLOAD_DESCRIPTOR
*PCIMAGE_DELAYLOAD_DESCRIPTOR
;
3670 /* generic relocation types */
3671 #define IMAGE_REL_BASED_ABSOLUTE 0
3672 #define IMAGE_REL_BASED_HIGH 1
3673 #define IMAGE_REL_BASED_LOW 2
3674 #define IMAGE_REL_BASED_HIGHLOW 3
3675 #define IMAGE_REL_BASED_HIGHADJ 4
3676 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3677 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3678 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3679 #define IMAGE_REL_BASED_SECTION 6
3680 #define IMAGE_REL_BASED_REL 7
3681 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3682 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3683 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3684 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3685 #define IMAGE_REL_BASED_DIR64 10
3686 #define IMAGE_REL_BASED_HIGH3ADJ 11
3688 /* I386 relocation types */
3689 #define IMAGE_REL_I386_ABSOLUTE 0
3690 #define IMAGE_REL_I386_DIR16 1
3691 #define IMAGE_REL_I386_REL16 2
3692 #define IMAGE_REL_I386_DIR32 6
3693 #define IMAGE_REL_I386_DIR32NB 7
3694 #define IMAGE_REL_I386_SEG12 9
3695 #define IMAGE_REL_I386_SECTION 10
3696 #define IMAGE_REL_I386_SECREL 11
3697 #define IMAGE_REL_I386_TOKEN 12
3698 #define IMAGE_REL_I386_SECREL7 13
3699 #define IMAGE_REL_I386_REL32 20
3701 /* MIPS relocation types */
3702 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3703 #define IMAGE_REL_MIPS_REFHALF 0x0001
3704 #define IMAGE_REL_MIPS_REFWORD 0x0002
3705 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3706 #define IMAGE_REL_MIPS_REFHI 0x0004
3707 #define IMAGE_REL_MIPS_REFLO 0x0005
3708 #define IMAGE_REL_MIPS_GPREL 0x0006
3709 #define IMAGE_REL_MIPS_LITERAL 0x0007
3710 #define IMAGE_REL_MIPS_SECTION 0x000A
3711 #define IMAGE_REL_MIPS_SECREL 0x000B
3712 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3713 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3714 #define IMAGE_REL_MIPS_TOKEN 0x000E
3715 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3716 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3717 #define IMAGE_REL_MIPS_PAIR 0x0025
3719 /* ALPHA relocation types */
3720 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3721 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3722 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3723 #define IMAGE_REL_ALPHA_GPREL 0x0003
3724 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3725 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3726 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3727 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3728 #define IMAGE_REL_ALPHA_HINT 0x0008
3729 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3730 #define IMAGE_REL_ALPHA_REFHI 0x000A
3731 #define IMAGE_REL_ALPHA_REFLO 0x000B
3732 #define IMAGE_REL_ALPHA_PAIR 0x000C
3733 #define IMAGE_REL_ALPHA_MATCH 0x000D
3734 #define IMAGE_REL_ALPHA_SECTION 0x000E
3735 #define IMAGE_REL_ALPHA_SECREL 0x000F
3736 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3737 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3738 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3739 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3740 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3741 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3742 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3743 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3745 /* PowerPC relocation types */
3746 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3747 #define IMAGE_REL_PPC_ADDR64 0x0001
3748 #define IMAGE_REL_PPC_ADDR 0x0002
3749 #define IMAGE_REL_PPC_ADDR24 0x0003
3750 #define IMAGE_REL_PPC_ADDR16 0x0004
3751 #define IMAGE_REL_PPC_ADDR14 0x0005
3752 #define IMAGE_REL_PPC_REL24 0x0006
3753 #define IMAGE_REL_PPC_REL14 0x0007
3754 #define IMAGE_REL_PPC_TOCREL16 0x0008
3755 #define IMAGE_REL_PPC_TOCREL14 0x0009
3756 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3757 #define IMAGE_REL_PPC_SECREL 0x000B
3758 #define IMAGE_REL_PPC_SECTION 0x000C
3759 #define IMAGE_REL_PPC_IFGLUE 0x000D
3760 #define IMAGE_REL_PPC_IMGLUE 0x000E
3761 #define IMAGE_REL_PPC_SECREL16 0x000F
3762 #define IMAGE_REL_PPC_REFHI 0x0010
3763 #define IMAGE_REL_PPC_REFLO 0x0011
3764 #define IMAGE_REL_PPC_PAIR 0x0012
3765 #define IMAGE_REL_PPC_SECRELLO 0x0013
3766 #define IMAGE_REL_PPC_SECRELHI 0x0014
3767 #define IMAGE_REL_PPC_GPREL 0x0015
3768 #define IMAGE_REL_PPC_TOKEN 0x0016
3769 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3771 #define IMAGE_REL_PPC_NEG 0x0100
3772 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3773 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3774 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3776 /* SH3 relocation types */
3777 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3778 #define IMAGE_REL_SH3_DIRECT16 0x0001
3779 #define IMAGE_REL_SH3_DIRECT 0x0002
3780 #define IMAGE_REL_SH3_DIRECT8 0x0003
3781 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3782 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3783 #define IMAGE_REL_SH3_DIRECT4 0x0006
3784 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3785 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3786 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3787 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3788 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3789 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3790 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3791 #define IMAGE_REL_SH3_SECTION 0x000E
3792 #define IMAGE_REL_SH3_SECREL 0x000F
3793 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3794 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3795 #define IMAGE_REL_SH3_TOKEN 0x0012
3797 /* ARM relocation types */
3798 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3799 #define IMAGE_REL_ARM_ADDR 0x0001
3800 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3801 #define IMAGE_REL_ARM_BRANCH24 0x0003
3802 #define IMAGE_REL_ARM_BRANCH11 0x0004
3803 #define IMAGE_REL_ARM_TOKEN 0x0005
3804 #define IMAGE_REL_ARM_GPREL12 0x0006
3805 #define IMAGE_REL_ARM_GPREL7 0x0007
3806 #define IMAGE_REL_ARM_BLX24 0x0008
3807 #define IMAGE_REL_ARM_BLX11 0x0009
3808 #define IMAGE_REL_ARM_SECTION 0x000E
3809 #define IMAGE_REL_ARM_SECREL 0x000F
3810 #define IMAGE_REL_ARM_MOV32A 0x0010
3811 #define IMAGE_REL_ARM_MOV32T 0x0011
3812 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3813 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3814 #define IMAGE_REL_ARM_BLX23T 0x0015
3816 /* ARM64 relocation types */
3817 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3818 #define IMAGE_REL_ARM64_ADDR32 0x0001
3819 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3820 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3821 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3822 #define IMAGE_REL_ARM64_REL21 0x0005
3823 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3824 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3825 #define IMAGE_REL_ARM64_SECREL 0x0008
3826 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3827 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3828 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3829 #define IMAGE_REL_ARM64_TOKEN 0x000C
3830 #define IMAGE_REL_ARM64_SECTION 0x000D
3831 #define IMAGE_REL_ARM64_ADDR64 0x000E
3832 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3834 /* IA64 relocation types */
3835 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3836 #define IMAGE_REL_IA64_IMM14 0x0001
3837 #define IMAGE_REL_IA64_IMM22 0x0002
3838 #define IMAGE_REL_IA64_IMM64 0x0003
3839 #define IMAGE_REL_IA64_DIR 0x0004
3840 #define IMAGE_REL_IA64_DIR64 0x0005
3841 #define IMAGE_REL_IA64_PCREL21B 0x0006
3842 #define IMAGE_REL_IA64_PCREL21M 0x0007
3843 #define IMAGE_REL_IA64_PCREL21F 0x0008
3844 #define IMAGE_REL_IA64_GPREL22 0x0009
3845 #define IMAGE_REL_IA64_LTOFF22 0x000A
3846 #define IMAGE_REL_IA64_SECTION 0x000B
3847 #define IMAGE_REL_IA64_SECREL22 0x000C
3848 #define IMAGE_REL_IA64_SECREL64I 0x000D
3849 #define IMAGE_REL_IA64_SECREL 0x000E
3850 #define IMAGE_REL_IA64_LTOFF64 0x000F
3851 #define IMAGE_REL_IA64_DIR32NB 0x0010
3852 #define IMAGE_REL_IA64_SREL14 0x0011
3853 #define IMAGE_REL_IA64_SREL22 0x0012
3854 #define IMAGE_REL_IA64_SREL32 0x0013
3855 #define IMAGE_REL_IA64_UREL32 0x0014
3856 #define IMAGE_REL_IA64_PCREL60X 0x0015
3857 #define IMAGE_REL_IA64_PCREL60B 0x0016
3858 #define IMAGE_REL_IA64_PCREL60F 0x0017
3859 #define IMAGE_REL_IA64_PCREL60I 0x0018
3860 #define IMAGE_REL_IA64_PCREL60M 0x0019
3861 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3862 #define IMAGE_REL_IA64_TOKEN 0x001B
3863 #define IMAGE_REL_IA64_GPREL32 0x001C
3864 #define IMAGE_REL_IA64_ADDEND 0x001F
3866 /* AMD64 relocation types */
3867 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3868 #define IMAGE_REL_AMD64_ADDR64 0x0001
3869 #define IMAGE_REL_AMD64_ADDR32 0x0002
3870 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3871 #define IMAGE_REL_AMD64_REL32 0x0004
3872 #define IMAGE_REL_AMD64_REL32_1 0x0005
3873 #define IMAGE_REL_AMD64_REL32_2 0x0006
3874 #define IMAGE_REL_AMD64_REL32_3 0x0007
3875 #define IMAGE_REL_AMD64_REL32_4 0x0008
3876 #define IMAGE_REL_AMD64_REL32_5 0x0009
3877 #define IMAGE_REL_AMD64_SECTION 0x000A
3878 #define IMAGE_REL_AMD64_SECREL 0x000B
3879 #define IMAGE_REL_AMD64_SECREL7 0x000C
3880 #define IMAGE_REL_AMD64_TOKEN 0x000D
3881 #define IMAGE_REL_AMD64_SREL32 0x000E
3882 #define IMAGE_REL_AMD64_PAIR 0x000F
3883 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3885 /* archive format */
3887 #define IMAGE_ARCHIVE_START_SIZE 8
3888 #define IMAGE_ARCHIVE_START "!<arch>\n"
3889 #define IMAGE_ARCHIVE_END "`\n"
3890 #define IMAGE_ARCHIVE_PAD "\n"
3891 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3892 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3894 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3903 } IMAGE_ARCHIVE_MEMBER_HEADER
, *PIMAGE_ARCHIVE_MEMBER_HEADER
;
3905 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3907 typedef struct _IMPORT_OBJECT_HEADER
3913 DWORD TimeDateStamp
;
3923 } IMPORT_OBJECT_HEADER
;
3925 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3927 typedef enum IMPORT_OBJECT_TYPE
3929 IMPORT_OBJECT_CODE
= 0,
3930 IMPORT_OBJECT_DATA
= 1,
3931 IMPORT_OBJECT_CONST
= 2
3932 } IMPORT_OBJECT_TYPE
;
3934 typedef enum IMPORT_OBJECT_NAME_TYPE
3936 IMPORT_OBJECT_ORDINAL
= 0,
3937 IMPORT_OBJECT_NAME
= 1,
3938 IMPORT_OBJECT_NAME_NO_PREFIX
= 2,
3939 IMPORT_OBJECT_NAME_UNDECORATE
= 3
3940 } IMPORT_OBJECT_NAME_TYPE
;
3942 typedef struct _ANON_OBJECT_HEADER
3948 DWORD TimeDateStamp
;
3951 } ANON_OBJECT_HEADER
;
3954 * Resource directory stuff
3956 typedef struct _IMAGE_RESOURCE_DIRECTORY
{
3957 DWORD Characteristics
;
3958 DWORD TimeDateStamp
;
3961 WORD NumberOfNamedEntries
;
3962 WORD NumberOfIdEntries
;
3963 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3964 } IMAGE_RESOURCE_DIRECTORY
,*PIMAGE_RESOURCE_DIRECTORY
;
3966 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3967 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3969 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
{
3972 unsigned NameOffset
:31;
3973 unsigned NameIsString
:1;
3981 unsigned OffsetToDirectory
:31;
3982 unsigned DataIsDirectory
:1;
3985 } IMAGE_RESOURCE_DIRECTORY_ENTRY
,*PIMAGE_RESOURCE_DIRECTORY_ENTRY
;
3988 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
{
3990 CHAR NameString
[ 1 ];
3991 } IMAGE_RESOURCE_DIRECTORY_STRING
,*PIMAGE_RESOURCE_DIRECTORY_STRING
;
3993 typedef struct _IMAGE_RESOURCE_DIR_STRING_U
{
3995 WCHAR NameString
[ 1 ];
3996 } IMAGE_RESOURCE_DIR_STRING_U
,*PIMAGE_RESOURCE_DIR_STRING_U
;
3998 typedef struct _IMAGE_RESOURCE_DATA_ENTRY
{
4003 } IMAGE_RESOURCE_DATA_ENTRY
,*PIMAGE_RESOURCE_DATA_ENTRY
;
4006 typedef VOID (CALLBACK
*PIMAGE_TLS_CALLBACK
)(
4007 LPVOID DllHandle
,DWORD Reason
,LPVOID Reserved
4010 typedef struct _IMAGE_TLS_DIRECTORY64
{
4011 ULONGLONG StartAddressOfRawData
;
4012 ULONGLONG EndAddressOfRawData
;
4013 ULONGLONG AddressOfIndex
;
4014 ULONGLONG AddressOfCallBacks
;
4015 DWORD SizeOfZeroFill
;
4016 DWORD Characteristics
;
4017 } IMAGE_TLS_DIRECTORY64
, *PIMAGE_TLS_DIRECTORY64
;
4019 typedef struct _IMAGE_TLS_DIRECTORY32
{
4020 DWORD StartAddressOfRawData
;
4021 DWORD EndAddressOfRawData
;
4022 DWORD AddressOfIndex
;
4023 DWORD AddressOfCallBacks
;
4024 DWORD SizeOfZeroFill
;
4025 DWORD Characteristics
;
4026 } IMAGE_TLS_DIRECTORY32
, *PIMAGE_TLS_DIRECTORY32
;
4029 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY
;
4030 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY
;
4032 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY
;
4033 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY
;
4036 typedef struct _IMAGE_DEBUG_DIRECTORY
{
4037 DWORD Characteristics
;
4038 DWORD TimeDateStamp
;
4043 DWORD AddressOfRawData
;
4044 DWORD PointerToRawData
;
4045 } IMAGE_DEBUG_DIRECTORY
, *PIMAGE_DEBUG_DIRECTORY
;
4047 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
4048 #define IMAGE_DEBUG_TYPE_COFF 1
4049 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
4050 #define IMAGE_DEBUG_TYPE_FPO 3
4051 #define IMAGE_DEBUG_TYPE_MISC 4
4052 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
4053 #define IMAGE_DEBUG_TYPE_FIXUP 6
4054 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
4055 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
4056 #define IMAGE_DEBUG_TYPE_BORLAND 9
4057 #define IMAGE_DEBUG_TYPE_RESERVED10 10
4058 #define IMAGE_DEBUG_TYPE_CLSID 11
4059 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
4060 #define IMAGE_DEBUG_TYPE_POGO 13
4061 #define IMAGE_DEBUG_TYPE_ILTCG 14
4062 #define IMAGE_DEBUG_TYPE_MPX 15
4063 #define IMAGE_DEBUG_TYPE_REPRO 16
4065 typedef enum ReplacesCorHdrNumericDefines
4067 COMIMAGE_FLAGS_ILONLY
= 0x00000001,
4068 COMIMAGE_FLAGS_32BITREQUIRED
= 0x00000002,
4069 COMIMAGE_FLAGS_IL_LIBRARY
= 0x00000004,
4070 COMIMAGE_FLAGS_STRONGNAMESIGNED
= 0x00000008,
4071 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT
= 0x00000010,
4072 COMIMAGE_FLAGS_TRACKDEBUGDATA
= 0x00010000,
4073 COMIMAGE_FLAGS_32BITPREFERRED
= 0x00020000,
4075 COR_VERSION_MAJOR_V2
= 2,
4076 COR_VERSION_MAJOR
= COR_VERSION_MAJOR_V2
,
4077 COR_VERSION_MINOR
= 5,
4078 COR_DELETED_NAME_LENGTH
= 8,
4079 COR_VTABLEGAP_NAME_LENGTH
= 8,
4081 NATIVE_TYPE_MAX_CB
= 1,
4082 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE
= 0xff,
4084 IMAGE_COR_MIH_METHODRVA
= 0x01,
4085 IMAGE_COR_MIH_EHRVA
= 0x02,
4086 IMAGE_COR_MIH_BASICBLOCK
= 0x08,
4088 COR_VTABLE_32BIT
= 0x01,
4089 COR_VTABLE_64BIT
= 0x02,
4090 COR_VTABLE_FROM_UNMANAGED
= 0x04,
4091 COR_VTABLE_CALL_MOST_DERIVED
= 0x10,
4093 IMAGE_COR_EATJ_THUNK_SIZE
= 32,
4095 MAX_CLASS_NAME
= 1024,
4096 MAX_PACKAGE_NAME
= 1024,
4097 } ReplacesCorHdrNumericDefines
;
4099 typedef struct IMAGE_COR20_HEADER
4102 WORD MajorRuntimeVersion
;
4103 WORD MinorRuntimeVersion
;
4105 IMAGE_DATA_DIRECTORY MetaData
;
4108 DWORD EntryPointToken
;
4109 DWORD EntryPointRVA
;
4112 IMAGE_DATA_DIRECTORY Resources
;
4113 IMAGE_DATA_DIRECTORY StrongNameSignature
;
4114 IMAGE_DATA_DIRECTORY CodeManagerTable
;
4115 IMAGE_DATA_DIRECTORY VTableFixups
;
4116 IMAGE_DATA_DIRECTORY ExportAddressTableJumps
;
4117 IMAGE_DATA_DIRECTORY ManagedNativeHeader
;
4119 } IMAGE_COR20_HEADER
, *PIMAGE_COR20_HEADER
;
4121 typedef struct _IMAGE_COFF_SYMBOLS_HEADER
{
4122 DWORD NumberOfSymbols
;
4123 DWORD LvaToFirstSymbol
;
4124 DWORD NumberOfLinenumbers
;
4125 DWORD LvaToFirstLinenumber
;
4126 DWORD RvaToFirstByteOfCode
;
4127 DWORD RvaToLastByteOfCode
;
4128 DWORD RvaToFirstByteOfData
;
4129 DWORD RvaToLastByteOfData
;
4130 } IMAGE_COFF_SYMBOLS_HEADER
, *PIMAGE_COFF_SYMBOLS_HEADER
;
4133 #define FRAME_TRAP 1
4135 #define FRAME_NONFPO 3
4137 typedef struct _FPO_DATA
{
4148 } FPO_DATA
, *PFPO_DATA
;
4150 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
{
4152 DWORD TimeDateStamp
;
4155 DWORD GlobalFlagsClear
;
4156 DWORD GlobalFlagsSet
;
4157 DWORD CriticalSectionDefaultTimeout
;
4158 ULONGLONG DeCommitFreeBlockThreshold
;
4159 ULONGLONG DeCommitTotalFreeThreshold
;
4160 ULONGLONG LockPrefixTable
;
4161 ULONGLONG MaximumAllocationSize
;
4162 ULONGLONG VirtualMemoryThreshold
;
4163 ULONGLONG ProcessAffinityMask
;
4164 DWORD ProcessHeapFlags
;
4168 ULONGLONG SecurityCookie
;
4169 ULONGLONG SEHandlerTable
;
4170 ULONGLONG SEHandlerCount
;
4171 } IMAGE_LOAD_CONFIG_DIRECTORY64
, *PIMAGE_LOAD_CONFIG_DIRECTORY64
;
4173 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
{
4175 DWORD TimeDateStamp
;
4178 DWORD GlobalFlagsClear
;
4179 DWORD GlobalFlagsSet
;
4180 DWORD CriticalSectionDefaultTimeout
;
4181 DWORD DeCommitFreeBlockThreshold
;
4182 DWORD DeCommitTotalFreeThreshold
;
4183 PVOID LockPrefixTable
;
4184 DWORD MaximumAllocationSize
;
4185 DWORD VirtualMemoryThreshold
;
4186 DWORD ProcessHeapFlags
;
4187 DWORD ProcessAffinityMask
;
4191 DWORD SecurityCookie
;
4192 DWORD SEHandlerTable
;
4193 DWORD SEHandlerCount
;
4194 } IMAGE_LOAD_CONFIG_DIRECTORY32
, *PIMAGE_LOAD_CONFIG_DIRECTORY32
;
4197 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY
;
4198 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY
;
4200 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY
;
4201 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY
;
4204 typedef struct _IMAGE_FUNCTION_ENTRY
{
4205 DWORD StartingAddress
;
4206 DWORD EndingAddress
;
4207 DWORD EndOfPrologue
;
4208 } IMAGE_FUNCTION_ENTRY
, *PIMAGE_FUNCTION_ENTRY
;
4210 #define IMAGE_DEBUG_MISC_EXENAME 1
4212 typedef struct _IMAGE_DEBUG_MISC
{
4218 } IMAGE_DEBUG_MISC
, *PIMAGE_DEBUG_MISC
;
4220 /* This is the structure that appears at the very start of a .DBG file. */
4222 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
{
4226 WORD Characteristics
;
4227 DWORD TimeDateStamp
;
4231 DWORD NumberOfSections
;
4232 DWORD ExportedNamesSize
;
4233 DWORD DebugDirectorySize
;
4234 DWORD SectionAlignment
;
4235 DWORD Reserved
[ 2 ];
4236 } IMAGE_SEPARATE_DEBUG_HEADER
,*PIMAGE_SEPARATE_DEBUG_HEADER
;
4238 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
4241 typedef struct tagMESSAGE_RESOURCE_ENTRY
{
4245 } MESSAGE_RESOURCE_ENTRY
,*PMESSAGE_RESOURCE_ENTRY
;
4246 #define MESSAGE_RESOURCE_UNICODE 0x0001
4248 typedef struct tagMESSAGE_RESOURCE_BLOCK
{
4251 DWORD OffsetToEntries
;
4252 } MESSAGE_RESOURCE_BLOCK
,*PMESSAGE_RESOURCE_BLOCK
;
4254 typedef struct tagMESSAGE_RESOURCE_DATA
{
4255 DWORD NumberOfBlocks
;
4256 MESSAGE_RESOURCE_BLOCK Blocks
[ 1 ];
4257 } MESSAGE_RESOURCE_DATA
,*PMESSAGE_RESOURCE_DATA
;
4260 * Here follows typedefs for security and tokens.
4264 * First a constant for the following typedefs.
4267 #define ANYSIZE_ARRAY 1
4269 /* FIXME: Orphan. What does it point to? */
4270 typedef PVOID PACCESS_TOKEN
;
4271 typedef PVOID PSECURITY_DESCRIPTOR
;
4274 typedef enum _TOKEN_ELEVATION_TYPE
{
4275 TokenElevationTypeDefault
= 1,
4276 TokenElevationTypeFull
,
4277 TokenElevationTypeLimited
4278 } TOKEN_ELEVATION_TYPE
, *PTOKEN_ELEVATION_TYPE
;
4281 * TOKEN_INFORMATION_CLASS
4284 typedef enum _TOKEN_INFORMATION_CLASS
{
4293 TokenImpersonationLevel
,
4295 TokenRestrictedSids
,
4297 TokenGroupsAndPrivileges
,
4298 TokenSessionReference
,
4305 TokenHasRestrictions
,
4306 TokenAccessInformation
,
4307 TokenVirtualizationAllowed
,
4308 TokenVirtualizationEnabled
,
4309 TokenIntegrityLevel
,
4311 TokenMandatoryPolicy
,
4313 TokenIsAppContainer
,
4315 TokenAppContainerSid
,
4316 TokenAppContainerNumber
,
4317 TokenUserClaimAttributes
,
4318 TokenDeviceClaimAttributes
,
4319 TokenRestrictedUserClaimAttributes
,
4320 TokenRestrictedDeviceClaimAttributes
,
4322 TokenRestrictedDeviceGroups
,
4323 TokenSecurityAttributes
,
4325 TokenProcessTrustLevel
,
4327 } TOKEN_INFORMATION_CLASS
;
4329 #define DISABLE_MAX_PRIVILEGE 0x1
4330 #define SANDBOX_INERT 0x2
4331 #define LUA_TOKEN 0x4
4332 #define WRITE_RESTRICTED 0x8
4334 #define TOKEN_ASSIGN_PRIMARY 0x0001
4335 #define TOKEN_DUPLICATE 0x0002
4336 #define TOKEN_IMPERSONATE 0x0004
4337 #define TOKEN_QUERY 0x0008
4338 #define TOKEN_QUERY_SOURCE 0x0010
4339 #define TOKEN_ADJUST_PRIVILEGES 0x0020
4340 #define TOKEN_ADJUST_GROUPS 0x0040
4341 #define TOKEN_ADJUST_DEFAULT 0x0080
4342 #define TOKEN_ADJUST_SESSIONID 0x0100
4343 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
4344 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
4345 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
4346 TOKEN_ADJUST_PRIVILEGES | \
4347 TOKEN_ADJUST_GROUPS | \
4348 TOKEN_ADJUST_DEFAULT )
4349 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
4350 TOKEN_ASSIGN_PRIMARY | \
4352 TOKEN_IMPERSONATE | \
4354 TOKEN_QUERY_SOURCE | \
4355 TOKEN_ADJUST_PRIVILEGES | \
4356 TOKEN_ADJUST_GROUPS | \
4357 TOKEN_ADJUST_SESSIONID | \
4358 TOKEN_ADJUST_DEFAULT )
4360 #ifndef _SECURITY_DEFINED
4361 #define _SECURITY_DEFINED
4363 typedef DWORD ACCESS_MASK
, *PACCESS_MASK
;
4365 typedef struct _GENERIC_MAPPING
{
4366 ACCESS_MASK GenericRead
;
4367 ACCESS_MASK GenericWrite
;
4368 ACCESS_MASK GenericExecute
;
4369 ACCESS_MASK GenericAll
;
4370 } GENERIC_MAPPING
, *PGENERIC_MAPPING
;
4372 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
4373 #define SID_IDENTIFIER_AUTHORITY_DEFINED
4376 } SID_IDENTIFIER_AUTHORITY
, *PSID_IDENTIFIER_AUTHORITY
;
4377 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
4381 typedef struct _SID
{
4383 BYTE SubAuthorityCount
;
4384 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
4385 DWORD SubAuthority
[1];
4387 #endif /* !defined(SID_DEFINED) */
4389 #define SID_REVISION (1) /* Current revision */
4390 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
4391 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
4393 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
4399 #define ACL_REVISION1 1
4400 #define ACL_REVISION2 2
4401 #define ACL_REVISION3 3
4402 #define ACL_REVISION4 4
4404 #define MIN_ACL_REVISION ACL_REVISION2
4405 #define MAX_ACL_REVISION ACL_REVISION4
4407 #define ACL_REVISION 2
4409 typedef struct _ACL
{
4417 typedef enum _ACL_INFORMATION_CLASS
4419 AclRevisionInformation
= 1,
4421 } ACL_INFORMATION_CLASS
;
4423 typedef struct _ACL_REVISION_INFORMATION
4426 } ACL_REVISION_INFORMATION
, *PACL_REVISION_INFORMATION
;
4428 typedef struct _ACL_SIZE_INFORMATION
4431 DWORD AclBytesInUse
;
4433 } ACL_SIZE_INFORMATION
, *PACL_SIZE_INFORMATION
;
4435 /* SECURITY_DESCRIPTOR */
4436 #define SECURITY_DESCRIPTOR_REVISION 1
4437 #define SECURITY_DESCRIPTOR_REVISION1 1
4444 #if defined(_MSC_VER) || defined(__MINGW32__)
4445 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4446 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4447 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4448 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4449 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4450 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4451 #define SE_TCB_NAME L"SeTcbPrivilege"
4452 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4453 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4454 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4455 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4456 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4457 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4458 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4459 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4460 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4461 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4462 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4463 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4464 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4465 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4466 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4467 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4468 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4469 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4470 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4471 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4472 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4473 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4474 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4475 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4476 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4477 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4478 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4479 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4480 #else /* _MSC_VER/__MINGW32__ */
4481 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 };
4482 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 };
4483 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 };
4484 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 };
4485 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 };
4486 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 };
4487 static const WCHAR SE_TCB_NAME
[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4488 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 };
4489 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 };
4490 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 };
4491 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 };
4492 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 };
4493 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 };
4494 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 };
4495 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 };
4496 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 };
4497 static const WCHAR SE_BACKUP_NAME
[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4498 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 };
4499 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 };
4500 static const WCHAR SE_DEBUG_NAME
[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4501 static const WCHAR SE_AUDIT_NAME
[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4502 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 };
4503 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 };
4504 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 };
4505 static const WCHAR SE_UNDOCK_NAME
[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4506 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 };
4507 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 };
4508 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 };
4509 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 };
4510 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 };
4511 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 };
4512 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 };
4513 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 };
4514 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 };
4515 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 };
4518 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4519 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4520 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4521 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4522 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4523 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4524 #define SE_TCB_NAME "SeTcbPrivilege"
4525 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4526 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4527 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4528 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4529 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4530 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4531 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4532 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4533 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4534 #define SE_BACKUP_NAME "SeBackupPrivilege"
4535 #define SE_RESTORE_NAME "SeRestorePrivilege"
4536 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4537 #define SE_DEBUG_NAME "SeDebugPrivilege"
4538 #define SE_AUDIT_NAME "SeAuditPrivilege"
4539 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4540 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4541 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4542 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4543 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4544 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4545 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4546 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4547 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4548 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4549 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4550 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4551 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4552 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4555 #define SE_GROUP_MANDATORY 0x00000001
4556 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4557 #define SE_GROUP_ENABLED 0x00000004
4558 #define SE_GROUP_OWNER 0x00000008
4559 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4560 #define SE_GROUP_INTEGRITY 0x00000020
4561 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4562 #define SE_GROUP_LOGON_ID 0xC0000000
4563 #define SE_GROUP_RESOURCE 0x20000000
4564 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4566 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4567 #define SE_PRIVILEGE_ENABLED 0x00000002
4568 #define SE_PRIVILEGE_REMOVED 0x00000004
4569 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4570 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4572 #define PRIVILEGE_SET_ALL_NECESSARY 1
4574 #define SE_OWNER_DEFAULTED 0x00000001
4575 #define SE_GROUP_DEFAULTED 0x00000002
4576 #define SE_DACL_PRESENT 0x00000004
4577 #define SE_DACL_DEFAULTED 0x00000008
4578 #define SE_SACL_PRESENT 0x00000010
4579 #define SE_SACL_DEFAULTED 0x00000020
4580 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4581 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4582 #define SE_DACL_AUTO_INHERITED 0x00000400
4583 #define SE_SACL_AUTO_INHERITED 0x00000800
4584 #define SE_DACL_PROTECTED 0x00001000
4585 #define SE_SACL_PROTECTED 0x00002000
4586 #define SE_RM_CONTROL_VALID 0x00004000
4587 #define SE_SELF_RELATIVE 0x00008000
4589 typedef DWORD SECURITY_INFORMATION
, *PSECURITY_INFORMATION
;
4590 typedef WORD SECURITY_DESCRIPTOR_CONTROL
, *PSECURITY_DESCRIPTOR_CONTROL
;
4592 /* The security descriptor structure */
4596 SECURITY_DESCRIPTOR_CONTROL Control
;
4601 } SECURITY_DESCRIPTOR_RELATIVE
, *PISECURITY_DESCRIPTOR_RELATIVE
;
4606 SECURITY_DESCRIPTOR_CONTROL Control
;
4611 } SECURITY_DESCRIPTOR
, *PISECURITY_DESCRIPTOR
;
4613 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4615 #endif /* _SECURITY_DEFINED */
4618 * SID_AND_ATTRIBUTES
4621 typedef struct _SID_AND_ATTRIBUTES
{
4624 } SID_AND_ATTRIBUTES
, *PSID_AND_ATTRIBUTES
;
4626 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY
[ANYSIZE_ARRAY
];
4627 typedef SID_AND_ATTRIBUTES_ARRAY
*PSID_AND_ATTRIBUTES_ARRAY
;
4629 #define SID_HASH_SIZE 32
4631 typedef ULONG_PTR SID_HASH_ENTRY
, *PSID_HASH_ENTRY
;
4633 typedef struct _SID_AND_ATTRIBUTES_HASH
{
4635 PSID_AND_ATTRIBUTES SidAttr
;
4636 SID_HASH_ENTRY Hash
[SID_HASH_SIZE
];
4637 } SID_AND_ATTRIBUTES_HASH
, *PSID_AND_ATTRIBUTES_HASH
;
4639 /* security entities */
4640 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4641 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4642 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4644 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4647 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4650 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4651 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4654 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4655 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4656 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4657 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4658 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4659 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4662 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4665 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4666 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4667 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4668 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4669 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4670 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4671 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4672 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4673 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4674 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4675 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4676 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4677 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4678 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4679 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4680 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4681 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4682 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4683 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4684 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4685 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4686 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4687 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4688 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4690 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4691 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4692 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4693 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4694 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4695 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4696 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4697 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4698 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4699 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4700 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4701 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4702 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4703 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4704 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4705 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4706 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4707 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4708 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4709 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4710 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4711 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4713 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4715 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4716 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4717 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4718 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4719 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4721 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4722 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4723 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4724 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4725 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4726 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4727 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4728 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4729 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4730 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4732 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4734 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4735 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4736 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4737 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4738 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4739 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4740 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4741 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4742 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4743 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4744 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4746 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4747 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4748 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4749 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4750 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4751 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4752 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4753 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4754 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4756 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4758 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4759 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4760 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4761 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4763 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4764 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4765 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4766 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4768 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4769 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4770 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4771 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4772 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4773 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4775 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4776 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4777 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4778 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4779 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4780 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4781 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4782 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4783 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4784 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4785 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4787 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4789 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4790 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4791 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4792 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4793 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4794 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4795 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4796 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4797 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4798 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4799 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4801 #define SYSTEM_LUID { 0x3e7, 0x0 }
4802 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4803 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4804 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4805 #define IUSER_LUID { 0x3e3, 0x0 }
4811 WinCreatorOwnerSid
= 3,
4812 WinCreatorGroupSid
= 4,
4813 WinCreatorOwnerServerSid
= 5,
4814 WinCreatorGroupServerSid
= 6,
4815 WinNtAuthoritySid
= 7,
4819 WinInteractiveSid
= 11,
4821 WinAnonymousSid
= 13,
4823 WinEnterpriseControllersSid
= 15,
4825 WinAuthenticatedUserSid
= 17,
4826 WinRestrictedCodeSid
= 18,
4827 WinTerminalServerSid
= 19,
4828 WinRemoteLogonIdSid
= 20,
4829 WinLogonIdsSid
= 21,
4830 WinLocalSystemSid
= 22,
4831 WinLocalServiceSid
= 23,
4832 WinNetworkServiceSid
= 24,
4833 WinBuiltinDomainSid
= 25,
4834 WinBuiltinAdministratorsSid
= 26,
4835 WinBuiltinUsersSid
= 27,
4836 WinBuiltinGuestsSid
= 28,
4837 WinBuiltinPowerUsersSid
= 29,
4838 WinBuiltinAccountOperatorsSid
= 30,
4839 WinBuiltinSystemOperatorsSid
= 31,
4840 WinBuiltinPrintOperatorsSid
= 32,
4841 WinBuiltinBackupOperatorsSid
= 33,
4842 WinBuiltinReplicatorSid
= 34,
4843 WinBuiltinPreWindows2000CompatibleAccessSid
= 35,
4844 WinBuiltinRemoteDesktopUsersSid
= 36,
4845 WinBuiltinNetworkConfigurationOperatorsSid
= 37,
4846 WinAccountAdministratorSid
= 38,
4847 WinAccountGuestSid
= 39,
4848 WinAccountKrbtgtSid
= 40,
4849 WinAccountDomainAdminsSid
= 41,
4850 WinAccountDomainUsersSid
= 42,
4851 WinAccountDomainGuestsSid
= 43,
4852 WinAccountComputersSid
= 44,
4853 WinAccountControllersSid
= 45,
4854 WinAccountCertAdminsSid
= 46,
4855 WinAccountSchemaAdminsSid
= 47,
4856 WinAccountEnterpriseAdminsSid
= 48,
4857 WinAccountPolicyAdminsSid
= 49,
4858 WinAccountRasAndIasServersSid
= 50,
4859 WinNTLMAuthenticationSid
= 51,
4860 WinDigestAuthenticationSid
= 52,
4861 WinSChannelAuthenticationSid
= 53,
4862 WinThisOrganizationSid
= 54,
4863 WinOtherOrganizationSid
= 55,
4864 WinBuiltinIncomingForestTrustBuildersSid
= 56,
4865 WinBuiltinPerfMonitoringUsersSid
= 57,
4866 WinBuiltinPerfLoggingUsersSid
= 58,
4867 WinBuiltinAuthorizationAccessSid
= 59,
4868 WinBuiltinTerminalServerLicenseServersSid
= 60,
4869 WinBuiltinDCOMUsersSid
= 61,
4870 WinBuiltinIUsersSid
= 62,
4872 WinBuiltinCryptoOperatorsSid
= 64,
4873 WinUntrustedLabelSid
= 65,
4874 WinLowLabelSid
= 66,
4875 WinMediumLabelSid
= 67,
4876 WinHighLabelSid
= 68,
4877 WinSystemLabelSid
= 69,
4878 WinWriteRestrictedCodeSid
= 70,
4879 WinCreatorOwnerRightsSid
= 71,
4880 WinCacheablePrincipalsGroupSid
= 72,
4881 WinNonCacheablePrincipalsGroupSid
= 73,
4882 WinEnterpriseReadonlyControllersSid
= 74,
4883 WinAccountReadonlyControllersSid
= 75,
4884 WinBuiltinEventLogReadersGroup
= 76,
4885 WinNewEnterpriseReadonlyControllersSid
= 77,
4886 WinBuiltinCertSvcDComAccessGroup
= 78,
4887 WinMediumPlusLabelSid
= 79,
4888 WinLocalLogonSid
= 80,
4889 WinConsoleLogonSid
= 81,
4890 WinThisOrganizationCertificateSid
= 82,
4891 WinApplicationPackageAuthoritySid
= 83,
4892 WinBuiltinAnyPackageSid
= 84,
4893 WinCapabilityInternetClientSid
= 85,
4894 WinCapabilityInternetClientServerSid
= 86,
4895 WinCapabilityPrivateNetworkClientServerSid
= 87,
4896 WinCapabilityPicturesLibrarySid
= 88,
4897 WinCapabilityVideosLibrarySid
= 89,
4898 WinCapabilityMusicLibrarySid
= 90,
4899 WinCapabilityDocumentsLibrarySid
= 91,
4900 WinCapabilitySharedUserCertificatesSid
= 92,
4901 WinCapabilityEnterpriseAuthenticationSid
= 93,
4902 WinCapabilityRemovableStorageSid
= 94,
4903 WinBuiltinRDSRemoteAccessServersSid
= 95,
4904 WinBuiltinRDSEndpointServersSid
= 96,
4905 WinBuiltinRDSManagementServersSid
= 97,
4906 WinUserModeDriversSid
= 98,
4907 WinBuiltinHyperVAdminsSid
= 99,
4908 WinAccountCloneableControllersSid
= 100,
4909 WinBuiltinAccessControlAssistanceOperatorsSid
= 101,
4910 WinBuiltinRemoteManagementUsersSid
= 102,
4911 WinAuthenticationAuthorityAssertedSid
= 103,
4912 WinAuthenticationServiceAssertedSid
= 104,
4913 WinLocalAccountSid
= 105,
4914 WinLocalAccountAndAdministratorSid
= 106,
4915 WinAccountProtectedUsersSid
= 107,
4916 } WELL_KNOWN_SID_TYPE
;
4922 typedef struct _TOKEN_USER
{
4923 SID_AND_ATTRIBUTES User
;
4924 } TOKEN_USER
, *PTOKEN_USER
;
4930 typedef struct _TOKEN_GROUPS
{
4932 SID_AND_ATTRIBUTES Groups
[ANYSIZE_ARRAY
];
4933 } TOKEN_GROUPS
, *PTOKEN_GROUPS
;
4936 * LUID_AND_ATTRIBUTES
4939 typedef union _LARGE_INTEGER
{
4941 #ifdef WORDS_BIGENDIAN
4949 #ifndef NONAMELESSSTRUCT
4951 #ifdef WORDS_BIGENDIAN
4961 } LARGE_INTEGER
, *PLARGE_INTEGER
;
4963 typedef union _ULARGE_INTEGER
{
4965 #ifdef WORDS_BIGENDIAN
4973 #ifndef NONAMELESSSTRUCT
4975 #ifdef WORDS_BIGENDIAN
4985 } ULARGE_INTEGER
, *PULARGE_INTEGER
;
4988 * Locally Unique Identifier
4991 typedef struct _LUID
{
4996 #include <pshpack4.h>
4997 typedef struct _LUID_AND_ATTRIBUTES
{
5000 } LUID_AND_ATTRIBUTES
, *PLUID_AND_ATTRIBUTES
;
5001 #include <poppack.h>
5007 typedef struct _PRIVILEGE_SET
{
5008 DWORD PrivilegeCount
;
5010 LUID_AND_ATTRIBUTES Privilege
[ANYSIZE_ARRAY
];
5011 } PRIVILEGE_SET
, *PPRIVILEGE_SET
;
5017 typedef struct _TOKEN_PRIVILEGES
{
5018 DWORD PrivilegeCount
;
5019 LUID_AND_ATTRIBUTES Privileges
[ANYSIZE_ARRAY
];
5020 } TOKEN_PRIVILEGES
, *PTOKEN_PRIVILEGES
;
5026 typedef struct _TOKEN_OWNER
{
5028 } TOKEN_OWNER
, *PTOKEN_OWNER
;
5031 * TOKEN_PRIMARY_GROUP
5034 typedef struct _TOKEN_PRIMARY_GROUP
{
5036 } TOKEN_PRIMARY_GROUP
, *PTOKEN_PRIMARY_GROUP
;
5040 * TOKEN_DEFAULT_DACL
5043 typedef struct _TOKEN_DEFAULT_DACL
{
5045 } TOKEN_DEFAULT_DACL
, *PTOKEN_DEFAULT_DACL
;
5051 #define TOKEN_SOURCE_LENGTH 8
5053 typedef struct _TOKEN_SOURCE
{
5054 char SourceName
[TOKEN_SOURCE_LENGTH
];
5055 LUID SourceIdentifier
;
5056 } TOKEN_SOURCE
, *PTOKEN_SOURCE
;
5062 typedef enum tagTOKEN_TYPE
{
5068 * SECURITY_IMPERSONATION_LEVEL
5071 typedef enum _SECURITY_IMPERSONATION_LEVEL
{
5073 SecurityIdentification
,
5074 SecurityImpersonation
,
5076 } SECURITY_IMPERSONATION_LEVEL
, *PSECURITY_IMPERSONATION_LEVEL
;
5078 #define SECURITY_DYNAMIC_TRACKING (TRUE)
5079 #define SECURITY_STATIC_TRACKING (FALSE)
5081 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE
,
5082 * PSECURITY_CONTEXT_TRACKING_MODE
;
5084 * Quality of Service
5087 typedef struct _SECURITY_QUALITY_OF_SERVICE
{
5089 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5090 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
;
5091 BOOLEAN EffectiveOnly
;
5092 } SECURITY_QUALITY_OF_SERVICE
, *PSECURITY_QUALITY_OF_SERVICE
;
5098 #include <pshpack4.h>
5099 typedef struct _TOKEN_STATISTICS
{
5101 LUID AuthenticationId
;
5102 LARGE_INTEGER ExpirationTime
;
5103 TOKEN_TYPE TokenType
;
5104 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5105 DWORD DynamicCharged
;
5106 DWORD DynamicAvailable
;
5108 DWORD PrivilegeCount
;
5111 #include <poppack.h>
5113 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES
{
5116 PSID_AND_ATTRIBUTES Sids
;
5117 DWORD RestrictedSidCount
;
5118 DWORD RestrictedSidLength
;
5119 PSID_AND_ATTRIBUTES RestrictedSids
;
5120 DWORD PrivilegeCount
;
5121 DWORD PrivilegeLength
;
5122 PLUID_AND_ATTRIBUTES Privileges
;
5123 LUID AuthenticationId
;
5124 } TOKEN_GROUPS_AND_PRIVILEGES
, * PTOKEN_GROUPS_AND_PRIVILEGES
;
5126 typedef struct _TOKEN_ORIGIN
{
5127 LUID OriginatingLogonSession
;
5128 } TOKEN_ORIGIN
, * PTOKEN_ORIGIN
;
5130 typedef struct _TOKEN_LINKED_TOKEN
{
5132 } TOKEN_LINKED_TOKEN
, * PTOKEN_LINKED_TOKEN
;
5134 typedef struct _TOKEN_ELEVATION
{
5135 DWORD TokenIsElevated
;
5136 } TOKEN_ELEVATION
, * PTOKEN_ELEVATION
;
5138 typedef struct _TOKEN_MANDATORY_LABEL
{
5139 SID_AND_ATTRIBUTES Label
;
5140 } TOKEN_MANDATORY_LABEL
, * PTOKEN_MANDATORY_LABEL
;
5142 #define TOKEN_MANDATORY_POLICY_OFF 0x0
5143 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
5144 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
5145 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
5147 typedef struct _TOKEN_MANDATORY_POLICY
{
5149 } TOKEN_MANDATORY_POLICY
, *PTOKEN_MANDATORY_POLICY
;
5151 typedef struct _TOKEN_APPCONTAINER_INFORMATION
{
5152 PSID TokenAppContainer
;
5153 } TOKEN_APPCONTAINER_INFORMATION
, * PTOKEN_APPCONTAINER_INFORMATION
;
5155 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
5157 typedef struct _TOKEN_AUDIT_POLICY
{
5158 BYTE PerUserPolicy
[((POLICY_AUDIT_SUBCATEGORY_COUNT
) >> 1) + 1];
5159 } TOKEN_AUDIT_POLICY
, *PTOKEN_AUDIT_POLICY
;
5161 typedef struct _TOKEN_ACCESS_INFORMATION
{
5162 PSID_AND_ATTRIBUTES_HASH SidHash
;
5163 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash
;
5164 PTOKEN_PRIVILEGES Privileges
;
5165 LUID AuthenticationId
;
5166 TOKEN_TYPE TokenType
;
5167 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5168 TOKEN_MANDATORY_POLICY MandatoryPolicy
;
5170 } TOKEN_ACCESS_INFORMATION
, *PTOKEN_ACCESS_INFORMATION
;
5172 typedef struct _TOKEN_CONTROL
{
5174 LUID AuthenticationId
;
5176 TOKEN_SOURCE TokenSource
;
5177 } TOKEN_CONTROL
, *PTOKEN_CONTROL
;
5183 /* ACEs, directly starting after an ACL */
5184 typedef struct _ACE_HEADER
{
5188 } ACE_HEADER
,*PACE_HEADER
;
5191 #define ACCESS_MIN_MS_ACE_TYPE 0x0
5192 #define ACCESS_ALLOWED_ACE_TYPE 0x0
5193 #define ACCESS_DENIED_ACE_TYPE 0x1
5194 #define SYSTEM_AUDIT_ACE_TYPE 0x2
5195 #define SYSTEM_ALARM_ACE_TYPE 0x3
5196 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
5197 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
5198 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
5199 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
5200 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
5201 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
5202 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
5203 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
5204 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
5205 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
5206 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
5207 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
5208 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
5209 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
5210 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
5211 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
5212 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
5213 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
5214 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
5215 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
5216 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
5217 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
5219 /* inherit AceFlags */
5220 #define OBJECT_INHERIT_ACE 0x01
5221 #define CONTAINER_INHERIT_ACE 0x02
5222 #define NO_PROPAGATE_INHERIT_ACE 0x04
5223 #define INHERIT_ONLY_ACE 0x08
5224 #define INHERITED_ACE 0x10
5225 #define VALID_INHERIT_FLAGS 0x1F
5227 /* AceFlags mask for what events we (should) audit */
5228 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
5229 #define FAILED_ACCESS_ACE_FLAG 0x80
5231 /* different ACEs depending on AceType
5232 * SidStart marks the begin of a SID
5233 * so the thing finally looks like this:
5238 typedef struct _ACCESS_ALLOWED_ACE
{
5242 } ACCESS_ALLOWED_ACE
,*PACCESS_ALLOWED_ACE
;
5244 typedef struct _ACCESS_DENIED_ACE
{
5248 } ACCESS_DENIED_ACE
,*PACCESS_DENIED_ACE
;
5250 typedef struct _SYSTEM_AUDIT_ACE
{
5254 } SYSTEM_AUDIT_ACE
,*PSYSTEM_AUDIT_ACE
;
5256 typedef struct _SYSTEM_ALARM_ACE
{
5260 } SYSTEM_ALARM_ACE
,*PSYSTEM_ALARM_ACE
;
5262 typedef struct _SYSTEM_MANDATORY_LABEL_ACE
{
5266 } SYSTEM_MANDATORY_LABEL_ACE
,*PSYSTEM_MANDATORY_LABEL_ACE
;
5268 typedef struct _ACCESS_ALLOWED_OBJECT_ACE
{
5273 GUID InheritedObjectType
;
5275 } ACCESS_ALLOWED_OBJECT_ACE
, *PACCESS_ALLOWED_OBJECT_ACE
;
5277 typedef struct _ACCESS_DENIED_OBJECT_ACE
{
5282 GUID InheritedObjectType
;
5284 } ACCESS_DENIED_OBJECT_ACE
, *PACCESS_DENIED_OBJECT_ACE
;
5286 typedef struct _SYSTEM_AUDIT_OBJECT_ACE
{
5291 GUID InheritedObjectType
;
5293 } SYSTEM_AUDIT_OBJECT_ACE
, *PSYSTEM_AUDIT_OBJECT_ACE
;
5295 typedef struct _SYSTEM_ALARM_OBJECT_ACE
{
5300 GUID InheritedObjectType
;
5302 } SYSTEM_ALARM_OBJECT_ACE
, *PSYSTEM_ALARM_OBJECT_aCE
;
5304 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE
{
5308 } ACCESS_ALLOWED_CALLBACK_ACE
,*PACCESS_ALLOWED_CALLBACK_ACE
;
5310 typedef struct _ACCESS_DENIED_CALLBACK_ACE
{
5314 } ACCESS_DENIED_CALLBACK_ACE
,*PACCESS_DENIED_CALLBACK_ACE
;
5316 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE
{
5320 } SYSTEM_AUDIT_CALLBACK_ACE
,*PSYSTEM_AUDIT_CALLBACK_ACE
;
5322 typedef struct _SYSTEM_ALARM_CALLBACK_ACE
{
5326 } SYSTEM_ALARM_CALLBACK_ACE
,*PSYSTEM_ALARM_CALLBACK_ACE
;
5328 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
{
5333 GUID InheritedObjectType
;
5335 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE
;
5337 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE
{
5342 GUID InheritedObjectType
;
5344 } ACCESS_DENIED_CALLBACK_OBJECT_ACE
, *PACCESS_DENIED_CALLBACK_OBJECT_ACE
;
5346 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
{
5351 GUID InheritedObjectType
;
5353 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE
;
5355 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE
{
5360 GUID InheritedObjectType
;
5362 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE
, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE
;
5364 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
5365 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
5366 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
5367 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
5369 typedef enum tagSID_NAME_USE
{
5374 SidTypeWellKnownGroup
,
5375 SidTypeDeletedAccount
,
5378 } SID_NAME_USE
,*PSID_NAME_USE
;
5380 #define ACE_OBJECT_TYPE_PRESENT 0x1
5381 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
5385 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
5387 #define DELETE 0x00010000
5388 #define READ_CONTROL 0x00020000
5389 #define WRITE_DAC 0x00040000
5390 #define WRITE_OWNER 0x00080000
5391 #define SYNCHRONIZE 0x00100000
5392 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
5394 #define STANDARD_RIGHTS_READ READ_CONTROL
5395 #define STANDARD_RIGHTS_WRITE READ_CONTROL
5396 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
5398 #define STANDARD_RIGHTS_ALL 0x001f0000
5400 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
5402 #define GENERIC_READ 0x80000000
5403 #define GENERIC_WRITE 0x40000000
5404 #define GENERIC_EXECUTE 0x20000000
5405 #define GENERIC_ALL 0x10000000
5407 #define MAXIMUM_ALLOWED 0x02000000
5408 #define ACCESS_SYSTEM_SECURITY 0x01000000
5410 #define EVENT_QUERY_STATE 0x0001
5411 #define EVENT_MODIFY_STATE 0x0002
5412 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5414 #define SEMAPHORE_QUERY_STATE 0x0001
5415 #define SEMAPHORE_MODIFY_STATE 0x0002
5416 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5418 #define MUTANT_QUERY_STATE 0x0001
5419 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5421 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5422 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5423 #define JOB_OBJECT_QUERY 0x0004
5424 #define JOB_OBJECT_TERMINATE 0x0008
5425 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5426 #define JOB_OBJECT_IMPERSONATE 0x0020
5427 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3f)
5429 #define TIMER_QUERY_STATE 0x0001
5430 #define TIMER_MODIFY_STATE 0x0002
5431 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5433 #define PROCESS_TERMINATE 0x0001
5434 #define PROCESS_CREATE_THREAD 0x0002
5435 #define PROCESS_VM_OPERATION 0x0008
5436 #define PROCESS_VM_READ 0x0010
5437 #define PROCESS_VM_WRITE 0x0020
5438 #define PROCESS_DUP_HANDLE 0x0040
5439 #define PROCESS_CREATE_PROCESS 0x0080
5440 #define PROCESS_SET_QUOTA 0x0100
5441 #define PROCESS_SET_INFORMATION 0x0200
5442 #define PROCESS_QUERY_INFORMATION 0x0400
5443 #define PROCESS_SUSPEND_RESUME 0x0800
5444 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5445 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5446 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5448 #define THREAD_TERMINATE 0x0001
5449 #define THREAD_SUSPEND_RESUME 0x0002
5450 #define THREAD_GET_CONTEXT 0x0008
5451 #define THREAD_SET_CONTEXT 0x0010
5452 #define THREAD_SET_INFORMATION 0x0020
5453 #define THREAD_QUERY_INFORMATION 0x0040
5454 #define THREAD_SET_THREAD_TOKEN 0x0080
5455 #define THREAD_IMPERSONATE 0x0100
5456 #define THREAD_DIRECT_IMPERSONATION 0x0200
5457 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5458 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5459 #define THREAD_RESUME 0x1000
5460 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5462 #define THREAD_BASE_PRIORITY_LOWRT 15
5463 #define THREAD_BASE_PRIORITY_MAX 2
5464 #define THREAD_BASE_PRIORITY_MIN -2
5465 #define THREAD_BASE_PRIORITY_IDLE -15
5467 typedef struct _QUOTA_LIMITS
{
5468 SIZE_T PagedPoolLimit
;
5469 SIZE_T NonPagedPoolLimit
;
5470 SIZE_T MinimumWorkingSetSize
;
5471 SIZE_T MaximumWorkingSetSize
;
5472 SIZE_T PagefileLimit
;
5473 LARGE_INTEGER TimeLimit
;
5474 } QUOTA_LIMITS
, *PQUOTA_LIMITS
;
5476 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5477 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5478 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5479 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5480 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5482 typedef union _RATE_QUOTA_LIMIT
{
5485 DWORD RatePercent
:7;
5488 } RATE_QUOTA_LIMIT
, *PRATE_QUOTA_LIMIT
;
5490 typedef struct _QUOTA_LIMITS_EX
{
5491 SIZE_T PagedPoolLimit
;
5492 SIZE_T NonPagedPoolLimit
;
5493 SIZE_T MinimumWorkingSetSize
;
5494 SIZE_T MaximumWorkingSetSize
;
5495 SIZE_T PagefileLimit
;
5496 LARGE_INTEGER TimeLimit
;
5497 SIZE_T WorkingSetLimit
;
5502 RATE_QUOTA_LIMIT CpuRateLimit
;
5503 } QUOTA_LIMITS_EX
, *PQUOTA_LIMITS_EX
;
5505 #define SECTION_QUERY 0x0001
5506 #define SECTION_MAP_WRITE 0x0002
5507 #define SECTION_MAP_READ 0x0004
5508 #define SECTION_MAP_EXECUTE 0x0008
5509 #define SECTION_EXTEND_SIZE 0x0010
5510 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5511 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5513 #define FILE_READ_DATA 0x0001 /* file & pipe */
5514 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5515 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5516 #define FILE_ADD_FILE 0x0002 /* directory */
5517 #define FILE_APPEND_DATA 0x0004 /* file */
5518 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5519 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5520 #define FILE_READ_EA 0x0008 /* file & directory */
5521 #define FILE_READ_PROPERTIES FILE_READ_EA
5522 #define FILE_WRITE_EA 0x0010 /* file & directory */
5523 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5524 #define FILE_EXECUTE 0x0020 /* file */
5525 #define FILE_TRAVERSE 0x0020 /* directory */
5526 #define FILE_DELETE_CHILD 0x0040 /* directory */
5527 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5528 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5529 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5531 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5532 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5534 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5535 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5536 FILE_APPEND_DATA | SYNCHRONIZE)
5537 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5538 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5540 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5541 #define DUPLICATE_SAME_ACCESS 0x00000002
5543 #define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
5546 /* File attribute flags */
5547 #define FILE_SHARE_READ 0x00000001
5548 #define FILE_SHARE_WRITE 0x00000002
5549 #define FILE_SHARE_DELETE 0x00000004
5551 #define FILE_ATTRIBUTE_READONLY 0x00000001
5552 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5553 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5554 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5555 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5556 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5557 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5558 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5559 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5560 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5561 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5562 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5563 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5564 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5565 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5566 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5567 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5568 #define FILE_ATTRIBUTE_EA 0x00040000
5570 /* File notification flags */
5571 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5572 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5573 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5574 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5575 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5576 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5577 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5578 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5579 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5580 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5581 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5582 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5583 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5585 #define FILE_ACTION_ADDED 0x00000001
5586 #define FILE_ACTION_REMOVED 0x00000002
5587 #define FILE_ACTION_MODIFIED 0x00000003
5588 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5589 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5590 #define FILE_ACTION_ADDED_STREAM 0x00000006
5591 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5592 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5593 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5594 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5595 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5597 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5598 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5599 #define FILE_UNICODE_ON_DISK 0x00000004
5600 #define FILE_PERSISTENT_ACLS 0x00000008
5601 #define FILE_FILE_COMPRESSION 0x00000010
5602 #define FILE_VOLUME_QUOTAS 0x00000020
5603 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5604 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5605 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5606 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5607 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5608 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5609 #define FILE_NAMED_STREAMS 0x00040000
5610 #define FILE_READ_ONLY_VOLUME 0x00080000
5611 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5612 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5613 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5614 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5615 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5616 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5617 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5618 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5619 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5620 #define FILE_DAX_VOLUME 0x20000000
5621 #define FILE_SUPPORTS_GHOSTING 0x40000000
5623 /* File alignments (NT) */
5624 #define FILE_BYTE_ALIGNMENT 0x00000000
5625 #define FILE_WORD_ALIGNMENT 0x00000001
5626 #define FILE_LONG_ALIGNMENT 0x00000003
5627 #define FILE_QUAD_ALIGNMENT 0x00000007
5628 #define FILE_OCTA_ALIGNMENT 0x0000000f
5629 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5630 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5631 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5632 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5633 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5635 #define COMPRESSION_FORMAT_NONE 0
5636 #define COMPRESSION_FORMAT_DEFAULT 1
5637 #define COMPRESSION_FORMAT_LZNT1 2
5638 #define COMPRESSION_ENGINE_STANDARD 0
5639 #define COMPRESSION_ENGINE_MAXIMUM 256
5641 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5642 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5644 #define REG_NONE 0 /* no type */
5645 #define REG_SZ 1 /* string type (ASCII) */
5646 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5647 #define REG_BINARY 3 /* binary format, callerspecific */
5648 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5649 #define REG_DWORD 4 /* DWORD in little endian format */
5650 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5651 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5652 #define REG_LINK 6 /* symbolic link (UNICODE) */
5653 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5654 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5655 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5656 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5657 #define REG_QWORD 11 /* QWORD in little endian format */
5658 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5660 /* ----------------------------- begin power management --------------------- */
5662 typedef enum _LATENCY_TIME
{
5665 } LATENCY_TIME
, *PLATENCY_TIME
;
5667 #define DISCHARGE_POLICY_CRITICAL 0
5668 #define DISCHARGE_POLICY_LOW 1
5669 #define NUM_DISCHARGE_POLICIES 4
5671 #define PO_THROTTLE_NONE 0
5672 #define PO_THROTTLE_CONSTANT 1
5673 #define PO_THROTTLE_DEGRADE 2
5674 #define PO_THROTTLE_ADAPTIVE 3
5676 typedef enum _POWER_ACTION
{
5677 PowerActionNone
= 0,
5678 PowerActionReserved
,
5680 PowerActionHibernate
,
5681 PowerActionShutdown
,
5682 PowerActionShutdownReset
,
5683 PowerActionShutdownOff
,
5684 PowerActionWarmEject
5688 typedef enum _POWER_PLATFORM_ROLE
{
5689 PlatformRoleUnspecified
,
5690 PlatformRoleDesktop
,
5692 PlatformRoleWorkstation
,
5693 PlatformRoleEnterpriseServer
,
5694 PlatformRoleSOHOServer
,
5695 PlatformRoleAppliancePC
,
5696 PlatformRolePerformanceServer
,
5699 } POWER_PLATFORM_ROLE
, *PPOWER_PLATFORM_ROLE
;
5701 typedef enum _SYSTEM_POWER_STATE
{
5702 PowerSystemUnspecified
= 0,
5703 PowerSystemWorking
= 1,
5704 PowerSystemSleeping1
= 2,
5705 PowerSystemSleeping2
= 3,
5706 PowerSystemSleeping3
= 4,
5707 PowerSystemHibernate
= 5,
5708 PowerSystemShutdown
= 6,
5709 PowerSystemMaximum
= 7
5710 } SYSTEM_POWER_STATE
,
5711 *PSYSTEM_POWER_STATE
;
5713 typedef enum _DEVICE_POWER_STATE
{
5714 PowerDeviceUnspecified
,
5720 } DEVICE_POWER_STATE
, *PDEVICE_POWER_STATE
;
5722 typedef enum _POWER_INFORMATION_LEVEL
{
5723 SystemPowerPolicyAc
,
5724 SystemPowerPolicyDc
,
5725 VerifySystemPolicyAc
,
5726 VerifySystemPolicyDc
,
5727 SystemPowerCapabilities
,
5729 SystemPowerStateHandler
,
5730 ProcessorStateHandler
,
5731 SystemPowerPolicyCurrent
,
5732 AdministratorPowerPolicy
,
5733 SystemReserveHiberFile
,
5734 ProcessorInformation
,
5735 SystemPowerInformation
,
5736 ProcessorStateHandler2
,
5739 SystemExecutionState
,
5740 SystemPowerStateNotifyHandler
,
5741 ProcessorPowerPolicyAc
,
5742 ProcessorPowerPolicyDc
,
5743 VerifyProcessorPowerPolicyAc
,
5744 VerifyProcessorPowerPolicyDc
,
5745 ProcessorPowerPolicyCurrent
5746 } POWER_INFORMATION_LEVEL
;
5748 typedef struct _ADMINISTRATOR_POWER_POLICY
{
5749 SYSTEM_POWER_STATE MinSleep
;
5750 SYSTEM_POWER_STATE MaxSleep
;
5751 ULONG MinVideoTimeout
;
5752 ULONG MaxVideoTimeout
;
5753 ULONG MinSpindownTimeout
;
5754 ULONG MaxSpindownTimeout
;
5755 } ADMINISTRATOR_POWER_POLICY
, *PADMINISTRATOR_POWER_POLICY
;
5760 } BATTERY_REPORTING_SCALE
,
5761 *PBATTERY_REPORTING_SCALE
;
5764 POWER_ACTION Action
;
5767 } POWER_ACTION_POLICY
,
5768 *PPOWER_ACTION_POLICY
;
5770 typedef struct _PROCESSOR_POWER_INFORMATION
{
5776 ULONG CurrentIdleState
;
5777 } PROCESSOR_POWER_INFORMATION
,
5778 *PPROCESSOR_POWER_INFORMATION
;
5780 typedef struct _PROCESSOR_POWER_POLICY_INFO
{
5784 UCHAR DemotePercent
;
5785 UCHAR PromotePercent
;
5787 ULONG AllowDemotion
:1;
5788 ULONG AllowPromotion
:1;
5790 } PROCESSOR_POWER_POLICY_INFO
,
5791 *PPROCESSOR_POWER_POLICY_INFO
;
5793 typedef struct _PROCESSOR_POWER_POLICY
{
5795 BYTE DynamicThrottle
;
5797 DWORD DisableCStates
:1;
5800 PROCESSOR_POWER_POLICY_INFO Policy
[3];
5801 } PROCESSOR_POWER_POLICY
,
5802 *PPROCESSOR_POWER_POLICY
;
5806 BOOLEAN BatteryPresent
;
5808 BOOLEAN Discharging
;
5812 ULONG RemainingCapacity
;
5814 ULONG EstimatedTime
;
5815 ULONG DefaultAlert1
;
5816 ULONG DefaultAlert2
;
5817 } SYSTEM_BATTERY_STATE
,
5818 *PSYSTEM_BATTERY_STATE
;
5821 BOOLEAN PowerButtonPresent
;
5822 BOOLEAN SleepButtonPresent
;
5829 BOOLEAN HiberFilePresent
;
5831 BOOLEAN VideoDimPresent
;
5834 BOOLEAN ThermalControl
;
5835 BOOLEAN ProcessorThrottle
;
5836 UCHAR ProcessorMinThrottle
;
5837 UCHAR ProcessorMaxThrottle
;
5839 BOOLEAN DiskSpinDown
;
5841 BOOLEAN SystemBatteriesPresent
;
5842 BOOLEAN BatteriesAreShortTerm
;
5843 BATTERY_REPORTING_SCALE BatteryScale
[3];
5844 SYSTEM_POWER_STATE AcOnLineWake
;
5845 SYSTEM_POWER_STATE SoftLidWake
;
5846 SYSTEM_POWER_STATE RtcWake
;
5847 SYSTEM_POWER_STATE MinDeviceWakeState
;
5848 SYSTEM_POWER_STATE DefaultLowLatencyWake
;
5849 } SYSTEM_POWER_CAPABILITIES
,
5850 *PSYSTEM_POWER_CAPABILITIES
;
5852 typedef struct _SYSTEM_POWER_INFORMATION
{
5853 ULONG MaxIdlenessAllowed
;
5855 ULONG TimeRemaining
;
5857 } SYSTEM_POWER_INFORMATION
,
5858 *PSYSTEM_POWER_INFORMATION
;
5860 typedef struct _SYSTEM_POWER_LEVEL
{
5864 POWER_ACTION_POLICY PowerPolicy
;
5865 SYSTEM_POWER_STATE MinSystemState
;
5866 } SYSTEM_POWER_LEVEL
,
5867 *PSYSTEM_POWER_LEVEL
;
5869 typedef struct _SYSTEM_POWER_POLICY
{
5871 POWER_ACTION_POLICY PowerButton
;
5872 POWER_ACTION_POLICY SleepButton
;
5873 POWER_ACTION_POLICY LidClose
;
5874 SYSTEM_POWER_STATE LidOpenWake
;
5876 POWER_ACTION_POLICY Idle
;
5878 UCHAR IdleSensitivity
;
5879 UCHAR DynamicThrottle
;
5881 SYSTEM_POWER_STATE MinSleep
;
5882 SYSTEM_POWER_STATE MaxSleep
;
5883 SYSTEM_POWER_STATE ReducedLatencySleep
;
5884 ULONG WinLogonFlags
;
5886 ULONG DozeS4Timeout
;
5887 ULONG BroadcastCapacityResolution
;
5888 SYSTEM_POWER_LEVEL DischargePolicy
[NUM_DISCHARGE_POLICIES
];
5890 BOOLEAN VideoDimDisplay
;
5891 ULONG VideoReserved
[3];
5892 ULONG SpindownTimeout
;
5893 BOOLEAN OptimizeForPower
;
5894 UCHAR FanThrottleTolerance
;
5895 UCHAR ForcedThrottle
;
5897 POWER_ACTION_POLICY OverThrottled
;
5898 } SYSTEM_POWER_POLICY
,
5899 *PSYSTEM_POWER_POLICY
;
5901 typedef enum _POWER_REQUEST_TYPE
5903 PowerRequestDisplayRequired
,
5904 PowerRequestSystemRequired
,
5905 PowerRequestAwayModeRequired
5906 } POWER_REQUEST_TYPE
, *PPOWER_REQUEST_TYPE
;
5908 #define POWER_REQUEST_CONTEXT_VERSION 0
5910 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5911 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5913 typedef union _FILE_SEGMENT_ELEMENT
{
5915 ULONGLONG Alignment
;
5916 } FILE_SEGMENT_ELEMENT
, *PFILE_SEGMENT_ELEMENT
;
5918 typedef struct _FILE_NOTIFY_INFORMATION
{
5919 DWORD NextEntryOffset
;
5921 DWORD FileNameLength
;
5923 } FILE_NOTIFY_INFORMATION
, *PFILE_NOTIFY_INFORMATION
;
5925 /* ----------------------------- begin tape storage --------------------- */
5927 #define TAPE_FIXED_PARTITIONS 0
5928 #define TAPE_SELECT_PARTITIONS 1
5929 #define TAPE_INITIATOR_PARTITIONS 2
5930 #define TAPE_ERASE_SHORT 0
5931 #define TAPE_ERASE_LONG 1
5933 #define TAPE_UNLOAD 1
5934 #define TAPE_TENSION 2
5936 #define TAPE_UNLOCK 4
5937 #define TAPE_FORMAT 5
5938 #define TAPE_SETMARKS 0
5939 #define TAPE_FILEMARKS 1
5940 #define TAPE_SHORT_FILEMARKS 2
5941 #define TAPE_LONG_FILEMARKS 3
5942 #define TAPE_REWIND 0
5943 #define TAPE_ABSOLUTE_BLOCK 1
5944 #define TAPE_LOGICAL_BLOCK 2
5945 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5946 #define TAPE_SPACE_END_OF_DATA 4
5947 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5948 #define TAPE_SPACE_FILEMARKS 6
5949 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5950 #define TAPE_SPACE_SETMARKS 8
5951 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5953 typedef struct _TAPE_CREATE_PARTITION
{
5957 } TAPE_CREATE_PARTITION
, *PTAPE_CREATE_PARTITION
;
5959 typedef struct _TAPE_ERASE
{
5962 } TAPE_ERASE
, *PTAPE_ERASE
;
5964 typedef struct _TAPE_PREPARE
{
5967 } TAPE_PREPARE
, *PTAPE_PREPARE
;
5969 typedef struct _TAPE_SET_DRIVE_PARAMETERS
{
5971 BOOLEAN Compression
;
5972 BOOLEAN DataPadding
;
5973 BOOLEAN ReportSetmarks
;
5974 ULONG EOTWarningZoneSize
;
5975 } TAPE_SET_DRIVE_PARAMETERS
, *PTAPE_SET_DRIVE_PARAMETERS
;
5977 typedef struct _TAPE_SET_MEDIA_PARAMETERS
{
5979 } TAPE_SET_MEDIA_PARAMETERS
, *PTAPE_SET_MEDIA_PARAMETERS
;
5981 typedef struct _TAPE_WRITE_MARKS
{
5985 } TAPE_WRITE_MARKS
, *PTAPE_WRITE_MARKS
;
5987 typedef struct _TAPE_GET_POSITION
{
5992 } TAPE_GET_POSITION
, *PTAPE_GET_POSITION
;
5994 typedef struct _TAPE_SET_POSITION
{
5997 LARGE_INTEGER Offset
;
5999 } TAPE_SET_POSITION
, *PTAPE_SET_POSITION
;
6001 typedef struct _TAPE_GET_DRIVE_PARAMETERS
{
6003 BOOLEAN Compression
;
6004 BOOLEAN DataPadding
;
6005 BOOLEAN ReportSetmarks
;
6006 DWORD DefaultBlockSize
;
6007 DWORD MaximumBlockSize
;
6008 DWORD MinimumBlockSize
;
6009 DWORD MaximumPartitionCount
;
6012 DWORD EOTWarningZoneSize
;
6013 } TAPE_GET_DRIVE_PARAMETERS
, *PTAPE_GET_DRIVE_PARAMETERS
;
6015 typedef struct _TAPE_GET_MEDIA_PARAMETERS
{
6016 LARGE_INTEGER Capacity
;
6017 LARGE_INTEGER Remaining
;
6019 DWORD PartitionCount
;
6020 BOOLEAN WriteProtected
;
6021 } TAPE_GET_MEDIA_PARAMETERS
, *PTAPE_GET_MEDIA_PARAMETERS
;
6023 /* ----------------------------- begin registry ----------------------------- */
6025 /* Registry security values */
6026 #define OWNER_SECURITY_INFORMATION 0x00000001
6027 #define GROUP_SECURITY_INFORMATION 0x00000002
6028 #define DACL_SECURITY_INFORMATION 0x00000004
6029 #define SACL_SECURITY_INFORMATION 0x00000008
6030 #define LABEL_SECURITY_INFORMATION 0x00000010
6032 #define REG_OPTION_RESERVED 0x00000000
6033 #define REG_OPTION_NON_VOLATILE 0x00000000
6034 #define REG_OPTION_VOLATILE 0x00000001
6035 #define REG_OPTION_CREATE_LINK 0x00000002
6036 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
6037 #define REG_OPTION_OPEN_LINK 0x00000008
6038 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
6039 REG_OPTION_NON_VOLATILE | \
6040 REG_OPTION_VOLATILE | \
6041 REG_OPTION_CREATE_LINK | \
6042 REG_OPTION_BACKUP_RESTORE | \
6043 REG_OPTION_OPEN_LINK)
6046 #define REG_CREATED_NEW_KEY 0x00000001
6047 #define REG_OPENED_EXISTING_KEY 0x00000002
6049 /* For RegNotifyChangeKeyValue */
6050 #define REG_NOTIFY_CHANGE_NAME 0x01
6051 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
6052 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
6053 #define REG_NOTIFY_CHANGE_SECURITY 0x08
6054 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
6056 #define KEY_QUERY_VALUE 0x00000001
6057 #define KEY_SET_VALUE 0x00000002
6058 #define KEY_CREATE_SUB_KEY 0x00000004
6059 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
6060 #define KEY_NOTIFY 0x00000010
6061 #define KEY_CREATE_LINK 0x00000020
6062 #define KEY_WOW64_64KEY 0x00000100
6063 #define KEY_WOW64_32KEY 0x00000200
6064 #define KEY_WOW64_RES 0x00000300
6066 /* for RegKeyRestore flags */
6067 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
6068 #define REG_REFRESH_HIVE 0x00000002
6069 #define REG_NO_LAZY_FLUSH 0x00000004
6070 #define REG_FORCE_RESTORE 0x00000008
6072 #define KEY_READ ((STANDARD_RIGHTS_READ| \
6074 KEY_ENUMERATE_SUB_KEYS| \
6078 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
6080 KEY_CREATE_SUB_KEY) \
6083 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
6084 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
6087 KEY_CREATE_SUB_KEY| \
6088 KEY_ENUMERATE_SUB_KEYS| \
6093 /* ------------------------------ end registry ------------------------------ */
6096 #define EVENTLOG_SUCCESS 0x0000
6097 #define EVENTLOG_ERROR_TYPE 0x0001
6098 #define EVENTLOG_WARNING_TYPE 0x0002
6099 #define EVENTLOG_INFORMATION_TYPE 0x0004
6100 #define EVENTLOG_AUDIT_SUCCESS 0x0008
6101 #define EVENTLOG_AUDIT_FAILURE 0x0010
6103 #define EVENTLOG_SEQUENTIAL_READ 0x0001
6104 #define EVENTLOG_SEEK_READ 0x0002
6105 #define EVENTLOG_FORWARDS_READ 0x0004
6106 #define EVENTLOG_BACKWARDS_READ 0x0008
6108 typedef struct _EVENTLOGRECORD
{
6112 DWORD TimeGenerated
;
6119 DWORD ClosingRecordNumber
;
6121 DWORD UserSidLength
;
6122 DWORD UserSidOffset
;
6125 } EVENTLOGRECORD
, *PEVENTLOGRECORD
;
6127 #define SERVICE_BOOT_START 0x00000000
6128 #define SERVICE_SYSTEM_START 0x00000001
6129 #define SERVICE_AUTO_START 0x00000002
6130 #define SERVICE_DEMAND_START 0x00000003
6131 #define SERVICE_DISABLED 0x00000004
6133 #define SERVICE_ERROR_IGNORE 0x00000000
6134 #define SERVICE_ERROR_NORMAL 0x00000001
6135 #define SERVICE_ERROR_SEVERE 0x00000002
6136 #define SERVICE_ERROR_CRITICAL 0x00000003
6139 #define SERVICE_KERNEL_DRIVER 0x00000001
6140 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
6141 #define SERVICE_ADAPTER 0x00000004
6142 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
6144 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
6145 SERVICE_RECOGNIZER_DRIVER )
6147 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
6148 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
6149 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
6151 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
6153 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
6154 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
6157 typedef enum _CM_SERVICE_NODE_TYPE
6159 DriverType
= SERVICE_KERNEL_DRIVER
,
6160 FileSystemType
= SERVICE_FILE_SYSTEM_DRIVER
,
6161 Win32ServiceOwnProcess
= SERVICE_WIN32_OWN_PROCESS
,
6162 Win32ServiceShareProcess
= SERVICE_WIN32_SHARE_PROCESS
,
6163 AdapterType
= SERVICE_ADAPTER
,
6164 RecognizerType
= SERVICE_RECOGNIZER_DRIVER
6165 } SERVICE_NODE_TYPE
;
6167 typedef enum _CM_SERVICE_LOAD_TYPE
6169 BootLoad
= SERVICE_BOOT_START
,
6170 SystemLoad
= SERVICE_SYSTEM_START
,
6171 AutoLoad
= SERVICE_AUTO_START
,
6172 DemandLoad
= SERVICE_DEMAND_START
,
6173 DisableLoad
= SERVICE_DISABLED
6174 } SERVICE_LOAD_TYPE
;
6176 typedef enum _CM_ERROR_CONTROL_TYPE
6178 IgnoreError
= SERVICE_ERROR_IGNORE
,
6179 NormalError
= SERVICE_ERROR_NORMAL
,
6180 SevereError
= SERVICE_ERROR_SEVERE
,
6181 CriticalError
= SERVICE_ERROR_CRITICAL
6182 } SERVICE_ERROR_TYPE
;
6184 NTSYSAPI SIZE_T WINAPI
RtlCompareMemory(const VOID
*, const VOID
*, SIZE_T
);
6185 NTSYSAPI SIZE_T WINAPI
RtlCompareMemoryUlong(VOID
*, SIZE_T
, ULONG
);
6187 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
6188 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
6189 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
6190 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
6191 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
6193 static FORCEINLINE
void *RtlSecureZeroMemory(void *buffer
, SIZE_T length
)
6195 volatile char *ptr
= (volatile char *)buffer
;
6197 while (length
--) *ptr
++ = 0;
6201 #include <guiddef.h>
6203 typedef struct _OBJECT_TYPE_LIST
{
6207 } OBJECT_TYPE_LIST
, *POBJECT_TYPE_LIST
;
6209 typedef struct _RTL_CRITICAL_SECTION_DEBUG
6212 WORD CreatorBackTraceIndex
;
6213 struct _RTL_CRITICAL_SECTION
*CriticalSection
;
6214 LIST_ENTRY ProcessLocksList
;
6216 DWORD ContentionCount
;
6217 #ifdef __WINESRC__ /* in Wine we store the name here */
6218 DWORD_PTR Spare
[8/sizeof(DWORD_PTR
)];
6222 } RTL_CRITICAL_SECTION_DEBUG
, *PRTL_CRITICAL_SECTION_DEBUG
, RTL_RESOURCE_DEBUG
, *PRTL_RESOURCE_DEBUG
;
6224 typedef struct _RTL_CRITICAL_SECTION
{
6225 PRTL_CRITICAL_SECTION_DEBUG DebugInfo
;
6227 LONG RecursionCount
;
6228 HANDLE OwningThread
;
6229 HANDLE LockSemaphore
;
6230 ULONG_PTR SpinCount
;
6231 } RTL_CRITICAL_SECTION
, *PRTL_CRITICAL_SECTION
;
6233 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
6234 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
6235 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
6236 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
6237 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
6239 typedef struct _RTL_SRWLOCK
{
6241 } RTL_SRWLOCK
, *PRTL_SRWLOCK
;
6243 #define RTL_SRWLOCK_INIT {0}
6245 typedef struct _RTL_CONDITION_VARIABLE
{
6247 } RTL_CONDITION_VARIABLE
, *PRTL_CONDITION_VARIABLE
;
6248 #define RTL_CONDITION_VARIABLE_INIT {0}
6249 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
6251 typedef VOID (NTAPI
* WAITORTIMERCALLBACKFUNC
) (PVOID
, BOOLEAN
);
6252 typedef VOID (NTAPI
* PFLS_CALLBACK_FUNCTION
) ( PVOID
);
6254 #define RTL_RUN_ONCE_INIT {0}
6255 typedef union _RTL_RUN_ONCE
{
6257 } RTL_RUN_ONCE
, *PRTL_RUN_ONCE
;
6259 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
6260 #define RTL_RUN_ONCE_ASYNC 0x00000002
6261 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
6263 typedef DWORD WINAPI
RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE
, PVOID
, PVOID
*);
6264 typedef RTL_RUN_ONCE_INIT_FN
*PRTL_RUN_ONCE_INIT_FN
;
6265 NTSYSAPI VOID WINAPI
RtlRunOnceInitialize(PRTL_RUN_ONCE
);
6266 NTSYSAPI DWORD WINAPI
RtlRunOnceExecuteOnce(PRTL_RUN_ONCE
,PRTL_RUN_ONCE_INIT_FN
,PVOID
,PVOID
*);
6267 NTSYSAPI DWORD WINAPI
RtlRunOnceBeginInitialize(PRTL_RUN_ONCE
, DWORD
, PVOID
*);
6268 NTSYSAPI DWORD WINAPI
RtlRunOnceComplete(PRTL_RUN_ONCE
, DWORD
, PVOID
);
6270 #include <pshpack8.h>
6271 typedef struct _IO_COUNTERS
{
6272 ULONGLONG
DECLSPEC_ALIGN(8) ReadOperationCount
;
6273 ULONGLONG
DECLSPEC_ALIGN(8) WriteOperationCount
;
6274 ULONGLONG
DECLSPEC_ALIGN(8) OtherOperationCount
;
6275 ULONGLONG
DECLSPEC_ALIGN(8) ReadTransferCount
;
6276 ULONGLONG
DECLSPEC_ALIGN(8) WriteTransferCount
;
6277 ULONGLONG
DECLSPEC_ALIGN(8) OtherTransferCount
;
6278 } IO_COUNTERS
, *PIO_COUNTERS
;
6279 #include <poppack.h>
6282 DWORD dwOSVersionInfoSize
;
6283 DWORD dwMajorVersion
;
6284 DWORD dwMinorVersion
;
6285 DWORD dwBuildNumber
;
6287 CHAR szCSDVersion
[128];
6288 } OSVERSIONINFOA
, *POSVERSIONINFOA
, *LPOSVERSIONINFOA
;
6291 DWORD dwOSVersionInfoSize
;
6292 DWORD dwMajorVersion
;
6293 DWORD dwMinorVersion
;
6294 DWORD dwBuildNumber
;
6296 WCHAR szCSDVersion
[128];
6297 } OSVERSIONINFOW
, *POSVERSIONINFOW
, *LPOSVERSIONINFOW
, RTL_OSVERSIONINFOW
, *PRTL_OSVERSIONINFOW
;
6299 DECL_WINELIB_TYPE_AW(OSVERSIONINFO
)
6300 DECL_WINELIB_TYPE_AW(POSVERSIONINFO
)
6301 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO
)
6304 DWORD dwOSVersionInfoSize
;
6305 DWORD dwMajorVersion
;
6306 DWORD dwMinorVersion
;
6307 DWORD dwBuildNumber
;
6309 CHAR szCSDVersion
[128];
6310 WORD wServicePackMajor
;
6311 WORD wServicePackMinor
;
6315 } OSVERSIONINFOEXA
, *POSVERSIONINFOEXA
, *LPOSVERSIONINFOEXA
;
6318 DWORD dwOSVersionInfoSize
;
6319 DWORD dwMajorVersion
;
6320 DWORD dwMinorVersion
;
6321 DWORD dwBuildNumber
;
6323 WCHAR szCSDVersion
[128];
6324 WORD wServicePackMajor
;
6325 WORD wServicePackMinor
;
6329 } OSVERSIONINFOEXW
, *POSVERSIONINFOEXW
, *LPOSVERSIONINFOEXW
, RTL_OSVERSIONINFOEXW
, *PRTL_OSVERSIONINFOEXW
;
6331 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX
)
6332 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX
)
6333 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX
)
6335 NTSYSAPI ULONGLONG WINAPI
VerSetConditionMask(ULONGLONG
,DWORD
,BYTE
);
6337 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
6339 #define VER_PLATFORM_WIN32s 0
6340 #define VER_PLATFORM_WIN32_WINDOWS 1
6341 #define VER_PLATFORM_WIN32_NT 2
6343 #define VER_MINORVERSION 0x00000001
6344 #define VER_MAJORVERSION 0x00000002
6345 #define VER_BUILDNUMBER 0x00000004
6346 #define VER_PLATFORMID 0x00000008
6347 #define VER_SERVICEPACKMINOR 0x00000010
6348 #define VER_SERVICEPACKMAJOR 0x00000020
6349 #define VER_SUITENAME 0x00000040
6350 #define VER_PRODUCT_TYPE 0x00000080
6352 #define VER_NT_WORKSTATION 1
6353 #define VER_NT_DOMAIN_CONTROLLER 2
6354 #define VER_NT_SERVER 3
6356 #define VER_SUITE_SMALLBUSINESS 0x00000001
6357 #define VER_SUITE_ENTERPRISE 0x00000002
6358 #define VER_SUITE_BACKOFFICE 0x00000004
6359 #define VER_SUITE_COMMUNICATIONS 0x00000008
6360 #define VER_SUITE_TERMINAL 0x00000010
6361 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
6362 #define VER_SUITE_EMBEDDEDNT 0x00000040
6363 #define VER_SUITE_DATACENTER 0x00000080
6364 #define VER_SUITE_SINGLEUSERTS 0x00000100
6365 #define VER_SUITE_PERSONAL 0x00000200
6366 #define VER_SUITE_BLADE 0x00000400
6367 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
6368 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
6369 #define VER_SUITE_STORAGE_SERVER 0x00002000
6370 #define VER_SUITE_COMPUTE_SERVER 0x00004000
6371 #define VER_SUITE_WH_SERVER 0x00008000
6374 #define VER_GREATER 2
6375 #define VER_GREATER_EQUAL 3
6377 #define VER_LESS_EQUAL 5
6381 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION
{
6383 DWORD ulFormatVersion
;
6384 DWORD ulAssemblyCount
;
6385 DWORD ulRootManifestPathType
;
6386 DWORD ulRootManifestPathChars
;
6387 DWORD ulRootConfigurationPathType
;
6388 DWORD ulRootConfigurationPathChars
;
6389 DWORD ulAppDirPathType
;
6390 DWORD ulAppDirPathChars
;
6391 PCWSTR lpRootManifestPath
;
6392 PCWSTR lpRootConfigurationPath
;
6393 PCWSTR lpAppDirPath
;
6394 } ACTIVATION_CONTEXT_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_DETAILED_INFORMATION
;
6396 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
{
6398 DWORD ulEncodedAssemblyIdentityLength
;
6399 DWORD ulManifestPathType
;
6400 DWORD ulManifestPathLength
;
6401 LARGE_INTEGER liManifestLastWriteTime
;
6402 DWORD ulPolicyPathType
;
6403 DWORD ulPolicyPathLength
;
6404 LARGE_INTEGER liPolicyLastWriteTime
;
6405 DWORD ulMetadataSatelliteRosterIndex
;
6406 DWORD ulManifestVersionMajor
;
6407 DWORD ulManifestVersionMinor
;
6408 DWORD ulPolicyVersionMajor
;
6409 DWORD ulPolicyVersionMinor
;
6410 DWORD ulAssemblyDirectoryNameLength
;
6411 PCWSTR lpAssemblyEncodedAssemblyIdentity
;
6412 PCWSTR lpAssemblyManifestPath
;
6413 PCWSTR lpAssemblyPolicyPath
;
6414 PCWSTR lpAssemblyDirectoryName
;
6416 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
;
6418 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX
{
6419 DWORD ulAssemblyIndex
;
6420 DWORD ulFileIndexInAssembly
;
6421 } ACTIVATION_CONTEXT_QUERY_INDEX
, *PACTIVATION_CONTEXT_QUERY_INDEX
;
6423 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX
*PCACTIVATION_CONTEXT_QUERY_INDEX
;
6425 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION
{
6427 DWORD ulFilenameLength
;
6431 } ASSEMBLY_FILE_DETAILED_INFORMATION
, *PASSEMBLY_FILE_DETAILED_INFORMATION
;
6433 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION
*PCASSEMBLY_FILE_DETAILED_INFORMATION
;
6436 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN
= 0,
6437 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
6438 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION
,
6439 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6440 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE
;
6442 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT
{
6444 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type
;
6445 } COMPATIBILITY_CONTEXT_ELEMENT
, *PCOMPATIBILITY_CONTEXT_ELEMENT
;
6447 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6448 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
{
6450 COMPATIBILITY_CONTEXT_ELEMENT Elements
[];
6451 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
;
6455 ACTCTX_RUN_LEVEL_UNSPECIFIED
= 0,
6456 ACTCTX_RUN_LEVEL_AS_INVOKER
,
6457 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE
,
6458 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
,
6459 ACTCTX_RUN_LEVEL_NUMBERS
6460 } ACTCTX_REQUESTED_RUN_LEVEL
;
6462 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
{
6464 ACTCTX_REQUESTED_RUN_LEVEL RunLevel
;
6466 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
6468 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
*PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
6470 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS
{
6471 ActivationContextBasicInformation
= 1,
6472 ActivationContextDetailedInformation
= 2,
6473 AssemblyDetailedInformationInActivationContext
= 3,
6474 FileInformationInAssemblyOfAssemblyInActivationContext
= 4,
6475 RunlevelInformationInActivationContext
= 5,
6476 CompatibilityInformationInActivationContext
= 6,
6477 ActivationContextManifestResourceName
= 7,
6478 MaxActivationContextInfoClass
,
6479 AssemblyDetailedInformationInActivationContxt
= AssemblyDetailedInformationInActivationContext
,
6480 FileInformationInAssemblyOfAssemblyInActivationContxt
= FileInformationInAssemblyOfAssemblyInActivationContext
6481 } ACTIVATION_CONTEXT_INFO_CLASS
;
6483 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6484 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6485 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6486 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6488 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6489 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6490 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6491 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6492 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6493 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6494 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6495 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6496 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6497 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6498 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6500 typedef enum _JOBOBJECTINFOCLASS
6502 JobObjectBasicAccountingInformation
= 1,
6503 JobObjectBasicLimitInformation
,
6504 JobObjectBasicProcessIdList
,
6505 JobObjectBasicUIRestrictions
,
6506 JobObjectSecurityLimitInformation
,
6507 JobObjectEndOfJobTimeInformation
,
6508 JobObjectAssociateCompletionPortInformation
,
6509 JobObjectBasicAndIoAccountingInformation
,
6510 JobObjectExtendedLimitInformation
,
6511 JobObjectJobSetInformation
,
6512 MaxJobObjectInfoClass
6513 } JOBOBJECTINFOCLASS
;
6515 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
{
6516 LARGE_INTEGER TotalUserTime
;
6517 LARGE_INTEGER TotalKernelTime
;
6518 LARGE_INTEGER ThisPeriodTotalUserTime
;
6519 LARGE_INTEGER ThisPeriodTotalKernelTime
;
6520 DWORD TotalPageFaultCount
;
6521 DWORD TotalProcesses
;
6522 DWORD ActiveProcesses
;
6523 DWORD TotalTerminatedProcesses
;
6524 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION
;
6526 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION
{
6527 LARGE_INTEGER PerProcessUserTimeLimit
;
6528 LARGE_INTEGER PerJobUserTimeLimit
;
6530 SIZE_T MinimumWorkingSetSize
;
6531 SIZE_T MaximumWorkingSetSize
;
6532 DWORD ActiveProcessLimit
;
6534 DWORD PriorityClass
;
6535 DWORD SchedulingClass
;
6536 } JOBOBJECT_BASIC_LIMIT_INFORMATION
, *PJOBOBJECT_BASIC_LIMIT_INFORMATION
;
6538 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST
{
6539 DWORD NumberOfAssignedProcesses
;
6540 DWORD NumberOfProcessIdsInList
;
6541 ULONG_PTR ProcessIdList
[1];
6542 } JOBOBJECT_BASIC_PROCESS_ID_LIST
, *PJOBOBJECT_BASIC_PROCESS_ID_LIST
;
6544 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS
{
6545 DWORD UIRestrictionsClass
;
6546 } JOBOBJECT_BASIC_UI_RESTRICTIONS
, *PJOBOBJECT_BASIC_UI_RESTRICTIONS
;
6548 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION
{
6549 DWORD SecurityLimitFlags
;
6551 PTOKEN_GROUPS SidsToDisable
;
6552 PTOKEN_PRIVILEGES PrivilegesToDelete
;
6553 PTOKEN_GROUPS RestrictedSids
;
6554 } JOBOBJECT_SECURITY_LIMIT_INFORMATION
, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION
;
6556 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION
{
6557 DWORD EndOfJobTimeAction
;
6558 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION
, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION
;
6560 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT
{
6561 PVOID CompletionKey
;
6562 HANDLE CompletionPort
;
6563 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT
, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT
;
6565 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6566 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6567 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6568 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6569 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6570 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6571 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6572 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6573 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6575 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
{
6576 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo
;
6578 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
;
6580 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION
{
6581 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation
;
6583 SIZE_T ProcessMemoryLimit
;
6584 SIZE_T JobMemoryLimit
;
6585 SIZE_T PeakProcessMemoryUsed
;
6586 SIZE_T PeakJobMemoryUsed
;
6587 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION
, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION
;
6589 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6590 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6591 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6592 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6593 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6594 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6595 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6596 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6597 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6598 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6599 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6600 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6601 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6602 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6603 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6605 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6606 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6607 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6609 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6611 RelationProcessorCore
= 0,
6612 RelationNumaNode
= 1,
6614 RelationProcessorPackage
= 3,
6616 RelationAll
= 0xffff
6617 } LOGICAL_PROCESSOR_RELATIONSHIP
;
6619 #define LTP_PC_SMT 0x1
6621 typedef enum _PROCESSOR_CACHE_TYPE
6627 } PROCESSOR_CACHE_TYPE
;
6629 typedef struct _PROCESSOR_GROUP_INFO
6631 BYTE MaximumProcessorCount
;
6632 BYTE ActiveProcessorCount
;
6634 KAFFINITY ActiveProcessorMask
;
6635 } PROCESSOR_GROUP_INFO
, *PPROCESSOR_GROUP_INFO
;
6637 typedef struct _CACHE_DESCRIPTOR
6643 PROCESSOR_CACHE_TYPE Type
;
6644 } CACHE_DESCRIPTOR
, *PCACHE_DESCRIPTOR
;
6646 typedef struct _GROUP_AFFINITY
6651 } GROUP_AFFINITY
, *PGROUP_AFFINITY
;
6653 #define ALL_PROCESSOR_GROUPS 0xffff
6655 typedef struct _PROCESSOR_NUMBER
6660 } PROCESSOR_NUMBER
, *PPROCESSOR_NUMBER
;
6662 typedef struct _PROCESSOR_RELATIONSHIP
6665 BYTE EfficiencyClass
;
6668 GROUP_AFFINITY GroupMask
[ANYSIZE_ARRAY
];
6669 } PROCESSOR_RELATIONSHIP
, *PPROCESSOR_RELATIONSHIP
;
6671 typedef struct _NUMA_NODE_RELATIONSHIP
6675 GROUP_AFFINITY GroupMask
;
6676 } NUMA_NODE_RELATIONSHIP
, *PNUMA_NODE_RELATIONSHIP
;
6678 typedef struct _CACHE_RELATIONSHIP
6684 PROCESSOR_CACHE_TYPE Type
;
6686 GROUP_AFFINITY GroupMask
;
6687 } CACHE_RELATIONSHIP
, *PCACHE_RELATIONSHIP
;
6689 typedef struct _GROUP_RELATIONSHIP
6691 WORD MaximumGroupCount
;
6692 WORD ActiveGroupCount
;
6694 PROCESSOR_GROUP_INFO GroupInfo
[ANYSIZE_ARRAY
];
6695 } GROUP_RELATIONSHIP
, *PGROUP_RELATIONSHIP
;
6697 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6699 ULONG_PTR ProcessorMask
;
6700 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6711 CACHE_DESCRIPTOR Cache
;
6712 ULONGLONG Reserved
[2];
6714 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION
;
6716 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6718 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6722 PROCESSOR_RELATIONSHIP Processor
;
6723 NUMA_NODE_RELATIONSHIP NumaNode
;
6724 CACHE_RELATIONSHIP Cache
;
6725 GROUP_RELATIONSHIP Group
;
6727 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
;
6729 /* Threadpool things */
6730 typedef DWORD TP_VERSION
,*PTP_VERSION
;
6732 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE
,*PTP_CALLBACK_INSTANCE
;
6734 typedef VOID (CALLBACK
*PTP_SIMPLE_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
);
6736 typedef struct _TP_POOL TP_POOL
,*PTP_POOL
;
6738 typedef enum _TP_CALLBACK_PRIORITY
6740 TP_CALLBACK_PRIORITY_HIGH
,
6741 TP_CALLBACK_PRIORITY_NORMAL
,
6742 TP_CALLBACK_PRIORITY_LOW
,
6743 TP_CALLBACK_PRIORITY_INVALID
,
6744 TP_CALLBACK_PRIORITY_COUNT
= TP_CALLBACK_PRIORITY_INVALID
6745 } TP_CALLBACK_PRIORITY
;
6747 typedef struct _TP_POOL_STACK_INFORMATION
6749 SIZE_T StackReserve
;
6751 } TP_POOL_STACK_INFORMATION
,*PTP_POOL_STACK_INFORMATION
;
6753 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP
,*PTP_CLEANUP_GROUP
;
6755 typedef VOID (CALLBACK
*PTP_CLEANUP_GROUP_CANCEL_CALLBACK
)(PVOID
,PVOID
);
6757 typedef struct _TP_CALLBACK_ENVIRON_V1
6761 PTP_CLEANUP_GROUP CleanupGroup
;
6762 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6764 struct _ACTIVATION_CONTEXT
* ActivationContext
;
6765 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6771 DWORD LongFunction
:1;
6776 } TP_CALLBACK_ENVIRON_V1
;
6778 typedef struct _TP_CALLBACK_ENVIRON_V3
6782 PTP_CLEANUP_GROUP CleanupGroup
;
6783 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6785 struct _ACTIVATION_CONTEXT
*ActivationContext
;
6786 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6792 DWORD LongFunction
:1;
6797 TP_CALLBACK_PRIORITY CallbackPriority
;
6799 } TP_CALLBACK_ENVIRON_V3
;
6801 typedef struct _TP_WORK TP_WORK
, *PTP_WORK
;
6802 typedef struct _TP_TIMER TP_TIMER
, *PTP_TIMER
;
6804 typedef DWORD TP_WAIT_RESULT
;
6805 typedef struct _TP_WAIT TP_WAIT
, *PTP_WAIT
;
6807 typedef struct _TP_IO TP_IO
, *PTP_IO
;
6809 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON
, *PTP_CALLBACK_ENVIRON
;
6811 typedef VOID (CALLBACK
*PTP_WORK_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WORK
);
6812 typedef VOID (CALLBACK
*PTP_TIMER_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_TIMER
);
6813 typedef VOID (CALLBACK
*PTP_WAIT_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WAIT
,TP_WAIT_RESULT
);
6816 NTSYSAPI BOOLEAN NTAPI
RtlGetProductInfo(DWORD
,DWORD
,DWORD
,DWORD
,PDWORD
);
6818 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6820 UmsThreadInvalidInfoClass
,
6821 UmsThreadUserContext
,
6825 UmsThreadIsSuspended
,
6826 UmsThreadIsTerminated
,
6827 UmsThreadMaxInfoClass
6828 } RTL_UMS_THREAD_INFO_CLASS
, *PRTL_UMS_THREAD_INFO_CLASS
;
6830 typedef enum _RTL_UMS_SCHEDULER_REASON
6832 UmsSchedulerStartup
,
6833 UmsSchedulerThreadBlocked
,
6834 UmsSchedulerThreadYield
,
6835 } RTL_UMS_SCHEDULER_REASON
, *PRTL_UMS_SCHEDULER_REASON
;
6837 typedef void (CALLBACK
*PRTL_UMS_SCHEDULER_ENTRY_POINT
)(RTL_UMS_SCHEDULER_REASON
,ULONG_PTR
,PVOID
);
6839 typedef enum _PROCESS_MITIGATION_POLICY
6843 ProcessDynamicCodePolicy
,
6844 ProcessStrictHandleCheckPolicy
,
6845 ProcessSystemCallDisablePolicy
,
6846 ProcessMitigationOptionsMask
,
6847 ProcessExtensionPointDisablePolicy
,
6848 ProcessControlFlowGuardPolicy
,
6849 ProcessSignaturePolicy
,
6850 ProcessFontDisablePolicy
,
6851 ProcessImageLoadPolicy
,
6852 ProcessSystemCallFilterPolicy
,
6853 ProcessPayloadRestrictionPolicy
,
6854 ProcessChildProcessPolicy
,
6855 ProcessSideChannelIsolationPolicy
,
6856 MaxProcessMitigationPolicy
6857 } PROCESS_MITIGATION_POLICY
, *PPROCESS_MITIGATION_POLICY
;
6861 BOOLEAN
_BitScanForward(unsigned long*,unsigned long);
6862 BOOLEAN
_BitScanReverse(unsigned long*,unsigned long);
6864 #pragma intrinsic(_BitScanForward)
6865 #pragma intrinsic(_BitScanReverse)
6867 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6869 return _BitScanForward((unsigned long*)index
, mask
);
6872 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6874 return _BitScanReverse((unsigned long*)index
, mask
);
6877 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
6879 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6881 *index
= __builtin_ctz(mask
);
6885 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6887 *index
= 31 - __builtin_clz(mask
);
6893 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6896 while (r
< 31 && !(mask
& (1 << r
))) r
++;
6901 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6903 unsigned int r
= 31;
6904 while (r
> 0 && !(mask
& (1 << r
))) r
--;
6911 /* Interlocked functions */
6915 #pragma intrinsic(_InterlockedAnd)
6916 #pragma intrinsic(_InterlockedCompareExchange)
6917 #pragma intrinsic(_InterlockedCompareExchange64)
6918 #pragma intrinsic(_InterlockedExchange)
6919 #pragma intrinsic(_InterlockedExchangeAdd)
6920 #pragma intrinsic(_InterlockedIncrement)
6921 #pragma intrinsic(_InterlockedIncrement16)
6922 #pragma intrinsic(_InterlockedDecrement)
6923 #pragma intrinsic(_InterlockedDecrement16)
6924 #pragma intrinsic(_InterlockedOr)
6926 long _InterlockedAnd(long volatile *,long);
6927 long _InterlockedCompareExchange(long volatile*,long,long);
6928 long long _InterlockedCompareExchange64(long long volatile*,long long,long long);
6929 long _InterlockedDecrement(long volatile*);
6930 short _InterlockedDecrement16(short volatile*);
6931 long _InterlockedExchange(long volatile*,long);
6932 long _InterlockedExchangeAdd(long volatile*,long);
6933 long _InterlockedIncrement(long volatile*);
6934 short _InterlockedIncrement16(short volatile*);
6935 long _InterlockedOr(long volatile *,long);
6937 static FORCEINLINE LONG WINAPI
InterlockedAnd( LONG
volatile *dest
, LONG val
)
6939 return _InterlockedAnd( (long volatile *)dest
, val
);
6942 static FORCEINLINE LONG WINAPI
InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
6944 return _InterlockedCompareExchange( (long volatile *)dest
, xchg
, compare
);
6947 static FORCEINLINE LONGLONG WINAPI
InterlockedCompareExchange64( LONGLONG
volatile *dest
, LONGLONG xchg
, LONGLONG compare
)
6949 return _InterlockedCompareExchange64( (long long volatile *)dest
, xchg
, compare
);
6952 static FORCEINLINE LONG WINAPI
InterlockedExchange( LONG
volatile *dest
, LONG val
)
6954 return _InterlockedExchange( (long volatile *)dest
, val
);
6957 static FORCEINLINE LONG WINAPI
InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
6959 return _InterlockedExchangeAdd( (long volatile *)dest
, incr
);
6962 static FORCEINLINE LONG WINAPI
InterlockedIncrement( LONG
volatile *dest
)
6964 return _InterlockedIncrement( (long volatile *)dest
);
6967 static FORCEINLINE
short WINAPI
InterlockedIncrement16( short volatile *dest
)
6969 return _InterlockedIncrement16( dest
);
6972 static FORCEINLINE LONG WINAPI
InterlockedDecrement( LONG
volatile *dest
)
6974 return _InterlockedDecrement( (long volatile *)dest
);
6977 static FORCEINLINE
short WINAPI
InterlockedDecrement16( short volatile *dest
)
6979 return _InterlockedDecrement16( dest
);
6982 static FORCEINLINE LONG WINAPI
InterlockedOr( LONG
volatile *dest
, LONG val
)
6984 return _InterlockedOr( (long volatile *)dest
, val
);
6989 #pragma intrinsic(_InterlockedCompareExchangePointer)
6990 #pragma intrinsic(_InterlockedExchangePointer)
6992 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
6993 #define InterlockedExchangePointer _InterlockedExchangePointer
6995 void *InterlockedCompareExchangePointer(void *volatile*,void*,void*);
6996 void *InterlockedExchangePointer(void *volatile*,void*);
7000 static FORCEINLINE
void * WINAPI
InterlockedCompareExchangePointer( void *volatile *dest
, void *xchg
, void *compare
)
7002 return (void *)_InterlockedCompareExchange( (long volatile*)dest
, (long)xchg
, (long)compare
);
7005 static FORCEINLINE
void * WINAPI
InterlockedExchangePointer( void *volatile *dest
, void *val
)
7007 return (void *)_InterlockedExchange( (long volatile*)dest
, (long)val
);
7010 #endif /* __i386__ */
7014 static FORCEINLINE
void MemoryBarrier(void)
7017 InterlockedOr(&dummy
, 0);
7020 #elif defined(__x86_64__)
7022 #pragma intrinsic(__faststorefence)
7024 void __faststorefence(void);
7026 static FORCEINLINE
void MemoryBarrier(void)
7031 #elif defined(__arm__)
7033 static FORCEINLINE
void MemoryBarrier(void)
7035 __dmb(_ARM_BARRIER_SY
);
7038 #elif defined(__aarch64__)
7040 static FORCEINLINE
void MemoryBarrier(void)
7042 __dmb(_ARM64_BARRIER_SY
);
7045 #endif /* __i386__ */
7047 #elif defined(__GNUC__)
7049 static FORCEINLINE LONG WINAPI
InterlockedAnd( LONG
volatile *dest
, LONG val
)
7051 return __sync_fetch_and_and( dest
, val
);
7054 static FORCEINLINE LONG WINAPI
InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
7056 return __sync_val_compare_and_swap( dest
, compare
, xchg
);
7059 static FORCEINLINE
void * WINAPI
InterlockedCompareExchangePointer( void *volatile *dest
, void *xchg
, void *compare
)
7061 return __sync_val_compare_and_swap( dest
, compare
, xchg
);
7064 static FORCEINLINE LONGLONG WINAPI
InterlockedCompareExchange64( LONGLONG
volatile *dest
, LONGLONG xchg
, LONGLONG compare
)
7066 return __sync_val_compare_and_swap( dest
, compare
, xchg
);
7069 static FORCEINLINE LONG WINAPI
InterlockedExchange( LONG
volatile *dest
, LONG val
)
7072 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
7073 ret
= __atomic_exchange_n( dest
, val
, __ATOMIC_SEQ_CST
);
7074 #elif defined(__i386__) || defined(__x86_64__)
7075 __asm__
__volatile__( "lock; xchgl %0,(%1)"
7076 : "=r" (ret
) :"r" (dest
), "0" (val
) : "memory" );
7078 do ret
= *dest
; while (!__sync_bool_compare_and_swap( dest
, ret
, val
));
7083 static FORCEINLINE LONG WINAPI
InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
7085 return __sync_fetch_and_add( dest
, incr
);
7088 static FORCEINLINE LONG WINAPI
InterlockedIncrement( LONG
volatile *dest
)
7090 return __sync_add_and_fetch( dest
, 1 );
7093 static FORCEINLINE
short WINAPI
InterlockedIncrement16( short volatile *dest
)
7095 return __sync_add_and_fetch( dest
, 1 );
7098 static FORCEINLINE LONG WINAPI
InterlockedDecrement( LONG
volatile *dest
)
7100 return __sync_add_and_fetch( dest
, -1 );
7103 static FORCEINLINE
short WINAPI
InterlockedDecrement16( short volatile *dest
)
7105 return __sync_add_and_fetch( dest
, -1 );
7108 static FORCEINLINE
void * WINAPI
InterlockedExchangePointer( void *volatile *dest
, void *val
)
7111 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
7112 ret
= __atomic_exchange_n( dest
, val
, __ATOMIC_SEQ_CST
);
7113 #elif defined(__x86_64__)
7114 __asm__
__volatile__( "lock; xchgq %0,(%1)" : "=r" (ret
) :"r" (dest
), "0" (val
) : "memory" );
7115 #elif defined(__i386__)
7116 __asm__
__volatile__( "lock; xchgl %0,(%1)" : "=r" (ret
) :"r" (dest
), "0" (val
) : "memory" );
7118 do ret
= *dest
; while (!__sync_bool_compare_and_swap( dest
, ret
, val
));
7123 static FORCEINLINE LONG WINAPI
InterlockedOr( LONG
volatile *dest
, LONG val
)
7125 return __sync_fetch_and_or( dest
, val
);
7128 static FORCEINLINE
void MemoryBarrier(void)
7130 __sync_synchronize();
7133 #endif /* __GNUC__ */
7136 #if defined(_MSC_VER) && !defined(__clang__)
7138 #pragma intrinsic(_InterlockedCompareExchange128)
7139 unsigned char _InterlockedCompareExchange128(volatile __int64
*, __int64
, __int64
, __int64
*);
7140 static FORCEINLINE
unsigned char WINAPI
InterlockedCompareExchange128( volatile __int64
*dest
, __int64 xchg_high
, __int64 xchg_low
, __int64
*compare
)
7142 return _InterlockedCompareExchange128( dest
, xchg_high
, xchg_low
, compare
);
7147 static FORCEINLINE
unsigned char InterlockedCompareExchange128( volatile __int64
*dest
, __int64 xchg_high
, __int64 xchg_low
, __int64
*compare
)
7151 __asm__
__volatile__( "lock cmpxchg16b %0; setz %b2"
7152 : "=m" (dest
[0]), "=m" (dest
[1]), "=r" (ret
),
7153 "=a" (compare
[0]), "=d" (compare
[1])
7154 : "m" (dest
[0]), "m" (dest
[1]), "3" (compare
[0]), "4" (compare
[1]),
7155 "c" (xchg_high
), "b" (xchg_low
) );
7158 return __sync_bool_compare_and_swap( (__int128
*)dest
, *(__int128
*)compare
, ((__int128
)xchg_high
<< 64) | xchg_low
);
7165 static FORCEINLINE
void YieldProcessor(void)
7168 #if defined(__i386__) || defined(__x86_64__)
7169 __asm__
__volatile__( "rep; nop" : : : "memory" );
7170 #elif defined(__arm__) || defined(__aarch64__)
7171 __asm__
__volatile__( "dmb ishst\n\tyield" : : : "memory" );
7173 __asm__
__volatile__( "" : : : "memory" );
7182 #endif /* _WINNT_ */