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