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