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
26 #include <winapifamily.h>
42 #define NTSYSAPI DECLSPEC_IMPORT
45 #define NTAPI __stdcall
46 #define FASTCALL __fastcall
49 # if defined(_MSC_VER)
50 # define DECLSPEC_IMPORT __declspec(dllimport)
51 # elif defined(__MINGW32__) || defined(__CYGWIN__)
52 # define DECLSPEC_IMPORT __attribute__((dllimport))
54 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
57 # define DECLSPEC_IMPORT
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))
66 # define DECLSPEC_NORETURN
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)))
76 # define DECLSPEC_ALIGN(x)
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))
86 # define DECLSPEC_NOTHROW
90 #ifndef DECLSPEC_CACHEALIGN
91 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
95 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
96 # define DECLSPEC_UUID(x) __declspec(uuid(x))
98 # define DECLSPEC_UUID(x)
102 #ifndef DECLSPEC_NOVTABLE
103 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
104 # define DECLSPEC_NOVTABLE __declspec(novtable)
106 # define DECLSPEC_NOVTABLE
110 #ifndef DECLSPEC_SELECTANY
111 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
112 #define DECLSPEC_SELECTANY __declspec(selectany)
114 #define DECLSPEC_SELECTANY
119 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
120 # define NOP_FUNCTION __noop
122 # define NOP_FUNCTION (void)0
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)
130 # define DECLSPEC_ADDRSAFE
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))
140 # define FORCEINLINE inline
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
152 # define DECLSPEC_DEPRECATED
153 # undef DEPRECATE_SUPPORTED
157 /* a couple of useful Wine extensions */
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")))
166 # define DECLSPEC_EXPORT
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")))
174 # define DECLSPEC_HIDDEN
177 #ifndef __has_attribute
178 # define __has_attribute(x) 0
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__))
184 #define DECLSPEC_HOTPATCH
187 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
188 #define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
190 #define __WINE_ALLOC_SIZE(x)
193 /* Anonymous union/struct handling */
195 #ifndef NONAMELESSSTRUCT
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
201 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
202 # define NONAMELESSSTRUCT
204 #endif /* NONAMELESSSTRUCT */
206 #ifndef NONAMELESSUNION
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
212 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
213 # define NONAMELESSUNION
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)
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__
293 # elif defined(_MSC_VER)
294 # define __C89_NAMELESS
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
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
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
341 # define RESTRICTED_POINTER
344 # define RESTRICTED_POINTER
347 /* C99 unaligned support */
350 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
351 # define UNALIGNED __unaligned
353 # define UNALIGNED64 __unaligned
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
369 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
370 #define MEMORY_ALLOCATION_ALIGNMENT 8
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)
378 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
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)
387 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
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()
400 # define DEFAULT_UNREACHABLE default:
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
411 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
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)); } \
422 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
425 /* Microsoft's macros for declaring functions */
428 # define EXTERN_C extern "C"
430 # define EXTERN_C extern
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 */
452 typedef VOID
*PVOID64
;
453 typedef BYTE BOOLEAN
, *PBOOLEAN
;
454 typedef char CHAR
, *PCHAR
;
455 typedef short SHORT
, *PSHORT
;
457 typedef long LONG
, *PLONG
;
459 typedef int LONG
, *PLONG
;
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
;
468 typedef unsigned short WCHAR
;
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 */
481 typedef signed __int64 LONGLONG
, *PLONGLONG
;
482 typedef unsigned __int64 ULONGLONG
, *PULONGLONG
;
484 typedef signed __int64
DECLSPEC_ALIGN(8) LONGLONG
, *PLONGLONG
;
485 typedef unsigned __int64
DECLSPEC_ALIGN(8) ULONGLONG
, *PULONGLONG
;
492 typedef ULONGLONG DWORDLONG
, *PDWORDLONG
;
494 typedef ULONGLONG
DECLSPEC_ALIGN(8) DWORDLONG
, *PDWORDLONG
;
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
526 # ifndef _TCHAR_DEFINED
527 typedef WCHAR TCHAR
, *PTCHAR
;
528 # define _TCHAR_DEFINED
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
;
545 # ifndef _TCHAR_DEFINED
546 typedef CHAR TCHAR
, *PTCHAR
;
547 # define _TCHAR_DEFINED
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 */
568 typedef DWORD LCID
, *PLCID
;
570 typedef DWORD EXECUTION_STATE
;
571 #ifndef _HRESULT_DEFINED
572 #define _HRESULT_DEFINED
573 typedef LONG HRESULT
;
578 typedef void *HANDLE
;
579 typedef HANDLE
*PHANDLE
, *LPHANDLE
;
582 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
584 #define DECLARE_HANDLE(a) typedef HANDLE a
591 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
593 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
594 # define __MSABI_LONG(x) x ## l
596 # define __MSABI_LONG(x) x
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 */
673 #define DLL_WINE_PREATTACH 8 /* called before process attach for Wine builtins */
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
723 #define MAXIMUM_PROCESSORS 64
725 #define MAXIMUM_PROCESSORS 32
728 typedef struct _MEMORY_BASIC_INFORMATION
731 LPVOID AllocationBase
;
732 DWORD AllocationProtect
;
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
{
754 DWORD64 Type
: MEM_EXTENDED_PARAMETER_TYPE_BITS
;
755 DWORD64 Reserved
: 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS
;
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
811 #define MINSHORT 0x8000
812 #define MAXSHORT 0x7fff
813 #define MINLONG 0x80000000
814 #define MAXLONG 0x7fffffff
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]))
831 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
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
;
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
{
858 ULONGLONG Sequence
:9;
859 ULONGLONG NextEntry
:39;
860 ULONGLONG HeaderType
:1;
862 ULONGLONG Reserved
:59;
867 ULONGLONG Sequence
:48;
868 ULONGLONG HeaderType
:1;
870 ULONGLONG Reserved
:2;
871 ULONGLONG NextEntry
:60;
873 } SLIST_HEADER
, *PSLIST_HEADER
;
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
{
889 } SLIST_HEADER
, *PSLIST_HEADER
;
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
);
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
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 */
989 #define SIZE_OF_80387_REGISTERS 80
991 typedef struct _FLOATING_SAVE_AREA
1000 BYTE RegisterArea
[SIZE_OF_80387_REGISTERS
];
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
{
1078 unsigned BaseMid
: 8;
1082 unsigned LimitHi
: 4;
1084 unsigned Reserved_0
: 1;
1085 unsigned Default_Big
: 1;
1086 unsigned Granularity
: 1;
1087 unsigned BaseHi
: 8;
1090 } LDT_ENTRY
, *PLDT_ENTRY
, WOW64_LDT_ENTRY
, *PWOW64_LDT_ENTRY
;
1092 typedef struct DECLSPEC_ALIGN(16) _M128A
{
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 */
1145 DWORD ContextFlags
; /* 030 */
1146 DWORD MxCsr
; /* 034 */
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 */
1158 DWORD64 Dr0
; /* 048 */
1159 DWORD64 Dr1
; /* 050 */
1160 DWORD64 Dr2
; /* 058 */
1161 DWORD64 Dr3
; /* 060 */
1162 DWORD64 Dr6
; /* 068 */
1163 DWORD64 Dr7
; /* 070 */
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 */
1184 DWORD64 Rip
; /* 0f8 */
1186 /* Floating point */
1188 XMM_SAVE_AREA32 FltSave
; /* 100 */
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 */
1212 M128A VectorRegister
[26]; /* 300 */
1213 DWORD64 VectorControl
; /* 4a0 */
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
1228 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1230 #define UNWIND_HISTORY_TABLE_SIZE 12
1232 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
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
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
1255 PM128A FloatingContext
[16];
1279 PULONG64 IntegerContext
[16];
1300 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1302 typedef struct _DISPATCHER_CONTEXT
1306 PRUNTIME_FUNCTION FunctionEntry
;
1307 ULONG64 EstablisherFrame
;
1309 PCONTEXT ContextRecord
;
1310 PEXCEPTION_ROUTINE LanguageHandler
;
1312 PUNWIND_HISTORY_TABLE HistoryTable
;
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
1341 #define MAXIMUM_XSTATE_FEATURES 64
1343 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1 << XSTATE_LEGACY_FLOATING_POINT)
1344 #define XSTATE_MASK_LEGACY_SSE (1 << XSTATE_LEGACY_SSE)
1345 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1346 #define XSTATE_MASK_GSSE (1 << XSTATE_GSSE)
1348 typedef struct _XSTATE_FEATURE
1352 } XSTATE_FEATURE
, *PXSTATE_FEATURE
;
1354 typedef struct _XSTATE_CONFIGURATION
1356 ULONG64 EnabledFeatures
;
1357 ULONG64 EnabledVolatileFeatures
;
1359 ULONG OptimizedSave
:1;
1360 ULONG CompactionEnabled
:1;
1361 XSTATE_FEATURE Features
[MAXIMUM_XSTATE_FEATURES
];
1363 ULONG64 EnabledSupervisorFeatures
;
1364 ULONG64 AlignedFeatures
;
1365 ULONG AllFeatureSize
;
1366 ULONG AllFeatures
[MAXIMUM_XSTATE_FEATURES
];
1367 ULONG64 EnabledUserVisibleSupervisorFeatures
;
1368 } XSTATE_CONFIGURATION
, *PXSTATE_CONFIGURATION
;
1370 typedef struct _YMMCONTEXT
1389 YMMCONTEXT
, *PYMMCONTEXT
;
1391 typedef struct _XSTATE
1394 ULONG64 CompactionMask
;
1395 ULONG64 Reserved
[6];
1396 YMMCONTEXT YmmContext
;
1399 typedef struct _CONTEXT_CHUNK
1403 } CONTEXT_CHUNK
, *PCONTEXT_CHUNK
;
1405 typedef struct _CONTEXT_EX
1408 CONTEXT_CHUNK Legacy
;
1409 CONTEXT_CHUNK XState
;
1413 } CONTEXT_EX
, *PCONTEXT_EX
;
1415 /* IA64 context definitions */
1418 #define CONTEXT_IA64 0x00080000
1419 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1420 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1421 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1422 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1423 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1424 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1425 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1426 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1427 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1429 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1430 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1431 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1432 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1434 typedef struct _CONTEXT
1629 ULONGLONG RsBSPSTORE
;
1643 ULONGLONG UNUSEDPACK
;
1644 } CONTEXT
, *PCONTEXT
;
1646 typedef struct _RUNTIME_FUNCTION
1650 ULONG UnwindInfoAddress
;
1651 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1653 typedef struct _FRAME_POINTERS
{
1654 ULONGLONG MemoryStackFp
;
1655 ULONGLONG BackingStoreFp
;
1656 } FRAME_POINTERS
, *PFRAME_POINTERS
;
1658 #define UNWIND_HISTORY_TABLE_SIZE 12
1660 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
{
1663 PRUNTIME_FUNCTION FunctionEntry
;
1664 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1666 typedef struct _UNWIND_HISTORY_TABLE
{
1670 ULONG64 HighAddress
;
1671 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1672 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1674 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1680 PFLOAT128 HighFloatingContext
[10];
1702 PULONGLONG IntS0Nat
;
1703 PULONGLONG IntS1Nat
;
1704 PULONGLONG IntS2Nat
;
1705 PULONGLONG IntS3Nat
;
1706 PULONGLONG IntSpNat
;
1722 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1724 NTSYSAPI ULONGLONG WINAPI
RtlVirtualUnwind(ULONGLONG
,ULONGLONG
,RUNTIME_FUNCTION
*,CONTEXT
*,BOOLEAN
*,FRAME_POINTERS
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1726 #endif /* __ia64__ */
1728 /* Alpha context definitions */
1729 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1731 #define CONTEXT_ALPHA 0x00020000
1733 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1734 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1735 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1736 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1738 #define EXCEPTION_READ_FAULT 0
1739 #define EXCEPTION_WRITE_FAULT 1
1740 #define EXCEPTION_EXECUTE_FAULT 8
1742 typedef struct _CONTEXT
1744 /* selected by CONTEXT_FLOATING_POINT */
1778 /* selected by CONTEXT_INTEGER */
1812 /* selected by CONTEXT_FLOATING_POINT */
1816 /* selected by CONTEXT_CONTROL */
1821 } CONTEXT
, *PCONTEXT
;
1823 #define _QUAD_PSR_OFFSET HighSoftFpcr
1824 #define _QUAD_FLAGS_OFFSET HighFir
1826 #endif /* _ALPHA_ */
1830 /* The following flags control the contents of the CONTEXT structure. */
1832 #define CONTEXT_ARM 0x0200000
1833 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1834 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1835 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1836 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1838 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1839 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1841 #define EXCEPTION_READ_FAULT 0
1842 #define EXCEPTION_WRITE_FAULT 1
1843 #define EXCEPTION_EXECUTE_FAULT 8
1845 #define ARM_MAX_BREAKPOINTS 8
1846 #define ARM_MAX_WATCHPOINTS 1
1848 typedef struct _RUNTIME_FUNCTION
1855 DWORD FunctionLength
: 11;
1862 DWORD StackAdjust
: 10;
1865 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1867 #define UNWIND_HISTORY_TABLE_SIZE 12
1869 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1872 PRUNTIME_FUNCTION FunctionEntry
;
1873 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1875 typedef struct _UNWIND_HISTORY_TABLE
1884 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1885 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1887 typedef struct _NEON128
1891 } NEON128
, *PNEON128
;
1893 typedef struct _CONTEXT
1895 ULONG ContextFlags
; /* 000 */
1896 /* CONTEXT_INTEGER */
1907 ULONG R10
; /* 02c */
1908 ULONG R11
; /* 030 */
1909 ULONG R12
; /* 034 */
1910 /* CONTEXT_CONTROL */
1914 ULONG Cpsr
; /* 044 */
1915 /* CONTEXT_FLOATING_POINT */
1916 ULONG Fpscr
; /* 048 */
1917 ULONG Padding
; /* 04c */
1923 } DUMMYUNIONNAME
; /* 050 */
1924 /* CONTEXT_DEBUG_REGISTERS */
1925 ULONG Bvr
[ARM_MAX_BREAKPOINTS
]; /* 150 */
1926 ULONG Bcr
[ARM_MAX_BREAKPOINTS
]; /* 170 */
1927 ULONG Wvr
[ARM_MAX_WATCHPOINTS
]; /* 190 */
1928 ULONG Wcr
[ARM_MAX_WATCHPOINTS
]; /* 194 */
1929 ULONG Padding2
[2]; /* 198 */
1930 } CONTEXT
, *PCONTEXT
;
1932 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1951 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1953 typedef struct _DISPATCHER_CONTEXT
1957 PRUNTIME_FUNCTION FunctionEntry
;
1958 DWORD EstablisherFrame
;
1960 PCONTEXT ContextRecord
;
1961 PEXCEPTION_ROUTINE LanguageHandler
;
1963 PUNWIND_HISTORY_TABLE HistoryTable
;
1965 BOOLEAN ControlPcIsUnwound
;
1966 PBYTE NonVolatileRegisters
;
1968 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1970 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD
);
1971 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD
);
1973 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,DWORD
,DWORD
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,DWORD
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1975 #define UNW_FLAG_NHANDLER 0
1976 #define UNW_FLAG_EHANDLER 1
1977 #define UNW_FLAG_UHANDLER 2
1979 #endif /* __arm__ */
1983 #define CONTEXT_ARM64 0x400000
1984 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1985 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1986 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1987 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1988 #define CONTEXT_ARM64_X18 (CONTEXT_ARM64 | 0x00000010)
1990 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1992 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1993 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_ARM64_X18)
1995 #define EXCEPTION_READ_FAULT 0
1996 #define EXCEPTION_WRITE_FAULT 1
1997 #define EXCEPTION_EXECUTE_FAULT 8
1999 #define ARM64_MAX_BREAKPOINTS 8
2000 #define ARM64_MAX_WATCHPOINTS 2
2002 typedef struct _RUNTIME_FUNCTION
2011 DWORD FunctionLength
: 11;
2016 DWORD FrameSize
: 9;
2019 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
2021 #define UNWIND_HISTORY_TABLE_SIZE 12
2023 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
2026 PRUNTIME_FUNCTION FunctionEntry
;
2027 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
2029 typedef struct _UNWIND_HISTORY_TABLE
2037 DWORD64 HighAddress
;
2038 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
2039 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
2041 typedef union _NEON128
2052 } NEON128
, *PNEON128
;
2054 typedef struct _CONTEXT
2056 ULONG ContextFlags
; /* 000 */
2057 /* CONTEXT_INTEGER */
2058 ULONG Cpsr
; /* 004 */
2063 DWORD64 X0
; /* 008 */
2064 DWORD64 X1
; /* 010 */
2065 DWORD64 X2
; /* 018 */
2066 DWORD64 X3
; /* 020 */
2067 DWORD64 X4
; /* 028 */
2068 DWORD64 X5
; /* 030 */
2069 DWORD64 X6
; /* 038 */
2070 DWORD64 X7
; /* 040 */
2071 DWORD64 X8
; /* 048 */
2072 DWORD64 X9
; /* 050 */
2073 DWORD64 X10
; /* 058 */
2074 DWORD64 X11
; /* 060 */
2075 DWORD64 X12
; /* 068 */
2076 DWORD64 X13
; /* 070 */
2077 DWORD64 X14
; /* 078 */
2078 DWORD64 X15
; /* 080 */
2079 DWORD64 X16
; /* 088 */
2080 DWORD64 X17
; /* 090 */
2081 DWORD64 X18
; /* 098 */
2082 DWORD64 X19
; /* 0a0 */
2083 DWORD64 X20
; /* 0a8 */
2084 DWORD64 X21
; /* 0b0 */
2085 DWORD64 X22
; /* 0b8 */
2086 DWORD64 X23
; /* 0c0 */
2087 DWORD64 X24
; /* 0c8 */
2088 DWORD64 X25
; /* 0d0 */
2089 DWORD64 X26
; /* 0d8 */
2090 DWORD64 X27
; /* 0e0 */
2091 DWORD64 X28
; /* 0e8 */
2092 DWORD64 Fp
; /* 0f0 */
2093 DWORD64 Lr
; /* 0f8 */
2095 DWORD64 X
[31]; /* 008 */
2097 /* CONTEXT_CONTROL */
2098 DWORD64 Sp
; /* 100 */
2099 DWORD64 Pc
; /* 108 */
2100 /* CONTEXT_FLOATING_POINT */
2101 NEON128 V
[32]; /* 110 */
2102 DWORD Fpcr
; /* 310 */
2103 DWORD Fpsr
; /* 314 */
2104 /* CONTEXT_DEBUG_REGISTERS */
2105 DWORD Bcr
[ARM64_MAX_BREAKPOINTS
]; /* 318 */
2106 DWORD64 Bvr
[ARM64_MAX_BREAKPOINTS
]; /* 338 */
2107 DWORD Wcr
[ARM64_MAX_WATCHPOINTS
]; /* 378 */
2108 DWORD64 Wvr
[ARM64_MAX_WATCHPOINTS
]; /* 380 */
2109 } CONTEXT
, *PCONTEXT
;
2111 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
2133 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
2135 typedef struct _DISPATCHER_CONTEXT
2137 ULONG_PTR ControlPc
;
2138 ULONG_PTR ImageBase
;
2139 PRUNTIME_FUNCTION FunctionEntry
;
2140 ULONG_PTR EstablisherFrame
;
2142 PCONTEXT ContextRecord
;
2143 PEXCEPTION_ROUTINE LanguageHandler
;
2145 PUNWIND_HISTORY_TABLE HistoryTable
;
2147 BOOLEAN ControlPcIsUnwound
;
2148 PBYTE NonVolatileRegisters
;
2149 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
2151 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD64
);
2152 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD64
);
2154 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,ULONG_PTR
,ULONG_PTR
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,ULONG_PTR
*,KNONVOLATILE_CONTEXT_POINTERS
*);
2156 #define UNW_FLAG_NHANDLER 0
2157 #define UNW_FLAG_EHANDLER 1
2158 #define UNW_FLAG_UHANDLER 2
2160 #endif /* __aarch64__ */
2163 /* Mips context definitions */
2164 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
2166 #define CONTEXT_R4000 0x00010000
2168 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
2169 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
2170 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
2172 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2174 #define EXCEPTION_READ_FAULT 0
2175 #define EXCEPTION_WRITE_FAULT 1
2176 #define EXCEPTION_EXECUTE_FAULT 8
2178 typedef struct _CONTEXT
2181 /* These are selected by CONTEXT_FLOATING_POINT */
2215 /* These are selected by CONTEXT_INTEGER */
2251 /* These are selected by CONTEXT_FLOATING_POINT */
2254 /* These are selected by CONTEXT_CONTROL */
2260 } CONTEXT
, *PCONTEXT
;
2264 /* PowerPC context definitions */
2267 #define CONTEXT_CONTROL 0x0001
2268 #define CONTEXT_FLOATING_POINT 0x0002
2269 #define CONTEXT_INTEGER 0x0004
2270 #define CONTEXT_DEBUG_REGISTERS 0x0008
2271 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2273 #define EXCEPTION_READ_FAULT 0
2274 #define EXCEPTION_WRITE_FAULT 1
2275 #define EXCEPTION_EXECUTE_FAULT 8
2279 /* These are selected by CONTEXT_FLOATING_POINT */
2314 /* These are selected by CONTEXT_INTEGER */
2351 /* These are selected by CONTEXT_CONTROL */
2353 DWORD Iar
; /* Instruction Address Register , aka PC ... */
2359 DWORD Dar
; /* Fault registers for coredump */
2361 DWORD Trap
; /* number of powerpc exception taken */
2363 /* These are selected by CONTEXT_DEBUG_REGISTERS */
2372 } CONTEXT
, *PCONTEXT
;
2374 typedef struct _STACK_FRAME_HEADER
2391 } STACK_FRAME_HEADER
,*PSTACK_FRAME_HEADER
;
2393 #endif /* __powerpc__ */
2395 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2396 #error You need to define a CONTEXT for your CPU
2399 NTSYSAPI
void WINAPI
RtlCaptureContext(CONTEXT
*);
2401 #define WOW64_CONTEXT_i386 0x00010000
2402 #define WOW64_CONTEXT_i486 0x00010000
2403 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
2404 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
2405 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
2406 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
2407 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
2408 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
2409 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2410 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
2411 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
2412 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
2413 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
2415 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2417 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
2418 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
2419 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
2420 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
2422 #define WOW64_SIZE_OF_80387_REGISTERS 80
2423 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
2425 typedef struct _WOW64_FLOATING_SAVE_AREA
2431 DWORD ErrorSelector
;
2434 BYTE RegisterArea
[WOW64_SIZE_OF_80387_REGISTERS
];
2436 } WOW64_FLOATING_SAVE_AREA
, *PWOW64_FLOATING_SAVE_AREA
;
2438 #include "pshpack4.h"
2439 typedef struct _WOW64_CONTEXT
2448 WOW64_FLOATING_SAVE_AREA FloatSave
;
2465 BYTE ExtendedRegisters
[WOW64_MAXIMUM_SUPPORTED_EXTENSION
];
2466 } WOW64_CONTEXT
, *PWOW64_CONTEXT
;
2467 #include "poppack.h"
2469 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
2471 typedef PRUNTIME_FUNCTION (CALLBACK
*PGET_RUNTIME_FUNCTION_CALLBACK
)(DWORD_PTR
,PVOID
);
2473 NTSYSAPI BOOLEAN CDECL
RtlAddFunctionTable(RUNTIME_FUNCTION
*,DWORD
,DWORD_PTR
);
2474 NTSYSAPI DWORD WINAPI
RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION
,DWORD
,DWORD
,ULONG_PTR
,ULONG_PTR
);
2475 NTSYSAPI BOOLEAN CDECL
RtlDeleteFunctionTable(RUNTIME_FUNCTION
*);
2476 NTSYSAPI
void WINAPI
RtlDeleteGrowableFunctionTable(void*);
2477 NTSYSAPI
void WINAPI
RtlGrowFunctionTable(void*,DWORD
);
2478 NTSYSAPI BOOLEAN CDECL
RtlInstallFunctionTableCallback(DWORD_PTR
,DWORD_PTR
,DWORD
,PGET_RUNTIME_FUNCTION_CALLBACK
,PVOID
,PCWSTR
);
2479 NTSYSAPI PRUNTIME_FUNCTION WINAPI
RtlLookupFunctionEntry(DWORD_PTR
,DWORD_PTR
*,UNWIND_HISTORY_TABLE
*);
2480 NTSYSAPI
void WINAPI
RtlUnwindEx(PVOID
,PVOID
,struct _EXCEPTION_RECORD
*,PVOID
,CONTEXT
*,UNWIND_HISTORY_TABLE
*);
2486 #define PRODUCT_UNDEFINED 0x00000000
2487 #define PRODUCT_ULTIMATE 0x00000001
2488 #define PRODUCT_HOME_BASIC 0x00000002
2489 #define PRODUCT_HOME_PREMIUM 0x00000003
2490 #define PRODUCT_ENTERPRISE 0x00000004
2491 #define PRODUCT_HOME_BASIC_N 0x00000005
2492 #define PRODUCT_BUSINESS 0x00000006
2493 #define PRODUCT_STANDARD_SERVER 0x00000007
2494 #define PRODUCT_DATACENTER_SERVER 0x00000008
2495 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2496 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2497 #define PRODUCT_STARTER 0x0000000B
2498 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2499 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2500 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2501 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2502 #define PRODUCT_BUSINESS_N 0x00000010
2503 #define PRODUCT_WEB_SERVER 0x00000011
2504 #define PRODUCT_CLUSTER_SERVER 0x00000012
2505 #define PRODUCT_HOME_SERVER 0x00000013
2506 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2507 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2508 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2509 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2510 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2511 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2512 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2513 #define PRODUCT_ENTERPRISE_N 0x0000001B
2514 #define PRODUCT_ULTIMATE_N 0x0000001C
2515 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2516 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2517 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2518 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2519 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2520 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2521 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2522 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2523 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2524 #define PRODUCT_SERVER_V 0x00000025
2525 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2526 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2527 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2528 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2529 #define PRODUCT_HYPERV 0x0000002A
2530 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2531 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2532 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2533 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2534 #define PRODUCT_STARTER_N 0x0000002F
2535 #define PRODUCT_PROFESSIONAL 0x00000030
2536 #define PRODUCT_PROFESSIONAL_N 0x00000031
2537 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2538 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2539 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2540 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2541 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2542 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2543 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2544 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2545 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2546 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2547 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2548 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2549 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2550 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2551 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2552 #define PRODUCT_EMBEDDED 0x00000041
2553 #define PRODUCT_STARTER_E 0x00000042
2554 #define PRODUCT_HOME_BASIC_E 0x00000043
2555 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2556 #define PRODUCT_PROFESSIONAL_E 0x00000045
2557 #define PRODUCT_ENTERPRISE_E 0x00000046
2558 #define PRODUCT_ULTIMATE_E 0x00000047
2559 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2560 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2561 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2562 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2563 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2564 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2565 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2566 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2567 #define PRODUCT_THINPC 0x00000057
2568 #define PRODUCT_EMBEDDED_A 0x00000058
2569 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2570 #define PRODUCT_EMBEDDED_E 0x0000005A
2571 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2572 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2573 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2574 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2575 #define PRODUCT_CORE_ARM 0x00000061
2576 #define PRODUCT_CORE_N 0x00000062
2577 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2578 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2579 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2580 #define PRODUCT_CORE 0x00000065
2581 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2582 #define PRODUCT_MOBILE_CORE 0x00000068
2583 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2584 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2585 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2586 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2587 #define PRODUCT_NANO_SERVER 0x0000006D
2588 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2589 #define PRODUCT_CORE_CONNECTED 0x0000006F
2590 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2591 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2592 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2593 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2594 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2595 #define PRODUCT_CONNECTED_CAR 0x00000075
2596 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2597 #define PRODUCT_PPI_PRO 0x00000077
2598 #define PRODUCT_ARM64_SERVER 0x00000078
2599 #define PRODUCT_EDUCATION 0x00000079
2600 #define PRODUCT_EDUCATION_N 0x0000007A
2601 #define PRODUCT_IOTUAP 0x0000007B
2602 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2603 #define PRODUCT_ENTERPRISE_S 0x0000007D
2604 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2605 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2606 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2607 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2608 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2609 #define PRODUCT_UNLICENSED 0xABCDABCD
2616 #define MAKELCID(l, s) (MAKELONG(l, s))
2618 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2619 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2620 #define SUBLANGID(l) ((WORD)(l) >> 10)
2622 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2623 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2625 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2626 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2627 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2628 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2629 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2630 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2631 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2632 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2633 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2634 #define LOCALE_NAME_MAX_LENGTH 85
2637 #define UNREFERENCED_PARAMETER(u) (void)(u)
2638 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2639 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2645 * Definitions for IsTextUnicode()
2648 #define IS_TEXT_UNICODE_ASCII16 0x0001
2649 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2650 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2651 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2652 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2653 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2654 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2655 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2656 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2657 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2658 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2659 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2660 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2661 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2662 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2663 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2665 #define MAXIMUM_WAIT_OBJECTS 64
2666 #define MAXIMUM_SUSPEND_COUNT 127
2668 #define WT_EXECUTEDEFAULT 0x00
2669 #define WT_EXECUTEINIOTHREAD 0x01
2670 #define WT_EXECUTEINUITHREAD 0x02
2671 #define WT_EXECUTEINWAITTHREAD 0x04
2672 #define WT_EXECUTEONLYONCE 0x08
2673 #define WT_EXECUTELONGFUNCTION 0x10
2674 #define WT_EXECUTEINTIMERTHREAD 0x20
2675 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2676 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2677 #define WT_EXECUTEINLONGTHREAD 0x10
2678 #define WT_EXECUTEDELETEWAIT 0x08
2679 #define WT_TRANSFER_IMPERSONATION 0x0100
2682 #define EXCEPTION_CONTINUABLE 0
2683 #define EXCEPTION_NONCONTINUABLE 0x01
2686 * The exception record used by Win32 to give additional information
2687 * about exception to exception handlers.
2690 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2692 typedef struct _EXCEPTION_RECORD
2694 DWORD ExceptionCode
;
2695 DWORD ExceptionFlags
;
2696 struct _EXCEPTION_RECORD
*ExceptionRecord
;
2698 PVOID ExceptionAddress
;
2699 DWORD NumberParameters
;
2700 ULONG_PTR ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2701 } EXCEPTION_RECORD
, *PEXCEPTION_RECORD
;
2703 typedef struct _EXCEPTION_RECORD32
2705 DWORD ExceptionCode
;
2706 DWORD ExceptionFlags
;
2707 DWORD ExceptionRecord
;
2708 DWORD ExceptionAddress
;
2709 DWORD NumberParameters
;
2710 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2711 } EXCEPTION_RECORD32
, *PEXCEPTION_RECORD32
;
2713 typedef struct _EXCEPTION_RECORD64
2715 DWORD ExceptionCode
;
2716 DWORD ExceptionFlags
;
2717 DWORD64 ExceptionRecord
;
2718 DWORD64 ExceptionAddress
;
2719 DWORD NumberParameters
;
2720 DWORD __unusedAlignment
;
2721 DWORD64 ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2722 } EXCEPTION_RECORD64
, *PEXCEPTION_RECORD64
;
2725 * The exception pointers structure passed to exception filters
2726 * in except() and the UnhandledExceptionFilter().
2729 typedef struct _EXCEPTION_POINTERS
2731 PEXCEPTION_RECORD ExceptionRecord
;
2732 PCONTEXT ContextRecord
;
2733 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
;
2737 * The exception frame, used for registering exception handlers
2738 * Win32 cares only about this, but compilers generally emit
2739 * larger exception frames for their own use.
2742 struct _EXCEPTION_REGISTRATION_RECORD
;
2744 typedef DWORD (CDECL
*PEXCEPTION_HANDLER
)(PEXCEPTION_RECORD
,struct _EXCEPTION_REGISTRATION_RECORD
*,
2745 PCONTEXT
,struct _EXCEPTION_REGISTRATION_RECORD
**);
2747 typedef struct _EXCEPTION_REGISTRATION_RECORD
2749 struct _EXCEPTION_REGISTRATION_RECORD
*Prev
;
2750 PEXCEPTION_HANDLER Handler
;
2751 } EXCEPTION_REGISTRATION_RECORD
;
2754 * function pointer to an exception filter
2757 typedef LONG (CALLBACK
*PVECTORED_EXCEPTION_HANDLER
)(PEXCEPTION_POINTERS ExceptionInfo
);
2759 typedef struct _NT_TIB
2761 struct _EXCEPTION_REGISTRATION_RECORD
*ExceptionList
;
2769 PVOID ArbitraryUserPointer
;
2770 struct _NT_TIB
*Self
;
2775 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2776 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2779 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb
));
2782 #elif defined(__i386__) && defined(_MSC_VER)
2783 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2786 __asm mov eax
, fs
:[0x18];
2790 #elif defined(__x86_64__) && defined(__GNUC__)
2791 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2794 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb
));
2797 #elif defined(__x86_64__) && defined(_MSC_VER)
2798 unsigned __int64
__readgsqword(unsigned long);
2799 #pragma intrinsic(__readgsqword)
2800 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2802 return (struct _TEB
*)__readgsqword(FIELD_OFFSET(NT_TIB
, Self
));
2804 #elif defined(__arm__) && defined(__MINGW32__)
2805 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2808 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb
));
2812 extern struct _TEB
* WINAPI
NtCurrentTeb(void);
2815 #ifdef NONAMELESSUNION
2816 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2818 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2820 #define GetFiberData() (*(void **)GetCurrentFiber())
2822 #define TLS_MINIMUM_AVAILABLE 64
2824 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2826 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2827 #define IO_REPARSE_TAG_RESERVED_ONE 1
2828 #define IO_REPARSE_TAG_RESERVED_TWO 2
2830 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2832 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2833 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2834 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2835 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2836 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2837 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2838 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2839 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2840 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2841 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2842 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2843 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2844 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2845 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2846 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2847 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2848 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2849 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2850 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2851 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2852 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2853 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2854 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2855 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2856 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2857 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2858 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2859 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2860 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2861 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2862 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2863 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2864 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2865 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2866 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2867 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2868 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2869 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2870 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2871 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2872 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2873 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2874 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2877 * File formats definitions
2880 #include <pshpack2.h>
2881 typedef struct _IMAGE_DOS_HEADER
{
2882 WORD e_magic
; /* 00: MZ Header signature */
2883 WORD e_cblp
; /* 02: Bytes on last page of file */
2884 WORD e_cp
; /* 04: Pages in file */
2885 WORD e_crlc
; /* 06: Relocations */
2886 WORD e_cparhdr
; /* 08: Size of header in paragraphs */
2887 WORD e_minalloc
; /* 0a: Minimum extra paragraphs needed */
2888 WORD e_maxalloc
; /* 0c: Maximum extra paragraphs needed */
2889 WORD e_ss
; /* 0e: Initial (relative) SS value */
2890 WORD e_sp
; /* 10: Initial SP value */
2891 WORD e_csum
; /* 12: Checksum */
2892 WORD e_ip
; /* 14: Initial IP value */
2893 WORD e_cs
; /* 16: Initial (relative) CS value */
2894 WORD e_lfarlc
; /* 18: File address of relocation table */
2895 WORD e_ovno
; /* 1a: Overlay number */
2896 WORD e_res
[4]; /* 1c: Reserved words */
2897 WORD e_oemid
; /* 24: OEM identifier (for e_oeminfo) */
2898 WORD e_oeminfo
; /* 26: OEM information; e_oemid specific */
2899 WORD e_res2
[10]; /* 28: Reserved words */
2900 DWORD e_lfanew
; /* 3c: Offset to extended header */
2901 } IMAGE_DOS_HEADER
, *PIMAGE_DOS_HEADER
;
2902 #include <poppack.h>
2904 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2905 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2906 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2907 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2908 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2909 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2912 * This is the Windows executable (NE) header.
2913 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2915 #include <pshpack2.h>
2918 WORD ne_magic
; /* 00 NE signature 'NE' */
2919 BYTE ne_ver
; /* 02 Linker version number */
2920 BYTE ne_rev
; /* 03 Linker revision number */
2921 WORD ne_enttab
; /* 04 Offset to entry table relative to NE */
2922 WORD ne_cbenttab
; /* 06 Length of entry table in bytes */
2923 LONG ne_crc
; /* 08 Checksum */
2924 WORD ne_flags
; /* 0c Flags about segments in this file */
2925 WORD ne_autodata
; /* 0e Automatic data segment number */
2926 WORD ne_heap
; /* 10 Initial size of local heap */
2927 WORD ne_stack
; /* 12 Initial size of stack */
2928 DWORD ne_csip
; /* 14 Initial CS:IP */
2929 DWORD ne_sssp
; /* 18 Initial SS:SP */
2930 WORD ne_cseg
; /* 1c # of entries in segment table */
2931 WORD ne_cmod
; /* 1e # of entries in module reference tab. */
2932 WORD ne_cbnrestab
; /* 20 Length of nonresident-name table */
2933 WORD ne_segtab
; /* 22 Offset to segment table */
2934 WORD ne_rsrctab
; /* 24 Offset to resource table */
2935 WORD ne_restab
; /* 26 Offset to resident-name table */
2936 WORD ne_modtab
; /* 28 Offset to module reference table */
2937 WORD ne_imptab
; /* 2a Offset to imported name table */
2938 DWORD ne_nrestab
; /* 2c Offset to nonresident-name table */
2939 WORD ne_cmovent
; /* 30 # of movable entry points */
2940 WORD ne_align
; /* 32 Logical sector alignment shift count */
2941 WORD ne_cres
; /* 34 # of resource segments */
2942 BYTE ne_exetyp
; /* 36 Flags indicating target OS */
2943 BYTE ne_flagsothers
; /* 37 Additional information flags */
2944 WORD ne_pretthunks
; /* 38 Offset to return thunks */
2945 WORD ne_psegrefbytes
; /* 3a Offset to segment ref. bytes */
2946 WORD ne_swaparea
; /* 3c Reserved by Microsoft */
2947 WORD ne_expver
; /* 3e Expected Windows version number */
2948 } IMAGE_OS2_HEADER
, *PIMAGE_OS2_HEADER
;
2949 #include <poppack.h>
2951 #include <pshpack2.h>
2952 typedef struct _IMAGE_VXD_HEADER
{
2967 DWORD e32_lastpagesize
;
2968 DWORD e32_fixupsize
;
2985 DWORD e32_impmodcnt
;
2991 DWORD e32_cbnrestab
;
2994 DWORD e32_debuginfo
;
2996 DWORD e32_instpreload
;
2997 DWORD e32_instdemand
;
3000 DWORD e32_winresoff
;
3001 DWORD e32_winreslen
;
3004 } IMAGE_VXD_HEADER
, *PIMAGE_VXD_HEADER
;
3005 #include <poppack.h>
3007 /* These defines describe the meanings of the bits in the Characteristics
3010 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
3011 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
3012 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
3013 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
3014 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
3015 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
3016 #define IMAGE_FILE_16BIT_MACHINE 0x0040
3017 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
3018 #define IMAGE_FILE_32BIT_MACHINE 0x0100
3019 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
3020 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
3021 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
3022 #define IMAGE_FILE_SYSTEM 0x1000
3023 #define IMAGE_FILE_DLL 0x2000
3024 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
3025 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
3027 /* These are the settings of the Machine field. */
3028 #define IMAGE_FILE_MACHINE_UNKNOWN 0
3029 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
3030 #define IMAGE_FILE_MACHINE_I860 0x014d
3031 #define IMAGE_FILE_MACHINE_I386 0x014c
3032 #define IMAGE_FILE_MACHINE_R3000 0x0162
3033 #define IMAGE_FILE_MACHINE_R4000 0x0166
3034 #define IMAGE_FILE_MACHINE_R10000 0x0168
3035 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
3036 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
3037 #define IMAGE_FILE_MACHINE_SH3 0x01a2
3038 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
3039 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
3040 #define IMAGE_FILE_MACHINE_SH4 0x01a6
3041 #define IMAGE_FILE_MACHINE_SH5 0x01a8
3042 #define IMAGE_FILE_MACHINE_ARM 0x01c0
3043 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
3044 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
3045 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
3046 #define IMAGE_FILE_MACHINE_AM33 0x01d3
3047 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
3048 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
3049 #define IMAGE_FILE_MACHINE_IA64 0x0200
3050 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
3051 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
3052 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
3053 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
3054 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
3055 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
3056 #define IMAGE_FILE_MACHINE_CEF 0x0cef
3057 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
3058 #define IMAGE_FILE_MACHINE_AMD64 0x8664
3059 #define IMAGE_FILE_MACHINE_M32R 0x9041
3060 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
3062 #define IMAGE_SIZEOF_FILE_HEADER 20
3063 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
3064 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
3065 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
3066 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
3067 #define IMAGE_SIZEOF_SHORT_NAME 8
3068 #define IMAGE_SIZEOF_SECTION_HEADER 40
3069 #define IMAGE_SIZEOF_SYMBOL 18
3070 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3071 #define IMAGE_SIZEOF_RELOCATION 10
3072 #define IMAGE_SIZEOF_BASE_RELOCATION 8
3073 #define IMAGE_SIZEOF_LINENUMBER 6
3074 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3076 /* Possible Magic values */
3077 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
3078 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
3079 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
3082 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
3083 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
3085 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
3086 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
3089 /* These are indexes into the DataDirectory array */
3090 #define IMAGE_FILE_EXPORT_DIRECTORY 0
3091 #define IMAGE_FILE_IMPORT_DIRECTORY 1
3092 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
3093 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
3094 #define IMAGE_FILE_SECURITY_DIRECTORY 4
3095 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
3096 #define IMAGE_FILE_DEBUG_DIRECTORY 6
3097 #define IMAGE_FILE_DESCRIPTION_STRING 7
3098 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
3099 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
3100 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
3102 /* Directory Entries, indices into the DataDirectory array */
3104 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
3105 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
3106 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
3107 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
3108 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
3109 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
3110 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
3111 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
3112 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
3113 #define IMAGE_DIRECTORY_ENTRY_TLS 9
3114 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
3115 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
3116 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
3117 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
3118 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
3120 /* Subsystem Values */
3122 #define IMAGE_SUBSYSTEM_UNKNOWN 0
3123 #define IMAGE_SUBSYSTEM_NATIVE 1
3124 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
3125 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
3126 #define IMAGE_SUBSYSTEM_OS2_CUI 5
3127 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
3128 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
3129 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
3130 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
3131 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
3132 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
3133 #define IMAGE_SUBSYSTEM_EFI_ROM 13
3134 #define IMAGE_SUBSYSTEM_XBOX 14
3135 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
3137 /* DLL Characteristics */
3138 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
3139 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
3140 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
3141 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
3142 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
3143 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
3144 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
3145 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
3147 typedef struct _IMAGE_FILE_HEADER
{
3149 WORD NumberOfSections
;
3150 DWORD TimeDateStamp
;
3151 DWORD PointerToSymbolTable
;
3152 DWORD NumberOfSymbols
;
3153 WORD SizeOfOptionalHeader
;
3154 WORD Characteristics
;
3155 } IMAGE_FILE_HEADER
, *PIMAGE_FILE_HEADER
;
3157 typedef struct _IMAGE_DATA_DIRECTORY
{
3158 DWORD VirtualAddress
;
3160 } IMAGE_DATA_DIRECTORY
, *PIMAGE_DATA_DIRECTORY
;
3162 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
3164 typedef struct _IMAGE_OPTIONAL_HEADER64
{
3165 WORD Magic
; /* 0x20b */
3166 BYTE MajorLinkerVersion
;
3167 BYTE MinorLinkerVersion
;
3169 DWORD SizeOfInitializedData
;
3170 DWORD SizeOfUninitializedData
;
3171 DWORD AddressOfEntryPoint
;
3173 ULONGLONG ImageBase
;
3174 DWORD SectionAlignment
;
3175 DWORD FileAlignment
;
3176 WORD MajorOperatingSystemVersion
;
3177 WORD MinorOperatingSystemVersion
;
3178 WORD MajorImageVersion
;
3179 WORD MinorImageVersion
;
3180 WORD MajorSubsystemVersion
;
3181 WORD MinorSubsystemVersion
;
3182 DWORD Win32VersionValue
;
3184 DWORD SizeOfHeaders
;
3187 WORD DllCharacteristics
;
3188 ULONGLONG SizeOfStackReserve
;
3189 ULONGLONG SizeOfStackCommit
;
3190 ULONGLONG SizeOfHeapReserve
;
3191 ULONGLONG SizeOfHeapCommit
;
3193 DWORD NumberOfRvaAndSizes
;
3194 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
];
3195 } IMAGE_OPTIONAL_HEADER64
, *PIMAGE_OPTIONAL_HEADER64
;
3197 typedef struct _IMAGE_NT_HEADERS64
{
3199 IMAGE_FILE_HEADER FileHeader
;
3200 IMAGE_OPTIONAL_HEADER64 OptionalHeader
;
3201 } IMAGE_NT_HEADERS64
, *PIMAGE_NT_HEADERS64
;
3203 typedef struct _IMAGE_OPTIONAL_HEADER
{
3205 /* Standard fields */
3207 WORD Magic
; /* 0x10b or 0x107 */ /* 0x00 */
3208 BYTE MajorLinkerVersion
;
3209 BYTE MinorLinkerVersion
;
3211 DWORD SizeOfInitializedData
;
3212 DWORD SizeOfUninitializedData
;
3213 DWORD AddressOfEntryPoint
; /* 0x10 */
3217 /* NT additional fields */
3220 DWORD SectionAlignment
; /* 0x20 */
3221 DWORD FileAlignment
;
3222 WORD MajorOperatingSystemVersion
;
3223 WORD MinorOperatingSystemVersion
;
3224 WORD MajorImageVersion
;
3225 WORD MinorImageVersion
;
3226 WORD MajorSubsystemVersion
; /* 0x30 */
3227 WORD MinorSubsystemVersion
;
3228 DWORD Win32VersionValue
;
3230 DWORD SizeOfHeaders
;
3231 DWORD CheckSum
; /* 0x40 */
3233 WORD DllCharacteristics
;
3234 DWORD SizeOfStackReserve
;
3235 DWORD SizeOfStackCommit
;
3236 DWORD SizeOfHeapReserve
; /* 0x50 */
3237 DWORD SizeOfHeapCommit
;
3239 DWORD NumberOfRvaAndSizes
;
3240 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
]; /* 0x60 */
3242 } IMAGE_OPTIONAL_HEADER32
, *PIMAGE_OPTIONAL_HEADER32
;
3244 typedef struct _IMAGE_NT_HEADERS
{
3245 DWORD Signature
; /* "PE"\0\0 */ /* 0x00 */
3246 IMAGE_FILE_HEADER FileHeader
; /* 0x04 */
3247 IMAGE_OPTIONAL_HEADER32 OptionalHeader
; /* 0x18 */
3248 } IMAGE_NT_HEADERS32
, *PIMAGE_NT_HEADERS32
;
3251 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS
;
3252 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS
;
3253 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER
;
3254 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER
;
3256 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS
;
3257 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
;
3258 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
;
3259 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER
;
3262 #define IMAGE_SIZEOF_SHORT_NAME 8
3264 typedef struct _IMAGE_SECTION_HEADER
{
3265 BYTE Name
[IMAGE_SIZEOF_SHORT_NAME
];
3267 DWORD PhysicalAddress
;
3270 DWORD VirtualAddress
;
3271 DWORD SizeOfRawData
;
3272 DWORD PointerToRawData
;
3273 DWORD PointerToRelocations
;
3274 DWORD PointerToLinenumbers
;
3275 WORD NumberOfRelocations
;
3276 WORD NumberOfLinenumbers
;
3277 DWORD Characteristics
;
3278 } IMAGE_SECTION_HEADER
, *PIMAGE_SECTION_HEADER
;
3280 #define IMAGE_SIZEOF_SECTION_HEADER 40
3282 #define IMAGE_FIRST_SECTION(ntheader) \
3283 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
3284 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
3286 /* These defines are for the Characteristics bitfield. */
3287 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
3288 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
3289 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
3290 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
3291 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
3292 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
3294 #define IMAGE_SCN_CNT_CODE 0x00000020
3295 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
3296 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
3298 #define IMAGE_SCN_LNK_OTHER 0x00000100
3299 #define IMAGE_SCN_LNK_INFO 0x00000200
3300 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
3301 #define IMAGE_SCN_LNK_REMOVE 0x00000800
3302 #define IMAGE_SCN_LNK_COMDAT 0x00001000
3304 /* 0x00002000 - Reserved */
3305 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
3306 #define IMAGE_SCN_MEM_FARDATA 0x00008000
3308 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
3309 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
3310 #define IMAGE_SCN_MEM_16BIT 0x00020000
3311 #define IMAGE_SCN_MEM_LOCKED 0x00040000
3312 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
3314 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
3315 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
3316 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
3317 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
3318 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
3319 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
3320 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
3321 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
3322 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
3323 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
3324 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
3325 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
3326 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
3327 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
3328 /* 0x00F00000 - Unused */
3329 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
3331 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
3334 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
3335 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
3336 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
3337 #define IMAGE_SCN_MEM_SHARED 0x10000000
3338 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
3339 #define IMAGE_SCN_MEM_READ 0x40000000
3340 #define IMAGE_SCN_MEM_WRITE 0x80000000
3342 #include <pshpack2.h>
3344 typedef struct _IMAGE_SYMBOL
{
3354 SHORT SectionNumber
;
3357 BYTE NumberOfAuxSymbols
;
3359 typedef IMAGE_SYMBOL
*PIMAGE_SYMBOL
;
3361 #define IMAGE_SIZEOF_SYMBOL 18
3363 typedef struct _IMAGE_LINENUMBER
{
3365 DWORD SymbolTableIndex
;
3366 DWORD VirtualAddress
;
3370 typedef IMAGE_LINENUMBER
*PIMAGE_LINENUMBER
;
3372 #define IMAGE_SIZEOF_LINENUMBER 6
3374 typedef union _IMAGE_AUX_SYMBOL
{
3386 DWORD PointerToLinenumber
;
3387 DWORD PointerToNextFunction
;
3396 BYTE Name
[IMAGE_SIZEOF_SYMBOL
];
3400 WORD NumberOfRelocations
;
3401 WORD NumberOfLinenumbers
;
3407 typedef IMAGE_AUX_SYMBOL
*PIMAGE_AUX_SYMBOL
;
3409 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3411 #include <poppack.h>
3413 #define IMAGE_SYM_UNDEFINED (SHORT)0
3414 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3415 #define IMAGE_SYM_DEBUG (SHORT)-2
3417 #define IMAGE_SYM_TYPE_NULL 0x0000
3418 #define IMAGE_SYM_TYPE_VOID 0x0001
3419 #define IMAGE_SYM_TYPE_CHAR 0x0002
3420 #define IMAGE_SYM_TYPE_SHORT 0x0003
3421 #define IMAGE_SYM_TYPE_INT 0x0004
3422 #define IMAGE_SYM_TYPE_LONG 0x0005
3423 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3424 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3425 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3426 #define IMAGE_SYM_TYPE_UNION 0x0009
3427 #define IMAGE_SYM_TYPE_ENUM 0x000A
3428 #define IMAGE_SYM_TYPE_MOE 0x000B
3429 #define IMAGE_SYM_TYPE_BYTE 0x000C
3430 #define IMAGE_SYM_TYPE_WORD 0x000D
3431 #define IMAGE_SYM_TYPE_UINT 0x000E
3432 #define IMAGE_SYM_TYPE_DWORD 0x000F
3433 #define IMAGE_SYM_TYPE_PCODE 0x8000
3435 #define IMAGE_SYM_DTYPE_NULL 0
3436 #define IMAGE_SYM_DTYPE_POINTER 1
3437 #define IMAGE_SYM_DTYPE_FUNCTION 2
3438 #define IMAGE_SYM_DTYPE_ARRAY 3
3440 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3441 #define IMAGE_SYM_CLASS_NULL 0x0000
3442 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3443 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3444 #define IMAGE_SYM_CLASS_STATIC 0x0003
3445 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3446 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3447 #define IMAGE_SYM_CLASS_LABEL 0x0006
3448 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3449 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3450 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3451 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3452 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3453 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3454 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3455 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3456 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3457 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3458 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3459 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3461 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3462 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3463 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3464 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3465 #define IMAGE_SYM_CLASS_FILE 0x0067
3466 #define IMAGE_SYM_CLASS_SECTION 0x0068
3467 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3469 #define N_BTMASK 0x000F
3470 #define N_TMASK 0x0030
3471 #define N_TMASK1 0x00C0
3472 #define N_TMASK2 0x00F0
3476 #define BTYPE(x) ((x) & N_BTMASK)
3479 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3483 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3487 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3491 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3495 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3498 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3501 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3502 #define IMAGE_COMDAT_SELECT_ANY 2
3503 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3504 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3505 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3506 #define IMAGE_COMDAT_SELECT_LARGEST 6
3507 #define IMAGE_COMDAT_SELECT_NEWEST 7
3509 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3510 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3511 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3513 /* Export module directory */
3515 typedef struct _IMAGE_EXPORT_DIRECTORY
{
3516 DWORD Characteristics
;
3517 DWORD TimeDateStamp
;
3522 DWORD NumberOfFunctions
;
3523 DWORD NumberOfNames
;
3524 DWORD AddressOfFunctions
;
3525 DWORD AddressOfNames
;
3526 DWORD AddressOfNameOrdinals
;
3527 } IMAGE_EXPORT_DIRECTORY
,*PIMAGE_EXPORT_DIRECTORY
;
3529 /* Import name entry */
3530 typedef struct _IMAGE_IMPORT_BY_NAME
{
3533 } IMAGE_IMPORT_BY_NAME
,*PIMAGE_IMPORT_BY_NAME
;
3535 #include <pshpack8.h>
3537 typedef struct _IMAGE_THUNK_DATA64
{
3539 ULONGLONG ForwarderString
;
3542 ULONGLONG AddressOfData
;
3544 } IMAGE_THUNK_DATA64
,*PIMAGE_THUNK_DATA64
;
3545 #include <poppack.h>
3547 typedef struct _IMAGE_THUNK_DATA32
{
3549 DWORD ForwarderString
;
3552 DWORD AddressOfData
;
3554 } IMAGE_THUNK_DATA32
,*PIMAGE_THUNK_DATA32
;
3556 /* Import module directory */
3558 typedef struct _IMAGE_IMPORT_DESCRIPTOR
{
3560 DWORD Characteristics
; /* 0 for terminating null import descriptor */
3561 DWORD OriginalFirstThunk
; /* RVA to original unbound IAT */
3563 DWORD TimeDateStamp
; /* 0 if not bound,
3564 * -1 if bound, and real date\time stamp
3565 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3567 * otherwise date/time stamp of DLL bound to
3570 DWORD ForwarderChain
; /* -1 if no forwarders */
3572 /* RVA to IAT (if bound this IAT has actual addresses) */
3574 } IMAGE_IMPORT_DESCRIPTOR
,*PIMAGE_IMPORT_DESCRIPTOR
;
3576 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3577 #define IMAGE_ORDINAL_FLAG32 0x80000000
3578 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3579 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3580 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3581 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3584 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3585 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3586 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3587 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA
;
3588 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA
;
3590 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3591 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3592 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3593 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA
;
3594 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
;
3597 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3599 DWORD TimeDateStamp
;
3600 WORD OffsetModuleName
;
3601 WORD NumberOfModuleForwarderRefs
;
3602 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3603 } IMAGE_BOUND_IMPORT_DESCRIPTOR
, *PIMAGE_BOUND_IMPORT_DESCRIPTOR
;
3605 typedef struct _IMAGE_BOUND_FORWARDER_REF
3607 DWORD TimeDateStamp
;
3608 WORD OffsetModuleName
;
3610 } IMAGE_BOUND_FORWARDER_REF
, *PIMAGE_BOUND_FORWARDER_REF
;
3612 typedef struct _IMAGE_BASE_RELOCATION
3614 DWORD VirtualAddress
;
3616 /* WORD TypeOffset[1]; */
3617 } IMAGE_BASE_RELOCATION
,*PIMAGE_BASE_RELOCATION
;
3619 #include <pshpack2.h>
3621 typedef struct _IMAGE_RELOCATION
3624 DWORD VirtualAddress
;
3627 DWORD SymbolTableIndex
;
3629 } IMAGE_RELOCATION
, *PIMAGE_RELOCATION
;
3631 #include <poppack.h>
3633 #define IMAGE_SIZEOF_RELOCATION 10
3635 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3639 DWORD AllAttributes
;
3643 DWORD ReservedAttributes
:31;
3648 DWORD ModuleHandleRVA
;
3649 DWORD ImportAddressTableRVA
;
3650 DWORD ImportNameTableRVA
;
3651 DWORD BoundImportAddressTableRVA
;
3652 DWORD UnloadInformationTableRVA
;
3653 DWORD TimeDateStamp
;
3654 } IMAGE_DELAYLOAD_DESCRIPTOR
, *PIMAGE_DELAYLOAD_DESCRIPTOR
;
3655 typedef const IMAGE_DELAYLOAD_DESCRIPTOR
*PCIMAGE_DELAYLOAD_DESCRIPTOR
;
3657 /* generic relocation types */
3658 #define IMAGE_REL_BASED_ABSOLUTE 0
3659 #define IMAGE_REL_BASED_HIGH 1
3660 #define IMAGE_REL_BASED_LOW 2
3661 #define IMAGE_REL_BASED_HIGHLOW 3
3662 #define IMAGE_REL_BASED_HIGHADJ 4
3663 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3664 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3665 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3666 #define IMAGE_REL_BASED_SECTION 6
3667 #define IMAGE_REL_BASED_REL 7
3668 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3669 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3670 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3671 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3672 #define IMAGE_REL_BASED_DIR64 10
3673 #define IMAGE_REL_BASED_HIGH3ADJ 11
3675 /* I386 relocation types */
3676 #define IMAGE_REL_I386_ABSOLUTE 0
3677 #define IMAGE_REL_I386_DIR16 1
3678 #define IMAGE_REL_I386_REL16 2
3679 #define IMAGE_REL_I386_DIR32 6
3680 #define IMAGE_REL_I386_DIR32NB 7
3681 #define IMAGE_REL_I386_SEG12 9
3682 #define IMAGE_REL_I386_SECTION 10
3683 #define IMAGE_REL_I386_SECREL 11
3684 #define IMAGE_REL_I386_TOKEN 12
3685 #define IMAGE_REL_I386_SECREL7 13
3686 #define IMAGE_REL_I386_REL32 20
3688 /* MIPS relocation types */
3689 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3690 #define IMAGE_REL_MIPS_REFHALF 0x0001
3691 #define IMAGE_REL_MIPS_REFWORD 0x0002
3692 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3693 #define IMAGE_REL_MIPS_REFHI 0x0004
3694 #define IMAGE_REL_MIPS_REFLO 0x0005
3695 #define IMAGE_REL_MIPS_GPREL 0x0006
3696 #define IMAGE_REL_MIPS_LITERAL 0x0007
3697 #define IMAGE_REL_MIPS_SECTION 0x000A
3698 #define IMAGE_REL_MIPS_SECREL 0x000B
3699 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3700 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3701 #define IMAGE_REL_MIPS_TOKEN 0x000E
3702 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3703 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3704 #define IMAGE_REL_MIPS_PAIR 0x0025
3706 /* ALPHA relocation types */
3707 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3708 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3709 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3710 #define IMAGE_REL_ALPHA_GPREL 0x0003
3711 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3712 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3713 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3714 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3715 #define IMAGE_REL_ALPHA_HINT 0x0008
3716 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3717 #define IMAGE_REL_ALPHA_REFHI 0x000A
3718 #define IMAGE_REL_ALPHA_REFLO 0x000B
3719 #define IMAGE_REL_ALPHA_PAIR 0x000C
3720 #define IMAGE_REL_ALPHA_MATCH 0x000D
3721 #define IMAGE_REL_ALPHA_SECTION 0x000E
3722 #define IMAGE_REL_ALPHA_SECREL 0x000F
3723 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3724 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3725 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3726 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3727 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3728 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3729 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3730 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3732 /* PowerPC relocation types */
3733 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3734 #define IMAGE_REL_PPC_ADDR64 0x0001
3735 #define IMAGE_REL_PPC_ADDR 0x0002
3736 #define IMAGE_REL_PPC_ADDR24 0x0003
3737 #define IMAGE_REL_PPC_ADDR16 0x0004
3738 #define IMAGE_REL_PPC_ADDR14 0x0005
3739 #define IMAGE_REL_PPC_REL24 0x0006
3740 #define IMAGE_REL_PPC_REL14 0x0007
3741 #define IMAGE_REL_PPC_TOCREL16 0x0008
3742 #define IMAGE_REL_PPC_TOCREL14 0x0009
3743 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3744 #define IMAGE_REL_PPC_SECREL 0x000B
3745 #define IMAGE_REL_PPC_SECTION 0x000C
3746 #define IMAGE_REL_PPC_IFGLUE 0x000D
3747 #define IMAGE_REL_PPC_IMGLUE 0x000E
3748 #define IMAGE_REL_PPC_SECREL16 0x000F
3749 #define IMAGE_REL_PPC_REFHI 0x0010
3750 #define IMAGE_REL_PPC_REFLO 0x0011
3751 #define IMAGE_REL_PPC_PAIR 0x0012
3752 #define IMAGE_REL_PPC_SECRELLO 0x0013
3753 #define IMAGE_REL_PPC_SECRELHI 0x0014
3754 #define IMAGE_REL_PPC_GPREL 0x0015
3755 #define IMAGE_REL_PPC_TOKEN 0x0016
3756 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3758 #define IMAGE_REL_PPC_NEG 0x0100
3759 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3760 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3761 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3763 /* SH3 relocation types */
3764 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3765 #define IMAGE_REL_SH3_DIRECT16 0x0001
3766 #define IMAGE_REL_SH3_DIRECT 0x0002
3767 #define IMAGE_REL_SH3_DIRECT8 0x0003
3768 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3769 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3770 #define IMAGE_REL_SH3_DIRECT4 0x0006
3771 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3772 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3773 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3774 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3775 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3776 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3777 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3778 #define IMAGE_REL_SH3_SECTION 0x000E
3779 #define IMAGE_REL_SH3_SECREL 0x000F
3780 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3781 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3782 #define IMAGE_REL_SH3_TOKEN 0x0012
3784 /* ARM relocation types */
3785 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3786 #define IMAGE_REL_ARM_ADDR 0x0001
3787 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3788 #define IMAGE_REL_ARM_BRANCH24 0x0003
3789 #define IMAGE_REL_ARM_BRANCH11 0x0004
3790 #define IMAGE_REL_ARM_TOKEN 0x0005
3791 #define IMAGE_REL_ARM_GPREL12 0x0006
3792 #define IMAGE_REL_ARM_GPREL7 0x0007
3793 #define IMAGE_REL_ARM_BLX24 0x0008
3794 #define IMAGE_REL_ARM_BLX11 0x0009
3795 #define IMAGE_REL_ARM_SECTION 0x000E
3796 #define IMAGE_REL_ARM_SECREL 0x000F
3797 #define IMAGE_REL_ARM_MOV32A 0x0010
3798 #define IMAGE_REL_ARM_MOV32T 0x0011
3799 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3800 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3801 #define IMAGE_REL_ARM_BLX23T 0x0015
3803 /* ARM64 relocation types */
3804 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3805 #define IMAGE_REL_ARM64_ADDR32 0x0001
3806 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3807 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3808 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3809 #define IMAGE_REL_ARM64_REL21 0x0005
3810 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3811 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3812 #define IMAGE_REL_ARM64_SECREL 0x0008
3813 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3814 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3815 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3816 #define IMAGE_REL_ARM64_TOKEN 0x000C
3817 #define IMAGE_REL_ARM64_SECTION 0x000D
3818 #define IMAGE_REL_ARM64_ADDR64 0x000E
3819 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3821 /* IA64 relocation types */
3822 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3823 #define IMAGE_REL_IA64_IMM14 0x0001
3824 #define IMAGE_REL_IA64_IMM22 0x0002
3825 #define IMAGE_REL_IA64_IMM64 0x0003
3826 #define IMAGE_REL_IA64_DIR 0x0004
3827 #define IMAGE_REL_IA64_DIR64 0x0005
3828 #define IMAGE_REL_IA64_PCREL21B 0x0006
3829 #define IMAGE_REL_IA64_PCREL21M 0x0007
3830 #define IMAGE_REL_IA64_PCREL21F 0x0008
3831 #define IMAGE_REL_IA64_GPREL22 0x0009
3832 #define IMAGE_REL_IA64_LTOFF22 0x000A
3833 #define IMAGE_REL_IA64_SECTION 0x000B
3834 #define IMAGE_REL_IA64_SECREL22 0x000C
3835 #define IMAGE_REL_IA64_SECREL64I 0x000D
3836 #define IMAGE_REL_IA64_SECREL 0x000E
3837 #define IMAGE_REL_IA64_LTOFF64 0x000F
3838 #define IMAGE_REL_IA64_DIR32NB 0x0010
3839 #define IMAGE_REL_IA64_SREL14 0x0011
3840 #define IMAGE_REL_IA64_SREL22 0x0012
3841 #define IMAGE_REL_IA64_SREL32 0x0013
3842 #define IMAGE_REL_IA64_UREL32 0x0014
3843 #define IMAGE_REL_IA64_PCREL60X 0x0015
3844 #define IMAGE_REL_IA64_PCREL60B 0x0016
3845 #define IMAGE_REL_IA64_PCREL60F 0x0017
3846 #define IMAGE_REL_IA64_PCREL60I 0x0018
3847 #define IMAGE_REL_IA64_PCREL60M 0x0019
3848 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3849 #define IMAGE_REL_IA64_TOKEN 0x001B
3850 #define IMAGE_REL_IA64_GPREL32 0x001C
3851 #define IMAGE_REL_IA64_ADDEND 0x001F
3853 /* AMD64 relocation types */
3854 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3855 #define IMAGE_REL_AMD64_ADDR64 0x0001
3856 #define IMAGE_REL_AMD64_ADDR32 0x0002
3857 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3858 #define IMAGE_REL_AMD64_REL32 0x0004
3859 #define IMAGE_REL_AMD64_REL32_1 0x0005
3860 #define IMAGE_REL_AMD64_REL32_2 0x0006
3861 #define IMAGE_REL_AMD64_REL32_3 0x0007
3862 #define IMAGE_REL_AMD64_REL32_4 0x0008
3863 #define IMAGE_REL_AMD64_REL32_5 0x0009
3864 #define IMAGE_REL_AMD64_SECTION 0x000A
3865 #define IMAGE_REL_AMD64_SECREL 0x000B
3866 #define IMAGE_REL_AMD64_SECREL7 0x000C
3867 #define IMAGE_REL_AMD64_TOKEN 0x000D
3868 #define IMAGE_REL_AMD64_SREL32 0x000E
3869 #define IMAGE_REL_AMD64_PAIR 0x000F
3870 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3872 /* archive format */
3874 #define IMAGE_ARCHIVE_START_SIZE 8
3875 #define IMAGE_ARCHIVE_START "!<arch>\n"
3876 #define IMAGE_ARCHIVE_END "`\n"
3877 #define IMAGE_ARCHIVE_PAD "\n"
3878 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3879 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3881 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3890 } IMAGE_ARCHIVE_MEMBER_HEADER
, *PIMAGE_ARCHIVE_MEMBER_HEADER
;
3892 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3894 typedef struct _IMPORT_OBJECT_HEADER
3900 DWORD TimeDateStamp
;
3910 } IMPORT_OBJECT_HEADER
;
3912 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3914 typedef enum IMPORT_OBJECT_TYPE
3916 IMPORT_OBJECT_CODE
= 0,
3917 IMPORT_OBJECT_DATA
= 1,
3918 IMPORT_OBJECT_CONST
= 2
3919 } IMPORT_OBJECT_TYPE
;
3921 typedef enum IMPORT_OBJECT_NAME_TYPE
3923 IMPORT_OBJECT_ORDINAL
= 0,
3924 IMPORT_OBJECT_NAME
= 1,
3925 IMPORT_OBJECT_NAME_NO_PREFIX
= 2,
3926 IMPORT_OBJECT_NAME_UNDECORATE
= 3
3927 } IMPORT_OBJECT_NAME_TYPE
;
3929 typedef struct _ANON_OBJECT_HEADER
3935 DWORD TimeDateStamp
;
3938 } ANON_OBJECT_HEADER
;
3941 * Resource directory stuff
3943 typedef struct _IMAGE_RESOURCE_DIRECTORY
{
3944 DWORD Characteristics
;
3945 DWORD TimeDateStamp
;
3948 WORD NumberOfNamedEntries
;
3949 WORD NumberOfIdEntries
;
3950 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3951 } IMAGE_RESOURCE_DIRECTORY
,*PIMAGE_RESOURCE_DIRECTORY
;
3953 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3954 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3956 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
{
3959 unsigned NameOffset
:31;
3960 unsigned NameIsString
:1;
3968 unsigned OffsetToDirectory
:31;
3969 unsigned DataIsDirectory
:1;
3972 } IMAGE_RESOURCE_DIRECTORY_ENTRY
,*PIMAGE_RESOURCE_DIRECTORY_ENTRY
;
3975 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
{
3977 CHAR NameString
[ 1 ];
3978 } IMAGE_RESOURCE_DIRECTORY_STRING
,*PIMAGE_RESOURCE_DIRECTORY_STRING
;
3980 typedef struct _IMAGE_RESOURCE_DIR_STRING_U
{
3982 WCHAR NameString
[ 1 ];
3983 } IMAGE_RESOURCE_DIR_STRING_U
,*PIMAGE_RESOURCE_DIR_STRING_U
;
3985 typedef struct _IMAGE_RESOURCE_DATA_ENTRY
{
3990 } IMAGE_RESOURCE_DATA_ENTRY
,*PIMAGE_RESOURCE_DATA_ENTRY
;
3993 typedef VOID (CALLBACK
*PIMAGE_TLS_CALLBACK
)(
3994 LPVOID DllHandle
,DWORD Reason
,LPVOID Reserved
3997 typedef struct _IMAGE_TLS_DIRECTORY64
{
3998 ULONGLONG StartAddressOfRawData
;
3999 ULONGLONG EndAddressOfRawData
;
4000 ULONGLONG AddressOfIndex
;
4001 ULONGLONG AddressOfCallBacks
;
4002 DWORD SizeOfZeroFill
;
4003 DWORD Characteristics
;
4004 } IMAGE_TLS_DIRECTORY64
, *PIMAGE_TLS_DIRECTORY64
;
4006 typedef struct _IMAGE_TLS_DIRECTORY32
{
4007 DWORD StartAddressOfRawData
;
4008 DWORD EndAddressOfRawData
;
4009 DWORD AddressOfIndex
;
4010 DWORD AddressOfCallBacks
;
4011 DWORD SizeOfZeroFill
;
4012 DWORD Characteristics
;
4013 } IMAGE_TLS_DIRECTORY32
, *PIMAGE_TLS_DIRECTORY32
;
4016 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY
;
4017 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY
;
4019 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY
;
4020 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY
;
4023 typedef struct _IMAGE_DEBUG_DIRECTORY
{
4024 DWORD Characteristics
;
4025 DWORD TimeDateStamp
;
4030 DWORD AddressOfRawData
;
4031 DWORD PointerToRawData
;
4032 } IMAGE_DEBUG_DIRECTORY
, *PIMAGE_DEBUG_DIRECTORY
;
4034 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
4035 #define IMAGE_DEBUG_TYPE_COFF 1
4036 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
4037 #define IMAGE_DEBUG_TYPE_FPO 3
4038 #define IMAGE_DEBUG_TYPE_MISC 4
4039 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
4040 #define IMAGE_DEBUG_TYPE_FIXUP 6
4041 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
4042 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
4043 #define IMAGE_DEBUG_TYPE_BORLAND 9
4044 #define IMAGE_DEBUG_TYPE_RESERVED10 10
4045 #define IMAGE_DEBUG_TYPE_CLSID 11
4046 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
4047 #define IMAGE_DEBUG_TYPE_POGO 13
4048 #define IMAGE_DEBUG_TYPE_ILTCG 14
4049 #define IMAGE_DEBUG_TYPE_MPX 15
4050 #define IMAGE_DEBUG_TYPE_REPRO 16
4052 typedef enum ReplacesCorHdrNumericDefines
4054 COMIMAGE_FLAGS_ILONLY
= 0x00000001,
4055 COMIMAGE_FLAGS_32BITREQUIRED
= 0x00000002,
4056 COMIMAGE_FLAGS_IL_LIBRARY
= 0x00000004,
4057 COMIMAGE_FLAGS_STRONGNAMESIGNED
= 0x00000008,
4058 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT
= 0x00000010,
4059 COMIMAGE_FLAGS_TRACKDEBUGDATA
= 0x00010000,
4060 COMIMAGE_FLAGS_32BITPREFERRED
= 0x00020000,
4062 COR_VERSION_MAJOR_V2
= 2,
4063 COR_VERSION_MAJOR
= COR_VERSION_MAJOR_V2
,
4064 COR_VERSION_MINOR
= 5,
4065 COR_DELETED_NAME_LENGTH
= 8,
4066 COR_VTABLEGAP_NAME_LENGTH
= 8,
4068 NATIVE_TYPE_MAX_CB
= 1,
4069 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE
= 0xff,
4071 IMAGE_COR_MIH_METHODRVA
= 0x01,
4072 IMAGE_COR_MIH_EHRVA
= 0x02,
4073 IMAGE_COR_MIH_BASICBLOCK
= 0x08,
4075 COR_VTABLE_32BIT
= 0x01,
4076 COR_VTABLE_64BIT
= 0x02,
4077 COR_VTABLE_FROM_UNMANAGED
= 0x04,
4078 COR_VTABLE_CALL_MOST_DERIVED
= 0x10,
4080 IMAGE_COR_EATJ_THUNK_SIZE
= 32,
4082 MAX_CLASS_NAME
= 1024,
4083 MAX_PACKAGE_NAME
= 1024,
4084 } ReplacesCorHdrNumericDefines
;
4086 typedef struct IMAGE_COR20_HEADER
4089 WORD MajorRuntimeVersion
;
4090 WORD MinorRuntimeVersion
;
4092 IMAGE_DATA_DIRECTORY MetaData
;
4095 DWORD EntryPointToken
;
4096 DWORD EntryPointRVA
;
4099 IMAGE_DATA_DIRECTORY Resources
;
4100 IMAGE_DATA_DIRECTORY StrongNameSignature
;
4101 IMAGE_DATA_DIRECTORY CodeManagerTable
;
4102 IMAGE_DATA_DIRECTORY VTableFixups
;
4103 IMAGE_DATA_DIRECTORY ExportAddressTableJumps
;
4104 IMAGE_DATA_DIRECTORY ManagedNativeHeader
;
4106 } IMAGE_COR20_HEADER
, *PIMAGE_COR20_HEADER
;
4108 typedef struct _IMAGE_COFF_SYMBOLS_HEADER
{
4109 DWORD NumberOfSymbols
;
4110 DWORD LvaToFirstSymbol
;
4111 DWORD NumberOfLinenumbers
;
4112 DWORD LvaToFirstLinenumber
;
4113 DWORD RvaToFirstByteOfCode
;
4114 DWORD RvaToLastByteOfCode
;
4115 DWORD RvaToFirstByteOfData
;
4116 DWORD RvaToLastByteOfData
;
4117 } IMAGE_COFF_SYMBOLS_HEADER
, *PIMAGE_COFF_SYMBOLS_HEADER
;
4120 #define FRAME_TRAP 1
4122 #define FRAME_NONFPO 3
4124 typedef struct _FPO_DATA
{
4135 } FPO_DATA
, *PFPO_DATA
;
4137 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
{
4139 DWORD TimeDateStamp
;
4142 DWORD GlobalFlagsClear
;
4143 DWORD GlobalFlagsSet
;
4144 DWORD CriticalSectionDefaultTimeout
;
4145 ULONGLONG DeCommitFreeBlockThreshold
;
4146 ULONGLONG DeCommitTotalFreeThreshold
;
4147 ULONGLONG LockPrefixTable
;
4148 ULONGLONG MaximumAllocationSize
;
4149 ULONGLONG VirtualMemoryThreshold
;
4150 ULONGLONG ProcessAffinityMask
;
4151 DWORD ProcessHeapFlags
;
4155 ULONGLONG SecurityCookie
;
4156 ULONGLONG SEHandlerTable
;
4157 ULONGLONG SEHandlerCount
;
4158 } IMAGE_LOAD_CONFIG_DIRECTORY64
, *PIMAGE_LOAD_CONFIG_DIRECTORY64
;
4160 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
{
4162 DWORD TimeDateStamp
;
4165 DWORD GlobalFlagsClear
;
4166 DWORD GlobalFlagsSet
;
4167 DWORD CriticalSectionDefaultTimeout
;
4168 DWORD DeCommitFreeBlockThreshold
;
4169 DWORD DeCommitTotalFreeThreshold
;
4170 PVOID LockPrefixTable
;
4171 DWORD MaximumAllocationSize
;
4172 DWORD VirtualMemoryThreshold
;
4173 DWORD ProcessHeapFlags
;
4174 DWORD ProcessAffinityMask
;
4178 DWORD SecurityCookie
;
4179 DWORD SEHandlerTable
;
4180 DWORD SEHandlerCount
;
4181 } IMAGE_LOAD_CONFIG_DIRECTORY32
, *PIMAGE_LOAD_CONFIG_DIRECTORY32
;
4184 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY
;
4185 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY
;
4187 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY
;
4188 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY
;
4191 typedef struct _IMAGE_FUNCTION_ENTRY
{
4192 DWORD StartingAddress
;
4193 DWORD EndingAddress
;
4194 DWORD EndOfPrologue
;
4195 } IMAGE_FUNCTION_ENTRY
, *PIMAGE_FUNCTION_ENTRY
;
4197 #define IMAGE_DEBUG_MISC_EXENAME 1
4199 typedef struct _IMAGE_DEBUG_MISC
{
4205 } IMAGE_DEBUG_MISC
, *PIMAGE_DEBUG_MISC
;
4207 /* This is the structure that appears at the very start of a .DBG file. */
4209 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
{
4213 WORD Characteristics
;
4214 DWORD TimeDateStamp
;
4218 DWORD NumberOfSections
;
4219 DWORD ExportedNamesSize
;
4220 DWORD DebugDirectorySize
;
4221 DWORD SectionAlignment
;
4222 DWORD Reserved
[ 2 ];
4223 } IMAGE_SEPARATE_DEBUG_HEADER
,*PIMAGE_SEPARATE_DEBUG_HEADER
;
4225 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
4228 typedef struct tagMESSAGE_RESOURCE_ENTRY
{
4232 } MESSAGE_RESOURCE_ENTRY
,*PMESSAGE_RESOURCE_ENTRY
;
4233 #define MESSAGE_RESOURCE_UNICODE 0x0001
4235 typedef struct tagMESSAGE_RESOURCE_BLOCK
{
4238 DWORD OffsetToEntries
;
4239 } MESSAGE_RESOURCE_BLOCK
,*PMESSAGE_RESOURCE_BLOCK
;
4241 typedef struct tagMESSAGE_RESOURCE_DATA
{
4242 DWORD NumberOfBlocks
;
4243 MESSAGE_RESOURCE_BLOCK Blocks
[ 1 ];
4244 } MESSAGE_RESOURCE_DATA
,*PMESSAGE_RESOURCE_DATA
;
4247 * Here follows typedefs for security and tokens.
4251 * First a constant for the following typedefs.
4254 #define ANYSIZE_ARRAY 1
4256 /* FIXME: Orphan. What does it point to? */
4257 typedef PVOID PACCESS_TOKEN
;
4258 typedef PVOID PSECURITY_DESCRIPTOR
;
4261 typedef enum _TOKEN_ELEVATION_TYPE
{
4262 TokenElevationTypeDefault
= 1,
4263 TokenElevationTypeFull
,
4264 TokenElevationTypeLimited
4265 } TOKEN_ELEVATION_TYPE
, *PTOKEN_ELEVATION_TYPE
;
4268 * TOKEN_INFORMATION_CLASS
4271 typedef enum _TOKEN_INFORMATION_CLASS
{
4280 TokenImpersonationLevel
,
4282 TokenRestrictedSids
,
4284 TokenGroupsAndPrivileges
,
4285 TokenSessionReference
,
4292 TokenHasRestrictions
,
4293 TokenAccessInformation
,
4294 TokenVirtualizationAllowed
,
4295 TokenVirtualizationEnabled
,
4296 TokenIntegrityLevel
,
4298 TokenMandatoryPolicy
,
4300 TokenIsAppContainer
,
4302 TokenAppContainerSid
,
4303 TokenAppContainerNumber
,
4304 TokenUserClaimAttributes
,
4305 TokenDeviceClaimAttributes
,
4306 TokenRestrictedUserClaimAttributes
,
4307 TokenRestrictedDeviceClaimAttributes
,
4309 TokenRestrictedDeviceGroups
,
4310 TokenSecurityAttributes
,
4312 TokenProcessTrustLevel
,
4314 } TOKEN_INFORMATION_CLASS
;
4316 #define DISABLE_MAX_PRIVILEGE 0x1
4317 #define SANDBOX_INERT 0x2
4318 #define LUA_TOKEN 0x4
4319 #define WRITE_RESTRICTED 0x8
4321 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
4322 #define TOKEN_ADJUST_GROUPS 0x0040
4323 #define TOKEN_ADJUST_PRIVILEGES 0x0020
4324 #define TOKEN_ADJUST_SESSIONID 0x0100
4325 #define TOKEN_ASSIGN_PRIMARY 0x0001
4326 #define TOKEN_DUPLICATE 0x0002
4327 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
4328 #define TOKEN_IMPERSONATE 0x0004
4329 #define TOKEN_QUERY 0x0008
4330 #define TOKEN_QUERY_SOURCE 0x0010
4331 #define TOKEN_ADJUST_DEFAULT 0x0080
4332 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
4333 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
4334 TOKEN_ADJUST_PRIVILEGES | \
4335 TOKEN_ADJUST_GROUPS | \
4336 TOKEN_ADJUST_DEFAULT )
4337 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
4338 TOKEN_ASSIGN_PRIMARY | \
4340 TOKEN_IMPERSONATE | \
4342 TOKEN_QUERY_SOURCE | \
4343 TOKEN_ADJUST_PRIVILEGES | \
4344 TOKEN_ADJUST_GROUPS | \
4345 TOKEN_ADJUST_SESSIONID | \
4346 TOKEN_ADJUST_DEFAULT )
4348 #ifndef _SECURITY_DEFINED
4349 #define _SECURITY_DEFINED
4351 typedef DWORD ACCESS_MASK
, *PACCESS_MASK
;
4353 typedef struct _GENERIC_MAPPING
{
4354 ACCESS_MASK GenericRead
;
4355 ACCESS_MASK GenericWrite
;
4356 ACCESS_MASK GenericExecute
;
4357 ACCESS_MASK GenericAll
;
4358 } GENERIC_MAPPING
, *PGENERIC_MAPPING
;
4360 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
4361 #define SID_IDENTIFIER_AUTHORITY_DEFINED
4364 } SID_IDENTIFIER_AUTHORITY
, *PSID_IDENTIFIER_AUTHORITY
;
4365 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
4369 typedef struct _SID
{
4371 BYTE SubAuthorityCount
;
4372 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
4373 DWORD SubAuthority
[1];
4375 #endif /* !defined(SID_DEFINED) */
4377 #define SID_REVISION (1) /* Current revision */
4378 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
4379 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
4381 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
4387 #define ACL_REVISION1 1
4388 #define ACL_REVISION2 2
4389 #define ACL_REVISION3 3
4390 #define ACL_REVISION4 4
4392 #define MIN_ACL_REVISION ACL_REVISION2
4393 #define MAX_ACL_REVISION ACL_REVISION4
4395 #define ACL_REVISION 2
4397 typedef struct _ACL
{
4405 typedef enum _ACL_INFORMATION_CLASS
4407 AclRevisionInformation
= 1,
4409 } ACL_INFORMATION_CLASS
;
4411 typedef struct _ACL_REVISION_INFORMATION
4414 } ACL_REVISION_INFORMATION
, *PACL_REVISION_INFORMATION
;
4416 typedef struct _ACL_SIZE_INFORMATION
4419 DWORD AclBytesInUse
;
4421 } ACL_SIZE_INFORMATION
, *PACL_SIZE_INFORMATION
;
4423 /* SECURITY_DESCRIPTOR */
4424 #define SECURITY_DESCRIPTOR_REVISION 1
4425 #define SECURITY_DESCRIPTOR_REVISION1 1
4432 #if defined(_MSC_VER) || defined(__MINGW32__)
4433 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4434 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4435 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4436 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4437 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4438 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4439 #define SE_TCB_NAME L"SeTcbPrivilege"
4440 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4441 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4442 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4443 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4444 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4445 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4446 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4447 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4448 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4449 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4450 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4451 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4452 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4453 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4454 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4455 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4456 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4457 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4458 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4459 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4460 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4461 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4462 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4463 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4464 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4465 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4466 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4467 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4468 #else /* _MSC_VER/__MINGW32__ */
4469 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 };
4470 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 };
4471 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 };
4472 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 };
4473 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 };
4474 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 };
4475 static const WCHAR SE_TCB_NAME
[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4476 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 };
4477 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 };
4478 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 };
4479 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 };
4480 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 };
4481 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 };
4482 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 };
4483 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 };
4484 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 };
4485 static const WCHAR SE_BACKUP_NAME
[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4486 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 };
4487 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 };
4488 static const WCHAR SE_DEBUG_NAME
[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4489 static const WCHAR SE_AUDIT_NAME
[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4490 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 };
4491 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 };
4492 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 };
4493 static const WCHAR SE_UNDOCK_NAME
[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4494 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 };
4495 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 };
4496 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 };
4497 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 };
4498 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 };
4499 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 };
4500 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 };
4501 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 };
4502 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 };
4503 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 };
4506 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4507 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4508 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4509 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4510 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4511 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4512 #define SE_TCB_NAME "SeTcbPrivilege"
4513 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4514 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4515 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4516 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4517 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4518 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4519 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4520 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4521 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4522 #define SE_BACKUP_NAME "SeBackupPrivilege"
4523 #define SE_RESTORE_NAME "SeRestorePrivilege"
4524 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4525 #define SE_DEBUG_NAME "SeDebugPrivilege"
4526 #define SE_AUDIT_NAME "SeAuditPrivilege"
4527 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4528 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4529 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4530 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4531 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4532 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4533 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4534 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4535 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4536 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4537 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4538 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4539 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4540 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4543 #define SE_GROUP_MANDATORY 0x00000001
4544 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4545 #define SE_GROUP_ENABLED 0x00000004
4546 #define SE_GROUP_OWNER 0x00000008
4547 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4548 #define SE_GROUP_INTEGRITY 0x00000020
4549 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4550 #define SE_GROUP_LOGON_ID 0xC0000000
4551 #define SE_GROUP_RESOURCE 0x20000000
4552 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4554 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4555 #define SE_PRIVILEGE_ENABLED 0x00000002
4556 #define SE_PRIVILEGE_REMOVED 0x00000004
4557 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4558 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4560 #define PRIVILEGE_SET_ALL_NECESSARY 1
4562 #define SE_OWNER_DEFAULTED 0x00000001
4563 #define SE_GROUP_DEFAULTED 0x00000002
4564 #define SE_DACL_PRESENT 0x00000004
4565 #define SE_DACL_DEFAULTED 0x00000008
4566 #define SE_SACL_PRESENT 0x00000010
4567 #define SE_SACL_DEFAULTED 0x00000020
4568 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4569 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4570 #define SE_DACL_AUTO_INHERITED 0x00000400
4571 #define SE_SACL_AUTO_INHERITED 0x00000800
4572 #define SE_DACL_PROTECTED 0x00001000
4573 #define SE_SACL_PROTECTED 0x00002000
4574 #define SE_RM_CONTROL_VALID 0x00004000
4575 #define SE_SELF_RELATIVE 0x00008000
4577 typedef DWORD SECURITY_INFORMATION
, *PSECURITY_INFORMATION
;
4578 typedef WORD SECURITY_DESCRIPTOR_CONTROL
, *PSECURITY_DESCRIPTOR_CONTROL
;
4580 /* The security descriptor structure */
4584 SECURITY_DESCRIPTOR_CONTROL Control
;
4589 } SECURITY_DESCRIPTOR_RELATIVE
, *PISECURITY_DESCRIPTOR_RELATIVE
;
4594 SECURITY_DESCRIPTOR_CONTROL Control
;
4599 } SECURITY_DESCRIPTOR
, *PISECURITY_DESCRIPTOR
;
4601 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4603 #endif /* _SECURITY_DEFINED */
4606 * SID_AND_ATTRIBUTES
4609 typedef struct _SID_AND_ATTRIBUTES
{
4612 } SID_AND_ATTRIBUTES
, *PSID_AND_ATTRIBUTES
;
4614 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY
[ANYSIZE_ARRAY
];
4615 typedef SID_AND_ATTRIBUTES_ARRAY
*PSID_AND_ATTRIBUTES_ARRAY
;
4617 #define SID_HASH_SIZE 32
4619 typedef ULONG_PTR SID_HASH_ENTRY
, *PSID_HASH_ENTRY
;
4621 typedef struct _SID_AND_ATTRIBUTES_HASH
{
4623 PSID_AND_ATTRIBUTES SidAttr
;
4624 SID_HASH_ENTRY Hash
[SID_HASH_SIZE
];
4625 } SID_AND_ATTRIBUTES_HASH
, *PSID_AND_ATTRIBUTES_HASH
;
4627 /* security entities */
4628 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4629 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4630 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4632 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4635 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4638 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4639 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4642 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4643 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4644 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4645 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4646 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4647 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4650 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4653 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4654 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4655 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4656 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4657 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4658 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4659 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4660 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4661 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4662 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4663 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4664 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4665 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4666 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4667 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4668 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4669 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4670 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4671 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4672 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4673 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4674 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4675 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4676 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4678 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4679 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4680 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4681 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4682 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4683 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4684 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4685 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4686 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4687 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4688 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4689 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4690 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4691 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4692 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4693 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4694 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4695 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4696 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4697 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4698 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4699 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4701 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4703 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4704 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4705 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4706 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4707 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4709 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4710 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4711 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4712 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4713 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4714 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4715 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4716 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4717 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4718 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4720 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4722 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4723 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4724 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4725 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4726 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4727 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4728 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4729 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4730 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4731 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4732 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4734 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4735 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4736 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4737 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4738 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4739 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4740 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4741 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4742 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4744 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4746 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4747 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4748 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4749 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4751 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4752 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4753 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4754 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4756 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4757 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4758 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4759 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4760 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4761 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4763 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4764 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4765 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4766 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4767 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4768 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4769 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4770 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4771 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4772 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4773 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4775 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4777 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4778 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4779 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4780 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4781 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4782 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4783 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4784 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4785 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4786 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4787 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4789 #define SYSTEM_LUID { 0x3e7, 0x0 }
4790 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4791 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4792 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4793 #define IUSER_LUID { 0x3e3, 0x0 }
4799 WinCreatorOwnerSid
= 3,
4800 WinCreatorGroupSid
= 4,
4801 WinCreatorOwnerServerSid
= 5,
4802 WinCreatorGroupServerSid
= 6,
4803 WinNtAuthoritySid
= 7,
4807 WinInteractiveSid
= 11,
4809 WinAnonymousSid
= 13,
4811 WinEnterpriseControllersSid
= 15,
4813 WinAuthenticatedUserSid
= 17,
4814 WinRestrictedCodeSid
= 18,
4815 WinTerminalServerSid
= 19,
4816 WinRemoteLogonIdSid
= 20,
4817 WinLogonIdsSid
= 21,
4818 WinLocalSystemSid
= 22,
4819 WinLocalServiceSid
= 23,
4820 WinNetworkServiceSid
= 24,
4821 WinBuiltinDomainSid
= 25,
4822 WinBuiltinAdministratorsSid
= 26,
4823 WinBuiltinUsersSid
= 27,
4824 WinBuiltinGuestsSid
= 28,
4825 WinBuiltinPowerUsersSid
= 29,
4826 WinBuiltinAccountOperatorsSid
= 30,
4827 WinBuiltinSystemOperatorsSid
= 31,
4828 WinBuiltinPrintOperatorsSid
= 32,
4829 WinBuiltinBackupOperatorsSid
= 33,
4830 WinBuiltinReplicatorSid
= 34,
4831 WinBuiltinPreWindows2000CompatibleAccessSid
= 35,
4832 WinBuiltinRemoteDesktopUsersSid
= 36,
4833 WinBuiltinNetworkConfigurationOperatorsSid
= 37,
4834 WinAccountAdministratorSid
= 38,
4835 WinAccountGuestSid
= 39,
4836 WinAccountKrbtgtSid
= 40,
4837 WinAccountDomainAdminsSid
= 41,
4838 WinAccountDomainUsersSid
= 42,
4839 WinAccountDomainGuestsSid
= 43,
4840 WinAccountComputersSid
= 44,
4841 WinAccountControllersSid
= 45,
4842 WinAccountCertAdminsSid
= 46,
4843 WinAccountSchemaAdminsSid
= 47,
4844 WinAccountEnterpriseAdminsSid
= 48,
4845 WinAccountPolicyAdminsSid
= 49,
4846 WinAccountRasAndIasServersSid
= 50,
4847 WinNTLMAuthenticationSid
= 51,
4848 WinDigestAuthenticationSid
= 52,
4849 WinSChannelAuthenticationSid
= 53,
4850 WinThisOrganizationSid
= 54,
4851 WinOtherOrganizationSid
= 55,
4852 WinBuiltinIncomingForestTrustBuildersSid
= 56,
4853 WinBuiltinPerfMonitoringUsersSid
= 57,
4854 WinBuiltinPerfLoggingUsersSid
= 58,
4855 WinBuiltinAuthorizationAccessSid
= 59,
4856 WinBuiltinTerminalServerLicenseServersSid
= 60,
4857 WinBuiltinDCOMUsersSid
= 61,
4858 WinBuiltinIUsersSid
= 62,
4860 WinBuiltinCryptoOperatorsSid
= 64,
4861 WinUntrustedLabelSid
= 65,
4862 WinLowLabelSid
= 66,
4863 WinMediumLabelSid
= 67,
4864 WinHighLabelSid
= 68,
4865 WinSystemLabelSid
= 69,
4866 WinWriteRestrictedCodeSid
= 70,
4867 WinCreatorOwnerRightsSid
= 71,
4868 WinCacheablePrincipalsGroupSid
= 72,
4869 WinNonCacheablePrincipalsGroupSid
= 73,
4870 WinEnterpriseReadonlyControllersSid
= 74,
4871 WinAccountReadonlyControllersSid
= 75,
4872 WinBuiltinEventLogReadersGroup
= 76,
4873 WinNewEnterpriseReadonlyControllersSid
= 77,
4874 WinBuiltinCertSvcDComAccessGroup
= 78,
4875 WinMediumPlusLabelSid
= 79,
4876 WinLocalLogonSid
= 80,
4877 WinConsoleLogonSid
= 81,
4878 WinThisOrganizationCertificateSid
= 82,
4879 WinApplicationPackageAuthoritySid
= 83,
4880 WinBuiltinAnyPackageSid
= 84,
4881 WinCapabilityInternetClientSid
= 85,
4882 WinCapabilityInternetClientServerSid
= 86,
4883 WinCapabilityPrivateNetworkClientServerSid
= 87,
4884 WinCapabilityPicturesLibrarySid
= 88,
4885 WinCapabilityVideosLibrarySid
= 89,
4886 WinCapabilityMusicLibrarySid
= 90,
4887 WinCapabilityDocumentsLibrarySid
= 91,
4888 WinCapabilitySharedUserCertificatesSid
= 92,
4889 WinCapabilityEnterpriseAuthenticationSid
= 93,
4890 WinCapabilityRemovableStorageSid
= 94,
4891 WinBuiltinRDSRemoteAccessServersSid
= 95,
4892 WinBuiltinRDSEndpointServersSid
= 96,
4893 WinBuiltinRDSManagementServersSid
= 97,
4894 WinUserModeDriversSid
= 98,
4895 WinBuiltinHyperVAdminsSid
= 99,
4896 WinAccountCloneableControllersSid
= 100,
4897 WinBuiltinAccessControlAssistanceOperatorsSid
= 101,
4898 WinBuiltinRemoteManagementUsersSid
= 102,
4899 WinAuthenticationAuthorityAssertedSid
= 103,
4900 WinAuthenticationServiceAssertedSid
= 104,
4901 WinLocalAccountSid
= 105,
4902 WinLocalAccountAndAdministratorSid
= 106,
4903 WinAccountProtectedUsersSid
= 107,
4904 } WELL_KNOWN_SID_TYPE
;
4910 typedef struct _TOKEN_USER
{
4911 SID_AND_ATTRIBUTES User
;
4912 } TOKEN_USER
, *PTOKEN_USER
;
4918 typedef struct _TOKEN_GROUPS
{
4920 SID_AND_ATTRIBUTES Groups
[ANYSIZE_ARRAY
];
4921 } TOKEN_GROUPS
, *PTOKEN_GROUPS
;
4924 * LUID_AND_ATTRIBUTES
4927 typedef union _LARGE_INTEGER
{
4929 #ifdef WORDS_BIGENDIAN
4937 #ifndef NONAMELESSSTRUCT
4939 #ifdef WORDS_BIGENDIAN
4949 } LARGE_INTEGER
, *PLARGE_INTEGER
;
4951 typedef union _ULARGE_INTEGER
{
4953 #ifdef WORDS_BIGENDIAN
4961 #ifndef NONAMELESSSTRUCT
4963 #ifdef WORDS_BIGENDIAN
4973 } ULARGE_INTEGER
, *PULARGE_INTEGER
;
4976 * Locally Unique Identifier
4979 typedef struct _LUID
{
4984 #include <pshpack4.h>
4985 typedef struct _LUID_AND_ATTRIBUTES
{
4988 } LUID_AND_ATTRIBUTES
, *PLUID_AND_ATTRIBUTES
;
4989 #include <poppack.h>
4995 typedef struct _PRIVILEGE_SET
{
4996 DWORD PrivilegeCount
;
4998 LUID_AND_ATTRIBUTES Privilege
[ANYSIZE_ARRAY
];
4999 } PRIVILEGE_SET
, *PPRIVILEGE_SET
;
5005 typedef struct _TOKEN_PRIVILEGES
{
5006 DWORD PrivilegeCount
;
5007 LUID_AND_ATTRIBUTES Privileges
[ANYSIZE_ARRAY
];
5008 } TOKEN_PRIVILEGES
, *PTOKEN_PRIVILEGES
;
5014 typedef struct _TOKEN_OWNER
{
5016 } TOKEN_OWNER
, *PTOKEN_OWNER
;
5019 * TOKEN_PRIMARY_GROUP
5022 typedef struct _TOKEN_PRIMARY_GROUP
{
5024 } TOKEN_PRIMARY_GROUP
, *PTOKEN_PRIMARY_GROUP
;
5028 * TOKEN_DEFAULT_DACL
5031 typedef struct _TOKEN_DEFAULT_DACL
{
5033 } TOKEN_DEFAULT_DACL
, *PTOKEN_DEFAULT_DACL
;
5039 #define TOKEN_SOURCE_LENGTH 8
5041 typedef struct _TOKEN_SOURCE
{
5042 char SourceName
[TOKEN_SOURCE_LENGTH
];
5043 LUID SourceIdentifier
;
5044 } TOKEN_SOURCE
, *PTOKEN_SOURCE
;
5050 typedef enum tagTOKEN_TYPE
{
5056 * SECURITY_IMPERSONATION_LEVEL
5059 typedef enum _SECURITY_IMPERSONATION_LEVEL
{
5061 SecurityIdentification
,
5062 SecurityImpersonation
,
5064 } SECURITY_IMPERSONATION_LEVEL
, *PSECURITY_IMPERSONATION_LEVEL
;
5066 #define SECURITY_DYNAMIC_TRACKING (TRUE)
5067 #define SECURITY_STATIC_TRACKING (FALSE)
5069 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE
,
5070 * PSECURITY_CONTEXT_TRACKING_MODE
;
5072 * Quality of Service
5075 typedef struct _SECURITY_QUALITY_OF_SERVICE
{
5077 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5078 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
;
5079 BOOLEAN EffectiveOnly
;
5080 } SECURITY_QUALITY_OF_SERVICE
, *PSECURITY_QUALITY_OF_SERVICE
;
5086 #include <pshpack4.h>
5087 typedef struct _TOKEN_STATISTICS
{
5089 LUID AuthenticationId
;
5090 LARGE_INTEGER ExpirationTime
;
5091 TOKEN_TYPE TokenType
;
5092 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5093 DWORD DynamicCharged
;
5094 DWORD DynamicAvailable
;
5096 DWORD PrivilegeCount
;
5099 #include <poppack.h>
5101 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES
{
5104 PSID_AND_ATTRIBUTES Sids
;
5105 DWORD RestrictedSidCount
;
5106 DWORD RestrictedSidLength
;
5107 PSID_AND_ATTRIBUTES RestrictedSids
;
5108 DWORD PrivilegeCount
;
5109 DWORD PrivilegeLength
;
5110 PLUID_AND_ATTRIBUTES Privileges
;
5111 LUID AuthenticationId
;
5112 } TOKEN_GROUPS_AND_PRIVILEGES
, * PTOKEN_GROUPS_AND_PRIVILEGES
;
5114 typedef struct _TOKEN_ORIGIN
{
5115 LUID OriginatingLogonSession
;
5116 } TOKEN_ORIGIN
, * PTOKEN_ORIGIN
;
5118 typedef struct _TOKEN_LINKED_TOKEN
{
5120 } TOKEN_LINKED_TOKEN
, * PTOKEN_LINKED_TOKEN
;
5122 typedef struct _TOKEN_ELEVATION
{
5123 DWORD TokenIsElevated
;
5124 } TOKEN_ELEVATION
, * PTOKEN_ELEVATION
;
5126 typedef struct _TOKEN_MANDATORY_LABEL
{
5127 SID_AND_ATTRIBUTES Label
;
5128 } TOKEN_MANDATORY_LABEL
, * PTOKEN_MANDATORY_LABEL
;
5130 #define TOKEN_MANDATORY_POLICY_OFF 0x0
5131 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
5132 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
5133 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
5135 typedef struct _TOKEN_MANDATORY_POLICY
{
5137 } TOKEN_MANDATORY_POLICY
, *PTOKEN_MANDATORY_POLICY
;
5139 typedef struct _TOKEN_APPCONTAINER_INFORMATION
{
5140 PSID TokenAppContainer
;
5141 } TOKEN_APPCONTAINER_INFORMATION
, * PTOKEN_APPCONTAINER_INFORMATION
;
5143 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
5145 typedef struct _TOKEN_AUDIT_POLICY
{
5146 BYTE PerUserPolicy
[((POLICY_AUDIT_SUBCATEGORY_COUNT
) >> 1) + 1];
5147 } TOKEN_AUDIT_POLICY
, *PTOKEN_AUDIT_POLICY
;
5149 typedef struct _TOKEN_ACCESS_INFORMATION
{
5150 PSID_AND_ATTRIBUTES_HASH SidHash
;
5151 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash
;
5152 PTOKEN_PRIVILEGES Privileges
;
5153 LUID AuthenticationId
;
5154 TOKEN_TYPE TokenType
;
5155 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5156 TOKEN_MANDATORY_POLICY MandatoryPolicy
;
5158 } TOKEN_ACCESS_INFORMATION
, *PTOKEN_ACCESS_INFORMATION
;
5160 typedef struct _TOKEN_CONTROL
{
5162 LUID AuthenticationId
;
5164 TOKEN_SOURCE TokenSource
;
5165 } TOKEN_CONTROL
, *PTOKEN_CONTROL
;
5171 /* ACEs, directly starting after an ACL */
5172 typedef struct _ACE_HEADER
{
5176 } ACE_HEADER
,*PACE_HEADER
;
5179 #define ACCESS_MIN_MS_ACE_TYPE 0x0
5180 #define ACCESS_ALLOWED_ACE_TYPE 0x0
5181 #define ACCESS_DENIED_ACE_TYPE 0x1
5182 #define SYSTEM_AUDIT_ACE_TYPE 0x2
5183 #define SYSTEM_ALARM_ACE_TYPE 0x3
5184 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
5185 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
5186 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
5187 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
5188 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
5189 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
5190 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
5191 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
5192 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
5193 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
5194 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
5195 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
5196 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
5197 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
5198 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
5199 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
5200 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
5201 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
5202 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
5203 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
5204 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
5205 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
5207 /* inherit AceFlags */
5208 #define OBJECT_INHERIT_ACE 0x01
5209 #define CONTAINER_INHERIT_ACE 0x02
5210 #define NO_PROPAGATE_INHERIT_ACE 0x04
5211 #define INHERIT_ONLY_ACE 0x08
5212 #define INHERITED_ACE 0x10
5213 #define VALID_INHERIT_FLAGS 0x1F
5215 /* AceFlags mask for what events we (should) audit */
5216 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
5217 #define FAILED_ACCESS_ACE_FLAG 0x80
5219 /* different ACEs depending on AceType
5220 * SidStart marks the begin of a SID
5221 * so the thing finally looks like this:
5226 typedef struct _ACCESS_ALLOWED_ACE
{
5230 } ACCESS_ALLOWED_ACE
,*PACCESS_ALLOWED_ACE
;
5232 typedef struct _ACCESS_DENIED_ACE
{
5236 } ACCESS_DENIED_ACE
,*PACCESS_DENIED_ACE
;
5238 typedef struct _SYSTEM_AUDIT_ACE
{
5242 } SYSTEM_AUDIT_ACE
,*PSYSTEM_AUDIT_ACE
;
5244 typedef struct _SYSTEM_ALARM_ACE
{
5248 } SYSTEM_ALARM_ACE
,*PSYSTEM_ALARM_ACE
;
5250 typedef struct _SYSTEM_MANDATORY_LABEL_ACE
{
5254 } SYSTEM_MANDATORY_LABEL_ACE
,*PSYSTEM_MANDATORY_LABEL_ACE
;
5256 typedef struct _ACCESS_ALLOWED_OBJECT_ACE
{
5261 GUID InheritedObjectType
;
5263 } ACCESS_ALLOWED_OBJECT_ACE
, *PACCESS_ALLOWED_OBJECT_ACE
;
5265 typedef struct _ACCESS_DENIED_OBJECT_ACE
{
5270 GUID InheritedObjectType
;
5272 } ACCESS_DENIED_OBJECT_ACE
, *PACCESS_DENIED_OBJECT_ACE
;
5274 typedef struct _SYSTEM_AUDIT_OBJECT_ACE
{
5279 GUID InheritedObjectType
;
5281 } SYSTEM_AUDIT_OBJECT_ACE
, *PSYSTEM_AUDIT_OBJECT_ACE
;
5283 typedef struct _SYSTEM_ALARM_OBJECT_ACE
{
5288 GUID InheritedObjectType
;
5290 } SYSTEM_ALARM_OBJECT_ACE
, *PSYSTEM_ALARM_OBJECT_aCE
;
5292 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE
{
5296 } ACCESS_ALLOWED_CALLBACK_ACE
,*PACCESS_ALLOWED_CALLBACK_ACE
;
5298 typedef struct _ACCESS_DENIED_CALLBACK_ACE
{
5302 } ACCESS_DENIED_CALLBACK_ACE
,*PACCESS_DENIED_CALLBACK_ACE
;
5304 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE
{
5308 } SYSTEM_AUDIT_CALLBACK_ACE
,*PSYSTEM_AUDIT_CALLBACK_ACE
;
5310 typedef struct _SYSTEM_ALARM_CALLBACK_ACE
{
5314 } SYSTEM_ALARM_CALLBACK_ACE
,*PSYSTEM_ALARM_CALLBACK_ACE
;
5316 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
{
5321 GUID InheritedObjectType
;
5323 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE
;
5325 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE
{
5330 GUID InheritedObjectType
;
5332 } ACCESS_DENIED_CALLBACK_OBJECT_ACE
, *PACCESS_DENIED_CALLBACK_OBJECT_ACE
;
5334 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
{
5339 GUID InheritedObjectType
;
5341 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE
;
5343 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE
{
5348 GUID InheritedObjectType
;
5350 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE
, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE
;
5352 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
5353 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
5354 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
5355 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
5357 typedef enum tagSID_NAME_USE
{
5362 SidTypeWellKnownGroup
,
5363 SidTypeDeletedAccount
,
5366 } SID_NAME_USE
,*PSID_NAME_USE
;
5368 #define ACE_OBJECT_TYPE_PRESENT 0x1
5369 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
5373 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
5375 #define DELETE 0x00010000
5376 #define READ_CONTROL 0x00020000
5377 #define WRITE_DAC 0x00040000
5378 #define WRITE_OWNER 0x00080000
5379 #define SYNCHRONIZE 0x00100000
5380 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
5382 #define STANDARD_RIGHTS_READ READ_CONTROL
5383 #define STANDARD_RIGHTS_WRITE READ_CONTROL
5384 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
5386 #define STANDARD_RIGHTS_ALL 0x001f0000
5388 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
5390 #define GENERIC_READ 0x80000000
5391 #define GENERIC_WRITE 0x40000000
5392 #define GENERIC_EXECUTE 0x20000000
5393 #define GENERIC_ALL 0x10000000
5395 #define MAXIMUM_ALLOWED 0x02000000
5396 #define ACCESS_SYSTEM_SECURITY 0x01000000
5398 #define EVENT_QUERY_STATE 0x0001
5399 #define EVENT_MODIFY_STATE 0x0002
5400 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5402 #define SEMAPHORE_QUERY_STATE 0x0001
5403 #define SEMAPHORE_MODIFY_STATE 0x0002
5404 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5406 #define MUTANT_QUERY_STATE 0x0001
5407 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5409 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5410 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5411 #define JOB_OBJECT_QUERY 0x0004
5412 #define JOB_OBJECT_TERMINATE 0x0008
5413 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5414 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
5416 #define TIMER_QUERY_STATE 0x0001
5417 #define TIMER_MODIFY_STATE 0x0002
5418 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5420 #define PROCESS_TERMINATE 0x0001
5421 #define PROCESS_CREATE_THREAD 0x0002
5422 #define PROCESS_VM_OPERATION 0x0008
5423 #define PROCESS_VM_READ 0x0010
5424 #define PROCESS_VM_WRITE 0x0020
5425 #define PROCESS_DUP_HANDLE 0x0040
5426 #define PROCESS_CREATE_PROCESS 0x0080
5427 #define PROCESS_SET_QUOTA 0x0100
5428 #define PROCESS_SET_INFORMATION 0x0200
5429 #define PROCESS_QUERY_INFORMATION 0x0400
5430 #define PROCESS_SUSPEND_RESUME 0x0800
5431 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5432 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5433 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5435 #define THREAD_TERMINATE 0x0001
5436 #define THREAD_SUSPEND_RESUME 0x0002
5437 #define THREAD_GET_CONTEXT 0x0008
5438 #define THREAD_SET_CONTEXT 0x0010
5439 #define THREAD_SET_INFORMATION 0x0020
5440 #define THREAD_QUERY_INFORMATION 0x0040
5441 #define THREAD_SET_THREAD_TOKEN 0x0080
5442 #define THREAD_IMPERSONATE 0x0100
5443 #define THREAD_DIRECT_IMPERSONATION 0x0200
5444 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5445 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5446 #define THREAD_RESUME 0x1000
5447 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5449 #define THREAD_BASE_PRIORITY_LOWRT 15
5450 #define THREAD_BASE_PRIORITY_MAX 2
5451 #define THREAD_BASE_PRIORITY_MIN -2
5452 #define THREAD_BASE_PRIORITY_IDLE -15
5454 typedef struct _QUOTA_LIMITS
{
5455 SIZE_T PagedPoolLimit
;
5456 SIZE_T NonPagedPoolLimit
;
5457 SIZE_T MinimumWorkingSetSize
;
5458 SIZE_T MaximumWorkingSetSize
;
5459 SIZE_T PagefileLimit
;
5460 LARGE_INTEGER TimeLimit
;
5461 } QUOTA_LIMITS
, *PQUOTA_LIMITS
;
5463 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5464 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5465 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5466 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5467 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5469 typedef union _RATE_QUOTA_LIMIT
{
5472 DWORD RatePercent
:7;
5475 } RATE_QUOTA_LIMIT
, *PRATE_QUOTA_LIMIT
;
5477 typedef struct _QUOTA_LIMITS_EX
{
5478 SIZE_T PagedPoolLimit
;
5479 SIZE_T NonPagedPoolLimit
;
5480 SIZE_T MinimumWorkingSetSize
;
5481 SIZE_T MaximumWorkingSetSize
;
5482 SIZE_T PagefileLimit
;
5483 LARGE_INTEGER TimeLimit
;
5484 SIZE_T WorkingSetLimit
;
5489 RATE_QUOTA_LIMIT CpuRateLimit
;
5490 } QUOTA_LIMITS_EX
, *PQUOTA_LIMITS_EX
;
5492 #define SECTION_QUERY 0x0001
5493 #define SECTION_MAP_WRITE 0x0002
5494 #define SECTION_MAP_READ 0x0004
5495 #define SECTION_MAP_EXECUTE 0x0008
5496 #define SECTION_EXTEND_SIZE 0x0010
5497 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5498 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5500 #define FILE_READ_DATA 0x0001 /* file & pipe */
5501 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5502 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5503 #define FILE_ADD_FILE 0x0002 /* directory */
5504 #define FILE_APPEND_DATA 0x0004 /* file */
5505 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5506 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5507 #define FILE_READ_EA 0x0008 /* file & directory */
5508 #define FILE_READ_PROPERTIES FILE_READ_EA
5509 #define FILE_WRITE_EA 0x0010 /* file & directory */
5510 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5511 #define FILE_EXECUTE 0x0020 /* file */
5512 #define FILE_TRAVERSE 0x0020 /* directory */
5513 #define FILE_DELETE_CHILD 0x0040 /* directory */
5514 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5515 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5516 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5518 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5519 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5521 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5522 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5523 FILE_APPEND_DATA | SYNCHRONIZE)
5524 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5525 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5527 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5528 #define DUPLICATE_SAME_ACCESS 0x00000002
5530 /* File attribute flags */
5531 #define FILE_SHARE_READ 0x00000001
5532 #define FILE_SHARE_WRITE 0x00000002
5533 #define FILE_SHARE_DELETE 0x00000004
5535 #define FILE_ATTRIBUTE_READONLY 0x00000001
5536 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5537 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5538 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5539 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5540 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5541 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5542 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5543 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5544 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5545 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5546 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5547 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5548 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5549 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5550 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5551 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5552 #define FILE_ATTRIBUTE_EA 0x00040000
5554 /* File notification flags */
5555 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5556 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5557 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5558 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5559 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5560 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5561 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5562 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5563 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5564 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5565 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5566 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5567 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5569 #define FILE_ACTION_ADDED 0x00000001
5570 #define FILE_ACTION_REMOVED 0x00000002
5571 #define FILE_ACTION_MODIFIED 0x00000003
5572 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5573 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5574 #define FILE_ACTION_ADDED_STREAM 0x00000006
5575 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5576 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5577 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5578 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5579 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5581 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5582 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5583 #define FILE_UNICODE_ON_DISK 0x00000004
5584 #define FILE_PERSISTENT_ACLS 0x00000008
5585 #define FILE_FILE_COMPRESSION 0x00000010
5586 #define FILE_VOLUME_QUOTAS 0x00000020
5587 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5588 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5589 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5590 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5591 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5592 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5593 #define FILE_NAMED_STREAMS 0x00040000
5594 #define FILE_READ_ONLY_VOLUME 0x00080000
5595 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5596 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5597 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5598 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5599 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5600 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5601 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5602 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5603 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5604 #define FILE_DAX_VOLUME 0x20000000
5605 #define FILE_SUPPORTS_GHOSTING 0x40000000
5607 /* File alignments (NT) */
5608 #define FILE_BYTE_ALIGNMENT 0x00000000
5609 #define FILE_WORD_ALIGNMENT 0x00000001
5610 #define FILE_LONG_ALIGNMENT 0x00000003
5611 #define FILE_QUAD_ALIGNMENT 0x00000007
5612 #define FILE_OCTA_ALIGNMENT 0x0000000f
5613 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5614 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5615 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5616 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5617 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5619 #define COMPRESSION_FORMAT_NONE 0
5620 #define COMPRESSION_FORMAT_DEFAULT 1
5621 #define COMPRESSION_FORMAT_LZNT1 2
5622 #define COMPRESSION_ENGINE_STANDARD 0
5623 #define COMPRESSION_ENGINE_MAXIMUM 256
5625 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5626 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5628 #define REG_NONE 0 /* no type */
5629 #define REG_SZ 1 /* string type (ASCII) */
5630 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5631 #define REG_BINARY 3 /* binary format, callerspecific */
5632 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5633 #define REG_DWORD 4 /* DWORD in little endian format */
5634 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5635 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5636 #define REG_LINK 6 /* symbolic link (UNICODE) */
5637 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5638 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5639 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5640 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5641 #define REG_QWORD 11 /* QWORD in little endian format */
5642 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5644 /* ----------------------------- begin power management --------------------- */
5646 typedef enum _LATENCY_TIME
{
5649 } LATENCY_TIME
, *PLATENCY_TIME
;
5651 #define DISCHARGE_POLICY_CRITICAL 0
5652 #define DISCHARGE_POLICY_LOW 1
5653 #define NUM_DISCHARGE_POLICIES 4
5655 #define PO_THROTTLE_NONE 0
5656 #define PO_THROTTLE_CONSTANT 1
5657 #define PO_THROTTLE_DEGRADE 2
5658 #define PO_THROTTLE_ADAPTIVE 3
5660 typedef enum _POWER_ACTION
{
5661 PowerActionNone
= 0,
5662 PowerActionReserved
,
5664 PowerActionHibernate
,
5665 PowerActionShutdown
,
5666 PowerActionShutdownReset
,
5667 PowerActionShutdownOff
,
5668 PowerActionWarmEject
5672 typedef enum _POWER_PLATFORM_ROLE
{
5673 PlatformRoleUnspecified
,
5674 PlatformRoleDesktop
,
5676 PlatformRoleWorkstation
,
5677 PlatformRoleEnterpriseServer
,
5678 PlatformRoleSOHOServer
,
5679 PlatformRoleAppliancePC
,
5680 PlatformRolePerformanceServer
,
5683 } POWER_PLATFORM_ROLE
, *PPOWER_PLATFORM_ROLE
;
5685 typedef enum _SYSTEM_POWER_STATE
{
5686 PowerSystemUnspecified
= 0,
5687 PowerSystemWorking
= 1,
5688 PowerSystemSleeping1
= 2,
5689 PowerSystemSleeping2
= 3,
5690 PowerSystemSleeping3
= 4,
5691 PowerSystemHibernate
= 5,
5692 PowerSystemShutdown
= 6,
5693 PowerSystemMaximum
= 7
5694 } SYSTEM_POWER_STATE
,
5695 *PSYSTEM_POWER_STATE
;
5697 typedef enum _DEVICE_POWER_STATE
{
5698 PowerDeviceUnspecified
,
5704 } DEVICE_POWER_STATE
, *PDEVICE_POWER_STATE
;
5706 typedef enum _POWER_INFORMATION_LEVEL
{
5707 SystemPowerPolicyAc
,
5708 SystemPowerPolicyDc
,
5709 VerifySystemPolicyAc
,
5710 VerifySystemPolicyDc
,
5711 SystemPowerCapabilities
,
5713 SystemPowerStateHandler
,
5714 ProcessorStateHandler
,
5715 SystemPowerPolicyCurrent
,
5716 AdministratorPowerPolicy
,
5717 SystemReserveHiberFile
,
5718 ProcessorInformation
,
5719 SystemPowerInformation
,
5720 ProcessorStateHandler2
,
5723 SystemExecutionState
,
5724 SystemPowerStateNotifyHandler
,
5725 ProcessorPowerPolicyAc
,
5726 ProcessorPowerPolicyDc
,
5727 VerifyProcessorPowerPolicyAc
,
5728 VerifyProcessorPowerPolicyDc
,
5729 ProcessorPowerPolicyCurrent
5730 } POWER_INFORMATION_LEVEL
;
5732 typedef struct _ADMINISTRATOR_POWER_POLICY
{
5733 SYSTEM_POWER_STATE MinSleep
;
5734 SYSTEM_POWER_STATE MaxSleep
;
5735 ULONG MinVideoTimeout
;
5736 ULONG MaxVideoTimeout
;
5737 ULONG MinSpindownTimeout
;
5738 ULONG MaxSpindownTimeout
;
5739 } ADMINISTRATOR_POWER_POLICY
, *PADMINISTRATOR_POWER_POLICY
;
5744 } BATTERY_REPORTING_SCALE
,
5745 *PBATTERY_REPORTING_SCALE
;
5748 POWER_ACTION Action
;
5751 } POWER_ACTION_POLICY
,
5752 *PPOWER_ACTION_POLICY
;
5754 typedef struct _PROCESSOR_POWER_INFORMATION
{
5760 ULONG CurrentIdleState
;
5761 } PROCESSOR_POWER_INFORMATION
,
5762 *PPROCESSOR_POWER_INFORMATION
;
5764 typedef struct _PROCESSOR_POWER_POLICY_INFO
{
5768 UCHAR DemotePercent
;
5769 UCHAR PromotePercent
;
5771 ULONG AllowDemotion
:1;
5772 ULONG AllowPromotion
:1;
5774 } PROCESSOR_POWER_POLICY_INFO
,
5775 *PPROCESSOR_POWER_POLICY_INFO
;
5777 typedef struct _PROCESSOR_POWER_POLICY
{
5779 BYTE DynamicThrottle
;
5781 DWORD DisableCStates
:1;
5784 PROCESSOR_POWER_POLICY_INFO Policy
[3];
5785 } PROCESSOR_POWER_POLICY
,
5786 *PPROCESSOR_POWER_POLICY
;
5790 BOOLEAN BatteryPresent
;
5792 BOOLEAN Discharging
;
5796 ULONG RemainingCapacity
;
5798 ULONG EstimatedTime
;
5799 ULONG DefaultAlert1
;
5800 ULONG DefaultAlert2
;
5801 } SYSTEM_BATTERY_STATE
,
5802 *PSYSTEM_BATTERY_STATE
;
5805 BOOLEAN PowerButtonPresent
;
5806 BOOLEAN SleepButtonPresent
;
5813 BOOLEAN HiberFilePresent
;
5815 BOOLEAN VideoDimPresent
;
5818 BOOLEAN ThermalControl
;
5819 BOOLEAN ProcessorThrottle
;
5820 UCHAR ProcessorMinThrottle
;
5821 UCHAR ProcessorMaxThrottle
;
5823 BOOLEAN DiskSpinDown
;
5825 BOOLEAN SystemBatteriesPresent
;
5826 BOOLEAN BatteriesAreShortTerm
;
5827 BATTERY_REPORTING_SCALE BatteryScale
[3];
5828 SYSTEM_POWER_STATE AcOnLineWake
;
5829 SYSTEM_POWER_STATE SoftLidWake
;
5830 SYSTEM_POWER_STATE RtcWake
;
5831 SYSTEM_POWER_STATE MinDeviceWakeState
;
5832 SYSTEM_POWER_STATE DefaultLowLatencyWake
;
5833 } SYSTEM_POWER_CAPABILITIES
,
5834 *PSYSTEM_POWER_CAPABILITIES
;
5836 typedef struct _SYSTEM_POWER_INFORMATION
{
5837 ULONG MaxIdlenessAllowed
;
5839 ULONG TimeRemaining
;
5841 } SYSTEM_POWER_INFORMATION
,
5842 *PSYSTEM_POWER_INFORMATION
;
5844 typedef struct _SYSTEM_POWER_LEVEL
{
5848 POWER_ACTION_POLICY PowerPolicy
;
5849 SYSTEM_POWER_STATE MinSystemState
;
5850 } SYSTEM_POWER_LEVEL
,
5851 *PSYSTEM_POWER_LEVEL
;
5853 typedef struct _SYSTEM_POWER_POLICY
{
5855 POWER_ACTION_POLICY PowerButton
;
5856 POWER_ACTION_POLICY SleepButton
;
5857 POWER_ACTION_POLICY LidClose
;
5858 SYSTEM_POWER_STATE LidOpenWake
;
5860 POWER_ACTION_POLICY Idle
;
5862 UCHAR IdleSensitivity
;
5863 UCHAR DynamicThrottle
;
5865 SYSTEM_POWER_STATE MinSleep
;
5866 SYSTEM_POWER_STATE MaxSleep
;
5867 SYSTEM_POWER_STATE ReducedLatencySleep
;
5868 ULONG WinLogonFlags
;
5870 ULONG DozeS4Timeout
;
5871 ULONG BroadcastCapacityResolution
;
5872 SYSTEM_POWER_LEVEL DischargePolicy
[NUM_DISCHARGE_POLICIES
];
5874 BOOLEAN VideoDimDisplay
;
5875 ULONG VideoReserved
[3];
5876 ULONG SpindownTimeout
;
5877 BOOLEAN OptimizeForPower
;
5878 UCHAR FanThrottleTolerance
;
5879 UCHAR ForcedThrottle
;
5881 POWER_ACTION_POLICY OverThrottled
;
5882 } SYSTEM_POWER_POLICY
,
5883 *PSYSTEM_POWER_POLICY
;
5885 typedef enum _POWER_REQUEST_TYPE
5887 PowerRequestDisplayRequired
,
5888 PowerRequestSystemRequired
,
5889 PowerRequestAwayModeRequired
5890 } POWER_REQUEST_TYPE
, *PPOWER_REQUEST_TYPE
;
5892 #define POWER_REQUEST_CONTEXT_VERSION 0
5894 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5895 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5897 typedef union _FILE_SEGMENT_ELEMENT
{
5899 ULONGLONG Alignment
;
5900 } FILE_SEGMENT_ELEMENT
, *PFILE_SEGMENT_ELEMENT
;
5902 typedef struct _FILE_NOTIFY_INFORMATION
{
5903 DWORD NextEntryOffset
;
5905 DWORD FileNameLength
;
5907 } FILE_NOTIFY_INFORMATION
, *PFILE_NOTIFY_INFORMATION
;
5909 /* ----------------------------- begin tape storage --------------------- */
5911 #define TAPE_FIXED_PARTITIONS 0
5912 #define TAPE_SELECT_PARTITIONS 1
5913 #define TAPE_INITIATOR_PARTITIONS 2
5914 #define TAPE_ERASE_SHORT 0
5915 #define TAPE_ERASE_LONG 1
5917 #define TAPE_UNLOAD 1
5918 #define TAPE_TENSION 2
5920 #define TAPE_UNLOCK 4
5921 #define TAPE_FORMAT 5
5922 #define TAPE_SETMARKS 0
5923 #define TAPE_FILEMARKS 1
5924 #define TAPE_SHORT_FILEMARKS 2
5925 #define TAPE_LONG_FILEMARKS 3
5926 #define TAPE_REWIND 0
5927 #define TAPE_ABSOLUTE_BLOCK 1
5928 #define TAPE_LOGICAL_BLOCK 2
5929 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5930 #define TAPE_SPACE_END_OF_DATA 4
5931 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5932 #define TAPE_SPACE_FILEMARKS 6
5933 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5934 #define TAPE_SPACE_SETMARKS 8
5935 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5937 typedef struct _TAPE_CREATE_PARTITION
{
5941 } TAPE_CREATE_PARTITION
, *PTAPE_CREATE_PARTITION
;
5943 typedef struct _TAPE_ERASE
{
5946 } TAPE_ERASE
, *PTAPE_ERASE
;
5948 typedef struct _TAPE_PREPARE
{
5951 } TAPE_PREPARE
, *PTAPE_PREPARE
;
5953 typedef struct _TAPE_SET_DRIVE_PARAMETERS
{
5955 BOOLEAN Compression
;
5956 BOOLEAN DataPadding
;
5957 BOOLEAN ReportSetmarks
;
5958 ULONG EOTWarningZoneSize
;
5959 } TAPE_SET_DRIVE_PARAMETERS
, *PTAPE_SET_DRIVE_PARAMETERS
;
5961 typedef struct _TAPE_SET_MEDIA_PARAMETERS
{
5963 } TAPE_SET_MEDIA_PARAMETERS
, *PTAPE_SET_MEDIA_PARAMETERS
;
5965 typedef struct _TAPE_WRITE_MARKS
{
5969 } TAPE_WRITE_MARKS
, *PTAPE_WRITE_MARKS
;
5971 typedef struct _TAPE_GET_POSITION
{
5976 } TAPE_GET_POSITION
, *PTAPE_GET_POSITION
;
5978 typedef struct _TAPE_SET_POSITION
{
5981 LARGE_INTEGER Offset
;
5983 } TAPE_SET_POSITION
, *PTAPE_SET_POSITION
;
5985 typedef struct _TAPE_GET_DRIVE_PARAMETERS
{
5987 BOOLEAN Compression
;
5988 BOOLEAN DataPadding
;
5989 BOOLEAN ReportSetmarks
;
5990 DWORD DefaultBlockSize
;
5991 DWORD MaximumBlockSize
;
5992 DWORD MinimumBlockSize
;
5993 DWORD MaximumPartitionCount
;
5996 DWORD EOTWarningZoneSize
;
5997 } TAPE_GET_DRIVE_PARAMETERS
, *PTAPE_GET_DRIVE_PARAMETERS
;
5999 typedef struct _TAPE_GET_MEDIA_PARAMETERS
{
6000 LARGE_INTEGER Capacity
;
6001 LARGE_INTEGER Remaining
;
6003 DWORD PartitionCount
;
6004 BOOLEAN WriteProtected
;
6005 } TAPE_GET_MEDIA_PARAMETERS
, *PTAPE_GET_MEDIA_PARAMETERS
;
6007 /* ----------------------------- begin registry ----------------------------- */
6009 /* Registry security values */
6010 #define OWNER_SECURITY_INFORMATION 0x00000001
6011 #define GROUP_SECURITY_INFORMATION 0x00000002
6012 #define DACL_SECURITY_INFORMATION 0x00000004
6013 #define SACL_SECURITY_INFORMATION 0x00000008
6014 #define LABEL_SECURITY_INFORMATION 0x00000010
6016 #define REG_OPTION_RESERVED 0x00000000
6017 #define REG_OPTION_NON_VOLATILE 0x00000000
6018 #define REG_OPTION_VOLATILE 0x00000001
6019 #define REG_OPTION_CREATE_LINK 0x00000002
6020 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
6021 #define REG_OPTION_OPEN_LINK 0x00000008
6022 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
6023 REG_OPTION_NON_VOLATILE | \
6024 REG_OPTION_VOLATILE | \
6025 REG_OPTION_CREATE_LINK | \
6026 REG_OPTION_BACKUP_RESTORE | \
6027 REG_OPTION_OPEN_LINK)
6030 #define REG_CREATED_NEW_KEY 0x00000001
6031 #define REG_OPENED_EXISTING_KEY 0x00000002
6033 /* For RegNotifyChangeKeyValue */
6034 #define REG_NOTIFY_CHANGE_NAME 0x01
6035 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
6036 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
6037 #define REG_NOTIFY_CHANGE_SECURITY 0x08
6038 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
6040 #define KEY_QUERY_VALUE 0x00000001
6041 #define KEY_SET_VALUE 0x00000002
6042 #define KEY_CREATE_SUB_KEY 0x00000004
6043 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
6044 #define KEY_NOTIFY 0x00000010
6045 #define KEY_CREATE_LINK 0x00000020
6046 #define KEY_WOW64_64KEY 0x00000100
6047 #define KEY_WOW64_32KEY 0x00000200
6048 #define KEY_WOW64_RES 0x00000300
6050 /* for RegKeyRestore flags */
6051 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
6052 #define REG_REFRESH_HIVE 0x00000002
6053 #define REG_NO_LAZY_FLUSH 0x00000004
6054 #define REG_FORCE_RESTORE 0x00000008
6056 #define KEY_READ ((STANDARD_RIGHTS_READ| \
6058 KEY_ENUMERATE_SUB_KEYS| \
6062 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
6064 KEY_CREATE_SUB_KEY) \
6067 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
6068 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
6071 KEY_CREATE_SUB_KEY| \
6072 KEY_ENUMERATE_SUB_KEYS| \
6077 /* ------------------------------ end registry ------------------------------ */
6080 #define EVENTLOG_SUCCESS 0x0000
6081 #define EVENTLOG_ERROR_TYPE 0x0001
6082 #define EVENTLOG_WARNING_TYPE 0x0002
6083 #define EVENTLOG_INFORMATION_TYPE 0x0004
6084 #define EVENTLOG_AUDIT_SUCCESS 0x0008
6085 #define EVENTLOG_AUDIT_FAILURE 0x0010
6087 #define EVENTLOG_SEQUENTIAL_READ 0x0001
6088 #define EVENTLOG_SEEK_READ 0x0002
6089 #define EVENTLOG_FORWARDS_READ 0x0004
6090 #define EVENTLOG_BACKWARDS_READ 0x0008
6092 typedef struct _EVENTLOGRECORD
{
6096 DWORD TimeGenerated
;
6103 DWORD ClosingRecordNumber
;
6105 DWORD UserSidLength
;
6106 DWORD UserSidOffset
;
6109 } EVENTLOGRECORD
, *PEVENTLOGRECORD
;
6111 #define SERVICE_BOOT_START 0x00000000
6112 #define SERVICE_SYSTEM_START 0x00000001
6113 #define SERVICE_AUTO_START 0x00000002
6114 #define SERVICE_DEMAND_START 0x00000003
6115 #define SERVICE_DISABLED 0x00000004
6117 #define SERVICE_ERROR_IGNORE 0x00000000
6118 #define SERVICE_ERROR_NORMAL 0x00000001
6119 #define SERVICE_ERROR_SEVERE 0x00000002
6120 #define SERVICE_ERROR_CRITICAL 0x00000003
6123 #define SERVICE_KERNEL_DRIVER 0x00000001
6124 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
6125 #define SERVICE_ADAPTER 0x00000004
6126 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
6128 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
6129 SERVICE_RECOGNIZER_DRIVER )
6131 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
6132 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
6133 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
6135 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
6137 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
6138 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
6141 typedef enum _CM_SERVICE_NODE_TYPE
6143 DriverType
= SERVICE_KERNEL_DRIVER
,
6144 FileSystemType
= SERVICE_FILE_SYSTEM_DRIVER
,
6145 Win32ServiceOwnProcess
= SERVICE_WIN32_OWN_PROCESS
,
6146 Win32ServiceShareProcess
= SERVICE_WIN32_SHARE_PROCESS
,
6147 AdapterType
= SERVICE_ADAPTER
,
6148 RecognizerType
= SERVICE_RECOGNIZER_DRIVER
6149 } SERVICE_NODE_TYPE
;
6151 typedef enum _CM_SERVICE_LOAD_TYPE
6153 BootLoad
= SERVICE_BOOT_START
,
6154 SystemLoad
= SERVICE_SYSTEM_START
,
6155 AutoLoad
= SERVICE_AUTO_START
,
6156 DemandLoad
= SERVICE_DEMAND_START
,
6157 DisableLoad
= SERVICE_DISABLED
6158 } SERVICE_LOAD_TYPE
;
6160 typedef enum _CM_ERROR_CONTROL_TYPE
6162 IgnoreError
= SERVICE_ERROR_IGNORE
,
6163 NormalError
= SERVICE_ERROR_NORMAL
,
6164 SevereError
= SERVICE_ERROR_SEVERE
,
6165 CriticalError
= SERVICE_ERROR_CRITICAL
6166 } SERVICE_ERROR_TYPE
;
6168 NTSYSAPI SIZE_T WINAPI
RtlCompareMemory(const VOID
*, const VOID
*, SIZE_T
);
6169 NTSYSAPI SIZE_T WINAPI
RtlCompareMemoryUlong(VOID
*, SIZE_T
, ULONG
);
6171 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
6172 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
6173 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
6174 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
6175 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
6177 static FORCEINLINE
void *RtlSecureZeroMemory(void *buffer
, SIZE_T length
)
6179 volatile char *ptr
= (volatile char *)buffer
;
6181 while (length
--) *ptr
++ = 0;
6185 #include <guiddef.h>
6187 typedef struct _OBJECT_TYPE_LIST
{
6191 } OBJECT_TYPE_LIST
, *POBJECT_TYPE_LIST
;
6193 typedef struct _RTL_CRITICAL_SECTION_DEBUG
6196 WORD CreatorBackTraceIndex
;
6197 struct _RTL_CRITICAL_SECTION
*CriticalSection
;
6198 LIST_ENTRY ProcessLocksList
;
6200 DWORD ContentionCount
;
6201 #ifdef __WINESRC__ /* in Wine we store the name here */
6202 DWORD_PTR Spare
[8/sizeof(DWORD_PTR
)];
6206 } RTL_CRITICAL_SECTION_DEBUG
, *PRTL_CRITICAL_SECTION_DEBUG
, RTL_RESOURCE_DEBUG
, *PRTL_RESOURCE_DEBUG
;
6208 typedef struct _RTL_CRITICAL_SECTION
{
6209 PRTL_CRITICAL_SECTION_DEBUG DebugInfo
;
6211 LONG RecursionCount
;
6212 HANDLE OwningThread
;
6213 HANDLE LockSemaphore
;
6214 ULONG_PTR SpinCount
;
6215 } RTL_CRITICAL_SECTION
, *PRTL_CRITICAL_SECTION
;
6217 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
6218 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
6219 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
6220 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
6221 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
6223 typedef struct _RTL_SRWLOCK
{
6225 } RTL_SRWLOCK
, *PRTL_SRWLOCK
;
6227 #define RTL_SRWLOCK_INIT {0}
6229 typedef struct _RTL_CONDITION_VARIABLE
{
6231 } RTL_CONDITION_VARIABLE
, *PRTL_CONDITION_VARIABLE
;
6232 #define RTL_CONDITION_VARIABLE_INIT {0}
6233 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
6235 typedef VOID (NTAPI
* WAITORTIMERCALLBACKFUNC
) (PVOID
, BOOLEAN
);
6236 typedef VOID (NTAPI
* PFLS_CALLBACK_FUNCTION
) ( PVOID
);
6238 #define RTL_RUN_ONCE_INIT {0}
6239 typedef union _RTL_RUN_ONCE
{
6241 } RTL_RUN_ONCE
, *PRTL_RUN_ONCE
;
6243 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
6244 #define RTL_RUN_ONCE_ASYNC 0x00000002
6245 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
6247 typedef DWORD WINAPI
RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE
, PVOID
, PVOID
*);
6248 typedef RTL_RUN_ONCE_INIT_FN
*PRTL_RUN_ONCE_INIT_FN
;
6249 NTSYSAPI VOID WINAPI
RtlRunOnceInitialize(PRTL_RUN_ONCE
);
6250 NTSYSAPI DWORD WINAPI
RtlRunOnceExecuteOnce(PRTL_RUN_ONCE
,PRTL_RUN_ONCE_INIT_FN
,PVOID
,PVOID
*);
6251 NTSYSAPI DWORD WINAPI
RtlRunOnceBeginInitialize(PRTL_RUN_ONCE
, DWORD
, PVOID
*);
6252 NTSYSAPI DWORD WINAPI
RtlRunOnceComplete(PRTL_RUN_ONCE
, DWORD
, PVOID
);
6254 #include <pshpack8.h>
6255 typedef struct _IO_COUNTERS
{
6256 ULONGLONG
DECLSPEC_ALIGN(8) ReadOperationCount
;
6257 ULONGLONG
DECLSPEC_ALIGN(8) WriteOperationCount
;
6258 ULONGLONG
DECLSPEC_ALIGN(8) OtherOperationCount
;
6259 ULONGLONG
DECLSPEC_ALIGN(8) ReadTransferCount
;
6260 ULONGLONG
DECLSPEC_ALIGN(8) WriteTransferCount
;
6261 ULONGLONG
DECLSPEC_ALIGN(8) OtherTransferCount
;
6262 } IO_COUNTERS
, *PIO_COUNTERS
;
6263 #include <poppack.h>
6266 DWORD dwOSVersionInfoSize
;
6267 DWORD dwMajorVersion
;
6268 DWORD dwMinorVersion
;
6269 DWORD dwBuildNumber
;
6271 CHAR szCSDVersion
[128];
6272 } OSVERSIONINFOA
, *POSVERSIONINFOA
, *LPOSVERSIONINFOA
;
6275 DWORD dwOSVersionInfoSize
;
6276 DWORD dwMajorVersion
;
6277 DWORD dwMinorVersion
;
6278 DWORD dwBuildNumber
;
6280 WCHAR szCSDVersion
[128];
6281 } OSVERSIONINFOW
, *POSVERSIONINFOW
, *LPOSVERSIONINFOW
, RTL_OSVERSIONINFOW
, *PRTL_OSVERSIONINFOW
;
6283 DECL_WINELIB_TYPE_AW(OSVERSIONINFO
)
6284 DECL_WINELIB_TYPE_AW(POSVERSIONINFO
)
6285 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO
)
6288 DWORD dwOSVersionInfoSize
;
6289 DWORD dwMajorVersion
;
6290 DWORD dwMinorVersion
;
6291 DWORD dwBuildNumber
;
6293 CHAR szCSDVersion
[128];
6294 WORD wServicePackMajor
;
6295 WORD wServicePackMinor
;
6299 } OSVERSIONINFOEXA
, *POSVERSIONINFOEXA
, *LPOSVERSIONINFOEXA
;
6302 DWORD dwOSVersionInfoSize
;
6303 DWORD dwMajorVersion
;
6304 DWORD dwMinorVersion
;
6305 DWORD dwBuildNumber
;
6307 WCHAR szCSDVersion
[128];
6308 WORD wServicePackMajor
;
6309 WORD wServicePackMinor
;
6313 } OSVERSIONINFOEXW
, *POSVERSIONINFOEXW
, *LPOSVERSIONINFOEXW
, RTL_OSVERSIONINFOEXW
, *PRTL_OSVERSIONINFOEXW
;
6315 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX
)
6316 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX
)
6317 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX
)
6319 NTSYSAPI ULONGLONG WINAPI
VerSetConditionMask(ULONGLONG
,DWORD
,BYTE
);
6321 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
6323 #define VER_PLATFORM_WIN32s 0
6324 #define VER_PLATFORM_WIN32_WINDOWS 1
6325 #define VER_PLATFORM_WIN32_NT 2
6327 #define VER_MINORVERSION 0x00000001
6328 #define VER_MAJORVERSION 0x00000002
6329 #define VER_BUILDNUMBER 0x00000004
6330 #define VER_PLATFORMID 0x00000008
6331 #define VER_SERVICEPACKMINOR 0x00000010
6332 #define VER_SERVICEPACKMAJOR 0x00000020
6333 #define VER_SUITENAME 0x00000040
6334 #define VER_PRODUCT_TYPE 0x00000080
6336 #define VER_NT_WORKSTATION 1
6337 #define VER_NT_DOMAIN_CONTROLLER 2
6338 #define VER_NT_SERVER 3
6340 #define VER_SUITE_SMALLBUSINESS 0x00000001
6341 #define VER_SUITE_ENTERPRISE 0x00000002
6342 #define VER_SUITE_BACKOFFICE 0x00000004
6343 #define VER_SUITE_COMMUNICATIONS 0x00000008
6344 #define VER_SUITE_TERMINAL 0x00000010
6345 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
6346 #define VER_SUITE_EMBEDDEDNT 0x00000040
6347 #define VER_SUITE_DATACENTER 0x00000080
6348 #define VER_SUITE_SINGLEUSERTS 0x00000100
6349 #define VER_SUITE_PERSONAL 0x00000200
6350 #define VER_SUITE_BLADE 0x00000400
6351 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
6352 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
6353 #define VER_SUITE_STORAGE_SERVER 0x00002000
6354 #define VER_SUITE_COMPUTE_SERVER 0x00004000
6355 #define VER_SUITE_WH_SERVER 0x00008000
6358 #define VER_GREATER 2
6359 #define VER_GREATER_EQUAL 3
6361 #define VER_LESS_EQUAL 5
6365 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION
{
6367 DWORD ulFormatVersion
;
6368 DWORD ulAssemblyCount
;
6369 DWORD ulRootManifestPathType
;
6370 DWORD ulRootManifestPathChars
;
6371 DWORD ulRootConfigurationPathType
;
6372 DWORD ulRootConfigurationPathChars
;
6373 DWORD ulAppDirPathType
;
6374 DWORD ulAppDirPathChars
;
6375 PCWSTR lpRootManifestPath
;
6376 PCWSTR lpRootConfigurationPath
;
6377 PCWSTR lpAppDirPath
;
6378 } ACTIVATION_CONTEXT_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_DETAILED_INFORMATION
;
6380 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
{
6382 DWORD ulEncodedAssemblyIdentityLength
;
6383 DWORD ulManifestPathType
;
6384 DWORD ulManifestPathLength
;
6385 LARGE_INTEGER liManifestLastWriteTime
;
6386 DWORD ulPolicyPathType
;
6387 DWORD ulPolicyPathLength
;
6388 LARGE_INTEGER liPolicyLastWriteTime
;
6389 DWORD ulMetadataSatelliteRosterIndex
;
6390 DWORD ulManifestVersionMajor
;
6391 DWORD ulManifestVersionMinor
;
6392 DWORD ulPolicyVersionMajor
;
6393 DWORD ulPolicyVersionMinor
;
6394 DWORD ulAssemblyDirectoryNameLength
;
6395 PCWSTR lpAssemblyEncodedAssemblyIdentity
;
6396 PCWSTR lpAssemblyManifestPath
;
6397 PCWSTR lpAssemblyPolicyPath
;
6398 PCWSTR lpAssemblyDirectoryName
;
6400 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
;
6402 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX
{
6403 DWORD ulAssemblyIndex
;
6404 DWORD ulFileIndexInAssembly
;
6405 } ACTIVATION_CONTEXT_QUERY_INDEX
, *PACTIVATION_CONTEXT_QUERY_INDEX
;
6407 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX
*PCACTIVATION_CONTEXT_QUERY_INDEX
;
6409 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION
{
6411 DWORD ulFilenameLength
;
6415 } ASSEMBLY_FILE_DETAILED_INFORMATION
, *PASSEMBLY_FILE_DETAILED_INFORMATION
;
6417 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION
*PCASSEMBLY_FILE_DETAILED_INFORMATION
;
6420 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN
= 0,
6421 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
6422 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION
,
6423 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6424 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE
;
6426 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT
{
6428 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type
;
6429 } COMPATIBILITY_CONTEXT_ELEMENT
, *PCOMPATIBILITY_CONTEXT_ELEMENT
;
6431 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6432 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
{
6434 COMPATIBILITY_CONTEXT_ELEMENT Elements
[];
6435 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
;
6439 ACTCTX_RUN_LEVEL_UNSPECIFIED
= 0,
6440 ACTCTX_RUN_LEVEL_AS_INVOKER
,
6441 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE
,
6442 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
,
6443 ACTCTX_RUN_LEVEL_NUMBERS
6444 } ACTCTX_REQUESTED_RUN_LEVEL
;
6446 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
{
6448 ACTCTX_REQUESTED_RUN_LEVEL RunLevel
;
6450 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
6452 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
*PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
6454 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS
{
6455 ActivationContextBasicInformation
= 1,
6456 ActivationContextDetailedInformation
= 2,
6457 AssemblyDetailedInformationInActivationContext
= 3,
6458 FileInformationInAssemblyOfAssemblyInActivationContext
= 4,
6459 RunlevelInformationInActivationContext
= 5,
6460 CompatibilityInformationInActivationContext
= 6,
6461 ActivationContextManifestResourceName
= 7,
6462 MaxActivationContextInfoClass
,
6463 AssemblyDetailedInformationInActivationContxt
= AssemblyDetailedInformationInActivationContext
,
6464 FileInformationInAssemblyOfAssemblyInActivationContxt
= FileInformationInAssemblyOfAssemblyInActivationContext
6465 } ACTIVATION_CONTEXT_INFO_CLASS
;
6467 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6468 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6469 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6470 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6472 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6473 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6474 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6475 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6476 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6477 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6478 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6479 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6480 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6481 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6482 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6484 typedef enum _JOBOBJECTINFOCLASS
6486 JobObjectBasicAccountingInformation
= 1,
6487 JobObjectBasicLimitInformation
,
6488 JobObjectBasicProcessIdList
,
6489 JobObjectBasicUIRestrictions
,
6490 JobObjectSecurityLimitInformation
,
6491 JobObjectEndOfJobTimeInformation
,
6492 JobObjectAssociateCompletionPortInformation
,
6493 JobObjectBasicAndIoAccountingInformation
,
6494 JobObjectExtendedLimitInformation
,
6495 JobObjectJobSetInformation
,
6496 MaxJobObjectInfoClass
6497 } JOBOBJECTINFOCLASS
;
6499 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
{
6500 LARGE_INTEGER TotalUserTime
;
6501 LARGE_INTEGER TotalKernelTime
;
6502 LARGE_INTEGER ThisPeriodTotalUserTime
;
6503 LARGE_INTEGER ThisPeriodTotalKernelTime
;
6504 DWORD TotalPageFaultCount
;
6505 DWORD TotalProcesses
;
6506 DWORD ActiveProcesses
;
6507 DWORD TotalTerminatedProcesses
;
6508 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION
;
6510 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION
{
6511 LARGE_INTEGER PerProcessUserTimeLimit
;
6512 LARGE_INTEGER PerJobUserTimeLimit
;
6514 SIZE_T MinimumWorkingSetSize
;
6515 SIZE_T MaximumWorkingSetSize
;
6516 DWORD ActiveProcessLimit
;
6518 DWORD PriorityClass
;
6519 DWORD SchedulingClass
;
6520 } JOBOBJECT_BASIC_LIMIT_INFORMATION
, *PJOBOBJECT_BASIC_LIMIT_INFORMATION
;
6522 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST
{
6523 DWORD NumberOfAssignedProcesses
;
6524 DWORD NumberOfProcessIdsInList
;
6525 ULONG_PTR ProcessIdList
[1];
6526 } JOBOBJECT_BASIC_PROCESS_ID_LIST
, *PJOBOBJECT_BASIC_PROCESS_ID_LIST
;
6528 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS
{
6529 DWORD UIRestrictionsClass
;
6530 } JOBOBJECT_BASIC_UI_RESTRICTIONS
, *PJOBOBJECT_BASIC_UI_RESTRICTIONS
;
6532 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION
{
6533 DWORD SecurityLimitFlags
;
6535 PTOKEN_GROUPS SidsToDisable
;
6536 PTOKEN_PRIVILEGES PrivilegesToDelete
;
6537 PTOKEN_GROUPS RestrictedSids
;
6538 } JOBOBJECT_SECURITY_LIMIT_INFORMATION
, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION
;
6540 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION
{
6541 DWORD EndOfJobTimeAction
;
6542 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION
, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION
;
6544 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT
{
6545 PVOID CompletionKey
;
6546 HANDLE CompletionPort
;
6547 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT
, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT
;
6549 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6550 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6551 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6552 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6553 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6554 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6555 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6556 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6557 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6559 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
{
6560 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo
;
6562 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
;
6564 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION
{
6565 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation
;
6567 SIZE_T ProcessMemoryLimit
;
6568 SIZE_T JobMemoryLimit
;
6569 SIZE_T PeakProcessMemoryUsed
;
6570 SIZE_T PeakJobMemoryUsed
;
6571 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION
, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION
;
6573 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6574 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6575 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6576 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6577 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6578 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6579 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6580 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6581 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6582 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6583 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6584 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6585 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6586 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6587 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6589 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6590 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6591 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6593 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6595 RelationProcessorCore
= 0,
6596 RelationNumaNode
= 1,
6598 RelationProcessorPackage
= 3,
6600 RelationAll
= 0xffff
6601 } LOGICAL_PROCESSOR_RELATIONSHIP
;
6603 #define LTP_PC_SMT 0x1
6605 typedef enum _PROCESSOR_CACHE_TYPE
6611 } PROCESSOR_CACHE_TYPE
;
6613 typedef struct _PROCESSOR_GROUP_INFO
6615 BYTE MaximumProcessorCount
;
6616 BYTE ActiveProcessorCount
;
6618 KAFFINITY ActiveProcessorMask
;
6619 } PROCESSOR_GROUP_INFO
, *PPROCESSOR_GROUP_INFO
;
6621 typedef struct _CACHE_DESCRIPTOR
6627 PROCESSOR_CACHE_TYPE Type
;
6628 } CACHE_DESCRIPTOR
, *PCACHE_DESCRIPTOR
;
6630 typedef struct _GROUP_AFFINITY
6635 } GROUP_AFFINITY
, *PGROUP_AFFINITY
;
6637 #define ALL_PROCESSOR_GROUPS 0xffff
6639 typedef struct _PROCESSOR_NUMBER
6644 } PROCESSOR_NUMBER
, *PPROCESSOR_NUMBER
;
6646 typedef struct _PROCESSOR_RELATIONSHIP
6649 BYTE EfficiencyClass
;
6652 GROUP_AFFINITY GroupMask
[ANYSIZE_ARRAY
];
6653 } PROCESSOR_RELATIONSHIP
, *PPROCESSOR_RELATIONSHIP
;
6655 typedef struct _NUMA_NODE_RELATIONSHIP
6659 GROUP_AFFINITY GroupMask
;
6660 } NUMA_NODE_RELATIONSHIP
, *PNUMA_NODE_RELATIONSHIP
;
6662 typedef struct _CACHE_RELATIONSHIP
6668 PROCESSOR_CACHE_TYPE Type
;
6670 GROUP_AFFINITY GroupMask
;
6671 } CACHE_RELATIONSHIP
, *PCACHE_RELATIONSHIP
;
6673 typedef struct _GROUP_RELATIONSHIP
6675 WORD MaximumGroupCount
;
6676 WORD ActiveGroupCount
;
6678 PROCESSOR_GROUP_INFO GroupInfo
[ANYSIZE_ARRAY
];
6679 } GROUP_RELATIONSHIP
, *PGROUP_RELATIONSHIP
;
6681 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6683 ULONG_PTR ProcessorMask
;
6684 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6695 CACHE_DESCRIPTOR Cache
;
6696 ULONGLONG Reserved
[2];
6698 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION
;
6700 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6702 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6706 PROCESSOR_RELATIONSHIP Processor
;
6707 NUMA_NODE_RELATIONSHIP NumaNode
;
6708 CACHE_RELATIONSHIP Cache
;
6709 GROUP_RELATIONSHIP Group
;
6711 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
;
6713 /* Threadpool things */
6714 typedef DWORD TP_VERSION
,*PTP_VERSION
;
6716 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE
,*PTP_CALLBACK_INSTANCE
;
6718 typedef VOID (CALLBACK
*PTP_SIMPLE_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
);
6720 typedef struct _TP_POOL TP_POOL
,*PTP_POOL
;
6722 typedef enum _TP_CALLBACK_PRIORITY
6724 TP_CALLBACK_PRIORITY_HIGH
,
6725 TP_CALLBACK_PRIORITY_NORMAL
,
6726 TP_CALLBACK_PRIORITY_LOW
,
6727 TP_CALLBACK_PRIORITY_INVALID
,
6728 TP_CALLBACK_PRIORITY_COUNT
= TP_CALLBACK_PRIORITY_INVALID
6729 } TP_CALLBACK_PRIORITY
;
6731 typedef struct _TP_POOL_STACK_INFORMATION
6733 SIZE_T StackReserve
;
6735 } TP_POOL_STACK_INFORMATION
,*PTP_POOL_STACK_INFORMATION
;
6737 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP
,*PTP_CLEANUP_GROUP
;
6739 typedef VOID (CALLBACK
*PTP_CLEANUP_GROUP_CANCEL_CALLBACK
)(PVOID
,PVOID
);
6741 typedef struct _TP_CALLBACK_ENVIRON_V1
6745 PTP_CLEANUP_GROUP CleanupGroup
;
6746 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6748 struct _ACTIVATION_CONTEXT
* ActivationContext
;
6749 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6755 DWORD LongFunction
:1;
6760 } TP_CALLBACK_ENVIRON_V1
;
6762 typedef struct _TP_CALLBACK_ENVIRON_V3
6766 PTP_CLEANUP_GROUP CleanupGroup
;
6767 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6769 struct _ACTIVATION_CONTEXT
*ActivationContext
;
6770 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6776 DWORD LongFunction
:1;
6781 TP_CALLBACK_PRIORITY CallbackPriority
;
6783 } TP_CALLBACK_ENVIRON_V3
;
6785 typedef struct _TP_WORK TP_WORK
, *PTP_WORK
;
6786 typedef struct _TP_TIMER TP_TIMER
, *PTP_TIMER
;
6788 typedef DWORD TP_WAIT_RESULT
;
6789 typedef struct _TP_WAIT TP_WAIT
, *PTP_WAIT
;
6791 typedef struct _TP_IO TP_IO
, *PTP_IO
;
6793 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON
, *PTP_CALLBACK_ENVIRON
;
6795 typedef VOID (CALLBACK
*PTP_WORK_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WORK
);
6796 typedef VOID (CALLBACK
*PTP_TIMER_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_TIMER
);
6797 typedef VOID (CALLBACK
*PTP_WAIT_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WAIT
,TP_WAIT_RESULT
);
6800 NTSYSAPI BOOLEAN NTAPI
RtlGetProductInfo(DWORD
,DWORD
,DWORD
,DWORD
,PDWORD
);
6802 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6804 UmsThreadInvalidInfoClass
,
6805 UmsThreadUserContext
,
6809 UmsThreadIsSuspended
,
6810 UmsThreadIsTerminated
,
6811 UmsThreadMaxInfoClass
6812 } RTL_UMS_THREAD_INFO_CLASS
, *PRTL_UMS_THREAD_INFO_CLASS
;
6814 typedef enum _RTL_UMS_SCHEDULER_REASON
6816 UmsSchedulerStartup
,
6817 UmsSchedulerThreadBlocked
,
6818 UmsSchedulerThreadYield
,
6819 } RTL_UMS_SCHEDULER_REASON
, *PRTL_UMS_SCHEDULER_REASON
;
6821 typedef void (CALLBACK
*PRTL_UMS_SCHEDULER_ENTRY_POINT
)(RTL_UMS_SCHEDULER_REASON
,ULONG_PTR
,PVOID
);
6823 typedef enum _PROCESS_MITIGATION_POLICY
6827 ProcessDynamicCodePolicy
,
6828 ProcessStrictHandleCheckPolicy
,
6829 ProcessSystemCallDisablePolicy
,
6830 ProcessMitigationOptionsMask
,
6831 ProcessExtensionPointDisablePolicy
,
6832 ProcessControlFlowGuardPolicy
,
6833 ProcessSignaturePolicy
,
6834 ProcessFontDisablePolicy
,
6835 ProcessImageLoadPolicy
,
6836 ProcessSystemCallFilterPolicy
,
6837 ProcessPayloadRestrictionPolicy
,
6838 ProcessChildProcessPolicy
,
6839 ProcessSideChannelIsolationPolicy
,
6840 MaxProcessMitigationPolicy
6841 } PROCESS_MITIGATION_POLICY
, *PPROCESS_MITIGATION_POLICY
;
6845 BOOLEAN
_BitScanForward(unsigned long*,unsigned long);
6846 BOOLEAN
_BitScanReverse(unsigned long*,unsigned long);
6848 #pragma intrinsic(_BitScanForward)
6849 #pragma intrinsic(_BitScanReverse)
6851 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6853 return _BitScanForward((unsigned long*)index
, mask
);
6856 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6858 return _BitScanReverse((unsigned long*)index
, mask
);
6861 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
6863 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6865 *index
= __builtin_ctz(mask
);
6869 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6871 *index
= 31 - __builtin_clz(mask
);
6877 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6880 while (r
< 31 && !(mask
& (1 << r
))) r
++;
6885 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6887 unsigned int r
= 31;
6888 while (r
> 0 && !(mask
& (1 << r
))) r
--;
6897 #if defined(_MSC_VER)
6899 #define InterlockedCompareExchange128 _InterlockedCompareExchange128
6900 unsigned char _InterlockedCompareExchange128(volatile __int64
*dest
, __int64 xchg_high
, __int64 xchg_low
, __int64
*compare
);
6901 #pragma intrinsic(_InterlockedCompareExchange128)
6903 #elif defined(__x86_64__)
6905 static inline unsigned char InterlockedCompareExchange128(__int64
*dest
, __int64 xchg_high
, __int64 xchg_low
, __int64
*compare
)
6908 __asm__
__volatile__( "lock cmpxchg16b %0; setz %b2"
6909 : "=m" (dest
[0]), "=m" (dest
[1]), "=r" (ret
),
6910 "=a" (compare
[0]), "=d" (compare
[1])
6911 : "m" (dest
[0]), "m" (dest
[1]), "3" (compare
[0]), "4" (compare
[1]),
6912 "c" (xchg_high
), "b" (xchg_low
) );
6916 #elif defined(__GNUC__)
6918 static inline unsigned char InterlockedCompareExchange128(__int64
*dest
, __int64 xchg_high
, __int64 xchg_low
, __int64
*compare
)
6920 return __sync_bool_compare_and_swap( (__int128
*)dest
, *(__int128
*)compare
, ((__int128
)xchg_high
<< 64) | xchg_low
);
6931 #endif /* _WINNT_ */