winemac.drv: Set DM_POSITION and DM_DISPLAYORIENTATION when reporting registry displa...
[wine.git] / include / winnt.h
blob863b19eae58f57d2eff4435004f8b571b690e217
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
933 /* Execution state flags */
934 #define ES_SYSTEM_REQUIRED 0x00000001
935 #define ES_DISPLAY_REQUIRED 0x00000002
936 #define ES_USER_PRESENT 0x00000004
937 #define ES_CONTINUOUS 0x80000000
939 #include <excpt.h>
941 struct _CONTEXT;
942 struct _EXCEPTION_POINTERS;
943 struct _EXCEPTION_RECORD;
945 typedef EXCEPTION_DISPOSITION WINAPI EXCEPTION_ROUTINE(struct _EXCEPTION_RECORD*,PVOID,
946 struct _CONTEXT*,PVOID);
947 typedef EXCEPTION_ROUTINE *PEXCEPTION_ROUTINE;
949 /* The Win32 register context */
951 /* i386 context definitions */
952 #ifdef __i386__
954 #define SIZE_OF_80387_REGISTERS 80
956 typedef struct _FLOATING_SAVE_AREA
958 DWORD ControlWord;
959 DWORD StatusWord;
960 DWORD TagWord;
961 DWORD ErrorOffset;
962 DWORD ErrorSelector;
963 DWORD DataOffset;
964 DWORD DataSelector;
965 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
966 DWORD Cr0NpxState;
967 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
969 #define MAXIMUM_SUPPORTED_EXTENSION 512
971 typedef struct _CONTEXT
973 DWORD ContextFlags; /* 000 */
975 /* These are selected by CONTEXT_DEBUG_REGISTERS */
976 DWORD Dr0; /* 004 */
977 DWORD Dr1; /* 008 */
978 DWORD Dr2; /* 00c */
979 DWORD Dr3; /* 010 */
980 DWORD Dr6; /* 014 */
981 DWORD Dr7; /* 018 */
983 /* These are selected by CONTEXT_FLOATING_POINT */
984 FLOATING_SAVE_AREA FloatSave; /* 01c */
986 /* These are selected by CONTEXT_SEGMENTS */
987 DWORD SegGs; /* 08c */
988 DWORD SegFs; /* 090 */
989 DWORD SegEs; /* 094 */
990 DWORD SegDs; /* 098 */
992 /* These are selected by CONTEXT_INTEGER */
993 DWORD Edi; /* 09c */
994 DWORD Esi; /* 0a0 */
995 DWORD Ebx; /* 0a4 */
996 DWORD Edx; /* 0a8 */
997 DWORD Ecx; /* 0ac */
998 DWORD Eax; /* 0b0 */
1000 /* These are selected by CONTEXT_CONTROL */
1001 DWORD Ebp; /* 0b4 */
1002 DWORD Eip; /* 0b8 */
1003 DWORD SegCs; /* 0bc */
1004 DWORD EFlags; /* 0c0 */
1005 DWORD Esp; /* 0c4 */
1006 DWORD SegSs; /* 0c8 */
1008 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; /* 0xcc */
1009 } CONTEXT, *PCONTEXT;
1011 #define CONTEXT_X86 0x00010000
1012 #define CONTEXT_i386 CONTEXT_X86
1013 #define CONTEXT_i486 CONTEXT_X86
1015 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
1016 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
1017 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
1018 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
1019 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
1020 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
1021 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x0040)
1022 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
1023 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
1024 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
1026 #define EXCEPTION_READ_FAULT 0
1027 #define EXCEPTION_WRITE_FAULT 1
1028 #define EXCEPTION_EXECUTE_FAULT 8
1030 #endif /* __i386__ */
1032 typedef struct _LDT_ENTRY {
1033 WORD LimitLow;
1034 WORD BaseLow;
1035 union {
1036 struct {
1037 BYTE BaseMid;
1038 BYTE Flags1;
1039 BYTE Flags2;
1040 BYTE BaseHi;
1041 } Bytes;
1042 struct {
1043 unsigned BaseMid: 8;
1044 unsigned Type : 5;
1045 unsigned Dpl : 2;
1046 unsigned Pres : 1;
1047 unsigned LimitHi : 4;
1048 unsigned Sys : 1;
1049 unsigned Reserved_0 : 1;
1050 unsigned Default_Big : 1;
1051 unsigned Granularity : 1;
1052 unsigned BaseHi : 8;
1053 } Bits;
1054 } HighWord;
1055 } LDT_ENTRY, *PLDT_ENTRY, WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
1057 /* x86-64 context definitions */
1058 #if defined(__x86_64__)
1060 #define CONTEXT_AMD64 0x00100000
1062 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
1063 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
1064 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1065 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1066 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1067 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x0040)
1068 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1069 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1071 #define EXCEPTION_READ_FAULT 0
1072 #define EXCEPTION_WRITE_FAULT 1
1073 #define EXCEPTION_EXECUTE_FAULT 8
1075 typedef struct DECLSPEC_ALIGN(16) _M128A {
1076 ULONGLONG Low;
1077 LONGLONG High;
1078 } M128A, *PM128A;
1080 typedef struct _XMM_SAVE_AREA32 {
1081 WORD ControlWord; /* 000 */
1082 WORD StatusWord; /* 002 */
1083 BYTE TagWord; /* 004 */
1084 BYTE Reserved1; /* 005 */
1085 WORD ErrorOpcode; /* 006 */
1086 DWORD ErrorOffset; /* 008 */
1087 WORD ErrorSelector; /* 00c */
1088 WORD Reserved2; /* 00e */
1089 DWORD DataOffset; /* 010 */
1090 WORD DataSelector; /* 014 */
1091 WORD Reserved3; /* 016 */
1092 DWORD MxCsr; /* 018 */
1093 DWORD MxCsr_Mask; /* 01c */
1094 M128A FloatRegisters[8]; /* 020 */
1095 M128A XmmRegisters[16]; /* 0a0 */
1096 BYTE Reserved4[96]; /* 1a0 */
1097 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1099 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1100 DWORD64 P1Home; /* 000 */
1101 DWORD64 P2Home; /* 008 */
1102 DWORD64 P3Home; /* 010 */
1103 DWORD64 P4Home; /* 018 */
1104 DWORD64 P5Home; /* 020 */
1105 DWORD64 P6Home; /* 028 */
1107 /* Control flags */
1108 DWORD ContextFlags; /* 030 */
1109 DWORD MxCsr; /* 034 */
1111 /* Segment */
1112 WORD SegCs; /* 038 */
1113 WORD SegDs; /* 03a */
1114 WORD SegEs; /* 03c */
1115 WORD SegFs; /* 03e */
1116 WORD SegGs; /* 040 */
1117 WORD SegSs; /* 042 */
1118 DWORD EFlags; /* 044 */
1120 /* Debug */
1121 DWORD64 Dr0; /* 048 */
1122 DWORD64 Dr1; /* 050 */
1123 DWORD64 Dr2; /* 058 */
1124 DWORD64 Dr3; /* 060 */
1125 DWORD64 Dr6; /* 068 */
1126 DWORD64 Dr7; /* 070 */
1128 /* Integer */
1129 DWORD64 Rax; /* 078 */
1130 DWORD64 Rcx; /* 080 */
1131 DWORD64 Rdx; /* 088 */
1132 DWORD64 Rbx; /* 090 */
1133 DWORD64 Rsp; /* 098 */
1134 DWORD64 Rbp; /* 0a0 */
1135 DWORD64 Rsi; /* 0a8 */
1136 DWORD64 Rdi; /* 0b0 */
1137 DWORD64 R8; /* 0b8 */
1138 DWORD64 R9; /* 0c0 */
1139 DWORD64 R10; /* 0c8 */
1140 DWORD64 R11; /* 0d0 */
1141 DWORD64 R12; /* 0d8 */
1142 DWORD64 R13; /* 0e0 */
1143 DWORD64 R14; /* 0e8 */
1144 DWORD64 R15; /* 0f0 */
1146 /* Counter */
1147 DWORD64 Rip; /* 0f8 */
1149 /* Floating point */
1150 union {
1151 XMM_SAVE_AREA32 FltSave; /* 100 */
1152 struct {
1153 M128A Header[2]; /* 100 */
1154 M128A Legacy[8]; /* 120 */
1155 M128A Xmm0; /* 1a0 */
1156 M128A Xmm1; /* 1b0 */
1157 M128A Xmm2; /* 1c0 */
1158 M128A Xmm3; /* 1d0 */
1159 M128A Xmm4; /* 1e0 */
1160 M128A Xmm5; /* 1f0 */
1161 M128A Xmm6; /* 200 */
1162 M128A Xmm7; /* 210 */
1163 M128A Xmm8; /* 220 */
1164 M128A Xmm9; /* 230 */
1165 M128A Xmm10; /* 240 */
1166 M128A Xmm11; /* 250 */
1167 M128A Xmm12; /* 260 */
1168 M128A Xmm13; /* 270 */
1169 M128A Xmm14; /* 280 */
1170 M128A Xmm15; /* 290 */
1171 } DUMMYSTRUCTNAME;
1172 } DUMMYUNIONNAME;
1174 /* Vector */
1175 M128A VectorRegister[26]; /* 300 */
1176 DWORD64 VectorControl; /* 4a0 */
1178 /* Debug control */
1179 DWORD64 DebugControl; /* 4a8 */
1180 DWORD64 LastBranchToRip; /* 4b0 */
1181 DWORD64 LastBranchFromRip; /* 4b8 */
1182 DWORD64 LastExceptionToRip; /* 4c0 */
1183 DWORD64 LastExceptionFromRip; /* 4c8 */
1184 } CONTEXT, *PCONTEXT;
1186 typedef struct _RUNTIME_FUNCTION
1188 DWORD BeginAddress;
1189 DWORD EndAddress;
1190 DWORD UnwindData;
1191 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1193 #define UNWIND_HISTORY_TABLE_SIZE 12
1195 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1197 ULONG64 ImageBase;
1198 PRUNTIME_FUNCTION FunctionEntry;
1199 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1201 #define UNWIND_HISTORY_TABLE_NONE 0
1202 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1203 #define UNWIND_HISTORY_TABLE_LOCAL 2
1205 typedef struct _UNWIND_HISTORY_TABLE
1207 ULONG Count;
1208 UCHAR Search;
1209 ULONG64 LowAddress;
1210 ULONG64 HighAddress;
1211 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1212 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1214 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1216 union
1218 PM128A FloatingContext[16];
1219 struct
1221 PM128A Xmm0;
1222 PM128A Xmm1;
1223 PM128A Xmm2;
1224 PM128A Xmm3;
1225 PM128A Xmm4;
1226 PM128A Xmm5;
1227 PM128A Xmm6;
1228 PM128A Xmm7;
1229 PM128A Xmm8;
1230 PM128A Xmm9;
1231 PM128A Xmm10;
1232 PM128A Xmm11;
1233 PM128A Xmm12;
1234 PM128A Xmm13;
1235 PM128A Xmm14;
1236 PM128A Xmm15;
1237 } DUMMYSTRUCTNAME;
1238 } DUMMYUNIONNAME;
1240 union
1242 PULONG64 IntegerContext[16];
1243 struct
1245 PULONG64 Rax;
1246 PULONG64 Rcx;
1247 PULONG64 Rdx;
1248 PULONG64 Rbx;
1249 PULONG64 Rsp;
1250 PULONG64 Rbp;
1251 PULONG64 Rsi;
1252 PULONG64 Rdi;
1253 PULONG64 R8;
1254 PULONG64 R9;
1255 PULONG64 R10;
1256 PULONG64 R11;
1257 PULONG64 R12;
1258 PULONG64 R13;
1259 PULONG64 R14;
1260 PULONG64 R15;
1261 } DUMMYSTRUCTNAME;
1262 } DUMMYUNIONNAME2;
1263 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1265 typedef struct _DISPATCHER_CONTEXT
1267 ULONG64 ControlPc;
1268 ULONG64 ImageBase;
1269 PRUNTIME_FUNCTION FunctionEntry;
1270 ULONG64 EstablisherFrame;
1271 ULONG64 TargetIp;
1272 PCONTEXT ContextRecord;
1273 PEXCEPTION_ROUTINE LanguageHandler;
1274 PVOID HandlerData;
1275 PUNWIND_HISTORY_TABLE HistoryTable;
1276 DWORD ScopeIndex;
1277 DWORD Fill0;
1278 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1280 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,PVOID);
1281 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,PVOID);
1283 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1285 #define UNW_FLAG_NHANDLER 0
1286 #define UNW_FLAG_EHANDLER 1
1287 #define UNW_FLAG_UHANDLER 2
1288 #define UNW_FLAG_CHAININFO 4
1290 #endif /* __x86_64__ */
1292 /* IA64 context definitions */
1293 #ifdef __ia64__
1295 #define CONTEXT_IA64 0x00080000
1296 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1297 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1298 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1299 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1300 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1301 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1302 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1303 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1304 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1306 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1307 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1308 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1309 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1311 typedef struct _CONTEXT
1313 DWORD ContextFlags;
1314 DWORD Fill1[3];
1315 ULONGLONG DbI0;
1316 ULONGLONG DbI1;
1317 ULONGLONG DbI2;
1318 ULONGLONG DbI3;
1319 ULONGLONG DbI4;
1320 ULONGLONG DbI5;
1321 ULONGLONG DbI6;
1322 ULONGLONG DbI7;
1323 ULONGLONG DbD0;
1324 ULONGLONG DbD1;
1325 ULONGLONG DbD2;
1326 ULONGLONG DbD3;
1327 ULONGLONG DbD4;
1328 ULONGLONG DbD5;
1329 ULONGLONG DbD6;
1330 ULONGLONG DbD7;
1331 FLOAT128 FltS0;
1332 FLOAT128 FltS1;
1333 FLOAT128 FltS2;
1334 FLOAT128 FltS3;
1335 FLOAT128 FltT0;
1336 FLOAT128 FltT1;
1337 FLOAT128 FltT2;
1338 FLOAT128 FltT3;
1339 FLOAT128 FltT4;
1340 FLOAT128 FltT5;
1341 FLOAT128 FltT6;
1342 FLOAT128 FltT7;
1343 FLOAT128 FltT8;
1344 FLOAT128 FltT9;
1345 FLOAT128 FltS4;
1346 FLOAT128 FltS5;
1347 FLOAT128 FltS6;
1348 FLOAT128 FltS7;
1349 FLOAT128 FltS8;
1350 FLOAT128 FltS9;
1351 FLOAT128 FltS10;
1352 FLOAT128 FltS11;
1353 FLOAT128 FltS12;
1354 FLOAT128 FltS13;
1355 FLOAT128 FltS14;
1356 FLOAT128 FltS15;
1357 FLOAT128 FltS16;
1358 FLOAT128 FltS17;
1359 FLOAT128 FltS18;
1360 FLOAT128 FltS19;
1361 FLOAT128 FltF32;
1362 FLOAT128 FltF33;
1363 FLOAT128 FltF34;
1364 FLOAT128 FltF35;
1365 FLOAT128 FltF36;
1366 FLOAT128 FltF37;
1367 FLOAT128 FltF38;
1368 FLOAT128 FltF39;
1369 FLOAT128 FltF40;
1370 FLOAT128 FltF41;
1371 FLOAT128 FltF42;
1372 FLOAT128 FltF43;
1373 FLOAT128 FltF44;
1374 FLOAT128 FltF45;
1375 FLOAT128 FltF46;
1376 FLOAT128 FltF47;
1377 FLOAT128 FltF48;
1378 FLOAT128 FltF49;
1379 FLOAT128 FltF50;
1380 FLOAT128 FltF51;
1381 FLOAT128 FltF52;
1382 FLOAT128 FltF53;
1383 FLOAT128 FltF54;
1384 FLOAT128 FltF55;
1385 FLOAT128 FltF56;
1386 FLOAT128 FltF57;
1387 FLOAT128 FltF58;
1388 FLOAT128 FltF59;
1389 FLOAT128 FltF60;
1390 FLOAT128 FltF61;
1391 FLOAT128 FltF62;
1392 FLOAT128 FltF63;
1393 FLOAT128 FltF64;
1394 FLOAT128 FltF65;
1395 FLOAT128 FltF66;
1396 FLOAT128 FltF67;
1397 FLOAT128 FltF68;
1398 FLOAT128 FltF69;
1399 FLOAT128 FltF70;
1400 FLOAT128 FltF71;
1401 FLOAT128 FltF72;
1402 FLOAT128 FltF73;
1403 FLOAT128 FltF74;
1404 FLOAT128 FltF75;
1405 FLOAT128 FltF76;
1406 FLOAT128 FltF77;
1407 FLOAT128 FltF78;
1408 FLOAT128 FltF79;
1409 FLOAT128 FltF80;
1410 FLOAT128 FltF81;
1411 FLOAT128 FltF82;
1412 FLOAT128 FltF83;
1413 FLOAT128 FltF84;
1414 FLOAT128 FltF85;
1415 FLOAT128 FltF86;
1416 FLOAT128 FltF87;
1417 FLOAT128 FltF88;
1418 FLOAT128 FltF89;
1419 FLOAT128 FltF90;
1420 FLOAT128 FltF91;
1421 FLOAT128 FltF92;
1422 FLOAT128 FltF93;
1423 FLOAT128 FltF94;
1424 FLOAT128 FltF95;
1425 FLOAT128 FltF96;
1426 FLOAT128 FltF97;
1427 FLOAT128 FltF98;
1428 FLOAT128 FltF99;
1429 FLOAT128 FltF100;
1430 FLOAT128 FltF101;
1431 FLOAT128 FltF102;
1432 FLOAT128 FltF103;
1433 FLOAT128 FltF104;
1434 FLOAT128 FltF105;
1435 FLOAT128 FltF106;
1436 FLOAT128 FltF107;
1437 FLOAT128 FltF108;
1438 FLOAT128 FltF109;
1439 FLOAT128 FltF110;
1440 FLOAT128 FltF111;
1441 FLOAT128 FltF112;
1442 FLOAT128 FltF113;
1443 FLOAT128 FltF114;
1444 FLOAT128 FltF115;
1445 FLOAT128 FltF116;
1446 FLOAT128 FltF117;
1447 FLOAT128 FltF118;
1448 FLOAT128 FltF119;
1449 FLOAT128 FltF120;
1450 FLOAT128 FltF121;
1451 FLOAT128 FltF122;
1452 FLOAT128 FltF123;
1453 FLOAT128 FltF124;
1454 FLOAT128 FltF125;
1455 FLOAT128 FltF126;
1456 FLOAT128 FltF127;
1457 ULONGLONG StFPSR;
1458 ULONGLONG IntGp;
1459 ULONGLONG IntT0;
1460 ULONGLONG IntT1;
1461 ULONGLONG IntS0;
1462 ULONGLONG IntS1;
1463 ULONGLONG IntS2;
1464 ULONGLONG IntS3;
1465 ULONGLONG IntV0;
1466 ULONGLONG IntT2;
1467 ULONGLONG IntT3;
1468 ULONGLONG IntT4;
1469 ULONGLONG IntSp;
1470 ULONGLONG IntTeb;
1471 ULONGLONG IntT5;
1472 ULONGLONG IntT6;
1473 ULONGLONG IntT7;
1474 ULONGLONG IntT8;
1475 ULONGLONG IntT9;
1476 ULONGLONG IntT10;
1477 ULONGLONG IntT11;
1478 ULONGLONG IntT12;
1479 ULONGLONG IntT13;
1480 ULONGLONG IntT14;
1481 ULONGLONG IntT15;
1482 ULONGLONG IntT16;
1483 ULONGLONG IntT17;
1484 ULONGLONG IntT18;
1485 ULONGLONG IntT19;
1486 ULONGLONG IntT20;
1487 ULONGLONG IntT21;
1488 ULONGLONG IntT22;
1489 ULONGLONG IntNats;
1490 ULONGLONG Preds;
1491 ULONGLONG BrRp;
1492 ULONGLONG BrS0;
1493 ULONGLONG BrS1;
1494 ULONGLONG BrS2;
1495 ULONGLONG BrS3;
1496 ULONGLONG BrS4;
1497 ULONGLONG BrT0;
1498 ULONGLONG BrT1;
1499 ULONGLONG ApUNAT;
1500 ULONGLONG ApLC;
1501 ULONGLONG ApEC;
1502 ULONGLONG ApCCV;
1503 ULONGLONG ApDCR;
1504 ULONGLONG RsPFS;
1505 ULONGLONG RsBSP;
1506 ULONGLONG RsBSPSTORE;
1507 ULONGLONG RsRSC;
1508 ULONGLONG RsRNAT;
1509 ULONGLONG StIPSR;
1510 ULONGLONG StIIP;
1511 ULONGLONG StIFS;
1512 ULONGLONG StFCR;
1513 ULONGLONG Eflag;
1514 ULONGLONG SegCSD;
1515 ULONGLONG SegSSD;
1516 ULONGLONG Cflag;
1517 ULONGLONG StFSR;
1518 ULONGLONG StFIR;
1519 ULONGLONG StFDR;
1520 ULONGLONG UNUSEDPACK;
1521 } CONTEXT, *PCONTEXT;
1523 typedef struct _RUNTIME_FUNCTION
1525 ULONG BeginAddress;
1526 ULONG EndAddress;
1527 ULONG UnwindInfoAddress;
1528 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1530 typedef struct _FRAME_POINTERS {
1531 ULONGLONG MemoryStackFp;
1532 ULONGLONG BackingStoreFp;
1533 } FRAME_POINTERS, *PFRAME_POINTERS;
1535 #define UNWIND_HISTORY_TABLE_SIZE 12
1537 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
1538 ULONG64 ImageBase;
1539 ULONG64 Gp;
1540 PRUNTIME_FUNCTION FunctionEntry;
1541 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1543 typedef struct _UNWIND_HISTORY_TABLE {
1544 ULONG Count;
1545 UCHAR Search;
1546 ULONG64 LowAddress;
1547 ULONG64 HighAddress;
1548 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1549 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1551 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1553 PFLOAT128 FltS0;
1554 PFLOAT128 FltS1;
1555 PFLOAT128 FltS2;
1556 PFLOAT128 FltS3;
1557 PFLOAT128 HighFloatingContext[10];
1558 PFLOAT128 FltS4;
1559 PFLOAT128 FltS5;
1560 PFLOAT128 FltS6;
1561 PFLOAT128 FltS7;
1562 PFLOAT128 FltS8;
1563 PFLOAT128 FltS9;
1564 PFLOAT128 FltS10;
1565 PFLOAT128 FltS11;
1566 PFLOAT128 FltS12;
1567 PFLOAT128 FltS13;
1568 PFLOAT128 FltS14;
1569 PFLOAT128 FltS15;
1570 PFLOAT128 FltS16;
1571 PFLOAT128 FltS17;
1572 PFLOAT128 FltS18;
1573 PFLOAT128 FltS19;
1574 PULONGLONG IntS0;
1575 PULONGLONG IntS1;
1576 PULONGLONG IntS2;
1577 PULONGLONG IntS3;
1578 PULONGLONG IntSp;
1579 PULONGLONG IntS0Nat;
1580 PULONGLONG IntS1Nat;
1581 PULONGLONG IntS2Nat;
1582 PULONGLONG IntS3Nat;
1583 PULONGLONG IntSpNat;
1584 PULONGLONG Preds;
1585 PULONGLONG BrRp;
1586 PULONGLONG BrS0;
1587 PULONGLONG BrS1;
1588 PULONGLONG BrS2;
1589 PULONGLONG BrS3;
1590 PULONGLONG BrS4;
1591 PULONGLONG ApUNAT;
1592 PULONGLONG ApLC;
1593 PULONGLONG ApEC;
1594 PULONGLONG RsPFS;
1595 PULONGLONG StFSR;
1596 PULONGLONG StFIR;
1597 PULONGLONG StFDR;
1598 PULONGLONG Cflag;
1599 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1601 NTSYSAPI ULONGLONG WINAPI RtlVirtualUnwind(ULONGLONG,ULONGLONG,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,FRAME_POINTERS*,KNONVOLATILE_CONTEXT_POINTERS*);
1603 #endif /* __ia64__ */
1605 /* Alpha context definitions */
1606 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1608 #define CONTEXT_ALPHA 0x00020000
1610 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1611 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1612 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1613 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1615 #define EXCEPTION_READ_FAULT 0
1616 #define EXCEPTION_WRITE_FAULT 1
1617 #define EXCEPTION_EXECUTE_FAULT 8
1619 typedef struct _CONTEXT
1621 /* selected by CONTEXT_FLOATING_POINT */
1622 ULONGLONG FltF0;
1623 ULONGLONG FltF1;
1624 ULONGLONG FltF2;
1625 ULONGLONG FltF3;
1626 ULONGLONG FltF4;
1627 ULONGLONG FltF5;
1628 ULONGLONG FltF6;
1629 ULONGLONG FltF7;
1630 ULONGLONG FltF8;
1631 ULONGLONG FltF9;
1632 ULONGLONG FltF10;
1633 ULONGLONG FltF11;
1634 ULONGLONG FltF12;
1635 ULONGLONG FltF13;
1636 ULONGLONG FltF14;
1637 ULONGLONG FltF15;
1638 ULONGLONG FltF16;
1639 ULONGLONG FltF17;
1640 ULONGLONG FltF18;
1641 ULONGLONG FltF19;
1642 ULONGLONG FltF20;
1643 ULONGLONG FltF21;
1644 ULONGLONG FltF22;
1645 ULONGLONG FltF23;
1646 ULONGLONG FltF24;
1647 ULONGLONG FltF25;
1648 ULONGLONG FltF26;
1649 ULONGLONG FltF27;
1650 ULONGLONG FltF28;
1651 ULONGLONG FltF29;
1652 ULONGLONG FltF30;
1653 ULONGLONG FltF31;
1655 /* selected by CONTEXT_INTEGER */
1656 ULONGLONG IntV0;
1657 ULONGLONG IntT0;
1658 ULONGLONG IntT1;
1659 ULONGLONG IntT2;
1660 ULONGLONG IntT3;
1661 ULONGLONG IntT4;
1662 ULONGLONG IntT5;
1663 ULONGLONG IntT6;
1664 ULONGLONG IntT7;
1665 ULONGLONG IntS0;
1666 ULONGLONG IntS1;
1667 ULONGLONG IntS2;
1668 ULONGLONG IntS3;
1669 ULONGLONG IntS4;
1670 ULONGLONG IntS5;
1671 ULONGLONG IntFp;
1672 ULONGLONG IntA0;
1673 ULONGLONG IntA1;
1674 ULONGLONG IntA2;
1675 ULONGLONG IntA3;
1676 ULONGLONG IntA4;
1677 ULONGLONG IntA5;
1678 ULONGLONG IntT8;
1679 ULONGLONG IntT9;
1680 ULONGLONG IntT10;
1681 ULONGLONG IntT11;
1682 ULONGLONG IntRa;
1683 ULONGLONG IntT12;
1684 ULONGLONG IntAt;
1685 ULONGLONG IntGp;
1686 ULONGLONG IntSp;
1687 ULONGLONG IntZero;
1689 /* selected by CONTEXT_FLOATING_POINT */
1690 ULONGLONG Fpcr;
1691 ULONGLONG SoftFpcr;
1693 /* selected by CONTEXT_CONTROL */
1694 ULONGLONG Fir;
1695 DWORD Psr;
1696 DWORD ContextFlags;
1697 DWORD Fill[4];
1698 } CONTEXT, *PCONTEXT;
1700 #define _QUAD_PSR_OFFSET HighSoftFpcr
1701 #define _QUAD_FLAGS_OFFSET HighFir
1703 #endif /* _ALPHA_ */
1705 #ifdef __arm__
1707 /* The following flags control the contents of the CONTEXT structure. */
1709 #define CONTEXT_ARM 0x0200000
1710 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1711 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1712 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1713 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1715 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1716 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1718 #define EXCEPTION_READ_FAULT 0
1719 #define EXCEPTION_WRITE_FAULT 1
1720 #define EXCEPTION_EXECUTE_FAULT 8
1722 #define ARM_MAX_BREAKPOINTS 8
1723 #define ARM_MAX_WATCHPOINTS 1
1725 typedef struct _RUNTIME_FUNCTION
1727 DWORD BeginAddress;
1728 union {
1729 DWORD UnwindData;
1730 struct {
1731 DWORD Flag : 2;
1732 DWORD FunctionLength : 11;
1733 DWORD Ret : 2;
1734 DWORD H : 1;
1735 DWORD Reg : 3;
1736 DWORD R : 1;
1737 DWORD L : 1;
1738 DWORD C : 1;
1739 DWORD StackAdjust : 10;
1740 } DUMMYSTRUCTNAME;
1741 } DUMMYUNIONNAME;
1742 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1744 #define UNWIND_HISTORY_TABLE_SIZE 12
1746 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1748 DWORD ImageBase;
1749 PRUNTIME_FUNCTION FunctionEntry;
1750 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1752 typedef struct _UNWIND_HISTORY_TABLE
1754 DWORD Count;
1755 BYTE LocalHint;
1756 BYTE GlobalHint;
1757 BYTE Search;
1758 BYTE Once;
1759 DWORD LowAddress;
1760 DWORD HighAddress;
1761 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1762 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1764 typedef struct _NEON128
1766 ULONGLONG Low;
1767 LONGLONG High;
1768 } NEON128, *PNEON128;
1770 typedef struct _CONTEXT
1772 ULONG ContextFlags; /* 000 */
1773 /* CONTEXT_INTEGER */
1774 ULONG R0; /* 004 */
1775 ULONG R1; /* 008 */
1776 ULONG R2; /* 00c */
1777 ULONG R3; /* 010 */
1778 ULONG R4; /* 014 */
1779 ULONG R5; /* 018 */
1780 ULONG R6; /* 01c */
1781 ULONG R7; /* 020 */
1782 ULONG R8; /* 024 */
1783 ULONG R9; /* 028 */
1784 ULONG R10; /* 02c */
1785 ULONG R11; /* 030 */
1786 ULONG R12; /* 034 */
1787 /* CONTEXT_CONTROL */
1788 ULONG Sp; /* 038 */
1789 ULONG Lr; /* 03c */
1790 ULONG Pc; /* 040 */
1791 ULONG Cpsr; /* 044 */
1792 /* CONTEXT_FLOATING_POINT */
1793 ULONG Fpscr; /* 048 */
1794 ULONG Padding; /* 04c */
1795 union
1797 NEON128 Q[16];
1798 ULONGLONG D[32];
1799 ULONG S[32];
1800 } DUMMYUNIONNAME; /* 050 */
1801 /* CONTEXT_DEBUG_REGISTERS */
1802 ULONG Bvr[ARM_MAX_BREAKPOINTS]; /* 150 */
1803 ULONG Bcr[ARM_MAX_BREAKPOINTS]; /* 170 */
1804 ULONG Wvr[ARM_MAX_WATCHPOINTS]; /* 190 */
1805 ULONG Wcr[ARM_MAX_WATCHPOINTS]; /* 194 */
1806 ULONG Padding2[2]; /* 198 */
1807 } CONTEXT, *PCONTEXT;
1809 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1811 PDWORD R4;
1812 PDWORD R5;
1813 PDWORD R6;
1814 PDWORD R7;
1815 PDWORD R8;
1816 PDWORD R9;
1817 PDWORD R10;
1818 PDWORD R11;
1819 PDWORD Lr;
1820 PULONGLONG D8;
1821 PULONGLONG D9;
1822 PULONGLONG D10;
1823 PULONGLONG D11;
1824 PULONGLONG D12;
1825 PULONGLONG D13;
1826 PULONGLONG D14;
1827 PULONGLONG D15;
1828 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1830 typedef struct _DISPATCHER_CONTEXT
1832 DWORD ControlPc;
1833 DWORD ImageBase;
1834 PRUNTIME_FUNCTION FunctionEntry;
1835 DWORD EstablisherFrame;
1836 DWORD TargetPc;
1837 PCONTEXT ContextRecord;
1838 PEXCEPTION_ROUTINE LanguageHandler;
1839 PVOID HandlerData;
1840 PUNWIND_HISTORY_TABLE HistoryTable;
1841 DWORD ScopeIndex;
1842 BOOLEAN ControlPcIsUnwound;
1843 PBYTE NonVolatileRegisters;
1844 DWORD Reserved;
1845 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1847 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD);
1848 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD);
1850 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,DWORD,DWORD,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,DWORD*,KNONVOLATILE_CONTEXT_POINTERS*);
1852 #define UNW_FLAG_NHANDLER 0
1853 #define UNW_FLAG_EHANDLER 1
1854 #define UNW_FLAG_UHANDLER 2
1856 #endif /* __arm__ */
1858 #ifdef __aarch64__
1860 #define CONTEXT_ARM64 0x400000
1861 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1862 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1863 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1864 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1866 #define CONTEXT_UNWOUND_TO_CALL 0x20000000
1868 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1869 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1871 #define EXCEPTION_READ_FAULT 0
1872 #define EXCEPTION_WRITE_FAULT 1
1873 #define EXCEPTION_EXECUTE_FAULT 8
1875 #define ARM64_MAX_BREAKPOINTS 8
1876 #define ARM64_MAX_WATCHPOINTS 2
1878 typedef struct _RUNTIME_FUNCTION
1880 DWORD BeginAddress;
1881 union
1883 DWORD UnwindData;
1884 struct
1886 DWORD Flag : 2;
1887 DWORD FunctionLength : 11;
1888 DWORD RegF : 3;
1889 DWORD RegI : 4;
1890 DWORD H : 1;
1891 DWORD CR : 2;
1892 DWORD FrameSize : 9;
1893 } DUMMYSTRUCTNAME;
1894 } DUMMYUNIONNAME;
1895 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1897 #define UNWIND_HISTORY_TABLE_SIZE 12
1899 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1901 DWORD64 ImageBase;
1902 PRUNTIME_FUNCTION FunctionEntry;
1903 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1905 typedef struct _UNWIND_HISTORY_TABLE
1907 DWORD Count;
1908 BYTE LocalHint;
1909 BYTE GlobalHint;
1910 BYTE Search;
1911 BYTE Once;
1912 DWORD64 LowAddress;
1913 DWORD64 HighAddress;
1914 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1915 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1917 typedef union _NEON128
1919 struct
1921 ULONGLONG Low;
1922 LONGLONG High;
1923 } DUMMYSTRUCTNAME;
1924 double D[2];
1925 float S[4];
1926 WORD H[8];
1927 BYTE B[16];
1928 } NEON128, *PNEON128;
1930 typedef struct _CONTEXT
1932 ULONG ContextFlags; /* 000 */
1933 /* CONTEXT_INTEGER */
1934 ULONG Cpsr; /* 004 */
1935 union
1937 struct
1939 DWORD64 X0; /* 008 */
1940 DWORD64 X1; /* 010 */
1941 DWORD64 X2; /* 018 */
1942 DWORD64 X3; /* 020 */
1943 DWORD64 X4; /* 028 */
1944 DWORD64 X5; /* 030 */
1945 DWORD64 X6; /* 038 */
1946 DWORD64 X7; /* 040 */
1947 DWORD64 X8; /* 048 */
1948 DWORD64 X9; /* 050 */
1949 DWORD64 X10; /* 058 */
1950 DWORD64 X11; /* 060 */
1951 DWORD64 X12; /* 068 */
1952 DWORD64 X13; /* 070 */
1953 DWORD64 X14; /* 078 */
1954 DWORD64 X15; /* 080 */
1955 DWORD64 X16; /* 088 */
1956 DWORD64 X17; /* 090 */
1957 DWORD64 X18; /* 098 */
1958 DWORD64 X19; /* 0a0 */
1959 DWORD64 X20; /* 0a8 */
1960 DWORD64 X21; /* 0b0 */
1961 DWORD64 X22; /* 0b8 */
1962 DWORD64 X23; /* 0c0 */
1963 DWORD64 X24; /* 0c8 */
1964 DWORD64 X25; /* 0d0 */
1965 DWORD64 X26; /* 0d8 */
1966 DWORD64 X27; /* 0e0 */
1967 DWORD64 X28; /* 0e8 */
1968 DWORD64 Fp; /* 0f0 */
1969 DWORD64 Lr; /* 0f8 */
1970 } DUMMYSTRUCTNAME;
1971 DWORD64 X[31]; /* 008 */
1972 } DUMMYUNIONNAME;
1973 /* CONTEXT_CONTROL */
1974 DWORD64 Sp; /* 100 */
1975 DWORD64 Pc; /* 108 */
1976 /* CONTEXT_FLOATING_POINT */
1977 NEON128 V[32]; /* 110 */
1978 DWORD Fpcr; /* 310 */
1979 DWORD Fpsr; /* 314 */
1980 /* CONTEXT_DEBUG_REGISTERS */
1981 DWORD Bcr[ARM64_MAX_BREAKPOINTS]; /* 318 */
1982 DWORD64 Bvr[ARM64_MAX_BREAKPOINTS]; /* 338 */
1983 DWORD Wcr[ARM64_MAX_WATCHPOINTS]; /* 378 */
1984 DWORD64 Wvr[ARM64_MAX_WATCHPOINTS]; /* 380 */
1985 } CONTEXT, *PCONTEXT;
1987 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1989 PDWORD64 X19;
1990 PDWORD64 X20;
1991 PDWORD64 X21;
1992 PDWORD64 X22;
1993 PDWORD64 X23;
1994 PDWORD64 X24;
1995 PDWORD64 X25;
1996 PDWORD64 X26;
1997 PDWORD64 X27;
1998 PDWORD64 X28;
1999 PDWORD64 Fp;
2000 PDWORD64 Lr;
2001 PDWORD64 D8;
2002 PDWORD64 D9;
2003 PDWORD64 D10;
2004 PDWORD64 D11;
2005 PDWORD64 D12;
2006 PDWORD64 D13;
2007 PDWORD64 D14;
2008 PDWORD64 D15;
2009 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2011 typedef struct _DISPATCHER_CONTEXT
2013 ULONG_PTR ControlPc;
2014 ULONG_PTR ImageBase;
2015 PRUNTIME_FUNCTION FunctionEntry;
2016 ULONG_PTR EstablisherFrame;
2017 ULONG_PTR TargetPc;
2018 PCONTEXT ContextRecord;
2019 PEXCEPTION_ROUTINE LanguageHandler;
2020 PVOID HandlerData;
2021 PUNWIND_HISTORY_TABLE HistoryTable;
2022 DWORD ScopeIndex;
2023 BOOLEAN ControlPcIsUnwound;
2024 PBYTE NonVolatileRegisters;
2025 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
2027 typedef LONG (CALLBACK *PEXCEPTION_FILTER)(struct _EXCEPTION_POINTERS*,DWORD64);
2028 typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD64);
2030 NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*);
2032 #define UNW_FLAG_NHANDLER 0
2033 #define UNW_FLAG_EHANDLER 1
2034 #define UNW_FLAG_UHANDLER 2
2036 #endif /* __aarch64__ */
2039 /* Mips context definitions */
2040 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
2042 #define CONTEXT_R4000 0x00010000
2044 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
2045 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
2046 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
2048 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2050 #define EXCEPTION_READ_FAULT 0
2051 #define EXCEPTION_WRITE_FAULT 1
2052 #define EXCEPTION_EXECUTE_FAULT 8
2054 typedef struct _CONTEXT
2056 DWORD Argument[4];
2057 /* These are selected by CONTEXT_FLOATING_POINT */
2058 DWORD FltF0;
2059 DWORD FltF1;
2060 DWORD FltF2;
2061 DWORD FltF3;
2062 DWORD FltF4;
2063 DWORD FltF5;
2064 DWORD FltF6;
2065 DWORD FltF7;
2066 DWORD FltF8;
2067 DWORD FltF9;
2068 DWORD FltF10;
2069 DWORD FltF11;
2070 DWORD FltF12;
2071 DWORD FltF13;
2072 DWORD FltF14;
2073 DWORD FltF15;
2074 DWORD FltF16;
2075 DWORD FltF17;
2076 DWORD FltF18;
2077 DWORD FltF19;
2078 DWORD FltF20;
2079 DWORD FltF21;
2080 DWORD FltF22;
2081 DWORD FltF23;
2082 DWORD FltF24;
2083 DWORD FltF25;
2084 DWORD FltF26;
2085 DWORD FltF27;
2086 DWORD FltF28;
2087 DWORD FltF29;
2088 DWORD FltF30;
2089 DWORD FltF31;
2091 /* These are selected by CONTEXT_INTEGER */
2092 DWORD IntZero;
2093 DWORD IntAt;
2094 DWORD IntV0;
2095 DWORD IntV1;
2096 DWORD IntA0;
2097 DWORD IntA1;
2098 DWORD IntA2;
2099 DWORD IntA3;
2100 DWORD IntT0;
2101 DWORD IntT1;
2102 DWORD IntT2;
2103 DWORD IntT3;
2104 DWORD IntT4;
2105 DWORD IntT5;
2106 DWORD IntT6;
2107 DWORD IntT7;
2108 DWORD IntS0;
2109 DWORD IntS1;
2110 DWORD IntS2;
2111 DWORD IntS3;
2112 DWORD IntS4;
2113 DWORD IntS5;
2114 DWORD IntS6;
2115 DWORD IntS7;
2116 DWORD IntT8;
2117 DWORD IntT9;
2118 DWORD IntK0;
2119 DWORD IntK1;
2120 DWORD IntGp;
2121 DWORD IntSp;
2122 DWORD IntS8;
2123 DWORD IntRa;
2124 DWORD IntLo;
2125 DWORD IntHi;
2127 /* These are selected by CONTEXT_FLOATING_POINT */
2128 DWORD Fsr;
2130 /* These are selected by CONTEXT_CONTROL */
2131 DWORD Fir;
2132 DWORD Psr;
2134 DWORD ContextFlags;
2135 DWORD Fill[2];
2136 } CONTEXT;
2138 #endif /* _MIPS_ */
2140 /* PowerPC context definitions */
2141 #ifdef __powerpc__
2143 #define CONTEXT_CONTROL 0x0001
2144 #define CONTEXT_FLOATING_POINT 0x0002
2145 #define CONTEXT_INTEGER 0x0004
2146 #define CONTEXT_DEBUG_REGISTERS 0x0008
2147 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
2149 #define EXCEPTION_READ_FAULT 0
2150 #define EXCEPTION_WRITE_FAULT 1
2151 #define EXCEPTION_EXECUTE_FAULT 8
2153 typedef struct
2155 /* These are selected by CONTEXT_FLOATING_POINT */
2156 double Fpr0;
2157 double Fpr1;
2158 double Fpr2;
2159 double Fpr3;
2160 double Fpr4;
2161 double Fpr5;
2162 double Fpr6;
2163 double Fpr7;
2164 double Fpr8;
2165 double Fpr9;
2166 double Fpr10;
2167 double Fpr11;
2168 double Fpr12;
2169 double Fpr13;
2170 double Fpr14;
2171 double Fpr15;
2172 double Fpr16;
2173 double Fpr17;
2174 double Fpr18;
2175 double Fpr19;
2176 double Fpr20;
2177 double Fpr21;
2178 double Fpr22;
2179 double Fpr23;
2180 double Fpr24;
2181 double Fpr25;
2182 double Fpr26;
2183 double Fpr27;
2184 double Fpr28;
2185 double Fpr29;
2186 double Fpr30;
2187 double Fpr31;
2188 double Fpscr;
2190 /* These are selected by CONTEXT_INTEGER */
2191 DWORD Gpr0;
2192 DWORD Gpr1;
2193 DWORD Gpr2;
2194 DWORD Gpr3;
2195 DWORD Gpr4;
2196 DWORD Gpr5;
2197 DWORD Gpr6;
2198 DWORD Gpr7;
2199 DWORD Gpr8;
2200 DWORD Gpr9;
2201 DWORD Gpr10;
2202 DWORD Gpr11;
2203 DWORD Gpr12;
2204 DWORD Gpr13;
2205 DWORD Gpr14;
2206 DWORD Gpr15;
2207 DWORD Gpr16;
2208 DWORD Gpr17;
2209 DWORD Gpr18;
2210 DWORD Gpr19;
2211 DWORD Gpr20;
2212 DWORD Gpr21;
2213 DWORD Gpr22;
2214 DWORD Gpr23;
2215 DWORD Gpr24;
2216 DWORD Gpr25;
2217 DWORD Gpr26;
2218 DWORD Gpr27;
2219 DWORD Gpr28;
2220 DWORD Gpr29;
2221 DWORD Gpr30;
2222 DWORD Gpr31;
2224 DWORD Cr;
2225 DWORD Xer;
2227 /* These are selected by CONTEXT_CONTROL */
2228 DWORD Msr;
2229 DWORD Iar; /* Instruction Address Register , aka PC ... */
2230 DWORD Lr;
2231 DWORD Ctr;
2233 DWORD ContextFlags;
2235 DWORD Dar; /* Fault registers for coredump */
2236 DWORD Dsisr;
2237 DWORD Trap; /* number of powerpc exception taken */
2239 /* These are selected by CONTEXT_DEBUG_REGISTERS */
2240 DWORD Dr0;
2241 DWORD Dr1;
2242 DWORD Dr2;
2243 DWORD Dr3;
2244 DWORD Dr4;
2245 DWORD Dr5;
2246 DWORD Dr6;
2247 DWORD Dr7;
2248 } CONTEXT;
2250 typedef struct _STACK_FRAME_HEADER
2252 DWORD BackChain;
2253 DWORD GlueSaved1;
2254 DWORD GlueSaved2;
2255 DWORD Reserved1;
2256 DWORD Spare1;
2257 DWORD Spare2;
2259 DWORD Parameter0;
2260 DWORD Parameter1;
2261 DWORD Parameter2;
2262 DWORD Parameter3;
2263 DWORD Parameter4;
2264 DWORD Parameter5;
2265 DWORD Parameter6;
2266 DWORD Parameter7;
2267 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
2269 #endif /* __powerpc__ */
2271 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2272 #error You need to define a CONTEXT for your CPU
2273 #endif
2275 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
2277 #define WOW64_CONTEXT_i386 0x00010000
2278 #define WOW64_CONTEXT_i486 0x00010000
2279 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
2280 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
2281 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
2282 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
2283 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
2284 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
2285 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2286 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
2287 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
2288 WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
2289 WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
2291 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2293 #define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
2294 #define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
2295 #define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
2296 #define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
2298 #define WOW64_SIZE_OF_80387_REGISTERS 80
2299 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
2301 typedef struct _WOW64_FLOATING_SAVE_AREA
2303 DWORD ControlWord;
2304 DWORD StatusWord;
2305 DWORD TagWord;
2306 DWORD ErrorOffset;
2307 DWORD ErrorSelector;
2308 DWORD DataOffset;
2309 DWORD DataSelector;
2310 BYTE RegisterArea[WOW64_SIZE_OF_80387_REGISTERS];
2311 DWORD Cr0NpxState;
2312 } WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
2314 #include "pshpack4.h"
2315 typedef struct _WOW64_CONTEXT
2317 DWORD ContextFlags;
2318 DWORD Dr0;
2319 DWORD Dr1;
2320 DWORD Dr2;
2321 DWORD Dr3;
2322 DWORD Dr6;
2323 DWORD Dr7;
2324 WOW64_FLOATING_SAVE_AREA FloatSave;
2325 DWORD SegGs;
2326 DWORD SegFs;
2327 DWORD SegEs;
2328 DWORD SegDs;
2329 DWORD Edi;
2330 DWORD Esi;
2331 DWORD Ebx;
2332 DWORD Edx;
2333 DWORD Ecx;
2334 DWORD Eax;
2335 DWORD Ebp;
2336 DWORD Eip;
2337 DWORD SegCs;
2338 DWORD EFlags;
2339 DWORD Esp;
2340 DWORD SegSs;
2341 BYTE ExtendedRegisters[WOW64_MAXIMUM_SUPPORTED_EXTENSION];
2342 } WOW64_CONTEXT, *PWOW64_CONTEXT;
2343 #include "poppack.h"
2345 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
2347 typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD_PTR,PVOID);
2349 NTSYSAPI BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD_PTR);
2350 NTSYSAPI DWORD WINAPI RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION,DWORD,DWORD,ULONG_PTR,ULONG_PTR);
2351 NTSYSAPI BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
2352 NTSYSAPI void WINAPI RtlDeleteGrowableFunctionTable(void*);
2353 NTSYSAPI void WINAPI RtlGrowFunctionTable(void*,DWORD);
2354 NTSYSAPI BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD_PTR,DWORD_PTR,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
2355 NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD_PTR,DWORD_PTR*,UNWIND_HISTORY_TABLE*);
2356 NTSYSAPI void WINAPI RtlUnwindEx(PVOID,PVOID,struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,UNWIND_HISTORY_TABLE*);
2357 #endif
2360 * Product types
2362 #define PRODUCT_UNDEFINED 0x00000000
2363 #define PRODUCT_ULTIMATE 0x00000001
2364 #define PRODUCT_HOME_BASIC 0x00000002
2365 #define PRODUCT_HOME_PREMIUM 0x00000003
2366 #define PRODUCT_ENTERPRISE 0x00000004
2367 #define PRODUCT_HOME_BASIC_N 0x00000005
2368 #define PRODUCT_BUSINESS 0x00000006
2369 #define PRODUCT_STANDARD_SERVER 0x00000007
2370 #define PRODUCT_DATACENTER_SERVER 0x00000008
2371 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2372 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2373 #define PRODUCT_STARTER 0x0000000B
2374 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2375 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2376 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2377 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2378 #define PRODUCT_BUSINESS_N 0x00000010
2379 #define PRODUCT_WEB_SERVER 0x00000011
2380 #define PRODUCT_CLUSTER_SERVER 0x00000012
2381 #define PRODUCT_HOME_SERVER 0x00000013
2382 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2383 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2384 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2385 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2386 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2387 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2388 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2389 #define PRODUCT_ENTERPRISE_N 0x0000001B
2390 #define PRODUCT_ULTIMATE_N 0x0000001C
2391 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2392 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2393 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2394 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2395 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2396 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2397 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2398 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2399 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2400 #define PRODUCT_SERVER_V 0x00000025
2401 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2402 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2403 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2404 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2405 #define PRODUCT_HYPERV 0x0000002A
2406 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2407 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2408 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2409 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2410 #define PRODUCT_STARTER_N 0x0000002F
2411 #define PRODUCT_PROFESSIONAL 0x00000030
2412 #define PRODUCT_PROFESSIONAL_N 0x00000031
2413 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2414 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2415 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2416 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2417 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2418 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2419 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2420 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2421 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2422 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2423 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2424 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2425 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2426 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2427 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2428 #define PRODUCT_EMBEDDED 0x00000041
2429 #define PRODUCT_STARTER_E 0x00000042
2430 #define PRODUCT_HOME_BASIC_E 0x00000043
2431 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2432 #define PRODUCT_PROFESSIONAL_E 0x00000045
2433 #define PRODUCT_ENTERPRISE_E 0x00000046
2434 #define PRODUCT_ULTIMATE_E 0x00000047
2435 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2436 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2437 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2438 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2439 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2440 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2441 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2442 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2443 #define PRODUCT_THINPC 0x00000057
2444 #define PRODUCT_EMBEDDED_A 0x00000058
2445 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2446 #define PRODUCT_EMBEDDED_E 0x0000005A
2447 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2448 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2449 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2450 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2451 #define PRODUCT_CORE_ARM 0x00000061
2452 #define PRODUCT_CORE_N 0x00000062
2453 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2454 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2455 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2456 #define PRODUCT_CORE 0x00000065
2457 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2458 #define PRODUCT_MOBILE_CORE 0x00000068
2459 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2460 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2461 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2462 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2463 #define PRODUCT_NANO_SERVER 0x0000006D
2464 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2465 #define PRODUCT_CORE_CONNECTED 0x0000006F
2466 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2467 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2468 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2469 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2470 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2471 #define PRODUCT_CONNECTED_CAR 0x00000075
2472 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2473 #define PRODUCT_PPI_PRO 0x00000077
2474 #define PRODUCT_ARM64_SERVER 0x00000078
2475 #define PRODUCT_EDUCATION 0x00000079
2476 #define PRODUCT_EDUCATION_N 0x0000007A
2477 #define PRODUCT_IOTUAP 0x0000007B
2478 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2479 #define PRODUCT_ENTERPRISE_S 0x0000007D
2480 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2481 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2482 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2483 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2484 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2485 #define PRODUCT_UNLICENSED 0xABCDABCD
2489 * Language IDs
2492 #define MAKELCID(l, s) (MAKELONG(l, s))
2494 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2495 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2496 #define SUBLANGID(l) ((WORD)(l) >> 10)
2498 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2499 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2501 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2502 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2503 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2504 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2505 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2506 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2507 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2508 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2509 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2510 #define LOCALE_NAME_MAX_LENGTH 85
2513 #define UNREFERENCED_PARAMETER(u) (void)(u)
2514 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2515 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2517 #include <winnt.rh>
2521 * Definitions for IsTextUnicode()
2524 #define IS_TEXT_UNICODE_ASCII16 0x0001
2525 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2526 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2527 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2528 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2529 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2530 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2531 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2532 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2533 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2534 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2535 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2536 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2537 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2538 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2539 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2541 #define MAXIMUM_WAIT_OBJECTS 64
2542 #define MAXIMUM_SUSPEND_COUNT 127
2544 #define WT_EXECUTEDEFAULT 0x00
2545 #define WT_EXECUTEINIOTHREAD 0x01
2546 #define WT_EXECUTEINUITHREAD 0x02
2547 #define WT_EXECUTEINWAITTHREAD 0x04
2548 #define WT_EXECUTEONLYONCE 0x08
2549 #define WT_EXECUTELONGFUNCTION 0x10
2550 #define WT_EXECUTEINTIMERTHREAD 0x20
2551 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2552 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2553 #define WT_EXECUTEINLONGTHREAD 0x10
2554 #define WT_EXECUTEDELETEWAIT 0x08
2555 #define WT_TRANSFER_IMPERSONATION 0x0100
2558 #define EXCEPTION_CONTINUABLE 0
2559 #define EXCEPTION_NONCONTINUABLE 0x01
2562 * The exception record used by Win32 to give additional information
2563 * about exception to exception handlers.
2566 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2568 typedef struct _EXCEPTION_RECORD
2570 DWORD ExceptionCode;
2571 DWORD ExceptionFlags;
2572 struct _EXCEPTION_RECORD *ExceptionRecord;
2574 PVOID ExceptionAddress;
2575 DWORD NumberParameters;
2576 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2577 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2579 typedef struct _EXCEPTION_RECORD32
2581 DWORD ExceptionCode;
2582 DWORD ExceptionFlags;
2583 DWORD ExceptionRecord;
2584 DWORD ExceptionAddress;
2585 DWORD NumberParameters;
2586 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2587 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
2589 typedef struct _EXCEPTION_RECORD64
2591 DWORD ExceptionCode;
2592 DWORD ExceptionFlags;
2593 DWORD64 ExceptionRecord;
2594 DWORD64 ExceptionAddress;
2595 DWORD NumberParameters;
2596 DWORD __unusedAlignment;
2597 DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2598 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
2601 * The exception pointers structure passed to exception filters
2602 * in except() and the UnhandledExceptionFilter().
2605 typedef struct _EXCEPTION_POINTERS
2607 PEXCEPTION_RECORD ExceptionRecord;
2608 PCONTEXT ContextRecord;
2609 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2613 * The exception frame, used for registering exception handlers
2614 * Win32 cares only about this, but compilers generally emit
2615 * larger exception frames for their own use.
2618 struct _EXCEPTION_REGISTRATION_RECORD;
2620 typedef DWORD (CDECL *PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2621 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2623 typedef struct _EXCEPTION_REGISTRATION_RECORD
2625 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2626 PEXCEPTION_HANDLER Handler;
2627 } EXCEPTION_REGISTRATION_RECORD;
2630 * function pointer to an exception filter
2633 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2635 typedef struct _NT_TIB
2637 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2638 PVOID StackBase;
2639 PVOID StackLimit;
2640 PVOID SubSystemTib;
2641 union {
2642 PVOID FiberData;
2643 DWORD Version;
2644 } DUMMYUNIONNAME;
2645 PVOID ArbitraryUserPointer;
2646 struct _NT_TIB *Self;
2647 } NT_TIB, *PNT_TIB;
2649 struct _TEB;
2651 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2652 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2654 struct _TEB *teb;
2655 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2656 return teb;
2658 #elif defined(__i386__) && defined(_MSC_VER)
2659 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2661 struct _TEB *teb;
2662 __asm mov eax, fs:[0x18];
2663 __asm mov teb, eax;
2664 return teb;
2666 #elif defined(__x86_64__) && defined(__GNUC__)
2667 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2669 struct _TEB *teb;
2670 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2671 return teb;
2673 #elif defined(__x86_64__) && defined(_MSC_VER)
2674 unsigned __int64 __readgsqword(unsigned long);
2675 #pragma intrinsic(__readgsqword)
2676 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2678 return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
2680 #elif defined(__arm__) && defined(__MINGW32__)
2681 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2683 struct _TEB *teb;
2684 __asm__("mrc p15, 0, %0, c13, c0, 2" : "=r" (teb));
2685 return teb;
2687 #else
2688 extern struct _TEB * WINAPI NtCurrentTeb(void);
2689 #endif
2691 #ifdef NONAMELESSUNION
2692 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2693 #else
2694 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2695 #endif
2696 #define GetFiberData() (*(void **)GetCurrentFiber())
2698 #define TLS_MINIMUM_AVAILABLE 64
2700 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
2702 #define IO_REPARSE_TAG_RESERVED_ZERO 0
2703 #define IO_REPARSE_TAG_RESERVED_ONE 1
2704 #define IO_REPARSE_TAG_RESERVED_TWO 2
2706 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_TWO
2708 #define IO_REPARSE_TAG_MOUNT_POINT __MSABI_LONG(0xA0000003)
2709 #define IO_REPARSE_TAG_HSM __MSABI_LONG(0xC0000004)
2710 #define IO_REPARSE_TAG_DRIVE_EXTENDER __MSABI_LONG(0x80000005)
2711 #define IO_REPARSE_TAG_HSM2 __MSABI_LONG(0x80000006)
2712 #define IO_REPARSE_TAG_SIS __MSABI_LONG(0x80000007)
2713 #define IO_REPARSE_TAG_WIM __MSABI_LONG(0x80000008)
2714 #define IO_REPARSE_TAG_CSV __MSABI_LONG(0x80000009)
2715 #define IO_REPARSE_TAG_DFS __MSABI_LONG(0x8000000A)
2716 #define IO_REPARSE_TAG_FILTER_MANAGER __MSABI_LONG(0x8000000B)
2717 #define IO_REPARSE_TAG_SYMLINK __MSABI_LONG(0xA000000C)
2718 #define IO_REPARSE_TAG_IIS_CACHE __MSABI_LONG(0xA0000010)
2719 #define IO_REPARSE_TAG_DFSR __MSABI_LONG(0x80000012)
2720 #define IO_REPARSE_TAG_DEDUP __MSABI_LONG(0x80000013)
2721 #define IO_REPARSE_TAG_NFS __MSABI_LONG(0x80000014)
2722 #define IO_REPARSE_TAG_FILE_PLACEHOLDER __MSABI_LONG(0x80000015)
2723 #define IO_REPARSE_TAG_WOF __MSABI_LONG(0x80000017)
2724 #define IO_REPARSE_TAG_WCI __MSABI_LONG(0x80000018)
2725 #define IO_REPARSE_TAG_WCI_1 __MSABI_LONG(0x90001018)
2726 #define IO_REPARSE_TAG_GLOBAL_REPARSE __MSABI_LONG(0xA0000019)
2727 #define IO_REPARSE_TAG_CLOUD __MSABI_LONG(0x9000001A)
2728 #define IO_REPARSE_TAG_CLOUD_1 __MSABI_LONG(0x9000101A)
2729 #define IO_REPARSE_TAG_CLOUD_2 __MSABI_LONG(0x9000201A)
2730 #define IO_REPARSE_TAG_CLOUD_3 __MSABI_LONG(0x9000301A)
2731 #define IO_REPARSE_TAG_CLOUD_4 __MSABI_LONG(0x9000401A)
2732 #define IO_REPARSE_TAG_CLOUD_5 __MSABI_LONG(0x9000501A)
2733 #define IO_REPARSE_TAG_CLOUD_6 __MSABI_LONG(0x9000601A)
2734 #define IO_REPARSE_TAG_CLOUD_7 __MSABI_LONG(0x9000701A)
2735 #define IO_REPARSE_TAG_CLOUD_8 __MSABI_LONG(0x9000801A)
2736 #define IO_REPARSE_TAG_CLOUD_9 __MSABI_LONG(0x9000901A)
2737 #define IO_REPARSE_TAG_CLOUD_A __MSABI_LONG(0x9000A01A)
2738 #define IO_REPARSE_TAG_CLOUD_B __MSABI_LONG(0x9000B01A)
2739 #define IO_REPARSE_TAG_CLOUD_C __MSABI_LONG(0x9000C01A)
2740 #define IO_REPARSE_TAG_CLOUD_D __MSABI_LONG(0x9000D01A)
2741 #define IO_REPARSE_TAG_CLOUD_E __MSABI_LONG(0x9000E01A)
2742 #define IO_REPARSE_TAG_CLOUD_F __MSABI_LONG(0x9000F01A)
2743 #define IO_REPARSE_TAG_CLOUD_MASK __MSABI_LONG(0x0000F000)
2744 #define IO_REPARSE_TAG_APPEXECLINK __MSABI_LONG(0x8000001B)
2745 #define IO_REPARSE_TAG_GVFS __MSABI_LONG(0x9000001C)
2746 #define IO_REPARSE_TAG_STORAGE_SYNC __MSABI_LONG(0x8000001E)
2747 #define IO_REPARSE_TAG_WCI_TOMBSTONE __MSABI_LONG(0xA000001F)
2748 #define IO_REPARSE_TAG_UNHANDLED __MSABI_LONG(0x80000020)
2749 #define IO_REPARSE_TAG_ONEDRIVE __MSABI_LONG(0x80000021)
2750 #define IO_REPARSE_TAG_GVFS_TOMBSTONE __MSABI_LONG(0xA0000022)
2753 * File formats definitions
2756 #include <pshpack2.h>
2757 typedef struct _IMAGE_DOS_HEADER {
2758 WORD e_magic; /* 00: MZ Header signature */
2759 WORD e_cblp; /* 02: Bytes on last page of file */
2760 WORD e_cp; /* 04: Pages in file */
2761 WORD e_crlc; /* 06: Relocations */
2762 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2763 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2764 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2765 WORD e_ss; /* 0e: Initial (relative) SS value */
2766 WORD e_sp; /* 10: Initial SP value */
2767 WORD e_csum; /* 12: Checksum */
2768 WORD e_ip; /* 14: Initial IP value */
2769 WORD e_cs; /* 16: Initial (relative) CS value */
2770 WORD e_lfarlc; /* 18: File address of relocation table */
2771 WORD e_ovno; /* 1a: Overlay number */
2772 WORD e_res[4]; /* 1c: Reserved words */
2773 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2774 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2775 WORD e_res2[10]; /* 28: Reserved words */
2776 DWORD e_lfanew; /* 3c: Offset to extended header */
2777 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2778 #include <poppack.h>
2780 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2781 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2782 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2783 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2784 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2785 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2788 * This is the Windows executable (NE) header.
2789 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2791 #include <pshpack2.h>
2792 typedef struct
2794 WORD ne_magic; /* 00 NE signature 'NE' */
2795 BYTE ne_ver; /* 02 Linker version number */
2796 BYTE ne_rev; /* 03 Linker revision number */
2797 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2798 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2799 LONG ne_crc; /* 08 Checksum */
2800 WORD ne_flags; /* 0c Flags about segments in this file */
2801 WORD ne_autodata; /* 0e Automatic data segment number */
2802 WORD ne_heap; /* 10 Initial size of local heap */
2803 WORD ne_stack; /* 12 Initial size of stack */
2804 DWORD ne_csip; /* 14 Initial CS:IP */
2805 DWORD ne_sssp; /* 18 Initial SS:SP */
2806 WORD ne_cseg; /* 1c # of entries in segment table */
2807 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2808 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2809 WORD ne_segtab; /* 22 Offset to segment table */
2810 WORD ne_rsrctab; /* 24 Offset to resource table */
2811 WORD ne_restab; /* 26 Offset to resident-name table */
2812 WORD ne_modtab; /* 28 Offset to module reference table */
2813 WORD ne_imptab; /* 2a Offset to imported name table */
2814 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2815 WORD ne_cmovent; /* 30 # of movable entry points */
2816 WORD ne_align; /* 32 Logical sector alignment shift count */
2817 WORD ne_cres; /* 34 # of resource segments */
2818 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2819 BYTE ne_flagsothers; /* 37 Additional information flags */
2820 WORD ne_pretthunks; /* 38 Offset to return thunks */
2821 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2822 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2823 WORD ne_expver; /* 3e Expected Windows version number */
2824 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2825 #include <poppack.h>
2827 #include <pshpack2.h>
2828 typedef struct _IMAGE_VXD_HEADER {
2829 WORD e32_magic;
2830 BYTE e32_border;
2831 BYTE e32_worder;
2832 DWORD e32_level;
2833 WORD e32_cpu;
2834 WORD e32_os;
2835 DWORD e32_ver;
2836 DWORD e32_mflags;
2837 DWORD e32_mpages;
2838 DWORD e32_startobj;
2839 DWORD e32_eip;
2840 DWORD e32_stackobj;
2841 DWORD e32_esp;
2842 DWORD e32_pagesize;
2843 DWORD e32_lastpagesize;
2844 DWORD e32_fixupsize;
2845 DWORD e32_fixupsum;
2846 DWORD e32_ldrsize;
2847 DWORD e32_ldrsum;
2848 DWORD e32_objtab;
2849 DWORD e32_objcnt;
2850 DWORD e32_objmap;
2851 DWORD e32_itermap;
2852 DWORD e32_rsrctab;
2853 DWORD e32_rsrccnt;
2854 DWORD e32_restab;
2855 DWORD e32_enttab;
2856 DWORD e32_dirtab;
2857 DWORD e32_dircnt;
2858 DWORD e32_fpagetab;
2859 DWORD e32_frectab;
2860 DWORD e32_impmod;
2861 DWORD e32_impmodcnt;
2862 DWORD e32_impproc;
2863 DWORD e32_pagesum;
2864 DWORD e32_datapage;
2865 DWORD e32_preload;
2866 DWORD e32_nrestab;
2867 DWORD e32_cbnrestab;
2868 DWORD e32_nressum;
2869 DWORD e32_autodata;
2870 DWORD e32_debuginfo;
2871 DWORD e32_debuglen;
2872 DWORD e32_instpreload;
2873 DWORD e32_instdemand;
2874 DWORD e32_heapsize;
2875 BYTE e32_res3[12];
2876 DWORD e32_winresoff;
2877 DWORD e32_winreslen;
2878 WORD e32_devid;
2879 WORD e32_ddkver;
2880 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2881 #include <poppack.h>
2883 /* These defines describe the meanings of the bits in the Characteristics
2884 field */
2886 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2887 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2888 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2889 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2890 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2891 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2892 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2893 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2894 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2895 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2896 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2897 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2898 #define IMAGE_FILE_SYSTEM 0x1000
2899 #define IMAGE_FILE_DLL 0x2000
2900 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2901 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2903 /* These are the settings of the Machine field. */
2904 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2905 #define IMAGE_FILE_MACHINE_TARGET_HOST 0x0001
2906 #define IMAGE_FILE_MACHINE_I860 0x014d
2907 #define IMAGE_FILE_MACHINE_I386 0x014c
2908 #define IMAGE_FILE_MACHINE_R3000 0x0162
2909 #define IMAGE_FILE_MACHINE_R4000 0x0166
2910 #define IMAGE_FILE_MACHINE_R10000 0x0168
2911 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2912 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2913 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2914 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2915 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2916 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2917 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2918 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2919 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2920 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2921 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2922 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2923 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2924 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2925 #define IMAGE_FILE_MACHINE_IA64 0x0200
2926 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2927 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2928 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2929 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2930 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2931 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2932 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2933 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2934 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2935 #define IMAGE_FILE_MACHINE_M32R 0x9041
2936 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2938 #define IMAGE_SIZEOF_FILE_HEADER 20
2939 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2940 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2941 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2942 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2943 #define IMAGE_SIZEOF_SHORT_NAME 8
2944 #define IMAGE_SIZEOF_SECTION_HEADER 40
2945 #define IMAGE_SIZEOF_SYMBOL 18
2946 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2947 #define IMAGE_SIZEOF_RELOCATION 10
2948 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2949 #define IMAGE_SIZEOF_LINENUMBER 6
2950 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2952 /* Possible Magic values */
2953 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2954 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2955 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2957 #ifdef _WIN64
2958 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2959 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2960 #else
2961 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2962 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2963 #endif
2965 /* These are indexes into the DataDirectory array */
2966 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2967 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2968 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2969 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2970 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2971 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2972 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2973 #define IMAGE_FILE_DESCRIPTION_STRING 7
2974 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2975 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2976 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2978 /* Directory Entries, indices into the DataDirectory array */
2980 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2981 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2982 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2983 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2984 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2985 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2986 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2987 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2988 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2989 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2990 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2991 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2992 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2993 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2994 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2996 /* Subsystem Values */
2998 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2999 #define IMAGE_SUBSYSTEM_NATIVE 1
3000 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
3001 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
3002 #define IMAGE_SUBSYSTEM_OS2_CUI 5
3003 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
3004 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
3005 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
3006 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
3007 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
3008 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
3009 #define IMAGE_SUBSYSTEM_EFI_ROM 13
3010 #define IMAGE_SUBSYSTEM_XBOX 14
3011 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
3013 /* DLL Characteristics */
3014 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
3015 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
3016 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
3017 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
3018 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
3019 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
3020 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
3021 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
3023 typedef struct _IMAGE_FILE_HEADER {
3024 WORD Machine;
3025 WORD NumberOfSections;
3026 DWORD TimeDateStamp;
3027 DWORD PointerToSymbolTable;
3028 DWORD NumberOfSymbols;
3029 WORD SizeOfOptionalHeader;
3030 WORD Characteristics;
3031 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
3033 typedef struct _IMAGE_DATA_DIRECTORY {
3034 DWORD VirtualAddress;
3035 DWORD Size;
3036 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
3038 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
3040 typedef struct _IMAGE_OPTIONAL_HEADER64 {
3041 WORD Magic; /* 0x20b */
3042 BYTE MajorLinkerVersion;
3043 BYTE MinorLinkerVersion;
3044 DWORD SizeOfCode;
3045 DWORD SizeOfInitializedData;
3046 DWORD SizeOfUninitializedData;
3047 DWORD AddressOfEntryPoint;
3048 DWORD BaseOfCode;
3049 ULONGLONG ImageBase;
3050 DWORD SectionAlignment;
3051 DWORD FileAlignment;
3052 WORD MajorOperatingSystemVersion;
3053 WORD MinorOperatingSystemVersion;
3054 WORD MajorImageVersion;
3055 WORD MinorImageVersion;
3056 WORD MajorSubsystemVersion;
3057 WORD MinorSubsystemVersion;
3058 DWORD Win32VersionValue;
3059 DWORD SizeOfImage;
3060 DWORD SizeOfHeaders;
3061 DWORD CheckSum;
3062 WORD Subsystem;
3063 WORD DllCharacteristics;
3064 ULONGLONG SizeOfStackReserve;
3065 ULONGLONG SizeOfStackCommit;
3066 ULONGLONG SizeOfHeapReserve;
3067 ULONGLONG SizeOfHeapCommit;
3068 DWORD LoaderFlags;
3069 DWORD NumberOfRvaAndSizes;
3070 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
3071 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
3073 typedef struct _IMAGE_NT_HEADERS64 {
3074 DWORD Signature;
3075 IMAGE_FILE_HEADER FileHeader;
3076 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
3077 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
3079 typedef struct _IMAGE_OPTIONAL_HEADER {
3081 /* Standard fields */
3083 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
3084 BYTE MajorLinkerVersion;
3085 BYTE MinorLinkerVersion;
3086 DWORD SizeOfCode;
3087 DWORD SizeOfInitializedData;
3088 DWORD SizeOfUninitializedData;
3089 DWORD AddressOfEntryPoint; /* 0x10 */
3090 DWORD BaseOfCode;
3091 DWORD BaseOfData;
3093 /* NT additional fields */
3095 DWORD ImageBase;
3096 DWORD SectionAlignment; /* 0x20 */
3097 DWORD FileAlignment;
3098 WORD MajorOperatingSystemVersion;
3099 WORD MinorOperatingSystemVersion;
3100 WORD MajorImageVersion;
3101 WORD MinorImageVersion;
3102 WORD MajorSubsystemVersion; /* 0x30 */
3103 WORD MinorSubsystemVersion;
3104 DWORD Win32VersionValue;
3105 DWORD SizeOfImage;
3106 DWORD SizeOfHeaders;
3107 DWORD CheckSum; /* 0x40 */
3108 WORD Subsystem;
3109 WORD DllCharacteristics;
3110 DWORD SizeOfStackReserve;
3111 DWORD SizeOfStackCommit;
3112 DWORD SizeOfHeapReserve; /* 0x50 */
3113 DWORD SizeOfHeapCommit;
3114 DWORD LoaderFlags;
3115 DWORD NumberOfRvaAndSizes;
3116 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
3117 /* 0xE0 */
3118 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
3120 typedef struct _IMAGE_NT_HEADERS {
3121 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
3122 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
3123 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
3124 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
3126 #ifdef _WIN64
3127 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
3128 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
3129 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
3130 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
3131 #else
3132 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
3133 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
3134 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
3135 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
3136 #endif
3138 #define IMAGE_SIZEOF_SHORT_NAME 8
3140 typedef struct _IMAGE_SECTION_HEADER {
3141 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
3142 union {
3143 DWORD PhysicalAddress;
3144 DWORD VirtualSize;
3145 } Misc;
3146 DWORD VirtualAddress;
3147 DWORD SizeOfRawData;
3148 DWORD PointerToRawData;
3149 DWORD PointerToRelocations;
3150 DWORD PointerToLinenumbers;
3151 WORD NumberOfRelocations;
3152 WORD NumberOfLinenumbers;
3153 DWORD Characteristics;
3154 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
3156 #define IMAGE_SIZEOF_SECTION_HEADER 40
3158 #define IMAGE_FIRST_SECTION(ntheader) \
3159 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
3160 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
3162 /* These defines are for the Characteristics bitfield. */
3163 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
3164 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
3165 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
3166 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
3167 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
3168 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
3170 #define IMAGE_SCN_CNT_CODE 0x00000020
3171 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
3172 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
3174 #define IMAGE_SCN_LNK_OTHER 0x00000100
3175 #define IMAGE_SCN_LNK_INFO 0x00000200
3176 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
3177 #define IMAGE_SCN_LNK_REMOVE 0x00000800
3178 #define IMAGE_SCN_LNK_COMDAT 0x00001000
3180 /* 0x00002000 - Reserved */
3181 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
3182 #define IMAGE_SCN_MEM_FARDATA 0x00008000
3184 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
3185 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
3186 #define IMAGE_SCN_MEM_16BIT 0x00020000
3187 #define IMAGE_SCN_MEM_LOCKED 0x00040000
3188 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
3190 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
3191 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
3192 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
3193 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
3194 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
3195 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
3196 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
3197 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
3198 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
3199 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
3200 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
3201 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
3202 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
3203 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
3204 /* 0x00F00000 - Unused */
3205 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
3207 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
3210 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
3211 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
3212 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
3213 #define IMAGE_SCN_MEM_SHARED 0x10000000
3214 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
3215 #define IMAGE_SCN_MEM_READ 0x40000000
3216 #define IMAGE_SCN_MEM_WRITE 0x80000000
3218 #include <pshpack2.h>
3220 typedef struct _IMAGE_SYMBOL {
3221 union {
3222 BYTE ShortName[8];
3223 struct {
3224 DWORD Short;
3225 DWORD Long;
3226 } Name;
3227 DWORD LongName[2];
3228 } N;
3229 DWORD Value;
3230 SHORT SectionNumber;
3231 WORD Type;
3232 BYTE StorageClass;
3233 BYTE NumberOfAuxSymbols;
3234 } IMAGE_SYMBOL;
3235 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
3237 #define IMAGE_SIZEOF_SYMBOL 18
3239 typedef struct _IMAGE_LINENUMBER {
3240 union {
3241 DWORD SymbolTableIndex;
3242 DWORD VirtualAddress;
3243 } Type;
3244 WORD Linenumber;
3245 } IMAGE_LINENUMBER;
3246 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
3248 #define IMAGE_SIZEOF_LINENUMBER 6
3250 typedef union _IMAGE_AUX_SYMBOL {
3251 struct {
3252 DWORD TagIndex;
3253 union {
3254 struct {
3255 WORD Linenumber;
3256 WORD Size;
3257 } LnSz;
3258 DWORD TotalSize;
3259 } Misc;
3260 union {
3261 struct {
3262 DWORD PointerToLinenumber;
3263 DWORD PointerToNextFunction;
3264 } Function;
3265 struct {
3266 WORD Dimension[4];
3267 } Array;
3268 } FcnAry;
3269 WORD TvIndex;
3270 } Sym;
3271 struct {
3272 BYTE Name[IMAGE_SIZEOF_SYMBOL];
3273 } File;
3274 struct {
3275 DWORD Length;
3276 WORD NumberOfRelocations;
3277 WORD NumberOfLinenumbers;
3278 DWORD CheckSum;
3279 SHORT Number;
3280 BYTE Selection;
3281 } Section;
3282 } IMAGE_AUX_SYMBOL;
3283 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
3285 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3287 #include <poppack.h>
3289 #define IMAGE_SYM_UNDEFINED (SHORT)0
3290 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3291 #define IMAGE_SYM_DEBUG (SHORT)-2
3293 #define IMAGE_SYM_TYPE_NULL 0x0000
3294 #define IMAGE_SYM_TYPE_VOID 0x0001
3295 #define IMAGE_SYM_TYPE_CHAR 0x0002
3296 #define IMAGE_SYM_TYPE_SHORT 0x0003
3297 #define IMAGE_SYM_TYPE_INT 0x0004
3298 #define IMAGE_SYM_TYPE_LONG 0x0005
3299 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3300 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3301 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3302 #define IMAGE_SYM_TYPE_UNION 0x0009
3303 #define IMAGE_SYM_TYPE_ENUM 0x000A
3304 #define IMAGE_SYM_TYPE_MOE 0x000B
3305 #define IMAGE_SYM_TYPE_BYTE 0x000C
3306 #define IMAGE_SYM_TYPE_WORD 0x000D
3307 #define IMAGE_SYM_TYPE_UINT 0x000E
3308 #define IMAGE_SYM_TYPE_DWORD 0x000F
3309 #define IMAGE_SYM_TYPE_PCODE 0x8000
3311 #define IMAGE_SYM_DTYPE_NULL 0
3312 #define IMAGE_SYM_DTYPE_POINTER 1
3313 #define IMAGE_SYM_DTYPE_FUNCTION 2
3314 #define IMAGE_SYM_DTYPE_ARRAY 3
3316 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3317 #define IMAGE_SYM_CLASS_NULL 0x0000
3318 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3319 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3320 #define IMAGE_SYM_CLASS_STATIC 0x0003
3321 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3322 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3323 #define IMAGE_SYM_CLASS_LABEL 0x0006
3324 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3325 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3326 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3327 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3328 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3329 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3330 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3331 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3332 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3333 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3334 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3335 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3337 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3338 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3339 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3340 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3341 #define IMAGE_SYM_CLASS_FILE 0x0067
3342 #define IMAGE_SYM_CLASS_SECTION 0x0068
3343 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3345 #define N_BTMASK 0x000F
3346 #define N_TMASK 0x0030
3347 #define N_TMASK1 0x00C0
3348 #define N_TMASK2 0x00F0
3349 #define N_BTSHFT 4
3350 #define N_TSHIFT 2
3352 #define BTYPE(x) ((x) & N_BTMASK)
3354 #ifndef ISPTR
3355 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3356 #endif
3358 #ifndef ISFCN
3359 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3360 #endif
3362 #ifndef ISARY
3363 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3364 #endif
3366 #ifndef ISTAG
3367 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3368 #endif
3370 #ifndef INCREF
3371 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3372 #endif
3373 #ifndef DECREF
3374 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3375 #endif
3377 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3378 #define IMAGE_COMDAT_SELECT_ANY 2
3379 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3380 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3381 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3382 #define IMAGE_COMDAT_SELECT_LARGEST 6
3383 #define IMAGE_COMDAT_SELECT_NEWEST 7
3385 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3386 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3387 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3389 /* Export module directory */
3391 typedef struct _IMAGE_EXPORT_DIRECTORY {
3392 DWORD Characteristics;
3393 DWORD TimeDateStamp;
3394 WORD MajorVersion;
3395 WORD MinorVersion;
3396 DWORD Name;
3397 DWORD Base;
3398 DWORD NumberOfFunctions;
3399 DWORD NumberOfNames;
3400 DWORD AddressOfFunctions;
3401 DWORD AddressOfNames;
3402 DWORD AddressOfNameOrdinals;
3403 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
3405 /* Import name entry */
3406 typedef struct _IMAGE_IMPORT_BY_NAME {
3407 WORD Hint;
3408 BYTE Name[1];
3409 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
3411 #include <pshpack8.h>
3412 /* Import thunk */
3413 typedef struct _IMAGE_THUNK_DATA64 {
3414 union {
3415 ULONGLONG ForwarderString;
3416 ULONGLONG Function;
3417 ULONGLONG Ordinal;
3418 ULONGLONG AddressOfData;
3419 } u1;
3420 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3421 #include <poppack.h>
3423 typedef struct _IMAGE_THUNK_DATA32 {
3424 union {
3425 DWORD ForwarderString;
3426 DWORD Function;
3427 DWORD Ordinal;
3428 DWORD AddressOfData;
3429 } u1;
3430 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3432 /* Import module directory */
3434 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3435 union {
3436 DWORD Characteristics; /* 0 for terminating null import descriptor */
3437 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3438 } DUMMYUNIONNAME;
3439 DWORD TimeDateStamp; /* 0 if not bound,
3440 * -1 if bound, and real date\time stamp
3441 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3442 * (new BIND)
3443 * otherwise date/time stamp of DLL bound to
3444 * (Old BIND)
3446 DWORD ForwarderChain; /* -1 if no forwarders */
3447 DWORD Name;
3448 /* RVA to IAT (if bound this IAT has actual addresses) */
3449 DWORD FirstThunk;
3450 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3452 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3453 #define IMAGE_ORDINAL_FLAG32 0x80000000
3454 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3455 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3456 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3457 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3459 #ifdef _WIN64
3460 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3461 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3462 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3463 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3464 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3465 #else
3466 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3467 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3468 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3469 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3470 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3471 #endif
3473 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3475 DWORD TimeDateStamp;
3476 WORD OffsetModuleName;
3477 WORD NumberOfModuleForwarderRefs;
3478 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3479 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3481 typedef struct _IMAGE_BOUND_FORWARDER_REF
3483 DWORD TimeDateStamp;
3484 WORD OffsetModuleName;
3485 WORD Reserved;
3486 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3488 typedef struct _IMAGE_BASE_RELOCATION
3490 DWORD VirtualAddress;
3491 DWORD SizeOfBlock;
3492 /* WORD TypeOffset[1]; */
3493 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3495 #include <pshpack2.h>
3497 typedef struct _IMAGE_RELOCATION
3499 union {
3500 DWORD VirtualAddress;
3501 DWORD RelocCount;
3502 } DUMMYUNIONNAME;
3503 DWORD SymbolTableIndex;
3504 WORD Type;
3505 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3507 #include <poppack.h>
3509 #define IMAGE_SIZEOF_RELOCATION 10
3511 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3513 union
3515 DWORD AllAttributes;
3516 struct
3518 DWORD RvaBased:1;
3519 DWORD ReservedAttributes:31;
3520 } DUMMYSTRUCTNAME;
3521 } Attributes;
3523 DWORD DllNameRVA;
3524 DWORD ModuleHandleRVA;
3525 DWORD ImportAddressTableRVA;
3526 DWORD ImportNameTableRVA;
3527 DWORD BoundImportAddressTableRVA;
3528 DWORD UnloadInformationTableRVA;
3529 DWORD TimeDateStamp;
3530 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3531 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3533 /* generic relocation types */
3534 #define IMAGE_REL_BASED_ABSOLUTE 0
3535 #define IMAGE_REL_BASED_HIGH 1
3536 #define IMAGE_REL_BASED_LOW 2
3537 #define IMAGE_REL_BASED_HIGHLOW 3
3538 #define IMAGE_REL_BASED_HIGHADJ 4
3539 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3540 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3541 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3542 #define IMAGE_REL_BASED_SECTION 6
3543 #define IMAGE_REL_BASED_REL 7
3544 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3545 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3546 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3547 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3548 #define IMAGE_REL_BASED_DIR64 10
3549 #define IMAGE_REL_BASED_HIGH3ADJ 11
3551 /* I386 relocation types */
3552 #define IMAGE_REL_I386_ABSOLUTE 0
3553 #define IMAGE_REL_I386_DIR16 1
3554 #define IMAGE_REL_I386_REL16 2
3555 #define IMAGE_REL_I386_DIR32 6
3556 #define IMAGE_REL_I386_DIR32NB 7
3557 #define IMAGE_REL_I386_SEG12 9
3558 #define IMAGE_REL_I386_SECTION 10
3559 #define IMAGE_REL_I386_SECREL 11
3560 #define IMAGE_REL_I386_TOKEN 12
3561 #define IMAGE_REL_I386_SECREL7 13
3562 #define IMAGE_REL_I386_REL32 20
3564 /* MIPS relocation types */
3565 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3566 #define IMAGE_REL_MIPS_REFHALF 0x0001
3567 #define IMAGE_REL_MIPS_REFWORD 0x0002
3568 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3569 #define IMAGE_REL_MIPS_REFHI 0x0004
3570 #define IMAGE_REL_MIPS_REFLO 0x0005
3571 #define IMAGE_REL_MIPS_GPREL 0x0006
3572 #define IMAGE_REL_MIPS_LITERAL 0x0007
3573 #define IMAGE_REL_MIPS_SECTION 0x000A
3574 #define IMAGE_REL_MIPS_SECREL 0x000B
3575 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3576 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3577 #define IMAGE_REL_MIPS_TOKEN 0x000E
3578 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3579 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3580 #define IMAGE_REL_MIPS_PAIR 0x0025
3582 /* ALPHA relocation types */
3583 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3584 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3585 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3586 #define IMAGE_REL_ALPHA_GPREL 0x0003
3587 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3588 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3589 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3590 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3591 #define IMAGE_REL_ALPHA_HINT 0x0008
3592 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3593 #define IMAGE_REL_ALPHA_REFHI 0x000A
3594 #define IMAGE_REL_ALPHA_REFLO 0x000B
3595 #define IMAGE_REL_ALPHA_PAIR 0x000C
3596 #define IMAGE_REL_ALPHA_MATCH 0x000D
3597 #define IMAGE_REL_ALPHA_SECTION 0x000E
3598 #define IMAGE_REL_ALPHA_SECREL 0x000F
3599 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3600 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3601 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3602 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3603 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3604 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3605 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3606 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3608 /* PowerPC relocation types */
3609 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3610 #define IMAGE_REL_PPC_ADDR64 0x0001
3611 #define IMAGE_REL_PPC_ADDR 0x0002
3612 #define IMAGE_REL_PPC_ADDR24 0x0003
3613 #define IMAGE_REL_PPC_ADDR16 0x0004
3614 #define IMAGE_REL_PPC_ADDR14 0x0005
3615 #define IMAGE_REL_PPC_REL24 0x0006
3616 #define IMAGE_REL_PPC_REL14 0x0007
3617 #define IMAGE_REL_PPC_TOCREL16 0x0008
3618 #define IMAGE_REL_PPC_TOCREL14 0x0009
3619 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3620 #define IMAGE_REL_PPC_SECREL 0x000B
3621 #define IMAGE_REL_PPC_SECTION 0x000C
3622 #define IMAGE_REL_PPC_IFGLUE 0x000D
3623 #define IMAGE_REL_PPC_IMGLUE 0x000E
3624 #define IMAGE_REL_PPC_SECREL16 0x000F
3625 #define IMAGE_REL_PPC_REFHI 0x0010
3626 #define IMAGE_REL_PPC_REFLO 0x0011
3627 #define IMAGE_REL_PPC_PAIR 0x0012
3628 #define IMAGE_REL_PPC_SECRELLO 0x0013
3629 #define IMAGE_REL_PPC_SECRELHI 0x0014
3630 #define IMAGE_REL_PPC_GPREL 0x0015
3631 #define IMAGE_REL_PPC_TOKEN 0x0016
3632 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3633 /* modifier bits */
3634 #define IMAGE_REL_PPC_NEG 0x0100
3635 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3636 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3637 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3639 /* SH3 relocation types */
3640 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3641 #define IMAGE_REL_SH3_DIRECT16 0x0001
3642 #define IMAGE_REL_SH3_DIRECT 0x0002
3643 #define IMAGE_REL_SH3_DIRECT8 0x0003
3644 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3645 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3646 #define IMAGE_REL_SH3_DIRECT4 0x0006
3647 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3648 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3649 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3650 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3651 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3652 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3653 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3654 #define IMAGE_REL_SH3_SECTION 0x000E
3655 #define IMAGE_REL_SH3_SECREL 0x000F
3656 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3657 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3658 #define IMAGE_REL_SH3_TOKEN 0x0012
3660 /* ARM relocation types */
3661 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3662 #define IMAGE_REL_ARM_ADDR 0x0001
3663 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3664 #define IMAGE_REL_ARM_BRANCH24 0x0003
3665 #define IMAGE_REL_ARM_BRANCH11 0x0004
3666 #define IMAGE_REL_ARM_TOKEN 0x0005
3667 #define IMAGE_REL_ARM_GPREL12 0x0006
3668 #define IMAGE_REL_ARM_GPREL7 0x0007
3669 #define IMAGE_REL_ARM_BLX24 0x0008
3670 #define IMAGE_REL_ARM_BLX11 0x0009
3671 #define IMAGE_REL_ARM_SECTION 0x000E
3672 #define IMAGE_REL_ARM_SECREL 0x000F
3673 #define IMAGE_REL_ARM_MOV32A 0x0010
3674 #define IMAGE_REL_ARM_MOV32T 0x0011
3675 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3676 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3677 #define IMAGE_REL_ARM_BLX23T 0x0015
3679 /* ARM64 relocation types */
3680 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3681 #define IMAGE_REL_ARM64_ADDR32 0x0001
3682 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3683 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3684 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3685 #define IMAGE_REL_ARM64_REL21 0x0005
3686 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3687 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3688 #define IMAGE_REL_ARM64_SECREL 0x0008
3689 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3690 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3691 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3692 #define IMAGE_REL_ARM64_TOKEN 0x000C
3693 #define IMAGE_REL_ARM64_SECTION 0x000D
3694 #define IMAGE_REL_ARM64_ADDR64 0x000E
3695 #define IMAGE_REL_ARM64_BRANCH19 0x000F
3697 /* IA64 relocation types */
3698 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3699 #define IMAGE_REL_IA64_IMM14 0x0001
3700 #define IMAGE_REL_IA64_IMM22 0x0002
3701 #define IMAGE_REL_IA64_IMM64 0x0003
3702 #define IMAGE_REL_IA64_DIR 0x0004
3703 #define IMAGE_REL_IA64_DIR64 0x0005
3704 #define IMAGE_REL_IA64_PCREL21B 0x0006
3705 #define IMAGE_REL_IA64_PCREL21M 0x0007
3706 #define IMAGE_REL_IA64_PCREL21F 0x0008
3707 #define IMAGE_REL_IA64_GPREL22 0x0009
3708 #define IMAGE_REL_IA64_LTOFF22 0x000A
3709 #define IMAGE_REL_IA64_SECTION 0x000B
3710 #define IMAGE_REL_IA64_SECREL22 0x000C
3711 #define IMAGE_REL_IA64_SECREL64I 0x000D
3712 #define IMAGE_REL_IA64_SECREL 0x000E
3713 #define IMAGE_REL_IA64_LTOFF64 0x000F
3714 #define IMAGE_REL_IA64_DIR32NB 0x0010
3715 #define IMAGE_REL_IA64_SREL14 0x0011
3716 #define IMAGE_REL_IA64_SREL22 0x0012
3717 #define IMAGE_REL_IA64_SREL32 0x0013
3718 #define IMAGE_REL_IA64_UREL32 0x0014
3719 #define IMAGE_REL_IA64_PCREL60X 0x0015
3720 #define IMAGE_REL_IA64_PCREL60B 0x0016
3721 #define IMAGE_REL_IA64_PCREL60F 0x0017
3722 #define IMAGE_REL_IA64_PCREL60I 0x0018
3723 #define IMAGE_REL_IA64_PCREL60M 0x0019
3724 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3725 #define IMAGE_REL_IA64_TOKEN 0x001B
3726 #define IMAGE_REL_IA64_GPREL32 0x001C
3727 #define IMAGE_REL_IA64_ADDEND 0x001F
3729 /* AMD64 relocation types */
3730 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3731 #define IMAGE_REL_AMD64_ADDR64 0x0001
3732 #define IMAGE_REL_AMD64_ADDR32 0x0002
3733 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3734 #define IMAGE_REL_AMD64_REL32 0x0004
3735 #define IMAGE_REL_AMD64_REL32_1 0x0005
3736 #define IMAGE_REL_AMD64_REL32_2 0x0006
3737 #define IMAGE_REL_AMD64_REL32_3 0x0007
3738 #define IMAGE_REL_AMD64_REL32_4 0x0008
3739 #define IMAGE_REL_AMD64_REL32_5 0x0009
3740 #define IMAGE_REL_AMD64_SECTION 0x000A
3741 #define IMAGE_REL_AMD64_SECREL 0x000B
3742 #define IMAGE_REL_AMD64_SECREL7 0x000C
3743 #define IMAGE_REL_AMD64_TOKEN 0x000D
3744 #define IMAGE_REL_AMD64_SREL32 0x000E
3745 #define IMAGE_REL_AMD64_PAIR 0x000F
3746 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3748 /* archive format */
3750 #define IMAGE_ARCHIVE_START_SIZE 8
3751 #define IMAGE_ARCHIVE_START "!<arch>\n"
3752 #define IMAGE_ARCHIVE_END "`\n"
3753 #define IMAGE_ARCHIVE_PAD "\n"
3754 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3755 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3757 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3759 BYTE Name[16];
3760 BYTE Date[12];
3761 BYTE UserID[6];
3762 BYTE GroupID[6];
3763 BYTE Mode[8];
3764 BYTE Size[10];
3765 BYTE EndHeader[2];
3766 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3768 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3770 typedef struct _IMPORT_OBJECT_HEADER
3772 WORD Sig1;
3773 WORD Sig2;
3774 WORD Version;
3775 WORD Machine;
3776 DWORD TimeDateStamp;
3777 DWORD SizeOfData;
3778 union
3780 WORD Ordinal;
3781 WORD Hint;
3782 } DUMMYUNIONNAME;
3783 WORD Type : 2;
3784 WORD NameType : 3;
3785 WORD Reserved : 11;
3786 } IMPORT_OBJECT_HEADER;
3788 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3790 typedef enum IMPORT_OBJECT_TYPE
3792 IMPORT_OBJECT_CODE = 0,
3793 IMPORT_OBJECT_DATA = 1,
3794 IMPORT_OBJECT_CONST = 2
3795 } IMPORT_OBJECT_TYPE;
3797 typedef enum IMPORT_OBJECT_NAME_TYPE
3799 IMPORT_OBJECT_ORDINAL = 0,
3800 IMPORT_OBJECT_NAME = 1,
3801 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3802 IMPORT_OBJECT_NAME_UNDECORATE = 3
3803 } IMPORT_OBJECT_NAME_TYPE;
3805 typedef struct _ANON_OBJECT_HEADER
3807 WORD Sig1;
3808 WORD Sig2;
3809 WORD Version;
3810 WORD Machine;
3811 DWORD TimeDateStamp;
3812 CLSID ClassID;
3813 DWORD SizeOfData;
3814 } ANON_OBJECT_HEADER;
3817 * Resource directory stuff
3819 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3820 DWORD Characteristics;
3821 DWORD TimeDateStamp;
3822 WORD MajorVersion;
3823 WORD MinorVersion;
3824 WORD NumberOfNamedEntries;
3825 WORD NumberOfIdEntries;
3826 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3827 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3829 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3830 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3832 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3833 union {
3834 struct {
3835 unsigned NameOffset:31;
3836 unsigned NameIsString:1;
3837 } DUMMYSTRUCTNAME;
3838 DWORD Name;
3839 WORD Id;
3840 } DUMMYUNIONNAME;
3841 union {
3842 DWORD OffsetToData;
3843 struct {
3844 unsigned OffsetToDirectory:31;
3845 unsigned DataIsDirectory:1;
3846 } DUMMYSTRUCTNAME2;
3847 } DUMMYUNIONNAME2;
3848 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3851 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3852 WORD Length;
3853 CHAR NameString[ 1 ];
3854 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3856 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3857 WORD Length;
3858 WCHAR NameString[ 1 ];
3859 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3861 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3862 DWORD OffsetToData;
3863 DWORD Size;
3864 DWORD CodePage;
3865 DWORD Reserved;
3866 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3869 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3870 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3873 typedef struct _IMAGE_TLS_DIRECTORY64 {
3874 ULONGLONG StartAddressOfRawData;
3875 ULONGLONG EndAddressOfRawData;
3876 ULONGLONG AddressOfIndex;
3877 ULONGLONG AddressOfCallBacks;
3878 DWORD SizeOfZeroFill;
3879 DWORD Characteristics;
3880 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3882 typedef struct _IMAGE_TLS_DIRECTORY32 {
3883 DWORD StartAddressOfRawData;
3884 DWORD EndAddressOfRawData;
3885 DWORD AddressOfIndex;
3886 DWORD AddressOfCallBacks;
3887 DWORD SizeOfZeroFill;
3888 DWORD Characteristics;
3889 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3891 #ifdef _WIN64
3892 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3893 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3894 #else
3895 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3896 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3897 #endif
3899 typedef struct _IMAGE_DEBUG_DIRECTORY {
3900 DWORD Characteristics;
3901 DWORD TimeDateStamp;
3902 WORD MajorVersion;
3903 WORD MinorVersion;
3904 DWORD Type;
3905 DWORD SizeOfData;
3906 DWORD AddressOfRawData;
3907 DWORD PointerToRawData;
3908 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3910 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3911 #define IMAGE_DEBUG_TYPE_COFF 1
3912 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3913 #define IMAGE_DEBUG_TYPE_FPO 3
3914 #define IMAGE_DEBUG_TYPE_MISC 4
3915 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3916 #define IMAGE_DEBUG_TYPE_FIXUP 6
3917 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3918 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3919 #define IMAGE_DEBUG_TYPE_BORLAND 9
3920 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3921 #define IMAGE_DEBUG_TYPE_CLSID 11
3922 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3923 #define IMAGE_DEBUG_TYPE_POGO 13
3924 #define IMAGE_DEBUG_TYPE_ILTCG 14
3925 #define IMAGE_DEBUG_TYPE_MPX 15
3926 #define IMAGE_DEBUG_TYPE_REPRO 16
3928 typedef enum ReplacesCorHdrNumericDefines
3930 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3931 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3932 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3933 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3934 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
3935 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3936 COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000,
3938 COR_VERSION_MAJOR_V2 = 2,
3939 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3940 COR_VERSION_MINOR = 5,
3941 COR_DELETED_NAME_LENGTH = 8,
3942 COR_VTABLEGAP_NAME_LENGTH = 8,
3944 NATIVE_TYPE_MAX_CB = 1,
3945 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3947 IMAGE_COR_MIH_METHODRVA = 0x01,
3948 IMAGE_COR_MIH_EHRVA = 0x02,
3949 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3951 COR_VTABLE_32BIT = 0x01,
3952 COR_VTABLE_64BIT = 0x02,
3953 COR_VTABLE_FROM_UNMANAGED = 0x04,
3954 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3956 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3958 MAX_CLASS_NAME = 1024,
3959 MAX_PACKAGE_NAME = 1024,
3960 } ReplacesCorHdrNumericDefines;
3962 typedef struct IMAGE_COR20_HEADER
3964 DWORD cb;
3965 WORD MajorRuntimeVersion;
3966 WORD MinorRuntimeVersion;
3968 IMAGE_DATA_DIRECTORY MetaData;
3969 DWORD Flags;
3970 union {
3971 DWORD EntryPointToken;
3972 DWORD EntryPointRVA;
3973 } DUMMYUNIONNAME;
3975 IMAGE_DATA_DIRECTORY Resources;
3976 IMAGE_DATA_DIRECTORY StrongNameSignature;
3977 IMAGE_DATA_DIRECTORY CodeManagerTable;
3978 IMAGE_DATA_DIRECTORY VTableFixups;
3979 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3980 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3982 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3984 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3985 DWORD NumberOfSymbols;
3986 DWORD LvaToFirstSymbol;
3987 DWORD NumberOfLinenumbers;
3988 DWORD LvaToFirstLinenumber;
3989 DWORD RvaToFirstByteOfCode;
3990 DWORD RvaToLastByteOfCode;
3991 DWORD RvaToFirstByteOfData;
3992 DWORD RvaToLastByteOfData;
3993 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3995 #define FRAME_FPO 0
3996 #define FRAME_TRAP 1
3997 #define FRAME_TSS 2
3998 #define FRAME_NONFPO 3
4000 typedef struct _FPO_DATA {
4001 DWORD ulOffStart;
4002 DWORD cbProcSize;
4003 DWORD cdwLocals;
4004 WORD cdwParams;
4005 WORD cbProlog : 8;
4006 WORD cbRegs : 3;
4007 WORD fHasSEH : 1;
4008 WORD fUseBP : 1;
4009 WORD reserved : 1;
4010 WORD cbFrame : 2;
4011 } FPO_DATA, *PFPO_DATA;
4013 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
4014 DWORD Size;
4015 DWORD TimeDateStamp;
4016 WORD MajorVersion;
4017 WORD MinorVersion;
4018 DWORD GlobalFlagsClear;
4019 DWORD GlobalFlagsSet;
4020 DWORD CriticalSectionDefaultTimeout;
4021 ULONGLONG DeCommitFreeBlockThreshold;
4022 ULONGLONG DeCommitTotalFreeThreshold;
4023 ULONGLONG LockPrefixTable;
4024 ULONGLONG MaximumAllocationSize;
4025 ULONGLONG VirtualMemoryThreshold;
4026 ULONGLONG ProcessAffinityMask;
4027 DWORD ProcessHeapFlags;
4028 WORD CSDVersion;
4029 WORD Reserved1;
4030 ULONGLONG EditList;
4031 ULONGLONG SecurityCookie;
4032 ULONGLONG SEHandlerTable;
4033 ULONGLONG SEHandlerCount;
4034 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
4036 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
4037 DWORD Size;
4038 DWORD TimeDateStamp;
4039 WORD MajorVersion;
4040 WORD MinorVersion;
4041 DWORD GlobalFlagsClear;
4042 DWORD GlobalFlagsSet;
4043 DWORD CriticalSectionDefaultTimeout;
4044 DWORD DeCommitFreeBlockThreshold;
4045 DWORD DeCommitTotalFreeThreshold;
4046 PVOID LockPrefixTable;
4047 DWORD MaximumAllocationSize;
4048 DWORD VirtualMemoryThreshold;
4049 DWORD ProcessHeapFlags;
4050 DWORD ProcessAffinityMask;
4051 WORD CSDVersion;
4052 WORD Reserved1;
4053 PVOID EditList;
4054 DWORD SecurityCookie;
4055 DWORD SEHandlerTable;
4056 DWORD SEHandlerCount;
4057 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
4059 #ifdef _WIN64
4060 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
4061 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
4062 #else
4063 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
4064 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
4065 #endif
4067 typedef struct _IMAGE_FUNCTION_ENTRY {
4068 DWORD StartingAddress;
4069 DWORD EndingAddress;
4070 DWORD EndOfPrologue;
4071 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
4073 #define IMAGE_DEBUG_MISC_EXENAME 1
4075 typedef struct _IMAGE_DEBUG_MISC {
4076 DWORD DataType;
4077 DWORD Length;
4078 BYTE Unicode;
4079 BYTE Reserved[ 3 ];
4080 BYTE Data[ 1 ];
4081 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
4083 /* This is the structure that appears at the very start of a .DBG file. */
4085 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
4086 WORD Signature;
4087 WORD Flags;
4088 WORD Machine;
4089 WORD Characteristics;
4090 DWORD TimeDateStamp;
4091 DWORD CheckSum;
4092 DWORD ImageBase;
4093 DWORD SizeOfImage;
4094 DWORD NumberOfSections;
4095 DWORD ExportedNamesSize;
4096 DWORD DebugDirectorySize;
4097 DWORD SectionAlignment;
4098 DWORD Reserved[ 2 ];
4099 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
4101 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
4104 typedef struct tagMESSAGE_RESOURCE_ENTRY {
4105 WORD Length;
4106 WORD Flags;
4107 BYTE Text[1];
4108 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
4109 #define MESSAGE_RESOURCE_UNICODE 0x0001
4111 typedef struct tagMESSAGE_RESOURCE_BLOCK {
4112 DWORD LowId;
4113 DWORD HighId;
4114 DWORD OffsetToEntries;
4115 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
4117 typedef struct tagMESSAGE_RESOURCE_DATA {
4118 DWORD NumberOfBlocks;
4119 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
4120 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
4123 * Here follows typedefs for security and tokens.
4127 * First a constant for the following typedefs.
4130 #define ANYSIZE_ARRAY 1
4132 /* FIXME: Orphan. What does it point to? */
4133 typedef PVOID PACCESS_TOKEN;
4134 typedef PVOID PSECURITY_DESCRIPTOR;
4135 typedef PVOID PSID;
4137 typedef enum _TOKEN_ELEVATION_TYPE {
4138 TokenElevationTypeDefault = 1,
4139 TokenElevationTypeFull,
4140 TokenElevationTypeLimited
4141 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
4144 * TOKEN_INFORMATION_CLASS
4147 typedef enum _TOKEN_INFORMATION_CLASS {
4148 TokenUser = 1,
4149 TokenGroups,
4150 TokenPrivileges,
4151 TokenOwner,
4152 TokenPrimaryGroup,
4153 TokenDefaultDacl,
4154 TokenSource,
4155 TokenType,
4156 TokenImpersonationLevel,
4157 TokenStatistics,
4158 TokenRestrictedSids,
4159 TokenSessionId,
4160 TokenGroupsAndPrivileges,
4161 TokenSessionReference,
4162 TokenSandBoxInert,
4163 TokenAuditPolicy,
4164 TokenOrigin,
4165 TokenElevationType,
4166 TokenLinkedToken,
4167 TokenElevation,
4168 TokenHasRestrictions,
4169 TokenAccessInformation,
4170 TokenVirtualizationAllowed,
4171 TokenVirtualizationEnabled,
4172 TokenIntegrityLevel,
4173 TokenUIAccess,
4174 TokenMandatoryPolicy,
4175 TokenLogonSid,
4176 TokenIsAppContainer,
4177 TokenCapabilities,
4178 TokenAppContainerSid,
4179 TokenAppContainerNumber,
4180 TokenUserClaimAttributes,
4181 TokenDeviceClaimAttributes,
4182 TokenRestrictedUserClaimAttributes,
4183 TokenRestrictedDeviceClaimAttributes,
4184 TokenDeviceGroups,
4185 TokenRestrictedDeviceGroups,
4186 TokenSecurityAttributes,
4187 TokenIsRestricted,
4188 TokenProcessTrustLevel,
4189 MaxTokenInfoClass
4190 } TOKEN_INFORMATION_CLASS;
4192 #define DISABLE_MAX_PRIVILEGE 0x1
4193 #define SANDBOX_INERT 0x2
4194 #define LUA_TOKEN 0x4
4195 #define WRITE_RESTRICTED 0x8
4197 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
4198 #define TOKEN_ADJUST_GROUPS 0x0040
4199 #define TOKEN_ADJUST_PRIVILEGES 0x0020
4200 #define TOKEN_ADJUST_SESSIONID 0x0100
4201 #define TOKEN_ASSIGN_PRIMARY 0x0001
4202 #define TOKEN_DUPLICATE 0x0002
4203 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
4204 #define TOKEN_IMPERSONATE 0x0004
4205 #define TOKEN_QUERY 0x0008
4206 #define TOKEN_QUERY_SOURCE 0x0010
4207 #define TOKEN_ADJUST_DEFAULT 0x0080
4208 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
4209 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
4210 TOKEN_ADJUST_PRIVILEGES | \
4211 TOKEN_ADJUST_GROUPS | \
4212 TOKEN_ADJUST_DEFAULT )
4213 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
4214 TOKEN_ASSIGN_PRIMARY | \
4215 TOKEN_DUPLICATE | \
4216 TOKEN_IMPERSONATE | \
4217 TOKEN_QUERY | \
4218 TOKEN_QUERY_SOURCE | \
4219 TOKEN_ADJUST_PRIVILEGES | \
4220 TOKEN_ADJUST_GROUPS | \
4221 TOKEN_ADJUST_SESSIONID | \
4222 TOKEN_ADJUST_DEFAULT )
4224 #ifndef _SECURITY_DEFINED
4225 #define _SECURITY_DEFINED
4228 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
4230 typedef struct _GENERIC_MAPPING {
4231 ACCESS_MASK GenericRead;
4232 ACCESS_MASK GenericWrite;
4233 ACCESS_MASK GenericExecute;
4234 ACCESS_MASK GenericAll;
4235 } GENERIC_MAPPING, *PGENERIC_MAPPING;
4237 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
4238 #define SID_IDENTIFIER_AUTHORITY_DEFINED
4239 typedef struct {
4240 BYTE Value[6];
4241 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
4242 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
4244 #ifndef SID_DEFINED
4245 #define SID_DEFINED
4246 typedef struct _SID {
4247 BYTE Revision;
4248 BYTE SubAuthorityCount;
4249 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
4250 DWORD SubAuthority[1];
4251 } SID,*PISID;
4252 #endif /* !defined(SID_DEFINED) */
4254 #define SID_REVISION (1) /* Current revision */
4255 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
4256 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
4258 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
4261 * ACL
4264 #define ACL_REVISION1 1
4265 #define ACL_REVISION2 2
4266 #define ACL_REVISION3 3
4267 #define ACL_REVISION4 4
4269 #define MIN_ACL_REVISION ACL_REVISION2
4270 #define MAX_ACL_REVISION ACL_REVISION4
4272 #define ACL_REVISION 2
4274 typedef struct _ACL {
4275 BYTE AclRevision;
4276 BYTE Sbz1;
4277 WORD AclSize;
4278 WORD AceCount;
4279 WORD Sbz2;
4280 } ACL, *PACL;
4282 typedef enum _ACL_INFORMATION_CLASS
4284 AclRevisionInformation = 1,
4285 AclSizeInformation
4286 } ACL_INFORMATION_CLASS;
4288 typedef struct _ACL_REVISION_INFORMATION
4290 DWORD AclRevision;
4291 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
4293 typedef struct _ACL_SIZE_INFORMATION
4295 DWORD AceCount;
4296 DWORD AclBytesInUse;
4297 DWORD AclBytesFree;
4298 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
4300 /* SECURITY_DESCRIPTOR */
4301 #define SECURITY_DESCRIPTOR_REVISION 1
4302 #define SECURITY_DESCRIPTOR_REVISION1 1
4306 * Privilege Names
4308 #ifdef UNICODE
4309 #if defined(_MSC_VER) || defined(__MINGW32__)
4310 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
4311 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
4312 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
4313 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
4314 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
4315 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
4316 #define SE_TCB_NAME L"SeTcbPrivilege"
4317 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
4318 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
4319 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
4320 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
4321 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
4322 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
4323 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
4324 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
4325 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
4326 #define SE_BACKUP_NAME L"SeBackupPrivilege"
4327 #define SE_RESTORE_NAME L"SeRestorePrivilege"
4328 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
4329 #define SE_DEBUG_NAME L"SeDebugPrivilege"
4330 #define SE_AUDIT_NAME L"SeAuditPrivilege"
4331 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
4332 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
4333 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
4334 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
4335 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
4336 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
4337 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
4338 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
4339 #define SE_TRUSTED_CREDMAN_ACCESS_NAME L"SeTrustedCredManAccessPrivilege"
4340 #define SE_RELABEL_NAME L"SeRelabelPrivilege"
4341 #define SE_INC_WORKING_SET_NAME L"SeIncreaseWorkingSetPrivilege"
4342 #define SE_TIME_ZONE_NAME L"SeTimeZonePrivilege"
4343 #define SE_CREATE_SYMBOLIC_LINK_NAME L"SeCreateSymbolicLinkPrivilege"
4344 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME L"SeDelegateSessionUserImpersonatePrivilege"
4345 #else /* _MSC_VER/__MINGW32__ */
4346 static const WCHAR SE_CREATE_TOKEN_NAME[] = { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
4347 static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME[] = { 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
4348 static const WCHAR SE_LOCK_MEMORY_NAME[] = { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
4349 static const WCHAR SE_INCREASE_QUOTA_NAME[] = { 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
4350 static const WCHAR SE_UNSOLICITED_INPUT_NAME[] = { 'S','e','U','n','s','o','l','i','c','i','t','e','d','I','n','p','u','t','P','r','i','v','i','l','e','g','e',0 };
4351 static const WCHAR SE_MACHINE_ACCOUNT_NAME[] = { 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
4352 static const WCHAR SE_TCB_NAME[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
4353 static const WCHAR SE_SECURITY_NAME[] = { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
4354 static const WCHAR SE_TAKE_OWNERSHIP_NAME[] = { 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
4355 static const WCHAR SE_LOAD_DRIVER_NAME[] = { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
4356 static const WCHAR SE_SYSTEM_PROFILE_NAME[] = { 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
4357 static const WCHAR SE_SYSTEMTIME_NAME[] = { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
4358 static const WCHAR SE_PROF_SINGLE_PROCESS_NAME[] = { 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
4359 static const WCHAR SE_INC_BASE_PRIORITY_NAME[] = { 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
4360 static const WCHAR SE_CREATE_PAGEFILE_NAME[] = { 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
4361 static const WCHAR SE_CREATE_PERMANENT_NAME[] = { 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
4362 static const WCHAR SE_BACKUP_NAME[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4363 static const WCHAR SE_RESTORE_NAME[] = { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
4364 static const WCHAR SE_SHUTDOWN_NAME[] = { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
4365 static const WCHAR SE_DEBUG_NAME[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4366 static const WCHAR SE_AUDIT_NAME[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4367 static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME[] = { 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
4368 static const WCHAR SE_CHANGE_NOTIFY_NAME[] = { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
4369 static const WCHAR SE_REMOTE_SHUTDOWN_NAME[] = { 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
4370 static const WCHAR SE_UNDOCK_NAME[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4371 static const WCHAR SE_ENABLE_DELEGATION_NAME[] = { 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
4372 static const WCHAR SE_MANAGE_VOLUME_NAME[] = { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
4373 static const WCHAR SE_IMPERSONATE_NAME[] = { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
4374 static const WCHAR SE_CREATE_GLOBAL_NAME[] = { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
4375 static const WCHAR SE_TRUSTED_CREDMAN_ACCESS_NAME[] = { 'S','e','T','r','u','s','t','e','d','C','r','e','d','M','a','n','A','c','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
4376 static const WCHAR SE_RELABEL_NAME[] = { 'S','e','R','e','l','a','b','e','l','P','r','i','v','i','l','e','g','e',0 };
4377 static const WCHAR SE_INC_WORKING_SET_NAME[] = { 'S','e','I','n','c','r','e','a','s','e','W','o','r','k','i','n','g','S','e','t','P','r','i','v','i','l','e','g','e',0 };
4378 static const WCHAR SE_TIME_ZONE_NAME[] = { 'S','e','T','i','m','e','Z','o','n','e','P','r','i','v','i','l','e','g','e',0 };
4379 static const WCHAR SE_CREATE_SYMBOLIC_LINK_NAME[] = { 'S','e','C','r','e','a','t','e','S','y','m','b','o','l','i','c','L','i','n','k','P','r','i','v','i','l','e','g','e',0 };
4380 static const WCHAR SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME[] = { 'S','e','D','e','l','e','g','a','t','e','S','e','s','s','i','o','n','U','s','e','r','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
4381 #endif
4382 #else /* UNICODE */
4383 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4384 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4385 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4386 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4387 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4388 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4389 #define SE_TCB_NAME "SeTcbPrivilege"
4390 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4391 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4392 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4393 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4394 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4395 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4396 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4397 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4398 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4399 #define SE_BACKUP_NAME "SeBackupPrivilege"
4400 #define SE_RESTORE_NAME "SeRestorePrivilege"
4401 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4402 #define SE_DEBUG_NAME "SeDebugPrivilege"
4403 #define SE_AUDIT_NAME "SeAuditPrivilege"
4404 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4405 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4406 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4407 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4408 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4409 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4410 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4411 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4412 #define SE_TRUSTED_CREDMAN_ACCESS_NAME "SeTrustedCredManAccessPrivilege"
4413 #define SE_RELABEL_NAME "SeRelabelPrivilege"
4414 #define SE_INC_WORKING_SET_NAME "SeIncreaseWorkingSetPrivilege"
4415 #define SE_TIME_ZONE_NAME "SeTimeZonePrivilege"
4416 #define SE_CREATE_SYMBOLIC_LINK_NAME "SeCreateSymbolicLinkPrivilege"
4417 #define SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME "SeDelegateSessionUserImpersonatePrivilege"
4418 #endif
4420 #define SE_GROUP_MANDATORY 0x00000001
4421 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4422 #define SE_GROUP_ENABLED 0x00000004
4423 #define SE_GROUP_OWNER 0x00000008
4424 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4425 #define SE_GROUP_INTEGRITY 0x00000020
4426 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4427 #define SE_GROUP_LOGON_ID 0xC0000000
4428 #define SE_GROUP_RESOURCE 0x20000000
4429 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4431 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4432 #define SE_PRIVILEGE_ENABLED 0x00000002
4433 #define SE_PRIVILEGE_REMOVED 0x00000004
4434 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4435 #define SE_PRIVILEGE_VALID_ATTRIBUTES 0x80000007
4437 #define PRIVILEGE_SET_ALL_NECESSARY 1
4439 #define SE_OWNER_DEFAULTED 0x00000001
4440 #define SE_GROUP_DEFAULTED 0x00000002
4441 #define SE_DACL_PRESENT 0x00000004
4442 #define SE_DACL_DEFAULTED 0x00000008
4443 #define SE_SACL_PRESENT 0x00000010
4444 #define SE_SACL_DEFAULTED 0x00000020
4445 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4446 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4447 #define SE_DACL_AUTO_INHERITED 0x00000400
4448 #define SE_SACL_AUTO_INHERITED 0x00000800
4449 #define SE_DACL_PROTECTED 0x00001000
4450 #define SE_SACL_PROTECTED 0x00002000
4451 #define SE_RM_CONTROL_VALID 0x00004000
4452 #define SE_SELF_RELATIVE 0x00008000
4454 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4455 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4457 /* The security descriptor structure */
4458 typedef struct {
4459 BYTE Revision;
4460 BYTE Sbz1;
4461 SECURITY_DESCRIPTOR_CONTROL Control;
4462 DWORD Owner;
4463 DWORD Group;
4464 DWORD Sacl;
4465 DWORD Dacl;
4466 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4468 typedef struct {
4469 BYTE Revision;
4470 BYTE Sbz1;
4471 SECURITY_DESCRIPTOR_CONTROL Control;
4472 PSID Owner;
4473 PSID Group;
4474 PACL Sacl;
4475 PACL Dacl;
4476 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4478 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4480 #endif /* _SECURITY_DEFINED */
4483 * SID_AND_ATTRIBUTES
4486 typedef struct _SID_AND_ATTRIBUTES {
4487 PSID Sid;
4488 DWORD Attributes;
4489 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4491 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
4492 typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
4494 #define SID_HASH_SIZE 32
4496 typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY;
4498 typedef struct _SID_AND_ATTRIBUTES_HASH {
4499 DWORD SidCount;
4500 PSID_AND_ATTRIBUTES SidAttr;
4501 SID_HASH_ENTRY Hash[SID_HASH_SIZE];
4502 } SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH;
4504 /* security entities */
4505 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4506 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4507 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4509 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4511 /* S-1-1 */
4512 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4514 /* S-1-2 */
4515 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4516 #define SECURITY_LOCAL_LOGON_RID __MSABI_LONG(0X00000000)
4518 /* S-1-3 */
4519 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4520 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4521 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4522 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4523 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4524 #define SECURITY_CREATOR_OWNER_RIGHTS_RID __MSABI_LONG(0x00000004)
4526 /* S-1-4 */
4527 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4529 /* S-1-5 */
4530 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4531 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4532 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4533 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4534 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4535 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4536 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4537 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4538 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4539 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4540 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4541 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4542 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4543 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4544 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4545 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4546 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4547 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4548 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4549 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4550 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4551 #define SECURITY_ENTERPRISE_READONLY_CONTROLLERS_RID __MSABI_LONG(0x00000016)
4552 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4553 #define SECURITY_WRITE_RESTRICTED_CODE_RID __MSABI_LONG(0x00000021)
4555 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4556 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4557 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4558 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4559 #define SECURITY_CRED_TYPE_BASE_RID __MSABI_LONG(0x00000041)
4560 #define SECURITY_CRED_TYPE_THIS_ORG_CERT_RID __MSABI_LONG(0x00000001)
4561 #define SECURITY_MIN_BASE_RID __MSABI_LONG(0x00000050)
4562 #define SECURITY_SERVICE_ID_BASE_RID __MSABI_LONG(0x00000050)
4563 #define SECURITY_RESERVED_ID_BASE_RID __MSABI_LONG(0x00000051)
4564 #define SECURITY_APPPOOL_ID_BASE_RID __MSABI_LONG(0x00000052)
4565 #define SECURITY_VIRTUALSERVER_ID_BASE_RID __MSABI_LONG(0x00000053)
4566 #define SECURITY_USERMODEDRIVERHOST_ID_BASE_RID __MSABI_LONG(0x00000054)
4567 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_BASE_RID __MSABI_LONG(0x00000055)
4568 #define SECURITY_WMIHOST_ID_BASE_RID __MSABI_LONG(0x00000056)
4569 #define SECURITY_TASK_ID_BASE_RID __MSABI_LONG(0x00000057)
4570 #define SECURITY_NFS_ID_BASE_RID __MSABI_LONG(0x00000058)
4571 #define SECURITY_COM_ID_BASE_RID __MSABI_LONG(0x00000059)
4572 #define SECURITY_MAX_BASE_RID __MSABI_LONG(0x0000006F)
4573 #define SECURITY_WINDOWSMOBILE_ID_BASE_RID __MSABI_LONG(0x00000070)
4574 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4575 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4576 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4578 #define DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS __MSABI_LONG(0x000001F2)
4580 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4581 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4582 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4583 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4584 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4586 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4587 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4588 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4589 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4590 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4591 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4592 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4593 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4594 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4595 #define DOMAIN_GROUP_RID_READONLY_CONTROLLERS __MSABI_LONG(0x00000209)
4597 #define SECURITY_RESOURCE_MANAGER_AUTHORITY {0,0,0,0,0,9}
4599 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4600 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4601 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4602 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4603 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4604 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4605 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4606 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4607 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4608 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4609 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4611 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4612 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4613 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4614 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4615 #define SECURITY_MANDATORY_MEDIUM_PLUS_RID __MSABI_LONG(0x00002100)
4616 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4617 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4618 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4619 #define SECURITY_MANDATORY_MAXIMUM_USER_RID SECURITY_MANDATORY_SYSTEM_RID
4621 #define MANDATORY_LEVEL_TO_MANDATORY_RID(ML) (ML * 0x1000)
4623 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4624 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4625 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4626 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4628 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4629 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4630 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4631 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4633 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4634 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4635 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4636 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4637 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4638 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4640 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4641 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4642 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4643 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4644 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4645 #define DOMAIN_ALIAS_RID_IUSERS __MSABI_LONG(0x00000238)
4646 #define DOMAIN_ALIAS_RID_CRYPTO_OPERATORS __MSABI_LONG(0x00000239)
4647 #define DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023B)
4648 #define DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP __MSABI_LONG(0x0000023C)
4649 #define DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP __MSABI_LONG(0x0000023D)
4650 #define DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP __MSABI_LONG(0x0000023E)
4652 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4654 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4655 #define SECURITY_CRED_TYPE_RID_COUNT __MSABI_LONG(2)
4656 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4657 #define SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT __MSABI_LONG(3)
4658 #define SECURITY_SERVICE_ID_RID_COUNT __MSABI_LONG(6)
4659 #define SECURITY_APPPOOL_ID_RID_COUNT __MSABI_LONG(6)
4660 #define SECURITY_VIRTUALSERVER_ID_RID_COUNT __MSABI_LONG(6)
4661 #define SECURITY_USERMODEDRIVERHOST_ID_RID_COUNT __MSABI_LONG(6)
4662 #define SECURITY_CLOUD_INFRASTRUCTURE_SERVICES_ID_RID_COUNT __MSABI_LONG(6)
4663 #define SECURITY_WMIHOST_ID_RID_COUNT __MSABI_LONG(6)
4664 #define SECURITY_VIRTUALACCOUNT_ID_RID_COUNT __MSABI_LONG(6)
4666 #define SYSTEM_LUID { 0x3e7, 0x0 }
4667 #define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
4668 #define LOCALSERVICE_LUID { 0x3e5, 0x0 }
4669 #define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
4670 #define IUSER_LUID { 0x3e3, 0x0 }
4672 typedef enum {
4673 WinNullSid = 0,
4674 WinWorldSid = 1,
4675 WinLocalSid = 2,
4676 WinCreatorOwnerSid = 3,
4677 WinCreatorGroupSid = 4,
4678 WinCreatorOwnerServerSid = 5,
4679 WinCreatorGroupServerSid = 6,
4680 WinNtAuthoritySid = 7,
4681 WinDialupSid = 8,
4682 WinNetworkSid = 9,
4683 WinBatchSid = 10,
4684 WinInteractiveSid = 11,
4685 WinServiceSid = 12,
4686 WinAnonymousSid = 13,
4687 WinProxySid = 14,
4688 WinEnterpriseControllersSid = 15,
4689 WinSelfSid = 16,
4690 WinAuthenticatedUserSid = 17,
4691 WinRestrictedCodeSid = 18,
4692 WinTerminalServerSid = 19,
4693 WinRemoteLogonIdSid = 20,
4694 WinLogonIdsSid = 21,
4695 WinLocalSystemSid = 22,
4696 WinLocalServiceSid = 23,
4697 WinNetworkServiceSid = 24,
4698 WinBuiltinDomainSid = 25,
4699 WinBuiltinAdministratorsSid = 26,
4700 WinBuiltinUsersSid = 27,
4701 WinBuiltinGuestsSid = 28,
4702 WinBuiltinPowerUsersSid = 29,
4703 WinBuiltinAccountOperatorsSid = 30,
4704 WinBuiltinSystemOperatorsSid = 31,
4705 WinBuiltinPrintOperatorsSid = 32,
4706 WinBuiltinBackupOperatorsSid = 33,
4707 WinBuiltinReplicatorSid = 34,
4708 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4709 WinBuiltinRemoteDesktopUsersSid = 36,
4710 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4711 WinAccountAdministratorSid = 38,
4712 WinAccountGuestSid = 39,
4713 WinAccountKrbtgtSid = 40,
4714 WinAccountDomainAdminsSid = 41,
4715 WinAccountDomainUsersSid = 42,
4716 WinAccountDomainGuestsSid = 43,
4717 WinAccountComputersSid = 44,
4718 WinAccountControllersSid = 45,
4719 WinAccountCertAdminsSid = 46,
4720 WinAccountSchemaAdminsSid = 47,
4721 WinAccountEnterpriseAdminsSid = 48,
4722 WinAccountPolicyAdminsSid = 49,
4723 WinAccountRasAndIasServersSid = 50,
4724 WinNTLMAuthenticationSid = 51,
4725 WinDigestAuthenticationSid = 52,
4726 WinSChannelAuthenticationSid = 53,
4727 WinThisOrganizationSid = 54,
4728 WinOtherOrganizationSid = 55,
4729 WinBuiltinIncomingForestTrustBuildersSid = 56,
4730 WinBuiltinPerfMonitoringUsersSid = 57,
4731 WinBuiltinPerfLoggingUsersSid = 58,
4732 WinBuiltinAuthorizationAccessSid = 59,
4733 WinBuiltinTerminalServerLicenseServersSid = 60,
4734 WinBuiltinDCOMUsersSid = 61,
4735 WinBuiltinIUsersSid = 62,
4736 WinIUserSid = 63,
4737 WinBuiltinCryptoOperatorsSid = 64,
4738 WinUntrustedLabelSid = 65,
4739 WinLowLabelSid = 66,
4740 WinMediumLabelSid = 67,
4741 WinHighLabelSid = 68,
4742 WinSystemLabelSid = 69,
4743 WinWriteRestrictedCodeSid = 70,
4744 WinCreatorOwnerRightsSid = 71,
4745 WinCacheablePrincipalsGroupSid = 72,
4746 WinNonCacheablePrincipalsGroupSid = 73,
4747 WinEnterpriseReadonlyControllersSid = 74,
4748 WinAccountReadonlyControllersSid = 75,
4749 WinBuiltinEventLogReadersGroup = 76,
4750 WinNewEnterpriseReadonlyControllersSid = 77,
4751 WinBuiltinCertSvcDComAccessGroup = 78,
4752 WinMediumPlusLabelSid = 79,
4753 WinLocalLogonSid = 80,
4754 WinConsoleLogonSid = 81,
4755 WinThisOrganizationCertificateSid = 82,
4756 WinApplicationPackageAuthoritySid = 83,
4757 WinBuiltinAnyPackageSid = 84,
4758 WinCapabilityInternetClientSid = 85,
4759 WinCapabilityInternetClientServerSid = 86,
4760 WinCapabilityPrivateNetworkClientServerSid = 87,
4761 WinCapabilityPicturesLibrarySid = 88,
4762 WinCapabilityVideosLibrarySid = 89,
4763 WinCapabilityMusicLibrarySid = 90,
4764 WinCapabilityDocumentsLibrarySid = 91,
4765 WinCapabilitySharedUserCertificatesSid = 92,
4766 WinCapabilityEnterpriseAuthenticationSid = 93,
4767 WinCapabilityRemovableStorageSid = 94,
4768 WinBuiltinRDSRemoteAccessServersSid = 95,
4769 WinBuiltinRDSEndpointServersSid = 96,
4770 WinBuiltinRDSManagementServersSid = 97,
4771 WinUserModeDriversSid = 98,
4772 WinBuiltinHyperVAdminsSid = 99,
4773 WinAccountCloneableControllersSid = 100,
4774 WinBuiltinAccessControlAssistanceOperatorsSid = 101,
4775 WinBuiltinRemoteManagementUsersSid = 102,
4776 WinAuthenticationAuthorityAssertedSid = 103,
4777 WinAuthenticationServiceAssertedSid = 104,
4778 WinLocalAccountSid = 105,
4779 WinLocalAccountAndAdministratorSid = 106,
4780 WinAccountProtectedUsersSid = 107,
4781 } WELL_KNOWN_SID_TYPE;
4784 * TOKEN_USER
4787 typedef struct _TOKEN_USER {
4788 SID_AND_ATTRIBUTES User;
4789 } TOKEN_USER, *PTOKEN_USER;
4792 * TOKEN_GROUPS
4795 typedef struct _TOKEN_GROUPS {
4796 DWORD GroupCount;
4797 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4798 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4801 * LUID_AND_ATTRIBUTES
4804 typedef union _LARGE_INTEGER {
4805 struct {
4806 #ifdef WORDS_BIGENDIAN
4807 LONG HighPart;
4808 DWORD LowPart;
4809 #else
4810 DWORD LowPart;
4811 LONG HighPart;
4812 #endif
4813 } u;
4814 #ifndef NONAMELESSSTRUCT
4815 struct {
4816 #ifdef WORDS_BIGENDIAN
4817 LONG HighPart;
4818 DWORD LowPart;
4819 #else
4820 DWORD LowPart;
4821 LONG HighPart;
4822 #endif
4824 #endif
4825 LONGLONG QuadPart;
4826 } LARGE_INTEGER, *PLARGE_INTEGER;
4828 typedef union _ULARGE_INTEGER {
4829 struct {
4830 #ifdef WORDS_BIGENDIAN
4831 DWORD HighPart;
4832 DWORD LowPart;
4833 #else
4834 DWORD LowPart;
4835 DWORD HighPart;
4836 #endif
4837 } u;
4838 #ifndef NONAMELESSSTRUCT
4839 struct {
4840 #ifdef WORDS_BIGENDIAN
4841 DWORD HighPart;
4842 DWORD LowPart;
4843 #else
4844 DWORD LowPart;
4845 DWORD HighPart;
4846 #endif
4848 #endif
4849 ULONGLONG QuadPart;
4850 } ULARGE_INTEGER, *PULARGE_INTEGER;
4853 * Locally Unique Identifier
4856 typedef struct _LUID {
4857 DWORD LowPart;
4858 LONG HighPart;
4859 } LUID, *PLUID;
4861 #include <pshpack4.h>
4862 typedef struct _LUID_AND_ATTRIBUTES {
4863 LUID Luid;
4864 DWORD Attributes;
4865 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4866 #include <poppack.h>
4869 * PRIVILEGE_SET
4872 typedef struct _PRIVILEGE_SET {
4873 DWORD PrivilegeCount;
4874 DWORD Control;
4875 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4876 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4879 * TOKEN_PRIVILEGES
4882 typedef struct _TOKEN_PRIVILEGES {
4883 DWORD PrivilegeCount;
4884 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4885 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4888 * TOKEN_OWNER
4891 typedef struct _TOKEN_OWNER {
4892 PSID Owner;
4893 } TOKEN_OWNER, *PTOKEN_OWNER;
4896 * TOKEN_PRIMARY_GROUP
4899 typedef struct _TOKEN_PRIMARY_GROUP {
4900 PSID PrimaryGroup;
4901 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4905 * TOKEN_DEFAULT_DACL
4908 typedef struct _TOKEN_DEFAULT_DACL {
4909 PACL DefaultDacl;
4910 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4913 * TOKEN_SOURCE
4916 #define TOKEN_SOURCE_LENGTH 8
4918 typedef struct _TOKEN_SOURCE {
4919 char SourceName[TOKEN_SOURCE_LENGTH];
4920 LUID SourceIdentifier;
4921 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4924 * TOKEN_TYPE
4927 typedef enum tagTOKEN_TYPE {
4928 TokenPrimary = 1,
4929 TokenImpersonation
4930 } TOKEN_TYPE;
4933 * SECURITY_IMPERSONATION_LEVEL
4936 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4937 SecurityAnonymous,
4938 SecurityIdentification,
4939 SecurityImpersonation,
4940 SecurityDelegation
4941 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4943 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4944 #define SECURITY_STATIC_TRACKING (FALSE)
4946 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4947 * PSECURITY_CONTEXT_TRACKING_MODE;
4949 * Quality of Service
4952 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4953 DWORD Length;
4954 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4955 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4956 BOOLEAN EffectiveOnly;
4957 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4960 * TOKEN_STATISTICS
4963 #include <pshpack4.h>
4964 typedef struct _TOKEN_STATISTICS {
4965 LUID TokenId;
4966 LUID AuthenticationId;
4967 LARGE_INTEGER ExpirationTime;
4968 TOKEN_TYPE TokenType;
4969 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4970 DWORD DynamicCharged;
4971 DWORD DynamicAvailable;
4972 DWORD GroupCount;
4973 DWORD PrivilegeCount;
4974 LUID ModifiedId;
4975 } TOKEN_STATISTICS;
4976 #include <poppack.h>
4978 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4979 DWORD SidCount;
4980 DWORD SidLength;
4981 PSID_AND_ATTRIBUTES Sids;
4982 DWORD RestrictedSidCount;
4983 DWORD RestrictedSidLength;
4984 PSID_AND_ATTRIBUTES RestrictedSids;
4985 DWORD PrivilegeCount;
4986 DWORD PrivilegeLength;
4987 PLUID_AND_ATTRIBUTES Privileges;
4988 LUID AuthenticationId;
4989 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4991 typedef struct _TOKEN_ORIGIN {
4992 LUID OriginatingLogonSession;
4993 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4995 typedef struct _TOKEN_LINKED_TOKEN {
4996 HANDLE LinkedToken;
4997 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4999 typedef struct _TOKEN_ELEVATION {
5000 DWORD TokenIsElevated;
5001 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
5003 typedef struct _TOKEN_MANDATORY_LABEL {
5004 SID_AND_ATTRIBUTES Label;
5005 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
5007 #define TOKEN_MANDATORY_POLICY_OFF 0x0
5008 #define TOKEN_MANDATORY_POLICY_NO_WRITEUP 0x1
5009 #define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2
5010 #define TOKEN_MANDATORY_POLICY_VALID_MASK 0x3
5012 typedef struct _TOKEN_MANDATORY_POLICY {
5013 DWORD Policy;
5014 } TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY;
5016 typedef struct _TOKEN_APPCONTAINER_INFORMATION {
5017 PSID TokenAppContainer;
5018 } TOKEN_APPCONTAINER_INFORMATION, * PTOKEN_APPCONTAINER_INFORMATION;
5020 #define POLICY_AUDIT_SUBCATEGORY_COUNT 53
5022 typedef struct _TOKEN_AUDIT_POLICY {
5023 BYTE PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1];
5024 } TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY;
5026 typedef struct _TOKEN_ACCESS_INFORMATION {
5027 PSID_AND_ATTRIBUTES_HASH SidHash;
5028 PSID_AND_ATTRIBUTES_HASH RestrictedSidHash;
5029 PTOKEN_PRIVILEGES Privileges;
5030 LUID AuthenticationId;
5031 TOKEN_TYPE TokenType;
5032 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
5033 TOKEN_MANDATORY_POLICY MandatoryPolicy;
5034 DWORD Flags;
5035 } TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION;
5037 typedef struct _TOKEN_CONTROL {
5038 LUID TokenId;
5039 LUID AuthenticationId;
5040 LUID ModifiedId;
5041 TOKEN_SOURCE TokenSource;
5042 } TOKEN_CONTROL, *PTOKEN_CONTROL;
5045 * ACLs of NT
5048 /* ACEs, directly starting after an ACL */
5049 typedef struct _ACE_HEADER {
5050 BYTE AceType;
5051 BYTE AceFlags;
5052 WORD AceSize;
5053 } ACE_HEADER,*PACE_HEADER;
5055 /* AceType */
5056 #define ACCESS_MIN_MS_ACE_TYPE 0x0
5057 #define ACCESS_ALLOWED_ACE_TYPE 0x0
5058 #define ACCESS_DENIED_ACE_TYPE 0x1
5059 #define SYSTEM_AUDIT_ACE_TYPE 0x2
5060 #define SYSTEM_ALARM_ACE_TYPE 0x3
5061 #define ACCESS_MAX_MS_V2_ACE_TYPE 0x3
5062 #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4
5063 #define ACCESS_MAX_MS_V3_ACE_TYPE 0x4
5064 #define ACCESS_MIN_MS_OBJECT_ACE_TYPE 0x5
5065 #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5
5066 #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6
5067 #define ACCESS_AUDIT_OBJECT_ACE_TYPE 0x7
5068 #define ACCESS_ALARM_OBJECT_ACE_TYPE 0x8
5069 #define ACCESS_MAX_MS_V4_ACE_TYPE 0x8
5070 #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9
5071 #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xa
5072 #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xb
5073 #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xc
5074 #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xd
5075 #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xe
5076 #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xf
5077 #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
5078 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
5079 #define SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE 0x12
5080 #define SYSTEM_SCOPED_POLICY_ID_ACE_TYPE 0x13
5081 #define SYSTEM_PROCESS_TRUST_LABEL_ACE_TYPE 0x14
5082 #define ACCESS_MAX_MS_V5_ACE_TYPE 0x14
5084 /* inherit AceFlags */
5085 #define OBJECT_INHERIT_ACE 0x01
5086 #define CONTAINER_INHERIT_ACE 0x02
5087 #define NO_PROPAGATE_INHERIT_ACE 0x04
5088 #define INHERIT_ONLY_ACE 0x08
5089 #define INHERITED_ACE 0x10
5090 #define VALID_INHERIT_FLAGS 0x1F
5092 /* AceFlags mask for what events we (should) audit */
5093 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
5094 #define FAILED_ACCESS_ACE_FLAG 0x80
5096 /* different ACEs depending on AceType
5097 * SidStart marks the begin of a SID
5098 * so the thing finally looks like this:
5099 * 0: ACE_HEADER
5100 * 4: ACCESS_MASK
5101 * 8... : SID
5103 typedef struct _ACCESS_ALLOWED_ACE {
5104 ACE_HEADER Header;
5105 DWORD Mask;
5106 DWORD SidStart;
5107 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
5109 typedef struct _ACCESS_DENIED_ACE {
5110 ACE_HEADER Header;
5111 DWORD Mask;
5112 DWORD SidStart;
5113 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
5115 typedef struct _SYSTEM_AUDIT_ACE {
5116 ACE_HEADER Header;
5117 DWORD Mask;
5118 DWORD SidStart;
5119 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
5121 typedef struct _SYSTEM_ALARM_ACE {
5122 ACE_HEADER Header;
5123 DWORD Mask;
5124 DWORD SidStart;
5125 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
5127 typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
5128 ACE_HEADER Header;
5129 ACCESS_MASK Mask;
5130 DWORD SidStart;
5131 } SYSTEM_MANDATORY_LABEL_ACE,*PSYSTEM_MANDATORY_LABEL_ACE;
5133 typedef struct _ACCESS_ALLOWED_OBJECT_ACE {
5134 ACE_HEADER Header;
5135 ACCESS_MASK Mask;
5136 DWORD Flags;
5137 GUID ObjectType;
5138 GUID InheritedObjectType;
5139 DWORD SidStart;
5140 } ACCESS_ALLOWED_OBJECT_ACE, *PACCESS_ALLOWED_OBJECT_ACE;
5142 typedef struct _ACCESS_DENIED_OBJECT_ACE {
5143 ACE_HEADER Header;
5144 ACCESS_MASK Mask;
5145 DWORD Flags;
5146 GUID ObjectType;
5147 GUID InheritedObjectType;
5148 DWORD SidStart;
5149 } ACCESS_DENIED_OBJECT_ACE, *PACCESS_DENIED_OBJECT_ACE;
5151 typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
5152 ACE_HEADER Header;
5153 ACCESS_MASK Mask;
5154 DWORD Flags;
5155 GUID ObjectType;
5156 GUID InheritedObjectType;
5157 DWORD SidStart;
5158 } SYSTEM_AUDIT_OBJECT_ACE, *PSYSTEM_AUDIT_OBJECT_ACE;
5160 typedef struct _SYSTEM_ALARM_OBJECT_ACE {
5161 ACE_HEADER Header;
5162 ACCESS_MASK Mask;
5163 DWORD Flags;
5164 GUID ObjectType;
5165 GUID InheritedObjectType;
5166 DWORD SidStart;
5167 } SYSTEM_ALARM_OBJECT_ACE, *PSYSTEM_ALARM_OBJECT_aCE;
5169 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
5170 ACE_HEADER Header;
5171 DWORD Mask;
5172 DWORD SidStart;
5173 } ACCESS_ALLOWED_CALLBACK_ACE,*PACCESS_ALLOWED_CALLBACK_ACE;
5175 typedef struct _ACCESS_DENIED_CALLBACK_ACE {
5176 ACE_HEADER Header;
5177 DWORD Mask;
5178 DWORD SidStart;
5179 } ACCESS_DENIED_CALLBACK_ACE,*PACCESS_DENIED_CALLBACK_ACE;
5181 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
5182 ACE_HEADER Header;
5183 DWORD Mask;
5184 DWORD SidStart;
5185 } SYSTEM_AUDIT_CALLBACK_ACE,*PSYSTEM_AUDIT_CALLBACK_ACE;
5187 typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
5188 ACE_HEADER Header;
5189 DWORD Mask;
5190 DWORD SidStart;
5191 } SYSTEM_ALARM_CALLBACK_ACE,*PSYSTEM_ALARM_CALLBACK_ACE;
5193 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
5194 ACE_HEADER Header;
5195 ACCESS_MASK Mask;
5196 DWORD Flags;
5197 GUID ObjectType;
5198 GUID InheritedObjectType;
5199 DWORD SidStart;
5200 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
5202 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
5203 ACE_HEADER Header;
5204 ACCESS_MASK Mask;
5205 DWORD Flags;
5206 GUID ObjectType;
5207 GUID InheritedObjectType;
5208 DWORD SidStart;
5209 } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
5211 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
5212 ACE_HEADER Header;
5213 ACCESS_MASK Mask;
5214 DWORD Flags;
5215 GUID ObjectType;
5216 GUID InheritedObjectType;
5217 DWORD SidStart;
5218 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
5220 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
5221 ACE_HEADER Header;
5222 ACCESS_MASK Mask;
5223 DWORD Flags;
5224 GUID ObjectType;
5225 GUID InheritedObjectType;
5226 DWORD SidStart;
5227 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
5229 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
5230 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
5231 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
5232 #define SYSTEM_MANDATORY_LABEL_VALID_MASK 0x7
5234 typedef enum tagSID_NAME_USE {
5235 SidTypeUser = 1,
5236 SidTypeGroup,
5237 SidTypeDomain,
5238 SidTypeAlias,
5239 SidTypeWellKnownGroup,
5240 SidTypeDeletedAccount,
5241 SidTypeInvalid,
5242 SidTypeUnknown
5243 } SID_NAME_USE,*PSID_NAME_USE;
5245 #define ACE_OBJECT_TYPE_PRESENT 0x1
5246 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
5248 /* Access rights */
5250 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
5251 #undef DELETE
5252 #define DELETE 0x00010000
5253 #define READ_CONTROL 0x00020000
5254 #define WRITE_DAC 0x00040000
5255 #define WRITE_OWNER 0x00080000
5256 #define SYNCHRONIZE 0x00100000
5257 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
5259 #define STANDARD_RIGHTS_READ READ_CONTROL
5260 #define STANDARD_RIGHTS_WRITE READ_CONTROL
5261 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
5263 #define STANDARD_RIGHTS_ALL 0x001f0000
5265 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
5267 #define GENERIC_READ 0x80000000
5268 #define GENERIC_WRITE 0x40000000
5269 #define GENERIC_EXECUTE 0x20000000
5270 #define GENERIC_ALL 0x10000000
5272 #define MAXIMUM_ALLOWED 0x02000000
5273 #define ACCESS_SYSTEM_SECURITY 0x01000000
5275 #define EVENT_QUERY_STATE 0x0001
5276 #define EVENT_MODIFY_STATE 0x0002
5277 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5279 #define SEMAPHORE_QUERY_STATE 0x0001
5280 #define SEMAPHORE_MODIFY_STATE 0x0002
5281 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5283 #define MUTANT_QUERY_STATE 0x0001
5284 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
5286 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
5287 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
5288 #define JOB_OBJECT_QUERY 0x0004
5289 #define JOB_OBJECT_TERMINATE 0x0008
5290 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
5291 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
5293 #define TIMER_QUERY_STATE 0x0001
5294 #define TIMER_MODIFY_STATE 0x0002
5295 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
5297 #define PROCESS_TERMINATE 0x0001
5298 #define PROCESS_CREATE_THREAD 0x0002
5299 #define PROCESS_VM_OPERATION 0x0008
5300 #define PROCESS_VM_READ 0x0010
5301 #define PROCESS_VM_WRITE 0x0020
5302 #define PROCESS_DUP_HANDLE 0x0040
5303 #define PROCESS_CREATE_PROCESS 0x0080
5304 #define PROCESS_SET_QUOTA 0x0100
5305 #define PROCESS_SET_INFORMATION 0x0200
5306 #define PROCESS_QUERY_INFORMATION 0x0400
5307 #define PROCESS_SUSPEND_RESUME 0x0800
5308 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
5309 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
5310 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5312 #define THREAD_TERMINATE 0x0001
5313 #define THREAD_SUSPEND_RESUME 0x0002
5314 #define THREAD_GET_CONTEXT 0x0008
5315 #define THREAD_SET_CONTEXT 0x0010
5316 #define THREAD_SET_INFORMATION 0x0020
5317 #define THREAD_QUERY_INFORMATION 0x0040
5318 #define THREAD_SET_THREAD_TOKEN 0x0080
5319 #define THREAD_IMPERSONATE 0x0100
5320 #define THREAD_DIRECT_IMPERSONATION 0x0200
5321 #define THREAD_SET_LIMITED_INFORMATION 0x0400
5322 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
5323 #define THREAD_RESUME 0x1000
5324 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
5326 #define THREAD_BASE_PRIORITY_LOWRT 15
5327 #define THREAD_BASE_PRIORITY_MAX 2
5328 #define THREAD_BASE_PRIORITY_MIN -2
5329 #define THREAD_BASE_PRIORITY_IDLE -15
5331 typedef struct _QUOTA_LIMITS {
5332 SIZE_T PagedPoolLimit;
5333 SIZE_T NonPagedPoolLimit;
5334 SIZE_T MinimumWorkingSetSize;
5335 SIZE_T MaximumWorkingSetSize;
5336 SIZE_T PagefileLimit;
5337 LARGE_INTEGER TimeLimit;
5338 } QUOTA_LIMITS, *PQUOTA_LIMITS;
5340 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
5341 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
5342 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
5343 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
5344 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
5346 typedef union _RATE_QUOTA_LIMIT {
5347 DWORD RateData;
5348 struct {
5349 DWORD RatePercent:7;
5350 DWORD Reserved0:25;
5351 } DUMMYSTRUCTNAME;
5352 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
5354 typedef struct _QUOTA_LIMITS_EX {
5355 SIZE_T PagedPoolLimit;
5356 SIZE_T NonPagedPoolLimit;
5357 SIZE_T MinimumWorkingSetSize;
5358 SIZE_T MaximumWorkingSetSize;
5359 SIZE_T PagefileLimit;
5360 LARGE_INTEGER TimeLimit;
5361 SIZE_T WorkingSetLimit;
5362 SIZE_T Reserved2;
5363 SIZE_T Reserved3;
5364 SIZE_T Reserved4;
5365 DWORD Flags;
5366 RATE_QUOTA_LIMIT CpuRateLimit;
5367 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
5369 #define SECTION_QUERY 0x0001
5370 #define SECTION_MAP_WRITE 0x0002
5371 #define SECTION_MAP_READ 0x0004
5372 #define SECTION_MAP_EXECUTE 0x0008
5373 #define SECTION_EXTEND_SIZE 0x0010
5374 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
5375 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
5377 #define FILE_READ_DATA 0x0001 /* file & pipe */
5378 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
5379 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
5380 #define FILE_ADD_FILE 0x0002 /* directory */
5381 #define FILE_APPEND_DATA 0x0004 /* file */
5382 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
5383 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
5384 #define FILE_READ_EA 0x0008 /* file & directory */
5385 #define FILE_READ_PROPERTIES FILE_READ_EA
5386 #define FILE_WRITE_EA 0x0010 /* file & directory */
5387 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
5388 #define FILE_EXECUTE 0x0020 /* file */
5389 #define FILE_TRAVERSE 0x0020 /* directory */
5390 #define FILE_DELETE_CHILD 0x0040 /* directory */
5391 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
5392 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
5393 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
5395 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
5396 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
5397 SYNCHRONIZE)
5398 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
5399 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
5400 FILE_APPEND_DATA | SYNCHRONIZE)
5401 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
5402 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
5404 #define DUPLICATE_CLOSE_SOURCE 0x00000001
5405 #define DUPLICATE_SAME_ACCESS 0x00000002
5407 /* File attribute flags */
5408 #define FILE_SHARE_READ 0x00000001
5409 #define FILE_SHARE_WRITE 0x00000002
5410 #define FILE_SHARE_DELETE 0x00000004
5412 #define FILE_ATTRIBUTE_READONLY 0x00000001
5413 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
5414 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
5415 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
5416 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
5417 #define FILE_ATTRIBUTE_DEVICE 0x00000040
5418 #define FILE_ATTRIBUTE_NORMAL 0x00000080
5419 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
5420 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
5421 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
5422 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
5423 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
5424 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
5425 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
5426 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
5427 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
5428 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
5429 #define FILE_ATTRIBUTE_EA 0x00040000
5431 /* File notification flags */
5432 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
5433 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
5434 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
5435 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
5436 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
5437 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
5438 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
5439 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
5440 #define FILE_NOTIFY_CHANGE_EA 0x00000080
5441 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
5442 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
5443 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
5444 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
5446 #define FILE_ACTION_ADDED 0x00000001
5447 #define FILE_ACTION_REMOVED 0x00000002
5448 #define FILE_ACTION_MODIFIED 0x00000003
5449 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
5450 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
5451 #define FILE_ACTION_ADDED_STREAM 0x00000006
5452 #define FILE_ACTION_REMOVED_STREAM 0x00000007
5453 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
5454 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
5455 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
5456 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
5458 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
5459 #define FILE_CASE_PRESERVED_NAMES 0x00000002
5460 #define FILE_UNICODE_ON_DISK 0x00000004
5461 #define FILE_PERSISTENT_ACLS 0x00000008
5462 #define FILE_FILE_COMPRESSION 0x00000010
5463 #define FILE_VOLUME_QUOTAS 0x00000020
5464 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
5465 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
5466 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
5467 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
5468 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
5469 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
5470 #define FILE_NAMED_STREAMS 0x00040000
5471 #define FILE_READ_ONLY_VOLUME 0x00080000
5472 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
5473 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
5474 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
5475 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
5476 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
5477 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
5478 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
5479 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
5480 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
5481 #define FILE_DAX_VOLUME 0x20000000
5482 #define FILE_SUPPORTS_GHOSTING 0x40000000
5484 /* File alignments (NT) */
5485 #define FILE_BYTE_ALIGNMENT 0x00000000
5486 #define FILE_WORD_ALIGNMENT 0x00000001
5487 #define FILE_LONG_ALIGNMENT 0x00000003
5488 #define FILE_QUAD_ALIGNMENT 0x00000007
5489 #define FILE_OCTA_ALIGNMENT 0x0000000f
5490 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
5491 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
5492 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
5493 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
5494 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
5496 #define COMPRESSION_FORMAT_NONE 0
5497 #define COMPRESSION_FORMAT_DEFAULT 1
5498 #define COMPRESSION_FORMAT_LZNT1 2
5499 #define COMPRESSION_ENGINE_STANDARD 0
5500 #define COMPRESSION_ENGINE_MAXIMUM 256
5502 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
5503 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
5505 #define REG_NONE 0 /* no type */
5506 #define REG_SZ 1 /* string type (ASCII) */
5507 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
5508 #define REG_BINARY 3 /* binary format, callerspecific */
5509 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
5510 #define REG_DWORD 4 /* DWORD in little endian format */
5511 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
5512 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
5513 #define REG_LINK 6 /* symbolic link (UNICODE) */
5514 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
5515 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
5516 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
5517 #define REG_RESOURCE_REQUIREMENTS_LIST 10
5518 #define REG_QWORD 11 /* QWORD in little endian format */
5519 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
5521 /* ----------------------------- begin power management --------------------- */
5523 typedef enum _LATENCY_TIME {
5524 LT_DONT_CARE,
5525 LT_LOWEST_LATENCY
5526 } LATENCY_TIME, *PLATENCY_TIME;
5528 #define DISCHARGE_POLICY_CRITICAL 0
5529 #define DISCHARGE_POLICY_LOW 1
5530 #define NUM_DISCHARGE_POLICIES 4
5532 #define PO_THROTTLE_NONE 0
5533 #define PO_THROTTLE_CONSTANT 1
5534 #define PO_THROTTLE_DEGRADE 2
5535 #define PO_THROTTLE_ADAPTIVE 3
5537 typedef enum _POWER_ACTION {
5538 PowerActionNone = 0,
5539 PowerActionReserved,
5540 PowerActionSleep,
5541 PowerActionHibernate,
5542 PowerActionShutdown,
5543 PowerActionShutdownReset,
5544 PowerActionShutdownOff,
5545 PowerActionWarmEject
5546 } POWER_ACTION,
5547 *PPOWER_ACTION;
5549 typedef enum _POWER_PLATFORM_ROLE {
5550 PlatformRoleUnspecified,
5551 PlatformRoleDesktop,
5552 PlatformRoleMobile,
5553 PlatformRoleWorkstation,
5554 PlatformRoleEnterpriseServer,
5555 PlatformRoleSOHOServer,
5556 PlatformRoleAppliancePC,
5557 PlatformRolePerformanceServer,
5558 PlatformRoleSlate,
5559 PlatformRoleMaximum
5560 } POWER_PLATFORM_ROLE, *PPOWER_PLATFORM_ROLE;
5562 typedef enum _SYSTEM_POWER_STATE {
5563 PowerSystemUnspecified = 0,
5564 PowerSystemWorking = 1,
5565 PowerSystemSleeping1 = 2,
5566 PowerSystemSleeping2 = 3,
5567 PowerSystemSleeping3 = 4,
5568 PowerSystemHibernate = 5,
5569 PowerSystemShutdown = 6,
5570 PowerSystemMaximum = 7
5571 } SYSTEM_POWER_STATE,
5572 *PSYSTEM_POWER_STATE;
5574 typedef enum _DEVICE_POWER_STATE {
5575 PowerDeviceUnspecified,
5576 PowerDeviceD0,
5577 PowerDeviceD1,
5578 PowerDeviceD2,
5579 PowerDeviceD3,
5580 PowerDeviceMaximum
5581 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
5583 typedef enum _POWER_INFORMATION_LEVEL {
5584 SystemPowerPolicyAc,
5585 SystemPowerPolicyDc,
5586 VerifySystemPolicyAc,
5587 VerifySystemPolicyDc,
5588 SystemPowerCapabilities,
5589 SystemBatteryState,
5590 SystemPowerStateHandler,
5591 ProcessorStateHandler,
5592 SystemPowerPolicyCurrent,
5593 AdministratorPowerPolicy,
5594 SystemReserveHiberFile,
5595 ProcessorInformation,
5596 SystemPowerInformation,
5597 ProcessorStateHandler2,
5598 LastWakeTime,
5599 LastSleepTime,
5600 SystemExecutionState,
5601 SystemPowerStateNotifyHandler,
5602 ProcessorPowerPolicyAc,
5603 ProcessorPowerPolicyDc,
5604 VerifyProcessorPowerPolicyAc,
5605 VerifyProcessorPowerPolicyDc,
5606 ProcessorPowerPolicyCurrent
5607 } POWER_INFORMATION_LEVEL;
5609 typedef struct _ADMINISTRATOR_POWER_POLICY {
5610 SYSTEM_POWER_STATE MinSleep;
5611 SYSTEM_POWER_STATE MaxSleep;
5612 ULONG MinVideoTimeout;
5613 ULONG MaxVideoTimeout;
5614 ULONG MinSpindownTimeout;
5615 ULONG MaxSpindownTimeout;
5616 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
5618 typedef struct {
5619 ULONG Granularity;
5620 ULONG Capacity;
5621 } BATTERY_REPORTING_SCALE,
5622 *PBATTERY_REPORTING_SCALE;
5624 typedef struct {
5625 POWER_ACTION Action;
5626 ULONG Flags;
5627 ULONG EventCode;
5628 } POWER_ACTION_POLICY,
5629 *PPOWER_ACTION_POLICY;
5631 typedef struct _PROCESSOR_POWER_INFORMATION {
5632 ULONG Number;
5633 ULONG MaxMhz;
5634 ULONG CurrentMhz;
5635 ULONG MhzLimit;
5636 ULONG MaxIdleState;
5637 ULONG CurrentIdleState;
5638 } PROCESSOR_POWER_INFORMATION,
5639 *PPROCESSOR_POWER_INFORMATION;
5641 typedef struct _PROCESSOR_POWER_POLICY_INFO {
5642 ULONG TimeCheck;
5643 ULONG DemoteLimit;
5644 ULONG PromoteLimit;
5645 UCHAR DemotePercent;
5646 UCHAR PromotePercent;
5647 UCHAR Spare[2];
5648 ULONG AllowDemotion:1;
5649 ULONG AllowPromotion:1;
5650 ULONG Reserved:30;
5651 } PROCESSOR_POWER_POLICY_INFO,
5652 *PPROCESSOR_POWER_POLICY_INFO;
5654 typedef struct _PROCESSOR_POWER_POLICY {
5655 DWORD Revision;
5656 BYTE DynamicThrottle;
5657 BYTE Spare[3];
5658 DWORD DisableCStates:1;
5659 DWORD Reserved:31;
5660 DWORD PolicyCount;
5661 PROCESSOR_POWER_POLICY_INFO Policy[3];
5662 } PROCESSOR_POWER_POLICY,
5663 *PPROCESSOR_POWER_POLICY;
5665 typedef struct {
5666 BOOLEAN AcOnLine;
5667 BOOLEAN BatteryPresent;
5668 BOOLEAN Charging;
5669 BOOLEAN Discharging;
5670 BOOLEAN Spare1[3];
5671 BYTE Tag;
5672 ULONG MaxCapacity;
5673 ULONG RemainingCapacity;
5674 ULONG Rate;
5675 ULONG EstimatedTime;
5676 ULONG DefaultAlert1;
5677 ULONG DefaultAlert2;
5678 } SYSTEM_BATTERY_STATE,
5679 *PSYSTEM_BATTERY_STATE;
5681 typedef struct {
5682 BOOLEAN PowerButtonPresent;
5683 BOOLEAN SleepButtonPresent;
5684 BOOLEAN LidPresent;
5685 BOOLEAN SystemS1;
5686 BOOLEAN SystemS2;
5687 BOOLEAN SystemS3;
5688 BOOLEAN SystemS4;
5689 BOOLEAN SystemS5;
5690 BOOLEAN HiberFilePresent;
5691 BOOLEAN FullWake;
5692 BOOLEAN VideoDimPresent;
5693 BOOLEAN ApmPresent;
5694 BOOLEAN UpsPresent;
5695 BOOLEAN ThermalControl;
5696 BOOLEAN ProcessorThrottle;
5697 UCHAR ProcessorMinThrottle;
5698 UCHAR ProcessorMaxThrottle;
5699 UCHAR spare2[4];
5700 BOOLEAN DiskSpinDown;
5701 UCHAR spare3[8];
5702 BOOLEAN SystemBatteriesPresent;
5703 BOOLEAN BatteriesAreShortTerm;
5704 BATTERY_REPORTING_SCALE BatteryScale[3];
5705 SYSTEM_POWER_STATE AcOnLineWake;
5706 SYSTEM_POWER_STATE SoftLidWake;
5707 SYSTEM_POWER_STATE RtcWake;
5708 SYSTEM_POWER_STATE MinDeviceWakeState;
5709 SYSTEM_POWER_STATE DefaultLowLatencyWake;
5710 } SYSTEM_POWER_CAPABILITIES,
5711 *PSYSTEM_POWER_CAPABILITIES;
5713 typedef struct _SYSTEM_POWER_INFORMATION {
5714 ULONG MaxIdlenessAllowed;
5715 ULONG Idleness;
5716 ULONG TimeRemaining;
5717 UCHAR CoolingMode;
5718 } SYSTEM_POWER_INFORMATION,
5719 *PSYSTEM_POWER_INFORMATION;
5721 typedef struct _SYSTEM_POWER_LEVEL {
5722 BOOLEAN Enable;
5723 UCHAR Spare[3];
5724 ULONG BatteryLevel;
5725 POWER_ACTION_POLICY PowerPolicy;
5726 SYSTEM_POWER_STATE MinSystemState;
5727 } SYSTEM_POWER_LEVEL,
5728 *PSYSTEM_POWER_LEVEL;
5730 typedef struct _SYSTEM_POWER_POLICY {
5731 ULONG Revision;
5732 POWER_ACTION_POLICY PowerButton;
5733 POWER_ACTION_POLICY SleepButton;
5734 POWER_ACTION_POLICY LidClose;
5735 SYSTEM_POWER_STATE LidOpenWake;
5736 ULONG Reserved;
5737 POWER_ACTION_POLICY Idle;
5738 ULONG IdleTimeout;
5739 UCHAR IdleSensitivity;
5740 UCHAR DynamicThrottle;
5741 UCHAR Spare2[2];
5742 SYSTEM_POWER_STATE MinSleep;
5743 SYSTEM_POWER_STATE MaxSleep;
5744 SYSTEM_POWER_STATE ReducedLatencySleep;
5745 ULONG WinLogonFlags;
5746 ULONG Spare3;
5747 ULONG DozeS4Timeout;
5748 ULONG BroadcastCapacityResolution;
5749 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
5750 ULONG VideoTimeout;
5751 BOOLEAN VideoDimDisplay;
5752 ULONG VideoReserved[3];
5753 ULONG SpindownTimeout;
5754 BOOLEAN OptimizeForPower;
5755 UCHAR FanThrottleTolerance;
5756 UCHAR ForcedThrottle;
5757 UCHAR MinThrottle;
5758 POWER_ACTION_POLICY OverThrottled;
5759 } SYSTEM_POWER_POLICY,
5760 *PSYSTEM_POWER_POLICY;
5762 typedef enum _POWER_REQUEST_TYPE
5764 PowerRequestDisplayRequired,
5765 PowerRequestSystemRequired,
5766 PowerRequestAwayModeRequired
5767 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE;
5769 #define POWER_REQUEST_CONTEXT_VERSION 0
5771 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001
5772 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002
5774 typedef union _FILE_SEGMENT_ELEMENT {
5775 PVOID64 Buffer;
5776 ULONGLONG Alignment;
5777 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5779 typedef struct _FILE_NOTIFY_INFORMATION {
5780 DWORD NextEntryOffset;
5781 DWORD Action;
5782 DWORD FileNameLength;
5783 WCHAR FileName[1];
5784 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5786 /* ----------------------------- begin tape storage --------------------- */
5788 #define TAPE_FIXED_PARTITIONS 0
5789 #define TAPE_SELECT_PARTITIONS 1
5790 #define TAPE_INITIATOR_PARTITIONS 2
5791 #define TAPE_ERASE_SHORT 0
5792 #define TAPE_ERASE_LONG 1
5793 #define TAPE_LOAD 0
5794 #define TAPE_UNLOAD 1
5795 #define TAPE_TENSION 2
5796 #define TAPE_LOCK 3
5797 #define TAPE_UNLOCK 4
5798 #define TAPE_FORMAT 5
5799 #define TAPE_SETMARKS 0
5800 #define TAPE_FILEMARKS 1
5801 #define TAPE_SHORT_FILEMARKS 2
5802 #define TAPE_LONG_FILEMARKS 3
5803 #define TAPE_REWIND 0
5804 #define TAPE_ABSOLUTE_BLOCK 1
5805 #define TAPE_LOGICAL_BLOCK 2
5806 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5807 #define TAPE_SPACE_END_OF_DATA 4
5808 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5809 #define TAPE_SPACE_FILEMARKS 6
5810 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5811 #define TAPE_SPACE_SETMARKS 8
5812 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5814 typedef struct _TAPE_CREATE_PARTITION {
5815 DWORD Method;
5816 DWORD Count;
5817 DWORD Size;
5818 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5820 typedef struct _TAPE_ERASE {
5821 DWORD Type;
5822 BOOLEAN Immediate;
5823 } TAPE_ERASE, *PTAPE_ERASE;
5825 typedef struct _TAPE_PREPARE {
5826 DWORD Operation;
5827 BOOLEAN Immediate;
5828 } TAPE_PREPARE, *PTAPE_PREPARE;
5830 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5831 BOOLEAN ECC;
5832 BOOLEAN Compression;
5833 BOOLEAN DataPadding;
5834 BOOLEAN ReportSetmarks;
5835 ULONG EOTWarningZoneSize;
5836 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5838 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5839 ULONG BlockSize;
5840 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5842 typedef struct _TAPE_WRITE_MARKS {
5843 DWORD Type;
5844 DWORD Count;
5845 BOOLEAN Immediate;
5846 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5848 typedef struct _TAPE_GET_POSITION {
5849 ULONG Type;
5850 ULONG Partition;
5851 ULONG OffsetLow;
5852 ULONG OffsetHigh;
5853 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5855 typedef struct _TAPE_SET_POSITION {
5856 ULONG Method;
5857 ULONG Partition;
5858 LARGE_INTEGER Offset;
5859 BOOLEAN Immediate;
5860 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5862 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5863 BOOLEAN ECC;
5864 BOOLEAN Compression;
5865 BOOLEAN DataPadding;
5866 BOOLEAN ReportSetmarks;
5867 DWORD DefaultBlockSize;
5868 DWORD MaximumBlockSize;
5869 DWORD MinimumBlockSize;
5870 DWORD MaximumPartitionCount;
5871 DWORD FeaturesLow;
5872 DWORD FeaturesHigh;
5873 DWORD EOTWarningZoneSize;
5874 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
5876 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
5877 LARGE_INTEGER Capacity;
5878 LARGE_INTEGER Remaining;
5879 DWORD BlockSize;
5880 DWORD PartitionCount;
5881 BOOLEAN WriteProtected;
5882 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
5884 /* ----------------------------- begin registry ----------------------------- */
5886 /* Registry security values */
5887 #define OWNER_SECURITY_INFORMATION 0x00000001
5888 #define GROUP_SECURITY_INFORMATION 0x00000002
5889 #define DACL_SECURITY_INFORMATION 0x00000004
5890 #define SACL_SECURITY_INFORMATION 0x00000008
5891 #define LABEL_SECURITY_INFORMATION 0x00000010
5893 #define REG_OPTION_RESERVED 0x00000000
5894 #define REG_OPTION_NON_VOLATILE 0x00000000
5895 #define REG_OPTION_VOLATILE 0x00000001
5896 #define REG_OPTION_CREATE_LINK 0x00000002
5897 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5898 #define REG_OPTION_OPEN_LINK 0x00000008
5899 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED | \
5900 REG_OPTION_NON_VOLATILE | \
5901 REG_OPTION_VOLATILE | \
5902 REG_OPTION_CREATE_LINK | \
5903 REG_OPTION_BACKUP_RESTORE | \
5904 REG_OPTION_OPEN_LINK)
5907 #define REG_CREATED_NEW_KEY 0x00000001
5908 #define REG_OPENED_EXISTING_KEY 0x00000002
5910 /* For RegNotifyChangeKeyValue */
5911 #define REG_NOTIFY_CHANGE_NAME 0x01
5912 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5913 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5914 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5915 #define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000
5917 #define KEY_QUERY_VALUE 0x00000001
5918 #define KEY_SET_VALUE 0x00000002
5919 #define KEY_CREATE_SUB_KEY 0x00000004
5920 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5921 #define KEY_NOTIFY 0x00000010
5922 #define KEY_CREATE_LINK 0x00000020
5923 #define KEY_WOW64_64KEY 0x00000100
5924 #define KEY_WOW64_32KEY 0x00000200
5925 #define KEY_WOW64_RES 0x00000300
5927 /* for RegKeyRestore flags */
5928 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5929 #define REG_REFRESH_HIVE 0x00000002
5930 #define REG_NO_LAZY_FLUSH 0x00000004
5931 #define REG_FORCE_RESTORE 0x00000008
5933 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5934 KEY_QUERY_VALUE| \
5935 KEY_ENUMERATE_SUB_KEYS| \
5936 KEY_NOTIFY) \
5937 & (~SYNCHRONIZE) \
5939 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5940 KEY_SET_VALUE| \
5941 KEY_CREATE_SUB_KEY) \
5942 & (~SYNCHRONIZE) \
5944 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5945 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5946 KEY_QUERY_VALUE| \
5947 KEY_SET_VALUE| \
5948 KEY_CREATE_SUB_KEY| \
5949 KEY_ENUMERATE_SUB_KEYS| \
5950 KEY_NOTIFY| \
5951 KEY_CREATE_LINK) \
5952 & (~SYNCHRONIZE) \
5954 /* ------------------------------ end registry ------------------------------ */
5957 #define EVENTLOG_SUCCESS 0x0000
5958 #define EVENTLOG_ERROR_TYPE 0x0001
5959 #define EVENTLOG_WARNING_TYPE 0x0002
5960 #define EVENTLOG_INFORMATION_TYPE 0x0004
5961 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5962 #define EVENTLOG_AUDIT_FAILURE 0x0010
5964 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5965 #define EVENTLOG_SEEK_READ 0x0002
5966 #define EVENTLOG_FORWARDS_READ 0x0004
5967 #define EVENTLOG_BACKWARDS_READ 0x0008
5969 typedef struct _EVENTLOGRECORD {
5970 DWORD Length;
5971 DWORD Reserved;
5972 DWORD RecordNumber;
5973 DWORD TimeGenerated;
5974 DWORD TimeWritten;
5975 DWORD EventID;
5976 WORD EventType;
5977 WORD NumStrings;
5978 WORD EventCategory;
5979 WORD ReservedFlags;
5980 DWORD ClosingRecordNumber;
5981 DWORD StringOffset;
5982 DWORD UserSidLength;
5983 DWORD UserSidOffset;
5984 DWORD DataLength;
5985 DWORD DataOffset;
5986 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5988 #define SERVICE_BOOT_START 0x00000000
5989 #define SERVICE_SYSTEM_START 0x00000001
5990 #define SERVICE_AUTO_START 0x00000002
5991 #define SERVICE_DEMAND_START 0x00000003
5992 #define SERVICE_DISABLED 0x00000004
5994 #define SERVICE_ERROR_IGNORE 0x00000000
5995 #define SERVICE_ERROR_NORMAL 0x00000001
5996 #define SERVICE_ERROR_SEVERE 0x00000002
5997 #define SERVICE_ERROR_CRITICAL 0x00000003
5999 /* Service types */
6000 #define SERVICE_KERNEL_DRIVER 0x00000001
6001 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
6002 #define SERVICE_ADAPTER 0x00000004
6003 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
6005 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
6006 SERVICE_RECOGNIZER_DRIVER )
6008 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
6009 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
6010 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
6012 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
6014 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
6015 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
6018 typedef enum _CM_SERVICE_NODE_TYPE
6020 DriverType = SERVICE_KERNEL_DRIVER,
6021 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
6022 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
6023 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
6024 AdapterType = SERVICE_ADAPTER,
6025 RecognizerType = SERVICE_RECOGNIZER_DRIVER
6026 } SERVICE_NODE_TYPE;
6028 typedef enum _CM_SERVICE_LOAD_TYPE
6030 BootLoad = SERVICE_BOOT_START,
6031 SystemLoad = SERVICE_SYSTEM_START,
6032 AutoLoad = SERVICE_AUTO_START,
6033 DemandLoad = SERVICE_DEMAND_START,
6034 DisableLoad = SERVICE_DISABLED
6035 } SERVICE_LOAD_TYPE;
6037 typedef enum _CM_ERROR_CONTROL_TYPE
6039 IgnoreError = SERVICE_ERROR_IGNORE,
6040 NormalError = SERVICE_ERROR_NORMAL,
6041 SevereError = SERVICE_ERROR_SEVERE,
6042 CriticalError = SERVICE_ERROR_CRITICAL
6043 } SERVICE_ERROR_TYPE;
6045 NTSYSAPI SIZE_T WINAPI RtlCompareMemory(const VOID*, const VOID*, SIZE_T);
6046 NTSYSAPI SIZE_T WINAPI RtlCompareMemoryUlong(VOID*, SIZE_T, ULONG);
6048 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
6049 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
6050 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
6051 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
6052 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
6054 static FORCEINLINE void *RtlSecureZeroMemory(void *buffer, SIZE_T length)
6056 volatile char *ptr = (volatile char *)buffer;
6058 while (length--) *ptr++ = 0;
6059 return buffer;
6062 #include <guiddef.h>
6064 typedef struct _OBJECT_TYPE_LIST {
6065 WORD Level;
6066 WORD Sbz;
6067 GUID *ObjectType;
6068 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
6070 typedef struct _RTL_CRITICAL_SECTION_DEBUG
6072 WORD Type;
6073 WORD CreatorBackTraceIndex;
6074 struct _RTL_CRITICAL_SECTION *CriticalSection;
6075 LIST_ENTRY ProcessLocksList;
6076 DWORD EntryCount;
6077 DWORD ContentionCount;
6078 #ifdef __WINESRC__ /* in Wine we store the name here */
6079 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
6080 #else
6081 DWORD Spare[ 2 ];
6082 #endif
6083 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
6085 typedef struct _RTL_CRITICAL_SECTION {
6086 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
6087 LONG LockCount;
6088 LONG RecursionCount;
6089 HANDLE OwningThread;
6090 HANDLE LockSemaphore;
6091 ULONG_PTR SpinCount;
6092 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
6094 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
6095 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
6096 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
6097 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
6098 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
6100 typedef struct _RTL_SRWLOCK {
6101 PVOID Ptr;
6102 } RTL_SRWLOCK, *PRTL_SRWLOCK;
6104 #define RTL_SRWLOCK_INIT {0}
6106 typedef struct _RTL_CONDITION_VARIABLE {
6107 PVOID Ptr;
6108 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
6109 #define RTL_CONDITION_VARIABLE_INIT {0}
6110 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
6112 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
6113 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
6115 #define RTL_RUN_ONCE_INIT {0}
6116 typedef union _RTL_RUN_ONCE {
6117 PVOID Ptr;
6118 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
6120 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
6121 #define RTL_RUN_ONCE_ASYNC 0x00000002
6122 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
6124 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
6125 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
6126 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
6127 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
6128 NTSYSAPI DWORD WINAPI RtlRunOnceBeginInitialize(PRTL_RUN_ONCE, DWORD, PVOID*);
6129 NTSYSAPI DWORD WINAPI RtlRunOnceComplete(PRTL_RUN_ONCE, DWORD, PVOID);
6131 #include <pshpack8.h>
6132 typedef struct _IO_COUNTERS {
6133 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
6134 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
6135 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
6136 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
6137 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
6138 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
6139 } IO_COUNTERS, *PIO_COUNTERS;
6140 #include <poppack.h>
6142 typedef struct {
6143 DWORD dwOSVersionInfoSize;
6144 DWORD dwMajorVersion;
6145 DWORD dwMinorVersion;
6146 DWORD dwBuildNumber;
6147 DWORD dwPlatformId;
6148 CHAR szCSDVersion[128];
6149 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
6151 typedef struct {
6152 DWORD dwOSVersionInfoSize;
6153 DWORD dwMajorVersion;
6154 DWORD dwMinorVersion;
6155 DWORD dwBuildNumber;
6156 DWORD dwPlatformId;
6157 WCHAR szCSDVersion[128];
6158 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
6160 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
6161 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
6162 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
6164 typedef struct {
6165 DWORD dwOSVersionInfoSize;
6166 DWORD dwMajorVersion;
6167 DWORD dwMinorVersion;
6168 DWORD dwBuildNumber;
6169 DWORD dwPlatformId;
6170 CHAR szCSDVersion[128];
6171 WORD wServicePackMajor;
6172 WORD wServicePackMinor;
6173 WORD wSuiteMask;
6174 BYTE wProductType;
6175 BYTE wReserved;
6176 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
6178 typedef struct {
6179 DWORD dwOSVersionInfoSize;
6180 DWORD dwMajorVersion;
6181 DWORD dwMinorVersion;
6182 DWORD dwBuildNumber;
6183 DWORD dwPlatformId;
6184 WCHAR szCSDVersion[128];
6185 WORD wServicePackMajor;
6186 WORD wServicePackMinor;
6187 WORD wSuiteMask;
6188 BYTE wProductType;
6189 BYTE wReserved;
6190 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
6192 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
6193 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
6194 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
6196 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
6198 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
6200 #define VER_PLATFORM_WIN32s 0
6201 #define VER_PLATFORM_WIN32_WINDOWS 1
6202 #define VER_PLATFORM_WIN32_NT 2
6204 #define VER_MINORVERSION 0x00000001
6205 #define VER_MAJORVERSION 0x00000002
6206 #define VER_BUILDNUMBER 0x00000004
6207 #define VER_PLATFORMID 0x00000008
6208 #define VER_SERVICEPACKMINOR 0x00000010
6209 #define VER_SERVICEPACKMAJOR 0x00000020
6210 #define VER_SUITENAME 0x00000040
6211 #define VER_PRODUCT_TYPE 0x00000080
6213 #define VER_NT_WORKSTATION 1
6214 #define VER_NT_DOMAIN_CONTROLLER 2
6215 #define VER_NT_SERVER 3
6217 #define VER_SUITE_SMALLBUSINESS 0x00000001
6218 #define VER_SUITE_ENTERPRISE 0x00000002
6219 #define VER_SUITE_BACKOFFICE 0x00000004
6220 #define VER_SUITE_COMMUNICATIONS 0x00000008
6221 #define VER_SUITE_TERMINAL 0x00000010
6222 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
6223 #define VER_SUITE_EMBEDDEDNT 0x00000040
6224 #define VER_SUITE_DATACENTER 0x00000080
6225 #define VER_SUITE_SINGLEUSERTS 0x00000100
6226 #define VER_SUITE_PERSONAL 0x00000200
6227 #define VER_SUITE_BLADE 0x00000400
6228 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
6229 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
6230 #define VER_SUITE_STORAGE_SERVER 0x00002000
6231 #define VER_SUITE_COMPUTE_SERVER 0x00004000
6232 #define VER_SUITE_WH_SERVER 0x00008000
6234 #define VER_EQUAL 1
6235 #define VER_GREATER 2
6236 #define VER_GREATER_EQUAL 3
6237 #define VER_LESS 4
6238 #define VER_LESS_EQUAL 5
6239 #define VER_AND 6
6240 #define VER_OR 7
6242 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
6243 DWORD dwFlags;
6244 DWORD ulFormatVersion;
6245 DWORD ulAssemblyCount;
6246 DWORD ulRootManifestPathType;
6247 DWORD ulRootManifestPathChars;
6248 DWORD ulRootConfigurationPathType;
6249 DWORD ulRootConfigurationPathChars;
6250 DWORD ulAppDirPathType;
6251 DWORD ulAppDirPathChars;
6252 PCWSTR lpRootManifestPath;
6253 PCWSTR lpRootConfigurationPath;
6254 PCWSTR lpAppDirPath;
6255 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
6257 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
6258 DWORD ulFlags;
6259 DWORD ulEncodedAssemblyIdentityLength;
6260 DWORD ulManifestPathType;
6261 DWORD ulManifestPathLength;
6262 LARGE_INTEGER liManifestLastWriteTime;
6263 DWORD ulPolicyPathType;
6264 DWORD ulPolicyPathLength;
6265 LARGE_INTEGER liPolicyLastWriteTime;
6266 DWORD ulMetadataSatelliteRosterIndex;
6267 DWORD ulManifestVersionMajor;
6268 DWORD ulManifestVersionMinor;
6269 DWORD ulPolicyVersionMajor;
6270 DWORD ulPolicyVersionMinor;
6271 DWORD ulAssemblyDirectoryNameLength;
6272 PCWSTR lpAssemblyEncodedAssemblyIdentity;
6273 PCWSTR lpAssemblyManifestPath;
6274 PCWSTR lpAssemblyPolicyPath;
6275 PCWSTR lpAssemblyDirectoryName;
6276 DWORD ulFileCount;
6277 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
6279 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
6280 DWORD ulAssemblyIndex;
6281 DWORD ulFileIndexInAssembly;
6282 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
6284 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
6286 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
6287 DWORD ulFlags;
6288 DWORD ulFilenameLength;
6289 DWORD ulPathLength;
6290 PCWSTR lpFileName;
6291 PCWSTR lpFilePath;
6292 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
6294 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
6296 typedef enum {
6297 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
6298 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
6299 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MITIGATION,
6300 ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED
6301 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
6303 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
6304 GUID Id;
6305 ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
6306 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
6308 #if !defined(__WINESRC__) && (defined(_MSC_EXTENSIONS) || ((defined(__GNUC__) && __GNUC__ >= 3)))
6309 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
6310 DWORD ElementCount;
6311 COMPATIBILITY_CONTEXT_ELEMENT Elements[];
6312 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
6313 #endif
6315 typedef enum {
6316 ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
6317 ACTCTX_RUN_LEVEL_AS_INVOKER,
6318 ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
6319 ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
6320 ACTCTX_RUN_LEVEL_NUMBERS
6321 } ACTCTX_REQUESTED_RUN_LEVEL;
6323 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
6324 DWORD ulFlags;
6325 ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
6326 DWORD UiAccess;
6327 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6329 typedef const struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION *PCACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
6331 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
6332 ActivationContextBasicInformation = 1,
6333 ActivationContextDetailedInformation = 2,
6334 AssemblyDetailedInformationInActivationContext = 3,
6335 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
6336 RunlevelInformationInActivationContext = 5,
6337 CompatibilityInformationInActivationContext = 6,
6338 ActivationContextManifestResourceName = 7,
6339 MaxActivationContextInfoClass,
6340 AssemblyDetailedInformationInActivationContxt = AssemblyDetailedInformationInActivationContext,
6341 FileInformationInAssemblyOfAssemblyInActivationContxt = FileInformationInAssemblyOfAssemblyInActivationContext
6342 } ACTIVATION_CONTEXT_INFO_CLASS;
6344 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
6345 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
6346 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
6347 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
6349 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
6350 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
6351 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
6352 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
6353 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
6354 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
6355 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
6356 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
6357 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
6358 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
6359 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
6361 typedef enum _JOBOBJECTINFOCLASS
6363 JobObjectBasicAccountingInformation = 1,
6364 JobObjectBasicLimitInformation,
6365 JobObjectBasicProcessIdList,
6366 JobObjectBasicUIRestrictions,
6367 JobObjectSecurityLimitInformation,
6368 JobObjectEndOfJobTimeInformation,
6369 JobObjectAssociateCompletionPortInformation,
6370 JobObjectBasicAndIoAccountingInformation,
6371 JobObjectExtendedLimitInformation,
6372 JobObjectJobSetInformation,
6373 MaxJobObjectInfoClass
6374 } JOBOBJECTINFOCLASS;
6376 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
6377 LARGE_INTEGER TotalUserTime;
6378 LARGE_INTEGER TotalKernelTime;
6379 LARGE_INTEGER ThisPeriodTotalUserTime;
6380 LARGE_INTEGER ThisPeriodTotalKernelTime;
6381 DWORD TotalPageFaultCount;
6382 DWORD TotalProcesses;
6383 DWORD ActiveProcesses;
6384 DWORD TotalTerminatedProcesses;
6385 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
6387 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
6388 LARGE_INTEGER PerProcessUserTimeLimit;
6389 LARGE_INTEGER PerJobUserTimeLimit;
6390 DWORD LimitFlags;
6391 SIZE_T MinimumWorkingSetSize;
6392 SIZE_T MaximumWorkingSetSize;
6393 DWORD ActiveProcessLimit;
6394 ULONG_PTR Affinity;
6395 DWORD PriorityClass;
6396 DWORD SchedulingClass;
6397 } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
6399 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
6400 DWORD NumberOfAssignedProcesses;
6401 DWORD NumberOfProcessIdsInList;
6402 ULONG_PTR ProcessIdList[1];
6403 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
6405 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
6406 DWORD UIRestrictionsClass;
6407 } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
6409 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
6410 DWORD SecurityLimitFlags;
6411 HANDLE JobToken;
6412 PTOKEN_GROUPS SidsToDisable;
6413 PTOKEN_PRIVILEGES PrivilegesToDelete;
6414 PTOKEN_GROUPS RestrictedSids;
6415 } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
6417 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
6418 DWORD EndOfJobTimeAction;
6419 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
6421 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
6422 PVOID CompletionKey;
6423 HANDLE CompletionPort;
6424 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
6426 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
6427 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
6428 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
6429 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
6430 #define JOB_OBJECT_MSG_NEW_PROCESS 6
6431 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
6432 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
6433 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
6434 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
6436 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
6437 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
6438 IO_COUNTERS IoInfo;
6439 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
6441 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
6442 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
6443 IO_COUNTERS IoInfo;
6444 SIZE_T ProcessMemoryLimit;
6445 SIZE_T JobMemoryLimit;
6446 SIZE_T PeakProcessMemoryUsed;
6447 SIZE_T PeakJobMemoryUsed;
6448 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
6450 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
6451 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
6452 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
6453 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
6454 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
6455 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
6456 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
6457 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
6458 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
6459 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
6460 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
6461 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
6462 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
6463 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
6464 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
6466 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
6467 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
6468 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
6470 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
6472 RelationProcessorCore = 0,
6473 RelationNumaNode = 1,
6474 RelationCache = 2,
6475 RelationProcessorPackage = 3,
6476 RelationGroup = 4,
6477 RelationAll = 0xffff
6478 } LOGICAL_PROCESSOR_RELATIONSHIP;
6480 #define LTP_PC_SMT 0x1
6482 typedef enum _PROCESSOR_CACHE_TYPE
6484 CacheUnified,
6485 CacheInstruction,
6486 CacheData,
6487 CacheTrace
6488 } PROCESSOR_CACHE_TYPE;
6490 typedef struct _PROCESSOR_GROUP_INFO
6492 BYTE MaximumProcessorCount;
6493 BYTE ActiveProcessorCount;
6494 BYTE Reserved[38];
6495 KAFFINITY ActiveProcessorMask;
6496 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
6498 typedef struct _CACHE_DESCRIPTOR
6500 BYTE Level;
6501 BYTE Associativity;
6502 WORD LineSize;
6503 DWORD Size;
6504 PROCESSOR_CACHE_TYPE Type;
6505 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
6507 typedef struct _GROUP_AFFINITY
6509 KAFFINITY Mask;
6510 WORD Group;
6511 WORD Reserved[3];
6512 } GROUP_AFFINITY, *PGROUP_AFFINITY;
6514 #define ALL_PROCESSOR_GROUPS 0xffff
6516 typedef struct _PROCESSOR_NUMBER
6518 WORD Group;
6519 BYTE Number;
6520 BYTE Reserved;
6521 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
6523 typedef struct _PROCESSOR_RELATIONSHIP
6525 BYTE Flags;
6526 BYTE EfficiencyClass;
6527 BYTE Reserved[20];
6528 WORD GroupCount;
6529 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
6530 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
6532 typedef struct _NUMA_NODE_RELATIONSHIP
6534 DWORD NodeNumber;
6535 BYTE Reserved[20];
6536 GROUP_AFFINITY GroupMask;
6537 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
6539 typedef struct _CACHE_RELATIONSHIP
6541 BYTE Level;
6542 BYTE Associativity;
6543 WORD LineSize;
6544 DWORD CacheSize;
6545 PROCESSOR_CACHE_TYPE Type;
6546 BYTE Reserved[20];
6547 GROUP_AFFINITY GroupMask;
6548 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
6550 typedef struct _GROUP_RELATIONSHIP
6552 WORD MaximumGroupCount;
6553 WORD ActiveGroupCount;
6554 BYTE Reserved[20];
6555 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
6556 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
6558 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
6560 ULONG_PTR ProcessorMask;
6561 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6562 union
6564 struct
6566 BYTE Flags;
6567 } ProcessorCore;
6568 struct
6570 DWORD NodeNumber;
6571 } NumaNode;
6572 CACHE_DESCRIPTOR Cache;
6573 ULONGLONG Reserved[2];
6574 } DUMMYUNIONNAME;
6575 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
6577 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
6579 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
6580 DWORD Size;
6581 union
6583 PROCESSOR_RELATIONSHIP Processor;
6584 NUMA_NODE_RELATIONSHIP NumaNode;
6585 CACHE_RELATIONSHIP Cache;
6586 GROUP_RELATIONSHIP Group;
6587 } DUMMYUNIONNAME;
6588 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
6590 /* Threadpool things */
6591 typedef DWORD TP_VERSION,*PTP_VERSION;
6593 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
6595 typedef VOID (CALLBACK *PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID);
6597 typedef struct _TP_POOL TP_POOL,*PTP_POOL;
6599 typedef enum _TP_CALLBACK_PRIORITY
6601 TP_CALLBACK_PRIORITY_HIGH,
6602 TP_CALLBACK_PRIORITY_NORMAL,
6603 TP_CALLBACK_PRIORITY_LOW,
6604 TP_CALLBACK_PRIORITY_INVALID,
6605 TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
6606 } TP_CALLBACK_PRIORITY;
6608 typedef struct _TP_POOL_STACK_INFORMATION
6610 SIZE_T StackReserve;
6611 SIZE_T StackCommit;
6612 } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION;
6614 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
6616 typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID,PVOID);
6618 typedef struct _TP_CALLBACK_ENVIRON_V1
6620 TP_VERSION Version;
6621 PTP_POOL Pool;
6622 PTP_CLEANUP_GROUP CleanupGroup;
6623 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6624 PVOID RaceDll;
6625 struct _ACTIVATION_CONTEXT* ActivationContext;
6626 PTP_SIMPLE_CALLBACK FinalizationCallback;
6627 union
6629 DWORD Flags;
6630 struct
6632 DWORD LongFunction:1;
6633 DWORD Persistent:1;
6634 DWORD Private:30;
6635 } s;
6636 } u;
6637 } TP_CALLBACK_ENVIRON_V1;
6639 typedef struct _TP_CALLBACK_ENVIRON_V3
6641 TP_VERSION Version;
6642 PTP_POOL Pool;
6643 PTP_CLEANUP_GROUP CleanupGroup;
6644 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
6645 PVOID RaceDll;
6646 struct _ACTIVATION_CONTEXT *ActivationContext;
6647 PTP_SIMPLE_CALLBACK FinalizationCallback;
6648 union
6650 DWORD Flags;
6651 struct
6653 DWORD LongFunction:1;
6654 DWORD Persistent:1;
6655 DWORD Private:30;
6656 } s;
6657 } u;
6658 TP_CALLBACK_PRIORITY CallbackPriority;
6659 DWORD Size;
6660 } TP_CALLBACK_ENVIRON_V3;
6662 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
6663 typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
6665 typedef DWORD TP_WAIT_RESULT;
6666 typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6668 typedef struct _TP_IO TP_IO, *PTP_IO;
6670 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
6672 typedef VOID (CALLBACK *PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WORK);
6673 typedef VOID (CALLBACK *PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_TIMER);
6674 typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,TP_WAIT_RESULT);
6677 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
6679 typedef enum _RTL_UMS_THREAD_INFO_CLASS
6681 UmsThreadInvalidInfoClass,
6682 UmsThreadUserContext,
6683 UmsThreadPriority,
6684 UmsThreadAffinity,
6685 UmsThreadTeb,
6686 UmsThreadIsSuspended,
6687 UmsThreadIsTerminated,
6688 UmsThreadMaxInfoClass
6689 } RTL_UMS_THREAD_INFO_CLASS, *PRTL_UMS_THREAD_INFO_CLASS;
6691 typedef enum _RTL_UMS_SCHEDULER_REASON
6693 UmsSchedulerStartup,
6694 UmsSchedulerThreadBlocked,
6695 UmsSchedulerThreadYield,
6696 } RTL_UMS_SCHEDULER_REASON, *PRTL_UMS_SCHEDULER_REASON;
6698 typedef void (CALLBACK *PRTL_UMS_SCHEDULER_ENTRY_POINT)(RTL_UMS_SCHEDULER_REASON,ULONG_PTR,PVOID);
6700 typedef enum _PROCESS_MITIGATION_POLICY
6702 ProcessDEPPolicy,
6703 ProcessASLRPolicy,
6704 ProcessDynamicCodePolicy,
6705 ProcessStrictHandleCheckPolicy,
6706 ProcessSystemCallDisablePolicy,
6707 ProcessMitigationOptionsMask,
6708 ProcessExtensionPointDisablePolicy,
6709 ProcessControlFlowGuardPolicy,
6710 ProcessSignaturePolicy,
6711 ProcessFontDisablePolicy,
6712 ProcessImageLoadPolicy,
6713 ProcessSystemCallFilterPolicy,
6714 ProcessPayloadRestrictionPolicy,
6715 ProcessChildProcessPolicy,
6716 ProcessSideChannelIsolationPolicy,
6717 MaxProcessMitigationPolicy
6718 } PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY;
6720 #ifdef _MSC_VER
6722 BOOLEAN _BitScanForward(unsigned long*,unsigned long);
6723 BOOLEAN _BitScanReverse(unsigned long*,unsigned long);
6725 #pragma intrinsic(_BitScanForward)
6726 #pragma intrinsic(_BitScanReverse)
6728 static inline BOOLEAN BitScanForward(DWORD *index, DWORD mask)
6730 return _BitScanForward((unsigned long*)index, mask);
6733 static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
6735 return _BitScanReverse((unsigned long*)index, mask);
6738 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
6740 static inline BOOLEAN BitScanForward(DWORD *index, DWORD mask)
6742 *index = __builtin_ctz(mask);
6743 return mask != 0;
6746 static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
6748 *index = 31 - __builtin_clz(mask);
6749 return mask != 0;
6752 #else
6754 static inline BOOLEAN BitScanForward(DWORD *index, DWORD mask)
6756 unsigned int r = 0;
6757 while (r < 31 && !(mask & (1 << r))) r++;
6758 *index = r;
6759 return mask != 0;
6762 static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
6764 unsigned int r = 31;
6765 while (r > 0 && !(mask & (1 << r))) r--;
6766 *index = r;
6767 return mask != 0;
6770 #endif
6772 #ifdef __cplusplus
6774 #endif
6776 #endif /* _WINNT_ */