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