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