user32: The app owns the text buffer memory after an EM_GETHANDLE.
[wine.git] / include / winnt.h
blob6911f1c40a0293a1c7cd1a73f13e94eb96acef99
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_UNKNOWN 0xFFFF
654 /* dwProcessorType */
655 #define PROCESSOR_INTEL_386 386
656 #define PROCESSOR_INTEL_486 486
657 #define PROCESSOR_INTEL_PENTIUM 586
658 #define PROCESSOR_INTEL_860 860
659 #define PROCESSOR_INTEL_IA64 2200
660 #define PROCESSOR_AMD_X8664 8664
661 #define PROCESSOR_MIPS_R2000 2000
662 #define PROCESSOR_MIPS_R3000 3000
663 #define PROCESSOR_MIPS_R4000 4000
664 #define PROCESSOR_ALPHA_21064 21064
665 #define PROCESSOR_PPC_601 601
666 #define PROCESSOR_PPC_603 603
667 #define PROCESSOR_PPC_604 604
668 #define PROCESSOR_PPC_620 620
669 #define PROCESSOR_HITACHI_SH3 10003
670 #define PROCESSOR_HITACHI_SH3E 10004
671 #define PROCESSOR_HITACHI_SH4 10005
672 #define PROCESSOR_MOTOROLA_821 821
673 #define PROCESSOR_SHx_SH3 103
674 #define PROCESSOR_SHx_SH4 104
675 #define PROCESSOR_STRONGARM 2577
676 #define PROCESSOR_ARM720 1824 /* 0x720 */
677 #define PROCESSOR_ARM820 2080 /* 0x820 */
678 #define PROCESSOR_ARM920 2336 /* 0x920 */
679 #define PROCESSOR_ARM_7TDMI 70001
680 #define PROCESSOR_OPTIL 18767
682 #ifdef _WIN64
683 #define MAXIMUM_PROCESSORS 64
684 #else
685 #define MAXIMUM_PROCESSORS 32
686 #endif
688 typedef struct _MEMORY_BASIC_INFORMATION
690 LPVOID BaseAddress;
691 LPVOID AllocationBase;
692 DWORD AllocationProtect;
693 SIZE_T RegionSize;
694 DWORD State;
695 DWORD Protect;
696 DWORD Type;
697 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
699 #define PAGE_NOACCESS 0x01
700 #define PAGE_READONLY 0x02
701 #define PAGE_READWRITE 0x04
702 #define PAGE_WRITECOPY 0x08
703 #define PAGE_EXECUTE 0x10
704 #define PAGE_EXECUTE_READ 0x20
705 #define PAGE_EXECUTE_READWRITE 0x40
706 #define PAGE_EXECUTE_WRITECOPY 0x80
707 #define PAGE_GUARD 0x100
708 #define PAGE_NOCACHE 0x200
709 #define PAGE_WRITECOMBINE 0x400
711 #define MEM_COMMIT 0x00001000
712 #define MEM_RESERVE 0x00002000
713 #define MEM_DECOMMIT 0x00004000
714 #define MEM_RELEASE 0x00008000
715 #define MEM_FREE 0x00010000
716 #define MEM_PRIVATE 0x00020000
717 #define MEM_MAPPED 0x00040000
718 #define MEM_RESET 0x00080000
719 #define MEM_TOP_DOWN 0x00100000
720 #define MEM_WRITE_WATCH 0x00200000
721 #define MEM_PHYSICAL 0x00400000
722 #define MEM_LARGE_PAGES 0x20000000
723 #define MEM_4MB_PAGES 0x80000000
725 #define SEC_FILE 0x00800000
726 #define SEC_IMAGE 0x01000000
727 #define SEC_RESERVE 0x04000000
728 #define SEC_COMMIT 0x08000000
729 #define SEC_NOCACHE 0x10000000
730 #define SEC_LARGE_PAGES 0x80000000
731 #define MEM_IMAGE SEC_IMAGE
733 #define WRITE_WATCH_FLAG_RESET 0x00000001
736 #define MINCHAR 0x80
737 #define MAXCHAR 0x7f
738 #define MINSHORT 0x8000
739 #define MAXSHORT 0x7fff
740 #define MINLONG 0x80000000
741 #define MAXLONG 0x7fffffff
742 #define MAXBYTE 0xff
743 #define MAXWORD 0xffff
744 #define MAXDWORD 0xffffffff
746 #define UNICODE_STRING_MAX_CHARS 32767
748 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
750 #define CONTAINING_RECORD(address, type, field) \
751 ((type *)((PCHAR)(address) - offsetof(type, field)))
753 /* Types */
755 typedef struct _LIST_ENTRY {
756 struct _LIST_ENTRY *Flink;
757 struct _LIST_ENTRY *Blink;
758 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
760 typedef struct _SINGLE_LIST_ENTRY {
761 struct _SINGLE_LIST_ENTRY *Next;
762 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
764 #ifdef _WIN64
766 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
767 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
768 PSLIST_ENTRY Next;
769 } SLIST_ENTRY;
771 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
772 struct {
773 ULONGLONG Alignment;
774 ULONGLONG Region;
775 } DUMMYSTRUCTNAME;
776 struct {
777 ULONGLONG Depth:16;
778 ULONGLONG Sequence:9;
779 ULONGLONG NextEntry:39;
780 ULONGLONG HeaderType:1;
781 ULONGLONG Init:1;
782 ULONGLONG Reserved:59;
783 ULONGLONG Region:3;
784 } Header8;
785 struct {
786 ULONGLONG Depth:16;
787 ULONGLONG Sequence:48;
788 ULONGLONG HeaderType:1;
789 ULONGLONG Init:1;
790 ULONGLONG Reserved:2;
791 ULONGLONG NextEntry:60;
792 } Header16;
793 } SLIST_HEADER, *PSLIST_HEADER;
795 #else
797 #undef SLIST_ENTRY /* for Mac OS */
798 #define SLIST_ENTRY SINGLE_LIST_ENTRY
799 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
800 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
802 typedef union _SLIST_HEADER {
803 ULONGLONG Alignment;
804 struct {
805 SLIST_ENTRY Next;
806 WORD Depth;
807 WORD Sequence;
808 } DUMMYSTRUCTNAME;
809 } SLIST_HEADER, *PSLIST_HEADER;
811 #endif
813 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
814 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
815 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
816 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
817 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
818 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
821 /* Heap flags */
823 #define HEAP_NO_SERIALIZE 0x00000001
824 #define HEAP_GROWABLE 0x00000002
825 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
826 #define HEAP_ZERO_MEMORY 0x00000008
827 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
828 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
829 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
830 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
831 #define HEAP_CREATE_ALIGN_16 0x00010000
832 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
833 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
835 /* This flag allows it to create heaps shared by all processes under win95,
836 FIXME: correct name */
837 #define HEAP_SHARED 0x04000000
839 typedef enum _HEAP_INFORMATION_CLASS {
840 HeapCompatibilityInformation,
841 } HEAP_INFORMATION_CLASS;
843 /* Processor feature flags. */
844 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
845 #define PF_FLOATING_POINT_EMULATED 1
846 #define PF_COMPARE_EXCHANGE_DOUBLE 2
847 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
848 #define PF_PPC_MOVEMEM_64BIT_OK 4
849 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
850 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
851 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
852 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
853 #define PF_PAE_ENABLED 9
854 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
855 #define PF_SSE_DAZ_MODE_AVAILABLE 11
856 #define PF_NX_ENABLED 12
857 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
858 #define PF_COMPARE_EXCHANGE128 14
859 #define PF_COMPARE64_EXCHANGE128 15
860 #define PF_CHANNELS_ENABLED 16
861 #define PF_XSAVE_ENABLED 17
862 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
863 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
864 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
865 #define PF_VIRT_FIRMWARE_ENABLED 21
866 #define PF_RDWRFSGSBASE_AVAILABLE 22
869 /* Execution state flags */
870 #define ES_SYSTEM_REQUIRED 0x00000001
871 #define ES_DISPLAY_REQUIRED 0x00000002
872 #define ES_USER_PRESENT 0x00000004
873 #define ES_CONTINUOUS 0x80000000
875 /* The Win32 register context */
877 /* i386 context definitions */
878 #ifdef __i386__
880 #define SIZE_OF_80387_REGISTERS 80
882 typedef struct _FLOATING_SAVE_AREA
884 DWORD ControlWord;
885 DWORD StatusWord;
886 DWORD TagWord;
887 DWORD ErrorOffset;
888 DWORD ErrorSelector;
889 DWORD DataOffset;
890 DWORD DataSelector;
891 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
892 DWORD Cr0NpxState;
893 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
895 #define MAXIMUM_SUPPORTED_EXTENSION 512
897 typedef struct _CONTEXT
899 DWORD ContextFlags;
901 /* These are selected by CONTEXT_DEBUG_REGISTERS */
902 DWORD Dr0;
903 DWORD Dr1;
904 DWORD Dr2;
905 DWORD Dr3;
906 DWORD Dr6;
907 DWORD Dr7;
909 /* These are selected by CONTEXT_FLOATING_POINT */
910 FLOATING_SAVE_AREA FloatSave;
912 /* These are selected by CONTEXT_SEGMENTS */
913 DWORD SegGs;
914 DWORD SegFs;
915 DWORD SegEs;
916 DWORD SegDs;
918 /* These are selected by CONTEXT_INTEGER */
919 DWORD Edi;
920 DWORD Esi;
921 DWORD Ebx;
922 DWORD Edx;
923 DWORD Ecx;
924 DWORD Eax;
926 /* These are selected by CONTEXT_CONTROL */
927 DWORD Ebp;
928 DWORD Eip;
929 DWORD SegCs;
930 DWORD EFlags;
931 DWORD Esp;
932 DWORD SegSs;
934 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
935 } CONTEXT;
937 #define CONTEXT_X86 0x00010000
938 #define CONTEXT_i386 CONTEXT_X86
939 #define CONTEXT_i486 CONTEXT_X86
941 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
942 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
943 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
944 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
945 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
946 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
947 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
948 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
949 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
951 #define EXCEPTION_READ_FAULT 0
952 #define EXCEPTION_WRITE_FAULT 1
953 #define EXCEPTION_EXECUTE_FAULT 8
955 #endif /* __i386__ */
957 typedef struct _LDT_ENTRY {
958 WORD LimitLow;
959 WORD BaseLow;
960 union {
961 struct {
962 BYTE BaseMid;
963 BYTE Flags1;
964 BYTE Flags2;
965 BYTE BaseHi;
966 } Bytes;
967 struct {
968 unsigned BaseMid: 8;
969 unsigned Type : 5;
970 unsigned Dpl : 2;
971 unsigned Pres : 1;
972 unsigned LimitHi : 4;
973 unsigned Sys : 1;
974 unsigned Reserved_0 : 1;
975 unsigned Default_Big : 1;
976 unsigned Granularity : 1;
977 unsigned BaseHi : 8;
978 } Bits;
979 } HighWord;
980 } LDT_ENTRY, *PLDT_ENTRY;
982 /* x86-64 context definitions */
983 #if defined(__x86_64__)
985 #define CONTEXT_AMD64 0x00100000
987 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
988 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
989 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
990 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
991 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
992 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
993 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
995 #define EXCEPTION_READ_FAULT 0
996 #define EXCEPTION_WRITE_FAULT 1
997 #define EXCEPTION_EXECUTE_FAULT 8
999 typedef struct DECLSPEC_ALIGN(16) _M128A {
1000 ULONGLONG Low;
1001 LONGLONG High;
1002 } M128A, *PM128A;
1004 typedef struct _XMM_SAVE_AREA32 {
1005 WORD ControlWord; /* 000 */
1006 WORD StatusWord; /* 002 */
1007 BYTE TagWord; /* 004 */
1008 BYTE Reserved1; /* 005 */
1009 WORD ErrorOpcode; /* 006 */
1010 DWORD ErrorOffset; /* 008 */
1011 WORD ErrorSelector; /* 00c */
1012 WORD Reserved2; /* 00e */
1013 DWORD DataOffset; /* 010 */
1014 WORD DataSelector; /* 014 */
1015 WORD Reserved3; /* 016 */
1016 DWORD MxCsr; /* 018 */
1017 DWORD MxCsr_Mask; /* 01c */
1018 M128A FloatRegisters[8]; /* 020 */
1019 M128A XmmRegisters[16]; /* 0a0 */
1020 BYTE Reserved4[96]; /* 1a0 */
1021 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1023 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1024 DWORD64 P1Home; /* 000 */
1025 DWORD64 P2Home; /* 008 */
1026 DWORD64 P3Home; /* 010 */
1027 DWORD64 P4Home; /* 018 */
1028 DWORD64 P5Home; /* 020 */
1029 DWORD64 P6Home; /* 028 */
1031 /* Control flags */
1032 DWORD ContextFlags; /* 030 */
1033 DWORD MxCsr; /* 034 */
1035 /* Segment */
1036 WORD SegCs; /* 038 */
1037 WORD SegDs; /* 03a */
1038 WORD SegEs; /* 03c */
1039 WORD SegFs; /* 03e */
1040 WORD SegGs; /* 040 */
1041 WORD SegSs; /* 042 */
1042 DWORD EFlags; /* 044 */
1044 /* Debug */
1045 DWORD64 Dr0; /* 048 */
1046 DWORD64 Dr1; /* 050 */
1047 DWORD64 Dr2; /* 058 */
1048 DWORD64 Dr3; /* 060 */
1049 DWORD64 Dr6; /* 068 */
1050 DWORD64 Dr7; /* 070 */
1052 /* Integer */
1053 DWORD64 Rax; /* 078 */
1054 DWORD64 Rcx; /* 080 */
1055 DWORD64 Rdx; /* 088 */
1056 DWORD64 Rbx; /* 090 */
1057 DWORD64 Rsp; /* 098 */
1058 DWORD64 Rbp; /* 0a0 */
1059 DWORD64 Rsi; /* 0a8 */
1060 DWORD64 Rdi; /* 0b0 */
1061 DWORD64 R8; /* 0b8 */
1062 DWORD64 R9; /* 0c0 */
1063 DWORD64 R10; /* 0c8 */
1064 DWORD64 R11; /* 0d0 */
1065 DWORD64 R12; /* 0d8 */
1066 DWORD64 R13; /* 0e0 */
1067 DWORD64 R14; /* 0e8 */
1068 DWORD64 R15; /* 0f0 */
1070 /* Counter */
1071 DWORD64 Rip; /* 0f8 */
1073 /* Floating point */
1074 union {
1075 XMM_SAVE_AREA32 FltSave; /* 100 */
1076 struct {
1077 M128A Header[2]; /* 100 */
1078 M128A Legacy[8]; /* 120 */
1079 M128A Xmm0; /* 1a0 */
1080 M128A Xmm1; /* 1b0 */
1081 M128A Xmm2; /* 1c0 */
1082 M128A Xmm3; /* 1d0 */
1083 M128A Xmm4; /* 1e0 */
1084 M128A Xmm5; /* 1f0 */
1085 M128A Xmm6; /* 200 */
1086 M128A Xmm7; /* 210 */
1087 M128A Xmm8; /* 220 */
1088 M128A Xmm9; /* 230 */
1089 M128A Xmm10; /* 240 */
1090 M128A Xmm11; /* 250 */
1091 M128A Xmm12; /* 260 */
1092 M128A Xmm13; /* 270 */
1093 M128A Xmm14; /* 280 */
1094 M128A Xmm15; /* 290 */
1095 } DUMMYSTRUCTNAME;
1096 } DUMMYUNIONNAME;
1098 /* Vector */
1099 M128A VectorRegister[26]; /* 300 */
1100 DWORD64 VectorControl; /* 4a0 */
1102 /* Debug control */
1103 DWORD64 DebugControl; /* 4a8 */
1104 DWORD64 LastBranchToRip; /* 4b0 */
1105 DWORD64 LastBranchFromRip; /* 4b8 */
1106 DWORD64 LastExceptionToRip; /* 4c0 */
1107 DWORD64 LastExceptionFromRip; /* 4c8 */
1108 } CONTEXT;
1110 typedef struct _RUNTIME_FUNCTION
1112 DWORD BeginAddress;
1113 DWORD EndAddress;
1114 DWORD UnwindData;
1115 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1117 #define UNWIND_HISTORY_TABLE_SIZE 12
1119 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1121 ULONG64 ImageBase;
1122 PRUNTIME_FUNCTION FunctionEntry;
1123 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1125 #define UNWIND_HISTORY_TABLE_NONE 0
1126 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1127 #define UNWIND_HISTORY_TABLE_LOCAL 2
1129 typedef struct _UNWIND_HISTORY_TABLE
1131 ULONG Count;
1132 UCHAR Search;
1133 ULONG64 LowAddress;
1134 ULONG64 HighAddress;
1135 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1136 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1138 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1140 union
1142 PM128A FloatingContext[16];
1143 struct
1145 PM128A Xmm0;
1146 PM128A Xmm1;
1147 PM128A Xmm2;
1148 PM128A Xmm3;
1149 PM128A Xmm4;
1150 PM128A Xmm5;
1151 PM128A Xmm6;
1152 PM128A Xmm7;
1153 PM128A Xmm8;
1154 PM128A Xmm9;
1155 PM128A Xmm10;
1156 PM128A Xmm11;
1157 PM128A Xmm12;
1158 PM128A Xmm13;
1159 PM128A Xmm14;
1160 PM128A Xmm15;
1161 } DUMMYSTRUCTNAME;
1162 } DUMMYUNIONNAME;
1164 union
1166 PULONG64 IntegerContext[16];
1167 struct
1169 PULONG64 Rax;
1170 PULONG64 Rcx;
1171 PULONG64 Rdx;
1172 PULONG64 Rbx;
1173 PULONG64 Rsp;
1174 PULONG64 Rbp;
1175 PULONG64 Rsi;
1176 PULONG64 Rdi;
1177 PULONG64 R8;
1178 PULONG64 R9;
1179 PULONG64 R10;
1180 PULONG64 R11;
1181 PULONG64 R12;
1182 PULONG64 R13;
1183 PULONG64 R14;
1184 PULONG64 R15;
1185 } DUMMYSTRUCTNAME;
1186 } DUMMYUNIONNAME2;
1187 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1189 BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD64);
1190 BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1191 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD64,DWORD64*,UNWIND_HISTORY_TABLE*);
1192 PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1194 #define UNW_FLAG_NHANDLER 0
1195 #define UNW_FLAG_EHANDLER 1
1196 #define UNW_FLAG_UHANDLER 2
1197 #define UNW_FLAG_CHAININFO 4
1199 #endif /* __x86_64__ */
1201 /* IA64 context definitions */
1202 #ifdef __ia64__
1204 #define CONTEXT_IA64 0x00080000
1205 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1206 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1207 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1208 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1209 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1210 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1211 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1212 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1213 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1215 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1216 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1217 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1218 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1220 typedef struct _CONTEXT
1222 DWORD ContextFlags;
1223 DWORD Fill1[3];
1224 ULONGLONG DbI0;
1225 ULONGLONG DbI1;
1226 ULONGLONG DbI2;
1227 ULONGLONG DbI3;
1228 ULONGLONG DbI4;
1229 ULONGLONG DbI5;
1230 ULONGLONG DbI6;
1231 ULONGLONG DbI7;
1232 ULONGLONG DbD0;
1233 ULONGLONG DbD1;
1234 ULONGLONG DbD2;
1235 ULONGLONG DbD3;
1236 ULONGLONG DbD4;
1237 ULONGLONG DbD5;
1238 ULONGLONG DbD6;
1239 ULONGLONG DbD7;
1240 FLOAT128 FltS0;
1241 FLOAT128 FltS1;
1242 FLOAT128 FltS2;
1243 FLOAT128 FltS3;
1244 FLOAT128 FltT0;
1245 FLOAT128 FltT1;
1246 FLOAT128 FltT2;
1247 FLOAT128 FltT3;
1248 FLOAT128 FltT4;
1249 FLOAT128 FltT5;
1250 FLOAT128 FltT6;
1251 FLOAT128 FltT7;
1252 FLOAT128 FltT8;
1253 FLOAT128 FltT9;
1254 FLOAT128 FltS4;
1255 FLOAT128 FltS5;
1256 FLOAT128 FltS6;
1257 FLOAT128 FltS7;
1258 FLOAT128 FltS8;
1259 FLOAT128 FltS9;
1260 FLOAT128 FltS10;
1261 FLOAT128 FltS11;
1262 FLOAT128 FltS12;
1263 FLOAT128 FltS13;
1264 FLOAT128 FltS14;
1265 FLOAT128 FltS15;
1266 FLOAT128 FltS16;
1267 FLOAT128 FltS17;
1268 FLOAT128 FltS18;
1269 FLOAT128 FltS19;
1270 FLOAT128 FltF32;
1271 FLOAT128 FltF33;
1272 FLOAT128 FltF34;
1273 FLOAT128 FltF35;
1274 FLOAT128 FltF36;
1275 FLOAT128 FltF37;
1276 FLOAT128 FltF38;
1277 FLOAT128 FltF39;
1278 FLOAT128 FltF40;
1279 FLOAT128 FltF41;
1280 FLOAT128 FltF42;
1281 FLOAT128 FltF43;
1282 FLOAT128 FltF44;
1283 FLOAT128 FltF45;
1284 FLOAT128 FltF46;
1285 FLOAT128 FltF47;
1286 FLOAT128 FltF48;
1287 FLOAT128 FltF49;
1288 FLOAT128 FltF50;
1289 FLOAT128 FltF51;
1290 FLOAT128 FltF52;
1291 FLOAT128 FltF53;
1292 FLOAT128 FltF54;
1293 FLOAT128 FltF55;
1294 FLOAT128 FltF56;
1295 FLOAT128 FltF57;
1296 FLOAT128 FltF58;
1297 FLOAT128 FltF59;
1298 FLOAT128 FltF60;
1299 FLOAT128 FltF61;
1300 FLOAT128 FltF62;
1301 FLOAT128 FltF63;
1302 FLOAT128 FltF64;
1303 FLOAT128 FltF65;
1304 FLOAT128 FltF66;
1305 FLOAT128 FltF67;
1306 FLOAT128 FltF68;
1307 FLOAT128 FltF69;
1308 FLOAT128 FltF70;
1309 FLOAT128 FltF71;
1310 FLOAT128 FltF72;
1311 FLOAT128 FltF73;
1312 FLOAT128 FltF74;
1313 FLOAT128 FltF75;
1314 FLOAT128 FltF76;
1315 FLOAT128 FltF77;
1316 FLOAT128 FltF78;
1317 FLOAT128 FltF79;
1318 FLOAT128 FltF80;
1319 FLOAT128 FltF81;
1320 FLOAT128 FltF82;
1321 FLOAT128 FltF83;
1322 FLOAT128 FltF84;
1323 FLOAT128 FltF85;
1324 FLOAT128 FltF86;
1325 FLOAT128 FltF87;
1326 FLOAT128 FltF88;
1327 FLOAT128 FltF89;
1328 FLOAT128 FltF90;
1329 FLOAT128 FltF91;
1330 FLOAT128 FltF92;
1331 FLOAT128 FltF93;
1332 FLOAT128 FltF94;
1333 FLOAT128 FltF95;
1334 FLOAT128 FltF96;
1335 FLOAT128 FltF97;
1336 FLOAT128 FltF98;
1337 FLOAT128 FltF99;
1338 FLOAT128 FltF100;
1339 FLOAT128 FltF101;
1340 FLOAT128 FltF102;
1341 FLOAT128 FltF103;
1342 FLOAT128 FltF104;
1343 FLOAT128 FltF105;
1344 FLOAT128 FltF106;
1345 FLOAT128 FltF107;
1346 FLOAT128 FltF108;
1347 FLOAT128 FltF109;
1348 FLOAT128 FltF110;
1349 FLOAT128 FltF111;
1350 FLOAT128 FltF112;
1351 FLOAT128 FltF113;
1352 FLOAT128 FltF114;
1353 FLOAT128 FltF115;
1354 FLOAT128 FltF116;
1355 FLOAT128 FltF117;
1356 FLOAT128 FltF118;
1357 FLOAT128 FltF119;
1358 FLOAT128 FltF120;
1359 FLOAT128 FltF121;
1360 FLOAT128 FltF122;
1361 FLOAT128 FltF123;
1362 FLOAT128 FltF124;
1363 FLOAT128 FltF125;
1364 FLOAT128 FltF126;
1365 FLOAT128 FltF127;
1366 ULONGLONG StFPSR;
1367 ULONGLONG IntGp;
1368 ULONGLONG IntT0;
1369 ULONGLONG IntT1;
1370 ULONGLONG IntS0;
1371 ULONGLONG IntS1;
1372 ULONGLONG IntS2;
1373 ULONGLONG IntS3;
1374 ULONGLONG IntV0;
1375 ULONGLONG IntT2;
1376 ULONGLONG IntT3;
1377 ULONGLONG IntT4;
1378 ULONGLONG IntSp;
1379 ULONGLONG IntTeb;
1380 ULONGLONG IntT5;
1381 ULONGLONG IntT6;
1382 ULONGLONG IntT7;
1383 ULONGLONG IntT8;
1384 ULONGLONG IntT9;
1385 ULONGLONG IntT10;
1386 ULONGLONG IntT11;
1387 ULONGLONG IntT12;
1388 ULONGLONG IntT13;
1389 ULONGLONG IntT14;
1390 ULONGLONG IntT15;
1391 ULONGLONG IntT16;
1392 ULONGLONG IntT17;
1393 ULONGLONG IntT18;
1394 ULONGLONG IntT19;
1395 ULONGLONG IntT20;
1396 ULONGLONG IntT21;
1397 ULONGLONG IntT22;
1398 ULONGLONG IntNats;
1399 ULONGLONG Preds;
1400 ULONGLONG BrRp;
1401 ULONGLONG BrS0;
1402 ULONGLONG BrS1;
1403 ULONGLONG BrS2;
1404 ULONGLONG BrS3;
1405 ULONGLONG BrS4;
1406 ULONGLONG BrT0;
1407 ULONGLONG BrT1;
1408 ULONGLONG ApUNAT;
1409 ULONGLONG ApLC;
1410 ULONGLONG ApEC;
1411 ULONGLONG ApCCV;
1412 ULONGLONG ApDCR;
1413 ULONGLONG RsPFS;
1414 ULONGLONG RsBSP;
1415 ULONGLONG RsBSPSTORE;
1416 ULONGLONG RsRSC;
1417 ULONGLONG RsRNAT;
1418 ULONGLONG StIPSR;
1419 ULONGLONG StIIP;
1420 ULONGLONG StIFS;
1421 ULONGLONG StFCR;
1422 ULONGLONG Eflag;
1423 ULONGLONG SegCSD;
1424 ULONGLONG SegSSD;
1425 ULONGLONG Cflag;
1426 ULONGLONG StFSR;
1427 ULONGLONG StFIR;
1428 ULONGLONG StFDR;
1429 ULONGLONG UNUSEDPACK;
1430 } CONTEXT, *PCONTEXT;
1432 typedef struct _RUNTIME_FUNCTION
1434 ULONG BeginAddress;
1435 ULONG EndAddress;
1436 ULONG UnwindInfoAddress;
1437 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1439 typedef struct _FRAME_POINTERS {
1440 ULONGLONG MemoryStackFp;
1441 ULONGLONG BackingStoreFp;
1442 } FRAME_POINTERS, *PFRAME_POINTERS;
1444 #define UNWIND_HISTORY_TABLE_SIZE 12
1446 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
1447 ULONG64 ImageBase;
1448 ULONG64 Gp;
1449 PRUNTIME_FUNCTION FunctionEntry;
1450 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1452 typedef struct _UNWIND_HISTORY_TABLE {
1453 ULONG Count;
1454 UCHAR Search;
1455 ULONG64 LowAddress;
1456 ULONG64 HighAddress;
1457 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1458 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1460 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1462 PFLOAT128 FltS0;
1463 PFLOAT128 FltS1;
1464 PFLOAT128 FltS2;
1465 PFLOAT128 FltS3;
1466 PFLOAT128 HighFloatingContext[10];
1467 PFLOAT128 FltS4;
1468 PFLOAT128 FltS5;
1469 PFLOAT128 FltS6;
1470 PFLOAT128 FltS7;
1471 PFLOAT128 FltS8;
1472 PFLOAT128 FltS9;
1473 PFLOAT128 FltS10;
1474 PFLOAT128 FltS11;
1475 PFLOAT128 FltS12;
1476 PFLOAT128 FltS13;
1477 PFLOAT128 FltS14;
1478 PFLOAT128 FltS15;
1479 PFLOAT128 FltS16;
1480 PFLOAT128 FltS17;
1481 PFLOAT128 FltS18;
1482 PFLOAT128 FltS19;
1483 PULONGLONG IntS0;
1484 PULONGLONG IntS1;
1485 PULONGLONG IntS2;
1486 PULONGLONG IntS3;
1487 PULONGLONG IntSp;
1488 PULONGLONG IntS0Nat;
1489 PULONGLONG IntS1Nat;
1490 PULONGLONG IntS2Nat;
1491 PULONGLONG IntS3Nat;
1492 PULONGLONG IntSpNat;
1493 PULONGLONG Preds;
1494 PULONGLONG BrRp;
1495 PULONGLONG BrS0;
1496 PULONGLONG BrS1;
1497 PULONGLONG BrS2;
1498 PULONGLONG BrS3;
1499 PULONGLONG BrS4;
1500 PULONGLONG ApUNAT;
1501 PULONGLONG ApLC;
1502 PULONGLONG ApEC;
1503 PULONGLONG RsPFS;
1504 PULONGLONG StFSR;
1505 PULONGLONG StFIR;
1506 PULONGLONG StFDR;
1507 PULONGLONG Cflag;
1508 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1510 ULONGLONG WINAPI RtlVirtualUnwind(ULONGLONG,ULONGLONG,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,FRAME_POINTERS*,KNONVOLATILE_CONTEXT_POINTERS*);
1512 #endif /* __ia64__ */
1514 /* Alpha context definitions */
1515 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1517 #define CONTEXT_ALPHA 0x00020000
1519 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1520 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1521 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1522 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1524 #define EXCEPTION_READ_FAULT 0
1525 #define EXCEPTION_WRITE_FAULT 1
1526 #define EXCEPTION_EXECUTE_FAULT 8
1528 typedef struct _CONTEXT
1530 /* selected by CONTEXT_FLOATING_POINT */
1531 ULONGLONG FltF0;
1532 ULONGLONG FltF1;
1533 ULONGLONG FltF2;
1534 ULONGLONG FltF3;
1535 ULONGLONG FltF4;
1536 ULONGLONG FltF5;
1537 ULONGLONG FltF6;
1538 ULONGLONG FltF7;
1539 ULONGLONG FltF8;
1540 ULONGLONG FltF9;
1541 ULONGLONG FltF10;
1542 ULONGLONG FltF11;
1543 ULONGLONG FltF12;
1544 ULONGLONG FltF13;
1545 ULONGLONG FltF14;
1546 ULONGLONG FltF15;
1547 ULONGLONG FltF16;
1548 ULONGLONG FltF17;
1549 ULONGLONG FltF18;
1550 ULONGLONG FltF19;
1551 ULONGLONG FltF20;
1552 ULONGLONG FltF21;
1553 ULONGLONG FltF22;
1554 ULONGLONG FltF23;
1555 ULONGLONG FltF24;
1556 ULONGLONG FltF25;
1557 ULONGLONG FltF26;
1558 ULONGLONG FltF27;
1559 ULONGLONG FltF28;
1560 ULONGLONG FltF29;
1561 ULONGLONG FltF30;
1562 ULONGLONG FltF31;
1564 /* selected by CONTEXT_INTEGER */
1565 ULONGLONG IntV0;
1566 ULONGLONG IntT0;
1567 ULONGLONG IntT1;
1568 ULONGLONG IntT2;
1569 ULONGLONG IntT3;
1570 ULONGLONG IntT4;
1571 ULONGLONG IntT5;
1572 ULONGLONG IntT6;
1573 ULONGLONG IntT7;
1574 ULONGLONG IntS0;
1575 ULONGLONG IntS1;
1576 ULONGLONG IntS2;
1577 ULONGLONG IntS3;
1578 ULONGLONG IntS4;
1579 ULONGLONG IntS5;
1580 ULONGLONG IntFp;
1581 ULONGLONG IntA0;
1582 ULONGLONG IntA1;
1583 ULONGLONG IntA2;
1584 ULONGLONG IntA3;
1585 ULONGLONG IntA4;
1586 ULONGLONG IntA5;
1587 ULONGLONG IntT8;
1588 ULONGLONG IntT9;
1589 ULONGLONG IntT10;
1590 ULONGLONG IntT11;
1591 ULONGLONG IntRa;
1592 ULONGLONG IntT12;
1593 ULONGLONG IntAt;
1594 ULONGLONG IntGp;
1595 ULONGLONG IntSp;
1596 ULONGLONG IntZero;
1598 /* selected by CONTEXT_FLOATING_POINT */
1599 ULONGLONG Fpcr;
1600 ULONGLONG SoftFpcr;
1602 /* selected by CONTEXT_CONTROL */
1603 ULONGLONG Fir;
1604 DWORD Psr;
1605 DWORD ContextFlags;
1606 DWORD Fill[4];
1607 } CONTEXT;
1609 #define _QUAD_PSR_OFFSET HighSoftFpcr
1610 #define _QUAD_FLAGS_OFFSET HighFir
1612 #endif /* _ALPHA_ */
1614 #ifdef __arm__
1616 /* The following flags control the contents of the CONTEXT structure. */
1618 #define CONTEXT_ARM 0x0200000
1619 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1620 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1621 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1622 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1624 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1626 #define EXCEPTION_READ_FAULT 0
1627 #define EXCEPTION_WRITE_FAULT 1
1628 #define EXCEPTION_EXECUTE_FAULT 8
1630 typedef struct _RUNTIME_FUNCTION
1632 DWORD BeginAddress;
1633 union {
1634 DWORD UnwindData;
1635 struct {
1636 DWORD Flag : 2;
1637 DWORD FunctionLength : 11;
1638 DWORD Ret : 2;
1639 DWORD H : 1;
1640 DWORD Reg : 3;
1641 DWORD R : 1;
1642 DWORD L : 1;
1643 DWORD C : 1;
1644 DWORD StackAdjust : 10;
1645 } DUMMYSTRUCTNAME;
1646 } DUMMYUNIONNAME;
1647 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1649 #define UNWIND_HISTORY_TABLE_SIZE 12
1651 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1653 DWORD ImageBase;
1654 PRUNTIME_FUNCTION FunctionEntry;
1655 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1657 typedef struct _UNWIND_HISTORY_TABLE
1659 DWORD Count;
1660 BYTE LocalHint;
1661 BYTE GlobalHint;
1662 BYTE Search;
1663 BYTE Once;
1664 DWORD LowAddress;
1665 DWORD HighAddress;
1666 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1667 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1669 typedef struct _CONTEXT {
1670 /* The flags values within this flag control the contents of
1671 a CONTEXT record.
1673 If the context record is used as an input parameter, then
1674 for each portion of the context record controlled by a flag
1675 whose value is set, it is assumed that that portion of the
1676 context record contains valid context. If the context record
1677 is being used to modify a thread's context, then only that
1678 portion of the threads context will be modified.
1680 If the context record is used as an IN OUT parameter to capture
1681 the context of a thread, then only those portions of the thread's
1682 context corresponding to set flags will be returned.
1684 The context record is never used as an OUT only parameter. */
1686 ULONG ContextFlags;
1688 /* This section is specified/returned if the ContextFlags word contains
1689 the flag CONTEXT_INTEGER. */
1690 ULONG R0;
1691 ULONG R1;
1692 ULONG R2;
1693 ULONG R3;
1694 ULONG R4;
1695 ULONG R5;
1696 ULONG R6;
1697 ULONG R7;
1698 ULONG R8;
1699 ULONG R9;
1700 ULONG R10;
1701 ULONG Fp;
1702 ULONG Ip;
1704 /* These are selected by CONTEXT_CONTROL */
1705 ULONG Sp;
1706 ULONG Lr;
1707 ULONG Pc;
1708 ULONG Cpsr;
1709 } CONTEXT;
1711 BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD);
1712 BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1713 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR,DWORD*,UNWIND_HISTORY_TABLE*);
1715 #endif /* __arm__ */
1717 #ifdef __aarch64__
1719 * FIXME:
1721 * There is not yet an official CONTEXT structure defined for the AArch64
1722 * architecture, so I just made one up.
1726 #define CONTEXT_ARM64 0x2000000
1727 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1728 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1729 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1730 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1732 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1734 #define EXCEPTION_READ_FAULT 0
1735 #define EXCEPTION_WRITE_FAULT 1
1736 #define EXCEPTION_EXECUTE_FAULT 8
1738 typedef struct _CONTEXT {
1739 ULONG ContextFlags;
1741 /* This section is specified/returned if the ContextFlags word contains
1742 the flag CONTEXT_INTEGER. */
1743 ULONGLONG X0;
1744 ULONGLONG X1;
1745 ULONGLONG X2;
1746 ULONGLONG X3;
1747 ULONGLONG X4;
1748 ULONGLONG X5;
1749 ULONGLONG X6;
1750 ULONGLONG X7;
1751 ULONGLONG X8;
1752 ULONGLONG X9;
1753 ULONGLONG X10;
1754 ULONGLONG X11;
1755 ULONGLONG X12;
1756 ULONGLONG X13;
1757 ULONGLONG X14;
1758 ULONGLONG X15;
1759 ULONGLONG X16;
1760 ULONGLONG X17;
1761 ULONGLONG X18;
1762 ULONGLONG X19;
1763 ULONGLONG X20;
1764 ULONGLONG X21;
1765 ULONGLONG X22;
1766 ULONGLONG X23;
1767 ULONGLONG X24;
1768 ULONGLONG X25;
1769 ULONGLONG X26;
1770 ULONGLONG X27;
1771 ULONGLONG X28;
1772 ULONGLONG X29;
1773 ULONGLONG X30;
1775 /* These are selected by CONTEXT_CONTROL */
1776 ULONGLONG Sp;
1777 ULONGLONG Pc;
1778 ULONGLONG PState;
1780 /* These are selected by CONTEXT_FLOATING_POINT */
1781 /* FIXME */
1782 } CONTEXT;
1784 #endif /* __aarch64__ */
1787 /* Mips context definitions */
1788 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
1790 #define CONTEXT_R4000 0x00010000
1792 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
1793 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
1794 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
1796 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1798 #define EXCEPTION_READ_FAULT 0
1799 #define EXCEPTION_WRITE_FAULT 1
1800 #define EXCEPTION_EXECUTE_FAULT 8
1802 typedef struct _CONTEXT
1804 DWORD Argument[4];
1805 /* These are selected by CONTEXT_FLOATING_POINT */
1806 DWORD FltF0;
1807 DWORD FltF1;
1808 DWORD FltF2;
1809 DWORD FltF3;
1810 DWORD FltF4;
1811 DWORD FltF5;
1812 DWORD FltF6;
1813 DWORD FltF7;
1814 DWORD FltF8;
1815 DWORD FltF9;
1816 DWORD FltF10;
1817 DWORD FltF11;
1818 DWORD FltF12;
1819 DWORD FltF13;
1820 DWORD FltF14;
1821 DWORD FltF15;
1822 DWORD FltF16;
1823 DWORD FltF17;
1824 DWORD FltF18;
1825 DWORD FltF19;
1826 DWORD FltF20;
1827 DWORD FltF21;
1828 DWORD FltF22;
1829 DWORD FltF23;
1830 DWORD FltF24;
1831 DWORD FltF25;
1832 DWORD FltF26;
1833 DWORD FltF27;
1834 DWORD FltF28;
1835 DWORD FltF29;
1836 DWORD FltF30;
1837 DWORD FltF31;
1839 /* These are selected by CONTEXT_INTEGER */
1840 DWORD IntZero;
1841 DWORD IntAt;
1842 DWORD IntV0;
1843 DWORD IntV1;
1844 DWORD IntA0;
1845 DWORD IntA1;
1846 DWORD IntA2;
1847 DWORD IntA3;
1848 DWORD IntT0;
1849 DWORD IntT1;
1850 DWORD IntT2;
1851 DWORD IntT3;
1852 DWORD IntT4;
1853 DWORD IntT5;
1854 DWORD IntT6;
1855 DWORD IntT7;
1856 DWORD IntS0;
1857 DWORD IntS1;
1858 DWORD IntS2;
1859 DWORD IntS3;
1860 DWORD IntS4;
1861 DWORD IntS5;
1862 DWORD IntS6;
1863 DWORD IntS7;
1864 DWORD IntT8;
1865 DWORD IntT9;
1866 DWORD IntK0;
1867 DWORD IntK1;
1868 DWORD IntGp;
1869 DWORD IntSp;
1870 DWORD IntS8;
1871 DWORD IntRa;
1872 DWORD IntLo;
1873 DWORD IntHi;
1875 /* These are selected by CONTEXT_FLOATING_POINT */
1876 DWORD Fsr;
1878 /* These are selected by CONTEXT_CONTROL */
1879 DWORD Fir;
1880 DWORD Psr;
1882 DWORD ContextFlags;
1883 DWORD Fill[2];
1884 } CONTEXT;
1886 #endif /* _MIPS_ */
1888 /* PowerPC context definitions */
1889 #ifdef __powerpc__
1891 #define CONTEXT_CONTROL 0x0001
1892 #define CONTEXT_FLOATING_POINT 0x0002
1893 #define CONTEXT_INTEGER 0x0004
1894 #define CONTEXT_DEBUG_REGISTERS 0x0008
1895 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1897 #define EXCEPTION_READ_FAULT 0
1898 #define EXCEPTION_WRITE_FAULT 1
1899 #define EXCEPTION_EXECUTE_FAULT 8
1901 typedef struct
1903 /* These are selected by CONTEXT_FLOATING_POINT */
1904 double Fpr0;
1905 double Fpr1;
1906 double Fpr2;
1907 double Fpr3;
1908 double Fpr4;
1909 double Fpr5;
1910 double Fpr6;
1911 double Fpr7;
1912 double Fpr8;
1913 double Fpr9;
1914 double Fpr10;
1915 double Fpr11;
1916 double Fpr12;
1917 double Fpr13;
1918 double Fpr14;
1919 double Fpr15;
1920 double Fpr16;
1921 double Fpr17;
1922 double Fpr18;
1923 double Fpr19;
1924 double Fpr20;
1925 double Fpr21;
1926 double Fpr22;
1927 double Fpr23;
1928 double Fpr24;
1929 double Fpr25;
1930 double Fpr26;
1931 double Fpr27;
1932 double Fpr28;
1933 double Fpr29;
1934 double Fpr30;
1935 double Fpr31;
1936 double Fpscr;
1938 /* These are selected by CONTEXT_INTEGER */
1939 DWORD Gpr0;
1940 DWORD Gpr1;
1941 DWORD Gpr2;
1942 DWORD Gpr3;
1943 DWORD Gpr4;
1944 DWORD Gpr5;
1945 DWORD Gpr6;
1946 DWORD Gpr7;
1947 DWORD Gpr8;
1948 DWORD Gpr9;
1949 DWORD Gpr10;
1950 DWORD Gpr11;
1951 DWORD Gpr12;
1952 DWORD Gpr13;
1953 DWORD Gpr14;
1954 DWORD Gpr15;
1955 DWORD Gpr16;
1956 DWORD Gpr17;
1957 DWORD Gpr18;
1958 DWORD Gpr19;
1959 DWORD Gpr20;
1960 DWORD Gpr21;
1961 DWORD Gpr22;
1962 DWORD Gpr23;
1963 DWORD Gpr24;
1964 DWORD Gpr25;
1965 DWORD Gpr26;
1966 DWORD Gpr27;
1967 DWORD Gpr28;
1968 DWORD Gpr29;
1969 DWORD Gpr30;
1970 DWORD Gpr31;
1972 DWORD Cr;
1973 DWORD Xer;
1975 /* These are selected by CONTEXT_CONTROL */
1976 DWORD Msr;
1977 DWORD Iar; /* Instruction Address Register , aka PC ... */
1978 DWORD Lr;
1979 DWORD Ctr;
1981 DWORD ContextFlags;
1983 DWORD Dar; /* Fault registers for coredump */
1984 DWORD Dsisr;
1985 DWORD Trap; /* number of powerpc exception taken */
1987 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1988 DWORD Dr0;
1989 DWORD Dr1;
1990 DWORD Dr2;
1991 DWORD Dr3;
1992 DWORD Dr4;
1993 DWORD Dr5;
1994 DWORD Dr6;
1995 DWORD Dr7;
1996 } CONTEXT;
1998 typedef struct _STACK_FRAME_HEADER
2000 DWORD BackChain;
2001 DWORD GlueSaved1;
2002 DWORD GlueSaved2;
2003 DWORD Reserved1;
2004 DWORD Spare1;
2005 DWORD Spare2;
2007 DWORD Parameter0;
2008 DWORD Parameter1;
2009 DWORD Parameter2;
2010 DWORD Parameter3;
2011 DWORD Parameter4;
2012 DWORD Parameter5;
2013 DWORD Parameter6;
2014 DWORD Parameter7;
2015 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
2017 #endif /* __powerpc__ */
2019 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2020 #error You need to define a CONTEXT for your CPU
2021 #endif
2023 typedef CONTEXT *PCONTEXT;
2025 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
2028 * Product types
2030 #define PRODUCT_UNDEFINED 0x00000000
2031 #define PRODUCT_ULTIMATE 0x00000001
2032 #define PRODUCT_HOME_BASIC 0x00000002
2033 #define PRODUCT_HOME_PREMIUM 0x00000003
2034 #define PRODUCT_ENTERPRISE 0x00000004
2035 #define PRODUCT_HOME_BASIC_N 0x00000005
2036 #define PRODUCT_BUSINESS 0x00000006
2037 #define PRODUCT_STANDARD_SERVER 0x00000007
2038 #define PRODUCT_DATACENTER_SERVER 0x00000008
2039 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2040 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2041 #define PRODUCT_STARTER 0x0000000B
2042 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2043 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2044 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2045 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2046 #define PRODUCT_BUSINESS_N 0x00000010
2047 #define PRODUCT_WEB_SERVER 0x00000011
2048 #define PRODUCT_CLUSTER_SERVER 0x00000012
2049 #define PRODUCT_HOME_SERVER 0x00000013
2050 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2051 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2052 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2053 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2054 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2055 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2056 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2057 #define PRODUCT_ENTERPRISE_N 0x0000001B
2058 #define PRODUCT_ULTIMATE_N 0x0000001C
2059 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2060 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2061 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2062 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2063 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2064 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2065 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2066 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2067 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2068 #define PRODUCT_SERVER_V 0x00000025
2069 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2070 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2071 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2072 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2073 #define PRODUCT_HYPERV 0x0000002A
2074 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2075 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2076 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2077 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2078 #define PRODUCT_STARTER_N 0x0000002F
2079 #define PRODUCT_PROFESSIONAL 0x00000030
2080 #define PRODUCT_PROFESSIONAL_N 0x00000031
2081 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2082 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2083 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2084 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2085 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2086 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2087 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2088 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2089 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2090 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2091 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2092 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2093 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2094 #define PRODUCT_EMBEDDED 0x00000041
2095 #define PRODUCT_STARTER_E 0x00000042
2096 #define PRODUCT_HOME_BASIC_E 0x00000043
2097 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2098 #define PRODUCT_PROFESSIONAL_E 0x00000045
2099 #define PRODUCT_ENTERPRISE_E 0x00000046
2100 #define PRODUCT_ULTIMATE_E 0x00000047
2101 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2102 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2103 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2104 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2105 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2106 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2107 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2108 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2109 #define PRODUCT_CORE_ARM 0x00000061
2110 #define PRODUCT_CORE_N 0x00000062
2111 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2112 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2113 #define PRODUCT_CORE 0x00000065
2114 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2115 #define PRODUCT_UNLICENSED 0xABCDABCD
2119 * Language IDs
2122 #define MAKELCID(l, s) (MAKELONG(l, s))
2124 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2125 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2126 #define SUBLANGID(l) ((WORD)(l) >> 10)
2128 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2129 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2131 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2132 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2133 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2134 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2135 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2136 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2137 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2138 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2139 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2140 #define LOCALE_NAME_MAX_LENGTH 85
2143 #define UNREFERENCED_PARAMETER(u) (void)(u)
2144 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2145 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2147 #include <winnt.rh>
2151 * Definitions for IsTextUnicode()
2154 #define IS_TEXT_UNICODE_ASCII16 0x0001
2155 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2156 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2157 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2158 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2159 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2160 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2161 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2162 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2163 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2164 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2165 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2166 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2167 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2168 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2169 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2171 #define MAXIMUM_WAIT_OBJECTS 64
2172 #define MAXIMUM_SUSPEND_COUNT 127
2174 #define WT_EXECUTEDEFAULT 0x00
2175 #define WT_EXECUTEINIOTHREAD 0x01
2176 #define WT_EXECUTEINUITHREAD 0x02
2177 #define WT_EXECUTEINWAITTHREAD 0x04
2178 #define WT_EXECUTEONLYONCE 0x08
2179 #define WT_EXECUTELONGFUNCTION 0x10
2180 #define WT_EXECUTEINTIMERTHREAD 0x20
2181 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2182 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2183 #define WT_EXECUTEINLONGTHREAD 0x10
2184 #define WT_EXECUTEDELETEWAIT 0x08
2185 #define WT_TRANSFER_IMPERSONATION 0x0100
2188 #define EXCEPTION_CONTINUABLE 0
2189 #define EXCEPTION_NONCONTINUABLE 0x01
2192 * The exception record used by Win32 to give additional information
2193 * about exception to exception handlers.
2196 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2198 typedef struct _EXCEPTION_RECORD
2200 DWORD ExceptionCode;
2201 DWORD ExceptionFlags;
2202 struct _EXCEPTION_RECORD *ExceptionRecord;
2204 PVOID ExceptionAddress;
2205 DWORD NumberParameters;
2206 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2207 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2210 * The exception pointers structure passed to exception filters
2211 * in except() and the UnhandledExceptionFilter().
2214 typedef struct _EXCEPTION_POINTERS
2216 PEXCEPTION_RECORD ExceptionRecord;
2217 PCONTEXT ContextRecord;
2218 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2222 * The exception frame, used for registering exception handlers
2223 * Win32 cares only about this, but compilers generally emit
2224 * larger exception frames for their own use.
2227 struct _EXCEPTION_REGISTRATION_RECORD;
2229 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2230 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2232 typedef struct _EXCEPTION_REGISTRATION_RECORD
2234 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2235 PEXCEPTION_HANDLER Handler;
2236 } EXCEPTION_REGISTRATION_RECORD;
2239 * function pointer to an exception filter
2242 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2244 typedef struct _NT_TIB
2246 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2247 PVOID StackBase;
2248 PVOID StackLimit;
2249 PVOID SubSystemTib;
2250 union {
2251 PVOID FiberData;
2252 DWORD Version;
2253 } DUMMYUNIONNAME;
2254 PVOID ArbitraryUserPointer;
2255 struct _NT_TIB *Self;
2256 } NT_TIB, *PNT_TIB;
2258 struct _TEB;
2260 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2261 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2263 struct _TEB *teb;
2264 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2265 return teb;
2267 #elif defined(__i386__) && defined(_MSC_VER)
2268 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2270 struct _TEB *teb;
2271 __asm mov eax, fs:[0x18];
2272 __asm mov teb, eax;
2273 return teb;
2275 #elif defined(__x86_64__) && defined(__GNUC__)
2276 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2278 struct _TEB *teb;
2279 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2280 return teb;
2282 #else
2283 extern struct _TEB * WINAPI NtCurrentTeb(void);
2284 #endif
2286 #ifdef NONAMELESSUNION
2287 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2288 #else
2289 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2290 #endif
2291 #define GetFiberData() (*(void **)GetCurrentFiber())
2293 #define TLS_MINIMUM_AVAILABLE 64
2296 * File formats definitions
2299 #include <pshpack2.h>
2300 typedef struct _IMAGE_DOS_HEADER {
2301 WORD e_magic; /* 00: MZ Header signature */
2302 WORD e_cblp; /* 02: Bytes on last page of file */
2303 WORD e_cp; /* 04: Pages in file */
2304 WORD e_crlc; /* 06: Relocations */
2305 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2306 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2307 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2308 WORD e_ss; /* 0e: Initial (relative) SS value */
2309 WORD e_sp; /* 10: Initial SP value */
2310 WORD e_csum; /* 12: Checksum */
2311 WORD e_ip; /* 14: Initial IP value */
2312 WORD e_cs; /* 16: Initial (relative) CS value */
2313 WORD e_lfarlc; /* 18: File address of relocation table */
2314 WORD e_ovno; /* 1a: Overlay number */
2315 WORD e_res[4]; /* 1c: Reserved words */
2316 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2317 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2318 WORD e_res2[10]; /* 28: Reserved words */
2319 DWORD e_lfanew; /* 3c: Offset to extended header */
2320 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2321 #include <poppack.h>
2323 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2324 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2325 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2326 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2327 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2328 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2331 * This is the Windows executable (NE) header.
2332 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2334 #include <pshpack2.h>
2335 typedef struct
2337 WORD ne_magic; /* 00 NE signature 'NE' */
2338 BYTE ne_ver; /* 02 Linker version number */
2339 BYTE ne_rev; /* 03 Linker revision number */
2340 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2341 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2342 LONG ne_crc; /* 08 Checksum */
2343 WORD ne_flags; /* 0c Flags about segments in this file */
2344 WORD ne_autodata; /* 0e Automatic data segment number */
2345 WORD ne_heap; /* 10 Initial size of local heap */
2346 WORD ne_stack; /* 12 Initial size of stack */
2347 DWORD ne_csip; /* 14 Initial CS:IP */
2348 DWORD ne_sssp; /* 18 Initial SS:SP */
2349 WORD ne_cseg; /* 1c # of entries in segment table */
2350 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2351 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2352 WORD ne_segtab; /* 22 Offset to segment table */
2353 WORD ne_rsrctab; /* 24 Offset to resource table */
2354 WORD ne_restab; /* 26 Offset to resident-name table */
2355 WORD ne_modtab; /* 28 Offset to module reference table */
2356 WORD ne_imptab; /* 2a Offset to imported name table */
2357 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2358 WORD ne_cmovent; /* 30 # of movable entry points */
2359 WORD ne_align; /* 32 Logical sector alignment shift count */
2360 WORD ne_cres; /* 34 # of resource segments */
2361 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2362 BYTE ne_flagsothers; /* 37 Additional information flags */
2363 WORD ne_pretthunks; /* 38 Offset to return thunks */
2364 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2365 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2366 WORD ne_expver; /* 3e Expected Windows version number */
2367 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2368 #include <poppack.h>
2370 #include <pshpack2.h>
2371 typedef struct _IMAGE_VXD_HEADER {
2372 WORD e32_magic;
2373 BYTE e32_border;
2374 BYTE e32_worder;
2375 DWORD e32_level;
2376 WORD e32_cpu;
2377 WORD e32_os;
2378 DWORD e32_ver;
2379 DWORD e32_mflags;
2380 DWORD e32_mpages;
2381 DWORD e32_startobj;
2382 DWORD e32_eip;
2383 DWORD e32_stackobj;
2384 DWORD e32_esp;
2385 DWORD e32_pagesize;
2386 DWORD e32_lastpagesize;
2387 DWORD e32_fixupsize;
2388 DWORD e32_fixupsum;
2389 DWORD e32_ldrsize;
2390 DWORD e32_ldrsum;
2391 DWORD e32_objtab;
2392 DWORD e32_objcnt;
2393 DWORD e32_objmap;
2394 DWORD e32_itermap;
2395 DWORD e32_rsrctab;
2396 DWORD e32_rsrccnt;
2397 DWORD e32_restab;
2398 DWORD e32_enttab;
2399 DWORD e32_dirtab;
2400 DWORD e32_dircnt;
2401 DWORD e32_fpagetab;
2402 DWORD e32_frectab;
2403 DWORD e32_impmod;
2404 DWORD e32_impmodcnt;
2405 DWORD e32_impproc;
2406 DWORD e32_pagesum;
2407 DWORD e32_datapage;
2408 DWORD e32_preload;
2409 DWORD e32_nrestab;
2410 DWORD e32_cbnrestab;
2411 DWORD e32_nressum;
2412 DWORD e32_autodata;
2413 DWORD e32_debuginfo;
2414 DWORD e32_debuglen;
2415 DWORD e32_instpreload;
2416 DWORD e32_instdemand;
2417 DWORD e32_heapsize;
2418 BYTE e32_res3[12];
2419 DWORD e32_winresoff;
2420 DWORD e32_winreslen;
2421 WORD e32_devid;
2422 WORD e32_ddkver;
2423 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2424 #include <poppack.h>
2426 /* These defines describe the meanings of the bits in the Characteristics
2427 field */
2429 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2430 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2431 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2432 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2433 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2434 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2435 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2436 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2437 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2438 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2439 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2440 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2441 #define IMAGE_FILE_SYSTEM 0x1000
2442 #define IMAGE_FILE_DLL 0x2000
2443 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2444 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2446 /* These are the settings of the Machine field. */
2447 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2448 #define IMAGE_FILE_MACHINE_I860 0x014d
2449 #define IMAGE_FILE_MACHINE_I386 0x014c
2450 #define IMAGE_FILE_MACHINE_R3000 0x0162
2451 #define IMAGE_FILE_MACHINE_R4000 0x0166
2452 #define IMAGE_FILE_MACHINE_R10000 0x0168
2453 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2454 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2455 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2456 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2457 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2458 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2459 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2460 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2461 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2462 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2463 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2464 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2465 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2466 #define IMAGE_FILE_MACHINE_IA64 0x0200
2467 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2468 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2469 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2470 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2471 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2472 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2473 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2474 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2475 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2476 #define IMAGE_FILE_MACHINE_M32R 0x9041
2477 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2479 /* Wine extension */
2480 #define IMAGE_FILE_MACHINE_ARM64 0x01c5
2482 #define IMAGE_SIZEOF_FILE_HEADER 20
2483 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2484 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2485 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2486 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2487 #define IMAGE_SIZEOF_SHORT_NAME 8
2488 #define IMAGE_SIZEOF_SECTION_HEADER 40
2489 #define IMAGE_SIZEOF_SYMBOL 18
2490 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2491 #define IMAGE_SIZEOF_RELOCATION 10
2492 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2493 #define IMAGE_SIZEOF_LINENUMBER 6
2494 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2496 /* Possible Magic values */
2497 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2498 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2499 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2501 #ifdef _WIN64
2502 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2503 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2504 #else
2505 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2506 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2507 #endif
2509 /* These are indexes into the DataDirectory array */
2510 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2511 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2512 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2513 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2514 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2515 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2516 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2517 #define IMAGE_FILE_DESCRIPTION_STRING 7
2518 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2519 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2520 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2522 /* Directory Entries, indices into the DataDirectory array */
2524 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2525 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2526 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2527 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2528 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2529 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2530 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2531 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2532 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2533 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2534 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2535 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2536 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2537 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2538 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2540 /* Subsystem Values */
2542 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2543 #define IMAGE_SUBSYSTEM_NATIVE 1
2544 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2545 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2546 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2547 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2548 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2549 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2550 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2551 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2552 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2553 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2554 #define IMAGE_SUBSYSTEM_XBOX 14
2555 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2557 /* DLL Characteristics */
2558 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2559 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2560 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2561 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2562 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2563 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2564 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2565 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2567 typedef struct _IMAGE_FILE_HEADER {
2568 WORD Machine;
2569 WORD NumberOfSections;
2570 DWORD TimeDateStamp;
2571 DWORD PointerToSymbolTable;
2572 DWORD NumberOfSymbols;
2573 WORD SizeOfOptionalHeader;
2574 WORD Characteristics;
2575 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2577 typedef struct _IMAGE_DATA_DIRECTORY {
2578 DWORD VirtualAddress;
2579 DWORD Size;
2580 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2582 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2584 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2585 WORD Magic; /* 0x20b */
2586 BYTE MajorLinkerVersion;
2587 BYTE MinorLinkerVersion;
2588 DWORD SizeOfCode;
2589 DWORD SizeOfInitializedData;
2590 DWORD SizeOfUninitializedData;
2591 DWORD AddressOfEntryPoint;
2592 DWORD BaseOfCode;
2593 ULONGLONG ImageBase;
2594 DWORD SectionAlignment;
2595 DWORD FileAlignment;
2596 WORD MajorOperatingSystemVersion;
2597 WORD MinorOperatingSystemVersion;
2598 WORD MajorImageVersion;
2599 WORD MinorImageVersion;
2600 WORD MajorSubsystemVersion;
2601 WORD MinorSubsystemVersion;
2602 DWORD Win32VersionValue;
2603 DWORD SizeOfImage;
2604 DWORD SizeOfHeaders;
2605 DWORD CheckSum;
2606 WORD Subsystem;
2607 WORD DllCharacteristics;
2608 ULONGLONG SizeOfStackReserve;
2609 ULONGLONG SizeOfStackCommit;
2610 ULONGLONG SizeOfHeapReserve;
2611 ULONGLONG SizeOfHeapCommit;
2612 DWORD LoaderFlags;
2613 DWORD NumberOfRvaAndSizes;
2614 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2615 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2617 typedef struct _IMAGE_NT_HEADERS64 {
2618 DWORD Signature;
2619 IMAGE_FILE_HEADER FileHeader;
2620 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2621 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2623 typedef struct _IMAGE_OPTIONAL_HEADER {
2625 /* Standard fields */
2627 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2628 BYTE MajorLinkerVersion;
2629 BYTE MinorLinkerVersion;
2630 DWORD SizeOfCode;
2631 DWORD SizeOfInitializedData;
2632 DWORD SizeOfUninitializedData;
2633 DWORD AddressOfEntryPoint; /* 0x10 */
2634 DWORD BaseOfCode;
2635 DWORD BaseOfData;
2637 /* NT additional fields */
2639 DWORD ImageBase;
2640 DWORD SectionAlignment; /* 0x20 */
2641 DWORD FileAlignment;
2642 WORD MajorOperatingSystemVersion;
2643 WORD MinorOperatingSystemVersion;
2644 WORD MajorImageVersion;
2645 WORD MinorImageVersion;
2646 WORD MajorSubsystemVersion; /* 0x30 */
2647 WORD MinorSubsystemVersion;
2648 DWORD Win32VersionValue;
2649 DWORD SizeOfImage;
2650 DWORD SizeOfHeaders;
2651 DWORD CheckSum; /* 0x40 */
2652 WORD Subsystem;
2653 WORD DllCharacteristics;
2654 DWORD SizeOfStackReserve;
2655 DWORD SizeOfStackCommit;
2656 DWORD SizeOfHeapReserve; /* 0x50 */
2657 DWORD SizeOfHeapCommit;
2658 DWORD LoaderFlags;
2659 DWORD NumberOfRvaAndSizes;
2660 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2661 /* 0xE0 */
2662 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2664 typedef struct _IMAGE_NT_HEADERS {
2665 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2666 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2667 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2668 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2670 #ifdef _WIN64
2671 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2672 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2673 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2674 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2675 #else
2676 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2677 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2678 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2679 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2680 #endif
2682 #define IMAGE_SIZEOF_SHORT_NAME 8
2684 typedef struct _IMAGE_SECTION_HEADER {
2685 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2686 union {
2687 DWORD PhysicalAddress;
2688 DWORD VirtualSize;
2689 } Misc;
2690 DWORD VirtualAddress;
2691 DWORD SizeOfRawData;
2692 DWORD PointerToRawData;
2693 DWORD PointerToRelocations;
2694 DWORD PointerToLinenumbers;
2695 WORD NumberOfRelocations;
2696 WORD NumberOfLinenumbers;
2697 DWORD Characteristics;
2698 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2700 #define IMAGE_SIZEOF_SECTION_HEADER 40
2702 #define IMAGE_FIRST_SECTION(ntheader) \
2703 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2704 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2706 /* These defines are for the Characteristics bitfield. */
2707 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2708 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2709 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2710 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2711 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2712 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2714 #define IMAGE_SCN_CNT_CODE 0x00000020
2715 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2716 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2718 #define IMAGE_SCN_LNK_OTHER 0x00000100
2719 #define IMAGE_SCN_LNK_INFO 0x00000200
2720 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2721 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2722 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2724 /* 0x00002000 - Reserved */
2725 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2726 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2728 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2729 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2730 #define IMAGE_SCN_MEM_16BIT 0x00020000
2731 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2732 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2734 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2735 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2736 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2737 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2738 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2739 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2740 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2741 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2742 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2743 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2744 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2745 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2746 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2747 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2748 /* 0x00F00000 - Unused */
2749 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2751 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2754 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2755 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2756 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2757 #define IMAGE_SCN_MEM_SHARED 0x10000000
2758 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2759 #define IMAGE_SCN_MEM_READ 0x40000000
2760 #define IMAGE_SCN_MEM_WRITE 0x80000000
2762 #include <pshpack2.h>
2764 typedef struct _IMAGE_SYMBOL {
2765 union {
2766 BYTE ShortName[8];
2767 struct {
2768 DWORD Short;
2769 DWORD Long;
2770 } Name;
2771 DWORD LongName[2];
2772 } N;
2773 DWORD Value;
2774 SHORT SectionNumber;
2775 WORD Type;
2776 BYTE StorageClass;
2777 BYTE NumberOfAuxSymbols;
2778 } IMAGE_SYMBOL;
2779 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2781 #define IMAGE_SIZEOF_SYMBOL 18
2783 typedef struct _IMAGE_LINENUMBER {
2784 union {
2785 DWORD SymbolTableIndex;
2786 DWORD VirtualAddress;
2787 } Type;
2788 WORD Linenumber;
2789 } IMAGE_LINENUMBER;
2790 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2792 #define IMAGE_SIZEOF_LINENUMBER 6
2794 typedef union _IMAGE_AUX_SYMBOL {
2795 struct {
2796 DWORD TagIndex;
2797 union {
2798 struct {
2799 WORD Linenumber;
2800 WORD Size;
2801 } LnSz;
2802 DWORD TotalSize;
2803 } Misc;
2804 union {
2805 struct {
2806 DWORD PointerToLinenumber;
2807 DWORD PointerToNextFunction;
2808 } Function;
2809 struct {
2810 WORD Dimension[4];
2811 } Array;
2812 } FcnAry;
2813 WORD TvIndex;
2814 } Sym;
2815 struct {
2816 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2817 } File;
2818 struct {
2819 DWORD Length;
2820 WORD NumberOfRelocations;
2821 WORD NumberOfLinenumbers;
2822 DWORD CheckSum;
2823 SHORT Number;
2824 BYTE Selection;
2825 } Section;
2826 } IMAGE_AUX_SYMBOL;
2827 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2829 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2831 #include <poppack.h>
2833 #define IMAGE_SYM_UNDEFINED (SHORT)0
2834 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2835 #define IMAGE_SYM_DEBUG (SHORT)-2
2837 #define IMAGE_SYM_TYPE_NULL 0x0000
2838 #define IMAGE_SYM_TYPE_VOID 0x0001
2839 #define IMAGE_SYM_TYPE_CHAR 0x0002
2840 #define IMAGE_SYM_TYPE_SHORT 0x0003
2841 #define IMAGE_SYM_TYPE_INT 0x0004
2842 #define IMAGE_SYM_TYPE_LONG 0x0005
2843 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2844 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2845 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2846 #define IMAGE_SYM_TYPE_UNION 0x0009
2847 #define IMAGE_SYM_TYPE_ENUM 0x000A
2848 #define IMAGE_SYM_TYPE_MOE 0x000B
2849 #define IMAGE_SYM_TYPE_BYTE 0x000C
2850 #define IMAGE_SYM_TYPE_WORD 0x000D
2851 #define IMAGE_SYM_TYPE_UINT 0x000E
2852 #define IMAGE_SYM_TYPE_DWORD 0x000F
2853 #define IMAGE_SYM_TYPE_PCODE 0x8000
2855 #define IMAGE_SYM_DTYPE_NULL 0
2856 #define IMAGE_SYM_DTYPE_POINTER 1
2857 #define IMAGE_SYM_DTYPE_FUNCTION 2
2858 #define IMAGE_SYM_DTYPE_ARRAY 3
2860 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2861 #define IMAGE_SYM_CLASS_NULL 0x0000
2862 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2863 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2864 #define IMAGE_SYM_CLASS_STATIC 0x0003
2865 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2866 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2867 #define IMAGE_SYM_CLASS_LABEL 0x0006
2868 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2869 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2870 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2871 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2872 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2873 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2874 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2875 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2876 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2877 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2878 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2879 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2881 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2882 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2883 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2884 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2885 #define IMAGE_SYM_CLASS_FILE 0x0067
2886 #define IMAGE_SYM_CLASS_SECTION 0x0068
2887 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2889 #define N_BTMASK 0x000F
2890 #define N_TMASK 0x0030
2891 #define N_TMASK1 0x00C0
2892 #define N_TMASK2 0x00F0
2893 #define N_BTSHFT 4
2894 #define N_TSHIFT 2
2896 #define BTYPE(x) ((x) & N_BTMASK)
2898 #ifndef ISPTR
2899 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2900 #endif
2902 #ifndef ISFCN
2903 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2904 #endif
2906 #ifndef ISARY
2907 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2908 #endif
2910 #ifndef ISTAG
2911 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2912 #endif
2914 #ifndef INCREF
2915 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2916 #endif
2917 #ifndef DECREF
2918 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2919 #endif
2921 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2922 #define IMAGE_COMDAT_SELECT_ANY 2
2923 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2924 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2925 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2926 #define IMAGE_COMDAT_SELECT_LARGEST 6
2927 #define IMAGE_COMDAT_SELECT_NEWEST 7
2929 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2930 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2931 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2933 /* Export module directory */
2935 typedef struct _IMAGE_EXPORT_DIRECTORY {
2936 DWORD Characteristics;
2937 DWORD TimeDateStamp;
2938 WORD MajorVersion;
2939 WORD MinorVersion;
2940 DWORD Name;
2941 DWORD Base;
2942 DWORD NumberOfFunctions;
2943 DWORD NumberOfNames;
2944 DWORD AddressOfFunctions;
2945 DWORD AddressOfNames;
2946 DWORD AddressOfNameOrdinals;
2947 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2949 /* Import name entry */
2950 typedef struct _IMAGE_IMPORT_BY_NAME {
2951 WORD Hint;
2952 BYTE Name[1];
2953 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2955 #include <pshpack8.h>
2956 /* Import thunk */
2957 typedef struct _IMAGE_THUNK_DATA64 {
2958 union {
2959 ULONGLONG ForwarderString;
2960 ULONGLONG Function;
2961 ULONGLONG Ordinal;
2962 ULONGLONG AddressOfData;
2963 } u1;
2964 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
2965 #include <poppack.h>
2967 typedef struct _IMAGE_THUNK_DATA32 {
2968 union {
2969 DWORD ForwarderString;
2970 DWORD Function;
2971 DWORD Ordinal;
2972 DWORD AddressOfData;
2973 } u1;
2974 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
2976 /* Import module directory */
2978 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2979 union {
2980 DWORD Characteristics; /* 0 for terminating null import descriptor */
2981 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
2982 } DUMMYUNIONNAME;
2983 DWORD TimeDateStamp; /* 0 if not bound,
2984 * -1 if bound, and real date\time stamp
2985 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2986 * (new BIND)
2987 * otherwise date/time stamp of DLL bound to
2988 * (Old BIND)
2990 DWORD ForwarderChain; /* -1 if no forwarders */
2991 DWORD Name;
2992 /* RVA to IAT (if bound this IAT has actual addresses) */
2993 DWORD FirstThunk;
2994 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2996 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
2997 #define IMAGE_ORDINAL_FLAG32 0x80000000
2998 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
2999 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3000 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3001 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3003 #ifdef _WIN64
3004 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3005 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3006 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3007 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3008 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3009 #else
3010 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3011 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3012 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3013 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3014 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3015 #endif
3017 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3019 DWORD TimeDateStamp;
3020 WORD OffsetModuleName;
3021 WORD NumberOfModuleForwarderRefs;
3022 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3023 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3025 typedef struct _IMAGE_BOUND_FORWARDER_REF
3027 DWORD TimeDateStamp;
3028 WORD OffsetModuleName;
3029 WORD Reserved;
3030 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3032 typedef struct _IMAGE_BASE_RELOCATION
3034 DWORD VirtualAddress;
3035 DWORD SizeOfBlock;
3036 /* WORD TypeOffset[1]; */
3037 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3039 #include <pshpack2.h>
3041 typedef struct _IMAGE_RELOCATION
3043 union {
3044 DWORD VirtualAddress;
3045 DWORD RelocCount;
3046 } DUMMYUNIONNAME;
3047 DWORD SymbolTableIndex;
3048 WORD Type;
3049 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3051 #include <poppack.h>
3053 #define IMAGE_SIZEOF_RELOCATION 10
3055 /* generic relocation types */
3056 #define IMAGE_REL_BASED_ABSOLUTE 0
3057 #define IMAGE_REL_BASED_HIGH 1
3058 #define IMAGE_REL_BASED_LOW 2
3059 #define IMAGE_REL_BASED_HIGHLOW 3
3060 #define IMAGE_REL_BASED_HIGHADJ 4
3061 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3062 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3063 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3064 #define IMAGE_REL_BASED_SECTION 6
3065 #define IMAGE_REL_BASED_REL 7
3066 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3067 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3068 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3069 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3070 #define IMAGE_REL_BASED_DIR64 10
3071 #define IMAGE_REL_BASED_HIGH3ADJ 11
3073 /* I386 relocation types */
3074 #define IMAGE_REL_I386_ABSOLUTE 0
3075 #define IMAGE_REL_I386_DIR16 1
3076 #define IMAGE_REL_I386_REL16 2
3077 #define IMAGE_REL_I386_DIR32 6
3078 #define IMAGE_REL_I386_DIR32NB 7
3079 #define IMAGE_REL_I386_SEG12 9
3080 #define IMAGE_REL_I386_SECTION 10
3081 #define IMAGE_REL_I386_SECREL 11
3082 #define IMAGE_REL_I386_TOKEN 12
3083 #define IMAGE_REL_I386_SECREL7 13
3084 #define IMAGE_REL_I386_REL32 20
3086 /* MIPS relocation types */
3087 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3088 #define IMAGE_REL_MIPS_REFHALF 0x0001
3089 #define IMAGE_REL_MIPS_REFWORD 0x0002
3090 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3091 #define IMAGE_REL_MIPS_REFHI 0x0004
3092 #define IMAGE_REL_MIPS_REFLO 0x0005
3093 #define IMAGE_REL_MIPS_GPREL 0x0006
3094 #define IMAGE_REL_MIPS_LITERAL 0x0007
3095 #define IMAGE_REL_MIPS_SECTION 0x000A
3096 #define IMAGE_REL_MIPS_SECREL 0x000B
3097 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3098 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3099 #define IMAGE_REL_MIPS_TOKEN 0x000E
3100 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3101 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3102 #define IMAGE_REL_MIPS_PAIR 0x0025
3104 /* ALPHA relocation types */
3105 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3106 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3107 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3108 #define IMAGE_REL_ALPHA_GPREL 0x0003
3109 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3110 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3111 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3112 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3113 #define IMAGE_REL_ALPHA_HINT 0x0008
3114 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3115 #define IMAGE_REL_ALPHA_REFHI 0x000A
3116 #define IMAGE_REL_ALPHA_REFLO 0x000B
3117 #define IMAGE_REL_ALPHA_PAIR 0x000C
3118 #define IMAGE_REL_ALPHA_MATCH 0x000D
3119 #define IMAGE_REL_ALPHA_SECTION 0x000E
3120 #define IMAGE_REL_ALPHA_SECREL 0x000F
3121 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3122 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3123 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3124 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3125 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3126 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3127 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3128 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3130 /* PowerPC relocation types */
3131 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3132 #define IMAGE_REL_PPC_ADDR64 0x0001
3133 #define IMAGE_REL_PPC_ADDR 0x0002
3134 #define IMAGE_REL_PPC_ADDR24 0x0003
3135 #define IMAGE_REL_PPC_ADDR16 0x0004
3136 #define IMAGE_REL_PPC_ADDR14 0x0005
3137 #define IMAGE_REL_PPC_REL24 0x0006
3138 #define IMAGE_REL_PPC_REL14 0x0007
3139 #define IMAGE_REL_PPC_TOCREL16 0x0008
3140 #define IMAGE_REL_PPC_TOCREL14 0x0009
3141 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3142 #define IMAGE_REL_PPC_SECREL 0x000B
3143 #define IMAGE_REL_PPC_SECTION 0x000C
3144 #define IMAGE_REL_PPC_IFGLUE 0x000D
3145 #define IMAGE_REL_PPC_IMGLUE 0x000E
3146 #define IMAGE_REL_PPC_SECREL16 0x000F
3147 #define IMAGE_REL_PPC_REFHI 0x0010
3148 #define IMAGE_REL_PPC_REFLO 0x0011
3149 #define IMAGE_REL_PPC_PAIR 0x0012
3150 #define IMAGE_REL_PPC_SECRELLO 0x0013
3151 #define IMAGE_REL_PPC_SECRELHI 0x0014
3152 #define IMAGE_REL_PPC_GPREL 0x0015
3153 #define IMAGE_REL_PPC_TOKEN 0x0016
3154 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3155 /* modifier bits */
3156 #define IMAGE_REL_PPC_NEG 0x0100
3157 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3158 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3159 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3161 /* SH3 relocation types */
3162 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3163 #define IMAGE_REL_SH3_DIRECT16 0x0001
3164 #define IMAGE_REL_SH3_DIRECT 0x0002
3165 #define IMAGE_REL_SH3_DIRECT8 0x0003
3166 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3167 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3168 #define IMAGE_REL_SH3_DIRECT4 0x0006
3169 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3170 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3171 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3172 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3173 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3174 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3175 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3176 #define IMAGE_REL_SH3_SECTION 0x000E
3177 #define IMAGE_REL_SH3_SECREL 0x000F
3178 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3179 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3180 #define IMAGE_REL_SH3_TOKEN 0x0012
3182 /* ARM relocation types */
3183 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3184 #define IMAGE_REL_ARM_ADDR 0x0001
3185 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3186 #define IMAGE_REL_ARM_BRANCH24 0x0003
3187 #define IMAGE_REL_ARM_BRANCH11 0x0004
3188 #define IMAGE_REL_ARM_TOKEN 0x0005
3189 #define IMAGE_REL_ARM_GPREL12 0x0006
3190 #define IMAGE_REL_ARM_GPREL7 0x0007
3191 #define IMAGE_REL_ARM_BLX24 0x0008
3192 #define IMAGE_REL_ARM_BLX11 0x0009
3193 #define IMAGE_REL_ARM_SECTION 0x000E
3194 #define IMAGE_REL_ARM_SECREL 0x000F
3195 #define IMAGE_REL_ARM_MOV32A 0x0010
3196 #define IMAGE_REL_ARM_MOV32T 0x0011
3197 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3198 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3199 #define IMAGE_REL_ARM_BLX23T 0x0015
3201 /* IA64 relocation types */
3202 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3203 #define IMAGE_REL_IA64_IMM14 0x0001
3204 #define IMAGE_REL_IA64_IMM22 0x0002
3205 #define IMAGE_REL_IA64_IMM64 0x0003
3206 #define IMAGE_REL_IA64_DIR 0x0004
3207 #define IMAGE_REL_IA64_DIR64 0x0005
3208 #define IMAGE_REL_IA64_PCREL21B 0x0006
3209 #define IMAGE_REL_IA64_PCREL21M 0x0007
3210 #define IMAGE_REL_IA64_PCREL21F 0x0008
3211 #define IMAGE_REL_IA64_GPREL22 0x0009
3212 #define IMAGE_REL_IA64_LTOFF22 0x000A
3213 #define IMAGE_REL_IA64_SECTION 0x000B
3214 #define IMAGE_REL_IA64_SECREL22 0x000C
3215 #define IMAGE_REL_IA64_SECREL64I 0x000D
3216 #define IMAGE_REL_IA64_SECREL 0x000E
3217 #define IMAGE_REL_IA64_LTOFF64 0x000F
3218 #define IMAGE_REL_IA64_DIR32NB 0x0010
3219 #define IMAGE_REL_IA64_SREL14 0x0011
3220 #define IMAGE_REL_IA64_SREL22 0x0012
3221 #define IMAGE_REL_IA64_SREL32 0x0013
3222 #define IMAGE_REL_IA64_UREL32 0x0014
3223 #define IMAGE_REL_IA64_PCREL60X 0x0015
3224 #define IMAGE_REL_IA64_PCREL60B 0x0016
3225 #define IMAGE_REL_IA64_PCREL60F 0x0017
3226 #define IMAGE_REL_IA64_PCREL60I 0x0018
3227 #define IMAGE_REL_IA64_PCREL60M 0x0019
3228 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3229 #define IMAGE_REL_IA64_TOKEN 0x001B
3230 #define IMAGE_REL_IA64_GPREL32 0x001C
3231 #define IMAGE_REL_IA64_ADDEND 0x001F
3233 /* AMD64 relocation types */
3234 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3235 #define IMAGE_REL_AMD64_ADDR64 0x0001
3236 #define IMAGE_REL_AMD64_ADDR32 0x0002
3237 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3238 #define IMAGE_REL_AMD64_REL32 0x0004
3239 #define IMAGE_REL_AMD64_REL32_1 0x0005
3240 #define IMAGE_REL_AMD64_REL32_2 0x0006
3241 #define IMAGE_REL_AMD64_REL32_3 0x0007
3242 #define IMAGE_REL_AMD64_REL32_4 0x0008
3243 #define IMAGE_REL_AMD64_REL32_5 0x0009
3244 #define IMAGE_REL_AMD64_SECTION 0x000A
3245 #define IMAGE_REL_AMD64_SECREL 0x000B
3246 #define IMAGE_REL_AMD64_SECREL7 0x000C
3247 #define IMAGE_REL_AMD64_TOKEN 0x000D
3248 #define IMAGE_REL_AMD64_SREL32 0x000E
3249 #define IMAGE_REL_AMD64_PAIR 0x000F
3250 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3252 /* archive format */
3254 #define IMAGE_ARCHIVE_START_SIZE 8
3255 #define IMAGE_ARCHIVE_START "!<arch>\n"
3256 #define IMAGE_ARCHIVE_END "`\n"
3257 #define IMAGE_ARCHIVE_PAD "\n"
3258 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3259 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3261 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3263 BYTE Name[16];
3264 BYTE Date[12];
3265 BYTE UserID[6];
3266 BYTE GroupID[6];
3267 BYTE Mode[8];
3268 BYTE Size[10];
3269 BYTE EndHeader[2];
3270 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3272 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3274 typedef struct _IMPORT_OBJECT_HEADER
3276 WORD Sig1;
3277 WORD Sig2;
3278 WORD Version;
3279 WORD Machine;
3280 DWORD TimeDateStamp;
3281 DWORD SizeOfData;
3282 union
3284 WORD Ordinal;
3285 WORD Hint;
3286 } DUMMYUNIONNAME;
3287 WORD Type : 2;
3288 WORD NameType : 3;
3289 WORD Reserved : 11;
3290 } IMPORT_OBJECT_HEADER;
3292 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3294 typedef enum IMPORT_OBJECT_TYPE
3296 IMPORT_OBJECT_CODE = 0,
3297 IMPORT_OBJECT_DATA = 1,
3298 IMPORT_OBJECT_CONST = 2
3299 } IMPORT_OBJECT_TYPE;
3301 typedef enum IMPORT_OBJECT_NAME_TYPE
3303 IMPORT_OBJECT_ORDINAL = 0,
3304 IMPORT_OBJECT_NAME = 1,
3305 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3306 IMPORT_OBJECT_NAME_UNDECORATE = 3
3307 } IMPORT_OBJECT_NAME_TYPE;
3309 typedef struct _ANON_OBJECT_HEADER
3311 WORD Sig1;
3312 WORD Sig2;
3313 WORD Version;
3314 WORD Machine;
3315 DWORD TimeDateStamp;
3316 CLSID ClassID;
3317 DWORD SizeOfData;
3318 } ANON_OBJECT_HEADER;
3321 * Resource directory stuff
3323 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3324 DWORD Characteristics;
3325 DWORD TimeDateStamp;
3326 WORD MajorVersion;
3327 WORD MinorVersion;
3328 WORD NumberOfNamedEntries;
3329 WORD NumberOfIdEntries;
3330 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3331 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3333 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3334 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3336 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3337 union {
3338 struct {
3339 #ifdef BITFIELDS_BIGENDIAN
3340 unsigned NameIsString:1;
3341 unsigned NameOffset:31;
3342 #else
3343 unsigned NameOffset:31;
3344 unsigned NameIsString:1;
3345 #endif
3346 } DUMMYSTRUCTNAME;
3347 DWORD Name;
3348 #ifdef WORDS_BIGENDIAN
3349 WORD __pad;
3350 WORD Id;
3351 #else
3352 WORD Id;
3353 WORD __pad;
3354 #endif
3355 } DUMMYUNIONNAME;
3356 union {
3357 DWORD OffsetToData;
3358 struct {
3359 #ifdef BITFIELDS_BIGENDIAN
3360 unsigned DataIsDirectory:1;
3361 unsigned OffsetToDirectory:31;
3362 #else
3363 unsigned OffsetToDirectory:31;
3364 unsigned DataIsDirectory:1;
3365 #endif
3366 } DUMMYSTRUCTNAME2;
3367 } DUMMYUNIONNAME2;
3368 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3371 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3372 WORD Length;
3373 CHAR NameString[ 1 ];
3374 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3376 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3377 WORD Length;
3378 WCHAR NameString[ 1 ];
3379 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3381 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3382 DWORD OffsetToData;
3383 DWORD Size;
3384 DWORD CodePage;
3385 DWORD Reserved;
3386 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3389 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3390 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3393 typedef struct _IMAGE_TLS_DIRECTORY64 {
3394 ULONGLONG StartAddressOfRawData;
3395 ULONGLONG EndAddressOfRawData;
3396 ULONGLONG AddressOfIndex;
3397 ULONGLONG AddressOfCallBacks;
3398 DWORD SizeOfZeroFill;
3399 DWORD Characteristics;
3400 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3402 typedef struct _IMAGE_TLS_DIRECTORY32 {
3403 DWORD StartAddressOfRawData;
3404 DWORD EndAddressOfRawData;
3405 DWORD AddressOfIndex;
3406 DWORD AddressOfCallBacks;
3407 DWORD SizeOfZeroFill;
3408 DWORD Characteristics;
3409 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3411 #ifdef _WIN64
3412 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3413 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3414 #else
3415 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3416 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3417 #endif
3419 typedef struct _IMAGE_DEBUG_DIRECTORY {
3420 DWORD Characteristics;
3421 DWORD TimeDateStamp;
3422 WORD MajorVersion;
3423 WORD MinorVersion;
3424 DWORD Type;
3425 DWORD SizeOfData;
3426 DWORD AddressOfRawData;
3427 DWORD PointerToRawData;
3428 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3430 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3431 #define IMAGE_DEBUG_TYPE_COFF 1
3432 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3433 #define IMAGE_DEBUG_TYPE_FPO 3
3434 #define IMAGE_DEBUG_TYPE_MISC 4
3435 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3436 #define IMAGE_DEBUG_TYPE_FIXUP 6
3437 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3438 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3439 #define IMAGE_DEBUG_TYPE_BORLAND 9
3440 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3441 #define IMAGE_DEBUG_TYPE_CLSID 11
3443 typedef enum ReplacesCorHdrNumericDefines
3445 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3446 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3447 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3448 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3449 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3451 COR_VERSION_MAJOR_V2 = 2,
3452 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3453 COR_VERSION_MINOR = 0,
3454 COR_DELETED_NAME_LENGTH = 8,
3455 COR_VTABLEGAP_NAME_LENGTH = 8,
3457 NATIVE_TYPE_MAX_CB = 1,
3458 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3460 IMAGE_COR_MIH_METHODRVA = 0x01,
3461 IMAGE_COR_MIH_EHRVA = 0x02,
3462 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3464 COR_VTABLE_32BIT = 0x01,
3465 COR_VTABLE_64BIT = 0x02,
3466 COR_VTABLE_FROM_UNMANAGED = 0x04,
3467 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3469 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3471 MAX_CLASS_NAME = 1024,
3472 MAX_PACKAGE_NAME = 1024,
3473 } ReplacesCorHdrNumericDefines;
3475 typedef struct IMAGE_COR20_HEADER
3477 DWORD cb;
3478 WORD MajorRuntimeVersion;
3479 WORD MinorRuntimeVersion;
3481 IMAGE_DATA_DIRECTORY MetaData;
3482 DWORD Flags;
3483 union {
3484 DWORD EntryPointToken;
3485 DWORD EntryPointRVA;
3486 } DUMMYUNIONNAME;
3488 IMAGE_DATA_DIRECTORY Resources;
3489 IMAGE_DATA_DIRECTORY StrongNameSignature;
3490 IMAGE_DATA_DIRECTORY CodeManagerTable;
3491 IMAGE_DATA_DIRECTORY VTableFixups;
3492 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3493 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3495 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3497 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3498 DWORD NumberOfSymbols;
3499 DWORD LvaToFirstSymbol;
3500 DWORD NumberOfLinenumbers;
3501 DWORD LvaToFirstLinenumber;
3502 DWORD RvaToFirstByteOfCode;
3503 DWORD RvaToLastByteOfCode;
3504 DWORD RvaToFirstByteOfData;
3505 DWORD RvaToLastByteOfData;
3506 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3508 #define FRAME_FPO 0
3509 #define FRAME_TRAP 1
3510 #define FRAME_TSS 2
3511 #define FRAME_NONFPO 3
3513 typedef struct _FPO_DATA {
3514 DWORD ulOffStart;
3515 DWORD cbProcSize;
3516 DWORD cdwLocals;
3517 WORD cdwParams;
3518 WORD cbProlog : 8;
3519 WORD cbRegs : 3;
3520 WORD fHasSEH : 1;
3521 WORD fUseBP : 1;
3522 WORD reserved : 1;
3523 WORD cbFrame : 2;
3524 } FPO_DATA, *PFPO_DATA;
3526 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
3527 DWORD Size;
3528 DWORD TimeDateStamp;
3529 WORD MajorVersion;
3530 WORD MinorVersion;
3531 DWORD GlobalFlagsClear;
3532 DWORD GlobalFlagsSet;
3533 DWORD CriticalSectionDefaultTimeout;
3534 DWORD DeCommitFreeBlockThreshold;
3535 DWORD DeCommitTotalFreeThreshold;
3536 PVOID LockPrefixTable;
3537 DWORD MaximumAllocationSize;
3538 DWORD VirtualMemoryThreshold;
3539 DWORD ProcessHeapFlags;
3540 DWORD ProcessAffinityMask;
3541 WORD CSDVersion;
3542 WORD Reserved1;
3543 PVOID EditList;
3544 DWORD SecurityCookie;
3545 DWORD SEHandlerTable;
3546 DWORD SEHandlerCount;
3547 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
3549 typedef struct _IMAGE_FUNCTION_ENTRY {
3550 DWORD StartingAddress;
3551 DWORD EndingAddress;
3552 DWORD EndOfPrologue;
3553 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3555 #define IMAGE_DEBUG_MISC_EXENAME 1
3557 typedef struct _IMAGE_DEBUG_MISC {
3558 DWORD DataType;
3559 DWORD Length;
3560 BYTE Unicode;
3561 BYTE Reserved[ 3 ];
3562 BYTE Data[ 1 ];
3563 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3565 /* This is the structure that appears at the very start of a .DBG file. */
3567 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3568 WORD Signature;
3569 WORD Flags;
3570 WORD Machine;
3571 WORD Characteristics;
3572 DWORD TimeDateStamp;
3573 DWORD CheckSum;
3574 DWORD ImageBase;
3575 DWORD SizeOfImage;
3576 DWORD NumberOfSections;
3577 DWORD ExportedNamesSize;
3578 DWORD DebugDirectorySize;
3579 DWORD SectionAlignment;
3580 DWORD Reserved[ 2 ];
3581 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3583 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3586 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3587 WORD Length;
3588 WORD Flags;
3589 BYTE Text[1];
3590 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3591 #define MESSAGE_RESOURCE_UNICODE 0x0001
3593 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3594 DWORD LowId;
3595 DWORD HighId;
3596 DWORD OffsetToEntries;
3597 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3599 typedef struct tagMESSAGE_RESOURCE_DATA {
3600 DWORD NumberOfBlocks;
3601 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
3602 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3605 * Here follows typedefs for security and tokens.
3609 * First a constant for the following typedefs.
3612 #define ANYSIZE_ARRAY 1
3614 /* FIXME: Orphan. What does it point to? */
3615 typedef PVOID PACCESS_TOKEN;
3616 typedef PVOID PSECURITY_DESCRIPTOR;
3617 typedef PVOID PSID;
3619 typedef enum _TOKEN_ELEVATION_TYPE {
3620 TokenElevationTypeDefault = 1,
3621 TokenElevationTypeFull,
3622 TokenElevationTypeLimited
3623 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
3626 * TOKEN_INFORMATION_CLASS
3629 typedef enum _TOKEN_INFORMATION_CLASS {
3630 TokenUser = 1,
3631 TokenGroups,
3632 TokenPrivileges,
3633 TokenOwner,
3634 TokenPrimaryGroup,
3635 TokenDefaultDacl,
3636 TokenSource,
3637 TokenType,
3638 TokenImpersonationLevel,
3639 TokenStatistics,
3640 TokenRestrictedSids,
3641 TokenSessionId,
3642 TokenGroupsAndPrivileges,
3643 TokenSessionReference,
3644 TokenSandBoxInert,
3645 TokenAuditPolicy,
3646 TokenOrigin,
3647 TokenElevationType,
3648 TokenLinkedToken,
3649 TokenElevation,
3650 TokenHasRestrictions,
3651 TokenAccessInformation,
3652 TokenVirtualizationAllowed,
3653 TokenVirtualizationEnabled,
3654 TokenIntegrityLevel,
3655 TokenUIAccess,
3656 TokenMandatoryPolicy,
3657 TokenLogonSid,
3658 MaxTokenInfoClass
3659 } TOKEN_INFORMATION_CLASS;
3661 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
3662 #define TOKEN_ADJUST_GROUPS 0x0040
3663 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3664 #define TOKEN_ADJUST_SESSIONID 0x0100
3665 #define TOKEN_ASSIGN_PRIMARY 0x0001
3666 #define TOKEN_DUPLICATE 0x0002
3667 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3668 #define TOKEN_IMPERSONATE 0x0004
3669 #define TOKEN_QUERY 0x0008
3670 #define TOKEN_QUERY_SOURCE 0x0010
3671 #define TOKEN_ADJUST_DEFAULT 0x0080
3672 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3673 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3674 TOKEN_ADJUST_PRIVILEGES | \
3675 TOKEN_ADJUST_GROUPS | \
3676 TOKEN_ADJUST_DEFAULT )
3677 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3678 TOKEN_ASSIGN_PRIMARY | \
3679 TOKEN_DUPLICATE | \
3680 TOKEN_IMPERSONATE | \
3681 TOKEN_QUERY | \
3682 TOKEN_QUERY_SOURCE | \
3683 TOKEN_ADJUST_PRIVILEGES | \
3684 TOKEN_ADJUST_GROUPS | \
3685 TOKEN_ADJUST_SESSIONID | \
3686 TOKEN_ADJUST_DEFAULT )
3688 #ifndef _SECURITY_DEFINED
3689 #define _SECURITY_DEFINED
3692 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3694 typedef struct _GENERIC_MAPPING {
3695 ACCESS_MASK GenericRead;
3696 ACCESS_MASK GenericWrite;
3697 ACCESS_MASK GenericExecute;
3698 ACCESS_MASK GenericAll;
3699 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3701 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3702 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3703 typedef struct {
3704 BYTE Value[6];
3705 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
3706 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3708 #ifndef SID_DEFINED
3709 #define SID_DEFINED
3710 typedef struct _SID {
3711 BYTE Revision;
3712 BYTE SubAuthorityCount;
3713 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3714 DWORD SubAuthority[1];
3715 } SID,*PISID;
3716 #endif /* !defined(SID_DEFINED) */
3718 #define SID_REVISION (1) /* Current revision */
3719 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3720 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3722 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3725 * ACL
3728 #define ACL_REVISION1 1
3729 #define ACL_REVISION2 2
3730 #define ACL_REVISION3 3
3731 #define ACL_REVISION4 4
3733 #define MIN_ACL_REVISION ACL_REVISION2
3734 #define MAX_ACL_REVISION ACL_REVISION4
3736 #define ACL_REVISION 2
3738 typedef struct _ACL {
3739 BYTE AclRevision;
3740 BYTE Sbz1;
3741 WORD AclSize;
3742 WORD AceCount;
3743 WORD Sbz2;
3744 } ACL, *PACL;
3746 typedef enum _ACL_INFORMATION_CLASS
3748 AclRevisionInformation = 1,
3749 AclSizeInformation
3750 } ACL_INFORMATION_CLASS;
3752 typedef struct _ACL_REVISION_INFORMATION
3754 DWORD AclRevision;
3755 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
3757 typedef struct _ACL_SIZE_INFORMATION
3759 DWORD AceCount;
3760 DWORD AclBytesInUse;
3761 DWORD AclBytesFree;
3762 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
3764 /* SECURITY_DESCRIPTOR */
3765 #define SECURITY_DESCRIPTOR_REVISION 1
3766 #define SECURITY_DESCRIPTOR_REVISION1 1
3770 * Privilege Names
3772 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
3773 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
3774 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
3775 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
3776 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
3777 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
3778 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
3779 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
3780 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
3781 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
3782 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
3783 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
3784 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
3785 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
3786 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
3787 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
3788 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
3789 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
3790 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
3791 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
3792 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
3793 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
3794 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
3795 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
3796 #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
3797 #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
3798 #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
3799 #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
3800 #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
3802 #define SE_GROUP_MANDATORY 0x00000001
3803 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
3804 #define SE_GROUP_ENABLED 0x00000004
3805 #define SE_GROUP_OWNER 0x00000008
3806 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
3807 #define SE_GROUP_INTEGRITY 0x00000020
3808 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
3809 #define SE_GROUP_LOGON_ID 0xC0000000
3810 #define SE_GROUP_RESOURCE 0x20000000
3811 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
3813 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
3814 #define SE_PRIVILEGE_ENABLED 0x00000002
3815 #define SE_PRIVILEGE_REMOVED 0x00000004
3816 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
3818 #define PRIVILEGE_SET_ALL_NECESSARY 1
3820 #define SE_OWNER_DEFAULTED 0x00000001
3821 #define SE_GROUP_DEFAULTED 0x00000002
3822 #define SE_DACL_PRESENT 0x00000004
3823 #define SE_DACL_DEFAULTED 0x00000008
3824 #define SE_SACL_PRESENT 0x00000010
3825 #define SE_SACL_DEFAULTED 0x00000020
3826 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
3827 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
3828 #define SE_DACL_AUTO_INHERITED 0x00000400
3829 #define SE_SACL_AUTO_INHERITED 0x00000800
3830 #define SE_DACL_PROTECTED 0x00001000
3831 #define SE_SACL_PROTECTED 0x00002000
3832 #define SE_RM_CONTROL_VALID 0x00004000
3833 #define SE_SELF_RELATIVE 0x00008000
3835 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
3836 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
3838 /* The security descriptor structure */
3839 typedef struct {
3840 BYTE Revision;
3841 BYTE Sbz1;
3842 SECURITY_DESCRIPTOR_CONTROL Control;
3843 DWORD Owner;
3844 DWORD Group;
3845 DWORD Sacl;
3846 DWORD Dacl;
3847 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
3849 typedef struct {
3850 BYTE Revision;
3851 BYTE Sbz1;
3852 SECURITY_DESCRIPTOR_CONTROL Control;
3853 PSID Owner;
3854 PSID Group;
3855 PACL Sacl;
3856 PACL Dacl;
3857 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
3859 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
3861 #endif /* _SECURITY_DEFINED */
3864 * SID_AND_ATTRIBUTES
3867 typedef struct _SID_AND_ATTRIBUTES {
3868 PSID Sid;
3869 DWORD Attributes;
3870 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
3872 /* security entities */
3873 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
3874 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
3875 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
3877 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
3879 /* S-1-1 */
3880 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
3882 /* S-1-2 */
3883 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
3885 /* S-1-3 */
3886 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
3887 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
3888 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
3889 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
3890 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
3892 /* S-1-4 */
3893 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
3895 /* S-1-5 */
3896 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
3897 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
3898 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
3899 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
3900 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
3901 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
3902 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
3903 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
3904 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
3905 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
3906 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
3907 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
3908 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
3909 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
3910 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
3911 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
3912 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
3913 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
3914 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
3915 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
3916 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
3917 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
3919 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
3920 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
3921 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
3922 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
3923 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
3924 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
3925 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
3927 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
3928 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
3929 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
3930 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
3931 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
3933 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
3934 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
3935 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
3936 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
3937 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
3938 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
3939 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
3940 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
3941 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
3943 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
3944 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
3945 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
3946 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
3947 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
3948 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
3949 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
3951 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
3952 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
3953 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
3954 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
3956 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
3957 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
3958 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
3959 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
3961 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
3962 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
3963 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
3964 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
3965 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
3966 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
3968 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
3969 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
3970 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
3971 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
3972 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
3974 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
3976 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
3977 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
3979 typedef enum {
3980 WinNullSid = 0,
3981 WinWorldSid = 1,
3982 WinLocalSid = 2,
3983 WinCreatorOwnerSid = 3,
3984 WinCreatorGroupSid = 4,
3985 WinCreatorOwnerServerSid = 5,
3986 WinCreatorGroupServerSid = 6,
3987 WinNtAuthoritySid = 7,
3988 WinDialupSid = 8,
3989 WinNetworkSid = 9,
3990 WinBatchSid = 10,
3991 WinInteractiveSid = 11,
3992 WinServiceSid = 12,
3993 WinAnonymousSid = 13,
3994 WinProxySid = 14,
3995 WinEnterpriseControllersSid = 15,
3996 WinSelfSid = 16,
3997 WinAuthenticatedUserSid = 17,
3998 WinRestrictedCodeSid = 18,
3999 WinTerminalServerSid = 19,
4000 WinRemoteLogonIdSid = 20,
4001 WinLogonIdsSid = 21,
4002 WinLocalSystemSid = 22,
4003 WinLocalServiceSid = 23,
4004 WinNetworkServiceSid = 24,
4005 WinBuiltinDomainSid = 25,
4006 WinBuiltinAdministratorsSid = 26,
4007 WinBuiltinUsersSid = 27,
4008 WinBuiltinGuestsSid = 28,
4009 WinBuiltinPowerUsersSid = 29,
4010 WinBuiltinAccountOperatorsSid = 30,
4011 WinBuiltinSystemOperatorsSid = 31,
4012 WinBuiltinPrintOperatorsSid = 32,
4013 WinBuiltinBackupOperatorsSid = 33,
4014 WinBuiltinReplicatorSid = 34,
4015 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4016 WinBuiltinRemoteDesktopUsersSid = 36,
4017 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4018 WinAccountAdministratorSid = 38,
4019 WinAccountGuestSid = 39,
4020 WinAccountKrbtgtSid = 40,
4021 WinAccountDomainAdminsSid = 41,
4022 WinAccountDomainUsersSid = 42,
4023 WinAccountDomainGuestsSid = 43,
4024 WinAccountComputersSid = 44,
4025 WinAccountControllersSid = 45,
4026 WinAccountCertAdminsSid = 46,
4027 WinAccountSchemaAdminsSid = 47,
4028 WinAccountEnterpriseAdminsSid = 48,
4029 WinAccountPolicyAdminsSid = 49,
4030 WinAccountRasAndIasServersSid = 50,
4031 WinNTLMAuthenticationSid = 51,
4032 WinDigestAuthenticationSid = 52,
4033 WinSChannelAuthenticationSid = 53,
4034 WinThisOrganizationSid = 54,
4035 WinOtherOrganizationSid = 55,
4036 WinBuiltinIncomingForestTrustBuildersSid = 56,
4037 WinBuiltinPerfMonitoringUsersSid = 57,
4038 WinBuiltinPerfLoggingUsersSid = 58,
4039 WinBuiltinAuthorizationAccessSid = 59,
4040 WinBuiltinTerminalServerLicenseServersSid = 60,
4041 WinBuiltinDCOMUsersSid = 61,
4042 WinBuiltinIUsersSid = 62,
4043 WinIUserSid = 63,
4044 WinBuiltinCryptoOperatorsSid = 64,
4045 WinUntrustedLabelSid = 65,
4046 WinLowLabelSid = 66,
4047 WinMediumLabelSid = 67,
4048 WinHighLabelSid = 68,
4049 WinSystemLabelSid = 69,
4050 WinWriteRestrictedCodeSid = 70,
4051 WinCreatorOwnerRightsSid = 71,
4052 WinCacheablePrincipalsGroupSid = 72,
4053 WinNonCacheablePrincipalsGroupSid = 73,
4054 WinEnterpriseReadonlyControllersSid = 74,
4055 WinAccountReadonlyControllersSid = 75,
4056 WinBuiltinEventLogReadersGroup = 76,
4057 WinNewEnterpriseReadonlyControllersSid = 77,
4058 WinBuiltinCertSvcDComAccessGroup = 78,
4059 WinMediumPlusLabelSid = 79,
4060 WinLocalLogonSid = 80,
4061 WinConsoleLogonSid = 81,
4062 WinThisOrganizationCertificateSid = 82,
4063 } WELL_KNOWN_SID_TYPE;
4066 * TOKEN_USER
4069 typedef struct _TOKEN_USER {
4070 SID_AND_ATTRIBUTES User;
4071 } TOKEN_USER, *PTOKEN_USER;
4074 * TOKEN_GROUPS
4077 typedef struct _TOKEN_GROUPS {
4078 DWORD GroupCount;
4079 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4080 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4083 * LUID_AND_ATTRIBUTES
4086 typedef union _LARGE_INTEGER {
4087 struct {
4088 #ifdef WORDS_BIGENDIAN
4089 LONG HighPart;
4090 DWORD LowPart;
4091 #else
4092 DWORD LowPart;
4093 LONG HighPart;
4094 #endif
4095 } u;
4096 #ifndef NONAMELESSSTRUCT
4097 struct {
4098 #ifdef WORDS_BIGENDIAN
4099 LONG HighPart;
4100 DWORD LowPart;
4101 #else
4102 DWORD LowPart;
4103 LONG HighPart;
4104 #endif
4106 #endif
4107 LONGLONG QuadPart;
4108 } LARGE_INTEGER, *PLARGE_INTEGER;
4110 typedef union _ULARGE_INTEGER {
4111 struct {
4112 #ifdef WORDS_BIGENDIAN
4113 DWORD HighPart;
4114 DWORD LowPart;
4115 #else
4116 DWORD LowPart;
4117 DWORD HighPart;
4118 #endif
4119 } u;
4120 #ifndef NONAMELESSSTRUCT
4121 struct {
4122 #ifdef WORDS_BIGENDIAN
4123 DWORD HighPart;
4124 DWORD LowPart;
4125 #else
4126 DWORD LowPart;
4127 DWORD HighPart;
4128 #endif
4130 #endif
4131 ULONGLONG QuadPart;
4132 } ULARGE_INTEGER, *PULARGE_INTEGER;
4135 * Locally Unique Identifier
4138 typedef struct _LUID {
4139 DWORD LowPart;
4140 LONG HighPart;
4141 } LUID, *PLUID;
4143 #include <pshpack4.h>
4144 typedef struct _LUID_AND_ATTRIBUTES {
4145 LUID Luid;
4146 DWORD Attributes;
4147 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4148 #include <poppack.h>
4151 * PRIVILEGE_SET
4154 typedef struct _PRIVILEGE_SET {
4155 DWORD PrivilegeCount;
4156 DWORD Control;
4157 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4158 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4161 * TOKEN_PRIVILEGES
4164 typedef struct _TOKEN_PRIVILEGES {
4165 DWORD PrivilegeCount;
4166 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4167 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4170 * TOKEN_OWNER
4173 typedef struct _TOKEN_OWNER {
4174 PSID Owner;
4175 } TOKEN_OWNER, *PTOKEN_OWNER;
4178 * TOKEN_PRIMARY_GROUP
4181 typedef struct _TOKEN_PRIMARY_GROUP {
4182 PSID PrimaryGroup;
4183 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4187 * TOKEN_DEFAULT_DACL
4190 typedef struct _TOKEN_DEFAULT_DACL {
4191 PACL DefaultDacl;
4192 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4195 * TOKEN_SOURCE
4198 #define TOKEN_SOURCE_LENGTH 8
4200 typedef struct _TOKEN_SOURCE {
4201 char SourceName[TOKEN_SOURCE_LENGTH];
4202 LUID SourceIdentifier;
4203 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4206 * TOKEN_TYPE
4209 typedef enum tagTOKEN_TYPE {
4210 TokenPrimary = 1,
4211 TokenImpersonation
4212 } TOKEN_TYPE;
4215 * SECURITY_IMPERSONATION_LEVEL
4218 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4219 SecurityAnonymous,
4220 SecurityIdentification,
4221 SecurityImpersonation,
4222 SecurityDelegation
4223 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4225 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4226 #define SECURITY_STATIC_TRACKING (FALSE)
4228 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4229 * PSECURITY_CONTEXT_TRACKING_MODE;
4231 * Quality of Service
4234 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4235 DWORD Length;
4236 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4237 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4238 BOOLEAN EffectiveOnly;
4239 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4242 * TOKEN_STATISTICS
4245 #include <pshpack4.h>
4246 typedef struct _TOKEN_STATISTICS {
4247 LUID TokenId;
4248 LUID AuthenticationId;
4249 LARGE_INTEGER ExpirationTime;
4250 TOKEN_TYPE TokenType;
4251 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4252 DWORD DynamicCharged;
4253 DWORD DynamicAvailable;
4254 DWORD GroupCount;
4255 DWORD PrivilegeCount;
4256 LUID ModifiedId;
4257 } TOKEN_STATISTICS;
4258 #include <poppack.h>
4260 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4261 DWORD SidCount;
4262 DWORD SidLength;
4263 PSID_AND_ATTRIBUTES Sids;
4264 DWORD RestrictedSidCount;
4265 DWORD RestrictedSidLength;
4266 PSID_AND_ATTRIBUTES RestrictedSids;
4267 DWORD PrivilegeCount;
4268 DWORD PrivilegeLength;
4269 PLUID_AND_ATTRIBUTES Privileges;
4270 LUID AuthenticationId;
4271 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4273 typedef struct _TOKEN_ORIGIN {
4274 LUID OriginatingLogonSession;
4275 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4277 typedef struct _TOKEN_LINKED_TOKEN {
4278 HANDLE LinkedToken;
4279 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4281 typedef struct _TOKEN_ELEVATION {
4282 DWORD TokenIsElevated;
4283 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
4285 typedef struct _TOKEN_MANDATORY_LABEL {
4286 SID_AND_ATTRIBUTES Label;
4287 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
4290 * ACLs of NT
4293 /* ACEs, directly starting after an ACL */
4294 typedef struct _ACE_HEADER {
4295 BYTE AceType;
4296 BYTE AceFlags;
4297 WORD AceSize;
4298 } ACE_HEADER,*PACE_HEADER;
4300 /* AceType */
4301 #define ACCESS_ALLOWED_ACE_TYPE 0
4302 #define ACCESS_DENIED_ACE_TYPE 1
4303 #define SYSTEM_AUDIT_ACE_TYPE 2
4304 #define SYSTEM_ALARM_ACE_TYPE 3
4306 /* inherit AceFlags */
4307 #define OBJECT_INHERIT_ACE 0x01
4308 #define CONTAINER_INHERIT_ACE 0x02
4309 #define NO_PROPAGATE_INHERIT_ACE 0x04
4310 #define INHERIT_ONLY_ACE 0x08
4311 #define INHERITED_ACE 0x10
4312 #define VALID_INHERIT_FLAGS 0x1F
4314 /* AceFlags mask for what events we (should) audit */
4315 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4316 #define FAILED_ACCESS_ACE_FLAG 0x80
4318 /* different ACEs depending on AceType
4319 * SidStart marks the begin of a SID
4320 * so the thing finally looks like this:
4321 * 0: ACE_HEADER
4322 * 4: ACCESS_MASK
4323 * 8... : SID
4325 typedef struct _ACCESS_ALLOWED_ACE {
4326 ACE_HEADER Header;
4327 DWORD Mask;
4328 DWORD SidStart;
4329 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
4331 typedef struct _ACCESS_DENIED_ACE {
4332 ACE_HEADER Header;
4333 DWORD Mask;
4334 DWORD SidStart;
4335 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
4337 typedef struct _SYSTEM_AUDIT_ACE {
4338 ACE_HEADER Header;
4339 DWORD Mask;
4340 DWORD SidStart;
4341 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
4343 typedef struct _SYSTEM_ALARM_ACE {
4344 ACE_HEADER Header;
4345 DWORD Mask;
4346 DWORD SidStart;
4347 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
4349 typedef enum tagSID_NAME_USE {
4350 SidTypeUser = 1,
4351 SidTypeGroup,
4352 SidTypeDomain,
4353 SidTypeAlias,
4354 SidTypeWellKnownGroup,
4355 SidTypeDeletedAccount,
4356 SidTypeInvalid,
4357 SidTypeUnknown
4358 } SID_NAME_USE,*PSID_NAME_USE;
4360 #define ACE_OBJECT_TYPE_PRESENT 0x1
4361 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4363 /* Access rights */
4365 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4366 #undef DELETE
4367 #define DELETE 0x00010000
4368 #define READ_CONTROL 0x00020000
4369 #define WRITE_DAC 0x00040000
4370 #define WRITE_OWNER 0x00080000
4371 #define SYNCHRONIZE 0x00100000
4372 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4374 #define STANDARD_RIGHTS_READ READ_CONTROL
4375 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4376 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4378 #define STANDARD_RIGHTS_ALL 0x001f0000
4380 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4382 #define GENERIC_READ 0x80000000
4383 #define GENERIC_WRITE 0x40000000
4384 #define GENERIC_EXECUTE 0x20000000
4385 #define GENERIC_ALL 0x10000000
4387 #define MAXIMUM_ALLOWED 0x02000000
4388 #define ACCESS_SYSTEM_SECURITY 0x01000000
4390 #define EVENT_QUERY_STATE 0x0001
4391 #define EVENT_MODIFY_STATE 0x0002
4392 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4394 #define SEMAPHORE_MODIFY_STATE 0x0002
4395 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4397 #define MUTANT_QUERY_STATE 0x0001
4398 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
4400 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
4401 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
4402 #define JOB_OBJECT_QUERY 0x0004
4403 #define JOB_OBJECT_TERMINATE 0x0008
4404 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
4405 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
4407 #define TIMER_QUERY_STATE 0x0001
4408 #define TIMER_MODIFY_STATE 0x0002
4409 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4411 #define PROCESS_TERMINATE 0x0001
4412 #define PROCESS_CREATE_THREAD 0x0002
4413 #define PROCESS_VM_OPERATION 0x0008
4414 #define PROCESS_VM_READ 0x0010
4415 #define PROCESS_VM_WRITE 0x0020
4416 #define PROCESS_DUP_HANDLE 0x0040
4417 #define PROCESS_CREATE_PROCESS 0x0080
4418 #define PROCESS_SET_QUOTA 0x0100
4419 #define PROCESS_SET_INFORMATION 0x0200
4420 #define PROCESS_QUERY_INFORMATION 0x0400
4421 #define PROCESS_SUSPEND_RESUME 0x0800
4422 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
4423 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
4425 #define THREAD_TERMINATE 0x0001
4426 #define THREAD_SUSPEND_RESUME 0x0002
4427 #define THREAD_GET_CONTEXT 0x0008
4428 #define THREAD_SET_CONTEXT 0x0010
4429 #define THREAD_SET_INFORMATION 0x0020
4430 #define THREAD_QUERY_INFORMATION 0x0040
4431 #define THREAD_SET_THREAD_TOKEN 0x0080
4432 #define THREAD_IMPERSONATE 0x0100
4433 #define THREAD_DIRECT_IMPERSONATION 0x0200
4434 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
4436 #define THREAD_BASE_PRIORITY_LOWRT 15
4437 #define THREAD_BASE_PRIORITY_MAX 2
4438 #define THREAD_BASE_PRIORITY_MIN -2
4439 #define THREAD_BASE_PRIORITY_IDLE -15
4441 typedef struct _QUOTA_LIMITS {
4442 SIZE_T PagedPoolLimit;
4443 SIZE_T NonPagedPoolLimit;
4444 SIZE_T MinimumWorkingSetSize;
4445 SIZE_T MaximumWorkingSetSize;
4446 SIZE_T PagefileLimit;
4447 LARGE_INTEGER TimeLimit;
4448 } QUOTA_LIMITS, *PQUOTA_LIMITS;
4450 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
4451 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
4452 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
4453 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
4455 typedef struct _QUOTA_LIMITS_EX {
4456 SIZE_T PagedPoolLimit;
4457 SIZE_T NonPagedPoolLimit;
4458 SIZE_T MinimumWorkingSetSize;
4459 SIZE_T MaximumWorkingSetSize;
4460 SIZE_T PagefileLimit;
4461 LARGE_INTEGER TimeLimit;
4462 SIZE_T Reserved1;
4463 SIZE_T Reserved2;
4464 SIZE_T Reserved3;
4465 SIZE_T Reserved4;
4466 DWORD Flags;
4467 DWORD Reserved5;
4468 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
4470 #define SECTION_QUERY 0x0001
4471 #define SECTION_MAP_WRITE 0x0002
4472 #define SECTION_MAP_READ 0x0004
4473 #define SECTION_MAP_EXECUTE 0x0008
4474 #define SECTION_EXTEND_SIZE 0x0010
4475 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
4476 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
4478 #define FILE_READ_DATA 0x0001 /* file & pipe */
4479 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
4480 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
4481 #define FILE_ADD_FILE 0x0002 /* directory */
4482 #define FILE_APPEND_DATA 0x0004 /* file */
4483 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
4484 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
4485 #define FILE_READ_EA 0x0008 /* file & directory */
4486 #define FILE_READ_PROPERTIES FILE_READ_EA
4487 #define FILE_WRITE_EA 0x0010 /* file & directory */
4488 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
4489 #define FILE_EXECUTE 0x0020 /* file */
4490 #define FILE_TRAVERSE 0x0020 /* directory */
4491 #define FILE_DELETE_CHILD 0x0040 /* directory */
4492 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
4493 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
4494 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
4496 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
4497 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
4498 SYNCHRONIZE)
4499 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
4500 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
4501 FILE_APPEND_DATA | SYNCHRONIZE)
4502 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
4503 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
4505 #define DUPLICATE_CLOSE_SOURCE 0x00000001
4506 #define DUPLICATE_SAME_ACCESS 0x00000002
4508 /* File attribute flags */
4509 #define FILE_SHARE_READ 0x00000001
4510 #define FILE_SHARE_WRITE 0x00000002
4511 #define FILE_SHARE_DELETE 0x00000004
4513 #define FILE_ATTRIBUTE_READONLY 0x00000001
4514 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
4515 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
4516 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
4517 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
4518 #define FILE_ATTRIBUTE_DEVICE 0x00000040
4519 #define FILE_ATTRIBUTE_NORMAL 0x00000080
4520 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
4521 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
4522 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
4523 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
4524 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
4525 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
4526 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
4528 /* File notification flags */
4529 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
4530 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
4531 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
4532 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
4533 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
4534 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
4535 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
4536 #define FILE_NOTIFY_CHANGE_EA 0x00000080
4537 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
4538 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
4539 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
4540 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
4542 #define FILE_ACTION_ADDED 0x00000001
4543 #define FILE_ACTION_REMOVED 0x00000002
4544 #define FILE_ACTION_MODIFIED 0x00000003
4545 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
4546 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
4547 #define FILE_ACTION_ADDED_STREAM 0x00000006
4548 #define FILE_ACTION_REMOVED_STREAM 0x00000007
4549 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
4551 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
4552 #define FILE_CASE_PRESERVED_NAMES 0x00000002
4553 #define FILE_UNICODE_ON_DISK 0x00000004
4554 #define FILE_PERSISTENT_ACLS 0x00000008
4555 #define FILE_FILE_COMPRESSION 0x00000010
4556 #define FILE_VOLUME_QUOTAS 0x00000020
4557 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
4558 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
4559 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
4560 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
4561 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
4562 #define FILE_NAMED_STREAMS 0x00040000
4563 #define FILE_READ_ONLY_VOLUME 0x00080000
4565 /* File alignments (NT) */
4566 #define FILE_BYTE_ALIGNMENT 0x00000000
4567 #define FILE_WORD_ALIGNMENT 0x00000001
4568 #define FILE_LONG_ALIGNMENT 0x00000003
4569 #define FILE_QUAD_ALIGNMENT 0x00000007
4570 #define FILE_OCTA_ALIGNMENT 0x0000000f
4571 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
4572 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
4573 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
4574 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
4575 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
4577 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
4578 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
4580 #define REG_NONE 0 /* no type */
4581 #define REG_SZ 1 /* string type (ASCII) */
4582 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
4583 #define REG_BINARY 3 /* binary format, callerspecific */
4584 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
4585 #define REG_DWORD 4 /* DWORD in little endian format */
4586 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
4587 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
4588 #define REG_LINK 6 /* symbolic link (UNICODE) */
4589 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
4590 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
4591 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
4592 #define REG_RESOURCE_REQUIREMENTS_LIST 10
4593 #define REG_QWORD 11 /* QWORD in little endian format */
4594 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
4596 /* ----------------------------- begin power management --------------------- */
4598 typedef enum _LATENCY_TIME {
4599 LT_DONT_CARE,
4600 LT_LOWEST_LATENCY
4601 } LATENCY_TIME, *PLATENCY_TIME;
4603 #define DISCHARGE_POLICY_CRITICAL 0
4604 #define DISCHARGE_POLICY_LOW 1
4605 #define NUM_DISCHARGE_POLICIES 4
4607 #define PO_THROTTLE_NONE 0
4608 #define PO_THROTTLE_CONSTANT 1
4609 #define PO_THROTTLE_DEGRADE 2
4610 #define PO_THROTTLE_ADAPTIVE 3
4612 typedef enum _POWER_ACTION {
4613 PowerActionNone = 0,
4614 PowerActionReserved,
4615 PowerActionSleep,
4616 PowerActionHibernate,
4617 PowerActionShutdown,
4618 PowerActionShutdownReset,
4619 PowerActionShutdownOff,
4620 PowerActionWarmEject
4621 } POWER_ACTION,
4622 *PPOWER_ACTION;
4624 typedef enum _SYSTEM_POWER_STATE {
4625 PowerSystemUnspecified = 0,
4626 PowerSystemWorking = 1,
4627 PowerSystemSleeping1 = 2,
4628 PowerSystemSleeping2 = 3,
4629 PowerSystemSleeping3 = 4,
4630 PowerSystemHibernate = 5,
4631 PowerSystemShutdown = 6,
4632 PowerSystemMaximum = 7
4633 } SYSTEM_POWER_STATE,
4634 *PSYSTEM_POWER_STATE;
4636 typedef enum _DEVICE_POWER_STATE {
4637 PowerDeviceUnspecified,
4638 PowerDeviceD0,
4639 PowerDeviceD1,
4640 PowerDeviceD2,
4641 PowerDeviceD3,
4642 PowerDeviceMaximum
4643 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
4645 typedef enum _POWER_INFORMATION_LEVEL {
4646 SystemPowerPolicyAc,
4647 SystemPowerPolicyDc,
4648 VerifySystemPolicyAc,
4649 VerifySystemPolicyDc,
4650 SystemPowerCapabilities,
4651 SystemBatteryState,
4652 SystemPowerStateHandler,
4653 ProcessorStateHandler,
4654 SystemPowerPolicyCurrent,
4655 AdministratorPowerPolicy,
4656 SystemReserveHiberFile,
4657 ProcessorInformation,
4658 SystemPowerInformation,
4659 ProcessorStateHandler2,
4660 LastWakeTime,
4661 LastSleepTime,
4662 SystemExecutionState,
4663 SystemPowerStateNotifyHandler,
4664 ProcessorPowerPolicyAc,
4665 ProcessorPowerPolicyDc,
4666 VerifyProcessorPowerPolicyAc,
4667 VerifyProcessorPowerPolicyDc,
4668 ProcessorPowerPolicyCurrent
4669 } POWER_INFORMATION_LEVEL;
4671 typedef struct _ADMINISTRATOR_POWER_POLICY {
4672 SYSTEM_POWER_STATE MinSleep;
4673 SYSTEM_POWER_STATE MaxSleep;
4674 ULONG MinVideoTimeout;
4675 ULONG MaxVideoTimeout;
4676 ULONG MinSpindownTimeout;
4677 ULONG MaxSpindownTimeout;
4678 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
4680 typedef struct {
4681 ULONG Granularity;
4682 ULONG Capacity;
4683 } BATTERY_REPORTING_SCALE,
4684 *PBATTERY_REPORTING_SCALE;
4686 typedef struct {
4687 POWER_ACTION Action;
4688 ULONG Flags;
4689 ULONG EventCode;
4690 } POWER_ACTION_POLICY,
4691 *PPOWER_ACTION_POLICY;
4693 typedef struct _PROCESSOR_POWER_INFORMATION {
4694 ULONG Number;
4695 ULONG MaxMhz;
4696 ULONG CurrentMhz;
4697 ULONG MhzLimit;
4698 ULONG MaxIdleState;
4699 ULONG CurrentIdleState;
4700 } PROCESSOR_POWER_INFORMATION,
4701 *PPROCESSOR_POWER_INFORMATION;
4703 typedef struct _PROCESSOR_POWER_POLICY_INFO {
4704 ULONG TimeCheck;
4705 ULONG DemoteLimit;
4706 ULONG PromoteLimit;
4707 UCHAR DemotePercent;
4708 UCHAR PromotePercent;
4709 UCHAR Spare[2];
4710 ULONG AllowDemotion:1;
4711 ULONG AllowPromotion:1;
4712 ULONG Reserved:30;
4713 } PROCESSOR_POWER_POLICY_INFO,
4714 *PPROCESSOR_POWER_POLICY_INFO;
4716 typedef struct _PROCESSOR_POWER_POLICY {
4717 DWORD Revision;
4718 BYTE DynamicThrottle;
4719 BYTE Spare[3];
4720 DWORD DisableCStates:1;
4721 DWORD Reserved:31;
4722 DWORD PolicyCount;
4723 PROCESSOR_POWER_POLICY_INFO Policy[3];
4724 } PROCESSOR_POWER_POLICY,
4725 *PPROCESSOR_POWER_POLICY;
4727 typedef struct {
4728 BOOLEAN AcOnLine;
4729 BOOLEAN BatteryPresent;
4730 BOOLEAN Charging;
4731 BOOLEAN Discharging;
4732 BOOLEAN Spare1[4];
4733 ULONG MaxCapacity;
4734 ULONG RemainingCapacity;
4735 ULONG Rate;
4736 ULONG EstimatedTime;
4737 ULONG DefaultAlert1;
4738 ULONG DefaultAlert2;
4739 } SYSTEM_BATTERY_STATE,
4740 *PSYSTEM_BATTERY_STATE;
4742 typedef struct {
4743 BOOLEAN PowerButtonPresent;
4744 BOOLEAN SleepButtonPresent;
4745 BOOLEAN LidPresent;
4746 BOOLEAN SystemS1;
4747 BOOLEAN SystemS2;
4748 BOOLEAN SystemS3;
4749 BOOLEAN SystemS4;
4750 BOOLEAN SystemS5;
4751 BOOLEAN HiberFilePresent;
4752 BOOLEAN FullWake;
4753 BOOLEAN VideoDimPresent;
4754 BOOLEAN ApmPresent;
4755 BOOLEAN UpsPresent;
4756 BOOLEAN ThermalControl;
4757 BOOLEAN ProcessorThrottle;
4758 UCHAR ProcessorMinThrottle;
4759 UCHAR ProcessorMaxThrottle;
4760 UCHAR spare2[4];
4761 BOOLEAN DiskSpinDown;
4762 UCHAR spare3[8];
4763 BOOLEAN SystemBatteriesPresent;
4764 BOOLEAN BatteriesAreShortTerm;
4765 BATTERY_REPORTING_SCALE BatteryScale[3];
4766 SYSTEM_POWER_STATE AcOnLineWake;
4767 SYSTEM_POWER_STATE SoftLidWake;
4768 SYSTEM_POWER_STATE RtcWake;
4769 SYSTEM_POWER_STATE MinDeviceWakeState;
4770 SYSTEM_POWER_STATE DefaultLowLatencyWake;
4771 } SYSTEM_POWER_CAPABILITIES,
4772 *PSYSTEM_POWER_CAPABILITIES;
4774 typedef struct _SYSTEM_POWER_INFORMATION {
4775 ULONG MaxIdlenessAllowed;
4776 ULONG Idleness;
4777 ULONG TimeRemaining;
4778 UCHAR CoolingMode;
4779 } SYSTEM_POWER_INFORMATION,
4780 *PSYSTEM_POWER_INFORMATION;
4782 typedef struct _SYSTEM_POWER_LEVEL {
4783 BOOLEAN Enable;
4784 UCHAR Spare[3];
4785 ULONG BatteryLevel;
4786 POWER_ACTION_POLICY PowerPolicy;
4787 SYSTEM_POWER_STATE MinSystemState;
4788 } SYSTEM_POWER_LEVEL,
4789 *PSYSTEM_POWER_LEVEL;
4791 typedef struct _SYSTEM_POWER_POLICY {
4792 ULONG Revision;
4793 POWER_ACTION_POLICY PowerButton;
4794 POWER_ACTION_POLICY SleepButton;
4795 POWER_ACTION_POLICY LidClose;
4796 SYSTEM_POWER_STATE LidOpenWake;
4797 ULONG Reserved;
4798 POWER_ACTION_POLICY Idle;
4799 ULONG IdleTimeout;
4800 UCHAR IdleSensitivity;
4801 UCHAR DynamicThrottle;
4802 UCHAR Spare2[2];
4803 SYSTEM_POWER_STATE MinSleep;
4804 SYSTEM_POWER_STATE MaxSleep;
4805 SYSTEM_POWER_STATE ReducedLatencySleep;
4806 ULONG WinLogonFlags;
4807 ULONG Spare3;
4808 ULONG DozeS4Timeout;
4809 ULONG BroadcastCapacityResolution;
4810 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
4811 ULONG VideoTimeout;
4812 BOOLEAN VideoDimDisplay;
4813 ULONG VideoReserved[3];
4814 ULONG SpindownTimeout;
4815 BOOLEAN OptimizeForPower;
4816 UCHAR FanThrottleTolerance;
4817 UCHAR ForcedThrottle;
4818 UCHAR MinThrottle;
4819 POWER_ACTION_POLICY OverThrottled;
4820 } SYSTEM_POWER_POLICY,
4821 *PSYSTEM_POWER_POLICY;
4823 typedef union _FILE_SEGMENT_ELEMENT {
4824 PVOID64 Buffer;
4825 ULONGLONG Alignment;
4826 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
4828 typedef struct _FILE_NOTIFY_INFORMATION {
4829 DWORD NextEntryOffset;
4830 DWORD Action;
4831 DWORD FileNameLength;
4832 WCHAR FileName[1];
4833 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
4835 /* ----------------------------- begin tape storage --------------------- */
4837 #define TAPE_FIXED_PARTITIONS 0
4838 #define TAPE_SELECT_PARTITIONS 1
4839 #define TAPE_INITIATOR_PARTITIONS 2
4840 #define TAPE_ERASE_SHORT 0
4841 #define TAPE_ERASE_LONG 1
4842 #define TAPE_LOAD 0
4843 #define TAPE_UNLOAD 1
4844 #define TAPE_TENSION 2
4845 #define TAPE_LOCK 3
4846 #define TAPE_UNLOCK 4
4847 #define TAPE_FORMAT 5
4848 #define TAPE_SETMARKS 0
4849 #define TAPE_FILEMARKS 1
4850 #define TAPE_SHORT_FILEMARKS 2
4851 #define TAPE_LONG_FILEMARKS 3
4852 #define TAPE_REWIND 0
4853 #define TAPE_ABSOLUTE_BLOCK 1
4854 #define TAPE_LOGICAL_BLOCK 2
4855 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
4856 #define TAPE_SPACE_END_OF_DATA 4
4857 #define TAPE_SPACE_RELATIVE_BLOCKS 5
4858 #define TAPE_SPACE_FILEMARKS 6
4859 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
4860 #define TAPE_SPACE_SETMARKS 8
4861 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
4863 typedef struct _TAPE_CREATE_PARTITION {
4864 DWORD Method;
4865 DWORD Count;
4866 DWORD Size;
4867 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
4869 typedef struct _TAPE_ERASE {
4870 DWORD Type;
4871 BOOLEAN Immediate;
4872 } TAPE_ERASE, *PTAPE_ERASE;
4874 typedef struct _TAPE_PREPARE {
4875 DWORD Operation;
4876 BOOLEAN Immediate;
4877 } TAPE_PREPARE, *PTAPE_PREPARE;
4879 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
4880 BOOLEAN ECC;
4881 BOOLEAN Compression;
4882 BOOLEAN DataPadding;
4883 BOOLEAN ReportSetmarks;
4884 ULONG EOTWarningZoneSize;
4885 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
4887 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
4888 ULONG BlockSize;
4889 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
4891 typedef struct _TAPE_WRITE_MARKS {
4892 DWORD Type;
4893 DWORD Count;
4894 BOOLEAN Immediate;
4895 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
4897 typedef struct _TAPE_GET_POSITION {
4898 ULONG Type;
4899 ULONG Partition;
4900 ULONG OffsetLow;
4901 ULONG OffsetHigh;
4902 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
4904 typedef struct _TAPE_SET_POSITION {
4905 ULONG Method;
4906 ULONG Partition;
4907 LARGE_INTEGER Offset;
4908 BOOLEAN Immediate;
4909 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
4911 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
4912 BOOLEAN ECC;
4913 BOOLEAN Compression;
4914 BOOLEAN DataPadding;
4915 BOOLEAN ReportSetmarks;
4916 DWORD DefaultBlockSize;
4917 DWORD MaximumBlockSize;
4918 DWORD MinimumBlockSize;
4919 DWORD MaximumPartitionCount;
4920 DWORD FeaturesLow;
4921 DWORD FeaturesHigh;
4922 DWORD EOTWarningZoneSize;
4923 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
4925 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
4926 LARGE_INTEGER Capacity;
4927 LARGE_INTEGER Remaining;
4928 DWORD BlockSize;
4929 DWORD PartitionCount;
4930 BOOLEAN WriteProtected;
4931 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
4933 /* ----------------------------- begin registry ----------------------------- */
4935 /* Registry security values */
4936 #define OWNER_SECURITY_INFORMATION 0x00000001
4937 #define GROUP_SECURITY_INFORMATION 0x00000002
4938 #define DACL_SECURITY_INFORMATION 0x00000004
4939 #define SACL_SECURITY_INFORMATION 0x00000008
4941 #define REG_OPTION_RESERVED 0x00000000
4942 #define REG_OPTION_NON_VOLATILE 0x00000000
4943 #define REG_OPTION_VOLATILE 0x00000001
4944 #define REG_OPTION_CREATE_LINK 0x00000002
4945 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
4946 #define REG_OPTION_OPEN_LINK 0x00000008
4947 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
4948 REG_OPTION_NON_VOLATILE| \
4949 REG_OPTION_VOLATILE| \
4950 REG_OPTION_CREATE_LINK| \
4951 REG_OPTION_BACKUP_RESTORE| \
4952 REG_OPTION_OPEN_LINK)
4955 #define REG_CREATED_NEW_KEY 0x00000001
4956 #define REG_OPENED_EXISTING_KEY 0x00000002
4958 /* For RegNotifyChangeKeyValue */
4959 #define REG_NOTIFY_CHANGE_NAME 0x01
4960 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
4961 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
4962 #define REG_NOTIFY_CHANGE_SECURITY 0x08
4964 #define KEY_QUERY_VALUE 0x00000001
4965 #define KEY_SET_VALUE 0x00000002
4966 #define KEY_CREATE_SUB_KEY 0x00000004
4967 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
4968 #define KEY_NOTIFY 0x00000010
4969 #define KEY_CREATE_LINK 0x00000020
4970 #define KEY_WOW64_64KEY 0x00000100
4971 #define KEY_WOW64_32KEY 0x00000200
4972 #define KEY_WOW64_RES 0x00000300
4974 /* for RegKeyRestore flags */
4975 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
4976 #define REG_REFRESH_HIVE 0x00000002
4977 #define REG_NO_LAZY_FLUSH 0x00000004
4978 #define REG_FORCE_RESTORE 0x00000008
4980 #define KEY_READ ((STANDARD_RIGHTS_READ| \
4981 KEY_QUERY_VALUE| \
4982 KEY_ENUMERATE_SUB_KEYS| \
4983 KEY_NOTIFY) \
4984 & (~SYNCHRONIZE) \
4986 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
4987 KEY_SET_VALUE| \
4988 KEY_CREATE_SUB_KEY) \
4989 & (~SYNCHRONIZE) \
4991 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
4992 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
4993 KEY_QUERY_VALUE| \
4994 KEY_SET_VALUE| \
4995 KEY_CREATE_SUB_KEY| \
4996 KEY_ENUMERATE_SUB_KEYS| \
4997 KEY_NOTIFY| \
4998 KEY_CREATE_LINK) \
4999 & (~SYNCHRONIZE) \
5001 /* ------------------------------ end registry ------------------------------ */
5004 #define EVENTLOG_SUCCESS 0x0000
5005 #define EVENTLOG_ERROR_TYPE 0x0001
5006 #define EVENTLOG_WARNING_TYPE 0x0002
5007 #define EVENTLOG_INFORMATION_TYPE 0x0004
5008 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5009 #define EVENTLOG_AUDIT_FAILURE 0x0010
5011 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5012 #define EVENTLOG_SEEK_READ 0x0002
5013 #define EVENTLOG_FORWARDS_READ 0x0004
5014 #define EVENTLOG_BACKWARDS_READ 0x0008
5016 typedef struct _EVENTLOGRECORD {
5017 DWORD Length;
5018 DWORD Reserved;
5019 DWORD RecordNumber;
5020 DWORD TimeGenerated;
5021 DWORD TimeWritten;
5022 DWORD EventID;
5023 WORD EventType;
5024 WORD NumStrings;
5025 WORD EventCategory;
5026 WORD ReservedFlags;
5027 DWORD ClosingRecordNumber;
5028 DWORD StringOffset;
5029 DWORD UserSidLength;
5030 DWORD UserSidOffset;
5031 DWORD DataLength;
5032 DWORD DataOffset;
5033 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5035 #define SERVICE_BOOT_START 0x00000000
5036 #define SERVICE_SYSTEM_START 0x00000001
5037 #define SERVICE_AUTO_START 0x00000002
5038 #define SERVICE_DEMAND_START 0x00000003
5039 #define SERVICE_DISABLED 0x00000004
5041 #define SERVICE_ERROR_IGNORE 0x00000000
5042 #define SERVICE_ERROR_NORMAL 0x00000001
5043 #define SERVICE_ERROR_SEVERE 0x00000002
5044 #define SERVICE_ERROR_CRITICAL 0x00000003
5046 /* Service types */
5047 #define SERVICE_KERNEL_DRIVER 0x00000001
5048 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5049 #define SERVICE_ADAPTER 0x00000004
5050 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5052 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5053 SERVICE_RECOGNIZER_DRIVER )
5055 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5056 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5057 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5059 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5061 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5062 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5065 typedef enum _CM_SERVICE_NODE_TYPE
5067 DriverType = SERVICE_KERNEL_DRIVER,
5068 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
5069 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
5070 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
5071 AdapterType = SERVICE_ADAPTER,
5072 RecognizerType = SERVICE_RECOGNIZER_DRIVER
5073 } SERVICE_NODE_TYPE;
5075 typedef enum _CM_SERVICE_LOAD_TYPE
5077 BootLoad = SERVICE_BOOT_START,
5078 SystemLoad = SERVICE_SYSTEM_START,
5079 AutoLoad = SERVICE_AUTO_START,
5080 DemandLoad = SERVICE_DEMAND_START,
5081 DisableLoad = SERVICE_DISABLED
5082 } SERVICE_LOAD_TYPE;
5084 typedef enum _CM_ERROR_CONTROL_TYPE
5086 IgnoreError = SERVICE_ERROR_IGNORE,
5087 NormalError = SERVICE_ERROR_NORMAL,
5088 SevereError = SERVICE_ERROR_SEVERE,
5089 CriticalError = SERVICE_ERROR_CRITICAL
5090 } SERVICE_ERROR_TYPE;
5094 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5095 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5096 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5097 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5098 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5100 #include <guiddef.h>
5102 typedef struct _OBJECT_TYPE_LIST {
5103 WORD Level;
5104 WORD Sbz;
5105 GUID *ObjectType;
5106 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
5108 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5110 WORD Type;
5111 WORD CreatorBackTraceIndex;
5112 struct _RTL_CRITICAL_SECTION *CriticalSection;
5113 LIST_ENTRY ProcessLocksList;
5114 DWORD EntryCount;
5115 DWORD ContentionCount;
5116 #ifdef __WINESRC__ /* in Wine we store the name here */
5117 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
5118 #else
5119 DWORD Spare[ 2 ];
5120 #endif
5121 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
5123 typedef struct _RTL_CRITICAL_SECTION {
5124 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
5125 LONG LockCount;
5126 LONG RecursionCount;
5127 HANDLE OwningThread;
5128 HANDLE LockSemaphore;
5129 ULONG_PTR SpinCount;
5130 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
5132 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5133 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5134 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5135 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5136 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5138 typedef struct _RTL_SRWLOCK {
5139 PVOID Ptr;
5140 } RTL_SRWLOCK, *PRTL_SRWLOCK;
5142 #define RTL_SRWLOCK_INIT {0}
5144 typedef struct _RTL_CONDITION_VARIABLE {
5145 PVOID Ptr;
5146 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
5147 #define RTL_CONDITION_VARIABLE_INIT {0}
5148 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
5150 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
5151 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
5153 #define RTL_RUN_ONCE_INIT {0}
5154 typedef union _RTL_RUN_ONCE {
5155 PVOID Ptr;
5156 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
5158 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
5159 #define RTL_RUN_ONCE_ASYNC 0x00000002
5160 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
5162 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
5163 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
5164 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
5165 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
5167 #include <pshpack8.h>
5168 typedef struct _IO_COUNTERS {
5169 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
5170 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
5171 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
5172 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
5173 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
5174 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
5175 } IO_COUNTERS, *PIO_COUNTERS;
5176 #include <poppack.h>
5178 typedef struct {
5179 DWORD dwOSVersionInfoSize;
5180 DWORD dwMajorVersion;
5181 DWORD dwMinorVersion;
5182 DWORD dwBuildNumber;
5183 DWORD dwPlatformId;
5184 CHAR szCSDVersion[128];
5185 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5187 typedef struct {
5188 DWORD dwOSVersionInfoSize;
5189 DWORD dwMajorVersion;
5190 DWORD dwMinorVersion;
5191 DWORD dwBuildNumber;
5192 DWORD dwPlatformId;
5193 WCHAR szCSDVersion[128];
5194 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
5196 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
5197 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
5198 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
5200 typedef struct {
5201 DWORD dwOSVersionInfoSize;
5202 DWORD dwMajorVersion;
5203 DWORD dwMinorVersion;
5204 DWORD dwBuildNumber;
5205 DWORD dwPlatformId;
5206 CHAR szCSDVersion[128];
5207 WORD wServicePackMajor;
5208 WORD wServicePackMinor;
5209 WORD wSuiteMask;
5210 BYTE wProductType;
5211 BYTE wReserved;
5212 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5214 typedef struct {
5215 DWORD dwOSVersionInfoSize;
5216 DWORD dwMajorVersion;
5217 DWORD dwMinorVersion;
5218 DWORD dwBuildNumber;
5219 DWORD dwPlatformId;
5220 WCHAR szCSDVersion[128];
5221 WORD wServicePackMajor;
5222 WORD wServicePackMinor;
5223 WORD wSuiteMask;
5224 BYTE wProductType;
5225 BYTE wReserved;
5226 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
5228 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
5229 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
5230 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
5232 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
5234 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5236 #define VER_PLATFORM_WIN32s 0
5237 #define VER_PLATFORM_WIN32_WINDOWS 1
5238 #define VER_PLATFORM_WIN32_NT 2
5240 #define VER_MINORVERSION 0x00000001
5241 #define VER_MAJORVERSION 0x00000002
5242 #define VER_BUILDNUMBER 0x00000004
5243 #define VER_PLATFORMID 0x00000008
5244 #define VER_SERVICEPACKMINOR 0x00000010
5245 #define VER_SERVICEPACKMAJOR 0x00000020
5246 #define VER_SUITENAME 0x00000040
5247 #define VER_PRODUCT_TYPE 0x00000080
5249 #define VER_NT_WORKSTATION 1
5250 #define VER_NT_DOMAIN_CONTROLLER 2
5251 #define VER_NT_SERVER 3
5253 #define VER_SUITE_SMALLBUSINESS 0x00000001
5254 #define VER_SUITE_ENTERPRISE 0x00000002
5255 #define VER_SUITE_BACKOFFICE 0x00000004
5256 #define VER_SUITE_COMMUNICATIONS 0x00000008
5257 #define VER_SUITE_TERMINAL 0x00000010
5258 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5259 #define VER_SUITE_EMBEDDEDNT 0x00000040
5260 #define VER_SUITE_DATACENTER 0x00000080
5261 #define VER_SUITE_SINGLEUSERTS 0x00000100
5262 #define VER_SUITE_PERSONAL 0x00000200
5263 #define VER_SUITE_BLADE 0x00000400
5264 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
5265 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
5266 #define VER_SUITE_STORAGE_SERVER 0x00002000
5267 #define VER_SUITE_COMPUTE_SERVER 0x00004000
5268 #define VER_SUITE_WH_SERVER 0x00008000
5270 #define VER_EQUAL 1
5271 #define VER_GREATER 2
5272 #define VER_GREATER_EQUAL 3
5273 #define VER_LESS 4
5274 #define VER_LESS_EQUAL 5
5275 #define VER_AND 6
5276 #define VER_OR 7
5278 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
5279 DWORD dwFlags;
5280 DWORD ulFormatVersion;
5281 DWORD ulAssemblyCount;
5282 DWORD ulRootManifestPathType;
5283 DWORD ulRootManifestPathChars;
5284 DWORD ulRootConfigurationPathType;
5285 DWORD ulRootConfigurationPathChars;
5286 DWORD ulAppDirPathType;
5287 DWORD ulAppDirPathChars;
5288 PCWSTR lpRootManifestPath;
5289 PCWSTR lpRootConfigurationPath;
5290 PCWSTR lpAppDirPath;
5291 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
5293 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
5294 DWORD ulFlags;
5295 DWORD ulEncodedAssemblyIdentityLength;
5296 DWORD ulManifestPathType;
5297 DWORD ulManifestPathLength;
5298 LARGE_INTEGER liManifestLastWriteTime;
5299 DWORD ulPolicyPathType;
5300 DWORD ulPolicyPathLength;
5301 LARGE_INTEGER liPolicyLastWriteTime;
5302 DWORD ulMetadataSatelliteRosterIndex;
5303 DWORD ulManifestVersionMajor;
5304 DWORD ulManifestVersionMinor;
5305 DWORD ulPolicyVersionMajor;
5306 DWORD ulPolicyVersionMinor;
5307 DWORD ulAssemblyDirectoryNameLength;
5308 PCWSTR lpAssemblyEncodedAssemblyIdentity;
5309 PCWSTR lpAssemblyManifestPath;
5310 PCWSTR lpAssemblyPolicyPath;
5311 PCWSTR lpAssemblyDirectoryName;
5312 DWORD ulFileCount;
5313 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
5315 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
5316 DWORD ulAssemblyIndex;
5317 DWORD ulFileIndexInAssembly;
5318 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
5320 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
5322 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
5323 DWORD ulFlags;
5324 DWORD ulFilenameLength;
5325 DWORD ulPathLength;
5326 PCWSTR lpFileName;
5327 PCWSTR lpFilePath;
5328 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
5330 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
5332 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
5333 ActivationContextBasicInformation = 1,
5334 ActivationContextDetailedInformation = 2,
5335 AssemblyDetailedInformationInActivationContext = 3,
5336 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
5337 MaxActivationContextInfoClass,
5339 AssemblyDetailedInformationInActivationContxt = 3,
5340 FileInformationInAssemblyOfAssemblyInActivationContxt = 4
5341 } ACTIVATION_CONTEXT_INFO_CLASS;
5343 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
5344 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
5345 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
5346 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
5348 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
5349 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
5350 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
5351 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
5352 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
5353 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
5354 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
5355 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
5356 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
5358 typedef enum _JOBOBJECTINFOCLASS
5360 JobObjectBasicAccountingInformation = 1,
5361 JobObjectBasicLimitInformation,
5362 JobObjectBasicProcessIdList,
5363 JobObjectBasicUIRestrictions,
5364 JobObjectSecurityLimitInformation,
5365 JobObjectEndOfJobTimeInformation,
5366 JobObjectAssociateCompletionPortInformation,
5367 JobObjectBasicAndIoAccountingInformation,
5368 JobObjectExtendedLimitInformation,
5369 JobObjectJobSetInformation,
5370 MaxJobObjectInfoClass
5371 } JOBOBJECTINFOCLASS;
5373 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
5375 RelationProcessorCore = 0,
5376 RelationNumaNode = 1,
5377 RelationCache = 2,
5378 RelationProcessorPackage = 3,
5379 RelationGroup = 4,
5380 RelationAll = 0xffff
5381 } LOGICAL_PROCESSOR_RELATIONSHIP;
5383 typedef enum _PROCESSOR_CACHE_TYPE
5385 CacheUnified,
5386 CacheInstruction,
5387 CacheData,
5388 CacheTrace
5389 } PROCESSOR_CACHE_TYPE;
5391 typedef struct _PROCESSOR_GROUP_INFO
5393 BYTE MaximumProcessorCount;
5394 BYTE ActiveProcessorCount;
5395 BYTE Reserved[38];
5396 KAFFINITY ActiveProcessorMask;
5397 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
5399 typedef struct _CACHE_DESCRIPTOR
5401 BYTE Level;
5402 BYTE Associativity;
5403 WORD LineSize;
5404 DWORD Size;
5405 PROCESSOR_CACHE_TYPE Type;
5406 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
5408 typedef struct _GROUP_AFFINITY
5410 KAFFINITY Mask;
5411 WORD Group;
5412 WORD Reserved[3];
5413 } GROUP_AFFINITY, *PGROUP_AFFINITY;
5415 typedef struct _PROCESSOR_NUMBER
5417 WORD Group;
5418 BYTE Number;
5419 BYTE Reserved;
5420 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
5422 typedef struct _PROCESSOR_RELATIONSHIP
5424 BYTE Flags;
5425 BYTE Reserved[21];
5426 WORD GroupCount;
5427 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
5428 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
5431 typedef struct _NUMA_NODE_RELATIONSHIP
5433 DWORD NodeNumber;
5434 BYTE Reserved[20];
5435 GROUP_AFFINITY GroupMask;
5436 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
5438 typedef struct _CACHE_RELATIONSHIP
5440 BYTE Level;
5441 BYTE Associativity;
5442 WORD LineSize;
5443 PROCESSOR_CACHE_TYPE Type;
5444 BYTE Reserved[20];
5445 GROUP_AFFINITY GroupMask;
5446 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
5448 typedef struct _GROUP_RELATIONSHIP
5450 WORD MaximumGroupCount;
5451 WORD ActiveGroupCount;
5452 BYTE Reserved[20];
5453 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
5454 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
5456 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
5458 ULONG_PTR ProcessorMask;
5459 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
5460 union
5462 struct
5464 BYTE Flags;
5465 } ProcessorCore;
5466 struct
5468 DWORD NodeNumber;
5469 } NumaNode;
5470 CACHE_DESCRIPTOR Cache;
5471 ULONGLONG Reserved[2];
5472 } DUMMYUNIONNAME;
5473 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
5475 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
5477 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
5478 DWORD Size;
5479 union
5481 PROCESSOR_RELATIONSHIP Processor;
5482 NUMA_NODE_RELATIONSHIP NumaNode;
5483 CACHE_RELATIONSHIP Cache;
5484 GROUP_RELATIONSHIP Group;
5485 } DUMMYUNIONNAME;
5486 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
5488 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
5490 #ifdef __cplusplus
5492 #endif
5494 #endif /* _WINNT_ */