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