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 defined(WINE_UNICODE_CHAR16)
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 PAGE_NOACCESS 0x01
740 #define PAGE_READONLY 0x02
741 #define PAGE_READWRITE 0x04
742 #define PAGE_WRITECOPY 0x08
743 #define PAGE_EXECUTE 0x10
744 #define PAGE_EXECUTE_READ 0x20
745 #define PAGE_EXECUTE_READWRITE 0x40
746 #define PAGE_EXECUTE_WRITECOPY 0x80
747 #define PAGE_GUARD 0x100
748 #define PAGE_NOCACHE 0x200
749 #define PAGE_WRITECOMBINE 0x400
751 #define MEM_COMMIT 0x00001000
752 #define MEM_RESERVE 0x00002000
753 #define MEM_DECOMMIT 0x00004000
754 #define MEM_RELEASE 0x00008000
755 #define MEM_FREE 0x00010000
756 #define MEM_PRIVATE 0x00020000
757 #define MEM_MAPPED 0x00040000
758 #define MEM_RESET 0x00080000
759 #define MEM_TOP_DOWN 0x00100000
760 #define MEM_WRITE_WATCH 0x00200000
761 #define MEM_PHYSICAL 0x00400000
762 #define MEM_LARGE_PAGES 0x20000000
763 #define MEM_4MB_PAGES 0x80000000
765 #define SEC_FILE 0x00800000
766 #define SEC_IMAGE 0x01000000
767 #define SEC_PROTECTED_IMAGE 0x02000000
768 #define SEC_RESERVE 0x04000000
769 #define SEC_COMMIT 0x08000000
770 #define SEC_NOCACHE 0x10000000
771 #define SEC_WRITECOMBINE 0x40000000
772 #define SEC_LARGE_PAGES 0x80000000
773 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
774 #define MEM_IMAGE SEC_IMAGE
776 #define WRITE_WATCH_FLAG_RESET 0x00000001
778 #define AT_ROUND_TO_PAGE 0x40000000
782 #define MINSHORT 0x8000
783 #define MAXSHORT 0x7fff
784 #define MINLONG 0x80000000
785 #define MAXLONG 0x7fffffff
787 #define MAXWORD 0xffff
788 #define MAXDWORD 0xffffffff
789 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
791 #define UNICODE_STRING_MAX_CHARS 32767
793 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
794 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
795 #define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
797 #define CONTAINING_RECORD(address, type, field) \
798 ((type *)((PCHAR)(address) - offsetof(type, field)))
800 #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
802 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
807 typedef struct _LIST_ENTRY
{
808 struct _LIST_ENTRY
*Flink
;
809 struct _LIST_ENTRY
*Blink
;
810 } LIST_ENTRY
, *PLIST_ENTRY
, * RESTRICTED_POINTER PRLIST_ENTRY
;
812 typedef struct _SINGLE_LIST_ENTRY
{
813 struct _SINGLE_LIST_ENTRY
*Next
;
814 } SINGLE_LIST_ENTRY
, *PSINGLE_LIST_ENTRY
;
818 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
{
819 struct _SLIST_ENTRY
*Next
;
820 } SLIST_ENTRY
, *PSLIST_ENTRY
;
822 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
{
829 ULONGLONG Sequence
:9;
830 ULONGLONG NextEntry
:39;
831 ULONGLONG HeaderType
:1;
833 ULONGLONG Reserved
:59;
838 ULONGLONG Sequence
:48;
839 ULONGLONG HeaderType
:1;
841 ULONGLONG Reserved
:2;
842 ULONGLONG NextEntry
:60;
844 } SLIST_HEADER
, *PSLIST_HEADER
;
848 #undef SLIST_ENTRY /* for Mac OS */
849 #define SLIST_ENTRY SINGLE_LIST_ENTRY
850 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
851 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
853 typedef union _SLIST_HEADER
{
860 } SLIST_HEADER
, *PSLIST_HEADER
;
864 NTSYSAPI PSLIST_ENTRY WINAPI
RtlFirstEntrySList(const SLIST_HEADER
*);
865 NTSYSAPI VOID WINAPI
RtlInitializeSListHead(PSLIST_HEADER
);
866 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedFlushSList(PSLIST_HEADER
);
867 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedPopEntrySList(PSLIST_HEADER
);
868 NTSYSAPI PSLIST_ENTRY WINAPI
RtlInterlockedPushEntrySList(PSLIST_HEADER
, PSLIST_ENTRY
);
869 NTSYSAPI WORD WINAPI
RtlQueryDepthSList(PSLIST_HEADER
);
874 #define HEAP_NO_SERIALIZE 0x00000001
875 #define HEAP_GROWABLE 0x00000002
876 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
877 #define HEAP_ZERO_MEMORY 0x00000008
878 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
879 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
880 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
881 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
882 #define HEAP_CREATE_ALIGN_16 0x00010000
883 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
884 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
886 /* This flag allows it to create heaps shared by all processes under win95,
887 FIXME: correct name */
888 #define HEAP_SHARED 0x04000000
890 typedef enum _HEAP_INFORMATION_CLASS
{
891 HeapCompatibilityInformation
,
892 } HEAP_INFORMATION_CLASS
;
894 /* Processor feature flags. */
895 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
896 #define PF_FLOATING_POINT_EMULATED 1
897 #define PF_COMPARE_EXCHANGE_DOUBLE 2
898 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
899 #define PF_PPC_MOVEMEM_64BIT_OK 4
900 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
901 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
902 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
903 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
904 #define PF_PAE_ENABLED 9
905 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
906 #define PF_SSE_DAZ_MODE_AVAILABLE 11
907 #define PF_NX_ENABLED 12
908 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
909 #define PF_COMPARE_EXCHANGE128 14
910 #define PF_COMPARE64_EXCHANGE128 15
911 #define PF_CHANNELS_ENABLED 16
912 #define PF_XSAVE_ENABLED 17
913 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
914 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
915 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
916 #define PF_VIRT_FIRMWARE_ENABLED 21
917 #define PF_RDWRFSGSBASE_AVAILABLE 22
918 #define PF_FASTFAIL_AVAILABLE 23
919 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
920 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
921 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
922 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
923 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
924 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
925 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
926 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
927 #define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
928 #define PF_RDPID_INSTRUCTION_AVAILABLE 33
929 #define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
930 #define PF_MONITORX_INSTRUCTION_AVAILABLE 35
933 /* Execution state flags */
934 #define ES_SYSTEM_REQUIRED 0x00000001
935 #define ES_DISPLAY_REQUIRED 0x00000002
936 #define ES_USER_PRESENT 0x00000004
937 #define ES_CONTINUOUS 0x80000000
942 struct _EXCEPTION_POINTERS
;
943 struct _EXCEPTION_RECORD
;
945 typedef EXCEPTION_DISPOSITION WINAPI
EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD
*,PVOID
,
946 struct _CONTEXT
*,PVOID
);
947 typedef EXCEPTION_ROUTINE
*PEXCEPTION_ROUTINE
;
949 /* The Win32 register context */
951 /* i386 context definitions */
954 #define SIZE_OF_80387_REGISTERS 80
956 typedef struct _FLOATING_SAVE_AREA
965 BYTE RegisterArea
[SIZE_OF_80387_REGISTERS
];
967 } FLOATING_SAVE_AREA
, *PFLOATING_SAVE_AREA
;
969 #define MAXIMUM_SUPPORTED_EXTENSION 512
971 typedef struct _CONTEXT
973 DWORD ContextFlags
; /* 000 */
975 /* These are selected by CONTEXT_DEBUG_REGISTERS */
983 /* These are selected by CONTEXT_FLOATING_POINT */
984 FLOATING_SAVE_AREA FloatSave
; /* 01c */
986 /* These are selected by CONTEXT_SEGMENTS */
987 DWORD SegGs
; /* 08c */
988 DWORD SegFs
; /* 090 */
989 DWORD SegEs
; /* 094 */
990 DWORD SegDs
; /* 098 */
992 /* These are selected by CONTEXT_INTEGER */
1000 /* These are selected by CONTEXT_CONTROL */
1001 DWORD Ebp
; /* 0b4 */
1002 DWORD Eip
; /* 0b8 */
1003 DWORD SegCs
; /* 0bc */
1004 DWORD EFlags
; /* 0c0 */
1005 DWORD Esp
; /* 0c4 */
1006 DWORD SegSs
; /* 0c8 */
1008 BYTE ExtendedRegisters
[MAXIMUM_SUPPORTED_EXTENSION
]; /* 0xcc */
1009 } CONTEXT
, *PCONTEXT
;
1011 #define CONTEXT_X86 0x00010000
1012 #define CONTEXT_i386 CONTEXT_X86
1013 #define CONTEXT_i486 CONTEXT_X86
1015 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1016 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1017 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1018 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1019 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1020 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1021 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x0040)
1022 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
1023 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
1024 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
1026 #define EXCEPTION_READ_FAULT 0
1027 #define EXCEPTION_WRITE_FAULT 1
1028 #define EXCEPTION_EXECUTE_FAULT 8
1030 #endif /* __i386__ */
1032 typedef struct _LDT_ENTRY
{
1043 unsigned BaseMid
: 8;
1047 unsigned LimitHi
: 4;
1049 unsigned Reserved_0
: 1;
1050 unsigned Default_Big
: 1;
1051 unsigned Granularity
: 1;
1052 unsigned BaseHi
: 8;
1055 } LDT_ENTRY
, *PLDT_ENTRY
, WOW64_LDT_ENTRY
, *PWOW64_LDT_ENTRY
;
1057 /* x86-64 context definitions */
1058 #if defined(__x86_64__)
1060 #define CONTEXT_AMD64 0x00100000
1062 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
1063 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
1064 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1065 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1066 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1067 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x0040)
1068 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1069 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1071 #define EXCEPTION_READ_FAULT 0
1072 #define EXCEPTION_WRITE_FAULT 1
1073 #define EXCEPTION_EXECUTE_FAULT 8
1075 typedef struct DECLSPEC_ALIGN(16) _M128A
{
1080 typedef struct _XMM_SAVE_AREA32
{
1081 WORD ControlWord
; /* 000 */
1082 WORD StatusWord
; /* 002 */
1083 BYTE TagWord
; /* 004 */
1084 BYTE Reserved1
; /* 005 */
1085 WORD ErrorOpcode
; /* 006 */
1086 DWORD ErrorOffset
; /* 008 */
1087 WORD ErrorSelector
; /* 00c */
1088 WORD Reserved2
; /* 00e */
1089 DWORD DataOffset
; /* 010 */
1090 WORD DataSelector
; /* 014 */
1091 WORD Reserved3
; /* 016 */
1092 DWORD MxCsr
; /* 018 */
1093 DWORD MxCsr_Mask
; /* 01c */
1094 M128A FloatRegisters
[8]; /* 020 */
1095 M128A XmmRegisters
[16]; /* 0a0 */
1096 BYTE Reserved4
[96]; /* 1a0 */
1097 } XMM_SAVE_AREA32
, *PXMM_SAVE_AREA32
;
1099 typedef struct DECLSPEC_ALIGN(16) _CONTEXT
{
1100 DWORD64 P1Home
; /* 000 */
1101 DWORD64 P2Home
; /* 008 */
1102 DWORD64 P3Home
; /* 010 */
1103 DWORD64 P4Home
; /* 018 */
1104 DWORD64 P5Home
; /* 020 */
1105 DWORD64 P6Home
; /* 028 */
1108 DWORD ContextFlags
; /* 030 */
1109 DWORD MxCsr
; /* 034 */
1112 WORD SegCs
; /* 038 */
1113 WORD SegDs
; /* 03a */
1114 WORD SegEs
; /* 03c */
1115 WORD SegFs
; /* 03e */
1116 WORD SegGs
; /* 040 */
1117 WORD SegSs
; /* 042 */
1118 DWORD EFlags
; /* 044 */
1121 DWORD64 Dr0
; /* 048 */
1122 DWORD64 Dr1
; /* 050 */
1123 DWORD64 Dr2
; /* 058 */
1124 DWORD64 Dr3
; /* 060 */
1125 DWORD64 Dr6
; /* 068 */
1126 DWORD64 Dr7
; /* 070 */
1129 DWORD64 Rax
; /* 078 */
1130 DWORD64 Rcx
; /* 080 */
1131 DWORD64 Rdx
; /* 088 */
1132 DWORD64 Rbx
; /* 090 */
1133 DWORD64 Rsp
; /* 098 */
1134 DWORD64 Rbp
; /* 0a0 */
1135 DWORD64 Rsi
; /* 0a8 */
1136 DWORD64 Rdi
; /* 0b0 */
1137 DWORD64 R8
; /* 0b8 */
1138 DWORD64 R9
; /* 0c0 */
1139 DWORD64 R10
; /* 0c8 */
1140 DWORD64 R11
; /* 0d0 */
1141 DWORD64 R12
; /* 0d8 */
1142 DWORD64 R13
; /* 0e0 */
1143 DWORD64 R14
; /* 0e8 */
1144 DWORD64 R15
; /* 0f0 */
1147 DWORD64 Rip
; /* 0f8 */
1149 /* Floating point */
1151 XMM_SAVE_AREA32 FltSave
; /* 100 */
1153 M128A Header
[2]; /* 100 */
1154 M128A Legacy
[8]; /* 120 */
1155 M128A Xmm0
; /* 1a0 */
1156 M128A Xmm1
; /* 1b0 */
1157 M128A Xmm2
; /* 1c0 */
1158 M128A Xmm3
; /* 1d0 */
1159 M128A Xmm4
; /* 1e0 */
1160 M128A Xmm5
; /* 1f0 */
1161 M128A Xmm6
; /* 200 */
1162 M128A Xmm7
; /* 210 */
1163 M128A Xmm8
; /* 220 */
1164 M128A Xmm9
; /* 230 */
1165 M128A Xmm10
; /* 240 */
1166 M128A Xmm11
; /* 250 */
1167 M128A Xmm12
; /* 260 */
1168 M128A Xmm13
; /* 270 */
1169 M128A Xmm14
; /* 280 */
1170 M128A Xmm15
; /* 290 */
1175 M128A VectorRegister
[26]; /* 300 */
1176 DWORD64 VectorControl
; /* 4a0 */
1179 DWORD64 DebugControl
; /* 4a8 */
1180 DWORD64 LastBranchToRip
; /* 4b0 */
1181 DWORD64 LastBranchFromRip
; /* 4b8 */
1182 DWORD64 LastExceptionToRip
; /* 4c0 */
1183 DWORD64 LastExceptionFromRip
; /* 4c8 */
1184 } CONTEXT
, *PCONTEXT
;
1186 typedef struct _RUNTIME_FUNCTION
1191 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1193 #define UNWIND_HISTORY_TABLE_SIZE 12
1195 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1198 PRUNTIME_FUNCTION FunctionEntry
;
1199 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1201 #define UNWIND_HISTORY_TABLE_NONE 0
1202 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1203 #define UNWIND_HISTORY_TABLE_LOCAL 2
1205 typedef struct _UNWIND_HISTORY_TABLE
1210 ULONG64 HighAddress
;
1211 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1212 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1214 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1218 PM128A FloatingContext
[16];
1242 PULONG64 IntegerContext
[16];
1263 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1265 typedef struct _DISPATCHER_CONTEXT
1269 PRUNTIME_FUNCTION FunctionEntry
;
1270 ULONG64 EstablisherFrame
;
1272 PCONTEXT ContextRecord
;
1273 PEXCEPTION_ROUTINE LanguageHandler
;
1275 PUNWIND_HISTORY_TABLE HistoryTable
;
1278 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1280 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,PVOID
);
1281 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,PVOID
);
1283 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(ULONG
,ULONG64
,ULONG64
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,ULONG64
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1285 #define UNW_FLAG_NHANDLER 0
1286 #define UNW_FLAG_EHANDLER 1
1287 #define UNW_FLAG_UHANDLER 2
1288 #define UNW_FLAG_CHAININFO 4
1290 #endif /* __x86_64__ */
1292 /* IA64 context definitions */
1295 #define CONTEXT_IA64 0x00080000
1296 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1297 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1298 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1299 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1300 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1301 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1302 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1303 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1304 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1306 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1307 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1308 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1309 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1311 typedef struct _CONTEXT
1506 ULONGLONG RsBSPSTORE
;
1520 ULONGLONG UNUSEDPACK
;
1521 } CONTEXT
, *PCONTEXT
;
1523 typedef struct _RUNTIME_FUNCTION
1527 ULONG UnwindInfoAddress
;
1528 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1530 typedef struct _FRAME_POINTERS
{
1531 ULONGLONG MemoryStackFp
;
1532 ULONGLONG BackingStoreFp
;
1533 } FRAME_POINTERS
, *PFRAME_POINTERS
;
1535 #define UNWIND_HISTORY_TABLE_SIZE 12
1537 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
{
1540 PRUNTIME_FUNCTION FunctionEntry
;
1541 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1543 typedef struct _UNWIND_HISTORY_TABLE
{
1547 ULONG64 HighAddress
;
1548 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1549 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1551 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1557 PFLOAT128 HighFloatingContext
[10];
1579 PULONGLONG IntS0Nat
;
1580 PULONGLONG IntS1Nat
;
1581 PULONGLONG IntS2Nat
;
1582 PULONGLONG IntS3Nat
;
1583 PULONGLONG IntSpNat
;
1599 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1601 NTSYSAPI ULONGLONG WINAPI
RtlVirtualUnwind(ULONGLONG
,ULONGLONG
,RUNTIME_FUNCTION
*,CONTEXT
*,BOOLEAN
*,FRAME_POINTERS
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1603 #endif /* __ia64__ */
1605 /* Alpha context definitions */
1606 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1608 #define CONTEXT_ALPHA 0x00020000
1610 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1611 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1612 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1613 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1615 #define EXCEPTION_READ_FAULT 0
1616 #define EXCEPTION_WRITE_FAULT 1
1617 #define EXCEPTION_EXECUTE_FAULT 8
1619 typedef struct _CONTEXT
1621 /* selected by CONTEXT_FLOATING_POINT */
1655 /* selected by CONTEXT_INTEGER */
1689 /* selected by CONTEXT_FLOATING_POINT */
1693 /* selected by CONTEXT_CONTROL */
1698 } CONTEXT
, *PCONTEXT
;
1700 #define _QUAD_PSR_OFFSET HighSoftFpcr
1701 #define _QUAD_FLAGS_OFFSET HighFir
1703 #endif /* _ALPHA_ */
1707 /* The following flags control the contents of the CONTEXT structure. */
1709 #define CONTEXT_ARM 0x0200000
1710 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1711 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1712 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1713 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1715 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1716 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1718 #define EXCEPTION_READ_FAULT 0
1719 #define EXCEPTION_WRITE_FAULT 1
1720 #define EXCEPTION_EXECUTE_FAULT 8
1722 #define ARM_MAX_BREAKPOINTS 8
1723 #define ARM_MAX_WATCHPOINTS 1
1725 typedef struct _RUNTIME_FUNCTION
1732 DWORD FunctionLength
: 11;
1739 DWORD StackAdjust
: 10;
1742 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1744 #define UNWIND_HISTORY_TABLE_SIZE 12
1746 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1749 PRUNTIME_FUNCTION FunctionEntry
;
1750 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1752 typedef struct _UNWIND_HISTORY_TABLE
1761 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1762 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1764 typedef struct _NEON128
1768 } NEON128
, *PNEON128
;
1770 typedef struct _CONTEXT
1772 ULONG ContextFlags
; /* 000 */
1773 /* CONTEXT_INTEGER */
1784 ULONG R10
; /* 02c */
1785 ULONG R11
; /* 030 */
1786 ULONG R12
; /* 034 */
1787 /* CONTEXT_CONTROL */
1791 ULONG Cpsr
; /* 044 */
1792 /* CONTEXT_FLOATING_POINT */
1793 ULONG Fpscr
; /* 048 */
1794 ULONG Padding
; /* 04c */
1800 } DUMMYUNIONNAME
; /* 050 */
1801 /* CONTEXT_DEBUG_REGISTERS */
1802 ULONG Bvr
[ARM_MAX_BREAKPOINTS
]; /* 150 */
1803 ULONG Bcr
[ARM_MAX_BREAKPOINTS
]; /* 170 */
1804 ULONG Wvr
[ARM_MAX_WATCHPOINTS
]; /* 190 */
1805 ULONG Wcr
[ARM_MAX_WATCHPOINTS
]; /* 194 */
1806 ULONG Padding2
[2]; /* 198 */
1807 } CONTEXT
, *PCONTEXT
;
1809 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1828 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
1830 typedef struct _DISPATCHER_CONTEXT
1834 PRUNTIME_FUNCTION FunctionEntry
;
1835 DWORD EstablisherFrame
;
1837 PCONTEXT ContextRecord
;
1838 PEXCEPTION_ROUTINE LanguageHandler
;
1840 PUNWIND_HISTORY_TABLE HistoryTable
;
1842 BOOLEAN ControlPcIsUnwound
;
1843 PBYTE NonVolatileRegisters
;
1845 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
1847 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD
);
1848 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD
);
1850 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,DWORD
,DWORD
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,DWORD
*,KNONVOLATILE_CONTEXT_POINTERS
*);
1852 #define UNW_FLAG_NHANDLER 0
1853 #define UNW_FLAG_EHANDLER 1
1854 #define UNW_FLAG_UHANDLER 2
1856 #endif /* __arm__ */
1860 #define CONTEXT_ARM64 0x400000
1861 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1862 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1863 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1864 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1866 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1868 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1869 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1871 #define EXCEPTION_READ_FAULT 0
1872 #define EXCEPTION_WRITE_FAULT 1
1873 #define EXCEPTION_EXECUTE_FAULT 8
1875 #define ARM64_MAX_BREAKPOINTS 8
1876 #define ARM64_MAX_WATCHPOINTS 2
1878 typedef struct _RUNTIME_FUNCTION
1887 DWORD FunctionLength
: 11;
1892 DWORD FrameSize
: 9;
1895 } RUNTIME_FUNCTION
, *PRUNTIME_FUNCTION
;
1897 #define UNWIND_HISTORY_TABLE_SIZE 12
1899 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1902 PRUNTIME_FUNCTION FunctionEntry
;
1903 } UNWIND_HISTORY_TABLE_ENTRY
, *PUNWIND_HISTORY_TABLE_ENTRY
;
1905 typedef struct _UNWIND_HISTORY_TABLE
1913 DWORD64 HighAddress
;
1914 UNWIND_HISTORY_TABLE_ENTRY Entry
[UNWIND_HISTORY_TABLE_SIZE
];
1915 } UNWIND_HISTORY_TABLE
, *PUNWIND_HISTORY_TABLE
;
1917 typedef union _NEON128
1928 } NEON128
, *PNEON128
;
1930 typedef struct _CONTEXT
1932 ULONG ContextFlags
; /* 000 */
1933 /* CONTEXT_INTEGER */
1934 ULONG Cpsr
; /* 004 */
1939 DWORD64 X0
; /* 008 */
1940 DWORD64 X1
; /* 010 */
1941 DWORD64 X2
; /* 018 */
1942 DWORD64 X3
; /* 020 */
1943 DWORD64 X4
; /* 028 */
1944 DWORD64 X5
; /* 030 */
1945 DWORD64 X6
; /* 038 */
1946 DWORD64 X7
; /* 040 */
1947 DWORD64 X8
; /* 048 */
1948 DWORD64 X9
; /* 050 */
1949 DWORD64 X10
; /* 058 */
1950 DWORD64 X11
; /* 060 */
1951 DWORD64 X12
; /* 068 */
1952 DWORD64 X13
; /* 070 */
1953 DWORD64 X14
; /* 078 */
1954 DWORD64 X15
; /* 080 */
1955 DWORD64 X16
; /* 088 */
1956 DWORD64 X17
; /* 090 */
1957 DWORD64 X18
; /* 098 */
1958 DWORD64 X19
; /* 0a0 */
1959 DWORD64 X20
; /* 0a8 */
1960 DWORD64 X21
; /* 0b0 */
1961 DWORD64 X22
; /* 0b8 */
1962 DWORD64 X23
; /* 0c0 */
1963 DWORD64 X24
; /* 0c8 */
1964 DWORD64 X25
; /* 0d0 */
1965 DWORD64 X26
; /* 0d8 */
1966 DWORD64 X27
; /* 0e0 */
1967 DWORD64 X28
; /* 0e8 */
1968 DWORD64 Fp
; /* 0f0 */
1969 DWORD64 Lr
; /* 0f8 */
1971 DWORD64 X
[31]; /* 008 */
1973 /* CONTEXT_CONTROL */
1974 DWORD64 Sp
; /* 100 */
1975 DWORD64 Pc
; /* 108 */
1976 /* CONTEXT_FLOATING_POINT */
1977 NEON128 V
[32]; /* 110 */
1978 DWORD Fpcr
; /* 310 */
1979 DWORD Fpsr
; /* 314 */
1980 /* CONTEXT_DEBUG_REGISTERS */
1981 DWORD Bcr
[ARM64_MAX_BREAKPOINTS
]; /* 318 */
1982 DWORD64 Bvr
[ARM64_MAX_BREAKPOINTS
]; /* 338 */
1983 DWORD Wcr
[ARM64_MAX_WATCHPOINTS
]; /* 378 */
1984 DWORD64 Wvr
[ARM64_MAX_WATCHPOINTS
]; /* 380 */
1985 } CONTEXT
, *PCONTEXT
;
1987 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
2009 } KNONVOLATILE_CONTEXT_POINTERS
, *PKNONVOLATILE_CONTEXT_POINTERS
;
2011 typedef struct _DISPATCHER_CONTEXT
2013 ULONG_PTR ControlPc
;
2014 ULONG_PTR ImageBase
;
2015 PRUNTIME_FUNCTION FunctionEntry
;
2016 ULONG_PTR EstablisherFrame
;
2018 PCONTEXT ContextRecord
;
2019 PEXCEPTION_ROUTINE LanguageHandler
;
2021 PUNWIND_HISTORY_TABLE HistoryTable
;
2023 BOOLEAN ControlPcIsUnwound
;
2024 PBYTE NonVolatileRegisters
;
2025 } DISPATCHER_CONTEXT
, *PDISPATCHER_CONTEXT
;
2027 typedef LONG (CALLBACK
*PEXCEPTION_FILTER
)(struct _EXCEPTION_POINTERS
*,DWORD64
);
2028 typedef void (CALLBACK
*PTERMINATION_HANDLER
)(BOOLEAN
,DWORD64
);
2030 NTSYSAPI PVOID WINAPI
RtlVirtualUnwind(DWORD
,ULONG_PTR
,ULONG_PTR
,RUNTIME_FUNCTION
*,CONTEXT
*,PVOID
*,ULONG_PTR
*,KNONVOLATILE_CONTEXT_POINTERS
*);
2032 #define UNW_FLAG_NHANDLER 0
2033 #define UNW_FLAG_EHANDLER 1
2034 #define UNW_FLAG_UHANDLER 2
2036 #endif /* __aarch64__ */
2039 /* Mips context definitions */
2040 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
2042 #define CONTEXT_R4000 0x00010000
2044 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
2045 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
2046 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
2048 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2050 #define EXCEPTION_READ_FAULT 0
2051 #define EXCEPTION_WRITE_FAULT 1
2052 #define EXCEPTION_EXECUTE_FAULT 8
2054 typedef struct _CONTEXT
2057 /* These are selected by CONTEXT_FLOATING_POINT */
2091 /* These are selected by CONTEXT_INTEGER */
2127 /* These are selected by CONTEXT_FLOATING_POINT */
2130 /* These are selected by CONTEXT_CONTROL */
2140 /* PowerPC context definitions */
2143 #define CONTEXT_CONTROL 0x0001
2144 #define CONTEXT_FLOATING_POINT 0x0002
2145 #define CONTEXT_INTEGER 0x0004
2146 #define CONTEXT_DEBUG_REGISTERS 0x0008
2147 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2149 #define EXCEPTION_READ_FAULT 0
2150 #define EXCEPTION_WRITE_FAULT 1
2151 #define EXCEPTION_EXECUTE_FAULT 8
2155 /* These are selected by CONTEXT_FLOATING_POINT */
2190 /* These are selected by CONTEXT_INTEGER */
2227 /* These are selected by CONTEXT_CONTROL */
2229 DWORD Iar
; /* Instruction Address Register , aka PC ... */
2235 DWORD Dar
; /* Fault registers for coredump */
2237 DWORD Trap
; /* number of powerpc exception taken */
2239 /* These are selected by CONTEXT_DEBUG_REGISTERS */
2250 typedef struct _STACK_FRAME_HEADER
2267 } STACK_FRAME_HEADER
,*PSTACK_FRAME_HEADER
;
2269 #endif /* __powerpc__ */
2271 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2272 #error You need to define a CONTEXT for your CPU
2275 NTSYSAPI
void WINAPI
RtlCaptureContext(CONTEXT
*);
2277 #define WOW64_CONTEXT_i386 0x00010000
2278 #define WOW64_CONTEXT_i486 0x00010000
2279 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
2280 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
2281 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
2282 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
2283 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
2284 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
2285 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2286 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
2287 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
2288 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
2289 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
2291 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2293 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
2294 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
2295 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
2296 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
2298 #define WOW64_SIZE_OF_80387_REGISTERS 80
2299 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
2301 typedef struct _WOW64_FLOATING_SAVE_AREA
2307 DWORD ErrorSelector
;
2310 BYTE RegisterArea
[WOW64_SIZE_OF_80387_REGISTERS
];
2312 } WOW64_FLOATING_SAVE_AREA
, *PWOW64_FLOATING_SAVE_AREA
;
2314 #include "pshpack4.h"
2315 typedef struct _WOW64_CONTEXT
2324 WOW64_FLOATING_SAVE_AREA FloatSave
;
2341 BYTE ExtendedRegisters
[WOW64_MAXIMUM_SUPPORTED_EXTENSION
];
2342 } WOW64_CONTEXT
, *PWOW64_CONTEXT
;
2343 #include "poppack.h"
2345 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
2347 typedef PRUNTIME_FUNCTION (CALLBACK
*PGET_RUNTIME_FUNCTION_CALLBACK
)(DWORD_PTR
,PVOID
);
2349 NTSYSAPI BOOLEAN CDECL
RtlAddFunctionTable(RUNTIME_FUNCTION
*,DWORD
,DWORD_PTR
);
2350 NTSYSAPI DWORD WINAPI
RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION
,DWORD
,DWORD
,ULONG_PTR
,ULONG_PTR
);
2351 NTSYSAPI BOOLEAN CDECL
RtlDeleteFunctionTable(RUNTIME_FUNCTION
*);
2352 NTSYSAPI
void WINAPI
RtlDeleteGrowableFunctionTable(void*);
2353 NTSYSAPI
void WINAPI
RtlGrowFunctionTable(void*,DWORD
);
2354 NTSYSAPI BOOLEAN CDECL
RtlInstallFunctionTableCallback(DWORD_PTR
,DWORD_PTR
,DWORD
,PGET_RUNTIME_FUNCTION_CALLBACK
,PVOID
,PCWSTR
);
2355 NTSYSAPI PRUNTIME_FUNCTION WINAPI
RtlLookupFunctionEntry(DWORD_PTR
,DWORD_PTR
*,UNWIND_HISTORY_TABLE
*);
2356 NTSYSAPI
void WINAPI
RtlUnwindEx(PVOID
,PVOID
,struct _EXCEPTION_RECORD
*,PVOID
,CONTEXT
*,UNWIND_HISTORY_TABLE
*);
2362 #define PRODUCT_UNDEFINED 0x00000000
2363 #define PRODUCT_ULTIMATE 0x00000001
2364 #define PRODUCT_HOME_BASIC 0x00000002
2365 #define PRODUCT_HOME_PREMIUM 0x00000003
2366 #define PRODUCT_ENTERPRISE 0x00000004
2367 #define PRODUCT_HOME_BASIC_N 0x00000005
2368 #define PRODUCT_BUSINESS 0x00000006
2369 #define PRODUCT_STANDARD_SERVER 0x00000007
2370 #define PRODUCT_DATACENTER_SERVER 0x00000008
2371 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2372 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2373 #define PRODUCT_STARTER 0x0000000B
2374 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2375 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2376 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2377 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2378 #define PRODUCT_BUSINESS_N 0x00000010
2379 #define PRODUCT_WEB_SERVER 0x00000011
2380 #define PRODUCT_CLUSTER_SERVER 0x00000012
2381 #define PRODUCT_HOME_SERVER 0x00000013
2382 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2383 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2384 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2385 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2386 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2387 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2388 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2389 #define PRODUCT_ENTERPRISE_N 0x0000001B
2390 #define PRODUCT_ULTIMATE_N 0x0000001C
2391 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2392 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2393 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2394 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2395 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2396 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2397 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2398 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2399 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2400 #define PRODUCT_SERVER_V 0x00000025
2401 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2402 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2403 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2404 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2405 #define PRODUCT_HYPERV 0x0000002A
2406 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2407 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2408 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2409 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2410 #define PRODUCT_STARTER_N 0x0000002F
2411 #define PRODUCT_PROFESSIONAL 0x00000030
2412 #define PRODUCT_PROFESSIONAL_N 0x00000031
2413 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2414 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2415 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2416 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2417 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2418 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2419 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2420 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2421 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2422 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2423 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2424 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2425 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2426 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2427 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2428 #define PRODUCT_EMBEDDED 0x00000041
2429 #define PRODUCT_STARTER_E 0x00000042
2430 #define PRODUCT_HOME_BASIC_E 0x00000043
2431 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2432 #define PRODUCT_PROFESSIONAL_E 0x00000045
2433 #define PRODUCT_ENTERPRISE_E 0x00000046
2434 #define PRODUCT_ULTIMATE_E 0x00000047
2435 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2436 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2437 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2438 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2439 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2440 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2441 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2442 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2443 #define PRODUCT_THINPC 0x00000057
2444 #define PRODUCT_EMBEDDED_A 0x00000058
2445 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2446 #define PRODUCT_EMBEDDED_E 0x0000005A
2447 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2448 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2449 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2450 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2451 #define PRODUCT_CORE_ARM 0x00000061
2452 #define PRODUCT_CORE_N 0x00000062
2453 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2454 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2455 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2456 #define PRODUCT_CORE 0x00000065
2457 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2458 #define PRODUCT_MOBILE_CORE 0x00000068
2459 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2460 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2461 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2462 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2463 #define PRODUCT_NANO_SERVER 0x0000006D
2464 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2465 #define PRODUCT_CORE_CONNECTED 0x0000006F
2466 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2467 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2468 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2469 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2470 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2471 #define PRODUCT_CONNECTED_CAR 0x00000075
2472 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2473 #define PRODUCT_PPI_PRO 0x00000077
2474 #define PRODUCT_ARM64_SERVER 0x00000078
2475 #define PRODUCT_EDUCATION 0x00000079
2476 #define PRODUCT_EDUCATION_N 0x0000007A
2477 #define PRODUCT_IOTUAP 0x0000007B
2478 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2479 #define PRODUCT_ENTERPRISE_S 0x0000007D
2480 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2481 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2482 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2483 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2484 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2485 #define PRODUCT_UNLICENSED 0xABCDABCD
2492 #define MAKELCID(l, s) (MAKELONG(l, s))
2494 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2495 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2496 #define SUBLANGID(l) ((WORD)(l) >> 10)
2498 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2499 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2501 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2502 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2503 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2504 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2505 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2506 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2507 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2508 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2509 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2510 #define LOCALE_NAME_MAX_LENGTH 85
2513 #define UNREFERENCED_PARAMETER(u) (void)(u)
2514 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2515 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2521 * Definitions for IsTextUnicode()
2524 #define IS_TEXT_UNICODE_ASCII16 0x0001
2525 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2526 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2527 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2528 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2529 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2530 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2531 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2532 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2533 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2534 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2535 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2536 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2537 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2538 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2539 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2541 #define MAXIMUM_WAIT_OBJECTS 64
2542 #define MAXIMUM_SUSPEND_COUNT 127
2544 #define WT_EXECUTEDEFAULT 0x00
2545 #define WT_EXECUTEINIOTHREAD 0x01
2546 #define WT_EXECUTEINUITHREAD 0x02
2547 #define WT_EXECUTEINWAITTHREAD 0x04
2548 #define WT_EXECUTEONLYONCE 0x08
2549 #define WT_EXECUTELONGFUNCTION 0x10
2550 #define WT_EXECUTEINTIMERTHREAD 0x20
2551 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2552 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2553 #define WT_EXECUTEINLONGTHREAD 0x10
2554 #define WT_EXECUTEDELETEWAIT 0x08
2555 #define WT_TRANSFER_IMPERSONATION 0x0100
2558 #define EXCEPTION_CONTINUABLE 0
2559 #define EXCEPTION_NONCONTINUABLE 0x01
2562 * The exception record used by Win32 to give additional information
2563 * about exception to exception handlers.
2566 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2568 typedef struct _EXCEPTION_RECORD
2570 DWORD ExceptionCode
;
2571 DWORD ExceptionFlags
;
2572 struct _EXCEPTION_RECORD
*ExceptionRecord
;
2574 PVOID ExceptionAddress
;
2575 DWORD NumberParameters
;
2576 ULONG_PTR ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2577 } EXCEPTION_RECORD
, *PEXCEPTION_RECORD
;
2579 typedef struct _EXCEPTION_RECORD32
2581 DWORD ExceptionCode
;
2582 DWORD ExceptionFlags
;
2583 DWORD ExceptionRecord
;
2584 DWORD ExceptionAddress
;
2585 DWORD NumberParameters
;
2586 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2587 } EXCEPTION_RECORD32
, *PEXCEPTION_RECORD32
;
2589 typedef struct _EXCEPTION_RECORD64
2591 DWORD ExceptionCode
;
2592 DWORD ExceptionFlags
;
2593 DWORD64 ExceptionRecord
;
2594 DWORD64 ExceptionAddress
;
2595 DWORD NumberParameters
;
2596 DWORD __unusedAlignment
;
2597 DWORD64 ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
2598 } EXCEPTION_RECORD64
, *PEXCEPTION_RECORD64
;
2601 * The exception pointers structure passed to exception filters
2602 * in except() and the UnhandledExceptionFilter().
2605 typedef struct _EXCEPTION_POINTERS
2607 PEXCEPTION_RECORD ExceptionRecord
;
2608 PCONTEXT ContextRecord
;
2609 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
;
2613 * The exception frame, used for registering exception handlers
2614 * Win32 cares only about this, but compilers generally emit
2615 * larger exception frames for their own use.
2618 struct _EXCEPTION_REGISTRATION_RECORD
;
2620 typedef DWORD (CDECL
*PEXCEPTION_HANDLER
)(PEXCEPTION_RECORD
,struct _EXCEPTION_REGISTRATION_RECORD
*,
2621 PCONTEXT
,struct _EXCEPTION_REGISTRATION_RECORD
**);
2623 typedef struct _EXCEPTION_REGISTRATION_RECORD
2625 struct _EXCEPTION_REGISTRATION_RECORD
*Prev
;
2626 PEXCEPTION_HANDLER Handler
;
2627 } EXCEPTION_REGISTRATION_RECORD
;
2630 * function pointer to an exception filter
2633 typedef LONG (CALLBACK
*PVECTORED_EXCEPTION_HANDLER
)(PEXCEPTION_POINTERS ExceptionInfo
);
2635 typedef struct _NT_TIB
2637 struct _EXCEPTION_REGISTRATION_RECORD
*ExceptionList
;
2645 PVOID ArbitraryUserPointer
;
2646 struct _NT_TIB
*Self
;
2651 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2652 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2655 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb
));
2658 #elif defined(__i386__) && defined(_MSC_VER)
2659 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2662 __asm mov eax
, fs
:[0x18];
2666 #elif defined(__x86_64__) && defined(__GNUC__)
2667 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2670 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb
));
2673 #elif defined(__x86_64__) && defined(_MSC_VER)
2674 unsigned __int64
__readgsqword(unsigned long);
2675 #pragma intrinsic(__readgsqword)
2676 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2678 return (struct _TEB
*)__readgsqword(FIELD_OFFSET(NT_TIB
, Self
));
2680 #elif defined(__arm__) && defined(__MINGW32__)
2681 static FORCEINLINE
struct _TEB
* WINAPI
NtCurrentTeb(void)
2684 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb
));
2688 extern struct _TEB
* WINAPI
NtCurrentTeb(void);
2691 #ifdef NONAMELESSUNION
2692 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2694 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2696 #define GetFiberData() (*(void **)GetCurrentFiber())
2698 #define TLS_MINIMUM_AVAILABLE 64
2700 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2702 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2703 #define IO_REPARSE_TAG_RESERVED_ONE 1
2704 #define IO_REPARSE_TAG_RESERVED_TWO 2
2706 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2708 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2709 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2710 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2711 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2712 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2713 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2714 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2715 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2716 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2717 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2718 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2719 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2720 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2721 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2722 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2723 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2724 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2725 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2726 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2727 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2728 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2729 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2730 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2731 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2732 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2733 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2734 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2735 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2736 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2737 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2738 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2739 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2740 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2741 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2742 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2743 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2744 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2745 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2746 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2747 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2748 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2749 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2750 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2753 * File formats definitions
2756 #include <pshpack2.h>
2757 typedef struct _IMAGE_DOS_HEADER
{
2758 WORD e_magic
; /* 00: MZ Header signature */
2759 WORD e_cblp
; /* 02: Bytes on last page of file */
2760 WORD e_cp
; /* 04: Pages in file */
2761 WORD e_crlc
; /* 06: Relocations */
2762 WORD e_cparhdr
; /* 08: Size of header in paragraphs */
2763 WORD e_minalloc
; /* 0a: Minimum extra paragraphs needed */
2764 WORD e_maxalloc
; /* 0c: Maximum extra paragraphs needed */
2765 WORD e_ss
; /* 0e: Initial (relative) SS value */
2766 WORD e_sp
; /* 10: Initial SP value */
2767 WORD e_csum
; /* 12: Checksum */
2768 WORD e_ip
; /* 14: Initial IP value */
2769 WORD e_cs
; /* 16: Initial (relative) CS value */
2770 WORD e_lfarlc
; /* 18: File address of relocation table */
2771 WORD e_ovno
; /* 1a: Overlay number */
2772 WORD e_res
[4]; /* 1c: Reserved words */
2773 WORD e_oemid
; /* 24: OEM identifier (for e_oeminfo) */
2774 WORD e_oeminfo
; /* 26: OEM information; e_oemid specific */
2775 WORD e_res2
[10]; /* 28: Reserved words */
2776 DWORD e_lfanew
; /* 3c: Offset to extended header */
2777 } IMAGE_DOS_HEADER
, *PIMAGE_DOS_HEADER
;
2778 #include <poppack.h>
2780 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2781 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2782 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2783 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2784 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2785 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2788 * This is the Windows executable (NE) header.
2789 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2791 #include <pshpack2.h>
2794 WORD ne_magic
; /* 00 NE signature 'NE' */
2795 BYTE ne_ver
; /* 02 Linker version number */
2796 BYTE ne_rev
; /* 03 Linker revision number */
2797 WORD ne_enttab
; /* 04 Offset to entry table relative to NE */
2798 WORD ne_cbenttab
; /* 06 Length of entry table in bytes */
2799 LONG ne_crc
; /* 08 Checksum */
2800 WORD ne_flags
; /* 0c Flags about segments in this file */
2801 WORD ne_autodata
; /* 0e Automatic data segment number */
2802 WORD ne_heap
; /* 10 Initial size of local heap */
2803 WORD ne_stack
; /* 12 Initial size of stack */
2804 DWORD ne_csip
; /* 14 Initial CS:IP */
2805 DWORD ne_sssp
; /* 18 Initial SS:SP */
2806 WORD ne_cseg
; /* 1c # of entries in segment table */
2807 WORD ne_cmod
; /* 1e # of entries in module reference tab. */
2808 WORD ne_cbnrestab
; /* 20 Length of nonresident-name table */
2809 WORD ne_segtab
; /* 22 Offset to segment table */
2810 WORD ne_rsrctab
; /* 24 Offset to resource table */
2811 WORD ne_restab
; /* 26 Offset to resident-name table */
2812 WORD ne_modtab
; /* 28 Offset to module reference table */
2813 WORD ne_imptab
; /* 2a Offset to imported name table */
2814 DWORD ne_nrestab
; /* 2c Offset to nonresident-name table */
2815 WORD ne_cmovent
; /* 30 # of movable entry points */
2816 WORD ne_align
; /* 32 Logical sector alignment shift count */
2817 WORD ne_cres
; /* 34 # of resource segments */
2818 BYTE ne_exetyp
; /* 36 Flags indicating target OS */
2819 BYTE ne_flagsothers
; /* 37 Additional information flags */
2820 WORD ne_pretthunks
; /* 38 Offset to return thunks */
2821 WORD ne_psegrefbytes
; /* 3a Offset to segment ref. bytes */
2822 WORD ne_swaparea
; /* 3c Reserved by Microsoft */
2823 WORD ne_expver
; /* 3e Expected Windows version number */
2824 } IMAGE_OS2_HEADER
, *PIMAGE_OS2_HEADER
;
2825 #include <poppack.h>
2827 #include <pshpack2.h>
2828 typedef struct _IMAGE_VXD_HEADER
{
2843 DWORD e32_lastpagesize
;
2844 DWORD e32_fixupsize
;
2861 DWORD e32_impmodcnt
;
2867 DWORD e32_cbnrestab
;
2870 DWORD e32_debuginfo
;
2872 DWORD e32_instpreload
;
2873 DWORD e32_instdemand
;
2876 DWORD e32_winresoff
;
2877 DWORD e32_winreslen
;
2880 } IMAGE_VXD_HEADER
, *PIMAGE_VXD_HEADER
;
2881 #include <poppack.h>
2883 /* These defines describe the meanings of the bits in the Characteristics
2886 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2887 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2888 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2889 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2890 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2891 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2892 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2893 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2894 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2895 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2896 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2897 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2898 #define IMAGE_FILE_SYSTEM 0x1000
2899 #define IMAGE_FILE_DLL 0x2000
2900 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2901 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2903 /* These are the settings of the Machine field. */
2904 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2905 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
2906 #define IMAGE_FILE_MACHINE_I860 0x014d
2907 #define IMAGE_FILE_MACHINE_I386 0x014c
2908 #define IMAGE_FILE_MACHINE_R3000 0x0162
2909 #define IMAGE_FILE_MACHINE_R4000 0x0166
2910 #define IMAGE_FILE_MACHINE_R10000 0x0168
2911 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2912 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2913 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2914 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2915 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2916 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2917 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2918 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2919 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2920 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2921 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2922 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2923 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2924 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2925 #define IMAGE_FILE_MACHINE_IA64 0x0200
2926 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2927 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2928 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2929 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2930 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2931 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2932 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2933 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2934 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2935 #define IMAGE_FILE_MACHINE_M32R 0x9041
2936 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2938 #define IMAGE_SIZEOF_FILE_HEADER 20
2939 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2940 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2941 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2942 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2943 #define IMAGE_SIZEOF_SHORT_NAME 8
2944 #define IMAGE_SIZEOF_SECTION_HEADER 40
2945 #define IMAGE_SIZEOF_SYMBOL 18
2946 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2947 #define IMAGE_SIZEOF_RELOCATION 10
2948 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2949 #define IMAGE_SIZEOF_LINENUMBER 6
2950 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2952 /* Possible Magic values */
2953 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2954 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2955 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2958 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2959 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2961 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2962 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2965 /* These are indexes into the DataDirectory array */
2966 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2967 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2968 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2969 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2970 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2971 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2972 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2973 #define IMAGE_FILE_DESCRIPTION_STRING 7
2974 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2975 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2976 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2978 /* Directory Entries, indices into the DataDirectory array */
2980 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2981 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2982 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2983 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2984 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2985 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2986 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2987 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2988 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2989 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2990 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2991 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2992 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2993 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2994 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2996 /* Subsystem Values */
2998 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2999 #define IMAGE_SUBSYSTEM_NATIVE 1
3000 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
3001 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
3002 #define IMAGE_SUBSYSTEM_OS2_CUI 5
3003 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
3004 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
3005 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
3006 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
3007 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
3008 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
3009 #define IMAGE_SUBSYSTEM_EFI_ROM 13
3010 #define IMAGE_SUBSYSTEM_XBOX 14
3011 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
3013 /* DLL Characteristics */
3014 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
3015 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
3016 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
3017 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
3018 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
3019 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
3020 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
3021 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
3023 typedef struct _IMAGE_FILE_HEADER
{
3025 WORD NumberOfSections
;
3026 DWORD TimeDateStamp
;
3027 DWORD PointerToSymbolTable
;
3028 DWORD NumberOfSymbols
;
3029 WORD SizeOfOptionalHeader
;
3030 WORD Characteristics
;
3031 } IMAGE_FILE_HEADER
, *PIMAGE_FILE_HEADER
;
3033 typedef struct _IMAGE_DATA_DIRECTORY
{
3034 DWORD VirtualAddress
;
3036 } IMAGE_DATA_DIRECTORY
, *PIMAGE_DATA_DIRECTORY
;
3038 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
3040 typedef struct _IMAGE_OPTIONAL_HEADER64
{
3041 WORD Magic
; /* 0x20b */
3042 BYTE MajorLinkerVersion
;
3043 BYTE MinorLinkerVersion
;
3045 DWORD SizeOfInitializedData
;
3046 DWORD SizeOfUninitializedData
;
3047 DWORD AddressOfEntryPoint
;
3049 ULONGLONG ImageBase
;
3050 DWORD SectionAlignment
;
3051 DWORD FileAlignment
;
3052 WORD MajorOperatingSystemVersion
;
3053 WORD MinorOperatingSystemVersion
;
3054 WORD MajorImageVersion
;
3055 WORD MinorImageVersion
;
3056 WORD MajorSubsystemVersion
;
3057 WORD MinorSubsystemVersion
;
3058 DWORD Win32VersionValue
;
3060 DWORD SizeOfHeaders
;
3063 WORD DllCharacteristics
;
3064 ULONGLONG SizeOfStackReserve
;
3065 ULONGLONG SizeOfStackCommit
;
3066 ULONGLONG SizeOfHeapReserve
;
3067 ULONGLONG SizeOfHeapCommit
;
3069 DWORD NumberOfRvaAndSizes
;
3070 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
];
3071 } IMAGE_OPTIONAL_HEADER64
, *PIMAGE_OPTIONAL_HEADER64
;
3073 typedef struct _IMAGE_NT_HEADERS64
{
3075 IMAGE_FILE_HEADER FileHeader
;
3076 IMAGE_OPTIONAL_HEADER64 OptionalHeader
;
3077 } IMAGE_NT_HEADERS64
, *PIMAGE_NT_HEADERS64
;
3079 typedef struct _IMAGE_OPTIONAL_HEADER
{
3081 /* Standard fields */
3083 WORD Magic
; /* 0x10b or 0x107 */ /* 0x00 */
3084 BYTE MajorLinkerVersion
;
3085 BYTE MinorLinkerVersion
;
3087 DWORD SizeOfInitializedData
;
3088 DWORD SizeOfUninitializedData
;
3089 DWORD AddressOfEntryPoint
; /* 0x10 */
3093 /* NT additional fields */
3096 DWORD SectionAlignment
; /* 0x20 */
3097 DWORD FileAlignment
;
3098 WORD MajorOperatingSystemVersion
;
3099 WORD MinorOperatingSystemVersion
;
3100 WORD MajorImageVersion
;
3101 WORD MinorImageVersion
;
3102 WORD MajorSubsystemVersion
; /* 0x30 */
3103 WORD MinorSubsystemVersion
;
3104 DWORD Win32VersionValue
;
3106 DWORD SizeOfHeaders
;
3107 DWORD CheckSum
; /* 0x40 */
3109 WORD DllCharacteristics
;
3110 DWORD SizeOfStackReserve
;
3111 DWORD SizeOfStackCommit
;
3112 DWORD SizeOfHeapReserve
; /* 0x50 */
3113 DWORD SizeOfHeapCommit
;
3115 DWORD NumberOfRvaAndSizes
;
3116 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
]; /* 0x60 */
3118 } IMAGE_OPTIONAL_HEADER32
, *PIMAGE_OPTIONAL_HEADER32
;
3120 typedef struct _IMAGE_NT_HEADERS
{
3121 DWORD Signature
; /* "PE"\0\0 */ /* 0x00 */
3122 IMAGE_FILE_HEADER FileHeader
; /* 0x04 */
3123 IMAGE_OPTIONAL_HEADER32 OptionalHeader
; /* 0x18 */
3124 } IMAGE_NT_HEADERS32
, *PIMAGE_NT_HEADERS32
;
3127 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS
;
3128 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS
;
3129 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER
;
3130 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER
;
3132 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS
;
3133 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
;
3134 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
;
3135 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER
;
3138 #define IMAGE_SIZEOF_SHORT_NAME 8
3140 typedef struct _IMAGE_SECTION_HEADER
{
3141 BYTE Name
[IMAGE_SIZEOF_SHORT_NAME
];
3143 DWORD PhysicalAddress
;
3146 DWORD VirtualAddress
;
3147 DWORD SizeOfRawData
;
3148 DWORD PointerToRawData
;
3149 DWORD PointerToRelocations
;
3150 DWORD PointerToLinenumbers
;
3151 WORD NumberOfRelocations
;
3152 WORD NumberOfLinenumbers
;
3153 DWORD Characteristics
;
3154 } IMAGE_SECTION_HEADER
, *PIMAGE_SECTION_HEADER
;
3156 #define IMAGE_SIZEOF_SECTION_HEADER 40
3158 #define IMAGE_FIRST_SECTION(ntheader) \
3159 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
3160 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
3162 /* These defines are for the Characteristics bitfield. */
3163 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
3164 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
3165 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
3166 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
3167 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
3168 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
3170 #define IMAGE_SCN_CNT_CODE 0x00000020
3171 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
3172 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
3174 #define IMAGE_SCN_LNK_OTHER 0x00000100
3175 #define IMAGE_SCN_LNK_INFO 0x00000200
3176 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
3177 #define IMAGE_SCN_LNK_REMOVE 0x00000800
3178 #define IMAGE_SCN_LNK_COMDAT 0x00001000
3180 /* 0x00002000 - Reserved */
3181 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
3182 #define IMAGE_SCN_MEM_FARDATA 0x00008000
3184 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
3185 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
3186 #define IMAGE_SCN_MEM_16BIT 0x00020000
3187 #define IMAGE_SCN_MEM_LOCKED 0x00040000
3188 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
3190 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
3191 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
3192 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
3193 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
3194 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
3195 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
3196 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
3197 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
3198 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
3199 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
3200 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
3201 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
3202 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
3203 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
3204 /* 0x00F00000 - Unused */
3205 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
3207 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
3210 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
3211 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
3212 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
3213 #define IMAGE_SCN_MEM_SHARED 0x10000000
3214 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
3215 #define IMAGE_SCN_MEM_READ 0x40000000
3216 #define IMAGE_SCN_MEM_WRITE 0x80000000
3218 #include <pshpack2.h>
3220 typedef struct _IMAGE_SYMBOL
{
3230 SHORT SectionNumber
;
3233 BYTE NumberOfAuxSymbols
;
3235 typedef IMAGE_SYMBOL
*PIMAGE_SYMBOL
;
3237 #define IMAGE_SIZEOF_SYMBOL 18
3239 typedef struct _IMAGE_LINENUMBER
{
3241 DWORD SymbolTableIndex
;
3242 DWORD VirtualAddress
;
3246 typedef IMAGE_LINENUMBER
*PIMAGE_LINENUMBER
;
3248 #define IMAGE_SIZEOF_LINENUMBER 6
3250 typedef union _IMAGE_AUX_SYMBOL
{
3262 DWORD PointerToLinenumber
;
3263 DWORD PointerToNextFunction
;
3272 BYTE Name
[IMAGE_SIZEOF_SYMBOL
];
3276 WORD NumberOfRelocations
;
3277 WORD NumberOfLinenumbers
;
3283 typedef IMAGE_AUX_SYMBOL
*PIMAGE_AUX_SYMBOL
;
3285 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3287 #include <poppack.h>
3289 #define IMAGE_SYM_UNDEFINED (SHORT)0
3290 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3291 #define IMAGE_SYM_DEBUG (SHORT)-2
3293 #define IMAGE_SYM_TYPE_NULL 0x0000
3294 #define IMAGE_SYM_TYPE_VOID 0x0001
3295 #define IMAGE_SYM_TYPE_CHAR 0x0002
3296 #define IMAGE_SYM_TYPE_SHORT 0x0003
3297 #define IMAGE_SYM_TYPE_INT 0x0004
3298 #define IMAGE_SYM_TYPE_LONG 0x0005
3299 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3300 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3301 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3302 #define IMAGE_SYM_TYPE_UNION 0x0009
3303 #define IMAGE_SYM_TYPE_ENUM 0x000A
3304 #define IMAGE_SYM_TYPE_MOE 0x000B
3305 #define IMAGE_SYM_TYPE_BYTE 0x000C
3306 #define IMAGE_SYM_TYPE_WORD 0x000D
3307 #define IMAGE_SYM_TYPE_UINT 0x000E
3308 #define IMAGE_SYM_TYPE_DWORD 0x000F
3309 #define IMAGE_SYM_TYPE_PCODE 0x8000
3311 #define IMAGE_SYM_DTYPE_NULL 0
3312 #define IMAGE_SYM_DTYPE_POINTER 1
3313 #define IMAGE_SYM_DTYPE_FUNCTION 2
3314 #define IMAGE_SYM_DTYPE_ARRAY 3
3316 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3317 #define IMAGE_SYM_CLASS_NULL 0x0000
3318 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3319 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3320 #define IMAGE_SYM_CLASS_STATIC 0x0003
3321 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3322 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3323 #define IMAGE_SYM_CLASS_LABEL 0x0006
3324 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3325 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3326 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3327 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3328 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3329 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3330 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3331 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3332 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3333 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3334 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3335 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3337 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3338 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3339 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3340 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3341 #define IMAGE_SYM_CLASS_FILE 0x0067
3342 #define IMAGE_SYM_CLASS_SECTION 0x0068
3343 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3345 #define N_BTMASK 0x000F
3346 #define N_TMASK 0x0030
3347 #define N_TMASK1 0x00C0
3348 #define N_TMASK2 0x00F0
3352 #define BTYPE(x) ((x) & N_BTMASK)
3355 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3359 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3363 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3367 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3371 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3374 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3377 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3378 #define IMAGE_COMDAT_SELECT_ANY 2
3379 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3380 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3381 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3382 #define IMAGE_COMDAT_SELECT_LARGEST 6
3383 #define IMAGE_COMDAT_SELECT_NEWEST 7
3385 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3386 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3387 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3389 /* Export module directory */
3391 typedef struct _IMAGE_EXPORT_DIRECTORY
{
3392 DWORD Characteristics
;
3393 DWORD TimeDateStamp
;
3398 DWORD NumberOfFunctions
;
3399 DWORD NumberOfNames
;
3400 DWORD AddressOfFunctions
;
3401 DWORD AddressOfNames
;
3402 DWORD AddressOfNameOrdinals
;
3403 } IMAGE_EXPORT_DIRECTORY
,*PIMAGE_EXPORT_DIRECTORY
;
3405 /* Import name entry */
3406 typedef struct _IMAGE_IMPORT_BY_NAME
{
3409 } IMAGE_IMPORT_BY_NAME
,*PIMAGE_IMPORT_BY_NAME
;
3411 #include <pshpack8.h>
3413 typedef struct _IMAGE_THUNK_DATA64
{
3415 ULONGLONG ForwarderString
;
3418 ULONGLONG AddressOfData
;
3420 } IMAGE_THUNK_DATA64
,*PIMAGE_THUNK_DATA64
;
3421 #include <poppack.h>
3423 typedef struct _IMAGE_THUNK_DATA32
{
3425 DWORD ForwarderString
;
3428 DWORD AddressOfData
;
3430 } IMAGE_THUNK_DATA32
,*PIMAGE_THUNK_DATA32
;
3432 /* Import module directory */
3434 typedef struct _IMAGE_IMPORT_DESCRIPTOR
{
3436 DWORD Characteristics
; /* 0 for terminating null import descriptor */
3437 DWORD OriginalFirstThunk
; /* RVA to original unbound IAT */
3439 DWORD TimeDateStamp
; /* 0 if not bound,
3440 * -1 if bound, and real date\time stamp
3441 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3443 * otherwise date/time stamp of DLL bound to
3446 DWORD ForwarderChain
; /* -1 if no forwarders */
3448 /* RVA to IAT (if bound this IAT has actual addresses) */
3450 } IMAGE_IMPORT_DESCRIPTOR
,*PIMAGE_IMPORT_DESCRIPTOR
;
3452 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3453 #define IMAGE_ORDINAL_FLAG32 0x80000000
3454 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3455 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3456 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3457 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3460 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3461 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3462 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3463 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA
;
3464 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA
;
3466 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3467 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3468 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3469 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA
;
3470 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
;
3473 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3475 DWORD TimeDateStamp
;
3476 WORD OffsetModuleName
;
3477 WORD NumberOfModuleForwarderRefs
;
3478 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3479 } IMAGE_BOUND_IMPORT_DESCRIPTOR
, *PIMAGE_BOUND_IMPORT_DESCRIPTOR
;
3481 typedef struct _IMAGE_BOUND_FORWARDER_REF
3483 DWORD TimeDateStamp
;
3484 WORD OffsetModuleName
;
3486 } IMAGE_BOUND_FORWARDER_REF
, *PIMAGE_BOUND_FORWARDER_REF
;
3488 typedef struct _IMAGE_BASE_RELOCATION
3490 DWORD VirtualAddress
;
3492 /* WORD TypeOffset[1]; */
3493 } IMAGE_BASE_RELOCATION
,*PIMAGE_BASE_RELOCATION
;
3495 #include <pshpack2.h>
3497 typedef struct _IMAGE_RELOCATION
3500 DWORD VirtualAddress
;
3503 DWORD SymbolTableIndex
;
3505 } IMAGE_RELOCATION
, *PIMAGE_RELOCATION
;
3507 #include <poppack.h>
3509 #define IMAGE_SIZEOF_RELOCATION 10
3511 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3515 DWORD AllAttributes
;
3519 DWORD ReservedAttributes
:31;
3524 DWORD ModuleHandleRVA
;
3525 DWORD ImportAddressTableRVA
;
3526 DWORD ImportNameTableRVA
;
3527 DWORD BoundImportAddressTableRVA
;
3528 DWORD UnloadInformationTableRVA
;
3529 DWORD TimeDateStamp
;
3530 } IMAGE_DELAYLOAD_DESCRIPTOR
, *PIMAGE_DELAYLOAD_DESCRIPTOR
;
3531 typedef const IMAGE_DELAYLOAD_DESCRIPTOR
*PCIMAGE_DELAYLOAD_DESCRIPTOR
;
3533 /* generic relocation types */
3534 #define IMAGE_REL_BASED_ABSOLUTE 0
3535 #define IMAGE_REL_BASED_HIGH 1
3536 #define IMAGE_REL_BASED_LOW 2
3537 #define IMAGE_REL_BASED_HIGHLOW 3
3538 #define IMAGE_REL_BASED_HIGHADJ 4
3539 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3540 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3541 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3542 #define IMAGE_REL_BASED_SECTION 6
3543 #define IMAGE_REL_BASED_REL 7
3544 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3545 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3546 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3547 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3548 #define IMAGE_REL_BASED_DIR64 10
3549 #define IMAGE_REL_BASED_HIGH3ADJ 11
3551 /* I386 relocation types */
3552 #define IMAGE_REL_I386_ABSOLUTE 0
3553 #define IMAGE_REL_I386_DIR16 1
3554 #define IMAGE_REL_I386_REL16 2
3555 #define IMAGE_REL_I386_DIR32 6
3556 #define IMAGE_REL_I386_DIR32NB 7
3557 #define IMAGE_REL_I386_SEG12 9
3558 #define IMAGE_REL_I386_SECTION 10
3559 #define IMAGE_REL_I386_SECREL 11
3560 #define IMAGE_REL_I386_TOKEN 12
3561 #define IMAGE_REL_I386_SECREL7 13
3562 #define IMAGE_REL_I386_REL32 20
3564 /* MIPS relocation types */
3565 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3566 #define IMAGE_REL_MIPS_REFHALF 0x0001
3567 #define IMAGE_REL_MIPS_REFWORD 0x0002
3568 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3569 #define IMAGE_REL_MIPS_REFHI 0x0004
3570 #define IMAGE_REL_MIPS_REFLO 0x0005
3571 #define IMAGE_REL_MIPS_GPREL 0x0006
3572 #define IMAGE_REL_MIPS_LITERAL 0x0007
3573 #define IMAGE_REL_MIPS_SECTION 0x000A
3574 #define IMAGE_REL_MIPS_SECREL 0x000B
3575 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3576 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3577 #define IMAGE_REL_MIPS_TOKEN 0x000E
3578 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3579 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3580 #define IMAGE_REL_MIPS_PAIR 0x0025
3582 /* ALPHA relocation types */
3583 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3584 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3585 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3586 #define IMAGE_REL_ALPHA_GPREL 0x0003
3587 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3588 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3589 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3590 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3591 #define IMAGE_REL_ALPHA_HINT 0x0008
3592 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3593 #define IMAGE_REL_ALPHA_REFHI 0x000A
3594 #define IMAGE_REL_ALPHA_REFLO 0x000B
3595 #define IMAGE_REL_ALPHA_PAIR 0x000C
3596 #define IMAGE_REL_ALPHA_MATCH 0x000D
3597 #define IMAGE_REL_ALPHA_SECTION 0x000E
3598 #define IMAGE_REL_ALPHA_SECREL 0x000F
3599 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3600 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3601 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3602 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3603 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3604 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3605 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3606 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3608 /* PowerPC relocation types */
3609 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3610 #define IMAGE_REL_PPC_ADDR64 0x0001
3611 #define IMAGE_REL_PPC_ADDR 0x0002
3612 #define IMAGE_REL_PPC_ADDR24 0x0003
3613 #define IMAGE_REL_PPC_ADDR16 0x0004
3614 #define IMAGE_REL_PPC_ADDR14 0x0005
3615 #define IMAGE_REL_PPC_REL24 0x0006
3616 #define IMAGE_REL_PPC_REL14 0x0007
3617 #define IMAGE_REL_PPC_TOCREL16 0x0008
3618 #define IMAGE_REL_PPC_TOCREL14 0x0009
3619 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3620 #define IMAGE_REL_PPC_SECREL 0x000B
3621 #define IMAGE_REL_PPC_SECTION 0x000C
3622 #define IMAGE_REL_PPC_IFGLUE 0x000D
3623 #define IMAGE_REL_PPC_IMGLUE 0x000E
3624 #define IMAGE_REL_PPC_SECREL16 0x000F
3625 #define IMAGE_REL_PPC_REFHI 0x0010
3626 #define IMAGE_REL_PPC_REFLO 0x0011
3627 #define IMAGE_REL_PPC_PAIR 0x0012
3628 #define IMAGE_REL_PPC_SECRELLO 0x0013
3629 #define IMAGE_REL_PPC_SECRELHI 0x0014
3630 #define IMAGE_REL_PPC_GPREL 0x0015
3631 #define IMAGE_REL_PPC_TOKEN 0x0016
3632 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3634 #define IMAGE_REL_PPC_NEG 0x0100
3635 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3636 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3637 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3639 /* SH3 relocation types */
3640 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3641 #define IMAGE_REL_SH3_DIRECT16 0x0001
3642 #define IMAGE_REL_SH3_DIRECT 0x0002
3643 #define IMAGE_REL_SH3_DIRECT8 0x0003
3644 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3645 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3646 #define IMAGE_REL_SH3_DIRECT4 0x0006
3647 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3648 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3649 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3650 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3651 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3652 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3653 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3654 #define IMAGE_REL_SH3_SECTION 0x000E
3655 #define IMAGE_REL_SH3_SECREL 0x000F
3656 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3657 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3658 #define IMAGE_REL_SH3_TOKEN 0x0012
3660 /* ARM relocation types */
3661 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3662 #define IMAGE_REL_ARM_ADDR 0x0001
3663 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3664 #define IMAGE_REL_ARM_BRANCH24 0x0003
3665 #define IMAGE_REL_ARM_BRANCH11 0x0004
3666 #define IMAGE_REL_ARM_TOKEN 0x0005
3667 #define IMAGE_REL_ARM_GPREL12 0x0006
3668 #define IMAGE_REL_ARM_GPREL7 0x0007
3669 #define IMAGE_REL_ARM_BLX24 0x0008
3670 #define IMAGE_REL_ARM_BLX11 0x0009
3671 #define IMAGE_REL_ARM_SECTION 0x000E
3672 #define IMAGE_REL_ARM_SECREL 0x000F
3673 #define IMAGE_REL_ARM_MOV32A 0x0010
3674 #define IMAGE_REL_ARM_MOV32T 0x0011
3675 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3676 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3677 #define IMAGE_REL_ARM_BLX23T 0x0015
3679 /* ARM64 relocation types */
3680 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3681 #define IMAGE_REL_ARM64_ADDR32 0x0001
3682 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3683 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3684 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3685 #define IMAGE_REL_ARM64_REL21 0x0005
3686 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3687 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3688 #define IMAGE_REL_ARM64_SECREL 0x0008
3689 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3690 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3691 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3692 #define IMAGE_REL_ARM64_TOKEN 0x000C
3693 #define IMAGE_REL_ARM64_SECTION 0x000D
3694 #define IMAGE_REL_ARM64_ADDR64 0x000E
3695 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3697 /* IA64 relocation types */
3698 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3699 #define IMAGE_REL_IA64_IMM14 0x0001
3700 #define IMAGE_REL_IA64_IMM22 0x0002
3701 #define IMAGE_REL_IA64_IMM64 0x0003
3702 #define IMAGE_REL_IA64_DIR 0x0004
3703 #define IMAGE_REL_IA64_DIR64 0x0005
3704 #define IMAGE_REL_IA64_PCREL21B 0x0006
3705 #define IMAGE_REL_IA64_PCREL21M 0x0007
3706 #define IMAGE_REL_IA64_PCREL21F 0x0008
3707 #define IMAGE_REL_IA64_GPREL22 0x0009
3708 #define IMAGE_REL_IA64_LTOFF22 0x000A
3709 #define IMAGE_REL_IA64_SECTION 0x000B
3710 #define IMAGE_REL_IA64_SECREL22 0x000C
3711 #define IMAGE_REL_IA64_SECREL64I 0x000D
3712 #define IMAGE_REL_IA64_SECREL 0x000E
3713 #define IMAGE_REL_IA64_LTOFF64 0x000F
3714 #define IMAGE_REL_IA64_DIR32NB 0x0010
3715 #define IMAGE_REL_IA64_SREL14 0x0011
3716 #define IMAGE_REL_IA64_SREL22 0x0012
3717 #define IMAGE_REL_IA64_SREL32 0x0013
3718 #define IMAGE_REL_IA64_UREL32 0x0014
3719 #define IMAGE_REL_IA64_PCREL60X 0x0015
3720 #define IMAGE_REL_IA64_PCREL60B 0x0016
3721 #define IMAGE_REL_IA64_PCREL60F 0x0017
3722 #define IMAGE_REL_IA64_PCREL60I 0x0018
3723 #define IMAGE_REL_IA64_PCREL60M 0x0019
3724 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3725 #define IMAGE_REL_IA64_TOKEN 0x001B
3726 #define IMAGE_REL_IA64_GPREL32 0x001C
3727 #define IMAGE_REL_IA64_ADDEND 0x001F
3729 /* AMD64 relocation types */
3730 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3731 #define IMAGE_REL_AMD64_ADDR64 0x0001
3732 #define IMAGE_REL_AMD64_ADDR32 0x0002
3733 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3734 #define IMAGE_REL_AMD64_REL32 0x0004
3735 #define IMAGE_REL_AMD64_REL32_1 0x0005
3736 #define IMAGE_REL_AMD64_REL32_2 0x0006
3737 #define IMAGE_REL_AMD64_REL32_3 0x0007
3738 #define IMAGE_REL_AMD64_REL32_4 0x0008
3739 #define IMAGE_REL_AMD64_REL32_5 0x0009
3740 #define IMAGE_REL_AMD64_SECTION 0x000A
3741 #define IMAGE_REL_AMD64_SECREL 0x000B
3742 #define IMAGE_REL_AMD64_SECREL7 0x000C
3743 #define IMAGE_REL_AMD64_TOKEN 0x000D
3744 #define IMAGE_REL_AMD64_SREL32 0x000E
3745 #define IMAGE_REL_AMD64_PAIR 0x000F
3746 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3748 /* archive format */
3750 #define IMAGE_ARCHIVE_START_SIZE 8
3751 #define IMAGE_ARCHIVE_START "!<arch>\n"
3752 #define IMAGE_ARCHIVE_END "`\n"
3753 #define IMAGE_ARCHIVE_PAD "\n"
3754 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3755 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3757 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3766 } IMAGE_ARCHIVE_MEMBER_HEADER
, *PIMAGE_ARCHIVE_MEMBER_HEADER
;
3768 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3770 typedef struct _IMPORT_OBJECT_HEADER
3776 DWORD TimeDateStamp
;
3786 } IMPORT_OBJECT_HEADER
;
3788 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3790 typedef enum IMPORT_OBJECT_TYPE
3792 IMPORT_OBJECT_CODE
= 0,
3793 IMPORT_OBJECT_DATA
= 1,
3794 IMPORT_OBJECT_CONST
= 2
3795 } IMPORT_OBJECT_TYPE
;
3797 typedef enum IMPORT_OBJECT_NAME_TYPE
3799 IMPORT_OBJECT_ORDINAL
= 0,
3800 IMPORT_OBJECT_NAME
= 1,
3801 IMPORT_OBJECT_NAME_NO_PREFIX
= 2,
3802 IMPORT_OBJECT_NAME_UNDECORATE
= 3
3803 } IMPORT_OBJECT_NAME_TYPE
;
3805 typedef struct _ANON_OBJECT_HEADER
3811 DWORD TimeDateStamp
;
3814 } ANON_OBJECT_HEADER
;
3817 * Resource directory stuff
3819 typedef struct _IMAGE_RESOURCE_DIRECTORY
{
3820 DWORD Characteristics
;
3821 DWORD TimeDateStamp
;
3824 WORD NumberOfNamedEntries
;
3825 WORD NumberOfIdEntries
;
3826 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3827 } IMAGE_RESOURCE_DIRECTORY
,*PIMAGE_RESOURCE_DIRECTORY
;
3829 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3830 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3832 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
{
3835 unsigned NameOffset
:31;
3836 unsigned NameIsString
:1;
3844 unsigned OffsetToDirectory
:31;
3845 unsigned DataIsDirectory
:1;
3848 } IMAGE_RESOURCE_DIRECTORY_ENTRY
,*PIMAGE_RESOURCE_DIRECTORY_ENTRY
;
3851 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
{
3853 CHAR NameString
[ 1 ];
3854 } IMAGE_RESOURCE_DIRECTORY_STRING
,*PIMAGE_RESOURCE_DIRECTORY_STRING
;
3856 typedef struct _IMAGE_RESOURCE_DIR_STRING_U
{
3858 WCHAR NameString
[ 1 ];
3859 } IMAGE_RESOURCE_DIR_STRING_U
,*PIMAGE_RESOURCE_DIR_STRING_U
;
3861 typedef struct _IMAGE_RESOURCE_DATA_ENTRY
{
3866 } IMAGE_RESOURCE_DATA_ENTRY
,*PIMAGE_RESOURCE_DATA_ENTRY
;
3869 typedef VOID (CALLBACK
*PIMAGE_TLS_CALLBACK
)(
3870 LPVOID DllHandle
,DWORD Reason
,LPVOID Reserved
3873 typedef struct _IMAGE_TLS_DIRECTORY64
{
3874 ULONGLONG StartAddressOfRawData
;
3875 ULONGLONG EndAddressOfRawData
;
3876 ULONGLONG AddressOfIndex
;
3877 ULONGLONG AddressOfCallBacks
;
3878 DWORD SizeOfZeroFill
;
3879 DWORD Characteristics
;
3880 } IMAGE_TLS_DIRECTORY64
, *PIMAGE_TLS_DIRECTORY64
;
3882 typedef struct _IMAGE_TLS_DIRECTORY32
{
3883 DWORD StartAddressOfRawData
;
3884 DWORD EndAddressOfRawData
;
3885 DWORD AddressOfIndex
;
3886 DWORD AddressOfCallBacks
;
3887 DWORD SizeOfZeroFill
;
3888 DWORD Characteristics
;
3889 } IMAGE_TLS_DIRECTORY32
, *PIMAGE_TLS_DIRECTORY32
;
3892 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY
;
3893 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY
;
3895 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY
;
3896 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY
;
3899 typedef struct _IMAGE_DEBUG_DIRECTORY
{
3900 DWORD Characteristics
;
3901 DWORD TimeDateStamp
;
3906 DWORD AddressOfRawData
;
3907 DWORD PointerToRawData
;
3908 } IMAGE_DEBUG_DIRECTORY
, *PIMAGE_DEBUG_DIRECTORY
;
3910 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3911 #define IMAGE_DEBUG_TYPE_COFF 1
3912 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3913 #define IMAGE_DEBUG_TYPE_FPO 3
3914 #define IMAGE_DEBUG_TYPE_MISC 4
3915 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3916 #define IMAGE_DEBUG_TYPE_FIXUP 6
3917 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3918 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3919 #define IMAGE_DEBUG_TYPE_BORLAND 9
3920 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3921 #define IMAGE_DEBUG_TYPE_CLSID 11
3922 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3923 #define IMAGE_DEBUG_TYPE_POGO 13
3924 #define IMAGE_DEBUG_TYPE_ILTCG 14
3925 #define IMAGE_DEBUG_TYPE_MPX 15
3926 #define IMAGE_DEBUG_TYPE_REPRO 16
3928 typedef enum ReplacesCorHdrNumericDefines
3930 COMIMAGE_FLAGS_ILONLY
= 0x00000001,
3931 COMIMAGE_FLAGS_32BITREQUIRED
= 0x00000002,
3932 COMIMAGE_FLAGS_IL_LIBRARY
= 0x00000004,
3933 COMIMAGE_FLAGS_STRONGNAMESIGNED
= 0x00000008,
3934 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT
= 0x00000010,
3935 COMIMAGE_FLAGS_TRACKDEBUGDATA
= 0x00010000,
3936 COMIMAGE_FLAGS_32BITPREFERRED
= 0x00020000,
3938 COR_VERSION_MAJOR_V2
= 2,
3939 COR_VERSION_MAJOR
= COR_VERSION_MAJOR_V2
,
3940 COR_VERSION_MINOR
= 5,
3941 COR_DELETED_NAME_LENGTH
= 8,
3942 COR_VTABLEGAP_NAME_LENGTH
= 8,
3944 NATIVE_TYPE_MAX_CB
= 1,
3945 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE
= 0xff,
3947 IMAGE_COR_MIH_METHODRVA
= 0x01,
3948 IMAGE_COR_MIH_EHRVA
= 0x02,
3949 IMAGE_COR_MIH_BASICBLOCK
= 0x08,
3951 COR_VTABLE_32BIT
= 0x01,
3952 COR_VTABLE_64BIT
= 0x02,
3953 COR_VTABLE_FROM_UNMANAGED
= 0x04,
3954 COR_VTABLE_CALL_MOST_DERIVED
= 0x10,
3956 IMAGE_COR_EATJ_THUNK_SIZE
= 32,
3958 MAX_CLASS_NAME
= 1024,
3959 MAX_PACKAGE_NAME
= 1024,
3960 } ReplacesCorHdrNumericDefines
;
3962 typedef struct IMAGE_COR20_HEADER
3965 WORD MajorRuntimeVersion
;
3966 WORD MinorRuntimeVersion
;
3968 IMAGE_DATA_DIRECTORY MetaData
;
3971 DWORD EntryPointToken
;
3972 DWORD EntryPointRVA
;
3975 IMAGE_DATA_DIRECTORY Resources
;
3976 IMAGE_DATA_DIRECTORY StrongNameSignature
;
3977 IMAGE_DATA_DIRECTORY CodeManagerTable
;
3978 IMAGE_DATA_DIRECTORY VTableFixups
;
3979 IMAGE_DATA_DIRECTORY ExportAddressTableJumps
;
3980 IMAGE_DATA_DIRECTORY ManagedNativeHeader
;
3982 } IMAGE_COR20_HEADER
, *PIMAGE_COR20_HEADER
;
3984 typedef struct _IMAGE_COFF_SYMBOLS_HEADER
{
3985 DWORD NumberOfSymbols
;
3986 DWORD LvaToFirstSymbol
;
3987 DWORD NumberOfLinenumbers
;
3988 DWORD LvaToFirstLinenumber
;
3989 DWORD RvaToFirstByteOfCode
;
3990 DWORD RvaToLastByteOfCode
;
3991 DWORD RvaToFirstByteOfData
;
3992 DWORD RvaToLastByteOfData
;
3993 } IMAGE_COFF_SYMBOLS_HEADER
, *PIMAGE_COFF_SYMBOLS_HEADER
;
3996 #define FRAME_TRAP 1
3998 #define FRAME_NONFPO 3
4000 typedef struct _FPO_DATA
{
4011 } FPO_DATA
, *PFPO_DATA
;
4013 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
{
4015 DWORD TimeDateStamp
;
4018 DWORD GlobalFlagsClear
;
4019 DWORD GlobalFlagsSet
;
4020 DWORD CriticalSectionDefaultTimeout
;
4021 ULONGLONG DeCommitFreeBlockThreshold
;
4022 ULONGLONG DeCommitTotalFreeThreshold
;
4023 ULONGLONG LockPrefixTable
;
4024 ULONGLONG MaximumAllocationSize
;
4025 ULONGLONG VirtualMemoryThreshold
;
4026 ULONGLONG ProcessAffinityMask
;
4027 DWORD ProcessHeapFlags
;
4031 ULONGLONG SecurityCookie
;
4032 ULONGLONG SEHandlerTable
;
4033 ULONGLONG SEHandlerCount
;
4034 } IMAGE_LOAD_CONFIG_DIRECTORY64
, *PIMAGE_LOAD_CONFIG_DIRECTORY64
;
4036 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
{
4038 DWORD TimeDateStamp
;
4041 DWORD GlobalFlagsClear
;
4042 DWORD GlobalFlagsSet
;
4043 DWORD CriticalSectionDefaultTimeout
;
4044 DWORD DeCommitFreeBlockThreshold
;
4045 DWORD DeCommitTotalFreeThreshold
;
4046 PVOID LockPrefixTable
;
4047 DWORD MaximumAllocationSize
;
4048 DWORD VirtualMemoryThreshold
;
4049 DWORD ProcessHeapFlags
;
4050 DWORD ProcessAffinityMask
;
4054 DWORD SecurityCookie
;
4055 DWORD SEHandlerTable
;
4056 DWORD SEHandlerCount
;
4057 } IMAGE_LOAD_CONFIG_DIRECTORY32
, *PIMAGE_LOAD_CONFIG_DIRECTORY32
;
4060 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY
;
4061 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY
;
4063 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY
;
4064 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY
;
4067 typedef struct _IMAGE_FUNCTION_ENTRY
{
4068 DWORD StartingAddress
;
4069 DWORD EndingAddress
;
4070 DWORD EndOfPrologue
;
4071 } IMAGE_FUNCTION_ENTRY
, *PIMAGE_FUNCTION_ENTRY
;
4073 #define IMAGE_DEBUG_MISC_EXENAME 1
4075 typedef struct _IMAGE_DEBUG_MISC
{
4081 } IMAGE_DEBUG_MISC
, *PIMAGE_DEBUG_MISC
;
4083 /* This is the structure that appears at the very start of a .DBG file. */
4085 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
{
4089 WORD Characteristics
;
4090 DWORD TimeDateStamp
;
4094 DWORD NumberOfSections
;
4095 DWORD ExportedNamesSize
;
4096 DWORD DebugDirectorySize
;
4097 DWORD SectionAlignment
;
4098 DWORD Reserved
[ 2 ];
4099 } IMAGE_SEPARATE_DEBUG_HEADER
,*PIMAGE_SEPARATE_DEBUG_HEADER
;
4101 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
4104 typedef struct tagMESSAGE_RESOURCE_ENTRY
{
4108 } MESSAGE_RESOURCE_ENTRY
,*PMESSAGE_RESOURCE_ENTRY
;
4109 #define MESSAGE_RESOURCE_UNICODE 0x0001
4111 typedef struct tagMESSAGE_RESOURCE_BLOCK
{
4114 DWORD OffsetToEntries
;
4115 } MESSAGE_RESOURCE_BLOCK
,*PMESSAGE_RESOURCE_BLOCK
;
4117 typedef struct tagMESSAGE_RESOURCE_DATA
{
4118 DWORD NumberOfBlocks
;
4119 MESSAGE_RESOURCE_BLOCK Blocks
[ 1 ];
4120 } MESSAGE_RESOURCE_DATA
,*PMESSAGE_RESOURCE_DATA
;
4123 * Here follows typedefs for security and tokens.
4127 * First a constant for the following typedefs.
4130 #define ANYSIZE_ARRAY 1
4132 /* FIXME: Orphan. What does it point to? */
4133 typedef PVOID PACCESS_TOKEN
;
4134 typedef PVOID PSECURITY_DESCRIPTOR
;
4137 typedef enum _TOKEN_ELEVATION_TYPE
{
4138 TokenElevationTypeDefault
= 1,
4139 TokenElevationTypeFull
,
4140 TokenElevationTypeLimited
4141 } TOKEN_ELEVATION_TYPE
, *PTOKEN_ELEVATION_TYPE
;
4144 * TOKEN_INFORMATION_CLASS
4147 typedef enum _TOKEN_INFORMATION_CLASS
{
4156 TokenImpersonationLevel
,
4158 TokenRestrictedSids
,
4160 TokenGroupsAndPrivileges
,
4161 TokenSessionReference
,
4168 TokenHasRestrictions
,
4169 TokenAccessInformation
,
4170 TokenVirtualizationAllowed
,
4171 TokenVirtualizationEnabled
,
4172 TokenIntegrityLevel
,
4174 TokenMandatoryPolicy
,
4176 TokenIsAppContainer
,
4178 TokenAppContainerSid
,
4179 TokenAppContainerNumber
,
4180 TokenUserClaimAttributes
,
4181 TokenDeviceClaimAttributes
,
4182 TokenRestrictedUserClaimAttributes
,
4183 TokenRestrictedDeviceClaimAttributes
,
4185 TokenRestrictedDeviceGroups
,
4186 TokenSecurityAttributes
,
4188 TokenProcessTrustLevel
,
4190 } TOKEN_INFORMATION_CLASS
;
4192 #define DISABLE_MAX_PRIVILEGE 0x1
4193 #define SANDBOX_INERT 0x2
4194 #define LUA_TOKEN 0x4
4195 #define WRITE_RESTRICTED 0x8
4197 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
4198 #define TOKEN_ADJUST_GROUPS 0x0040
4199 #define TOKEN_ADJUST_PRIVILEGES 0x0020
4200 #define TOKEN_ADJUST_SESSIONID 0x0100
4201 #define TOKEN_ASSIGN_PRIMARY 0x0001
4202 #define TOKEN_DUPLICATE 0x0002
4203 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
4204 #define TOKEN_IMPERSONATE 0x0004
4205 #define TOKEN_QUERY 0x0008
4206 #define TOKEN_QUERY_SOURCE 0x0010
4207 #define TOKEN_ADJUST_DEFAULT 0x0080
4208 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
4209 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
4210 TOKEN_ADJUST_PRIVILEGES | \
4211 TOKEN_ADJUST_GROUPS | \
4212 TOKEN_ADJUST_DEFAULT )
4213 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
4214 TOKEN_ASSIGN_PRIMARY | \
4216 TOKEN_IMPERSONATE | \
4218 TOKEN_QUERY_SOURCE | \
4219 TOKEN_ADJUST_PRIVILEGES | \
4220 TOKEN_ADJUST_GROUPS | \
4221 TOKEN_ADJUST_SESSIONID | \
4222 TOKEN_ADJUST_DEFAULT )
4224 #ifndef _SECURITY_DEFINED
4225 #define _SECURITY_DEFINED
4228 typedef DWORD ACCESS_MASK
, *PACCESS_MASK
;
4230 typedef struct _GENERIC_MAPPING
{
4231 ACCESS_MASK GenericRead
;
4232 ACCESS_MASK GenericWrite
;
4233 ACCESS_MASK GenericExecute
;
4234 ACCESS_MASK GenericAll
;
4235 } GENERIC_MAPPING
, *PGENERIC_MAPPING
;
4237 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
4238 #define SID_IDENTIFIER_AUTHORITY_DEFINED
4241 } SID_IDENTIFIER_AUTHORITY
, *PSID_IDENTIFIER_AUTHORITY
;
4242 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
4246 typedef struct _SID
{
4248 BYTE SubAuthorityCount
;
4249 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
4250 DWORD SubAuthority
[1];
4252 #endif /* !defined(SID_DEFINED) */
4254 #define SID_REVISION (1) /* Current revision */
4255 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
4256 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
4258 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
4264 #define ACL_REVISION1 1
4265 #define ACL_REVISION2 2
4266 #define ACL_REVISION3 3
4267 #define ACL_REVISION4 4
4269 #define MIN_ACL_REVISION ACL_REVISION2
4270 #define MAX_ACL_REVISION ACL_REVISION4
4272 #define ACL_REVISION 2
4274 typedef struct _ACL
{
4282 typedef enum _ACL_INFORMATION_CLASS
4284 AclRevisionInformation
= 1,
4286 } ACL_INFORMATION_CLASS
;
4288 typedef struct _ACL_REVISION_INFORMATION
4291 } ACL_REVISION_INFORMATION
, *PACL_REVISION_INFORMATION
;
4293 typedef struct _ACL_SIZE_INFORMATION
4296 DWORD AclBytesInUse
;
4298 } ACL_SIZE_INFORMATION
, *PACL_SIZE_INFORMATION
;
4300 /* SECURITY_DESCRIPTOR */
4301 #define SECURITY_DESCRIPTOR_REVISION 1
4302 #define SECURITY_DESCRIPTOR_REVISION1 1
4309 #if defined(_MSC_VER) || defined(__MINGW32__)
4310 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4311 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4312 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4313 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4314 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4315 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4316 #define SE_TCB_NAME L"SeTcbPrivilege"
4317 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4318 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4319 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4320 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4321 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4322 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4323 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4324 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4325 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4326 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4327 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4328 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4329 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4330 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4331 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4332 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4333 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4334 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4335 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4336 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4337 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4338 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4339 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4340 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4341 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4342 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4343 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4344 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4345 #else /* _MSC_VER/__MINGW32__ */
4346 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 };
4347 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 };
4348 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 };
4349 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 };
4350 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 };
4351 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 };
4352 static const WCHAR SE_TCB_NAME
[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4353 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 };
4354 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 };
4355 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 };
4356 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 };
4357 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 };
4358 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 };
4359 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 };
4360 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 };
4361 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 };
4362 static const WCHAR SE_BACKUP_NAME
[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4363 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 };
4364 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 };
4365 static const WCHAR SE_DEBUG_NAME
[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4366 static const WCHAR SE_AUDIT_NAME
[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4367 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 };
4368 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 };
4369 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 };
4370 static const WCHAR SE_UNDOCK_NAME
[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4371 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 };
4372 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 };
4373 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 };
4374 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 };
4375 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 };
4376 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 };
4377 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 };
4378 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 };
4379 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 };
4380 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 };
4383 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4384 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4385 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4386 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4387 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4388 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4389 #define SE_TCB_NAME "SeTcbPrivilege"
4390 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4391 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4392 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4393 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4394 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4395 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4396 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4397 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4398 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4399 #define SE_BACKUP_NAME "SeBackupPrivilege"
4400 #define SE_RESTORE_NAME "SeRestorePrivilege"
4401 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4402 #define SE_DEBUG_NAME "SeDebugPrivilege"
4403 #define SE_AUDIT_NAME "SeAuditPrivilege"
4404 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4405 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4406 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4407 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4408 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4409 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4410 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4411 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4412 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4413 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4414 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4415 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4416 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4417 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4420 #define SE_GROUP_MANDATORY 0x00000001
4421 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4422 #define SE_GROUP_ENABLED 0x00000004
4423 #define SE_GROUP_OWNER 0x00000008
4424 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4425 #define SE_GROUP_INTEGRITY 0x00000020
4426 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4427 #define SE_GROUP_LOGON_ID 0xC0000000
4428 #define SE_GROUP_RESOURCE 0x20000000
4429 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4431 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4432 #define SE_PRIVILEGE_ENABLED 0x00000002
4433 #define SE_PRIVILEGE_REMOVED 0x00000004
4434 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4435 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4437 #define PRIVILEGE_SET_ALL_NECESSARY 1
4439 #define SE_OWNER_DEFAULTED 0x00000001
4440 #define SE_GROUP_DEFAULTED 0x00000002
4441 #define SE_DACL_PRESENT 0x00000004
4442 #define SE_DACL_DEFAULTED 0x00000008
4443 #define SE_SACL_PRESENT 0x00000010
4444 #define SE_SACL_DEFAULTED 0x00000020
4445 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4446 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4447 #define SE_DACL_AUTO_INHERITED 0x00000400
4448 #define SE_SACL_AUTO_INHERITED 0x00000800
4449 #define SE_DACL_PROTECTED 0x00001000
4450 #define SE_SACL_PROTECTED 0x00002000
4451 #define SE_RM_CONTROL_VALID 0x00004000
4452 #define SE_SELF_RELATIVE 0x00008000
4454 typedef DWORD SECURITY_INFORMATION
, *PSECURITY_INFORMATION
;
4455 typedef WORD SECURITY_DESCRIPTOR_CONTROL
, *PSECURITY_DESCRIPTOR_CONTROL
;
4457 /* The security descriptor structure */
4461 SECURITY_DESCRIPTOR_CONTROL Control
;
4466 } SECURITY_DESCRIPTOR_RELATIVE
, *PISECURITY_DESCRIPTOR_RELATIVE
;
4471 SECURITY_DESCRIPTOR_CONTROL Control
;
4476 } SECURITY_DESCRIPTOR
, *PISECURITY_DESCRIPTOR
;
4478 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4480 #endif /* _SECURITY_DEFINED */
4483 * SID_AND_ATTRIBUTES
4486 typedef struct _SID_AND_ATTRIBUTES
{
4489 } SID_AND_ATTRIBUTES
, *PSID_AND_ATTRIBUTES
;
4491 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY
[ANYSIZE_ARRAY
];
4492 typedef SID_AND_ATTRIBUTES_ARRAY
*PSID_AND_ATTRIBUTES_ARRAY
;
4494 #define SID_HASH_SIZE 32
4496 typedef ULONG_PTR SID_HASH_ENTRY
, *PSID_HASH_ENTRY
;
4498 typedef struct _SID_AND_ATTRIBUTES_HASH
{
4500 PSID_AND_ATTRIBUTES SidAttr
;
4501 SID_HASH_ENTRY Hash
[SID_HASH_SIZE
];
4502 } SID_AND_ATTRIBUTES_HASH
, *PSID_AND_ATTRIBUTES_HASH
;
4504 /* security entities */
4505 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4506 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4507 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4509 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4512 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4515 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4516 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4519 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4520 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4521 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4522 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4523 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4524 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4527 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4530 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4531 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4532 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4533 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4534 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4535 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4536 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4537 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4538 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4539 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4540 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4541 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4542 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4543 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4544 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4545 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4546 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4547 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4548 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4549 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4550 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4551 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4552 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4553 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4555 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4556 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4557 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4558 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4559 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4560 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4561 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4562 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4563 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4564 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4565 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4566 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4567 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4568 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4569 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4570 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4571 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4572 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4573 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4574 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4575 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4576 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4578 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4580 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4581 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4582 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4583 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4584 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4586 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4587 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4588 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4589 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4590 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4591 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4592 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4593 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4594 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4595 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4597 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4599 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4600 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4601 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4602 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4603 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4604 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4605 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4606 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4607 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4608 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4609 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4611 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4612 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4613 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4614 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4615 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4616 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4617 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4618 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4619 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4621 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4623 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4624 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4625 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4626 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4628 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4629 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4630 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4631 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4633 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4634 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4635 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4636 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4637 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4638 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4640 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4641 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4642 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4643 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4644 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4645 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4646 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4647 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4648 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4649 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4650 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4652 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4654 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4655 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4656 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4657 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4658 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4659 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4660 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4661 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4662 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4663 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4664 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4666 #define SYSTEM_LUID { 0x3e7, 0x0 }
4667 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4668 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4669 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4670 #define IUSER_LUID { 0x3e3, 0x0 }
4676 WinCreatorOwnerSid
= 3,
4677 WinCreatorGroupSid
= 4,
4678 WinCreatorOwnerServerSid
= 5,
4679 WinCreatorGroupServerSid
= 6,
4680 WinNtAuthoritySid
= 7,
4684 WinInteractiveSid
= 11,
4686 WinAnonymousSid
= 13,
4688 WinEnterpriseControllersSid
= 15,
4690 WinAuthenticatedUserSid
= 17,
4691 WinRestrictedCodeSid
= 18,
4692 WinTerminalServerSid
= 19,
4693 WinRemoteLogonIdSid
= 20,
4694 WinLogonIdsSid
= 21,
4695 WinLocalSystemSid
= 22,
4696 WinLocalServiceSid
= 23,
4697 WinNetworkServiceSid
= 24,
4698 WinBuiltinDomainSid
= 25,
4699 WinBuiltinAdministratorsSid
= 26,
4700 WinBuiltinUsersSid
= 27,
4701 WinBuiltinGuestsSid
= 28,
4702 WinBuiltinPowerUsersSid
= 29,
4703 WinBuiltinAccountOperatorsSid
= 30,
4704 WinBuiltinSystemOperatorsSid
= 31,
4705 WinBuiltinPrintOperatorsSid
= 32,
4706 WinBuiltinBackupOperatorsSid
= 33,
4707 WinBuiltinReplicatorSid
= 34,
4708 WinBuiltinPreWindows2000CompatibleAccessSid
= 35,
4709 WinBuiltinRemoteDesktopUsersSid
= 36,
4710 WinBuiltinNetworkConfigurationOperatorsSid
= 37,
4711 WinAccountAdministratorSid
= 38,
4712 WinAccountGuestSid
= 39,
4713 WinAccountKrbtgtSid
= 40,
4714 WinAccountDomainAdminsSid
= 41,
4715 WinAccountDomainUsersSid
= 42,
4716 WinAccountDomainGuestsSid
= 43,
4717 WinAccountComputersSid
= 44,
4718 WinAccountControllersSid
= 45,
4719 WinAccountCertAdminsSid
= 46,
4720 WinAccountSchemaAdminsSid
= 47,
4721 WinAccountEnterpriseAdminsSid
= 48,
4722 WinAccountPolicyAdminsSid
= 49,
4723 WinAccountRasAndIasServersSid
= 50,
4724 WinNTLMAuthenticationSid
= 51,
4725 WinDigestAuthenticationSid
= 52,
4726 WinSChannelAuthenticationSid
= 53,
4727 WinThisOrganizationSid
= 54,
4728 WinOtherOrganizationSid
= 55,
4729 WinBuiltinIncomingForestTrustBuildersSid
= 56,
4730 WinBuiltinPerfMonitoringUsersSid
= 57,
4731 WinBuiltinPerfLoggingUsersSid
= 58,
4732 WinBuiltinAuthorizationAccessSid
= 59,
4733 WinBuiltinTerminalServerLicenseServersSid
= 60,
4734 WinBuiltinDCOMUsersSid
= 61,
4735 WinBuiltinIUsersSid
= 62,
4737 WinBuiltinCryptoOperatorsSid
= 64,
4738 WinUntrustedLabelSid
= 65,
4739 WinLowLabelSid
= 66,
4740 WinMediumLabelSid
= 67,
4741 WinHighLabelSid
= 68,
4742 WinSystemLabelSid
= 69,
4743 WinWriteRestrictedCodeSid
= 70,
4744 WinCreatorOwnerRightsSid
= 71,
4745 WinCacheablePrincipalsGroupSid
= 72,
4746 WinNonCacheablePrincipalsGroupSid
= 73,
4747 WinEnterpriseReadonlyControllersSid
= 74,
4748 WinAccountReadonlyControllersSid
= 75,
4749 WinBuiltinEventLogReadersGroup
= 76,
4750 WinNewEnterpriseReadonlyControllersSid
= 77,
4751 WinBuiltinCertSvcDComAccessGroup
= 78,
4752 WinMediumPlusLabelSid
= 79,
4753 WinLocalLogonSid
= 80,
4754 WinConsoleLogonSid
= 81,
4755 WinThisOrganizationCertificateSid
= 82,
4756 WinApplicationPackageAuthoritySid
= 83,
4757 WinBuiltinAnyPackageSid
= 84,
4758 WinCapabilityInternetClientSid
= 85,
4759 WinCapabilityInternetClientServerSid
= 86,
4760 WinCapabilityPrivateNetworkClientServerSid
= 87,
4761 WinCapabilityPicturesLibrarySid
= 88,
4762 WinCapabilityVideosLibrarySid
= 89,
4763 WinCapabilityMusicLibrarySid
= 90,
4764 WinCapabilityDocumentsLibrarySid
= 91,
4765 WinCapabilitySharedUserCertificatesSid
= 92,
4766 WinCapabilityEnterpriseAuthenticationSid
= 93,
4767 WinCapabilityRemovableStorageSid
= 94,
4768 WinBuiltinRDSRemoteAccessServersSid
= 95,
4769 WinBuiltinRDSEndpointServersSid
= 96,
4770 WinBuiltinRDSManagementServersSid
= 97,
4771 WinUserModeDriversSid
= 98,
4772 WinBuiltinHyperVAdminsSid
= 99,
4773 WinAccountCloneableControllersSid
= 100,
4774 WinBuiltinAccessControlAssistanceOperatorsSid
= 101,
4775 WinBuiltinRemoteManagementUsersSid
= 102,
4776 WinAuthenticationAuthorityAssertedSid
= 103,
4777 WinAuthenticationServiceAssertedSid
= 104,
4778 WinLocalAccountSid
= 105,
4779 WinLocalAccountAndAdministratorSid
= 106,
4780 WinAccountProtectedUsersSid
= 107,
4781 } WELL_KNOWN_SID_TYPE
;
4787 typedef struct _TOKEN_USER
{
4788 SID_AND_ATTRIBUTES User
;
4789 } TOKEN_USER
, *PTOKEN_USER
;
4795 typedef struct _TOKEN_GROUPS
{
4797 SID_AND_ATTRIBUTES Groups
[ANYSIZE_ARRAY
];
4798 } TOKEN_GROUPS
, *PTOKEN_GROUPS
;
4801 * LUID_AND_ATTRIBUTES
4804 typedef union _LARGE_INTEGER
{
4806 #ifdef WORDS_BIGENDIAN
4814 #ifndef NONAMELESSSTRUCT
4816 #ifdef WORDS_BIGENDIAN
4826 } LARGE_INTEGER
, *PLARGE_INTEGER
;
4828 typedef union _ULARGE_INTEGER
{
4830 #ifdef WORDS_BIGENDIAN
4838 #ifndef NONAMELESSSTRUCT
4840 #ifdef WORDS_BIGENDIAN
4850 } ULARGE_INTEGER
, *PULARGE_INTEGER
;
4853 * Locally Unique Identifier
4856 typedef struct _LUID
{
4861 #include <pshpack4.h>
4862 typedef struct _LUID_AND_ATTRIBUTES
{
4865 } LUID_AND_ATTRIBUTES
, *PLUID_AND_ATTRIBUTES
;
4866 #include <poppack.h>
4872 typedef struct _PRIVILEGE_SET
{
4873 DWORD PrivilegeCount
;
4875 LUID_AND_ATTRIBUTES Privilege
[ANYSIZE_ARRAY
];
4876 } PRIVILEGE_SET
, *PPRIVILEGE_SET
;
4882 typedef struct _TOKEN_PRIVILEGES
{
4883 DWORD PrivilegeCount
;
4884 LUID_AND_ATTRIBUTES Privileges
[ANYSIZE_ARRAY
];
4885 } TOKEN_PRIVILEGES
, *PTOKEN_PRIVILEGES
;
4891 typedef struct _TOKEN_OWNER
{
4893 } TOKEN_OWNER
, *PTOKEN_OWNER
;
4896 * TOKEN_PRIMARY_GROUP
4899 typedef struct _TOKEN_PRIMARY_GROUP
{
4901 } TOKEN_PRIMARY_GROUP
, *PTOKEN_PRIMARY_GROUP
;
4905 * TOKEN_DEFAULT_DACL
4908 typedef struct _TOKEN_DEFAULT_DACL
{
4910 } TOKEN_DEFAULT_DACL
, *PTOKEN_DEFAULT_DACL
;
4916 #define TOKEN_SOURCE_LENGTH 8
4918 typedef struct _TOKEN_SOURCE
{
4919 char SourceName
[TOKEN_SOURCE_LENGTH
];
4920 LUID SourceIdentifier
;
4921 } TOKEN_SOURCE
, *PTOKEN_SOURCE
;
4927 typedef enum tagTOKEN_TYPE
{
4933 * SECURITY_IMPERSONATION_LEVEL
4936 typedef enum _SECURITY_IMPERSONATION_LEVEL
{
4938 SecurityIdentification
,
4939 SecurityImpersonation
,
4941 } SECURITY_IMPERSONATION_LEVEL
, *PSECURITY_IMPERSONATION_LEVEL
;
4943 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4944 #define SECURITY_STATIC_TRACKING (FALSE)
4946 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE
,
4947 * PSECURITY_CONTEXT_TRACKING_MODE
;
4949 * Quality of Service
4952 typedef struct _SECURITY_QUALITY_OF_SERVICE
{
4954 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
4955 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
;
4956 BOOLEAN EffectiveOnly
;
4957 } SECURITY_QUALITY_OF_SERVICE
, *PSECURITY_QUALITY_OF_SERVICE
;
4963 #include <pshpack4.h>
4964 typedef struct _TOKEN_STATISTICS
{
4966 LUID AuthenticationId
;
4967 LARGE_INTEGER ExpirationTime
;
4968 TOKEN_TYPE TokenType
;
4969 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
4970 DWORD DynamicCharged
;
4971 DWORD DynamicAvailable
;
4973 DWORD PrivilegeCount
;
4976 #include <poppack.h>
4978 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES
{
4981 PSID_AND_ATTRIBUTES Sids
;
4982 DWORD RestrictedSidCount
;
4983 DWORD RestrictedSidLength
;
4984 PSID_AND_ATTRIBUTES RestrictedSids
;
4985 DWORD PrivilegeCount
;
4986 DWORD PrivilegeLength
;
4987 PLUID_AND_ATTRIBUTES Privileges
;
4988 LUID AuthenticationId
;
4989 } TOKEN_GROUPS_AND_PRIVILEGES
, * PTOKEN_GROUPS_AND_PRIVILEGES
;
4991 typedef struct _TOKEN_ORIGIN
{
4992 LUID OriginatingLogonSession
;
4993 } TOKEN_ORIGIN
, * PTOKEN_ORIGIN
;
4995 typedef struct _TOKEN_LINKED_TOKEN
{
4997 } TOKEN_LINKED_TOKEN
, * PTOKEN_LINKED_TOKEN
;
4999 typedef struct _TOKEN_ELEVATION
{
5000 DWORD TokenIsElevated
;
5001 } TOKEN_ELEVATION
, * PTOKEN_ELEVATION
;
5003 typedef struct _TOKEN_MANDATORY_LABEL
{
5004 SID_AND_ATTRIBUTES Label
;
5005 } TOKEN_MANDATORY_LABEL
, * PTOKEN_MANDATORY_LABEL
;
5007 #define TOKEN_MANDATORY_POLICY_OFF 0x0
5008 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
5009 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
5010 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
5012 typedef struct _TOKEN_MANDATORY_POLICY
{
5014 } TOKEN_MANDATORY_POLICY
, *PTOKEN_MANDATORY_POLICY
;
5016 typedef struct _TOKEN_APPCONTAINER_INFORMATION
{
5017 PSID TokenAppContainer
;
5018 } TOKEN_APPCONTAINER_INFORMATION
, * PTOKEN_APPCONTAINER_INFORMATION
;
5020 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
5022 typedef struct _TOKEN_AUDIT_POLICY
{
5023 BYTE PerUserPolicy
[((POLICY_AUDIT_SUBCATEGORY_COUNT
) >> 1) + 1];
5024 } TOKEN_AUDIT_POLICY
, *PTOKEN_AUDIT_POLICY
;
5026 typedef struct _TOKEN_ACCESS_INFORMATION
{
5027 PSID_AND_ATTRIBUTES_HASH SidHash
;
5028 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash
;
5029 PTOKEN_PRIVILEGES Privileges
;
5030 LUID AuthenticationId
;
5031 TOKEN_TYPE TokenType
;
5032 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
5033 TOKEN_MANDATORY_POLICY MandatoryPolicy
;
5035 } TOKEN_ACCESS_INFORMATION
, *PTOKEN_ACCESS_INFORMATION
;
5037 typedef struct _TOKEN_CONTROL
{
5039 LUID AuthenticationId
;
5041 TOKEN_SOURCE TokenSource
;
5042 } TOKEN_CONTROL
, *PTOKEN_CONTROL
;
5048 /* ACEs, directly starting after an ACL */
5049 typedef struct _ACE_HEADER
{
5053 } ACE_HEADER
,*PACE_HEADER
;
5056 #define ACCESS_MIN_MS_ACE_TYPE 0x0
5057 #define ACCESS_ALLOWED_ACE_TYPE 0x0
5058 #define ACCESS_DENIED_ACE_TYPE 0x1
5059 #define SYSTEM_AUDIT_ACE_TYPE 0x2
5060 #define SYSTEM_ALARM_ACE_TYPE 0x3
5061 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
5062 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
5063 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
5064 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
5065 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
5066 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
5067 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
5068 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
5069 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
5070 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
5071 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
5072 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
5073 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
5074 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
5075 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
5076 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
5077 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
5078 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
5079 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
5080 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
5081 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
5082 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
5084 /* inherit AceFlags */
5085 #define OBJECT_INHERIT_ACE 0x01
5086 #define CONTAINER_INHERIT_ACE 0x02
5087 #define NO_PROPAGATE_INHERIT_ACE 0x04
5088 #define INHERIT_ONLY_ACE 0x08
5089 #define INHERITED_ACE 0x10
5090 #define VALID_INHERIT_FLAGS 0x1F
5092 /* AceFlags mask for what events we (should) audit */
5093 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
5094 #define FAILED_ACCESS_ACE_FLAG 0x80
5096 /* different ACEs depending on AceType
5097 * SidStart marks the begin of a SID
5098 * so the thing finally looks like this:
5103 typedef struct _ACCESS_ALLOWED_ACE
{
5107 } ACCESS_ALLOWED_ACE
,*PACCESS_ALLOWED_ACE
;
5109 typedef struct _ACCESS_DENIED_ACE
{
5113 } ACCESS_DENIED_ACE
,*PACCESS_DENIED_ACE
;
5115 typedef struct _SYSTEM_AUDIT_ACE
{
5119 } SYSTEM_AUDIT_ACE
,*PSYSTEM_AUDIT_ACE
;
5121 typedef struct _SYSTEM_ALARM_ACE
{
5125 } SYSTEM_ALARM_ACE
,*PSYSTEM_ALARM_ACE
;
5127 typedef struct _SYSTEM_MANDATORY_LABEL_ACE
{
5131 } SYSTEM_MANDATORY_LABEL_ACE
,*PSYSTEM_MANDATORY_LABEL_ACE
;
5133 typedef struct _ACCESS_ALLOWED_OBJECT_ACE
{
5138 GUID InheritedObjectType
;
5140 } ACCESS_ALLOWED_OBJECT_ACE
, *PACCESS_ALLOWED_OBJECT_ACE
;
5142 typedef struct _ACCESS_DENIED_OBJECT_ACE
{
5147 GUID InheritedObjectType
;
5149 } ACCESS_DENIED_OBJECT_ACE
, *PACCESS_DENIED_OBJECT_ACE
;
5151 typedef struct _SYSTEM_AUDIT_OBJECT_ACE
{
5156 GUID InheritedObjectType
;
5158 } SYSTEM_AUDIT_OBJECT_ACE
, *PSYSTEM_AUDIT_OBJECT_ACE
;
5160 typedef struct _SYSTEM_ALARM_OBJECT_ACE
{
5165 GUID InheritedObjectType
;
5167 } SYSTEM_ALARM_OBJECT_ACE
, *PSYSTEM_ALARM_OBJECT_aCE
;
5169 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE
{
5173 } ACCESS_ALLOWED_CALLBACK_ACE
,*PACCESS_ALLOWED_CALLBACK_ACE
;
5175 typedef struct _ACCESS_DENIED_CALLBACK_ACE
{
5179 } ACCESS_DENIED_CALLBACK_ACE
,*PACCESS_DENIED_CALLBACK_ACE
;
5181 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE
{
5185 } SYSTEM_AUDIT_CALLBACK_ACE
,*PSYSTEM_AUDIT_CALLBACK_ACE
;
5187 typedef struct _SYSTEM_ALARM_CALLBACK_ACE
{
5191 } SYSTEM_ALARM_CALLBACK_ACE
,*PSYSTEM_ALARM_CALLBACK_ACE
;
5193 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
{
5198 GUID InheritedObjectType
;
5200 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE
, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE
;
5202 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE
{
5207 GUID InheritedObjectType
;
5209 } ACCESS_DENIED_CALLBACK_OBJECT_ACE
, *PACCESS_DENIED_CALLBACK_OBJECT_ACE
;
5211 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
{
5216 GUID InheritedObjectType
;
5218 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE
, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE
;
5220 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE
{
5225 GUID InheritedObjectType
;
5227 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE
, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE
;
5229 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
5230 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
5231 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
5232 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
5234 typedef enum tagSID_NAME_USE
{
5239 SidTypeWellKnownGroup
,
5240 SidTypeDeletedAccount
,
5243 } SID_NAME_USE
,*PSID_NAME_USE
;
5245 #define ACE_OBJECT_TYPE_PRESENT 0x1
5246 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
5250 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
5252 #define DELETE 0x00010000
5253 #define READ_CONTROL 0x00020000
5254 #define WRITE_DAC 0x00040000
5255 #define WRITE_OWNER 0x00080000
5256 #define SYNCHRONIZE 0x00100000
5257 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
5259 #define STANDARD_RIGHTS_READ READ_CONTROL
5260 #define STANDARD_RIGHTS_WRITE READ_CONTROL
5261 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
5263 #define STANDARD_RIGHTS_ALL 0x001f0000
5265 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
5267 #define GENERIC_READ 0x80000000
5268 #define GENERIC_WRITE 0x40000000
5269 #define GENERIC_EXECUTE 0x20000000
5270 #define GENERIC_ALL 0x10000000
5272 #define MAXIMUM_ALLOWED 0x02000000
5273 #define ACCESS_SYSTEM_SECURITY 0x01000000
5275 #define EVENT_QUERY_STATE 0x0001
5276 #define EVENT_MODIFY_STATE 0x0002
5277 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5279 #define SEMAPHORE_QUERY_STATE 0x0001
5280 #define SEMAPHORE_MODIFY_STATE 0x0002
5281 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5283 #define MUTANT_QUERY_STATE 0x0001
5284 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5286 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5287 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5288 #define JOB_OBJECT_QUERY 0x0004
5289 #define JOB_OBJECT_TERMINATE 0x0008
5290 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5291 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
5293 #define TIMER_QUERY_STATE 0x0001
5294 #define TIMER_MODIFY_STATE 0x0002
5295 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5297 #define PROCESS_TERMINATE 0x0001
5298 #define PROCESS_CREATE_THREAD 0x0002
5299 #define PROCESS_VM_OPERATION 0x0008
5300 #define PROCESS_VM_READ 0x0010
5301 #define PROCESS_VM_WRITE 0x0020
5302 #define PROCESS_DUP_HANDLE 0x0040
5303 #define PROCESS_CREATE_PROCESS 0x0080
5304 #define PROCESS_SET_QUOTA 0x0100
5305 #define PROCESS_SET_INFORMATION 0x0200
5306 #define PROCESS_QUERY_INFORMATION 0x0400
5307 #define PROCESS_SUSPEND_RESUME 0x0800
5308 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5309 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5310 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5312 #define THREAD_TERMINATE 0x0001
5313 #define THREAD_SUSPEND_RESUME 0x0002
5314 #define THREAD_GET_CONTEXT 0x0008
5315 #define THREAD_SET_CONTEXT 0x0010
5316 #define THREAD_SET_INFORMATION 0x0020
5317 #define THREAD_QUERY_INFORMATION 0x0040
5318 #define THREAD_SET_THREAD_TOKEN 0x0080
5319 #define THREAD_IMPERSONATE 0x0100
5320 #define THREAD_DIRECT_IMPERSONATION 0x0200
5321 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5322 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5323 #define THREAD_RESUME 0x1000
5324 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5326 #define THREAD_BASE_PRIORITY_LOWRT 15
5327 #define THREAD_BASE_PRIORITY_MAX 2
5328 #define THREAD_BASE_PRIORITY_MIN -2
5329 #define THREAD_BASE_PRIORITY_IDLE -15
5331 typedef struct _QUOTA_LIMITS
{
5332 SIZE_T PagedPoolLimit
;
5333 SIZE_T NonPagedPoolLimit
;
5334 SIZE_T MinimumWorkingSetSize
;
5335 SIZE_T MaximumWorkingSetSize
;
5336 SIZE_T PagefileLimit
;
5337 LARGE_INTEGER TimeLimit
;
5338 } QUOTA_LIMITS
, *PQUOTA_LIMITS
;
5340 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5341 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5342 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5343 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5344 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5346 typedef union _RATE_QUOTA_LIMIT
{
5349 DWORD RatePercent
:7;
5352 } RATE_QUOTA_LIMIT
, *PRATE_QUOTA_LIMIT
;
5354 typedef struct _QUOTA_LIMITS_EX
{
5355 SIZE_T PagedPoolLimit
;
5356 SIZE_T NonPagedPoolLimit
;
5357 SIZE_T MinimumWorkingSetSize
;
5358 SIZE_T MaximumWorkingSetSize
;
5359 SIZE_T PagefileLimit
;
5360 LARGE_INTEGER TimeLimit
;
5361 SIZE_T WorkingSetLimit
;
5366 RATE_QUOTA_LIMIT CpuRateLimit
;
5367 } QUOTA_LIMITS_EX
, *PQUOTA_LIMITS_EX
;
5369 #define SECTION_QUERY 0x0001
5370 #define SECTION_MAP_WRITE 0x0002
5371 #define SECTION_MAP_READ 0x0004
5372 #define SECTION_MAP_EXECUTE 0x0008
5373 #define SECTION_EXTEND_SIZE 0x0010
5374 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5375 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5377 #define FILE_READ_DATA 0x0001 /* file & pipe */
5378 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5379 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5380 #define FILE_ADD_FILE 0x0002 /* directory */
5381 #define FILE_APPEND_DATA 0x0004 /* file */
5382 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5383 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5384 #define FILE_READ_EA 0x0008 /* file & directory */
5385 #define FILE_READ_PROPERTIES FILE_READ_EA
5386 #define FILE_WRITE_EA 0x0010 /* file & directory */
5387 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5388 #define FILE_EXECUTE 0x0020 /* file */
5389 #define FILE_TRAVERSE 0x0020 /* directory */
5390 #define FILE_DELETE_CHILD 0x0040 /* directory */
5391 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5392 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5393 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5395 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5396 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5398 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5399 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5400 FILE_APPEND_DATA | SYNCHRONIZE)
5401 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5402 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5404 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5405 #define DUPLICATE_SAME_ACCESS 0x00000002
5407 /* File attribute flags */
5408 #define FILE_SHARE_READ 0x00000001
5409 #define FILE_SHARE_WRITE 0x00000002
5410 #define FILE_SHARE_DELETE 0x00000004
5412 #define FILE_ATTRIBUTE_READONLY 0x00000001
5413 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5414 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5415 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5416 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5417 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5418 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5419 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5420 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5421 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5422 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5423 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5424 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5425 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5426 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5427 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5428 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5429 #define FILE_ATTRIBUTE_EA 0x00040000
5431 /* File notification flags */
5432 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5433 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5434 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5435 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5436 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5437 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5438 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5439 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5440 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5441 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5442 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5443 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5444 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5446 #define FILE_ACTION_ADDED 0x00000001
5447 #define FILE_ACTION_REMOVED 0x00000002
5448 #define FILE_ACTION_MODIFIED 0x00000003
5449 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5450 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5451 #define FILE_ACTION_ADDED_STREAM 0x00000006
5452 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5453 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5454 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5455 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5456 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5458 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5459 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5460 #define FILE_UNICODE_ON_DISK 0x00000004
5461 #define FILE_PERSISTENT_ACLS 0x00000008
5462 #define FILE_FILE_COMPRESSION 0x00000010
5463 #define FILE_VOLUME_QUOTAS 0x00000020
5464 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5465 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5466 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5467 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5468 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5469 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5470 #define FILE_NAMED_STREAMS 0x00040000
5471 #define FILE_READ_ONLY_VOLUME 0x00080000
5472 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5473 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5474 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5475 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5476 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5477 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5478 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5479 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5480 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5481 #define FILE_DAX_VOLUME 0x20000000
5482 #define FILE_SUPPORTS_GHOSTING 0x40000000
5484 /* File alignments (NT) */
5485 #define FILE_BYTE_ALIGNMENT 0x00000000
5486 #define FILE_WORD_ALIGNMENT 0x00000001
5487 #define FILE_LONG_ALIGNMENT 0x00000003
5488 #define FILE_QUAD_ALIGNMENT 0x00000007
5489 #define FILE_OCTA_ALIGNMENT 0x0000000f
5490 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5491 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5492 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5493 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5494 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5496 #define COMPRESSION_FORMAT_NONE 0
5497 #define COMPRESSION_FORMAT_DEFAULT 1
5498 #define COMPRESSION_FORMAT_LZNT1 2
5499 #define COMPRESSION_ENGINE_STANDARD 0
5500 #define COMPRESSION_ENGINE_MAXIMUM 256
5502 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5503 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5505 #define REG_NONE 0 /* no type */
5506 #define REG_SZ 1 /* string type (ASCII) */
5507 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5508 #define REG_BINARY 3 /* binary format, callerspecific */
5509 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5510 #define REG_DWORD 4 /* DWORD in little endian format */
5511 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5512 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5513 #define REG_LINK 6 /* symbolic link (UNICODE) */
5514 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5515 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5516 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5517 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5518 #define REG_QWORD 11 /* QWORD in little endian format */
5519 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5521 /* ----------------------------- begin power management --------------------- */
5523 typedef enum _LATENCY_TIME
{
5526 } LATENCY_TIME
, *PLATENCY_TIME
;
5528 #define DISCHARGE_POLICY_CRITICAL 0
5529 #define DISCHARGE_POLICY_LOW 1
5530 #define NUM_DISCHARGE_POLICIES 4
5532 #define PO_THROTTLE_NONE 0
5533 #define PO_THROTTLE_CONSTANT 1
5534 #define PO_THROTTLE_DEGRADE 2
5535 #define PO_THROTTLE_ADAPTIVE 3
5537 typedef enum _POWER_ACTION
{
5538 PowerActionNone
= 0,
5539 PowerActionReserved
,
5541 PowerActionHibernate
,
5542 PowerActionShutdown
,
5543 PowerActionShutdownReset
,
5544 PowerActionShutdownOff
,
5545 PowerActionWarmEject
5549 typedef enum _POWER_PLATFORM_ROLE
{
5550 PlatformRoleUnspecified
,
5551 PlatformRoleDesktop
,
5553 PlatformRoleWorkstation
,
5554 PlatformRoleEnterpriseServer
,
5555 PlatformRoleSOHOServer
,
5556 PlatformRoleAppliancePC
,
5557 PlatformRolePerformanceServer
,
5560 } POWER_PLATFORM_ROLE
, *PPOWER_PLATFORM_ROLE
;
5562 typedef enum _SYSTEM_POWER_STATE
{
5563 PowerSystemUnspecified
= 0,
5564 PowerSystemWorking
= 1,
5565 PowerSystemSleeping1
= 2,
5566 PowerSystemSleeping2
= 3,
5567 PowerSystemSleeping3
= 4,
5568 PowerSystemHibernate
= 5,
5569 PowerSystemShutdown
= 6,
5570 PowerSystemMaximum
= 7
5571 } SYSTEM_POWER_STATE
,
5572 *PSYSTEM_POWER_STATE
;
5574 typedef enum _DEVICE_POWER_STATE
{
5575 PowerDeviceUnspecified
,
5581 } DEVICE_POWER_STATE
, *PDEVICE_POWER_STATE
;
5583 typedef enum _POWER_INFORMATION_LEVEL
{
5584 SystemPowerPolicyAc
,
5585 SystemPowerPolicyDc
,
5586 VerifySystemPolicyAc
,
5587 VerifySystemPolicyDc
,
5588 SystemPowerCapabilities
,
5590 SystemPowerStateHandler
,
5591 ProcessorStateHandler
,
5592 SystemPowerPolicyCurrent
,
5593 AdministratorPowerPolicy
,
5594 SystemReserveHiberFile
,
5595 ProcessorInformation
,
5596 SystemPowerInformation
,
5597 ProcessorStateHandler2
,
5600 SystemExecutionState
,
5601 SystemPowerStateNotifyHandler
,
5602 ProcessorPowerPolicyAc
,
5603 ProcessorPowerPolicyDc
,
5604 VerifyProcessorPowerPolicyAc
,
5605 VerifyProcessorPowerPolicyDc
,
5606 ProcessorPowerPolicyCurrent
5607 } POWER_INFORMATION_LEVEL
;
5609 typedef struct _ADMINISTRATOR_POWER_POLICY
{
5610 SYSTEM_POWER_STATE MinSleep
;
5611 SYSTEM_POWER_STATE MaxSleep
;
5612 ULONG MinVideoTimeout
;
5613 ULONG MaxVideoTimeout
;
5614 ULONG MinSpindownTimeout
;
5615 ULONG MaxSpindownTimeout
;
5616 } ADMINISTRATOR_POWER_POLICY
, *PADMINISTRATOR_POWER_POLICY
;
5621 } BATTERY_REPORTING_SCALE
,
5622 *PBATTERY_REPORTING_SCALE
;
5625 POWER_ACTION Action
;
5628 } POWER_ACTION_POLICY
,
5629 *PPOWER_ACTION_POLICY
;
5631 typedef struct _PROCESSOR_POWER_INFORMATION
{
5637 ULONG CurrentIdleState
;
5638 } PROCESSOR_POWER_INFORMATION
,
5639 *PPROCESSOR_POWER_INFORMATION
;
5641 typedef struct _PROCESSOR_POWER_POLICY_INFO
{
5645 UCHAR DemotePercent
;
5646 UCHAR PromotePercent
;
5648 ULONG AllowDemotion
:1;
5649 ULONG AllowPromotion
:1;
5651 } PROCESSOR_POWER_POLICY_INFO
,
5652 *PPROCESSOR_POWER_POLICY_INFO
;
5654 typedef struct _PROCESSOR_POWER_POLICY
{
5656 BYTE DynamicThrottle
;
5658 DWORD DisableCStates
:1;
5661 PROCESSOR_POWER_POLICY_INFO Policy
[3];
5662 } PROCESSOR_POWER_POLICY
,
5663 *PPROCESSOR_POWER_POLICY
;
5667 BOOLEAN BatteryPresent
;
5669 BOOLEAN Discharging
;
5673 ULONG RemainingCapacity
;
5675 ULONG EstimatedTime
;
5676 ULONG DefaultAlert1
;
5677 ULONG DefaultAlert2
;
5678 } SYSTEM_BATTERY_STATE
,
5679 *PSYSTEM_BATTERY_STATE
;
5682 BOOLEAN PowerButtonPresent
;
5683 BOOLEAN SleepButtonPresent
;
5690 BOOLEAN HiberFilePresent
;
5692 BOOLEAN VideoDimPresent
;
5695 BOOLEAN ThermalControl
;
5696 BOOLEAN ProcessorThrottle
;
5697 UCHAR ProcessorMinThrottle
;
5698 UCHAR ProcessorMaxThrottle
;
5700 BOOLEAN DiskSpinDown
;
5702 BOOLEAN SystemBatteriesPresent
;
5703 BOOLEAN BatteriesAreShortTerm
;
5704 BATTERY_REPORTING_SCALE BatteryScale
[3];
5705 SYSTEM_POWER_STATE AcOnLineWake
;
5706 SYSTEM_POWER_STATE SoftLidWake
;
5707 SYSTEM_POWER_STATE RtcWake
;
5708 SYSTEM_POWER_STATE MinDeviceWakeState
;
5709 SYSTEM_POWER_STATE DefaultLowLatencyWake
;
5710 } SYSTEM_POWER_CAPABILITIES
,
5711 *PSYSTEM_POWER_CAPABILITIES
;
5713 typedef struct _SYSTEM_POWER_INFORMATION
{
5714 ULONG MaxIdlenessAllowed
;
5716 ULONG TimeRemaining
;
5718 } SYSTEM_POWER_INFORMATION
,
5719 *PSYSTEM_POWER_INFORMATION
;
5721 typedef struct _SYSTEM_POWER_LEVEL
{
5725 POWER_ACTION_POLICY PowerPolicy
;
5726 SYSTEM_POWER_STATE MinSystemState
;
5727 } SYSTEM_POWER_LEVEL
,
5728 *PSYSTEM_POWER_LEVEL
;
5730 typedef struct _SYSTEM_POWER_POLICY
{
5732 POWER_ACTION_POLICY PowerButton
;
5733 POWER_ACTION_POLICY SleepButton
;
5734 POWER_ACTION_POLICY LidClose
;
5735 SYSTEM_POWER_STATE LidOpenWake
;
5737 POWER_ACTION_POLICY Idle
;
5739 UCHAR IdleSensitivity
;
5740 UCHAR DynamicThrottle
;
5742 SYSTEM_POWER_STATE MinSleep
;
5743 SYSTEM_POWER_STATE MaxSleep
;
5744 SYSTEM_POWER_STATE ReducedLatencySleep
;
5745 ULONG WinLogonFlags
;
5747 ULONG DozeS4Timeout
;
5748 ULONG BroadcastCapacityResolution
;
5749 SYSTEM_POWER_LEVEL DischargePolicy
[NUM_DISCHARGE_POLICIES
];
5751 BOOLEAN VideoDimDisplay
;
5752 ULONG VideoReserved
[3];
5753 ULONG SpindownTimeout
;
5754 BOOLEAN OptimizeForPower
;
5755 UCHAR FanThrottleTolerance
;
5756 UCHAR ForcedThrottle
;
5758 POWER_ACTION_POLICY OverThrottled
;
5759 } SYSTEM_POWER_POLICY
,
5760 *PSYSTEM_POWER_POLICY
;
5762 typedef enum _POWER_REQUEST_TYPE
5764 PowerRequestDisplayRequired
,
5765 PowerRequestSystemRequired
,
5766 PowerRequestAwayModeRequired
5767 } POWER_REQUEST_TYPE
, *PPOWER_REQUEST_TYPE
;
5769 #define POWER_REQUEST_CONTEXT_VERSION 0
5771 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5772 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5774 typedef union _FILE_SEGMENT_ELEMENT
{
5776 ULONGLONG Alignment
;
5777 } FILE_SEGMENT_ELEMENT
, *PFILE_SEGMENT_ELEMENT
;
5779 typedef struct _FILE_NOTIFY_INFORMATION
{
5780 DWORD NextEntryOffset
;
5782 DWORD FileNameLength
;
5784 } FILE_NOTIFY_INFORMATION
, *PFILE_NOTIFY_INFORMATION
;
5786 /* ----------------------------- begin tape storage --------------------- */
5788 #define TAPE_FIXED_PARTITIONS 0
5789 #define TAPE_SELECT_PARTITIONS 1
5790 #define TAPE_INITIATOR_PARTITIONS 2
5791 #define TAPE_ERASE_SHORT 0
5792 #define TAPE_ERASE_LONG 1
5794 #define TAPE_UNLOAD 1
5795 #define TAPE_TENSION 2
5797 #define TAPE_UNLOCK 4
5798 #define TAPE_FORMAT 5
5799 #define TAPE_SETMARKS 0
5800 #define TAPE_FILEMARKS 1
5801 #define TAPE_SHORT_FILEMARKS 2
5802 #define TAPE_LONG_FILEMARKS 3
5803 #define TAPE_REWIND 0
5804 #define TAPE_ABSOLUTE_BLOCK 1
5805 #define TAPE_LOGICAL_BLOCK 2
5806 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5807 #define TAPE_SPACE_END_OF_DATA 4
5808 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5809 #define TAPE_SPACE_FILEMARKS 6
5810 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5811 #define TAPE_SPACE_SETMARKS 8
5812 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5814 typedef struct _TAPE_CREATE_PARTITION
{
5818 } TAPE_CREATE_PARTITION
, *PTAPE_CREATE_PARTITION
;
5820 typedef struct _TAPE_ERASE
{
5823 } TAPE_ERASE
, *PTAPE_ERASE
;
5825 typedef struct _TAPE_PREPARE
{
5828 } TAPE_PREPARE
, *PTAPE_PREPARE
;
5830 typedef struct _TAPE_SET_DRIVE_PARAMETERS
{
5832 BOOLEAN Compression
;
5833 BOOLEAN DataPadding
;
5834 BOOLEAN ReportSetmarks
;
5835 ULONG EOTWarningZoneSize
;
5836 } TAPE_SET_DRIVE_PARAMETERS
, *PTAPE_SET_DRIVE_PARAMETERS
;
5838 typedef struct _TAPE_SET_MEDIA_PARAMETERS
{
5840 } TAPE_SET_MEDIA_PARAMETERS
, *PTAPE_SET_MEDIA_PARAMETERS
;
5842 typedef struct _TAPE_WRITE_MARKS
{
5846 } TAPE_WRITE_MARKS
, *PTAPE_WRITE_MARKS
;
5848 typedef struct _TAPE_GET_POSITION
{
5853 } TAPE_GET_POSITION
, *PTAPE_GET_POSITION
;
5855 typedef struct _TAPE_SET_POSITION
{
5858 LARGE_INTEGER Offset
;
5860 } TAPE_SET_POSITION
, *PTAPE_SET_POSITION
;
5862 typedef struct _TAPE_GET_DRIVE_PARAMETERS
{
5864 BOOLEAN Compression
;
5865 BOOLEAN DataPadding
;
5866 BOOLEAN ReportSetmarks
;
5867 DWORD DefaultBlockSize
;
5868 DWORD MaximumBlockSize
;
5869 DWORD MinimumBlockSize
;
5870 DWORD MaximumPartitionCount
;
5873 DWORD EOTWarningZoneSize
;
5874 } TAPE_GET_DRIVE_PARAMETERS
, *PTAPE_GET_DRIVE_PARAMETERS
;
5876 typedef struct _TAPE_GET_MEDIA_PARAMETERS
{
5877 LARGE_INTEGER Capacity
;
5878 LARGE_INTEGER Remaining
;
5880 DWORD PartitionCount
;
5881 BOOLEAN WriteProtected
;
5882 } TAPE_GET_MEDIA_PARAMETERS
, *PTAPE_GET_MEDIA_PARAMETERS
;
5884 /* ----------------------------- begin registry ----------------------------- */
5886 /* Registry security values */
5887 #define OWNER_SECURITY_INFORMATION 0x00000001
5888 #define GROUP_SECURITY_INFORMATION 0x00000002
5889 #define DACL_SECURITY_INFORMATION 0x00000004
5890 #define SACL_SECURITY_INFORMATION 0x00000008
5891 #define LABEL_SECURITY_INFORMATION 0x00000010
5893 #define REG_OPTION_RESERVED 0x00000000
5894 #define REG_OPTION_NON_VOLATILE 0x00000000
5895 #define REG_OPTION_VOLATILE 0x00000001
5896 #define REG_OPTION_CREATE_LINK 0x00000002
5897 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5898 #define REG_OPTION_OPEN_LINK 0x00000008
5899 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
5900 REG_OPTION_NON_VOLATILE | \
5901 REG_OPTION_VOLATILE | \
5902 REG_OPTION_CREATE_LINK | \
5903 REG_OPTION_BACKUP_RESTORE | \
5904 REG_OPTION_OPEN_LINK)
5907 #define REG_CREATED_NEW_KEY 0x00000001
5908 #define REG_OPENED_EXISTING_KEY 0x00000002
5910 /* For RegNotifyChangeKeyValue */
5911 #define REG_NOTIFY_CHANGE_NAME 0x01
5912 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5913 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5914 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5915 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
5917 #define KEY_QUERY_VALUE 0x00000001
5918 #define KEY_SET_VALUE 0x00000002
5919 #define KEY_CREATE_SUB_KEY 0x00000004
5920 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5921 #define KEY_NOTIFY 0x00000010
5922 #define KEY_CREATE_LINK 0x00000020
5923 #define KEY_WOW64_64KEY 0x00000100
5924 #define KEY_WOW64_32KEY 0x00000200
5925 #define KEY_WOW64_RES 0x00000300
5927 /* for RegKeyRestore flags */
5928 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5929 #define REG_REFRESH_HIVE 0x00000002
5930 #define REG_NO_LAZY_FLUSH 0x00000004
5931 #define REG_FORCE_RESTORE 0x00000008
5933 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5935 KEY_ENUMERATE_SUB_KEYS| \
5939 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5941 KEY_CREATE_SUB_KEY) \
5944 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5945 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5948 KEY_CREATE_SUB_KEY| \
5949 KEY_ENUMERATE_SUB_KEYS| \
5954 /* ------------------------------ end registry ------------------------------ */
5957 #define EVENTLOG_SUCCESS 0x0000
5958 #define EVENTLOG_ERROR_TYPE 0x0001
5959 #define EVENTLOG_WARNING_TYPE 0x0002
5960 #define EVENTLOG_INFORMATION_TYPE 0x0004
5961 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5962 #define EVENTLOG_AUDIT_FAILURE 0x0010
5964 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5965 #define EVENTLOG_SEEK_READ 0x0002
5966 #define EVENTLOG_FORWARDS_READ 0x0004
5967 #define EVENTLOG_BACKWARDS_READ 0x0008
5969 typedef struct _EVENTLOGRECORD
{
5973 DWORD TimeGenerated
;
5980 DWORD ClosingRecordNumber
;
5982 DWORD UserSidLength
;
5983 DWORD UserSidOffset
;
5986 } EVENTLOGRECORD
, *PEVENTLOGRECORD
;
5988 #define SERVICE_BOOT_START 0x00000000
5989 #define SERVICE_SYSTEM_START 0x00000001
5990 #define SERVICE_AUTO_START 0x00000002
5991 #define SERVICE_DEMAND_START 0x00000003
5992 #define SERVICE_DISABLED 0x00000004
5994 #define SERVICE_ERROR_IGNORE 0x00000000
5995 #define SERVICE_ERROR_NORMAL 0x00000001
5996 #define SERVICE_ERROR_SEVERE 0x00000002
5997 #define SERVICE_ERROR_CRITICAL 0x00000003
6000 #define SERVICE_KERNEL_DRIVER 0x00000001
6001 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
6002 #define SERVICE_ADAPTER 0x00000004
6003 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
6005 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
6006 SERVICE_RECOGNIZER_DRIVER )
6008 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
6009 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
6010 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
6012 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
6014 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
6015 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
6018 typedef enum _CM_SERVICE_NODE_TYPE
6020 DriverType
= SERVICE_KERNEL_DRIVER
,
6021 FileSystemType
= SERVICE_FILE_SYSTEM_DRIVER
,
6022 Win32ServiceOwnProcess
= SERVICE_WIN32_OWN_PROCESS
,
6023 Win32ServiceShareProcess
= SERVICE_WIN32_SHARE_PROCESS
,
6024 AdapterType
= SERVICE_ADAPTER
,
6025 RecognizerType
= SERVICE_RECOGNIZER_DRIVER
6026 } SERVICE_NODE_TYPE
;
6028 typedef enum _CM_SERVICE_LOAD_TYPE
6030 BootLoad
= SERVICE_BOOT_START
,
6031 SystemLoad
= SERVICE_SYSTEM_START
,
6032 AutoLoad
= SERVICE_AUTO_START
,
6033 DemandLoad
= SERVICE_DEMAND_START
,
6034 DisableLoad
= SERVICE_DISABLED
6035 } SERVICE_LOAD_TYPE
;
6037 typedef enum _CM_ERROR_CONTROL_TYPE
6039 IgnoreError
= SERVICE_ERROR_IGNORE
,
6040 NormalError
= SERVICE_ERROR_NORMAL
,
6041 SevereError
= SERVICE_ERROR_SEVERE
,
6042 CriticalError
= SERVICE_ERROR_CRITICAL
6043 } SERVICE_ERROR_TYPE
;
6045 NTSYSAPI SIZE_T WINAPI
RtlCompareMemory(const VOID
*, const VOID
*, SIZE_T
);
6046 NTSYSAPI SIZE_T WINAPI
RtlCompareMemoryUlong(VOID
*, SIZE_T
, ULONG
);
6048 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
6049 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
6050 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
6051 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
6052 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
6054 static FORCEINLINE
void *RtlSecureZeroMemory(void *buffer
, SIZE_T length
)
6056 volatile char *ptr
= (volatile char *)buffer
;
6058 while (length
--) *ptr
++ = 0;
6062 #include <guiddef.h>
6064 typedef struct _OBJECT_TYPE_LIST
{
6068 } OBJECT_TYPE_LIST
, *POBJECT_TYPE_LIST
;
6070 typedef struct _RTL_CRITICAL_SECTION_DEBUG
6073 WORD CreatorBackTraceIndex
;
6074 struct _RTL_CRITICAL_SECTION
*CriticalSection
;
6075 LIST_ENTRY ProcessLocksList
;
6077 DWORD ContentionCount
;
6078 #ifdef __WINESRC__ /* in Wine we store the name here */
6079 DWORD_PTR Spare
[8/sizeof(DWORD_PTR
)];
6083 } RTL_CRITICAL_SECTION_DEBUG
, *PRTL_CRITICAL_SECTION_DEBUG
, RTL_RESOURCE_DEBUG
, *PRTL_RESOURCE_DEBUG
;
6085 typedef struct _RTL_CRITICAL_SECTION
{
6086 PRTL_CRITICAL_SECTION_DEBUG DebugInfo
;
6088 LONG RecursionCount
;
6089 HANDLE OwningThread
;
6090 HANDLE LockSemaphore
;
6091 ULONG_PTR SpinCount
;
6092 } RTL_CRITICAL_SECTION
, *PRTL_CRITICAL_SECTION
;
6094 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
6095 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
6096 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
6097 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
6098 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
6100 typedef struct _RTL_SRWLOCK
{
6102 } RTL_SRWLOCK
, *PRTL_SRWLOCK
;
6104 #define RTL_SRWLOCK_INIT {0}
6106 typedef struct _RTL_CONDITION_VARIABLE
{
6108 } RTL_CONDITION_VARIABLE
, *PRTL_CONDITION_VARIABLE
;
6109 #define RTL_CONDITION_VARIABLE_INIT {0}
6110 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
6112 typedef VOID (NTAPI
* WAITORTIMERCALLBACKFUNC
) (PVOID
, BOOLEAN
);
6113 typedef VOID (NTAPI
* PFLS_CALLBACK_FUNCTION
) ( PVOID
);
6115 #define RTL_RUN_ONCE_INIT {0}
6116 typedef union _RTL_RUN_ONCE
{
6118 } RTL_RUN_ONCE
, *PRTL_RUN_ONCE
;
6120 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
6121 #define RTL_RUN_ONCE_ASYNC 0x00000002
6122 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
6124 typedef DWORD WINAPI
RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE
, PVOID
, PVOID
*);
6125 typedef RTL_RUN_ONCE_INIT_FN
*PRTL_RUN_ONCE_INIT_FN
;
6126 NTSYSAPI VOID WINAPI
RtlRunOnceInitialize(PRTL_RUN_ONCE
);
6127 NTSYSAPI DWORD WINAPI
RtlRunOnceExecuteOnce(PRTL_RUN_ONCE
,PRTL_RUN_ONCE_INIT_FN
,PVOID
,PVOID
*);
6128 NTSYSAPI DWORD WINAPI
RtlRunOnceBeginInitialize(PRTL_RUN_ONCE
, DWORD
, PVOID
*);
6129 NTSYSAPI DWORD WINAPI
RtlRunOnceComplete(PRTL_RUN_ONCE
, DWORD
, PVOID
);
6131 #include <pshpack8.h>
6132 typedef struct _IO_COUNTERS
{
6133 ULONGLONG
DECLSPEC_ALIGN(8) ReadOperationCount
;
6134 ULONGLONG
DECLSPEC_ALIGN(8) WriteOperationCount
;
6135 ULONGLONG
DECLSPEC_ALIGN(8) OtherOperationCount
;
6136 ULONGLONG
DECLSPEC_ALIGN(8) ReadTransferCount
;
6137 ULONGLONG
DECLSPEC_ALIGN(8) WriteTransferCount
;
6138 ULONGLONG
DECLSPEC_ALIGN(8) OtherTransferCount
;
6139 } IO_COUNTERS
, *PIO_COUNTERS
;
6140 #include <poppack.h>
6143 DWORD dwOSVersionInfoSize
;
6144 DWORD dwMajorVersion
;
6145 DWORD dwMinorVersion
;
6146 DWORD dwBuildNumber
;
6148 CHAR szCSDVersion
[128];
6149 } OSVERSIONINFOA
, *POSVERSIONINFOA
, *LPOSVERSIONINFOA
;
6152 DWORD dwOSVersionInfoSize
;
6153 DWORD dwMajorVersion
;
6154 DWORD dwMinorVersion
;
6155 DWORD dwBuildNumber
;
6157 WCHAR szCSDVersion
[128];
6158 } OSVERSIONINFOW
, *POSVERSIONINFOW
, *LPOSVERSIONINFOW
, RTL_OSVERSIONINFOW
, *PRTL_OSVERSIONINFOW
;
6160 DECL_WINELIB_TYPE_AW(OSVERSIONINFO
)
6161 DECL_WINELIB_TYPE_AW(POSVERSIONINFO
)
6162 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO
)
6165 DWORD dwOSVersionInfoSize
;
6166 DWORD dwMajorVersion
;
6167 DWORD dwMinorVersion
;
6168 DWORD dwBuildNumber
;
6170 CHAR szCSDVersion
[128];
6171 WORD wServicePackMajor
;
6172 WORD wServicePackMinor
;
6176 } OSVERSIONINFOEXA
, *POSVERSIONINFOEXA
, *LPOSVERSIONINFOEXA
;
6179 DWORD dwOSVersionInfoSize
;
6180 DWORD dwMajorVersion
;
6181 DWORD dwMinorVersion
;
6182 DWORD dwBuildNumber
;
6184 WCHAR szCSDVersion
[128];
6185 WORD wServicePackMajor
;
6186 WORD wServicePackMinor
;
6190 } OSVERSIONINFOEXW
, *POSVERSIONINFOEXW
, *LPOSVERSIONINFOEXW
, RTL_OSVERSIONINFOEXW
, *PRTL_OSVERSIONINFOEXW
;
6192 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX
)
6193 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX
)
6194 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX
)
6196 NTSYSAPI ULONGLONG WINAPI
VerSetConditionMask(ULONGLONG
,DWORD
,BYTE
);
6198 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
6200 #define VER_PLATFORM_WIN32s 0
6201 #define VER_PLATFORM_WIN32_WINDOWS 1
6202 #define VER_PLATFORM_WIN32_NT 2
6204 #define VER_MINORVERSION 0x00000001
6205 #define VER_MAJORVERSION 0x00000002
6206 #define VER_BUILDNUMBER 0x00000004
6207 #define VER_PLATFORMID 0x00000008
6208 #define VER_SERVICEPACKMINOR 0x00000010
6209 #define VER_SERVICEPACKMAJOR 0x00000020
6210 #define VER_SUITENAME 0x00000040
6211 #define VER_PRODUCT_TYPE 0x00000080
6213 #define VER_NT_WORKSTATION 1
6214 #define VER_NT_DOMAIN_CONTROLLER 2
6215 #define VER_NT_SERVER 3
6217 #define VER_SUITE_SMALLBUSINESS 0x00000001
6218 #define VER_SUITE_ENTERPRISE 0x00000002
6219 #define VER_SUITE_BACKOFFICE 0x00000004
6220 #define VER_SUITE_COMMUNICATIONS 0x00000008
6221 #define VER_SUITE_TERMINAL 0x00000010
6222 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
6223 #define VER_SUITE_EMBEDDEDNT 0x00000040
6224 #define VER_SUITE_DATACENTER 0x00000080
6225 #define VER_SUITE_SINGLEUSERTS 0x00000100
6226 #define VER_SUITE_PERSONAL 0x00000200
6227 #define VER_SUITE_BLADE 0x00000400
6228 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
6229 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
6230 #define VER_SUITE_STORAGE_SERVER 0x00002000
6231 #define VER_SUITE_COMPUTE_SERVER 0x00004000
6232 #define VER_SUITE_WH_SERVER 0x00008000
6235 #define VER_GREATER 2
6236 #define VER_GREATER_EQUAL 3
6238 #define VER_LESS_EQUAL 5
6242 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION
{
6244 DWORD ulFormatVersion
;
6245 DWORD ulAssemblyCount
;
6246 DWORD ulRootManifestPathType
;
6247 DWORD ulRootManifestPathChars
;
6248 DWORD ulRootConfigurationPathType
;
6249 DWORD ulRootConfigurationPathChars
;
6250 DWORD ulAppDirPathType
;
6251 DWORD ulAppDirPathChars
;
6252 PCWSTR lpRootManifestPath
;
6253 PCWSTR lpRootConfigurationPath
;
6254 PCWSTR lpAppDirPath
;
6255 } ACTIVATION_CONTEXT_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_DETAILED_INFORMATION
;
6257 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
{
6259 DWORD ulEncodedAssemblyIdentityLength
;
6260 DWORD ulManifestPathType
;
6261 DWORD ulManifestPathLength
;
6262 LARGE_INTEGER liManifestLastWriteTime
;
6263 DWORD ulPolicyPathType
;
6264 DWORD ulPolicyPathLength
;
6265 LARGE_INTEGER liPolicyLastWriteTime
;
6266 DWORD ulMetadataSatelliteRosterIndex
;
6267 DWORD ulManifestVersionMajor
;
6268 DWORD ulManifestVersionMinor
;
6269 DWORD ulPolicyVersionMajor
;
6270 DWORD ulPolicyVersionMinor
;
6271 DWORD ulAssemblyDirectoryNameLength
;
6272 PCWSTR lpAssemblyEncodedAssemblyIdentity
;
6273 PCWSTR lpAssemblyManifestPath
;
6274 PCWSTR lpAssemblyPolicyPath
;
6275 PCWSTR lpAssemblyDirectoryName
;
6277 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
;
6279 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX
{
6280 DWORD ulAssemblyIndex
;
6281 DWORD ulFileIndexInAssembly
;
6282 } ACTIVATION_CONTEXT_QUERY_INDEX
, *PACTIVATION_CONTEXT_QUERY_INDEX
;
6284 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX
*PCACTIVATION_CONTEXT_QUERY_INDEX
;
6286 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION
{
6288 DWORD ulFilenameLength
;
6292 } ASSEMBLY_FILE_DETAILED_INFORMATION
, *PASSEMBLY_FILE_DETAILED_INFORMATION
;
6294 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION
*PCASSEMBLY_FILE_DETAILED_INFORMATION
;
6297 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN
= 0,
6298 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
,
6299 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION
,
6300 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6301 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE
;
6303 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT
{
6305 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type
;
6306 } COMPATIBILITY_CONTEXT_ELEMENT
, *PCOMPATIBILITY_CONTEXT_ELEMENT
;
6308 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6309 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
{
6311 COMPATIBILITY_CONTEXT_ELEMENT Elements
[];
6312 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION
;
6316 ACTCTX_RUN_LEVEL_UNSPECIFIED
= 0,
6317 ACTCTX_RUN_LEVEL_AS_INVOKER
,
6318 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE
,
6319 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN
,
6320 ACTCTX_RUN_LEVEL_NUMBERS
6321 } ACTCTX_REQUESTED_RUN_LEVEL
;
6323 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
{
6325 ACTCTX_REQUESTED_RUN_LEVEL RunLevel
;
6327 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
6329 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
*PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION
;
6331 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS
{
6332 ActivationContextBasicInformation
= 1,
6333 ActivationContextDetailedInformation
= 2,
6334 AssemblyDetailedInformationInActivationContext
= 3,
6335 FileInformationInAssemblyOfAssemblyInActivationContext
= 4,
6336 RunlevelInformationInActivationContext
= 5,
6337 CompatibilityInformationInActivationContext
= 6,
6338 ActivationContextManifestResourceName
= 7,
6339 MaxActivationContextInfoClass
,
6340 AssemblyDetailedInformationInActivationContxt
= AssemblyDetailedInformationInActivationContext
,
6341 FileInformationInAssemblyOfAssemblyInActivationContxt
= FileInformationInAssemblyOfAssemblyInActivationContext
6342 } ACTIVATION_CONTEXT_INFO_CLASS
;
6344 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6345 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6346 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6347 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6349 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6350 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6351 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6352 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6353 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6354 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6355 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6356 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6357 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6358 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6359 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6361 typedef enum _JOBOBJECTINFOCLASS
6363 JobObjectBasicAccountingInformation
= 1,
6364 JobObjectBasicLimitInformation
,
6365 JobObjectBasicProcessIdList
,
6366 JobObjectBasicUIRestrictions
,
6367 JobObjectSecurityLimitInformation
,
6368 JobObjectEndOfJobTimeInformation
,
6369 JobObjectAssociateCompletionPortInformation
,
6370 JobObjectBasicAndIoAccountingInformation
,
6371 JobObjectExtendedLimitInformation
,
6372 JobObjectJobSetInformation
,
6373 MaxJobObjectInfoClass
6374 } JOBOBJECTINFOCLASS
;
6376 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
{
6377 LARGE_INTEGER TotalUserTime
;
6378 LARGE_INTEGER TotalKernelTime
;
6379 LARGE_INTEGER ThisPeriodTotalUserTime
;
6380 LARGE_INTEGER ThisPeriodTotalKernelTime
;
6381 DWORD TotalPageFaultCount
;
6382 DWORD TotalProcesses
;
6383 DWORD ActiveProcesses
;
6384 DWORD TotalTerminatedProcesses
;
6385 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION
;
6387 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION
{
6388 LARGE_INTEGER PerProcessUserTimeLimit
;
6389 LARGE_INTEGER PerJobUserTimeLimit
;
6391 SIZE_T MinimumWorkingSetSize
;
6392 SIZE_T MaximumWorkingSetSize
;
6393 DWORD ActiveProcessLimit
;
6395 DWORD PriorityClass
;
6396 DWORD SchedulingClass
;
6397 } JOBOBJECT_BASIC_LIMIT_INFORMATION
, *PJOBOBJECT_BASIC_LIMIT_INFORMATION
;
6399 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST
{
6400 DWORD NumberOfAssignedProcesses
;
6401 DWORD NumberOfProcessIdsInList
;
6402 ULONG_PTR ProcessIdList
[1];
6403 } JOBOBJECT_BASIC_PROCESS_ID_LIST
, *PJOBOBJECT_BASIC_PROCESS_ID_LIST
;
6405 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS
{
6406 DWORD UIRestrictionsClass
;
6407 } JOBOBJECT_BASIC_UI_RESTRICTIONS
, *PJOBOBJECT_BASIC_UI_RESTRICTIONS
;
6409 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION
{
6410 DWORD SecurityLimitFlags
;
6412 PTOKEN_GROUPS SidsToDisable
;
6413 PTOKEN_PRIVILEGES PrivilegesToDelete
;
6414 PTOKEN_GROUPS RestrictedSids
;
6415 } JOBOBJECT_SECURITY_LIMIT_INFORMATION
, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION
;
6417 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION
{
6418 DWORD EndOfJobTimeAction
;
6419 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION
, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION
;
6421 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT
{
6422 PVOID CompletionKey
;
6423 HANDLE CompletionPort
;
6424 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT
, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT
;
6426 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6427 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6428 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6429 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6430 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6431 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6432 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6433 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6434 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6436 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
{
6437 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo
;
6439 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION
;
6441 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION
{
6442 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation
;
6444 SIZE_T ProcessMemoryLimit
;
6445 SIZE_T JobMemoryLimit
;
6446 SIZE_T PeakProcessMemoryUsed
;
6447 SIZE_T PeakJobMemoryUsed
;
6448 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION
, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION
;
6450 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6451 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6452 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6453 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6454 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6455 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6456 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6457 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6458 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6459 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6460 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6461 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6462 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6463 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6464 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6466 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6467 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6468 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6470 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6472 RelationProcessorCore
= 0,
6473 RelationNumaNode
= 1,
6475 RelationProcessorPackage
= 3,
6477 RelationAll
= 0xffff
6478 } LOGICAL_PROCESSOR_RELATIONSHIP
;
6480 #define LTP_PC_SMT 0x1
6482 typedef enum _PROCESSOR_CACHE_TYPE
6488 } PROCESSOR_CACHE_TYPE
;
6490 typedef struct _PROCESSOR_GROUP_INFO
6492 BYTE MaximumProcessorCount
;
6493 BYTE ActiveProcessorCount
;
6495 KAFFINITY ActiveProcessorMask
;
6496 } PROCESSOR_GROUP_INFO
, *PPROCESSOR_GROUP_INFO
;
6498 typedef struct _CACHE_DESCRIPTOR
6504 PROCESSOR_CACHE_TYPE Type
;
6505 } CACHE_DESCRIPTOR
, *PCACHE_DESCRIPTOR
;
6507 typedef struct _GROUP_AFFINITY
6512 } GROUP_AFFINITY
, *PGROUP_AFFINITY
;
6514 #define ALL_PROCESSOR_GROUPS 0xffff
6516 typedef struct _PROCESSOR_NUMBER
6521 } PROCESSOR_NUMBER
, *PPROCESSOR_NUMBER
;
6523 typedef struct _PROCESSOR_RELATIONSHIP
6526 BYTE EfficiencyClass
;
6529 GROUP_AFFINITY GroupMask
[ANYSIZE_ARRAY
];
6530 } PROCESSOR_RELATIONSHIP
, *PPROCESSOR_RELATIONSHIP
;
6532 typedef struct _NUMA_NODE_RELATIONSHIP
6536 GROUP_AFFINITY GroupMask
;
6537 } NUMA_NODE_RELATIONSHIP
, *PNUMA_NODE_RELATIONSHIP
;
6539 typedef struct _CACHE_RELATIONSHIP
6545 PROCESSOR_CACHE_TYPE Type
;
6547 GROUP_AFFINITY GroupMask
;
6548 } CACHE_RELATIONSHIP
, *PCACHE_RELATIONSHIP
;
6550 typedef struct _GROUP_RELATIONSHIP
6552 WORD MaximumGroupCount
;
6553 WORD ActiveGroupCount
;
6555 PROCESSOR_GROUP_INFO GroupInfo
[ANYSIZE_ARRAY
];
6556 } GROUP_RELATIONSHIP
, *PGROUP_RELATIONSHIP
;
6558 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6560 ULONG_PTR ProcessorMask
;
6561 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6572 CACHE_DESCRIPTOR Cache
;
6573 ULONGLONG Reserved
[2];
6575 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION
;
6577 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6579 LOGICAL_PROCESSOR_RELATIONSHIP Relationship
;
6583 PROCESSOR_RELATIONSHIP Processor
;
6584 NUMA_NODE_RELATIONSHIP NumaNode
;
6585 CACHE_RELATIONSHIP Cache
;
6586 GROUP_RELATIONSHIP Group
;
6588 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
;
6590 /* Threadpool things */
6591 typedef DWORD TP_VERSION
,*PTP_VERSION
;
6593 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE
,*PTP_CALLBACK_INSTANCE
;
6595 typedef VOID (CALLBACK
*PTP_SIMPLE_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
);
6597 typedef struct _TP_POOL TP_POOL
,*PTP_POOL
;
6599 typedef enum _TP_CALLBACK_PRIORITY
6601 TP_CALLBACK_PRIORITY_HIGH
,
6602 TP_CALLBACK_PRIORITY_NORMAL
,
6603 TP_CALLBACK_PRIORITY_LOW
,
6604 TP_CALLBACK_PRIORITY_INVALID
,
6605 TP_CALLBACK_PRIORITY_COUNT
= TP_CALLBACK_PRIORITY_INVALID
6606 } TP_CALLBACK_PRIORITY
;
6608 typedef struct _TP_POOL_STACK_INFORMATION
6610 SIZE_T StackReserve
;
6612 } TP_POOL_STACK_INFORMATION
,*PTP_POOL_STACK_INFORMATION
;
6614 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP
,*PTP_CLEANUP_GROUP
;
6616 typedef VOID (CALLBACK
*PTP_CLEANUP_GROUP_CANCEL_CALLBACK
)(PVOID
,PVOID
);
6618 typedef struct _TP_CALLBACK_ENVIRON_V1
6622 PTP_CLEANUP_GROUP CleanupGroup
;
6623 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6625 struct _ACTIVATION_CONTEXT
* ActivationContext
;
6626 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6632 DWORD LongFunction
:1;
6637 } TP_CALLBACK_ENVIRON_V1
;
6639 typedef struct _TP_CALLBACK_ENVIRON_V3
6643 PTP_CLEANUP_GROUP CleanupGroup
;
6644 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback
;
6646 struct _ACTIVATION_CONTEXT
*ActivationContext
;
6647 PTP_SIMPLE_CALLBACK FinalizationCallback
;
6653 DWORD LongFunction
:1;
6658 TP_CALLBACK_PRIORITY CallbackPriority
;
6660 } TP_CALLBACK_ENVIRON_V3
;
6662 typedef struct _TP_WORK TP_WORK
, *PTP_WORK
;
6663 typedef struct _TP_TIMER TP_TIMER
, *PTP_TIMER
;
6665 typedef DWORD TP_WAIT_RESULT
;
6666 typedef struct _TP_WAIT TP_WAIT
, *PTP_WAIT
;
6668 typedef struct _TP_IO TP_IO
, *PTP_IO
;
6670 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON
, *PTP_CALLBACK_ENVIRON
;
6672 typedef VOID (CALLBACK
*PTP_WORK_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WORK
);
6673 typedef VOID (CALLBACK
*PTP_TIMER_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_TIMER
);
6674 typedef VOID (CALLBACK
*PTP_WAIT_CALLBACK
)(PTP_CALLBACK_INSTANCE
,PVOID
,PTP_WAIT
,TP_WAIT_RESULT
);
6677 NTSYSAPI BOOLEAN NTAPI
RtlGetProductInfo(DWORD
,DWORD
,DWORD
,DWORD
,PDWORD
);
6679 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6681 UmsThreadInvalidInfoClass
,
6682 UmsThreadUserContext
,
6686 UmsThreadIsSuspended
,
6687 UmsThreadIsTerminated
,
6688 UmsThreadMaxInfoClass
6689 } RTL_UMS_THREAD_INFO_CLASS
, *PRTL_UMS_THREAD_INFO_CLASS
;
6691 typedef enum _RTL_UMS_SCHEDULER_REASON
6693 UmsSchedulerStartup
,
6694 UmsSchedulerThreadBlocked
,
6695 UmsSchedulerThreadYield
,
6696 } RTL_UMS_SCHEDULER_REASON
, *PRTL_UMS_SCHEDULER_REASON
;
6698 typedef void (CALLBACK
*PRTL_UMS_SCHEDULER_ENTRY_POINT
)(RTL_UMS_SCHEDULER_REASON
,ULONG_PTR
,PVOID
);
6700 typedef enum _PROCESS_MITIGATION_POLICY
6704 ProcessDynamicCodePolicy
,
6705 ProcessStrictHandleCheckPolicy
,
6706 ProcessSystemCallDisablePolicy
,
6707 ProcessMitigationOptionsMask
,
6708 ProcessExtensionPointDisablePolicy
,
6709 ProcessControlFlowGuardPolicy
,
6710 ProcessSignaturePolicy
,
6711 ProcessFontDisablePolicy
,
6712 ProcessImageLoadPolicy
,
6713 ProcessSystemCallFilterPolicy
,
6714 ProcessPayloadRestrictionPolicy
,
6715 ProcessChildProcessPolicy
,
6716 ProcessSideChannelIsolationPolicy
,
6717 MaxProcessMitigationPolicy
6718 } PROCESS_MITIGATION_POLICY
, *PPROCESS_MITIGATION_POLICY
;
6722 BOOLEAN
_BitScanForward(unsigned long*,unsigned long);
6723 BOOLEAN
_BitScanReverse(unsigned long*,unsigned long);
6725 #pragma intrinsic(_BitScanForward)
6726 #pragma intrinsic(_BitScanReverse)
6728 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6730 return _BitScanForward((unsigned long*)index
, mask
);
6733 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6735 return _BitScanReverse((unsigned long*)index
, mask
);
6738 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
6740 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6742 *index
= __builtin_ctz(mask
);
6746 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6748 *index
= 31 - __builtin_clz(mask
);
6754 static inline BOOLEAN
BitScanForward(DWORD
*index
, DWORD mask
)
6757 while (r
< 31 && !(mask
& (1 << r
))) r
++;
6762 static inline BOOLEAN
BitScanReverse(DWORD
*index
, DWORD mask
)
6764 unsigned int r
= 31;
6765 while (r
> 0 && !(mask
& (1 << r
))) r
--;
6776 #endif /* _WINNT_ */