mfreadwrite/reader: Only attempt to copy sample buffers from responses with non-NULL...
[wine.git] / include / winnt.h
blob76aee026d84c1cf7b5a19756529e9a8bfe8d57e0
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 #define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
764 typedef enum MEM_EXTENDED_PARAMETER_TYPE {
765 MemExtendedParameterInvalidType = 0,
766 MemExtendedParameterAddressRequirements,
767 MemExtendedParameterNumaNode,
768 MemExtendedParameterPartitionHandle,
769 MemExtendedParameterUserPhysicalHandle,
770 MemExtendedParameterAttributeFlags,
771 MemExtendedParameterMax
772 } MEM_EXTENDED_PARAMETER_TYPE, *PMEM_EXTENDED_PARAMETER_TYPE;
774 typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER {
775 struct
777 DWORD64 Type : MEM_EXTENDED_PARAMETER_TYPE_BITS;
778 DWORD64 Reserved : 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS;
779 } DUMMYSTRUCTNAME;
781 union
783 DWORD64 ULong64;
784 PVOID Pointer;
785 SIZE_T Size;
786 HANDLE Handle;
787 DWORD ULong;
788 } DUMMYUNIONNAME;
789 } MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;
791 #define PAGE_NOACCESS 0x01
792 #define PAGE_READONLY 0x02
793 #define PAGE_READWRITE 0x04
794 #define PAGE_WRITECOPY 0x08
795 #define PAGE_EXECUTE 0x10
796 #define PAGE_EXECUTE_READ 0x20
797 #define PAGE_EXECUTE_READWRITE 0x40
798 #define PAGE_EXECUTE_WRITECOPY 0x80
799 #define PAGE_GUARD 0x100
800 #define PAGE_NOCACHE 0x200
801 #define PAGE_WRITECOMBINE 0x400
803 #define MEM_COMMIT 0x00001000
804 #define MEM_RESERVE 0x00002000
805 #define MEM_REPLACE_PLACEHOLDER 0x00004000
806 #define MEM_RESERVE_PLACEHOLDER 0x00040000
807 #define MEM_RESET 0x00080000
808 #define MEM_TOP_DOWN 0x00100000
809 #define MEM_PHYSICAL 0x00400000
810 #define MEM_RESET_UNDO 0x10000000
811 #define MEM_LARGE_PAGES 0x20000000
813 #define MEM_COALESCE_PLACEHOLDERS 0x00000001
814 #define MEM_PRESERVE_PLACEHOLDER 0x00000002
815 #define MEM_DECOMMIT 0x00004000
816 #define MEM_RELEASE 0x00008000
818 #define MEM_FREE 0x00010000
819 #define MEM_PRIVATE 0x00020000
820 #define MEM_MAPPED 0x00040000
821 #define MEM_WRITE_WATCH 0x00200000
822 #define MEM_4MB_PAGES 0x80000000
824 #define SEC_FILE 0x00800000
825 #define SEC_IMAGE 0x01000000
826 #define SEC_PROTECTED_IMAGE 0x02000000
827 #define SEC_RESERVE 0x04000000
828 #define SEC_COMMIT 0x08000000
829 #define SEC_NOCACHE 0x10000000
830 #define SEC_WRITECOMBINE 0x40000000
831 #define SEC_LARGE_PAGES 0x80000000
832 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
833 #define MEM_IMAGE SEC_IMAGE
835 #define WRITE_WATCH_FLAG_RESET 0x00000001
837 #define AT_ROUND_TO_PAGE 0x40000000
839 #define MINCHAR 0x80
840 #define MAXCHAR 0x7f
841 #define MINSHORT 0x8000
842 #define MAXSHORT 0x7fff
843 #define MINLONG 0x80000000
844 #define MAXLONG 0x7fffffff
845 #define MAXBYTE 0xff
846 #define MAXWORD 0xffff
847 #define MAXDWORD 0xffffffff
848 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
850 #define UNICODE_STRING_MAX_CHARS 32767
852 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
853 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
854 #define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
856 #define CONTAINING_RECORD(address, type, field) \
857 ((type *)((PCHAR)(address) - offsetof(type, field)))
859 #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
860 #ifdef __WINESRC__
861 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
862 #endif
864 /* Types */
866 typedef struct _LIST_ENTRY {
867 struct _LIST_ENTRY *Flink;
868 struct _LIST_ENTRY *Blink;
869 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
871 typedef struct _SINGLE_LIST_ENTRY {
872 struct _SINGLE_LIST_ENTRY *Next;
873 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
875 #ifdef _WIN64
877 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
878 struct _SLIST_ENTRY *Next;
879 } SLIST_ENTRY, *PSLIST_ENTRY;
881 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
882 struct {
883 ULONGLONG Alignment;
884 ULONGLONG Region;
885 } DUMMYSTRUCTNAME;
886 struct {
887 ULONGLONG Depth:16;
888 ULONGLONG Sequence:9;
889 ULONGLONG NextEntry:39;
890 ULONGLONG HeaderType:1;
891 ULONGLONG Init:1;
892 ULONGLONG Reserved:59;
893 ULONGLONG Region:3;
894 } Header8;
895 struct {
896 ULONGLONG Depth:16;
897 ULONGLONG Sequence:48;
898 ULONGLONG HeaderType:1;
899 ULONGLONG Init:1;
900 ULONGLONG Reserved:2;
901 ULONGLONG NextEntry:60;
902 } Header16;
903 } SLIST_HEADER, *PSLIST_HEADER;
905 #else
907 #undef SLIST_ENTRY /* for Mac OS */
908 #define SLIST_ENTRY SINGLE_LIST_ENTRY
909 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
910 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
912 typedef union _SLIST_HEADER {
913 ULONGLONG Alignment;
914 struct {
915 SLIST_ENTRY Next;
916 WORD Depth;
917 WORD Sequence;
918 } DUMMYSTRUCTNAME;
919 } SLIST_HEADER, *PSLIST_HEADER;
921 #endif
923 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
924 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
925 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
926 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
927 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
928 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
931 /* Fast fail (__fastfail) codes */
933 #define FAST_FAIL_LEGACY_GS_VIOLATION 0
934 #define FAST_FAIL_VTGUARD_CHECK_FAILURE 1
935 #define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2
936 #define FAST_FAIL_CORRUPT_LIST_ENTRY 3
937 #define FAST_FAIL_INCORRECT_STACK 4
938 #define FAST_FAIL_INVALID_ARG 5
939 #define FAST_FAIL_GS_COOKIE_INIT 6
940 #define FAST_FAIL_FATAL_APP_EXIT 7
941 #define FAST_FAIL_RANGE_CHECK_FAILURE 8
942 #define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9
943 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10
944 #define FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11
945 #define FAST_FAIL_INVALID_FIBER_SWITCH 12
946 #define FAST_FAIL_INVALID_SET_OF_CONTEXT 13
947 #define FAST_FAIL_INVALID_REFERENCE_COUNT 14
948 #define FAST_FAIL_INVALID_JUMP_BUFFER 18
949 #define FAST_FAIL_MRDATA_MODIFIED 19
950 #define FAST_FAIL_CERTIFICATION_FAILURE 20
951 #define FAST_FAIL_INVALID_EXCEPTION_CHAIN 21
952 #define FAST_FAIL_CRYPTO_LIBRARY 22
953 #define FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT 23
954 #define FAST_FAIL_INVALID_IMAGE_BASE 24
955 #define FAST_FAIL_DLOAD_PROTECTION_FAILURE 25
956 #define FAST_FAIL_UNSAFE_EXTENSION_CALL 26
957 #define FAST_FAIL_DEPRECATED_SERVICE_INVOKED 27
958 #define FAST_FAIL_INVALID_BUFFER_ACCESS 28
959 #define FAST_FAIL_INVALID_BALANCED_TREE 29
960 #define FAST_FAIL_INVALID_NEXT_THREAD 30
961 #define FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED 31
962 #define FAST_FAIL_APCS_DISABLED 32
963 #define FAST_FAIL_INVALID_IDLE_STATE 33
964 #define FAST_FAIL_MRDATA_PROTECTION_FAILURE 34
965 #define FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION 35
966 #define FAST_FAIL_INVALID_LOCK_STATE 36
967 #define FAST_FAIL_GUARD_JUMPTABLE 37
968 #define FAST_FAIL_INVALID_LONGJUMP_TARGET 38
969 #define FAST_FAIL_INVALID_DISPATCH_CONTEXT 39
970 #define FAST_FAIL_INVALID_THREAD 40
971 #define FAST_FAIL_INVALID_SYSCALL_NUMBER 41
972 #define FAST_FAIL_INVALID_FILE_OPERATION 42
973 #define FAST_FAIL_LPAC_ACCESS_DENIED 43
974 #define FAST_FAIL_GUARD_SS_FAILURE 44
975 #define FAST_FAIL_LOADER_CONTINUITY_FAILURE 45
976 #define FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE 46
977 #define FAST_FAIL_INVALID_CONTROL_STACK 47
978 #define FAST_FAIL_SET_CONTEXT_DENIED 48
979 #define FAST_FAIL_INVALID_IAT 49
980 #define FAST_FAIL_HEAP_METADATA_CORRUPTION 50
981 #define FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION 51
982 #define FAST_FAIL_LOW_LABEL_ACCESS_DENIED 52
983 #define FAST_FAIL_ENCLAVE_CALL_FAILURE 53
984 #define FAST_FAIL_UNHANDLED_LSS_EXCEPTON 54
985 #define FAST_FAIL_ADMINLESS_ACCESS_DENIED 55
986 #define FAST_FAIL_UNEXPECTED_CALL 56
987 #define FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS 57
988 #define FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR 58
989 #define FAST_FAIL_FLAGS_CORRUPTION 59
990 #define FAST_FAIL_VEH_CORRUPTION 60
991 #define FAST_FAIL_ETW_CORRUPTION 61
992 #define FAST_FAIL_RIO_ABORT 62
993 #define FAST_FAIL_INVALID_PFN 63
994 #define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE_XFG 64
995 #define FAST_FAIL_CAST_GUARD 65
996 #define FAST_FAIL_HOST_VISIBILITY_CHANGE 66
997 #define FAST_FAIL_KERNEL_CET_SHADOW_STACK_ASSIST 67
998 #define FAST_FAIL_PATCH_CALLBACK_FAILED 68
999 #define FAST_FAIL_NTDLL_PATCH_FAILED 69
1000 #define FAST_FAIL_INVALID_FLS_DATA 70
1001 #define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xFFFFFFFF
1003 /* Heap flags */
1005 #define HEAP_NO_SERIALIZE 0x00000001
1006 #define HEAP_GROWABLE 0x00000002
1007 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
1008 #define HEAP_ZERO_MEMORY 0x00000008
1009 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
1010 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
1011 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
1012 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
1013 #define HEAP_CREATE_ALIGN_16 0x00010000
1014 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
1015 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
1017 /* This flag allows it to create heaps shared by all processes under win95,
1018 FIXME: correct name */
1019 #define HEAP_SHARED 0x04000000
1021 typedef enum _HEAP_INFORMATION_CLASS {
1022 HeapCompatibilityInformation,
1023 } HEAP_INFORMATION_CLASS;
1025 /* Processor feature flags. */
1026 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
1027 #define PF_FLOATING_POINT_EMULATED 1
1028 #define PF_COMPARE_EXCHANGE_DOUBLE 2
1029 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
1030 #define PF_PPC_MOVEMEM_64BIT_OK 4
1031 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
1032 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
1033 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
1034 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
1035 #define PF_PAE_ENABLED 9
1036 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
1037 #define PF_SSE_DAZ_MODE_AVAILABLE 11
1038 #define PF_NX_ENABLED 12
1039 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
1040 #define PF_COMPARE_EXCHANGE128 14
1041 #define PF_COMPARE64_EXCHANGE128 15
1042 #define PF_CHANNELS_ENABLED 16
1043 #define PF_XSAVE_ENABLED 17
1044 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
1045 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
1046 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
1047 #define PF_VIRT_FIRMWARE_ENABLED 21
1048 #define PF_RDWRFSGSBASE_AVAILABLE 22
1049 #define PF_FASTFAIL_AVAILABLE 23
1050 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
1051 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
1052 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
1053 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
1054 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
1055 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
1056 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
1057 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
1058 #define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
1059 #define PF_RDPID_INSTRUCTION_AVAILABLE 33
1060 #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
1061 #define PF_MONITORX_INSTRUCTION_AVAILABLE 35
1062 #define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
1063 #define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
1064 #define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
1065 #define PF_AVX_INSTRUCTIONS_AVAILABLE 39
1066 #define PF_AVX2_INSTRUCTIONS_AVAILABLE 40
1067 #define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
1070 /* Execution state flags */
1071 #define ES_SYSTEM_REQUIRED 0x00000001
1072 #define ES_DISPLAY_REQUIRED 0x00000002
1073 #define ES_USER_PRESENT 0x00000004
1074 #define ES_CONTINUOUS 0x80000000
1076 #include <excpt.h>
1078 /* The Win32 register context */
1080 /* i386 context definitions */
1082 #define I386_SIZE_OF_80387_REGISTERS 80
1084 typedef struct _I386_FLOATING_SAVE_AREA
1086 DWORD ControlWord;
1087 DWORD StatusWord;
1088 DWORD TagWord;
1089 DWORD ErrorOffset;
1090 DWORD ErrorSelector;
1091 DWORD DataOffset;
1092 DWORD DataSelector;
1093 BYTE RegisterArea[I386_SIZE_OF_80387_REGISTERS];
1094 DWORD Cr0NpxState;
1095 } I386_FLOATING_SAVE_AREA, WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
1097 #define I386_MAXIMUM_SUPPORTED_EXTENSION 512
1099 #include "pshpack4.h"
1100 typedef struct _I386_CONTEXT
1102 DWORD ContextFlags; /* 000 */
1104 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1105 DWORD Dr0; /* 004 */
1106 DWORD Dr1; /* 008 */
1107 DWORD Dr2; /* 00c */
1108 DWORD Dr3; /* 010 */
1109 DWORD Dr6; /* 014 */
1110 DWORD Dr7; /* 018 */
1112 /* These are selected by CONTEXT_FLOATING_POINT */
1113 I386_FLOATING_SAVE_AREA FloatSave; /* 01c */
1115 /* These are selected by CONTEXT_SEGMENTS */
1116 DWORD SegGs; /* 08c */
1117 DWORD SegFs; /* 090 */
1118 DWORD SegEs; /* 094 */
1119 DWORD SegDs; /* 098 */
1121 /* These are selected by CONTEXT_INTEGER */
1122 DWORD Edi; /* 09c */
1123 DWORD Esi; /* 0a0 */
1124 DWORD Ebx; /* 0a4 */
1125 DWORD Edx; /* 0a8 */
1126 DWORD Ecx; /* 0ac */
1127 DWORD Eax; /* 0b0 */
1129 /* These are selected by CONTEXT_CONTROL */
1130 DWORD Ebp; /* 0b4 */
1131 DWORD Eip; /* 0b8 */
1132 DWORD SegCs; /* 0bc */
1133 DWORD EFlags; /* 0c0 */
1134 DWORD Esp; /* 0c4 */
1135 DWORD SegSs; /* 0c8 */
1137 BYTE ExtendedRegisters[I386_MAXIMUM_SUPPORTED_EXTENSION]; /* 0xcc */
1138 } I386_CONTEXT, WOW64_CONTEXT, *PWOW64_CONTEXT;
1139 #include "poppack.h"
1141 #define CONTEXT_i386 0x00010000
1142 #define CONTEXT_i486 0x00010000
1144 #define CONTEXT_I386_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1145 #define CONTEXT_I386_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1146 #define CONTEXT_I386_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1147 #define CONTEXT_I386_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1148 #define CONTEXT_I386_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1149 #define CONTEXT_I386_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1150 #define CONTEXT_I386_XSTATE (CONTEXT_i386 | 0x0040)
1151 #define CONTEXT_I386_FULL (CONTEXT_I386_CONTROL | CONTEXT_I386_INTEGER | CONTEXT_I386_SEGMENTS)
1152 #define CONTEXT_I386_ALL (CONTEXT_I386_FULL | CONTEXT_I386_FLOATING_POINT | CONTEXT_I386_DEBUG_REGISTERS | CONTEXT_I386_EXTENDED_REGISTERS)
1154 #ifdef __i386__
1156 #define CONTEXT_CONTROL CONTEXT_I386_CONTROL
1157 #define CONTEXT_INTEGER CONTEXT_I386_INTEGER
1158 #define CONTEXT_SEGMENTS CONTEXT_I386_SEGMENTS
1159 #define CONTEXT_FLOATING_POINT CONTEXT_I386_FLOATING_POINT
1160 #define CONTEXT_DEBUG_REGISTERS CONTEXT_I386_DEBUG_REGISTERS
1161 #define CONTEXT_EXTENDED_REGISTERS CONTEXT_I386_EXTENDED_REGISTERS
1162 #define CONTEXT_XSTATE CONTEXT_I386_XSTATE
1163 #define CONTEXT_FULL CONTEXT_I386_FULL
1164 #define CONTEXT_ALL CONTEXT_I386_ALL
1165 #define SIZE_OF_80387_REGISTERS I386_SIZE_OF_80387_REGISTERS
1166 #define MAXIMUM_SUPPORTED_EXTENSION I386_MAXIMUM_SUPPORTED_EXTENSION
1168 typedef I386_FLOATING_SAVE_AREA FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1169 typedef I386_CONTEXT CONTEXT, *PCONTEXT;
1171 #endif /* __i386__ */
1173 typedef struct _LDT_ENTRY {
1174 WORD LimitLow;
1175 WORD BaseLow;
1176 union {
1177 struct {
1178 BYTE BaseMid;
1179 BYTE Flags1;
1180 BYTE Flags2;
1181 BYTE BaseHi;
1182 } Bytes;
1183 struct {
1184 unsigned BaseMid: 8;
1185 unsigned Type : 5;
1186 unsigned Dpl : 2;
1187 unsigned Pres : 1;
1188 unsigned LimitHi : 4;
1189 unsigned Sys : 1;
1190 unsigned Reserved_0 : 1;
1191 unsigned Default_Big : 1;
1192 unsigned Granularity : 1;
1193 unsigned BaseHi : 8;
1194 } Bits;
1195 } HighWord;
1196 } LDT_ENTRY, *PLDT_ENTRY, WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
1198 typedef struct DECLSPEC_ALIGN(16) _M128A {
1199 ULONGLONG Low;
1200 LONGLONG High;
1201 } M128A, *PM128A;
1203 typedef struct _XSAVE_FORMAT {
1204 WORD ControlWord; /* 000 */
1205 WORD StatusWord; /* 002 */
1206 BYTE TagWord; /* 004 */
1207 BYTE Reserved1; /* 005 */
1208 WORD ErrorOpcode; /* 006 */
1209 DWORD ErrorOffset; /* 008 */
1210 WORD ErrorSelector; /* 00c */
1211 WORD Reserved2; /* 00e */
1212 DWORD DataOffset; /* 010 */
1213 WORD DataSelector; /* 014 */
1214 WORD Reserved3; /* 016 */
1215 DWORD MxCsr; /* 018 */
1216 DWORD MxCsr_Mask; /* 01c */
1217 M128A FloatRegisters[8]; /* 020 */
1218 M128A XmmRegisters[16]; /* 0a0 */
1219 BYTE Reserved4[96]; /* 1a0 */
1220 } XSAVE_FORMAT, *PXSAVE_FORMAT;
1222 /* x86-64 context definitions */
1224 typedef struct _AMD64_RUNTIME_FUNCTION
1226 DWORD BeginAddress;
1227 DWORD EndAddress;
1228 DWORD UnwindData;
1229 } AMD64_RUNTIME_FUNCTION;
1231 #define CONTEXT_AMD64 0x00100000
1233 #define CONTEXT_AMD64_CONTROL (CONTEXT_AMD64 | 0x0001)
1234 #define CONTEXT_AMD64_INTEGER (CONTEXT_AMD64 | 0x0002)
1235 #define CONTEXT_AMD64_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1236 #define CONTEXT_AMD64_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1237 #define CONTEXT_AMD64_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1238 #define CONTEXT_AMD64_XSTATE (CONTEXT_AMD64 | 0x0040)
1239 #define CONTEXT_AMD64_FULL (CONTEXT_AMD64_CONTROL | CONTEXT_AMD64_INTEGER | CONTEXT_AMD64_FLOATING_POINT)
1240 #define CONTEXT_AMD64_ALL (CONTEXT_AMD64_CONTROL | CONTEXT_AMD64_INTEGER | CONTEXT_AMD64_SEGMENTS | CONTEXT_AMD64_FLOATING_POINT | CONTEXT_AMD64_DEBUG_REGISTERS)
1242 typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1244 typedef struct DECLSPEC_ALIGN(16) _AMD64_CONTEXT {
1245 DWORD64 P1Home; /* 000 */
1246 DWORD64 P2Home; /* 008 */
1247 DWORD64 P3Home; /* 010 */
1248 DWORD64 P4Home; /* 018 */
1249 DWORD64 P5Home; /* 020 */
1250 DWORD64 P6Home; /* 028 */
1252 /* Control flags */
1253 DWORD ContextFlags; /* 030 */
1254 DWORD MxCsr; /* 034 */
1256 /* Segment */
1257 WORD SegCs; /* 038 */
1258 WORD SegDs; /* 03a */
1259 WORD SegEs; /* 03c */
1260 WORD SegFs; /* 03e */
1261 WORD SegGs; /* 040 */
1262 WORD SegSs; /* 042 */
1263 DWORD EFlags; /* 044 */
1265 /* Debug */
1266 DWORD64 Dr0; /* 048 */
1267 DWORD64 Dr1; /* 050 */
1268 DWORD64 Dr2; /* 058 */
1269 DWORD64 Dr3; /* 060 */
1270 DWORD64 Dr6; /* 068 */
1271 DWORD64 Dr7; /* 070 */
1273 /* Integer */
1274 DWORD64 Rax; /* 078 */
1275 DWORD64 Rcx; /* 080 */
1276 DWORD64 Rdx; /* 088 */
1277 DWORD64 Rbx; /* 090 */
1278 DWORD64 Rsp; /* 098 */
1279 DWORD64 Rbp; /* 0a0 */
1280 DWORD64 Rsi; /* 0a8 */
1281 DWORD64 Rdi; /* 0b0 */
1282 DWORD64 R8; /* 0b8 */
1283 DWORD64 R9; /* 0c0 */
1284 DWORD64 R10; /* 0c8 */
1285 DWORD64 R11; /* 0d0 */
1286 DWORD64 R12; /* 0d8 */
1287 DWORD64 R13; /* 0e0 */
1288 DWORD64 R14; /* 0e8 */
1289 DWORD64 R15; /* 0f0 */
1291 /* Counter */
1292 DWORD64 Rip; /* 0f8 */
1294 /* Floating point */
1295 union {
1296 XMM_SAVE_AREA32 FltSave; /* 100 */
1297 struct {
1298 M128A Header[2]; /* 100 */
1299 M128A Legacy[8]; /* 120 */
1300 M128A Xmm0; /* 1a0 */
1301 M128A Xmm1; /* 1b0 */
1302 M128A Xmm2; /* 1c0 */
1303 M128A Xmm3; /* 1d0 */
1304 M128A Xmm4; /* 1e0 */
1305 M128A Xmm5; /* 1f0 */
1306 M128A Xmm6; /* 200 */
1307 M128A Xmm7; /* 210 */
1308 M128A Xmm8; /* 220 */
1309 M128A Xmm9; /* 230 */
1310 M128A Xmm10; /* 240 */
1311 M128A Xmm11; /* 250 */
1312 M128A Xmm12; /* 260 */
1313 M128A Xmm13; /* 270 */
1314 M128A Xmm14; /* 280 */
1315 M128A Xmm15; /* 290 */
1316 } DUMMYSTRUCTNAME;
1317 } DUMMYUNIONNAME;
1319 /* Vector */
1320 M128A VectorRegister[26]; /* 300 */
1321 DWORD64 VectorControl; /* 4a0 */
1323 /* Debug control */
1324 DWORD64 DebugControl; /* 4a8 */
1325 DWORD64 LastBranchToRip; /* 4b0 */
1326 DWORD64 LastBranchFromRip; /* 4b8 */
1327 DWORD64 LastExceptionToRip; /* 4c0 */
1328 DWORD64 LastExceptionFromRip; /* 4c8 */
1329 } AMD64_CONTEXT;
1331 #ifdef __x86_64__
1333 #define CONTEXT_CONTROL CONTEXT_AMD64_CONTROL
1334 #define CONTEXT_INTEGER CONTEXT_AMD64_INTEGER
1335 #define CONTEXT_SEGMENTS CONTEXT_AMD64_SEGMENTS
1336 #define CONTEXT_FLOATING_POINT CONTEXT_AMD64_FLOATING_POINT
1337 #define CONTEXT_DEBUG_REGISTERS CONTEXT_AMD64_DEBUG_REGISTERS
1338 #define CONTEXT_XSTATE CONTEXT_AMD64_XSTATE
1339 #define CONTEXT_FULL CONTEXT_AMD64_FULL
1340 #define CONTEXT_ALL CONTEXT_AMD64_ALL
1342 typedef AMD64_CONTEXT CONTEXT, *PCONTEXT;
1343 typedef AMD64_RUNTIME_FUNCTION RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1345 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1347 union
1349 PM128A FloatingContext[16];
1350 struct
1352 PM128A Xmm0;
1353 PM128A Xmm1;
1354 PM128A Xmm2;
1355 PM128A Xmm3;
1356 PM128A Xmm4;
1357 PM128A Xmm5;
1358 PM128A Xmm6;
1359 PM128A Xmm7;
1360 PM128A Xmm8;
1361 PM128A Xmm9;
1362 PM128A Xmm10;
1363 PM128A Xmm11;
1364 PM128A Xmm12;
1365 PM128A Xmm13;
1366 PM128A Xmm14;
1367 PM128A Xmm15;
1368 } DUMMYSTRUCTNAME;
1369 } DUMMYUNIONNAME;
1371 union
1373 PULONG64 IntegerContext[16];
1374 struct
1376 PULONG64 Rax;
1377 PULONG64 Rcx;
1378 PULONG64 Rdx;
1379 PULONG64 Rbx;
1380 PULONG64 Rsp;
1381 PULONG64 Rbp;
1382 PULONG64 Rsi;
1383 PULONG64 Rdi;
1384 PULONG64 R8;
1385 PULONG64 R9;
1386 PULONG64 R10;
1387 PULONG64 R11;
1388 PULONG64 R12;
1389 PULONG64 R13;
1390 PULONG64 R14;
1391 PULONG64 R15;
1392 } DUMMYSTRUCTNAME;
1393 } DUMMYUNIONNAME2;
1394 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1396 #endif /* __x86_64__ */
1398 #define XSTATE_LEGACY_FLOATING_POINT 0
1399 #define XSTATE_LEGACY_SSE 1
1400 #define XSTATE_GSSE 2
1401 #define XSTATE_AVX XSTATE_GSSE
1402 #define XSTATE_MPX_BNDREGS 3
1403 #define XSTATE_MPX_BNDCSR 4
1404 #define XSTATE_AVX512_KMASK 5
1405 #define XSTATE_AVX512_ZMM_H 6
1406 #define XSTATE_AVX512_ZMM 7
1407 #define XSTATE_IPT 8
1408 #define XSTATE_CET_U 11
1409 #define XSTATE_LWP 62
1410 #define MAXIMUM_XSTATE_FEATURES 64
1412 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1 << XSTATE_LEGACY_FLOATING_POINT)
1413 #define XSTATE_MASK_LEGACY_SSE (1 << XSTATE_LEGACY_SSE)
1414 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1415 #define XSTATE_MASK_GSSE (1 << XSTATE_GSSE)
1417 typedef struct _XSTATE_FEATURE
1419 ULONG Offset;
1420 ULONG Size;
1421 } XSTATE_FEATURE, *PXSTATE_FEATURE;
1423 typedef struct _XSTATE_CONFIGURATION
1425 ULONG64 EnabledFeatures;
1426 ULONG64 EnabledVolatileFeatures;
1427 ULONG Size;
1428 ULONG OptimizedSave:1;
1429 ULONG CompactionEnabled:1;
1430 XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
1432 ULONG64 EnabledSupervisorFeatures;
1433 ULONG64 AlignedFeatures;
1434 ULONG AllFeatureSize;
1435 ULONG AllFeatures[MAXIMUM_XSTATE_FEATURES];
1436 ULONG64 EnabledUserVisibleSupervisorFeatures;
1437 } XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION;
1439 typedef struct _YMMCONTEXT
1441 M128A Ymm0;
1442 M128A Ymm1;
1443 M128A Ymm2;
1444 M128A Ymm3;
1445 M128A Ymm4;
1446 M128A Ymm5;
1447 M128A Ymm6;
1448 M128A Ymm7;
1449 M128A Ymm8;
1450 M128A Ymm9;
1451 M128A Ymm10;
1452 M128A Ymm11;
1453 M128A Ymm12;
1454 M128A Ymm13;
1455 M128A Ymm14;
1456 M128A Ymm15;
1458 YMMCONTEXT, *PYMMCONTEXT;
1460 typedef struct _XSTATE
1462 ULONG64 Mask;
1463 ULONG64 CompactionMask;
1464 ULONG64 Reserved[6];
1465 YMMCONTEXT YmmContext;
1466 } XSTATE, *PXSTATE;
1468 typedef struct _CONTEXT_CHUNK
1470 LONG Offset;
1471 ULONG Length;
1472 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
1474 typedef struct _CONTEXT_EX
1476 CONTEXT_CHUNK All;
1477 CONTEXT_CHUNK Legacy;
1478 CONTEXT_CHUNK XState;
1479 #ifdef _WIN64
1480 ULONG64 align;
1481 #endif
1482 } CONTEXT_EX, *PCONTEXT_EX;
1484 #define CONTEXT_ARM 0x0200000
1485 #define CONTEXT_ARM_CONTROL (CONTEXT_ARM | 0x00000001)
1486 #define CONTEXT_ARM_INTEGER (CONTEXT_ARM | 0x00000002)
1487 #define CONTEXT_ARM_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1488 #define CONTEXT_ARM_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1489 #define CONTEXT_ARM_FULL (CONTEXT_ARM_CONTROL | CONTEXT_ARM_INTEGER)
1490 #define CONTEXT_ARM_ALL (CONTEXT_ARM_FULL | CONTEXT_ARM_FLOATING_POINT | CONTEXT_ARM_DEBUG_REGISTERS)
1492 #define ARM_MAX_BREAKPOINTS 8
1493 #define ARM_MAX_WATCHPOINTS 1
1495 typedef struct _IMAGE_ARM_RUNTIME_FUNCTION
1497 DWORD BeginAddress;
1498 union {
1499 DWORD UnwindData;
1500 struct {
1501 DWORD Flag : 2;
1502 DWORD FunctionLength : 11;
1503 DWORD Ret : 2;
1504 DWORD H : 1;
1505 DWORD Reg : 3;
1506 DWORD R : 1;
1507 DWORD L : 1;
1508 DWORD C : 1;
1509 DWORD StackAdjust : 10;
1510 } DUMMYSTRUCTNAME;
1511 } DUMMYUNIONNAME;
1512 } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY;
1514 typedef struct _ARM_NEON128
1516 ULONGLONG Low;
1517 LONGLONG High;
1518 } ARM_NEON128;
1520 typedef struct _ARM_CONTEXT
1522 ULONG ContextFlags; /* 000 */
1523 /* CONTEXT_INTEGER */
1524 ULONG R0; /* 004 */
1525 ULONG R1; /* 008 */
1526 ULONG R2; /* 00c */
1527 ULONG R3; /* 010 */
1528 ULONG R4; /* 014 */
1529 ULONG R5; /* 018 */
1530 ULONG R6; /* 01c */
1531 ULONG R7; /* 020 */
1532 ULONG R8; /* 024 */
1533 ULONG R9; /* 028 */
1534 ULONG R10; /* 02c */
1535 ULONG R11; /* 030 */
1536 ULONG R12; /* 034 */
1537 /* CONTEXT_CONTROL */
1538 ULONG Sp; /* 038 */
1539 ULONG Lr; /* 03c */
1540 ULONG Pc; /* 040 */
1541 ULONG Cpsr; /* 044 */
1542 /* CONTEXT_FLOATING_POINT */
1543 ULONG Fpscr; /* 048 */
1544 ULONG Padding; /* 04c */
1545 union
1547 ARM_NEON128 Q[16];
1548 ULONGLONG D[32];
1549 ULONG S[32];
1550 } DUMMYUNIONNAME; /* 050 */
1551 /* CONTEXT_DEBUG_REGISTERS */
1552 ULONG Bvr[ARM_MAX_BREAKPOINTS]; /* 150 */
1553 ULONG Bcr[ARM_MAX_BREAKPOINTS]; /* 170 */
1554 ULONG Wvr[ARM_MAX_WATCHPOINTS]; /* 190 */
1555 ULONG Wcr[ARM_MAX_WATCHPOINTS]; /* 194 */
1556 ULONG Padding2[2]; /* 198 */
1557 } ARM_CONTEXT;
1559 #ifdef __arm__
1561 #define CONTEXT_CONTROL CONTEXT_ARM_CONTROL
1562 #define CONTEXT_INTEGER CONTEXT_ARM_INTEGER
1563 #define CONTEXT_FLOATING_POINT CONTEXT_ARM_FLOATING_POINT
1564 #define CONTEXT_DEBUG_REGISTERS CONTEXT_ARM_DEBUG_REGISTERS
1565 #define CONTEXT_FULL CONTEXT_ARM_FULL
1566 #define CONTEXT_ALL CONTEXT_ARM_ALL
1568 typedef IMAGE_ARM_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1569 typedef ARM_NEON128 NEON128, *PNEON128;
1570 typedef ARM_CONTEXT CONTEXT, *PCONTEXT;
1572 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1574 PDWORD R4;
1575 PDWORD R5;
1576 PDWORD R6;
1577 PDWORD R7;
1578 PDWORD R8;
1579 PDWORD R9;
1580 PDWORD R10;
1581 PDWORD R11;
1582 PDWORD Lr;
1583 PULONGLONG D8;
1584 PULONGLONG D9;
1585 PULONGLONG D10;
1586 PULONGLONG D11;
1587 PULONGLONG D12;
1588 PULONGLONG D13;
1589 PULONGLONG D14;
1590 PULONGLONG D15;
1591 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1593 #endif /* __arm__ */
1595 #define CONTEXT_ARM64 0x400000
1596 #define CONTEXT_ARM64_CONTROL (CONTEXT_ARM64 | 0x00000001)
1597 #define CONTEXT_ARM64_INTEGER (CONTEXT_ARM64 | 0x00000002)
1598 #define CONTEXT_ARM64_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1599 #define CONTEXT_ARM64_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1600 #define CONTEXT_ARM64_X18 (CONTEXT_ARM64 | 0x00000010)
1601 #define CONTEXT_ARM64_FULL (CONTEXT_ARM64_CONTROL | CONTEXT_ARM64_INTEGER | CONTEXT_ARM64_FLOATING_POINT)
1602 #define CONTEXT_ARM64_ALL (CONTEXT_ARM64_FULL | CONTEXT_ARM64_DEBUG_REGISTERS | CONTEXT_ARM64_X18)
1604 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1606 #define ARM64_MAX_BREAKPOINTS 8
1607 #define ARM64_MAX_WATCHPOINTS 2
1609 typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY
1611 DWORD BeginAddress;
1612 union
1614 DWORD UnwindData;
1615 struct
1617 DWORD Flag : 2;
1618 DWORD FunctionLength : 11;
1619 DWORD RegF : 3;
1620 DWORD RegI : 4;
1621 DWORD H : 1;
1622 DWORD CR : 2;
1623 DWORD FrameSize : 9;
1624 } DUMMYSTRUCTNAME;
1625 } DUMMYUNIONNAME;
1626 } IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;
1628 typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY ARM64_RUNTIME_FUNCTION, *PARM64_RUNTIME_FUNCTION;
1630 typedef union _ARM64_NT_NEON128
1632 struct
1634 ULONGLONG Low;
1635 LONGLONG High;
1636 } DUMMYSTRUCTNAME;
1637 double D[2];
1638 float S[4];
1639 WORD H[8];
1640 BYTE B[16];
1641 } ARM64_NT_NEON128, *PARM64_NT_NEON128;
1643 typedef struct DECLSPEC_ALIGN(16) _ARM64_NT_CONTEXT
1645 ULONG ContextFlags; /* 000 */
1646 /* CONTEXT_INTEGER */
1647 ULONG Cpsr; /* 004 */
1648 union
1650 struct
1652 DWORD64 X0; /* 008 */
1653 DWORD64 X1; /* 010 */
1654 DWORD64 X2; /* 018 */
1655 DWORD64 X3; /* 020 */
1656 DWORD64 X4; /* 028 */
1657 DWORD64 X5; /* 030 */
1658 DWORD64 X6; /* 038 */
1659 DWORD64 X7; /* 040 */
1660 DWORD64 X8; /* 048 */
1661 DWORD64 X9; /* 050 */
1662 DWORD64 X10; /* 058 */
1663 DWORD64 X11; /* 060 */
1664 DWORD64 X12; /* 068 */
1665 DWORD64 X13; /* 070 */
1666 DWORD64 X14; /* 078 */
1667 DWORD64 X15; /* 080 */
1668 DWORD64 X16; /* 088 */
1669 DWORD64 X17; /* 090 */
1670 DWORD64 X18; /* 098 */
1671 DWORD64 X19; /* 0a0 */
1672 DWORD64 X20; /* 0a8 */
1673 DWORD64 X21; /* 0b0 */
1674 DWORD64 X22; /* 0b8 */
1675 DWORD64 X23; /* 0c0 */
1676 DWORD64 X24; /* 0c8 */
1677 DWORD64 X25; /* 0d0 */
1678 DWORD64 X26; /* 0d8 */
1679 DWORD64 X27; /* 0e0 */
1680 DWORD64 X28; /* 0e8 */
1681 DWORD64 Fp; /* 0f0 */
1682 DWORD64 Lr; /* 0f8 */
1683 } DUMMYSTRUCTNAME;
1684 DWORD64 X[31]; /* 008 */
1685 } DUMMYUNIONNAME;
1686 /* CONTEXT_CONTROL */
1687 DWORD64 Sp; /* 100 */
1688 DWORD64 Pc; /* 108 */
1689 /* CONTEXT_FLOATING_POINT */
1690 ARM64_NT_NEON128 V[32]; /* 110 */
1691 DWORD Fpcr; /* 310 */
1692 DWORD Fpsr; /* 314 */
1693 /* CONTEXT_DEBUG_REGISTERS */
1694 DWORD Bcr[ARM64_MAX_BREAKPOINTS]; /* 318 */
1695 DWORD64 Bvr[ARM64_MAX_BREAKPOINTS]; /* 338 */
1696 DWORD Wcr[ARM64_MAX_WATCHPOINTS]; /* 378 */
1697 DWORD64 Wvr[ARM64_MAX_WATCHPOINTS]; /* 380 */
1698 } ARM64_NT_CONTEXT, *PARM64_NT_CONTEXT;
1700 #ifdef __aarch64__
1702 #define CONTEXT_CONTROL CONTEXT_ARM64_CONTROL
1703 #define CONTEXT_INTEGER CONTEXT_ARM64_INTEGER
1704 #define CONTEXT_FLOATING_POINT CONTEXT_ARM64_FLOATING_POINT
1705 #define CONTEXT_DEBUG_REGISTERS CONTEXT_ARM64_DEBUG_REGISTERS
1706 #define CONTEXT_FULL CONTEXT_ARM64_FULL
1707 #define CONTEXT_ALL CONTEXT_ARM64_ALL
1709 typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1710 typedef ARM64_NT_NEON128 NEON128, *PNEON128;
1711 typedef ARM64_NT_CONTEXT CONTEXT, *PCONTEXT;
1713 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1715 PDWORD64 X19;
1716 PDWORD64 X20;
1717 PDWORD64 X21;
1718 PDWORD64 X22;
1719 PDWORD64 X23;
1720 PDWORD64 X24;
1721 PDWORD64 X25;
1722 PDWORD64 X26;
1723 PDWORD64 X27;
1724 PDWORD64 X28;
1725 PDWORD64 Fp;
1726 PDWORD64 Lr;
1727 PDWORD64 D8;
1728 PDWORD64 D9;
1729 PDWORD64 D10;
1730 PDWORD64 D11;
1731 PDWORD64 D12;
1732 PDWORD64 D13;
1733 PDWORD64 D14;
1734 PDWORD64 D15;
1735 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1737 #endif /* __aarch64__ */
1739 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1740 #error You need to define a CONTEXT for your CPU
1741 #endif
1743 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
1745 #define WOW64_CONTEXT_i386 0x00010000
1746 #define WOW64_CONTEXT_i486 0x00010000
1747 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
1748 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
1749 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
1750 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
1751 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
1752 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
1753 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
1754 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
1755 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
1756 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
1757 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
1759 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
1760 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
1761 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
1762 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
1764 #define WOW64_SIZE_OF_80387_REGISTERS 80
1765 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
1767 /* Exception definitions */
1769 #define EXCEPTION_READ_FAULT 0
1770 #define EXCEPTION_WRITE_FAULT 1
1771 #define EXCEPTION_EXECUTE_FAULT 8
1773 struct _EXCEPTION_POINTERS;
1774 struct _EXCEPTION_RECORD;
1776 typedef EXCEPTION_DISPOSITION WINAPI EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,PVOID);
1777 typedef EXCEPTION_ROUTINE *PEXCEPTION_ROUTINE;
1779 #ifdef __x86_64__
1781 #define UNWIND_HISTORY_TABLE_SIZE 12
1783 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1785 ULONG64 ImageBase;
1786 PRUNTIME_FUNCTION FunctionEntry;
1787 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1789 #define UNWIND_HISTORY_TABLE_NONE 0
1790 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1791 #define UNWIND_HISTORY_TABLE_LOCAL 2
1793 typedef struct _UNWIND_HISTORY_TABLE
1795 ULONG Count;
1796 UCHAR Search;
1797 ULONG64 LowAddress;
1798 ULONG64 HighAddress;
1799 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1800 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1802 typedef struct _DISPATCHER_CONTEXT
1804 ULONG64 ControlPc;
1805 ULONG64 ImageBase;
1806 PRUNTIME_FUNCTION FunctionEntry;
1807 ULONG64 EstablisherFrame;
1808 ULONG64 TargetIp;
1809 PCONTEXT ContextRecord;
1810 PEXCEPTION_ROUTINE LanguageHandler;
1811 PVOID HandlerData;
1812 PUNWIND_HISTORY_TABLE HistoryTable;
1813 DWORD ScopeIndex;
1814 DWORD Fill0;
1815 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1817 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,PVOID);
1818 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,PVOID);
1820 #define UNW_FLAG_NHANDLER 0
1821 #define UNW_FLAG_EHANDLER 1
1822 #define UNW_FLAG_UHANDLER 2
1823 #define UNW_FLAG_CHAININFO 4
1825 #elif defined(__arm__)
1827 #define UNWIND_HISTORY_TABLE_SIZE 12
1829 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1831 DWORD ImageBase;
1832 PRUNTIME_FUNCTION FunctionEntry;
1833 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1835 typedef struct _UNWIND_HISTORY_TABLE
1837 DWORD Count;
1838 BYTE LocalHint;
1839 BYTE GlobalHint;
1840 BYTE Search;
1841 BYTE Once;
1842 DWORD LowAddress;
1843 DWORD HighAddress;
1844 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1845 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1847 typedef struct _DISPATCHER_CONTEXT
1849 DWORD ControlPc;
1850 DWORD ImageBase;
1851 PRUNTIME_FUNCTION FunctionEntry;
1852 DWORD EstablisherFrame;
1853 DWORD TargetPc;
1854 PCONTEXT ContextRecord;
1855 PEXCEPTION_ROUTINE LanguageHandler;
1856 PVOID HandlerData;
1857 PUNWIND_HISTORY_TABLE HistoryTable;
1858 DWORD ScopeIndex;
1859 BOOLEAN ControlPcIsUnwound;
1860 PBYTE NonVolatileRegisters;
1861 DWORD Reserved;
1862 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1864 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD);
1865 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD);
1867 #define UNW_FLAG_NHANDLER 0
1868 #define UNW_FLAG_EHANDLER 1
1869 #define UNW_FLAG_UHANDLER 2
1871 #elif defined(__aarch64__)
1873 #define UNWIND_HISTORY_TABLE_SIZE 12
1875 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1877 DWORD64 ImageBase;
1878 PRUNTIME_FUNCTION FunctionEntry;
1879 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1881 typedef struct _UNWIND_HISTORY_TABLE
1883 DWORD Count;
1884 BYTE LocalHint;
1885 BYTE GlobalHint;
1886 BYTE Search;
1887 BYTE Once;
1888 DWORD64 LowAddress;
1889 DWORD64 HighAddress;
1890 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1891 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1893 typedef struct _DISPATCHER_CONTEXT
1895 ULONG_PTR ControlPc;
1896 ULONG_PTR ImageBase;
1897 PRUNTIME_FUNCTION FunctionEntry;
1898 ULONG_PTR EstablisherFrame;
1899 ULONG_PTR TargetPc;
1900 PCONTEXT ContextRecord;
1901 PEXCEPTION_ROUTINE LanguageHandler;
1902 PVOID HandlerData;
1903 PUNWIND_HISTORY_TABLE HistoryTable;
1904 DWORD ScopeIndex;
1905 BOOLEAN ControlPcIsUnwound;
1906 PBYTE NonVolatileRegisters;
1907 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1909 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD64);
1910 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD64);
1912 #define UNW_FLAG_NHANDLER 0
1913 #define UNW_FLAG_EHANDLER 1
1914 #define UNW_FLAG_UHANDLER 2
1916 #endif /* __aarch64__ */
1918 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
1920 typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD_PTR,PVOID);
1922 NTSYSAPI BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD_PTR);
1923 NTSYSAPI DWORD WINAPI RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION,DWORD,DWORD,ULONG_PTR,ULONG_PTR);
1924 NTSYSAPI BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1925 NTSYSAPI void WINAPI RtlDeleteGrowableFunctionTable(void*);
1926 NTSYSAPI void WINAPI RtlGrowFunctionTable(void*,DWORD);
1927 NTSYSAPI BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD_PTR,DWORD_PTR,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
1928 NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD_PTR,DWORD_PTR*,UNWIND_HISTORY_TABLE*);
1929 NTSYSAPI void WINAPI RtlUnwindEx(PVOID,PVOID,struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,UNWIND_HISTORY_TABLE*);
1930 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*);
1932 #endif
1935 * Product types
1937 #define PRODUCT_UNDEFINED 0x00000000
1938 #define PRODUCT_ULTIMATE 0x00000001
1939 #define PRODUCT_HOME_BASIC 0x00000002
1940 #define PRODUCT_HOME_PREMIUM 0x00000003
1941 #define PRODUCT_ENTERPRISE 0x00000004
1942 #define PRODUCT_HOME_BASIC_N 0x00000005
1943 #define PRODUCT_BUSINESS 0x00000006
1944 #define PRODUCT_STANDARD_SERVER 0x00000007
1945 #define PRODUCT_DATACENTER_SERVER 0x00000008
1946 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
1947 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
1948 #define PRODUCT_STARTER 0x0000000B
1949 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
1950 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
1951 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
1952 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
1953 #define PRODUCT_BUSINESS_N 0x00000010
1954 #define PRODUCT_WEB_SERVER 0x00000011
1955 #define PRODUCT_CLUSTER_SERVER 0x00000012
1956 #define PRODUCT_HOME_SERVER 0x00000013
1957 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
1958 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
1959 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
1960 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
1961 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
1962 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
1963 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
1964 #define PRODUCT_ENTERPRISE_N 0x0000001B
1965 #define PRODUCT_ULTIMATE_N 0x0000001C
1966 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
1967 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
1968 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
1969 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
1970 #define PRODUCT_SERVER_FOUNDATION 0x00000021
1971 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
1972 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
1973 #define PRODUCT_STANDARD_SERVER_V 0x00000024
1974 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
1975 #define PRODUCT_SERVER_V 0x00000025
1976 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
1977 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
1978 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
1979 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
1980 #define PRODUCT_HYPERV 0x0000002A
1981 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
1982 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
1983 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
1984 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
1985 #define PRODUCT_STARTER_N 0x0000002F
1986 #define PRODUCT_PROFESSIONAL 0x00000030
1987 #define PRODUCT_PROFESSIONAL_N 0x00000031
1988 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
1989 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
1990 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
1991 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
1992 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
1993 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
1994 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
1995 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
1996 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
1997 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
1998 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
1999 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2000 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2001 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2002 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2003 #define PRODUCT_EMBEDDED 0x00000041
2004 #define PRODUCT_STARTER_E 0x00000042
2005 #define PRODUCT_HOME_BASIC_E 0x00000043
2006 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2007 #define PRODUCT_PROFESSIONAL_E 0x00000045
2008 #define PRODUCT_ENTERPRISE_E 0x00000046
2009 #define PRODUCT_ULTIMATE_E 0x00000047
2010 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2011 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2012 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2013 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2014 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2015 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2016 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2017 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2018 #define PRODUCT_THINPC 0x00000057
2019 #define PRODUCT_EMBEDDED_A 0x00000058
2020 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2021 #define PRODUCT_EMBEDDED_E 0x0000005A
2022 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2023 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2024 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2025 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2026 #define PRODUCT_CORE_ARM 0x00000061
2027 #define PRODUCT_CORE_N 0x00000062
2028 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2029 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2030 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2031 #define PRODUCT_CORE 0x00000065
2032 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2033 #define PRODUCT_MOBILE_CORE 0x00000068
2034 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2035 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2036 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2037 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2038 #define PRODUCT_NANO_SERVER 0x0000006D
2039 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2040 #define PRODUCT_CORE_CONNECTED 0x0000006F
2041 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2042 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2043 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2044 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2045 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2046 #define PRODUCT_CONNECTED_CAR 0x00000075
2047 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2048 #define PRODUCT_PPI_PRO 0x00000077
2049 #define PRODUCT_ARM64_SERVER 0x00000078
2050 #define PRODUCT_EDUCATION 0x00000079
2051 #define PRODUCT_EDUCATION_N 0x0000007A
2052 #define PRODUCT_IOTUAP 0x0000007B
2053 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2054 #define PRODUCT_ENTERPRISE_S 0x0000007D
2055 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2056 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2057 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2058 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2059 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2060 #define PRODUCT_UNLICENSED 0xABCDABCD
2064 * Language IDs
2067 #define MAKELCID(l, s) (MAKELONG(l, s))
2069 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2070 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2071 #define SUBLANGID(l) ((WORD)(l) >> 10)
2073 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2074 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2076 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2077 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2078 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2079 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2080 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2081 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2082 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2083 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2084 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2085 #define LOCALE_NAME_MAX_LENGTH 85
2088 #define UNREFERENCED_PARAMETER(u) (void)(u)
2089 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2090 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2092 #include <winnt.rh>
2096 * Definitions for IsTextUnicode()
2099 #define IS_TEXT_UNICODE_ASCII16 0x0001
2100 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2101 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2102 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2103 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2104 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2105 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2106 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2107 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2108 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2109 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2110 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2111 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2112 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2113 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2114 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2116 #define MAXIMUM_WAIT_OBJECTS 64
2117 #define MAXIMUM_SUSPEND_COUNT 127
2119 #define WT_EXECUTEDEFAULT 0x00
2120 #define WT_EXECUTEINIOTHREAD 0x01
2121 #define WT_EXECUTEINUITHREAD 0x02
2122 #define WT_EXECUTEINWAITTHREAD 0x04
2123 #define WT_EXECUTEONLYONCE 0x08
2124 #define WT_EXECUTELONGFUNCTION 0x10
2125 #define WT_EXECUTEINTIMERTHREAD 0x20
2126 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2127 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2128 #define WT_EXECUTEINLONGTHREAD 0x10
2129 #define WT_EXECUTEDELETEWAIT 0x08
2130 #define WT_TRANSFER_IMPERSONATION 0x0100
2133 #define EXCEPTION_CONTINUABLE 0
2134 #define EXCEPTION_NONCONTINUABLE 0x01
2137 * The exception record used by Win32 to give additional information
2138 * about exception to exception handlers.
2141 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2143 typedef struct _EXCEPTION_RECORD
2145 DWORD ExceptionCode;
2146 DWORD ExceptionFlags;
2147 struct _EXCEPTION_RECORD *ExceptionRecord;
2149 PVOID ExceptionAddress;
2150 DWORD NumberParameters;
2151 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2152 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2154 typedef struct _EXCEPTION_RECORD32
2156 DWORD ExceptionCode;
2157 DWORD ExceptionFlags;
2158 DWORD ExceptionRecord;
2159 DWORD ExceptionAddress;
2160 DWORD NumberParameters;
2161 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2162 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
2164 typedef struct _EXCEPTION_RECORD64
2166 DWORD ExceptionCode;
2167 DWORD ExceptionFlags;
2168 DWORD64 ExceptionRecord;
2169 DWORD64 ExceptionAddress;
2170 DWORD NumberParameters;
2171 DWORD __unusedAlignment;
2172 DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2173 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
2176 * The exception pointers structure passed to exception filters
2177 * in except() and the UnhandledExceptionFilter().
2180 typedef struct _EXCEPTION_POINTERS
2182 PEXCEPTION_RECORD ExceptionRecord;
2183 PCONTEXT ContextRecord;
2184 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2188 * The exception frame, used for registering exception handlers
2189 * Win32 cares only about this, but compilers generally emit
2190 * larger exception frames for their own use.
2193 struct _EXCEPTION_REGISTRATION_RECORD;
2195 typedef DWORD (CDECL *PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2196 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2198 typedef struct _EXCEPTION_REGISTRATION_RECORD
2200 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2201 PEXCEPTION_HANDLER Handler;
2202 } EXCEPTION_REGISTRATION_RECORD;
2205 * function pointer to an exception filter
2208 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2210 typedef struct _NT_TIB
2212 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2213 PVOID StackBase;
2214 PVOID StackLimit;
2215 PVOID SubSystemTib;
2216 union {
2217 PVOID FiberData;
2218 DWORD Version;
2219 } DUMMYUNIONNAME;
2220 PVOID ArbitraryUserPointer;
2221 struct _NT_TIB *Self;
2222 } NT_TIB, *PNT_TIB;
2224 struct _TEB;
2226 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2227 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2229 struct _TEB *teb;
2230 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2231 return teb;
2233 #elif defined(__i386__) && defined(_MSC_VER)
2234 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2236 struct _TEB *teb;
2237 __asm mov eax, fs:[0x18];
2238 __asm mov teb, eax;
2239 return teb;
2241 #elif defined(__x86_64__) && defined(__GNUC__)
2242 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2244 struct _TEB *teb;
2245 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2246 return teb;
2248 #elif defined(__x86_64__) && defined(_MSC_VER)
2249 unsigned __int64 __readgsqword(unsigned long);
2250 #pragma intrinsic(__readgsqword)
2251 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2253 return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
2255 #elif defined(__arm__) && defined(__GNUC__)
2256 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2258 struct _TEB *teb;
2259 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb));
2260 return teb;
2262 #elif defined(__arm__) && defined(_MSC_VER)
2263 #pragma intrinsic(_MoveFromCoprocessor)
2264 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2266 return (struct _TEB *)(ULONG_PTR)_MoveFromCoprocessor(15, 0, 13, 0, 2);
2268 #else
2269 extern struct _TEB * WINAPI NtCurrentTeb(void);
2270 #endif
2272 #ifdef NONAMELESSUNION
2273 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2274 #else
2275 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2276 #endif
2277 #define GetFiberData() (*(void **)GetCurrentFiber())
2279 #define TLS_MINIMUM_AVAILABLE 64
2281 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2283 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2284 #define IO_REPARSE_TAG_RESERVED_ONE 1
2285 #define IO_REPARSE_TAG_RESERVED_TWO 2
2287 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2289 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2290 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2291 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2292 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2293 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2294 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2295 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2296 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2297 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2298 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2299 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2300 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2301 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2302 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2303 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2304 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2305 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2306 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2307 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2308 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2309 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2310 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2311 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2312 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2313 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2314 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2315 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2316 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2317 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2318 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2319 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2320 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2321 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2322 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2323 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2324 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2325 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2326 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2327 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2328 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2329 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2330 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2331 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2334 * File formats definitions
2337 #include <pshpack2.h>
2338 typedef struct _IMAGE_DOS_HEADER {
2339 WORD e_magic; /* 00: MZ Header signature */
2340 WORD e_cblp; /* 02: Bytes on last page of file */
2341 WORD e_cp; /* 04: Pages in file */
2342 WORD e_crlc; /* 06: Relocations */
2343 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2344 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2345 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2346 WORD e_ss; /* 0e: Initial (relative) SS value */
2347 WORD e_sp; /* 10: Initial SP value */
2348 WORD e_csum; /* 12: Checksum */
2349 WORD e_ip; /* 14: Initial IP value */
2350 WORD e_cs; /* 16: Initial (relative) CS value */
2351 WORD e_lfarlc; /* 18: File address of relocation table */
2352 WORD e_ovno; /* 1a: Overlay number */
2353 WORD e_res[4]; /* 1c: Reserved words */
2354 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2355 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2356 WORD e_res2[10]; /* 28: Reserved words */
2357 DWORD e_lfanew; /* 3c: Offset to extended header */
2358 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2359 #include <poppack.h>
2361 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2362 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2363 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2364 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2365 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2366 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2369 * This is the Windows executable (NE) header.
2370 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2372 #include <pshpack2.h>
2373 typedef struct
2375 WORD ne_magic; /* 00 NE signature 'NE' */
2376 BYTE ne_ver; /* 02 Linker version number */
2377 BYTE ne_rev; /* 03 Linker revision number */
2378 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2379 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2380 LONG ne_crc; /* 08 Checksum */
2381 WORD ne_flags; /* 0c Flags about segments in this file */
2382 WORD ne_autodata; /* 0e Automatic data segment number */
2383 WORD ne_heap; /* 10 Initial size of local heap */
2384 WORD ne_stack; /* 12 Initial size of stack */
2385 DWORD ne_csip; /* 14 Initial CS:IP */
2386 DWORD ne_sssp; /* 18 Initial SS:SP */
2387 WORD ne_cseg; /* 1c # of entries in segment table */
2388 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2389 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2390 WORD ne_segtab; /* 22 Offset to segment table */
2391 WORD ne_rsrctab; /* 24 Offset to resource table */
2392 WORD ne_restab; /* 26 Offset to resident-name table */
2393 WORD ne_modtab; /* 28 Offset to module reference table */
2394 WORD ne_imptab; /* 2a Offset to imported name table */
2395 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2396 WORD ne_cmovent; /* 30 # of movable entry points */
2397 WORD ne_align; /* 32 Logical sector alignment shift count */
2398 WORD ne_cres; /* 34 # of resource segments */
2399 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2400 BYTE ne_flagsothers; /* 37 Additional information flags */
2401 WORD ne_pretthunks; /* 38 Offset to return thunks */
2402 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2403 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2404 WORD ne_expver; /* 3e Expected Windows version number */
2405 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2406 #include <poppack.h>
2408 #include <pshpack2.h>
2409 typedef struct _IMAGE_VXD_HEADER {
2410 WORD e32_magic;
2411 BYTE e32_border;
2412 BYTE e32_worder;
2413 DWORD e32_level;
2414 WORD e32_cpu;
2415 WORD e32_os;
2416 DWORD e32_ver;
2417 DWORD e32_mflags;
2418 DWORD e32_mpages;
2419 DWORD e32_startobj;
2420 DWORD e32_eip;
2421 DWORD e32_stackobj;
2422 DWORD e32_esp;
2423 DWORD e32_pagesize;
2424 DWORD e32_lastpagesize;
2425 DWORD e32_fixupsize;
2426 DWORD e32_fixupsum;
2427 DWORD e32_ldrsize;
2428 DWORD e32_ldrsum;
2429 DWORD e32_objtab;
2430 DWORD e32_objcnt;
2431 DWORD e32_objmap;
2432 DWORD e32_itermap;
2433 DWORD e32_rsrctab;
2434 DWORD e32_rsrccnt;
2435 DWORD e32_restab;
2436 DWORD e32_enttab;
2437 DWORD e32_dirtab;
2438 DWORD e32_dircnt;
2439 DWORD e32_fpagetab;
2440 DWORD e32_frectab;
2441 DWORD e32_impmod;
2442 DWORD e32_impmodcnt;
2443 DWORD e32_impproc;
2444 DWORD e32_pagesum;
2445 DWORD e32_datapage;
2446 DWORD e32_preload;
2447 DWORD e32_nrestab;
2448 DWORD e32_cbnrestab;
2449 DWORD e32_nressum;
2450 DWORD e32_autodata;
2451 DWORD e32_debuginfo;
2452 DWORD e32_debuglen;
2453 DWORD e32_instpreload;
2454 DWORD e32_instdemand;
2455 DWORD e32_heapsize;
2456 BYTE e32_res3[12];
2457 DWORD e32_winresoff;
2458 DWORD e32_winreslen;
2459 WORD e32_devid;
2460 WORD e32_ddkver;
2461 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2462 #include <poppack.h>
2464 /* These defines describe the meanings of the bits in the Characteristics
2465 field */
2467 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2468 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2469 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2470 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2471 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2472 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2473 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2474 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2475 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2476 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2477 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2478 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2479 #define IMAGE_FILE_SYSTEM 0x1000
2480 #define IMAGE_FILE_DLL 0x2000
2481 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2482 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2484 /* These are the settings of the Machine field. */
2485 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2486 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
2487 #define IMAGE_FILE_MACHINE_I860 0x014d
2488 #define IMAGE_FILE_MACHINE_I386 0x014c
2489 #define IMAGE_FILE_MACHINE_R3000 0x0162
2490 #define IMAGE_FILE_MACHINE_R4000 0x0166
2491 #define IMAGE_FILE_MACHINE_R10000 0x0168
2492 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2493 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2494 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2495 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2496 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2497 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2498 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2499 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2500 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2501 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2502 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2503 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2504 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2505 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2506 #define IMAGE_FILE_MACHINE_IA64 0x0200
2507 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2508 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2509 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2510 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2511 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2512 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2513 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2514 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2515 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2516 #define IMAGE_FILE_MACHINE_M32R 0x9041
2517 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2519 #define IMAGE_SIZEOF_FILE_HEADER 20
2520 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2521 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2522 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2523 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2524 #define IMAGE_SIZEOF_SHORT_NAME 8
2525 #define IMAGE_SIZEOF_SECTION_HEADER 40
2526 #define IMAGE_SIZEOF_SYMBOL 18
2527 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2528 #define IMAGE_SIZEOF_RELOCATION 10
2529 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2530 #define IMAGE_SIZEOF_LINENUMBER 6
2531 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2533 /* Possible Magic values */
2534 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2535 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2536 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2538 #ifdef _WIN64
2539 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2540 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2541 #else
2542 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2543 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2544 #endif
2546 /* These are indexes into the DataDirectory array */
2547 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2548 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2549 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2550 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2551 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2552 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2553 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2554 #define IMAGE_FILE_DESCRIPTION_STRING 7
2555 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2556 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2557 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2559 /* Directory Entries, indices into the DataDirectory array */
2561 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2562 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2563 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2564 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2565 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2566 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2567 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2568 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2569 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2570 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2571 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2572 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2573 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2574 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2575 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2577 /* Subsystem Values */
2579 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2580 #define IMAGE_SUBSYSTEM_NATIVE 1
2581 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2582 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2583 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2584 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2585 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2586 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2587 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2588 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2589 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2590 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2591 #define IMAGE_SUBSYSTEM_XBOX 14
2592 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2594 /* DLL Characteristics */
2595 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
2596 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2597 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2598 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2599 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2600 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2601 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2602 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
2603 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2604 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
2605 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2607 typedef struct _IMAGE_FILE_HEADER {
2608 WORD Machine;
2609 WORD NumberOfSections;
2610 DWORD TimeDateStamp;
2611 DWORD PointerToSymbolTable;
2612 DWORD NumberOfSymbols;
2613 WORD SizeOfOptionalHeader;
2614 WORD Characteristics;
2615 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2617 typedef struct _IMAGE_DATA_DIRECTORY {
2618 DWORD VirtualAddress;
2619 DWORD Size;
2620 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2622 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2624 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2625 WORD Magic; /* 0x20b */
2626 BYTE MajorLinkerVersion;
2627 BYTE MinorLinkerVersion;
2628 DWORD SizeOfCode;
2629 DWORD SizeOfInitializedData;
2630 DWORD SizeOfUninitializedData;
2631 DWORD AddressOfEntryPoint;
2632 DWORD BaseOfCode;
2633 ULONGLONG ImageBase;
2634 DWORD SectionAlignment;
2635 DWORD FileAlignment;
2636 WORD MajorOperatingSystemVersion;
2637 WORD MinorOperatingSystemVersion;
2638 WORD MajorImageVersion;
2639 WORD MinorImageVersion;
2640 WORD MajorSubsystemVersion;
2641 WORD MinorSubsystemVersion;
2642 DWORD Win32VersionValue;
2643 DWORD SizeOfImage;
2644 DWORD SizeOfHeaders;
2645 DWORD CheckSum;
2646 WORD Subsystem;
2647 WORD DllCharacteristics;
2648 ULONGLONG SizeOfStackReserve;
2649 ULONGLONG SizeOfStackCommit;
2650 ULONGLONG SizeOfHeapReserve;
2651 ULONGLONG SizeOfHeapCommit;
2652 DWORD LoaderFlags;
2653 DWORD NumberOfRvaAndSizes;
2654 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2655 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2657 typedef struct _IMAGE_NT_HEADERS64 {
2658 DWORD Signature;
2659 IMAGE_FILE_HEADER FileHeader;
2660 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2661 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2663 typedef struct _IMAGE_OPTIONAL_HEADER {
2665 /* Standard fields */
2667 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2668 BYTE MajorLinkerVersion;
2669 BYTE MinorLinkerVersion;
2670 DWORD SizeOfCode;
2671 DWORD SizeOfInitializedData;
2672 DWORD SizeOfUninitializedData;
2673 DWORD AddressOfEntryPoint; /* 0x10 */
2674 DWORD BaseOfCode;
2675 DWORD BaseOfData;
2677 /* NT additional fields */
2679 DWORD ImageBase;
2680 DWORD SectionAlignment; /* 0x20 */
2681 DWORD FileAlignment;
2682 WORD MajorOperatingSystemVersion;
2683 WORD MinorOperatingSystemVersion;
2684 WORD MajorImageVersion;
2685 WORD MinorImageVersion;
2686 WORD MajorSubsystemVersion; /* 0x30 */
2687 WORD MinorSubsystemVersion;
2688 DWORD Win32VersionValue;
2689 DWORD SizeOfImage;
2690 DWORD SizeOfHeaders;
2691 DWORD CheckSum; /* 0x40 */
2692 WORD Subsystem;
2693 WORD DllCharacteristics;
2694 DWORD SizeOfStackReserve;
2695 DWORD SizeOfStackCommit;
2696 DWORD SizeOfHeapReserve; /* 0x50 */
2697 DWORD SizeOfHeapCommit;
2698 DWORD LoaderFlags;
2699 DWORD NumberOfRvaAndSizes;
2700 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2701 /* 0xE0 */
2702 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2704 typedef struct _IMAGE_NT_HEADERS {
2705 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2706 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2707 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2708 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2710 #ifdef _WIN64
2711 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2712 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2713 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2714 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2715 #else
2716 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2717 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2718 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2719 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2720 #endif
2722 #define IMAGE_SIZEOF_SHORT_NAME 8
2724 typedef struct _IMAGE_SECTION_HEADER {
2725 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2726 union {
2727 DWORD PhysicalAddress;
2728 DWORD VirtualSize;
2729 } Misc;
2730 DWORD VirtualAddress;
2731 DWORD SizeOfRawData;
2732 DWORD PointerToRawData;
2733 DWORD PointerToRelocations;
2734 DWORD PointerToLinenumbers;
2735 WORD NumberOfRelocations;
2736 WORD NumberOfLinenumbers;
2737 DWORD Characteristics;
2738 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2740 #define IMAGE_SIZEOF_SECTION_HEADER 40
2742 #define IMAGE_FIRST_SECTION(ntheader) \
2743 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2744 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2746 /* These defines are for the Characteristics bitfield. */
2747 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2748 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2749 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2750 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2751 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2752 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2754 #define IMAGE_SCN_CNT_CODE 0x00000020
2755 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2756 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2758 #define IMAGE_SCN_LNK_OTHER 0x00000100
2759 #define IMAGE_SCN_LNK_INFO 0x00000200
2760 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2761 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2762 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2764 /* 0x00002000 - Reserved */
2765 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2766 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2768 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2769 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2770 #define IMAGE_SCN_MEM_16BIT 0x00020000
2771 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2772 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2774 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2775 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2776 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2777 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2778 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2779 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2780 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2781 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2782 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2783 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2784 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2785 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2786 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2787 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2788 /* 0x00F00000 - Unused */
2789 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2791 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2794 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2795 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2796 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2797 #define IMAGE_SCN_MEM_SHARED 0x10000000
2798 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2799 #define IMAGE_SCN_MEM_READ 0x40000000
2800 #define IMAGE_SCN_MEM_WRITE 0x80000000
2802 #include <pshpack2.h>
2804 typedef struct _IMAGE_SYMBOL {
2805 union {
2806 BYTE ShortName[8];
2807 struct {
2808 DWORD Short;
2809 DWORD Long;
2810 } Name;
2811 DWORD LongName[2];
2812 } N;
2813 DWORD Value;
2814 SHORT SectionNumber;
2815 WORD Type;
2816 BYTE StorageClass;
2817 BYTE NumberOfAuxSymbols;
2818 } IMAGE_SYMBOL;
2819 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2821 #define IMAGE_SIZEOF_SYMBOL 18
2823 typedef struct _IMAGE_LINENUMBER {
2824 union {
2825 DWORD SymbolTableIndex;
2826 DWORD VirtualAddress;
2827 } Type;
2828 WORD Linenumber;
2829 } IMAGE_LINENUMBER;
2830 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2832 #define IMAGE_SIZEOF_LINENUMBER 6
2834 typedef union _IMAGE_AUX_SYMBOL {
2835 struct {
2836 DWORD TagIndex;
2837 union {
2838 struct {
2839 WORD Linenumber;
2840 WORD Size;
2841 } LnSz;
2842 DWORD TotalSize;
2843 } Misc;
2844 union {
2845 struct {
2846 DWORD PointerToLinenumber;
2847 DWORD PointerToNextFunction;
2848 } Function;
2849 struct {
2850 WORD Dimension[4];
2851 } Array;
2852 } FcnAry;
2853 WORD TvIndex;
2854 } Sym;
2855 struct {
2856 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2857 } File;
2858 struct {
2859 DWORD Length;
2860 WORD NumberOfRelocations;
2861 WORD NumberOfLinenumbers;
2862 DWORD CheckSum;
2863 SHORT Number;
2864 BYTE Selection;
2865 } Section;
2866 } IMAGE_AUX_SYMBOL;
2867 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2869 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2871 #include <poppack.h>
2873 #define IMAGE_SYM_UNDEFINED (SHORT)0
2874 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2875 #define IMAGE_SYM_DEBUG (SHORT)-2
2877 #define IMAGE_SYM_TYPE_NULL 0x0000
2878 #define IMAGE_SYM_TYPE_VOID 0x0001
2879 #define IMAGE_SYM_TYPE_CHAR 0x0002
2880 #define IMAGE_SYM_TYPE_SHORT 0x0003
2881 #define IMAGE_SYM_TYPE_INT 0x0004
2882 #define IMAGE_SYM_TYPE_LONG 0x0005
2883 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2884 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2885 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2886 #define IMAGE_SYM_TYPE_UNION 0x0009
2887 #define IMAGE_SYM_TYPE_ENUM 0x000A
2888 #define IMAGE_SYM_TYPE_MOE 0x000B
2889 #define IMAGE_SYM_TYPE_BYTE 0x000C
2890 #define IMAGE_SYM_TYPE_WORD 0x000D
2891 #define IMAGE_SYM_TYPE_UINT 0x000E
2892 #define IMAGE_SYM_TYPE_DWORD 0x000F
2893 #define IMAGE_SYM_TYPE_PCODE 0x8000
2895 #define IMAGE_SYM_DTYPE_NULL 0
2896 #define IMAGE_SYM_DTYPE_POINTER 1
2897 #define IMAGE_SYM_DTYPE_FUNCTION 2
2898 #define IMAGE_SYM_DTYPE_ARRAY 3
2900 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2901 #define IMAGE_SYM_CLASS_NULL 0x0000
2902 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2903 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2904 #define IMAGE_SYM_CLASS_STATIC 0x0003
2905 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2906 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2907 #define IMAGE_SYM_CLASS_LABEL 0x0006
2908 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2909 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2910 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2911 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2912 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2913 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2914 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2915 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2916 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2917 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2918 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2919 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2921 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2922 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2923 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2924 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2925 #define IMAGE_SYM_CLASS_FILE 0x0067
2926 #define IMAGE_SYM_CLASS_SECTION 0x0068
2927 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2929 #define N_BTMASK 0x000F
2930 #define N_TMASK 0x0030
2931 #define N_TMASK1 0x00C0
2932 #define N_TMASK2 0x00F0
2933 #define N_BTSHFT 4
2934 #define N_TSHIFT 2
2936 #define BTYPE(x) ((x) & N_BTMASK)
2938 #ifndef ISPTR
2939 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2940 #endif
2942 #ifndef ISFCN
2943 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2944 #endif
2946 #ifndef ISARY
2947 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2948 #endif
2950 #ifndef ISTAG
2951 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2952 #endif
2954 #ifndef INCREF
2955 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2956 #endif
2957 #ifndef DECREF
2958 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2959 #endif
2961 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2962 #define IMAGE_COMDAT_SELECT_ANY 2
2963 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2964 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2965 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2966 #define IMAGE_COMDAT_SELECT_LARGEST 6
2967 #define IMAGE_COMDAT_SELECT_NEWEST 7
2969 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2970 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2971 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2973 /* Export module directory */
2975 typedef struct _IMAGE_EXPORT_DIRECTORY {
2976 DWORD Characteristics;
2977 DWORD TimeDateStamp;
2978 WORD MajorVersion;
2979 WORD MinorVersion;
2980 DWORD Name;
2981 DWORD Base;
2982 DWORD NumberOfFunctions;
2983 DWORD NumberOfNames;
2984 DWORD AddressOfFunctions;
2985 DWORD AddressOfNames;
2986 DWORD AddressOfNameOrdinals;
2987 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2989 /* Import name entry */
2990 typedef struct _IMAGE_IMPORT_BY_NAME {
2991 WORD Hint;
2992 BYTE Name[1];
2993 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2995 #include <pshpack8.h>
2996 /* Import thunk */
2997 typedef struct _IMAGE_THUNK_DATA64 {
2998 union {
2999 ULONGLONG ForwarderString;
3000 ULONGLONG Function;
3001 ULONGLONG Ordinal;
3002 ULONGLONG AddressOfData;
3003 } u1;
3004 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3005 #include <poppack.h>
3007 typedef struct _IMAGE_THUNK_DATA32 {
3008 union {
3009 DWORD ForwarderString;
3010 DWORD Function;
3011 DWORD Ordinal;
3012 DWORD AddressOfData;
3013 } u1;
3014 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3016 /* Import module directory */
3018 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3019 union {
3020 DWORD Characteristics; /* 0 for terminating null import descriptor */
3021 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3022 } DUMMYUNIONNAME;
3023 DWORD TimeDateStamp; /* 0 if not bound,
3024 * -1 if bound, and real date\time stamp
3025 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3026 * (new BIND)
3027 * otherwise date/time stamp of DLL bound to
3028 * (Old BIND)
3030 DWORD ForwarderChain; /* -1 if no forwarders */
3031 DWORD Name;
3032 /* RVA to IAT (if bound this IAT has actual addresses) */
3033 DWORD FirstThunk;
3034 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3036 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3037 #define IMAGE_ORDINAL_FLAG32 0x80000000
3038 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3039 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3040 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3041 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3043 #ifdef _WIN64
3044 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3045 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3046 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3047 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3048 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3049 #else
3050 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3051 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3052 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3053 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3054 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3055 #endif
3057 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3059 DWORD TimeDateStamp;
3060 WORD OffsetModuleName;
3061 WORD NumberOfModuleForwarderRefs;
3062 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3063 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3065 typedef struct _IMAGE_BOUND_FORWARDER_REF
3067 DWORD TimeDateStamp;
3068 WORD OffsetModuleName;
3069 WORD Reserved;
3070 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3072 typedef struct _IMAGE_BASE_RELOCATION
3074 DWORD VirtualAddress;
3075 DWORD SizeOfBlock;
3076 /* WORD TypeOffset[1]; */
3077 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3079 #include <pshpack2.h>
3081 typedef struct _IMAGE_RELOCATION
3083 union {
3084 DWORD VirtualAddress;
3085 DWORD RelocCount;
3086 } DUMMYUNIONNAME;
3087 DWORD SymbolTableIndex;
3088 WORD Type;
3089 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3091 #include <poppack.h>
3093 #define IMAGE_SIZEOF_RELOCATION 10
3095 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3097 union
3099 DWORD AllAttributes;
3100 struct
3102 DWORD RvaBased:1;
3103 DWORD ReservedAttributes:31;
3104 } DUMMYSTRUCTNAME;
3105 } Attributes;
3107 DWORD DllNameRVA;
3108 DWORD ModuleHandleRVA;
3109 DWORD ImportAddressTableRVA;
3110 DWORD ImportNameTableRVA;
3111 DWORD BoundImportAddressTableRVA;
3112 DWORD UnloadInformationTableRVA;
3113 DWORD TimeDateStamp;
3114 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3115 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3117 /* generic relocation types */
3118 #define IMAGE_REL_BASED_ABSOLUTE 0
3119 #define IMAGE_REL_BASED_HIGH 1
3120 #define IMAGE_REL_BASED_LOW 2
3121 #define IMAGE_REL_BASED_HIGHLOW 3
3122 #define IMAGE_REL_BASED_HIGHADJ 4
3123 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3124 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3125 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3126 #define IMAGE_REL_BASED_SECTION 6
3127 #define IMAGE_REL_BASED_REL 7
3128 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3129 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3130 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3131 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3132 #define IMAGE_REL_BASED_DIR64 10
3133 #define IMAGE_REL_BASED_HIGH3ADJ 11
3135 /* I386 relocation types */
3136 #define IMAGE_REL_I386_ABSOLUTE 0
3137 #define IMAGE_REL_I386_DIR16 1
3138 #define IMAGE_REL_I386_REL16 2
3139 #define IMAGE_REL_I386_DIR32 6
3140 #define IMAGE_REL_I386_DIR32NB 7
3141 #define IMAGE_REL_I386_SEG12 9
3142 #define IMAGE_REL_I386_SECTION 10
3143 #define IMAGE_REL_I386_SECREL 11
3144 #define IMAGE_REL_I386_TOKEN 12
3145 #define IMAGE_REL_I386_SECREL7 13
3146 #define IMAGE_REL_I386_REL32 20
3148 /* MIPS relocation types */
3149 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3150 #define IMAGE_REL_MIPS_REFHALF 0x0001
3151 #define IMAGE_REL_MIPS_REFWORD 0x0002
3152 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3153 #define IMAGE_REL_MIPS_REFHI 0x0004
3154 #define IMAGE_REL_MIPS_REFLO 0x0005
3155 #define IMAGE_REL_MIPS_GPREL 0x0006
3156 #define IMAGE_REL_MIPS_LITERAL 0x0007
3157 #define IMAGE_REL_MIPS_SECTION 0x000A
3158 #define IMAGE_REL_MIPS_SECREL 0x000B
3159 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3160 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3161 #define IMAGE_REL_MIPS_TOKEN 0x000E
3162 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3163 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3164 #define IMAGE_REL_MIPS_PAIR 0x0025
3166 /* ALPHA relocation types */
3167 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3168 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3169 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3170 #define IMAGE_REL_ALPHA_GPREL 0x0003
3171 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3172 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3173 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3174 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3175 #define IMAGE_REL_ALPHA_HINT 0x0008
3176 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3177 #define IMAGE_REL_ALPHA_REFHI 0x000A
3178 #define IMAGE_REL_ALPHA_REFLO 0x000B
3179 #define IMAGE_REL_ALPHA_PAIR 0x000C
3180 #define IMAGE_REL_ALPHA_MATCH 0x000D
3181 #define IMAGE_REL_ALPHA_SECTION 0x000E
3182 #define IMAGE_REL_ALPHA_SECREL 0x000F
3183 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3184 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3185 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3186 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3187 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3188 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3189 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3190 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3192 /* PowerPC relocation types */
3193 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3194 #define IMAGE_REL_PPC_ADDR64 0x0001
3195 #define IMAGE_REL_PPC_ADDR 0x0002
3196 #define IMAGE_REL_PPC_ADDR24 0x0003
3197 #define IMAGE_REL_PPC_ADDR16 0x0004
3198 #define IMAGE_REL_PPC_ADDR14 0x0005
3199 #define IMAGE_REL_PPC_REL24 0x0006
3200 #define IMAGE_REL_PPC_REL14 0x0007
3201 #define IMAGE_REL_PPC_TOCREL16 0x0008
3202 #define IMAGE_REL_PPC_TOCREL14 0x0009
3203 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3204 #define IMAGE_REL_PPC_SECREL 0x000B
3205 #define IMAGE_REL_PPC_SECTION 0x000C
3206 #define IMAGE_REL_PPC_IFGLUE 0x000D
3207 #define IMAGE_REL_PPC_IMGLUE 0x000E
3208 #define IMAGE_REL_PPC_SECREL16 0x000F
3209 #define IMAGE_REL_PPC_REFHI 0x0010
3210 #define IMAGE_REL_PPC_REFLO 0x0011
3211 #define IMAGE_REL_PPC_PAIR 0x0012
3212 #define IMAGE_REL_PPC_SECRELLO 0x0013
3213 #define IMAGE_REL_PPC_SECRELHI 0x0014
3214 #define IMAGE_REL_PPC_GPREL 0x0015
3215 #define IMAGE_REL_PPC_TOKEN 0x0016
3216 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3217 /* modifier bits */
3218 #define IMAGE_REL_PPC_NEG 0x0100
3219 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3220 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3221 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3223 /* SH3 relocation types */
3224 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3225 #define IMAGE_REL_SH3_DIRECT16 0x0001
3226 #define IMAGE_REL_SH3_DIRECT 0x0002
3227 #define IMAGE_REL_SH3_DIRECT8 0x0003
3228 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3229 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3230 #define IMAGE_REL_SH3_DIRECT4 0x0006
3231 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3232 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3233 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3234 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3235 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3236 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3237 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3238 #define IMAGE_REL_SH3_SECTION 0x000E
3239 #define IMAGE_REL_SH3_SECREL 0x000F
3240 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3241 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3242 #define IMAGE_REL_SH3_TOKEN 0x0012
3244 /* ARM relocation types */
3245 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3246 #define IMAGE_REL_ARM_ADDR 0x0001
3247 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3248 #define IMAGE_REL_ARM_BRANCH24 0x0003
3249 #define IMAGE_REL_ARM_BRANCH11 0x0004
3250 #define IMAGE_REL_ARM_TOKEN 0x0005
3251 #define IMAGE_REL_ARM_GPREL12 0x0006
3252 #define IMAGE_REL_ARM_GPREL7 0x0007
3253 #define IMAGE_REL_ARM_BLX24 0x0008
3254 #define IMAGE_REL_ARM_BLX11 0x0009
3255 #define IMAGE_REL_ARM_SECTION 0x000E
3256 #define IMAGE_REL_ARM_SECREL 0x000F
3257 #define IMAGE_REL_ARM_MOV32A 0x0010
3258 #define IMAGE_REL_ARM_MOV32T 0x0011
3259 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3260 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3261 #define IMAGE_REL_ARM_BLX23T 0x0015
3263 /* ARM64 relocation types */
3264 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3265 #define IMAGE_REL_ARM64_ADDR32 0x0001
3266 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3267 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3268 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3269 #define IMAGE_REL_ARM64_REL21 0x0005
3270 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3271 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3272 #define IMAGE_REL_ARM64_SECREL 0x0008
3273 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3274 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3275 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3276 #define IMAGE_REL_ARM64_TOKEN 0x000C
3277 #define IMAGE_REL_ARM64_SECTION 0x000D
3278 #define IMAGE_REL_ARM64_ADDR64 0x000E
3279 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3281 /* IA64 relocation types */
3282 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3283 #define IMAGE_REL_IA64_IMM14 0x0001
3284 #define IMAGE_REL_IA64_IMM22 0x0002
3285 #define IMAGE_REL_IA64_IMM64 0x0003
3286 #define IMAGE_REL_IA64_DIR 0x0004
3287 #define IMAGE_REL_IA64_DIR64 0x0005
3288 #define IMAGE_REL_IA64_PCREL21B 0x0006
3289 #define IMAGE_REL_IA64_PCREL21M 0x0007
3290 #define IMAGE_REL_IA64_PCREL21F 0x0008
3291 #define IMAGE_REL_IA64_GPREL22 0x0009
3292 #define IMAGE_REL_IA64_LTOFF22 0x000A
3293 #define IMAGE_REL_IA64_SECTION 0x000B
3294 #define IMAGE_REL_IA64_SECREL22 0x000C
3295 #define IMAGE_REL_IA64_SECREL64I 0x000D
3296 #define IMAGE_REL_IA64_SECREL 0x000E
3297 #define IMAGE_REL_IA64_LTOFF64 0x000F
3298 #define IMAGE_REL_IA64_DIR32NB 0x0010
3299 #define IMAGE_REL_IA64_SREL14 0x0011
3300 #define IMAGE_REL_IA64_SREL22 0x0012
3301 #define IMAGE_REL_IA64_SREL32 0x0013
3302 #define IMAGE_REL_IA64_UREL32 0x0014
3303 #define IMAGE_REL_IA64_PCREL60X 0x0015
3304 #define IMAGE_REL_IA64_PCREL60B 0x0016
3305 #define IMAGE_REL_IA64_PCREL60F 0x0017
3306 #define IMAGE_REL_IA64_PCREL60I 0x0018
3307 #define IMAGE_REL_IA64_PCREL60M 0x0019
3308 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3309 #define IMAGE_REL_IA64_TOKEN 0x001B
3310 #define IMAGE_REL_IA64_GPREL32 0x001C
3311 #define IMAGE_REL_IA64_ADDEND 0x001F
3313 /* AMD64 relocation types */
3314 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3315 #define IMAGE_REL_AMD64_ADDR64 0x0001
3316 #define IMAGE_REL_AMD64_ADDR32 0x0002
3317 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3318 #define IMAGE_REL_AMD64_REL32 0x0004
3319 #define IMAGE_REL_AMD64_REL32_1 0x0005
3320 #define IMAGE_REL_AMD64_REL32_2 0x0006
3321 #define IMAGE_REL_AMD64_REL32_3 0x0007
3322 #define IMAGE_REL_AMD64_REL32_4 0x0008
3323 #define IMAGE_REL_AMD64_REL32_5 0x0009
3324 #define IMAGE_REL_AMD64_SECTION 0x000A
3325 #define IMAGE_REL_AMD64_SECREL 0x000B
3326 #define IMAGE_REL_AMD64_SECREL7 0x000C
3327 #define IMAGE_REL_AMD64_TOKEN 0x000D
3328 #define IMAGE_REL_AMD64_SREL32 0x000E
3329 #define IMAGE_REL_AMD64_PAIR 0x000F
3330 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3332 /* archive format */
3334 #define IMAGE_ARCHIVE_START_SIZE 8
3335 #define IMAGE_ARCHIVE_START "!<arch>\n"
3336 #define IMAGE_ARCHIVE_END "`\n"
3337 #define IMAGE_ARCHIVE_PAD "\n"
3338 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3339 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3341 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3343 BYTE Name[16];
3344 BYTE Date[12];
3345 BYTE UserID[6];
3346 BYTE GroupID[6];
3347 BYTE Mode[8];
3348 BYTE Size[10];
3349 BYTE EndHeader[2];
3350 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3352 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3354 typedef struct _IMPORT_OBJECT_HEADER
3356 WORD Sig1;
3357 WORD Sig2;
3358 WORD Version;
3359 WORD Machine;
3360 DWORD TimeDateStamp;
3361 DWORD SizeOfData;
3362 union
3364 WORD Ordinal;
3365 WORD Hint;
3366 } DUMMYUNIONNAME;
3367 WORD Type : 2;
3368 WORD NameType : 3;
3369 WORD Reserved : 11;
3370 } IMPORT_OBJECT_HEADER;
3372 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3374 typedef enum IMPORT_OBJECT_TYPE
3376 IMPORT_OBJECT_CODE = 0,
3377 IMPORT_OBJECT_DATA = 1,
3378 IMPORT_OBJECT_CONST = 2
3379 } IMPORT_OBJECT_TYPE;
3381 typedef enum IMPORT_OBJECT_NAME_TYPE
3383 IMPORT_OBJECT_ORDINAL = 0,
3384 IMPORT_OBJECT_NAME = 1,
3385 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3386 IMPORT_OBJECT_NAME_UNDECORATE = 3
3387 } IMPORT_OBJECT_NAME_TYPE;
3389 typedef struct _ANON_OBJECT_HEADER
3391 WORD Sig1;
3392 WORD Sig2;
3393 WORD Version;
3394 WORD Machine;
3395 DWORD TimeDateStamp;
3396 CLSID ClassID;
3397 DWORD SizeOfData;
3398 } ANON_OBJECT_HEADER;
3401 * Resource directory stuff
3403 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3404 DWORD Characteristics;
3405 DWORD TimeDateStamp;
3406 WORD MajorVersion;
3407 WORD MinorVersion;
3408 WORD NumberOfNamedEntries;
3409 WORD NumberOfIdEntries;
3410 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3411 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3413 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3414 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3416 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3417 union {
3418 struct {
3419 unsigned NameOffset:31;
3420 unsigned NameIsString:1;
3421 } DUMMYSTRUCTNAME;
3422 DWORD Name;
3423 WORD Id;
3424 } DUMMYUNIONNAME;
3425 union {
3426 DWORD OffsetToData;
3427 struct {
3428 unsigned OffsetToDirectory:31;
3429 unsigned DataIsDirectory:1;
3430 } DUMMYSTRUCTNAME2;
3431 } DUMMYUNIONNAME2;
3432 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3435 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3436 WORD Length;
3437 CHAR NameString[ 1 ];
3438 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3440 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3441 WORD Length;
3442 WCHAR NameString[ 1 ];
3443 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3445 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3446 DWORD OffsetToData;
3447 DWORD Size;
3448 DWORD CodePage;
3449 DWORD Reserved;
3450 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3453 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3454 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3457 typedef struct _IMAGE_TLS_DIRECTORY64 {
3458 ULONGLONG StartAddressOfRawData;
3459 ULONGLONG EndAddressOfRawData;
3460 ULONGLONG AddressOfIndex;
3461 ULONGLONG AddressOfCallBacks;
3462 DWORD SizeOfZeroFill;
3463 DWORD Characteristics;
3464 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3466 typedef struct _IMAGE_TLS_DIRECTORY32 {
3467 DWORD StartAddressOfRawData;
3468 DWORD EndAddressOfRawData;
3469 DWORD AddressOfIndex;
3470 DWORD AddressOfCallBacks;
3471 DWORD SizeOfZeroFill;
3472 DWORD Characteristics;
3473 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3475 #ifdef _WIN64
3476 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3477 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3478 #else
3479 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3480 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3481 #endif
3483 typedef struct _IMAGE_DEBUG_DIRECTORY {
3484 DWORD Characteristics;
3485 DWORD TimeDateStamp;
3486 WORD MajorVersion;
3487 WORD MinorVersion;
3488 DWORD Type;
3489 DWORD SizeOfData;
3490 DWORD AddressOfRawData;
3491 DWORD PointerToRawData;
3492 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3494 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3495 #define IMAGE_DEBUG_TYPE_COFF 1
3496 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3497 #define IMAGE_DEBUG_TYPE_FPO 3
3498 #define IMAGE_DEBUG_TYPE_MISC 4
3499 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3500 #define IMAGE_DEBUG_TYPE_FIXUP 6
3501 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3502 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3503 #define IMAGE_DEBUG_TYPE_BORLAND 9
3504 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3505 #define IMAGE_DEBUG_TYPE_CLSID 11
3506 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3507 #define IMAGE_DEBUG_TYPE_POGO 13
3508 #define IMAGE_DEBUG_TYPE_ILTCG 14
3509 #define IMAGE_DEBUG_TYPE_MPX 15
3510 #define IMAGE_DEBUG_TYPE_REPRO 16
3512 typedef enum ReplacesCorHdrNumericDefines
3514 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3515 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3516 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3517 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3518 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
3519 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3520 COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000,
3522 COR_VERSION_MAJOR_V2 = 2,
3523 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3524 COR_VERSION_MINOR = 5,
3525 COR_DELETED_NAME_LENGTH = 8,
3526 COR_VTABLEGAP_NAME_LENGTH = 8,
3528 NATIVE_TYPE_MAX_CB = 1,
3529 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3531 IMAGE_COR_MIH_METHODRVA = 0x01,
3532 IMAGE_COR_MIH_EHRVA = 0x02,
3533 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3535 COR_VTABLE_32BIT = 0x01,
3536 COR_VTABLE_64BIT = 0x02,
3537 COR_VTABLE_FROM_UNMANAGED = 0x04,
3538 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3540 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3542 MAX_CLASS_NAME = 1024,
3543 MAX_PACKAGE_NAME = 1024,
3544 } ReplacesCorHdrNumericDefines;
3546 typedef struct IMAGE_COR20_HEADER
3548 DWORD cb;
3549 WORD MajorRuntimeVersion;
3550 WORD MinorRuntimeVersion;
3552 IMAGE_DATA_DIRECTORY MetaData;
3553 DWORD Flags;
3554 union {
3555 DWORD EntryPointToken;
3556 DWORD EntryPointRVA;
3557 } DUMMYUNIONNAME;
3559 IMAGE_DATA_DIRECTORY Resources;
3560 IMAGE_DATA_DIRECTORY StrongNameSignature;
3561 IMAGE_DATA_DIRECTORY CodeManagerTable;
3562 IMAGE_DATA_DIRECTORY VTableFixups;
3563 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3564 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3566 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3568 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3569 DWORD NumberOfSymbols;
3570 DWORD LvaToFirstSymbol;
3571 DWORD NumberOfLinenumbers;
3572 DWORD LvaToFirstLinenumber;
3573 DWORD RvaToFirstByteOfCode;
3574 DWORD RvaToLastByteOfCode;
3575 DWORD RvaToFirstByteOfData;
3576 DWORD RvaToLastByteOfData;
3577 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3579 #define FRAME_FPO 0
3580 #define FRAME_TRAP 1
3581 #define FRAME_TSS 2
3582 #define FRAME_NONFPO 3
3584 typedef struct _FPO_DATA {
3585 DWORD ulOffStart;
3586 DWORD cbProcSize;
3587 DWORD cdwLocals;
3588 WORD cdwParams;
3589 WORD cbProlog : 8;
3590 WORD cbRegs : 3;
3591 WORD fHasSEH : 1;
3592 WORD fUseBP : 1;
3593 WORD reserved : 1;
3594 WORD cbFrame : 2;
3595 } FPO_DATA, *PFPO_DATA;
3597 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
3598 DWORD Size;
3599 DWORD TimeDateStamp;
3600 WORD MajorVersion;
3601 WORD MinorVersion;
3602 DWORD GlobalFlagsClear;
3603 DWORD GlobalFlagsSet;
3604 DWORD CriticalSectionDefaultTimeout;
3605 ULONGLONG DeCommitFreeBlockThreshold;
3606 ULONGLONG DeCommitTotalFreeThreshold;
3607 ULONGLONG LockPrefixTable;
3608 ULONGLONG MaximumAllocationSize;
3609 ULONGLONG VirtualMemoryThreshold;
3610 ULONGLONG ProcessAffinityMask;
3611 DWORD ProcessHeapFlags;
3612 WORD CSDVersion;
3613 WORD Reserved1;
3614 ULONGLONG EditList;
3615 ULONGLONG SecurityCookie;
3616 ULONGLONG SEHandlerTable;
3617 ULONGLONG SEHandlerCount;
3618 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
3620 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
3621 DWORD Size;
3622 DWORD TimeDateStamp;
3623 WORD MajorVersion;
3624 WORD MinorVersion;
3625 DWORD GlobalFlagsClear;
3626 DWORD GlobalFlagsSet;
3627 DWORD CriticalSectionDefaultTimeout;
3628 DWORD DeCommitFreeBlockThreshold;
3629 DWORD DeCommitTotalFreeThreshold;
3630 PVOID LockPrefixTable;
3631 DWORD MaximumAllocationSize;
3632 DWORD VirtualMemoryThreshold;
3633 DWORD ProcessHeapFlags;
3634 DWORD ProcessAffinityMask;
3635 WORD CSDVersion;
3636 WORD Reserved1;
3637 PVOID EditList;
3638 DWORD SecurityCookie;
3639 DWORD SEHandlerTable;
3640 DWORD SEHandlerCount;
3641 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
3643 #ifdef _WIN64
3644 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
3645 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
3646 #else
3647 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
3648 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
3649 #endif
3651 typedef struct _IMAGE_FUNCTION_ENTRY {
3652 DWORD StartingAddress;
3653 DWORD EndingAddress;
3654 DWORD EndOfPrologue;
3655 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3657 #define IMAGE_DEBUG_MISC_EXENAME 1
3659 typedef struct _IMAGE_DEBUG_MISC {
3660 DWORD DataType;
3661 DWORD Length;
3662 BYTE Unicode;
3663 BYTE Reserved[ 3 ];
3664 BYTE Data[ 1 ];
3665 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3667 /* This is the structure that appears at the very start of a .DBG file. */
3669 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3670 WORD Signature;
3671 WORD Flags;
3672 WORD Machine;
3673 WORD Characteristics;
3674 DWORD TimeDateStamp;
3675 DWORD CheckSum;
3676 DWORD ImageBase;
3677 DWORD SizeOfImage;
3678 DWORD NumberOfSections;
3679 DWORD ExportedNamesSize;
3680 DWORD DebugDirectorySize;
3681 DWORD SectionAlignment;
3682 DWORD Reserved[ 2 ];
3683 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3685 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3688 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3689 WORD Length;
3690 WORD Flags;
3691 BYTE Text[1];
3692 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3693 #define MESSAGE_RESOURCE_UNICODE 0x0001
3695 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3696 DWORD LowId;
3697 DWORD HighId;
3698 DWORD OffsetToEntries;
3699 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3701 typedef struct tagMESSAGE_RESOURCE_DATA {
3702 DWORD NumberOfBlocks;
3703 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
3704 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3707 * Here follows typedefs for security and tokens.
3711 * First a constant for the following typedefs.
3714 #define ANYSIZE_ARRAY 1
3716 /* FIXME: Orphan. What does it point to? */
3717 typedef PVOID PACCESS_TOKEN;
3718 typedef PVOID PSECURITY_DESCRIPTOR;
3719 typedef PVOID PSID;
3721 typedef enum _TOKEN_ELEVATION_TYPE {
3722 TokenElevationTypeDefault = 1,
3723 TokenElevationTypeFull,
3724 TokenElevationTypeLimited
3725 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
3728 * TOKEN_INFORMATION_CLASS
3731 typedef enum _TOKEN_INFORMATION_CLASS {
3732 TokenUser = 1,
3733 TokenGroups,
3734 TokenPrivileges,
3735 TokenOwner,
3736 TokenPrimaryGroup,
3737 TokenDefaultDacl,
3738 TokenSource,
3739 TokenType,
3740 TokenImpersonationLevel,
3741 TokenStatistics,
3742 TokenRestrictedSids,
3743 TokenSessionId,
3744 TokenGroupsAndPrivileges,
3745 TokenSessionReference,
3746 TokenSandBoxInert,
3747 TokenAuditPolicy,
3748 TokenOrigin,
3749 TokenElevationType,
3750 TokenLinkedToken,
3751 TokenElevation,
3752 TokenHasRestrictions,
3753 TokenAccessInformation,
3754 TokenVirtualizationAllowed,
3755 TokenVirtualizationEnabled,
3756 TokenIntegrityLevel,
3757 TokenUIAccess,
3758 TokenMandatoryPolicy,
3759 TokenLogonSid,
3760 TokenIsAppContainer,
3761 TokenCapabilities,
3762 TokenAppContainerSid,
3763 TokenAppContainerNumber,
3764 TokenUserClaimAttributes,
3765 TokenDeviceClaimAttributes,
3766 TokenRestrictedUserClaimAttributes,
3767 TokenRestrictedDeviceClaimAttributes,
3768 TokenDeviceGroups,
3769 TokenRestrictedDeviceGroups,
3770 TokenSecurityAttributes,
3771 TokenIsRestricted,
3772 TokenProcessTrustLevel,
3773 MaxTokenInfoClass
3774 } TOKEN_INFORMATION_CLASS;
3776 #define DISABLE_MAX_PRIVILEGE 0x1
3777 #define SANDBOX_INERT 0x2
3778 #define LUA_TOKEN 0x4
3779 #define WRITE_RESTRICTED 0x8
3781 #define TOKEN_ASSIGN_PRIMARY 0x0001
3782 #define TOKEN_DUPLICATE 0x0002
3783 #define TOKEN_IMPERSONATE 0x0004
3784 #define TOKEN_QUERY 0x0008
3785 #define TOKEN_QUERY_SOURCE 0x0010
3786 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3787 #define TOKEN_ADJUST_GROUPS 0x0040
3788 #define TOKEN_ADJUST_DEFAULT 0x0080
3789 #define TOKEN_ADJUST_SESSIONID 0x0100
3790 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3791 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3792 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3793 TOKEN_ADJUST_PRIVILEGES | \
3794 TOKEN_ADJUST_GROUPS | \
3795 TOKEN_ADJUST_DEFAULT )
3796 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3797 TOKEN_ASSIGN_PRIMARY | \
3798 TOKEN_DUPLICATE | \
3799 TOKEN_IMPERSONATE | \
3800 TOKEN_QUERY | \
3801 TOKEN_QUERY_SOURCE | \
3802 TOKEN_ADJUST_PRIVILEGES | \
3803 TOKEN_ADJUST_GROUPS | \
3804 TOKEN_ADJUST_SESSIONID | \
3805 TOKEN_ADJUST_DEFAULT )
3807 #ifndef _SECURITY_DEFINED
3808 #define _SECURITY_DEFINED
3810 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3812 typedef struct _GENERIC_MAPPING {
3813 ACCESS_MASK GenericRead;
3814 ACCESS_MASK GenericWrite;
3815 ACCESS_MASK GenericExecute;
3816 ACCESS_MASK GenericAll;
3817 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3819 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3820 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3821 typedef struct {
3822 BYTE Value[6];
3823 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
3824 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3826 #ifndef SID_DEFINED
3827 #define SID_DEFINED
3828 typedef struct _SID {
3829 BYTE Revision;
3830 BYTE SubAuthorityCount;
3831 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3832 DWORD SubAuthority[1];
3833 } SID,*PISID;
3834 #endif /* !defined(SID_DEFINED) */
3836 #define CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID 0x01
3838 #define SID_REVISION (1) /* Current revision */
3839 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3840 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3842 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3845 * ACL
3848 #define ACL_REVISION1 1
3849 #define ACL_REVISION2 2
3850 #define ACL_REVISION3 3
3851 #define ACL_REVISION4 4
3853 #define MIN_ACL_REVISION ACL_REVISION2
3854 #define MAX_ACL_REVISION ACL_REVISION4
3856 #define ACL_REVISION 2
3858 typedef struct _ACL {
3859 BYTE AclRevision;
3860 BYTE Sbz1;
3861 WORD AclSize;
3862 WORD AceCount;
3863 WORD Sbz2;
3864 } ACL, *PACL;
3866 typedef enum _ACL_INFORMATION_CLASS
3868 AclRevisionInformation = 1,
3869 AclSizeInformation
3870 } ACL_INFORMATION_CLASS;
3872 typedef struct _ACL_REVISION_INFORMATION
3874 DWORD AclRevision;
3875 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
3877 typedef struct _ACL_SIZE_INFORMATION
3879 DWORD AceCount;
3880 DWORD AclBytesInUse;
3881 DWORD AclBytesFree;
3882 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
3884 /* SECURITY_DESCRIPTOR */
3885 #define SECURITY_DESCRIPTOR_REVISION 1
3886 #define SECURITY_DESCRIPTOR_REVISION1 1
3890 * Privilege Names
3892 #ifdef UNICODE
3893 #if defined(_MSC_VER) || defined(__MINGW32__)
3894 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
3895 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
3896 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
3897 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
3898 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
3899 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
3900 #define SE_TCB_NAME L"SeTcbPrivilege"
3901 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
3902 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
3903 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
3904 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
3905 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
3906 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
3907 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
3908 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
3909 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
3910 #define SE_BACKUP_NAME L"SeBackupPrivilege"
3911 #define SE_RESTORE_NAME L"SeRestorePrivilege"
3912 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
3913 #define SE_DEBUG_NAME L"SeDebugPrivilege"
3914 #define SE_AUDIT_NAME L"SeAuditPrivilege"
3915 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
3916 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
3917 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
3918 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
3919 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
3920 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
3921 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
3922 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
3923 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
3924 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
3925 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
3926 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
3927 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
3928 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
3929 #else /* _MSC_VER/__MINGW32__ */
3930 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 };
3931 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 };
3932 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 };
3933 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 };
3934 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 };
3935 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 };
3936 static const WCHAR SE_TCB_NAME[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
3937 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 };
3938 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 };
3939 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 };
3940 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 };
3941 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 };
3942 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 };
3943 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 };
3944 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 };
3945 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 };
3946 static const WCHAR SE_BACKUP_NAME[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
3947 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 };
3948 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 };
3949 static const WCHAR SE_DEBUG_NAME[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
3950 static const WCHAR SE_AUDIT_NAME[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
3951 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 };
3952 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 };
3953 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 };
3954 static const WCHAR SE_UNDOCK_NAME[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
3955 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 };
3956 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 };
3957 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 };
3958 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 };
3959 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 };
3960 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 };
3961 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 };
3962 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 };
3963 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 };
3964 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 };
3965 #endif
3966 #else /* UNICODE */
3967 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
3968 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
3969 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
3970 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
3971 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
3972 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
3973 #define SE_TCB_NAME "SeTcbPrivilege"
3974 #define SE_SECURITY_NAME "SeSecurityPrivilege"
3975 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
3976 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
3977 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
3978 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
3979 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
3980 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
3981 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
3982 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
3983 #define SE_BACKUP_NAME "SeBackupPrivilege"
3984 #define SE_RESTORE_NAME "SeRestorePrivilege"
3985 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
3986 #define SE_DEBUG_NAME "SeDebugPrivilege"
3987 #define SE_AUDIT_NAME "SeAuditPrivilege"
3988 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
3989 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
3990 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
3991 #define SE_UNDOCK_NAME "SeUndockPrivilege"
3992 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
3993 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
3994 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
3995 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
3996 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
3997 #define SE_RELABEL_NAME "SeRelabelPrivilege"
3998 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
3999 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4000 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4001 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4002 #endif
4004 #define SE_GROUP_MANDATORY 0x00000001
4005 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4006 #define SE_GROUP_ENABLED 0x00000004
4007 #define SE_GROUP_OWNER 0x00000008
4008 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4009 #define SE_GROUP_INTEGRITY 0x00000020
4010 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4011 #define SE_GROUP_LOGON_ID 0xC0000000
4012 #define SE_GROUP_RESOURCE 0x20000000
4013 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4015 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4016 #define SE_PRIVILEGE_ENABLED 0x00000002
4017 #define SE_PRIVILEGE_REMOVED 0x00000004
4018 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4019 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4021 #define PRIVILEGE_SET_ALL_NECESSARY 1
4023 #define SE_OWNER_DEFAULTED 0x00000001
4024 #define SE_GROUP_DEFAULTED 0x00000002
4025 #define SE_DACL_PRESENT 0x00000004
4026 #define SE_DACL_DEFAULTED 0x00000008
4027 #define SE_SACL_PRESENT 0x00000010
4028 #define SE_SACL_DEFAULTED 0x00000020
4029 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4030 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4031 #define SE_DACL_AUTO_INHERITED 0x00000400
4032 #define SE_SACL_AUTO_INHERITED 0x00000800
4033 #define SE_DACL_PROTECTED 0x00001000
4034 #define SE_SACL_PROTECTED 0x00002000
4035 #define SE_RM_CONTROL_VALID 0x00004000
4036 #define SE_SELF_RELATIVE 0x00008000
4038 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4039 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4041 /* The security descriptor structure */
4042 typedef struct {
4043 BYTE Revision;
4044 BYTE Sbz1;
4045 SECURITY_DESCRIPTOR_CONTROL Control;
4046 DWORD Owner;
4047 DWORD Group;
4048 DWORD Sacl;
4049 DWORD Dacl;
4050 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4052 typedef struct {
4053 BYTE Revision;
4054 BYTE Sbz1;
4055 SECURITY_DESCRIPTOR_CONTROL Control;
4056 PSID Owner;
4057 PSID Group;
4058 PACL Sacl;
4059 PACL Dacl;
4060 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4062 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4064 #endif /* _SECURITY_DEFINED */
4067 * SID_AND_ATTRIBUTES
4070 typedef struct _SID_AND_ATTRIBUTES {
4071 PSID Sid;
4072 DWORD Attributes;
4073 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4075 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
4076 typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
4078 #define SID_HASH_SIZE 32
4080 typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
4082 typedef struct _SID_AND_ATTRIBUTES_HASH {
4083 DWORD SidCount;
4084 PSID_AND_ATTRIBUTES SidAttr;
4085 SID_HASH_ENTRY Hash[SID_HASH_SIZE];
4086 } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
4088 /* security entities */
4089 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4090 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4091 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4093 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4095 /* S-1-1 */
4096 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4098 /* S-1-2 */
4099 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4100 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4102 /* S-1-3 */
4103 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4104 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4105 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4106 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4107 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4108 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4110 /* S-1-4 */
4111 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4113 /* S-1-5 */
4114 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4115 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4116 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4117 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4118 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4119 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4120 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4121 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4122 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4123 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4124 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4125 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4126 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4127 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4128 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4129 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4130 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4131 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4132 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4133 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4134 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4135 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4136 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4137 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4139 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4140 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4141 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4142 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4143 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4144 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4145 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4146 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4147 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4148 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4149 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4150 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4151 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4152 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4153 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4154 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4155 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4156 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4157 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4158 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4159 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4160 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4162 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4164 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4165 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4166 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4167 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4168 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4170 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4171 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4172 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4173 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4174 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4175 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4176 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4177 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4178 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4179 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4181 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4183 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4184 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4185 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4186 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4187 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4188 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4189 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4190 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4191 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4192 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4193 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4195 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4196 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4197 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4198 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4199 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4200 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4201 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4202 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4203 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4205 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4207 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4208 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4209 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4210 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4212 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4213 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4214 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4215 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4217 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4218 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4219 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4220 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4221 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4222 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4224 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4225 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4226 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4227 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4228 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4229 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4230 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4231 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4232 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4233 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4234 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4236 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4238 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4239 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4240 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4241 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4242 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4243 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4244 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4245 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4246 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4247 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4248 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4250 #define SYSTEM_LUID { 0x3e7, 0x0 }
4251 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4252 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4253 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4254 #define IUSER_LUID { 0x3e3, 0x0 }
4256 typedef enum {
4257 WinNullSid = 0,
4258 WinWorldSid = 1,
4259 WinLocalSid = 2,
4260 WinCreatorOwnerSid = 3,
4261 WinCreatorGroupSid = 4,
4262 WinCreatorOwnerServerSid = 5,
4263 WinCreatorGroupServerSid = 6,
4264 WinNtAuthoritySid = 7,
4265 WinDialupSid = 8,
4266 WinNetworkSid = 9,
4267 WinBatchSid = 10,
4268 WinInteractiveSid = 11,
4269 WinServiceSid = 12,
4270 WinAnonymousSid = 13,
4271 WinProxySid = 14,
4272 WinEnterpriseControllersSid = 15,
4273 WinSelfSid = 16,
4274 WinAuthenticatedUserSid = 17,
4275 WinRestrictedCodeSid = 18,
4276 WinTerminalServerSid = 19,
4277 WinRemoteLogonIdSid = 20,
4278 WinLogonIdsSid = 21,
4279 WinLocalSystemSid = 22,
4280 WinLocalServiceSid = 23,
4281 WinNetworkServiceSid = 24,
4282 WinBuiltinDomainSid = 25,
4283 WinBuiltinAdministratorsSid = 26,
4284 WinBuiltinUsersSid = 27,
4285 WinBuiltinGuestsSid = 28,
4286 WinBuiltinPowerUsersSid = 29,
4287 WinBuiltinAccountOperatorsSid = 30,
4288 WinBuiltinSystemOperatorsSid = 31,
4289 WinBuiltinPrintOperatorsSid = 32,
4290 WinBuiltinBackupOperatorsSid = 33,
4291 WinBuiltinReplicatorSid = 34,
4292 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4293 WinBuiltinRemoteDesktopUsersSid = 36,
4294 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4295 WinAccountAdministratorSid = 38,
4296 WinAccountGuestSid = 39,
4297 WinAccountKrbtgtSid = 40,
4298 WinAccountDomainAdminsSid = 41,
4299 WinAccountDomainUsersSid = 42,
4300 WinAccountDomainGuestsSid = 43,
4301 WinAccountComputersSid = 44,
4302 WinAccountControllersSid = 45,
4303 WinAccountCertAdminsSid = 46,
4304 WinAccountSchemaAdminsSid = 47,
4305 WinAccountEnterpriseAdminsSid = 48,
4306 WinAccountPolicyAdminsSid = 49,
4307 WinAccountRasAndIasServersSid = 50,
4308 WinNTLMAuthenticationSid = 51,
4309 WinDigestAuthenticationSid = 52,
4310 WinSChannelAuthenticationSid = 53,
4311 WinThisOrganizationSid = 54,
4312 WinOtherOrganizationSid = 55,
4313 WinBuiltinIncomingForestTrustBuildersSid = 56,
4314 WinBuiltinPerfMonitoringUsersSid = 57,
4315 WinBuiltinPerfLoggingUsersSid = 58,
4316 WinBuiltinAuthorizationAccessSid = 59,
4317 WinBuiltinTerminalServerLicenseServersSid = 60,
4318 WinBuiltinDCOMUsersSid = 61,
4319 WinBuiltinIUsersSid = 62,
4320 WinIUserSid = 63,
4321 WinBuiltinCryptoOperatorsSid = 64,
4322 WinUntrustedLabelSid = 65,
4323 WinLowLabelSid = 66,
4324 WinMediumLabelSid = 67,
4325 WinHighLabelSid = 68,
4326 WinSystemLabelSid = 69,
4327 WinWriteRestrictedCodeSid = 70,
4328 WinCreatorOwnerRightsSid = 71,
4329 WinCacheablePrincipalsGroupSid = 72,
4330 WinNonCacheablePrincipalsGroupSid = 73,
4331 WinEnterpriseReadonlyControllersSid = 74,
4332 WinAccountReadonlyControllersSid = 75,
4333 WinBuiltinEventLogReadersGroup = 76,
4334 WinNewEnterpriseReadonlyControllersSid = 77,
4335 WinBuiltinCertSvcDComAccessGroup = 78,
4336 WinMediumPlusLabelSid = 79,
4337 WinLocalLogonSid = 80,
4338 WinConsoleLogonSid = 81,
4339 WinThisOrganizationCertificateSid = 82,
4340 WinApplicationPackageAuthoritySid = 83,
4341 WinBuiltinAnyPackageSid = 84,
4342 WinCapabilityInternetClientSid = 85,
4343 WinCapabilityInternetClientServerSid = 86,
4344 WinCapabilityPrivateNetworkClientServerSid = 87,
4345 WinCapabilityPicturesLibrarySid = 88,
4346 WinCapabilityVideosLibrarySid = 89,
4347 WinCapabilityMusicLibrarySid = 90,
4348 WinCapabilityDocumentsLibrarySid = 91,
4349 WinCapabilitySharedUserCertificatesSid = 92,
4350 WinCapabilityEnterpriseAuthenticationSid = 93,
4351 WinCapabilityRemovableStorageSid = 94,
4352 WinBuiltinRDSRemoteAccessServersSid = 95,
4353 WinBuiltinRDSEndpointServersSid = 96,
4354 WinBuiltinRDSManagementServersSid = 97,
4355 WinUserModeDriversSid = 98,
4356 WinBuiltinHyperVAdminsSid = 99,
4357 WinAccountCloneableControllersSid = 100,
4358 WinBuiltinAccessControlAssistanceOperatorsSid = 101,
4359 WinBuiltinRemoteManagementUsersSid = 102,
4360 WinAuthenticationAuthorityAssertedSid = 103,
4361 WinAuthenticationServiceAssertedSid = 104,
4362 WinLocalAccountSid = 105,
4363 WinLocalAccountAndAdministratorSid = 106,
4364 WinAccountProtectedUsersSid = 107,
4365 } WELL_KNOWN_SID_TYPE;
4368 * TOKEN_USER
4371 typedef struct _TOKEN_USER {
4372 SID_AND_ATTRIBUTES User;
4373 } TOKEN_USER, *PTOKEN_USER;
4376 * TOKEN_GROUPS
4379 typedef struct _TOKEN_GROUPS {
4380 DWORD GroupCount;
4381 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4382 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4385 * LUID_AND_ATTRIBUTES
4388 typedef union _LARGE_INTEGER {
4389 struct {
4390 #ifdef WORDS_BIGENDIAN
4391 LONG HighPart;
4392 DWORD LowPart;
4393 #else
4394 DWORD LowPart;
4395 LONG HighPart;
4396 #endif
4397 } u;
4398 #ifndef NONAMELESSSTRUCT
4399 struct {
4400 #ifdef WORDS_BIGENDIAN
4401 LONG HighPart;
4402 DWORD LowPart;
4403 #else
4404 DWORD LowPart;
4405 LONG HighPart;
4406 #endif
4408 #endif
4409 LONGLONG QuadPart;
4410 } LARGE_INTEGER, *PLARGE_INTEGER;
4412 typedef union _ULARGE_INTEGER {
4413 struct {
4414 #ifdef WORDS_BIGENDIAN
4415 DWORD HighPart;
4416 DWORD LowPart;
4417 #else
4418 DWORD LowPart;
4419 DWORD HighPart;
4420 #endif
4421 } u;
4422 #ifndef NONAMELESSSTRUCT
4423 struct {
4424 #ifdef WORDS_BIGENDIAN
4425 DWORD HighPart;
4426 DWORD LowPart;
4427 #else
4428 DWORD LowPart;
4429 DWORD HighPart;
4430 #endif
4432 #endif
4433 ULONGLONG QuadPart;
4434 } ULARGE_INTEGER, *PULARGE_INTEGER;
4437 * Locally Unique Identifier
4440 typedef struct _LUID {
4441 DWORD LowPart;
4442 LONG HighPart;
4443 } LUID, *PLUID;
4445 #include <pshpack4.h>
4446 typedef struct _LUID_AND_ATTRIBUTES {
4447 LUID Luid;
4448 DWORD Attributes;
4449 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4450 #include <poppack.h>
4453 * PRIVILEGE_SET
4456 typedef struct _PRIVILEGE_SET {
4457 DWORD PrivilegeCount;
4458 DWORD Control;
4459 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4460 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4463 * TOKEN_PRIVILEGES
4466 typedef struct _TOKEN_PRIVILEGES {
4467 DWORD PrivilegeCount;
4468 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4469 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4472 * TOKEN_OWNER
4475 typedef struct _TOKEN_OWNER {
4476 PSID Owner;
4477 } TOKEN_OWNER, *PTOKEN_OWNER;
4480 * TOKEN_PRIMARY_GROUP
4483 typedef struct _TOKEN_PRIMARY_GROUP {
4484 PSID PrimaryGroup;
4485 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4489 * TOKEN_DEFAULT_DACL
4492 typedef struct _TOKEN_DEFAULT_DACL {
4493 PACL DefaultDacl;
4494 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4497 * TOKEN_SOURCE
4500 #define TOKEN_SOURCE_LENGTH 8
4502 typedef struct _TOKEN_SOURCE {
4503 char SourceName[TOKEN_SOURCE_LENGTH];
4504 LUID SourceIdentifier;
4505 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4508 * TOKEN_TYPE
4511 typedef enum tagTOKEN_TYPE {
4512 TokenPrimary = 1,
4513 TokenImpersonation
4514 } TOKEN_TYPE;
4517 * SECURITY_IMPERSONATION_LEVEL
4520 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4521 SecurityAnonymous,
4522 SecurityIdentification,
4523 SecurityImpersonation,
4524 SecurityDelegation
4525 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4527 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4528 #define SECURITY_STATIC_TRACKING (FALSE)
4530 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4531 * PSECURITY_CONTEXT_TRACKING_MODE;
4533 * Quality of Service
4536 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4537 DWORD Length;
4538 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4539 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4540 BOOLEAN EffectiveOnly;
4541 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4544 * TOKEN_STATISTICS
4547 #include <pshpack4.h>
4548 typedef struct _TOKEN_STATISTICS {
4549 LUID TokenId;
4550 LUID AuthenticationId;
4551 LARGE_INTEGER ExpirationTime;
4552 TOKEN_TYPE TokenType;
4553 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4554 DWORD DynamicCharged;
4555 DWORD DynamicAvailable;
4556 DWORD GroupCount;
4557 DWORD PrivilegeCount;
4558 LUID ModifiedId;
4559 } TOKEN_STATISTICS;
4560 #include <poppack.h>
4562 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4563 DWORD SidCount;
4564 DWORD SidLength;
4565 PSID_AND_ATTRIBUTES Sids;
4566 DWORD RestrictedSidCount;
4567 DWORD RestrictedSidLength;
4568 PSID_AND_ATTRIBUTES RestrictedSids;
4569 DWORD PrivilegeCount;
4570 DWORD PrivilegeLength;
4571 PLUID_AND_ATTRIBUTES Privileges;
4572 LUID AuthenticationId;
4573 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4575 typedef struct _TOKEN_ORIGIN {
4576 LUID OriginatingLogonSession;
4577 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4579 typedef struct _TOKEN_LINKED_TOKEN {
4580 HANDLE LinkedToken;
4581 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4583 typedef struct _TOKEN_ELEVATION {
4584 DWORD TokenIsElevated;
4585 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
4587 typedef struct _TOKEN_MANDATORY_LABEL {
4588 SID_AND_ATTRIBUTES Label;
4589 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
4591 #define TOKEN_MANDATORY_POLICY_OFF 0x0
4592 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
4593 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
4594 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
4596 typedef struct _TOKEN_MANDATORY_POLICY {
4597 DWORD Policy;
4598 } TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY;
4600 typedef struct _TOKEN_APPCONTAINER_INFORMATION {
4601 PSID TokenAppContainer;
4602 } TOKEN_APPCONTAINER_INFORMATION, * PTOKEN_APPCONTAINER_INFORMATION;
4604 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
4606 typedef struct _TOKEN_AUDIT_POLICY {
4607 BYTE PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
4608 } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
4610 typedef struct _TOKEN_ACCESS_INFORMATION {
4611 PSID_AND_ATTRIBUTES_HASH SidHash;
4612 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
4613 PTOKEN_PRIVILEGES Privileges;
4614 LUID AuthenticationId;
4615 TOKEN_TYPE TokenType;
4616 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4617 TOKEN_MANDATORY_POLICY MandatoryPolicy;
4618 DWORD Flags;
4619 } TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION;
4621 typedef struct _TOKEN_CONTROL {
4622 LUID TokenId;
4623 LUID AuthenticationId;
4624 LUID ModifiedId;
4625 TOKEN_SOURCE TokenSource;
4626 } TOKEN_CONTROL, *PTOKEN_CONTROL;
4629 * ACLs of NT
4632 /* ACEs, directly starting after an ACL */
4633 typedef struct _ACE_HEADER {
4634 BYTE AceType;
4635 BYTE AceFlags;
4636 WORD AceSize;
4637 } ACE_HEADER,*PACE_HEADER;
4639 /* AceType */
4640 #define ACCESS_MIN_MS_ACE_TYPE 0x0
4641 #define ACCESS_ALLOWED_ACE_TYPE 0x0
4642 #define ACCESS_DENIED_ACE_TYPE 0x1
4643 #define SYSTEM_AUDIT_ACE_TYPE 0x2
4644 #define SYSTEM_ALARM_ACE_TYPE 0x3
4645 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
4646 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
4647 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
4648 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
4649 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
4650 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
4651 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
4652 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
4653 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
4654 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
4655 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
4656 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
4657 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
4658 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
4659 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
4660 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
4661 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
4662 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
4663 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
4664 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
4665 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
4666 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
4668 /* inherit AceFlags */
4669 #define OBJECT_INHERIT_ACE 0x01
4670 #define CONTAINER_INHERIT_ACE 0x02
4671 #define NO_PROPAGATE_INHERIT_ACE 0x04
4672 #define INHERIT_ONLY_ACE 0x08
4673 #define INHERITED_ACE 0x10
4674 #define VALID_INHERIT_FLAGS 0x1F
4676 /* AceFlags mask for what events we (should) audit */
4677 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4678 #define FAILED_ACCESS_ACE_FLAG 0x80
4680 /* different ACEs depending on AceType
4681 * SidStart marks the begin of a SID
4682 * so the thing finally looks like this:
4683 * 0: ACE_HEADER
4684 * 4: ACCESS_MASK
4685 * 8... : SID
4687 typedef struct _ACCESS_ALLOWED_ACE {
4688 ACE_HEADER Header;
4689 DWORD Mask;
4690 DWORD SidStart;
4691 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
4693 typedef struct _ACCESS_DENIED_ACE {
4694 ACE_HEADER Header;
4695 DWORD Mask;
4696 DWORD SidStart;
4697 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
4699 typedef struct _SYSTEM_AUDIT_ACE {
4700 ACE_HEADER Header;
4701 DWORD Mask;
4702 DWORD SidStart;
4703 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
4705 typedef struct _SYSTEM_ALARM_ACE {
4706 ACE_HEADER Header;
4707 DWORD Mask;
4708 DWORD SidStart;
4709 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
4711 typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
4712 ACE_HEADER Header;
4713 ACCESS_MASK Mask;
4714 DWORD SidStart;
4715 } SYSTEM_MANDATORY_LABEL_ACE,*PSYSTEM_MANDATORY_LABEL_ACE;
4717 typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
4718 ACE_HEADER Header;
4719 ACCESS_MASK Mask;
4720 DWORD Flags;
4721 GUID ObjectType;
4722 GUID InheritedObjectType;
4723 DWORD SidStart;
4724 } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
4726 typedef struct _ACCESS_DENIED_OBJECT_ACE {
4727 ACE_HEADER Header;
4728 ACCESS_MASK Mask;
4729 DWORD Flags;
4730 GUID ObjectType;
4731 GUID InheritedObjectType;
4732 DWORD SidStart;
4733 } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
4735 typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
4736 ACE_HEADER Header;
4737 ACCESS_MASK Mask;
4738 DWORD Flags;
4739 GUID ObjectType;
4740 GUID InheritedObjectType;
4741 DWORD SidStart;
4742 } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
4744 typedef struct _SYSTEM_ALARM_OBJECT_ACE {
4745 ACE_HEADER Header;
4746 ACCESS_MASK Mask;
4747 DWORD Flags;
4748 GUID ObjectType;
4749 GUID InheritedObjectType;
4750 DWORD SidStart;
4751 } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_aCE;
4753 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
4754 ACE_HEADER Header;
4755 DWORD Mask;
4756 DWORD SidStart;
4757 } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
4759 typedef struct _ACCESS_DENIED_CALLBACK_ACE {
4760 ACE_HEADER Header;
4761 DWORD Mask;
4762 DWORD SidStart;
4763 } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
4765 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
4766 ACE_HEADER Header;
4767 DWORD Mask;
4768 DWORD SidStart;
4769 } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
4771 typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
4772 ACE_HEADER Header;
4773 DWORD Mask;
4774 DWORD SidStart;
4775 } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
4777 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
4778 ACE_HEADER Header;
4779 ACCESS_MASK Mask;
4780 DWORD Flags;
4781 GUID ObjectType;
4782 GUID InheritedObjectType;
4783 DWORD SidStart;
4784 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
4786 typedef struct _ACCESS_DENIED_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_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
4795 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
4796 ACE_HEADER Header;
4797 ACCESS_MASK Mask;
4798 DWORD Flags;
4799 GUID ObjectType;
4800 GUID InheritedObjectType;
4801 DWORD SidStart;
4802 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
4804 typedef struct _SYSTEM_ALARM_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_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
4813 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
4814 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
4815 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
4816 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
4818 typedef enum tagSID_NAME_USE {
4819 SidTypeUser = 1,
4820 SidTypeGroup,
4821 SidTypeDomain,
4822 SidTypeAlias,
4823 SidTypeWellKnownGroup,
4824 SidTypeDeletedAccount,
4825 SidTypeInvalid,
4826 SidTypeUnknown
4827 } SID_NAME_USE,*PSID_NAME_USE;
4829 #define ACE_OBJECT_TYPE_PRESENT 0x1
4830 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4832 /* Access rights */
4834 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4835 #undef DELETE
4836 #define DELETE 0x00010000
4837 #define READ_CONTROL 0x00020000
4838 #define WRITE_DAC 0x00040000
4839 #define WRITE_OWNER 0x00080000
4840 #define SYNCHRONIZE 0x00100000
4841 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4843 #define STANDARD_RIGHTS_READ READ_CONTROL
4844 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4845 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4847 #define STANDARD_RIGHTS_ALL 0x001f0000
4849 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4851 #define GENERIC_READ 0x80000000
4852 #define GENERIC_WRITE 0x40000000
4853 #define GENERIC_EXECUTE 0x20000000
4854 #define GENERIC_ALL 0x10000000
4856 #define MAXIMUM_ALLOWED 0x02000000
4857 #define ACCESS_SYSTEM_SECURITY 0x01000000
4859 #define EVENT_QUERY_STATE 0x0001
4860 #define EVENT_MODIFY_STATE 0x0002
4861 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4863 #define SEMAPHORE_QUERY_STATE 0x0001
4864 #define SEMAPHORE_MODIFY_STATE 0x0002
4865 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4867 #define MUTANT_QUERY_STATE 0x0001
4868 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
4870 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
4871 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
4872 #define JOB_OBJECT_QUERY 0x0004
4873 #define JOB_OBJECT_TERMINATE 0x0008
4874 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
4875 #define JOB_OBJECT_IMPERSONATE 0x0020
4876 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3f)
4878 #define TIMER_QUERY_STATE 0x0001
4879 #define TIMER_MODIFY_STATE 0x0002
4880 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4882 #define PROCESS_TERMINATE 0x0001
4883 #define PROCESS_CREATE_THREAD 0x0002
4884 #define PROCESS_VM_OPERATION 0x0008
4885 #define PROCESS_VM_READ 0x0010
4886 #define PROCESS_VM_WRITE 0x0020
4887 #define PROCESS_DUP_HANDLE 0x0040
4888 #define PROCESS_CREATE_PROCESS 0x0080
4889 #define PROCESS_SET_QUOTA 0x0100
4890 #define PROCESS_SET_INFORMATION 0x0200
4891 #define PROCESS_QUERY_INFORMATION 0x0400
4892 #define PROCESS_SUSPEND_RESUME 0x0800
4893 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
4894 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
4895 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
4897 #define THREAD_TERMINATE 0x0001
4898 #define THREAD_SUSPEND_RESUME 0x0002
4899 #define THREAD_GET_CONTEXT 0x0008
4900 #define THREAD_SET_CONTEXT 0x0010
4901 #define THREAD_SET_INFORMATION 0x0020
4902 #define THREAD_QUERY_INFORMATION 0x0040
4903 #define THREAD_SET_THREAD_TOKEN 0x0080
4904 #define THREAD_IMPERSONATE 0x0100
4905 #define THREAD_DIRECT_IMPERSONATION 0x0200
4906 #define THREAD_SET_LIMITED_INFORMATION 0x0400
4907 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
4908 #define THREAD_RESUME 0x1000
4909 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
4911 #define THREAD_BASE_PRIORITY_LOWRT 15
4912 #define THREAD_BASE_PRIORITY_MAX 2
4913 #define THREAD_BASE_PRIORITY_MIN -2
4914 #define THREAD_BASE_PRIORITY_IDLE -15
4916 typedef struct _QUOTA_LIMITS {
4917 SIZE_T PagedPoolLimit;
4918 SIZE_T NonPagedPoolLimit;
4919 SIZE_T MinimumWorkingSetSize;
4920 SIZE_T MaximumWorkingSetSize;
4921 SIZE_T PagefileLimit;
4922 LARGE_INTEGER TimeLimit;
4923 } QUOTA_LIMITS, *PQUOTA_LIMITS;
4925 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
4926 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
4927 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
4928 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
4929 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
4931 typedef union _RATE_QUOTA_LIMIT {
4932 DWORD RateData;
4933 struct {
4934 DWORD RatePercent:7;
4935 DWORD Reserved0:25;
4936 } DUMMYSTRUCTNAME;
4937 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
4939 typedef struct _QUOTA_LIMITS_EX {
4940 SIZE_T PagedPoolLimit;
4941 SIZE_T NonPagedPoolLimit;
4942 SIZE_T MinimumWorkingSetSize;
4943 SIZE_T MaximumWorkingSetSize;
4944 SIZE_T PagefileLimit;
4945 LARGE_INTEGER TimeLimit;
4946 SIZE_T WorkingSetLimit;
4947 SIZE_T Reserved2;
4948 SIZE_T Reserved3;
4949 SIZE_T Reserved4;
4950 DWORD Flags;
4951 RATE_QUOTA_LIMIT CpuRateLimit;
4952 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
4954 #define SECTION_QUERY 0x0001
4955 #define SECTION_MAP_WRITE 0x0002
4956 #define SECTION_MAP_READ 0x0004
4957 #define SECTION_MAP_EXECUTE 0x0008
4958 #define SECTION_EXTEND_SIZE 0x0010
4959 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
4960 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
4962 #define FILE_READ_DATA 0x0001 /* file & pipe */
4963 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
4964 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
4965 #define FILE_ADD_FILE 0x0002 /* directory */
4966 #define FILE_APPEND_DATA 0x0004 /* file */
4967 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
4968 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
4969 #define FILE_READ_EA 0x0008 /* file & directory */
4970 #define FILE_READ_PROPERTIES FILE_READ_EA
4971 #define FILE_WRITE_EA 0x0010 /* file & directory */
4972 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
4973 #define FILE_EXECUTE 0x0020 /* file */
4974 #define FILE_TRAVERSE 0x0020 /* directory */
4975 #define FILE_DELETE_CHILD 0x0040 /* directory */
4976 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
4977 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
4978 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
4980 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
4981 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
4982 SYNCHRONIZE)
4983 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
4984 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
4985 FILE_APPEND_DATA | SYNCHRONIZE)
4986 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
4987 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
4989 #define DUPLICATE_CLOSE_SOURCE 0x00000001
4990 #define DUPLICATE_SAME_ACCESS 0x00000002
4991 #ifdef __WINESRC__
4992 #define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
4993 #endif
4995 /* File attribute flags */
4996 #define FILE_SHARE_READ 0x00000001
4997 #define FILE_SHARE_WRITE 0x00000002
4998 #define FILE_SHARE_DELETE 0x00000004
5000 #define FILE_ATTRIBUTE_READONLY 0x00000001
5001 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5002 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5003 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5004 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5005 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5006 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5007 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5008 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5009 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5010 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5011 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5012 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5013 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5014 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5015 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5016 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5017 #define FILE_ATTRIBUTE_EA 0x00040000
5019 /* File notification flags */
5020 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5021 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5022 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5023 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5024 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5025 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5026 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5027 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5028 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5029 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5030 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5031 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5032 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5034 #define FILE_ACTION_ADDED 0x00000001
5035 #define FILE_ACTION_REMOVED 0x00000002
5036 #define FILE_ACTION_MODIFIED 0x00000003
5037 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5038 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5039 #define FILE_ACTION_ADDED_STREAM 0x00000006
5040 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5041 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5042 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5043 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5044 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5046 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5047 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5048 #define FILE_UNICODE_ON_DISK 0x00000004
5049 #define FILE_PERSISTENT_ACLS 0x00000008
5050 #define FILE_FILE_COMPRESSION 0x00000010
5051 #define FILE_VOLUME_QUOTAS 0x00000020
5052 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5053 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5054 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5055 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5056 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5057 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5058 #define FILE_NAMED_STREAMS 0x00040000
5059 #define FILE_READ_ONLY_VOLUME 0x00080000
5060 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5061 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5062 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5063 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5064 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5065 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5066 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5067 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5068 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5069 #define FILE_DAX_VOLUME 0x20000000
5070 #define FILE_SUPPORTS_GHOSTING 0x40000000
5072 /* File alignments (NT) */
5073 #define FILE_BYTE_ALIGNMENT 0x00000000
5074 #define FILE_WORD_ALIGNMENT 0x00000001
5075 #define FILE_LONG_ALIGNMENT 0x00000003
5076 #define FILE_QUAD_ALIGNMENT 0x00000007
5077 #define FILE_OCTA_ALIGNMENT 0x0000000f
5078 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5079 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5080 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5081 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5082 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5084 #define COMPRESSION_FORMAT_NONE 0
5085 #define COMPRESSION_FORMAT_DEFAULT 1
5086 #define COMPRESSION_FORMAT_LZNT1 2
5087 #define COMPRESSION_ENGINE_STANDARD 0
5088 #define COMPRESSION_ENGINE_MAXIMUM 256
5090 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5091 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5093 #define REG_NONE 0 /* no type */
5094 #define REG_SZ 1 /* string type (ASCII) */
5095 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5096 #define REG_BINARY 3 /* binary format, callerspecific */
5097 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5098 #define REG_DWORD 4 /* DWORD in little endian format */
5099 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5100 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5101 #define REG_LINK 6 /* symbolic link (UNICODE) */
5102 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5103 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5104 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5105 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5106 #define REG_QWORD 11 /* QWORD in little endian format */
5107 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5109 /* ----------------------------- begin power management --------------------- */
5111 typedef enum _LATENCY_TIME {
5112 LT_DONT_CARE,
5113 LT_LOWEST_LATENCY
5114 } LATENCY_TIME, *PLATENCY_TIME;
5116 #define DISCHARGE_POLICY_CRITICAL 0
5117 #define DISCHARGE_POLICY_LOW 1
5118 #define NUM_DISCHARGE_POLICIES 4
5120 #define PO_THROTTLE_NONE 0
5121 #define PO_THROTTLE_CONSTANT 1
5122 #define PO_THROTTLE_DEGRADE 2
5123 #define PO_THROTTLE_ADAPTIVE 3
5125 typedef enum _POWER_ACTION {
5126 PowerActionNone = 0,
5127 PowerActionReserved,
5128 PowerActionSleep,
5129 PowerActionHibernate,
5130 PowerActionShutdown,
5131 PowerActionShutdownReset,
5132 PowerActionShutdownOff,
5133 PowerActionWarmEject
5134 } POWER_ACTION,
5135 *PPOWER_ACTION;
5137 typedef enum _POWER_PLATFORM_ROLE {
5138 PlatformRoleUnspecified,
5139 PlatformRoleDesktop,
5140 PlatformRoleMobile,
5141 PlatformRoleWorkstation,
5142 PlatformRoleEnterpriseServer,
5143 PlatformRoleSOHOServer,
5144 PlatformRoleAppliancePC,
5145 PlatformRolePerformanceServer,
5146 PlatformRoleSlate,
5147 PlatformRoleMaximum
5148 } POWER_PLATFORM_ROLE, *PPOWER_PLATFORM_ROLE;
5150 typedef enum _SYSTEM_POWER_STATE {
5151 PowerSystemUnspecified = 0,
5152 PowerSystemWorking = 1,
5153 PowerSystemSleeping1 = 2,
5154 PowerSystemSleeping2 = 3,
5155 PowerSystemSleeping3 = 4,
5156 PowerSystemHibernate = 5,
5157 PowerSystemShutdown = 6,
5158 PowerSystemMaximum = 7
5159 } SYSTEM_POWER_STATE,
5160 *PSYSTEM_POWER_STATE;
5162 typedef enum _DEVICE_POWER_STATE {
5163 PowerDeviceUnspecified,
5164 PowerDeviceD0,
5165 PowerDeviceD1,
5166 PowerDeviceD2,
5167 PowerDeviceD3,
5168 PowerDeviceMaximum
5169 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
5171 typedef enum _POWER_INFORMATION_LEVEL {
5172 SystemPowerPolicyAc,
5173 SystemPowerPolicyDc,
5174 VerifySystemPolicyAc,
5175 VerifySystemPolicyDc,
5176 SystemPowerCapabilities,
5177 SystemBatteryState,
5178 SystemPowerStateHandler,
5179 ProcessorStateHandler,
5180 SystemPowerPolicyCurrent,
5181 AdministratorPowerPolicy,
5182 SystemReserveHiberFile,
5183 ProcessorInformation,
5184 SystemPowerInformation,
5185 ProcessorStateHandler2,
5186 LastWakeTime,
5187 LastSleepTime,
5188 SystemExecutionState,
5189 SystemPowerStateNotifyHandler,
5190 ProcessorPowerPolicyAc,
5191 ProcessorPowerPolicyDc,
5192 VerifyProcessorPowerPolicyAc,
5193 VerifyProcessorPowerPolicyDc,
5194 ProcessorPowerPolicyCurrent
5195 } POWER_INFORMATION_LEVEL;
5197 typedef struct _ADMINISTRATOR_POWER_POLICY {
5198 SYSTEM_POWER_STATE MinSleep;
5199 SYSTEM_POWER_STATE MaxSleep;
5200 ULONG MinVideoTimeout;
5201 ULONG MaxVideoTimeout;
5202 ULONG MinSpindownTimeout;
5203 ULONG MaxSpindownTimeout;
5204 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
5206 typedef struct {
5207 ULONG Granularity;
5208 ULONG Capacity;
5209 } BATTERY_REPORTING_SCALE,
5210 *PBATTERY_REPORTING_SCALE;
5212 typedef struct {
5213 POWER_ACTION Action;
5214 ULONG Flags;
5215 ULONG EventCode;
5216 } POWER_ACTION_POLICY,
5217 *PPOWER_ACTION_POLICY;
5219 typedef struct _PROCESSOR_POWER_INFORMATION {
5220 ULONG Number;
5221 ULONG MaxMhz;
5222 ULONG CurrentMhz;
5223 ULONG MhzLimit;
5224 ULONG MaxIdleState;
5225 ULONG CurrentIdleState;
5226 } PROCESSOR_POWER_INFORMATION,
5227 *PPROCESSOR_POWER_INFORMATION;
5229 typedef struct _PROCESSOR_POWER_POLICY_INFO {
5230 ULONG TimeCheck;
5231 ULONG DemoteLimit;
5232 ULONG PromoteLimit;
5233 UCHAR DemotePercent;
5234 UCHAR PromotePercent;
5235 UCHAR Spare[2];
5236 ULONG AllowDemotion:1;
5237 ULONG AllowPromotion:1;
5238 ULONG Reserved:30;
5239 } PROCESSOR_POWER_POLICY_INFO,
5240 *PPROCESSOR_POWER_POLICY_INFO;
5242 typedef struct _PROCESSOR_POWER_POLICY {
5243 DWORD Revision;
5244 BYTE DynamicThrottle;
5245 BYTE Spare[3];
5246 DWORD DisableCStates:1;
5247 DWORD Reserved:31;
5248 DWORD PolicyCount;
5249 PROCESSOR_POWER_POLICY_INFO Policy[3];
5250 } PROCESSOR_POWER_POLICY,
5251 *PPROCESSOR_POWER_POLICY;
5253 typedef struct {
5254 BOOLEAN AcOnLine;
5255 BOOLEAN BatteryPresent;
5256 BOOLEAN Charging;
5257 BOOLEAN Discharging;
5258 BOOLEAN Spare1[3];
5259 BYTE Tag;
5260 ULONG MaxCapacity;
5261 ULONG RemainingCapacity;
5262 ULONG Rate;
5263 ULONG EstimatedTime;
5264 ULONG DefaultAlert1;
5265 ULONG DefaultAlert2;
5266 } SYSTEM_BATTERY_STATE,
5267 *PSYSTEM_BATTERY_STATE;
5269 typedef struct {
5270 BOOLEAN PowerButtonPresent;
5271 BOOLEAN SleepButtonPresent;
5272 BOOLEAN LidPresent;
5273 BOOLEAN SystemS1;
5274 BOOLEAN SystemS2;
5275 BOOLEAN SystemS3;
5276 BOOLEAN SystemS4;
5277 BOOLEAN SystemS5;
5278 BOOLEAN HiberFilePresent;
5279 BOOLEAN FullWake;
5280 BOOLEAN VideoDimPresent;
5281 BOOLEAN ApmPresent;
5282 BOOLEAN UpsPresent;
5283 BOOLEAN ThermalControl;
5284 BOOLEAN ProcessorThrottle;
5285 UCHAR ProcessorMinThrottle;
5286 UCHAR ProcessorMaxThrottle;
5287 UCHAR spare2[4];
5288 BOOLEAN DiskSpinDown;
5289 UCHAR spare3[8];
5290 BOOLEAN SystemBatteriesPresent;
5291 BOOLEAN BatteriesAreShortTerm;
5292 BATTERY_REPORTING_SCALE BatteryScale[3];
5293 SYSTEM_POWER_STATE AcOnLineWake;
5294 SYSTEM_POWER_STATE SoftLidWake;
5295 SYSTEM_POWER_STATE RtcWake;
5296 SYSTEM_POWER_STATE MinDeviceWakeState;
5297 SYSTEM_POWER_STATE DefaultLowLatencyWake;
5298 } SYSTEM_POWER_CAPABILITIES,
5299 *PSYSTEM_POWER_CAPABILITIES;
5301 typedef struct _SYSTEM_POWER_INFORMATION {
5302 ULONG MaxIdlenessAllowed;
5303 ULONG Idleness;
5304 ULONG TimeRemaining;
5305 UCHAR CoolingMode;
5306 } SYSTEM_POWER_INFORMATION,
5307 *PSYSTEM_POWER_INFORMATION;
5309 typedef struct _SYSTEM_POWER_LEVEL {
5310 BOOLEAN Enable;
5311 UCHAR Spare[3];
5312 ULONG BatteryLevel;
5313 POWER_ACTION_POLICY PowerPolicy;
5314 SYSTEM_POWER_STATE MinSystemState;
5315 } SYSTEM_POWER_LEVEL,
5316 *PSYSTEM_POWER_LEVEL;
5318 typedef struct _SYSTEM_POWER_POLICY {
5319 ULONG Revision;
5320 POWER_ACTION_POLICY PowerButton;
5321 POWER_ACTION_POLICY SleepButton;
5322 POWER_ACTION_POLICY LidClose;
5323 SYSTEM_POWER_STATE LidOpenWake;
5324 ULONG Reserved;
5325 POWER_ACTION_POLICY Idle;
5326 ULONG IdleTimeout;
5327 UCHAR IdleSensitivity;
5328 UCHAR DynamicThrottle;
5329 UCHAR Spare2[2];
5330 SYSTEM_POWER_STATE MinSleep;
5331 SYSTEM_POWER_STATE MaxSleep;
5332 SYSTEM_POWER_STATE ReducedLatencySleep;
5333 ULONG WinLogonFlags;
5334 ULONG Spare3;
5335 ULONG DozeS4Timeout;
5336 ULONG BroadcastCapacityResolution;
5337 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
5338 ULONG VideoTimeout;
5339 BOOLEAN VideoDimDisplay;
5340 ULONG VideoReserved[3];
5341 ULONG SpindownTimeout;
5342 BOOLEAN OptimizeForPower;
5343 UCHAR FanThrottleTolerance;
5344 UCHAR ForcedThrottle;
5345 UCHAR MinThrottle;
5346 POWER_ACTION_POLICY OverThrottled;
5347 } SYSTEM_POWER_POLICY,
5348 *PSYSTEM_POWER_POLICY;
5350 typedef enum _POWER_REQUEST_TYPE
5352 PowerRequestDisplayRequired,
5353 PowerRequestSystemRequired,
5354 PowerRequestAwayModeRequired
5355 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
5357 #define POWER_REQUEST_CONTEXT_VERSION 0
5359 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5360 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5362 typedef union _FILE_SEGMENT_ELEMENT {
5363 PVOID64 Buffer;
5364 ULONGLONG Alignment;
5365 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5367 typedef struct _FILE_NOTIFY_INFORMATION {
5368 DWORD NextEntryOffset;
5369 DWORD Action;
5370 DWORD FileNameLength;
5371 WCHAR FileName[1];
5372 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5374 /* ----------------------------- begin tape storage --------------------- */
5376 #define TAPE_FIXED_PARTITIONS 0
5377 #define TAPE_SELECT_PARTITIONS 1
5378 #define TAPE_INITIATOR_PARTITIONS 2
5379 #define TAPE_ERASE_SHORT 0
5380 #define TAPE_ERASE_LONG 1
5381 #define TAPE_LOAD 0
5382 #define TAPE_UNLOAD 1
5383 #define TAPE_TENSION 2
5384 #define TAPE_LOCK 3
5385 #define TAPE_UNLOCK 4
5386 #define TAPE_FORMAT 5
5387 #define TAPE_SETMARKS 0
5388 #define TAPE_FILEMARKS 1
5389 #define TAPE_SHORT_FILEMARKS 2
5390 #define TAPE_LONG_FILEMARKS 3
5391 #define TAPE_REWIND 0
5392 #define TAPE_ABSOLUTE_BLOCK 1
5393 #define TAPE_LOGICAL_BLOCK 2
5394 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5395 #define TAPE_SPACE_END_OF_DATA 4
5396 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5397 #define TAPE_SPACE_FILEMARKS 6
5398 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5399 #define TAPE_SPACE_SETMARKS 8
5400 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5402 typedef struct _TAPE_CREATE_PARTITION {
5403 DWORD Method;
5404 DWORD Count;
5405 DWORD Size;
5406 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5408 typedef struct _TAPE_ERASE {
5409 DWORD Type;
5410 BOOLEAN Immediate;
5411 } TAPE_ERASE, *PTAPE_ERASE;
5413 typedef struct _TAPE_PREPARE {
5414 DWORD Operation;
5415 BOOLEAN Immediate;
5416 } TAPE_PREPARE, *PTAPE_PREPARE;
5418 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5419 BOOLEAN ECC;
5420 BOOLEAN Compression;
5421 BOOLEAN DataPadding;
5422 BOOLEAN ReportSetmarks;
5423 ULONG EOTWarningZoneSize;
5424 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5426 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5427 ULONG BlockSize;
5428 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5430 typedef struct _TAPE_WRITE_MARKS {
5431 DWORD Type;
5432 DWORD Count;
5433 BOOLEAN Immediate;
5434 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5436 typedef struct _TAPE_GET_POSITION {
5437 ULONG Type;
5438 ULONG Partition;
5439 ULONG OffsetLow;
5440 ULONG OffsetHigh;
5441 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5443 typedef struct _TAPE_SET_POSITION {
5444 ULONG Method;
5445 ULONG Partition;
5446 LARGE_INTEGER Offset;
5447 BOOLEAN Immediate;
5448 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5450 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5451 BOOLEAN ECC;
5452 BOOLEAN Compression;
5453 BOOLEAN DataPadding;
5454 BOOLEAN ReportSetmarks;
5455 DWORD DefaultBlockSize;
5456 DWORD MaximumBlockSize;
5457 DWORD MinimumBlockSize;
5458 DWORD MaximumPartitionCount;
5459 DWORD FeaturesLow;
5460 DWORD FeaturesHigh;
5461 DWORD EOTWarningZoneSize;
5462 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
5464 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
5465 LARGE_INTEGER Capacity;
5466 LARGE_INTEGER Remaining;
5467 DWORD BlockSize;
5468 DWORD PartitionCount;
5469 BOOLEAN WriteProtected;
5470 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
5472 /* ----------------------------- begin registry ----------------------------- */
5474 /* Registry security values */
5475 #define OWNER_SECURITY_INFORMATION 0x00000001
5476 #define GROUP_SECURITY_INFORMATION 0x00000002
5477 #define DACL_SECURITY_INFORMATION 0x00000004
5478 #define SACL_SECURITY_INFORMATION 0x00000008
5479 #define LABEL_SECURITY_INFORMATION 0x00000010
5481 #define REG_OPTION_RESERVED 0x00000000
5482 #define REG_OPTION_NON_VOLATILE 0x00000000
5483 #define REG_OPTION_VOLATILE 0x00000001
5484 #define REG_OPTION_CREATE_LINK 0x00000002
5485 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5486 #define REG_OPTION_OPEN_LINK 0x00000008
5487 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
5488 REG_OPTION_NON_VOLATILE | \
5489 REG_OPTION_VOLATILE | \
5490 REG_OPTION_CREATE_LINK | \
5491 REG_OPTION_BACKUP_RESTORE | \
5492 REG_OPTION_OPEN_LINK)
5495 #define REG_CREATED_NEW_KEY 0x00000001
5496 #define REG_OPENED_EXISTING_KEY 0x00000002
5498 /* For RegNotifyChangeKeyValue */
5499 #define REG_NOTIFY_CHANGE_NAME 0x01
5500 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5501 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5502 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5503 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
5505 #define KEY_QUERY_VALUE 0x00000001
5506 #define KEY_SET_VALUE 0x00000002
5507 #define KEY_CREATE_SUB_KEY 0x00000004
5508 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5509 #define KEY_NOTIFY 0x00000010
5510 #define KEY_CREATE_LINK 0x00000020
5511 #define KEY_WOW64_64KEY 0x00000100
5512 #define KEY_WOW64_32KEY 0x00000200
5513 #define KEY_WOW64_RES 0x00000300
5515 /* for RegKeyRestore flags */
5516 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5517 #define REG_REFRESH_HIVE 0x00000002
5518 #define REG_NO_LAZY_FLUSH 0x00000004
5519 #define REG_FORCE_RESTORE 0x00000008
5521 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5522 KEY_QUERY_VALUE| \
5523 KEY_ENUMERATE_SUB_KEYS| \
5524 KEY_NOTIFY) \
5525 & (~SYNCHRONIZE) \
5527 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5528 KEY_SET_VALUE| \
5529 KEY_CREATE_SUB_KEY) \
5530 & (~SYNCHRONIZE) \
5532 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5533 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5534 KEY_QUERY_VALUE| \
5535 KEY_SET_VALUE| \
5536 KEY_CREATE_SUB_KEY| \
5537 KEY_ENUMERATE_SUB_KEYS| \
5538 KEY_NOTIFY| \
5539 KEY_CREATE_LINK) \
5540 & (~SYNCHRONIZE) \
5542 /* ------------------------------ end registry ------------------------------ */
5545 #define EVENTLOG_SUCCESS 0x0000
5546 #define EVENTLOG_ERROR_TYPE 0x0001
5547 #define EVENTLOG_WARNING_TYPE 0x0002
5548 #define EVENTLOG_INFORMATION_TYPE 0x0004
5549 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5550 #define EVENTLOG_AUDIT_FAILURE 0x0010
5552 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5553 #define EVENTLOG_SEEK_READ 0x0002
5554 #define EVENTLOG_FORWARDS_READ 0x0004
5555 #define EVENTLOG_BACKWARDS_READ 0x0008
5557 typedef struct _EVENTLOGRECORD {
5558 DWORD Length;
5559 DWORD Reserved;
5560 DWORD RecordNumber;
5561 DWORD TimeGenerated;
5562 DWORD TimeWritten;
5563 DWORD EventID;
5564 WORD EventType;
5565 WORD NumStrings;
5566 WORD EventCategory;
5567 WORD ReservedFlags;
5568 DWORD ClosingRecordNumber;
5569 DWORD StringOffset;
5570 DWORD UserSidLength;
5571 DWORD UserSidOffset;
5572 DWORD DataLength;
5573 DWORD DataOffset;
5574 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5576 #define SERVICE_BOOT_START 0x00000000
5577 #define SERVICE_SYSTEM_START 0x00000001
5578 #define SERVICE_AUTO_START 0x00000002
5579 #define SERVICE_DEMAND_START 0x00000003
5580 #define SERVICE_DISABLED 0x00000004
5582 #define SERVICE_ERROR_IGNORE 0x00000000
5583 #define SERVICE_ERROR_NORMAL 0x00000001
5584 #define SERVICE_ERROR_SEVERE 0x00000002
5585 #define SERVICE_ERROR_CRITICAL 0x00000003
5587 /* Service types */
5588 #define SERVICE_KERNEL_DRIVER 0x00000001
5589 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5590 #define SERVICE_ADAPTER 0x00000004
5591 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5593 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5594 SERVICE_RECOGNIZER_DRIVER )
5596 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5597 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5598 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5600 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5602 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5603 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5606 typedef enum _CM_SERVICE_NODE_TYPE
5608 DriverType = SERVICE_KERNEL_DRIVER,
5609 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
5610 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
5611 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
5612 AdapterType = SERVICE_ADAPTER,
5613 RecognizerType = SERVICE_RECOGNIZER_DRIVER
5614 } SERVICE_NODE_TYPE;
5616 typedef enum _CM_SERVICE_LOAD_TYPE
5618 BootLoad = SERVICE_BOOT_START,
5619 SystemLoad = SERVICE_SYSTEM_START,
5620 AutoLoad = SERVICE_AUTO_START,
5621 DemandLoad = SERVICE_DEMAND_START,
5622 DisableLoad = SERVICE_DISABLED
5623 } SERVICE_LOAD_TYPE;
5625 typedef enum _CM_ERROR_CONTROL_TYPE
5627 IgnoreError = SERVICE_ERROR_IGNORE,
5628 NormalError = SERVICE_ERROR_NORMAL,
5629 SevereError = SERVICE_ERROR_SEVERE,
5630 CriticalError = SERVICE_ERROR_CRITICAL
5631 } SERVICE_ERROR_TYPE;
5633 NTSYSAPI SIZE_T WINAPI RtlCompareMemory(const VOID*, const VOID*, SIZE_T);
5634 NTSYSAPI SIZE_T WINAPI RtlCompareMemoryUlong(VOID*, SIZE_T, ULONG);
5636 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5637 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5638 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5639 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5640 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5642 static FORCEINLINE void *RtlSecureZeroMemory(void *buffer, SIZE_T length)
5644 volatile char *ptr = (volatile char *)buffer;
5646 while (length--) *ptr++ = 0;
5647 return buffer;
5650 #include <guiddef.h>
5652 typedef struct _OBJECT_TYPE_LIST {
5653 WORD Level;
5654 WORD Sbz;
5655 GUID *ObjectType;
5656 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
5658 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5660 WORD Type;
5661 WORD CreatorBackTraceIndex;
5662 struct _RTL_CRITICAL_SECTION *CriticalSection;
5663 LIST_ENTRY ProcessLocksList;
5664 DWORD EntryCount;
5665 DWORD ContentionCount;
5666 #ifdef __WINESRC__ /* in Wine we store the name here */
5667 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
5668 #else
5669 DWORD Spare[ 2 ];
5670 #endif
5671 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
5673 typedef struct _RTL_CRITICAL_SECTION {
5674 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
5675 LONG LockCount;
5676 LONG RecursionCount;
5677 HANDLE OwningThread;
5678 HANDLE LockSemaphore;
5679 ULONG_PTR SpinCount;
5680 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
5682 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5683 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5684 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5685 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5686 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5688 typedef struct _RTL_SRWLOCK {
5689 PVOID Ptr;
5690 } RTL_SRWLOCK, *PRTL_SRWLOCK;
5692 #define RTL_SRWLOCK_INIT {0}
5694 typedef struct _RTL_CONDITION_VARIABLE {
5695 PVOID Ptr;
5696 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
5697 #define RTL_CONDITION_VARIABLE_INIT {0}
5698 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
5700 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
5701 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
5703 #define RTL_RUN_ONCE_INIT {0}
5704 typedef union _RTL_RUN_ONCE {
5705 PVOID Ptr;
5706 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
5708 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
5709 #define RTL_RUN_ONCE_ASYNC 0x00000002
5710 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
5712 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
5713 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
5714 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
5715 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
5716 NTSYSAPI DWORD WINAPI RtlRunOnceBeginInitialize(PRTL_RUN_ONCE, DWORD, PVOID*);
5717 NTSYSAPI DWORD WINAPI RtlRunOnceComplete(PRTL_RUN_ONCE, DWORD, PVOID);
5719 #include <pshpack8.h>
5720 typedef struct _IO_COUNTERS {
5721 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
5722 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
5723 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
5724 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
5725 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
5726 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
5727 } IO_COUNTERS, *PIO_COUNTERS;
5728 #include <poppack.h>
5730 typedef struct {
5731 DWORD dwOSVersionInfoSize;
5732 DWORD dwMajorVersion;
5733 DWORD dwMinorVersion;
5734 DWORD dwBuildNumber;
5735 DWORD dwPlatformId;
5736 CHAR szCSDVersion[128];
5737 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5739 typedef struct {
5740 DWORD dwOSVersionInfoSize;
5741 DWORD dwMajorVersion;
5742 DWORD dwMinorVersion;
5743 DWORD dwBuildNumber;
5744 DWORD dwPlatformId;
5745 WCHAR szCSDVersion[128];
5746 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
5748 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
5749 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
5750 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
5752 typedef struct {
5753 DWORD dwOSVersionInfoSize;
5754 DWORD dwMajorVersion;
5755 DWORD dwMinorVersion;
5756 DWORD dwBuildNumber;
5757 DWORD dwPlatformId;
5758 CHAR szCSDVersion[128];
5759 WORD wServicePackMajor;
5760 WORD wServicePackMinor;
5761 WORD wSuiteMask;
5762 BYTE wProductType;
5763 BYTE wReserved;
5764 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5766 typedef struct {
5767 DWORD dwOSVersionInfoSize;
5768 DWORD dwMajorVersion;
5769 DWORD dwMinorVersion;
5770 DWORD dwBuildNumber;
5771 DWORD dwPlatformId;
5772 WCHAR szCSDVersion[128];
5773 WORD wServicePackMajor;
5774 WORD wServicePackMinor;
5775 WORD wSuiteMask;
5776 BYTE wProductType;
5777 BYTE wReserved;
5778 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
5780 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
5781 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
5782 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
5784 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
5786 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5788 #define VER_PLATFORM_WIN32s 0
5789 #define VER_PLATFORM_WIN32_WINDOWS 1
5790 #define VER_PLATFORM_WIN32_NT 2
5792 #define VER_MINORVERSION 0x00000001
5793 #define VER_MAJORVERSION 0x00000002
5794 #define VER_BUILDNUMBER 0x00000004
5795 #define VER_PLATFORMID 0x00000008
5796 #define VER_SERVICEPACKMINOR 0x00000010
5797 #define VER_SERVICEPACKMAJOR 0x00000020
5798 #define VER_SUITENAME 0x00000040
5799 #define VER_PRODUCT_TYPE 0x00000080
5801 #define VER_NT_WORKSTATION 1
5802 #define VER_NT_DOMAIN_CONTROLLER 2
5803 #define VER_NT_SERVER 3
5805 #define VER_SUITE_SMALLBUSINESS 0x00000001
5806 #define VER_SUITE_ENTERPRISE 0x00000002
5807 #define VER_SUITE_BACKOFFICE 0x00000004
5808 #define VER_SUITE_COMMUNICATIONS 0x00000008
5809 #define VER_SUITE_TERMINAL 0x00000010
5810 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5811 #define VER_SUITE_EMBEDDEDNT 0x00000040
5812 #define VER_SUITE_DATACENTER 0x00000080
5813 #define VER_SUITE_SINGLEUSERTS 0x00000100
5814 #define VER_SUITE_PERSONAL 0x00000200
5815 #define VER_SUITE_BLADE 0x00000400
5816 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
5817 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
5818 #define VER_SUITE_STORAGE_SERVER 0x00002000
5819 #define VER_SUITE_COMPUTE_SERVER 0x00004000
5820 #define VER_SUITE_WH_SERVER 0x00008000
5822 #define VER_EQUAL 1
5823 #define VER_GREATER 2
5824 #define VER_GREATER_EQUAL 3
5825 #define VER_LESS 4
5826 #define VER_LESS_EQUAL 5
5827 #define VER_AND 6
5828 #define VER_OR 7
5830 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
5831 DWORD dwFlags;
5832 DWORD ulFormatVersion;
5833 DWORD ulAssemblyCount;
5834 DWORD ulRootManifestPathType;
5835 DWORD ulRootManifestPathChars;
5836 DWORD ulRootConfigurationPathType;
5837 DWORD ulRootConfigurationPathChars;
5838 DWORD ulAppDirPathType;
5839 DWORD ulAppDirPathChars;
5840 PCWSTR lpRootManifestPath;
5841 PCWSTR lpRootConfigurationPath;
5842 PCWSTR lpAppDirPath;
5843 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
5845 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
5846 DWORD ulFlags;
5847 DWORD ulEncodedAssemblyIdentityLength;
5848 DWORD ulManifestPathType;
5849 DWORD ulManifestPathLength;
5850 LARGE_INTEGER liManifestLastWriteTime;
5851 DWORD ulPolicyPathType;
5852 DWORD ulPolicyPathLength;
5853 LARGE_INTEGER liPolicyLastWriteTime;
5854 DWORD ulMetadataSatelliteRosterIndex;
5855 DWORD ulManifestVersionMajor;
5856 DWORD ulManifestVersionMinor;
5857 DWORD ulPolicyVersionMajor;
5858 DWORD ulPolicyVersionMinor;
5859 DWORD ulAssemblyDirectoryNameLength;
5860 PCWSTR lpAssemblyEncodedAssemblyIdentity;
5861 PCWSTR lpAssemblyManifestPath;
5862 PCWSTR lpAssemblyPolicyPath;
5863 PCWSTR lpAssemblyDirectoryName;
5864 DWORD ulFileCount;
5865 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
5867 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
5868 DWORD ulAssemblyIndex;
5869 DWORD ulFileIndexInAssembly;
5870 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
5872 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
5874 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
5875 DWORD ulFlags;
5876 DWORD ulFilenameLength;
5877 DWORD ulPathLength;
5878 PCWSTR lpFileName;
5879 PCWSTR lpFilePath;
5880 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
5882 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
5884 typedef enum {
5885 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
5886 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
5887 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION,
5888 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
5889 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
5891 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
5892 GUID Id;
5893 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
5894 ULONGLONG MaxVersionTested;
5895 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
5897 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
5898 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
5899 DWORD ElementCount;
5900 COMPATIBILITY_CONTEXT_ELEMENT Elements[];
5901 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
5902 #endif
5904 typedef enum {
5905 ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
5906 ACTCTX_RUN_LEVEL_AS_INVOKER,
5907 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
5908 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
5909 ACTCTX_RUN_LEVEL_NUMBERS
5910 } ACTCTX_REQUESTED_RUN_LEVEL;
5912 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
5913 DWORD ulFlags;
5914 ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
5915 DWORD UiAccess;
5916 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
5918 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION *PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
5920 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
5921 ActivationContextBasicInformation = 1,
5922 ActivationContextDetailedInformation = 2,
5923 AssemblyDetailedInformationInActivationContext = 3,
5924 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
5925 RunlevelInformationInActivationContext = 5,
5926 CompatibilityInformationInActivationContext = 6,
5927 ActivationContextManifestResourceName = 7,
5928 MaxActivationContextInfoClass,
5929 AssemblyDetailedInformationInActivationContxt = AssemblyDetailedInformationInActivationContext,
5930 FileInformationInAssemblyOfAssemblyInActivationContxt = FileInformationInAssemblyOfAssemblyInActivationContext
5931 } ACTIVATION_CONTEXT_INFO_CLASS;
5933 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
5934 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
5935 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
5936 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
5938 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
5939 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
5940 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
5941 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
5942 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
5943 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
5944 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
5945 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
5946 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
5947 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
5948 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
5949 #define ACTIVATION_CONTEXT_SECTION_WINRT_ACTIVATABLE_CLASSES 12
5951 typedef enum _JOBOBJECTINFOCLASS
5953 JobObjectBasicAccountingInformation = 1,
5954 JobObjectBasicLimitInformation,
5955 JobObjectBasicProcessIdList,
5956 JobObjectBasicUIRestrictions,
5957 JobObjectSecurityLimitInformation,
5958 JobObjectEndOfJobTimeInformation,
5959 JobObjectAssociateCompletionPortInformation,
5960 JobObjectBasicAndIoAccountingInformation,
5961 JobObjectExtendedLimitInformation,
5962 JobObjectJobSetInformation,
5963 MaxJobObjectInfoClass
5964 } JOBOBJECTINFOCLASS;
5966 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
5967 LARGE_INTEGER TotalUserTime;
5968 LARGE_INTEGER TotalKernelTime;
5969 LARGE_INTEGER ThisPeriodTotalUserTime;
5970 LARGE_INTEGER ThisPeriodTotalKernelTime;
5971 DWORD TotalPageFaultCount;
5972 DWORD TotalProcesses;
5973 DWORD ActiveProcesses;
5974 DWORD TotalTerminatedProcesses;
5975 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
5977 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
5978 LARGE_INTEGER PerProcessUserTimeLimit;
5979 LARGE_INTEGER PerJobUserTimeLimit;
5980 DWORD LimitFlags;
5981 SIZE_T MinimumWorkingSetSize;
5982 SIZE_T MaximumWorkingSetSize;
5983 DWORD ActiveProcessLimit;
5984 ULONG_PTR Affinity;
5985 DWORD PriorityClass;
5986 DWORD SchedulingClass;
5987 } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
5989 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
5990 DWORD NumberOfAssignedProcesses;
5991 DWORD NumberOfProcessIdsInList;
5992 ULONG_PTR ProcessIdList[1];
5993 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
5995 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
5996 DWORD UIRestrictionsClass;
5997 } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
5999 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
6000 DWORD SecurityLimitFlags;
6001 HANDLE JobToken;
6002 PTOKEN_GROUPS SidsToDisable;
6003 PTOKEN_PRIVILEGES PrivilegesToDelete;
6004 PTOKEN_GROUPS RestrictedSids;
6005 } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
6007 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
6008 DWORD EndOfJobTimeAction;
6009 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
6011 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
6012 PVOID CompletionKey;
6013 HANDLE CompletionPort;
6014 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
6016 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6017 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6018 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6019 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6020 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6021 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6022 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6023 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6024 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6026 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
6027 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
6028 IO_COUNTERS IoInfo;
6029 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
6031 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
6032 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
6033 IO_COUNTERS IoInfo;
6034 SIZE_T ProcessMemoryLimit;
6035 SIZE_T JobMemoryLimit;
6036 SIZE_T PeakProcessMemoryUsed;
6037 SIZE_T PeakJobMemoryUsed;
6038 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
6040 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6041 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6042 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6043 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6044 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6045 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6046 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6047 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6048 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6049 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6050 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6051 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6052 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6053 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6054 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6056 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6057 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6058 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6060 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6062 RelationProcessorCore = 0,
6063 RelationNumaNode = 1,
6064 RelationCache = 2,
6065 RelationProcessorPackage = 3,
6066 RelationGroup = 4,
6067 RelationAll = 0xffff
6068 } LOGICAL_PROCESSOR_RELATIONSHIP;
6070 #define LTP_PC_SMT 0x1
6072 typedef enum _PROCESSOR_CACHE_TYPE
6074 CacheUnified,
6075 CacheInstruction,
6076 CacheData,
6077 CacheTrace
6078 } PROCESSOR_CACHE_TYPE;
6080 typedef struct _PROCESSOR_GROUP_INFO
6082 BYTE MaximumProcessorCount;
6083 BYTE ActiveProcessorCount;
6084 BYTE Reserved[38];
6085 KAFFINITY ActiveProcessorMask;
6086 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
6088 typedef struct _CACHE_DESCRIPTOR
6090 BYTE Level;
6091 BYTE Associativity;
6092 WORD LineSize;
6093 DWORD Size;
6094 PROCESSOR_CACHE_TYPE Type;
6095 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
6097 typedef struct _GROUP_AFFINITY
6099 KAFFINITY Mask;
6100 WORD Group;
6101 WORD Reserved[3];
6102 } GROUP_AFFINITY, *PGROUP_AFFINITY;
6104 #define ALL_PROCESSOR_GROUPS 0xffff
6106 typedef struct _PROCESSOR_NUMBER
6108 WORD Group;
6109 BYTE Number;
6110 BYTE Reserved;
6111 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
6113 typedef struct _PROCESSOR_RELATIONSHIP
6115 BYTE Flags;
6116 BYTE EfficiencyClass;
6117 BYTE Reserved[20];
6118 WORD GroupCount;
6119 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
6120 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
6122 typedef struct _NUMA_NODE_RELATIONSHIP
6124 DWORD NodeNumber;
6125 BYTE Reserved[20];
6126 GROUP_AFFINITY GroupMask;
6127 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
6129 typedef struct _CACHE_RELATIONSHIP
6131 BYTE Level;
6132 BYTE Associativity;
6133 WORD LineSize;
6134 DWORD CacheSize;
6135 PROCESSOR_CACHE_TYPE Type;
6136 BYTE Reserved[20];
6137 GROUP_AFFINITY GroupMask;
6138 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
6140 typedef struct _GROUP_RELATIONSHIP
6142 WORD MaximumGroupCount;
6143 WORD ActiveGroupCount;
6144 BYTE Reserved[20];
6145 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
6146 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
6148 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6150 ULONG_PTR ProcessorMask;
6151 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6152 union
6154 struct
6156 BYTE Flags;
6157 } ProcessorCore;
6158 struct
6160 DWORD NodeNumber;
6161 } NumaNode;
6162 CACHE_DESCRIPTOR Cache;
6163 ULONGLONG Reserved[2];
6164 } DUMMYUNIONNAME;
6165 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
6167 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6169 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6170 DWORD Size;
6171 union
6173 PROCESSOR_RELATIONSHIP Processor;
6174 NUMA_NODE_RELATIONSHIP NumaNode;
6175 CACHE_RELATIONSHIP Cache;
6176 GROUP_RELATIONSHIP Group;
6177 } DUMMYUNIONNAME;
6178 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
6180 typedef enum _CPU_SET_INFORMATION_TYPE
6182 CpuSetInformation,
6183 } CPU_SET_INFORMATION_TYPE, *PCPU_SET_INFORMATION_TYPE;
6185 typedef struct _SYSTEM_CPU_SET_INFORMATION
6187 DWORD Size;
6188 CPU_SET_INFORMATION_TYPE Type;
6189 union
6191 struct
6193 DWORD Id;
6194 WORD Group;
6195 BYTE LogicalProcessorIndex;
6196 BYTE CoreIndex;
6197 BYTE LastLevelCacheIndex;
6198 BYTE NumaNodeIndex;
6199 BYTE EfficiencyClass;
6200 union
6202 BYTE AllFlags;
6203 struct
6205 BYTE Parked : 1;
6206 BYTE Allocated : 1;
6207 BYTE AllocatedToTargetProcess : 1;
6208 BYTE RealTime : 1;
6209 BYTE ReservedFlags : 4;
6210 } DUMMYSTRUCTNAME;
6211 } DUMMYUNIONNAME2;
6212 union {
6213 DWORD Reserved;
6214 BYTE SchedulingClass;
6216 DWORD64 AllocationTag;
6217 } CpuSet;
6218 } DUMMYUNIONNAME;
6219 } SYSTEM_CPU_SET_INFORMATION, *PSYSTEM_CPU_SET_INFORMATION;
6221 /* Threadpool things */
6222 typedef DWORD TP_VERSION,*PTP_VERSION;
6224 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
6226 typedef VOID (CALLBACK *PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID);
6228 typedef struct _TP_POOL TP_POOL,*PTP_POOL;
6230 typedef enum _TP_CALLBACK_PRIORITY
6232 TP_CALLBACK_PRIORITY_HIGH,
6233 TP_CALLBACK_PRIORITY_NORMAL,
6234 TP_CALLBACK_PRIORITY_LOW,
6235 TP_CALLBACK_PRIORITY_INVALID,
6236 TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
6237 } TP_CALLBACK_PRIORITY;
6239 typedef struct _TP_POOL_STACK_INFORMATION
6241 SIZE_T StackReserve;
6242 SIZE_T StackCommit;
6243 } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION;
6245 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
6247 typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID,PVOID);
6249 typedef struct _TP_CALLBACK_ENVIRON_V1
6251 TP_VERSION Version;
6252 PTP_POOL Pool;
6253 PTP_CLEANUP_GROUP CleanupGroup;
6254 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6255 PVOID RaceDll;
6256 struct _ACTIVATION_CONTEXT* ActivationContext;
6257 PTP_SIMPLE_CALLBACK FinalizationCallback;
6258 union
6260 DWORD Flags;
6261 struct
6263 DWORD LongFunction:1;
6264 DWORD Persistent:1;
6265 DWORD Private:30;
6266 } s;
6267 } u;
6268 } TP_CALLBACK_ENVIRON_V1;
6270 typedef struct _TP_CALLBACK_ENVIRON_V3
6272 TP_VERSION Version;
6273 PTP_POOL Pool;
6274 PTP_CLEANUP_GROUP CleanupGroup;
6275 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6276 PVOID RaceDll;
6277 struct _ACTIVATION_CONTEXT *ActivationContext;
6278 PTP_SIMPLE_CALLBACK FinalizationCallback;
6279 union
6281 DWORD Flags;
6282 struct
6284 DWORD LongFunction:1;
6285 DWORD Persistent:1;
6286 DWORD Private:30;
6287 } s;
6288 } u;
6289 TP_CALLBACK_PRIORITY CallbackPriority;
6290 DWORD Size;
6291 } TP_CALLBACK_ENVIRON_V3;
6293 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
6294 typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
6296 typedef DWORD TP_WAIT_RESULT;
6297 typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6299 typedef struct _TP_IO TP_IO, *PTP_IO;
6301 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
6303 typedef VOID (CALLBACK *PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WORK);
6304 typedef VOID (CALLBACK *PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_TIMER);
6305 typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,TP_WAIT_RESULT);
6308 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
6310 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6312 UmsThreadInvalidInfoClass,
6313 UmsThreadUserContext,
6314 UmsThreadPriority,
6315 UmsThreadAffinity,
6316 UmsThreadTeb,
6317 UmsThreadIsSuspended,
6318 UmsThreadIsTerminated,
6319 UmsThreadMaxInfoClass
6320 } RTL_UMS_THREAD_INFO_CLASS, *PRTL_UMS_THREAD_INFO_CLASS;
6322 typedef enum _RTL_UMS_SCHEDULER_REASON
6324 UmsSchedulerStartup,
6325 UmsSchedulerThreadBlocked,
6326 UmsSchedulerThreadYield,
6327 } RTL_UMS_SCHEDULER_REASON, *PRTL_UMS_SCHEDULER_REASON;
6329 typedef void (CALLBACK *PRTL_UMS_SCHEDULER_ENTRY_POINT)(RTL_UMS_SCHEDULER_REASON,ULONG_PTR,PVOID);
6331 typedef enum _PROCESS_MITIGATION_POLICY
6333 ProcessDEPPolicy,
6334 ProcessASLRPolicy,
6335 ProcessDynamicCodePolicy,
6336 ProcessStrictHandleCheckPolicy,
6337 ProcessSystemCallDisablePolicy,
6338 ProcessMitigationOptionsMask,
6339 ProcessExtensionPointDisablePolicy,
6340 ProcessControlFlowGuardPolicy,
6341 ProcessSignaturePolicy,
6342 ProcessFontDisablePolicy,
6343 ProcessImageLoadPolicy,
6344 ProcessSystemCallFilterPolicy,
6345 ProcessPayloadRestrictionPolicy,
6346 ProcessChildProcessPolicy,
6347 ProcessSideChannelIsolationPolicy,
6348 MaxProcessMitigationPolicy
6349 } PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY;
6352 /* Intrinsic functions */
6354 #define BitScanForward _BitScanForward
6355 #define BitScanReverse _BitScanReverse
6356 #define InterlockedAdd _InlineInterlockedAdd
6357 #define InterlockedAnd _InterlockedAnd
6358 #define InterlockedAnd64 _InterlockedAnd64
6359 #define InterlockedCompareExchange _InterlockedCompareExchange
6360 #define InterlockedCompareExchange64 _InterlockedCompareExchange64
6361 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
6362 #define InterlockedDecrement _InterlockedDecrement
6363 #define InterlockedDecrement16 _InterlockedDecrement16
6364 #define InterlockedDecrement64 _InterlockedDecrement64
6365 #define InterlockedExchange _InterlockedExchange
6366 #define InterlockedExchangeAdd _InterlockedExchangeAdd
6367 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
6368 #define InterlockedExchangePointer _InterlockedExchangePointer
6369 #define InterlockedIncrement _InterlockedIncrement
6370 #define InterlockedIncrement16 _InterlockedIncrement16
6371 #define InterlockedIncrement64 _InterlockedIncrement64
6372 #define InterlockedOr _InterlockedOr
6373 #define InterlockedOr64 _InterlockedOr64
6374 #define InterlockedXor _InterlockedXor
6375 #define InterlockedXor64 _InterlockedXor64
6377 #ifdef _MSC_VER
6379 #pragma intrinsic(_BitScanForward)
6380 #pragma intrinsic(_BitScanReverse)
6381 #pragma intrinsic(_InterlockedAnd)
6382 #pragma intrinsic(_InterlockedCompareExchange)
6383 #pragma intrinsic(_InterlockedCompareExchange64)
6384 #pragma intrinsic(_InterlockedExchange)
6385 #pragma intrinsic(_InterlockedExchangeAdd)
6386 #pragma intrinsic(_InterlockedIncrement)
6387 #pragma intrinsic(_InterlockedIncrement16)
6388 #pragma intrinsic(_InterlockedDecrement)
6389 #pragma intrinsic(_InterlockedDecrement16)
6390 #pragma intrinsic(_InterlockedOr)
6391 #pragma intrinsic(_InterlockedXor)
6392 #pragma intrinsic(__fastfail)
6394 BOOLEAN _BitScanForward(unsigned long*,unsigned long);
6395 BOOLEAN _BitScanReverse(unsigned long*,unsigned long);
6396 long _InterlockedAnd(long volatile *,long);
6397 long _InterlockedCompareExchange(long volatile*,long,long);
6398 long long _InterlockedCompareExchange64(long long volatile*,long long,long long);
6399 long _InterlockedDecrement(long volatile*);
6400 short _InterlockedDecrement16(short volatile*);
6401 long _InterlockedExchange(long volatile*,long);
6402 long _InterlockedExchangeAdd(long volatile*,long);
6403 long _InterlockedIncrement(long volatile*);
6404 short _InterlockedIncrement16(short volatile*);
6405 long _InterlockedOr(long volatile *,long);
6406 long _InterlockedXor(long volatile *,long);
6407 DECLSPEC_NORETURN void __fastfail(unsigned int);
6409 #ifndef __i386__
6411 #pragma intrinsic(_InterlockedAnd64)
6412 #pragma intrinsic(_InterlockedCompareExchangePointer)
6413 #pragma intrinsic(_InterlockedDecrement64)
6414 #pragma intrinsic(_InterlockedExchangeAdd64)
6415 #pragma intrinsic(_InterlockedExchangePointer)
6416 #pragma intrinsic(_InterlockedIncrement64)
6417 #pragma intrinsic(_InterlockedOr64)
6418 #pragma intrinsic(_InterlockedXor64)
6420 __int64 _InterlockedAnd64(__int64 volatile *, __int64);
6421 void * _InterlockedCompareExchangePointer(void *volatile*,void*,void*);
6422 __int64 _InterlockedDecrement64(__int64 volatile *);
6423 __int64 _InterlockedExchangeAdd64(__int64 volatile *, __int64);
6424 void * _InterlockedExchangePointer(void *volatile*,void*);
6425 __int64 _InterlockedIncrement64(__int64 volatile *);
6426 __int64 _InterlockedOr64(__int64 volatile *, __int64);
6427 __int64 _InterlockedXor64(__int64 volatile *, __int64);
6429 #else
6431 static FORCEINLINE __int64 InterlockedAnd64( __int64 volatile *dest, __int64 val )
6433 __int64 prev;
6434 do prev = *dest; while (InterlockedCompareExchange64( dest, prev & val, prev ) != prev);
6435 return prev;
6438 static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
6440 return (void *)_InterlockedCompareExchange( (long volatile*)dest, (long)xchg, (long)compare );
6443 static FORCEINLINE __int64 InterlockedExchangeAdd64( __int64 volatile *dest, __int64 val )
6445 __int64 prev;
6446 do prev = *dest; while (InterlockedCompareExchange64( dest, prev + val, prev ) != prev);
6447 return prev;
6450 static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
6452 return (void *)_InterlockedExchange( (long volatile*)dest, (long)val );
6455 static FORCEINLINE __int64 InterlockedIncrement64( __int64 volatile *dest )
6457 return InterlockedExchangeAdd64( dest, 1 ) + 1;
6460 static FORCEINLINE __int64 InterlockedDecrement64( __int64 volatile *dest )
6462 return InterlockedExchangeAdd64( dest, -1 ) - 1;
6465 static FORCEINLINE __int64 InterlockedOr64( __int64 volatile *dest, __int64 val )
6467 __int64 prev;
6468 do prev = *dest; while (InterlockedCompareExchange64( dest, prev | val, prev ) != prev);
6469 return prev;
6472 static FORCEINLINE __int64 InterlockedXor64( __int64 volatile *dest, __int64 val )
6474 __int64 prev;
6475 do prev = *dest; while (InterlockedCompareExchange64( dest, prev ^ val, prev ) != prev);
6476 return prev;
6479 #endif /* __i386__ */
6481 static FORCEINLINE long InterlockedAdd( long volatile *dest, long val )
6483 return InterlockedExchangeAdd( dest, val ) + val;
6486 static FORCEINLINE __int64 InterlockedAdd64( __int64 volatile *dest, __int64 val )
6488 return InterlockedExchangeAdd64( dest, val ) + val;
6491 #ifdef __i386__
6493 static FORCEINLINE void MemoryBarrier(void)
6495 LONG dummy;
6496 InterlockedOr(&dummy, 0);
6499 #elif defined(__x86_64__)
6501 #pragma intrinsic(__faststorefence)
6502 void __faststorefence(void);
6504 static FORCEINLINE void MemoryBarrier(void)
6506 __faststorefence();
6509 #elif defined(__arm__)
6511 static FORCEINLINE void MemoryBarrier(void)
6513 __dmb(_ARM_BARRIER_SY);
6516 #elif defined(__aarch64__)
6518 static FORCEINLINE void MemoryBarrier(void)
6520 __dmb(_ARM64_BARRIER_SY);
6523 #endif /* __i386__ */
6525 #elif defined(__GNUC__)
6527 static FORCEINLINE BOOLEAN WINAPI BitScanForward(DWORD *index, DWORD mask)
6529 *index = __builtin_ctz( mask );
6530 return mask != 0;
6533 static FORCEINLINE BOOLEAN WINAPI BitScanReverse(DWORD *index, DWORD mask)
6535 *index = 31 - __builtin_clz( mask );
6536 return mask != 0;
6539 static FORCEINLINE LONG WINAPI InterlockedAdd( LONG volatile *dest, LONG val )
6541 return __sync_add_and_fetch( dest, val );
6544 static FORCEINLINE LONGLONG WINAPI InterlockedAdd64( LONGLONG volatile *dest, LONGLONG val )
6546 return __sync_add_and_fetch( dest, val );
6549 static FORCEINLINE LONG WINAPI InterlockedAnd( LONG volatile *dest, LONG val )
6551 return __sync_fetch_and_and( dest, val );
6554 static FORCEINLINE LONGLONG WINAPI InterlockedAnd64( LONGLONG volatile *dest, LONGLONG val )
6556 return __sync_fetch_and_and( dest, val );
6559 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
6561 return __sync_val_compare_and_swap( dest, compare, xchg );
6564 static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
6566 return __sync_val_compare_and_swap( dest, compare, xchg );
6569 static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
6571 return __sync_val_compare_and_swap( dest, compare, xchg );
6574 static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
6576 LONG ret;
6577 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
6578 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
6579 #elif defined(__i386__) || defined(__x86_64__)
6580 __asm__ __volatile__( "lock; xchgl %0,(%1)"
6581 : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
6582 #else
6583 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
6584 #endif
6585 return ret;
6588 static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
6590 return __sync_fetch_and_add( dest, incr );
6593 static FORCEINLINE LONGLONG WINAPI InterlockedExchangeAdd64( LONGLONG volatile *dest, LONGLONG incr )
6595 return __sync_fetch_and_add( dest, incr );
6598 static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
6600 return __sync_add_and_fetch( dest, 1 );
6603 static FORCEINLINE short WINAPI InterlockedIncrement16( short volatile *dest )
6605 return __sync_add_and_fetch( dest, 1 );
6608 static FORCEINLINE LONGLONG WINAPI InterlockedIncrement64( LONGLONG volatile *dest )
6610 return __sync_add_and_fetch( dest, 1 );
6613 static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
6615 return __sync_add_and_fetch( dest, -1 );
6618 static FORCEINLINE short WINAPI InterlockedDecrement16( short volatile *dest )
6620 return __sync_add_and_fetch( dest, -1 );
6623 static FORCEINLINE LONGLONG WINAPI InterlockedDecrement64( LONGLONG volatile *dest )
6625 return __sync_add_and_fetch( dest, -1 );
6628 static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
6630 void *ret;
6631 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
6632 ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST );
6633 #elif defined(__x86_64__)
6634 __asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
6635 #elif defined(__i386__)
6636 __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
6637 #else
6638 do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
6639 #endif
6640 return ret;
6643 static FORCEINLINE LONG WINAPI InterlockedOr( LONG volatile *dest, LONG val )
6645 return __sync_fetch_and_or( dest, val );
6648 static FORCEINLINE LONGLONG WINAPI InterlockedOr64( LONGLONG volatile *dest, LONGLONG val )
6650 return __sync_fetch_and_or( dest, val );
6653 static FORCEINLINE LONG WINAPI InterlockedXor( LONG volatile *dest, LONG val )
6655 return __sync_fetch_and_xor( dest, val );
6658 static FORCEINLINE LONGLONG WINAPI InterlockedXor64( LONGLONG volatile *dest, LONGLONG val )
6660 return __sync_fetch_and_xor( dest, val );
6663 static FORCEINLINE void MemoryBarrier(void)
6665 __sync_synchronize();
6668 static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code)
6670 #if defined(__x86_64__) || defined(__i386__)
6671 for (;;) __asm__ __volatile__( "int $0x29" :: "c" ((ULONG_PTR)code) : "memory" );
6672 #elif defined(__aarch64__)
6673 register ULONG_PTR val __asm__("x0") = code;
6674 for (;;) __asm__ __volatile__( "brk #0xf003" :: "r" (val) : "memory" );
6675 #elif defined(__arm__)
6676 register ULONG_PTR val __asm__("r0") = code;
6677 for (;;) __asm__ __volatile__( "udf #0xfb" :: "r" (val) : "memory" );
6678 #endif
6681 #endif /* __GNUC__ */
6683 #ifdef _WIN64
6685 #define InterlockedCompareExchange128 _InterlockedCompareExchange128
6687 #if defined(_MSC_VER) && !defined(__clang__)
6689 #pragma intrinsic(_InterlockedCompareExchange128)
6690 unsigned char _InterlockedCompareExchange128(volatile __int64 *, __int64, __int64, __int64 *);
6692 #else
6694 static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64 *dest, __int64 xchg_high, __int64 xchg_low, __int64 *compare )
6696 #ifdef __x86_64__
6697 unsigned char ret;
6698 __asm__ __volatile__( "lock cmpxchg16b %0; setz %b2"
6699 : "=m" (dest[0]), "=m" (dest[1]), "=r" (ret),
6700 "=a" (compare[0]), "=d" (compare[1])
6701 : "m" (dest[0]), "m" (dest[1]), "3" (compare[0]), "4" (compare[1]),
6702 "c" (xchg_high), "b" (xchg_low) );
6703 return ret;
6704 #else
6705 return __sync_bool_compare_and_swap( (__int128 *)dest, *(__int128 *)compare, ((__int128)xchg_high << 64) | xchg_low );
6706 #endif
6709 #endif
6711 #define InterlockedDecrementSizeT(a) InterlockeDecrement64((LONGLONG *)(a))
6712 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)(a), (b))
6713 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)(a))
6715 #else /* _WIN64 */
6717 #define InterlockedDecrementSizeT(a) InterlockeDecrement((LONG *)(a))
6718 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)(a), (b))
6719 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)(a))
6721 #endif /* _WIN64 */
6723 static FORCEINLINE void YieldProcessor(void)
6725 #ifdef __GNUC__
6726 #if defined(__i386__) || defined(__x86_64__)
6727 __asm__ __volatile__( "rep; nop" : : : "memory" );
6728 #elif defined(__arm__) || defined(__aarch64__)
6729 __asm__ __volatile__( "dmb ishst\n\tyield" : : : "memory" );
6730 #else
6731 __asm__ __volatile__( "" : : : "memory" );
6732 #endif
6733 #endif
6736 #ifdef __cplusplus
6738 #endif
6740 #endif /* _WINNT_ */