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