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