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