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