widl: Generate helper macros for WinRT implementation.
[wine/zf.git] / include / winnt.h
blob48f1715c3b65de3d3be62cf930d8bd3a7e4010fa
1 /*
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
21 #ifndef _WINNT_
22 #define _WINNT_
24 #include <basetsd.h>
25 #include <guiddef.h>
26 #include <winapifamily.h>
28 #ifndef RC_INVOKED
29 #include <ctype.h>
30 #include <stddef.h>
31 #include <string.h>
32 #endif
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #ifdef _NTSYSTEM_
40 #define NTSYSAPI
41 #else
42 #define NTSYSAPI DECLSPEC_IMPORT
43 #endif
45 #define NTAPI __stdcall
46 #define FASTCALL __fastcall
48 #ifndef MIDL_PASS
49 # if defined(_MSC_VER)
50 # define DECLSPEC_IMPORT __declspec(dllimport)
51 # elif defined(__MINGW32__) || defined(__CYGWIN__)
52 # define DECLSPEC_IMPORT __attribute__((dllimport))
53 # else
54 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
55 # endif
56 #else
57 # define DECLSPEC_IMPORT
58 #endif
60 #ifndef DECLSPEC_NORETURN
61 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
62 # define DECLSPEC_NORETURN __declspec(noreturn)
63 # elif defined(__GNUC__)
64 # define DECLSPEC_NORETURN __attribute__((noreturn))
65 # else
66 # define DECLSPEC_NORETURN
67 # endif
68 #endif
70 #ifndef DECLSPEC_ALIGN
71 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
72 # define DECLSPEC_ALIGN(x) __declspec(align(x))
73 # elif defined(__GNUC__)
74 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
75 # else
76 # define DECLSPEC_ALIGN(x)
77 # endif
78 #endif
80 #ifndef DECLSPEC_NOTHROW
81 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
82 # define DECLSPEC_NOTHROW __declspec(nothrow)
83 # elif defined(__GNUC__)
84 # define DECLSPEC_NOTHROW __attribute__((nothrow))
85 # else
86 # define DECLSPEC_NOTHROW
87 # endif
88 #endif
90 #ifndef DECLSPEC_CACHEALIGN
91 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
92 #endif
94 #ifndef DECLSPEC_UUID
95 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
96 # define DECLSPEC_UUID(x) __declspec(uuid(x))
97 # else
98 # define DECLSPEC_UUID(x)
99 # endif
100 #endif
102 #ifndef DECLSPEC_NOVTABLE
103 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
104 # define DECLSPEC_NOVTABLE __declspec(novtable)
105 # else
106 # define DECLSPEC_NOVTABLE
107 # endif
108 #endif
110 #ifndef DECLSPEC_SELECTANY
111 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
112 #define DECLSPEC_SELECTANY __declspec(selectany)
113 #elif defined(__MINGW32__)
114 #define DECLSPEC_SELECTANY __attribute__((selectany))
115 #else
116 #define DECLSPEC_SELECTANY
117 #endif
118 #endif
120 #ifndef NOP_FUNCTION
121 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
122 # define NOP_FUNCTION __noop
123 # else
124 # define NOP_FUNCTION (void)0
125 # endif
126 #endif
128 #ifndef DECLSPEC_ADDRSAFE
129 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
130 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
131 # else
132 # define DECLSPEC_ADDRSAFE
133 # endif
134 #endif
136 #ifndef FORCEINLINE
137 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
138 # define FORCEINLINE __forceinline
139 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
140 # define FORCEINLINE inline __attribute__((always_inline))
141 # else
142 # define FORCEINLINE inline
143 # endif
144 #endif
146 #ifndef DECLSPEC_DEPRECATED
147 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
148 # define DECLSPEC_DEPRECATED __declspec(deprecated)
149 # define DEPRECATE_SUPPORTED
150 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
151 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
152 # define DEPRECATE_SUPPORTED
153 # else
154 # define DECLSPEC_DEPRECATED
155 # undef DEPRECATE_SUPPORTED
156 # endif
157 #endif
159 /* a couple of useful Wine extensions */
161 #ifdef _MSC_VER
162 # define DECLSPEC_EXPORT __declspec(dllexport)
163 #elif defined(__MINGW32__)
164 # define DECLSPEC_EXPORT __attribute__((dllexport))
165 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) && !defined(__sun)
166 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
167 #else
168 # define DECLSPEC_EXPORT
169 #endif
171 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || defined(__sun)
172 # define DECLSPEC_HIDDEN
173 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
174 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
175 #else
176 # define DECLSPEC_HIDDEN
177 #endif
179 #ifndef __has_attribute
180 # define __has_attribute(x) 0
181 #endif
183 #if ((defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)))) || __has_attribute(ms_hook_prologue)) && (defined(__i386__) || defined(__x86_64__))
184 #define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__))
185 #else
186 #define DECLSPEC_HOTPATCH
187 #endif
189 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
190 #define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
191 #else
192 #define __WINE_ALLOC_SIZE(x)
193 #endif
195 /* Anonymous union/struct handling */
197 #ifndef NONAMELESSSTRUCT
198 # ifdef __GNUC__
199 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
200 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
201 # define NONAMELESSSTRUCT
202 # endif
203 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
204 # define NONAMELESSSTRUCT
205 # endif
206 #endif /* NONAMELESSSTRUCT */
208 #ifndef NONAMELESSUNION
209 # ifdef __GNUC__
210 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
211 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
212 # define NONAMELESSUNION
213 # endif
214 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
215 # define NONAMELESSUNION
216 # endif
217 #endif /* NONAMELESSUNION */
219 #undef DUMMYSTRUCTNAME
220 #undef DUMMYSTRUCTNAME1
221 #undef DUMMYSTRUCTNAME2
222 #undef DUMMYSTRUCTNAME3
223 #undef DUMMYSTRUCTNAME4
224 #undef DUMMYSTRUCTNAME5
225 #ifndef NONAMELESSSTRUCT
226 #define DUMMYSTRUCTNAME
227 #define DUMMYSTRUCTNAME1
228 #define DUMMYSTRUCTNAME2
229 #define DUMMYSTRUCTNAME3
230 #define DUMMYSTRUCTNAME4
231 #define DUMMYSTRUCTNAME5
232 #else /* !defined(NONAMELESSSTRUCT) */
233 #define DUMMYSTRUCTNAME s
234 #define DUMMYSTRUCTNAME1 s1
235 #define DUMMYSTRUCTNAME2 s2
236 #define DUMMYSTRUCTNAME3 s3
237 #define DUMMYSTRUCTNAME4 s4
238 #define DUMMYSTRUCTNAME5 s5
239 #endif /* !defined(NONAMELESSSTRUCT) */
241 #undef DUMMYUNIONNAME
242 #undef DUMMYUNIONNAME1
243 #undef DUMMYUNIONNAME2
244 #undef DUMMYUNIONNAME3
245 #undef DUMMYUNIONNAME4
246 #undef DUMMYUNIONNAME5
247 #undef DUMMYUNIONNAME6
248 #undef DUMMYUNIONNAME7
249 #undef DUMMYUNIONNAME8
250 #ifndef NONAMELESSUNION
251 #define DUMMYUNIONNAME
252 #define DUMMYUNIONNAME1
253 #define DUMMYUNIONNAME2
254 #define DUMMYUNIONNAME3
255 #define DUMMYUNIONNAME4
256 #define DUMMYUNIONNAME5
257 #define DUMMYUNIONNAME6
258 #define DUMMYUNIONNAME7
259 #define DUMMYUNIONNAME8
260 #else /* !defined(NONAMELESSUNION) */
261 #define DUMMYUNIONNAME u
262 #define DUMMYUNIONNAME1 u1
263 #define DUMMYUNIONNAME2 u2
264 #define DUMMYUNIONNAME3 u3
265 #define DUMMYUNIONNAME4 u4
266 #define DUMMYUNIONNAME5 u5
267 #define DUMMYUNIONNAME6 u6
268 #define DUMMYUNIONNAME7 u7
269 #define DUMMYUNIONNAME8 u8
270 #endif /* !defined(NONAMELESSUNION) */
272 #undef __C89_NAMELESS
273 #undef __C89_NAMELESSSTRUCTNAME
274 #undef __C89_NAMELESSSTRUCTNAME1
275 #undef __C89_NAMELESSSTRUCTNAME2
276 #undef __C89_NAMELESSSTRUCTNAME3
277 #undef __C89_NAMELESSSTRUCTNAME4
278 #undef __C89_NAMELESSSTRUCTNAME5
279 #undef __C89_NAMELESSUNIONNAME
280 #undef __C89_NAMELESSUNIONNAME1
281 #undef __C89_NAMELESSUNIONNAME2
282 #undef __C89_NAMELESSUNIONNAME3
283 #undef __C89_NAMELESSUNIONNAME4
284 #undef __C89_NAMELESSUNIONNAME5
285 #undef __C89_NAMELESSUNIONNAME6
286 #undef __C89_NAMELESSUNIONNAME7
287 #undef __C89_NAMELESSUNIONNAME8
289 #if !defined(__WINESRC__) && !defined(WINE_NO_NAMELESS_EXTENSION)
290 # ifdef __GNUC__
291 /* Anonymous structs support starts with gcc 2.96/g++ 2.95 */
292 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ > 95) || ((__GNUC_MINOR__ == 95) && defined(__cplusplus))))
293 # define __C89_NAMELESS __extension__
294 # endif
295 # elif defined(_MSC_VER)
296 # define __C89_NAMELESS
297 # endif
298 #endif
300 #ifdef __C89_NAMELESS
301 # define __C89_NAMELESSSTRUCTNAME
302 # define __C89_NAMELESSSTRUCTNAME1
303 # define __C89_NAMELESSSTRUCTNAME2
304 # define __C89_NAMELESSSTRUCTNAME3
305 # define __C89_NAMELESSSTRUCTNAME4
306 # define __C89_NAMELESSSTRUCTNAME5
307 # define __C89_NAMELESSUNIONNAME
308 # define __C89_NAMELESSUNIONNAME1
309 # define __C89_NAMELESSUNIONNAME2
310 # define __C89_NAMELESSUNIONNAME3
311 # define __C89_NAMELESSUNIONNAME4
312 # define __C89_NAMELESSUNIONNAME5
313 # define __C89_NAMELESSUNIONNAME6
314 # define __C89_NAMELESSUNIONNAME7
315 # define __C89_NAMELESSUNIONNAME8
316 #else
317 # define __C89_NAMELESS
318 # define __C89_NAMELESSSTRUCTNAME DUMMYSTRUCTNAME
319 # define __C89_NAMELESSSTRUCTNAME1 DUMMYSTRUCTNAME1
320 # define __C89_NAMELESSSTRUCTNAME2 DUMMYSTRUCTNAME2
321 # define __C89_NAMELESSSTRUCTNAME3 DUMMYSTRUCTNAME3
322 # define __C89_NAMELESSSTRUCTNAME4 DUMMYSTRUCTNAME4
323 # define __C89_NAMELESSSTRUCTNAME5 DUMMYSTRUCTNAME5
324 # define __C89_NAMELESSUNIONNAME DUMMYUNIONNAME
325 # define __C89_NAMELESSUNIONNAME1 DUMMYUNIONNAME1
326 # define __C89_NAMELESSUNIONNAME2 DUMMYUNIONNAME2
327 # define __C89_NAMELESSUNIONNAME3 DUMMYUNIONNAME3
328 # define __C89_NAMELESSUNIONNAME4 DUMMYUNIONNAME4
329 # define __C89_NAMELESSUNIONNAME5 DUMMYUNIONNAME5
330 # define __C89_NAMELESSUNIONNAME6 DUMMYUNIONNAME6
331 # define __C89_NAMELESSUNIONNAME7 DUMMYUNIONNAME7
332 # define __C89_NAMELESSUNIONNAME8 DUMMYUNIONNAME8
333 #endif
335 /* C99 restrict support */
337 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
338 # if defined(_MSC_VER) && defined(_M_MRX000)
339 # define RESTRICTED_POINTER __restrict
340 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
341 # define RESTRICTED_POINTER __restrict
342 # else
343 # define RESTRICTED_POINTER
344 # endif
345 #else
346 # define RESTRICTED_POINTER
347 #endif
349 /* C99 unaligned support */
351 #ifndef UNALIGNED
352 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
353 # define UNALIGNED __unaligned
354 # ifdef _WIN64
355 # define UNALIGNED64 __unaligned
356 # else
357 # define UNALIGNED64
358 # endif
359 #else
360 # define UNALIGNED
361 # define UNALIGNED64
362 #endif
363 #endif
365 /* Alignment macros */
367 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
368 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
369 #define MEMORY_ALLOCATION_ALIGNMENT 16
370 #else
371 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
372 #define MEMORY_ALLOCATION_ALIGNMENT 8
373 #endif
375 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
376 # define TYPE_ALIGNMENT(t) __alignof(t)
377 #elif defined(__GNUC__)
378 # define TYPE_ALIGNMENT(t) __alignof__(t)
379 #else
380 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
381 #endif
383 #ifdef _WIN64
384 # define PROBE_ALIGNMENT(_s) \
385 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
386 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
387 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
388 #else
389 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
390 #endif
392 /* Compile time assertion */
394 #define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
396 /* Eliminate Microsoft C/C++ compiler warning 4715 */
397 #if defined(_MSC_VER) && (_MSC_VER > 1200)
398 # define DEFAULT_UNREACHABLE default: __assume(0)
399 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
400 # define DEFAULT_UNREACHABLE default: __builtin_unreachable()
401 #else
402 # define DEFAULT_UNREACHABLE default:
403 #endif
405 /* Error Masks */
406 #define APPLICATION_ERROR_MASK 0x20000000
407 #define ERROR_SEVERITY_SUCCESS 0x00000000
408 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
409 #define ERROR_SEVERITY_WARNING 0x80000000
410 #define ERROR_SEVERITY_ERROR 0xC0000000
412 #ifdef __cplusplus
413 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
414 extern "C++" { \
415 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
416 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
417 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \
418 inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
419 inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \
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)); } \
423 #else
424 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
425 #endif
427 /* Microsoft's macros for declaring functions */
429 #ifdef __cplusplus
430 # define EXTERN_C extern "C"
431 #else
432 # define EXTERN_C extern
433 #endif
435 #define STDMETHODCALLTYPE WINAPI
436 #define STDMETHODVCALLTYPE WINAPIV
437 #define STDAPICALLTYPE WINAPI
438 #define STDAPIVCALLTYPE WINAPIV
440 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
441 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
442 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
443 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
444 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
445 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
446 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
447 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
449 /* Define the basic types */
450 #ifndef VOID
451 #define VOID void
452 #endif
453 typedef VOID *PVOID;
454 typedef VOID *PVOID64;
455 typedef BYTE BOOLEAN, *PBOOLEAN;
456 typedef char CHAR, *PCHAR;
457 typedef short SHORT, *PSHORT;
458 #ifdef WINE_USE_LONG
459 typedef long LONG, *PLONG;
460 #else
461 typedef int LONG, *PLONG;
462 #endif
464 /* Some systems might have wchar_t, but we really need 16 bit characters */
465 #if defined(WINE_UNICODE_NATIVE)
466 typedef wchar_t WCHAR;
467 #elif __cpp_unicode_literals >= 200710
468 typedef char16_t WCHAR;
469 #else
470 typedef unsigned short WCHAR;
471 #endif
472 typedef WCHAR *PWCHAR;
474 typedef ULONG UCSCHAR;
475 #define MIN_UCSCHAR (0)
476 #define MAX_UCSCHAR (0x0010ffff)
477 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
479 /* 'Extended/Wide' numerical types */
480 #ifndef _ULONGLONG_
481 # define _ULONGLONG_
482 # ifdef _MSC_VER
483 typedef signed __int64 LONGLONG, *PLONGLONG;
484 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
485 # else
486 typedef signed __int64 DECLSPEC_ALIGN(8) LONGLONG, *PLONGLONG;
487 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONGLONG, *PULONGLONG;
488 # endif
489 #endif
491 #ifndef _DWORDLONG_
492 # define _DWORDLONG_
493 # ifdef _MSC_VER
494 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
495 # else
496 typedef ULONGLONG DECLSPEC_ALIGN(8) DWORDLONG, *PDWORDLONG;
497 # endif
498 #endif
500 /* ANSI string types */
501 typedef CHAR *PCH, *LPCH, *PNZCH;
502 typedef const CHAR *PCCH, *LPCCH, *PCNZCH;
503 typedef CHAR *PSTR, *LPSTR, *NPSTR;
504 typedef const CHAR *PCSTR, *LPCSTR;
505 typedef CHAR *PZZSTR;
506 typedef const CHAR *PCZZSTR;
508 /* Unicode string types */
509 typedef const WCHAR *PCWCHAR, *LPCUWCHAR, *PCUWCHAR;
510 typedef WCHAR *PWCH, *LPWCH;
511 typedef const WCHAR *PCWCH, *LPCWCH;
512 typedef WCHAR *PNZWCH, *PUNZWCH;
513 typedef const WCHAR *PCNZWCH, *PCUNZWCH;
514 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
515 typedef const WCHAR *PCWSTR, *LPCWSTR;
516 typedef WCHAR *PZZWSTR, *PUZZWSTR;
517 typedef const WCHAR *PCZZWSTR, *PCUZZWSTR;
518 typedef PWSTR *PZPWSTR;
519 typedef PCWSTR *PZPCWSTR;
521 /* Neutral character and string types */
522 /* These are only defined for Winelib, i.e. _not_ defined for
523 * the emulator. The reason is they depend on the UNICODE
524 * macro which only exists in the user's code.
526 #ifndef WINE_NO_UNICODE_MACROS
527 # ifdef UNICODE
528 # ifndef _TCHAR_DEFINED
529 typedef WCHAR TCHAR, *PTCHAR;
530 # define _TCHAR_DEFINED
531 #endif
532 typedef LPWCH PTCH, LPTCH;
533 typedef LPCWCH PCTCH, LPCTCH;
534 typedef LPWSTR PTSTR, LPTSTR;
535 typedef LPCWSTR PCTSTR, LPCTSTR;
536 typedef LPWSTR PUTSTR, LPUTSTR;
537 typedef LPCWSTR PCUTSTR, LPCUTSTR;
538 typedef PNZWCH PNZTCH;
539 typedef PUNZWCH PUNZTCH;
540 typedef PCNZWCH PCNZTCH;
541 typedef PCUNZWCH PCUNZTCH;
542 typedef PZZWSTR PZZTSTR;
543 typedef PCZZWSTR PCZZTSTR;
544 typedef PUZZWSTR PUZZTSTR;
545 typedef PCUZZWSTR PCUZZTSTR;
546 # else /* UNICODE */
547 # ifndef _TCHAR_DEFINED
548 typedef CHAR TCHAR, *PTCHAR;
549 # define _TCHAR_DEFINED
550 # endif
551 typedef LPCH PTCH, LPTCH;
552 typedef LPCCH PCTCH, LPCTCH;
553 typedef LPSTR PTSTR, LPTSTR;
554 typedef LPCSTR PCTSTR, LPCTSTR;
555 typedef PNZCH PNZTCH, PUNZTCH;
556 typedef PCNZCH PCNZTCH, PCUNZTCH;
557 typedef PZZSTR PZZTSTR, PUZZTSTR;
558 typedef PCZZSTR PCZZTSTR, PCUZZTSTR;
559 # endif /* UNICODE */
560 #endif /* WINE_NO_UNICODE_MACROS */
562 /* UCS string types */
563 typedef UCSCHAR *PUCSCHAR, *PUUCSCHAR;
564 typedef const UCSCHAR *PCUCSCHAR, *PCUUCSCHAR;
565 typedef UCSCHAR *PUCSSTR, *PUUCSSTR;
566 typedef const UCSCHAR *PCUCSSTR, *PCUUCSSTR;
568 /* Misc common WIN32 types */
569 typedef char CCHAR;
570 typedef DWORD LCID, *PLCID;
571 typedef WORD LANGID;
572 typedef DWORD EXECUTION_STATE;
573 #ifndef _HRESULT_DEFINED
574 #define _HRESULT_DEFINED
575 typedef LONG HRESULT;
576 #endif
578 /* Handle type */
580 typedef void *HANDLE;
581 typedef HANDLE *PHANDLE, *LPHANDLE;
583 #ifdef STRICT
584 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
585 #else /*STRICT*/
586 #define DECLARE_HANDLE(a) typedef HANDLE a
587 #endif /*STRICT*/
589 typedef BYTE FCHAR;
590 typedef WORD FSHORT;
591 typedef DWORD FLONG;
593 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
594 #ifndef __MSABI_LONG
595 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
596 # define __MSABI_LONG(x) x ## l
597 # else
598 # define __MSABI_LONG(x) x
599 # endif
600 #endif
602 /* Defines */
604 #ifndef WIN32_NO_STATUS
606 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
607 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
608 #define STATUS_USER_APC ((DWORD) 0x000000C0)
609 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
610 #define STATUS_PENDING ((DWORD) 0x00000103)
611 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
612 #define STATUS_FATAL_APP_EXIT ((DWORD) 0x40000015)
613 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
614 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
615 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
616 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
617 #define STATUS_LONGJUMP ((DWORD) 0x80000026)
618 #define STATUS_UNWIND_CONSOLIDATE ((DWORD) 0x80000029)
619 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
620 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
621 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
622 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
623 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
624 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
625 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
626 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
627 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
628 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
629 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
630 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
631 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
632 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
633 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
634 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
635 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
636 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
637 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
638 #define STATUS_DLL_NOT_FOUND ((DWORD) 0xC0000135)
639 #define STATUS_ORDINAL_NOT_FOUND ((DWORD) 0xC0000138)
640 #define STATUS_ENTRYPOINT_NOT_FOUND ((DWORD) 0xC0000139)
641 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
642 #define STATUS_DLL_INIT_FAILED ((DWORD) 0xC0000142)
643 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
644 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
645 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
646 #define STATUS_HEAP_CORRUPTION ((DWORD) 0xC0000374)
647 #define STATUS_STACK_BUFFER_OVERRUN ((DWORD) 0xC0000409)
648 #define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD) 0xC0000417)
649 #define STATUS_ASSERTION_FAILURE ((DWORD) 0xC0000420)
650 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
651 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
653 /* status values for ContinueDebugEvent */
654 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
655 #define DBG_CONTINUE ((DWORD) 0x00010002)
656 #define DBG_REPLY_LATER ((DWORD) 0x40010001)
657 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
658 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
659 #define DBG_CONTROL_C ((DWORD) 0x40010005)
660 #define DBG_PRINTEXCEPTION_C ((DWORD) 0x40010006)
661 #define DBG_RIPEXCEPTION ((DWORD) 0x40010007)
662 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
663 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
664 #define DBG_PRINTEXCEPTION_WIDE_C ((DWORD) 0x4001000A)
665 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
667 #endif /* WIN32_NO_STATUS */
669 /* Argument 1 passed to the DllEntryProc. */
670 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
671 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
672 #define DLL_THREAD_ATTACH 2 /* attach new thread */
673 #define DLL_THREAD_DETACH 3 /* detach thread */
674 #ifdef __WINESRC__
675 #define DLL_WINE_PREATTACH 8 /* called before process attach for Wine builtins */
676 #endif
678 /* u.x.wProcessorArchitecture (NT) */
679 #define PROCESSOR_ARCHITECTURE_INTEL 0
680 #define PROCESSOR_ARCHITECTURE_MIPS 1
681 #define PROCESSOR_ARCHITECTURE_ALPHA 2
682 #define PROCESSOR_ARCHITECTURE_PPC 3
683 #define PROCESSOR_ARCHITECTURE_SHX 4
684 #define PROCESSOR_ARCHITECTURE_ARM 5
685 #define PROCESSOR_ARCHITECTURE_IA64 6
686 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
687 #define PROCESSOR_ARCHITECTURE_MSIL 8
688 #define PROCESSOR_ARCHITECTURE_AMD64 9
689 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
690 #define PROCESSOR_ARCHITECTURE_NEUTRAL 11
691 #define PROCESSOR_ARCHITECTURE_ARM64 12
692 #define PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64 13
693 #define PROCESSOR_ARCHITECTURE_IA32_ON_ARM64 14
694 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
696 /* dwProcessorType */
697 #define PROCESSOR_INTEL_386 386
698 #define PROCESSOR_INTEL_486 486
699 #define PROCESSOR_INTEL_PENTIUM 586
700 #define PROCESSOR_INTEL_860 860
701 #define PROCESSOR_INTEL_IA64 2200
702 #define PROCESSOR_AMD_X8664 8664
703 #define PROCESSOR_MIPS_R2000 2000
704 #define PROCESSOR_MIPS_R3000 3000
705 #define PROCESSOR_MIPS_R4000 4000
706 #define PROCESSOR_ALPHA_21064 21064
707 #define PROCESSOR_PPC_601 601
708 #define PROCESSOR_PPC_603 603
709 #define PROCESSOR_PPC_604 604
710 #define PROCESSOR_PPC_620 620
711 #define PROCESSOR_HITACHI_SH3 10003
712 #define PROCESSOR_HITACHI_SH3E 10004
713 #define PROCESSOR_HITACHI_SH4 10005
714 #define PROCESSOR_MOTOROLA_821 821
715 #define PROCESSOR_SHx_SH3 103
716 #define PROCESSOR_SHx_SH4 104
717 #define PROCESSOR_STRONGARM 2577
718 #define PROCESSOR_ARM720 1824 /* 0x720 */
719 #define PROCESSOR_ARM820 2080 /* 0x820 */
720 #define PROCESSOR_ARM920 2336 /* 0x920 */
721 #define PROCESSOR_ARM_7TDMI 70001
722 #define PROCESSOR_OPTIL 18767
724 #ifdef _WIN64
725 #define MAXIMUM_PROCESSORS 64
726 #else
727 #define MAXIMUM_PROCESSORS 32
728 #endif
730 typedef struct _MEMORY_BASIC_INFORMATION
732 LPVOID BaseAddress;
733 LPVOID AllocationBase;
734 DWORD AllocationProtect;
735 SIZE_T RegionSize;
736 DWORD State;
737 DWORD Protect;
738 DWORD Type;
739 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
741 #define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
743 typedef enum MEM_EXTENDED_PARAMETER_TYPE {
744 MemExtendedParameterInvalidType = 0,
745 MemExtendedParameterAddressRequirements,
746 MemExtendedParameterNumaNode,
747 MemExtendedParameterPartitionHandle,
748 MemExtendedParameterUserPhysicalHandle,
749 MemExtendedParameterAttributeFlags,
750 MemExtendedParameterMax
751 } MEM_EXTENDED_PARAMETER_TYPE, *PMEM_EXTENDED_PARAMETER_TYPE;
753 typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER {
754 struct
756 DWORD64 Type : MEM_EXTENDED_PARAMETER_TYPE_BITS;
757 DWORD64 Reserved : 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS;
758 } DUMMYSTRUCTNAME;
760 union
762 DWORD64 ULong64;
763 PVOID Pointer;
764 SIZE_T Size;
765 HANDLE Handle;
766 DWORD ULong;
767 } DUMMYUNIONNAME;
768 } MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;
770 #define PAGE_NOACCESS 0x01
771 #define PAGE_READONLY 0x02
772 #define PAGE_READWRITE 0x04
773 #define PAGE_WRITECOPY 0x08
774 #define PAGE_EXECUTE 0x10
775 #define PAGE_EXECUTE_READ 0x20
776 #define PAGE_EXECUTE_READWRITE 0x40
777 #define PAGE_EXECUTE_WRITECOPY 0x80
778 #define PAGE_GUARD 0x100
779 #define PAGE_NOCACHE 0x200
780 #define PAGE_WRITECOMBINE 0x400
782 #define MEM_COMMIT 0x00001000
783 #define MEM_RESERVE 0x00002000
784 #define MEM_DECOMMIT 0x00004000
785 #define MEM_RELEASE 0x00008000
786 #define MEM_FREE 0x00010000
787 #define MEM_PRIVATE 0x00020000
788 #define MEM_MAPPED 0x00040000
789 #define MEM_RESET 0x00080000
790 #define MEM_TOP_DOWN 0x00100000
791 #define MEM_WRITE_WATCH 0x00200000
792 #define MEM_PHYSICAL 0x00400000
793 #define MEM_LARGE_PAGES 0x20000000
794 #define MEM_4MB_PAGES 0x80000000
796 #define SEC_FILE 0x00800000
797 #define SEC_IMAGE 0x01000000
798 #define SEC_PROTECTED_IMAGE 0x02000000
799 #define SEC_RESERVE 0x04000000
800 #define SEC_COMMIT 0x08000000
801 #define SEC_NOCACHE 0x10000000
802 #define SEC_WRITECOMBINE 0x40000000
803 #define SEC_LARGE_PAGES 0x80000000
804 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
805 #define MEM_IMAGE SEC_IMAGE
807 #define WRITE_WATCH_FLAG_RESET 0x00000001
809 #define AT_ROUND_TO_PAGE 0x40000000
811 #define MINCHAR 0x80
812 #define MAXCHAR 0x7f
813 #define MINSHORT 0x8000
814 #define MAXSHORT 0x7fff
815 #define MINLONG 0x80000000
816 #define MAXLONG 0x7fffffff
817 #define MAXBYTE 0xff
818 #define MAXWORD 0xffff
819 #define MAXDWORD 0xffffffff
820 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
822 #define UNICODE_STRING_MAX_CHARS 32767
824 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
825 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
826 #define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
828 #define CONTAINING_RECORD(address, type, field) \
829 ((type *)((PCHAR)(address) - offsetof(type, field)))
831 #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
832 #ifdef __WINESRC__
833 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
834 #endif
836 /* Types */
838 typedef struct _LIST_ENTRY {
839 struct _LIST_ENTRY *Flink;
840 struct _LIST_ENTRY *Blink;
841 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
843 typedef struct _SINGLE_LIST_ENTRY {
844 struct _SINGLE_LIST_ENTRY *Next;
845 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
847 #ifdef _WIN64
849 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
850 struct _SLIST_ENTRY *Next;
851 } SLIST_ENTRY, *PSLIST_ENTRY;
853 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
854 struct {
855 ULONGLONG Alignment;
856 ULONGLONG Region;
857 } DUMMYSTRUCTNAME;
858 struct {
859 ULONGLONG Depth:16;
860 ULONGLONG Sequence:9;
861 ULONGLONG NextEntry:39;
862 ULONGLONG HeaderType:1;
863 ULONGLONG Init:1;
864 ULONGLONG Reserved:59;
865 ULONGLONG Region:3;
866 } Header8;
867 struct {
868 ULONGLONG Depth:16;
869 ULONGLONG Sequence:48;
870 ULONGLONG HeaderType:1;
871 ULONGLONG Init:1;
872 ULONGLONG Reserved:2;
873 ULONGLONG NextEntry:60;
874 } Header16;
875 } SLIST_HEADER, *PSLIST_HEADER;
877 #else
879 #undef SLIST_ENTRY /* for Mac OS */
880 #define SLIST_ENTRY SINGLE_LIST_ENTRY
881 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
882 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
884 typedef union _SLIST_HEADER {
885 ULONGLONG Alignment;
886 struct {
887 SLIST_ENTRY Next;
888 WORD Depth;
889 WORD Sequence;
890 } DUMMYSTRUCTNAME;
891 } SLIST_HEADER, *PSLIST_HEADER;
893 #endif
895 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
896 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
897 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
898 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
899 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
900 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
903 /* Heap flags */
905 #define HEAP_NO_SERIALIZE 0x00000001
906 #define HEAP_GROWABLE 0x00000002
907 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
908 #define HEAP_ZERO_MEMORY 0x00000008
909 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
910 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
911 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
912 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
913 #define HEAP_CREATE_ALIGN_16 0x00010000
914 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
915 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
917 /* This flag allows it to create heaps shared by all processes under win95,
918 FIXME: correct name */
919 #define HEAP_SHARED 0x04000000
921 typedef enum _HEAP_INFORMATION_CLASS {
922 HeapCompatibilityInformation,
923 } HEAP_INFORMATION_CLASS;
925 /* Processor feature flags. */
926 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
927 #define PF_FLOATING_POINT_EMULATED 1
928 #define PF_COMPARE_EXCHANGE_DOUBLE 2
929 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
930 #define PF_PPC_MOVEMEM_64BIT_OK 4
931 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
932 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
933 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
934 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
935 #define PF_PAE_ENABLED 9
936 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
937 #define PF_SSE_DAZ_MODE_AVAILABLE 11
938 #define PF_NX_ENABLED 12
939 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
940 #define PF_COMPARE_EXCHANGE128 14
941 #define PF_COMPARE64_EXCHANGE128 15
942 #define PF_CHANNELS_ENABLED 16
943 #define PF_XSAVE_ENABLED 17
944 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
945 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
946 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
947 #define PF_VIRT_FIRMWARE_ENABLED 21
948 #define PF_RDWRFSGSBASE_AVAILABLE 22
949 #define PF_FASTFAIL_AVAILABLE 23
950 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
951 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
952 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
953 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
954 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
955 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
956 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
957 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
958 #define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
959 #define PF_RDPID_INSTRUCTION_AVAILABLE 33
960 #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
961 #define PF_MONITORX_INSTRUCTION_AVAILABLE 35
962 #define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
963 #define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
964 #define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
965 #define PF_AVX_INSTRUCTIONS_AVAILABLE 39
966 #define PF_AVX2_INSTRUCTIONS_AVAILABLE 40
967 #define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
970 /* Execution state flags */
971 #define ES_SYSTEM_REQUIRED 0x00000001
972 #define ES_DISPLAY_REQUIRED 0x00000002
973 #define ES_USER_PRESENT 0x00000004
974 #define ES_CONTINUOUS 0x80000000
976 #include <excpt.h>
978 struct _CONTEXT;
979 struct _EXCEPTION_POINTERS;
980 struct _EXCEPTION_RECORD;
982 typedef EXCEPTION_DISPOSITION WINAPI EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD*,PVOID,
983 struct _CONTEXT*,PVOID);
984 typedef EXCEPTION_ROUTINE *PEXCEPTION_ROUTINE;
986 /* The Win32 register context */
988 /* i386 context definitions */
989 #ifdef __i386__
991 #define SIZE_OF_80387_REGISTERS 80
993 typedef struct _FLOATING_SAVE_AREA
995 DWORD ControlWord;
996 DWORD StatusWord;
997 DWORD TagWord;
998 DWORD ErrorOffset;
999 DWORD ErrorSelector;
1000 DWORD DataOffset;
1001 DWORD DataSelector;
1002 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
1003 DWORD Cr0NpxState;
1004 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1006 #define MAXIMUM_SUPPORTED_EXTENSION 512
1008 typedef struct _CONTEXT
1010 DWORD ContextFlags; /* 000 */
1012 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1013 DWORD Dr0; /* 004 */
1014 DWORD Dr1; /* 008 */
1015 DWORD Dr2; /* 00c */
1016 DWORD Dr3; /* 010 */
1017 DWORD Dr6; /* 014 */
1018 DWORD Dr7; /* 018 */
1020 /* These are selected by CONTEXT_FLOATING_POINT */
1021 FLOATING_SAVE_AREA FloatSave; /* 01c */
1023 /* These are selected by CONTEXT_SEGMENTS */
1024 DWORD SegGs; /* 08c */
1025 DWORD SegFs; /* 090 */
1026 DWORD SegEs; /* 094 */
1027 DWORD SegDs; /* 098 */
1029 /* These are selected by CONTEXT_INTEGER */
1030 DWORD Edi; /* 09c */
1031 DWORD Esi; /* 0a0 */
1032 DWORD Ebx; /* 0a4 */
1033 DWORD Edx; /* 0a8 */
1034 DWORD Ecx; /* 0ac */
1035 DWORD Eax; /* 0b0 */
1037 /* These are selected by CONTEXT_CONTROL */
1038 DWORD Ebp; /* 0b4 */
1039 DWORD Eip; /* 0b8 */
1040 DWORD SegCs; /* 0bc */
1041 DWORD EFlags; /* 0c0 */
1042 DWORD Esp; /* 0c4 */
1043 DWORD SegSs; /* 0c8 */
1045 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; /* 0xcc */
1046 } CONTEXT, *PCONTEXT;
1048 #define CONTEXT_X86 0x00010000
1049 #define CONTEXT_i386 CONTEXT_X86
1050 #define CONTEXT_i486 CONTEXT_X86
1052 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1053 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1054 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1055 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1056 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1057 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1058 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x0040)
1059 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
1060 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
1061 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
1063 #define EXCEPTION_READ_FAULT 0
1064 #define EXCEPTION_WRITE_FAULT 1
1065 #define EXCEPTION_EXECUTE_FAULT 8
1067 #endif /* __i386__ */
1069 typedef struct _LDT_ENTRY {
1070 WORD LimitLow;
1071 WORD BaseLow;
1072 union {
1073 struct {
1074 BYTE BaseMid;
1075 BYTE Flags1;
1076 BYTE Flags2;
1077 BYTE BaseHi;
1078 } Bytes;
1079 struct {
1080 unsigned BaseMid: 8;
1081 unsigned Type : 5;
1082 unsigned Dpl : 2;
1083 unsigned Pres : 1;
1084 unsigned LimitHi : 4;
1085 unsigned Sys : 1;
1086 unsigned Reserved_0 : 1;
1087 unsigned Default_Big : 1;
1088 unsigned Granularity : 1;
1089 unsigned BaseHi : 8;
1090 } Bits;
1091 } HighWord;
1092 } LDT_ENTRY, *PLDT_ENTRY, WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
1094 typedef struct DECLSPEC_ALIGN(16) _M128A {
1095 ULONGLONG Low;
1096 LONGLONG High;
1097 } M128A, *PM128A;
1099 typedef struct _XSAVE_FORMAT {
1100 WORD ControlWord; /* 000 */
1101 WORD StatusWord; /* 002 */
1102 BYTE TagWord; /* 004 */
1103 BYTE Reserved1; /* 005 */
1104 WORD ErrorOpcode; /* 006 */
1105 DWORD ErrorOffset; /* 008 */
1106 WORD ErrorSelector; /* 00c */
1107 WORD Reserved2; /* 00e */
1108 DWORD DataOffset; /* 010 */
1109 WORD DataSelector; /* 014 */
1110 WORD Reserved3; /* 016 */
1111 DWORD MxCsr; /* 018 */
1112 DWORD MxCsr_Mask; /* 01c */
1113 M128A FloatRegisters[8]; /* 020 */
1114 M128A XmmRegisters[16]; /* 0a0 */
1115 BYTE Reserved4[96]; /* 1a0 */
1116 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1118 /* x86-64 context definitions */
1119 #if defined(__x86_64__)
1121 #define CONTEXT_AMD64 0x00100000
1123 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
1124 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
1125 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1126 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1127 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1128 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x0040)
1129 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1130 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1132 #define EXCEPTION_READ_FAULT 0
1133 #define EXCEPTION_WRITE_FAULT 1
1134 #define EXCEPTION_EXECUTE_FAULT 8
1136 typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1138 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1139 DWORD64 P1Home; /* 000 */
1140 DWORD64 P2Home; /* 008 */
1141 DWORD64 P3Home; /* 010 */
1142 DWORD64 P4Home; /* 018 */
1143 DWORD64 P5Home; /* 020 */
1144 DWORD64 P6Home; /* 028 */
1146 /* Control flags */
1147 DWORD ContextFlags; /* 030 */
1148 DWORD MxCsr; /* 034 */
1150 /* Segment */
1151 WORD SegCs; /* 038 */
1152 WORD SegDs; /* 03a */
1153 WORD SegEs; /* 03c */
1154 WORD SegFs; /* 03e */
1155 WORD SegGs; /* 040 */
1156 WORD SegSs; /* 042 */
1157 DWORD EFlags; /* 044 */
1159 /* Debug */
1160 DWORD64 Dr0; /* 048 */
1161 DWORD64 Dr1; /* 050 */
1162 DWORD64 Dr2; /* 058 */
1163 DWORD64 Dr3; /* 060 */
1164 DWORD64 Dr6; /* 068 */
1165 DWORD64 Dr7; /* 070 */
1167 /* Integer */
1168 DWORD64 Rax; /* 078 */
1169 DWORD64 Rcx; /* 080 */
1170 DWORD64 Rdx; /* 088 */
1171 DWORD64 Rbx; /* 090 */
1172 DWORD64 Rsp; /* 098 */
1173 DWORD64 Rbp; /* 0a0 */
1174 DWORD64 Rsi; /* 0a8 */
1175 DWORD64 Rdi; /* 0b0 */
1176 DWORD64 R8; /* 0b8 */
1177 DWORD64 R9; /* 0c0 */
1178 DWORD64 R10; /* 0c8 */
1179 DWORD64 R11; /* 0d0 */
1180 DWORD64 R12; /* 0d8 */
1181 DWORD64 R13; /* 0e0 */
1182 DWORD64 R14; /* 0e8 */
1183 DWORD64 R15; /* 0f0 */
1185 /* Counter */
1186 DWORD64 Rip; /* 0f8 */
1188 /* Floating point */
1189 union {
1190 XMM_SAVE_AREA32 FltSave; /* 100 */
1191 struct {
1192 M128A Header[2]; /* 100 */
1193 M128A Legacy[8]; /* 120 */
1194 M128A Xmm0; /* 1a0 */
1195 M128A Xmm1; /* 1b0 */
1196 M128A Xmm2; /* 1c0 */
1197 M128A Xmm3; /* 1d0 */
1198 M128A Xmm4; /* 1e0 */
1199 M128A Xmm5; /* 1f0 */
1200 M128A Xmm6; /* 200 */
1201 M128A Xmm7; /* 210 */
1202 M128A Xmm8; /* 220 */
1203 M128A Xmm9; /* 230 */
1204 M128A Xmm10; /* 240 */
1205 M128A Xmm11; /* 250 */
1206 M128A Xmm12; /* 260 */
1207 M128A Xmm13; /* 270 */
1208 M128A Xmm14; /* 280 */
1209 M128A Xmm15; /* 290 */
1210 } DUMMYSTRUCTNAME;
1211 } DUMMYUNIONNAME;
1213 /* Vector */
1214 M128A VectorRegister[26]; /* 300 */
1215 DWORD64 VectorControl; /* 4a0 */
1217 /* Debug control */
1218 DWORD64 DebugControl; /* 4a8 */
1219 DWORD64 LastBranchToRip; /* 4b0 */
1220 DWORD64 LastBranchFromRip; /* 4b8 */
1221 DWORD64 LastExceptionToRip; /* 4c0 */
1222 DWORD64 LastExceptionFromRip; /* 4c8 */
1223 } CONTEXT, *PCONTEXT;
1225 typedef struct _RUNTIME_FUNCTION
1227 DWORD BeginAddress;
1228 DWORD EndAddress;
1229 DWORD UnwindData;
1230 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1232 #define UNWIND_HISTORY_TABLE_SIZE 12
1234 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1236 ULONG64 ImageBase;
1237 PRUNTIME_FUNCTION FunctionEntry;
1238 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1240 #define UNWIND_HISTORY_TABLE_NONE 0
1241 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1242 #define UNWIND_HISTORY_TABLE_LOCAL 2
1244 typedef struct _UNWIND_HISTORY_TABLE
1246 ULONG Count;
1247 UCHAR Search;
1248 ULONG64 LowAddress;
1249 ULONG64 HighAddress;
1250 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1251 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1253 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1255 union
1257 PM128A FloatingContext[16];
1258 struct
1260 PM128A Xmm0;
1261 PM128A Xmm1;
1262 PM128A Xmm2;
1263 PM128A Xmm3;
1264 PM128A Xmm4;
1265 PM128A Xmm5;
1266 PM128A Xmm6;
1267 PM128A Xmm7;
1268 PM128A Xmm8;
1269 PM128A Xmm9;
1270 PM128A Xmm10;
1271 PM128A Xmm11;
1272 PM128A Xmm12;
1273 PM128A Xmm13;
1274 PM128A Xmm14;
1275 PM128A Xmm15;
1276 } DUMMYSTRUCTNAME;
1277 } DUMMYUNIONNAME;
1279 union
1281 PULONG64 IntegerContext[16];
1282 struct
1284 PULONG64 Rax;
1285 PULONG64 Rcx;
1286 PULONG64 Rdx;
1287 PULONG64 Rbx;
1288 PULONG64 Rsp;
1289 PULONG64 Rbp;
1290 PULONG64 Rsi;
1291 PULONG64 Rdi;
1292 PULONG64 R8;
1293 PULONG64 R9;
1294 PULONG64 R10;
1295 PULONG64 R11;
1296 PULONG64 R12;
1297 PULONG64 R13;
1298 PULONG64 R14;
1299 PULONG64 R15;
1300 } DUMMYSTRUCTNAME;
1301 } DUMMYUNIONNAME2;
1302 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1304 typedef struct _DISPATCHER_CONTEXT
1306 ULONG64 ControlPc;
1307 ULONG64 ImageBase;
1308 PRUNTIME_FUNCTION FunctionEntry;
1309 ULONG64 EstablisherFrame;
1310 ULONG64 TargetIp;
1311 PCONTEXT ContextRecord;
1312 PEXCEPTION_ROUTINE LanguageHandler;
1313 PVOID HandlerData;
1314 PUNWIND_HISTORY_TABLE HistoryTable;
1315 DWORD ScopeIndex;
1316 DWORD Fill0;
1317 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1319 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,PVOID);
1320 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,PVOID);
1322 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1324 #define UNW_FLAG_NHANDLER 0
1325 #define UNW_FLAG_EHANDLER 1
1326 #define UNW_FLAG_UHANDLER 2
1327 #define UNW_FLAG_CHAININFO 4
1329 #endif /* __x86_64__ */
1331 #define XSTATE_LEGACY_FLOATING_POINT 0
1332 #define XSTATE_LEGACY_SSE 1
1333 #define XSTATE_GSSE 2
1334 #define XSTATE_AVX XSTATE_GSSE
1335 #define XSTATE_MPX_BNDREGS 3
1336 #define XSTATE_MPX_BNDCSR 4
1337 #define XSTATE_AVX512_KMASK 5
1338 #define XSTATE_AVX512_ZMM_H 6
1339 #define XSTATE_AVX512_ZMM 7
1340 #define XSTATE_IPT 8
1341 #define XSTATE_CET_U 11
1342 #define XSTATE_LWP 62
1343 #define MAXIMUM_XSTATE_FEATURES 64
1345 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1 << XSTATE_LEGACY_FLOATING_POINT)
1346 #define XSTATE_MASK_LEGACY_SSE (1 << XSTATE_LEGACY_SSE)
1347 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1348 #define XSTATE_MASK_GSSE (1 << XSTATE_GSSE)
1350 typedef struct _XSTATE_FEATURE
1352 ULONG Offset;
1353 ULONG Size;
1354 } XSTATE_FEATURE, *PXSTATE_FEATURE;
1356 typedef struct _XSTATE_CONFIGURATION
1358 ULONG64 EnabledFeatures;
1359 ULONG64 EnabledVolatileFeatures;
1360 ULONG Size;
1361 ULONG OptimizedSave:1;
1362 ULONG CompactionEnabled:1;
1363 XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
1365 ULONG64 EnabledSupervisorFeatures;
1366 ULONG64 AlignedFeatures;
1367 ULONG AllFeatureSize;
1368 ULONG AllFeatures[MAXIMUM_XSTATE_FEATURES];
1369 ULONG64 EnabledUserVisibleSupervisorFeatures;
1370 } XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION;
1372 typedef struct _YMMCONTEXT
1374 M128A Ymm0;
1375 M128A Ymm1;
1376 M128A Ymm2;
1377 M128A Ymm3;
1378 M128A Ymm4;
1379 M128A Ymm5;
1380 M128A Ymm6;
1381 M128A Ymm7;
1382 M128A Ymm8;
1383 M128A Ymm9;
1384 M128A Ymm10;
1385 M128A Ymm11;
1386 M128A Ymm12;
1387 M128A Ymm13;
1388 M128A Ymm14;
1389 M128A Ymm15;
1391 YMMCONTEXT, *PYMMCONTEXT;
1393 typedef struct _XSTATE
1395 ULONG64 Mask;
1396 ULONG64 CompactionMask;
1397 ULONG64 Reserved[6];
1398 YMMCONTEXT YmmContext;
1399 } XSTATE, *PXSTATE;
1401 typedef struct _CONTEXT_CHUNK
1403 LONG Offset;
1404 ULONG Length;
1405 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
1407 typedef struct _CONTEXT_EX
1409 CONTEXT_CHUNK All;
1410 CONTEXT_CHUNK Legacy;
1411 CONTEXT_CHUNK XState;
1412 #ifdef _WIN64
1413 ULONG64 align;
1414 #endif
1415 } CONTEXT_EX, *PCONTEXT_EX;
1417 /* IA64 context definitions */
1418 #ifdef __ia64__
1420 #define CONTEXT_IA64 0x00080000
1421 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1422 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1423 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1424 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1425 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1426 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1427 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1428 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1429 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1431 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1432 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1433 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1434 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1436 typedef struct _CONTEXT
1438 DWORD ContextFlags;
1439 DWORD Fill1[3];
1440 ULONGLONG DbI0;
1441 ULONGLONG DbI1;
1442 ULONGLONG DbI2;
1443 ULONGLONG DbI3;
1444 ULONGLONG DbI4;
1445 ULONGLONG DbI5;
1446 ULONGLONG DbI6;
1447 ULONGLONG DbI7;
1448 ULONGLONG DbD0;
1449 ULONGLONG DbD1;
1450 ULONGLONG DbD2;
1451 ULONGLONG DbD3;
1452 ULONGLONG DbD4;
1453 ULONGLONG DbD5;
1454 ULONGLONG DbD6;
1455 ULONGLONG DbD7;
1456 FLOAT128 FltS0;
1457 FLOAT128 FltS1;
1458 FLOAT128 FltS2;
1459 FLOAT128 FltS3;
1460 FLOAT128 FltT0;
1461 FLOAT128 FltT1;
1462 FLOAT128 FltT2;
1463 FLOAT128 FltT3;
1464 FLOAT128 FltT4;
1465 FLOAT128 FltT5;
1466 FLOAT128 FltT6;
1467 FLOAT128 FltT7;
1468 FLOAT128 FltT8;
1469 FLOAT128 FltT9;
1470 FLOAT128 FltS4;
1471 FLOAT128 FltS5;
1472 FLOAT128 FltS6;
1473 FLOAT128 FltS7;
1474 FLOAT128 FltS8;
1475 FLOAT128 FltS9;
1476 FLOAT128 FltS10;
1477 FLOAT128 FltS11;
1478 FLOAT128 FltS12;
1479 FLOAT128 FltS13;
1480 FLOAT128 FltS14;
1481 FLOAT128 FltS15;
1482 FLOAT128 FltS16;
1483 FLOAT128 FltS17;
1484 FLOAT128 FltS18;
1485 FLOAT128 FltS19;
1486 FLOAT128 FltF32;
1487 FLOAT128 FltF33;
1488 FLOAT128 FltF34;
1489 FLOAT128 FltF35;
1490 FLOAT128 FltF36;
1491 FLOAT128 FltF37;
1492 FLOAT128 FltF38;
1493 FLOAT128 FltF39;
1494 FLOAT128 FltF40;
1495 FLOAT128 FltF41;
1496 FLOAT128 FltF42;
1497 FLOAT128 FltF43;
1498 FLOAT128 FltF44;
1499 FLOAT128 FltF45;
1500 FLOAT128 FltF46;
1501 FLOAT128 FltF47;
1502 FLOAT128 FltF48;
1503 FLOAT128 FltF49;
1504 FLOAT128 FltF50;
1505 FLOAT128 FltF51;
1506 FLOAT128 FltF52;
1507 FLOAT128 FltF53;
1508 FLOAT128 FltF54;
1509 FLOAT128 FltF55;
1510 FLOAT128 FltF56;
1511 FLOAT128 FltF57;
1512 FLOAT128 FltF58;
1513 FLOAT128 FltF59;
1514 FLOAT128 FltF60;
1515 FLOAT128 FltF61;
1516 FLOAT128 FltF62;
1517 FLOAT128 FltF63;
1518 FLOAT128 FltF64;
1519 FLOAT128 FltF65;
1520 FLOAT128 FltF66;
1521 FLOAT128 FltF67;
1522 FLOAT128 FltF68;
1523 FLOAT128 FltF69;
1524 FLOAT128 FltF70;
1525 FLOAT128 FltF71;
1526 FLOAT128 FltF72;
1527 FLOAT128 FltF73;
1528 FLOAT128 FltF74;
1529 FLOAT128 FltF75;
1530 FLOAT128 FltF76;
1531 FLOAT128 FltF77;
1532 FLOAT128 FltF78;
1533 FLOAT128 FltF79;
1534 FLOAT128 FltF80;
1535 FLOAT128 FltF81;
1536 FLOAT128 FltF82;
1537 FLOAT128 FltF83;
1538 FLOAT128 FltF84;
1539 FLOAT128 FltF85;
1540 FLOAT128 FltF86;
1541 FLOAT128 FltF87;
1542 FLOAT128 FltF88;
1543 FLOAT128 FltF89;
1544 FLOAT128 FltF90;
1545 FLOAT128 FltF91;
1546 FLOAT128 FltF92;
1547 FLOAT128 FltF93;
1548 FLOAT128 FltF94;
1549 FLOAT128 FltF95;
1550 FLOAT128 FltF96;
1551 FLOAT128 FltF97;
1552 FLOAT128 FltF98;
1553 FLOAT128 FltF99;
1554 FLOAT128 FltF100;
1555 FLOAT128 FltF101;
1556 FLOAT128 FltF102;
1557 FLOAT128 FltF103;
1558 FLOAT128 FltF104;
1559 FLOAT128 FltF105;
1560 FLOAT128 FltF106;
1561 FLOAT128 FltF107;
1562 FLOAT128 FltF108;
1563 FLOAT128 FltF109;
1564 FLOAT128 FltF110;
1565 FLOAT128 FltF111;
1566 FLOAT128 FltF112;
1567 FLOAT128 FltF113;
1568 FLOAT128 FltF114;
1569 FLOAT128 FltF115;
1570 FLOAT128 FltF116;
1571 FLOAT128 FltF117;
1572 FLOAT128 FltF118;
1573 FLOAT128 FltF119;
1574 FLOAT128 FltF120;
1575 FLOAT128 FltF121;
1576 FLOAT128 FltF122;
1577 FLOAT128 FltF123;
1578 FLOAT128 FltF124;
1579 FLOAT128 FltF125;
1580 FLOAT128 FltF126;
1581 FLOAT128 FltF127;
1582 ULONGLONG StFPSR;
1583 ULONGLONG IntGp;
1584 ULONGLONG IntT0;
1585 ULONGLONG IntT1;
1586 ULONGLONG IntS0;
1587 ULONGLONG IntS1;
1588 ULONGLONG IntS2;
1589 ULONGLONG IntS3;
1590 ULONGLONG IntV0;
1591 ULONGLONG IntT2;
1592 ULONGLONG IntT3;
1593 ULONGLONG IntT4;
1594 ULONGLONG IntSp;
1595 ULONGLONG IntTeb;
1596 ULONGLONG IntT5;
1597 ULONGLONG IntT6;
1598 ULONGLONG IntT7;
1599 ULONGLONG IntT8;
1600 ULONGLONG IntT9;
1601 ULONGLONG IntT10;
1602 ULONGLONG IntT11;
1603 ULONGLONG IntT12;
1604 ULONGLONG IntT13;
1605 ULONGLONG IntT14;
1606 ULONGLONG IntT15;
1607 ULONGLONG IntT16;
1608 ULONGLONG IntT17;
1609 ULONGLONG IntT18;
1610 ULONGLONG IntT19;
1611 ULONGLONG IntT20;
1612 ULONGLONG IntT21;
1613 ULONGLONG IntT22;
1614 ULONGLONG IntNats;
1615 ULONGLONG Preds;
1616 ULONGLONG BrRp;
1617 ULONGLONG BrS0;
1618 ULONGLONG BrS1;
1619 ULONGLONG BrS2;
1620 ULONGLONG BrS3;
1621 ULONGLONG BrS4;
1622 ULONGLONG BrT0;
1623 ULONGLONG BrT1;
1624 ULONGLONG ApUNAT;
1625 ULONGLONG ApLC;
1626 ULONGLONG ApEC;
1627 ULONGLONG ApCCV;
1628 ULONGLONG ApDCR;
1629 ULONGLONG RsPFS;
1630 ULONGLONG RsBSP;
1631 ULONGLONG RsBSPSTORE;
1632 ULONGLONG RsRSC;
1633 ULONGLONG RsRNAT;
1634 ULONGLONG StIPSR;
1635 ULONGLONG StIIP;
1636 ULONGLONG StIFS;
1637 ULONGLONG StFCR;
1638 ULONGLONG Eflag;
1639 ULONGLONG SegCSD;
1640 ULONGLONG SegSSD;
1641 ULONGLONG Cflag;
1642 ULONGLONG StFSR;
1643 ULONGLONG StFIR;
1644 ULONGLONG StFDR;
1645 ULONGLONG UNUSEDPACK;
1646 } CONTEXT, *PCONTEXT;
1648 typedef struct _RUNTIME_FUNCTION
1650 ULONG BeginAddress;
1651 ULONG EndAddress;
1652 ULONG UnwindInfoAddress;
1653 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1655 typedef struct _FRAME_POINTERS {
1656 ULONGLONG MemoryStackFp;
1657 ULONGLONG BackingStoreFp;
1658 } FRAME_POINTERS, *PFRAME_POINTERS;
1660 #define UNWIND_HISTORY_TABLE_SIZE 12
1662 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
1663 ULONG64 ImageBase;
1664 ULONG64 Gp;
1665 PRUNTIME_FUNCTION FunctionEntry;
1666 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1668 typedef struct _UNWIND_HISTORY_TABLE {
1669 ULONG Count;
1670 UCHAR Search;
1671 ULONG64 LowAddress;
1672 ULONG64 HighAddress;
1673 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1674 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1676 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1678 PFLOAT128 FltS0;
1679 PFLOAT128 FltS1;
1680 PFLOAT128 FltS2;
1681 PFLOAT128 FltS3;
1682 PFLOAT128 HighFloatingContext[10];
1683 PFLOAT128 FltS4;
1684 PFLOAT128 FltS5;
1685 PFLOAT128 FltS6;
1686 PFLOAT128 FltS7;
1687 PFLOAT128 FltS8;
1688 PFLOAT128 FltS9;
1689 PFLOAT128 FltS10;
1690 PFLOAT128 FltS11;
1691 PFLOAT128 FltS12;
1692 PFLOAT128 FltS13;
1693 PFLOAT128 FltS14;
1694 PFLOAT128 FltS15;
1695 PFLOAT128 FltS16;
1696 PFLOAT128 FltS17;
1697 PFLOAT128 FltS18;
1698 PFLOAT128 FltS19;
1699 PULONGLONG IntS0;
1700 PULONGLONG IntS1;
1701 PULONGLONG IntS2;
1702 PULONGLONG IntS3;
1703 PULONGLONG IntSp;
1704 PULONGLONG IntS0Nat;
1705 PULONGLONG IntS1Nat;
1706 PULONGLONG IntS2Nat;
1707 PULONGLONG IntS3Nat;
1708 PULONGLONG IntSpNat;
1709 PULONGLONG Preds;
1710 PULONGLONG BrRp;
1711 PULONGLONG BrS0;
1712 PULONGLONG BrS1;
1713 PULONGLONG BrS2;
1714 PULONGLONG BrS3;
1715 PULONGLONG BrS4;
1716 PULONGLONG ApUNAT;
1717 PULONGLONG ApLC;
1718 PULONGLONG ApEC;
1719 PULONGLONG RsPFS;
1720 PULONGLONG StFSR;
1721 PULONGLONG StFIR;
1722 PULONGLONG StFDR;
1723 PULONGLONG Cflag;
1724 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1726 NTSYSAPI ULONGLONG WINAPI RtlVirtualUnwind(ULONGLONG,ULONGLONG,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,FRAME_POINTERS*,KNONVOLATILE_CONTEXT_POINTERS*);
1728 #endif /* __ia64__ */
1730 /* Alpha context definitions */
1731 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1733 #define CONTEXT_ALPHA 0x00020000
1735 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1736 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1737 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1738 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1740 #define EXCEPTION_READ_FAULT 0
1741 #define EXCEPTION_WRITE_FAULT 1
1742 #define EXCEPTION_EXECUTE_FAULT 8
1744 typedef struct _CONTEXT
1746 /* selected by CONTEXT_FLOATING_POINT */
1747 ULONGLONG FltF0;
1748 ULONGLONG FltF1;
1749 ULONGLONG FltF2;
1750 ULONGLONG FltF3;
1751 ULONGLONG FltF4;
1752 ULONGLONG FltF5;
1753 ULONGLONG FltF6;
1754 ULONGLONG FltF7;
1755 ULONGLONG FltF8;
1756 ULONGLONG FltF9;
1757 ULONGLONG FltF10;
1758 ULONGLONG FltF11;
1759 ULONGLONG FltF12;
1760 ULONGLONG FltF13;
1761 ULONGLONG FltF14;
1762 ULONGLONG FltF15;
1763 ULONGLONG FltF16;
1764 ULONGLONG FltF17;
1765 ULONGLONG FltF18;
1766 ULONGLONG FltF19;
1767 ULONGLONG FltF20;
1768 ULONGLONG FltF21;
1769 ULONGLONG FltF22;
1770 ULONGLONG FltF23;
1771 ULONGLONG FltF24;
1772 ULONGLONG FltF25;
1773 ULONGLONG FltF26;
1774 ULONGLONG FltF27;
1775 ULONGLONG FltF28;
1776 ULONGLONG FltF29;
1777 ULONGLONG FltF30;
1778 ULONGLONG FltF31;
1780 /* selected by CONTEXT_INTEGER */
1781 ULONGLONG IntV0;
1782 ULONGLONG IntT0;
1783 ULONGLONG IntT1;
1784 ULONGLONG IntT2;
1785 ULONGLONG IntT3;
1786 ULONGLONG IntT4;
1787 ULONGLONG IntT5;
1788 ULONGLONG IntT6;
1789 ULONGLONG IntT7;
1790 ULONGLONG IntS0;
1791 ULONGLONG IntS1;
1792 ULONGLONG IntS2;
1793 ULONGLONG IntS3;
1794 ULONGLONG IntS4;
1795 ULONGLONG IntS5;
1796 ULONGLONG IntFp;
1797 ULONGLONG IntA0;
1798 ULONGLONG IntA1;
1799 ULONGLONG IntA2;
1800 ULONGLONG IntA3;
1801 ULONGLONG IntA4;
1802 ULONGLONG IntA5;
1803 ULONGLONG IntT8;
1804 ULONGLONG IntT9;
1805 ULONGLONG IntT10;
1806 ULONGLONG IntT11;
1807 ULONGLONG IntRa;
1808 ULONGLONG IntT12;
1809 ULONGLONG IntAt;
1810 ULONGLONG IntGp;
1811 ULONGLONG IntSp;
1812 ULONGLONG IntZero;
1814 /* selected by CONTEXT_FLOATING_POINT */
1815 ULONGLONG Fpcr;
1816 ULONGLONG SoftFpcr;
1818 /* selected by CONTEXT_CONTROL */
1819 ULONGLONG Fir;
1820 DWORD Psr;
1821 DWORD ContextFlags;
1822 DWORD Fill[4];
1823 } CONTEXT, *PCONTEXT;
1825 #define _QUAD_PSR_OFFSET HighSoftFpcr
1826 #define _QUAD_FLAGS_OFFSET HighFir
1828 #endif /* _ALPHA_ */
1830 #ifdef __arm__
1832 /* The following flags control the contents of the CONTEXT structure. */
1834 #define CONTEXT_ARM 0x0200000
1835 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1836 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1837 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1838 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1840 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1841 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1843 #define EXCEPTION_READ_FAULT 0
1844 #define EXCEPTION_WRITE_FAULT 1
1845 #define EXCEPTION_EXECUTE_FAULT 8
1847 #define ARM_MAX_BREAKPOINTS 8
1848 #define ARM_MAX_WATCHPOINTS 1
1850 typedef struct _RUNTIME_FUNCTION
1852 DWORD BeginAddress;
1853 union {
1854 DWORD UnwindData;
1855 struct {
1856 DWORD Flag : 2;
1857 DWORD FunctionLength : 11;
1858 DWORD Ret : 2;
1859 DWORD H : 1;
1860 DWORD Reg : 3;
1861 DWORD R : 1;
1862 DWORD L : 1;
1863 DWORD C : 1;
1864 DWORD StackAdjust : 10;
1865 } DUMMYSTRUCTNAME;
1866 } DUMMYUNIONNAME;
1867 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1869 #define UNWIND_HISTORY_TABLE_SIZE 12
1871 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1873 DWORD ImageBase;
1874 PRUNTIME_FUNCTION FunctionEntry;
1875 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1877 typedef struct _UNWIND_HISTORY_TABLE
1879 DWORD Count;
1880 BYTE LocalHint;
1881 BYTE GlobalHint;
1882 BYTE Search;
1883 BYTE Once;
1884 DWORD LowAddress;
1885 DWORD HighAddress;
1886 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1887 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1889 typedef struct _NEON128
1891 ULONGLONG Low;
1892 LONGLONG High;
1893 } NEON128, *PNEON128;
1895 typedef struct _CONTEXT
1897 ULONG ContextFlags; /* 000 */
1898 /* CONTEXT_INTEGER */
1899 ULONG R0; /* 004 */
1900 ULONG R1; /* 008 */
1901 ULONG R2; /* 00c */
1902 ULONG R3; /* 010 */
1903 ULONG R4; /* 014 */
1904 ULONG R5; /* 018 */
1905 ULONG R6; /* 01c */
1906 ULONG R7; /* 020 */
1907 ULONG R8; /* 024 */
1908 ULONG R9; /* 028 */
1909 ULONG R10; /* 02c */
1910 ULONG R11; /* 030 */
1911 ULONG R12; /* 034 */
1912 /* CONTEXT_CONTROL */
1913 ULONG Sp; /* 038 */
1914 ULONG Lr; /* 03c */
1915 ULONG Pc; /* 040 */
1916 ULONG Cpsr; /* 044 */
1917 /* CONTEXT_FLOATING_POINT */
1918 ULONG Fpscr; /* 048 */
1919 ULONG Padding; /* 04c */
1920 union
1922 NEON128 Q[16];
1923 ULONGLONG D[32];
1924 ULONG S[32];
1925 } DUMMYUNIONNAME; /* 050 */
1926 /* CONTEXT_DEBUG_REGISTERS */
1927 ULONG Bvr[ARM_MAX_BREAKPOINTS]; /* 150 */
1928 ULONG Bcr[ARM_MAX_BREAKPOINTS]; /* 170 */
1929 ULONG Wvr[ARM_MAX_WATCHPOINTS]; /* 190 */
1930 ULONG Wcr[ARM_MAX_WATCHPOINTS]; /* 194 */
1931 ULONG Padding2[2]; /* 198 */
1932 } CONTEXT, *PCONTEXT;
1934 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1936 PDWORD R4;
1937 PDWORD R5;
1938 PDWORD R6;
1939 PDWORD R7;
1940 PDWORD R8;
1941 PDWORD R9;
1942 PDWORD R10;
1943 PDWORD R11;
1944 PDWORD Lr;
1945 PULONGLONG D8;
1946 PULONGLONG D9;
1947 PULONGLONG D10;
1948 PULONGLONG D11;
1949 PULONGLONG D12;
1950 PULONGLONG D13;
1951 PULONGLONG D14;
1952 PULONGLONG D15;
1953 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1955 typedef struct _DISPATCHER_CONTEXT
1957 DWORD ControlPc;
1958 DWORD ImageBase;
1959 PRUNTIME_FUNCTION FunctionEntry;
1960 DWORD EstablisherFrame;
1961 DWORD TargetPc;
1962 PCONTEXT ContextRecord;
1963 PEXCEPTION_ROUTINE LanguageHandler;
1964 PVOID HandlerData;
1965 PUNWIND_HISTORY_TABLE HistoryTable;
1966 DWORD ScopeIndex;
1967 BOOLEAN ControlPcIsUnwound;
1968 PBYTE NonVolatileRegisters;
1969 DWORD Reserved;
1970 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1972 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD);
1973 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD);
1975 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,DWORD,DWORD,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,DWORD*,KNONVOLATILE_CONTEXT_POINTERS*);
1977 #define UNW_FLAG_NHANDLER 0
1978 #define UNW_FLAG_EHANDLER 1
1979 #define UNW_FLAG_UHANDLER 2
1981 #endif /* __arm__ */
1983 #ifdef __aarch64__
1985 #define CONTEXT_ARM64 0x400000
1986 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1987 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1988 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1989 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1990 #define CONTEXT_ARM64_X18 (CONTEXT_ARM64 | 0x00000010)
1992 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1994 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1995 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_ARM64_X18)
1997 #define EXCEPTION_READ_FAULT 0
1998 #define EXCEPTION_WRITE_FAULT 1
1999 #define EXCEPTION_EXECUTE_FAULT 8
2001 #define ARM64_MAX_BREAKPOINTS 8
2002 #define ARM64_MAX_WATCHPOINTS 2
2004 typedef struct _RUNTIME_FUNCTION
2006 DWORD BeginAddress;
2007 union
2009 DWORD UnwindData;
2010 struct
2012 DWORD Flag : 2;
2013 DWORD FunctionLength : 11;
2014 DWORD RegF : 3;
2015 DWORD RegI : 4;
2016 DWORD H : 1;
2017 DWORD CR : 2;
2018 DWORD FrameSize : 9;
2019 } DUMMYSTRUCTNAME;
2020 } DUMMYUNIONNAME;
2021 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
2023 #define UNWIND_HISTORY_TABLE_SIZE 12
2025 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
2027 DWORD64 ImageBase;
2028 PRUNTIME_FUNCTION FunctionEntry;
2029 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
2031 typedef struct _UNWIND_HISTORY_TABLE
2033 DWORD Count;
2034 BYTE LocalHint;
2035 BYTE GlobalHint;
2036 BYTE Search;
2037 BYTE Once;
2038 DWORD64 LowAddress;
2039 DWORD64 HighAddress;
2040 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
2041 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
2043 typedef union _NEON128
2045 struct
2047 ULONGLONG Low;
2048 LONGLONG High;
2049 } DUMMYSTRUCTNAME;
2050 double D[2];
2051 float S[4];
2052 WORD H[8];
2053 BYTE B[16];
2054 } NEON128, *PNEON128;
2056 typedef struct _CONTEXT
2058 ULONG ContextFlags; /* 000 */
2059 /* CONTEXT_INTEGER */
2060 ULONG Cpsr; /* 004 */
2061 union
2063 struct
2065 DWORD64 X0; /* 008 */
2066 DWORD64 X1; /* 010 */
2067 DWORD64 X2; /* 018 */
2068 DWORD64 X3; /* 020 */
2069 DWORD64 X4; /* 028 */
2070 DWORD64 X5; /* 030 */
2071 DWORD64 X6; /* 038 */
2072 DWORD64 X7; /* 040 */
2073 DWORD64 X8; /* 048 */
2074 DWORD64 X9; /* 050 */
2075 DWORD64 X10; /* 058 */
2076 DWORD64 X11; /* 060 */
2077 DWORD64 X12; /* 068 */
2078 DWORD64 X13; /* 070 */
2079 DWORD64 X14; /* 078 */
2080 DWORD64 X15; /* 080 */
2081 DWORD64 X16; /* 088 */
2082 DWORD64 X17; /* 090 */
2083 DWORD64 X18; /* 098 */
2084 DWORD64 X19; /* 0a0 */
2085 DWORD64 X20; /* 0a8 */
2086 DWORD64 X21; /* 0b0 */
2087 DWORD64 X22; /* 0b8 */
2088 DWORD64 X23; /* 0c0 */
2089 DWORD64 X24; /* 0c8 */
2090 DWORD64 X25; /* 0d0 */
2091 DWORD64 X26; /* 0d8 */
2092 DWORD64 X27; /* 0e0 */
2093 DWORD64 X28; /* 0e8 */
2094 DWORD64 Fp; /* 0f0 */
2095 DWORD64 Lr; /* 0f8 */
2096 } DUMMYSTRUCTNAME;
2097 DWORD64 X[31]; /* 008 */
2098 } DUMMYUNIONNAME;
2099 /* CONTEXT_CONTROL */
2100 DWORD64 Sp; /* 100 */
2101 DWORD64 Pc; /* 108 */
2102 /* CONTEXT_FLOATING_POINT */
2103 NEON128 V[32]; /* 110 */
2104 DWORD Fpcr; /* 310 */
2105 DWORD Fpsr; /* 314 */
2106 /* CONTEXT_DEBUG_REGISTERS */
2107 DWORD Bcr[ARM64_MAX_BREAKPOINTS]; /* 318 */
2108 DWORD64 Bvr[ARM64_MAX_BREAKPOINTS]; /* 338 */
2109 DWORD Wcr[ARM64_MAX_WATCHPOINTS]; /* 378 */
2110 DWORD64 Wvr[ARM64_MAX_WATCHPOINTS]; /* 380 */
2111 } CONTEXT, *PCONTEXT;
2113 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
2115 PDWORD64 X19;
2116 PDWORD64 X20;
2117 PDWORD64 X21;
2118 PDWORD64 X22;
2119 PDWORD64 X23;
2120 PDWORD64 X24;
2121 PDWORD64 X25;
2122 PDWORD64 X26;
2123 PDWORD64 X27;
2124 PDWORD64 X28;
2125 PDWORD64 Fp;
2126 PDWORD64 Lr;
2127 PDWORD64 D8;
2128 PDWORD64 D9;
2129 PDWORD64 D10;
2130 PDWORD64 D11;
2131 PDWORD64 D12;
2132 PDWORD64 D13;
2133 PDWORD64 D14;
2134 PDWORD64 D15;
2135 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2137 typedef struct _DISPATCHER_CONTEXT
2139 ULONG_PTR ControlPc;
2140 ULONG_PTR ImageBase;
2141 PRUNTIME_FUNCTION FunctionEntry;
2142 ULONG_PTR EstablisherFrame;
2143 ULONG_PTR TargetPc;
2144 PCONTEXT ContextRecord;
2145 PEXCEPTION_ROUTINE LanguageHandler;
2146 PVOID HandlerData;
2147 PUNWIND_HISTORY_TABLE HistoryTable;
2148 DWORD ScopeIndex;
2149 BOOLEAN ControlPcIsUnwound;
2150 PBYTE NonVolatileRegisters;
2151 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
2153 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD64);
2154 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD64);
2156 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*);
2158 #define UNW_FLAG_NHANDLER 0
2159 #define UNW_FLAG_EHANDLER 1
2160 #define UNW_FLAG_UHANDLER 2
2162 #endif /* __aarch64__ */
2165 /* Mips context definitions */
2166 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
2168 #define CONTEXT_R4000 0x00010000
2170 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
2171 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
2172 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
2174 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2176 #define EXCEPTION_READ_FAULT 0
2177 #define EXCEPTION_WRITE_FAULT 1
2178 #define EXCEPTION_EXECUTE_FAULT 8
2180 typedef struct _CONTEXT
2182 DWORD Argument[4];
2183 /* These are selected by CONTEXT_FLOATING_POINT */
2184 DWORD FltF0;
2185 DWORD FltF1;
2186 DWORD FltF2;
2187 DWORD FltF3;
2188 DWORD FltF4;
2189 DWORD FltF5;
2190 DWORD FltF6;
2191 DWORD FltF7;
2192 DWORD FltF8;
2193 DWORD FltF9;
2194 DWORD FltF10;
2195 DWORD FltF11;
2196 DWORD FltF12;
2197 DWORD FltF13;
2198 DWORD FltF14;
2199 DWORD FltF15;
2200 DWORD FltF16;
2201 DWORD FltF17;
2202 DWORD FltF18;
2203 DWORD FltF19;
2204 DWORD FltF20;
2205 DWORD FltF21;
2206 DWORD FltF22;
2207 DWORD FltF23;
2208 DWORD FltF24;
2209 DWORD FltF25;
2210 DWORD FltF26;
2211 DWORD FltF27;
2212 DWORD FltF28;
2213 DWORD FltF29;
2214 DWORD FltF30;
2215 DWORD FltF31;
2217 /* These are selected by CONTEXT_INTEGER */
2218 DWORD IntZero;
2219 DWORD IntAt;
2220 DWORD IntV0;
2221 DWORD IntV1;
2222 DWORD IntA0;
2223 DWORD IntA1;
2224 DWORD IntA2;
2225 DWORD IntA3;
2226 DWORD IntT0;
2227 DWORD IntT1;
2228 DWORD IntT2;
2229 DWORD IntT3;
2230 DWORD IntT4;
2231 DWORD IntT5;
2232 DWORD IntT6;
2233 DWORD IntT7;
2234 DWORD IntS0;
2235 DWORD IntS1;
2236 DWORD IntS2;
2237 DWORD IntS3;
2238 DWORD IntS4;
2239 DWORD IntS5;
2240 DWORD IntS6;
2241 DWORD IntS7;
2242 DWORD IntT8;
2243 DWORD IntT9;
2244 DWORD IntK0;
2245 DWORD IntK1;
2246 DWORD IntGp;
2247 DWORD IntSp;
2248 DWORD IntS8;
2249 DWORD IntRa;
2250 DWORD IntLo;
2251 DWORD IntHi;
2253 /* These are selected by CONTEXT_FLOATING_POINT */
2254 DWORD Fsr;
2256 /* These are selected by CONTEXT_CONTROL */
2257 DWORD Fir;
2258 DWORD Psr;
2260 DWORD ContextFlags;
2261 DWORD Fill[2];
2262 } CONTEXT, *PCONTEXT;
2264 #endif /* _MIPS_ */
2266 /* PowerPC context definitions */
2267 #ifdef __powerpc__
2269 #define CONTEXT_CONTROL 0x0001
2270 #define CONTEXT_FLOATING_POINT 0x0002
2271 #define CONTEXT_INTEGER 0x0004
2272 #define CONTEXT_DEBUG_REGISTERS 0x0008
2273 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2275 #define EXCEPTION_READ_FAULT 0
2276 #define EXCEPTION_WRITE_FAULT 1
2277 #define EXCEPTION_EXECUTE_FAULT 8
2279 typedef struct
2281 /* These are selected by CONTEXT_FLOATING_POINT */
2282 double Fpr0;
2283 double Fpr1;
2284 double Fpr2;
2285 double Fpr3;
2286 double Fpr4;
2287 double Fpr5;
2288 double Fpr6;
2289 double Fpr7;
2290 double Fpr8;
2291 double Fpr9;
2292 double Fpr10;
2293 double Fpr11;
2294 double Fpr12;
2295 double Fpr13;
2296 double Fpr14;
2297 double Fpr15;
2298 double Fpr16;
2299 double Fpr17;
2300 double Fpr18;
2301 double Fpr19;
2302 double Fpr20;
2303 double Fpr21;
2304 double Fpr22;
2305 double Fpr23;
2306 double Fpr24;
2307 double Fpr25;
2308 double Fpr26;
2309 double Fpr27;
2310 double Fpr28;
2311 double Fpr29;
2312 double Fpr30;
2313 double Fpr31;
2314 double Fpscr;
2316 /* These are selected by CONTEXT_INTEGER */
2317 DWORD Gpr0;
2318 DWORD Gpr1;
2319 DWORD Gpr2;
2320 DWORD Gpr3;
2321 DWORD Gpr4;
2322 DWORD Gpr5;
2323 DWORD Gpr6;
2324 DWORD Gpr7;
2325 DWORD Gpr8;
2326 DWORD Gpr9;
2327 DWORD Gpr10;
2328 DWORD Gpr11;
2329 DWORD Gpr12;
2330 DWORD Gpr13;
2331 DWORD Gpr14;
2332 DWORD Gpr15;
2333 DWORD Gpr16;
2334 DWORD Gpr17;
2335 DWORD Gpr18;
2336 DWORD Gpr19;
2337 DWORD Gpr20;
2338 DWORD Gpr21;
2339 DWORD Gpr22;
2340 DWORD Gpr23;
2341 DWORD Gpr24;
2342 DWORD Gpr25;
2343 DWORD Gpr26;
2344 DWORD Gpr27;
2345 DWORD Gpr28;
2346 DWORD Gpr29;
2347 DWORD Gpr30;
2348 DWORD Gpr31;
2350 DWORD Cr;
2351 DWORD Xer;
2353 /* These are selected by CONTEXT_CONTROL */
2354 DWORD Msr;
2355 DWORD Iar; /* Instruction Address Register , aka PC ... */
2356 DWORD Lr;
2357 DWORD Ctr;
2359 DWORD ContextFlags;
2361 DWORD Dar; /* Fault registers for coredump */
2362 DWORD Dsisr;
2363 DWORD Trap; /* number of powerpc exception taken */
2365 /* These are selected by CONTEXT_DEBUG_REGISTERS */
2366 DWORD Dr0;
2367 DWORD Dr1;
2368 DWORD Dr2;
2369 DWORD Dr3;
2370 DWORD Dr4;
2371 DWORD Dr5;
2372 DWORD Dr6;
2373 DWORD Dr7;
2374 } CONTEXT, *PCONTEXT;
2376 typedef struct _STACK_FRAME_HEADER
2378 DWORD BackChain;
2379 DWORD GlueSaved1;
2380 DWORD GlueSaved2;
2381 DWORD Reserved1;
2382 DWORD Spare1;
2383 DWORD Spare2;
2385 DWORD Parameter0;
2386 DWORD Parameter1;
2387 DWORD Parameter2;
2388 DWORD Parameter3;
2389 DWORD Parameter4;
2390 DWORD Parameter5;
2391 DWORD Parameter6;
2392 DWORD Parameter7;
2393 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
2395 #endif /* __powerpc__ */
2397 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2398 #error You need to define a CONTEXT for your CPU
2399 #endif
2401 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
2403 #define WOW64_CONTEXT_i386 0x00010000
2404 #define WOW64_CONTEXT_i486 0x00010000
2405 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
2406 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
2407 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
2408 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
2409 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
2410 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
2411 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2412 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
2413 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
2414 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
2415 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
2417 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2419 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
2420 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
2421 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
2422 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
2424 #define WOW64_SIZE_OF_80387_REGISTERS 80
2425 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
2427 typedef struct _WOW64_FLOATING_SAVE_AREA
2429 DWORD ControlWord;
2430 DWORD StatusWord;
2431 DWORD TagWord;
2432 DWORD ErrorOffset;
2433 DWORD ErrorSelector;
2434 DWORD DataOffset;
2435 DWORD DataSelector;
2436 BYTE RegisterArea[WOW64_SIZE_OF_80387_REGISTERS];
2437 DWORD Cr0NpxState;
2438 } WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
2440 #include "pshpack4.h"
2441 typedef struct _WOW64_CONTEXT
2443 DWORD ContextFlags;
2444 DWORD Dr0;
2445 DWORD Dr1;
2446 DWORD Dr2;
2447 DWORD Dr3;
2448 DWORD Dr6;
2449 DWORD Dr7;
2450 WOW64_FLOATING_SAVE_AREA FloatSave;
2451 DWORD SegGs;
2452 DWORD SegFs;
2453 DWORD SegEs;
2454 DWORD SegDs;
2455 DWORD Edi;
2456 DWORD Esi;
2457 DWORD Ebx;
2458 DWORD Edx;
2459 DWORD Ecx;
2460 DWORD Eax;
2461 DWORD Ebp;
2462 DWORD Eip;
2463 DWORD SegCs;
2464 DWORD EFlags;
2465 DWORD Esp;
2466 DWORD SegSs;
2467 BYTE ExtendedRegisters[WOW64_MAXIMUM_SUPPORTED_EXTENSION];
2468 } WOW64_CONTEXT, *PWOW64_CONTEXT;
2469 #include "poppack.h"
2471 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
2473 typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD_PTR,PVOID);
2475 NTSYSAPI BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD_PTR);
2476 NTSYSAPI DWORD WINAPI RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION,DWORD,DWORD,ULONG_PTR,ULONG_PTR);
2477 NTSYSAPI BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
2478 NTSYSAPI void WINAPI RtlDeleteGrowableFunctionTable(void*);
2479 NTSYSAPI void WINAPI RtlGrowFunctionTable(void*,DWORD);
2480 NTSYSAPI BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD_PTR,DWORD_PTR,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
2481 NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD_PTR,DWORD_PTR*,UNWIND_HISTORY_TABLE*);
2482 NTSYSAPI void WINAPI RtlUnwindEx(PVOID,PVOID,struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,UNWIND_HISTORY_TABLE*);
2483 #endif
2486 * Product types
2488 #define PRODUCT_UNDEFINED 0x00000000
2489 #define PRODUCT_ULTIMATE 0x00000001
2490 #define PRODUCT_HOME_BASIC 0x00000002
2491 #define PRODUCT_HOME_PREMIUM 0x00000003
2492 #define PRODUCT_ENTERPRISE 0x00000004
2493 #define PRODUCT_HOME_BASIC_N 0x00000005
2494 #define PRODUCT_BUSINESS 0x00000006
2495 #define PRODUCT_STANDARD_SERVER 0x00000007
2496 #define PRODUCT_DATACENTER_SERVER 0x00000008
2497 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2498 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2499 #define PRODUCT_STARTER 0x0000000B
2500 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2501 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2502 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2503 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2504 #define PRODUCT_BUSINESS_N 0x00000010
2505 #define PRODUCT_WEB_SERVER 0x00000011
2506 #define PRODUCT_CLUSTER_SERVER 0x00000012
2507 #define PRODUCT_HOME_SERVER 0x00000013
2508 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2509 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2510 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2511 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2512 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2513 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2514 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2515 #define PRODUCT_ENTERPRISE_N 0x0000001B
2516 #define PRODUCT_ULTIMATE_N 0x0000001C
2517 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2518 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2519 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2520 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2521 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2522 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2523 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2524 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2525 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2526 #define PRODUCT_SERVER_V 0x00000025
2527 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2528 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2529 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2530 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2531 #define PRODUCT_HYPERV 0x0000002A
2532 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2533 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2534 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2535 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2536 #define PRODUCT_STARTER_N 0x0000002F
2537 #define PRODUCT_PROFESSIONAL 0x00000030
2538 #define PRODUCT_PROFESSIONAL_N 0x00000031
2539 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2540 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2541 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2542 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2543 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2544 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2545 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2546 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2547 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2548 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2549 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2550 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2551 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2552 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2553 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2554 #define PRODUCT_EMBEDDED 0x00000041
2555 #define PRODUCT_STARTER_E 0x00000042
2556 #define PRODUCT_HOME_BASIC_E 0x00000043
2557 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2558 #define PRODUCT_PROFESSIONAL_E 0x00000045
2559 #define PRODUCT_ENTERPRISE_E 0x00000046
2560 #define PRODUCT_ULTIMATE_E 0x00000047
2561 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2562 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2563 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2564 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2565 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2566 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2567 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2568 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2569 #define PRODUCT_THINPC 0x00000057
2570 #define PRODUCT_EMBEDDED_A 0x00000058
2571 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2572 #define PRODUCT_EMBEDDED_E 0x0000005A
2573 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2574 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2575 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2576 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2577 #define PRODUCT_CORE_ARM 0x00000061
2578 #define PRODUCT_CORE_N 0x00000062
2579 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2580 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2581 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2582 #define PRODUCT_CORE 0x00000065
2583 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2584 #define PRODUCT_MOBILE_CORE 0x00000068
2585 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2586 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2587 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2588 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2589 #define PRODUCT_NANO_SERVER 0x0000006D
2590 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2591 #define PRODUCT_CORE_CONNECTED 0x0000006F
2592 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2593 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2594 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2595 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2596 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2597 #define PRODUCT_CONNECTED_CAR 0x00000075
2598 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2599 #define PRODUCT_PPI_PRO 0x00000077
2600 #define PRODUCT_ARM64_SERVER 0x00000078
2601 #define PRODUCT_EDUCATION 0x00000079
2602 #define PRODUCT_EDUCATION_N 0x0000007A
2603 #define PRODUCT_IOTUAP 0x0000007B
2604 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2605 #define PRODUCT_ENTERPRISE_S 0x0000007D
2606 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2607 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2608 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2609 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2610 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2611 #define PRODUCT_UNLICENSED 0xABCDABCD
2615 * Language IDs
2618 #define MAKELCID(l, s) (MAKELONG(l, s))
2620 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2621 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2622 #define SUBLANGID(l) ((WORD)(l) >> 10)
2624 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2625 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2627 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2628 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2629 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2630 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2631 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2632 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2633 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2634 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2635 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2636 #define LOCALE_NAME_MAX_LENGTH 85
2639 #define UNREFERENCED_PARAMETER(u) (void)(u)
2640 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2641 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2643 #include <winnt.rh>
2647 * Definitions for IsTextUnicode()
2650 #define IS_TEXT_UNICODE_ASCII16 0x0001
2651 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2652 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2653 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2654 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2655 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2656 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2657 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2658 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2659 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2660 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2661 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2662 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2663 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2664 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2665 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2667 #define MAXIMUM_WAIT_OBJECTS 64
2668 #define MAXIMUM_SUSPEND_COUNT 127
2670 #define WT_EXECUTEDEFAULT 0x00
2671 #define WT_EXECUTEINIOTHREAD 0x01
2672 #define WT_EXECUTEINUITHREAD 0x02
2673 #define WT_EXECUTEINWAITTHREAD 0x04
2674 #define WT_EXECUTEONLYONCE 0x08
2675 #define WT_EXECUTELONGFUNCTION 0x10
2676 #define WT_EXECUTEINTIMERTHREAD 0x20
2677 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2678 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2679 #define WT_EXECUTEINLONGTHREAD 0x10
2680 #define WT_EXECUTEDELETEWAIT 0x08
2681 #define WT_TRANSFER_IMPERSONATION 0x0100
2684 #define EXCEPTION_CONTINUABLE 0
2685 #define EXCEPTION_NONCONTINUABLE 0x01
2688 * The exception record used by Win32 to give additional information
2689 * about exception to exception handlers.
2692 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2694 typedef struct _EXCEPTION_RECORD
2696 DWORD ExceptionCode;
2697 DWORD ExceptionFlags;
2698 struct _EXCEPTION_RECORD *ExceptionRecord;
2700 PVOID ExceptionAddress;
2701 DWORD NumberParameters;
2702 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2703 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2705 typedef struct _EXCEPTION_RECORD32
2707 DWORD ExceptionCode;
2708 DWORD ExceptionFlags;
2709 DWORD ExceptionRecord;
2710 DWORD ExceptionAddress;
2711 DWORD NumberParameters;
2712 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2713 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
2715 typedef struct _EXCEPTION_RECORD64
2717 DWORD ExceptionCode;
2718 DWORD ExceptionFlags;
2719 DWORD64 ExceptionRecord;
2720 DWORD64 ExceptionAddress;
2721 DWORD NumberParameters;
2722 DWORD __unusedAlignment;
2723 DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2724 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
2727 * The exception pointers structure passed to exception filters
2728 * in except() and the UnhandledExceptionFilter().
2731 typedef struct _EXCEPTION_POINTERS
2733 PEXCEPTION_RECORD ExceptionRecord;
2734 PCONTEXT ContextRecord;
2735 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2739 * The exception frame, used for registering exception handlers
2740 * Win32 cares only about this, but compilers generally emit
2741 * larger exception frames for their own use.
2744 struct _EXCEPTION_REGISTRATION_RECORD;
2746 typedef DWORD (CDECL *PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2747 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2749 typedef struct _EXCEPTION_REGISTRATION_RECORD
2751 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2752 PEXCEPTION_HANDLER Handler;
2753 } EXCEPTION_REGISTRATION_RECORD;
2756 * function pointer to an exception filter
2759 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2761 typedef struct _NT_TIB
2763 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2764 PVOID StackBase;
2765 PVOID StackLimit;
2766 PVOID SubSystemTib;
2767 union {
2768 PVOID FiberData;
2769 DWORD Version;
2770 } DUMMYUNIONNAME;
2771 PVOID ArbitraryUserPointer;
2772 struct _NT_TIB *Self;
2773 } NT_TIB, *PNT_TIB;
2775 struct _TEB;
2777 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2778 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2780 struct _TEB *teb;
2781 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2782 return teb;
2784 #elif defined(__i386__) && defined(_MSC_VER)
2785 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2787 struct _TEB *teb;
2788 __asm mov eax, fs:[0x18];
2789 __asm mov teb, eax;
2790 return teb;
2792 #elif defined(__x86_64__) && defined(__GNUC__)
2793 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2795 struct _TEB *teb;
2796 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2797 return teb;
2799 #elif defined(__x86_64__) && defined(_MSC_VER)
2800 unsigned __int64 __readgsqword(unsigned long);
2801 #pragma intrinsic(__readgsqword)
2802 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2804 return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
2806 #elif defined(__arm__) && defined(__GNUC__)
2807 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2809 struct _TEB *teb;
2810 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb));
2811 return teb;
2813 #else
2814 extern struct _TEB * WINAPI NtCurrentTeb(void);
2815 #endif
2817 #ifdef NONAMELESSUNION
2818 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2819 #else
2820 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2821 #endif
2822 #define GetFiberData() (*(void **)GetCurrentFiber())
2824 #define TLS_MINIMUM_AVAILABLE 64
2826 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2828 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2829 #define IO_REPARSE_TAG_RESERVED_ONE 1
2830 #define IO_REPARSE_TAG_RESERVED_TWO 2
2832 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2834 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2835 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2836 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2837 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2838 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2839 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2840 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2841 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2842 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2843 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2844 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2845 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2846 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2847 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2848 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2849 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2850 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2851 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2852 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2853 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2854 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2855 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2856 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2857 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2858 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2859 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2860 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2861 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2862 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2863 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2864 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2865 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2866 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2867 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2868 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2869 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2870 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2871 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2872 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2873 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2874 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2875 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2876 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2879 * File formats definitions
2882 #include <pshpack2.h>
2883 typedef struct _IMAGE_DOS_HEADER {
2884 WORD e_magic; /* 00: MZ Header signature */
2885 WORD e_cblp; /* 02: Bytes on last page of file */
2886 WORD e_cp; /* 04: Pages in file */
2887 WORD e_crlc; /* 06: Relocations */
2888 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2889 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2890 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2891 WORD e_ss; /* 0e: Initial (relative) SS value */
2892 WORD e_sp; /* 10: Initial SP value */
2893 WORD e_csum; /* 12: Checksum */
2894 WORD e_ip; /* 14: Initial IP value */
2895 WORD e_cs; /* 16: Initial (relative) CS value */
2896 WORD e_lfarlc; /* 18: File address of relocation table */
2897 WORD e_ovno; /* 1a: Overlay number */
2898 WORD e_res[4]; /* 1c: Reserved words */
2899 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2900 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2901 WORD e_res2[10]; /* 28: Reserved words */
2902 DWORD e_lfanew; /* 3c: Offset to extended header */
2903 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2904 #include <poppack.h>
2906 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2907 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2908 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2909 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2910 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2911 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2914 * This is the Windows executable (NE) header.
2915 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2917 #include <pshpack2.h>
2918 typedef struct
2920 WORD ne_magic; /* 00 NE signature 'NE' */
2921 BYTE ne_ver; /* 02 Linker version number */
2922 BYTE ne_rev; /* 03 Linker revision number */
2923 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2924 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2925 LONG ne_crc; /* 08 Checksum */
2926 WORD ne_flags; /* 0c Flags about segments in this file */
2927 WORD ne_autodata; /* 0e Automatic data segment number */
2928 WORD ne_heap; /* 10 Initial size of local heap */
2929 WORD ne_stack; /* 12 Initial size of stack */
2930 DWORD ne_csip; /* 14 Initial CS:IP */
2931 DWORD ne_sssp; /* 18 Initial SS:SP */
2932 WORD ne_cseg; /* 1c # of entries in segment table */
2933 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2934 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2935 WORD ne_segtab; /* 22 Offset to segment table */
2936 WORD ne_rsrctab; /* 24 Offset to resource table */
2937 WORD ne_restab; /* 26 Offset to resident-name table */
2938 WORD ne_modtab; /* 28 Offset to module reference table */
2939 WORD ne_imptab; /* 2a Offset to imported name table */
2940 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2941 WORD ne_cmovent; /* 30 # of movable entry points */
2942 WORD ne_align; /* 32 Logical sector alignment shift count */
2943 WORD ne_cres; /* 34 # of resource segments */
2944 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2945 BYTE ne_flagsothers; /* 37 Additional information flags */
2946 WORD ne_pretthunks; /* 38 Offset to return thunks */
2947 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2948 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2949 WORD ne_expver; /* 3e Expected Windows version number */
2950 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2951 #include <poppack.h>
2953 #include <pshpack2.h>
2954 typedef struct _IMAGE_VXD_HEADER {
2955 WORD e32_magic;
2956 BYTE e32_border;
2957 BYTE e32_worder;
2958 DWORD e32_level;
2959 WORD e32_cpu;
2960 WORD e32_os;
2961 DWORD e32_ver;
2962 DWORD e32_mflags;
2963 DWORD e32_mpages;
2964 DWORD e32_startobj;
2965 DWORD e32_eip;
2966 DWORD e32_stackobj;
2967 DWORD e32_esp;
2968 DWORD e32_pagesize;
2969 DWORD e32_lastpagesize;
2970 DWORD e32_fixupsize;
2971 DWORD e32_fixupsum;
2972 DWORD e32_ldrsize;
2973 DWORD e32_ldrsum;
2974 DWORD e32_objtab;
2975 DWORD e32_objcnt;
2976 DWORD e32_objmap;
2977 DWORD e32_itermap;
2978 DWORD e32_rsrctab;
2979 DWORD e32_rsrccnt;
2980 DWORD e32_restab;
2981 DWORD e32_enttab;
2982 DWORD e32_dirtab;
2983 DWORD e32_dircnt;
2984 DWORD e32_fpagetab;
2985 DWORD e32_frectab;
2986 DWORD e32_impmod;
2987 DWORD e32_impmodcnt;
2988 DWORD e32_impproc;
2989 DWORD e32_pagesum;
2990 DWORD e32_datapage;
2991 DWORD e32_preload;
2992 DWORD e32_nrestab;
2993 DWORD e32_cbnrestab;
2994 DWORD e32_nressum;
2995 DWORD e32_autodata;
2996 DWORD e32_debuginfo;
2997 DWORD e32_debuglen;
2998 DWORD e32_instpreload;
2999 DWORD e32_instdemand;
3000 DWORD e32_heapsize;
3001 BYTE e32_res3[12];
3002 DWORD e32_winresoff;
3003 DWORD e32_winreslen;
3004 WORD e32_devid;
3005 WORD e32_ddkver;
3006 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
3007 #include <poppack.h>
3009 /* These defines describe the meanings of the bits in the Characteristics
3010 field */
3012 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
3013 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
3014 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
3015 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
3016 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
3017 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
3018 #define IMAGE_FILE_16BIT_MACHINE 0x0040
3019 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
3020 #define IMAGE_FILE_32BIT_MACHINE 0x0100
3021 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
3022 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
3023 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
3024 #define IMAGE_FILE_SYSTEM 0x1000
3025 #define IMAGE_FILE_DLL 0x2000
3026 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
3027 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
3029 /* These are the settings of the Machine field. */
3030 #define IMAGE_FILE_MACHINE_UNKNOWN 0
3031 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
3032 #define IMAGE_FILE_MACHINE_I860 0x014d
3033 #define IMAGE_FILE_MACHINE_I386 0x014c
3034 #define IMAGE_FILE_MACHINE_R3000 0x0162
3035 #define IMAGE_FILE_MACHINE_R4000 0x0166
3036 #define IMAGE_FILE_MACHINE_R10000 0x0168
3037 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
3038 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
3039 #define IMAGE_FILE_MACHINE_SH3 0x01a2
3040 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
3041 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
3042 #define IMAGE_FILE_MACHINE_SH4 0x01a6
3043 #define IMAGE_FILE_MACHINE_SH5 0x01a8
3044 #define IMAGE_FILE_MACHINE_ARM 0x01c0
3045 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
3046 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
3047 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
3048 #define IMAGE_FILE_MACHINE_AM33 0x01d3
3049 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
3050 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
3051 #define IMAGE_FILE_MACHINE_IA64 0x0200
3052 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
3053 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
3054 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
3055 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
3056 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
3057 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
3058 #define IMAGE_FILE_MACHINE_CEF 0x0cef
3059 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
3060 #define IMAGE_FILE_MACHINE_AMD64 0x8664
3061 #define IMAGE_FILE_MACHINE_M32R 0x9041
3062 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
3064 #define IMAGE_SIZEOF_FILE_HEADER 20
3065 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
3066 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
3067 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
3068 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
3069 #define IMAGE_SIZEOF_SHORT_NAME 8
3070 #define IMAGE_SIZEOF_SECTION_HEADER 40
3071 #define IMAGE_SIZEOF_SYMBOL 18
3072 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3073 #define IMAGE_SIZEOF_RELOCATION 10
3074 #define IMAGE_SIZEOF_BASE_RELOCATION 8
3075 #define IMAGE_SIZEOF_LINENUMBER 6
3076 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3078 /* Possible Magic values */
3079 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
3080 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
3081 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
3083 #ifdef _WIN64
3084 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
3085 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
3086 #else
3087 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
3088 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
3089 #endif
3091 /* These are indexes into the DataDirectory array */
3092 #define IMAGE_FILE_EXPORT_DIRECTORY 0
3093 #define IMAGE_FILE_IMPORT_DIRECTORY 1
3094 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
3095 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
3096 #define IMAGE_FILE_SECURITY_DIRECTORY 4
3097 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
3098 #define IMAGE_FILE_DEBUG_DIRECTORY 6
3099 #define IMAGE_FILE_DESCRIPTION_STRING 7
3100 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
3101 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
3102 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
3104 /* Directory Entries, indices into the DataDirectory array */
3106 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
3107 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
3108 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
3109 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
3110 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
3111 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
3112 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
3113 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
3114 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
3115 #define IMAGE_DIRECTORY_ENTRY_TLS 9
3116 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
3117 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
3118 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
3119 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
3120 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
3122 /* Subsystem Values */
3124 #define IMAGE_SUBSYSTEM_UNKNOWN 0
3125 #define IMAGE_SUBSYSTEM_NATIVE 1
3126 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
3127 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
3128 #define IMAGE_SUBSYSTEM_OS2_CUI 5
3129 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
3130 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
3131 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
3132 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
3133 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
3134 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
3135 #define IMAGE_SUBSYSTEM_EFI_ROM 13
3136 #define IMAGE_SUBSYSTEM_XBOX 14
3137 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
3139 /* DLL Characteristics */
3140 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
3141 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
3142 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
3143 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
3144 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
3145 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
3146 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
3147 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
3148 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
3149 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
3150 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
3152 typedef struct _IMAGE_FILE_HEADER {
3153 WORD Machine;
3154 WORD NumberOfSections;
3155 DWORD TimeDateStamp;
3156 DWORD PointerToSymbolTable;
3157 DWORD NumberOfSymbols;
3158 WORD SizeOfOptionalHeader;
3159 WORD Characteristics;
3160 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
3162 typedef struct _IMAGE_DATA_DIRECTORY {
3163 DWORD VirtualAddress;
3164 DWORD Size;
3165 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
3167 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
3169 typedef struct _IMAGE_OPTIONAL_HEADER64 {
3170 WORD Magic; /* 0x20b */
3171 BYTE MajorLinkerVersion;
3172 BYTE MinorLinkerVersion;
3173 DWORD SizeOfCode;
3174 DWORD SizeOfInitializedData;
3175 DWORD SizeOfUninitializedData;
3176 DWORD AddressOfEntryPoint;
3177 DWORD BaseOfCode;
3178 ULONGLONG ImageBase;
3179 DWORD SectionAlignment;
3180 DWORD FileAlignment;
3181 WORD MajorOperatingSystemVersion;
3182 WORD MinorOperatingSystemVersion;
3183 WORD MajorImageVersion;
3184 WORD MinorImageVersion;
3185 WORD MajorSubsystemVersion;
3186 WORD MinorSubsystemVersion;
3187 DWORD Win32VersionValue;
3188 DWORD SizeOfImage;
3189 DWORD SizeOfHeaders;
3190 DWORD CheckSum;
3191 WORD Subsystem;
3192 WORD DllCharacteristics;
3193 ULONGLONG SizeOfStackReserve;
3194 ULONGLONG SizeOfStackCommit;
3195 ULONGLONG SizeOfHeapReserve;
3196 ULONGLONG SizeOfHeapCommit;
3197 DWORD LoaderFlags;
3198 DWORD NumberOfRvaAndSizes;
3199 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
3200 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
3202 typedef struct _IMAGE_NT_HEADERS64 {
3203 DWORD Signature;
3204 IMAGE_FILE_HEADER FileHeader;
3205 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
3206 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
3208 typedef struct _IMAGE_OPTIONAL_HEADER {
3210 /* Standard fields */
3212 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
3213 BYTE MajorLinkerVersion;
3214 BYTE MinorLinkerVersion;
3215 DWORD SizeOfCode;
3216 DWORD SizeOfInitializedData;
3217 DWORD SizeOfUninitializedData;
3218 DWORD AddressOfEntryPoint; /* 0x10 */
3219 DWORD BaseOfCode;
3220 DWORD BaseOfData;
3222 /* NT additional fields */
3224 DWORD ImageBase;
3225 DWORD SectionAlignment; /* 0x20 */
3226 DWORD FileAlignment;
3227 WORD MajorOperatingSystemVersion;
3228 WORD MinorOperatingSystemVersion;
3229 WORD MajorImageVersion;
3230 WORD MinorImageVersion;
3231 WORD MajorSubsystemVersion; /* 0x30 */
3232 WORD MinorSubsystemVersion;
3233 DWORD Win32VersionValue;
3234 DWORD SizeOfImage;
3235 DWORD SizeOfHeaders;
3236 DWORD CheckSum; /* 0x40 */
3237 WORD Subsystem;
3238 WORD DllCharacteristics;
3239 DWORD SizeOfStackReserve;
3240 DWORD SizeOfStackCommit;
3241 DWORD SizeOfHeapReserve; /* 0x50 */
3242 DWORD SizeOfHeapCommit;
3243 DWORD LoaderFlags;
3244 DWORD NumberOfRvaAndSizes;
3245 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
3246 /* 0xE0 */
3247 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
3249 typedef struct _IMAGE_NT_HEADERS {
3250 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
3251 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
3252 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
3253 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
3255 #ifdef _WIN64
3256 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
3257 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
3258 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
3259 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
3260 #else
3261 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
3262 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
3263 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
3264 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
3265 #endif
3267 #define IMAGE_SIZEOF_SHORT_NAME 8
3269 typedef struct _IMAGE_SECTION_HEADER {
3270 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
3271 union {
3272 DWORD PhysicalAddress;
3273 DWORD VirtualSize;
3274 } Misc;
3275 DWORD VirtualAddress;
3276 DWORD SizeOfRawData;
3277 DWORD PointerToRawData;
3278 DWORD PointerToRelocations;
3279 DWORD PointerToLinenumbers;
3280 WORD NumberOfRelocations;
3281 WORD NumberOfLinenumbers;
3282 DWORD Characteristics;
3283 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
3285 #define IMAGE_SIZEOF_SECTION_HEADER 40
3287 #define IMAGE_FIRST_SECTION(ntheader) \
3288 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
3289 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
3291 /* These defines are for the Characteristics bitfield. */
3292 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
3293 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
3294 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
3295 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
3296 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
3297 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
3299 #define IMAGE_SCN_CNT_CODE 0x00000020
3300 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
3301 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
3303 #define IMAGE_SCN_LNK_OTHER 0x00000100
3304 #define IMAGE_SCN_LNK_INFO 0x00000200
3305 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
3306 #define IMAGE_SCN_LNK_REMOVE 0x00000800
3307 #define IMAGE_SCN_LNK_COMDAT 0x00001000
3309 /* 0x00002000 - Reserved */
3310 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
3311 #define IMAGE_SCN_MEM_FARDATA 0x00008000
3313 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
3314 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
3315 #define IMAGE_SCN_MEM_16BIT 0x00020000
3316 #define IMAGE_SCN_MEM_LOCKED 0x00040000
3317 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
3319 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
3320 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
3321 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
3322 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
3323 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
3324 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
3325 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
3326 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
3327 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
3328 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
3329 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
3330 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
3331 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
3332 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
3333 /* 0x00F00000 - Unused */
3334 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
3336 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
3339 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
3340 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
3341 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
3342 #define IMAGE_SCN_MEM_SHARED 0x10000000
3343 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
3344 #define IMAGE_SCN_MEM_READ 0x40000000
3345 #define IMAGE_SCN_MEM_WRITE 0x80000000
3347 #include <pshpack2.h>
3349 typedef struct _IMAGE_SYMBOL {
3350 union {
3351 BYTE ShortName[8];
3352 struct {
3353 DWORD Short;
3354 DWORD Long;
3355 } Name;
3356 DWORD LongName[2];
3357 } N;
3358 DWORD Value;
3359 SHORT SectionNumber;
3360 WORD Type;
3361 BYTE StorageClass;
3362 BYTE NumberOfAuxSymbols;
3363 } IMAGE_SYMBOL;
3364 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
3366 #define IMAGE_SIZEOF_SYMBOL 18
3368 typedef struct _IMAGE_LINENUMBER {
3369 union {
3370 DWORD SymbolTableIndex;
3371 DWORD VirtualAddress;
3372 } Type;
3373 WORD Linenumber;
3374 } IMAGE_LINENUMBER;
3375 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
3377 #define IMAGE_SIZEOF_LINENUMBER 6
3379 typedef union _IMAGE_AUX_SYMBOL {
3380 struct {
3381 DWORD TagIndex;
3382 union {
3383 struct {
3384 WORD Linenumber;
3385 WORD Size;
3386 } LnSz;
3387 DWORD TotalSize;
3388 } Misc;
3389 union {
3390 struct {
3391 DWORD PointerToLinenumber;
3392 DWORD PointerToNextFunction;
3393 } Function;
3394 struct {
3395 WORD Dimension[4];
3396 } Array;
3397 } FcnAry;
3398 WORD TvIndex;
3399 } Sym;
3400 struct {
3401 BYTE Name[IMAGE_SIZEOF_SYMBOL];
3402 } File;
3403 struct {
3404 DWORD Length;
3405 WORD NumberOfRelocations;
3406 WORD NumberOfLinenumbers;
3407 DWORD CheckSum;
3408 SHORT Number;
3409 BYTE Selection;
3410 } Section;
3411 } IMAGE_AUX_SYMBOL;
3412 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
3414 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3416 #include <poppack.h>
3418 #define IMAGE_SYM_UNDEFINED (SHORT)0
3419 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3420 #define IMAGE_SYM_DEBUG (SHORT)-2
3422 #define IMAGE_SYM_TYPE_NULL 0x0000
3423 #define IMAGE_SYM_TYPE_VOID 0x0001
3424 #define IMAGE_SYM_TYPE_CHAR 0x0002
3425 #define IMAGE_SYM_TYPE_SHORT 0x0003
3426 #define IMAGE_SYM_TYPE_INT 0x0004
3427 #define IMAGE_SYM_TYPE_LONG 0x0005
3428 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3429 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3430 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3431 #define IMAGE_SYM_TYPE_UNION 0x0009
3432 #define IMAGE_SYM_TYPE_ENUM 0x000A
3433 #define IMAGE_SYM_TYPE_MOE 0x000B
3434 #define IMAGE_SYM_TYPE_BYTE 0x000C
3435 #define IMAGE_SYM_TYPE_WORD 0x000D
3436 #define IMAGE_SYM_TYPE_UINT 0x000E
3437 #define IMAGE_SYM_TYPE_DWORD 0x000F
3438 #define IMAGE_SYM_TYPE_PCODE 0x8000
3440 #define IMAGE_SYM_DTYPE_NULL 0
3441 #define IMAGE_SYM_DTYPE_POINTER 1
3442 #define IMAGE_SYM_DTYPE_FUNCTION 2
3443 #define IMAGE_SYM_DTYPE_ARRAY 3
3445 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3446 #define IMAGE_SYM_CLASS_NULL 0x0000
3447 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3448 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3449 #define IMAGE_SYM_CLASS_STATIC 0x0003
3450 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3451 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3452 #define IMAGE_SYM_CLASS_LABEL 0x0006
3453 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3454 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3455 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3456 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3457 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3458 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3459 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3460 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3461 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3462 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3463 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3464 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3466 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3467 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3468 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3469 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3470 #define IMAGE_SYM_CLASS_FILE 0x0067
3471 #define IMAGE_SYM_CLASS_SECTION 0x0068
3472 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3474 #define N_BTMASK 0x000F
3475 #define N_TMASK 0x0030
3476 #define N_TMASK1 0x00C0
3477 #define N_TMASK2 0x00F0
3478 #define N_BTSHFT 4
3479 #define N_TSHIFT 2
3481 #define BTYPE(x) ((x) & N_BTMASK)
3483 #ifndef ISPTR
3484 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3485 #endif
3487 #ifndef ISFCN
3488 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3489 #endif
3491 #ifndef ISARY
3492 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3493 #endif
3495 #ifndef ISTAG
3496 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3497 #endif
3499 #ifndef INCREF
3500 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3501 #endif
3502 #ifndef DECREF
3503 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3504 #endif
3506 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3507 #define IMAGE_COMDAT_SELECT_ANY 2
3508 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3509 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3510 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3511 #define IMAGE_COMDAT_SELECT_LARGEST 6
3512 #define IMAGE_COMDAT_SELECT_NEWEST 7
3514 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3515 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3516 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3518 /* Export module directory */
3520 typedef struct _IMAGE_EXPORT_DIRECTORY {
3521 DWORD Characteristics;
3522 DWORD TimeDateStamp;
3523 WORD MajorVersion;
3524 WORD MinorVersion;
3525 DWORD Name;
3526 DWORD Base;
3527 DWORD NumberOfFunctions;
3528 DWORD NumberOfNames;
3529 DWORD AddressOfFunctions;
3530 DWORD AddressOfNames;
3531 DWORD AddressOfNameOrdinals;
3532 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
3534 /* Import name entry */
3535 typedef struct _IMAGE_IMPORT_BY_NAME {
3536 WORD Hint;
3537 BYTE Name[1];
3538 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
3540 #include <pshpack8.h>
3541 /* Import thunk */
3542 typedef struct _IMAGE_THUNK_DATA64 {
3543 union {
3544 ULONGLONG ForwarderString;
3545 ULONGLONG Function;
3546 ULONGLONG Ordinal;
3547 ULONGLONG AddressOfData;
3548 } u1;
3549 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3550 #include <poppack.h>
3552 typedef struct _IMAGE_THUNK_DATA32 {
3553 union {
3554 DWORD ForwarderString;
3555 DWORD Function;
3556 DWORD Ordinal;
3557 DWORD AddressOfData;
3558 } u1;
3559 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3561 /* Import module directory */
3563 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3564 union {
3565 DWORD Characteristics; /* 0 for terminating null import descriptor */
3566 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3567 } DUMMYUNIONNAME;
3568 DWORD TimeDateStamp; /* 0 if not bound,
3569 * -1 if bound, and real date\time stamp
3570 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3571 * (new BIND)
3572 * otherwise date/time stamp of DLL bound to
3573 * (Old BIND)
3575 DWORD ForwarderChain; /* -1 if no forwarders */
3576 DWORD Name;
3577 /* RVA to IAT (if bound this IAT has actual addresses) */
3578 DWORD FirstThunk;
3579 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3581 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3582 #define IMAGE_ORDINAL_FLAG32 0x80000000
3583 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3584 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3585 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3586 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3588 #ifdef _WIN64
3589 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3590 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3591 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3592 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3593 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3594 #else
3595 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3596 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3597 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3598 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3599 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3600 #endif
3602 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3604 DWORD TimeDateStamp;
3605 WORD OffsetModuleName;
3606 WORD NumberOfModuleForwarderRefs;
3607 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3608 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3610 typedef struct _IMAGE_BOUND_FORWARDER_REF
3612 DWORD TimeDateStamp;
3613 WORD OffsetModuleName;
3614 WORD Reserved;
3615 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3617 typedef struct _IMAGE_BASE_RELOCATION
3619 DWORD VirtualAddress;
3620 DWORD SizeOfBlock;
3621 /* WORD TypeOffset[1]; */
3622 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3624 #include <pshpack2.h>
3626 typedef struct _IMAGE_RELOCATION
3628 union {
3629 DWORD VirtualAddress;
3630 DWORD RelocCount;
3631 } DUMMYUNIONNAME;
3632 DWORD SymbolTableIndex;
3633 WORD Type;
3634 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3636 #include <poppack.h>
3638 #define IMAGE_SIZEOF_RELOCATION 10
3640 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3642 union
3644 DWORD AllAttributes;
3645 struct
3647 DWORD RvaBased:1;
3648 DWORD ReservedAttributes:31;
3649 } DUMMYSTRUCTNAME;
3650 } Attributes;
3652 DWORD DllNameRVA;
3653 DWORD ModuleHandleRVA;
3654 DWORD ImportAddressTableRVA;
3655 DWORD ImportNameTableRVA;
3656 DWORD BoundImportAddressTableRVA;
3657 DWORD UnloadInformationTableRVA;
3658 DWORD TimeDateStamp;
3659 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3660 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3662 /* generic relocation types */
3663 #define IMAGE_REL_BASED_ABSOLUTE 0
3664 #define IMAGE_REL_BASED_HIGH 1
3665 #define IMAGE_REL_BASED_LOW 2
3666 #define IMAGE_REL_BASED_HIGHLOW 3
3667 #define IMAGE_REL_BASED_HIGHADJ 4
3668 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3669 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3670 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3671 #define IMAGE_REL_BASED_SECTION 6
3672 #define IMAGE_REL_BASED_REL 7
3673 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3674 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3675 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3676 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3677 #define IMAGE_REL_BASED_DIR64 10
3678 #define IMAGE_REL_BASED_HIGH3ADJ 11
3680 /* I386 relocation types */
3681 #define IMAGE_REL_I386_ABSOLUTE 0
3682 #define IMAGE_REL_I386_DIR16 1
3683 #define IMAGE_REL_I386_REL16 2
3684 #define IMAGE_REL_I386_DIR32 6
3685 #define IMAGE_REL_I386_DIR32NB 7
3686 #define IMAGE_REL_I386_SEG12 9
3687 #define IMAGE_REL_I386_SECTION 10
3688 #define IMAGE_REL_I386_SECREL 11
3689 #define IMAGE_REL_I386_TOKEN 12
3690 #define IMAGE_REL_I386_SECREL7 13
3691 #define IMAGE_REL_I386_REL32 20
3693 /* MIPS relocation types */
3694 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3695 #define IMAGE_REL_MIPS_REFHALF 0x0001
3696 #define IMAGE_REL_MIPS_REFWORD 0x0002
3697 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3698 #define IMAGE_REL_MIPS_REFHI 0x0004
3699 #define IMAGE_REL_MIPS_REFLO 0x0005
3700 #define IMAGE_REL_MIPS_GPREL 0x0006
3701 #define IMAGE_REL_MIPS_LITERAL 0x0007
3702 #define IMAGE_REL_MIPS_SECTION 0x000A
3703 #define IMAGE_REL_MIPS_SECREL 0x000B
3704 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3705 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3706 #define IMAGE_REL_MIPS_TOKEN 0x000E
3707 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3708 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3709 #define IMAGE_REL_MIPS_PAIR 0x0025
3711 /* ALPHA relocation types */
3712 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3713 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3714 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3715 #define IMAGE_REL_ALPHA_GPREL 0x0003
3716 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3717 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3718 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3719 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3720 #define IMAGE_REL_ALPHA_HINT 0x0008
3721 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3722 #define IMAGE_REL_ALPHA_REFHI 0x000A
3723 #define IMAGE_REL_ALPHA_REFLO 0x000B
3724 #define IMAGE_REL_ALPHA_PAIR 0x000C
3725 #define IMAGE_REL_ALPHA_MATCH 0x000D
3726 #define IMAGE_REL_ALPHA_SECTION 0x000E
3727 #define IMAGE_REL_ALPHA_SECREL 0x000F
3728 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3729 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3730 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3731 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3732 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3733 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3734 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3735 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3737 /* PowerPC relocation types */
3738 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3739 #define IMAGE_REL_PPC_ADDR64 0x0001
3740 #define IMAGE_REL_PPC_ADDR 0x0002
3741 #define IMAGE_REL_PPC_ADDR24 0x0003
3742 #define IMAGE_REL_PPC_ADDR16 0x0004
3743 #define IMAGE_REL_PPC_ADDR14 0x0005
3744 #define IMAGE_REL_PPC_REL24 0x0006
3745 #define IMAGE_REL_PPC_REL14 0x0007
3746 #define IMAGE_REL_PPC_TOCREL16 0x0008
3747 #define IMAGE_REL_PPC_TOCREL14 0x0009
3748 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3749 #define IMAGE_REL_PPC_SECREL 0x000B
3750 #define IMAGE_REL_PPC_SECTION 0x000C
3751 #define IMAGE_REL_PPC_IFGLUE 0x000D
3752 #define IMAGE_REL_PPC_IMGLUE 0x000E
3753 #define IMAGE_REL_PPC_SECREL16 0x000F
3754 #define IMAGE_REL_PPC_REFHI 0x0010
3755 #define IMAGE_REL_PPC_REFLO 0x0011
3756 #define IMAGE_REL_PPC_PAIR 0x0012
3757 #define IMAGE_REL_PPC_SECRELLO 0x0013
3758 #define IMAGE_REL_PPC_SECRELHI 0x0014
3759 #define IMAGE_REL_PPC_GPREL 0x0015
3760 #define IMAGE_REL_PPC_TOKEN 0x0016
3761 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3762 /* modifier bits */
3763 #define IMAGE_REL_PPC_NEG 0x0100
3764 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3765 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3766 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3768 /* SH3 relocation types */
3769 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3770 #define IMAGE_REL_SH3_DIRECT16 0x0001
3771 #define IMAGE_REL_SH3_DIRECT 0x0002
3772 #define IMAGE_REL_SH3_DIRECT8 0x0003
3773 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3774 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3775 #define IMAGE_REL_SH3_DIRECT4 0x0006
3776 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3777 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3778 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3779 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3780 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3781 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3782 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3783 #define IMAGE_REL_SH3_SECTION 0x000E
3784 #define IMAGE_REL_SH3_SECREL 0x000F
3785 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3786 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3787 #define IMAGE_REL_SH3_TOKEN 0x0012
3789 /* ARM relocation types */
3790 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3791 #define IMAGE_REL_ARM_ADDR 0x0001
3792 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3793 #define IMAGE_REL_ARM_BRANCH24 0x0003
3794 #define IMAGE_REL_ARM_BRANCH11 0x0004
3795 #define IMAGE_REL_ARM_TOKEN 0x0005
3796 #define IMAGE_REL_ARM_GPREL12 0x0006
3797 #define IMAGE_REL_ARM_GPREL7 0x0007
3798 #define IMAGE_REL_ARM_BLX24 0x0008
3799 #define IMAGE_REL_ARM_BLX11 0x0009
3800 #define IMAGE_REL_ARM_SECTION 0x000E
3801 #define IMAGE_REL_ARM_SECREL 0x000F
3802 #define IMAGE_REL_ARM_MOV32A 0x0010
3803 #define IMAGE_REL_ARM_MOV32T 0x0011
3804 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3805 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3806 #define IMAGE_REL_ARM_BLX23T 0x0015
3808 /* ARM64 relocation types */
3809 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3810 #define IMAGE_REL_ARM64_ADDR32 0x0001
3811 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3812 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3813 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3814 #define IMAGE_REL_ARM64_REL21 0x0005
3815 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3816 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3817 #define IMAGE_REL_ARM64_SECREL 0x0008
3818 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3819 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3820 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3821 #define IMAGE_REL_ARM64_TOKEN 0x000C
3822 #define IMAGE_REL_ARM64_SECTION 0x000D
3823 #define IMAGE_REL_ARM64_ADDR64 0x000E
3824 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3826 /* IA64 relocation types */
3827 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3828 #define IMAGE_REL_IA64_IMM14 0x0001
3829 #define IMAGE_REL_IA64_IMM22 0x0002
3830 #define IMAGE_REL_IA64_IMM64 0x0003
3831 #define IMAGE_REL_IA64_DIR 0x0004
3832 #define IMAGE_REL_IA64_DIR64 0x0005
3833 #define IMAGE_REL_IA64_PCREL21B 0x0006
3834 #define IMAGE_REL_IA64_PCREL21M 0x0007
3835 #define IMAGE_REL_IA64_PCREL21F 0x0008
3836 #define IMAGE_REL_IA64_GPREL22 0x0009
3837 #define IMAGE_REL_IA64_LTOFF22 0x000A
3838 #define IMAGE_REL_IA64_SECTION 0x000B
3839 #define IMAGE_REL_IA64_SECREL22 0x000C
3840 #define IMAGE_REL_IA64_SECREL64I 0x000D
3841 #define IMAGE_REL_IA64_SECREL 0x000E
3842 #define IMAGE_REL_IA64_LTOFF64 0x000F
3843 #define IMAGE_REL_IA64_DIR32NB 0x0010
3844 #define IMAGE_REL_IA64_SREL14 0x0011
3845 #define IMAGE_REL_IA64_SREL22 0x0012
3846 #define IMAGE_REL_IA64_SREL32 0x0013
3847 #define IMAGE_REL_IA64_UREL32 0x0014
3848 #define IMAGE_REL_IA64_PCREL60X 0x0015
3849 #define IMAGE_REL_IA64_PCREL60B 0x0016
3850 #define IMAGE_REL_IA64_PCREL60F 0x0017
3851 #define IMAGE_REL_IA64_PCREL60I 0x0018
3852 #define IMAGE_REL_IA64_PCREL60M 0x0019
3853 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3854 #define IMAGE_REL_IA64_TOKEN 0x001B
3855 #define IMAGE_REL_IA64_GPREL32 0x001C
3856 #define IMAGE_REL_IA64_ADDEND 0x001F
3858 /* AMD64 relocation types */
3859 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3860 #define IMAGE_REL_AMD64_ADDR64 0x0001
3861 #define IMAGE_REL_AMD64_ADDR32 0x0002
3862 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3863 #define IMAGE_REL_AMD64_REL32 0x0004
3864 #define IMAGE_REL_AMD64_REL32_1 0x0005
3865 #define IMAGE_REL_AMD64_REL32_2 0x0006
3866 #define IMAGE_REL_AMD64_REL32_3 0x0007
3867 #define IMAGE_REL_AMD64_REL32_4 0x0008
3868 #define IMAGE_REL_AMD64_REL32_5 0x0009
3869 #define IMAGE_REL_AMD64_SECTION 0x000A
3870 #define IMAGE_REL_AMD64_SECREL 0x000B
3871 #define IMAGE_REL_AMD64_SECREL7 0x000C
3872 #define IMAGE_REL_AMD64_TOKEN 0x000D
3873 #define IMAGE_REL_AMD64_SREL32 0x000E
3874 #define IMAGE_REL_AMD64_PAIR 0x000F
3875 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3877 /* archive format */
3879 #define IMAGE_ARCHIVE_START_SIZE 8
3880 #define IMAGE_ARCHIVE_START "!<arch>\n"
3881 #define IMAGE_ARCHIVE_END "`\n"
3882 #define IMAGE_ARCHIVE_PAD "\n"
3883 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3884 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3886 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3888 BYTE Name[16];
3889 BYTE Date[12];
3890 BYTE UserID[6];
3891 BYTE GroupID[6];
3892 BYTE Mode[8];
3893 BYTE Size[10];
3894 BYTE EndHeader[2];
3895 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3897 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3899 typedef struct _IMPORT_OBJECT_HEADER
3901 WORD Sig1;
3902 WORD Sig2;
3903 WORD Version;
3904 WORD Machine;
3905 DWORD TimeDateStamp;
3906 DWORD SizeOfData;
3907 union
3909 WORD Ordinal;
3910 WORD Hint;
3911 } DUMMYUNIONNAME;
3912 WORD Type : 2;
3913 WORD NameType : 3;
3914 WORD Reserved : 11;
3915 } IMPORT_OBJECT_HEADER;
3917 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3919 typedef enum IMPORT_OBJECT_TYPE
3921 IMPORT_OBJECT_CODE = 0,
3922 IMPORT_OBJECT_DATA = 1,
3923 IMPORT_OBJECT_CONST = 2
3924 } IMPORT_OBJECT_TYPE;
3926 typedef enum IMPORT_OBJECT_NAME_TYPE
3928 IMPORT_OBJECT_ORDINAL = 0,
3929 IMPORT_OBJECT_NAME = 1,
3930 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3931 IMPORT_OBJECT_NAME_UNDECORATE = 3
3932 } IMPORT_OBJECT_NAME_TYPE;
3934 typedef struct _ANON_OBJECT_HEADER
3936 WORD Sig1;
3937 WORD Sig2;
3938 WORD Version;
3939 WORD Machine;
3940 DWORD TimeDateStamp;
3941 CLSID ClassID;
3942 DWORD SizeOfData;
3943 } ANON_OBJECT_HEADER;
3946 * Resource directory stuff
3948 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3949 DWORD Characteristics;
3950 DWORD TimeDateStamp;
3951 WORD MajorVersion;
3952 WORD MinorVersion;
3953 WORD NumberOfNamedEntries;
3954 WORD NumberOfIdEntries;
3955 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3956 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3958 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3959 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3961 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3962 union {
3963 struct {
3964 unsigned NameOffset:31;
3965 unsigned NameIsString:1;
3966 } DUMMYSTRUCTNAME;
3967 DWORD Name;
3968 WORD Id;
3969 } DUMMYUNIONNAME;
3970 union {
3971 DWORD OffsetToData;
3972 struct {
3973 unsigned OffsetToDirectory:31;
3974 unsigned DataIsDirectory:1;
3975 } DUMMYSTRUCTNAME2;
3976 } DUMMYUNIONNAME2;
3977 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3980 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3981 WORD Length;
3982 CHAR NameString[ 1 ];
3983 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3985 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3986 WORD Length;
3987 WCHAR NameString[ 1 ];
3988 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3990 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3991 DWORD OffsetToData;
3992 DWORD Size;
3993 DWORD CodePage;
3994 DWORD Reserved;
3995 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3998 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3999 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
4002 typedef struct _IMAGE_TLS_DIRECTORY64 {
4003 ULONGLONG StartAddressOfRawData;
4004 ULONGLONG EndAddressOfRawData;
4005 ULONGLONG AddressOfIndex;
4006 ULONGLONG AddressOfCallBacks;
4007 DWORD SizeOfZeroFill;
4008 DWORD Characteristics;
4009 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
4011 typedef struct _IMAGE_TLS_DIRECTORY32 {
4012 DWORD StartAddressOfRawData;
4013 DWORD EndAddressOfRawData;
4014 DWORD AddressOfIndex;
4015 DWORD AddressOfCallBacks;
4016 DWORD SizeOfZeroFill;
4017 DWORD Characteristics;
4018 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
4020 #ifdef _WIN64
4021 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
4022 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
4023 #else
4024 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
4025 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
4026 #endif
4028 typedef struct _IMAGE_DEBUG_DIRECTORY {
4029 DWORD Characteristics;
4030 DWORD TimeDateStamp;
4031 WORD MajorVersion;
4032 WORD MinorVersion;
4033 DWORD Type;
4034 DWORD SizeOfData;
4035 DWORD AddressOfRawData;
4036 DWORD PointerToRawData;
4037 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
4039 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
4040 #define IMAGE_DEBUG_TYPE_COFF 1
4041 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
4042 #define IMAGE_DEBUG_TYPE_FPO 3
4043 #define IMAGE_DEBUG_TYPE_MISC 4
4044 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
4045 #define IMAGE_DEBUG_TYPE_FIXUP 6
4046 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
4047 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
4048 #define IMAGE_DEBUG_TYPE_BORLAND 9
4049 #define IMAGE_DEBUG_TYPE_RESERVED10 10
4050 #define IMAGE_DEBUG_TYPE_CLSID 11
4051 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
4052 #define IMAGE_DEBUG_TYPE_POGO 13
4053 #define IMAGE_DEBUG_TYPE_ILTCG 14
4054 #define IMAGE_DEBUG_TYPE_MPX 15
4055 #define IMAGE_DEBUG_TYPE_REPRO 16
4057 typedef enum ReplacesCorHdrNumericDefines
4059 COMIMAGE_FLAGS_ILONLY = 0x00000001,
4060 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
4061 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
4062 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
4063 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
4064 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
4065 COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000,
4067 COR_VERSION_MAJOR_V2 = 2,
4068 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
4069 COR_VERSION_MINOR = 5,
4070 COR_DELETED_NAME_LENGTH = 8,
4071 COR_VTABLEGAP_NAME_LENGTH = 8,
4073 NATIVE_TYPE_MAX_CB = 1,
4074 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
4076 IMAGE_COR_MIH_METHODRVA = 0x01,
4077 IMAGE_COR_MIH_EHRVA = 0x02,
4078 IMAGE_COR_MIH_BASICBLOCK = 0x08,
4080 COR_VTABLE_32BIT = 0x01,
4081 COR_VTABLE_64BIT = 0x02,
4082 COR_VTABLE_FROM_UNMANAGED = 0x04,
4083 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
4085 IMAGE_COR_EATJ_THUNK_SIZE = 32,
4087 MAX_CLASS_NAME = 1024,
4088 MAX_PACKAGE_NAME = 1024,
4089 } ReplacesCorHdrNumericDefines;
4091 typedef struct IMAGE_COR20_HEADER
4093 DWORD cb;
4094 WORD MajorRuntimeVersion;
4095 WORD MinorRuntimeVersion;
4097 IMAGE_DATA_DIRECTORY MetaData;
4098 DWORD Flags;
4099 union {
4100 DWORD EntryPointToken;
4101 DWORD EntryPointRVA;
4102 } DUMMYUNIONNAME;
4104 IMAGE_DATA_DIRECTORY Resources;
4105 IMAGE_DATA_DIRECTORY StrongNameSignature;
4106 IMAGE_DATA_DIRECTORY CodeManagerTable;
4107 IMAGE_DATA_DIRECTORY VTableFixups;
4108 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
4109 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
4111 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
4113 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
4114 DWORD NumberOfSymbols;
4115 DWORD LvaToFirstSymbol;
4116 DWORD NumberOfLinenumbers;
4117 DWORD LvaToFirstLinenumber;
4118 DWORD RvaToFirstByteOfCode;
4119 DWORD RvaToLastByteOfCode;
4120 DWORD RvaToFirstByteOfData;
4121 DWORD RvaToLastByteOfData;
4122 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
4124 #define FRAME_FPO 0
4125 #define FRAME_TRAP 1
4126 #define FRAME_TSS 2
4127 #define FRAME_NONFPO 3
4129 typedef struct _FPO_DATA {
4130 DWORD ulOffStart;
4131 DWORD cbProcSize;
4132 DWORD cdwLocals;
4133 WORD cdwParams;
4134 WORD cbProlog : 8;
4135 WORD cbRegs : 3;
4136 WORD fHasSEH : 1;
4137 WORD fUseBP : 1;
4138 WORD reserved : 1;
4139 WORD cbFrame : 2;
4140 } FPO_DATA, *PFPO_DATA;
4142 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
4143 DWORD Size;
4144 DWORD TimeDateStamp;
4145 WORD MajorVersion;
4146 WORD MinorVersion;
4147 DWORD GlobalFlagsClear;
4148 DWORD GlobalFlagsSet;
4149 DWORD CriticalSectionDefaultTimeout;
4150 ULONGLONG DeCommitFreeBlockThreshold;
4151 ULONGLONG DeCommitTotalFreeThreshold;
4152 ULONGLONG LockPrefixTable;
4153 ULONGLONG MaximumAllocationSize;
4154 ULONGLONG VirtualMemoryThreshold;
4155 ULONGLONG ProcessAffinityMask;
4156 DWORD ProcessHeapFlags;
4157 WORD CSDVersion;
4158 WORD Reserved1;
4159 ULONGLONG EditList;
4160 ULONGLONG SecurityCookie;
4161 ULONGLONG SEHandlerTable;
4162 ULONGLONG SEHandlerCount;
4163 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
4165 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
4166 DWORD Size;
4167 DWORD TimeDateStamp;
4168 WORD MajorVersion;
4169 WORD MinorVersion;
4170 DWORD GlobalFlagsClear;
4171 DWORD GlobalFlagsSet;
4172 DWORD CriticalSectionDefaultTimeout;
4173 DWORD DeCommitFreeBlockThreshold;
4174 DWORD DeCommitTotalFreeThreshold;
4175 PVOID LockPrefixTable;
4176 DWORD MaximumAllocationSize;
4177 DWORD VirtualMemoryThreshold;
4178 DWORD ProcessHeapFlags;
4179 DWORD ProcessAffinityMask;
4180 WORD CSDVersion;
4181 WORD Reserved1;
4182 PVOID EditList;
4183 DWORD SecurityCookie;
4184 DWORD SEHandlerTable;
4185 DWORD SEHandlerCount;
4186 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
4188 #ifdef _WIN64
4189 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
4190 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
4191 #else
4192 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
4193 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
4194 #endif
4196 typedef struct _IMAGE_FUNCTION_ENTRY {
4197 DWORD StartingAddress;
4198 DWORD EndingAddress;
4199 DWORD EndOfPrologue;
4200 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
4202 #define IMAGE_DEBUG_MISC_EXENAME 1
4204 typedef struct _IMAGE_DEBUG_MISC {
4205 DWORD DataType;
4206 DWORD Length;
4207 BYTE Unicode;
4208 BYTE Reserved[ 3 ];
4209 BYTE Data[ 1 ];
4210 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
4212 /* This is the structure that appears at the very start of a .DBG file. */
4214 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
4215 WORD Signature;
4216 WORD Flags;
4217 WORD Machine;
4218 WORD Characteristics;
4219 DWORD TimeDateStamp;
4220 DWORD CheckSum;
4221 DWORD ImageBase;
4222 DWORD SizeOfImage;
4223 DWORD NumberOfSections;
4224 DWORD ExportedNamesSize;
4225 DWORD DebugDirectorySize;
4226 DWORD SectionAlignment;
4227 DWORD Reserved[ 2 ];
4228 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
4230 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
4233 typedef struct tagMESSAGE_RESOURCE_ENTRY {
4234 WORD Length;
4235 WORD Flags;
4236 BYTE Text[1];
4237 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
4238 #define MESSAGE_RESOURCE_UNICODE 0x0001
4240 typedef struct tagMESSAGE_RESOURCE_BLOCK {
4241 DWORD LowId;
4242 DWORD HighId;
4243 DWORD OffsetToEntries;
4244 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
4246 typedef struct tagMESSAGE_RESOURCE_DATA {
4247 DWORD NumberOfBlocks;
4248 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
4249 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
4252 * Here follows typedefs for security and tokens.
4256 * First a constant for the following typedefs.
4259 #define ANYSIZE_ARRAY 1
4261 /* FIXME: Orphan. What does it point to? */
4262 typedef PVOID PACCESS_TOKEN;
4263 typedef PVOID PSECURITY_DESCRIPTOR;
4264 typedef PVOID PSID;
4266 typedef enum _TOKEN_ELEVATION_TYPE {
4267 TokenElevationTypeDefault = 1,
4268 TokenElevationTypeFull,
4269 TokenElevationTypeLimited
4270 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
4273 * TOKEN_INFORMATION_CLASS
4276 typedef enum _TOKEN_INFORMATION_CLASS {
4277 TokenUser = 1,
4278 TokenGroups,
4279 TokenPrivileges,
4280 TokenOwner,
4281 TokenPrimaryGroup,
4282 TokenDefaultDacl,
4283 TokenSource,
4284 TokenType,
4285 TokenImpersonationLevel,
4286 TokenStatistics,
4287 TokenRestrictedSids,
4288 TokenSessionId,
4289 TokenGroupsAndPrivileges,
4290 TokenSessionReference,
4291 TokenSandBoxInert,
4292 TokenAuditPolicy,
4293 TokenOrigin,
4294 TokenElevationType,
4295 TokenLinkedToken,
4296 TokenElevation,
4297 TokenHasRestrictions,
4298 TokenAccessInformation,
4299 TokenVirtualizationAllowed,
4300 TokenVirtualizationEnabled,
4301 TokenIntegrityLevel,
4302 TokenUIAccess,
4303 TokenMandatoryPolicy,
4304 TokenLogonSid,
4305 TokenIsAppContainer,
4306 TokenCapabilities,
4307 TokenAppContainerSid,
4308 TokenAppContainerNumber,
4309 TokenUserClaimAttributes,
4310 TokenDeviceClaimAttributes,
4311 TokenRestrictedUserClaimAttributes,
4312 TokenRestrictedDeviceClaimAttributes,
4313 TokenDeviceGroups,
4314 TokenRestrictedDeviceGroups,
4315 TokenSecurityAttributes,
4316 TokenIsRestricted,
4317 TokenProcessTrustLevel,
4318 MaxTokenInfoClass
4319 } TOKEN_INFORMATION_CLASS;
4321 #define DISABLE_MAX_PRIVILEGE 0x1
4322 #define SANDBOX_INERT 0x2
4323 #define LUA_TOKEN 0x4
4324 #define WRITE_RESTRICTED 0x8
4326 #define TOKEN_ASSIGN_PRIMARY 0x0001
4327 #define TOKEN_DUPLICATE 0x0002
4328 #define TOKEN_IMPERSONATE 0x0004
4329 #define TOKEN_QUERY 0x0008
4330 #define TOKEN_QUERY_SOURCE 0x0010
4331 #define TOKEN_ADJUST_PRIVILEGES 0x0020
4332 #define TOKEN_ADJUST_GROUPS 0x0040
4333 #define TOKEN_ADJUST_DEFAULT 0x0080
4334 #define TOKEN_ADJUST_SESSIONID 0x0100
4335 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
4336 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
4337 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
4338 TOKEN_ADJUST_PRIVILEGES | \
4339 TOKEN_ADJUST_GROUPS | \
4340 TOKEN_ADJUST_DEFAULT )
4341 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
4342 TOKEN_ASSIGN_PRIMARY | \
4343 TOKEN_DUPLICATE | \
4344 TOKEN_IMPERSONATE | \
4345 TOKEN_QUERY | \
4346 TOKEN_QUERY_SOURCE | \
4347 TOKEN_ADJUST_PRIVILEGES | \
4348 TOKEN_ADJUST_GROUPS | \
4349 TOKEN_ADJUST_SESSIONID | \
4350 TOKEN_ADJUST_DEFAULT )
4352 #ifndef _SECURITY_DEFINED
4353 #define _SECURITY_DEFINED
4355 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
4357 typedef struct _GENERIC_MAPPING {
4358 ACCESS_MASK GenericRead;
4359 ACCESS_MASK GenericWrite;
4360 ACCESS_MASK GenericExecute;
4361 ACCESS_MASK GenericAll;
4362 } GENERIC_MAPPING, *PGENERIC_MAPPING;
4364 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
4365 #define SID_IDENTIFIER_AUTHORITY_DEFINED
4366 typedef struct {
4367 BYTE Value[6];
4368 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
4369 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
4371 #ifndef SID_DEFINED
4372 #define SID_DEFINED
4373 typedef struct _SID {
4374 BYTE Revision;
4375 BYTE SubAuthorityCount;
4376 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
4377 DWORD SubAuthority[1];
4378 } SID,*PISID;
4379 #endif /* !defined(SID_DEFINED) */
4381 #define SID_REVISION (1) /* Current revision */
4382 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
4383 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
4385 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
4388 * ACL
4391 #define ACL_REVISION1 1
4392 #define ACL_REVISION2 2
4393 #define ACL_REVISION3 3
4394 #define ACL_REVISION4 4
4396 #define MIN_ACL_REVISION ACL_REVISION2
4397 #define MAX_ACL_REVISION ACL_REVISION4
4399 #define ACL_REVISION 2
4401 typedef struct _ACL {
4402 BYTE AclRevision;
4403 BYTE Sbz1;
4404 WORD AclSize;
4405 WORD AceCount;
4406 WORD Sbz2;
4407 } ACL, *PACL;
4409 typedef enum _ACL_INFORMATION_CLASS
4411 AclRevisionInformation = 1,
4412 AclSizeInformation
4413 } ACL_INFORMATION_CLASS;
4415 typedef struct _ACL_REVISION_INFORMATION
4417 DWORD AclRevision;
4418 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
4420 typedef struct _ACL_SIZE_INFORMATION
4422 DWORD AceCount;
4423 DWORD AclBytesInUse;
4424 DWORD AclBytesFree;
4425 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
4427 /* SECURITY_DESCRIPTOR */
4428 #define SECURITY_DESCRIPTOR_REVISION 1
4429 #define SECURITY_DESCRIPTOR_REVISION1 1
4433 * Privilege Names
4435 #ifdef UNICODE
4436 #if defined(_MSC_VER) || defined(__MINGW32__)
4437 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4438 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4439 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4440 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4441 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4442 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4443 #define SE_TCB_NAME L"SeTcbPrivilege"
4444 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4445 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4446 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4447 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4448 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4449 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4450 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4451 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4452 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4453 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4454 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4455 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4456 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4457 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4458 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4459 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4460 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4461 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4462 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4463 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4464 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4465 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4466 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4467 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4468 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4469 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4470 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4471 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4472 #else /* _MSC_VER/__MINGW32__ */
4473 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 };
4474 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 };
4475 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 };
4476 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 };
4477 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 };
4478 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 };
4479 static const WCHAR SE_TCB_NAME[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4480 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 };
4481 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 };
4482 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 };
4483 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 };
4484 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 };
4485 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 };
4486 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 };
4487 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 };
4488 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 };
4489 static const WCHAR SE_BACKUP_NAME[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4490 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 };
4491 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 };
4492 static const WCHAR SE_DEBUG_NAME[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4493 static const WCHAR SE_AUDIT_NAME[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4494 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 };
4495 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 };
4496 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 };
4497 static const WCHAR SE_UNDOCK_NAME[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4498 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 };
4499 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 };
4500 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 };
4501 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 };
4502 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 };
4503 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 };
4504 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 };
4505 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 };
4506 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 };
4507 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 };
4508 #endif
4509 #else /* UNICODE */
4510 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4511 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4512 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4513 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4514 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4515 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4516 #define SE_TCB_NAME "SeTcbPrivilege"
4517 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4518 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4519 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4520 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4521 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4522 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4523 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4524 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4525 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4526 #define SE_BACKUP_NAME "SeBackupPrivilege"
4527 #define SE_RESTORE_NAME "SeRestorePrivilege"
4528 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4529 #define SE_DEBUG_NAME "SeDebugPrivilege"
4530 #define SE_AUDIT_NAME "SeAuditPrivilege"
4531 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4532 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4533 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4534 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4535 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4536 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4537 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4538 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4539 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4540 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4541 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4542 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4543 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4544 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4545 #endif
4547 #define SE_GROUP_MANDATORY 0x00000001
4548 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4549 #define SE_GROUP_ENABLED 0x00000004
4550 #define SE_GROUP_OWNER 0x00000008
4551 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4552 #define SE_GROUP_INTEGRITY 0x00000020
4553 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4554 #define SE_GROUP_LOGON_ID 0xC0000000
4555 #define SE_GROUP_RESOURCE 0x20000000
4556 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4558 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4559 #define SE_PRIVILEGE_ENABLED 0x00000002
4560 #define SE_PRIVILEGE_REMOVED 0x00000004
4561 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4562 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4564 #define PRIVILEGE_SET_ALL_NECESSARY 1
4566 #define SE_OWNER_DEFAULTED 0x00000001
4567 #define SE_GROUP_DEFAULTED 0x00000002
4568 #define SE_DACL_PRESENT 0x00000004
4569 #define SE_DACL_DEFAULTED 0x00000008
4570 #define SE_SACL_PRESENT 0x00000010
4571 #define SE_SACL_DEFAULTED 0x00000020
4572 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4573 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4574 #define SE_DACL_AUTO_INHERITED 0x00000400
4575 #define SE_SACL_AUTO_INHERITED 0x00000800
4576 #define SE_DACL_PROTECTED 0x00001000
4577 #define SE_SACL_PROTECTED 0x00002000
4578 #define SE_RM_CONTROL_VALID 0x00004000
4579 #define SE_SELF_RELATIVE 0x00008000
4581 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4582 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4584 /* The security descriptor structure */
4585 typedef struct {
4586 BYTE Revision;
4587 BYTE Sbz1;
4588 SECURITY_DESCRIPTOR_CONTROL Control;
4589 DWORD Owner;
4590 DWORD Group;
4591 DWORD Sacl;
4592 DWORD Dacl;
4593 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4595 typedef struct {
4596 BYTE Revision;
4597 BYTE Sbz1;
4598 SECURITY_DESCRIPTOR_CONTROL Control;
4599 PSID Owner;
4600 PSID Group;
4601 PACL Sacl;
4602 PACL Dacl;
4603 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4605 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4607 #endif /* _SECURITY_DEFINED */
4610 * SID_AND_ATTRIBUTES
4613 typedef struct _SID_AND_ATTRIBUTES {
4614 PSID Sid;
4615 DWORD Attributes;
4616 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4618 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
4619 typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
4621 #define SID_HASH_SIZE 32
4623 typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
4625 typedef struct _SID_AND_ATTRIBUTES_HASH {
4626 DWORD SidCount;
4627 PSID_AND_ATTRIBUTES SidAttr;
4628 SID_HASH_ENTRY Hash[SID_HASH_SIZE];
4629 } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
4631 /* security entities */
4632 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4633 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4634 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4636 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4638 /* S-1-1 */
4639 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4641 /* S-1-2 */
4642 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4643 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4645 /* S-1-3 */
4646 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4647 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4648 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4649 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4650 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4651 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4653 /* S-1-4 */
4654 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4656 /* S-1-5 */
4657 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4658 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4659 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4660 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4661 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4662 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4663 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4664 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4665 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4666 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4667 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4668 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4669 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4670 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4671 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4672 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4673 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4674 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4675 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4676 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4677 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4678 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4679 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4680 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4682 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4683 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4684 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4685 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4686 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4687 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4688 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4689 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4690 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4691 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4692 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4693 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4694 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4695 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4696 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4697 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4698 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4699 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4700 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4701 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4702 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4703 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4705 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4707 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4708 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4709 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4710 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4711 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4713 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4714 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4715 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4716 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4717 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4718 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4719 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4720 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4721 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4722 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4724 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4726 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4727 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4728 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4729 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4730 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4731 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4732 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4733 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4734 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4735 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4736 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4738 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4739 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4740 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4741 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4742 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4743 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4744 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4745 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4746 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4748 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4750 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4751 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4752 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4753 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4755 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4756 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4757 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4758 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4760 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4761 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4762 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4763 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4764 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4765 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4767 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4768 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4769 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4770 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4771 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4772 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4773 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4774 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4775 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4776 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4777 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4779 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4781 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4782 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4783 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4784 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4785 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4786 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4787 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4788 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4789 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4790 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4791 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4793 #define SYSTEM_LUID { 0x3e7, 0x0 }
4794 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4795 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4796 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4797 #define IUSER_LUID { 0x3e3, 0x0 }
4799 typedef enum {
4800 WinNullSid = 0,
4801 WinWorldSid = 1,
4802 WinLocalSid = 2,
4803 WinCreatorOwnerSid = 3,
4804 WinCreatorGroupSid = 4,
4805 WinCreatorOwnerServerSid = 5,
4806 WinCreatorGroupServerSid = 6,
4807 WinNtAuthoritySid = 7,
4808 WinDialupSid = 8,
4809 WinNetworkSid = 9,
4810 WinBatchSid = 10,
4811 WinInteractiveSid = 11,
4812 WinServiceSid = 12,
4813 WinAnonymousSid = 13,
4814 WinProxySid = 14,
4815 WinEnterpriseControllersSid = 15,
4816 WinSelfSid = 16,
4817 WinAuthenticatedUserSid = 17,
4818 WinRestrictedCodeSid = 18,
4819 WinTerminalServerSid = 19,
4820 WinRemoteLogonIdSid = 20,
4821 WinLogonIdsSid = 21,
4822 WinLocalSystemSid = 22,
4823 WinLocalServiceSid = 23,
4824 WinNetworkServiceSid = 24,
4825 WinBuiltinDomainSid = 25,
4826 WinBuiltinAdministratorsSid = 26,
4827 WinBuiltinUsersSid = 27,
4828 WinBuiltinGuestsSid = 28,
4829 WinBuiltinPowerUsersSid = 29,
4830 WinBuiltinAccountOperatorsSid = 30,
4831 WinBuiltinSystemOperatorsSid = 31,
4832 WinBuiltinPrintOperatorsSid = 32,
4833 WinBuiltinBackupOperatorsSid = 33,
4834 WinBuiltinReplicatorSid = 34,
4835 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4836 WinBuiltinRemoteDesktopUsersSid = 36,
4837 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4838 WinAccountAdministratorSid = 38,
4839 WinAccountGuestSid = 39,
4840 WinAccountKrbtgtSid = 40,
4841 WinAccountDomainAdminsSid = 41,
4842 WinAccountDomainUsersSid = 42,
4843 WinAccountDomainGuestsSid = 43,
4844 WinAccountComputersSid = 44,
4845 WinAccountControllersSid = 45,
4846 WinAccountCertAdminsSid = 46,
4847 WinAccountSchemaAdminsSid = 47,
4848 WinAccountEnterpriseAdminsSid = 48,
4849 WinAccountPolicyAdminsSid = 49,
4850 WinAccountRasAndIasServersSid = 50,
4851 WinNTLMAuthenticationSid = 51,
4852 WinDigestAuthenticationSid = 52,
4853 WinSChannelAuthenticationSid = 53,
4854 WinThisOrganizationSid = 54,
4855 WinOtherOrganizationSid = 55,
4856 WinBuiltinIncomingForestTrustBuildersSid = 56,
4857 WinBuiltinPerfMonitoringUsersSid = 57,
4858 WinBuiltinPerfLoggingUsersSid = 58,
4859 WinBuiltinAuthorizationAccessSid = 59,
4860 WinBuiltinTerminalServerLicenseServersSid = 60,
4861 WinBuiltinDCOMUsersSid = 61,
4862 WinBuiltinIUsersSid = 62,
4863 WinIUserSid = 63,
4864 WinBuiltinCryptoOperatorsSid = 64,
4865 WinUntrustedLabelSid = 65,
4866 WinLowLabelSid = 66,
4867 WinMediumLabelSid = 67,
4868 WinHighLabelSid = 68,
4869 WinSystemLabelSid = 69,
4870 WinWriteRestrictedCodeSid = 70,
4871 WinCreatorOwnerRightsSid = 71,
4872 WinCacheablePrincipalsGroupSid = 72,
4873 WinNonCacheablePrincipalsGroupSid = 73,
4874 WinEnterpriseReadonlyControllersSid = 74,
4875 WinAccountReadonlyControllersSid = 75,
4876 WinBuiltinEventLogReadersGroup = 76,
4877 WinNewEnterpriseReadonlyControllersSid = 77,
4878 WinBuiltinCertSvcDComAccessGroup = 78,
4879 WinMediumPlusLabelSid = 79,
4880 WinLocalLogonSid = 80,
4881 WinConsoleLogonSid = 81,
4882 WinThisOrganizationCertificateSid = 82,
4883 WinApplicationPackageAuthoritySid = 83,
4884 WinBuiltinAnyPackageSid = 84,
4885 WinCapabilityInternetClientSid = 85,
4886 WinCapabilityInternetClientServerSid = 86,
4887 WinCapabilityPrivateNetworkClientServerSid = 87,
4888 WinCapabilityPicturesLibrarySid = 88,
4889 WinCapabilityVideosLibrarySid = 89,
4890 WinCapabilityMusicLibrarySid = 90,
4891 WinCapabilityDocumentsLibrarySid = 91,
4892 WinCapabilitySharedUserCertificatesSid = 92,
4893 WinCapabilityEnterpriseAuthenticationSid = 93,
4894 WinCapabilityRemovableStorageSid = 94,
4895 WinBuiltinRDSRemoteAccessServersSid = 95,
4896 WinBuiltinRDSEndpointServersSid = 96,
4897 WinBuiltinRDSManagementServersSid = 97,
4898 WinUserModeDriversSid = 98,
4899 WinBuiltinHyperVAdminsSid = 99,
4900 WinAccountCloneableControllersSid = 100,
4901 WinBuiltinAccessControlAssistanceOperatorsSid = 101,
4902 WinBuiltinRemoteManagementUsersSid = 102,
4903 WinAuthenticationAuthorityAssertedSid = 103,
4904 WinAuthenticationServiceAssertedSid = 104,
4905 WinLocalAccountSid = 105,
4906 WinLocalAccountAndAdministratorSid = 106,
4907 WinAccountProtectedUsersSid = 107,
4908 } WELL_KNOWN_SID_TYPE;
4911 * TOKEN_USER
4914 typedef struct _TOKEN_USER {
4915 SID_AND_ATTRIBUTES User;
4916 } TOKEN_USER, *PTOKEN_USER;
4919 * TOKEN_GROUPS
4922 typedef struct _TOKEN_GROUPS {
4923 DWORD GroupCount;
4924 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4925 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4928 * LUID_AND_ATTRIBUTES
4931 typedef union _LARGE_INTEGER {
4932 struct {
4933 #ifdef WORDS_BIGENDIAN
4934 LONG HighPart;
4935 DWORD LowPart;
4936 #else
4937 DWORD LowPart;
4938 LONG HighPart;
4939 #endif
4940 } u;
4941 #ifndef NONAMELESSSTRUCT
4942 struct {
4943 #ifdef WORDS_BIGENDIAN
4944 LONG HighPart;
4945 DWORD LowPart;
4946 #else
4947 DWORD LowPart;
4948 LONG HighPart;
4949 #endif
4951 #endif
4952 LONGLONG QuadPart;
4953 } LARGE_INTEGER, *PLARGE_INTEGER;
4955 typedef union _ULARGE_INTEGER {
4956 struct {
4957 #ifdef WORDS_BIGENDIAN
4958 DWORD HighPart;
4959 DWORD LowPart;
4960 #else
4961 DWORD LowPart;
4962 DWORD HighPart;
4963 #endif
4964 } u;
4965 #ifndef NONAMELESSSTRUCT
4966 struct {
4967 #ifdef WORDS_BIGENDIAN
4968 DWORD HighPart;
4969 DWORD LowPart;
4970 #else
4971 DWORD LowPart;
4972 DWORD HighPart;
4973 #endif
4975 #endif
4976 ULONGLONG QuadPart;
4977 } ULARGE_INTEGER, *PULARGE_INTEGER;
4980 * Locally Unique Identifier
4983 typedef struct _LUID {
4984 DWORD LowPart;
4985 LONG HighPart;
4986 } LUID, *PLUID;
4988 #include <pshpack4.h>
4989 typedef struct _LUID_AND_ATTRIBUTES {
4990 LUID Luid;
4991 DWORD Attributes;
4992 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4993 #include <poppack.h>
4996 * PRIVILEGE_SET
4999 typedef struct _PRIVILEGE_SET {
5000 DWORD PrivilegeCount;
5001 DWORD Control;
5002 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
5003 } PRIVILEGE_SET, *PPRIVILEGE_SET;
5006 * TOKEN_PRIVILEGES
5009 typedef struct _TOKEN_PRIVILEGES {
5010 DWORD PrivilegeCount;
5011 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
5012 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
5015 * TOKEN_OWNER
5018 typedef struct _TOKEN_OWNER {
5019 PSID Owner;
5020 } TOKEN_OWNER, *PTOKEN_OWNER;
5023 * TOKEN_PRIMARY_GROUP
5026 typedef struct _TOKEN_PRIMARY_GROUP {
5027 PSID PrimaryGroup;
5028 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
5032 * TOKEN_DEFAULT_DACL
5035 typedef struct _TOKEN_DEFAULT_DACL {
5036 PACL DefaultDacl;
5037 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
5040 * TOKEN_SOURCE
5043 #define TOKEN_SOURCE_LENGTH 8
5045 typedef struct _TOKEN_SOURCE {
5046 char SourceName[TOKEN_SOURCE_LENGTH];
5047 LUID SourceIdentifier;
5048 } TOKEN_SOURCE, *PTOKEN_SOURCE;
5051 * TOKEN_TYPE
5054 typedef enum tagTOKEN_TYPE {
5055 TokenPrimary = 1,
5056 TokenImpersonation
5057 } TOKEN_TYPE;
5060 * SECURITY_IMPERSONATION_LEVEL
5063 typedef enum _SECURITY_IMPERSONATION_LEVEL {
5064 SecurityAnonymous,
5065 SecurityIdentification,
5066 SecurityImpersonation,
5067 SecurityDelegation
5068 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
5070 #define SECURITY_DYNAMIC_TRACKING (TRUE)
5071 #define SECURITY_STATIC_TRACKING (FALSE)
5073 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
5074 * PSECURITY_CONTEXT_TRACKING_MODE;
5076 * Quality of Service
5079 typedef struct _SECURITY_QUALITY_OF_SERVICE {
5080 DWORD Length;
5081 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
5082 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
5083 BOOLEAN EffectiveOnly;
5084 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
5087 * TOKEN_STATISTICS
5090 #include <pshpack4.h>
5091 typedef struct _TOKEN_STATISTICS {
5092 LUID TokenId;
5093 LUID AuthenticationId;
5094 LARGE_INTEGER ExpirationTime;
5095 TOKEN_TYPE TokenType;
5096 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
5097 DWORD DynamicCharged;
5098 DWORD DynamicAvailable;
5099 DWORD GroupCount;
5100 DWORD PrivilegeCount;
5101 LUID ModifiedId;
5102 } TOKEN_STATISTICS;
5103 #include <poppack.h>
5105 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
5106 DWORD SidCount;
5107 DWORD SidLength;
5108 PSID_AND_ATTRIBUTES Sids;
5109 DWORD RestrictedSidCount;
5110 DWORD RestrictedSidLength;
5111 PSID_AND_ATTRIBUTES RestrictedSids;
5112 DWORD PrivilegeCount;
5113 DWORD PrivilegeLength;
5114 PLUID_AND_ATTRIBUTES Privileges;
5115 LUID AuthenticationId;
5116 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
5118 typedef struct _TOKEN_ORIGIN {
5119 LUID OriginatingLogonSession;
5120 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
5122 typedef struct _TOKEN_LINKED_TOKEN {
5123 HANDLE LinkedToken;
5124 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
5126 typedef struct _TOKEN_ELEVATION {
5127 DWORD TokenIsElevated;
5128 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
5130 typedef struct _TOKEN_MANDATORY_LABEL {
5131 SID_AND_ATTRIBUTES Label;
5132 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
5134 #define TOKEN_MANDATORY_POLICY_OFF 0x0
5135 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
5136 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
5137 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
5139 typedef struct _TOKEN_MANDATORY_POLICY {
5140 DWORD Policy;
5141 } TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY;
5143 typedef struct _TOKEN_APPCONTAINER_INFORMATION {
5144 PSID TokenAppContainer;
5145 } TOKEN_APPCONTAINER_INFORMATION, * PTOKEN_APPCONTAINER_INFORMATION;
5147 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
5149 typedef struct _TOKEN_AUDIT_POLICY {
5150 BYTE PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
5151 } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
5153 typedef struct _TOKEN_ACCESS_INFORMATION {
5154 PSID_AND_ATTRIBUTES_HASH SidHash;
5155 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
5156 PTOKEN_PRIVILEGES Privileges;
5157 LUID AuthenticationId;
5158 TOKEN_TYPE TokenType;
5159 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
5160 TOKEN_MANDATORY_POLICY MandatoryPolicy;
5161 DWORD Flags;
5162 } TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION;
5164 typedef struct _TOKEN_CONTROL {
5165 LUID TokenId;
5166 LUID AuthenticationId;
5167 LUID ModifiedId;
5168 TOKEN_SOURCE TokenSource;
5169 } TOKEN_CONTROL, *PTOKEN_CONTROL;
5172 * ACLs of NT
5175 /* ACEs, directly starting after an ACL */
5176 typedef struct _ACE_HEADER {
5177 BYTE AceType;
5178 BYTE AceFlags;
5179 WORD AceSize;
5180 } ACE_HEADER,*PACE_HEADER;
5182 /* AceType */
5183 #define ACCESS_MIN_MS_ACE_TYPE 0x0
5184 #define ACCESS_ALLOWED_ACE_TYPE 0x0
5185 #define ACCESS_DENIED_ACE_TYPE 0x1
5186 #define SYSTEM_AUDIT_ACE_TYPE 0x2
5187 #define SYSTEM_ALARM_ACE_TYPE 0x3
5188 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
5189 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
5190 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
5191 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
5192 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
5193 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
5194 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
5195 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
5196 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
5197 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
5198 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
5199 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
5200 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
5201 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
5202 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
5203 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
5204 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
5205 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
5206 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
5207 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
5208 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
5209 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
5211 /* inherit AceFlags */
5212 #define OBJECT_INHERIT_ACE 0x01
5213 #define CONTAINER_INHERIT_ACE 0x02
5214 #define NO_PROPAGATE_INHERIT_ACE 0x04
5215 #define INHERIT_ONLY_ACE 0x08
5216 #define INHERITED_ACE 0x10
5217 #define VALID_INHERIT_FLAGS 0x1F
5219 /* AceFlags mask for what events we (should) audit */
5220 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
5221 #define FAILED_ACCESS_ACE_FLAG 0x80
5223 /* different ACEs depending on AceType
5224 * SidStart marks the begin of a SID
5225 * so the thing finally looks like this:
5226 * 0: ACE_HEADER
5227 * 4: ACCESS_MASK
5228 * 8... : SID
5230 typedef struct _ACCESS_ALLOWED_ACE {
5231 ACE_HEADER Header;
5232 DWORD Mask;
5233 DWORD SidStart;
5234 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
5236 typedef struct _ACCESS_DENIED_ACE {
5237 ACE_HEADER Header;
5238 DWORD Mask;
5239 DWORD SidStart;
5240 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
5242 typedef struct _SYSTEM_AUDIT_ACE {
5243 ACE_HEADER Header;
5244 DWORD Mask;
5245 DWORD SidStart;
5246 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
5248 typedef struct _SYSTEM_ALARM_ACE {
5249 ACE_HEADER Header;
5250 DWORD Mask;
5251 DWORD SidStart;
5252 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
5254 typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
5255 ACE_HEADER Header;
5256 ACCESS_MASK Mask;
5257 DWORD SidStart;
5258 } SYSTEM_MANDATORY_LABEL_ACE,*PSYSTEM_MANDATORY_LABEL_ACE;
5260 typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
5261 ACE_HEADER Header;
5262 ACCESS_MASK Mask;
5263 DWORD Flags;
5264 GUID ObjectType;
5265 GUID InheritedObjectType;
5266 DWORD SidStart;
5267 } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
5269 typedef struct _ACCESS_DENIED_OBJECT_ACE {
5270 ACE_HEADER Header;
5271 ACCESS_MASK Mask;
5272 DWORD Flags;
5273 GUID ObjectType;
5274 GUID InheritedObjectType;
5275 DWORD SidStart;
5276 } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
5278 typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
5279 ACE_HEADER Header;
5280 ACCESS_MASK Mask;
5281 DWORD Flags;
5282 GUID ObjectType;
5283 GUID InheritedObjectType;
5284 DWORD SidStart;
5285 } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
5287 typedef struct _SYSTEM_ALARM_OBJECT_ACE {
5288 ACE_HEADER Header;
5289 ACCESS_MASK Mask;
5290 DWORD Flags;
5291 GUID ObjectType;
5292 GUID InheritedObjectType;
5293 DWORD SidStart;
5294 } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_aCE;
5296 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
5297 ACE_HEADER Header;
5298 DWORD Mask;
5299 DWORD SidStart;
5300 } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
5302 typedef struct _ACCESS_DENIED_CALLBACK_ACE {
5303 ACE_HEADER Header;
5304 DWORD Mask;
5305 DWORD SidStart;
5306 } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
5308 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
5309 ACE_HEADER Header;
5310 DWORD Mask;
5311 DWORD SidStart;
5312 } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
5314 typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
5315 ACE_HEADER Header;
5316 DWORD Mask;
5317 DWORD SidStart;
5318 } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
5320 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
5321 ACE_HEADER Header;
5322 ACCESS_MASK Mask;
5323 DWORD Flags;
5324 GUID ObjectType;
5325 GUID InheritedObjectType;
5326 DWORD SidStart;
5327 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
5329 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
5330 ACE_HEADER Header;
5331 ACCESS_MASK Mask;
5332 DWORD Flags;
5333 GUID ObjectType;
5334 GUID InheritedObjectType;
5335 DWORD SidStart;
5336 } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
5338 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
5339 ACE_HEADER Header;
5340 ACCESS_MASK Mask;
5341 DWORD Flags;
5342 GUID ObjectType;
5343 GUID InheritedObjectType;
5344 DWORD SidStart;
5345 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
5347 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
5348 ACE_HEADER Header;
5349 ACCESS_MASK Mask;
5350 DWORD Flags;
5351 GUID ObjectType;
5352 GUID InheritedObjectType;
5353 DWORD SidStart;
5354 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
5356 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
5357 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
5358 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
5359 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
5361 typedef enum tagSID_NAME_USE {
5362 SidTypeUser = 1,
5363 SidTypeGroup,
5364 SidTypeDomain,
5365 SidTypeAlias,
5366 SidTypeWellKnownGroup,
5367 SidTypeDeletedAccount,
5368 SidTypeInvalid,
5369 SidTypeUnknown
5370 } SID_NAME_USE,*PSID_NAME_USE;
5372 #define ACE_OBJECT_TYPE_PRESENT 0x1
5373 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
5375 /* Access rights */
5377 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
5378 #undef DELETE
5379 #define DELETE 0x00010000
5380 #define READ_CONTROL 0x00020000
5381 #define WRITE_DAC 0x00040000
5382 #define WRITE_OWNER 0x00080000
5383 #define SYNCHRONIZE 0x00100000
5384 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
5386 #define STANDARD_RIGHTS_READ READ_CONTROL
5387 #define STANDARD_RIGHTS_WRITE READ_CONTROL
5388 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
5390 #define STANDARD_RIGHTS_ALL 0x001f0000
5392 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
5394 #define GENERIC_READ 0x80000000
5395 #define GENERIC_WRITE 0x40000000
5396 #define GENERIC_EXECUTE 0x20000000
5397 #define GENERIC_ALL 0x10000000
5399 #define MAXIMUM_ALLOWED 0x02000000
5400 #define ACCESS_SYSTEM_SECURITY 0x01000000
5402 #define EVENT_QUERY_STATE 0x0001
5403 #define EVENT_MODIFY_STATE 0x0002
5404 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5406 #define SEMAPHORE_QUERY_STATE 0x0001
5407 #define SEMAPHORE_MODIFY_STATE 0x0002
5408 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5410 #define MUTANT_QUERY_STATE 0x0001
5411 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5413 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5414 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5415 #define JOB_OBJECT_QUERY 0x0004
5416 #define JOB_OBJECT_TERMINATE 0x0008
5417 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5418 #define JOB_OBJECT_IMPERSONATE 0x0020
5419 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3f)
5421 #define TIMER_QUERY_STATE 0x0001
5422 #define TIMER_MODIFY_STATE 0x0002
5423 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5425 #define PROCESS_TERMINATE 0x0001
5426 #define PROCESS_CREATE_THREAD 0x0002
5427 #define PROCESS_VM_OPERATION 0x0008
5428 #define PROCESS_VM_READ 0x0010
5429 #define PROCESS_VM_WRITE 0x0020
5430 #define PROCESS_DUP_HANDLE 0x0040
5431 #define PROCESS_CREATE_PROCESS 0x0080
5432 #define PROCESS_SET_QUOTA 0x0100
5433 #define PROCESS_SET_INFORMATION 0x0200
5434 #define PROCESS_QUERY_INFORMATION 0x0400
5435 #define PROCESS_SUSPEND_RESUME 0x0800
5436 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5437 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5438 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5440 #define THREAD_TERMINATE 0x0001
5441 #define THREAD_SUSPEND_RESUME 0x0002
5442 #define THREAD_GET_CONTEXT 0x0008
5443 #define THREAD_SET_CONTEXT 0x0010
5444 #define THREAD_SET_INFORMATION 0x0020
5445 #define THREAD_QUERY_INFORMATION 0x0040
5446 #define THREAD_SET_THREAD_TOKEN 0x0080
5447 #define THREAD_IMPERSONATE 0x0100
5448 #define THREAD_DIRECT_IMPERSONATION 0x0200
5449 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5450 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5451 #define THREAD_RESUME 0x1000
5452 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5454 #define THREAD_BASE_PRIORITY_LOWRT 15
5455 #define THREAD_BASE_PRIORITY_MAX 2
5456 #define THREAD_BASE_PRIORITY_MIN -2
5457 #define THREAD_BASE_PRIORITY_IDLE -15
5459 typedef struct _QUOTA_LIMITS {
5460 SIZE_T PagedPoolLimit;
5461 SIZE_T NonPagedPoolLimit;
5462 SIZE_T MinimumWorkingSetSize;
5463 SIZE_T MaximumWorkingSetSize;
5464 SIZE_T PagefileLimit;
5465 LARGE_INTEGER TimeLimit;
5466 } QUOTA_LIMITS, *PQUOTA_LIMITS;
5468 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5469 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5470 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5471 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5472 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5474 typedef union _RATE_QUOTA_LIMIT {
5475 DWORD RateData;
5476 struct {
5477 DWORD RatePercent:7;
5478 DWORD Reserved0:25;
5479 } DUMMYSTRUCTNAME;
5480 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
5482 typedef struct _QUOTA_LIMITS_EX {
5483 SIZE_T PagedPoolLimit;
5484 SIZE_T NonPagedPoolLimit;
5485 SIZE_T MinimumWorkingSetSize;
5486 SIZE_T MaximumWorkingSetSize;
5487 SIZE_T PagefileLimit;
5488 LARGE_INTEGER TimeLimit;
5489 SIZE_T WorkingSetLimit;
5490 SIZE_T Reserved2;
5491 SIZE_T Reserved3;
5492 SIZE_T Reserved4;
5493 DWORD Flags;
5494 RATE_QUOTA_LIMIT CpuRateLimit;
5495 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
5497 #define SECTION_QUERY 0x0001
5498 #define SECTION_MAP_WRITE 0x0002
5499 #define SECTION_MAP_READ 0x0004
5500 #define SECTION_MAP_EXECUTE 0x0008
5501 #define SECTION_EXTEND_SIZE 0x0010
5502 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5503 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5505 #define FILE_READ_DATA 0x0001 /* file & pipe */
5506 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5507 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5508 #define FILE_ADD_FILE 0x0002 /* directory */
5509 #define FILE_APPEND_DATA 0x0004 /* file */
5510 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5511 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5512 #define FILE_READ_EA 0x0008 /* file & directory */
5513 #define FILE_READ_PROPERTIES FILE_READ_EA
5514 #define FILE_WRITE_EA 0x0010 /* file & directory */
5515 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5516 #define FILE_EXECUTE 0x0020 /* file */
5517 #define FILE_TRAVERSE 0x0020 /* directory */
5518 #define FILE_DELETE_CHILD 0x0040 /* directory */
5519 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5520 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5521 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5523 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5524 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5525 SYNCHRONIZE)
5526 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5527 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5528 FILE_APPEND_DATA | SYNCHRONIZE)
5529 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5530 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5532 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5533 #define DUPLICATE_SAME_ACCESS 0x00000002
5534 #ifdef __WINESRC__
5535 #define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
5536 #endif
5538 /* File attribute flags */
5539 #define FILE_SHARE_READ 0x00000001
5540 #define FILE_SHARE_WRITE 0x00000002
5541 #define FILE_SHARE_DELETE 0x00000004
5543 #define FILE_ATTRIBUTE_READONLY 0x00000001
5544 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5545 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5546 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5547 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5548 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5549 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5550 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5551 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5552 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5553 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5554 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5555 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5556 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5557 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5558 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5559 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5560 #define FILE_ATTRIBUTE_EA 0x00040000
5562 /* File notification flags */
5563 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5564 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5565 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5566 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5567 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5568 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5569 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5570 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5571 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5572 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5573 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5574 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5575 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5577 #define FILE_ACTION_ADDED 0x00000001
5578 #define FILE_ACTION_REMOVED 0x00000002
5579 #define FILE_ACTION_MODIFIED 0x00000003
5580 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5581 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5582 #define FILE_ACTION_ADDED_STREAM 0x00000006
5583 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5584 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5585 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5586 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5587 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5589 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5590 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5591 #define FILE_UNICODE_ON_DISK 0x00000004
5592 #define FILE_PERSISTENT_ACLS 0x00000008
5593 #define FILE_FILE_COMPRESSION 0x00000010
5594 #define FILE_VOLUME_QUOTAS 0x00000020
5595 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5596 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5597 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5598 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5599 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5600 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5601 #define FILE_NAMED_STREAMS 0x00040000
5602 #define FILE_READ_ONLY_VOLUME 0x00080000
5603 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5604 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5605 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5606 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5607 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5608 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5609 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5610 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5611 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5612 #define FILE_DAX_VOLUME 0x20000000
5613 #define FILE_SUPPORTS_GHOSTING 0x40000000
5615 /* File alignments (NT) */
5616 #define FILE_BYTE_ALIGNMENT 0x00000000
5617 #define FILE_WORD_ALIGNMENT 0x00000001
5618 #define FILE_LONG_ALIGNMENT 0x00000003
5619 #define FILE_QUAD_ALIGNMENT 0x00000007
5620 #define FILE_OCTA_ALIGNMENT 0x0000000f
5621 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5622 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5623 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5624 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5625 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5627 #define COMPRESSION_FORMAT_NONE 0
5628 #define COMPRESSION_FORMAT_DEFAULT 1
5629 #define COMPRESSION_FORMAT_LZNT1 2
5630 #define COMPRESSION_ENGINE_STANDARD 0
5631 #define COMPRESSION_ENGINE_MAXIMUM 256
5633 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5634 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5636 #define REG_NONE 0 /* no type */
5637 #define REG_SZ 1 /* string type (ASCII) */
5638 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5639 #define REG_BINARY 3 /* binary format, callerspecific */
5640 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5641 #define REG_DWORD 4 /* DWORD in little endian format */
5642 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5643 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5644 #define REG_LINK 6 /* symbolic link (UNICODE) */
5645 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5646 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5647 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5648 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5649 #define REG_QWORD 11 /* QWORD in little endian format */
5650 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5652 /* ----------------------------- begin power management --------------------- */
5654 typedef enum _LATENCY_TIME {
5655 LT_DONT_CARE,
5656 LT_LOWEST_LATENCY
5657 } LATENCY_TIME, *PLATENCY_TIME;
5659 #define DISCHARGE_POLICY_CRITICAL 0
5660 #define DISCHARGE_POLICY_LOW 1
5661 #define NUM_DISCHARGE_POLICIES 4
5663 #define PO_THROTTLE_NONE 0
5664 #define PO_THROTTLE_CONSTANT 1
5665 #define PO_THROTTLE_DEGRADE 2
5666 #define PO_THROTTLE_ADAPTIVE 3
5668 typedef enum _POWER_ACTION {
5669 PowerActionNone = 0,
5670 PowerActionReserved,
5671 PowerActionSleep,
5672 PowerActionHibernate,
5673 PowerActionShutdown,
5674 PowerActionShutdownReset,
5675 PowerActionShutdownOff,
5676 PowerActionWarmEject
5677 } POWER_ACTION,
5678 *PPOWER_ACTION;
5680 typedef enum _POWER_PLATFORM_ROLE {
5681 PlatformRoleUnspecified,
5682 PlatformRoleDesktop,
5683 PlatformRoleMobile,
5684 PlatformRoleWorkstation,
5685 PlatformRoleEnterpriseServer,
5686 PlatformRoleSOHOServer,
5687 PlatformRoleAppliancePC,
5688 PlatformRolePerformanceServer,
5689 PlatformRoleSlate,
5690 PlatformRoleMaximum
5691 } POWER_PLATFORM_ROLE, *PPOWER_PLATFORM_ROLE;
5693 typedef enum _SYSTEM_POWER_STATE {
5694 PowerSystemUnspecified = 0,
5695 PowerSystemWorking = 1,
5696 PowerSystemSleeping1 = 2,
5697 PowerSystemSleeping2 = 3,
5698 PowerSystemSleeping3 = 4,
5699 PowerSystemHibernate = 5,
5700 PowerSystemShutdown = 6,
5701 PowerSystemMaximum = 7
5702 } SYSTEM_POWER_STATE,
5703 *PSYSTEM_POWER_STATE;
5705 typedef enum _DEVICE_POWER_STATE {
5706 PowerDeviceUnspecified,
5707 PowerDeviceD0,
5708 PowerDeviceD1,
5709 PowerDeviceD2,
5710 PowerDeviceD3,
5711 PowerDeviceMaximum
5712 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
5714 typedef enum _POWER_INFORMATION_LEVEL {
5715 SystemPowerPolicyAc,
5716 SystemPowerPolicyDc,
5717 VerifySystemPolicyAc,
5718 VerifySystemPolicyDc,
5719 SystemPowerCapabilities,
5720 SystemBatteryState,
5721 SystemPowerStateHandler,
5722 ProcessorStateHandler,
5723 SystemPowerPolicyCurrent,
5724 AdministratorPowerPolicy,
5725 SystemReserveHiberFile,
5726 ProcessorInformation,
5727 SystemPowerInformation,
5728 ProcessorStateHandler2,
5729 LastWakeTime,
5730 LastSleepTime,
5731 SystemExecutionState,
5732 SystemPowerStateNotifyHandler,
5733 ProcessorPowerPolicyAc,
5734 ProcessorPowerPolicyDc,
5735 VerifyProcessorPowerPolicyAc,
5736 VerifyProcessorPowerPolicyDc,
5737 ProcessorPowerPolicyCurrent
5738 } POWER_INFORMATION_LEVEL;
5740 typedef struct _ADMINISTRATOR_POWER_POLICY {
5741 SYSTEM_POWER_STATE MinSleep;
5742 SYSTEM_POWER_STATE MaxSleep;
5743 ULONG MinVideoTimeout;
5744 ULONG MaxVideoTimeout;
5745 ULONG MinSpindownTimeout;
5746 ULONG MaxSpindownTimeout;
5747 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
5749 typedef struct {
5750 ULONG Granularity;
5751 ULONG Capacity;
5752 } BATTERY_REPORTING_SCALE,
5753 *PBATTERY_REPORTING_SCALE;
5755 typedef struct {
5756 POWER_ACTION Action;
5757 ULONG Flags;
5758 ULONG EventCode;
5759 } POWER_ACTION_POLICY,
5760 *PPOWER_ACTION_POLICY;
5762 typedef struct _PROCESSOR_POWER_INFORMATION {
5763 ULONG Number;
5764 ULONG MaxMhz;
5765 ULONG CurrentMhz;
5766 ULONG MhzLimit;
5767 ULONG MaxIdleState;
5768 ULONG CurrentIdleState;
5769 } PROCESSOR_POWER_INFORMATION,
5770 *PPROCESSOR_POWER_INFORMATION;
5772 typedef struct _PROCESSOR_POWER_POLICY_INFO {
5773 ULONG TimeCheck;
5774 ULONG DemoteLimit;
5775 ULONG PromoteLimit;
5776 UCHAR DemotePercent;
5777 UCHAR PromotePercent;
5778 UCHAR Spare[2];
5779 ULONG AllowDemotion:1;
5780 ULONG AllowPromotion:1;
5781 ULONG Reserved:30;
5782 } PROCESSOR_POWER_POLICY_INFO,
5783 *PPROCESSOR_POWER_POLICY_INFO;
5785 typedef struct _PROCESSOR_POWER_POLICY {
5786 DWORD Revision;
5787 BYTE DynamicThrottle;
5788 BYTE Spare[3];
5789 DWORD DisableCStates:1;
5790 DWORD Reserved:31;
5791 DWORD PolicyCount;
5792 PROCESSOR_POWER_POLICY_INFO Policy[3];
5793 } PROCESSOR_POWER_POLICY,
5794 *PPROCESSOR_POWER_POLICY;
5796 typedef struct {
5797 BOOLEAN AcOnLine;
5798 BOOLEAN BatteryPresent;
5799 BOOLEAN Charging;
5800 BOOLEAN Discharging;
5801 BOOLEAN Spare1[3];
5802 BYTE Tag;
5803 ULONG MaxCapacity;
5804 ULONG RemainingCapacity;
5805 ULONG Rate;
5806 ULONG EstimatedTime;
5807 ULONG DefaultAlert1;
5808 ULONG DefaultAlert2;
5809 } SYSTEM_BATTERY_STATE,
5810 *PSYSTEM_BATTERY_STATE;
5812 typedef struct {
5813 BOOLEAN PowerButtonPresent;
5814 BOOLEAN SleepButtonPresent;
5815 BOOLEAN LidPresent;
5816 BOOLEAN SystemS1;
5817 BOOLEAN SystemS2;
5818 BOOLEAN SystemS3;
5819 BOOLEAN SystemS4;
5820 BOOLEAN SystemS5;
5821 BOOLEAN HiberFilePresent;
5822 BOOLEAN FullWake;
5823 BOOLEAN VideoDimPresent;
5824 BOOLEAN ApmPresent;
5825 BOOLEAN UpsPresent;
5826 BOOLEAN ThermalControl;
5827 BOOLEAN ProcessorThrottle;
5828 UCHAR ProcessorMinThrottle;
5829 UCHAR ProcessorMaxThrottle;
5830 UCHAR spare2[4];
5831 BOOLEAN DiskSpinDown;
5832 UCHAR spare3[8];
5833 BOOLEAN SystemBatteriesPresent;
5834 BOOLEAN BatteriesAreShortTerm;
5835 BATTERY_REPORTING_SCALE BatteryScale[3];
5836 SYSTEM_POWER_STATE AcOnLineWake;
5837 SYSTEM_POWER_STATE SoftLidWake;
5838 SYSTEM_POWER_STATE RtcWake;
5839 SYSTEM_POWER_STATE MinDeviceWakeState;
5840 SYSTEM_POWER_STATE DefaultLowLatencyWake;
5841 } SYSTEM_POWER_CAPABILITIES,
5842 *PSYSTEM_POWER_CAPABILITIES;
5844 typedef struct _SYSTEM_POWER_INFORMATION {
5845 ULONG MaxIdlenessAllowed;
5846 ULONG Idleness;
5847 ULONG TimeRemaining;
5848 UCHAR CoolingMode;
5849 } SYSTEM_POWER_INFORMATION,
5850 *PSYSTEM_POWER_INFORMATION;
5852 typedef struct _SYSTEM_POWER_LEVEL {
5853 BOOLEAN Enable;
5854 UCHAR Spare[3];
5855 ULONG BatteryLevel;
5856 POWER_ACTION_POLICY PowerPolicy;
5857 SYSTEM_POWER_STATE MinSystemState;
5858 } SYSTEM_POWER_LEVEL,
5859 *PSYSTEM_POWER_LEVEL;
5861 typedef struct _SYSTEM_POWER_POLICY {
5862 ULONG Revision;
5863 POWER_ACTION_POLICY PowerButton;
5864 POWER_ACTION_POLICY SleepButton;
5865 POWER_ACTION_POLICY LidClose;
5866 SYSTEM_POWER_STATE LidOpenWake;
5867 ULONG Reserved;
5868 POWER_ACTION_POLICY Idle;
5869 ULONG IdleTimeout;
5870 UCHAR IdleSensitivity;
5871 UCHAR DynamicThrottle;
5872 UCHAR Spare2[2];
5873 SYSTEM_POWER_STATE MinSleep;
5874 SYSTEM_POWER_STATE MaxSleep;
5875 SYSTEM_POWER_STATE ReducedLatencySleep;
5876 ULONG WinLogonFlags;
5877 ULONG Spare3;
5878 ULONG DozeS4Timeout;
5879 ULONG BroadcastCapacityResolution;
5880 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
5881 ULONG VideoTimeout;
5882 BOOLEAN VideoDimDisplay;
5883 ULONG VideoReserved[3];
5884 ULONG SpindownTimeout;
5885 BOOLEAN OptimizeForPower;
5886 UCHAR FanThrottleTolerance;
5887 UCHAR ForcedThrottle;
5888 UCHAR MinThrottle;
5889 POWER_ACTION_POLICY OverThrottled;
5890 } SYSTEM_POWER_POLICY,
5891 *PSYSTEM_POWER_POLICY;
5893 typedef enum _POWER_REQUEST_TYPE
5895 PowerRequestDisplayRequired,
5896 PowerRequestSystemRequired,
5897 PowerRequestAwayModeRequired
5898 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
5900 #define POWER_REQUEST_CONTEXT_VERSION 0
5902 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5903 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5905 typedef union _FILE_SEGMENT_ELEMENT {
5906 PVOID64 Buffer;
5907 ULONGLONG Alignment;
5908 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5910 typedef struct _FILE_NOTIFY_INFORMATION {
5911 DWORD NextEntryOffset;
5912 DWORD Action;
5913 DWORD FileNameLength;
5914 WCHAR FileName[1];
5915 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5917 /* ----------------------------- begin tape storage --------------------- */
5919 #define TAPE_FIXED_PARTITIONS 0
5920 #define TAPE_SELECT_PARTITIONS 1
5921 #define TAPE_INITIATOR_PARTITIONS 2
5922 #define TAPE_ERASE_SHORT 0
5923 #define TAPE_ERASE_LONG 1
5924 #define TAPE_LOAD 0
5925 #define TAPE_UNLOAD 1
5926 #define TAPE_TENSION 2
5927 #define TAPE_LOCK 3
5928 #define TAPE_UNLOCK 4
5929 #define TAPE_FORMAT 5
5930 #define TAPE_SETMARKS 0
5931 #define TAPE_FILEMARKS 1
5932 #define TAPE_SHORT_FILEMARKS 2
5933 #define TAPE_LONG_FILEMARKS 3
5934 #define TAPE_REWIND 0
5935 #define TAPE_ABSOLUTE_BLOCK 1
5936 #define TAPE_LOGICAL_BLOCK 2
5937 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5938 #define TAPE_SPACE_END_OF_DATA 4
5939 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5940 #define TAPE_SPACE_FILEMARKS 6
5941 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5942 #define TAPE_SPACE_SETMARKS 8
5943 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5945 typedef struct _TAPE_CREATE_PARTITION {
5946 DWORD Method;
5947 DWORD Count;
5948 DWORD Size;
5949 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5951 typedef struct _TAPE_ERASE {
5952 DWORD Type;
5953 BOOLEAN Immediate;
5954 } TAPE_ERASE, *PTAPE_ERASE;
5956 typedef struct _TAPE_PREPARE {
5957 DWORD Operation;
5958 BOOLEAN Immediate;
5959 } TAPE_PREPARE, *PTAPE_PREPARE;
5961 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5962 BOOLEAN ECC;
5963 BOOLEAN Compression;
5964 BOOLEAN DataPadding;
5965 BOOLEAN ReportSetmarks;
5966 ULONG EOTWarningZoneSize;
5967 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5969 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5970 ULONG BlockSize;
5971 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5973 typedef struct _TAPE_WRITE_MARKS {
5974 DWORD Type;
5975 DWORD Count;
5976 BOOLEAN Immediate;
5977 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5979 typedef struct _TAPE_GET_POSITION {
5980 ULONG Type;
5981 ULONG Partition;
5982 ULONG OffsetLow;
5983 ULONG OffsetHigh;
5984 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5986 typedef struct _TAPE_SET_POSITION {
5987 ULONG Method;
5988 ULONG Partition;
5989 LARGE_INTEGER Offset;
5990 BOOLEAN Immediate;
5991 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5993 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5994 BOOLEAN ECC;
5995 BOOLEAN Compression;
5996 BOOLEAN DataPadding;
5997 BOOLEAN ReportSetmarks;
5998 DWORD DefaultBlockSize;
5999 DWORD MaximumBlockSize;
6000 DWORD MinimumBlockSize;
6001 DWORD MaximumPartitionCount;
6002 DWORD FeaturesLow;
6003 DWORD FeaturesHigh;
6004 DWORD EOTWarningZoneSize;
6005 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
6007 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
6008 LARGE_INTEGER Capacity;
6009 LARGE_INTEGER Remaining;
6010 DWORD BlockSize;
6011 DWORD PartitionCount;
6012 BOOLEAN WriteProtected;
6013 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
6015 /* ----------------------------- begin registry ----------------------------- */
6017 /* Registry security values */
6018 #define OWNER_SECURITY_INFORMATION 0x00000001
6019 #define GROUP_SECURITY_INFORMATION 0x00000002
6020 #define DACL_SECURITY_INFORMATION 0x00000004
6021 #define SACL_SECURITY_INFORMATION 0x00000008
6022 #define LABEL_SECURITY_INFORMATION 0x00000010
6024 #define REG_OPTION_RESERVED 0x00000000
6025 #define REG_OPTION_NON_VOLATILE 0x00000000
6026 #define REG_OPTION_VOLATILE 0x00000001
6027 #define REG_OPTION_CREATE_LINK 0x00000002
6028 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
6029 #define REG_OPTION_OPEN_LINK 0x00000008
6030 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
6031 REG_OPTION_NON_VOLATILE | \
6032 REG_OPTION_VOLATILE | \
6033 REG_OPTION_CREATE_LINK | \
6034 REG_OPTION_BACKUP_RESTORE | \
6035 REG_OPTION_OPEN_LINK)
6038 #define REG_CREATED_NEW_KEY 0x00000001
6039 #define REG_OPENED_EXISTING_KEY 0x00000002
6041 /* For RegNotifyChangeKeyValue */
6042 #define REG_NOTIFY_CHANGE_NAME 0x01
6043 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
6044 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
6045 #define REG_NOTIFY_CHANGE_SECURITY 0x08
6046 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
6048 #define KEY_QUERY_VALUE 0x00000001
6049 #define KEY_SET_VALUE 0x00000002
6050 #define KEY_CREATE_SUB_KEY 0x00000004
6051 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
6052 #define KEY_NOTIFY 0x00000010
6053 #define KEY_CREATE_LINK 0x00000020
6054 #define KEY_WOW64_64KEY 0x00000100
6055 #define KEY_WOW64_32KEY 0x00000200
6056 #define KEY_WOW64_RES 0x00000300
6058 /* for RegKeyRestore flags */
6059 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
6060 #define REG_REFRESH_HIVE 0x00000002
6061 #define REG_NO_LAZY_FLUSH 0x00000004
6062 #define REG_FORCE_RESTORE 0x00000008
6064 #define KEY_READ ((STANDARD_RIGHTS_READ| \
6065 KEY_QUERY_VALUE| \
6066 KEY_ENUMERATE_SUB_KEYS| \
6067 KEY_NOTIFY) \
6068 & (~SYNCHRONIZE) \
6070 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
6071 KEY_SET_VALUE| \
6072 KEY_CREATE_SUB_KEY) \
6073 & (~SYNCHRONIZE) \
6075 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
6076 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
6077 KEY_QUERY_VALUE| \
6078 KEY_SET_VALUE| \
6079 KEY_CREATE_SUB_KEY| \
6080 KEY_ENUMERATE_SUB_KEYS| \
6081 KEY_NOTIFY| \
6082 KEY_CREATE_LINK) \
6083 & (~SYNCHRONIZE) \
6085 /* ------------------------------ end registry ------------------------------ */
6088 #define EVENTLOG_SUCCESS 0x0000
6089 #define EVENTLOG_ERROR_TYPE 0x0001
6090 #define EVENTLOG_WARNING_TYPE 0x0002
6091 #define EVENTLOG_INFORMATION_TYPE 0x0004
6092 #define EVENTLOG_AUDIT_SUCCESS 0x0008
6093 #define EVENTLOG_AUDIT_FAILURE 0x0010
6095 #define EVENTLOG_SEQUENTIAL_READ 0x0001
6096 #define EVENTLOG_SEEK_READ 0x0002
6097 #define EVENTLOG_FORWARDS_READ 0x0004
6098 #define EVENTLOG_BACKWARDS_READ 0x0008
6100 typedef struct _EVENTLOGRECORD {
6101 DWORD Length;
6102 DWORD Reserved;
6103 DWORD RecordNumber;
6104 DWORD TimeGenerated;
6105 DWORD TimeWritten;
6106 DWORD EventID;
6107 WORD EventType;
6108 WORD NumStrings;
6109 WORD EventCategory;
6110 WORD ReservedFlags;
6111 DWORD ClosingRecordNumber;
6112 DWORD StringOffset;
6113 DWORD UserSidLength;
6114 DWORD UserSidOffset;
6115 DWORD DataLength;
6116 DWORD DataOffset;
6117 } EVENTLOGRECORD, *PEVENTLOGRECORD;
6119 #define SERVICE_BOOT_START 0x00000000
6120 #define SERVICE_SYSTEM_START 0x00000001
6121 #define SERVICE_AUTO_START 0x00000002
6122 #define SERVICE_DEMAND_START 0x00000003
6123 #define SERVICE_DISABLED 0x00000004
6125 #define SERVICE_ERROR_IGNORE 0x00000000
6126 #define SERVICE_ERROR_NORMAL 0x00000001
6127 #define SERVICE_ERROR_SEVERE 0x00000002
6128 #define SERVICE_ERROR_CRITICAL 0x00000003
6130 /* Service types */
6131 #define SERVICE_KERNEL_DRIVER 0x00000001
6132 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
6133 #define SERVICE_ADAPTER 0x00000004
6134 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
6136 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
6137 SERVICE_RECOGNIZER_DRIVER )
6139 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
6140 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
6141 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
6143 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
6145 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
6146 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
6149 typedef enum _CM_SERVICE_NODE_TYPE
6151 DriverType = SERVICE_KERNEL_DRIVER,
6152 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
6153 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
6154 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
6155 AdapterType = SERVICE_ADAPTER,
6156 RecognizerType = SERVICE_RECOGNIZER_DRIVER
6157 } SERVICE_NODE_TYPE;
6159 typedef enum _CM_SERVICE_LOAD_TYPE
6161 BootLoad = SERVICE_BOOT_START,
6162 SystemLoad = SERVICE_SYSTEM_START,
6163 AutoLoad = SERVICE_AUTO_START,
6164 DemandLoad = SERVICE_DEMAND_START,
6165 DisableLoad = SERVICE_DISABLED
6166 } SERVICE_LOAD_TYPE;
6168 typedef enum _CM_ERROR_CONTROL_TYPE
6170 IgnoreError = SERVICE_ERROR_IGNORE,
6171 NormalError = SERVICE_ERROR_NORMAL,
6172 SevereError = SERVICE_ERROR_SEVERE,
6173 CriticalError = SERVICE_ERROR_CRITICAL
6174 } SERVICE_ERROR_TYPE;
6176 NTSYSAPI SIZE_T WINAPI RtlCompareMemory(const VOID*, const VOID*, SIZE_T);
6177 NTSYSAPI SIZE_T WINAPI RtlCompareMemoryUlong(VOID*, SIZE_T, ULONG);
6179 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
6180 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
6181 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
6182 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
6183 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
6185 static FORCEINLINE void *RtlSecureZeroMemory(void *buffer, SIZE_T length)
6187 volatile char *ptr = (volatile char *)buffer;
6189 while (length--) *ptr++ = 0;
6190 return buffer;
6193 #include <guiddef.h>
6195 typedef struct _OBJECT_TYPE_LIST {
6196 WORD Level;
6197 WORD Sbz;
6198 GUID *ObjectType;
6199 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
6201 typedef struct _RTL_CRITICAL_SECTION_DEBUG
6203 WORD Type;
6204 WORD CreatorBackTraceIndex;
6205 struct _RTL_CRITICAL_SECTION *CriticalSection;
6206 LIST_ENTRY ProcessLocksList;
6207 DWORD EntryCount;
6208 DWORD ContentionCount;
6209 #ifdef __WINESRC__ /* in Wine we store the name here */
6210 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
6211 #else
6212 DWORD Spare[ 2 ];
6213 #endif
6214 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
6216 typedef struct _RTL_CRITICAL_SECTION {
6217 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
6218 LONG LockCount;
6219 LONG RecursionCount;
6220 HANDLE OwningThread;
6221 HANDLE LockSemaphore;
6222 ULONG_PTR SpinCount;
6223 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
6225 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
6226 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
6227 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
6228 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
6229 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
6231 typedef struct _RTL_SRWLOCK {
6232 PVOID Ptr;
6233 } RTL_SRWLOCK, *PRTL_SRWLOCK;
6235 #define RTL_SRWLOCK_INIT {0}
6237 typedef struct _RTL_CONDITION_VARIABLE {
6238 PVOID Ptr;
6239 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
6240 #define RTL_CONDITION_VARIABLE_INIT {0}
6241 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
6243 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
6244 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
6246 #define RTL_RUN_ONCE_INIT {0}
6247 typedef union _RTL_RUN_ONCE {
6248 PVOID Ptr;
6249 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
6251 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
6252 #define RTL_RUN_ONCE_ASYNC 0x00000002
6253 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
6255 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
6256 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
6257 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
6258 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
6259 NTSYSAPI DWORD WINAPI RtlRunOnceBeginInitialize(PRTL_RUN_ONCE, DWORD, PVOID*);
6260 NTSYSAPI DWORD WINAPI RtlRunOnceComplete(PRTL_RUN_ONCE, DWORD, PVOID);
6262 #include <pshpack8.h>
6263 typedef struct _IO_COUNTERS {
6264 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
6265 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
6266 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
6267 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
6268 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
6269 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
6270 } IO_COUNTERS, *PIO_COUNTERS;
6271 #include <poppack.h>
6273 typedef struct {
6274 DWORD dwOSVersionInfoSize;
6275 DWORD dwMajorVersion;
6276 DWORD dwMinorVersion;
6277 DWORD dwBuildNumber;
6278 DWORD dwPlatformId;
6279 CHAR szCSDVersion[128];
6280 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
6282 typedef struct {
6283 DWORD dwOSVersionInfoSize;
6284 DWORD dwMajorVersion;
6285 DWORD dwMinorVersion;
6286 DWORD dwBuildNumber;
6287 DWORD dwPlatformId;
6288 WCHAR szCSDVersion[128];
6289 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
6291 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
6292 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
6293 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
6295 typedef struct {
6296 DWORD dwOSVersionInfoSize;
6297 DWORD dwMajorVersion;
6298 DWORD dwMinorVersion;
6299 DWORD dwBuildNumber;
6300 DWORD dwPlatformId;
6301 CHAR szCSDVersion[128];
6302 WORD wServicePackMajor;
6303 WORD wServicePackMinor;
6304 WORD wSuiteMask;
6305 BYTE wProductType;
6306 BYTE wReserved;
6307 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
6309 typedef struct {
6310 DWORD dwOSVersionInfoSize;
6311 DWORD dwMajorVersion;
6312 DWORD dwMinorVersion;
6313 DWORD dwBuildNumber;
6314 DWORD dwPlatformId;
6315 WCHAR szCSDVersion[128];
6316 WORD wServicePackMajor;
6317 WORD wServicePackMinor;
6318 WORD wSuiteMask;
6319 BYTE wProductType;
6320 BYTE wReserved;
6321 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
6323 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
6324 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
6325 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
6327 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
6329 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
6331 #define VER_PLATFORM_WIN32s 0
6332 #define VER_PLATFORM_WIN32_WINDOWS 1
6333 #define VER_PLATFORM_WIN32_NT 2
6335 #define VER_MINORVERSION 0x00000001
6336 #define VER_MAJORVERSION 0x00000002
6337 #define VER_BUILDNUMBER 0x00000004
6338 #define VER_PLATFORMID 0x00000008
6339 #define VER_SERVICEPACKMINOR 0x00000010
6340 #define VER_SERVICEPACKMAJOR 0x00000020
6341 #define VER_SUITENAME 0x00000040
6342 #define VER_PRODUCT_TYPE 0x00000080
6344 #define VER_NT_WORKSTATION 1
6345 #define VER_NT_DOMAIN_CONTROLLER 2
6346 #define VER_NT_SERVER 3
6348 #define VER_SUITE_SMALLBUSINESS 0x00000001
6349 #define VER_SUITE_ENTERPRISE 0x00000002
6350 #define VER_SUITE_BACKOFFICE 0x00000004
6351 #define VER_SUITE_COMMUNICATIONS 0x00000008
6352 #define VER_SUITE_TERMINAL 0x00000010
6353 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
6354 #define VER_SUITE_EMBEDDEDNT 0x00000040
6355 #define VER_SUITE_DATACENTER 0x00000080
6356 #define VER_SUITE_SINGLEUSERTS 0x00000100
6357 #define VER_SUITE_PERSONAL 0x00000200
6358 #define VER_SUITE_BLADE 0x00000400
6359 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
6360 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
6361 #define VER_SUITE_STORAGE_SERVER 0x00002000
6362 #define VER_SUITE_COMPUTE_SERVER 0x00004000
6363 #define VER_SUITE_WH_SERVER 0x00008000
6365 #define VER_EQUAL 1
6366 #define VER_GREATER 2
6367 #define VER_GREATER_EQUAL 3
6368 #define VER_LESS 4
6369 #define VER_LESS_EQUAL 5
6370 #define VER_AND 6
6371 #define VER_OR 7
6373 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
6374 DWORD dwFlags;
6375 DWORD ulFormatVersion;
6376 DWORD ulAssemblyCount;
6377 DWORD ulRootManifestPathType;
6378 DWORD ulRootManifestPathChars;
6379 DWORD ulRootConfigurationPathType;
6380 DWORD ulRootConfigurationPathChars;
6381 DWORD ulAppDirPathType;
6382 DWORD ulAppDirPathChars;
6383 PCWSTR lpRootManifestPath;
6384 PCWSTR lpRootConfigurationPath;
6385 PCWSTR lpAppDirPath;
6386 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
6388 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
6389 DWORD ulFlags;
6390 DWORD ulEncodedAssemblyIdentityLength;
6391 DWORD ulManifestPathType;
6392 DWORD ulManifestPathLength;
6393 LARGE_INTEGER liManifestLastWriteTime;
6394 DWORD ulPolicyPathType;
6395 DWORD ulPolicyPathLength;
6396 LARGE_INTEGER liPolicyLastWriteTime;
6397 DWORD ulMetadataSatelliteRosterIndex;
6398 DWORD ulManifestVersionMajor;
6399 DWORD ulManifestVersionMinor;
6400 DWORD ulPolicyVersionMajor;
6401 DWORD ulPolicyVersionMinor;
6402 DWORD ulAssemblyDirectoryNameLength;
6403 PCWSTR lpAssemblyEncodedAssemblyIdentity;
6404 PCWSTR lpAssemblyManifestPath;
6405 PCWSTR lpAssemblyPolicyPath;
6406 PCWSTR lpAssemblyDirectoryName;
6407 DWORD ulFileCount;
6408 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
6410 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
6411 DWORD ulAssemblyIndex;
6412 DWORD ulFileIndexInAssembly;
6413 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
6415 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
6417 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
6418 DWORD ulFlags;
6419 DWORD ulFilenameLength;
6420 DWORD ulPathLength;
6421 PCWSTR lpFileName;
6422 PCWSTR lpFilePath;
6423 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
6425 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
6427 typedef enum {
6428 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
6429 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
6430 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION,
6431 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6432 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
6434 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
6435 GUID Id;
6436 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
6437 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
6439 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6440 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
6441 DWORD ElementCount;
6442 COMPATIBILITY_CONTEXT_ELEMENT Elements[];
6443 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
6444 #endif
6446 typedef enum {
6447 ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
6448 ACTCTX_RUN_LEVEL_AS_INVOKER,
6449 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
6450 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
6451 ACTCTX_RUN_LEVEL_NUMBERS
6452 } ACTCTX_REQUESTED_RUN_LEVEL;
6454 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
6455 DWORD ulFlags;
6456 ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
6457 DWORD UiAccess;
6458 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6460 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION *PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6462 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
6463 ActivationContextBasicInformation = 1,
6464 ActivationContextDetailedInformation = 2,
6465 AssemblyDetailedInformationInActivationContext = 3,
6466 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
6467 RunlevelInformationInActivationContext = 5,
6468 CompatibilityInformationInActivationContext = 6,
6469 ActivationContextManifestResourceName = 7,
6470 MaxActivationContextInfoClass,
6471 AssemblyDetailedInformationInActivationContxt = AssemblyDetailedInformationInActivationContext,
6472 FileInformationInAssemblyOfAssemblyInActivationContxt = FileInformationInAssemblyOfAssemblyInActivationContext
6473 } ACTIVATION_CONTEXT_INFO_CLASS;
6475 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6476 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6477 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6478 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6480 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6481 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6482 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6483 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6484 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6485 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6486 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6487 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6488 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6489 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6490 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6492 typedef enum _JOBOBJECTINFOCLASS
6494 JobObjectBasicAccountingInformation = 1,
6495 JobObjectBasicLimitInformation,
6496 JobObjectBasicProcessIdList,
6497 JobObjectBasicUIRestrictions,
6498 JobObjectSecurityLimitInformation,
6499 JobObjectEndOfJobTimeInformation,
6500 JobObjectAssociateCompletionPortInformation,
6501 JobObjectBasicAndIoAccountingInformation,
6502 JobObjectExtendedLimitInformation,
6503 JobObjectJobSetInformation,
6504 MaxJobObjectInfoClass
6505 } JOBOBJECTINFOCLASS;
6507 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
6508 LARGE_INTEGER TotalUserTime;
6509 LARGE_INTEGER TotalKernelTime;
6510 LARGE_INTEGER ThisPeriodTotalUserTime;
6511 LARGE_INTEGER ThisPeriodTotalKernelTime;
6512 DWORD TotalPageFaultCount;
6513 DWORD TotalProcesses;
6514 DWORD ActiveProcesses;
6515 DWORD TotalTerminatedProcesses;
6516 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
6518 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
6519 LARGE_INTEGER PerProcessUserTimeLimit;
6520 LARGE_INTEGER PerJobUserTimeLimit;
6521 DWORD LimitFlags;
6522 SIZE_T MinimumWorkingSetSize;
6523 SIZE_T MaximumWorkingSetSize;
6524 DWORD ActiveProcessLimit;
6525 ULONG_PTR Affinity;
6526 DWORD PriorityClass;
6527 DWORD SchedulingClass;
6528 } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
6530 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
6531 DWORD NumberOfAssignedProcesses;
6532 DWORD NumberOfProcessIdsInList;
6533 ULONG_PTR ProcessIdList[1];
6534 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
6536 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
6537 DWORD UIRestrictionsClass;
6538 } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
6540 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
6541 DWORD SecurityLimitFlags;
6542 HANDLE JobToken;
6543 PTOKEN_GROUPS SidsToDisable;
6544 PTOKEN_PRIVILEGES PrivilegesToDelete;
6545 PTOKEN_GROUPS RestrictedSids;
6546 } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
6548 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
6549 DWORD EndOfJobTimeAction;
6550 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
6552 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
6553 PVOID CompletionKey;
6554 HANDLE CompletionPort;
6555 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
6557 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6558 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6559 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6560 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6561 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6562 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6563 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6564 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6565 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6567 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
6568 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
6569 IO_COUNTERS IoInfo;
6570 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
6572 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
6573 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
6574 IO_COUNTERS IoInfo;
6575 SIZE_T ProcessMemoryLimit;
6576 SIZE_T JobMemoryLimit;
6577 SIZE_T PeakProcessMemoryUsed;
6578 SIZE_T PeakJobMemoryUsed;
6579 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
6581 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6582 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6583 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6584 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6585 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6586 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6587 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6588 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6589 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6590 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6591 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6592 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6593 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6594 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6595 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6597 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6598 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6599 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6601 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6603 RelationProcessorCore = 0,
6604 RelationNumaNode = 1,
6605 RelationCache = 2,
6606 RelationProcessorPackage = 3,
6607 RelationGroup = 4,
6608 RelationAll = 0xffff
6609 } LOGICAL_PROCESSOR_RELATIONSHIP;
6611 #define LTP_PC_SMT 0x1
6613 typedef enum _PROCESSOR_CACHE_TYPE
6615 CacheUnified,
6616 CacheInstruction,
6617 CacheData,
6618 CacheTrace
6619 } PROCESSOR_CACHE_TYPE;
6621 typedef struct _PROCESSOR_GROUP_INFO
6623 BYTE MaximumProcessorCount;
6624 BYTE ActiveProcessorCount;
6625 BYTE Reserved[38];
6626 KAFFINITY ActiveProcessorMask;
6627 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
6629 typedef struct _CACHE_DESCRIPTOR
6631 BYTE Level;
6632 BYTE Associativity;
6633 WORD LineSize;
6634 DWORD Size;
6635 PROCESSOR_CACHE_TYPE Type;
6636 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
6638 typedef struct _GROUP_AFFINITY
6640 KAFFINITY Mask;
6641 WORD Group;
6642 WORD Reserved[3];
6643 } GROUP_AFFINITY, *PGROUP_AFFINITY;
6645 #define ALL_PROCESSOR_GROUPS 0xffff
6647 typedef struct _PROCESSOR_NUMBER
6649 WORD Group;
6650 BYTE Number;
6651 BYTE Reserved;
6652 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
6654 typedef struct _PROCESSOR_RELATIONSHIP
6656 BYTE Flags;
6657 BYTE EfficiencyClass;
6658 BYTE Reserved[20];
6659 WORD GroupCount;
6660 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
6661 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
6663 typedef struct _NUMA_NODE_RELATIONSHIP
6665 DWORD NodeNumber;
6666 BYTE Reserved[20];
6667 GROUP_AFFINITY GroupMask;
6668 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
6670 typedef struct _CACHE_RELATIONSHIP
6672 BYTE Level;
6673 BYTE Associativity;
6674 WORD LineSize;
6675 DWORD CacheSize;
6676 PROCESSOR_CACHE_TYPE Type;
6677 BYTE Reserved[20];
6678 GROUP_AFFINITY GroupMask;
6679 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
6681 typedef struct _GROUP_RELATIONSHIP
6683 WORD MaximumGroupCount;
6684 WORD ActiveGroupCount;
6685 BYTE Reserved[20];
6686 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
6687 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
6689 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6691 ULONG_PTR ProcessorMask;
6692 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6693 union
6695 struct
6697 BYTE Flags;
6698 } ProcessorCore;
6699 struct
6701 DWORD NodeNumber;
6702 } NumaNode;
6703 CACHE_DESCRIPTOR Cache;
6704 ULONGLONG Reserved[2];
6705 } DUMMYUNIONNAME;
6706 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
6708 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6710 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6711 DWORD Size;
6712 union
6714 PROCESSOR_RELATIONSHIP Processor;
6715 NUMA_NODE_RELATIONSHIP NumaNode;
6716 CACHE_RELATIONSHIP Cache;
6717 GROUP_RELATIONSHIP Group;
6718 } DUMMYUNIONNAME;
6719 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
6721 /* Threadpool things */
6722 typedef DWORD TP_VERSION,*PTP_VERSION;
6724 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
6726 typedef VOID (CALLBACK *PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID);
6728 typedef struct _TP_POOL TP_POOL,*PTP_POOL;
6730 typedef enum _TP_CALLBACK_PRIORITY
6732 TP_CALLBACK_PRIORITY_HIGH,
6733 TP_CALLBACK_PRIORITY_NORMAL,
6734 TP_CALLBACK_PRIORITY_LOW,
6735 TP_CALLBACK_PRIORITY_INVALID,
6736 TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
6737 } TP_CALLBACK_PRIORITY;
6739 typedef struct _TP_POOL_STACK_INFORMATION
6741 SIZE_T StackReserve;
6742 SIZE_T StackCommit;
6743 } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION;
6745 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
6747 typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID,PVOID);
6749 typedef struct _TP_CALLBACK_ENVIRON_V1
6751 TP_VERSION Version;
6752 PTP_POOL Pool;
6753 PTP_CLEANUP_GROUP CleanupGroup;
6754 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6755 PVOID RaceDll;
6756 struct _ACTIVATION_CONTEXT* ActivationContext;
6757 PTP_SIMPLE_CALLBACK FinalizationCallback;
6758 union
6760 DWORD Flags;
6761 struct
6763 DWORD LongFunction:1;
6764 DWORD Persistent:1;
6765 DWORD Private:30;
6766 } s;
6767 } u;
6768 } TP_CALLBACK_ENVIRON_V1;
6770 typedef struct _TP_CALLBACK_ENVIRON_V3
6772 TP_VERSION Version;
6773 PTP_POOL Pool;
6774 PTP_CLEANUP_GROUP CleanupGroup;
6775 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6776 PVOID RaceDll;
6777 struct _ACTIVATION_CONTEXT *ActivationContext;
6778 PTP_SIMPLE_CALLBACK FinalizationCallback;
6779 union
6781 DWORD Flags;
6782 struct
6784 DWORD LongFunction:1;
6785 DWORD Persistent:1;
6786 DWORD Private:30;
6787 } s;
6788 } u;
6789 TP_CALLBACK_PRIORITY CallbackPriority;
6790 DWORD Size;
6791 } TP_CALLBACK_ENVIRON_V3;
6793 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
6794 typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
6796 typedef DWORD TP_WAIT_RESULT;
6797 typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6799 typedef struct _TP_IO TP_IO, *PTP_IO;
6801 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
6803 typedef VOID (CALLBACK *PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WORK);
6804 typedef VOID (CALLBACK *PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_TIMER);
6805 typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,TP_WAIT_RESULT);
6808 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
6810 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6812 UmsThreadInvalidInfoClass,
6813 UmsThreadUserContext,
6814 UmsThreadPriority,
6815 UmsThreadAffinity,
6816 UmsThreadTeb,
6817 UmsThreadIsSuspended,
6818 UmsThreadIsTerminated,
6819 UmsThreadMaxInfoClass
6820 } RTL_UMS_THREAD_INFO_CLASS, *PRTL_UMS_THREAD_INFO_CLASS;
6822 typedef enum _RTL_UMS_SCHEDULER_REASON
6824 UmsSchedulerStartup,
6825 UmsSchedulerThreadBlocked,
6826 UmsSchedulerThreadYield,
6827 } RTL_UMS_SCHEDULER_REASON, *PRTL_UMS_SCHEDULER_REASON;
6829 typedef void (CALLBACK *PRTL_UMS_SCHEDULER_ENTRY_POINT)(RTL_UMS_SCHEDULER_REASON,ULONG_PTR,PVOID);
6831 typedef enum _PROCESS_MITIGATION_POLICY
6833 ProcessDEPPolicy,
6834 ProcessASLRPolicy,
6835 ProcessDynamicCodePolicy,
6836 ProcessStrictHandleCheckPolicy,
6837 ProcessSystemCallDisablePolicy,
6838 ProcessMitigationOptionsMask,
6839 ProcessExtensionPointDisablePolicy,
6840 ProcessControlFlowGuardPolicy,
6841 ProcessSignaturePolicy,
6842 ProcessFontDisablePolicy,
6843 ProcessImageLoadPolicy,
6844 ProcessSystemCallFilterPolicy,
6845 ProcessPayloadRestrictionPolicy,
6846 ProcessChildProcessPolicy,
6847 ProcessSideChannelIsolationPolicy,
6848 MaxProcessMitigationPolicy
6849 } PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY;
6851 #ifdef _MSC_VER
6853 BOOLEAN _BitScanForward(unsigned long*,unsigned long);
6854 BOOLEAN _BitScanReverse(unsigned long*,unsigned long);
6856 #pragma intrinsic(_BitScanForward)
6857 #pragma intrinsic(_BitScanReverse)
6859 static inline BOOLEAN BitScanForward(DWORD *index, DWORD mask)
6861 return _BitScanForward((unsigned long*)index, mask);
6864 static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
6866 return _BitScanReverse((unsigned long*)index, mask);
6869 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
6871 static inline BOOLEAN BitScanForward(DWORD *index, DWORD mask)
6873 *index = __builtin_ctz(mask);
6874 return mask != 0;
6877 static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
6879 *index = 31 - __builtin_clz(mask);
6880 return mask != 0;
6883 #else
6885 static inline BOOLEAN BitScanForward(DWORD *index, DWORD mask)
6887 unsigned int r = 0;
6888 while (r < 31 && !(mask & (1 << r))) r++;
6889 *index = r;
6890 return mask != 0;
6893 static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
6895 unsigned int r = 31;
6896 while (r > 0 && !(mask & (1 << r))) r--;
6897 *index = r;
6898 return mask != 0;
6901 #endif
6903 /* Interlocked functions */
6905 #ifdef _MSC_VER
6907 #pragma intrinsic(_InterlockedAnd)
6908 #pragma intrinsic(_InterlockedCompareExchange)
6909 #pragma intrinsic(_InterlockedCompareExchange64)
6910 #ifdef _WIN64
6911 #pragma intrinsic(_InterlockedCompareExchange128)
6912 #endif
6913 #pragma intrinsic(_InterlockedExchange)
6914 #pragma intrinsic(_InterlockedExchangeAdd)
6915 #pragma intrinsic(_InterlockedIncrement)
6916 #pragma intrinsic(_InterlockedIncrement16)
6917 #pragma intrinsic(_InterlockedDecrement)
6918 #pragma intrinsic(_InterlockedDecrement16)
6919 #pragma intrinsic(_InterlockedOr)
6921 long _InterlockedAnd(long volatile *,long);
6922 long _InterlockedCompareExchange(long volatile*,long,long);
6923 long long _InterlockedCompareExchange64(long long volatile*,long long,long long);
6924 #ifdef _WIN64
6925 unsigned char _InterlockedCompareExchange128(volatile __int64 *, __int64, __int64, __int64 *);
6926 #endif
6927 long _InterlockedDecrement(long volatile*);
6928 short _InterlockedDecrement16(short volatile*);
6929 long _InterlockedExchange(long volatile*,long);
6930 long _InterlockedExchangeAdd(long volatile*,long);
6931 long _InterlockedIncrement(long volatile*);
6932 short _InterlockedIncrement16(short volatile*);
6933 long _InterlockedOr(long volatile *,long);
6935 static FORCEINLINE LONG WINAPI InterlockedAnd( LONG volatile *dest, LONG val )
6937 return _InterlockedAnd( (long volatile *)dest, val );
6940 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
6942 return _InterlockedCompareExchange( (long volatile *)dest, xchg, compare );
6945 static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
6947 return _InterlockedCompareExchange64( (long long volatile *)dest, compare, xchg );
6950 #ifdef _WIN64
6951 static FORCEINLINE unsigned char WINAPI InterlockedCompareExchange128( volatile __int64 *dest, __int64 xchg_high, __int64 xchg_low, __int64 *compare )
6953 return _InterlockedCompareExchange128( dest, xchg_high, xchg_low, compare );
6955 #endif
6957 static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
6959 return _InterlockedExchange( (long volatile *)dest, val );
6962 static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
6964 return _InterlockedExchangeAdd( (long volatile *)dest, incr );
6967 static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
6969 return _InterlockedIncrement( (long volatile *)dest );
6972 static FORCEINLINE short WINAPI InterlockedIncrement16( short volatile *dest )
6974 return _InterlockedIncrement16( dest );
6977 static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
6979 return _InterlockedDecrement( (long volatile *)dest );
6982 static FORCEINLINE short WINAPI InterlockedDecrement16( short volatile *dest )
6984 return _InterlockedDecrement16( dest );
6987 static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val )
6989 return _InterlockedOr( (long volatile *)dest, val );
6992 #ifndef __i386__
6994 #pragma intrinsic(_InterlockedCompareExchangePointer)
6995 #pragma intrinsic(_InterlockedExchangePointer)
6997 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
6998 #define InterlockedExchangePointer _InterlockedExchangePointer
7000 void *InterlockedCompareExchangePointer(void *volatile*,void*,void*);
7001 void *InterlockedExchangePointer(void *volatile*,void*);
7003 #else
7005 static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
7007 return (void *)_InterlockedCompareExchange( (long volatile*)dest, (long)xchg, (long)compare );
7010 static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
7012 return (void *)_InterlockedExchange( (long volatile*)dest, (long)val );
7015 #endif /* __i386__ */
7017 #ifdef __i386__
7019 static FORCEINLINE void MemoryBarrier(void)
7021 LONG dummy;
7022 InterlockedOr(&dummy, 0);
7025 #elif defined(__x86_64__)
7027 #pragma intrinsic(__faststorefence)
7029 void __faststorefence(void);
7031 static FORCEINLINE void MemoryBarrier(void)
7033 __faststorefence();
7036 #elif defined(__arm__)
7038 #pragma intrinsic(__dmb)
7040 void __dmb(void);
7042 static FORCEINLINE void MemoryBarrier(void)
7044 __dmb(_ARM_BARRIER_SY);
7047 #elif defined(__aarch64__)
7049 #pragma intrinsic(__dmb)
7051 void __dmb(void);
7053 static FORCEINLINE void MemoryBarrier(void)
7055 __dmb(_ARM64_BARRIER_SY);
7058 #endif /* __i386__ */
7060 #elif defined(__GNUC__)
7062 static FORCEINLINE LONG WINAPI InterlockedAnd( LONG volatile *dest, LONG val )
7064 return __sync_fetch_and_and( dest, val );
7067 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
7069 return __sync_val_compare_and_swap( dest, compare, xchg );
7072 static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
7074 return __sync_val_compare_and_swap( dest, compare, xchg );
7077 static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
7079 return __sync_val_compare_and_swap( dest, compare, xchg );
7082 #ifdef _WIN64
7083 static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64 *dest, __int64 xchg_high, __int64 xchg_low, __int64 *compare )
7085 #ifdef __x86_64__
7086 unsigned char ret;
7087 __asm__ __volatile__( "lock cmpxchg16b %0; setz %b2"
7088 : "=m" (dest[0]), "=m" (dest[1]), "=r" (ret),
7089 "=a" (compare[0]), "=d" (compare[1])
7090 : "m" (dest[0]), "m" (dest[1]), "3" (compare[0]), "4" (compare[1]),
7091 "c" (xchg_high), "b" (xchg_low) );
7092 return ret;
7093 #else
7094 return __sync_bool_compare_and_swap( (__int128 *)dest, *(__int128 *)compare, ((__int128)xchg_high << 64) | xchg_low );
7095 #endif
7097 #endif
7099 static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
7101 LONG ret;
7102 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
7103 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
7104 #elif defined(__i386__) || defined(__x86_64__)
7105 __asm__ __volatile__( "lock; xchgl %0,(%1)"
7106 : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
7107 #else
7108 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
7109 #endif
7110 return ret;
7113 static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
7115 return __sync_fetch_and_add( dest, incr );
7118 static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
7120 return __sync_add_and_fetch( dest, 1 );
7123 static FORCEINLINE short WINAPI InterlockedIncrement16( short volatile *dest )
7125 return __sync_add_and_fetch( dest, 1 );
7128 static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
7130 return __sync_add_and_fetch( dest, -1 );
7133 static FORCEINLINE short WINAPI InterlockedDecrement16( short volatile *dest )
7135 return __sync_add_and_fetch( dest, -1 );
7138 static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
7140 void *ret;
7141 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
7142 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
7143 #elif defined(__x86_64__)
7144 __asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
7145 #elif defined(__i386__)
7146 __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
7147 #else
7148 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
7149 #endif
7150 return ret;
7153 static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val )
7155 return __sync_fetch_and_or( dest, val );
7158 static FORCEINLINE void MemoryBarrier(void)
7160 __sync_synchronize();
7163 #endif /* __GNUC__ */
7165 static FORCEINLINE void YieldProcessor(void)
7167 #ifdef __GNUC__
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" );
7172 #else
7173 __asm__ __volatile__( "" : : : "memory" );
7174 #endif
7175 #endif
7178 #ifdef __cplusplus
7180 #endif
7182 #endif /* _WINNT_ */