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