dmloader: Get rid of the custom generic stream wrapper.
[wine.git] / include / winnt.h
blobd4137a64aea0069df4ed9ae089ce2c128eb4bb81
1 /*
2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef _WINNT_
22 #define _WINNT_
24 #include <basetsd.h>
25 #include <guiddef.h>
26 #include <winapifamily.h>
27 #include <specstrings.h>
29 #ifndef RC_INVOKED
30 #include <ctype.h>
31 #include <stddef.h>
32 #include <string.h>
33 #endif
36 #if defined(_MSC_VER) && (defined(__arm__) || defined(__aarch64__))
37 #include <intrin.h>
38 #endif
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 #if defined(_NTSYSTEM_) || defined(WINE_UNIX_LIB)
46 #define NTSYSAPI
47 #else
48 #define NTSYSAPI DECLSPEC_IMPORT
49 #endif
51 #define NTAPI __stdcall
52 #define FASTCALL __fastcall
54 #ifndef MIDL_PASS
55 # if defined(_MSC_VER)
56 # define DECLSPEC_IMPORT __declspec(dllimport)
57 # elif defined(__MINGW32__) || defined(__CYGWIN__)
58 # define DECLSPEC_IMPORT __attribute__((dllimport))
59 # else
60 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
61 # endif
62 #else
63 # define DECLSPEC_IMPORT
64 #endif
66 #ifndef DECLSPEC_NORETURN
67 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
68 # define DECLSPEC_NORETURN __declspec(noreturn)
69 # elif defined(__GNUC__)
70 # define DECLSPEC_NORETURN __attribute__((noreturn))
71 # else
72 # define DECLSPEC_NORETURN
73 # endif
74 #endif
76 #ifndef DECLSPEC_ALIGN
77 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
78 # define DECLSPEC_ALIGN(x) __declspec(align(x))
79 # elif defined(__GNUC__)
80 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
81 # else
82 # define DECLSPEC_ALIGN(x)
83 # endif
84 #endif
86 #ifndef DECLSPEC_NOTHROW
87 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
88 # define DECLSPEC_NOTHROW __declspec(nothrow)
89 # elif defined(__GNUC__)
90 # define DECLSPEC_NOTHROW __attribute__((nothrow))
91 # else
92 # define DECLSPEC_NOTHROW
93 # endif
94 #endif
96 #ifndef DECLSPEC_CACHEALIGN
97 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
98 #endif
100 #ifndef DECLSPEC_UUID
101 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
102 # define DECLSPEC_UUID(x) __declspec(uuid(x))
103 # else
104 # define DECLSPEC_UUID(x)
105 # endif
106 #endif
108 #ifndef DECLSPEC_NOVTABLE
109 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
110 # define DECLSPEC_NOVTABLE __declspec(novtable)
111 # else
112 # define DECLSPEC_NOVTABLE
113 # endif
114 #endif
116 #ifndef DECLSPEC_SELECTANY
117 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
118 #define DECLSPEC_SELECTANY __declspec(selectany)
119 #elif defined(__MINGW32__)
120 #define DECLSPEC_SELECTANY __attribute__((selectany))
121 #elif defined(__GNUC__)
122 #define DECLSPEC_SELECTANY __attribute__((weak))
123 #else
124 #define DECLSPEC_SELECTANY
125 #endif
126 #endif
128 #ifndef NOP_FUNCTION
129 # if defined(_MSC_VER)
130 # if (_MSC_VER >= 1210)
131 # define NOP_FUNCTION __noop
132 # else
133 # define NOP_FUNCTION (void)0
134 # endif
135 # else
136 # define NOP_FUNCTION(...)
137 # endif
138 #endif
140 #ifndef DECLSPEC_ADDRSAFE
141 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
142 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
143 # else
144 # define DECLSPEC_ADDRSAFE
145 # endif
146 #endif
148 #ifndef FORCEINLINE
149 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
150 # define FORCEINLINE __forceinline
151 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
152 # define FORCEINLINE inline __attribute__((always_inline))
153 # else
154 # define FORCEINLINE inline
155 # endif
156 #endif
158 #ifndef DECLSPEC_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(__x86_64__) && defined(__GNUC__)
2409 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2411 struct _TEB *teb;
2412 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2413 return teb;
2415 #elif defined(__x86_64__) && defined(_MSC_VER)
2416 unsigned __int64 __readgsqword(unsigned long);
2417 #pragma intrinsic(__readgsqword)
2418 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2420 return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
2422 #elif defined(__arm__) && defined(__GNUC__)
2423 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2425 struct _TEB *teb;
2426 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb));
2427 return teb;
2429 #elif defined(__arm__) && defined(_MSC_VER)
2430 #pragma intrinsic(_MoveFromCoprocessor)
2431 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2433 return (struct _TEB *)(ULONG_PTR)_MoveFromCoprocessor(15, 0, 13, 0, 2);
2435 #elif defined(__aarch64__) && defined(__GNUC__)
2436 register struct _TEB *__wine_current_teb __asm__("x18");
2437 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2439 return __wine_current_teb;
2441 #elif defined(__aarch64__) && defined(_MSC_VER)
2442 unsigned __int64 __getReg(int);
2443 #pragma intrinsic(__getReg)
2444 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2446 return (struct _TEB *)__getReg(18);
2448 #elif !defined(RC_INVOKED)
2449 # error You must define NtCurrentTeb() for your architecture
2450 #endif
2452 #ifdef NONAMELESSUNION
2453 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2454 #else
2455 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2456 #endif
2457 #define GetFiberData() (*(void **)GetCurrentFiber())
2459 #define TLS_MINIMUM_AVAILABLE 64
2461 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2463 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2464 #define IO_REPARSE_TAG_RESERVED_ONE 1
2465 #define IO_REPARSE_TAG_RESERVED_TWO 2
2467 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2469 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2470 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2471 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2472 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2473 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2474 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2475 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2476 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2477 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2478 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2479 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2480 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2481 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2482 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2483 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2484 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2485 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2486 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2487 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2488 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2489 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2490 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2491 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2492 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2493 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2494 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2495 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2496 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2497 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2498 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2499 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2500 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2501 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2502 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2503 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2504 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2505 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2506 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2507 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2508 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2509 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2510 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2511 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2513 #define IsReparseTagNameSurrogate(x) ((x) & 0x20000000)
2516 * File formats definitions
2519 #include <pshpack2.h>
2520 typedef struct _IMAGE_DOS_HEADER {
2521 WORD e_magic; /* 00: MZ Header signature */
2522 WORD e_cblp; /* 02: Bytes on last page of file */
2523 WORD e_cp; /* 04: Pages in file */
2524 WORD e_crlc; /* 06: Relocations */
2525 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2526 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2527 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2528 WORD e_ss; /* 0e: Initial (relative) SS value */
2529 WORD e_sp; /* 10: Initial SP value */
2530 WORD e_csum; /* 12: Checksum */
2531 WORD e_ip; /* 14: Initial IP value */
2532 WORD e_cs; /* 16: Initial (relative) CS value */
2533 WORD e_lfarlc; /* 18: File address of relocation table */
2534 WORD e_ovno; /* 1a: Overlay number */
2535 WORD e_res[4]; /* 1c: Reserved words */
2536 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2537 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2538 WORD e_res2[10]; /* 28: Reserved words */
2539 DWORD e_lfanew; /* 3c: Offset to extended header */
2540 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2541 #include <poppack.h>
2543 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2544 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2545 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2546 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2547 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2548 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2551 * This is the Windows executable (NE) header.
2552 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2554 #include <pshpack2.h>
2555 typedef struct
2557 WORD ne_magic; /* 00 NE signature 'NE' */
2558 BYTE ne_ver; /* 02 Linker version number */
2559 BYTE ne_rev; /* 03 Linker revision number */
2560 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2561 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2562 LONG ne_crc; /* 08 Checksum */
2563 WORD ne_flags; /* 0c Flags about segments in this file */
2564 WORD ne_autodata; /* 0e Automatic data segment number */
2565 WORD ne_heap; /* 10 Initial size of local heap */
2566 WORD ne_stack; /* 12 Initial size of stack */
2567 DWORD ne_csip; /* 14 Initial CS:IP */
2568 DWORD ne_sssp; /* 18 Initial SS:SP */
2569 WORD ne_cseg; /* 1c # of entries in segment table */
2570 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2571 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2572 WORD ne_segtab; /* 22 Offset to segment table */
2573 WORD ne_rsrctab; /* 24 Offset to resource table */
2574 WORD ne_restab; /* 26 Offset to resident-name table */
2575 WORD ne_modtab; /* 28 Offset to module reference table */
2576 WORD ne_imptab; /* 2a Offset to imported name table */
2577 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2578 WORD ne_cmovent; /* 30 # of movable entry points */
2579 WORD ne_align; /* 32 Logical sector alignment shift count */
2580 WORD ne_cres; /* 34 # of resource segments */
2581 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2582 BYTE ne_flagsothers; /* 37 Additional information flags */
2583 WORD ne_pretthunks; /* 38 Offset to return thunks */
2584 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2585 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2586 WORD ne_expver; /* 3e Expected Windows version number */
2587 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2588 #include <poppack.h>
2590 #include <pshpack2.h>
2591 typedef struct _IMAGE_VXD_HEADER {
2592 WORD e32_magic;
2593 BYTE e32_border;
2594 BYTE e32_worder;
2595 DWORD e32_level;
2596 WORD e32_cpu;
2597 WORD e32_os;
2598 DWORD e32_ver;
2599 DWORD e32_mflags;
2600 DWORD e32_mpages;
2601 DWORD e32_startobj;
2602 DWORD e32_eip;
2603 DWORD e32_stackobj;
2604 DWORD e32_esp;
2605 DWORD e32_pagesize;
2606 DWORD e32_lastpagesize;
2607 DWORD e32_fixupsize;
2608 DWORD e32_fixupsum;
2609 DWORD e32_ldrsize;
2610 DWORD e32_ldrsum;
2611 DWORD e32_objtab;
2612 DWORD e32_objcnt;
2613 DWORD e32_objmap;
2614 DWORD e32_itermap;
2615 DWORD e32_rsrctab;
2616 DWORD e32_rsrccnt;
2617 DWORD e32_restab;
2618 DWORD e32_enttab;
2619 DWORD e32_dirtab;
2620 DWORD e32_dircnt;
2621 DWORD e32_fpagetab;
2622 DWORD e32_frectab;
2623 DWORD e32_impmod;
2624 DWORD e32_impmodcnt;
2625 DWORD e32_impproc;
2626 DWORD e32_pagesum;
2627 DWORD e32_datapage;
2628 DWORD e32_preload;
2629 DWORD e32_nrestab;
2630 DWORD e32_cbnrestab;
2631 DWORD e32_nressum;
2632 DWORD e32_autodata;
2633 DWORD e32_debuginfo;
2634 DWORD e32_debuglen;
2635 DWORD e32_instpreload;
2636 DWORD e32_instdemand;
2637 DWORD e32_heapsize;
2638 BYTE e32_res3[12];
2639 DWORD e32_winresoff;
2640 DWORD e32_winreslen;
2641 WORD e32_devid;
2642 WORD e32_ddkver;
2643 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2644 #include <poppack.h>
2646 /* These defines describe the meanings of the bits in the Characteristics
2647 field */
2649 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2650 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2651 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2652 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2653 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2654 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2655 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2656 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2657 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2658 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2659 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2660 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2661 #define IMAGE_FILE_SYSTEM 0x1000
2662 #define IMAGE_FILE_DLL 0x2000
2663 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2664 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2666 /* These are the settings of the Machine field. */
2667 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2668 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
2669 #define IMAGE_FILE_MACHINE_I386 0x014c
2670 #define IMAGE_FILE_MACHINE_R3000 0x0162
2671 #define IMAGE_FILE_MACHINE_R4000 0x0166
2672 #define IMAGE_FILE_MACHINE_R10000 0x0168
2673 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2674 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2675 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2676 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2677 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2678 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2679 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2680 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2681 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2682 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2683 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2684 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2685 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2686 #define IMAGE_FILE_MACHINE_IA64 0x0200
2687 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2688 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2689 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2690 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2691 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2692 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2693 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2694 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2695 #define IMAGE_FILE_MACHINE_CHPE_X86 0x3a64
2696 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2697 #define IMAGE_FILE_MACHINE_M32R 0x9041
2698 #define IMAGE_FILE_MACHINE_ARM64EC 0xa641
2699 #define IMAGE_FILE_MACHINE_ARM64X 0xa64e
2700 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2701 #define IMAGE_FILE_MACHINE_RISCV32 0x5032
2702 #define IMAGE_FILE_MACHINE_RISCV64 0x5064
2703 #define IMAGE_FILE_MACHINE_RISCV128 0x5128
2704 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2706 #define IMAGE_SIZEOF_FILE_HEADER 20
2707 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2708 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2709 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2710 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2711 #define IMAGE_SIZEOF_SHORT_NAME 8
2712 #define IMAGE_SIZEOF_SECTION_HEADER 40
2713 #define IMAGE_SIZEOF_SYMBOL 18
2714 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2715 #define IMAGE_SIZEOF_RELOCATION 10
2716 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2717 #define IMAGE_SIZEOF_LINENUMBER 6
2718 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2720 /* Possible Magic values */
2721 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2722 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2723 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2725 #ifdef _WIN64
2726 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2727 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2728 #else
2729 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2730 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2731 #endif
2733 /* These are indexes into the DataDirectory array */
2734 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2735 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2736 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2737 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2738 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2739 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2740 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2741 #define IMAGE_FILE_DESCRIPTION_STRING 7
2742 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2743 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2744 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2746 /* Directory Entries, indices into the DataDirectory array */
2748 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2749 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2750 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2751 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2752 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2753 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2754 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2755 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2756 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2757 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2758 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2759 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2760 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2761 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2762 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2764 /* Subsystem Values */
2766 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2767 #define IMAGE_SUBSYSTEM_NATIVE 1
2768 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2769 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2770 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2771 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2772 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2773 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2774 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2775 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2776 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2777 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2778 #define IMAGE_SUBSYSTEM_XBOX 14
2779 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2781 /* DLL Characteristics */
2782 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
2783 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2784 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2785 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2786 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2787 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2788 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2789 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
2790 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2791 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
2792 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2794 typedef struct _IMAGE_FILE_HEADER {
2795 WORD Machine;
2796 WORD NumberOfSections;
2797 DWORD TimeDateStamp;
2798 DWORD PointerToSymbolTable;
2799 DWORD NumberOfSymbols;
2800 WORD SizeOfOptionalHeader;
2801 WORD Characteristics;
2802 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2804 typedef struct _IMAGE_DATA_DIRECTORY {
2805 DWORD VirtualAddress;
2806 DWORD Size;
2807 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2809 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2811 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2812 WORD Magic; /* 0x20b */
2813 BYTE MajorLinkerVersion;
2814 BYTE MinorLinkerVersion;
2815 DWORD SizeOfCode;
2816 DWORD SizeOfInitializedData;
2817 DWORD SizeOfUninitializedData;
2818 DWORD AddressOfEntryPoint;
2819 DWORD BaseOfCode;
2820 ULONGLONG ImageBase;
2821 DWORD SectionAlignment;
2822 DWORD FileAlignment;
2823 WORD MajorOperatingSystemVersion;
2824 WORD MinorOperatingSystemVersion;
2825 WORD MajorImageVersion;
2826 WORD MinorImageVersion;
2827 WORD MajorSubsystemVersion;
2828 WORD MinorSubsystemVersion;
2829 DWORD Win32VersionValue;
2830 DWORD SizeOfImage;
2831 DWORD SizeOfHeaders;
2832 DWORD CheckSum;
2833 WORD Subsystem;
2834 WORD DllCharacteristics;
2835 ULONGLONG SizeOfStackReserve;
2836 ULONGLONG SizeOfStackCommit;
2837 ULONGLONG SizeOfHeapReserve;
2838 ULONGLONG SizeOfHeapCommit;
2839 DWORD LoaderFlags;
2840 DWORD NumberOfRvaAndSizes;
2841 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2842 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2844 typedef struct _IMAGE_NT_HEADERS64 {
2845 DWORD Signature;
2846 IMAGE_FILE_HEADER FileHeader;
2847 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2848 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2850 typedef struct _IMAGE_OPTIONAL_HEADER {
2852 /* Standard fields */
2854 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2855 BYTE MajorLinkerVersion;
2856 BYTE MinorLinkerVersion;
2857 DWORD SizeOfCode;
2858 DWORD SizeOfInitializedData;
2859 DWORD SizeOfUninitializedData;
2860 DWORD AddressOfEntryPoint; /* 0x10 */
2861 DWORD BaseOfCode;
2862 DWORD BaseOfData;
2864 /* NT additional fields */
2866 DWORD ImageBase;
2867 DWORD SectionAlignment; /* 0x20 */
2868 DWORD FileAlignment;
2869 WORD MajorOperatingSystemVersion;
2870 WORD MinorOperatingSystemVersion;
2871 WORD MajorImageVersion;
2872 WORD MinorImageVersion;
2873 WORD MajorSubsystemVersion; /* 0x30 */
2874 WORD MinorSubsystemVersion;
2875 DWORD Win32VersionValue;
2876 DWORD SizeOfImage;
2877 DWORD SizeOfHeaders;
2878 DWORD CheckSum; /* 0x40 */
2879 WORD Subsystem;
2880 WORD DllCharacteristics;
2881 DWORD SizeOfStackReserve;
2882 DWORD SizeOfStackCommit;
2883 DWORD SizeOfHeapReserve; /* 0x50 */
2884 DWORD SizeOfHeapCommit;
2885 DWORD LoaderFlags;
2886 DWORD NumberOfRvaAndSizes;
2887 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2888 /* 0xE0 */
2889 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2891 typedef struct _IMAGE_NT_HEADERS {
2892 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2893 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2894 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2895 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2897 #ifdef _WIN64
2898 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2899 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2900 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2901 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2902 #else
2903 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2904 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2905 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2906 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2907 #endif
2909 #define IMAGE_SIZEOF_SHORT_NAME 8
2911 typedef struct _IMAGE_SECTION_HEADER {
2912 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2913 union {
2914 DWORD PhysicalAddress;
2915 DWORD VirtualSize;
2916 } Misc;
2917 DWORD VirtualAddress;
2918 DWORD SizeOfRawData;
2919 DWORD PointerToRawData;
2920 DWORD PointerToRelocations;
2921 DWORD PointerToLinenumbers;
2922 WORD NumberOfRelocations;
2923 WORD NumberOfLinenumbers;
2924 DWORD Characteristics;
2925 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2927 #define IMAGE_SIZEOF_SECTION_HEADER 40
2929 #define IMAGE_FIRST_SECTION(ntheader) \
2930 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2931 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2933 /* These defines are for the Characteristics bitfield. */
2934 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2935 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2936 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2937 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2938 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2939 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2941 #define IMAGE_SCN_CNT_CODE 0x00000020
2942 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2943 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2945 #define IMAGE_SCN_LNK_OTHER 0x00000100
2946 #define IMAGE_SCN_LNK_INFO 0x00000200
2947 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2948 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2949 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2951 /* 0x00002000 - Reserved */
2952 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2953 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2955 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2956 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2957 #define IMAGE_SCN_MEM_16BIT 0x00020000
2958 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2959 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2961 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2962 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2963 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2964 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2965 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2966 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2967 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2968 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2969 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2970 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2971 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2972 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2973 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2974 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2975 /* 0x00F00000 - Unused */
2976 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2978 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2981 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2982 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2983 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2984 #define IMAGE_SCN_MEM_SHARED 0x10000000
2985 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2986 #define IMAGE_SCN_MEM_READ 0x40000000
2987 #define IMAGE_SCN_MEM_WRITE 0x80000000
2989 #include <pshpack2.h>
2991 typedef struct _IMAGE_SYMBOL {
2992 union {
2993 BYTE ShortName[8];
2994 struct {
2995 DWORD Short;
2996 DWORD Long;
2997 } Name;
2998 DWORD LongName[2];
2999 } N;
3000 DWORD Value;
3001 SHORT SectionNumber;
3002 WORD Type;
3003 BYTE StorageClass;
3004 BYTE NumberOfAuxSymbols;
3005 } IMAGE_SYMBOL;
3006 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
3008 #define IMAGE_SIZEOF_SYMBOL 18
3010 typedef struct _IMAGE_LINENUMBER {
3011 union {
3012 DWORD SymbolTableIndex;
3013 DWORD VirtualAddress;
3014 } Type;
3015 WORD Linenumber;
3016 } IMAGE_LINENUMBER;
3017 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
3019 #define IMAGE_SIZEOF_LINENUMBER 6
3021 typedef union _IMAGE_AUX_SYMBOL {
3022 struct {
3023 DWORD TagIndex;
3024 union {
3025 struct {
3026 WORD Linenumber;
3027 WORD Size;
3028 } LnSz;
3029 DWORD TotalSize;
3030 } Misc;
3031 union {
3032 struct {
3033 DWORD PointerToLinenumber;
3034 DWORD PointerToNextFunction;
3035 } Function;
3036 struct {
3037 WORD Dimension[4];
3038 } Array;
3039 } FcnAry;
3040 WORD TvIndex;
3041 } Sym;
3042 struct {
3043 BYTE Name[IMAGE_SIZEOF_SYMBOL];
3044 } File;
3045 struct {
3046 DWORD Length;
3047 WORD NumberOfRelocations;
3048 WORD NumberOfLinenumbers;
3049 DWORD CheckSum;
3050 SHORT Number;
3051 BYTE Selection;
3052 } Section;
3053 } IMAGE_AUX_SYMBOL;
3054 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
3056 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3058 #include <poppack.h>
3060 #define IMAGE_SYM_UNDEFINED (SHORT)0
3061 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3062 #define IMAGE_SYM_DEBUG (SHORT)-2
3064 #define IMAGE_SYM_TYPE_NULL 0x0000
3065 #define IMAGE_SYM_TYPE_VOID 0x0001
3066 #define IMAGE_SYM_TYPE_CHAR 0x0002
3067 #define IMAGE_SYM_TYPE_SHORT 0x0003
3068 #define IMAGE_SYM_TYPE_INT 0x0004
3069 #define IMAGE_SYM_TYPE_LONG 0x0005
3070 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3071 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3072 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3073 #define IMAGE_SYM_TYPE_UNION 0x0009
3074 #define IMAGE_SYM_TYPE_ENUM 0x000A
3075 #define IMAGE_SYM_TYPE_MOE 0x000B
3076 #define IMAGE_SYM_TYPE_BYTE 0x000C
3077 #define IMAGE_SYM_TYPE_WORD 0x000D
3078 #define IMAGE_SYM_TYPE_UINT 0x000E
3079 #define IMAGE_SYM_TYPE_DWORD 0x000F
3080 #define IMAGE_SYM_TYPE_PCODE 0x8000
3082 #define IMAGE_SYM_DTYPE_NULL 0
3083 #define IMAGE_SYM_DTYPE_POINTER 1
3084 #define IMAGE_SYM_DTYPE_FUNCTION 2
3085 #define IMAGE_SYM_DTYPE_ARRAY 3
3087 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3088 #define IMAGE_SYM_CLASS_NULL 0x0000
3089 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3090 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3091 #define IMAGE_SYM_CLASS_STATIC 0x0003
3092 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3093 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3094 #define IMAGE_SYM_CLASS_LABEL 0x0006
3095 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3096 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3097 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3098 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3099 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3100 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3101 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3102 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3103 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3104 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3105 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3106 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3108 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3109 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3110 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3111 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3112 #define IMAGE_SYM_CLASS_FILE 0x0067
3113 #define IMAGE_SYM_CLASS_SECTION 0x0068
3114 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3116 #define N_BTMASK 0x000F
3117 #define N_TMASK 0x0030
3118 #define N_TMASK1 0x00C0
3119 #define N_TMASK2 0x00F0
3120 #define N_BTSHFT 4
3121 #define N_TSHIFT 2
3123 #define BTYPE(x) ((x) & N_BTMASK)
3125 #ifndef ISPTR
3126 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3127 #endif
3129 #ifndef ISFCN
3130 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3131 #endif
3133 #ifndef ISARY
3134 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3135 #endif
3137 #ifndef ISTAG
3138 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3139 #endif
3141 #ifndef INCREF
3142 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3143 #endif
3144 #ifndef DECREF
3145 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3146 #endif
3148 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3149 #define IMAGE_COMDAT_SELECT_ANY 2
3150 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3151 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3152 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3153 #define IMAGE_COMDAT_SELECT_LARGEST 6
3154 #define IMAGE_COMDAT_SELECT_NEWEST 7
3156 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3157 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3158 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3160 /* Export module directory */
3162 typedef struct _IMAGE_EXPORT_DIRECTORY {
3163 DWORD Characteristics;
3164 DWORD TimeDateStamp;
3165 WORD MajorVersion;
3166 WORD MinorVersion;
3167 DWORD Name;
3168 DWORD Base;
3169 DWORD NumberOfFunctions;
3170 DWORD NumberOfNames;
3171 DWORD AddressOfFunctions;
3172 DWORD AddressOfNames;
3173 DWORD AddressOfNameOrdinals;
3174 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
3176 /* Import name entry */
3177 typedef struct _IMAGE_IMPORT_BY_NAME {
3178 WORD Hint;
3179 BYTE Name[1];
3180 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
3182 #include <pshpack8.h>
3183 /* Import thunk */
3184 typedef struct _IMAGE_THUNK_DATA64 {
3185 union {
3186 ULONGLONG ForwarderString;
3187 ULONGLONG Function;
3188 ULONGLONG Ordinal;
3189 ULONGLONG AddressOfData;
3190 } u1;
3191 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3192 #include <poppack.h>
3194 typedef struct _IMAGE_THUNK_DATA32 {
3195 union {
3196 DWORD ForwarderString;
3197 DWORD Function;
3198 DWORD Ordinal;
3199 DWORD AddressOfData;
3200 } u1;
3201 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3203 /* Import module directory */
3205 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3206 union {
3207 DWORD Characteristics; /* 0 for terminating null import descriptor */
3208 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3209 } DUMMYUNIONNAME;
3210 DWORD TimeDateStamp; /* 0 if not bound,
3211 * -1 if bound, and real date\time stamp
3212 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3213 * (new BIND)
3214 * otherwise date/time stamp of DLL bound to
3215 * (Old BIND)
3217 DWORD ForwarderChain; /* -1 if no forwarders */
3218 DWORD Name;
3219 /* RVA to IAT (if bound this IAT has actual addresses) */
3220 DWORD FirstThunk;
3221 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3223 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3224 #define IMAGE_ORDINAL_FLAG32 0x80000000
3225 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3226 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3227 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3228 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3230 #ifdef _WIN64
3231 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3232 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3233 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3234 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3235 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3236 #else
3237 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3238 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3239 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3240 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3241 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3242 #endif
3244 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3246 DWORD TimeDateStamp;
3247 WORD OffsetModuleName;
3248 WORD NumberOfModuleForwarderRefs;
3249 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3250 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3252 typedef struct _IMAGE_BOUND_FORWARDER_REF
3254 DWORD TimeDateStamp;
3255 WORD OffsetModuleName;
3256 WORD Reserved;
3257 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3259 typedef struct _IMAGE_BASE_RELOCATION
3261 DWORD VirtualAddress;
3262 DWORD SizeOfBlock;
3263 /* WORD TypeOffset[1]; */
3264 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3266 #include <pshpack2.h>
3268 typedef struct _IMAGE_RELOCATION
3270 union {
3271 DWORD VirtualAddress;
3272 DWORD RelocCount;
3273 } DUMMYUNIONNAME;
3274 DWORD SymbolTableIndex;
3275 WORD Type;
3276 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3278 #include <poppack.h>
3280 #define IMAGE_SIZEOF_RELOCATION 10
3282 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3284 union
3286 DWORD AllAttributes;
3287 struct
3289 DWORD RvaBased:1;
3290 DWORD ReservedAttributes:31;
3291 } DUMMYSTRUCTNAME;
3292 } Attributes;
3294 DWORD DllNameRVA;
3295 DWORD ModuleHandleRVA;
3296 DWORD ImportAddressTableRVA;
3297 DWORD ImportNameTableRVA;
3298 DWORD BoundImportAddressTableRVA;
3299 DWORD UnloadInformationTableRVA;
3300 DWORD TimeDateStamp;
3301 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3302 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3304 /* generic relocation types */
3305 #define IMAGE_REL_BASED_ABSOLUTE 0
3306 #define IMAGE_REL_BASED_HIGH 1
3307 #define IMAGE_REL_BASED_LOW 2
3308 #define IMAGE_REL_BASED_HIGHLOW 3
3309 #define IMAGE_REL_BASED_HIGHADJ 4
3310 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3311 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3312 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3313 #define IMAGE_REL_BASED_SECTION 6
3314 #define IMAGE_REL_BASED_REL 7
3315 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3316 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3317 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3318 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3319 #define IMAGE_REL_BASED_DIR64 10
3320 #define IMAGE_REL_BASED_HIGH3ADJ 11
3322 /* I386 relocation types */
3323 #define IMAGE_REL_I386_ABSOLUTE 0
3324 #define IMAGE_REL_I386_DIR16 1
3325 #define IMAGE_REL_I386_REL16 2
3326 #define IMAGE_REL_I386_DIR32 6
3327 #define IMAGE_REL_I386_DIR32NB 7
3328 #define IMAGE_REL_I386_SEG12 9
3329 #define IMAGE_REL_I386_SECTION 10
3330 #define IMAGE_REL_I386_SECREL 11
3331 #define IMAGE_REL_I386_TOKEN 12
3332 #define IMAGE_REL_I386_SECREL7 13
3333 #define IMAGE_REL_I386_REL32 20
3335 /* MIPS relocation types */
3336 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3337 #define IMAGE_REL_MIPS_REFHALF 0x0001
3338 #define IMAGE_REL_MIPS_REFWORD 0x0002
3339 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3340 #define IMAGE_REL_MIPS_REFHI 0x0004
3341 #define IMAGE_REL_MIPS_REFLO 0x0005
3342 #define IMAGE_REL_MIPS_GPREL 0x0006
3343 #define IMAGE_REL_MIPS_LITERAL 0x0007
3344 #define IMAGE_REL_MIPS_SECTION 0x000A
3345 #define IMAGE_REL_MIPS_SECREL 0x000B
3346 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3347 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3348 #define IMAGE_REL_MIPS_TOKEN 0x000E
3349 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3350 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3351 #define IMAGE_REL_MIPS_PAIR 0x0025
3353 /* ALPHA relocation types */
3354 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3355 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3356 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3357 #define IMAGE_REL_ALPHA_GPREL 0x0003
3358 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3359 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3360 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3361 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3362 #define IMAGE_REL_ALPHA_HINT 0x0008
3363 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3364 #define IMAGE_REL_ALPHA_REFHI 0x000A
3365 #define IMAGE_REL_ALPHA_REFLO 0x000B
3366 #define IMAGE_REL_ALPHA_PAIR 0x000C
3367 #define IMAGE_REL_ALPHA_MATCH 0x000D
3368 #define IMAGE_REL_ALPHA_SECTION 0x000E
3369 #define IMAGE_REL_ALPHA_SECREL 0x000F
3370 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3371 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3372 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3373 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3374 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3375 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3376 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3377 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3379 /* PowerPC relocation types */
3380 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3381 #define IMAGE_REL_PPC_ADDR64 0x0001
3382 #define IMAGE_REL_PPC_ADDR 0x0002
3383 #define IMAGE_REL_PPC_ADDR24 0x0003
3384 #define IMAGE_REL_PPC_ADDR16 0x0004
3385 #define IMAGE_REL_PPC_ADDR14 0x0005
3386 #define IMAGE_REL_PPC_REL24 0x0006
3387 #define IMAGE_REL_PPC_REL14 0x0007
3388 #define IMAGE_REL_PPC_TOCREL16 0x0008
3389 #define IMAGE_REL_PPC_TOCREL14 0x0009
3390 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3391 #define IMAGE_REL_PPC_SECREL 0x000B
3392 #define IMAGE_REL_PPC_SECTION 0x000C
3393 #define IMAGE_REL_PPC_IFGLUE 0x000D
3394 #define IMAGE_REL_PPC_IMGLUE 0x000E
3395 #define IMAGE_REL_PPC_SECREL16 0x000F
3396 #define IMAGE_REL_PPC_REFHI 0x0010
3397 #define IMAGE_REL_PPC_REFLO 0x0011
3398 #define IMAGE_REL_PPC_PAIR 0x0012
3399 #define IMAGE_REL_PPC_SECRELLO 0x0013
3400 #define IMAGE_REL_PPC_SECRELHI 0x0014
3401 #define IMAGE_REL_PPC_GPREL 0x0015
3402 #define IMAGE_REL_PPC_TOKEN 0x0016
3403 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3404 /* modifier bits */
3405 #define IMAGE_REL_PPC_NEG 0x0100
3406 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3407 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3408 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3410 /* SH3 relocation types */
3411 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3412 #define IMAGE_REL_SH3_DIRECT16 0x0001
3413 #define IMAGE_REL_SH3_DIRECT 0x0002
3414 #define IMAGE_REL_SH3_DIRECT8 0x0003
3415 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3416 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3417 #define IMAGE_REL_SH3_DIRECT4 0x0006
3418 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3419 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3420 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3421 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3422 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3423 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3424 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3425 #define IMAGE_REL_SH3_SECTION 0x000E
3426 #define IMAGE_REL_SH3_SECREL 0x000F
3427 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3428 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3429 #define IMAGE_REL_SH3_TOKEN 0x0012
3431 /* ARM relocation types */
3432 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3433 #define IMAGE_REL_ARM_ADDR 0x0001
3434 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3435 #define IMAGE_REL_ARM_BRANCH24 0x0003
3436 #define IMAGE_REL_ARM_BRANCH11 0x0004
3437 #define IMAGE_REL_ARM_TOKEN 0x0005
3438 #define IMAGE_REL_ARM_GPREL12 0x0006
3439 #define IMAGE_REL_ARM_GPREL7 0x0007
3440 #define IMAGE_REL_ARM_BLX24 0x0008
3441 #define IMAGE_REL_ARM_BLX11 0x0009
3442 #define IMAGE_REL_ARM_SECTION 0x000E
3443 #define IMAGE_REL_ARM_SECREL 0x000F
3444 #define IMAGE_REL_ARM_MOV32A 0x0010
3445 #define IMAGE_REL_ARM_MOV32T 0x0011
3446 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3447 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3448 #define IMAGE_REL_ARM_BLX23T 0x0015
3450 /* ARM64 relocation types */
3451 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3452 #define IMAGE_REL_ARM64_ADDR32 0x0001
3453 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3454 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3455 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3456 #define IMAGE_REL_ARM64_REL21 0x0005
3457 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3458 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3459 #define IMAGE_REL_ARM64_SECREL 0x0008
3460 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3461 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3462 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3463 #define IMAGE_REL_ARM64_TOKEN 0x000C
3464 #define IMAGE_REL_ARM64_SECTION 0x000D
3465 #define IMAGE_REL_ARM64_ADDR64 0x000E
3466 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3468 /* IA64 relocation types */
3469 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3470 #define IMAGE_REL_IA64_IMM14 0x0001
3471 #define IMAGE_REL_IA64_IMM22 0x0002
3472 #define IMAGE_REL_IA64_IMM64 0x0003
3473 #define IMAGE_REL_IA64_DIR 0x0004
3474 #define IMAGE_REL_IA64_DIR64 0x0005
3475 #define IMAGE_REL_IA64_PCREL21B 0x0006
3476 #define IMAGE_REL_IA64_PCREL21M 0x0007
3477 #define IMAGE_REL_IA64_PCREL21F 0x0008
3478 #define IMAGE_REL_IA64_GPREL22 0x0009
3479 #define IMAGE_REL_IA64_LTOFF22 0x000A
3480 #define IMAGE_REL_IA64_SECTION 0x000B
3481 #define IMAGE_REL_IA64_SECREL22 0x000C
3482 #define IMAGE_REL_IA64_SECREL64I 0x000D
3483 #define IMAGE_REL_IA64_SECREL 0x000E
3484 #define IMAGE_REL_IA64_LTOFF64 0x000F
3485 #define IMAGE_REL_IA64_DIR32NB 0x0010
3486 #define IMAGE_REL_IA64_SREL14 0x0011
3487 #define IMAGE_REL_IA64_SREL22 0x0012
3488 #define IMAGE_REL_IA64_SREL32 0x0013
3489 #define IMAGE_REL_IA64_UREL32 0x0014
3490 #define IMAGE_REL_IA64_PCREL60X 0x0015
3491 #define IMAGE_REL_IA64_PCREL60B 0x0016
3492 #define IMAGE_REL_IA64_PCREL60F 0x0017
3493 #define IMAGE_REL_IA64_PCREL60I 0x0018
3494 #define IMAGE_REL_IA64_PCREL60M 0x0019
3495 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3496 #define IMAGE_REL_IA64_TOKEN 0x001B
3497 #define IMAGE_REL_IA64_GPREL32 0x001C
3498 #define IMAGE_REL_IA64_ADDEND 0x001F
3500 /* AMD64 relocation types */
3501 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3502 #define IMAGE_REL_AMD64_ADDR64 0x0001
3503 #define IMAGE_REL_AMD64_ADDR32 0x0002
3504 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3505 #define IMAGE_REL_AMD64_REL32 0x0004
3506 #define IMAGE_REL_AMD64_REL32_1 0x0005
3507 #define IMAGE_REL_AMD64_REL32_2 0x0006
3508 #define IMAGE_REL_AMD64_REL32_3 0x0007
3509 #define IMAGE_REL_AMD64_REL32_4 0x0008
3510 #define IMAGE_REL_AMD64_REL32_5 0x0009
3511 #define IMAGE_REL_AMD64_SECTION 0x000A
3512 #define IMAGE_REL_AMD64_SECREL 0x000B
3513 #define IMAGE_REL_AMD64_SECREL7 0x000C
3514 #define IMAGE_REL_AMD64_TOKEN 0x000D
3515 #define IMAGE_REL_AMD64_SREL32 0x000E
3516 #define IMAGE_REL_AMD64_PAIR 0x000F
3517 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3519 /* archive format */
3521 #define IMAGE_ARCHIVE_START_SIZE 8
3522 #define IMAGE_ARCHIVE_START "!<arch>\n"
3523 #define IMAGE_ARCHIVE_END "`\n"
3524 #define IMAGE_ARCHIVE_PAD "\n"
3525 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3526 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3528 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3530 BYTE Name[16];
3531 BYTE Date[12];
3532 BYTE UserID[6];
3533 BYTE GroupID[6];
3534 BYTE Mode[8];
3535 BYTE Size[10];
3536 BYTE EndHeader[2];
3537 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3539 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3541 typedef struct _IMPORT_OBJECT_HEADER
3543 WORD Sig1;
3544 WORD Sig2;
3545 WORD Version;
3546 WORD Machine;
3547 DWORD TimeDateStamp;
3548 DWORD SizeOfData;
3549 union
3551 WORD Ordinal;
3552 WORD Hint;
3553 } DUMMYUNIONNAME;
3554 WORD Type : 2;
3555 WORD NameType : 3;
3556 WORD Reserved : 11;
3557 } IMPORT_OBJECT_HEADER;
3559 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3561 typedef enum IMPORT_OBJECT_TYPE
3563 IMPORT_OBJECT_CODE = 0,
3564 IMPORT_OBJECT_DATA = 1,
3565 IMPORT_OBJECT_CONST = 2
3566 } IMPORT_OBJECT_TYPE;
3568 typedef enum IMPORT_OBJECT_NAME_TYPE
3570 IMPORT_OBJECT_ORDINAL = 0,
3571 IMPORT_OBJECT_NAME = 1,
3572 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3573 IMPORT_OBJECT_NAME_UNDECORATE = 3,
3574 IMPORT_OBJECT_NAME_EXPORTAS = 4
3575 } IMPORT_OBJECT_NAME_TYPE;
3577 typedef struct _ANON_OBJECT_HEADER
3579 WORD Sig1;
3580 WORD Sig2;
3581 WORD Version;
3582 WORD Machine;
3583 DWORD TimeDateStamp;
3584 CLSID ClassID;
3585 DWORD SizeOfData;
3586 } ANON_OBJECT_HEADER;
3589 * Resource directory stuff
3591 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3592 DWORD Characteristics;
3593 DWORD TimeDateStamp;
3594 WORD MajorVersion;
3595 WORD MinorVersion;
3596 WORD NumberOfNamedEntries;
3597 WORD NumberOfIdEntries;
3598 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3599 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3601 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3602 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3604 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3605 union {
3606 struct {
3607 unsigned NameOffset:31;
3608 unsigned NameIsString:1;
3609 } DUMMYSTRUCTNAME;
3610 DWORD Name;
3611 WORD Id;
3612 } DUMMYUNIONNAME;
3613 union {
3614 DWORD OffsetToData;
3615 struct {
3616 unsigned OffsetToDirectory:31;
3617 unsigned DataIsDirectory:1;
3618 } DUMMYSTRUCTNAME2;
3619 } DUMMYUNIONNAME2;
3620 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3623 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3624 WORD Length;
3625 CHAR NameString[ 1 ];
3626 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3628 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3629 WORD Length;
3630 WCHAR NameString[ 1 ];
3631 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3633 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3634 DWORD OffsetToData;
3635 DWORD Size;
3636 DWORD CodePage;
3637 DWORD Reserved;
3638 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3641 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3642 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3645 typedef struct _IMAGE_TLS_DIRECTORY64 {
3646 ULONGLONG StartAddressOfRawData;
3647 ULONGLONG EndAddressOfRawData;
3648 ULONGLONG AddressOfIndex;
3649 ULONGLONG AddressOfCallBacks;
3650 DWORD SizeOfZeroFill;
3651 DWORD Characteristics;
3652 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3654 typedef struct _IMAGE_TLS_DIRECTORY32 {
3655 DWORD StartAddressOfRawData;
3656 DWORD EndAddressOfRawData;
3657 DWORD AddressOfIndex;
3658 DWORD AddressOfCallBacks;
3659 DWORD SizeOfZeroFill;
3660 DWORD Characteristics;
3661 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3663 #ifdef _WIN64
3664 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3665 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3666 #else
3667 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3668 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3669 #endif
3671 typedef struct _IMAGE_DEBUG_DIRECTORY {
3672 DWORD Characteristics;
3673 DWORD TimeDateStamp;
3674 WORD MajorVersion;
3675 WORD MinorVersion;
3676 DWORD Type;
3677 DWORD SizeOfData;
3678 DWORD AddressOfRawData;
3679 DWORD PointerToRawData;
3680 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3682 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3683 #define IMAGE_DEBUG_TYPE_COFF 1
3684 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3685 #define IMAGE_DEBUG_TYPE_FPO 3
3686 #define IMAGE_DEBUG_TYPE_MISC 4
3687 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3688 #define IMAGE_DEBUG_TYPE_FIXUP 6
3689 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3690 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3691 #define IMAGE_DEBUG_TYPE_BORLAND 9
3692 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3693 #define IMAGE_DEBUG_TYPE_CLSID 11
3694 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3695 #define IMAGE_DEBUG_TYPE_POGO 13
3696 #define IMAGE_DEBUG_TYPE_ILTCG 14
3697 #define IMAGE_DEBUG_TYPE_MPX 15
3698 #define IMAGE_DEBUG_TYPE_REPRO 16
3700 typedef enum ReplacesCorHdrNumericDefines
3702 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3703 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3704 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3705 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3706 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
3707 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3708 COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000,
3710 COR_VERSION_MAJOR_V2 = 2,
3711 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3712 COR_VERSION_MINOR = 5,
3713 COR_DELETED_NAME_LENGTH = 8,
3714 COR_VTABLEGAP_NAME_LENGTH = 8,
3716 NATIVE_TYPE_MAX_CB = 1,
3717 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3719 IMAGE_COR_MIH_METHODRVA = 0x01,
3720 IMAGE_COR_MIH_EHRVA = 0x02,
3721 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3723 COR_VTABLE_32BIT = 0x01,
3724 COR_VTABLE_64BIT = 0x02,
3725 COR_VTABLE_FROM_UNMANAGED = 0x04,
3726 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3728 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3730 MAX_CLASS_NAME = 1024,
3731 MAX_PACKAGE_NAME = 1024,
3732 } ReplacesCorHdrNumericDefines;
3734 typedef struct IMAGE_COR20_HEADER
3736 DWORD cb;
3737 WORD MajorRuntimeVersion;
3738 WORD MinorRuntimeVersion;
3740 IMAGE_DATA_DIRECTORY MetaData;
3741 DWORD Flags;
3742 union {
3743 DWORD EntryPointToken;
3744 DWORD EntryPointRVA;
3745 } DUMMYUNIONNAME;
3747 IMAGE_DATA_DIRECTORY Resources;
3748 IMAGE_DATA_DIRECTORY StrongNameSignature;
3749 IMAGE_DATA_DIRECTORY CodeManagerTable;
3750 IMAGE_DATA_DIRECTORY VTableFixups;
3751 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3752 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3754 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3756 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3757 DWORD NumberOfSymbols;
3758 DWORD LvaToFirstSymbol;
3759 DWORD NumberOfLinenumbers;
3760 DWORD LvaToFirstLinenumber;
3761 DWORD RvaToFirstByteOfCode;
3762 DWORD RvaToLastByteOfCode;
3763 DWORD RvaToFirstByteOfData;
3764 DWORD RvaToLastByteOfData;
3765 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3767 #define FRAME_FPO 0
3768 #define FRAME_TRAP 1
3769 #define FRAME_TSS 2
3770 #define FRAME_NONFPO 3
3772 typedef struct _FPO_DATA {
3773 DWORD ulOffStart;
3774 DWORD cbProcSize;
3775 DWORD cdwLocals;
3776 WORD cdwParams;
3777 WORD cbProlog : 8;
3778 WORD cbRegs : 3;
3779 WORD fHasSEH : 1;
3780 WORD fUseBP : 1;
3781 WORD reserved : 1;
3782 WORD cbFrame : 2;
3783 } FPO_DATA, *PFPO_DATA;
3785 typedef struct _IMAGE_LOAD_CONFIG_CODE_INTEGRITY
3787 WORD Flags;
3788 WORD Catalog;
3789 DWORD CatalogOffset;
3790 DWORD Reserved;
3791 } IMAGE_LOAD_CONFIG_CODE_INTEGRITY, *PIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
3793 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
3794 DWORD Size; /* 000 */
3795 DWORD TimeDateStamp;
3796 WORD MajorVersion;
3797 WORD MinorVersion;
3798 DWORD GlobalFlagsClear;
3799 DWORD GlobalFlagsSet; /* 010 */
3800 DWORD CriticalSectionDefaultTimeout;
3801 ULONGLONG DeCommitFreeBlockThreshold;
3802 ULONGLONG DeCommitTotalFreeThreshold; /* 020 */
3803 ULONGLONG LockPrefixTable;
3804 ULONGLONG MaximumAllocationSize; /* 030 */
3805 ULONGLONG VirtualMemoryThreshold;
3806 ULONGLONG ProcessAffinityMask; /* 040 */
3807 DWORD ProcessHeapFlags;
3808 WORD CSDVersion;
3809 WORD DependentLoadFlags;
3810 ULONGLONG EditList; /* 050 */
3811 ULONGLONG SecurityCookie;
3812 ULONGLONG SEHandlerTable; /* 060 */
3813 ULONGLONG SEHandlerCount;
3814 ULONGLONG GuardCFCheckFunctionPointer; /* 070 */
3815 ULONGLONG GuardCFDispatchFunctionPointer;
3816 ULONGLONG GuardCFFunctionTable; /* 080 */
3817 ULONGLONG GuardCFFunctionCount;
3818 DWORD GuardFlags; /* 090 */
3819 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
3820 ULONGLONG GuardAddressTakenIatEntryTable; /* 0a0 */
3821 ULONGLONG GuardAddressTakenIatEntryCount;
3822 ULONGLONG GuardLongJumpTargetTable; /* 0b0 */
3823 ULONGLONG GuardLongJumpTargetCount;
3824 ULONGLONG DynamicValueRelocTable; /* 0c0 */
3825 ULONGLONG CHPEMetadataPointer;
3826 ULONGLONG GuardRFFailureRoutine; /* 0d0 */
3827 ULONGLONG GuardRFFailureRoutineFunctionPointer;
3828 DWORD DynamicValueRelocTableOffset; /* 0e0 */
3829 WORD DynamicValueRelocTableSection;
3830 WORD Reserved2;
3831 ULONGLONG GuardRFVerifyStackPointerFunctionPointer;
3832 DWORD HotPatchTableOffset; /* 0f0 */
3833 DWORD Reserved3;
3834 ULONGLONG EnclaveConfigurationPointer;
3835 ULONGLONG VolatileMetadataPointer; /* 100 */
3836 ULONGLONG GuardEHContinuationTable;
3837 ULONGLONG GuardEHContinuationCount; /* 110 */
3838 ULONGLONG GuardXFGCheckFunctionPointer;
3839 ULONGLONG GuardXFGDispatchFunctionPointer; /* 120 */
3840 ULONGLONG GuardXFGTableDispatchFunctionPointer;
3841 ULONGLONG CastGuardOsDeterminedFailureMode; /* 130 */
3842 ULONGLONG GuardMemcpyFunctionPointer;
3843 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
3845 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
3846 DWORD Size; /* 000 */
3847 DWORD TimeDateStamp;
3848 WORD MajorVersion;
3849 WORD MinorVersion;
3850 DWORD GlobalFlagsClear;
3851 DWORD GlobalFlagsSet; /* 010 */
3852 DWORD CriticalSectionDefaultTimeout;
3853 DWORD DeCommitFreeBlockThreshold;
3854 DWORD DeCommitTotalFreeThreshold;
3855 DWORD LockPrefixTable; /* 020 */
3856 DWORD MaximumAllocationSize;
3857 DWORD VirtualMemoryThreshold;
3858 DWORD ProcessHeapFlags;
3859 DWORD ProcessAffinityMask; /* 030 */
3860 WORD CSDVersion;
3861 WORD DependentLoadFlags;
3862 DWORD EditList;
3863 DWORD SecurityCookie;
3864 DWORD SEHandlerTable; /* 040 */
3865 DWORD SEHandlerCount;
3866 DWORD GuardCFCheckFunctionPointer;
3867 DWORD GuardCFDispatchFunctionPointer;
3868 DWORD GuardCFFunctionTable; /* 050 */
3869 DWORD GuardCFFunctionCount;
3870 DWORD GuardFlags;
3871 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
3872 DWORD GuardAddressTakenIatEntryTable;
3873 DWORD GuardAddressTakenIatEntryCount;
3874 DWORD GuardLongJumpTargetTable; /* 070 */
3875 DWORD GuardLongJumpTargetCount;
3876 DWORD DynamicValueRelocTable;
3877 DWORD CHPEMetadataPointer;
3878 DWORD GuardRFFailureRoutine; /* 080 */
3879 DWORD GuardRFFailureRoutineFunctionPointer;
3880 DWORD DynamicValueRelocTableOffset;
3881 WORD DynamicValueRelocTableSection;
3882 WORD Reserved2;
3883 DWORD GuardRFVerifyStackPointerFunctionPointer; /* 090 */
3884 DWORD HotPatchTableOffset;
3885 DWORD Reserved3;
3886 DWORD EnclaveConfigurationPointer;
3887 DWORD VolatileMetadataPointer; /* 0a0 */
3888 DWORD GuardEHContinuationTable;
3889 DWORD GuardEHContinuationCount;
3890 DWORD GuardXFGCheckFunctionPointer;
3891 DWORD GuardXFGDispatchFunctionPointer; /* 0b0 */
3892 DWORD GuardXFGTableDispatchFunctionPointer;
3893 DWORD CastGuardOsDeterminedFailureMode;
3894 DWORD GuardMemcpyFunctionPointer;
3895 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
3897 #ifdef _WIN64
3898 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
3899 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
3900 #else
3901 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
3902 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
3903 #endif
3905 typedef struct _IMAGE_DYNAMIC_RELOCATION_TABLE
3907 DWORD Version;
3908 DWORD Size;
3909 } IMAGE_DYNAMIC_RELOCATION_TABLE, *PIMAGE_DYNAMIC_RELOCATION_TABLE;
3911 #include <pshpack1.h>
3913 typedef struct _IMAGE_DYNAMIC_RELOCATION32
3915 DWORD Symbol;
3916 DWORD BaseRelocSize;
3917 } IMAGE_DYNAMIC_RELOCATION32, *PIMAGE_DYNAMIC_RELOCATION32;
3919 typedef struct _IMAGE_DYNAMIC_RELOCATION64
3921 ULONGLONG Symbol;
3922 DWORD BaseRelocSize;
3923 } IMAGE_DYNAMIC_RELOCATION64, *PIMAGE_DYNAMIC_RELOCATION64;
3925 typedef struct _IMAGE_DYNAMIC_RELOCATION32_V2
3927 DWORD HeaderSize;
3928 DWORD FixupInfoSize;
3929 DWORD Symbol;
3930 DWORD SymbolGroup;
3931 DWORD Flags;
3932 } IMAGE_DYNAMIC_RELOCATION32_V2, *PIMAGE_DYNAMIC_RELOCATION32_V2;
3934 typedef struct _IMAGE_DYNAMIC_RELOCATION64_V2
3936 DWORD HeaderSize;
3937 DWORD FixupInfoSize;
3938 ULONGLONG Symbol;
3939 DWORD SymbolGroup;
3940 DWORD Flags;
3941 } IMAGE_DYNAMIC_RELOCATION64_V2, *PIMAGE_DYNAMIC_RELOCATION64_V2;
3943 #include <poppack.h>
3945 #ifdef _WIN64
3946 typedef IMAGE_DYNAMIC_RELOCATION64 IMAGE_DYNAMIC_RELOCATION;
3947 typedef PIMAGE_DYNAMIC_RELOCATION64 PIMAGE_DYNAMIC_RELOCATION;
3948 typedef IMAGE_DYNAMIC_RELOCATION64_V2 IMAGE_DYNAMIC_RELOCATION_V2;
3949 typedef PIMAGE_DYNAMIC_RELOCATION64_V2 PIMAGE_DYNAMIC_RELOCATION_V2;
3950 #else
3951 typedef IMAGE_DYNAMIC_RELOCATION32 IMAGE_DYNAMIC_RELOCATION;
3952 typedef PIMAGE_DYNAMIC_RELOCATION32 PIMAGE_DYNAMIC_RELOCATION;
3953 typedef IMAGE_DYNAMIC_RELOCATION32_V2 IMAGE_DYNAMIC_RELOCATION_V2;
3954 typedef PIMAGE_DYNAMIC_RELOCATION32_V2 PIMAGE_DYNAMIC_RELOCATION_V2;
3955 #endif
3957 #define IMAGE_DYNAMIC_RELOCATION_GUARD_RF_PROLOGUE 1
3958 #define IMAGE_DYNAMIC_RELOCATION_GUARD_RF_EPILOGUE 2
3959 #define IMAGE_DYNAMIC_RELOCATION_GUARD_IMPORT_CONTROL_TRANSFER 3
3960 #define IMAGE_DYNAMIC_RELOCATION_GUARD_INDIR_CONTROL_TRANSFER 4
3961 #define IMAGE_DYNAMIC_RELOCATION_GUARD_SWITCHTABLE_BRANCH 5
3962 #define IMAGE_DYNAMIC_RELOCATION_ARM64X 6
3964 typedef struct _IMAGE_CHPE_METADATA_X86
3966 ULONG Version;
3967 ULONG CHPECodeAddressRangeOffset;
3968 ULONG CHPECodeAddressRangeCount;
3969 ULONG WowA64ExceptionHandlerFunctionPointer;
3970 ULONG WowA64DispatchCallFunctionPointer;
3971 ULONG WowA64DispatchIndirectCallFunctionPointer;
3972 ULONG WowA64DispatchIndirectCallCfgFunctionPointer;
3973 ULONG WowA64DispatchRetFunctionPointer;
3974 ULONG WowA64DispatchRetLeafFunctionPointer;
3975 ULONG WowA64DispatchJumpFunctionPointer;
3976 ULONG CompilerIATPointer;
3977 ULONG WowA64RdtscFunctionPointer;
3978 ULONG unknown[4];
3979 } IMAGE_CHPE_METADATA_X86, *PIMAGE_CHPE_METADATA_X86;
3981 typedef struct _IMAGE_CHPE_RANGE_ENTRY
3983 union
3985 ULONG StartOffset;
3986 struct
3988 ULONG NativeCode : 1;
3989 ULONG AddressBits : 31;
3990 } DUMMYSTRUCTNAME;
3991 } DUMMYUNIONNAME;
3992 ULONG Length;
3993 } IMAGE_CHPE_RANGE_ENTRY, *PIMAGE_CHPE_RANGE_ENTRY;
3995 typedef struct _IMAGE_ARM64EC_METADATA
3997 ULONG Version;
3998 ULONG CodeMap;
3999 ULONG CodeMapCount;
4000 ULONG CodeRangesToEntryPoints;
4001 ULONG RedirectionMetadata;
4002 ULONG __os_arm64x_dispatch_call_no_redirect;
4003 ULONG __os_arm64x_dispatch_ret;
4004 ULONG __os_arm64x_dispatch_call;
4005 ULONG __os_arm64x_dispatch_icall;
4006 ULONG __os_arm64x_dispatch_icall_cfg;
4007 ULONG AlternateEntryPoint;
4008 ULONG AuxiliaryIAT;
4009 ULONG CodeRangesToEntryPointsCount;
4010 ULONG RedirectionMetadataCount;
4011 ULONG GetX64InformationFunctionPointer;
4012 ULONG SetX64InformationFunctionPointer;
4013 ULONG ExtraRFETable;
4014 ULONG ExtraRFETableSize;
4015 ULONG __os_arm64x_dispatch_fptr;
4016 ULONG AuxiliaryIATCopy;
4017 } IMAGE_ARM64EC_METADATA;
4019 typedef struct _IMAGE_ARM64EC_REDIRECTION_ENTRY
4021 ULONG Source;
4022 ULONG Destination;
4023 } IMAGE_ARM64EC_REDIRECTION_ENTRY;
4025 typedef struct _IMAGE_ARM64EC_CODE_RANGE_ENTRY_POINT
4027 ULONG StartRva;
4028 ULONG EndRva;
4029 ULONG EntryPoint;
4030 } IMAGE_ARM64EC_CODE_RANGE_ENTRY_POINT;
4032 #define IMAGE_DVRT_ARM64X_FIXUP_TYPE_ZEROFILL 0
4033 #define IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE 1
4034 #define IMAGE_DVRT_ARM64X_FIXUP_TYPE_DELTA 2
4036 #define IMAGE_DVRT_ARM64X_FIXUP_SIZE_2BYTES 1
4037 #define IMAGE_DVRT_ARM64X_FIXUP_SIZE_4BYTES 2
4038 #define IMAGE_DVRT_ARM64X_FIXUP_SIZE_8BYTES 3
4040 typedef struct _IMAGE_DVRT_ARM64X_FIXUP_RECORD
4042 USHORT Offset : 12;
4043 USHORT Type : 2;
4044 USHORT Size : 2;
4045 } IMAGE_DVRT_ARM64X_FIXUP_RECORD, *PIMAGE_DVRT_ARM64X_FIXUP_RECORD;
4047 typedef struct _IMAGE_DVRT_ARM64X_DELTA_FIXUP_RECORD
4049 USHORT Offset : 12;
4050 USHORT Type : 2;
4051 USHORT Sign : 1;
4052 USHORT Scale : 1;
4053 } IMAGE_DVRT_ARM64X_DELTA_FIXUP_RECORD, *PIMAGE_DVRT_ARM64X_DELTA_FIXUP_RECORD;
4055 typedef struct _IMAGE_FUNCTION_ENTRY {
4056 DWORD StartingAddress;
4057 DWORD EndingAddress;
4058 DWORD EndOfPrologue;
4059 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
4061 #define IMAGE_DEBUG_MISC_EXENAME 1
4063 typedef struct _IMAGE_DEBUG_MISC {
4064 DWORD DataType;
4065 DWORD Length;
4066 BYTE Unicode;
4067 BYTE Reserved[ 3 ];
4068 BYTE Data[ 1 ];
4069 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
4071 /* This is the structure that appears at the very start of a .DBG file. */
4073 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
4074 WORD Signature;
4075 WORD Flags;
4076 WORD Machine;
4077 WORD Characteristics;
4078 DWORD TimeDateStamp;
4079 DWORD CheckSum;
4080 DWORD ImageBase;
4081 DWORD SizeOfImage;
4082 DWORD NumberOfSections;
4083 DWORD ExportedNamesSize;
4084 DWORD DebugDirectorySize;
4085 DWORD SectionAlignment;
4086 DWORD Reserved[ 2 ];
4087 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
4089 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
4092 typedef struct tagMESSAGE_RESOURCE_ENTRY {
4093 WORD Length;
4094 WORD Flags;
4095 BYTE Text[1];
4096 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
4097 #define MESSAGE_RESOURCE_UNICODE 0x0001
4099 typedef struct tagMESSAGE_RESOURCE_BLOCK {
4100 DWORD LowId;
4101 DWORD HighId;
4102 DWORD OffsetToEntries;
4103 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
4105 typedef struct tagMESSAGE_RESOURCE_DATA {
4106 DWORD NumberOfBlocks;
4107 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
4108 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
4111 * Here follows typedefs for security and tokens.
4115 * First a constant for the following typedefs.
4118 #define ANYSIZE_ARRAY 1
4120 /* FIXME: Orphan. What does it point to? */
4121 typedef PVOID PACCESS_TOKEN;
4122 typedef PVOID PSECURITY_DESCRIPTOR;
4123 typedef PVOID PSID;
4125 typedef enum _TOKEN_ELEVATION_TYPE {
4126 TokenElevationTypeDefault = 1,
4127 TokenElevationTypeFull,
4128 TokenElevationTypeLimited
4129 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
4132 * TOKEN_INFORMATION_CLASS
4135 typedef enum _TOKEN_INFORMATION_CLASS {
4136 TokenUser = 1,
4137 TokenGroups,
4138 TokenPrivileges,
4139 TokenOwner,
4140 TokenPrimaryGroup,
4141 TokenDefaultDacl,
4142 TokenSource,
4143 TokenType,
4144 TokenImpersonationLevel,
4145 TokenStatistics,
4146 TokenRestrictedSids,
4147 TokenSessionId,
4148 TokenGroupsAndPrivileges,
4149 TokenSessionReference,
4150 TokenSandBoxInert,
4151 TokenAuditPolicy,
4152 TokenOrigin,
4153 TokenElevationType,
4154 TokenLinkedToken,
4155 TokenElevation,
4156 TokenHasRestrictions,
4157 TokenAccessInformation,
4158 TokenVirtualizationAllowed,
4159 TokenVirtualizationEnabled,
4160 TokenIntegrityLevel,
4161 TokenUIAccess,
4162 TokenMandatoryPolicy,
4163 TokenLogonSid,
4164 TokenIsAppContainer,
4165 TokenCapabilities,
4166 TokenAppContainerSid,
4167 TokenAppContainerNumber,
4168 TokenUserClaimAttributes,
4169 TokenDeviceClaimAttributes,
4170 TokenRestrictedUserClaimAttributes,
4171 TokenRestrictedDeviceClaimAttributes,
4172 TokenDeviceGroups,
4173 TokenRestrictedDeviceGroups,
4174 TokenSecurityAttributes,
4175 TokenIsRestricted,
4176 TokenProcessTrustLevel,
4177 MaxTokenInfoClass
4178 } TOKEN_INFORMATION_CLASS;
4180 #define DISABLE_MAX_PRIVILEGE 0x1
4181 #define SANDBOX_INERT 0x2
4182 #define LUA_TOKEN 0x4
4183 #define WRITE_RESTRICTED 0x8
4185 #define TOKEN_ASSIGN_PRIMARY 0x0001
4186 #define TOKEN_DUPLICATE 0x0002
4187 #define TOKEN_IMPERSONATE 0x0004
4188 #define TOKEN_QUERY 0x0008
4189 #define TOKEN_QUERY_SOURCE 0x0010
4190 #define TOKEN_ADJUST_PRIVILEGES 0x0020
4191 #define TOKEN_ADJUST_GROUPS 0x0040
4192 #define TOKEN_ADJUST_DEFAULT 0x0080
4193 #define TOKEN_ADJUST_SESSIONID 0x0100
4194 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
4195 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
4196 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
4197 TOKEN_ADJUST_PRIVILEGES | \
4198 TOKEN_ADJUST_GROUPS | \
4199 TOKEN_ADJUST_DEFAULT )
4200 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
4201 TOKEN_ASSIGN_PRIMARY | \
4202 TOKEN_DUPLICATE | \
4203 TOKEN_IMPERSONATE | \
4204 TOKEN_QUERY | \
4205 TOKEN_QUERY_SOURCE | \
4206 TOKEN_ADJUST_PRIVILEGES | \
4207 TOKEN_ADJUST_GROUPS | \
4208 TOKEN_ADJUST_SESSIONID | \
4209 TOKEN_ADJUST_DEFAULT )
4211 #ifndef _SECURITY_DEFINED
4212 #define _SECURITY_DEFINED
4214 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
4216 typedef struct _GENERIC_MAPPING {
4217 ACCESS_MASK GenericRead;
4218 ACCESS_MASK GenericWrite;
4219 ACCESS_MASK GenericExecute;
4220 ACCESS_MASK GenericAll;
4221 } GENERIC_MAPPING, *PGENERIC_MAPPING;
4223 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
4224 #define SID_IDENTIFIER_AUTHORITY_DEFINED
4225 typedef struct {
4226 BYTE Value[6];
4227 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
4228 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
4230 #ifndef SID_DEFINED
4231 #define SID_DEFINED
4232 typedef struct _SID {
4233 BYTE Revision;
4234 BYTE SubAuthorityCount;
4235 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
4236 DWORD SubAuthority[1];
4237 } SID,*PISID;
4238 #endif /* !defined(SID_DEFINED) */
4240 #define CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID 0x01
4242 #define SID_REVISION (1) /* Current revision */
4243 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
4244 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
4246 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
4249 * ACL
4252 #define ACL_REVISION1 1
4253 #define ACL_REVISION2 2
4254 #define ACL_REVISION3 3
4255 #define ACL_REVISION4 4
4257 #define MIN_ACL_REVISION ACL_REVISION2
4258 #define MAX_ACL_REVISION ACL_REVISION4
4260 #define ACL_REVISION 2
4262 typedef struct _ACL {
4263 BYTE AclRevision;
4264 BYTE Sbz1;
4265 WORD AclSize;
4266 WORD AceCount;
4267 WORD Sbz2;
4268 } ACL, *PACL;
4270 typedef enum _ACL_INFORMATION_CLASS
4272 AclRevisionInformation = 1,
4273 AclSizeInformation
4274 } ACL_INFORMATION_CLASS;
4276 typedef struct _ACL_REVISION_INFORMATION
4278 DWORD AclRevision;
4279 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
4281 typedef struct _ACL_SIZE_INFORMATION
4283 DWORD AceCount;
4284 DWORD AclBytesInUse;
4285 DWORD AclBytesFree;
4286 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
4288 /* SECURITY_DESCRIPTOR */
4289 #define SECURITY_DESCRIPTOR_REVISION 1
4290 #define SECURITY_DESCRIPTOR_REVISION1 1
4294 * Privilege Names
4296 #ifdef UNICODE
4297 #if defined(_MSC_VER) || defined(__MINGW32__)
4298 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4299 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4300 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4301 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4302 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4303 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4304 #define SE_TCB_NAME L"SeTcbPrivilege"
4305 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4306 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4307 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4308 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4309 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4310 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4311 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4312 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4313 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4314 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4315 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4316 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4317 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4318 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4319 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4320 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4321 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4322 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4323 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4324 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4325 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4326 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4327 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4328 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4329 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4330 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4331 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4332 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4333 #else /* _MSC_VER/__MINGW32__ */
4334 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 };
4335 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 };
4336 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 };
4337 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 };
4338 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 };
4339 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 };
4340 static const WCHAR SE_TCB_NAME[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4341 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 };
4342 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 };
4343 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 };
4344 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 };
4345 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 };
4346 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 };
4347 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 };
4348 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 };
4349 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 };
4350 static const WCHAR SE_BACKUP_NAME[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4351 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 };
4352 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 };
4353 static const WCHAR SE_DEBUG_NAME[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4354 static const WCHAR SE_AUDIT_NAME[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4355 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 };
4356 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 };
4357 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 };
4358 static const WCHAR SE_UNDOCK_NAME[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4359 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 };
4360 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 };
4361 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 };
4362 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 };
4363 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 };
4364 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 };
4365 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 };
4366 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 };
4367 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 };
4368 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 };
4369 #endif
4370 #else /* UNICODE */
4371 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4372 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4373 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4374 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4375 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4376 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4377 #define SE_TCB_NAME "SeTcbPrivilege"
4378 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4379 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4380 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4381 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4382 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4383 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4384 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4385 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4386 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4387 #define SE_BACKUP_NAME "SeBackupPrivilege"
4388 #define SE_RESTORE_NAME "SeRestorePrivilege"
4389 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4390 #define SE_DEBUG_NAME "SeDebugPrivilege"
4391 #define SE_AUDIT_NAME "SeAuditPrivilege"
4392 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4393 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4394 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4395 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4396 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4397 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4398 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4399 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4400 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4401 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4402 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4403 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4404 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4405 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4406 #endif
4408 #define SE_GROUP_MANDATORY 0x00000001
4409 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4410 #define SE_GROUP_ENABLED 0x00000004
4411 #define SE_GROUP_OWNER 0x00000008
4412 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4413 #define SE_GROUP_INTEGRITY 0x00000020
4414 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4415 #define SE_GROUP_LOGON_ID 0xC0000000
4416 #define SE_GROUP_RESOURCE 0x20000000
4417 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4419 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4420 #define SE_PRIVILEGE_ENABLED 0x00000002
4421 #define SE_PRIVILEGE_REMOVED 0x00000004
4422 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4423 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4425 #define PRIVILEGE_SET_ALL_NECESSARY 1
4427 #define SE_OWNER_DEFAULTED 0x00000001
4428 #define SE_GROUP_DEFAULTED 0x00000002
4429 #define SE_DACL_PRESENT 0x00000004
4430 #define SE_DACL_DEFAULTED 0x00000008
4431 #define SE_SACL_PRESENT 0x00000010
4432 #define SE_SACL_DEFAULTED 0x00000020
4433 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4434 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4435 #define SE_DACL_AUTO_INHERITED 0x00000400
4436 #define SE_SACL_AUTO_INHERITED 0x00000800
4437 #define SE_DACL_PROTECTED 0x00001000
4438 #define SE_SACL_PROTECTED 0x00002000
4439 #define SE_RM_CONTROL_VALID 0x00004000
4440 #define SE_SELF_RELATIVE 0x00008000
4442 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4443 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4445 /* The security descriptor structure */
4446 typedef struct {
4447 BYTE Revision;
4448 BYTE Sbz1;
4449 SECURITY_DESCRIPTOR_CONTROL Control;
4450 DWORD Owner;
4451 DWORD Group;
4452 DWORD Sacl;
4453 DWORD Dacl;
4454 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4456 typedef struct {
4457 BYTE Revision;
4458 BYTE Sbz1;
4459 SECURITY_DESCRIPTOR_CONTROL Control;
4460 PSID Owner;
4461 PSID Group;
4462 PACL Sacl;
4463 PACL Dacl;
4464 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4466 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4468 #endif /* _SECURITY_DEFINED */
4471 * SID_AND_ATTRIBUTES
4474 typedef struct _SID_AND_ATTRIBUTES {
4475 PSID Sid;
4476 DWORD Attributes;
4477 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4479 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
4480 typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
4482 #define SID_HASH_SIZE 32
4484 typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
4486 typedef struct _SID_AND_ATTRIBUTES_HASH {
4487 DWORD SidCount;
4488 PSID_AND_ATTRIBUTES SidAttr;
4489 SID_HASH_ENTRY Hash[SID_HASH_SIZE];
4490 } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
4492 /* security entities */
4493 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4494 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4495 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4497 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4499 /* S-1-1 */
4500 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4502 /* S-1-2 */
4503 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4504 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4506 /* S-1-3 */
4507 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4508 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4509 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4510 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4511 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4512 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4514 /* S-1-4 */
4515 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4517 /* S-1-5 */
4518 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4519 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4520 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4521 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4522 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4523 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4524 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4525 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4526 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4527 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4528 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4529 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4530 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4531 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4532 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4533 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4534 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4535 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4536 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4537 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4538 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4539 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4540 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4541 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4543 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4544 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4545 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4546 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4547 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4548 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4549 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4550 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4551 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4552 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4553 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4554 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4555 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4556 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4557 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4558 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4559 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4560 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4561 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4562 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4563 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4564 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4566 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4568 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4569 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4570 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4571 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4572 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4574 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4575 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4576 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4577 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4578 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4579 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4580 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4581 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4582 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4583 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4585 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4587 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4588 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4589 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4590 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4591 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4592 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4593 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4594 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4595 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4596 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4597 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4599 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4600 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4601 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4602 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4603 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4604 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4605 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4606 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4607 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4609 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4611 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4612 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4613 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4614 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4616 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4617 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4618 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4619 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4621 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4622 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4623 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4624 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4625 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4626 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4628 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4629 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4630 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4631 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4632 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4633 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4634 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4635 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4636 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4637 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4638 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4640 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4642 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4643 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4644 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4645 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4646 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4647 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4648 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4649 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4650 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4651 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4652 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4654 #define SYSTEM_LUID { 0x3e7, 0x0 }
4655 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4656 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4657 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4658 #define IUSER_LUID { 0x3e3, 0x0 }
4660 typedef enum {
4661 WinNullSid = 0,
4662 WinWorldSid = 1,
4663 WinLocalSid = 2,
4664 WinCreatorOwnerSid = 3,
4665 WinCreatorGroupSid = 4,
4666 WinCreatorOwnerServerSid = 5,
4667 WinCreatorGroupServerSid = 6,
4668 WinNtAuthoritySid = 7,
4669 WinDialupSid = 8,
4670 WinNetworkSid = 9,
4671 WinBatchSid = 10,
4672 WinInteractiveSid = 11,
4673 WinServiceSid = 12,
4674 WinAnonymousSid = 13,
4675 WinProxySid = 14,
4676 WinEnterpriseControllersSid = 15,
4677 WinSelfSid = 16,
4678 WinAuthenticatedUserSid = 17,
4679 WinRestrictedCodeSid = 18,
4680 WinTerminalServerSid = 19,
4681 WinRemoteLogonIdSid = 20,
4682 WinLogonIdsSid = 21,
4683 WinLocalSystemSid = 22,
4684 WinLocalServiceSid = 23,
4685 WinNetworkServiceSid = 24,
4686 WinBuiltinDomainSid = 25,
4687 WinBuiltinAdministratorsSid = 26,
4688 WinBuiltinUsersSid = 27,
4689 WinBuiltinGuestsSid = 28,
4690 WinBuiltinPowerUsersSid = 29,
4691 WinBuiltinAccountOperatorsSid = 30,
4692 WinBuiltinSystemOperatorsSid = 31,
4693 WinBuiltinPrintOperatorsSid = 32,
4694 WinBuiltinBackupOperatorsSid = 33,
4695 WinBuiltinReplicatorSid = 34,
4696 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4697 WinBuiltinRemoteDesktopUsersSid = 36,
4698 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4699 WinAccountAdministratorSid = 38,
4700 WinAccountGuestSid = 39,
4701 WinAccountKrbtgtSid = 40,
4702 WinAccountDomainAdminsSid = 41,
4703 WinAccountDomainUsersSid = 42,
4704 WinAccountDomainGuestsSid = 43,
4705 WinAccountComputersSid = 44,
4706 WinAccountControllersSid = 45,
4707 WinAccountCertAdminsSid = 46,
4708 WinAccountSchemaAdminsSid = 47,
4709 WinAccountEnterpriseAdminsSid = 48,
4710 WinAccountPolicyAdminsSid = 49,
4711 WinAccountRasAndIasServersSid = 50,
4712 WinNTLMAuthenticationSid = 51,
4713 WinDigestAuthenticationSid = 52,
4714 WinSChannelAuthenticationSid = 53,
4715 WinThisOrganizationSid = 54,
4716 WinOtherOrganizationSid = 55,
4717 WinBuiltinIncomingForestTrustBuildersSid = 56,
4718 WinBuiltinPerfMonitoringUsersSid = 57,
4719 WinBuiltinPerfLoggingUsersSid = 58,
4720 WinBuiltinAuthorizationAccessSid = 59,
4721 WinBuiltinTerminalServerLicenseServersSid = 60,
4722 WinBuiltinDCOMUsersSid = 61,
4723 WinBuiltinIUsersSid = 62,
4724 WinIUserSid = 63,
4725 WinBuiltinCryptoOperatorsSid = 64,
4726 WinUntrustedLabelSid = 65,
4727 WinLowLabelSid = 66,
4728 WinMediumLabelSid = 67,
4729 WinHighLabelSid = 68,
4730 WinSystemLabelSid = 69,
4731 WinWriteRestrictedCodeSid = 70,
4732 WinCreatorOwnerRightsSid = 71,
4733 WinCacheablePrincipalsGroupSid = 72,
4734 WinNonCacheablePrincipalsGroupSid = 73,
4735 WinEnterpriseReadonlyControllersSid = 74,
4736 WinAccountReadonlyControllersSid = 75,
4737 WinBuiltinEventLogReadersGroup = 76,
4738 WinNewEnterpriseReadonlyControllersSid = 77,
4739 WinBuiltinCertSvcDComAccessGroup = 78,
4740 WinMediumPlusLabelSid = 79,
4741 WinLocalLogonSid = 80,
4742 WinConsoleLogonSid = 81,
4743 WinThisOrganizationCertificateSid = 82,
4744 WinApplicationPackageAuthoritySid = 83,
4745 WinBuiltinAnyPackageSid = 84,
4746 WinCapabilityInternetClientSid = 85,
4747 WinCapabilityInternetClientServerSid = 86,
4748 WinCapabilityPrivateNetworkClientServerSid = 87,
4749 WinCapabilityPicturesLibrarySid = 88,
4750 WinCapabilityVideosLibrarySid = 89,
4751 WinCapabilityMusicLibrarySid = 90,
4752 WinCapabilityDocumentsLibrarySid = 91,
4753 WinCapabilitySharedUserCertificatesSid = 92,
4754 WinCapabilityEnterpriseAuthenticationSid = 93,
4755 WinCapabilityRemovableStorageSid = 94,
4756 WinBuiltinRDSRemoteAccessServersSid = 95,
4757 WinBuiltinRDSEndpointServersSid = 96,
4758 WinBuiltinRDSManagementServersSid = 97,
4759 WinUserModeDriversSid = 98,
4760 WinBuiltinHyperVAdminsSid = 99,
4761 WinAccountCloneableControllersSid = 100,
4762 WinBuiltinAccessControlAssistanceOperatorsSid = 101,
4763 WinBuiltinRemoteManagementUsersSid = 102,
4764 WinAuthenticationAuthorityAssertedSid = 103,
4765 WinAuthenticationServiceAssertedSid = 104,
4766 WinLocalAccountSid = 105,
4767 WinLocalAccountAndAdministratorSid = 106,
4768 WinAccountProtectedUsersSid = 107,
4769 } WELL_KNOWN_SID_TYPE;
4772 * TOKEN_USER
4775 typedef struct _TOKEN_USER {
4776 SID_AND_ATTRIBUTES User;
4777 } TOKEN_USER, *PTOKEN_USER;
4780 * TOKEN_GROUPS
4783 typedef struct _TOKEN_GROUPS {
4784 DWORD GroupCount;
4785 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4786 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4789 * LUID_AND_ATTRIBUTES
4792 typedef union _LARGE_INTEGER {
4793 struct {
4794 #ifdef WORDS_BIGENDIAN
4795 LONG HighPart;
4796 DWORD LowPart;
4797 #else
4798 DWORD LowPart;
4799 LONG HighPart;
4800 #endif
4801 } u;
4802 #ifndef NONAMELESSSTRUCT
4803 struct {
4804 #ifdef WORDS_BIGENDIAN
4805 LONG HighPart;
4806 DWORD LowPart;
4807 #else
4808 DWORD LowPart;
4809 LONG HighPart;
4810 #endif
4812 #endif
4813 LONGLONG QuadPart;
4814 } LARGE_INTEGER, *PLARGE_INTEGER;
4816 typedef union _ULARGE_INTEGER {
4817 struct {
4818 #ifdef WORDS_BIGENDIAN
4819 DWORD HighPart;
4820 DWORD LowPart;
4821 #else
4822 DWORD LowPart;
4823 DWORD HighPart;
4824 #endif
4825 } u;
4826 #ifndef NONAMELESSSTRUCT
4827 struct {
4828 #ifdef WORDS_BIGENDIAN
4829 DWORD HighPart;
4830 DWORD LowPart;
4831 #else
4832 DWORD LowPart;
4833 DWORD HighPart;
4834 #endif
4836 #endif
4837 ULONGLONG QuadPart;
4838 } ULARGE_INTEGER, *PULARGE_INTEGER;
4841 * Locally Unique Identifier
4844 typedef struct _LUID {
4845 DWORD LowPart;
4846 LONG HighPart;
4847 } LUID, *PLUID;
4849 #include <pshpack4.h>
4850 typedef struct _LUID_AND_ATTRIBUTES {
4851 LUID Luid;
4852 DWORD Attributes;
4853 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4854 #include <poppack.h>
4857 * PRIVILEGE_SET
4860 typedef struct _PRIVILEGE_SET {
4861 DWORD PrivilegeCount;
4862 DWORD Control;
4863 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4864 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4867 * TOKEN_PRIVILEGES
4870 typedef struct _TOKEN_PRIVILEGES {
4871 DWORD PrivilegeCount;
4872 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4873 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4876 * TOKEN_OWNER
4879 typedef struct _TOKEN_OWNER {
4880 PSID Owner;
4881 } TOKEN_OWNER, *PTOKEN_OWNER;
4884 * TOKEN_PRIMARY_GROUP
4887 typedef struct _TOKEN_PRIMARY_GROUP {
4888 PSID PrimaryGroup;
4889 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4893 * TOKEN_DEFAULT_DACL
4896 typedef struct _TOKEN_DEFAULT_DACL {
4897 PACL DefaultDacl;
4898 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4901 * TOKEN_SOURCE
4904 #define TOKEN_SOURCE_LENGTH 8
4906 typedef struct _TOKEN_SOURCE {
4907 char SourceName[TOKEN_SOURCE_LENGTH];
4908 LUID SourceIdentifier;
4909 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4912 * TOKEN_TYPE
4915 typedef enum tagTOKEN_TYPE {
4916 TokenPrimary = 1,
4917 TokenImpersonation
4918 } TOKEN_TYPE;
4921 * SECURITY_IMPERSONATION_LEVEL
4924 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4925 SecurityAnonymous,
4926 SecurityIdentification,
4927 SecurityImpersonation,
4928 SecurityDelegation
4929 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4931 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4932 #define SECURITY_STATIC_TRACKING (FALSE)
4934 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4935 * PSECURITY_CONTEXT_TRACKING_MODE;
4937 * Quality of Service
4940 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4941 DWORD Length;
4942 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4943 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4944 BOOLEAN EffectiveOnly;
4945 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4948 * TOKEN_STATISTICS
4951 #include <pshpack4.h>
4952 typedef struct _TOKEN_STATISTICS {
4953 LUID TokenId;
4954 LUID AuthenticationId;
4955 LARGE_INTEGER ExpirationTime;
4956 TOKEN_TYPE TokenType;
4957 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4958 DWORD DynamicCharged;
4959 DWORD DynamicAvailable;
4960 DWORD GroupCount;
4961 DWORD PrivilegeCount;
4962 LUID ModifiedId;
4963 } TOKEN_STATISTICS;
4964 #include <poppack.h>
4966 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4967 DWORD SidCount;
4968 DWORD SidLength;
4969 PSID_AND_ATTRIBUTES Sids;
4970 DWORD RestrictedSidCount;
4971 DWORD RestrictedSidLength;
4972 PSID_AND_ATTRIBUTES RestrictedSids;
4973 DWORD PrivilegeCount;
4974 DWORD PrivilegeLength;
4975 PLUID_AND_ATTRIBUTES Privileges;
4976 LUID AuthenticationId;
4977 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4979 typedef struct _TOKEN_ORIGIN {
4980 LUID OriginatingLogonSession;
4981 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4983 typedef struct _TOKEN_LINKED_TOKEN {
4984 HANDLE LinkedToken;
4985 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4987 typedef struct _TOKEN_ELEVATION {
4988 DWORD TokenIsElevated;
4989 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
4991 typedef struct _TOKEN_MANDATORY_LABEL {
4992 SID_AND_ATTRIBUTES Label;
4993 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
4995 #define TOKEN_MANDATORY_POLICY_OFF 0x0
4996 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
4997 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
4998 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
5000 typedef struct _TOKEN_MANDATORY_POLICY {
5001 DWORD Policy;
5002 } TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY;
5004 typedef struct _TOKEN_APPCONTAINER_INFORMATION {
5005 PSID TokenAppContainer;
5006 } TOKEN_APPCONTAINER_INFORMATION, * PTOKEN_APPCONTAINER_INFORMATION;
5008 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
5010 typedef struct _TOKEN_AUDIT_POLICY {
5011 BYTE PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
5012 } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
5014 typedef struct _TOKEN_ACCESS_INFORMATION {
5015 PSID_AND_ATTRIBUTES_HASH SidHash;
5016 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
5017 PTOKEN_PRIVILEGES Privileges;
5018 LUID AuthenticationId;
5019 TOKEN_TYPE TokenType;
5020 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
5021 TOKEN_MANDATORY_POLICY MandatoryPolicy;
5022 DWORD Flags;
5023 } TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION;
5025 typedef struct _TOKEN_CONTROL {
5026 LUID TokenId;
5027 LUID AuthenticationId;
5028 LUID ModifiedId;
5029 TOKEN_SOURCE TokenSource;
5030 } TOKEN_CONTROL, *PTOKEN_CONTROL;
5033 * ACLs of NT
5036 /* ACEs, directly starting after an ACL */
5037 typedef struct _ACE_HEADER {
5038 BYTE AceType;
5039 BYTE AceFlags;
5040 WORD AceSize;
5041 } ACE_HEADER,*PACE_HEADER;
5043 /* AceType */
5044 #define ACCESS_MIN_MS_ACE_TYPE 0x0
5045 #define ACCESS_ALLOWED_ACE_TYPE 0x0
5046 #define ACCESS_DENIED_ACE_TYPE 0x1
5047 #define SYSTEM_AUDIT_ACE_TYPE 0x2
5048 #define SYSTEM_ALARM_ACE_TYPE 0x3
5049 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
5050 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
5051 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
5052 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
5053 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
5054 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
5055 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
5056 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
5057 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
5058 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
5059 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
5060 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
5061 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
5062 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
5063 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
5064 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
5065 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
5066 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
5067 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
5068 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
5069 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
5070 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
5072 /* inherit AceFlags */
5073 #define OBJECT_INHERIT_ACE 0x01
5074 #define CONTAINER_INHERIT_ACE 0x02
5075 #define NO_PROPAGATE_INHERIT_ACE 0x04
5076 #define INHERIT_ONLY_ACE 0x08
5077 #define INHERITED_ACE 0x10
5078 #define VALID_INHERIT_FLAGS 0x1F
5080 /* AceFlags mask for what events we (should) audit */
5081 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
5082 #define FAILED_ACCESS_ACE_FLAG 0x80
5084 /* different ACEs depending on AceType
5085 * SidStart marks the begin of a SID
5086 * so the thing finally looks like this:
5087 * 0: ACE_HEADER
5088 * 4: ACCESS_MASK
5089 * 8... : SID
5091 typedef struct _ACCESS_ALLOWED_ACE {
5092 ACE_HEADER Header;
5093 DWORD Mask;
5094 DWORD SidStart;
5095 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
5097 typedef struct _ACCESS_DENIED_ACE {
5098 ACE_HEADER Header;
5099 DWORD Mask;
5100 DWORD SidStart;
5101 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
5103 typedef struct _SYSTEM_AUDIT_ACE {
5104 ACE_HEADER Header;
5105 DWORD Mask;
5106 DWORD SidStart;
5107 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
5109 typedef struct _SYSTEM_ALARM_ACE {
5110 ACE_HEADER Header;
5111 DWORD Mask;
5112 DWORD SidStart;
5113 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
5115 typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
5116 ACE_HEADER Header;
5117 ACCESS_MASK Mask;
5118 DWORD SidStart;
5119 } SYSTEM_MANDATORY_LABEL_ACE,*PSYSTEM_MANDATORY_LABEL_ACE;
5121 typedef struct _SYSTEM_PROCESS_TRUST_LABEL_ACE {
5122 ACE_HEADER Header;
5123 ACCESS_MASK Mask;
5124 DWORD SidStart;
5125 } SYSTEM_PROCESS_TRUST_LABEL_ACE, *PSYSTEM_PROCESS_TRUST_LABEL_ACE;
5127 typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
5128 ACE_HEADER Header;
5129 ACCESS_MASK Mask;
5130 DWORD Flags;
5131 GUID ObjectType;
5132 GUID InheritedObjectType;
5133 DWORD SidStart;
5134 } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
5136 typedef struct _ACCESS_DENIED_OBJECT_ACE {
5137 ACE_HEADER Header;
5138 ACCESS_MASK Mask;
5139 DWORD Flags;
5140 GUID ObjectType;
5141 GUID InheritedObjectType;
5142 DWORD SidStart;
5143 } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
5145 typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
5146 ACE_HEADER Header;
5147 ACCESS_MASK Mask;
5148 DWORD Flags;
5149 GUID ObjectType;
5150 GUID InheritedObjectType;
5151 DWORD SidStart;
5152 } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
5154 typedef struct _SYSTEM_ALARM_OBJECT_ACE {
5155 ACE_HEADER Header;
5156 ACCESS_MASK Mask;
5157 DWORD Flags;
5158 GUID ObjectType;
5159 GUID InheritedObjectType;
5160 DWORD SidStart;
5161 } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_aCE;
5163 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
5164 ACE_HEADER Header;
5165 DWORD Mask;
5166 DWORD SidStart;
5167 } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
5169 typedef struct _ACCESS_DENIED_CALLBACK_ACE {
5170 ACE_HEADER Header;
5171 DWORD Mask;
5172 DWORD SidStart;
5173 } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
5175 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
5176 ACE_HEADER Header;
5177 DWORD Mask;
5178 DWORD SidStart;
5179 } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
5181 typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
5182 ACE_HEADER Header;
5183 DWORD Mask;
5184 DWORD SidStart;
5185 } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
5187 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
5188 ACE_HEADER Header;
5189 ACCESS_MASK Mask;
5190 DWORD Flags;
5191 GUID ObjectType;
5192 GUID InheritedObjectType;
5193 DWORD SidStart;
5194 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
5196 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
5197 ACE_HEADER Header;
5198 ACCESS_MASK Mask;
5199 DWORD Flags;
5200 GUID ObjectType;
5201 GUID InheritedObjectType;
5202 DWORD SidStart;
5203 } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
5205 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
5206 ACE_HEADER Header;
5207 ACCESS_MASK Mask;
5208 DWORD Flags;
5209 GUID ObjectType;
5210 GUID InheritedObjectType;
5211 DWORD SidStart;
5212 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
5214 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
5215 ACE_HEADER Header;
5216 ACCESS_MASK Mask;
5217 DWORD Flags;
5218 GUID ObjectType;
5219 GUID InheritedObjectType;
5220 DWORD SidStart;
5221 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
5223 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
5224 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
5225 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
5226 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
5227 #define SYSTEM_PROCESS_TRUST_LABEL_VALID_MASK 0x00ffffff
5228 #define SYSTEM_PROCESS_TRUST_NOCONSTRAINT_MASK 0xffffffff
5230 typedef enum tagSID_NAME_USE {
5231 SidTypeUser = 1,
5232 SidTypeGroup,
5233 SidTypeDomain,
5234 SidTypeAlias,
5235 SidTypeWellKnownGroup,
5236 SidTypeDeletedAccount,
5237 SidTypeInvalid,
5238 SidTypeUnknown
5239 } SID_NAME_USE,*PSID_NAME_USE;
5241 #define ACE_OBJECT_TYPE_PRESENT 0x1
5242 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
5244 /* Access rights */
5246 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
5247 #undef DELETE
5248 #define DELETE 0x00010000
5249 #define READ_CONTROL 0x00020000
5250 #define WRITE_DAC 0x00040000
5251 #define WRITE_OWNER 0x00080000
5252 #define SYNCHRONIZE 0x00100000
5253 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
5255 #define STANDARD_RIGHTS_READ READ_CONTROL
5256 #define STANDARD_RIGHTS_WRITE READ_CONTROL
5257 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
5259 #define STANDARD_RIGHTS_ALL 0x001f0000
5261 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
5263 #define GENERIC_READ 0x80000000
5264 #define GENERIC_WRITE 0x40000000
5265 #define GENERIC_EXECUTE 0x20000000
5266 #define GENERIC_ALL 0x10000000
5268 #define MAXIMUM_ALLOWED 0x02000000
5269 #define ACCESS_SYSTEM_SECURITY 0x01000000
5271 #define EVENT_QUERY_STATE 0x0001
5272 #define EVENT_MODIFY_STATE 0x0002
5273 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5275 #define SEMAPHORE_QUERY_STATE 0x0001
5276 #define SEMAPHORE_MODIFY_STATE 0x0002
5277 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5279 #define MUTANT_QUERY_STATE 0x0001
5280 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5282 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5283 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5284 #define JOB_OBJECT_QUERY 0x0004
5285 #define JOB_OBJECT_TERMINATE 0x0008
5286 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5287 #define JOB_OBJECT_IMPERSONATE 0x0020
5288 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3f)
5290 #define TIMER_QUERY_STATE 0x0001
5291 #define TIMER_MODIFY_STATE 0x0002
5292 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5294 #define PROCESS_TERMINATE 0x0001
5295 #define PROCESS_CREATE_THREAD 0x0002
5296 #define PROCESS_VM_OPERATION 0x0008
5297 #define PROCESS_VM_READ 0x0010
5298 #define PROCESS_VM_WRITE 0x0020
5299 #define PROCESS_DUP_HANDLE 0x0040
5300 #define PROCESS_CREATE_PROCESS 0x0080
5301 #define PROCESS_SET_QUOTA 0x0100
5302 #define PROCESS_SET_INFORMATION 0x0200
5303 #define PROCESS_QUERY_INFORMATION 0x0400
5304 #define PROCESS_SUSPEND_RESUME 0x0800
5305 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5306 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5307 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5309 #define THREAD_TERMINATE 0x0001
5310 #define THREAD_SUSPEND_RESUME 0x0002
5311 #define THREAD_GET_CONTEXT 0x0008
5312 #define THREAD_SET_CONTEXT 0x0010
5313 #define THREAD_SET_INFORMATION 0x0020
5314 #define THREAD_QUERY_INFORMATION 0x0040
5315 #define THREAD_SET_THREAD_TOKEN 0x0080
5316 #define THREAD_IMPERSONATE 0x0100
5317 #define THREAD_DIRECT_IMPERSONATION 0x0200
5318 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5319 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5320 #define THREAD_RESUME 0x1000
5321 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5323 #define THREAD_BASE_PRIORITY_LOWRT 15
5324 #define THREAD_BASE_PRIORITY_MAX 2
5325 #define THREAD_BASE_PRIORITY_MIN -2
5326 #define THREAD_BASE_PRIORITY_IDLE -15
5328 typedef struct _QUOTA_LIMITS {
5329 SIZE_T PagedPoolLimit;
5330 SIZE_T NonPagedPoolLimit;
5331 SIZE_T MinimumWorkingSetSize;
5332 SIZE_T MaximumWorkingSetSize;
5333 SIZE_T PagefileLimit;
5334 LARGE_INTEGER TimeLimit;
5335 } QUOTA_LIMITS, *PQUOTA_LIMITS;
5337 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5338 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5339 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5340 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5341 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5343 typedef union _RATE_QUOTA_LIMIT {
5344 DWORD RateData;
5345 struct {
5346 DWORD RatePercent:7;
5347 DWORD Reserved0:25;
5348 } DUMMYSTRUCTNAME;
5349 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
5351 typedef struct _QUOTA_LIMITS_EX {
5352 SIZE_T PagedPoolLimit;
5353 SIZE_T NonPagedPoolLimit;
5354 SIZE_T MinimumWorkingSetSize;
5355 SIZE_T MaximumWorkingSetSize;
5356 SIZE_T PagefileLimit;
5357 LARGE_INTEGER TimeLimit;
5358 SIZE_T WorkingSetLimit;
5359 SIZE_T Reserved2;
5360 SIZE_T Reserved3;
5361 SIZE_T Reserved4;
5362 DWORD Flags;
5363 RATE_QUOTA_LIMIT CpuRateLimit;
5364 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
5366 #define SECTION_QUERY 0x0001
5367 #define SECTION_MAP_WRITE 0x0002
5368 #define SECTION_MAP_READ 0x0004
5369 #define SECTION_MAP_EXECUTE 0x0008
5370 #define SECTION_EXTEND_SIZE 0x0010
5371 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5372 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5374 #define FILE_READ_DATA 0x0001 /* file & pipe */
5375 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5376 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5377 #define FILE_ADD_FILE 0x0002 /* directory */
5378 #define FILE_APPEND_DATA 0x0004 /* file */
5379 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5380 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5381 #define FILE_READ_EA 0x0008 /* file & directory */
5382 #define FILE_READ_PROPERTIES FILE_READ_EA
5383 #define FILE_WRITE_EA 0x0010 /* file & directory */
5384 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5385 #define FILE_EXECUTE 0x0020 /* file */
5386 #define FILE_TRAVERSE 0x0020 /* directory */
5387 #define FILE_DELETE_CHILD 0x0040 /* directory */
5388 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5389 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5390 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5392 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5393 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5394 SYNCHRONIZE)
5395 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5396 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5397 FILE_APPEND_DATA | SYNCHRONIZE)
5398 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5399 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5401 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5402 #define DUPLICATE_SAME_ACCESS 0x00000002
5403 #ifdef __WINESRC__
5404 #define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
5405 #endif
5407 /* File attribute flags */
5408 #define FILE_SHARE_READ 0x00000001
5409 #define FILE_SHARE_WRITE 0x00000002
5410 #define FILE_SHARE_DELETE 0x00000004
5412 #define FILE_ATTRIBUTE_READONLY 0x00000001
5413 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5414 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5415 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5416 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5417 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5418 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5419 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5420 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5421 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5422 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5423 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5424 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5425 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5426 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5427 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5428 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5429 #define FILE_ATTRIBUTE_EA 0x00040000
5431 /* File notification flags */
5432 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5433 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5434 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5435 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5436 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5437 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5438 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5439 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5440 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5441 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5442 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5443 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5444 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5446 #define FILE_ACTION_ADDED 0x00000001
5447 #define FILE_ACTION_REMOVED 0x00000002
5448 #define FILE_ACTION_MODIFIED 0x00000003
5449 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5450 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5451 #define FILE_ACTION_ADDED_STREAM 0x00000006
5452 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5453 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5454 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5455 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5456 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5458 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5459 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5460 #define FILE_UNICODE_ON_DISK 0x00000004
5461 #define FILE_PERSISTENT_ACLS 0x00000008
5462 #define FILE_FILE_COMPRESSION 0x00000010
5463 #define FILE_VOLUME_QUOTAS 0x00000020
5464 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5465 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5466 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5467 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5468 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5469 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5470 #define FILE_NAMED_STREAMS 0x00040000
5471 #define FILE_READ_ONLY_VOLUME 0x00080000
5472 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5473 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5474 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5475 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5476 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5477 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5478 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5479 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5480 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5481 #define FILE_DAX_VOLUME 0x20000000
5482 #define FILE_SUPPORTS_GHOSTING 0x40000000
5484 /* File alignments (NT) */
5485 #define FILE_BYTE_ALIGNMENT 0x00000000
5486 #define FILE_WORD_ALIGNMENT 0x00000001
5487 #define FILE_LONG_ALIGNMENT 0x00000003
5488 #define FILE_QUAD_ALIGNMENT 0x00000007
5489 #define FILE_OCTA_ALIGNMENT 0x0000000f
5490 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5491 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5492 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5493 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5494 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5496 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5497 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5499 #define REG_NONE 0 /* no type */
5500 #define REG_SZ 1 /* string type (ASCII) */
5501 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5502 #define REG_BINARY 3 /* binary format, callerspecific */
5503 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5504 #define REG_DWORD 4 /* DWORD in little endian format */
5505 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5506 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5507 #define REG_LINK 6 /* symbolic link (UNICODE) */
5508 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5509 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5510 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5511 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5512 #define REG_QWORD 11 /* QWORD in little endian format */
5513 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5515 /* ----------------------------- begin power management --------------------- */
5517 typedef enum _LATENCY_TIME {
5518 LT_DONT_CARE,
5519 LT_LOWEST_LATENCY
5520 } LATENCY_TIME, *PLATENCY_TIME;
5522 #define DISCHARGE_POLICY_CRITICAL 0
5523 #define DISCHARGE_POLICY_LOW 1
5524 #define NUM_DISCHARGE_POLICIES 4
5526 #define PO_THROTTLE_NONE 0
5527 #define PO_THROTTLE_CONSTANT 1
5528 #define PO_THROTTLE_DEGRADE 2
5529 #define PO_THROTTLE_ADAPTIVE 3
5531 typedef enum _POWER_ACTION {
5532 PowerActionNone = 0,
5533 PowerActionReserved,
5534 PowerActionSleep,
5535 PowerActionHibernate,
5536 PowerActionShutdown,
5537 PowerActionShutdownReset,
5538 PowerActionShutdownOff,
5539 PowerActionWarmEject
5540 } POWER_ACTION,
5541 *PPOWER_ACTION;
5543 typedef enum _POWER_PLATFORM_ROLE {
5544 PlatformRoleUnspecified,
5545 PlatformRoleDesktop,
5546 PlatformRoleMobile,
5547 PlatformRoleWorkstation,
5548 PlatformRoleEnterpriseServer,
5549 PlatformRoleSOHOServer,
5550 PlatformRoleAppliancePC,
5551 PlatformRolePerformanceServer,
5552 PlatformRoleSlate,
5553 PlatformRoleMaximum
5554 } POWER_PLATFORM_ROLE, *PPOWER_PLATFORM_ROLE;
5556 typedef enum _SYSTEM_POWER_STATE {
5557 PowerSystemUnspecified = 0,
5558 PowerSystemWorking = 1,
5559 PowerSystemSleeping1 = 2,
5560 PowerSystemSleeping2 = 3,
5561 PowerSystemSleeping3 = 4,
5562 PowerSystemHibernate = 5,
5563 PowerSystemShutdown = 6,
5564 PowerSystemMaximum = 7
5565 } SYSTEM_POWER_STATE,
5566 *PSYSTEM_POWER_STATE;
5568 typedef enum _DEVICE_POWER_STATE {
5569 PowerDeviceUnspecified,
5570 PowerDeviceD0,
5571 PowerDeviceD1,
5572 PowerDeviceD2,
5573 PowerDeviceD3,
5574 PowerDeviceMaximum
5575 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
5577 typedef enum _POWER_INFORMATION_LEVEL {
5578 SystemPowerPolicyAc,
5579 SystemPowerPolicyDc,
5580 VerifySystemPolicyAc,
5581 VerifySystemPolicyDc,
5582 SystemPowerCapabilities,
5583 SystemBatteryState,
5584 SystemPowerStateHandler,
5585 ProcessorStateHandler,
5586 SystemPowerPolicyCurrent,
5587 AdministratorPowerPolicy,
5588 SystemReserveHiberFile,
5589 ProcessorInformation,
5590 SystemPowerInformation,
5591 ProcessorStateHandler2,
5592 LastWakeTime,
5593 LastSleepTime,
5594 SystemExecutionState,
5595 SystemPowerStateNotifyHandler,
5596 ProcessorPowerPolicyAc,
5597 ProcessorPowerPolicyDc,
5598 VerifyProcessorPowerPolicyAc,
5599 VerifyProcessorPowerPolicyDc,
5600 ProcessorPowerPolicyCurrent
5601 } POWER_INFORMATION_LEVEL;
5603 typedef struct _ADMINISTRATOR_POWER_POLICY {
5604 SYSTEM_POWER_STATE MinSleep;
5605 SYSTEM_POWER_STATE MaxSleep;
5606 ULONG MinVideoTimeout;
5607 ULONG MaxVideoTimeout;
5608 ULONG MinSpindownTimeout;
5609 ULONG MaxSpindownTimeout;
5610 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
5612 typedef struct {
5613 ULONG Granularity;
5614 ULONG Capacity;
5615 } BATTERY_REPORTING_SCALE,
5616 *PBATTERY_REPORTING_SCALE;
5618 typedef struct {
5619 POWER_ACTION Action;
5620 ULONG Flags;
5621 ULONG EventCode;
5622 } POWER_ACTION_POLICY,
5623 *PPOWER_ACTION_POLICY;
5625 typedef struct _PROCESSOR_POWER_INFORMATION {
5626 ULONG Number;
5627 ULONG MaxMhz;
5628 ULONG CurrentMhz;
5629 ULONG MhzLimit;
5630 ULONG MaxIdleState;
5631 ULONG CurrentIdleState;
5632 } PROCESSOR_POWER_INFORMATION,
5633 *PPROCESSOR_POWER_INFORMATION;
5635 typedef struct _PROCESSOR_POWER_POLICY_INFO {
5636 ULONG TimeCheck;
5637 ULONG DemoteLimit;
5638 ULONG PromoteLimit;
5639 UCHAR DemotePercent;
5640 UCHAR PromotePercent;
5641 UCHAR Spare[2];
5642 ULONG AllowDemotion:1;
5643 ULONG AllowPromotion:1;
5644 ULONG Reserved:30;
5645 } PROCESSOR_POWER_POLICY_INFO,
5646 *PPROCESSOR_POWER_POLICY_INFO;
5648 typedef struct _PROCESSOR_POWER_POLICY {
5649 DWORD Revision;
5650 BYTE DynamicThrottle;
5651 BYTE Spare[3];
5652 DWORD DisableCStates:1;
5653 DWORD Reserved:31;
5654 DWORD PolicyCount;
5655 PROCESSOR_POWER_POLICY_INFO Policy[3];
5656 } PROCESSOR_POWER_POLICY,
5657 *PPROCESSOR_POWER_POLICY;
5659 typedef struct {
5660 BOOLEAN AcOnLine;
5661 BOOLEAN BatteryPresent;
5662 BOOLEAN Charging;
5663 BOOLEAN Discharging;
5664 BOOLEAN Spare1[3];
5665 BYTE Tag;
5666 ULONG MaxCapacity;
5667 ULONG RemainingCapacity;
5668 ULONG Rate;
5669 ULONG EstimatedTime;
5670 ULONG DefaultAlert1;
5671 ULONG DefaultAlert2;
5672 } SYSTEM_BATTERY_STATE,
5673 *PSYSTEM_BATTERY_STATE;
5675 typedef struct {
5676 BOOLEAN PowerButtonPresent;
5677 BOOLEAN SleepButtonPresent;
5678 BOOLEAN LidPresent;
5679 BOOLEAN SystemS1;
5680 BOOLEAN SystemS2;
5681 BOOLEAN SystemS3;
5682 BOOLEAN SystemS4;
5683 BOOLEAN SystemS5;
5684 BOOLEAN HiberFilePresent;
5685 BOOLEAN FullWake;
5686 BOOLEAN VideoDimPresent;
5687 BOOLEAN ApmPresent;
5688 BOOLEAN UpsPresent;
5689 BOOLEAN ThermalControl;
5690 BOOLEAN ProcessorThrottle;
5691 UCHAR ProcessorMinThrottle;
5692 UCHAR ProcessorMaxThrottle;
5693 UCHAR spare2[4];
5694 BOOLEAN DiskSpinDown;
5695 UCHAR spare3[8];
5696 BOOLEAN SystemBatteriesPresent;
5697 BOOLEAN BatteriesAreShortTerm;
5698 BATTERY_REPORTING_SCALE BatteryScale[3];
5699 SYSTEM_POWER_STATE AcOnLineWake;
5700 SYSTEM_POWER_STATE SoftLidWake;
5701 SYSTEM_POWER_STATE RtcWake;
5702 SYSTEM_POWER_STATE MinDeviceWakeState;
5703 SYSTEM_POWER_STATE DefaultLowLatencyWake;
5704 } SYSTEM_POWER_CAPABILITIES,
5705 *PSYSTEM_POWER_CAPABILITIES;
5707 typedef struct _SYSTEM_POWER_INFORMATION {
5708 ULONG MaxIdlenessAllowed;
5709 ULONG Idleness;
5710 ULONG TimeRemaining;
5711 UCHAR CoolingMode;
5712 } SYSTEM_POWER_INFORMATION,
5713 *PSYSTEM_POWER_INFORMATION;
5715 typedef struct _SYSTEM_POWER_LEVEL {
5716 BOOLEAN Enable;
5717 UCHAR Spare[3];
5718 ULONG BatteryLevel;
5719 POWER_ACTION_POLICY PowerPolicy;
5720 SYSTEM_POWER_STATE MinSystemState;
5721 } SYSTEM_POWER_LEVEL,
5722 *PSYSTEM_POWER_LEVEL;
5724 typedef struct _SYSTEM_POWER_POLICY {
5725 ULONG Revision;
5726 POWER_ACTION_POLICY PowerButton;
5727 POWER_ACTION_POLICY SleepButton;
5728 POWER_ACTION_POLICY LidClose;
5729 SYSTEM_POWER_STATE LidOpenWake;
5730 ULONG Reserved;
5731 POWER_ACTION_POLICY Idle;
5732 ULONG IdleTimeout;
5733 UCHAR IdleSensitivity;
5734 UCHAR DynamicThrottle;
5735 UCHAR Spare2[2];
5736 SYSTEM_POWER_STATE MinSleep;
5737 SYSTEM_POWER_STATE MaxSleep;
5738 SYSTEM_POWER_STATE ReducedLatencySleep;
5739 ULONG WinLogonFlags;
5740 ULONG Spare3;
5741 ULONG DozeS4Timeout;
5742 ULONG BroadcastCapacityResolution;
5743 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
5744 ULONG VideoTimeout;
5745 BOOLEAN VideoDimDisplay;
5746 ULONG VideoReserved[3];
5747 ULONG SpindownTimeout;
5748 BOOLEAN OptimizeForPower;
5749 UCHAR FanThrottleTolerance;
5750 UCHAR ForcedThrottle;
5751 UCHAR MinThrottle;
5752 POWER_ACTION_POLICY OverThrottled;
5753 } SYSTEM_POWER_POLICY,
5754 *PSYSTEM_POWER_POLICY;
5756 typedef enum _POWER_REQUEST_TYPE
5758 PowerRequestDisplayRequired,
5759 PowerRequestSystemRequired,
5760 PowerRequestAwayModeRequired
5761 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
5763 #define POWER_REQUEST_CONTEXT_VERSION 0
5765 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5766 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5768 typedef union _FILE_SEGMENT_ELEMENT {
5769 PVOID64 Buffer;
5770 ULONGLONG Alignment;
5771 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5773 typedef struct _FILE_NOTIFY_INFORMATION {
5774 DWORD NextEntryOffset;
5775 DWORD Action;
5776 DWORD FileNameLength;
5777 WCHAR FileName[1];
5778 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5780 /* ----------------------------- begin tape storage --------------------- */
5782 #define TAPE_FIXED_PARTITIONS 0
5783 #define TAPE_SELECT_PARTITIONS 1
5784 #define TAPE_INITIATOR_PARTITIONS 2
5785 #define TAPE_ERASE_SHORT 0
5786 #define TAPE_ERASE_LONG 1
5787 #define TAPE_LOAD 0
5788 #define TAPE_UNLOAD 1
5789 #define TAPE_TENSION 2
5790 #define TAPE_LOCK 3
5791 #define TAPE_UNLOCK 4
5792 #define TAPE_FORMAT 5
5793 #define TAPE_SETMARKS 0
5794 #define TAPE_FILEMARKS 1
5795 #define TAPE_SHORT_FILEMARKS 2
5796 #define TAPE_LONG_FILEMARKS 3
5797 #define TAPE_REWIND 0
5798 #define TAPE_ABSOLUTE_BLOCK 1
5799 #define TAPE_LOGICAL_BLOCK 2
5800 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5801 #define TAPE_SPACE_END_OF_DATA 4
5802 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5803 #define TAPE_SPACE_FILEMARKS 6
5804 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5805 #define TAPE_SPACE_SETMARKS 8
5806 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5808 typedef struct _TAPE_CREATE_PARTITION {
5809 DWORD Method;
5810 DWORD Count;
5811 DWORD Size;
5812 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5814 typedef struct _TAPE_ERASE {
5815 DWORD Type;
5816 BOOLEAN Immediate;
5817 } TAPE_ERASE, *PTAPE_ERASE;
5819 typedef struct _TAPE_PREPARE {
5820 DWORD Operation;
5821 BOOLEAN Immediate;
5822 } TAPE_PREPARE, *PTAPE_PREPARE;
5824 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5825 BOOLEAN ECC;
5826 BOOLEAN Compression;
5827 BOOLEAN DataPadding;
5828 BOOLEAN ReportSetmarks;
5829 ULONG EOTWarningZoneSize;
5830 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5832 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5833 ULONG BlockSize;
5834 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5836 typedef struct _TAPE_WRITE_MARKS {
5837 DWORD Type;
5838 DWORD Count;
5839 BOOLEAN Immediate;
5840 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5842 typedef struct _TAPE_GET_POSITION {
5843 ULONG Type;
5844 ULONG Partition;
5845 ULONG OffsetLow;
5846 ULONG OffsetHigh;
5847 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5849 typedef struct _TAPE_SET_POSITION {
5850 ULONG Method;
5851 ULONG Partition;
5852 LARGE_INTEGER Offset;
5853 BOOLEAN Immediate;
5854 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5856 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5857 BOOLEAN ECC;
5858 BOOLEAN Compression;
5859 BOOLEAN DataPadding;
5860 BOOLEAN ReportSetmarks;
5861 DWORD DefaultBlockSize;
5862 DWORD MaximumBlockSize;
5863 DWORD MinimumBlockSize;
5864 DWORD MaximumPartitionCount;
5865 DWORD FeaturesLow;
5866 DWORD FeaturesHigh;
5867 DWORD EOTWarningZoneSize;
5868 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
5870 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
5871 LARGE_INTEGER Capacity;
5872 LARGE_INTEGER Remaining;
5873 DWORD BlockSize;
5874 DWORD PartitionCount;
5875 BOOLEAN WriteProtected;
5876 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
5878 /* ----------------------------- begin registry ----------------------------- */
5880 /* Registry security values */
5881 #define OWNER_SECURITY_INFORMATION 0x00000001
5882 #define GROUP_SECURITY_INFORMATION 0x00000002
5883 #define DACL_SECURITY_INFORMATION 0x00000004
5884 #define SACL_SECURITY_INFORMATION 0x00000008
5885 #define LABEL_SECURITY_INFORMATION 0x00000010
5887 #define REG_OPTION_RESERVED 0x00000000
5888 #define REG_OPTION_NON_VOLATILE 0x00000000
5889 #define REG_OPTION_VOLATILE 0x00000001
5890 #define REG_OPTION_CREATE_LINK 0x00000002
5891 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5892 #define REG_OPTION_OPEN_LINK 0x00000008
5893 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
5894 REG_OPTION_NON_VOLATILE | \
5895 REG_OPTION_VOLATILE | \
5896 REG_OPTION_CREATE_LINK | \
5897 REG_OPTION_BACKUP_RESTORE | \
5898 REG_OPTION_OPEN_LINK)
5901 #define REG_CREATED_NEW_KEY 0x00000001
5902 #define REG_OPENED_EXISTING_KEY 0x00000002
5904 /* For RegNotifyChangeKeyValue */
5905 #define REG_NOTIFY_CHANGE_NAME 0x01
5906 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5907 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5908 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5909 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
5911 #define KEY_QUERY_VALUE 0x00000001
5912 #define KEY_SET_VALUE 0x00000002
5913 #define KEY_CREATE_SUB_KEY 0x00000004
5914 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5915 #define KEY_NOTIFY 0x00000010
5916 #define KEY_CREATE_LINK 0x00000020
5917 #define KEY_WOW64_64KEY 0x00000100
5918 #define KEY_WOW64_32KEY 0x00000200
5919 #define KEY_WOW64_RES 0x00000300
5921 /* for RegKeyRestore flags */
5922 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5923 #define REG_REFRESH_HIVE 0x00000002
5924 #define REG_NO_LAZY_FLUSH 0x00000004
5925 #define REG_FORCE_RESTORE 0x00000008
5926 #define REG_APP_HIVE 0x00000010
5927 #define REG_PROCESS_PRIVATE 0x00000020
5929 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5930 KEY_QUERY_VALUE| \
5931 KEY_ENUMERATE_SUB_KEYS| \
5932 KEY_NOTIFY) \
5933 & (~SYNCHRONIZE) \
5935 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5936 KEY_SET_VALUE| \
5937 KEY_CREATE_SUB_KEY) \
5938 & (~SYNCHRONIZE) \
5940 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5941 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5942 KEY_QUERY_VALUE| \
5943 KEY_SET_VALUE| \
5944 KEY_CREATE_SUB_KEY| \
5945 KEY_ENUMERATE_SUB_KEYS| \
5946 KEY_NOTIFY| \
5947 KEY_CREATE_LINK) \
5948 & (~SYNCHRONIZE) \
5950 /* ------------------------------ end registry ------------------------------ */
5953 #define EVENTLOG_SUCCESS 0x0000
5954 #define EVENTLOG_ERROR_TYPE 0x0001
5955 #define EVENTLOG_WARNING_TYPE 0x0002
5956 #define EVENTLOG_INFORMATION_TYPE 0x0004
5957 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5958 #define EVENTLOG_AUDIT_FAILURE 0x0010
5960 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5961 #define EVENTLOG_SEEK_READ 0x0002
5962 #define EVENTLOG_FORWARDS_READ 0x0004
5963 #define EVENTLOG_BACKWARDS_READ 0x0008
5965 typedef struct _EVENTLOGRECORD {
5966 DWORD Length;
5967 DWORD Reserved;
5968 DWORD RecordNumber;
5969 DWORD TimeGenerated;
5970 DWORD TimeWritten;
5971 DWORD EventID;
5972 WORD EventType;
5973 WORD NumStrings;
5974 WORD EventCategory;
5975 WORD ReservedFlags;
5976 DWORD ClosingRecordNumber;
5977 DWORD StringOffset;
5978 DWORD UserSidLength;
5979 DWORD UserSidOffset;
5980 DWORD DataLength;
5981 DWORD DataOffset;
5982 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5984 #define SERVICE_BOOT_START 0x00000000
5985 #define SERVICE_SYSTEM_START 0x00000001
5986 #define SERVICE_AUTO_START 0x00000002
5987 #define SERVICE_DEMAND_START 0x00000003
5988 #define SERVICE_DISABLED 0x00000004
5990 #define SERVICE_ERROR_IGNORE 0x00000000
5991 #define SERVICE_ERROR_NORMAL 0x00000001
5992 #define SERVICE_ERROR_SEVERE 0x00000002
5993 #define SERVICE_ERROR_CRITICAL 0x00000003
5995 /* Service types */
5996 #define SERVICE_KERNEL_DRIVER 0x00000001
5997 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5998 #define SERVICE_ADAPTER 0x00000004
5999 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
6001 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
6002 SERVICE_RECOGNIZER_DRIVER )
6004 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
6005 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
6006 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
6008 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
6010 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
6011 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
6014 typedef enum _CM_SERVICE_NODE_TYPE
6016 DriverType = SERVICE_KERNEL_DRIVER,
6017 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
6018 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
6019 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
6020 AdapterType = SERVICE_ADAPTER,
6021 RecognizerType = SERVICE_RECOGNIZER_DRIVER
6022 } SERVICE_NODE_TYPE;
6024 typedef enum _CM_SERVICE_LOAD_TYPE
6026 BootLoad = SERVICE_BOOT_START,
6027 SystemLoad = SERVICE_SYSTEM_START,
6028 AutoLoad = SERVICE_AUTO_START,
6029 DemandLoad = SERVICE_DEMAND_START,
6030 DisableLoad = SERVICE_DISABLED
6031 } SERVICE_LOAD_TYPE;
6033 typedef enum _CM_ERROR_CONTROL_TYPE
6035 IgnoreError = SERVICE_ERROR_IGNORE,
6036 NormalError = SERVICE_ERROR_NORMAL,
6037 SevereError = SERVICE_ERROR_SEVERE,
6038 CriticalError = SERVICE_ERROR_CRITICAL
6039 } SERVICE_ERROR_TYPE;
6041 NTSYSAPI SIZE_T WINAPI RtlCompareMemory(const VOID*, const VOID*, SIZE_T);
6042 NTSYSAPI SIZE_T WINAPI RtlCompareMemoryUlong(VOID*, SIZE_T, ULONG);
6044 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
6045 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
6046 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
6047 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
6048 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
6050 static FORCEINLINE void *RtlSecureZeroMemory(void *buffer, SIZE_T length)
6052 volatile char *ptr = (volatile char *)buffer;
6054 while (length--) *ptr++ = 0;
6055 return buffer;
6058 #include <guiddef.h>
6060 typedef struct _OBJECT_TYPE_LIST {
6061 WORD Level;
6062 WORD Sbz;
6063 GUID *ObjectType;
6064 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
6066 typedef struct _RTL_CRITICAL_SECTION_DEBUG
6068 WORD Type;
6069 WORD CreatorBackTraceIndex;
6070 struct _RTL_CRITICAL_SECTION *CriticalSection;
6071 LIST_ENTRY ProcessLocksList;
6072 DWORD EntryCount;
6073 DWORD ContentionCount;
6074 #ifdef __WINESRC__ /* in Wine we store the name here */
6075 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
6076 #else
6077 DWORD Spare[ 2 ];
6078 #endif
6079 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
6081 typedef struct _RTL_CRITICAL_SECTION {
6082 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
6083 LONG LockCount;
6084 LONG RecursionCount;
6085 HANDLE OwningThread;
6086 HANDLE LockSemaphore;
6087 ULONG_PTR SpinCount;
6088 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
6090 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
6091 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
6092 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
6093 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
6094 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
6096 typedef struct _RTL_SRWLOCK {
6097 PVOID Ptr;
6098 } RTL_SRWLOCK, *PRTL_SRWLOCK;
6100 #define RTL_SRWLOCK_INIT {0}
6102 typedef struct _RTL_CONDITION_VARIABLE {
6103 PVOID Ptr;
6104 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
6105 #define RTL_CONDITION_VARIABLE_INIT {0}
6106 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
6108 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
6109 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
6111 #define RTL_RUN_ONCE_INIT {0}
6112 typedef union _RTL_RUN_ONCE {
6113 PVOID Ptr;
6114 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
6116 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
6117 #define RTL_RUN_ONCE_ASYNC 0x00000002
6118 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
6120 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
6121 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
6122 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
6123 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
6124 NTSYSAPI DWORD WINAPI RtlRunOnceBeginInitialize(PRTL_RUN_ONCE, DWORD, PVOID*);
6125 NTSYSAPI DWORD WINAPI RtlRunOnceComplete(PRTL_RUN_ONCE, DWORD, PVOID);
6127 #include <pshpack8.h>
6128 typedef struct _IO_COUNTERS {
6129 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
6130 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
6131 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
6132 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
6133 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
6134 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
6135 } IO_COUNTERS, *PIO_COUNTERS;
6136 #include <poppack.h>
6138 typedef struct {
6139 DWORD dwOSVersionInfoSize;
6140 DWORD dwMajorVersion;
6141 DWORD dwMinorVersion;
6142 DWORD dwBuildNumber;
6143 DWORD dwPlatformId;
6144 CHAR szCSDVersion[128];
6145 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
6147 typedef struct {
6148 DWORD dwOSVersionInfoSize;
6149 DWORD dwMajorVersion;
6150 DWORD dwMinorVersion;
6151 DWORD dwBuildNumber;
6152 DWORD dwPlatformId;
6153 WCHAR szCSDVersion[128];
6154 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
6156 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
6157 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
6158 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
6160 typedef struct {
6161 DWORD dwOSVersionInfoSize;
6162 DWORD dwMajorVersion;
6163 DWORD dwMinorVersion;
6164 DWORD dwBuildNumber;
6165 DWORD dwPlatformId;
6166 CHAR szCSDVersion[128];
6167 WORD wServicePackMajor;
6168 WORD wServicePackMinor;
6169 WORD wSuiteMask;
6170 BYTE wProductType;
6171 BYTE wReserved;
6172 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
6174 typedef struct {
6175 DWORD dwOSVersionInfoSize;
6176 DWORD dwMajorVersion;
6177 DWORD dwMinorVersion;
6178 DWORD dwBuildNumber;
6179 DWORD dwPlatformId;
6180 WCHAR szCSDVersion[128];
6181 WORD wServicePackMajor;
6182 WORD wServicePackMinor;
6183 WORD wSuiteMask;
6184 BYTE wProductType;
6185 BYTE wReserved;
6186 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
6188 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
6189 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
6190 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
6192 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
6194 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
6196 #define VER_PLATFORM_WIN32s 0
6197 #define VER_PLATFORM_WIN32_WINDOWS 1
6198 #define VER_PLATFORM_WIN32_NT 2
6200 #define VER_MINORVERSION 0x00000001
6201 #define VER_MAJORVERSION 0x00000002
6202 #define VER_BUILDNUMBER 0x00000004
6203 #define VER_PLATFORMID 0x00000008
6204 #define VER_SERVICEPACKMINOR 0x00000010
6205 #define VER_SERVICEPACKMAJOR 0x00000020
6206 #define VER_SUITENAME 0x00000040
6207 #define VER_PRODUCT_TYPE 0x00000080
6209 #define VER_NT_WORKSTATION 1
6210 #define VER_NT_DOMAIN_CONTROLLER 2
6211 #define VER_NT_SERVER 3
6213 #define VER_SUITE_SMALLBUSINESS 0x00000001
6214 #define VER_SUITE_ENTERPRISE 0x00000002
6215 #define VER_SUITE_BACKOFFICE 0x00000004
6216 #define VER_SUITE_COMMUNICATIONS 0x00000008
6217 #define VER_SUITE_TERMINAL 0x00000010
6218 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
6219 #define VER_SUITE_EMBEDDEDNT 0x00000040
6220 #define VER_SUITE_DATACENTER 0x00000080
6221 #define VER_SUITE_SINGLEUSERTS 0x00000100
6222 #define VER_SUITE_PERSONAL 0x00000200
6223 #define VER_SUITE_BLADE 0x00000400
6224 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
6225 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
6226 #define VER_SUITE_STORAGE_SERVER 0x00002000
6227 #define VER_SUITE_COMPUTE_SERVER 0x00004000
6228 #define VER_SUITE_WH_SERVER 0x00008000
6230 #define VER_EQUAL 1
6231 #define VER_GREATER 2
6232 #define VER_GREATER_EQUAL 3
6233 #define VER_LESS 4
6234 #define VER_LESS_EQUAL 5
6235 #define VER_AND 6
6236 #define VER_OR 7
6238 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
6239 DWORD dwFlags;
6240 DWORD ulFormatVersion;
6241 DWORD ulAssemblyCount;
6242 DWORD ulRootManifestPathType;
6243 DWORD ulRootManifestPathChars;
6244 DWORD ulRootConfigurationPathType;
6245 DWORD ulRootConfigurationPathChars;
6246 DWORD ulAppDirPathType;
6247 DWORD ulAppDirPathChars;
6248 PCWSTR lpRootManifestPath;
6249 PCWSTR lpRootConfigurationPath;
6250 PCWSTR lpAppDirPath;
6251 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
6253 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
6254 DWORD ulFlags;
6255 DWORD ulEncodedAssemblyIdentityLength;
6256 DWORD ulManifestPathType;
6257 DWORD ulManifestPathLength;
6258 LARGE_INTEGER liManifestLastWriteTime;
6259 DWORD ulPolicyPathType;
6260 DWORD ulPolicyPathLength;
6261 LARGE_INTEGER liPolicyLastWriteTime;
6262 DWORD ulMetadataSatelliteRosterIndex;
6263 DWORD ulManifestVersionMajor;
6264 DWORD ulManifestVersionMinor;
6265 DWORD ulPolicyVersionMajor;
6266 DWORD ulPolicyVersionMinor;
6267 DWORD ulAssemblyDirectoryNameLength;
6268 PCWSTR lpAssemblyEncodedAssemblyIdentity;
6269 PCWSTR lpAssemblyManifestPath;
6270 PCWSTR lpAssemblyPolicyPath;
6271 PCWSTR lpAssemblyDirectoryName;
6272 DWORD ulFileCount;
6273 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
6275 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
6276 DWORD ulAssemblyIndex;
6277 DWORD ulFileIndexInAssembly;
6278 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
6280 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
6282 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
6283 DWORD ulFlags;
6284 DWORD ulFilenameLength;
6285 DWORD ulPathLength;
6286 PCWSTR lpFileName;
6287 PCWSTR lpFilePath;
6288 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
6290 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
6292 typedef enum {
6293 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
6294 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
6295 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION,
6296 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6297 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
6299 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
6300 GUID Id;
6301 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
6302 ULONGLONG MaxVersionTested;
6303 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
6305 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6306 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
6307 DWORD ElementCount;
6308 COMPATIBILITY_CONTEXT_ELEMENT Elements[];
6309 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
6310 #endif
6312 typedef enum {
6313 ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
6314 ACTCTX_RUN_LEVEL_AS_INVOKER,
6315 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
6316 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
6317 ACTCTX_RUN_LEVEL_NUMBERS
6318 } ACTCTX_REQUESTED_RUN_LEVEL;
6320 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
6321 DWORD ulFlags;
6322 ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
6323 DWORD UiAccess;
6324 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6326 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION *PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6328 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
6329 ActivationContextBasicInformation = 1,
6330 ActivationContextDetailedInformation = 2,
6331 AssemblyDetailedInformationInActivationContext = 3,
6332 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
6333 RunlevelInformationInActivationContext = 5,
6334 CompatibilityInformationInActivationContext = 6,
6335 ActivationContextManifestResourceName = 7,
6336 MaxActivationContextInfoClass,
6337 AssemblyDetailedInformationInActivationContxt = AssemblyDetailedInformationInActivationContext,
6338 FileInformationInAssemblyOfAssemblyInActivationContxt = FileInformationInAssemblyOfAssemblyInActivationContext
6339 } ACTIVATION_CONTEXT_INFO_CLASS;
6341 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6342 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6343 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6344 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6346 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6347 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6348 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6349 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6350 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6351 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6352 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6353 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6354 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6355 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6356 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6357 #define ACTIVATION_CONTEXT_SECTION_WINRT_ACTIVATABLE_CLASSES 12
6359 typedef enum _JOBOBJECTINFOCLASS
6361 JobObjectBasicAccountingInformation = 1,
6362 JobObjectBasicLimitInformation,
6363 JobObjectBasicProcessIdList,
6364 JobObjectBasicUIRestrictions,
6365 JobObjectSecurityLimitInformation,
6366 JobObjectEndOfJobTimeInformation,
6367 JobObjectAssociateCompletionPortInformation,
6368 JobObjectBasicAndIoAccountingInformation,
6369 JobObjectExtendedLimitInformation,
6370 JobObjectJobSetInformation,
6371 MaxJobObjectInfoClass
6372 } JOBOBJECTINFOCLASS;
6374 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
6375 LARGE_INTEGER TotalUserTime;
6376 LARGE_INTEGER TotalKernelTime;
6377 LARGE_INTEGER ThisPeriodTotalUserTime;
6378 LARGE_INTEGER ThisPeriodTotalKernelTime;
6379 DWORD TotalPageFaultCount;
6380 DWORD TotalProcesses;
6381 DWORD ActiveProcesses;
6382 DWORD TotalTerminatedProcesses;
6383 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
6385 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
6386 LARGE_INTEGER PerProcessUserTimeLimit;
6387 LARGE_INTEGER PerJobUserTimeLimit;
6388 DWORD LimitFlags;
6389 SIZE_T MinimumWorkingSetSize;
6390 SIZE_T MaximumWorkingSetSize;
6391 DWORD ActiveProcessLimit;
6392 ULONG_PTR Affinity;
6393 DWORD PriorityClass;
6394 DWORD SchedulingClass;
6395 } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
6397 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
6398 DWORD NumberOfAssignedProcesses;
6399 DWORD NumberOfProcessIdsInList;
6400 ULONG_PTR ProcessIdList[1];
6401 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
6403 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
6404 DWORD UIRestrictionsClass;
6405 } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
6407 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
6408 DWORD SecurityLimitFlags;
6409 HANDLE JobToken;
6410 PTOKEN_GROUPS SidsToDisable;
6411 PTOKEN_PRIVILEGES PrivilegesToDelete;
6412 PTOKEN_GROUPS RestrictedSids;
6413 } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
6415 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
6416 DWORD EndOfJobTimeAction;
6417 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
6419 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
6420 PVOID CompletionKey;
6421 HANDLE CompletionPort;
6422 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
6424 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6425 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6426 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6427 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6428 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6429 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6430 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6431 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6432 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6434 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
6435 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
6436 IO_COUNTERS IoInfo;
6437 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
6439 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
6440 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
6441 IO_COUNTERS IoInfo;
6442 SIZE_T ProcessMemoryLimit;
6443 SIZE_T JobMemoryLimit;
6444 SIZE_T PeakProcessMemoryUsed;
6445 SIZE_T PeakJobMemoryUsed;
6446 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
6448 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6449 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6450 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6451 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6452 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6453 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6454 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6455 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6456 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6457 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6458 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6459 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6460 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6461 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6462 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6464 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6465 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6466 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6468 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6470 RelationProcessorCore = 0,
6471 RelationNumaNode = 1,
6472 RelationCache = 2,
6473 RelationProcessorPackage = 3,
6474 RelationGroup = 4,
6475 RelationProcessorDie = 5,
6476 RelationNumaNodeEx = 6,
6477 RelationProcessorModule = 7,
6478 RelationAll = 0xffff
6479 } LOGICAL_PROCESSOR_RELATIONSHIP;
6481 #define LTP_PC_SMT 0x1
6483 typedef enum _PROCESSOR_CACHE_TYPE
6485 CacheUnified,
6486 CacheInstruction,
6487 CacheData,
6488 CacheTrace
6489 } PROCESSOR_CACHE_TYPE;
6491 typedef struct _PROCESSOR_GROUP_INFO
6493 BYTE MaximumProcessorCount;
6494 BYTE ActiveProcessorCount;
6495 BYTE Reserved[38];
6496 KAFFINITY ActiveProcessorMask;
6497 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
6499 typedef struct _CACHE_DESCRIPTOR
6501 BYTE Level;
6502 BYTE Associativity;
6503 WORD LineSize;
6504 DWORD Size;
6505 PROCESSOR_CACHE_TYPE Type;
6506 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
6508 typedef struct _GROUP_AFFINITY
6510 KAFFINITY Mask;
6511 WORD Group;
6512 WORD Reserved[3];
6513 } GROUP_AFFINITY, *PGROUP_AFFINITY;
6515 #define ALL_PROCESSOR_GROUPS 0xffff
6517 typedef struct _PROCESSOR_NUMBER
6519 WORD Group;
6520 BYTE Number;
6521 BYTE Reserved;
6522 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
6524 typedef struct _PROCESSOR_RELATIONSHIP
6526 BYTE Flags;
6527 BYTE EfficiencyClass;
6528 BYTE Reserved[20];
6529 WORD GroupCount;
6530 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
6531 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
6533 typedef struct _NUMA_NODE_RELATIONSHIP
6535 DWORD NodeNumber;
6536 BYTE Reserved[20];
6537 GROUP_AFFINITY GroupMask;
6538 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
6540 typedef struct _CACHE_RELATIONSHIP
6542 BYTE Level;
6543 BYTE Associativity;
6544 WORD LineSize;
6545 DWORD CacheSize;
6546 PROCESSOR_CACHE_TYPE Type;
6547 BYTE Reserved[20];
6548 GROUP_AFFINITY GroupMask;
6549 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
6551 typedef struct _GROUP_RELATIONSHIP
6553 WORD MaximumGroupCount;
6554 WORD ActiveGroupCount;
6555 BYTE Reserved[20];
6556 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
6557 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
6559 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6561 ULONG_PTR ProcessorMask;
6562 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6563 union
6565 struct
6567 BYTE Flags;
6568 } ProcessorCore;
6569 struct
6571 DWORD NodeNumber;
6572 } NumaNode;
6573 CACHE_DESCRIPTOR Cache;
6574 ULONGLONG Reserved[2];
6575 } DUMMYUNIONNAME;
6576 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
6578 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6580 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6581 DWORD Size;
6582 union
6584 PROCESSOR_RELATIONSHIP Processor;
6585 NUMA_NODE_RELATIONSHIP NumaNode;
6586 CACHE_RELATIONSHIP Cache;
6587 GROUP_RELATIONSHIP Group;
6588 } DUMMYUNIONNAME;
6589 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
6591 typedef enum _CPU_SET_INFORMATION_TYPE
6593 CpuSetInformation,
6594 } CPU_SET_INFORMATION_TYPE, *PCPU_SET_INFORMATION_TYPE;
6596 typedef struct _SYSTEM_CPU_SET_INFORMATION
6598 DWORD Size;
6599 CPU_SET_INFORMATION_TYPE Type;
6600 union
6602 struct
6604 DWORD Id;
6605 WORD Group;
6606 BYTE LogicalProcessorIndex;
6607 BYTE CoreIndex;
6608 BYTE LastLevelCacheIndex;
6609 BYTE NumaNodeIndex;
6610 BYTE EfficiencyClass;
6611 union
6613 BYTE AllFlags;
6614 struct
6616 BYTE Parked : 1;
6617 BYTE Allocated : 1;
6618 BYTE AllocatedToTargetProcess : 1;
6619 BYTE RealTime : 1;
6620 BYTE ReservedFlags : 4;
6621 } DUMMYSTRUCTNAME;
6622 } DUMMYUNIONNAME2;
6623 union {
6624 DWORD Reserved;
6625 BYTE SchedulingClass;
6627 DWORD64 AllocationTag;
6628 } CpuSet;
6629 } DUMMYUNIONNAME;
6630 } SYSTEM_CPU_SET_INFORMATION, *PSYSTEM_CPU_SET_INFORMATION;
6632 /* Threadpool things */
6633 typedef DWORD TP_VERSION,*PTP_VERSION;
6635 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
6637 typedef VOID (CALLBACK *PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID);
6639 typedef struct _TP_POOL TP_POOL,*PTP_POOL;
6641 typedef enum _TP_CALLBACK_PRIORITY
6643 TP_CALLBACK_PRIORITY_HIGH,
6644 TP_CALLBACK_PRIORITY_NORMAL,
6645 TP_CALLBACK_PRIORITY_LOW,
6646 TP_CALLBACK_PRIORITY_INVALID,
6647 TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
6648 } TP_CALLBACK_PRIORITY;
6650 typedef struct _TP_POOL_STACK_INFORMATION
6652 SIZE_T StackReserve;
6653 SIZE_T StackCommit;
6654 } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION;
6656 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
6658 typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID,PVOID);
6660 typedef struct _TP_CALLBACK_ENVIRON_V1
6662 TP_VERSION Version;
6663 PTP_POOL Pool;
6664 PTP_CLEANUP_GROUP CleanupGroup;
6665 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6666 PVOID RaceDll;
6667 struct _ACTIVATION_CONTEXT* ActivationContext;
6668 PTP_SIMPLE_CALLBACK FinalizationCallback;
6669 union
6671 DWORD Flags;
6672 struct
6674 DWORD LongFunction:1;
6675 DWORD Persistent:1;
6676 DWORD Private:30;
6677 } s;
6678 } u;
6679 } TP_CALLBACK_ENVIRON_V1;
6681 typedef struct _TP_CALLBACK_ENVIRON_V3
6683 TP_VERSION Version;
6684 PTP_POOL Pool;
6685 PTP_CLEANUP_GROUP CleanupGroup;
6686 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6687 PVOID RaceDll;
6688 struct _ACTIVATION_CONTEXT *ActivationContext;
6689 PTP_SIMPLE_CALLBACK FinalizationCallback;
6690 union
6692 DWORD Flags;
6693 struct
6695 DWORD LongFunction:1;
6696 DWORD Persistent:1;
6697 DWORD Private:30;
6698 } s;
6699 } u;
6700 TP_CALLBACK_PRIORITY CallbackPriority;
6701 DWORD Size;
6702 } TP_CALLBACK_ENVIRON_V3;
6704 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
6705 typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
6707 typedef DWORD TP_WAIT_RESULT;
6708 typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6710 typedef struct _TP_IO TP_IO, *PTP_IO;
6712 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
6714 typedef VOID (CALLBACK *PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WORK);
6715 typedef VOID (CALLBACK *PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_TIMER);
6716 typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,TP_WAIT_RESULT);
6719 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
6720 NTSYSAPI void* NTAPI RtlPcToFileHeader(void*,void**);
6722 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6724 UmsThreadInvalidInfoClass,
6725 UmsThreadUserContext,
6726 UmsThreadPriority,
6727 UmsThreadAffinity,
6728 UmsThreadTeb,
6729 UmsThreadIsSuspended,
6730 UmsThreadIsTerminated,
6731 UmsThreadMaxInfoClass
6732 } RTL_UMS_THREAD_INFO_CLASS, *PRTL_UMS_THREAD_INFO_CLASS;
6734 typedef enum _RTL_UMS_SCHEDULER_REASON
6736 UmsSchedulerStartup,
6737 UmsSchedulerThreadBlocked,
6738 UmsSchedulerThreadYield,
6739 } RTL_UMS_SCHEDULER_REASON, *PRTL_UMS_SCHEDULER_REASON;
6741 typedef void (CALLBACK *PRTL_UMS_SCHEDULER_ENTRY_POINT)(RTL_UMS_SCHEDULER_REASON,ULONG_PTR,PVOID);
6743 typedef enum _PROCESS_MITIGATION_POLICY
6745 ProcessDEPPolicy,
6746 ProcessASLRPolicy,
6747 ProcessDynamicCodePolicy,
6748 ProcessStrictHandleCheckPolicy,
6749 ProcessSystemCallDisablePolicy,
6750 ProcessMitigationOptionsMask,
6751 ProcessExtensionPointDisablePolicy,
6752 ProcessControlFlowGuardPolicy,
6753 ProcessSignaturePolicy,
6754 ProcessFontDisablePolicy,
6755 ProcessImageLoadPolicy,
6756 ProcessSystemCallFilterPolicy,
6757 ProcessPayloadRestrictionPolicy,
6758 ProcessChildProcessPolicy,
6759 ProcessSideChannelIsolationPolicy,
6760 MaxProcessMitigationPolicy
6761 } PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY;
6763 typedef enum _FIRMWARE_TYPE
6765 FirmwareTypeUnknown,
6766 FirmwareTypeBios,
6767 FirmwareTypeUefi,
6768 FirmwareTypeMax
6769 } FIRMWARE_TYPE, *PFIRMWARE_TYPE;
6771 /* Intrinsic functions */
6773 #define BitScanForward _BitScanForward
6774 #define BitScanReverse _BitScanReverse
6775 #define InterlockedAdd _InlineInterlockedAdd
6776 #define InterlockedAnd _InterlockedAnd
6777 #define InterlockedAnd64 _InterlockedAnd64
6778 #define InterlockedCompareExchange _InterlockedCompareExchange
6779 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
6780 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
6781 #define InterlockedDecrement _InterlockedDecrement
6782 #define InterlockedDecrement16 _InterlockedDecrement16
6783 #define InterlockedDecrement64 _InterlockedDecrement64
6784 #define InterlockedExchange _InterlockedExchange
6785 #define InterlockedExchangeAdd _InterlockedExchangeAdd
6786 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
6787 #define InterlockedExchangePointer _InterlockedExchangePointer
6788 #define InterlockedIncrement _InterlockedIncrement
6789 #define InterlockedIncrement16 _InterlockedIncrement16
6790 #define InterlockedIncrement64 _InterlockedIncrement64
6791 #define InterlockedOr _InterlockedOr
6792 #define InterlockedOr64 _InterlockedOr64
6793 #define InterlockedXor _InterlockedXor
6794 #define InterlockedXor64 _InterlockedXor64
6796 #ifdef _MSC_VER
6798 #pragma intrinsic(_BitScanForward)
6799 #pragma intrinsic(_BitScanReverse)
6800 #pragma intrinsic(_InterlockedAnd)
6801 #pragma intrinsic(_InterlockedCompareExchange)
6802 #pragma intrinsic(_InterlockedCompareExchange64)
6803 #pragma intrinsic(_InterlockedCompareExchangePointer)
6804 #pragma intrinsic(_InterlockedExchange)
6805 #pragma intrinsic(_InterlockedExchangeAdd)
6806 #pragma intrinsic(_InterlockedExchangePointer)
6807 #pragma intrinsic(_InterlockedIncrement)
6808 #pragma intrinsic(_InterlockedIncrement16)
6809 #pragma intrinsic(_InterlockedDecrement)
6810 #pragma intrinsic(_InterlockedDecrement16)
6811 #pragma intrinsic(_InterlockedOr)
6812 #pragma intrinsic(_InterlockedXor)
6813 #pragma intrinsic(__fastfail)
6815 BOOLEAN _BitScanForward(unsigned long*,unsigned long);
6816 BOOLEAN _BitScanReverse(unsigned long*,unsigned long);
6817 long _InterlockedAnd(long volatile *,long);
6818 long _InterlockedCompareExchange(long volatile*,long,long);
6819 long long _InterlockedCompareExchange64(long long volatile*,long long,long long);
6820 void * _InterlockedCompareExchangePointer(void *volatile*,void*,void*);
6821 long _InterlockedDecrement(long volatile*);
6822 short _InterlockedDecrement16(short volatile*);
6823 long _InterlockedExchange(long volatile*,long);
6824 long _InterlockedExchangeAdd(long volatile*,long);
6825 void * _InterlockedExchangePointer(void *volatile*,void*);
6826 long _InterlockedIncrement(long volatile*);
6827 short _InterlockedIncrement16(short volatile*);
6828 long _InterlockedOr(long volatile *,long);
6829 long _InterlockedXor(long volatile *,long);
6830 DECLSPEC_NORETURN void __fastfail(unsigned int);
6832 #ifndef __i386__
6834 #pragma intrinsic(_InterlockedAnd64)
6835 #pragma intrinsic(_InterlockedDecrement64)
6836 #pragma intrinsic(_InterlockedExchangeAdd64)
6837 #pragma intrinsic(_InterlockedIncrement64)
6838 #pragma intrinsic(_InterlockedOr64)
6839 #pragma intrinsic(_InterlockedXor64)
6841 __int64 _InterlockedAnd64(__int64 volatile *, __int64);
6842 __int64 _InterlockedDecrement64(__int64 volatile *);
6843 __int64 _InterlockedExchangeAdd64(__int64 volatile *, __int64);
6844 __int64 _InterlockedIncrement64(__int64 volatile *);
6845 __int64 _InterlockedOr64(__int64 volatile *, __int64);
6846 __int64 _InterlockedXor64(__int64 volatile *, __int64);
6848 #else
6850 static FORCEINLINE __int64 InterlockedAnd64( __int64 volatile *dest, __int64 val )
6852 __int64 prev;
6853 do prev = *dest; while (InterlockedCompareExchange64( dest, prev & val, prev ) != prev);
6854 return prev;
6857 static FORCEINLINE __int64 InterlockedExchangeAdd64( __int64 volatile *dest, __int64 val )
6859 __int64 prev;
6860 do prev = *dest; while (InterlockedCompareExchange64( dest, prev + val, prev ) != prev);
6861 return prev;
6864 static FORCEINLINE __int64 InterlockedIncrement64( __int64 volatile *dest )
6866 return InterlockedExchangeAdd64( dest, 1 ) + 1;
6869 static FORCEINLINE __int64 InterlockedDecrement64( __int64 volatile *dest )
6871 return InterlockedExchangeAdd64( dest, -1 ) - 1;
6874 static FORCEINLINE __int64 InterlockedOr64( __int64 volatile *dest, __int64 val )
6876 __int64 prev;
6877 do prev = *dest; while (InterlockedCompareExchange64( dest, prev | val, prev ) != prev);
6878 return prev;
6881 static FORCEINLINE __int64 InterlockedXor64( __int64 volatile *dest, __int64 val )
6883 __int64 prev;
6884 do prev = *dest; while (InterlockedCompareExchange64( dest, prev ^ val, prev ) != prev);
6885 return prev;
6888 #endif /* __i386__ */
6890 static FORCEINLINE long InterlockedAdd( long volatile *dest, long val )
6892 return InterlockedExchangeAdd( dest, val ) + val;
6895 static FORCEINLINE __int64 InterlockedAdd64( __int64 volatile *dest, __int64 val )
6897 return InterlockedExchangeAdd64( dest, val ) + val;
6900 #ifdef __i386__
6902 static FORCEINLINE void MemoryBarrier(void)
6904 LONG dummy;
6905 InterlockedOr(&dummy, 0);
6908 #elif defined(__x86_64__)
6910 #pragma intrinsic(__faststorefence)
6911 void __faststorefence(void);
6913 static FORCEINLINE void MemoryBarrier(void)
6915 __faststorefence();
6918 #elif defined(__arm__)
6920 static FORCEINLINE void MemoryBarrier(void)
6922 __dmb(_ARM_BARRIER_SY);
6925 #elif defined(__aarch64__)
6927 static FORCEINLINE void MemoryBarrier(void)
6929 __dmb(_ARM64_BARRIER_SY);
6932 #endif /* __i386__ */
6934 /* Since Visual Studio 2012, volatile accesses do not always imply acquire and
6935 * release semantics. We explicitly use ISO volatile semantics, manually
6936 * placing barriers as appropriate.
6938 #if _MSC_VER >= 1700
6939 #pragma intrinsic(__iso_volatile_load32)
6940 #pragma intrinsic(__iso_volatile_store32)
6941 #define __WINE_LOAD32_NO_FENCE(src) (__iso_volatile_load32(src))
6942 #define __WINE_STORE32_NO_FENCE(dest, value) (__iso_volatile_store32(dest, value))
6943 #else /* _MSC_VER >= 1700 */
6944 #define __WINE_LOAD32_NO_FENCE(src) (*(src))
6945 #define __WINE_STORE32_NO_FENCE(dest, value) ((void)(*(dest) = (value)))
6946 #endif /* _MSC_VER >= 1700 */
6948 #if defined(__i386__) || defined(__x86_64__)
6949 #pragma intrinsic(_ReadWriteBarrier)
6950 void _ReadWriteBarrier(void);
6951 #endif /* defined(__i386__) || defined(__x86_64__) */
6953 static void __wine_memory_barrier_acq_rel(void)
6955 #if defined(__i386__) || defined(__x86_64__)
6956 #pragma warning(suppress:4996)
6957 _ReadWriteBarrier();
6958 #elif defined(__arm__)
6959 __dmb(_ARM_BARRIER_ISH);
6960 #elif defined(__aarch64__)
6961 __dmb(_ARM64_BARRIER_ISH);
6962 #endif /* defined(__i386__) || defined(__x86_64__) */
6965 static FORCEINLINE LONG ReadAcquire( LONG const volatile *src )
6967 LONG value = __WINE_LOAD32_NO_FENCE( (int const volatile *)src );
6968 __wine_memory_barrier_acq_rel();
6969 return value;
6972 static FORCEINLINE LONG ReadNoFence( LONG const volatile *src )
6974 LONG value = __WINE_LOAD32_NO_FENCE( (int const volatile *)src );
6975 return value;
6978 static FORCEINLINE void WriteRelease( LONG volatile *dest, LONG value )
6980 __wine_memory_barrier_acq_rel();
6981 __WINE_STORE32_NO_FENCE( (int volatile *)dest, value );
6984 static FORCEINLINE void WriteNoFence( LONG volatile *dest, LONG value )
6986 __WINE_STORE32_NO_FENCE( (int volatile *)dest, value );
6989 #elif defined(__GNUC__)
6991 static FORCEINLINE BOOLEAN WINAPI BitScanForward(DWORD *index, DWORD mask)
6993 *index = __builtin_ctz( mask );
6994 return mask != 0;
6997 static FORCEINLINE BOOLEAN WINAPI BitScanReverse(DWORD *index, DWORD mask)
6999 *index = 31 - __builtin_clz( mask );
7000 return mask != 0;
7003 static FORCEINLINE LONG WINAPI InterlockedAdd( LONG volatile *dest, LONG val )
7005 return __sync_add_and_fetch( dest, val );
7008 static FORCEINLINE LONGLONG WINAPI InterlockedAdd64( LONGLONG volatile *dest, LONGLONG val )
7010 return __sync_add_and_fetch( dest, val );
7013 static FORCEINLINE LONG WINAPI InterlockedAnd( LONG volatile *dest, LONG val )
7015 return __sync_fetch_and_and( dest, val );
7018 static FORCEINLINE LONGLONG WINAPI InterlockedAnd64( LONGLONG volatile *dest, LONGLONG val )
7020 return __sync_fetch_and_and( dest, val );
7023 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
7025 return __sync_val_compare_and_swap( dest, compare, xchg );
7028 static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
7030 return __sync_val_compare_and_swap( dest, compare, xchg );
7033 static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
7035 return __sync_val_compare_and_swap( dest, compare, xchg );
7038 static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
7040 LONG ret;
7041 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
7042 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
7043 #elif defined(__i386__) || defined(__x86_64__)
7044 __asm__ __volatile__( "lock; xchgl %0,(%1)"
7045 : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
7046 #else
7047 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
7048 #endif
7049 return ret;
7052 static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
7054 return __sync_fetch_and_add( dest, incr );
7057 static FORCEINLINE LONGLONG WINAPI InterlockedExchangeAdd64( LONGLONG volatile *dest, LONGLONG incr )
7059 return __sync_fetch_and_add( dest, incr );
7062 static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
7064 return __sync_add_and_fetch( dest, 1 );
7067 static FORCEINLINE short WINAPI InterlockedIncrement16( short volatile *dest )
7069 return __sync_add_and_fetch( dest, 1 );
7072 static FORCEINLINE LONGLONG WINAPI InterlockedIncrement64( LONGLONG volatile *dest )
7074 return __sync_add_and_fetch( dest, 1 );
7077 static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
7079 return __sync_add_and_fetch( dest, -1 );
7082 static FORCEINLINE short WINAPI InterlockedDecrement16( short volatile *dest )
7084 return __sync_add_and_fetch( dest, -1 );
7087 static FORCEINLINE LONGLONG WINAPI InterlockedDecrement64( LONGLONG volatile *dest )
7089 return __sync_add_and_fetch( dest, -1 );
7092 static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
7094 void *ret;
7095 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
7096 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
7097 #elif defined(__x86_64__)
7098 __asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
7099 #elif defined(__i386__)
7100 __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
7101 #else
7102 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
7103 #endif
7104 return ret;
7107 static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val )
7109 return __sync_fetch_and_or( dest, val );
7112 static FORCEINLINE LONGLONG WINAPI InterlockedOr64( LONGLONG volatile *dest, LONGLONG val )
7114 return __sync_fetch_and_or( dest, val );
7117 static FORCEINLINE LONG WINAPI InterlockedXor( LONG volatile *dest, LONG val )
7119 return __sync_fetch_and_xor( dest, val );
7122 static FORCEINLINE LONGLONG WINAPI InterlockedXor64( LONGLONG volatile *dest, LONGLONG val )
7124 return __sync_fetch_and_xor( dest, val );
7127 static FORCEINLINE void MemoryBarrier(void)
7129 __sync_synchronize();
7132 #if defined(__x86_64__) || defined(__i386__)
7133 /* On x86, Support old GCC with either no or buggy (GCC BZ#81316) __atomic_* support */
7134 #define __WINE_ATOMIC_LOAD_ACQUIRE(ptr, ret) do { *(ret) = *(ptr); __asm__ __volatile__( "" ::: "memory" ); } while (0)
7135 #define __WINE_ATOMIC_LOAD_RELAXED(ptr, ret) do { *(ret) = *(ptr); } while (0)
7136 #define __WINE_ATOMIC_STORE_RELEASE(ptr, val) do { __asm__ __volatile__( "" ::: "memory" ); *(ptr) = *(val); } while (0)
7137 #define __WINE_ATOMIC_STORE_RELAXED(ptr, val) do { *(ptr) = *(val); } while (0)
7138 #else
7139 #define __WINE_ATOMIC_LOAD_ACQUIRE(ptr, ret) __atomic_load(ptr, ret, __ATOMIC_ACQUIRE)
7140 #define __WINE_ATOMIC_LOAD_RELAXED(ptr, ret) __atomic_load(ptr, ret, __ATOMIC_RELAXED)
7141 #define __WINE_ATOMIC_STORE_RELEASE(ptr, val) __atomic_store(ptr, val, __ATOMIC_RELEASE)
7142 #define __WINE_ATOMIC_STORE_RELAXED(ptr, val) __atomic_store(ptr, val, __ATOMIC_RELAXED)
7143 #endif /* defined(__x86_64__) || defined(__i386__) */
7145 static FORCEINLINE LONG ReadAcquire( LONG const volatile *src )
7147 LONG value;
7148 __WINE_ATOMIC_LOAD_ACQUIRE( src, &value );
7149 return value;
7152 static FORCEINLINE LONG ReadNoFence( LONG const volatile *src )
7154 LONG value;
7155 __WINE_ATOMIC_LOAD_RELAXED( src, &value );
7156 return value;
7159 static FORCEINLINE void WriteRelease( LONG volatile *dest, LONG value )
7161 __WINE_ATOMIC_STORE_RELEASE( dest, &value );
7164 static FORCEINLINE void WriteNoFence( LONG volatile *dest, LONG value )
7166 __WINE_ATOMIC_STORE_RELAXED( dest, &value );
7169 static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code)
7171 #if defined(__x86_64__) || defined(__i386__)
7172 for (;;) __asm__ __volatile__( "int $0x29" :: "c" ((ULONG_PTR)code) : "memory" );
7173 #elif defined(__aarch64__)
7174 register ULONG_PTR val __asm__("x0") = code;
7175 for (;;) __asm__ __volatile__( "brk #0xf003" :: "r" (val) : "memory" );
7176 #elif defined(__arm__)
7177 register ULONG_PTR val __asm__("r0") = code;
7178 for (;;) __asm__ __volatile__( "udf #0xfb" :: "r" (val) : "memory" );
7179 #endif
7182 #endif /* __GNUC__ */
7184 #ifdef _WIN64
7186 #define InterlockedCompareExchange128 _InterlockedCompareExchange128
7188 #if defined(_MSC_VER) && !defined(__clang__)
7190 #pragma intrinsic(_InterlockedCompareExchange128)
7191 unsigned char _InterlockedCompareExchange128(volatile __int64 *, __int64, __int64, __int64 *);
7193 #else
7195 static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64 *dest, __int64 xchg_high, __int64 xchg_low, __int64 *compare )
7197 #ifdef __x86_64__
7198 unsigned char ret;
7199 __asm__ __volatile__( "lock cmpxchg16b %0; setz %b2"
7200 : "=m" (dest[0]), "=m" (dest[1]), "=r" (ret),
7201 "=a" (compare[0]), "=d" (compare[1])
7202 : "m" (dest[0]), "m" (dest[1]), "3" (compare[0]), "4" (compare[1]),
7203 "c" (xchg_high), "b" (xchg_low) );
7204 return ret;
7205 #else
7206 return __sync_bool_compare_and_swap( (__int128 *)dest, *(__int128 *)compare, ((__int128)xchg_high << 64) | xchg_low );
7207 #endif
7210 #endif
7212 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONGLONG *)(a))
7213 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)(a), (b))
7214 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)(a))
7216 #else /* _WIN64 */
7218 #define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)(a))
7219 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)(a), (b))
7220 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)(a))
7222 #endif /* _WIN64 */
7224 static FORCEINLINE void YieldProcessor(void)
7226 #ifdef __GNUC__
7227 #if defined(__i386__) || defined(__x86_64__)
7228 __asm__ __volatile__( "rep; nop" : : : "memory" );
7229 #elif defined(__arm__) || defined(__aarch64__)
7230 __asm__ __volatile__( "dmb ishst\n\tyield" : : : "memory" );
7231 #else
7232 __asm__ __volatile__( "" : : : "memory" );
7233 #endif
7234 #endif
7237 #ifdef __cplusplus
7239 #endif
7241 #endif /* _WINNT_ */