wineps: Handle EMR_SETMAPPERFLAGS record in spool files.
[wine.git] / include / winnt.h
blob15c254fbcffd3089cafe17d92f7f51f8876b4683
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>
27 #include <specstrings.h>
29 #ifndef RC_INVOKED
30 #include <ctype.h>
31 #include <stddef.h>
32 #include <string.h>
33 #endif
36 #if defined(_MSC_VER) && (defined(__arm__) || defined(__aarch64__))
37 #include <intrin.h>
38 #endif
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 #if defined(_NTSYSTEM_) || defined(WINE_UNIX_LIB)
46 #define NTSYSAPI
47 #else
48 #define NTSYSAPI DECLSPEC_IMPORT
49 #endif
51 #define NTAPI __stdcall
52 #define FASTCALL __fastcall
54 #ifndef MIDL_PASS
55 # if defined(_MSC_VER)
56 # define DECLSPEC_IMPORT __declspec(dllimport)
57 # elif defined(__MINGW32__) || defined(__CYGWIN__)
58 # define DECLSPEC_IMPORT __attribute__((dllimport))
59 # else
60 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
61 # endif
62 #else
63 # define DECLSPEC_IMPORT
64 #endif
66 #ifndef DECLSPEC_NORETURN
67 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
68 # define DECLSPEC_NORETURN __declspec(noreturn)
69 # elif defined(__GNUC__)
70 # define DECLSPEC_NORETURN __attribute__((noreturn))
71 # else
72 # define DECLSPEC_NORETURN
73 # endif
74 #endif
76 #ifndef DECLSPEC_ALIGN
77 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
78 # define DECLSPEC_ALIGN(x) __declspec(align(x))
79 # elif defined(__GNUC__)
80 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
81 # else
82 # define DECLSPEC_ALIGN(x)
83 # endif
84 #endif
86 #ifndef DECLSPEC_NOTHROW
87 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
88 # define DECLSPEC_NOTHROW __declspec(nothrow)
89 # elif defined(__GNUC__)
90 # define DECLSPEC_NOTHROW __attribute__((nothrow))
91 # else
92 # define DECLSPEC_NOTHROW
93 # endif
94 #endif
96 #ifndef DECLSPEC_CACHEALIGN
97 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
98 #endif
100 #ifndef DECLSPEC_UUID
101 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
102 # define DECLSPEC_UUID(x) __declspec(uuid(x))
103 # else
104 # define DECLSPEC_UUID(x)
105 # endif
106 #endif
108 #ifndef DECLSPEC_NOVTABLE
109 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
110 # define DECLSPEC_NOVTABLE __declspec(novtable)
111 # else
112 # define DECLSPEC_NOVTABLE
113 # endif
114 #endif
116 #ifndef DECLSPEC_SELECTANY
117 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
118 #define DECLSPEC_SELECTANY __declspec(selectany)
119 #elif defined(__MINGW32__)
120 #define DECLSPEC_SELECTANY __attribute__((selectany))
121 #elif defined(__GNUC__)
122 #define DECLSPEC_SELECTANY __attribute__((weak))
123 #else
124 #define DECLSPEC_SELECTANY
125 #endif
126 #endif
128 #ifndef NOP_FUNCTION
129 # if defined(_MSC_VER)
130 # if (_MSC_VER >= 1210)
131 # define NOP_FUNCTION __noop
132 # else
133 # define NOP_FUNCTION (void)0
134 # endif
135 # else
136 # define NOP_FUNCTION(...)
137 # endif
138 #endif
140 #ifndef DECLSPEC_ADDRSAFE
141 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
142 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
143 # else
144 # define DECLSPEC_ADDRSAFE
145 # endif
146 #endif
148 #ifndef FORCEINLINE
149 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
150 # define FORCEINLINE __forceinline
151 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
152 # define FORCEINLINE inline __attribute__((always_inline))
153 # else
154 # define FORCEINLINE inline
155 # endif
156 #endif
158 #ifndef DECLSPEC_DEPRECATED
159 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
160 # define DECLSPEC_DEPRECATED __declspec(deprecated)
161 # define DEPRECATE_SUPPORTED
162 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
163 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
164 # define DEPRECATE_SUPPORTED
165 # else
166 # define DECLSPEC_DEPRECATED
167 # undef DEPRECATE_SUPPORTED
168 # endif
169 #endif
171 /* a couple of useful Wine extensions */
173 #ifdef _MSC_VER
174 # define DECLSPEC_EXPORT __declspec(dllexport)
175 #elif defined(__MINGW32__)
176 # define DECLSPEC_EXPORT __attribute__((dllexport))
177 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) && !defined(__sun)
178 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
179 #else
180 # define DECLSPEC_EXPORT
181 #endif
183 #ifndef DECLSPEC_HIDDEN
184 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || defined(__sun)
185 # define DECLSPEC_HIDDEN
186 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
187 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
188 # else
189 # define DECLSPEC_HIDDEN
190 # endif
191 #endif
193 #ifndef __has_attribute
194 # define __has_attribute(x) 0
195 #endif
197 #if ((defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)))) || __has_attribute(ms_hook_prologue)) && (defined(__i386__) || defined(__x86_64__))
198 #define DECLSPEC_HOTPATCH __attribute__((__ms_hook_prologue__))
199 #else
200 #define DECLSPEC_HOTPATCH
201 #endif
203 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
204 #define __WINE_ALLOC_SIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
205 #else
206 #define __WINE_ALLOC_SIZE(...)
207 #endif
209 #if defined(__GNUC__) && (__GNUC__ > 10)
210 #define __WINE_DEALLOC(...) __attribute__((malloc (__VA_ARGS__)))
211 #else
212 #define __WINE_DEALLOC(...)
213 #endif
215 #if defined(__GNUC__) && (__GNUC__ > 2)
216 #define __WINE_MALLOC __attribute__((malloc))
217 #else
218 #define __WINE_MALLOC
219 #endif
221 /* Anonymous union/struct handling */
223 #ifndef NONAMELESSSTRUCT
224 # ifdef __GNUC__
225 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
226 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
227 # define NONAMELESSSTRUCT
228 # endif
229 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
230 # define NONAMELESSSTRUCT
231 # endif
232 #endif /* NONAMELESSSTRUCT */
234 #ifndef NONAMELESSUNION
235 # ifdef __GNUC__
236 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
237 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
238 # define NONAMELESSUNION
239 # endif
240 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
241 # define NONAMELESSUNION
242 # endif
243 #endif /* NONAMELESSUNION */
245 #undef DUMMYSTRUCTNAME
246 #undef DUMMYSTRUCTNAME1
247 #undef DUMMYSTRUCTNAME2
248 #undef DUMMYSTRUCTNAME3
249 #undef DUMMYSTRUCTNAME4
250 #undef DUMMYSTRUCTNAME5
251 #ifndef NONAMELESSSTRUCT
252 #define DUMMYSTRUCTNAME
253 #define DUMMYSTRUCTNAME1
254 #define DUMMYSTRUCTNAME2
255 #define DUMMYSTRUCTNAME3
256 #define DUMMYSTRUCTNAME4
257 #define DUMMYSTRUCTNAME5
258 #else /* !defined(NONAMELESSSTRUCT) */
259 #define DUMMYSTRUCTNAME s
260 #define DUMMYSTRUCTNAME1 s1
261 #define DUMMYSTRUCTNAME2 s2
262 #define DUMMYSTRUCTNAME3 s3
263 #define DUMMYSTRUCTNAME4 s4
264 #define DUMMYSTRUCTNAME5 s5
265 #endif /* !defined(NONAMELESSSTRUCT) */
267 #undef DUMMYUNIONNAME
268 #undef DUMMYUNIONNAME1
269 #undef DUMMYUNIONNAME2
270 #undef DUMMYUNIONNAME3
271 #undef DUMMYUNIONNAME4
272 #undef DUMMYUNIONNAME5
273 #undef DUMMYUNIONNAME6
274 #undef DUMMYUNIONNAME7
275 #undef DUMMYUNIONNAME8
276 #ifndef NONAMELESSUNION
277 #define DUMMYUNIONNAME
278 #define DUMMYUNIONNAME1
279 #define DUMMYUNIONNAME2
280 #define DUMMYUNIONNAME3
281 #define DUMMYUNIONNAME4
282 #define DUMMYUNIONNAME5
283 #define DUMMYUNIONNAME6
284 #define DUMMYUNIONNAME7
285 #define DUMMYUNIONNAME8
286 #else /* !defined(NONAMELESSUNION) */
287 #define DUMMYUNIONNAME u
288 #define DUMMYUNIONNAME1 u1
289 #define DUMMYUNIONNAME2 u2
290 #define DUMMYUNIONNAME3 u3
291 #define DUMMYUNIONNAME4 u4
292 #define DUMMYUNIONNAME5 u5
293 #define DUMMYUNIONNAME6 u6
294 #define DUMMYUNIONNAME7 u7
295 #define DUMMYUNIONNAME8 u8
296 #endif /* !defined(NONAMELESSUNION) */
298 #undef __C89_NAMELESS
299 #undef __C89_NAMELESSSTRUCTNAME
300 #undef __C89_NAMELESSSTRUCTNAME1
301 #undef __C89_NAMELESSSTRUCTNAME2
302 #undef __C89_NAMELESSSTRUCTNAME3
303 #undef __C89_NAMELESSSTRUCTNAME4
304 #undef __C89_NAMELESSSTRUCTNAME5
305 #undef __C89_NAMELESSUNIONNAME
306 #undef __C89_NAMELESSUNIONNAME1
307 #undef __C89_NAMELESSUNIONNAME2
308 #undef __C89_NAMELESSUNIONNAME3
309 #undef __C89_NAMELESSUNIONNAME4
310 #undef __C89_NAMELESSUNIONNAME5
311 #undef __C89_NAMELESSUNIONNAME6
312 #undef __C89_NAMELESSUNIONNAME7
313 #undef __C89_NAMELESSUNIONNAME8
315 #if !defined(WINE_NO_NAMELESS_EXTENSION)
316 # ifdef __GNUC__
317 /* Anonymous structs support starts with gcc 2.96/g++ 2.95 */
318 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ > 95) || ((__GNUC_MINOR__ == 95) && defined(__cplusplus))))
319 # define __C89_NAMELESS __extension__
320 # endif
321 # elif defined(_MSC_VER)
322 # define __C89_NAMELESS
323 # endif
324 #endif
326 #ifdef __C89_NAMELESS
327 # define __C89_NAMELESSSTRUCTNAME
328 # define __C89_NAMELESSSTRUCTNAME1
329 # define __C89_NAMELESSSTRUCTNAME2
330 # define __C89_NAMELESSSTRUCTNAME3
331 # define __C89_NAMELESSSTRUCTNAME4
332 # define __C89_NAMELESSSTRUCTNAME5
333 # define __C89_NAMELESSUNIONNAME
334 # define __C89_NAMELESSUNIONNAME1
335 # define __C89_NAMELESSUNIONNAME2
336 # define __C89_NAMELESSUNIONNAME3
337 # define __C89_NAMELESSUNIONNAME4
338 # define __C89_NAMELESSUNIONNAME5
339 # define __C89_NAMELESSUNIONNAME6
340 # define __C89_NAMELESSUNIONNAME7
341 # define __C89_NAMELESSUNIONNAME8
342 #else
343 # define __C89_NAMELESS
344 # define __C89_NAMELESSSTRUCTNAME DUMMYSTRUCTNAME
345 # define __C89_NAMELESSSTRUCTNAME1 DUMMYSTRUCTNAME1
346 # define __C89_NAMELESSSTRUCTNAME2 DUMMYSTRUCTNAME2
347 # define __C89_NAMELESSSTRUCTNAME3 DUMMYSTRUCTNAME3
348 # define __C89_NAMELESSSTRUCTNAME4 DUMMYSTRUCTNAME4
349 # define __C89_NAMELESSSTRUCTNAME5 DUMMYSTRUCTNAME5
350 # define __C89_NAMELESSUNIONNAME DUMMYUNIONNAME
351 # define __C89_NAMELESSUNIONNAME1 DUMMYUNIONNAME1
352 # define __C89_NAMELESSUNIONNAME2 DUMMYUNIONNAME2
353 # define __C89_NAMELESSUNIONNAME3 DUMMYUNIONNAME3
354 # define __C89_NAMELESSUNIONNAME4 DUMMYUNIONNAME4
355 # define __C89_NAMELESSUNIONNAME5 DUMMYUNIONNAME5
356 # define __C89_NAMELESSUNIONNAME6 DUMMYUNIONNAME6
357 # define __C89_NAMELESSUNIONNAME7 DUMMYUNIONNAME7
358 # define __C89_NAMELESSUNIONNAME8 DUMMYUNIONNAME8
359 #endif
361 /* C99 restrict support */
363 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
364 # if defined(_MSC_VER) && defined(_M_MRX000)
365 # define RESTRICTED_POINTER __restrict
366 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
367 # define RESTRICTED_POINTER __restrict
368 # else
369 # define RESTRICTED_POINTER
370 # endif
371 #else
372 # define RESTRICTED_POINTER
373 #endif
375 /* C99 unaligned support */
377 #ifndef UNALIGNED
378 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
379 # define UNALIGNED __unaligned
380 # ifdef _WIN64
381 # define UNALIGNED64 __unaligned
382 # else
383 # define UNALIGNED64
384 # endif
385 #else
386 # define UNALIGNED
387 # define UNALIGNED64
388 #endif
389 #endif
391 /* Alignment macros */
393 #ifdef _WIN64
394 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
395 #define MEMORY_ALLOCATION_ALIGNMENT 16
396 #else
397 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
398 #define MEMORY_ALLOCATION_ALIGNMENT 8
399 #endif
401 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
402 # define TYPE_ALIGNMENT(t) __alignof(t)
403 #elif defined(__GNUC__)
404 # define TYPE_ALIGNMENT(t) __alignof__(t)
405 #else
406 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
407 #endif
409 #ifdef _WIN64
410 # define PROBE_ALIGNMENT(_s) \
411 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
412 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
413 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
414 #else
415 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
416 #endif
418 /* Compile time assertion */
420 #define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
422 /* Eliminate Microsoft C/C++ compiler warning 4715 */
423 #if defined(_MSC_VER) && (_MSC_VER > 1200)
424 # define DEFAULT_UNREACHABLE default: __assume(0)
425 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
426 # define DEFAULT_UNREACHABLE default: __builtin_unreachable()
427 #else
428 # define DEFAULT_UNREACHABLE default:
429 #endif
431 /* Error Masks */
432 #define APPLICATION_ERROR_MASK 0x20000000
433 #define ERROR_SEVERITY_SUCCESS 0x00000000
434 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
435 #define ERROR_SEVERITY_WARNING 0x80000000
436 #define ERROR_SEVERITY_ERROR 0xC0000000
438 #ifdef __cplusplus
439 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
440 extern "C++" { \
441 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
442 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
443 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \
444 inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
445 inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \
446 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \
447 inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
449 #else
450 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
451 #endif
453 /* Microsoft's macros for declaring functions */
455 #ifdef __cplusplus
456 # define EXTERN_C extern "C"
457 #else
458 # define EXTERN_C extern
459 #endif
461 #define STDMETHODCALLTYPE WINAPI
462 #define STDMETHODVCALLTYPE WINAPIV
463 #define STDAPICALLTYPE WINAPI
464 #define STDAPIVCALLTYPE WINAPIV
466 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
467 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
468 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
469 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
470 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
471 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
472 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
473 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
475 /* Define the basic types */
476 #ifndef VOID
477 #define VOID void
478 #endif
479 typedef VOID *PVOID;
480 typedef VOID *PVOID64;
481 typedef BYTE BOOLEAN, *PBOOLEAN;
482 typedef char CHAR, *PCHAR;
483 typedef short SHORT, *PSHORT;
484 #if !defined(__LP64__) && !defined(WINE_NO_LONG_TYPES)
485 typedef long LONG, *PLONG;
486 #else
487 typedef int LONG, *PLONG;
488 #endif
490 /* Some systems might have wchar_t, but we really need 16 bit characters */
491 #if defined(WINE_UNICODE_NATIVE)
492 typedef wchar_t WCHAR;
493 #elif __cpp_unicode_literals >= 200710
494 typedef char16_t WCHAR;
495 #else
496 typedef unsigned short WCHAR;
497 #endif
498 typedef WCHAR *PWCHAR;
500 typedef ULONG UCSCHAR;
501 #define MIN_UCSCHAR (0)
502 #define MAX_UCSCHAR (0x0010ffff)
503 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
505 /* 'Extended/Wide' numerical types */
506 #ifndef _ULONGLONG_
507 # define _ULONGLONG_
508 # ifdef _MSC_VER
509 typedef signed __int64 LONGLONG, *PLONGLONG;
510 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
511 # else
512 typedef signed __int64 DECLSPEC_ALIGN(8) LONGLONG, *PLONGLONG;
513 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONGLONG, *PULONGLONG;
514 # endif
515 #endif
517 #ifndef _DWORDLONG_
518 # define _DWORDLONG_
519 # ifdef _MSC_VER
520 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
521 # else
522 typedef ULONGLONG DECLSPEC_ALIGN(8) DWORDLONG, *PDWORDLONG;
523 # endif
524 #endif
526 /* ANSI string types */
527 typedef CHAR *PCH, *LPCH, *PNZCH;
528 typedef const CHAR *PCCH, *LPCCH, *PCNZCH;
529 typedef CHAR *PSTR, *LPSTR, *NPSTR;
530 typedef const CHAR *PCSTR, *LPCSTR;
531 typedef CHAR *PZZSTR;
532 typedef const CHAR *PCZZSTR;
534 /* Unicode string types */
535 typedef const WCHAR *PCWCHAR, *LPCUWCHAR, *PCUWCHAR;
536 typedef WCHAR *PWCH, *LPWCH;
537 typedef const WCHAR *PCWCH, *LPCWCH;
538 typedef WCHAR *PNZWCH, *PUNZWCH;
539 typedef const WCHAR *PCNZWCH, *PCUNZWCH;
540 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
541 typedef const WCHAR *PCWSTR, *LPCWSTR;
542 typedef WCHAR *PZZWSTR, *PUZZWSTR;
543 typedef const WCHAR *PCZZWSTR, *PCUZZWSTR;
544 typedef PWSTR *PZPWSTR;
545 typedef PCWSTR *PZPCWSTR;
547 /* Neutral character and string types */
548 /* These are only defined for Winelib, i.e. _not_ defined for
549 * the emulator. The reason is they depend on the UNICODE
550 * macro which only exists in the user's code.
552 #ifndef WINE_NO_UNICODE_MACROS
553 # ifdef UNICODE
554 # ifndef _TCHAR_DEFINED
555 typedef WCHAR TCHAR, *PTCHAR;
556 # define _TCHAR_DEFINED
557 #endif
558 typedef LPWCH PTCH, LPTCH;
559 typedef LPCWCH PCTCH, LPCTCH;
560 typedef LPWSTR PTSTR, LPTSTR;
561 typedef LPCWSTR PCTSTR, LPCTSTR;
562 typedef LPWSTR PUTSTR, LPUTSTR;
563 typedef LPCWSTR PCUTSTR, LPCUTSTR;
564 typedef PNZWCH PNZTCH;
565 typedef PUNZWCH PUNZTCH;
566 typedef PCNZWCH PCNZTCH;
567 typedef PCUNZWCH PCUNZTCH;
568 typedef PZZWSTR PZZTSTR;
569 typedef PCZZWSTR PCZZTSTR;
570 typedef PUZZWSTR PUZZTSTR;
571 typedef PCUZZWSTR PCUZZTSTR;
572 # else /* UNICODE */
573 # ifndef _TCHAR_DEFINED
574 typedef CHAR TCHAR, *PTCHAR;
575 # define _TCHAR_DEFINED
576 # endif
577 typedef LPCH PTCH, LPTCH;
578 typedef LPCCH PCTCH, LPCTCH;
579 typedef LPSTR PTSTR, LPTSTR;
580 typedef LPCSTR PCTSTR, LPCTSTR;
581 typedef PNZCH PNZTCH, PUNZTCH;
582 typedef PCNZCH PCNZTCH, PCUNZTCH;
583 typedef PZZSTR PZZTSTR, PUZZTSTR;
584 typedef PCZZSTR PCZZTSTR, PCUZZTSTR;
585 # endif /* UNICODE */
586 #endif /* WINE_NO_UNICODE_MACROS */
588 /* UCS string types */
589 typedef UCSCHAR *PUCSCHAR, *PUUCSCHAR;
590 typedef const UCSCHAR *PCUCSCHAR, *PCUUCSCHAR;
591 typedef UCSCHAR *PUCSSTR, *PUUCSSTR;
592 typedef const UCSCHAR *PCUCSSTR, *PCUUCSSTR;
594 /* Misc common WIN32 types */
595 typedef char CCHAR;
596 typedef DWORD LCID, *PLCID;
597 typedef WORD LANGID;
598 typedef DWORD EXECUTION_STATE;
599 #ifndef _HRESULT_DEFINED
600 #define _HRESULT_DEFINED
601 typedef LONG HRESULT;
602 #endif
604 /* Handle type */
606 typedef void *HANDLE;
607 typedef HANDLE *PHANDLE, *LPHANDLE;
609 #ifdef STRICT
610 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
611 #else /*STRICT*/
612 #define DECLARE_HANDLE(a) typedef HANDLE a
613 #endif /*STRICT*/
615 typedef BYTE FCHAR;
616 typedef WORD FSHORT;
617 typedef DWORD FLONG;
619 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
620 #ifndef __MSABI_LONG
621 #if !defined(__LP64__) && !defined(WINE_NO_LONG_TYPES)
622 # define __MSABI_LONG(x) x ## l
623 # else
624 # define __MSABI_LONG(x) x
625 # endif
626 #endif
628 /* Defines */
630 #ifndef WIN32_NO_STATUS
632 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
633 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
634 #define STATUS_USER_APC ((DWORD) 0x000000C0)
635 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
636 #define STATUS_PENDING ((DWORD) 0x00000103)
637 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
638 #define STATUS_FATAL_APP_EXIT ((DWORD) 0x40000015)
639 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
640 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
641 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
642 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
643 #define STATUS_LONGJUMP ((DWORD) 0x80000026)
644 #define STATUS_UNWIND_CONSOLIDATE ((DWORD) 0x80000029)
645 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
646 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
647 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
648 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
649 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
650 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
651 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
652 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
653 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
654 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
655 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
656 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
657 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
658 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
659 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
660 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
661 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
662 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
663 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
664 #define STATUS_DLL_NOT_FOUND ((DWORD) 0xC0000135)
665 #define STATUS_ORDINAL_NOT_FOUND ((DWORD) 0xC0000138)
666 #define STATUS_ENTRYPOINT_NOT_FOUND ((DWORD) 0xC0000139)
667 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
668 #define STATUS_DLL_INIT_FAILED ((DWORD) 0xC0000142)
669 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
670 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
671 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
672 #define STATUS_HEAP_CORRUPTION ((DWORD) 0xC0000374)
673 #define STATUS_STACK_BUFFER_OVERRUN ((DWORD) 0xC0000409)
674 #define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD) 0xC0000417)
675 #define STATUS_ASSERTION_FAILURE ((DWORD) 0xC0000420)
676 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
677 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
679 /* status values for ContinueDebugEvent */
680 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
681 #define DBG_CONTINUE ((DWORD) 0x00010002)
682 #define DBG_REPLY_LATER ((DWORD) 0x40010001)
683 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
684 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
685 #define DBG_CONTROL_C ((DWORD) 0x40010005)
686 #define DBG_PRINTEXCEPTION_C ((DWORD) 0x40010006)
687 #define DBG_RIPEXCEPTION ((DWORD) 0x40010007)
688 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
689 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
690 #define DBG_PRINTEXCEPTION_WIDE_C ((DWORD) 0x4001000A)
691 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
693 #endif /* WIN32_NO_STATUS */
695 /* Argument 1 passed to the DllEntryProc. */
696 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
697 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
698 #define DLL_THREAD_ATTACH 2 /* attach new thread */
699 #define DLL_THREAD_DETACH 3 /* detach thread */
701 /* u.x.wProcessorArchitecture (NT) */
702 #define PROCESSOR_ARCHITECTURE_INTEL 0
703 #define PROCESSOR_ARCHITECTURE_MIPS 1
704 #define PROCESSOR_ARCHITECTURE_ALPHA 2
705 #define PROCESSOR_ARCHITECTURE_PPC 3
706 #define PROCESSOR_ARCHITECTURE_SHX 4
707 #define PROCESSOR_ARCHITECTURE_ARM 5
708 #define PROCESSOR_ARCHITECTURE_IA64 6
709 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
710 #define PROCESSOR_ARCHITECTURE_MSIL 8
711 #define PROCESSOR_ARCHITECTURE_AMD64 9
712 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
713 #define PROCESSOR_ARCHITECTURE_NEUTRAL 11
714 #define PROCESSOR_ARCHITECTURE_ARM64 12
715 #define PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64 13
716 #define PROCESSOR_ARCHITECTURE_IA32_ON_ARM64 14
717 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
719 /* dwProcessorType */
720 #define PROCESSOR_INTEL_386 386
721 #define PROCESSOR_INTEL_486 486
722 #define PROCESSOR_INTEL_PENTIUM 586
723 #define PROCESSOR_INTEL_860 860
724 #define PROCESSOR_INTEL_IA64 2200
725 #define PROCESSOR_AMD_X8664 8664
726 #define PROCESSOR_MIPS_R2000 2000
727 #define PROCESSOR_MIPS_R3000 3000
728 #define PROCESSOR_MIPS_R4000 4000
729 #define PROCESSOR_ALPHA_21064 21064
730 #define PROCESSOR_PPC_601 601
731 #define PROCESSOR_PPC_603 603
732 #define PROCESSOR_PPC_604 604
733 #define PROCESSOR_PPC_620 620
734 #define PROCESSOR_HITACHI_SH3 10003
735 #define PROCESSOR_HITACHI_SH3E 10004
736 #define PROCESSOR_HITACHI_SH4 10005
737 #define PROCESSOR_MOTOROLA_821 821
738 #define PROCESSOR_SHx_SH3 103
739 #define PROCESSOR_SHx_SH4 104
740 #define PROCESSOR_STRONGARM 2577
741 #define PROCESSOR_ARM720 1824 /* 0x720 */
742 #define PROCESSOR_ARM820 2080 /* 0x820 */
743 #define PROCESSOR_ARM920 2336 /* 0x920 */
744 #define PROCESSOR_ARM_7TDMI 70001
745 #define PROCESSOR_OPTIL 18767
747 #ifdef _WIN64
748 #define MAXIMUM_PROCESSORS 64
749 #else
750 #define MAXIMUM_PROCESSORS 32
751 #endif
753 typedef struct _MEMORY_BASIC_INFORMATION
755 LPVOID BaseAddress;
756 LPVOID AllocationBase;
757 DWORD AllocationProtect;
758 SIZE_T RegionSize;
759 DWORD State;
760 DWORD Protect;
761 DWORD Type;
762 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
764 typedef struct _MEM_ADDRESS_REQUIREMENTS
766 void *LowestStartingAddress;
767 void *HighestEndingAddress;
768 SIZE_T Alignment;
769 } MEM_ADDRESS_REQUIREMENTS, *PMEM_ADDRESS_REQUIREMENTS;
771 #define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
773 typedef enum MEM_EXTENDED_PARAMETER_TYPE {
774 MemExtendedParameterInvalidType = 0,
775 MemExtendedParameterAddressRequirements,
776 MemExtendedParameterNumaNode,
777 MemExtendedParameterPartitionHandle,
778 MemExtendedParameterUserPhysicalHandle,
779 MemExtendedParameterAttributeFlags,
780 MemExtendedParameterMax
781 } MEM_EXTENDED_PARAMETER_TYPE, *PMEM_EXTENDED_PARAMETER_TYPE;
783 typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER {
784 struct
786 DWORD64 Type : MEM_EXTENDED_PARAMETER_TYPE_BITS;
787 DWORD64 Reserved : 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS;
788 } DUMMYSTRUCTNAME;
790 union
792 DWORD64 ULong64;
793 PVOID Pointer;
794 SIZE_T Size;
795 HANDLE Handle;
796 DWORD ULong;
797 } DUMMYUNIONNAME;
798 } MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;
800 #define PAGE_NOACCESS 0x01
801 #define PAGE_READONLY 0x02
802 #define PAGE_READWRITE 0x04
803 #define PAGE_WRITECOPY 0x08
804 #define PAGE_EXECUTE 0x10
805 #define PAGE_EXECUTE_READ 0x20
806 #define PAGE_EXECUTE_READWRITE 0x40
807 #define PAGE_EXECUTE_WRITECOPY 0x80
808 #define PAGE_GUARD 0x100
809 #define PAGE_NOCACHE 0x200
810 #define PAGE_WRITECOMBINE 0x400
812 #define MEM_COMMIT 0x00001000
813 #define MEM_RESERVE 0x00002000
814 #define MEM_REPLACE_PLACEHOLDER 0x00004000
815 #define MEM_RESERVE_PLACEHOLDER 0x00040000
816 #define MEM_RESET 0x00080000
817 #define MEM_TOP_DOWN 0x00100000
818 #define MEM_PHYSICAL 0x00400000
819 #define MEM_RESET_UNDO 0x10000000
820 #define MEM_LARGE_PAGES 0x20000000
822 #define MEM_COALESCE_PLACEHOLDERS 0x00000001
823 #define MEM_PRESERVE_PLACEHOLDER 0x00000002
824 #define MEM_DECOMMIT 0x00004000
825 #define MEM_RELEASE 0x00008000
827 #define MEM_FREE 0x00010000
828 #define MEM_PRIVATE 0x00020000
829 #define MEM_MAPPED 0x00040000
830 #define MEM_WRITE_WATCH 0x00200000
831 #define MEM_4MB_PAGES 0x80000000
833 #define SEC_FILE 0x00800000
834 #define SEC_IMAGE 0x01000000
835 #define SEC_PROTECTED_IMAGE 0x02000000
836 #define SEC_RESERVE 0x04000000
837 #define SEC_COMMIT 0x08000000
838 #define SEC_NOCACHE 0x10000000
839 #define SEC_WRITECOMBINE 0x40000000
840 #define SEC_LARGE_PAGES 0x80000000
841 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
842 #define MEM_IMAGE SEC_IMAGE
844 #define WRITE_WATCH_FLAG_RESET 0x00000001
846 #define AT_ROUND_TO_PAGE 0x40000000
848 #define MINCHAR 0x80
849 #define MAXCHAR 0x7f
850 #define MINSHORT 0x8000
851 #define MAXSHORT 0x7fff
852 #define MINLONG 0x80000000
853 #define MAXLONG 0x7fffffff
854 #define MAXBYTE 0xff
855 #define MAXWORD 0xffff
856 #define MAXDWORD 0xffffffff
857 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
859 #define UNICODE_STRING_MAX_CHARS 32767
861 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
862 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
863 #define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
865 #define CONTAINING_RECORD(address, type, field) \
866 ((type *)((PCHAR)(address) - offsetof(type, field)))
868 #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
869 #ifdef __WINESRC__
870 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
871 #endif
873 /* Types */
875 typedef struct _LIST_ENTRY {
876 struct _LIST_ENTRY *Flink;
877 struct _LIST_ENTRY *Blink;
878 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
880 typedef struct _SINGLE_LIST_ENTRY {
881 struct _SINGLE_LIST_ENTRY *Next;
882 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
884 #ifdef _WIN64
886 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
887 struct _SLIST_ENTRY *Next;
888 } SLIST_ENTRY, *PSLIST_ENTRY;
890 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
891 struct {
892 ULONGLONG Alignment;
893 ULONGLONG Region;
894 } DUMMYSTRUCTNAME;
895 struct {
896 ULONGLONG Depth:16;
897 ULONGLONG Sequence:9;
898 ULONGLONG NextEntry:39;
899 ULONGLONG HeaderType:1;
900 ULONGLONG Init:1;
901 ULONGLONG Reserved:59;
902 ULONGLONG Region:3;
903 } Header8;
904 struct {
905 ULONGLONG Depth:16;
906 ULONGLONG Sequence:48;
907 ULONGLONG HeaderType:1;
908 ULONGLONG Init:1;
909 ULONGLONG Reserved:2;
910 ULONGLONG NextEntry:60;
911 } Header16;
912 } SLIST_HEADER, *PSLIST_HEADER;
914 #else
916 #undef SLIST_ENTRY /* for Mac OS */
917 #define SLIST_ENTRY SINGLE_LIST_ENTRY
918 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
919 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
921 typedef union _SLIST_HEADER {
922 ULONGLONG Alignment;
923 struct {
924 SLIST_ENTRY Next;
925 WORD Depth;
926 WORD Sequence;
927 } DUMMYSTRUCTNAME;
928 } SLIST_HEADER, *PSLIST_HEADER;
930 #endif
932 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
933 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
934 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
935 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
936 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
937 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
940 /* Fast fail (__fastfail) codes */
942 #define FAST_FAIL_LEGACY_GS_VIOLATION 0
943 #define FAST_FAIL_VTGUARD_CHECK_FAILURE 1
944 #define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2
945 #define FAST_FAIL_CORRUPT_LIST_ENTRY 3
946 #define FAST_FAIL_INCORRECT_STACK 4
947 #define FAST_FAIL_INVALID_ARG 5
948 #define FAST_FAIL_GS_COOKIE_INIT 6
949 #define FAST_FAIL_FATAL_APP_EXIT 7
950 #define FAST_FAIL_RANGE_CHECK_FAILURE 8
951 #define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9
952 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10
953 #define FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11
954 #define FAST_FAIL_INVALID_FIBER_SWITCH 12
955 #define FAST_FAIL_INVALID_SET_OF_CONTEXT 13
956 #define FAST_FAIL_INVALID_REFERENCE_COUNT 14
957 #define FAST_FAIL_INVALID_JUMP_BUFFER 18
958 #define FAST_FAIL_MRDATA_MODIFIED 19
959 #define FAST_FAIL_CERTIFICATION_FAILURE 20
960 #define FAST_FAIL_INVALID_EXCEPTION_CHAIN 21
961 #define FAST_FAIL_CRYPTO_LIBRARY 22
962 #define FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT 23
963 #define FAST_FAIL_INVALID_IMAGE_BASE 24
964 #define FAST_FAIL_DLOAD_PROTECTION_FAILURE 25
965 #define FAST_FAIL_UNSAFE_EXTENSION_CALL 26
966 #define FAST_FAIL_DEPRECATED_SERVICE_INVOKED 27
967 #define FAST_FAIL_INVALID_BUFFER_ACCESS 28
968 #define FAST_FAIL_INVALID_BALANCED_TREE 29
969 #define FAST_FAIL_INVALID_NEXT_THREAD 30
970 #define FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED 31
971 #define FAST_FAIL_APCS_DISABLED 32
972 #define FAST_FAIL_INVALID_IDLE_STATE 33
973 #define FAST_FAIL_MRDATA_PROTECTION_FAILURE 34
974 #define FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION 35
975 #define FAST_FAIL_INVALID_LOCK_STATE 36
976 #define FAST_FAIL_GUARD_JUMPTABLE 37
977 #define FAST_FAIL_INVALID_LONGJUMP_TARGET 38
978 #define FAST_FAIL_INVALID_DISPATCH_CONTEXT 39
979 #define FAST_FAIL_INVALID_THREAD 40
980 #define FAST_FAIL_INVALID_SYSCALL_NUMBER 41
981 #define FAST_FAIL_INVALID_FILE_OPERATION 42
982 #define FAST_FAIL_LPAC_ACCESS_DENIED 43
983 #define FAST_FAIL_GUARD_SS_FAILURE 44
984 #define FAST_FAIL_LOADER_CONTINUITY_FAILURE 45
985 #define FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE 46
986 #define FAST_FAIL_INVALID_CONTROL_STACK 47
987 #define FAST_FAIL_SET_CONTEXT_DENIED 48
988 #define FAST_FAIL_INVALID_IAT 49
989 #define FAST_FAIL_HEAP_METADATA_CORRUPTION 50
990 #define FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION 51
991 #define FAST_FAIL_LOW_LABEL_ACCESS_DENIED 52
992 #define FAST_FAIL_ENCLAVE_CALL_FAILURE 53
993 #define FAST_FAIL_UNHANDLED_LSS_EXCEPTON 54
994 #define FAST_FAIL_ADMINLESS_ACCESS_DENIED 55
995 #define FAST_FAIL_UNEXPECTED_CALL 56
996 #define FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS 57
997 #define FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR 58
998 #define FAST_FAIL_FLAGS_CORRUPTION 59
999 #define FAST_FAIL_VEH_CORRUPTION 60
1000 #define FAST_FAIL_ETW_CORRUPTION 61
1001 #define FAST_FAIL_RIO_ABORT 62
1002 #define FAST_FAIL_INVALID_PFN 63
1003 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE_XFG 64
1004 #define FAST_FAIL_CAST_GUARD 65
1005 #define FAST_FAIL_HOST_VISIBILITY_CHANGE 66
1006 #define FAST_FAIL_KERNEL_CET_SHADOW_STACK_ASSIST 67
1007 #define FAST_FAIL_PATCH_CALLBACK_FAILED 68
1008 #define FAST_FAIL_NTDLL_PATCH_FAILED 69
1009 #define FAST_FAIL_INVALID_FLS_DATA 70
1010 #define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xFFFFFFFF
1012 /* Heap flags */
1014 #define HEAP_NO_SERIALIZE 0x00000001
1015 #define HEAP_GROWABLE 0x00000002
1016 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
1017 #define HEAP_ZERO_MEMORY 0x00000008
1018 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
1019 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
1020 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
1021 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
1022 #define HEAP_CREATE_ALIGN_16 0x00010000
1023 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
1024 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
1026 /* This flag allows it to create heaps shared by all processes under win95,
1027 FIXME: correct name */
1028 #define HEAP_SHARED 0x04000000
1030 typedef enum _HEAP_INFORMATION_CLASS {
1031 HeapCompatibilityInformation,
1032 } HEAP_INFORMATION_CLASS;
1034 /* Processor feature flags. */
1035 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
1036 #define PF_FLOATING_POINT_EMULATED 1
1037 #define PF_COMPARE_EXCHANGE_DOUBLE 2
1038 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
1039 #define PF_PPC_MOVEMEM_64BIT_OK 4
1040 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
1041 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
1042 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
1043 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
1044 #define PF_PAE_ENABLED 9
1045 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
1046 #define PF_SSE_DAZ_MODE_AVAILABLE 11
1047 #define PF_NX_ENABLED 12
1048 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
1049 #define PF_COMPARE_EXCHANGE128 14
1050 #define PF_COMPARE64_EXCHANGE128 15
1051 #define PF_CHANNELS_ENABLED 16
1052 #define PF_XSAVE_ENABLED 17
1053 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
1054 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
1055 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
1056 #define PF_VIRT_FIRMWARE_ENABLED 21
1057 #define PF_RDWRFSGSBASE_AVAILABLE 22
1058 #define PF_FASTFAIL_AVAILABLE 23
1059 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
1060 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
1061 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
1062 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
1063 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
1064 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
1065 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
1066 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
1067 #define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
1068 #define PF_RDPID_INSTRUCTION_AVAILABLE 33
1069 #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
1070 #define PF_MONITORX_INSTRUCTION_AVAILABLE 35
1071 #define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
1072 #define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
1073 #define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
1074 #define PF_AVX_INSTRUCTIONS_AVAILABLE 39
1075 #define PF_AVX2_INSTRUCTIONS_AVAILABLE 40
1076 #define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
1077 #define PF_ERMS_AVAILABLE 42
1078 #define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43
1079 #define PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE 44
1080 #define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45
1083 /* Execution state flags */
1084 #define ES_SYSTEM_REQUIRED 0x00000001
1085 #define ES_DISPLAY_REQUIRED 0x00000002
1086 #define ES_USER_PRESENT 0x00000004
1087 #define ES_CONTINUOUS 0x80000000
1089 #include <excpt.h>
1091 /* The Win32 register context */
1093 /* i386 context definitions */
1095 #define I386_SIZE_OF_80387_REGISTERS 80
1097 typedef struct _I386_FLOATING_SAVE_AREA
1099 DWORD ControlWord;
1100 DWORD StatusWord;
1101 DWORD TagWord;
1102 DWORD ErrorOffset;
1103 DWORD ErrorSelector;
1104 DWORD DataOffset;
1105 DWORD DataSelector;
1106 BYTE RegisterArea[I386_SIZE_OF_80387_REGISTERS];
1107 DWORD Cr0NpxState;
1108 } I386_FLOATING_SAVE_AREA, WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
1110 #define I386_MAXIMUM_SUPPORTED_EXTENSION 512
1112 #include "pshpack4.h"
1113 typedef struct _I386_CONTEXT
1115 DWORD ContextFlags; /* 000 */
1117 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1118 DWORD Dr0; /* 004 */
1119 DWORD Dr1; /* 008 */
1120 DWORD Dr2; /* 00c */
1121 DWORD Dr3; /* 010 */
1122 DWORD Dr6; /* 014 */
1123 DWORD Dr7; /* 018 */
1125 /* These are selected by CONTEXT_FLOATING_POINT */
1126 I386_FLOATING_SAVE_AREA FloatSave; /* 01c */
1128 /* These are selected by CONTEXT_SEGMENTS */
1129 DWORD SegGs; /* 08c */
1130 DWORD SegFs; /* 090 */
1131 DWORD SegEs; /* 094 */
1132 DWORD SegDs; /* 098 */
1134 /* These are selected by CONTEXT_INTEGER */
1135 DWORD Edi; /* 09c */
1136 DWORD Esi; /* 0a0 */
1137 DWORD Ebx; /* 0a4 */
1138 DWORD Edx; /* 0a8 */
1139 DWORD Ecx; /* 0ac */
1140 DWORD Eax; /* 0b0 */
1142 /* These are selected by CONTEXT_CONTROL */
1143 DWORD Ebp; /* 0b4 */
1144 DWORD Eip; /* 0b8 */
1145 DWORD SegCs; /* 0bc */
1146 DWORD EFlags; /* 0c0 */
1147 DWORD Esp; /* 0c4 */
1148 DWORD SegSs; /* 0c8 */
1150 BYTE ExtendedRegisters[I386_MAXIMUM_SUPPORTED_EXTENSION]; /* 0xcc */
1151 } I386_CONTEXT, WOW64_CONTEXT, *PWOW64_CONTEXT;
1152 #include "poppack.h"
1154 #define CONTEXT_i386 0x00010000
1155 #define CONTEXT_i486 0x00010000
1157 #define CONTEXT_I386_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1158 #define CONTEXT_I386_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1159 #define CONTEXT_I386_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1160 #define CONTEXT_I386_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1161 #define CONTEXT_I386_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1162 #define CONTEXT_I386_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1163 #define CONTEXT_I386_XSTATE (CONTEXT_i386 | 0x0040)
1164 #define CONTEXT_I386_FULL (CONTEXT_I386_CONTROL | CONTEXT_I386_INTEGER | CONTEXT_I386_SEGMENTS)
1165 #define CONTEXT_I386_ALL (CONTEXT_I386_FULL | CONTEXT_I386_FLOATING_POINT | CONTEXT_I386_DEBUG_REGISTERS | CONTEXT_I386_EXTENDED_REGISTERS)
1167 #ifdef __i386__
1169 #define CONTEXT_CONTROL CONTEXT_I386_CONTROL
1170 #define CONTEXT_INTEGER CONTEXT_I386_INTEGER
1171 #define CONTEXT_SEGMENTS CONTEXT_I386_SEGMENTS
1172 #define CONTEXT_FLOATING_POINT CONTEXT_I386_FLOATING_POINT
1173 #define CONTEXT_DEBUG_REGISTERS CONTEXT_I386_DEBUG_REGISTERS
1174 #define CONTEXT_EXTENDED_REGISTERS CONTEXT_I386_EXTENDED_REGISTERS
1175 #define CONTEXT_XSTATE CONTEXT_I386_XSTATE
1176 #define CONTEXT_FULL CONTEXT_I386_FULL
1177 #define CONTEXT_ALL CONTEXT_I386_ALL
1178 #define SIZE_OF_80387_REGISTERS I386_SIZE_OF_80387_REGISTERS
1179 #define MAXIMUM_SUPPORTED_EXTENSION I386_MAXIMUM_SUPPORTED_EXTENSION
1181 typedef I386_FLOATING_SAVE_AREA FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1182 typedef I386_CONTEXT CONTEXT, *PCONTEXT;
1184 #endif /* __i386__ */
1186 typedef struct _LDT_ENTRY {
1187 WORD LimitLow;
1188 WORD BaseLow;
1189 union {
1190 struct {
1191 BYTE BaseMid;
1192 BYTE Flags1;
1193 BYTE Flags2;
1194 BYTE BaseHi;
1195 } Bytes;
1196 struct {
1197 unsigned BaseMid: 8;
1198 unsigned Type : 5;
1199 unsigned Dpl : 2;
1200 unsigned Pres : 1;
1201 unsigned LimitHi : 4;
1202 unsigned Sys : 1;
1203 unsigned Reserved_0 : 1;
1204 unsigned Default_Big : 1;
1205 unsigned Granularity : 1;
1206 unsigned BaseHi : 8;
1207 } Bits;
1208 } HighWord;
1209 } LDT_ENTRY, *PLDT_ENTRY, WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
1211 typedef struct DECLSPEC_ALIGN(16) _M128A {
1212 ULONGLONG Low;
1213 LONGLONG High;
1214 } M128A, *PM128A;
1216 typedef struct _XSAVE_FORMAT {
1217 WORD ControlWord; /* 000 */
1218 WORD StatusWord; /* 002 */
1219 BYTE TagWord; /* 004 */
1220 BYTE Reserved1; /* 005 */
1221 WORD ErrorOpcode; /* 006 */
1222 DWORD ErrorOffset; /* 008 */
1223 WORD ErrorSelector; /* 00c */
1224 WORD Reserved2; /* 00e */
1225 DWORD DataOffset; /* 010 */
1226 WORD DataSelector; /* 014 */
1227 WORD Reserved3; /* 016 */
1228 DWORD MxCsr; /* 018 */
1229 DWORD MxCsr_Mask; /* 01c */
1230 M128A FloatRegisters[8]; /* 020 */
1231 M128A XmmRegisters[16]; /* 0a0 */
1232 BYTE Reserved4[96]; /* 1a0 */
1233 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1235 /* x86-64 context definitions */
1237 typedef struct _AMD64_RUNTIME_FUNCTION
1239 DWORD BeginAddress;
1240 DWORD EndAddress;
1241 DWORD UnwindData;
1242 } AMD64_RUNTIME_FUNCTION;
1244 #define CONTEXT_AMD64 0x00100000
1246 #define CONTEXT_AMD64_CONTROL (CONTEXT_AMD64 | 0x0001)
1247 #define CONTEXT_AMD64_INTEGER (CONTEXT_AMD64 | 0x0002)
1248 #define CONTEXT_AMD64_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1249 #define CONTEXT_AMD64_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1250 #define CONTEXT_AMD64_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1251 #define CONTEXT_AMD64_XSTATE (CONTEXT_AMD64 | 0x0040)
1252 #define CONTEXT_AMD64_FULL (CONTEXT_AMD64_CONTROL | CONTEXT_AMD64_INTEGER | CONTEXT_AMD64_FLOATING_POINT)
1253 #define CONTEXT_AMD64_ALL (CONTEXT_AMD64_CONTROL | CONTEXT_AMD64_INTEGER | CONTEXT_AMD64_SEGMENTS | CONTEXT_AMD64_FLOATING_POINT | CONTEXT_AMD64_DEBUG_REGISTERS)
1255 typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1257 typedef struct DECLSPEC_ALIGN(16) _AMD64_CONTEXT {
1258 DWORD64 P1Home; /* 000 */
1259 DWORD64 P2Home; /* 008 */
1260 DWORD64 P3Home; /* 010 */
1261 DWORD64 P4Home; /* 018 */
1262 DWORD64 P5Home; /* 020 */
1263 DWORD64 P6Home; /* 028 */
1265 /* Control flags */
1266 DWORD ContextFlags; /* 030 */
1267 DWORD MxCsr; /* 034 */
1269 /* Segment */
1270 WORD SegCs; /* 038 */
1271 WORD SegDs; /* 03a */
1272 WORD SegEs; /* 03c */
1273 WORD SegFs; /* 03e */
1274 WORD SegGs; /* 040 */
1275 WORD SegSs; /* 042 */
1276 DWORD EFlags; /* 044 */
1278 /* Debug */
1279 DWORD64 Dr0; /* 048 */
1280 DWORD64 Dr1; /* 050 */
1281 DWORD64 Dr2; /* 058 */
1282 DWORD64 Dr3; /* 060 */
1283 DWORD64 Dr6; /* 068 */
1284 DWORD64 Dr7; /* 070 */
1286 /* Integer */
1287 DWORD64 Rax; /* 078 */
1288 DWORD64 Rcx; /* 080 */
1289 DWORD64 Rdx; /* 088 */
1290 DWORD64 Rbx; /* 090 */
1291 DWORD64 Rsp; /* 098 */
1292 DWORD64 Rbp; /* 0a0 */
1293 DWORD64 Rsi; /* 0a8 */
1294 DWORD64 Rdi; /* 0b0 */
1295 DWORD64 R8; /* 0b8 */
1296 DWORD64 R9; /* 0c0 */
1297 DWORD64 R10; /* 0c8 */
1298 DWORD64 R11; /* 0d0 */
1299 DWORD64 R12; /* 0d8 */
1300 DWORD64 R13; /* 0e0 */
1301 DWORD64 R14; /* 0e8 */
1302 DWORD64 R15; /* 0f0 */
1304 /* Counter */
1305 DWORD64 Rip; /* 0f8 */
1307 /* Floating point */
1308 union {
1309 XMM_SAVE_AREA32 FltSave; /* 100 */
1310 struct {
1311 M128A Header[2]; /* 100 */
1312 M128A Legacy[8]; /* 120 */
1313 M128A Xmm0; /* 1a0 */
1314 M128A Xmm1; /* 1b0 */
1315 M128A Xmm2; /* 1c0 */
1316 M128A Xmm3; /* 1d0 */
1317 M128A Xmm4; /* 1e0 */
1318 M128A Xmm5; /* 1f0 */
1319 M128A Xmm6; /* 200 */
1320 M128A Xmm7; /* 210 */
1321 M128A Xmm8; /* 220 */
1322 M128A Xmm9; /* 230 */
1323 M128A Xmm10; /* 240 */
1324 M128A Xmm11; /* 250 */
1325 M128A Xmm12; /* 260 */
1326 M128A Xmm13; /* 270 */
1327 M128A Xmm14; /* 280 */
1328 M128A Xmm15; /* 290 */
1329 } DUMMYSTRUCTNAME;
1330 } DUMMYUNIONNAME;
1332 /* Vector */
1333 M128A VectorRegister[26]; /* 300 */
1334 DWORD64 VectorControl; /* 4a0 */
1336 /* Debug control */
1337 DWORD64 DebugControl; /* 4a8 */
1338 DWORD64 LastBranchToRip; /* 4b0 */
1339 DWORD64 LastBranchFromRip; /* 4b8 */
1340 DWORD64 LastExceptionToRip; /* 4c0 */
1341 DWORD64 LastExceptionFromRip; /* 4c8 */
1342 } AMD64_CONTEXT;
1344 #ifdef __x86_64__
1346 #define CONTEXT_CONTROL CONTEXT_AMD64_CONTROL
1347 #define CONTEXT_INTEGER CONTEXT_AMD64_INTEGER
1348 #define CONTEXT_SEGMENTS CONTEXT_AMD64_SEGMENTS
1349 #define CONTEXT_FLOATING_POINT CONTEXT_AMD64_FLOATING_POINT
1350 #define CONTEXT_DEBUG_REGISTERS CONTEXT_AMD64_DEBUG_REGISTERS
1351 #define CONTEXT_XSTATE CONTEXT_AMD64_XSTATE
1352 #define CONTEXT_FULL CONTEXT_AMD64_FULL
1353 #define CONTEXT_ALL CONTEXT_AMD64_ALL
1355 typedef AMD64_CONTEXT CONTEXT, *PCONTEXT;
1356 typedef AMD64_RUNTIME_FUNCTION RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1358 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1360 union
1362 PM128A FloatingContext[16];
1363 struct
1365 PM128A Xmm0;
1366 PM128A Xmm1;
1367 PM128A Xmm2;
1368 PM128A Xmm3;
1369 PM128A Xmm4;
1370 PM128A Xmm5;
1371 PM128A Xmm6;
1372 PM128A Xmm7;
1373 PM128A Xmm8;
1374 PM128A Xmm9;
1375 PM128A Xmm10;
1376 PM128A Xmm11;
1377 PM128A Xmm12;
1378 PM128A Xmm13;
1379 PM128A Xmm14;
1380 PM128A Xmm15;
1381 } DUMMYSTRUCTNAME;
1382 } DUMMYUNIONNAME;
1384 union
1386 PULONG64 IntegerContext[16];
1387 struct
1389 PULONG64 Rax;
1390 PULONG64 Rcx;
1391 PULONG64 Rdx;
1392 PULONG64 Rbx;
1393 PULONG64 Rsp;
1394 PULONG64 Rbp;
1395 PULONG64 Rsi;
1396 PULONG64 Rdi;
1397 PULONG64 R8;
1398 PULONG64 R9;
1399 PULONG64 R10;
1400 PULONG64 R11;
1401 PULONG64 R12;
1402 PULONG64 R13;
1403 PULONG64 R14;
1404 PULONG64 R15;
1405 } DUMMYSTRUCTNAME;
1406 } DUMMYUNIONNAME2;
1407 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1409 #endif /* __x86_64__ */
1411 #define XSTATE_LEGACY_FLOATING_POINT 0
1412 #define XSTATE_LEGACY_SSE 1
1413 #define XSTATE_GSSE 2
1414 #define XSTATE_AVX XSTATE_GSSE
1415 #define XSTATE_MPX_BNDREGS 3
1416 #define XSTATE_MPX_BNDCSR 4
1417 #define XSTATE_AVX512_KMASK 5
1418 #define XSTATE_AVX512_ZMM_H 6
1419 #define XSTATE_AVX512_ZMM 7
1420 #define XSTATE_IPT 8
1421 #define XSTATE_CET_U 11
1422 #define XSTATE_LWP 62
1423 #define MAXIMUM_XSTATE_FEATURES 64
1425 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1 << XSTATE_LEGACY_FLOATING_POINT)
1426 #define XSTATE_MASK_LEGACY_SSE (1 << XSTATE_LEGACY_SSE)
1427 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1428 #define XSTATE_MASK_GSSE (1 << XSTATE_GSSE)
1430 typedef struct _XSTATE_FEATURE
1432 ULONG Offset;
1433 ULONG Size;
1434 } XSTATE_FEATURE, *PXSTATE_FEATURE;
1436 typedef struct _XSTATE_CONFIGURATION
1438 ULONG64 EnabledFeatures;
1439 ULONG64 EnabledVolatileFeatures;
1440 ULONG Size;
1441 ULONG OptimizedSave:1;
1442 ULONG CompactionEnabled:1;
1443 XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
1445 ULONG64 EnabledSupervisorFeatures;
1446 ULONG64 AlignedFeatures;
1447 ULONG AllFeatureSize;
1448 ULONG AllFeatures[MAXIMUM_XSTATE_FEATURES];
1449 ULONG64 EnabledUserVisibleSupervisorFeatures;
1450 } XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION;
1452 typedef struct _YMMCONTEXT
1454 M128A Ymm0;
1455 M128A Ymm1;
1456 M128A Ymm2;
1457 M128A Ymm3;
1458 M128A Ymm4;
1459 M128A Ymm5;
1460 M128A Ymm6;
1461 M128A Ymm7;
1462 M128A Ymm8;
1463 M128A Ymm9;
1464 M128A Ymm10;
1465 M128A Ymm11;
1466 M128A Ymm12;
1467 M128A Ymm13;
1468 M128A Ymm14;
1469 M128A Ymm15;
1471 YMMCONTEXT, *PYMMCONTEXT;
1473 typedef struct _XSTATE
1475 ULONG64 Mask;
1476 ULONG64 CompactionMask;
1477 ULONG64 Reserved[6];
1478 YMMCONTEXT YmmContext;
1479 } XSTATE, *PXSTATE;
1481 typedef struct _CONTEXT_CHUNK
1483 LONG Offset;
1484 ULONG Length;
1485 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
1487 typedef struct _CONTEXT_EX
1489 CONTEXT_CHUNK All;
1490 CONTEXT_CHUNK Legacy;
1491 CONTEXT_CHUNK XState;
1492 #ifdef _WIN64
1493 ULONG64 align;
1494 #endif
1495 } CONTEXT_EX, *PCONTEXT_EX;
1497 #define CONTEXT_ARM 0x0200000
1498 #define CONTEXT_ARM_CONTROL (CONTEXT_ARM | 0x00000001)
1499 #define CONTEXT_ARM_INTEGER (CONTEXT_ARM | 0x00000002)
1500 #define CONTEXT_ARM_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1501 #define CONTEXT_ARM_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1502 #define CONTEXT_ARM_FULL (CONTEXT_ARM_CONTROL | CONTEXT_ARM_INTEGER)
1503 #define CONTEXT_ARM_ALL (CONTEXT_ARM_FULL | CONTEXT_ARM_FLOATING_POINT | CONTEXT_ARM_DEBUG_REGISTERS)
1505 #define ARM_MAX_BREAKPOINTS 8
1506 #define ARM_MAX_WATCHPOINTS 1
1508 typedef struct _IMAGE_ARM_RUNTIME_FUNCTION
1510 DWORD BeginAddress;
1511 union {
1512 DWORD UnwindData;
1513 struct {
1514 DWORD Flag : 2;
1515 DWORD FunctionLength : 11;
1516 DWORD Ret : 2;
1517 DWORD H : 1;
1518 DWORD Reg : 3;
1519 DWORD R : 1;
1520 DWORD L : 1;
1521 DWORD C : 1;
1522 DWORD StackAdjust : 10;
1523 } DUMMYSTRUCTNAME;
1524 } DUMMYUNIONNAME;
1525 } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY;
1527 typedef struct _ARM_NEON128
1529 ULONGLONG Low;
1530 LONGLONG High;
1531 } ARM_NEON128;
1533 typedef struct _ARM_CONTEXT
1535 ULONG ContextFlags; /* 000 */
1536 /* CONTEXT_INTEGER */
1537 ULONG R0; /* 004 */
1538 ULONG R1; /* 008 */
1539 ULONG R2; /* 00c */
1540 ULONG R3; /* 010 */
1541 ULONG R4; /* 014 */
1542 ULONG R5; /* 018 */
1543 ULONG R6; /* 01c */
1544 ULONG R7; /* 020 */
1545 ULONG R8; /* 024 */
1546 ULONG R9; /* 028 */
1547 ULONG R10; /* 02c */
1548 ULONG R11; /* 030 */
1549 ULONG R12; /* 034 */
1550 /* CONTEXT_CONTROL */
1551 ULONG Sp; /* 038 */
1552 ULONG Lr; /* 03c */
1553 ULONG Pc; /* 040 */
1554 ULONG Cpsr; /* 044 */
1555 /* CONTEXT_FLOATING_POINT */
1556 ULONG Fpscr; /* 048 */
1557 ULONG Padding; /* 04c */
1558 union
1560 ARM_NEON128 Q[16];
1561 ULONGLONG D[32];
1562 ULONG S[32];
1563 } DUMMYUNIONNAME; /* 050 */
1564 /* CONTEXT_DEBUG_REGISTERS */
1565 ULONG Bvr[ARM_MAX_BREAKPOINTS]; /* 150 */
1566 ULONG Bcr[ARM_MAX_BREAKPOINTS]; /* 170 */
1567 ULONG Wvr[ARM_MAX_WATCHPOINTS]; /* 190 */
1568 ULONG Wcr[ARM_MAX_WATCHPOINTS]; /* 194 */
1569 ULONG Padding2[2]; /* 198 */
1570 } ARM_CONTEXT;
1572 #ifdef __arm__
1574 #define CONTEXT_CONTROL CONTEXT_ARM_CONTROL
1575 #define CONTEXT_INTEGER CONTEXT_ARM_INTEGER
1576 #define CONTEXT_FLOATING_POINT CONTEXT_ARM_FLOATING_POINT
1577 #define CONTEXT_DEBUG_REGISTERS CONTEXT_ARM_DEBUG_REGISTERS
1578 #define CONTEXT_FULL CONTEXT_ARM_FULL
1579 #define CONTEXT_ALL CONTEXT_ARM_ALL
1581 typedef IMAGE_ARM_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1582 typedef ARM_NEON128 NEON128, *PNEON128;
1583 typedef ARM_CONTEXT CONTEXT, *PCONTEXT;
1585 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1587 PDWORD R4;
1588 PDWORD R5;
1589 PDWORD R6;
1590 PDWORD R7;
1591 PDWORD R8;
1592 PDWORD R9;
1593 PDWORD R10;
1594 PDWORD R11;
1595 PDWORD Lr;
1596 PULONGLONG D8;
1597 PULONGLONG D9;
1598 PULONGLONG D10;
1599 PULONGLONG D11;
1600 PULONGLONG D12;
1601 PULONGLONG D13;
1602 PULONGLONG D14;
1603 PULONGLONG D15;
1604 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1606 #endif /* __arm__ */
1608 #define CONTEXT_ARM64 0x400000
1609 #define CONTEXT_ARM64_CONTROL (CONTEXT_ARM64 | 0x00000001)
1610 #define CONTEXT_ARM64_INTEGER (CONTEXT_ARM64 | 0x00000002)
1611 #define CONTEXT_ARM64_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1612 #define CONTEXT_ARM64_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1613 #define CONTEXT_ARM64_X18 (CONTEXT_ARM64 | 0x00000010)
1614 #define CONTEXT_ARM64_FULL (CONTEXT_ARM64_CONTROL | CONTEXT_ARM64_INTEGER | CONTEXT_ARM64_FLOATING_POINT)
1615 #define CONTEXT_ARM64_ALL (CONTEXT_ARM64_FULL | CONTEXT_ARM64_DEBUG_REGISTERS | CONTEXT_ARM64_X18)
1617 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1619 #define ARM64_MAX_BREAKPOINTS 8
1620 #define ARM64_MAX_WATCHPOINTS 2
1622 typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY
1624 DWORD BeginAddress;
1625 union
1627 DWORD UnwindData;
1628 struct
1630 DWORD Flag : 2;
1631 DWORD FunctionLength : 11;
1632 DWORD RegF : 3;
1633 DWORD RegI : 4;
1634 DWORD H : 1;
1635 DWORD CR : 2;
1636 DWORD FrameSize : 9;
1637 } DUMMYSTRUCTNAME;
1638 } DUMMYUNIONNAME;
1639 } IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;
1641 typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY ARM64_RUNTIME_FUNCTION, *PARM64_RUNTIME_FUNCTION;
1643 typedef union _ARM64_NT_NEON128
1645 struct
1647 ULONGLONG Low;
1648 LONGLONG High;
1649 } DUMMYSTRUCTNAME;
1650 double D[2];
1651 float S[4];
1652 WORD H[8];
1653 BYTE B[16];
1654 } ARM64_NT_NEON128, *PARM64_NT_NEON128;
1656 typedef struct DECLSPEC_ALIGN(16) _ARM64_NT_CONTEXT
1658 ULONG ContextFlags; /* 000 */
1659 /* CONTEXT_INTEGER */
1660 ULONG Cpsr; /* 004 */
1661 union
1663 struct
1665 DWORD64 X0; /* 008 */
1666 DWORD64 X1; /* 010 */
1667 DWORD64 X2; /* 018 */
1668 DWORD64 X3; /* 020 */
1669 DWORD64 X4; /* 028 */
1670 DWORD64 X5; /* 030 */
1671 DWORD64 X6; /* 038 */
1672 DWORD64 X7; /* 040 */
1673 DWORD64 X8; /* 048 */
1674 DWORD64 X9; /* 050 */
1675 DWORD64 X10; /* 058 */
1676 DWORD64 X11; /* 060 */
1677 DWORD64 X12; /* 068 */
1678 DWORD64 X13; /* 070 */
1679 DWORD64 X14; /* 078 */
1680 DWORD64 X15; /* 080 */
1681 DWORD64 X16; /* 088 */
1682 DWORD64 X17; /* 090 */
1683 DWORD64 X18; /* 098 */
1684 DWORD64 X19; /* 0a0 */
1685 DWORD64 X20; /* 0a8 */
1686 DWORD64 X21; /* 0b0 */
1687 DWORD64 X22; /* 0b8 */
1688 DWORD64 X23; /* 0c0 */
1689 DWORD64 X24; /* 0c8 */
1690 DWORD64 X25; /* 0d0 */
1691 DWORD64 X26; /* 0d8 */
1692 DWORD64 X27; /* 0e0 */
1693 DWORD64 X28; /* 0e8 */
1694 DWORD64 Fp; /* 0f0 */
1695 DWORD64 Lr; /* 0f8 */
1696 } DUMMYSTRUCTNAME;
1697 DWORD64 X[31]; /* 008 */
1698 } DUMMYUNIONNAME;
1699 /* CONTEXT_CONTROL */
1700 DWORD64 Sp; /* 100 */
1701 DWORD64 Pc; /* 108 */
1702 /* CONTEXT_FLOATING_POINT */
1703 ARM64_NT_NEON128 V[32]; /* 110 */
1704 DWORD Fpcr; /* 310 */
1705 DWORD Fpsr; /* 314 */
1706 /* CONTEXT_DEBUG_REGISTERS */
1707 DWORD Bcr[ARM64_MAX_BREAKPOINTS]; /* 318 */
1708 DWORD64 Bvr[ARM64_MAX_BREAKPOINTS]; /* 338 */
1709 DWORD Wcr[ARM64_MAX_WATCHPOINTS]; /* 378 */
1710 DWORD64 Wvr[ARM64_MAX_WATCHPOINTS]; /* 380 */
1711 } ARM64_NT_CONTEXT, *PARM64_NT_CONTEXT;
1713 #ifdef __aarch64__
1715 #define CONTEXT_CONTROL CONTEXT_ARM64_CONTROL
1716 #define CONTEXT_INTEGER CONTEXT_ARM64_INTEGER
1717 #define CONTEXT_FLOATING_POINT CONTEXT_ARM64_FLOATING_POINT
1718 #define CONTEXT_DEBUG_REGISTERS CONTEXT_ARM64_DEBUG_REGISTERS
1719 #define CONTEXT_FULL CONTEXT_ARM64_FULL
1720 #define CONTEXT_ALL CONTEXT_ARM64_ALL
1722 typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1723 typedef ARM64_NT_NEON128 NEON128, *PNEON128;
1724 typedef ARM64_NT_CONTEXT CONTEXT, *PCONTEXT;
1726 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1728 PDWORD64 X19;
1729 PDWORD64 X20;
1730 PDWORD64 X21;
1731 PDWORD64 X22;
1732 PDWORD64 X23;
1733 PDWORD64 X24;
1734 PDWORD64 X25;
1735 PDWORD64 X26;
1736 PDWORD64 X27;
1737 PDWORD64 X28;
1738 PDWORD64 Fp;
1739 PDWORD64 Lr;
1740 PDWORD64 D8;
1741 PDWORD64 D9;
1742 PDWORD64 D10;
1743 PDWORD64 D11;
1744 PDWORD64 D12;
1745 PDWORD64 D13;
1746 PDWORD64 D14;
1747 PDWORD64 D15;
1748 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1750 #endif /* __aarch64__ */
1752 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1753 #error You need to define a CONTEXT for your CPU
1754 #endif
1756 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
1758 #define WOW64_CONTEXT_i386 0x00010000
1759 #define WOW64_CONTEXT_i486 0x00010000
1760 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
1761 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
1762 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
1763 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
1764 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
1765 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
1766 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
1767 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
1768 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
1769 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
1770 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
1772 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
1773 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
1774 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
1775 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
1777 #define WOW64_SIZE_OF_80387_REGISTERS 80
1778 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
1780 /* Exception definitions */
1782 #define EXCEPTION_READ_FAULT 0
1783 #define EXCEPTION_WRITE_FAULT 1
1784 #define EXCEPTION_EXECUTE_FAULT 8
1786 struct _EXCEPTION_POINTERS;
1787 struct _EXCEPTION_RECORD;
1789 typedef EXCEPTION_DISPOSITION WINAPI EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,PVOID);
1790 typedef EXCEPTION_ROUTINE *PEXCEPTION_ROUTINE;
1792 #ifdef __x86_64__
1794 #define UNWIND_HISTORY_TABLE_SIZE 12
1796 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1798 ULONG64 ImageBase;
1799 PRUNTIME_FUNCTION FunctionEntry;
1800 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1802 #define UNWIND_HISTORY_TABLE_NONE 0
1803 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1804 #define UNWIND_HISTORY_TABLE_LOCAL 2
1806 typedef struct _UNWIND_HISTORY_TABLE
1808 ULONG Count;
1809 UCHAR Search;
1810 ULONG64 LowAddress;
1811 ULONG64 HighAddress;
1812 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1813 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1815 typedef struct _DISPATCHER_CONTEXT
1817 ULONG64 ControlPc;
1818 ULONG64 ImageBase;
1819 PRUNTIME_FUNCTION FunctionEntry;
1820 ULONG64 EstablisherFrame;
1821 ULONG64 TargetIp;
1822 PCONTEXT ContextRecord;
1823 PEXCEPTION_ROUTINE LanguageHandler;
1824 PVOID HandlerData;
1825 PUNWIND_HISTORY_TABLE HistoryTable;
1826 DWORD ScopeIndex;
1827 DWORD Fill0;
1828 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1830 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,PVOID);
1831 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,PVOID);
1833 #define UNW_FLAG_NHANDLER 0
1834 #define UNW_FLAG_EHANDLER 1
1835 #define UNW_FLAG_UHANDLER 2
1836 #define UNW_FLAG_CHAININFO 4
1838 #elif defined(__arm__)
1840 #define UNWIND_HISTORY_TABLE_SIZE 12
1842 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1844 DWORD ImageBase;
1845 PRUNTIME_FUNCTION FunctionEntry;
1846 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1848 typedef struct _UNWIND_HISTORY_TABLE
1850 DWORD Count;
1851 BYTE LocalHint;
1852 BYTE GlobalHint;
1853 BYTE Search;
1854 BYTE Once;
1855 DWORD LowAddress;
1856 DWORD HighAddress;
1857 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1858 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1860 typedef struct _DISPATCHER_CONTEXT
1862 DWORD ControlPc;
1863 DWORD ImageBase;
1864 PRUNTIME_FUNCTION FunctionEntry;
1865 DWORD EstablisherFrame;
1866 DWORD TargetPc;
1867 PCONTEXT ContextRecord;
1868 PEXCEPTION_ROUTINE LanguageHandler;
1869 PVOID HandlerData;
1870 PUNWIND_HISTORY_TABLE HistoryTable;
1871 DWORD ScopeIndex;
1872 BOOLEAN ControlPcIsUnwound;
1873 PBYTE NonVolatileRegisters;
1874 DWORD Reserved;
1875 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1877 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD);
1878 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD);
1880 #define UNW_FLAG_NHANDLER 0
1881 #define UNW_FLAG_EHANDLER 1
1882 #define UNW_FLAG_UHANDLER 2
1884 #elif defined(__aarch64__)
1886 #define UNWIND_HISTORY_TABLE_SIZE 12
1888 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1890 DWORD64 ImageBase;
1891 PRUNTIME_FUNCTION FunctionEntry;
1892 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1894 typedef struct _UNWIND_HISTORY_TABLE
1896 DWORD Count;
1897 BYTE LocalHint;
1898 BYTE GlobalHint;
1899 BYTE Search;
1900 BYTE Once;
1901 DWORD64 LowAddress;
1902 DWORD64 HighAddress;
1903 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1904 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1906 typedef struct _DISPATCHER_CONTEXT
1908 ULONG_PTR ControlPc;
1909 ULONG_PTR ImageBase;
1910 PRUNTIME_FUNCTION FunctionEntry;
1911 ULONG_PTR EstablisherFrame;
1912 ULONG_PTR TargetPc;
1913 PCONTEXT ContextRecord;
1914 PEXCEPTION_ROUTINE LanguageHandler;
1915 PVOID HandlerData;
1916 PUNWIND_HISTORY_TABLE HistoryTable;
1917 DWORD ScopeIndex;
1918 BOOLEAN ControlPcIsUnwound;
1919 PBYTE NonVolatileRegisters;
1920 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1922 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD64);
1923 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD64);
1925 #define UNW_FLAG_NHANDLER 0
1926 #define UNW_FLAG_EHANDLER 1
1927 #define UNW_FLAG_UHANDLER 2
1929 #endif /* __aarch64__ */
1931 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
1933 typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD_PTR,PVOID);
1935 NTSYSAPI BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD_PTR);
1936 NTSYSAPI DWORD WINAPI RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION,DWORD,DWORD,ULONG_PTR,ULONG_PTR);
1937 NTSYSAPI BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1938 NTSYSAPI void WINAPI RtlDeleteGrowableFunctionTable(void*);
1939 NTSYSAPI void WINAPI RtlGrowFunctionTable(void*,DWORD);
1940 NTSYSAPI BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD_PTR,DWORD_PTR,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
1941 NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD_PTR,DWORD_PTR*,UNWIND_HISTORY_TABLE*);
1942 NTSYSAPI void WINAPI RtlUnwindEx(PVOID,PVOID,struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,UNWIND_HISTORY_TABLE*);
1943 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*);
1945 #endif
1948 * Product types
1950 #define PRODUCT_UNDEFINED 0x00000000
1951 #define PRODUCT_ULTIMATE 0x00000001
1952 #define PRODUCT_HOME_BASIC 0x00000002
1953 #define PRODUCT_HOME_PREMIUM 0x00000003
1954 #define PRODUCT_ENTERPRISE 0x00000004
1955 #define PRODUCT_HOME_BASIC_N 0x00000005
1956 #define PRODUCT_BUSINESS 0x00000006
1957 #define PRODUCT_STANDARD_SERVER 0x00000007
1958 #define PRODUCT_DATACENTER_SERVER 0x00000008
1959 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
1960 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
1961 #define PRODUCT_STARTER 0x0000000B
1962 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
1963 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
1964 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
1965 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
1966 #define PRODUCT_BUSINESS_N 0x00000010
1967 #define PRODUCT_WEB_SERVER 0x00000011
1968 #define PRODUCT_CLUSTER_SERVER 0x00000012
1969 #define PRODUCT_HOME_SERVER 0x00000013
1970 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
1971 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
1972 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
1973 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
1974 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
1975 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
1976 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
1977 #define PRODUCT_ENTERPRISE_N 0x0000001B
1978 #define PRODUCT_ULTIMATE_N 0x0000001C
1979 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
1980 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
1981 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
1982 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
1983 #define PRODUCT_SERVER_FOUNDATION 0x00000021
1984 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
1985 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
1986 #define PRODUCT_STANDARD_SERVER_V 0x00000024
1987 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
1988 #define PRODUCT_SERVER_V 0x00000025
1989 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
1990 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
1991 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
1992 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
1993 #define PRODUCT_HYPERV 0x0000002A
1994 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
1995 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
1996 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
1997 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
1998 #define PRODUCT_STARTER_N 0x0000002F
1999 #define PRODUCT_PROFESSIONAL 0x00000030
2000 #define PRODUCT_PROFESSIONAL_N 0x00000031
2001 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2002 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2003 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2004 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2005 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2006 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2007 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2008 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2009 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2010 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2011 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2012 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2013 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2014 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2015 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2016 #define PRODUCT_EMBEDDED 0x00000041
2017 #define PRODUCT_STARTER_E 0x00000042
2018 #define PRODUCT_HOME_BASIC_E 0x00000043
2019 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2020 #define PRODUCT_PROFESSIONAL_E 0x00000045
2021 #define PRODUCT_ENTERPRISE_E 0x00000046
2022 #define PRODUCT_ULTIMATE_E 0x00000047
2023 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2024 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2025 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2026 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2027 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2028 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2029 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2030 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2031 #define PRODUCT_THINPC 0x00000057
2032 #define PRODUCT_EMBEDDED_A 0x00000058
2033 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2034 #define PRODUCT_EMBEDDED_E 0x0000005A
2035 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2036 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2037 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2038 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2039 #define PRODUCT_CORE_ARM 0x00000061
2040 #define PRODUCT_CORE_N 0x00000062
2041 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2042 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2043 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2044 #define PRODUCT_CORE 0x00000065
2045 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2046 #define PRODUCT_MOBILE_CORE 0x00000068
2047 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2048 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2049 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2050 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2051 #define PRODUCT_NANO_SERVER 0x0000006D
2052 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2053 #define PRODUCT_CORE_CONNECTED 0x0000006F
2054 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2055 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2056 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2057 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2058 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2059 #define PRODUCT_CONNECTED_CAR 0x00000075
2060 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2061 #define PRODUCT_PPI_PRO 0x00000077
2062 #define PRODUCT_ARM64_SERVER 0x00000078
2063 #define PRODUCT_EDUCATION 0x00000079
2064 #define PRODUCT_EDUCATION_N 0x0000007A
2065 #define PRODUCT_IOTUAP 0x0000007B
2066 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2067 #define PRODUCT_ENTERPRISE_S 0x0000007D
2068 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2069 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2070 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2071 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2072 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2073 #define PRODUCT_UNLICENSED 0xABCDABCD
2077 * Language IDs
2080 #define MAKELCID(l, s) (MAKELONG(l, s))
2082 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2083 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2084 #define SUBLANGID(l) ((WORD)(l) >> 10)
2086 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2087 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2089 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2090 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2091 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2092 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2093 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2094 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2095 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2096 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2097 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2098 #define LOCALE_NAME_MAX_LENGTH 85
2101 #define UNREFERENCED_PARAMETER(u) (void)(u)
2102 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2103 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2105 #include <winnt.rh>
2109 * Definitions for IsTextUnicode()
2112 #define IS_TEXT_UNICODE_ASCII16 0x0001
2113 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2114 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2115 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2116 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2117 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2118 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2119 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2120 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2121 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2122 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2123 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2124 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2125 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2126 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2127 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2129 #define MAXIMUM_WAIT_OBJECTS 64
2130 #define MAXIMUM_SUSPEND_COUNT 127
2132 #define WT_EXECUTEDEFAULT 0x00
2133 #define WT_EXECUTEINIOTHREAD 0x01
2134 #define WT_EXECUTEINUITHREAD 0x02
2135 #define WT_EXECUTEINWAITTHREAD 0x04
2136 #define WT_EXECUTEONLYONCE 0x08
2137 #define WT_EXECUTELONGFUNCTION 0x10
2138 #define WT_EXECUTEINTIMERTHREAD 0x20
2139 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2140 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2141 #define WT_EXECUTEINLONGTHREAD 0x10
2142 #define WT_EXECUTEDELETEWAIT 0x08
2143 #define WT_TRANSFER_IMPERSONATION 0x0100
2146 #define EXCEPTION_CONTINUABLE 0
2147 #define EXCEPTION_NONCONTINUABLE 0x01
2150 * The exception record used by Win32 to give additional information
2151 * about exception to exception handlers.
2154 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2156 typedef struct _EXCEPTION_RECORD
2158 DWORD ExceptionCode;
2159 DWORD ExceptionFlags;
2160 struct _EXCEPTION_RECORD *ExceptionRecord;
2162 PVOID ExceptionAddress;
2163 DWORD NumberParameters;
2164 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2165 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2167 typedef struct _EXCEPTION_RECORD32
2169 DWORD ExceptionCode;
2170 DWORD ExceptionFlags;
2171 DWORD ExceptionRecord;
2172 DWORD ExceptionAddress;
2173 DWORD NumberParameters;
2174 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2175 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
2177 typedef struct _EXCEPTION_RECORD64
2179 DWORD ExceptionCode;
2180 DWORD ExceptionFlags;
2181 DWORD64 ExceptionRecord;
2182 DWORD64 ExceptionAddress;
2183 DWORD NumberParameters;
2184 DWORD __unusedAlignment;
2185 DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2186 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
2189 * The exception pointers structure passed to exception filters
2190 * in except() and the UnhandledExceptionFilter().
2193 typedef struct _EXCEPTION_POINTERS
2195 PEXCEPTION_RECORD ExceptionRecord;
2196 PCONTEXT ContextRecord;
2197 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2201 * The exception frame, used for registering exception handlers
2202 * Win32 cares only about this, but compilers generally emit
2203 * larger exception frames for their own use.
2206 struct _EXCEPTION_REGISTRATION_RECORD;
2208 typedef DWORD (CDECL *PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2209 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2211 typedef struct _EXCEPTION_REGISTRATION_RECORD
2213 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2214 PEXCEPTION_HANDLER Handler;
2215 } EXCEPTION_REGISTRATION_RECORD;
2218 * function pointer to an exception filter
2221 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2223 typedef struct _NT_TIB
2225 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2226 PVOID StackBase;
2227 PVOID StackLimit;
2228 PVOID SubSystemTib;
2229 union {
2230 PVOID FiberData;
2231 DWORD Version;
2232 } DUMMYUNIONNAME;
2233 PVOID ArbitraryUserPointer;
2234 struct _NT_TIB *Self;
2235 } NT_TIB, *PNT_TIB;
2237 struct _TEB;
2239 #if defined(__i386__) && defined(__GNUC__) && !defined(WINE_UNIX_LIB)
2240 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2242 struct _TEB *teb;
2243 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2244 return teb;
2246 #elif defined(__i386__) && defined(_MSC_VER) && !defined(WINE_UNIX_LIB)
2247 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2249 struct _TEB *teb;
2250 __asm mov eax, fs:[0x18];
2251 __asm mov teb, eax;
2252 return teb;
2254 #elif defined(__x86_64__) && defined(__GNUC__) && !defined(WINE_UNIX_LIB)
2255 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2257 struct _TEB *teb;
2258 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2259 return teb;
2261 #elif defined(__x86_64__) && defined(_MSC_VER) && !defined(WINE_UNIX_LIB)
2262 unsigned __int64 __readgsqword(unsigned long);
2263 #pragma intrinsic(__readgsqword)
2264 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2266 return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
2268 #elif defined(__arm__) && defined(__GNUC__) && !defined(WINE_UNIX_LIB)
2269 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2271 struct _TEB *teb;
2272 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb));
2273 return teb;
2275 #elif defined(__arm__) && defined(_MSC_VER) && !defined(WINE_UNIX_LIB)
2276 #pragma intrinsic(_MoveFromCoprocessor)
2277 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2279 return (struct _TEB *)(ULONG_PTR)_MoveFromCoprocessor(15, 0, 13, 0, 2);
2281 #elif defined(__GNUC__)
2282 extern struct _TEB * WINAPI NtCurrentTeb(void) __attribute__((pure));
2283 #else
2284 extern struct _TEB * WINAPI NtCurrentTeb(void);
2285 #endif
2287 #ifdef NONAMELESSUNION
2288 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2289 #else
2290 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2291 #endif
2292 #define GetFiberData() (*(void **)GetCurrentFiber())
2294 #define TLS_MINIMUM_AVAILABLE 64
2296 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2298 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2299 #define IO_REPARSE_TAG_RESERVED_ONE 1
2300 #define IO_REPARSE_TAG_RESERVED_TWO 2
2302 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2304 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2305 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2306 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2307 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2308 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2309 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2310 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2311 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2312 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2313 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2314 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2315 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2316 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2317 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2318 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2319 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2320 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2321 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2322 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2323 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2324 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2325 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2326 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2327 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2328 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2329 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2330 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2331 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2332 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2333 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2334 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2335 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2336 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2337 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2338 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2339 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2340 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2341 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2342 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2343 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2344 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2345 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2346 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2349 * File formats definitions
2352 #include <pshpack2.h>
2353 typedef struct _IMAGE_DOS_HEADER {
2354 WORD e_magic; /* 00: MZ Header signature */
2355 WORD e_cblp; /* 02: Bytes on last page of file */
2356 WORD e_cp; /* 04: Pages in file */
2357 WORD e_crlc; /* 06: Relocations */
2358 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2359 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2360 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2361 WORD e_ss; /* 0e: Initial (relative) SS value */
2362 WORD e_sp; /* 10: Initial SP value */
2363 WORD e_csum; /* 12: Checksum */
2364 WORD e_ip; /* 14: Initial IP value */
2365 WORD e_cs; /* 16: Initial (relative) CS value */
2366 WORD e_lfarlc; /* 18: File address of relocation table */
2367 WORD e_ovno; /* 1a: Overlay number */
2368 WORD e_res[4]; /* 1c: Reserved words */
2369 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2370 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2371 WORD e_res2[10]; /* 28: Reserved words */
2372 DWORD e_lfanew; /* 3c: Offset to extended header */
2373 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2374 #include <poppack.h>
2376 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2377 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2378 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2379 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2380 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2381 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2384 * This is the Windows executable (NE) header.
2385 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2387 #include <pshpack2.h>
2388 typedef struct
2390 WORD ne_magic; /* 00 NE signature 'NE' */
2391 BYTE ne_ver; /* 02 Linker version number */
2392 BYTE ne_rev; /* 03 Linker revision number */
2393 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2394 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2395 LONG ne_crc; /* 08 Checksum */
2396 WORD ne_flags; /* 0c Flags about segments in this file */
2397 WORD ne_autodata; /* 0e Automatic data segment number */
2398 WORD ne_heap; /* 10 Initial size of local heap */
2399 WORD ne_stack; /* 12 Initial size of stack */
2400 DWORD ne_csip; /* 14 Initial CS:IP */
2401 DWORD ne_sssp; /* 18 Initial SS:SP */
2402 WORD ne_cseg; /* 1c # of entries in segment table */
2403 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2404 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2405 WORD ne_segtab; /* 22 Offset to segment table */
2406 WORD ne_rsrctab; /* 24 Offset to resource table */
2407 WORD ne_restab; /* 26 Offset to resident-name table */
2408 WORD ne_modtab; /* 28 Offset to module reference table */
2409 WORD ne_imptab; /* 2a Offset to imported name table */
2410 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2411 WORD ne_cmovent; /* 30 # of movable entry points */
2412 WORD ne_align; /* 32 Logical sector alignment shift count */
2413 WORD ne_cres; /* 34 # of resource segments */
2414 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2415 BYTE ne_flagsothers; /* 37 Additional information flags */
2416 WORD ne_pretthunks; /* 38 Offset to return thunks */
2417 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2418 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2419 WORD ne_expver; /* 3e Expected Windows version number */
2420 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2421 #include <poppack.h>
2423 #include <pshpack2.h>
2424 typedef struct _IMAGE_VXD_HEADER {
2425 WORD e32_magic;
2426 BYTE e32_border;
2427 BYTE e32_worder;
2428 DWORD e32_level;
2429 WORD e32_cpu;
2430 WORD e32_os;
2431 DWORD e32_ver;
2432 DWORD e32_mflags;
2433 DWORD e32_mpages;
2434 DWORD e32_startobj;
2435 DWORD e32_eip;
2436 DWORD e32_stackobj;
2437 DWORD e32_esp;
2438 DWORD e32_pagesize;
2439 DWORD e32_lastpagesize;
2440 DWORD e32_fixupsize;
2441 DWORD e32_fixupsum;
2442 DWORD e32_ldrsize;
2443 DWORD e32_ldrsum;
2444 DWORD e32_objtab;
2445 DWORD e32_objcnt;
2446 DWORD e32_objmap;
2447 DWORD e32_itermap;
2448 DWORD e32_rsrctab;
2449 DWORD e32_rsrccnt;
2450 DWORD e32_restab;
2451 DWORD e32_enttab;
2452 DWORD e32_dirtab;
2453 DWORD e32_dircnt;
2454 DWORD e32_fpagetab;
2455 DWORD e32_frectab;
2456 DWORD e32_impmod;
2457 DWORD e32_impmodcnt;
2458 DWORD e32_impproc;
2459 DWORD e32_pagesum;
2460 DWORD e32_datapage;
2461 DWORD e32_preload;
2462 DWORD e32_nrestab;
2463 DWORD e32_cbnrestab;
2464 DWORD e32_nressum;
2465 DWORD e32_autodata;
2466 DWORD e32_debuginfo;
2467 DWORD e32_debuglen;
2468 DWORD e32_instpreload;
2469 DWORD e32_instdemand;
2470 DWORD e32_heapsize;
2471 BYTE e32_res3[12];
2472 DWORD e32_winresoff;
2473 DWORD e32_winreslen;
2474 WORD e32_devid;
2475 WORD e32_ddkver;
2476 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2477 #include <poppack.h>
2479 /* These defines describe the meanings of the bits in the Characteristics
2480 field */
2482 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2483 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2484 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2485 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2486 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2487 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2488 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2489 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2490 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2491 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2492 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2493 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2494 #define IMAGE_FILE_SYSTEM 0x1000
2495 #define IMAGE_FILE_DLL 0x2000
2496 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2497 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2499 /* These are the settings of the Machine field. */
2500 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2501 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
2502 #define IMAGE_FILE_MACHINE_I860 0x014d
2503 #define IMAGE_FILE_MACHINE_I386 0x014c
2504 #define IMAGE_FILE_MACHINE_R3000 0x0162
2505 #define IMAGE_FILE_MACHINE_R4000 0x0166
2506 #define IMAGE_FILE_MACHINE_R10000 0x0168
2507 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2508 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2509 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2510 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2511 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2512 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2513 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2514 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2515 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2516 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2517 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2518 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2519 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2520 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2521 #define IMAGE_FILE_MACHINE_IA64 0x0200
2522 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2523 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2524 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2525 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2526 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2527 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2528 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2529 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2530 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2531 #define IMAGE_FILE_MACHINE_M32R 0x9041
2532 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2534 #define IMAGE_SIZEOF_FILE_HEADER 20
2535 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2536 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2537 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2538 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2539 #define IMAGE_SIZEOF_SHORT_NAME 8
2540 #define IMAGE_SIZEOF_SECTION_HEADER 40
2541 #define IMAGE_SIZEOF_SYMBOL 18
2542 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2543 #define IMAGE_SIZEOF_RELOCATION 10
2544 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2545 #define IMAGE_SIZEOF_LINENUMBER 6
2546 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2548 /* Possible Magic values */
2549 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2550 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2551 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2553 #ifdef _WIN64
2554 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2555 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2556 #else
2557 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2558 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2559 #endif
2561 /* These are indexes into the DataDirectory array */
2562 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2563 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2564 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2565 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2566 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2567 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2568 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2569 #define IMAGE_FILE_DESCRIPTION_STRING 7
2570 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2571 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2572 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2574 /* Directory Entries, indices into the DataDirectory array */
2576 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2577 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2578 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2579 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2580 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2581 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2582 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2583 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2584 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2585 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2586 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2587 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2588 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2589 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2590 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2592 /* Subsystem Values */
2594 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2595 #define IMAGE_SUBSYSTEM_NATIVE 1
2596 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2597 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2598 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2599 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2600 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2601 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2602 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2603 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2604 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2605 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2606 #define IMAGE_SUBSYSTEM_XBOX 14
2607 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2609 /* DLL Characteristics */
2610 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
2611 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2612 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2613 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2614 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2615 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2616 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2617 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
2618 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2619 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
2620 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2622 typedef struct _IMAGE_FILE_HEADER {
2623 WORD Machine;
2624 WORD NumberOfSections;
2625 DWORD TimeDateStamp;
2626 DWORD PointerToSymbolTable;
2627 DWORD NumberOfSymbols;
2628 WORD SizeOfOptionalHeader;
2629 WORD Characteristics;
2630 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2632 typedef struct _IMAGE_DATA_DIRECTORY {
2633 DWORD VirtualAddress;
2634 DWORD Size;
2635 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2637 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2639 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2640 WORD Magic; /* 0x20b */
2641 BYTE MajorLinkerVersion;
2642 BYTE MinorLinkerVersion;
2643 DWORD SizeOfCode;
2644 DWORD SizeOfInitializedData;
2645 DWORD SizeOfUninitializedData;
2646 DWORD AddressOfEntryPoint;
2647 DWORD BaseOfCode;
2648 ULONGLONG ImageBase;
2649 DWORD SectionAlignment;
2650 DWORD FileAlignment;
2651 WORD MajorOperatingSystemVersion;
2652 WORD MinorOperatingSystemVersion;
2653 WORD MajorImageVersion;
2654 WORD MinorImageVersion;
2655 WORD MajorSubsystemVersion;
2656 WORD MinorSubsystemVersion;
2657 DWORD Win32VersionValue;
2658 DWORD SizeOfImage;
2659 DWORD SizeOfHeaders;
2660 DWORD CheckSum;
2661 WORD Subsystem;
2662 WORD DllCharacteristics;
2663 ULONGLONG SizeOfStackReserve;
2664 ULONGLONG SizeOfStackCommit;
2665 ULONGLONG SizeOfHeapReserve;
2666 ULONGLONG SizeOfHeapCommit;
2667 DWORD LoaderFlags;
2668 DWORD NumberOfRvaAndSizes;
2669 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2670 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2672 typedef struct _IMAGE_NT_HEADERS64 {
2673 DWORD Signature;
2674 IMAGE_FILE_HEADER FileHeader;
2675 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2676 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2678 typedef struct _IMAGE_OPTIONAL_HEADER {
2680 /* Standard fields */
2682 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2683 BYTE MajorLinkerVersion;
2684 BYTE MinorLinkerVersion;
2685 DWORD SizeOfCode;
2686 DWORD SizeOfInitializedData;
2687 DWORD SizeOfUninitializedData;
2688 DWORD AddressOfEntryPoint; /* 0x10 */
2689 DWORD BaseOfCode;
2690 DWORD BaseOfData;
2692 /* NT additional fields */
2694 DWORD ImageBase;
2695 DWORD SectionAlignment; /* 0x20 */
2696 DWORD FileAlignment;
2697 WORD MajorOperatingSystemVersion;
2698 WORD MinorOperatingSystemVersion;
2699 WORD MajorImageVersion;
2700 WORD MinorImageVersion;
2701 WORD MajorSubsystemVersion; /* 0x30 */
2702 WORD MinorSubsystemVersion;
2703 DWORD Win32VersionValue;
2704 DWORD SizeOfImage;
2705 DWORD SizeOfHeaders;
2706 DWORD CheckSum; /* 0x40 */
2707 WORD Subsystem;
2708 WORD DllCharacteristics;
2709 DWORD SizeOfStackReserve;
2710 DWORD SizeOfStackCommit;
2711 DWORD SizeOfHeapReserve; /* 0x50 */
2712 DWORD SizeOfHeapCommit;
2713 DWORD LoaderFlags;
2714 DWORD NumberOfRvaAndSizes;
2715 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2716 /* 0xE0 */
2717 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2719 typedef struct _IMAGE_NT_HEADERS {
2720 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2721 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2722 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2723 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2725 #ifdef _WIN64
2726 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2727 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2728 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2729 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2730 #else
2731 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2732 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2733 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2734 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2735 #endif
2737 #define IMAGE_SIZEOF_SHORT_NAME 8
2739 typedef struct _IMAGE_SECTION_HEADER {
2740 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2741 union {
2742 DWORD PhysicalAddress;
2743 DWORD VirtualSize;
2744 } Misc;
2745 DWORD VirtualAddress;
2746 DWORD SizeOfRawData;
2747 DWORD PointerToRawData;
2748 DWORD PointerToRelocations;
2749 DWORD PointerToLinenumbers;
2750 WORD NumberOfRelocations;
2751 WORD NumberOfLinenumbers;
2752 DWORD Characteristics;
2753 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2755 #define IMAGE_SIZEOF_SECTION_HEADER 40
2757 #define IMAGE_FIRST_SECTION(ntheader) \
2758 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2759 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2761 /* These defines are for the Characteristics bitfield. */
2762 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2763 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2764 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2765 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2766 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2767 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2769 #define IMAGE_SCN_CNT_CODE 0x00000020
2770 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2771 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2773 #define IMAGE_SCN_LNK_OTHER 0x00000100
2774 #define IMAGE_SCN_LNK_INFO 0x00000200
2775 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2776 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2777 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2779 /* 0x00002000 - Reserved */
2780 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2781 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2783 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2784 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2785 #define IMAGE_SCN_MEM_16BIT 0x00020000
2786 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2787 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2789 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2790 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2791 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2792 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2793 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2794 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2795 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2796 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2797 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2798 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2799 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2800 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2801 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2802 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2803 /* 0x00F00000 - Unused */
2804 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2806 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2809 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2810 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2811 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2812 #define IMAGE_SCN_MEM_SHARED 0x10000000
2813 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2814 #define IMAGE_SCN_MEM_READ 0x40000000
2815 #define IMAGE_SCN_MEM_WRITE 0x80000000
2817 #include <pshpack2.h>
2819 typedef struct _IMAGE_SYMBOL {
2820 union {
2821 BYTE ShortName[8];
2822 struct {
2823 DWORD Short;
2824 DWORD Long;
2825 } Name;
2826 DWORD LongName[2];
2827 } N;
2828 DWORD Value;
2829 SHORT SectionNumber;
2830 WORD Type;
2831 BYTE StorageClass;
2832 BYTE NumberOfAuxSymbols;
2833 } IMAGE_SYMBOL;
2834 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2836 #define IMAGE_SIZEOF_SYMBOL 18
2838 typedef struct _IMAGE_LINENUMBER {
2839 union {
2840 DWORD SymbolTableIndex;
2841 DWORD VirtualAddress;
2842 } Type;
2843 WORD Linenumber;
2844 } IMAGE_LINENUMBER;
2845 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2847 #define IMAGE_SIZEOF_LINENUMBER 6
2849 typedef union _IMAGE_AUX_SYMBOL {
2850 struct {
2851 DWORD TagIndex;
2852 union {
2853 struct {
2854 WORD Linenumber;
2855 WORD Size;
2856 } LnSz;
2857 DWORD TotalSize;
2858 } Misc;
2859 union {
2860 struct {
2861 DWORD PointerToLinenumber;
2862 DWORD PointerToNextFunction;
2863 } Function;
2864 struct {
2865 WORD Dimension[4];
2866 } Array;
2867 } FcnAry;
2868 WORD TvIndex;
2869 } Sym;
2870 struct {
2871 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2872 } File;
2873 struct {
2874 DWORD Length;
2875 WORD NumberOfRelocations;
2876 WORD NumberOfLinenumbers;
2877 DWORD CheckSum;
2878 SHORT Number;
2879 BYTE Selection;
2880 } Section;
2881 } IMAGE_AUX_SYMBOL;
2882 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2884 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2886 #include <poppack.h>
2888 #define IMAGE_SYM_UNDEFINED (SHORT)0
2889 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2890 #define IMAGE_SYM_DEBUG (SHORT)-2
2892 #define IMAGE_SYM_TYPE_NULL 0x0000
2893 #define IMAGE_SYM_TYPE_VOID 0x0001
2894 #define IMAGE_SYM_TYPE_CHAR 0x0002
2895 #define IMAGE_SYM_TYPE_SHORT 0x0003
2896 #define IMAGE_SYM_TYPE_INT 0x0004
2897 #define IMAGE_SYM_TYPE_LONG 0x0005
2898 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2899 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2900 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2901 #define IMAGE_SYM_TYPE_UNION 0x0009
2902 #define IMAGE_SYM_TYPE_ENUM 0x000A
2903 #define IMAGE_SYM_TYPE_MOE 0x000B
2904 #define IMAGE_SYM_TYPE_BYTE 0x000C
2905 #define IMAGE_SYM_TYPE_WORD 0x000D
2906 #define IMAGE_SYM_TYPE_UINT 0x000E
2907 #define IMAGE_SYM_TYPE_DWORD 0x000F
2908 #define IMAGE_SYM_TYPE_PCODE 0x8000
2910 #define IMAGE_SYM_DTYPE_NULL 0
2911 #define IMAGE_SYM_DTYPE_POINTER 1
2912 #define IMAGE_SYM_DTYPE_FUNCTION 2
2913 #define IMAGE_SYM_DTYPE_ARRAY 3
2915 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2916 #define IMAGE_SYM_CLASS_NULL 0x0000
2917 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2918 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2919 #define IMAGE_SYM_CLASS_STATIC 0x0003
2920 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2921 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2922 #define IMAGE_SYM_CLASS_LABEL 0x0006
2923 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2924 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2925 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2926 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2927 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2928 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2929 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2930 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2931 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2932 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2933 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2934 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2936 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2937 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2938 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2939 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2940 #define IMAGE_SYM_CLASS_FILE 0x0067
2941 #define IMAGE_SYM_CLASS_SECTION 0x0068
2942 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2944 #define N_BTMASK 0x000F
2945 #define N_TMASK 0x0030
2946 #define N_TMASK1 0x00C0
2947 #define N_TMASK2 0x00F0
2948 #define N_BTSHFT 4
2949 #define N_TSHIFT 2
2951 #define BTYPE(x) ((x) & N_BTMASK)
2953 #ifndef ISPTR
2954 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2955 #endif
2957 #ifndef ISFCN
2958 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2959 #endif
2961 #ifndef ISARY
2962 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2963 #endif
2965 #ifndef ISTAG
2966 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2967 #endif
2969 #ifndef INCREF
2970 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2971 #endif
2972 #ifndef DECREF
2973 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2974 #endif
2976 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2977 #define IMAGE_COMDAT_SELECT_ANY 2
2978 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2979 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2980 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2981 #define IMAGE_COMDAT_SELECT_LARGEST 6
2982 #define IMAGE_COMDAT_SELECT_NEWEST 7
2984 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2985 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2986 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2988 /* Export module directory */
2990 typedef struct _IMAGE_EXPORT_DIRECTORY {
2991 DWORD Characteristics;
2992 DWORD TimeDateStamp;
2993 WORD MajorVersion;
2994 WORD MinorVersion;
2995 DWORD Name;
2996 DWORD Base;
2997 DWORD NumberOfFunctions;
2998 DWORD NumberOfNames;
2999 DWORD AddressOfFunctions;
3000 DWORD AddressOfNames;
3001 DWORD AddressOfNameOrdinals;
3002 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
3004 /* Import name entry */
3005 typedef struct _IMAGE_IMPORT_BY_NAME {
3006 WORD Hint;
3007 BYTE Name[1];
3008 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
3010 #include <pshpack8.h>
3011 /* Import thunk */
3012 typedef struct _IMAGE_THUNK_DATA64 {
3013 union {
3014 ULONGLONG ForwarderString;
3015 ULONGLONG Function;
3016 ULONGLONG Ordinal;
3017 ULONGLONG AddressOfData;
3018 } u1;
3019 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3020 #include <poppack.h>
3022 typedef struct _IMAGE_THUNK_DATA32 {
3023 union {
3024 DWORD ForwarderString;
3025 DWORD Function;
3026 DWORD Ordinal;
3027 DWORD AddressOfData;
3028 } u1;
3029 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3031 /* Import module directory */
3033 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3034 union {
3035 DWORD Characteristics; /* 0 for terminating null import descriptor */
3036 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3037 } DUMMYUNIONNAME;
3038 DWORD TimeDateStamp; /* 0 if not bound,
3039 * -1 if bound, and real date\time stamp
3040 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3041 * (new BIND)
3042 * otherwise date/time stamp of DLL bound to
3043 * (Old BIND)
3045 DWORD ForwarderChain; /* -1 if no forwarders */
3046 DWORD Name;
3047 /* RVA to IAT (if bound this IAT has actual addresses) */
3048 DWORD FirstThunk;
3049 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3051 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3052 #define IMAGE_ORDINAL_FLAG32 0x80000000
3053 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3054 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3055 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3056 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3058 #ifdef _WIN64
3059 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3060 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3061 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3062 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3063 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3064 #else
3065 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3066 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3067 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3068 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3069 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3070 #endif
3072 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3074 DWORD TimeDateStamp;
3075 WORD OffsetModuleName;
3076 WORD NumberOfModuleForwarderRefs;
3077 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3078 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3080 typedef struct _IMAGE_BOUND_FORWARDER_REF
3082 DWORD TimeDateStamp;
3083 WORD OffsetModuleName;
3084 WORD Reserved;
3085 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3087 typedef struct _IMAGE_BASE_RELOCATION
3089 DWORD VirtualAddress;
3090 DWORD SizeOfBlock;
3091 /* WORD TypeOffset[1]; */
3092 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3094 #include <pshpack2.h>
3096 typedef struct _IMAGE_RELOCATION
3098 union {
3099 DWORD VirtualAddress;
3100 DWORD RelocCount;
3101 } DUMMYUNIONNAME;
3102 DWORD SymbolTableIndex;
3103 WORD Type;
3104 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3106 #include <poppack.h>
3108 #define IMAGE_SIZEOF_RELOCATION 10
3110 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3112 union
3114 DWORD AllAttributes;
3115 struct
3117 DWORD RvaBased:1;
3118 DWORD ReservedAttributes:31;
3119 } DUMMYSTRUCTNAME;
3120 } Attributes;
3122 DWORD DllNameRVA;
3123 DWORD ModuleHandleRVA;
3124 DWORD ImportAddressTableRVA;
3125 DWORD ImportNameTableRVA;
3126 DWORD BoundImportAddressTableRVA;
3127 DWORD UnloadInformationTableRVA;
3128 DWORD TimeDateStamp;
3129 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3130 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3132 /* generic relocation types */
3133 #define IMAGE_REL_BASED_ABSOLUTE 0
3134 #define IMAGE_REL_BASED_HIGH 1
3135 #define IMAGE_REL_BASED_LOW 2
3136 #define IMAGE_REL_BASED_HIGHLOW 3
3137 #define IMAGE_REL_BASED_HIGHADJ 4
3138 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3139 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3140 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3141 #define IMAGE_REL_BASED_SECTION 6
3142 #define IMAGE_REL_BASED_REL 7
3143 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3144 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3145 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3146 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3147 #define IMAGE_REL_BASED_DIR64 10
3148 #define IMAGE_REL_BASED_HIGH3ADJ 11
3150 /* I386 relocation types */
3151 #define IMAGE_REL_I386_ABSOLUTE 0
3152 #define IMAGE_REL_I386_DIR16 1
3153 #define IMAGE_REL_I386_REL16 2
3154 #define IMAGE_REL_I386_DIR32 6
3155 #define IMAGE_REL_I386_DIR32NB 7
3156 #define IMAGE_REL_I386_SEG12 9
3157 #define IMAGE_REL_I386_SECTION 10
3158 #define IMAGE_REL_I386_SECREL 11
3159 #define IMAGE_REL_I386_TOKEN 12
3160 #define IMAGE_REL_I386_SECREL7 13
3161 #define IMAGE_REL_I386_REL32 20
3163 /* MIPS relocation types */
3164 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3165 #define IMAGE_REL_MIPS_REFHALF 0x0001
3166 #define IMAGE_REL_MIPS_REFWORD 0x0002
3167 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3168 #define IMAGE_REL_MIPS_REFHI 0x0004
3169 #define IMAGE_REL_MIPS_REFLO 0x0005
3170 #define IMAGE_REL_MIPS_GPREL 0x0006
3171 #define IMAGE_REL_MIPS_LITERAL 0x0007
3172 #define IMAGE_REL_MIPS_SECTION 0x000A
3173 #define IMAGE_REL_MIPS_SECREL 0x000B
3174 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3175 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3176 #define IMAGE_REL_MIPS_TOKEN 0x000E
3177 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3178 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3179 #define IMAGE_REL_MIPS_PAIR 0x0025
3181 /* ALPHA relocation types */
3182 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3183 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3184 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3185 #define IMAGE_REL_ALPHA_GPREL 0x0003
3186 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3187 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3188 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3189 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3190 #define IMAGE_REL_ALPHA_HINT 0x0008
3191 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3192 #define IMAGE_REL_ALPHA_REFHI 0x000A
3193 #define IMAGE_REL_ALPHA_REFLO 0x000B
3194 #define IMAGE_REL_ALPHA_PAIR 0x000C
3195 #define IMAGE_REL_ALPHA_MATCH 0x000D
3196 #define IMAGE_REL_ALPHA_SECTION 0x000E
3197 #define IMAGE_REL_ALPHA_SECREL 0x000F
3198 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3199 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3200 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3201 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3202 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3203 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3204 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3205 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3207 /* PowerPC relocation types */
3208 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3209 #define IMAGE_REL_PPC_ADDR64 0x0001
3210 #define IMAGE_REL_PPC_ADDR 0x0002
3211 #define IMAGE_REL_PPC_ADDR24 0x0003
3212 #define IMAGE_REL_PPC_ADDR16 0x0004
3213 #define IMAGE_REL_PPC_ADDR14 0x0005
3214 #define IMAGE_REL_PPC_REL24 0x0006
3215 #define IMAGE_REL_PPC_REL14 0x0007
3216 #define IMAGE_REL_PPC_TOCREL16 0x0008
3217 #define IMAGE_REL_PPC_TOCREL14 0x0009
3218 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3219 #define IMAGE_REL_PPC_SECREL 0x000B
3220 #define IMAGE_REL_PPC_SECTION 0x000C
3221 #define IMAGE_REL_PPC_IFGLUE 0x000D
3222 #define IMAGE_REL_PPC_IMGLUE 0x000E
3223 #define IMAGE_REL_PPC_SECREL16 0x000F
3224 #define IMAGE_REL_PPC_REFHI 0x0010
3225 #define IMAGE_REL_PPC_REFLO 0x0011
3226 #define IMAGE_REL_PPC_PAIR 0x0012
3227 #define IMAGE_REL_PPC_SECRELLO 0x0013
3228 #define IMAGE_REL_PPC_SECRELHI 0x0014
3229 #define IMAGE_REL_PPC_GPREL 0x0015
3230 #define IMAGE_REL_PPC_TOKEN 0x0016
3231 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3232 /* modifier bits */
3233 #define IMAGE_REL_PPC_NEG 0x0100
3234 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3235 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3236 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3238 /* SH3 relocation types */
3239 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3240 #define IMAGE_REL_SH3_DIRECT16 0x0001
3241 #define IMAGE_REL_SH3_DIRECT 0x0002
3242 #define IMAGE_REL_SH3_DIRECT8 0x0003
3243 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3244 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3245 #define IMAGE_REL_SH3_DIRECT4 0x0006
3246 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3247 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3248 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3249 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3250 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3251 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3252 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3253 #define IMAGE_REL_SH3_SECTION 0x000E
3254 #define IMAGE_REL_SH3_SECREL 0x000F
3255 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3256 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3257 #define IMAGE_REL_SH3_TOKEN 0x0012
3259 /* ARM relocation types */
3260 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3261 #define IMAGE_REL_ARM_ADDR 0x0001
3262 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3263 #define IMAGE_REL_ARM_BRANCH24 0x0003
3264 #define IMAGE_REL_ARM_BRANCH11 0x0004
3265 #define IMAGE_REL_ARM_TOKEN 0x0005
3266 #define IMAGE_REL_ARM_GPREL12 0x0006
3267 #define IMAGE_REL_ARM_GPREL7 0x0007
3268 #define IMAGE_REL_ARM_BLX24 0x0008
3269 #define IMAGE_REL_ARM_BLX11 0x0009
3270 #define IMAGE_REL_ARM_SECTION 0x000E
3271 #define IMAGE_REL_ARM_SECREL 0x000F
3272 #define IMAGE_REL_ARM_MOV32A 0x0010
3273 #define IMAGE_REL_ARM_MOV32T 0x0011
3274 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3275 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3276 #define IMAGE_REL_ARM_BLX23T 0x0015
3278 /* ARM64 relocation types */
3279 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3280 #define IMAGE_REL_ARM64_ADDR32 0x0001
3281 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3282 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3283 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3284 #define IMAGE_REL_ARM64_REL21 0x0005
3285 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3286 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3287 #define IMAGE_REL_ARM64_SECREL 0x0008
3288 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3289 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3290 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3291 #define IMAGE_REL_ARM64_TOKEN 0x000C
3292 #define IMAGE_REL_ARM64_SECTION 0x000D
3293 #define IMAGE_REL_ARM64_ADDR64 0x000E
3294 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3296 /* IA64 relocation types */
3297 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3298 #define IMAGE_REL_IA64_IMM14 0x0001
3299 #define IMAGE_REL_IA64_IMM22 0x0002
3300 #define IMAGE_REL_IA64_IMM64 0x0003
3301 #define IMAGE_REL_IA64_DIR 0x0004
3302 #define IMAGE_REL_IA64_DIR64 0x0005
3303 #define IMAGE_REL_IA64_PCREL21B 0x0006
3304 #define IMAGE_REL_IA64_PCREL21M 0x0007
3305 #define IMAGE_REL_IA64_PCREL21F 0x0008
3306 #define IMAGE_REL_IA64_GPREL22 0x0009
3307 #define IMAGE_REL_IA64_LTOFF22 0x000A
3308 #define IMAGE_REL_IA64_SECTION 0x000B
3309 #define IMAGE_REL_IA64_SECREL22 0x000C
3310 #define IMAGE_REL_IA64_SECREL64I 0x000D
3311 #define IMAGE_REL_IA64_SECREL 0x000E
3312 #define IMAGE_REL_IA64_LTOFF64 0x000F
3313 #define IMAGE_REL_IA64_DIR32NB 0x0010
3314 #define IMAGE_REL_IA64_SREL14 0x0011
3315 #define IMAGE_REL_IA64_SREL22 0x0012
3316 #define IMAGE_REL_IA64_SREL32 0x0013
3317 #define IMAGE_REL_IA64_UREL32 0x0014
3318 #define IMAGE_REL_IA64_PCREL60X 0x0015
3319 #define IMAGE_REL_IA64_PCREL60B 0x0016
3320 #define IMAGE_REL_IA64_PCREL60F 0x0017
3321 #define IMAGE_REL_IA64_PCREL60I 0x0018
3322 #define IMAGE_REL_IA64_PCREL60M 0x0019
3323 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3324 #define IMAGE_REL_IA64_TOKEN 0x001B
3325 #define IMAGE_REL_IA64_GPREL32 0x001C
3326 #define IMAGE_REL_IA64_ADDEND 0x001F
3328 /* AMD64 relocation types */
3329 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3330 #define IMAGE_REL_AMD64_ADDR64 0x0001
3331 #define IMAGE_REL_AMD64_ADDR32 0x0002
3332 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3333 #define IMAGE_REL_AMD64_REL32 0x0004
3334 #define IMAGE_REL_AMD64_REL32_1 0x0005
3335 #define IMAGE_REL_AMD64_REL32_2 0x0006
3336 #define IMAGE_REL_AMD64_REL32_3 0x0007
3337 #define IMAGE_REL_AMD64_REL32_4 0x0008
3338 #define IMAGE_REL_AMD64_REL32_5 0x0009
3339 #define IMAGE_REL_AMD64_SECTION 0x000A
3340 #define IMAGE_REL_AMD64_SECREL 0x000B
3341 #define IMAGE_REL_AMD64_SECREL7 0x000C
3342 #define IMAGE_REL_AMD64_TOKEN 0x000D
3343 #define IMAGE_REL_AMD64_SREL32 0x000E
3344 #define IMAGE_REL_AMD64_PAIR 0x000F
3345 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3347 /* archive format */
3349 #define IMAGE_ARCHIVE_START_SIZE 8
3350 #define IMAGE_ARCHIVE_START "!<arch>\n"
3351 #define IMAGE_ARCHIVE_END "`\n"
3352 #define IMAGE_ARCHIVE_PAD "\n"
3353 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3354 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3356 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3358 BYTE Name[16];
3359 BYTE Date[12];
3360 BYTE UserID[6];
3361 BYTE GroupID[6];
3362 BYTE Mode[8];
3363 BYTE Size[10];
3364 BYTE EndHeader[2];
3365 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3367 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3369 typedef struct _IMPORT_OBJECT_HEADER
3371 WORD Sig1;
3372 WORD Sig2;
3373 WORD Version;
3374 WORD Machine;
3375 DWORD TimeDateStamp;
3376 DWORD SizeOfData;
3377 union
3379 WORD Ordinal;
3380 WORD Hint;
3381 } DUMMYUNIONNAME;
3382 WORD Type : 2;
3383 WORD NameType : 3;
3384 WORD Reserved : 11;
3385 } IMPORT_OBJECT_HEADER;
3387 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3389 typedef enum IMPORT_OBJECT_TYPE
3391 IMPORT_OBJECT_CODE = 0,
3392 IMPORT_OBJECT_DATA = 1,
3393 IMPORT_OBJECT_CONST = 2
3394 } IMPORT_OBJECT_TYPE;
3396 typedef enum IMPORT_OBJECT_NAME_TYPE
3398 IMPORT_OBJECT_ORDINAL = 0,
3399 IMPORT_OBJECT_NAME = 1,
3400 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3401 IMPORT_OBJECT_NAME_UNDECORATE = 3
3402 } IMPORT_OBJECT_NAME_TYPE;
3404 typedef struct _ANON_OBJECT_HEADER
3406 WORD Sig1;
3407 WORD Sig2;
3408 WORD Version;
3409 WORD Machine;
3410 DWORD TimeDateStamp;
3411 CLSID ClassID;
3412 DWORD SizeOfData;
3413 } ANON_OBJECT_HEADER;
3416 * Resource directory stuff
3418 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3419 DWORD Characteristics;
3420 DWORD TimeDateStamp;
3421 WORD MajorVersion;
3422 WORD MinorVersion;
3423 WORD NumberOfNamedEntries;
3424 WORD NumberOfIdEntries;
3425 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3426 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3428 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3429 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3431 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3432 union {
3433 struct {
3434 unsigned NameOffset:31;
3435 unsigned NameIsString:1;
3436 } DUMMYSTRUCTNAME;
3437 DWORD Name;
3438 WORD Id;
3439 } DUMMYUNIONNAME;
3440 union {
3441 DWORD OffsetToData;
3442 struct {
3443 unsigned OffsetToDirectory:31;
3444 unsigned DataIsDirectory:1;
3445 } DUMMYSTRUCTNAME2;
3446 } DUMMYUNIONNAME2;
3447 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3450 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3451 WORD Length;
3452 CHAR NameString[ 1 ];
3453 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3455 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3456 WORD Length;
3457 WCHAR NameString[ 1 ];
3458 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3460 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3461 DWORD OffsetToData;
3462 DWORD Size;
3463 DWORD CodePage;
3464 DWORD Reserved;
3465 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3468 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3469 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3472 typedef struct _IMAGE_TLS_DIRECTORY64 {
3473 ULONGLONG StartAddressOfRawData;
3474 ULONGLONG EndAddressOfRawData;
3475 ULONGLONG AddressOfIndex;
3476 ULONGLONG AddressOfCallBacks;
3477 DWORD SizeOfZeroFill;
3478 DWORD Characteristics;
3479 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3481 typedef struct _IMAGE_TLS_DIRECTORY32 {
3482 DWORD StartAddressOfRawData;
3483 DWORD EndAddressOfRawData;
3484 DWORD AddressOfIndex;
3485 DWORD AddressOfCallBacks;
3486 DWORD SizeOfZeroFill;
3487 DWORD Characteristics;
3488 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3490 #ifdef _WIN64
3491 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3492 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3493 #else
3494 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3495 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3496 #endif
3498 typedef struct _IMAGE_DEBUG_DIRECTORY {
3499 DWORD Characteristics;
3500 DWORD TimeDateStamp;
3501 WORD MajorVersion;
3502 WORD MinorVersion;
3503 DWORD Type;
3504 DWORD SizeOfData;
3505 DWORD AddressOfRawData;
3506 DWORD PointerToRawData;
3507 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3509 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3510 #define IMAGE_DEBUG_TYPE_COFF 1
3511 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3512 #define IMAGE_DEBUG_TYPE_FPO 3
3513 #define IMAGE_DEBUG_TYPE_MISC 4
3514 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3515 #define IMAGE_DEBUG_TYPE_FIXUP 6
3516 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3517 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3518 #define IMAGE_DEBUG_TYPE_BORLAND 9
3519 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3520 #define IMAGE_DEBUG_TYPE_CLSID 11
3521 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3522 #define IMAGE_DEBUG_TYPE_POGO 13
3523 #define IMAGE_DEBUG_TYPE_ILTCG 14
3524 #define IMAGE_DEBUG_TYPE_MPX 15
3525 #define IMAGE_DEBUG_TYPE_REPRO 16
3527 typedef enum ReplacesCorHdrNumericDefines
3529 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3530 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3531 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3532 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3533 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
3534 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3535 COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000,
3537 COR_VERSION_MAJOR_V2 = 2,
3538 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3539 COR_VERSION_MINOR = 5,
3540 COR_DELETED_NAME_LENGTH = 8,
3541 COR_VTABLEGAP_NAME_LENGTH = 8,
3543 NATIVE_TYPE_MAX_CB = 1,
3544 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3546 IMAGE_COR_MIH_METHODRVA = 0x01,
3547 IMAGE_COR_MIH_EHRVA = 0x02,
3548 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3550 COR_VTABLE_32BIT = 0x01,
3551 COR_VTABLE_64BIT = 0x02,
3552 COR_VTABLE_FROM_UNMANAGED = 0x04,
3553 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3555 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3557 MAX_CLASS_NAME = 1024,
3558 MAX_PACKAGE_NAME = 1024,
3559 } ReplacesCorHdrNumericDefines;
3561 typedef struct IMAGE_COR20_HEADER
3563 DWORD cb;
3564 WORD MajorRuntimeVersion;
3565 WORD MinorRuntimeVersion;
3567 IMAGE_DATA_DIRECTORY MetaData;
3568 DWORD Flags;
3569 union {
3570 DWORD EntryPointToken;
3571 DWORD EntryPointRVA;
3572 } DUMMYUNIONNAME;
3574 IMAGE_DATA_DIRECTORY Resources;
3575 IMAGE_DATA_DIRECTORY StrongNameSignature;
3576 IMAGE_DATA_DIRECTORY CodeManagerTable;
3577 IMAGE_DATA_DIRECTORY VTableFixups;
3578 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3579 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3581 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3583 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3584 DWORD NumberOfSymbols;
3585 DWORD LvaToFirstSymbol;
3586 DWORD NumberOfLinenumbers;
3587 DWORD LvaToFirstLinenumber;
3588 DWORD RvaToFirstByteOfCode;
3589 DWORD RvaToLastByteOfCode;
3590 DWORD RvaToFirstByteOfData;
3591 DWORD RvaToLastByteOfData;
3592 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3594 #define FRAME_FPO 0
3595 #define FRAME_TRAP 1
3596 #define FRAME_TSS 2
3597 #define FRAME_NONFPO 3
3599 typedef struct _FPO_DATA {
3600 DWORD ulOffStart;
3601 DWORD cbProcSize;
3602 DWORD cdwLocals;
3603 WORD cdwParams;
3604 WORD cbProlog : 8;
3605 WORD cbRegs : 3;
3606 WORD fHasSEH : 1;
3607 WORD fUseBP : 1;
3608 WORD reserved : 1;
3609 WORD cbFrame : 2;
3610 } FPO_DATA, *PFPO_DATA;
3612 typedef struct _IMAGE_LOAD_CONFIG_CODE_INTEGRITY
3614 WORD Flags;
3615 WORD Catalog;
3616 DWORD CatalogOffset;
3617 DWORD Reserved;
3618 } IMAGE_LOAD_CONFIG_CODE_INTEGRITY, *PIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
3620 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
3621 DWORD Size; /* 000 */
3622 DWORD TimeDateStamp;
3623 WORD MajorVersion;
3624 WORD MinorVersion;
3625 DWORD GlobalFlagsClear;
3626 DWORD GlobalFlagsSet; /* 010 */
3627 DWORD CriticalSectionDefaultTimeout;
3628 ULONGLONG DeCommitFreeBlockThreshold;
3629 ULONGLONG DeCommitTotalFreeThreshold; /* 020 */
3630 ULONGLONG LockPrefixTable;
3631 ULONGLONG MaximumAllocationSize; /* 030 */
3632 ULONGLONG VirtualMemoryThreshold;
3633 ULONGLONG ProcessAffinityMask; /* 040 */
3634 DWORD ProcessHeapFlags;
3635 WORD CSDVersion;
3636 WORD DependentLoadFlags;
3637 ULONGLONG EditList; /* 050 */
3638 ULONGLONG SecurityCookie;
3639 ULONGLONG SEHandlerTable; /* 060 */
3640 ULONGLONG SEHandlerCount;
3641 ULONGLONG GuardCFCheckFunctionPointer; /* 070 */
3642 ULONGLONG GuardCFDispatchFunctionPointer;
3643 ULONGLONG GuardCFFunctionTable; /* 080 */
3644 ULONGLONG GuardCFFunctionCount;
3645 DWORD GuardFlags; /* 090 */
3646 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
3647 ULONGLONG GuardAddressTakenIatEntryTable; /* 0a0 */
3648 ULONGLONG GuardAddressTakenIatEntryCount;
3649 ULONGLONG GuardLongJumpTargetTable; /* 0b0 */
3650 ULONGLONG GuardLongJumpTargetCount;
3651 ULONGLONG DynamicValueRelocTable; /* 0c0 */
3652 ULONGLONG CHPEMetadataPointer;
3653 ULONGLONG GuardRFFailureRoutine; /* 0d0 */
3654 ULONGLONG GuardRFFailureRoutineFunctionPointer;
3655 DWORD DynamicValueRelocTableOffset; /* 0e0 */
3656 WORD DynamicValueRelocTableSection;
3657 WORD Reserved2;
3658 ULONGLONG GuardRFVerifyStackPointerFunctionPointer;
3659 DWORD HotPatchTableOffset; /* 0f0 */
3660 DWORD Reserved3;
3661 ULONGLONG EnclaveConfigurationPointer;
3662 ULONGLONG VolatileMetadataPointer; /* 100 */
3663 ULONGLONG GuardEHContinuationTable;
3664 ULONGLONG GuardEHContinuationCount; /* 110 */
3665 ULONGLONG GuardXFGCheckFunctionPointer;
3666 ULONGLONG GuardXFGDispatchFunctionPointer; /* 120 */
3667 ULONGLONG GuardXFGTableDispatchFunctionPointer;
3668 ULONGLONG CastGuardOsDeterminedFailureMode; /* 130 */
3669 ULONGLONG GuardMemcpyFunctionPointer;
3670 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
3672 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
3673 DWORD Size; /* 000 */
3674 DWORD TimeDateStamp;
3675 WORD MajorVersion;
3676 WORD MinorVersion;
3677 DWORD GlobalFlagsClear;
3678 DWORD GlobalFlagsSet; /* 010 */
3679 DWORD CriticalSectionDefaultTimeout;
3680 DWORD DeCommitFreeBlockThreshold;
3681 DWORD DeCommitTotalFreeThreshold;
3682 DWORD LockPrefixTable; /* 020 */
3683 DWORD MaximumAllocationSize;
3684 DWORD VirtualMemoryThreshold;
3685 DWORD ProcessHeapFlags;
3686 DWORD ProcessAffinityMask; /* 030 */
3687 WORD CSDVersion;
3688 WORD DependentLoadFlags;
3689 DWORD EditList;
3690 DWORD SecurityCookie;
3691 DWORD SEHandlerTable; /* 040 */
3692 DWORD SEHandlerCount;
3693 DWORD GuardCFCheckFunctionPointer;
3694 DWORD GuardCFDispatchFunctionPointer;
3695 DWORD GuardCFFunctionTable; /* 050 */
3696 DWORD GuardCFFunctionCount;
3697 DWORD GuardFlags;
3698 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
3699 DWORD GuardAddressTakenIatEntryTable;
3700 DWORD GuardAddressTakenIatEntryCount;
3701 DWORD GuardLongJumpTargetTable; /* 070 */
3702 DWORD GuardLongJumpTargetCount;
3703 DWORD DynamicValueRelocTable;
3704 DWORD CHPEMetadataPointer;
3705 DWORD GuardRFFailureRoutine; /* 080 */
3706 DWORD GuardRFFailureRoutineFunctionPointer;
3707 DWORD DynamicValueRelocTableOffset;
3708 WORD DynamicValueRelocTableSection;
3709 WORD Reserved2;
3710 DWORD GuardRFVerifyStackPointerFunctionPointer; /* 090 */
3711 DWORD HotPatchTableOffset;
3712 DWORD Reserved3;
3713 DWORD EnclaveConfigurationPointer;
3714 DWORD VolatileMetadataPointer; /* 0a0 */
3715 DWORD GuardEHContinuationTable;
3716 DWORD GuardEHContinuationCount;
3717 DWORD GuardXFGCheckFunctionPointer;
3718 DWORD GuardXFGDispatchFunctionPointer; /* 0b0 */
3719 DWORD GuardXFGTableDispatchFunctionPointer;
3720 DWORD CastGuardOsDeterminedFailureMode;
3721 DWORD GuardMemcpyFunctionPointer;
3722 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
3724 #ifdef _WIN64
3725 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
3726 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
3727 #else
3728 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
3729 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
3730 #endif
3732 typedef struct _IMAGE_DYNAMIC_RELOCATION_TABLE
3734 DWORD Version;
3735 DWORD Size;
3736 } IMAGE_DYNAMIC_RELOCATION_TABLE, *PIMAGE_DYNAMIC_RELOCATION_TABLE;
3738 #include <pshpack1.h>
3740 typedef struct _IMAGE_DYNAMIC_RELOCATION32
3742 DWORD Symbol;
3743 DWORD BaseRelocSize;
3744 } IMAGE_DYNAMIC_RELOCATION32, *PIMAGE_DYNAMIC_RELOCATION32;
3746 typedef struct _IMAGE_DYNAMIC_RELOCATION64
3748 ULONGLONG Symbol;
3749 DWORD BaseRelocSize;
3750 } IMAGE_DYNAMIC_RELOCATION64, *PIMAGE_DYNAMIC_RELOCATION64;
3752 typedef struct _IMAGE_DYNAMIC_RELOCATION32_V2
3754 DWORD HeaderSize;
3755 DWORD FixupInfoSize;
3756 DWORD Symbol;
3757 DWORD SymbolGroup;
3758 DWORD Flags;
3759 } IMAGE_DYNAMIC_RELOCATION32_V2, *PIMAGE_DYNAMIC_RELOCATION32_V2;
3761 typedef struct _IMAGE_DYNAMIC_RELOCATION64_V2
3763 DWORD HeaderSize;
3764 DWORD FixupInfoSize;
3765 ULONGLONG Symbol;
3766 DWORD SymbolGroup;
3767 DWORD Flags;
3768 } IMAGE_DYNAMIC_RELOCATION64_V2, *PIMAGE_DYNAMIC_RELOCATION64_V2;
3770 #include <poppack.h>
3772 #ifdef _WIN64
3773 typedef IMAGE_DYNAMIC_RELOCATION64 IMAGE_DYNAMIC_RELOCATION;
3774 typedef PIMAGE_DYNAMIC_RELOCATION64 PIMAGE_DYNAMIC_RELOCATION;
3775 typedef IMAGE_DYNAMIC_RELOCATION64_V2 IMAGE_DYNAMIC_RELOCATION_V2;
3776 typedef PIMAGE_DYNAMIC_RELOCATION64_V2 PIMAGE_DYNAMIC_RELOCATION_V2;
3777 #else
3778 typedef IMAGE_DYNAMIC_RELOCATION32 IMAGE_DYNAMIC_RELOCATION;
3779 typedef PIMAGE_DYNAMIC_RELOCATION32 PIMAGE_DYNAMIC_RELOCATION;
3780 typedef IMAGE_DYNAMIC_RELOCATION32_V2 IMAGE_DYNAMIC_RELOCATION_V2;
3781 typedef PIMAGE_DYNAMIC_RELOCATION32_V2 PIMAGE_DYNAMIC_RELOCATION_V2;
3782 #endif
3784 #define IMAGE_DYNAMIC_RELOCATION_GUARD_RF_PROLOGUE 1
3785 #define IMAGE_DYNAMIC_RELOCATION_GUARD_RF_EPILOGUE 2
3786 #define IMAGE_DYNAMIC_RELOCATION_GUARD_IMPORT_CONTROL_TRANSFER 3
3787 #define IMAGE_DYNAMIC_RELOCATION_GUARD_INDIR_CONTROL_TRANSFER 4
3788 #define IMAGE_DYNAMIC_RELOCATION_GUARD_SWITCHTABLE_BRANCH 5
3789 #define IMAGE_DYNAMIC_RELOCATION_ARM64X 6
3791 typedef struct _IMAGE_FUNCTION_ENTRY {
3792 DWORD StartingAddress;
3793 DWORD EndingAddress;
3794 DWORD EndOfPrologue;
3795 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3797 #define IMAGE_DEBUG_MISC_EXENAME 1
3799 typedef struct _IMAGE_DEBUG_MISC {
3800 DWORD DataType;
3801 DWORD Length;
3802 BYTE Unicode;
3803 BYTE Reserved[ 3 ];
3804 BYTE Data[ 1 ];
3805 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3807 /* This is the structure that appears at the very start of a .DBG file. */
3809 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3810 WORD Signature;
3811 WORD Flags;
3812 WORD Machine;
3813 WORD Characteristics;
3814 DWORD TimeDateStamp;
3815 DWORD CheckSum;
3816 DWORD ImageBase;
3817 DWORD SizeOfImage;
3818 DWORD NumberOfSections;
3819 DWORD ExportedNamesSize;
3820 DWORD DebugDirectorySize;
3821 DWORD SectionAlignment;
3822 DWORD Reserved[ 2 ];
3823 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3825 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3828 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3829 WORD Length;
3830 WORD Flags;
3831 BYTE Text[1];
3832 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3833 #define MESSAGE_RESOURCE_UNICODE 0x0001
3835 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3836 DWORD LowId;
3837 DWORD HighId;
3838 DWORD OffsetToEntries;
3839 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3841 typedef struct tagMESSAGE_RESOURCE_DATA {
3842 DWORD NumberOfBlocks;
3843 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
3844 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3847 * Here follows typedefs for security and tokens.
3851 * First a constant for the following typedefs.
3854 #define ANYSIZE_ARRAY 1
3856 /* FIXME: Orphan. What does it point to? */
3857 typedef PVOID PACCESS_TOKEN;
3858 typedef PVOID PSECURITY_DESCRIPTOR;
3859 typedef PVOID PSID;
3861 typedef enum _TOKEN_ELEVATION_TYPE {
3862 TokenElevationTypeDefault = 1,
3863 TokenElevationTypeFull,
3864 TokenElevationTypeLimited
3865 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
3868 * TOKEN_INFORMATION_CLASS
3871 typedef enum _TOKEN_INFORMATION_CLASS {
3872 TokenUser = 1,
3873 TokenGroups,
3874 TokenPrivileges,
3875 TokenOwner,
3876 TokenPrimaryGroup,
3877 TokenDefaultDacl,
3878 TokenSource,
3879 TokenType,
3880 TokenImpersonationLevel,
3881 TokenStatistics,
3882 TokenRestrictedSids,
3883 TokenSessionId,
3884 TokenGroupsAndPrivileges,
3885 TokenSessionReference,
3886 TokenSandBoxInert,
3887 TokenAuditPolicy,
3888 TokenOrigin,
3889 TokenElevationType,
3890 TokenLinkedToken,
3891 TokenElevation,
3892 TokenHasRestrictions,
3893 TokenAccessInformation,
3894 TokenVirtualizationAllowed,
3895 TokenVirtualizationEnabled,
3896 TokenIntegrityLevel,
3897 TokenUIAccess,
3898 TokenMandatoryPolicy,
3899 TokenLogonSid,
3900 TokenIsAppContainer,
3901 TokenCapabilities,
3902 TokenAppContainerSid,
3903 TokenAppContainerNumber,
3904 TokenUserClaimAttributes,
3905 TokenDeviceClaimAttributes,
3906 TokenRestrictedUserClaimAttributes,
3907 TokenRestrictedDeviceClaimAttributes,
3908 TokenDeviceGroups,
3909 TokenRestrictedDeviceGroups,
3910 TokenSecurityAttributes,
3911 TokenIsRestricted,
3912 TokenProcessTrustLevel,
3913 MaxTokenInfoClass
3914 } TOKEN_INFORMATION_CLASS;
3916 #define DISABLE_MAX_PRIVILEGE 0x1
3917 #define SANDBOX_INERT 0x2
3918 #define LUA_TOKEN 0x4
3919 #define WRITE_RESTRICTED 0x8
3921 #define TOKEN_ASSIGN_PRIMARY 0x0001
3922 #define TOKEN_DUPLICATE 0x0002
3923 #define TOKEN_IMPERSONATE 0x0004
3924 #define TOKEN_QUERY 0x0008
3925 #define TOKEN_QUERY_SOURCE 0x0010
3926 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3927 #define TOKEN_ADJUST_GROUPS 0x0040
3928 #define TOKEN_ADJUST_DEFAULT 0x0080
3929 #define TOKEN_ADJUST_SESSIONID 0x0100
3930 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3931 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3932 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3933 TOKEN_ADJUST_PRIVILEGES | \
3934 TOKEN_ADJUST_GROUPS | \
3935 TOKEN_ADJUST_DEFAULT )
3936 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3937 TOKEN_ASSIGN_PRIMARY | \
3938 TOKEN_DUPLICATE | \
3939 TOKEN_IMPERSONATE | \
3940 TOKEN_QUERY | \
3941 TOKEN_QUERY_SOURCE | \
3942 TOKEN_ADJUST_PRIVILEGES | \
3943 TOKEN_ADJUST_GROUPS | \
3944 TOKEN_ADJUST_SESSIONID | \
3945 TOKEN_ADJUST_DEFAULT )
3947 #ifndef _SECURITY_DEFINED
3948 #define _SECURITY_DEFINED
3950 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3952 typedef struct _GENERIC_MAPPING {
3953 ACCESS_MASK GenericRead;
3954 ACCESS_MASK GenericWrite;
3955 ACCESS_MASK GenericExecute;
3956 ACCESS_MASK GenericAll;
3957 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3959 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3960 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3961 typedef struct {
3962 BYTE Value[6];
3963 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
3964 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3966 #ifndef SID_DEFINED
3967 #define SID_DEFINED
3968 typedef struct _SID {
3969 BYTE Revision;
3970 BYTE SubAuthorityCount;
3971 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3972 DWORD SubAuthority[1];
3973 } SID,*PISID;
3974 #endif /* !defined(SID_DEFINED) */
3976 #define CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID 0x01
3978 #define SID_REVISION (1) /* Current revision */
3979 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3980 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3982 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3985 * ACL
3988 #define ACL_REVISION1 1
3989 #define ACL_REVISION2 2
3990 #define ACL_REVISION3 3
3991 #define ACL_REVISION4 4
3993 #define MIN_ACL_REVISION ACL_REVISION2
3994 #define MAX_ACL_REVISION ACL_REVISION4
3996 #define ACL_REVISION 2
3998 typedef struct _ACL {
3999 BYTE AclRevision;
4000 BYTE Sbz1;
4001 WORD AclSize;
4002 WORD AceCount;
4003 WORD Sbz2;
4004 } ACL, *PACL;
4006 typedef enum _ACL_INFORMATION_CLASS
4008 AclRevisionInformation = 1,
4009 AclSizeInformation
4010 } ACL_INFORMATION_CLASS;
4012 typedef struct _ACL_REVISION_INFORMATION
4014 DWORD AclRevision;
4015 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
4017 typedef struct _ACL_SIZE_INFORMATION
4019 DWORD AceCount;
4020 DWORD AclBytesInUse;
4021 DWORD AclBytesFree;
4022 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
4024 /* SECURITY_DESCRIPTOR */
4025 #define SECURITY_DESCRIPTOR_REVISION 1
4026 #define SECURITY_DESCRIPTOR_REVISION1 1
4030 * Privilege Names
4032 #ifdef UNICODE
4033 #if defined(_MSC_VER) || defined(__MINGW32__)
4034 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4035 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4036 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4037 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4038 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4039 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4040 #define SE_TCB_NAME L"SeTcbPrivilege"
4041 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4042 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4043 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4044 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4045 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4046 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4047 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4048 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4049 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4050 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4051 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4052 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4053 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4054 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4055 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4056 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4057 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4058 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4059 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4060 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4061 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4062 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4063 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4064 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4065 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4066 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4067 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4068 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4069 #else /* _MSC_VER/__MINGW32__ */
4070 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 };
4071 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 };
4072 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 };
4073 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 };
4074 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 };
4075 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 };
4076 static const WCHAR SE_TCB_NAME[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4077 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 };
4078 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 };
4079 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 };
4080 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 };
4081 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 };
4082 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 };
4083 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 };
4084 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 };
4085 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 };
4086 static const WCHAR SE_BACKUP_NAME[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4087 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 };
4088 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 };
4089 static const WCHAR SE_DEBUG_NAME[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4090 static const WCHAR SE_AUDIT_NAME[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4091 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 };
4092 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 };
4093 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 };
4094 static const WCHAR SE_UNDOCK_NAME[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4095 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 };
4096 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 };
4097 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 };
4098 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 };
4099 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 };
4100 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 };
4101 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 };
4102 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 };
4103 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 };
4104 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 };
4105 #endif
4106 #else /* UNICODE */
4107 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4108 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4109 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4110 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4111 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4112 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4113 #define SE_TCB_NAME "SeTcbPrivilege"
4114 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4115 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4116 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4117 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4118 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4119 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4120 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4121 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4122 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4123 #define SE_BACKUP_NAME "SeBackupPrivilege"
4124 #define SE_RESTORE_NAME "SeRestorePrivilege"
4125 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4126 #define SE_DEBUG_NAME "SeDebugPrivilege"
4127 #define SE_AUDIT_NAME "SeAuditPrivilege"
4128 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4129 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4130 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4131 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4132 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4133 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4134 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4135 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4136 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4137 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4138 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4139 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4140 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4141 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4142 #endif
4144 #define SE_GROUP_MANDATORY 0x00000001
4145 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4146 #define SE_GROUP_ENABLED 0x00000004
4147 #define SE_GROUP_OWNER 0x00000008
4148 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4149 #define SE_GROUP_INTEGRITY 0x00000020
4150 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4151 #define SE_GROUP_LOGON_ID 0xC0000000
4152 #define SE_GROUP_RESOURCE 0x20000000
4153 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4155 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4156 #define SE_PRIVILEGE_ENABLED 0x00000002
4157 #define SE_PRIVILEGE_REMOVED 0x00000004
4158 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4159 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4161 #define PRIVILEGE_SET_ALL_NECESSARY 1
4163 #define SE_OWNER_DEFAULTED 0x00000001
4164 #define SE_GROUP_DEFAULTED 0x00000002
4165 #define SE_DACL_PRESENT 0x00000004
4166 #define SE_DACL_DEFAULTED 0x00000008
4167 #define SE_SACL_PRESENT 0x00000010
4168 #define SE_SACL_DEFAULTED 0x00000020
4169 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4170 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4171 #define SE_DACL_AUTO_INHERITED 0x00000400
4172 #define SE_SACL_AUTO_INHERITED 0x00000800
4173 #define SE_DACL_PROTECTED 0x00001000
4174 #define SE_SACL_PROTECTED 0x00002000
4175 #define SE_RM_CONTROL_VALID 0x00004000
4176 #define SE_SELF_RELATIVE 0x00008000
4178 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4179 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4181 /* The security descriptor structure */
4182 typedef struct {
4183 BYTE Revision;
4184 BYTE Sbz1;
4185 SECURITY_DESCRIPTOR_CONTROL Control;
4186 DWORD Owner;
4187 DWORD Group;
4188 DWORD Sacl;
4189 DWORD Dacl;
4190 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4192 typedef struct {
4193 BYTE Revision;
4194 BYTE Sbz1;
4195 SECURITY_DESCRIPTOR_CONTROL Control;
4196 PSID Owner;
4197 PSID Group;
4198 PACL Sacl;
4199 PACL Dacl;
4200 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4202 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4204 #endif /* _SECURITY_DEFINED */
4207 * SID_AND_ATTRIBUTES
4210 typedef struct _SID_AND_ATTRIBUTES {
4211 PSID Sid;
4212 DWORD Attributes;
4213 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4215 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
4216 typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
4218 #define SID_HASH_SIZE 32
4220 typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
4222 typedef struct _SID_AND_ATTRIBUTES_HASH {
4223 DWORD SidCount;
4224 PSID_AND_ATTRIBUTES SidAttr;
4225 SID_HASH_ENTRY Hash[SID_HASH_SIZE];
4226 } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
4228 /* security entities */
4229 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4230 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4231 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4233 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4235 /* S-1-1 */
4236 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4238 /* S-1-2 */
4239 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4240 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4242 /* S-1-3 */
4243 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4244 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4245 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4246 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4247 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4248 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4250 /* S-1-4 */
4251 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4253 /* S-1-5 */
4254 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4255 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4256 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4257 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4258 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4259 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4260 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4261 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4262 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4263 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4264 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4265 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4266 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4267 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4268 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4269 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4270 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4271 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4272 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4273 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4274 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4275 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4276 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4277 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4279 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4280 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4281 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4282 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4283 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4284 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4285 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4286 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4287 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4288 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4289 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4290 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4291 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4292 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4293 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4294 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4295 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4296 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4297 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4298 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4299 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4300 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4302 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4304 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4305 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4306 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4307 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4308 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4310 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4311 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4312 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4313 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4314 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4315 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4316 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4317 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4318 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4319 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4321 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4323 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4324 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4325 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4326 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4327 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4328 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4329 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4330 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4331 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4332 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4333 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4335 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4336 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4337 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4338 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4339 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4340 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4341 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4342 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4343 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4345 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4347 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4348 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4349 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4350 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4352 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4353 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4354 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4355 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4357 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4358 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4359 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4360 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4361 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4362 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4364 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4365 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4366 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4367 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4368 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4369 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4370 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4371 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4372 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4373 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4374 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4376 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4378 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4379 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4380 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4381 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4382 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4383 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4384 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4385 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4386 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4387 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4388 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4390 #define SYSTEM_LUID { 0x3e7, 0x0 }
4391 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4392 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4393 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4394 #define IUSER_LUID { 0x3e3, 0x0 }
4396 typedef enum {
4397 WinNullSid = 0,
4398 WinWorldSid = 1,
4399 WinLocalSid = 2,
4400 WinCreatorOwnerSid = 3,
4401 WinCreatorGroupSid = 4,
4402 WinCreatorOwnerServerSid = 5,
4403 WinCreatorGroupServerSid = 6,
4404 WinNtAuthoritySid = 7,
4405 WinDialupSid = 8,
4406 WinNetworkSid = 9,
4407 WinBatchSid = 10,
4408 WinInteractiveSid = 11,
4409 WinServiceSid = 12,
4410 WinAnonymousSid = 13,
4411 WinProxySid = 14,
4412 WinEnterpriseControllersSid = 15,
4413 WinSelfSid = 16,
4414 WinAuthenticatedUserSid = 17,
4415 WinRestrictedCodeSid = 18,
4416 WinTerminalServerSid = 19,
4417 WinRemoteLogonIdSid = 20,
4418 WinLogonIdsSid = 21,
4419 WinLocalSystemSid = 22,
4420 WinLocalServiceSid = 23,
4421 WinNetworkServiceSid = 24,
4422 WinBuiltinDomainSid = 25,
4423 WinBuiltinAdministratorsSid = 26,
4424 WinBuiltinUsersSid = 27,
4425 WinBuiltinGuestsSid = 28,
4426 WinBuiltinPowerUsersSid = 29,
4427 WinBuiltinAccountOperatorsSid = 30,
4428 WinBuiltinSystemOperatorsSid = 31,
4429 WinBuiltinPrintOperatorsSid = 32,
4430 WinBuiltinBackupOperatorsSid = 33,
4431 WinBuiltinReplicatorSid = 34,
4432 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4433 WinBuiltinRemoteDesktopUsersSid = 36,
4434 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4435 WinAccountAdministratorSid = 38,
4436 WinAccountGuestSid = 39,
4437 WinAccountKrbtgtSid = 40,
4438 WinAccountDomainAdminsSid = 41,
4439 WinAccountDomainUsersSid = 42,
4440 WinAccountDomainGuestsSid = 43,
4441 WinAccountComputersSid = 44,
4442 WinAccountControllersSid = 45,
4443 WinAccountCertAdminsSid = 46,
4444 WinAccountSchemaAdminsSid = 47,
4445 WinAccountEnterpriseAdminsSid = 48,
4446 WinAccountPolicyAdminsSid = 49,
4447 WinAccountRasAndIasServersSid = 50,
4448 WinNTLMAuthenticationSid = 51,
4449 WinDigestAuthenticationSid = 52,
4450 WinSChannelAuthenticationSid = 53,
4451 WinThisOrganizationSid = 54,
4452 WinOtherOrganizationSid = 55,
4453 WinBuiltinIncomingForestTrustBuildersSid = 56,
4454 WinBuiltinPerfMonitoringUsersSid = 57,
4455 WinBuiltinPerfLoggingUsersSid = 58,
4456 WinBuiltinAuthorizationAccessSid = 59,
4457 WinBuiltinTerminalServerLicenseServersSid = 60,
4458 WinBuiltinDCOMUsersSid = 61,
4459 WinBuiltinIUsersSid = 62,
4460 WinIUserSid = 63,
4461 WinBuiltinCryptoOperatorsSid = 64,
4462 WinUntrustedLabelSid = 65,
4463 WinLowLabelSid = 66,
4464 WinMediumLabelSid = 67,
4465 WinHighLabelSid = 68,
4466 WinSystemLabelSid = 69,
4467 WinWriteRestrictedCodeSid = 70,
4468 WinCreatorOwnerRightsSid = 71,
4469 WinCacheablePrincipalsGroupSid = 72,
4470 WinNonCacheablePrincipalsGroupSid = 73,
4471 WinEnterpriseReadonlyControllersSid = 74,
4472 WinAccountReadonlyControllersSid = 75,
4473 WinBuiltinEventLogReadersGroup = 76,
4474 WinNewEnterpriseReadonlyControllersSid = 77,
4475 WinBuiltinCertSvcDComAccessGroup = 78,
4476 WinMediumPlusLabelSid = 79,
4477 WinLocalLogonSid = 80,
4478 WinConsoleLogonSid = 81,
4479 WinThisOrganizationCertificateSid = 82,
4480 WinApplicationPackageAuthoritySid = 83,
4481 WinBuiltinAnyPackageSid = 84,
4482 WinCapabilityInternetClientSid = 85,
4483 WinCapabilityInternetClientServerSid = 86,
4484 WinCapabilityPrivateNetworkClientServerSid = 87,
4485 WinCapabilityPicturesLibrarySid = 88,
4486 WinCapabilityVideosLibrarySid = 89,
4487 WinCapabilityMusicLibrarySid = 90,
4488 WinCapabilityDocumentsLibrarySid = 91,
4489 WinCapabilitySharedUserCertificatesSid = 92,
4490 WinCapabilityEnterpriseAuthenticationSid = 93,
4491 WinCapabilityRemovableStorageSid = 94,
4492 WinBuiltinRDSRemoteAccessServersSid = 95,
4493 WinBuiltinRDSEndpointServersSid = 96,
4494 WinBuiltinRDSManagementServersSid = 97,
4495 WinUserModeDriversSid = 98,
4496 WinBuiltinHyperVAdminsSid = 99,
4497 WinAccountCloneableControllersSid = 100,
4498 WinBuiltinAccessControlAssistanceOperatorsSid = 101,
4499 WinBuiltinRemoteManagementUsersSid = 102,
4500 WinAuthenticationAuthorityAssertedSid = 103,
4501 WinAuthenticationServiceAssertedSid = 104,
4502 WinLocalAccountSid = 105,
4503 WinLocalAccountAndAdministratorSid = 106,
4504 WinAccountProtectedUsersSid = 107,
4505 } WELL_KNOWN_SID_TYPE;
4508 * TOKEN_USER
4511 typedef struct _TOKEN_USER {
4512 SID_AND_ATTRIBUTES User;
4513 } TOKEN_USER, *PTOKEN_USER;
4516 * TOKEN_GROUPS
4519 typedef struct _TOKEN_GROUPS {
4520 DWORD GroupCount;
4521 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4522 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4525 * LUID_AND_ATTRIBUTES
4528 typedef union _LARGE_INTEGER {
4529 struct {
4530 #ifdef WORDS_BIGENDIAN
4531 LONG HighPart;
4532 DWORD LowPart;
4533 #else
4534 DWORD LowPart;
4535 LONG HighPart;
4536 #endif
4537 } u;
4538 #ifndef NONAMELESSSTRUCT
4539 struct {
4540 #ifdef WORDS_BIGENDIAN
4541 LONG HighPart;
4542 DWORD LowPart;
4543 #else
4544 DWORD LowPart;
4545 LONG HighPart;
4546 #endif
4548 #endif
4549 LONGLONG QuadPart;
4550 } LARGE_INTEGER, *PLARGE_INTEGER;
4552 typedef union _ULARGE_INTEGER {
4553 struct {
4554 #ifdef WORDS_BIGENDIAN
4555 DWORD HighPart;
4556 DWORD LowPart;
4557 #else
4558 DWORD LowPart;
4559 DWORD HighPart;
4560 #endif
4561 } u;
4562 #ifndef NONAMELESSSTRUCT
4563 struct {
4564 #ifdef WORDS_BIGENDIAN
4565 DWORD HighPart;
4566 DWORD LowPart;
4567 #else
4568 DWORD LowPart;
4569 DWORD HighPart;
4570 #endif
4572 #endif
4573 ULONGLONG QuadPart;
4574 } ULARGE_INTEGER, *PULARGE_INTEGER;
4577 * Locally Unique Identifier
4580 typedef struct _LUID {
4581 DWORD LowPart;
4582 LONG HighPart;
4583 } LUID, *PLUID;
4585 #include <pshpack4.h>
4586 typedef struct _LUID_AND_ATTRIBUTES {
4587 LUID Luid;
4588 DWORD Attributes;
4589 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4590 #include <poppack.h>
4593 * PRIVILEGE_SET
4596 typedef struct _PRIVILEGE_SET {
4597 DWORD PrivilegeCount;
4598 DWORD Control;
4599 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4600 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4603 * TOKEN_PRIVILEGES
4606 typedef struct _TOKEN_PRIVILEGES {
4607 DWORD PrivilegeCount;
4608 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4609 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4612 * TOKEN_OWNER
4615 typedef struct _TOKEN_OWNER {
4616 PSID Owner;
4617 } TOKEN_OWNER, *PTOKEN_OWNER;
4620 * TOKEN_PRIMARY_GROUP
4623 typedef struct _TOKEN_PRIMARY_GROUP {
4624 PSID PrimaryGroup;
4625 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4629 * TOKEN_DEFAULT_DACL
4632 typedef struct _TOKEN_DEFAULT_DACL {
4633 PACL DefaultDacl;
4634 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4637 * TOKEN_SOURCE
4640 #define TOKEN_SOURCE_LENGTH 8
4642 typedef struct _TOKEN_SOURCE {
4643 char SourceName[TOKEN_SOURCE_LENGTH];
4644 LUID SourceIdentifier;
4645 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4648 * TOKEN_TYPE
4651 typedef enum tagTOKEN_TYPE {
4652 TokenPrimary = 1,
4653 TokenImpersonation
4654 } TOKEN_TYPE;
4657 * SECURITY_IMPERSONATION_LEVEL
4660 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4661 SecurityAnonymous,
4662 SecurityIdentification,
4663 SecurityImpersonation,
4664 SecurityDelegation
4665 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4667 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4668 #define SECURITY_STATIC_TRACKING (FALSE)
4670 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4671 * PSECURITY_CONTEXT_TRACKING_MODE;
4673 * Quality of Service
4676 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4677 DWORD Length;
4678 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4679 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4680 BOOLEAN EffectiveOnly;
4681 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4684 * TOKEN_STATISTICS
4687 #include <pshpack4.h>
4688 typedef struct _TOKEN_STATISTICS {
4689 LUID TokenId;
4690 LUID AuthenticationId;
4691 LARGE_INTEGER ExpirationTime;
4692 TOKEN_TYPE TokenType;
4693 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4694 DWORD DynamicCharged;
4695 DWORD DynamicAvailable;
4696 DWORD GroupCount;
4697 DWORD PrivilegeCount;
4698 LUID ModifiedId;
4699 } TOKEN_STATISTICS;
4700 #include <poppack.h>
4702 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4703 DWORD SidCount;
4704 DWORD SidLength;
4705 PSID_AND_ATTRIBUTES Sids;
4706 DWORD RestrictedSidCount;
4707 DWORD RestrictedSidLength;
4708 PSID_AND_ATTRIBUTES RestrictedSids;
4709 DWORD PrivilegeCount;
4710 DWORD PrivilegeLength;
4711 PLUID_AND_ATTRIBUTES Privileges;
4712 LUID AuthenticationId;
4713 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4715 typedef struct _TOKEN_ORIGIN {
4716 LUID OriginatingLogonSession;
4717 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4719 typedef struct _TOKEN_LINKED_TOKEN {
4720 HANDLE LinkedToken;
4721 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4723 typedef struct _TOKEN_ELEVATION {
4724 DWORD TokenIsElevated;
4725 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
4727 typedef struct _TOKEN_MANDATORY_LABEL {
4728 SID_AND_ATTRIBUTES Label;
4729 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
4731 #define TOKEN_MANDATORY_POLICY_OFF 0x0
4732 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
4733 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
4734 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
4736 typedef struct _TOKEN_MANDATORY_POLICY {
4737 DWORD Policy;
4738 } TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY;
4740 typedef struct _TOKEN_APPCONTAINER_INFORMATION {
4741 PSID TokenAppContainer;
4742 } TOKEN_APPCONTAINER_INFORMATION, * PTOKEN_APPCONTAINER_INFORMATION;
4744 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
4746 typedef struct _TOKEN_AUDIT_POLICY {
4747 BYTE PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
4748 } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
4750 typedef struct _TOKEN_ACCESS_INFORMATION {
4751 PSID_AND_ATTRIBUTES_HASH SidHash;
4752 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
4753 PTOKEN_PRIVILEGES Privileges;
4754 LUID AuthenticationId;
4755 TOKEN_TYPE TokenType;
4756 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4757 TOKEN_MANDATORY_POLICY MandatoryPolicy;
4758 DWORD Flags;
4759 } TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION;
4761 typedef struct _TOKEN_CONTROL {
4762 LUID TokenId;
4763 LUID AuthenticationId;
4764 LUID ModifiedId;
4765 TOKEN_SOURCE TokenSource;
4766 } TOKEN_CONTROL, *PTOKEN_CONTROL;
4769 * ACLs of NT
4772 /* ACEs, directly starting after an ACL */
4773 typedef struct _ACE_HEADER {
4774 BYTE AceType;
4775 BYTE AceFlags;
4776 WORD AceSize;
4777 } ACE_HEADER,*PACE_HEADER;
4779 /* AceType */
4780 #define ACCESS_MIN_MS_ACE_TYPE 0x0
4781 #define ACCESS_ALLOWED_ACE_TYPE 0x0
4782 #define ACCESS_DENIED_ACE_TYPE 0x1
4783 #define SYSTEM_AUDIT_ACE_TYPE 0x2
4784 #define SYSTEM_ALARM_ACE_TYPE 0x3
4785 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
4786 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
4787 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
4788 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
4789 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
4790 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
4791 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
4792 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
4793 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
4794 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
4795 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
4796 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
4797 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
4798 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
4799 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
4800 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
4801 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
4802 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
4803 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
4804 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
4805 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
4806 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
4808 /* inherit AceFlags */
4809 #define OBJECT_INHERIT_ACE 0x01
4810 #define CONTAINER_INHERIT_ACE 0x02
4811 #define NO_PROPAGATE_INHERIT_ACE 0x04
4812 #define INHERIT_ONLY_ACE 0x08
4813 #define INHERITED_ACE 0x10
4814 #define VALID_INHERIT_FLAGS 0x1F
4816 /* AceFlags mask for what events we (should) audit */
4817 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4818 #define FAILED_ACCESS_ACE_FLAG 0x80
4820 /* different ACEs depending on AceType
4821 * SidStart marks the begin of a SID
4822 * so the thing finally looks like this:
4823 * 0: ACE_HEADER
4824 * 4: ACCESS_MASK
4825 * 8... : SID
4827 typedef struct _ACCESS_ALLOWED_ACE {
4828 ACE_HEADER Header;
4829 DWORD Mask;
4830 DWORD SidStart;
4831 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
4833 typedef struct _ACCESS_DENIED_ACE {
4834 ACE_HEADER Header;
4835 DWORD Mask;
4836 DWORD SidStart;
4837 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
4839 typedef struct _SYSTEM_AUDIT_ACE {
4840 ACE_HEADER Header;
4841 DWORD Mask;
4842 DWORD SidStart;
4843 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
4845 typedef struct _SYSTEM_ALARM_ACE {
4846 ACE_HEADER Header;
4847 DWORD Mask;
4848 DWORD SidStart;
4849 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
4851 typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
4852 ACE_HEADER Header;
4853 ACCESS_MASK Mask;
4854 DWORD SidStart;
4855 } SYSTEM_MANDATORY_LABEL_ACE,*PSYSTEM_MANDATORY_LABEL_ACE;
4857 typedef struct _SYSTEM_PROCESS_TRUST_LABEL_ACE {
4858 ACE_HEADER Header;
4859 ACCESS_MASK Mask;
4860 DWORD SidStart;
4861 } SYSTEM_PROCESS_TRUST_LABEL_ACE, *PSYSTEM_PROCESS_TRUST_LABEL_ACE;
4863 typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
4864 ACE_HEADER Header;
4865 ACCESS_MASK Mask;
4866 DWORD Flags;
4867 GUID ObjectType;
4868 GUID InheritedObjectType;
4869 DWORD SidStart;
4870 } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
4872 typedef struct _ACCESS_DENIED_OBJECT_ACE {
4873 ACE_HEADER Header;
4874 ACCESS_MASK Mask;
4875 DWORD Flags;
4876 GUID ObjectType;
4877 GUID InheritedObjectType;
4878 DWORD SidStart;
4879 } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
4881 typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
4882 ACE_HEADER Header;
4883 ACCESS_MASK Mask;
4884 DWORD Flags;
4885 GUID ObjectType;
4886 GUID InheritedObjectType;
4887 DWORD SidStart;
4888 } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
4890 typedef struct _SYSTEM_ALARM_OBJECT_ACE {
4891 ACE_HEADER Header;
4892 ACCESS_MASK Mask;
4893 DWORD Flags;
4894 GUID ObjectType;
4895 GUID InheritedObjectType;
4896 DWORD SidStart;
4897 } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_aCE;
4899 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
4900 ACE_HEADER Header;
4901 DWORD Mask;
4902 DWORD SidStart;
4903 } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
4905 typedef struct _ACCESS_DENIED_CALLBACK_ACE {
4906 ACE_HEADER Header;
4907 DWORD Mask;
4908 DWORD SidStart;
4909 } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
4911 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
4912 ACE_HEADER Header;
4913 DWORD Mask;
4914 DWORD SidStart;
4915 } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
4917 typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
4918 ACE_HEADER Header;
4919 DWORD Mask;
4920 DWORD SidStart;
4921 } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
4923 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
4924 ACE_HEADER Header;
4925 ACCESS_MASK Mask;
4926 DWORD Flags;
4927 GUID ObjectType;
4928 GUID InheritedObjectType;
4929 DWORD SidStart;
4930 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
4932 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
4933 ACE_HEADER Header;
4934 ACCESS_MASK Mask;
4935 DWORD Flags;
4936 GUID ObjectType;
4937 GUID InheritedObjectType;
4938 DWORD SidStart;
4939 } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
4941 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
4942 ACE_HEADER Header;
4943 ACCESS_MASK Mask;
4944 DWORD Flags;
4945 GUID ObjectType;
4946 GUID InheritedObjectType;
4947 DWORD SidStart;
4948 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
4950 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
4951 ACE_HEADER Header;
4952 ACCESS_MASK Mask;
4953 DWORD Flags;
4954 GUID ObjectType;
4955 GUID InheritedObjectType;
4956 DWORD SidStart;
4957 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
4959 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
4960 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
4961 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
4962 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
4963 #define SYSTEM_PROCESS_TRUST_LABEL_VALID_MASK 0x00ffffff
4964 #define SYSTEM_PROCESS_TRUST_NOCONSTRAINT_MASK 0xffffffff
4966 typedef enum tagSID_NAME_USE {
4967 SidTypeUser = 1,
4968 SidTypeGroup,
4969 SidTypeDomain,
4970 SidTypeAlias,
4971 SidTypeWellKnownGroup,
4972 SidTypeDeletedAccount,
4973 SidTypeInvalid,
4974 SidTypeUnknown
4975 } SID_NAME_USE,*PSID_NAME_USE;
4977 #define ACE_OBJECT_TYPE_PRESENT 0x1
4978 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4980 /* Access rights */
4982 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4983 #undef DELETE
4984 #define DELETE 0x00010000
4985 #define READ_CONTROL 0x00020000
4986 #define WRITE_DAC 0x00040000
4987 #define WRITE_OWNER 0x00080000
4988 #define SYNCHRONIZE 0x00100000
4989 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4991 #define STANDARD_RIGHTS_READ READ_CONTROL
4992 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4993 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4995 #define STANDARD_RIGHTS_ALL 0x001f0000
4997 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4999 #define GENERIC_READ 0x80000000
5000 #define GENERIC_WRITE 0x40000000
5001 #define GENERIC_EXECUTE 0x20000000
5002 #define GENERIC_ALL 0x10000000
5004 #define MAXIMUM_ALLOWED 0x02000000
5005 #define ACCESS_SYSTEM_SECURITY 0x01000000
5007 #define EVENT_QUERY_STATE 0x0001
5008 #define EVENT_MODIFY_STATE 0x0002
5009 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5011 #define SEMAPHORE_QUERY_STATE 0x0001
5012 #define SEMAPHORE_MODIFY_STATE 0x0002
5013 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5015 #define MUTANT_QUERY_STATE 0x0001
5016 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5018 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5019 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5020 #define JOB_OBJECT_QUERY 0x0004
5021 #define JOB_OBJECT_TERMINATE 0x0008
5022 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5023 #define JOB_OBJECT_IMPERSONATE 0x0020
5024 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3f)
5026 #define TIMER_QUERY_STATE 0x0001
5027 #define TIMER_MODIFY_STATE 0x0002
5028 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5030 #define PROCESS_TERMINATE 0x0001
5031 #define PROCESS_CREATE_THREAD 0x0002
5032 #define PROCESS_VM_OPERATION 0x0008
5033 #define PROCESS_VM_READ 0x0010
5034 #define PROCESS_VM_WRITE 0x0020
5035 #define PROCESS_DUP_HANDLE 0x0040
5036 #define PROCESS_CREATE_PROCESS 0x0080
5037 #define PROCESS_SET_QUOTA 0x0100
5038 #define PROCESS_SET_INFORMATION 0x0200
5039 #define PROCESS_QUERY_INFORMATION 0x0400
5040 #define PROCESS_SUSPEND_RESUME 0x0800
5041 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5042 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5043 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5045 #define THREAD_TERMINATE 0x0001
5046 #define THREAD_SUSPEND_RESUME 0x0002
5047 #define THREAD_GET_CONTEXT 0x0008
5048 #define THREAD_SET_CONTEXT 0x0010
5049 #define THREAD_SET_INFORMATION 0x0020
5050 #define THREAD_QUERY_INFORMATION 0x0040
5051 #define THREAD_SET_THREAD_TOKEN 0x0080
5052 #define THREAD_IMPERSONATE 0x0100
5053 #define THREAD_DIRECT_IMPERSONATION 0x0200
5054 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5055 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5056 #define THREAD_RESUME 0x1000
5057 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5059 #define THREAD_BASE_PRIORITY_LOWRT 15
5060 #define THREAD_BASE_PRIORITY_MAX 2
5061 #define THREAD_BASE_PRIORITY_MIN -2
5062 #define THREAD_BASE_PRIORITY_IDLE -15
5064 typedef struct _QUOTA_LIMITS {
5065 SIZE_T PagedPoolLimit;
5066 SIZE_T NonPagedPoolLimit;
5067 SIZE_T MinimumWorkingSetSize;
5068 SIZE_T MaximumWorkingSetSize;
5069 SIZE_T PagefileLimit;
5070 LARGE_INTEGER TimeLimit;
5071 } QUOTA_LIMITS, *PQUOTA_LIMITS;
5073 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5074 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5075 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5076 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5077 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5079 typedef union _RATE_QUOTA_LIMIT {
5080 DWORD RateData;
5081 struct {
5082 DWORD RatePercent:7;
5083 DWORD Reserved0:25;
5084 } DUMMYSTRUCTNAME;
5085 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
5087 typedef struct _QUOTA_LIMITS_EX {
5088 SIZE_T PagedPoolLimit;
5089 SIZE_T NonPagedPoolLimit;
5090 SIZE_T MinimumWorkingSetSize;
5091 SIZE_T MaximumWorkingSetSize;
5092 SIZE_T PagefileLimit;
5093 LARGE_INTEGER TimeLimit;
5094 SIZE_T WorkingSetLimit;
5095 SIZE_T Reserved2;
5096 SIZE_T Reserved3;
5097 SIZE_T Reserved4;
5098 DWORD Flags;
5099 RATE_QUOTA_LIMIT CpuRateLimit;
5100 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
5102 #define SECTION_QUERY 0x0001
5103 #define SECTION_MAP_WRITE 0x0002
5104 #define SECTION_MAP_READ 0x0004
5105 #define SECTION_MAP_EXECUTE 0x0008
5106 #define SECTION_EXTEND_SIZE 0x0010
5107 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5108 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5110 #define FILE_READ_DATA 0x0001 /* file & pipe */
5111 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5112 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5113 #define FILE_ADD_FILE 0x0002 /* directory */
5114 #define FILE_APPEND_DATA 0x0004 /* file */
5115 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5116 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5117 #define FILE_READ_EA 0x0008 /* file & directory */
5118 #define FILE_READ_PROPERTIES FILE_READ_EA
5119 #define FILE_WRITE_EA 0x0010 /* file & directory */
5120 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5121 #define FILE_EXECUTE 0x0020 /* file */
5122 #define FILE_TRAVERSE 0x0020 /* directory */
5123 #define FILE_DELETE_CHILD 0x0040 /* directory */
5124 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5125 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5126 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5128 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5129 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5130 SYNCHRONIZE)
5131 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5132 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5133 FILE_APPEND_DATA | SYNCHRONIZE)
5134 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5135 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5137 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5138 #define DUPLICATE_SAME_ACCESS 0x00000002
5139 #ifdef __WINESRC__
5140 #define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
5141 #endif
5143 /* File attribute flags */
5144 #define FILE_SHARE_READ 0x00000001
5145 #define FILE_SHARE_WRITE 0x00000002
5146 #define FILE_SHARE_DELETE 0x00000004
5148 #define FILE_ATTRIBUTE_READONLY 0x00000001
5149 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5150 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5151 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5152 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5153 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5154 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5155 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5156 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5157 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5158 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5159 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5160 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5161 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5162 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5163 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5164 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5165 #define FILE_ATTRIBUTE_EA 0x00040000
5167 /* File notification flags */
5168 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5169 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5170 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5171 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5172 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5173 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5174 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5175 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5176 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5177 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5178 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5179 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5180 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5182 #define FILE_ACTION_ADDED 0x00000001
5183 #define FILE_ACTION_REMOVED 0x00000002
5184 #define FILE_ACTION_MODIFIED 0x00000003
5185 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5186 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5187 #define FILE_ACTION_ADDED_STREAM 0x00000006
5188 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5189 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5190 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5191 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5192 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5194 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5195 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5196 #define FILE_UNICODE_ON_DISK 0x00000004
5197 #define FILE_PERSISTENT_ACLS 0x00000008
5198 #define FILE_FILE_COMPRESSION 0x00000010
5199 #define FILE_VOLUME_QUOTAS 0x00000020
5200 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5201 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5202 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5203 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5204 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5205 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5206 #define FILE_NAMED_STREAMS 0x00040000
5207 #define FILE_READ_ONLY_VOLUME 0x00080000
5208 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5209 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5210 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5211 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5212 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5213 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5214 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5215 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5216 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5217 #define FILE_DAX_VOLUME 0x20000000
5218 #define FILE_SUPPORTS_GHOSTING 0x40000000
5220 /* File alignments (NT) */
5221 #define FILE_BYTE_ALIGNMENT 0x00000000
5222 #define FILE_WORD_ALIGNMENT 0x00000001
5223 #define FILE_LONG_ALIGNMENT 0x00000003
5224 #define FILE_QUAD_ALIGNMENT 0x00000007
5225 #define FILE_OCTA_ALIGNMENT 0x0000000f
5226 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5227 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5228 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5229 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5230 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5232 #define COMPRESSION_FORMAT_NONE 0
5233 #define COMPRESSION_FORMAT_DEFAULT 1
5234 #define COMPRESSION_FORMAT_LZNT1 2
5235 #define COMPRESSION_ENGINE_STANDARD 0
5236 #define COMPRESSION_ENGINE_MAXIMUM 256
5238 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5239 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5241 #define REG_NONE 0 /* no type */
5242 #define REG_SZ 1 /* string type (ASCII) */
5243 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5244 #define REG_BINARY 3 /* binary format, callerspecific */
5245 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5246 #define REG_DWORD 4 /* DWORD in little endian format */
5247 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5248 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5249 #define REG_LINK 6 /* symbolic link (UNICODE) */
5250 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5251 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5252 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5253 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5254 #define REG_QWORD 11 /* QWORD in little endian format */
5255 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5257 /* ----------------------------- begin power management --------------------- */
5259 typedef enum _LATENCY_TIME {
5260 LT_DONT_CARE,
5261 LT_LOWEST_LATENCY
5262 } LATENCY_TIME, *PLATENCY_TIME;
5264 #define DISCHARGE_POLICY_CRITICAL 0
5265 #define DISCHARGE_POLICY_LOW 1
5266 #define NUM_DISCHARGE_POLICIES 4
5268 #define PO_THROTTLE_NONE 0
5269 #define PO_THROTTLE_CONSTANT 1
5270 #define PO_THROTTLE_DEGRADE 2
5271 #define PO_THROTTLE_ADAPTIVE 3
5273 typedef enum _POWER_ACTION {
5274 PowerActionNone = 0,
5275 PowerActionReserved,
5276 PowerActionSleep,
5277 PowerActionHibernate,
5278 PowerActionShutdown,
5279 PowerActionShutdownReset,
5280 PowerActionShutdownOff,
5281 PowerActionWarmEject
5282 } POWER_ACTION,
5283 *PPOWER_ACTION;
5285 typedef enum _POWER_PLATFORM_ROLE {
5286 PlatformRoleUnspecified,
5287 PlatformRoleDesktop,
5288 PlatformRoleMobile,
5289 PlatformRoleWorkstation,
5290 PlatformRoleEnterpriseServer,
5291 PlatformRoleSOHOServer,
5292 PlatformRoleAppliancePC,
5293 PlatformRolePerformanceServer,
5294 PlatformRoleSlate,
5295 PlatformRoleMaximum
5296 } POWER_PLATFORM_ROLE, *PPOWER_PLATFORM_ROLE;
5298 typedef enum _SYSTEM_POWER_STATE {
5299 PowerSystemUnspecified = 0,
5300 PowerSystemWorking = 1,
5301 PowerSystemSleeping1 = 2,
5302 PowerSystemSleeping2 = 3,
5303 PowerSystemSleeping3 = 4,
5304 PowerSystemHibernate = 5,
5305 PowerSystemShutdown = 6,
5306 PowerSystemMaximum = 7
5307 } SYSTEM_POWER_STATE,
5308 *PSYSTEM_POWER_STATE;
5310 typedef enum _DEVICE_POWER_STATE {
5311 PowerDeviceUnspecified,
5312 PowerDeviceD0,
5313 PowerDeviceD1,
5314 PowerDeviceD2,
5315 PowerDeviceD3,
5316 PowerDeviceMaximum
5317 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
5319 typedef enum _POWER_INFORMATION_LEVEL {
5320 SystemPowerPolicyAc,
5321 SystemPowerPolicyDc,
5322 VerifySystemPolicyAc,
5323 VerifySystemPolicyDc,
5324 SystemPowerCapabilities,
5325 SystemBatteryState,
5326 SystemPowerStateHandler,
5327 ProcessorStateHandler,
5328 SystemPowerPolicyCurrent,
5329 AdministratorPowerPolicy,
5330 SystemReserveHiberFile,
5331 ProcessorInformation,
5332 SystemPowerInformation,
5333 ProcessorStateHandler2,
5334 LastWakeTime,
5335 LastSleepTime,
5336 SystemExecutionState,
5337 SystemPowerStateNotifyHandler,
5338 ProcessorPowerPolicyAc,
5339 ProcessorPowerPolicyDc,
5340 VerifyProcessorPowerPolicyAc,
5341 VerifyProcessorPowerPolicyDc,
5342 ProcessorPowerPolicyCurrent
5343 } POWER_INFORMATION_LEVEL;
5345 typedef struct _ADMINISTRATOR_POWER_POLICY {
5346 SYSTEM_POWER_STATE MinSleep;
5347 SYSTEM_POWER_STATE MaxSleep;
5348 ULONG MinVideoTimeout;
5349 ULONG MaxVideoTimeout;
5350 ULONG MinSpindownTimeout;
5351 ULONG MaxSpindownTimeout;
5352 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
5354 typedef struct {
5355 ULONG Granularity;
5356 ULONG Capacity;
5357 } BATTERY_REPORTING_SCALE,
5358 *PBATTERY_REPORTING_SCALE;
5360 typedef struct {
5361 POWER_ACTION Action;
5362 ULONG Flags;
5363 ULONG EventCode;
5364 } POWER_ACTION_POLICY,
5365 *PPOWER_ACTION_POLICY;
5367 typedef struct _PROCESSOR_POWER_INFORMATION {
5368 ULONG Number;
5369 ULONG MaxMhz;
5370 ULONG CurrentMhz;
5371 ULONG MhzLimit;
5372 ULONG MaxIdleState;
5373 ULONG CurrentIdleState;
5374 } PROCESSOR_POWER_INFORMATION,
5375 *PPROCESSOR_POWER_INFORMATION;
5377 typedef struct _PROCESSOR_POWER_POLICY_INFO {
5378 ULONG TimeCheck;
5379 ULONG DemoteLimit;
5380 ULONG PromoteLimit;
5381 UCHAR DemotePercent;
5382 UCHAR PromotePercent;
5383 UCHAR Spare[2];
5384 ULONG AllowDemotion:1;
5385 ULONG AllowPromotion:1;
5386 ULONG Reserved:30;
5387 } PROCESSOR_POWER_POLICY_INFO,
5388 *PPROCESSOR_POWER_POLICY_INFO;
5390 typedef struct _PROCESSOR_POWER_POLICY {
5391 DWORD Revision;
5392 BYTE DynamicThrottle;
5393 BYTE Spare[3];
5394 DWORD DisableCStates:1;
5395 DWORD Reserved:31;
5396 DWORD PolicyCount;
5397 PROCESSOR_POWER_POLICY_INFO Policy[3];
5398 } PROCESSOR_POWER_POLICY,
5399 *PPROCESSOR_POWER_POLICY;
5401 typedef struct {
5402 BOOLEAN AcOnLine;
5403 BOOLEAN BatteryPresent;
5404 BOOLEAN Charging;
5405 BOOLEAN Discharging;
5406 BOOLEAN Spare1[3];
5407 BYTE Tag;
5408 ULONG MaxCapacity;
5409 ULONG RemainingCapacity;
5410 ULONG Rate;
5411 ULONG EstimatedTime;
5412 ULONG DefaultAlert1;
5413 ULONG DefaultAlert2;
5414 } SYSTEM_BATTERY_STATE,
5415 *PSYSTEM_BATTERY_STATE;
5417 typedef struct {
5418 BOOLEAN PowerButtonPresent;
5419 BOOLEAN SleepButtonPresent;
5420 BOOLEAN LidPresent;
5421 BOOLEAN SystemS1;
5422 BOOLEAN SystemS2;
5423 BOOLEAN SystemS3;
5424 BOOLEAN SystemS4;
5425 BOOLEAN SystemS5;
5426 BOOLEAN HiberFilePresent;
5427 BOOLEAN FullWake;
5428 BOOLEAN VideoDimPresent;
5429 BOOLEAN ApmPresent;
5430 BOOLEAN UpsPresent;
5431 BOOLEAN ThermalControl;
5432 BOOLEAN ProcessorThrottle;
5433 UCHAR ProcessorMinThrottle;
5434 UCHAR ProcessorMaxThrottle;
5435 UCHAR spare2[4];
5436 BOOLEAN DiskSpinDown;
5437 UCHAR spare3[8];
5438 BOOLEAN SystemBatteriesPresent;
5439 BOOLEAN BatteriesAreShortTerm;
5440 BATTERY_REPORTING_SCALE BatteryScale[3];
5441 SYSTEM_POWER_STATE AcOnLineWake;
5442 SYSTEM_POWER_STATE SoftLidWake;
5443 SYSTEM_POWER_STATE RtcWake;
5444 SYSTEM_POWER_STATE MinDeviceWakeState;
5445 SYSTEM_POWER_STATE DefaultLowLatencyWake;
5446 } SYSTEM_POWER_CAPABILITIES,
5447 *PSYSTEM_POWER_CAPABILITIES;
5449 typedef struct _SYSTEM_POWER_INFORMATION {
5450 ULONG MaxIdlenessAllowed;
5451 ULONG Idleness;
5452 ULONG TimeRemaining;
5453 UCHAR CoolingMode;
5454 } SYSTEM_POWER_INFORMATION,
5455 *PSYSTEM_POWER_INFORMATION;
5457 typedef struct _SYSTEM_POWER_LEVEL {
5458 BOOLEAN Enable;
5459 UCHAR Spare[3];
5460 ULONG BatteryLevel;
5461 POWER_ACTION_POLICY PowerPolicy;
5462 SYSTEM_POWER_STATE MinSystemState;
5463 } SYSTEM_POWER_LEVEL,
5464 *PSYSTEM_POWER_LEVEL;
5466 typedef struct _SYSTEM_POWER_POLICY {
5467 ULONG Revision;
5468 POWER_ACTION_POLICY PowerButton;
5469 POWER_ACTION_POLICY SleepButton;
5470 POWER_ACTION_POLICY LidClose;
5471 SYSTEM_POWER_STATE LidOpenWake;
5472 ULONG Reserved;
5473 POWER_ACTION_POLICY Idle;
5474 ULONG IdleTimeout;
5475 UCHAR IdleSensitivity;
5476 UCHAR DynamicThrottle;
5477 UCHAR Spare2[2];
5478 SYSTEM_POWER_STATE MinSleep;
5479 SYSTEM_POWER_STATE MaxSleep;
5480 SYSTEM_POWER_STATE ReducedLatencySleep;
5481 ULONG WinLogonFlags;
5482 ULONG Spare3;
5483 ULONG DozeS4Timeout;
5484 ULONG BroadcastCapacityResolution;
5485 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
5486 ULONG VideoTimeout;
5487 BOOLEAN VideoDimDisplay;
5488 ULONG VideoReserved[3];
5489 ULONG SpindownTimeout;
5490 BOOLEAN OptimizeForPower;
5491 UCHAR FanThrottleTolerance;
5492 UCHAR ForcedThrottle;
5493 UCHAR MinThrottle;
5494 POWER_ACTION_POLICY OverThrottled;
5495 } SYSTEM_POWER_POLICY,
5496 *PSYSTEM_POWER_POLICY;
5498 typedef enum _POWER_REQUEST_TYPE
5500 PowerRequestDisplayRequired,
5501 PowerRequestSystemRequired,
5502 PowerRequestAwayModeRequired
5503 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
5505 #define POWER_REQUEST_CONTEXT_VERSION 0
5507 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5508 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5510 typedef union _FILE_SEGMENT_ELEMENT {
5511 PVOID64 Buffer;
5512 ULONGLONG Alignment;
5513 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5515 typedef struct _FILE_NOTIFY_INFORMATION {
5516 DWORD NextEntryOffset;
5517 DWORD Action;
5518 DWORD FileNameLength;
5519 WCHAR FileName[1];
5520 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5522 /* ----------------------------- begin tape storage --------------------- */
5524 #define TAPE_FIXED_PARTITIONS 0
5525 #define TAPE_SELECT_PARTITIONS 1
5526 #define TAPE_INITIATOR_PARTITIONS 2
5527 #define TAPE_ERASE_SHORT 0
5528 #define TAPE_ERASE_LONG 1
5529 #define TAPE_LOAD 0
5530 #define TAPE_UNLOAD 1
5531 #define TAPE_TENSION 2
5532 #define TAPE_LOCK 3
5533 #define TAPE_UNLOCK 4
5534 #define TAPE_FORMAT 5
5535 #define TAPE_SETMARKS 0
5536 #define TAPE_FILEMARKS 1
5537 #define TAPE_SHORT_FILEMARKS 2
5538 #define TAPE_LONG_FILEMARKS 3
5539 #define TAPE_REWIND 0
5540 #define TAPE_ABSOLUTE_BLOCK 1
5541 #define TAPE_LOGICAL_BLOCK 2
5542 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5543 #define TAPE_SPACE_END_OF_DATA 4
5544 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5545 #define TAPE_SPACE_FILEMARKS 6
5546 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5547 #define TAPE_SPACE_SETMARKS 8
5548 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5550 typedef struct _TAPE_CREATE_PARTITION {
5551 DWORD Method;
5552 DWORD Count;
5553 DWORD Size;
5554 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5556 typedef struct _TAPE_ERASE {
5557 DWORD Type;
5558 BOOLEAN Immediate;
5559 } TAPE_ERASE, *PTAPE_ERASE;
5561 typedef struct _TAPE_PREPARE {
5562 DWORD Operation;
5563 BOOLEAN Immediate;
5564 } TAPE_PREPARE, *PTAPE_PREPARE;
5566 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5567 BOOLEAN ECC;
5568 BOOLEAN Compression;
5569 BOOLEAN DataPadding;
5570 BOOLEAN ReportSetmarks;
5571 ULONG EOTWarningZoneSize;
5572 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5574 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5575 ULONG BlockSize;
5576 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5578 typedef struct _TAPE_WRITE_MARKS {
5579 DWORD Type;
5580 DWORD Count;
5581 BOOLEAN Immediate;
5582 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5584 typedef struct _TAPE_GET_POSITION {
5585 ULONG Type;
5586 ULONG Partition;
5587 ULONG OffsetLow;
5588 ULONG OffsetHigh;
5589 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5591 typedef struct _TAPE_SET_POSITION {
5592 ULONG Method;
5593 ULONG Partition;
5594 LARGE_INTEGER Offset;
5595 BOOLEAN Immediate;
5596 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5598 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5599 BOOLEAN ECC;
5600 BOOLEAN Compression;
5601 BOOLEAN DataPadding;
5602 BOOLEAN ReportSetmarks;
5603 DWORD DefaultBlockSize;
5604 DWORD MaximumBlockSize;
5605 DWORD MinimumBlockSize;
5606 DWORD MaximumPartitionCount;
5607 DWORD FeaturesLow;
5608 DWORD FeaturesHigh;
5609 DWORD EOTWarningZoneSize;
5610 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
5612 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
5613 LARGE_INTEGER Capacity;
5614 LARGE_INTEGER Remaining;
5615 DWORD BlockSize;
5616 DWORD PartitionCount;
5617 BOOLEAN WriteProtected;
5618 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
5620 /* ----------------------------- begin registry ----------------------------- */
5622 /* Registry security values */
5623 #define OWNER_SECURITY_INFORMATION 0x00000001
5624 #define GROUP_SECURITY_INFORMATION 0x00000002
5625 #define DACL_SECURITY_INFORMATION 0x00000004
5626 #define SACL_SECURITY_INFORMATION 0x00000008
5627 #define LABEL_SECURITY_INFORMATION 0x00000010
5629 #define REG_OPTION_RESERVED 0x00000000
5630 #define REG_OPTION_NON_VOLATILE 0x00000000
5631 #define REG_OPTION_VOLATILE 0x00000001
5632 #define REG_OPTION_CREATE_LINK 0x00000002
5633 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5634 #define REG_OPTION_OPEN_LINK 0x00000008
5635 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
5636 REG_OPTION_NON_VOLATILE | \
5637 REG_OPTION_VOLATILE | \
5638 REG_OPTION_CREATE_LINK | \
5639 REG_OPTION_BACKUP_RESTORE | \
5640 REG_OPTION_OPEN_LINK)
5643 #define REG_CREATED_NEW_KEY 0x00000001
5644 #define REG_OPENED_EXISTING_KEY 0x00000002
5646 /* For RegNotifyChangeKeyValue */
5647 #define REG_NOTIFY_CHANGE_NAME 0x01
5648 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5649 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5650 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5651 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
5653 #define KEY_QUERY_VALUE 0x00000001
5654 #define KEY_SET_VALUE 0x00000002
5655 #define KEY_CREATE_SUB_KEY 0x00000004
5656 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5657 #define KEY_NOTIFY 0x00000010
5658 #define KEY_CREATE_LINK 0x00000020
5659 #define KEY_WOW64_64KEY 0x00000100
5660 #define KEY_WOW64_32KEY 0x00000200
5661 #define KEY_WOW64_RES 0x00000300
5663 /* for RegKeyRestore flags */
5664 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5665 #define REG_REFRESH_HIVE 0x00000002
5666 #define REG_NO_LAZY_FLUSH 0x00000004
5667 #define REG_FORCE_RESTORE 0x00000008
5668 #define REG_APP_HIVE 0x00000010
5669 #define REG_PROCESS_PRIVATE 0x00000020
5671 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5672 KEY_QUERY_VALUE| \
5673 KEY_ENUMERATE_SUB_KEYS| \
5674 KEY_NOTIFY) \
5675 & (~SYNCHRONIZE) \
5677 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5678 KEY_SET_VALUE| \
5679 KEY_CREATE_SUB_KEY) \
5680 & (~SYNCHRONIZE) \
5682 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5683 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5684 KEY_QUERY_VALUE| \
5685 KEY_SET_VALUE| \
5686 KEY_CREATE_SUB_KEY| \
5687 KEY_ENUMERATE_SUB_KEYS| \
5688 KEY_NOTIFY| \
5689 KEY_CREATE_LINK) \
5690 & (~SYNCHRONIZE) \
5692 /* ------------------------------ end registry ------------------------------ */
5695 #define EVENTLOG_SUCCESS 0x0000
5696 #define EVENTLOG_ERROR_TYPE 0x0001
5697 #define EVENTLOG_WARNING_TYPE 0x0002
5698 #define EVENTLOG_INFORMATION_TYPE 0x0004
5699 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5700 #define EVENTLOG_AUDIT_FAILURE 0x0010
5702 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5703 #define EVENTLOG_SEEK_READ 0x0002
5704 #define EVENTLOG_FORWARDS_READ 0x0004
5705 #define EVENTLOG_BACKWARDS_READ 0x0008
5707 typedef struct _EVENTLOGRECORD {
5708 DWORD Length;
5709 DWORD Reserved;
5710 DWORD RecordNumber;
5711 DWORD TimeGenerated;
5712 DWORD TimeWritten;
5713 DWORD EventID;
5714 WORD EventType;
5715 WORD NumStrings;
5716 WORD EventCategory;
5717 WORD ReservedFlags;
5718 DWORD ClosingRecordNumber;
5719 DWORD StringOffset;
5720 DWORD UserSidLength;
5721 DWORD UserSidOffset;
5722 DWORD DataLength;
5723 DWORD DataOffset;
5724 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5726 #define SERVICE_BOOT_START 0x00000000
5727 #define SERVICE_SYSTEM_START 0x00000001
5728 #define SERVICE_AUTO_START 0x00000002
5729 #define SERVICE_DEMAND_START 0x00000003
5730 #define SERVICE_DISABLED 0x00000004
5732 #define SERVICE_ERROR_IGNORE 0x00000000
5733 #define SERVICE_ERROR_NORMAL 0x00000001
5734 #define SERVICE_ERROR_SEVERE 0x00000002
5735 #define SERVICE_ERROR_CRITICAL 0x00000003
5737 /* Service types */
5738 #define SERVICE_KERNEL_DRIVER 0x00000001
5739 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5740 #define SERVICE_ADAPTER 0x00000004
5741 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5743 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5744 SERVICE_RECOGNIZER_DRIVER )
5746 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5747 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5748 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5750 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5752 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5753 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5756 typedef enum _CM_SERVICE_NODE_TYPE
5758 DriverType = SERVICE_KERNEL_DRIVER,
5759 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
5760 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
5761 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
5762 AdapterType = SERVICE_ADAPTER,
5763 RecognizerType = SERVICE_RECOGNIZER_DRIVER
5764 } SERVICE_NODE_TYPE;
5766 typedef enum _CM_SERVICE_LOAD_TYPE
5768 BootLoad = SERVICE_BOOT_START,
5769 SystemLoad = SERVICE_SYSTEM_START,
5770 AutoLoad = SERVICE_AUTO_START,
5771 DemandLoad = SERVICE_DEMAND_START,
5772 DisableLoad = SERVICE_DISABLED
5773 } SERVICE_LOAD_TYPE;
5775 typedef enum _CM_ERROR_CONTROL_TYPE
5777 IgnoreError = SERVICE_ERROR_IGNORE,
5778 NormalError = SERVICE_ERROR_NORMAL,
5779 SevereError = SERVICE_ERROR_SEVERE,
5780 CriticalError = SERVICE_ERROR_CRITICAL
5781 } SERVICE_ERROR_TYPE;
5783 NTSYSAPI SIZE_T WINAPI RtlCompareMemory(const VOID*, const VOID*, SIZE_T);
5784 NTSYSAPI SIZE_T WINAPI RtlCompareMemoryUlong(VOID*, SIZE_T, ULONG);
5786 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5787 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5788 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5789 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5790 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5792 static FORCEINLINE void *RtlSecureZeroMemory(void *buffer, SIZE_T length)
5794 volatile char *ptr = (volatile char *)buffer;
5796 while (length--) *ptr++ = 0;
5797 return buffer;
5800 #include <guiddef.h>
5802 typedef struct _OBJECT_TYPE_LIST {
5803 WORD Level;
5804 WORD Sbz;
5805 GUID *ObjectType;
5806 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
5808 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5810 WORD Type;
5811 WORD CreatorBackTraceIndex;
5812 struct _RTL_CRITICAL_SECTION *CriticalSection;
5813 LIST_ENTRY ProcessLocksList;
5814 DWORD EntryCount;
5815 DWORD ContentionCount;
5816 #ifdef __WINESRC__ /* in Wine we store the name here */
5817 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
5818 #else
5819 DWORD Spare[ 2 ];
5820 #endif
5821 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
5823 typedef struct _RTL_CRITICAL_SECTION {
5824 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
5825 LONG LockCount;
5826 LONG RecursionCount;
5827 HANDLE OwningThread;
5828 HANDLE LockSemaphore;
5829 ULONG_PTR SpinCount;
5830 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
5832 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5833 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5834 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5835 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5836 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5838 typedef struct _RTL_SRWLOCK {
5839 PVOID Ptr;
5840 } RTL_SRWLOCK, *PRTL_SRWLOCK;
5842 #define RTL_SRWLOCK_INIT {0}
5844 typedef struct _RTL_CONDITION_VARIABLE {
5845 PVOID Ptr;
5846 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
5847 #define RTL_CONDITION_VARIABLE_INIT {0}
5848 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
5850 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
5851 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
5853 #define RTL_RUN_ONCE_INIT {0}
5854 typedef union _RTL_RUN_ONCE {
5855 PVOID Ptr;
5856 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
5858 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
5859 #define RTL_RUN_ONCE_ASYNC 0x00000002
5860 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
5862 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
5863 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
5864 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
5865 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
5866 NTSYSAPI DWORD WINAPI RtlRunOnceBeginInitialize(PRTL_RUN_ONCE, DWORD, PVOID*);
5867 NTSYSAPI DWORD WINAPI RtlRunOnceComplete(PRTL_RUN_ONCE, DWORD, PVOID);
5869 #include <pshpack8.h>
5870 typedef struct _IO_COUNTERS {
5871 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
5872 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
5873 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
5874 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
5875 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
5876 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
5877 } IO_COUNTERS, *PIO_COUNTERS;
5878 #include <poppack.h>
5880 typedef struct {
5881 DWORD dwOSVersionInfoSize;
5882 DWORD dwMajorVersion;
5883 DWORD dwMinorVersion;
5884 DWORD dwBuildNumber;
5885 DWORD dwPlatformId;
5886 CHAR szCSDVersion[128];
5887 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5889 typedef struct {
5890 DWORD dwOSVersionInfoSize;
5891 DWORD dwMajorVersion;
5892 DWORD dwMinorVersion;
5893 DWORD dwBuildNumber;
5894 DWORD dwPlatformId;
5895 WCHAR szCSDVersion[128];
5896 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
5898 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
5899 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
5900 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
5902 typedef struct {
5903 DWORD dwOSVersionInfoSize;
5904 DWORD dwMajorVersion;
5905 DWORD dwMinorVersion;
5906 DWORD dwBuildNumber;
5907 DWORD dwPlatformId;
5908 CHAR szCSDVersion[128];
5909 WORD wServicePackMajor;
5910 WORD wServicePackMinor;
5911 WORD wSuiteMask;
5912 BYTE wProductType;
5913 BYTE wReserved;
5914 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5916 typedef struct {
5917 DWORD dwOSVersionInfoSize;
5918 DWORD dwMajorVersion;
5919 DWORD dwMinorVersion;
5920 DWORD dwBuildNumber;
5921 DWORD dwPlatformId;
5922 WCHAR szCSDVersion[128];
5923 WORD wServicePackMajor;
5924 WORD wServicePackMinor;
5925 WORD wSuiteMask;
5926 BYTE wProductType;
5927 BYTE wReserved;
5928 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
5930 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
5931 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
5932 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
5934 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
5936 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5938 #define VER_PLATFORM_WIN32s 0
5939 #define VER_PLATFORM_WIN32_WINDOWS 1
5940 #define VER_PLATFORM_WIN32_NT 2
5942 #define VER_MINORVERSION 0x00000001
5943 #define VER_MAJORVERSION 0x00000002
5944 #define VER_BUILDNUMBER 0x00000004
5945 #define VER_PLATFORMID 0x00000008
5946 #define VER_SERVICEPACKMINOR 0x00000010
5947 #define VER_SERVICEPACKMAJOR 0x00000020
5948 #define VER_SUITENAME 0x00000040
5949 #define VER_PRODUCT_TYPE 0x00000080
5951 #define VER_NT_WORKSTATION 1
5952 #define VER_NT_DOMAIN_CONTROLLER 2
5953 #define VER_NT_SERVER 3
5955 #define VER_SUITE_SMALLBUSINESS 0x00000001
5956 #define VER_SUITE_ENTERPRISE 0x00000002
5957 #define VER_SUITE_BACKOFFICE 0x00000004
5958 #define VER_SUITE_COMMUNICATIONS 0x00000008
5959 #define VER_SUITE_TERMINAL 0x00000010
5960 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5961 #define VER_SUITE_EMBEDDEDNT 0x00000040
5962 #define VER_SUITE_DATACENTER 0x00000080
5963 #define VER_SUITE_SINGLEUSERTS 0x00000100
5964 #define VER_SUITE_PERSONAL 0x00000200
5965 #define VER_SUITE_BLADE 0x00000400
5966 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
5967 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
5968 #define VER_SUITE_STORAGE_SERVER 0x00002000
5969 #define VER_SUITE_COMPUTE_SERVER 0x00004000
5970 #define VER_SUITE_WH_SERVER 0x00008000
5972 #define VER_EQUAL 1
5973 #define VER_GREATER 2
5974 #define VER_GREATER_EQUAL 3
5975 #define VER_LESS 4
5976 #define VER_LESS_EQUAL 5
5977 #define VER_AND 6
5978 #define VER_OR 7
5980 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
5981 DWORD dwFlags;
5982 DWORD ulFormatVersion;
5983 DWORD ulAssemblyCount;
5984 DWORD ulRootManifestPathType;
5985 DWORD ulRootManifestPathChars;
5986 DWORD ulRootConfigurationPathType;
5987 DWORD ulRootConfigurationPathChars;
5988 DWORD ulAppDirPathType;
5989 DWORD ulAppDirPathChars;
5990 PCWSTR lpRootManifestPath;
5991 PCWSTR lpRootConfigurationPath;
5992 PCWSTR lpAppDirPath;
5993 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
5995 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
5996 DWORD ulFlags;
5997 DWORD ulEncodedAssemblyIdentityLength;
5998 DWORD ulManifestPathType;
5999 DWORD ulManifestPathLength;
6000 LARGE_INTEGER liManifestLastWriteTime;
6001 DWORD ulPolicyPathType;
6002 DWORD ulPolicyPathLength;
6003 LARGE_INTEGER liPolicyLastWriteTime;
6004 DWORD ulMetadataSatelliteRosterIndex;
6005 DWORD ulManifestVersionMajor;
6006 DWORD ulManifestVersionMinor;
6007 DWORD ulPolicyVersionMajor;
6008 DWORD ulPolicyVersionMinor;
6009 DWORD ulAssemblyDirectoryNameLength;
6010 PCWSTR lpAssemblyEncodedAssemblyIdentity;
6011 PCWSTR lpAssemblyManifestPath;
6012 PCWSTR lpAssemblyPolicyPath;
6013 PCWSTR lpAssemblyDirectoryName;
6014 DWORD ulFileCount;
6015 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
6017 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
6018 DWORD ulAssemblyIndex;
6019 DWORD ulFileIndexInAssembly;
6020 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
6022 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
6024 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
6025 DWORD ulFlags;
6026 DWORD ulFilenameLength;
6027 DWORD ulPathLength;
6028 PCWSTR lpFileName;
6029 PCWSTR lpFilePath;
6030 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
6032 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
6034 typedef enum {
6035 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
6036 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
6037 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION,
6038 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6039 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
6041 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
6042 GUID Id;
6043 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
6044 ULONGLONG MaxVersionTested;
6045 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
6047 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6048 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
6049 DWORD ElementCount;
6050 COMPATIBILITY_CONTEXT_ELEMENT Elements[];
6051 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
6052 #endif
6054 typedef enum {
6055 ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
6056 ACTCTX_RUN_LEVEL_AS_INVOKER,
6057 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
6058 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
6059 ACTCTX_RUN_LEVEL_NUMBERS
6060 } ACTCTX_REQUESTED_RUN_LEVEL;
6062 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
6063 DWORD ulFlags;
6064 ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
6065 DWORD UiAccess;
6066 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6068 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION *PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6070 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
6071 ActivationContextBasicInformation = 1,
6072 ActivationContextDetailedInformation = 2,
6073 AssemblyDetailedInformationInActivationContext = 3,
6074 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
6075 RunlevelInformationInActivationContext = 5,
6076 CompatibilityInformationInActivationContext = 6,
6077 ActivationContextManifestResourceName = 7,
6078 MaxActivationContextInfoClass,
6079 AssemblyDetailedInformationInActivationContxt = AssemblyDetailedInformationInActivationContext,
6080 FileInformationInAssemblyOfAssemblyInActivationContxt = FileInformationInAssemblyOfAssemblyInActivationContext
6081 } ACTIVATION_CONTEXT_INFO_CLASS;
6083 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6084 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6085 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6086 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6088 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6089 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6090 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6091 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6092 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6093 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6094 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6095 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6096 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6097 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6098 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6099 #define ACTIVATION_CONTEXT_SECTION_WINRT_ACTIVATABLE_CLASSES 12
6101 typedef enum _JOBOBJECTINFOCLASS
6103 JobObjectBasicAccountingInformation = 1,
6104 JobObjectBasicLimitInformation,
6105 JobObjectBasicProcessIdList,
6106 JobObjectBasicUIRestrictions,
6107 JobObjectSecurityLimitInformation,
6108 JobObjectEndOfJobTimeInformation,
6109 JobObjectAssociateCompletionPortInformation,
6110 JobObjectBasicAndIoAccountingInformation,
6111 JobObjectExtendedLimitInformation,
6112 JobObjectJobSetInformation,
6113 MaxJobObjectInfoClass
6114 } JOBOBJECTINFOCLASS;
6116 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
6117 LARGE_INTEGER TotalUserTime;
6118 LARGE_INTEGER TotalKernelTime;
6119 LARGE_INTEGER ThisPeriodTotalUserTime;
6120 LARGE_INTEGER ThisPeriodTotalKernelTime;
6121 DWORD TotalPageFaultCount;
6122 DWORD TotalProcesses;
6123 DWORD ActiveProcesses;
6124 DWORD TotalTerminatedProcesses;
6125 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
6127 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
6128 LARGE_INTEGER PerProcessUserTimeLimit;
6129 LARGE_INTEGER PerJobUserTimeLimit;
6130 DWORD LimitFlags;
6131 SIZE_T MinimumWorkingSetSize;
6132 SIZE_T MaximumWorkingSetSize;
6133 DWORD ActiveProcessLimit;
6134 ULONG_PTR Affinity;
6135 DWORD PriorityClass;
6136 DWORD SchedulingClass;
6137 } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
6139 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
6140 DWORD NumberOfAssignedProcesses;
6141 DWORD NumberOfProcessIdsInList;
6142 ULONG_PTR ProcessIdList[1];
6143 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
6145 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
6146 DWORD UIRestrictionsClass;
6147 } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
6149 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
6150 DWORD SecurityLimitFlags;
6151 HANDLE JobToken;
6152 PTOKEN_GROUPS SidsToDisable;
6153 PTOKEN_PRIVILEGES PrivilegesToDelete;
6154 PTOKEN_GROUPS RestrictedSids;
6155 } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
6157 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
6158 DWORD EndOfJobTimeAction;
6159 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
6161 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
6162 PVOID CompletionKey;
6163 HANDLE CompletionPort;
6164 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
6166 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6167 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6168 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6169 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6170 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6171 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6172 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6173 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6174 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6176 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
6177 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
6178 IO_COUNTERS IoInfo;
6179 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
6181 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
6182 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
6183 IO_COUNTERS IoInfo;
6184 SIZE_T ProcessMemoryLimit;
6185 SIZE_T JobMemoryLimit;
6186 SIZE_T PeakProcessMemoryUsed;
6187 SIZE_T PeakJobMemoryUsed;
6188 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
6190 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6191 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6192 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6193 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6194 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6195 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6196 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6197 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6198 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6199 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6200 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6201 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6202 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6203 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6204 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6206 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6207 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6208 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6210 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6212 RelationProcessorCore = 0,
6213 RelationNumaNode = 1,
6214 RelationCache = 2,
6215 RelationProcessorPackage = 3,
6216 RelationGroup = 4,
6217 RelationProcessorDie = 5,
6218 RelationNumaNodeEx = 6,
6219 RelationProcessorModule = 7,
6220 RelationAll = 0xffff
6221 } LOGICAL_PROCESSOR_RELATIONSHIP;
6223 #define LTP_PC_SMT 0x1
6225 typedef enum _PROCESSOR_CACHE_TYPE
6227 CacheUnified,
6228 CacheInstruction,
6229 CacheData,
6230 CacheTrace
6231 } PROCESSOR_CACHE_TYPE;
6233 typedef struct _PROCESSOR_GROUP_INFO
6235 BYTE MaximumProcessorCount;
6236 BYTE ActiveProcessorCount;
6237 BYTE Reserved[38];
6238 KAFFINITY ActiveProcessorMask;
6239 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
6241 typedef struct _CACHE_DESCRIPTOR
6243 BYTE Level;
6244 BYTE Associativity;
6245 WORD LineSize;
6246 DWORD Size;
6247 PROCESSOR_CACHE_TYPE Type;
6248 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
6250 typedef struct _GROUP_AFFINITY
6252 KAFFINITY Mask;
6253 WORD Group;
6254 WORD Reserved[3];
6255 } GROUP_AFFINITY, *PGROUP_AFFINITY;
6257 #define ALL_PROCESSOR_GROUPS 0xffff
6259 typedef struct _PROCESSOR_NUMBER
6261 WORD Group;
6262 BYTE Number;
6263 BYTE Reserved;
6264 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
6266 typedef struct _PROCESSOR_RELATIONSHIP
6268 BYTE Flags;
6269 BYTE EfficiencyClass;
6270 BYTE Reserved[20];
6271 WORD GroupCount;
6272 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
6273 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
6275 typedef struct _NUMA_NODE_RELATIONSHIP
6277 DWORD NodeNumber;
6278 BYTE Reserved[20];
6279 GROUP_AFFINITY GroupMask;
6280 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
6282 typedef struct _CACHE_RELATIONSHIP
6284 BYTE Level;
6285 BYTE Associativity;
6286 WORD LineSize;
6287 DWORD CacheSize;
6288 PROCESSOR_CACHE_TYPE Type;
6289 BYTE Reserved[20];
6290 GROUP_AFFINITY GroupMask;
6291 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
6293 typedef struct _GROUP_RELATIONSHIP
6295 WORD MaximumGroupCount;
6296 WORD ActiveGroupCount;
6297 BYTE Reserved[20];
6298 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
6299 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
6301 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6303 ULONG_PTR ProcessorMask;
6304 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6305 union
6307 struct
6309 BYTE Flags;
6310 } ProcessorCore;
6311 struct
6313 DWORD NodeNumber;
6314 } NumaNode;
6315 CACHE_DESCRIPTOR Cache;
6316 ULONGLONG Reserved[2];
6317 } DUMMYUNIONNAME;
6318 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
6320 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6322 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6323 DWORD Size;
6324 union
6326 PROCESSOR_RELATIONSHIP Processor;
6327 NUMA_NODE_RELATIONSHIP NumaNode;
6328 CACHE_RELATIONSHIP Cache;
6329 GROUP_RELATIONSHIP Group;
6330 } DUMMYUNIONNAME;
6331 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
6333 typedef enum _CPU_SET_INFORMATION_TYPE
6335 CpuSetInformation,
6336 } CPU_SET_INFORMATION_TYPE, *PCPU_SET_INFORMATION_TYPE;
6338 typedef struct _SYSTEM_CPU_SET_INFORMATION
6340 DWORD Size;
6341 CPU_SET_INFORMATION_TYPE Type;
6342 union
6344 struct
6346 DWORD Id;
6347 WORD Group;
6348 BYTE LogicalProcessorIndex;
6349 BYTE CoreIndex;
6350 BYTE LastLevelCacheIndex;
6351 BYTE NumaNodeIndex;
6352 BYTE EfficiencyClass;
6353 union
6355 BYTE AllFlags;
6356 struct
6358 BYTE Parked : 1;
6359 BYTE Allocated : 1;
6360 BYTE AllocatedToTargetProcess : 1;
6361 BYTE RealTime : 1;
6362 BYTE ReservedFlags : 4;
6363 } DUMMYSTRUCTNAME;
6364 } DUMMYUNIONNAME2;
6365 union {
6366 DWORD Reserved;
6367 BYTE SchedulingClass;
6369 DWORD64 AllocationTag;
6370 } CpuSet;
6371 } DUMMYUNIONNAME;
6372 } SYSTEM_CPU_SET_INFORMATION, *PSYSTEM_CPU_SET_INFORMATION;
6374 /* Threadpool things */
6375 typedef DWORD TP_VERSION,*PTP_VERSION;
6377 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
6379 typedef VOID (CALLBACK *PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID);
6381 typedef struct _TP_POOL TP_POOL,*PTP_POOL;
6383 typedef enum _TP_CALLBACK_PRIORITY
6385 TP_CALLBACK_PRIORITY_HIGH,
6386 TP_CALLBACK_PRIORITY_NORMAL,
6387 TP_CALLBACK_PRIORITY_LOW,
6388 TP_CALLBACK_PRIORITY_INVALID,
6389 TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
6390 } TP_CALLBACK_PRIORITY;
6392 typedef struct _TP_POOL_STACK_INFORMATION
6394 SIZE_T StackReserve;
6395 SIZE_T StackCommit;
6396 } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION;
6398 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
6400 typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID,PVOID);
6402 typedef struct _TP_CALLBACK_ENVIRON_V1
6404 TP_VERSION Version;
6405 PTP_POOL Pool;
6406 PTP_CLEANUP_GROUP CleanupGroup;
6407 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6408 PVOID RaceDll;
6409 struct _ACTIVATION_CONTEXT* ActivationContext;
6410 PTP_SIMPLE_CALLBACK FinalizationCallback;
6411 union
6413 DWORD Flags;
6414 struct
6416 DWORD LongFunction:1;
6417 DWORD Persistent:1;
6418 DWORD Private:30;
6419 } s;
6420 } u;
6421 } TP_CALLBACK_ENVIRON_V1;
6423 typedef struct _TP_CALLBACK_ENVIRON_V3
6425 TP_VERSION Version;
6426 PTP_POOL Pool;
6427 PTP_CLEANUP_GROUP CleanupGroup;
6428 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6429 PVOID RaceDll;
6430 struct _ACTIVATION_CONTEXT *ActivationContext;
6431 PTP_SIMPLE_CALLBACK FinalizationCallback;
6432 union
6434 DWORD Flags;
6435 struct
6437 DWORD LongFunction:1;
6438 DWORD Persistent:1;
6439 DWORD Private:30;
6440 } s;
6441 } u;
6442 TP_CALLBACK_PRIORITY CallbackPriority;
6443 DWORD Size;
6444 } TP_CALLBACK_ENVIRON_V3;
6446 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
6447 typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
6449 typedef DWORD TP_WAIT_RESULT;
6450 typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6452 typedef struct _TP_IO TP_IO, *PTP_IO;
6454 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
6456 typedef VOID (CALLBACK *PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WORK);
6457 typedef VOID (CALLBACK *PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_TIMER);
6458 typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,TP_WAIT_RESULT);
6461 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
6463 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6465 UmsThreadInvalidInfoClass,
6466 UmsThreadUserContext,
6467 UmsThreadPriority,
6468 UmsThreadAffinity,
6469 UmsThreadTeb,
6470 UmsThreadIsSuspended,
6471 UmsThreadIsTerminated,
6472 UmsThreadMaxInfoClass
6473 } RTL_UMS_THREAD_INFO_CLASS, *PRTL_UMS_THREAD_INFO_CLASS;
6475 typedef enum _RTL_UMS_SCHEDULER_REASON
6477 UmsSchedulerStartup,
6478 UmsSchedulerThreadBlocked,
6479 UmsSchedulerThreadYield,
6480 } RTL_UMS_SCHEDULER_REASON, *PRTL_UMS_SCHEDULER_REASON;
6482 typedef void (CALLBACK *PRTL_UMS_SCHEDULER_ENTRY_POINT)(RTL_UMS_SCHEDULER_REASON,ULONG_PTR,PVOID);
6484 typedef enum _PROCESS_MITIGATION_POLICY
6486 ProcessDEPPolicy,
6487 ProcessASLRPolicy,
6488 ProcessDynamicCodePolicy,
6489 ProcessStrictHandleCheckPolicy,
6490 ProcessSystemCallDisablePolicy,
6491 ProcessMitigationOptionsMask,
6492 ProcessExtensionPointDisablePolicy,
6493 ProcessControlFlowGuardPolicy,
6494 ProcessSignaturePolicy,
6495 ProcessFontDisablePolicy,
6496 ProcessImageLoadPolicy,
6497 ProcessSystemCallFilterPolicy,
6498 ProcessPayloadRestrictionPolicy,
6499 ProcessChildProcessPolicy,
6500 ProcessSideChannelIsolationPolicy,
6501 MaxProcessMitigationPolicy
6502 } PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY;
6504 typedef enum _FIRMWARE_TYPE
6506 FirmwareTypeUnknown,
6507 FirmwareTypeBios,
6508 FirmwareTypeUefi,
6509 FirmwareTypeMax
6510 } FIRMWARE_TYPE, *PFIRMWARE_TYPE;
6512 /* Intrinsic functions */
6514 #define BitScanForward _BitScanForward
6515 #define BitScanReverse _BitScanReverse
6516 #define InterlockedAdd _InlineInterlockedAdd
6517 #define InterlockedAnd _InterlockedAnd
6518 #define InterlockedAnd64 _InterlockedAnd64
6519 #define InterlockedCompareExchange _InterlockedCompareExchange
6520 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
6521 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
6522 #define InterlockedDecrement _InterlockedDecrement
6523 #define InterlockedDecrement16 _InterlockedDecrement16
6524 #define InterlockedDecrement64 _InterlockedDecrement64
6525 #define InterlockedExchange _InterlockedExchange
6526 #define InterlockedExchangeAdd _InterlockedExchangeAdd
6527 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
6528 #define InterlockedExchangePointer _InterlockedExchangePointer
6529 #define InterlockedIncrement _InterlockedIncrement
6530 #define InterlockedIncrement16 _InterlockedIncrement16
6531 #define InterlockedIncrement64 _InterlockedIncrement64
6532 #define InterlockedOr _InterlockedOr
6533 #define InterlockedOr64 _InterlockedOr64
6534 #define InterlockedXor _InterlockedXor
6535 #define InterlockedXor64 _InterlockedXor64
6537 #ifdef _MSC_VER
6539 #pragma intrinsic(_BitScanForward)
6540 #pragma intrinsic(_BitScanReverse)
6541 #pragma intrinsic(_InterlockedAnd)
6542 #pragma intrinsic(_InterlockedCompareExchange)
6543 #pragma intrinsic(_InterlockedCompareExchange64)
6544 #pragma intrinsic(_InterlockedCompareExchangePointer)
6545 #pragma intrinsic(_InterlockedExchange)
6546 #pragma intrinsic(_InterlockedExchangeAdd)
6547 #pragma intrinsic(_InterlockedExchangePointer)
6548 #pragma intrinsic(_InterlockedIncrement)
6549 #pragma intrinsic(_InterlockedIncrement16)
6550 #pragma intrinsic(_InterlockedDecrement)
6551 #pragma intrinsic(_InterlockedDecrement16)
6552 #pragma intrinsic(_InterlockedOr)
6553 #pragma intrinsic(_InterlockedXor)
6554 #pragma intrinsic(__fastfail)
6556 BOOLEAN _BitScanForward(unsigned long*,unsigned long);
6557 BOOLEAN _BitScanReverse(unsigned long*,unsigned long);
6558 long _InterlockedAnd(long volatile *,long);
6559 long _InterlockedCompareExchange(long volatile*,long,long);
6560 long long _InterlockedCompareExchange64(long long volatile*,long long,long long);
6561 void * _InterlockedCompareExchangePointer(void *volatile*,void*,void*);
6562 long _InterlockedDecrement(long volatile*);
6563 short _InterlockedDecrement16(short volatile*);
6564 long _InterlockedExchange(long volatile*,long);
6565 long _InterlockedExchangeAdd(long volatile*,long);
6566 void * _InterlockedExchangePointer(void *volatile*,void*);
6567 long _InterlockedIncrement(long volatile*);
6568 short _InterlockedIncrement16(short volatile*);
6569 long _InterlockedOr(long volatile *,long);
6570 long _InterlockedXor(long volatile *,long);
6571 DECLSPEC_NORETURN void __fastfail(unsigned int);
6573 #ifndef __i386__
6575 #pragma intrinsic(_InterlockedAnd64)
6576 #pragma intrinsic(_InterlockedDecrement64)
6577 #pragma intrinsic(_InterlockedExchangeAdd64)
6578 #pragma intrinsic(_InterlockedIncrement64)
6579 #pragma intrinsic(_InterlockedOr64)
6580 #pragma intrinsic(_InterlockedXor64)
6582 __int64 _InterlockedAnd64(__int64 volatile *, __int64);
6583 __int64 _InterlockedDecrement64(__int64 volatile *);
6584 __int64 _InterlockedExchangeAdd64(__int64 volatile *, __int64);
6585 __int64 _InterlockedIncrement64(__int64 volatile *);
6586 __int64 _InterlockedOr64(__int64 volatile *, __int64);
6587 __int64 _InterlockedXor64(__int64 volatile *, __int64);
6589 #else
6591 static FORCEINLINE __int64 InterlockedAnd64( __int64 volatile *dest, __int64 val )
6593 __int64 prev;
6594 do prev = *dest; while (InterlockedCompareExchange64( dest, prev & val, prev ) != prev);
6595 return prev;
6598 static FORCEINLINE __int64 InterlockedExchangeAdd64( __int64 volatile *dest, __int64 val )
6600 __int64 prev;
6601 do prev = *dest; while (InterlockedCompareExchange64( dest, prev + val, prev ) != prev);
6602 return prev;
6605 static FORCEINLINE __int64 InterlockedIncrement64( __int64 volatile *dest )
6607 return InterlockedExchangeAdd64( dest, 1 ) + 1;
6610 static FORCEINLINE __int64 InterlockedDecrement64( __int64 volatile *dest )
6612 return InterlockedExchangeAdd64( dest, -1 ) - 1;
6615 static FORCEINLINE __int64 InterlockedOr64( __int64 volatile *dest, __int64 val )
6617 __int64 prev;
6618 do prev = *dest; while (InterlockedCompareExchange64( dest, prev | val, prev ) != prev);
6619 return prev;
6622 static FORCEINLINE __int64 InterlockedXor64( __int64 volatile *dest, __int64 val )
6624 __int64 prev;
6625 do prev = *dest; while (InterlockedCompareExchange64( dest, prev ^ val, prev ) != prev);
6626 return prev;
6629 #endif /* __i386__ */
6631 static FORCEINLINE long InterlockedAdd( long volatile *dest, long val )
6633 return InterlockedExchangeAdd( dest, val ) + val;
6636 static FORCEINLINE __int64 InterlockedAdd64( __int64 volatile *dest, __int64 val )
6638 return InterlockedExchangeAdd64( dest, val ) + val;
6641 #ifdef __i386__
6643 static FORCEINLINE void MemoryBarrier(void)
6645 LONG dummy;
6646 InterlockedOr(&dummy, 0);
6649 #elif defined(__x86_64__)
6651 #pragma intrinsic(__faststorefence)
6652 void __faststorefence(void);
6654 static FORCEINLINE void MemoryBarrier(void)
6656 __faststorefence();
6659 #elif defined(__arm__)
6661 static FORCEINLINE void MemoryBarrier(void)
6663 __dmb(_ARM_BARRIER_SY);
6666 #elif defined(__aarch64__)
6668 static FORCEINLINE void MemoryBarrier(void)
6670 __dmb(_ARM64_BARRIER_SY);
6673 #endif /* __i386__ */
6675 /* Since Visual Studio 2012, volatile accesses do not always imply acquire and
6676 * release semantics. We explicitly use ISO volatile semantics, manually
6677 * placing barriers as appropriate.
6679 #if _MSC_VER >= 1700
6680 #pragma intrinsic(__iso_volatile_load32)
6681 #pragma intrinsic(__iso_volatile_store32)
6682 #define __WINE_LOAD32_NO_FENCE(src) (__iso_volatile_load32(src))
6683 #define __WINE_STORE32_NO_FENCE(dest, value) (__iso_volatile_store32(dest, value))
6684 #else /* _MSC_VER >= 1700 */
6685 #define __WINE_LOAD32_NO_FENCE(src) (*(src))
6686 #define __WINE_STORE32_NO_FENCE(dest, value) ((void)(*(dest) = (value)))
6687 #endif /* _MSC_VER >= 1700 */
6689 #if defined(__i386__) || defined(__x86_64__)
6690 #pragma intrinsic(_ReadWriteBarrier)
6691 void _ReadWriteBarrier(void);
6692 #endif /* defined(__i386__) || defined(__x86_64__) */
6694 static void __wine_memory_barrier_acq_rel(void)
6696 #if defined(__i386__) || defined(__x86_64__)
6697 #pragma warning(suppress:4996)
6698 _ReadWriteBarrier();
6699 #elif defined(__arm__)
6700 __dmb(_ARM_BARRIER_ISH);
6701 #elif defined(__aarch64__)
6702 __dmb(_ARM64_BARRIER_ISH);
6703 #endif /* defined(__i386__) || defined(__x86_64__) */
6706 static FORCEINLINE LONG ReadAcquire( LONG const volatile *src )
6708 LONG value = __WINE_LOAD32_NO_FENCE( (int const volatile *)src );
6709 __wine_memory_barrier_acq_rel();
6710 return value;
6713 static FORCEINLINE LONG ReadNoFence( LONG const volatile *src )
6715 LONG value = __WINE_LOAD32_NO_FENCE( (int const volatile *)src );
6716 return value;
6719 static FORCEINLINE void WriteRelease( LONG volatile *dest, LONG value )
6721 __wine_memory_barrier_acq_rel();
6722 __WINE_STORE32_NO_FENCE( (int volatile *)dest, value );
6725 static FORCEINLINE void WriteNoFence( LONG volatile *dest, LONG value )
6727 __WINE_STORE32_NO_FENCE( (int volatile *)dest, value );
6730 #elif defined(__GNUC__)
6732 static FORCEINLINE BOOLEAN WINAPI BitScanForward(DWORD *index, DWORD mask)
6734 *index = __builtin_ctz( mask );
6735 return mask != 0;
6738 static FORCEINLINE BOOLEAN WINAPI BitScanReverse(DWORD *index, DWORD mask)
6740 *index = 31 - __builtin_clz( mask );
6741 return mask != 0;
6744 static FORCEINLINE LONG WINAPI InterlockedAdd( LONG volatile *dest, LONG val )
6746 return __sync_add_and_fetch( dest, val );
6749 static FORCEINLINE LONGLONG WINAPI InterlockedAdd64( LONGLONG volatile *dest, LONGLONG val )
6751 return __sync_add_and_fetch( dest, val );
6754 static FORCEINLINE LONG WINAPI InterlockedAnd( LONG volatile *dest, LONG val )
6756 return __sync_fetch_and_and( dest, val );
6759 static FORCEINLINE LONGLONG WINAPI InterlockedAnd64( LONGLONG volatile *dest, LONGLONG val )
6761 return __sync_fetch_and_and( dest, val );
6764 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
6766 return __sync_val_compare_and_swap( dest, compare, xchg );
6769 static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
6771 return __sync_val_compare_and_swap( dest, compare, xchg );
6774 static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
6776 return __sync_val_compare_and_swap( dest, compare, xchg );
6779 static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
6781 LONG ret;
6782 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
6783 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
6784 #elif defined(__i386__) || defined(__x86_64__)
6785 __asm__ __volatile__( "lock; xchgl %0,(%1)"
6786 : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
6787 #else
6788 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
6789 #endif
6790 return ret;
6793 static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
6795 return __sync_fetch_and_add( dest, incr );
6798 static FORCEINLINE LONGLONG WINAPI InterlockedExchangeAdd64( LONGLONG volatile *dest, LONGLONG incr )
6800 return __sync_fetch_and_add( dest, incr );
6803 static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
6805 return __sync_add_and_fetch( dest, 1 );
6808 static FORCEINLINE short WINAPI InterlockedIncrement16( short volatile *dest )
6810 return __sync_add_and_fetch( dest, 1 );
6813 static FORCEINLINE LONGLONG WINAPI InterlockedIncrement64( LONGLONG volatile *dest )
6815 return __sync_add_and_fetch( dest, 1 );
6818 static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
6820 return __sync_add_and_fetch( dest, -1 );
6823 static FORCEINLINE short WINAPI InterlockedDecrement16( short volatile *dest )
6825 return __sync_add_and_fetch( dest, -1 );
6828 static FORCEINLINE LONGLONG WINAPI InterlockedDecrement64( LONGLONG volatile *dest )
6830 return __sync_add_and_fetch( dest, -1 );
6833 static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
6835 void *ret;
6836 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
6837 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
6838 #elif defined(__x86_64__)
6839 __asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
6840 #elif defined(__i386__)
6841 __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
6842 #else
6843 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
6844 #endif
6845 return ret;
6848 static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val )
6850 return __sync_fetch_and_or( dest, val );
6853 static FORCEINLINE LONGLONG WINAPI InterlockedOr64( LONGLONG volatile *dest, LONGLONG val )
6855 return __sync_fetch_and_or( dest, val );
6858 static FORCEINLINE LONG WINAPI InterlockedXor( LONG volatile *dest, LONG val )
6860 return __sync_fetch_and_xor( dest, val );
6863 static FORCEINLINE LONGLONG WINAPI InterlockedXor64( LONGLONG volatile *dest, LONGLONG val )
6865 return __sync_fetch_and_xor( dest, val );
6868 static FORCEINLINE void MemoryBarrier(void)
6870 __sync_synchronize();
6873 #if defined(__x86_64__) || defined(__i386__)
6874 /* On x86, Support old GCC with either no or buggy (GCC BZ#81316) __atomic_* support */
6875 #define __WINE_ATOMIC_LOAD_ACQUIRE(ptr, ret) do { *(ret) = *(ptr); __asm__ __volatile__( "" ::: "memory" ); } while (0)
6876 #define __WINE_ATOMIC_LOAD_RELAXED(ptr, ret) do { *(ret) = *(ptr); } while (0)
6877 #define __WINE_ATOMIC_STORE_RELEASE(ptr, val) do { __asm__ __volatile__( "" ::: "memory" ); *(ptr) = *(val); } while (0)
6878 #define __WINE_ATOMIC_STORE_RELAXED(ptr, val) do { *(ptr) = *(val); } while (0)
6879 #else
6880 #define __WINE_ATOMIC_LOAD_ACQUIRE(ptr, ret) __atomic_load(ptr, ret, __ATOMIC_ACQUIRE)
6881 #define __WINE_ATOMIC_LOAD_RELAXED(ptr, ret) __atomic_load(ptr, ret, __ATOMIC_RELAXED)
6882 #define __WINE_ATOMIC_STORE_RELEASE(ptr, val) __atomic_store(ptr, val, __ATOMIC_RELEASE)
6883 #define __WINE_ATOMIC_STORE_RELAXED(ptr, val) __atomic_store(ptr, val, __ATOMIC_RELAXED)
6884 #endif /* defined(__x86_64__) || defined(__i386__) */
6886 static FORCEINLINE LONG ReadAcquire( LONG const volatile *src )
6888 LONG value;
6889 __WINE_ATOMIC_LOAD_ACQUIRE( src, &value );
6890 return value;
6893 static FORCEINLINE LONG ReadNoFence( LONG const volatile *src )
6895 LONG value;
6896 __WINE_ATOMIC_LOAD_RELAXED( src, &value );
6897 return value;
6900 static FORCEINLINE void WriteRelease( LONG volatile *dest, LONG value )
6902 __WINE_ATOMIC_STORE_RELEASE( dest, &value );
6905 static FORCEINLINE void WriteNoFence( LONG volatile *dest, LONG value )
6907 __WINE_ATOMIC_STORE_RELAXED( dest, &value );
6910 static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code)
6912 #if defined(__x86_64__) || defined(__i386__)
6913 for (;;) __asm__ __volatile__( "int $0x29" :: "c" ((ULONG_PTR)code) : "memory" );
6914 #elif defined(__aarch64__)
6915 register ULONG_PTR val __asm__("x0") = code;
6916 for (;;) __asm__ __volatile__( "brk #0xf003" :: "r" (val) : "memory" );
6917 #elif defined(__arm__)
6918 register ULONG_PTR val __asm__("r0") = code;
6919 for (;;) __asm__ __volatile__( "udf #0xfb" :: "r" (val) : "memory" );
6920 #endif
6923 #endif /* __GNUC__ */
6925 #ifdef _WIN64
6927 #define InterlockedCompareExchange128 _InterlockedCompareExchange128
6929 #if defined(_MSC_VER) && !defined(__clang__)
6931 #pragma intrinsic(_InterlockedCompareExchange128)
6932 unsigned char _InterlockedCompareExchange128(volatile __int64 *, __int64, __int64, __int64 *);
6934 #else
6936 static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64 *dest, __int64 xchg_high, __int64 xchg_low, __int64 *compare )
6938 #ifdef __x86_64__
6939 unsigned char ret;
6940 __asm__ __volatile__( "lock cmpxchg16b %0; setz %b2"
6941 : "=m" (dest[0]), "=m" (dest[1]), "=r" (ret),
6942 "=a" (compare[0]), "=d" (compare[1])
6943 : "m" (dest[0]), "m" (dest[1]), "3" (compare[0]), "4" (compare[1]),
6944 "c" (xchg_high), "b" (xchg_low) );
6945 return ret;
6946 #else
6947 return __sync_bool_compare_and_swap( (__int128 *)dest, *(__int128 *)compare, ((__int128)xchg_high << 64) | xchg_low );
6948 #endif
6951 #endif
6953 #define InterlockedDecrementSizeT(a) InterlockeDecrement64((LONGLONG *)(a))
6954 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)(a), (b))
6955 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)(a))
6957 #else /* _WIN64 */
6959 #define InterlockedDecrementSizeT(a) InterlockeDecrement((LONG *)(a))
6960 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)(a), (b))
6961 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)(a))
6963 #endif /* _WIN64 */
6965 static FORCEINLINE void YieldProcessor(void)
6967 #ifdef __GNUC__
6968 #if defined(__i386__) || defined(__x86_64__)
6969 __asm__ __volatile__( "rep; nop" : : : "memory" );
6970 #elif defined(__arm__) || defined(__aarch64__)
6971 __asm__ __volatile__( "dmb ishst\n\tyield" : : : "memory" );
6972 #else
6973 __asm__ __volatile__( "" : : : "memory" );
6974 #endif
6975 #endif
6978 #ifdef __cplusplus
6980 #endif
6982 #endif /* _WINNT_ */