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