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