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
41 #define NTSYSAPI DECLSPEC_IMPORT
44 #define NTAPI __stdcall
47 # if defined(_MSC_VER)
48 # define DECLSPEC_IMPORT __declspec(dllimport)
49 # elif defined(__MINGW32__) || defined(__CYGWIN__)
50 # define DECLSPEC_IMPORT __attribute__((dllimport))
52 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
55 # define DECLSPEC_IMPORT
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))
64 # define DECLSPEC_NORETURN
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)))
74 # define DECLSPEC_ALIGN(x)
78 #ifndef DECLSPEC_CACHEALIGN
79 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
83 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
84 # define DECLSPEC_UUID(x) __declspec(uuid(x))
86 # define DECLSPEC_UUID(x)
90 #ifndef DECLSPEC_NOVTABLE
91 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
92 # define DECLSPEC_NOVTABLE __declspec(novtable)
94 # define DECLSPEC_NOVTABLE
98 #ifndef DECLSPEC_SELECTANY
99 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
100 #define DECLSPEC_SELECTANY __declspec(selectany)
102 #define DECLSPEC_SELECTANY
107 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
108 # define NOP_FUNCTION __noop
110 # define NOP_FUNCTION (void)0
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)
118 # define DECLSPEC_ADDRSAFE
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))
128 # define FORCEINLINE inline
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
140 # define DECLSPEC_DEPRECATED
141 # undef DEPRECATE_SUPPORTED
145 /* a couple of useful Wine extensions */
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")))
154 # define DECLSPEC_EXPORT
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")))
162 # define DECLSPEC_HIDDEN
165 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
166 #define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
168 #define __WINE_ALLOC_SIZE(x)
171 /* Anonymous union/struct handling */
173 #ifndef NONAMELESSSTRUCT
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
179 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
180 # define NONAMELESSSTRUCT
182 #endif /* NONAMELESSSTRUCT */
184 #ifndef NONAMELESSUNION
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
190 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
191 # define NONAMELESSUNION
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)
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__
271 # elif defined(_MSC_VER)
272 # define __C89_NAMELESS
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
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
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
319 # define RESTRICTED_POINTER
322 # define RESTRICTED_POINTER
325 /* C99 unaligned support */
328 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
329 # define UNALIGNED __unaligned
331 # define UNALIGNED64 __unaligned
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
347 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
348 #define MEMORY_ALLOCATION_ALIGNMENT 8
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)
356 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
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)
365 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
368 /* Compile time assertion */
370 #if defined(_MSC_VER)
371 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
373 # define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
376 /* Eliminate Microsoft C/C++ compiler warning 4715 */
377 #if defined(_MSC_VER) && (_MSC_VER > 1200)
378 # define DEFAULT_UNREACHABLE default: __assume(0)
380 # define DEFAULT_UNREACHABLE
384 #define APPLICATION_ERROR_MASK 0x20000000
385 #define ERROR_SEVERITY_SUCCESS 0x00000000
386 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
387 #define ERROR_SEVERITY_WARNING 0x80000000
388 #define ERROR_SEVERITY_ERROR 0xC0000000
391 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
393 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
394 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
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) { return (ENUMTYPE)(~((int)a)); } \
398 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \
399 inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
402 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
405 /* Microsoft's macros for declaring functions */
408 # define EXTERN_C extern "C"
410 # define EXTERN_C extern
413 #define STDMETHODCALLTYPE __stdcall
414 #define STDMETHODVCALLTYPE __cdecl
415 #define STDAPICALLTYPE __stdcall
416 #define STDAPIVCALLTYPE __cdecl
418 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
419 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
420 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
421 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
422 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
423 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
424 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
425 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
427 /* Define the basic types */
432 typedef VOID *PVOID64;
433 typedef BYTE BOOLEAN, *PBOOLEAN;
434 typedef char CHAR, *PCHAR;
435 typedef short SHORT, *PSHORT;
437 typedef long LONG, *PLONG;
439 typedef int LONG, *PLONG;
442 /* Some systems might have wchar_t, but we really need 16 bit characters */
443 #ifdef WINE_UNICODE_NATIVE
444 typedef wchar_t WCHAR, *PWCHAR;
446 typedef unsigned short WCHAR, *PWCHAR;
449 typedef ULONG UCSCHAR;
450 #define MIN_UCSCHAR (0)
451 #define MAX_UCSCHAR (0x0010ffff)
452 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
454 /* 'Extended/Wide' numerical types */
458 typedef signed __int64 LONGLONG, *PLONGLONG;
459 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
461 typedef signed __int64 DECLSPEC_ALIGN(8) LONGLONG, *PLONGLONG;
462 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONGLONG, *PULONGLONG;
469 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
471 typedef ULONGLONG DECLSPEC_ALIGN(8) DWORDLONG, *PDWORDLONG;
475 /* ANSI string types */
476 typedef CHAR *PCH, *LPCH, *PNZCH;
477 typedef const CHAR *PCCH, *LPCCH, *PCNZCH;
478 typedef CHAR *PSTR, *LPSTR, *NPSTR;
479 typedef const CHAR *PCSTR, *LPCSTR;
480 typedef CHAR *PZZSTR;
481 typedef const CHAR *PCZZSTR;
483 /* Unicode string types */
484 typedef const WCHAR *PCWCHAR, *LPCUWCHAR, *PCUWCHAR;
485 typedef WCHAR *PWCH, *LPWCH;
486 typedef const WCHAR *PCWCH, *LPCWCH;
487 typedef WCHAR *PNZWCH, *PUNZWCH;
488 typedef const WCHAR *PCNZWCH, *PCUNZWCH;
489 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
490 typedef const WCHAR *PCWSTR, *LPCWSTR;
491 typedef WCHAR *PZZWSTR, *PUZZWSTR;
492 typedef const WCHAR *PCZZWSTR, *PCUZZWSTR;
493 typedef PWSTR *PZPWSTR;
494 typedef PCWSTR *PZPCWSTR;
496 /* Neutral character and string types */
497 /* These are only defined for Winelib, i.e. _not_ defined for
498 * the emulator. The reason is they depend on the UNICODE
499 * macro which only exists in the user's code.
501 #ifndef WINE_NO_UNICODE_MACROS
503 # ifndef _TCHAR_DEFINED
504 typedef WCHAR TCHAR, *PTCHAR;
505 # define _TCHAR_DEFINED
507 typedef LPWCH PTCH, LPTCH;
508 typedef LPCWCH PCTCH, LPCTCH;
509 typedef LPWSTR PTSTR, LPTSTR;
510 typedef LPCWSTR PCTSTR, LPCTSTR;
511 typedef LPWSTR PUTSTR, LPUTSTR;
512 typedef LPCWSTR PCUTSTR, LPCUTSTR;
513 typedef PNZWCH PNZTCH;
514 typedef PUNZWCH PUNZTCH;
515 typedef PCNZWCH PCNZTCH;
516 typedef PCUNZWCH PCUNZTCH;
517 typedef PZZWSTR PZZTSTR;
518 typedef PCZZWSTR PCZZTSTR;
519 typedef PUZZWSTR PUZZTSTR;
520 typedef PCUZZWSTR PCUZZTSTR;
522 # ifndef _TCHAR_DEFINED
523 typedef CHAR TCHAR, *PTCHAR;
524 # define _TCHAR_DEFINED
526 typedef LPCH PTCH, LPTCH;
527 typedef LPCCH PCTCH, LPCTCH;
528 typedef LPSTR PTSTR, LPTSTR;
529 typedef LPCSTR PCTSTR, LPCTSTR;
530 typedef PNZCH PNZTCH, PUNZTCH;
531 typedef PCNZCH PCNZTCH, PCUNZTCH;
532 typedef PZZSTR PZZTSTR, PUZZTSTR;
533 typedef PCZZSTR PCZZTSTR, PCUZZTSTR;
534 # endif /* UNICODE */
535 #endif /* WINE_NO_UNICODE_MACROS */
537 /* UCS string types */
538 typedef UCSCHAR *PUCSCHAR, *PUUCSCHAR;
539 typedef const UCSCHAR *PCUCSCHAR, *PCUUCSCHAR;
540 typedef UCSCHAR *PUCSSTR, *PUUCSSTR;
541 typedef const UCSCHAR *PCUCSSTR, *PCUUCSSTR;
543 /* Misc common WIN32 types */
545 typedef DWORD LCID, *PLCID;
547 typedef DWORD EXECUTION_STATE;
548 #ifndef _HRESULT_DEFINED
549 #define _HRESULT_DEFINED
550 typedef LONG HRESULT;
555 typedef void *HANDLE;
556 typedef HANDLE *PHANDLE, *LPHANDLE;
559 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
561 #define DECLARE_HANDLE(a) typedef HANDLE a
568 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
570 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
571 # define __MSABI_LONG(x) x ## l
573 # define __MSABI_LONG(x) x
579 #ifndef WIN32_NO_STATUS
581 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
582 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
583 #define STATUS_USER_APC ((DWORD) 0x000000C0)
584 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
585 #define STATUS_PENDING ((DWORD) 0x00000103)
586 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
587 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
588 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
589 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
590 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
591 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
592 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
593 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
594 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
595 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
596 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
597 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
598 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
599 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
600 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
601 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
602 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
603 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
604 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
605 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
606 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
607 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
608 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
609 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
610 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
611 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
612 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
613 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
614 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
615 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
617 /* status values for ContinueDebugEvent */
618 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
619 #define DBG_CONTINUE ((DWORD) 0x00010002)
620 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
621 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
622 #define DBG_CONTROL_C ((DWORD) 0x40010005)
623 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
624 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
625 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
627 #endif /* WIN32_NO_STATUS */
629 /* Argument 1 passed to the DllEntryProc. */
630 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
631 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
632 #define DLL_THREAD_ATTACH 2 /* attach new thread */
633 #define DLL_THREAD_DETACH 3 /* detach thread */
635 #define DLL_WINE_PREATTACH 8 /* called before process attach for Wine builtins */
638 /* u.x.wProcessorArchitecture (NT) */
639 #define PROCESSOR_ARCHITECTURE_INTEL 0
640 #define PROCESSOR_ARCHITECTURE_MIPS 1
641 #define PROCESSOR_ARCHITECTURE_ALPHA 2
642 #define PROCESSOR_ARCHITECTURE_PPC 3
643 #define PROCESSOR_ARCHITECTURE_SHX 4
644 #define PROCESSOR_ARCHITECTURE_ARM 5
645 #define PROCESSOR_ARCHITECTURE_IA64 6
646 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
647 #define PROCESSOR_ARCHITECTURE_MSIL 8
648 #define PROCESSOR_ARCHITECTURE_AMD64 9
649 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
650 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
653 #define PROCESSOR_ARCHITECTURE_SPARC 20
655 /* dwProcessorType */
656 #define PROCESSOR_INTEL_386 386
657 #define PROCESSOR_INTEL_486 486
658 #define PROCESSOR_INTEL_PENTIUM 586
659 #define PROCESSOR_INTEL_860 860
660 #define PROCESSOR_INTEL_IA64 2200
661 #define PROCESSOR_AMD_X8664 8664
662 #define PROCESSOR_MIPS_R2000 2000
663 #define PROCESSOR_MIPS_R3000 3000
664 #define PROCESSOR_MIPS_R4000 4000
665 #define PROCESSOR_ALPHA_21064 21064
666 #define PROCESSOR_PPC_601 601
667 #define PROCESSOR_PPC_603 603
668 #define PROCESSOR_PPC_604 604
669 #define PROCESSOR_PPC_620 620
670 #define PROCESSOR_HITACHI_SH3 10003
671 #define PROCESSOR_HITACHI_SH3E 10004
672 #define PROCESSOR_HITACHI_SH4 10005
673 #define PROCESSOR_MOTOROLA_821 821
674 #define PROCESSOR_SHx_SH3 103
675 #define PROCESSOR_SHx_SH4 104
676 #define PROCESSOR_STRONGARM 2577
677 #define PROCESSOR_ARM720 1824 /* 0x720 */
678 #define PROCESSOR_ARM820 2080 /* 0x820 */
679 #define PROCESSOR_ARM920 2336 /* 0x920 */
680 #define PROCESSOR_ARM_7TDMI 70001
681 #define PROCESSOR_OPTIL 18767
684 #define MAXIMUM_PROCESSORS 64
686 #define MAXIMUM_PROCESSORS 32
689 typedef struct _MEMORY_BASIC_INFORMATION
692 LPVOID AllocationBase;
693 DWORD AllocationProtect;
698 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
700 #define PAGE_NOACCESS 0x01
701 #define PAGE_READONLY 0x02
702 #define PAGE_READWRITE 0x04
703 #define PAGE_WRITECOPY 0x08
704 #define PAGE_EXECUTE 0x10
705 #define PAGE_EXECUTE_READ 0x20
706 #define PAGE_EXECUTE_READWRITE 0x40
707 #define PAGE_EXECUTE_WRITECOPY 0x80
708 #define PAGE_GUARD 0x100
709 #define PAGE_NOCACHE 0x200
710 #define PAGE_WRITECOMBINE 0x400
712 #define MEM_COMMIT 0x00001000
713 #define MEM_RESERVE 0x00002000
714 #define MEM_DECOMMIT 0x00004000
715 #define MEM_RELEASE 0x00008000
716 #define MEM_FREE 0x00010000
717 #define MEM_PRIVATE 0x00020000
718 #define MEM_MAPPED 0x00040000
719 #define MEM_RESET 0x00080000
720 #define MEM_TOP_DOWN 0x00100000
721 #define MEM_WRITE_WATCH 0x00200000
722 #define MEM_PHYSICAL 0x00400000
723 #define MEM_LARGE_PAGES 0x20000000
724 #define MEM_4MB_PAGES 0x80000000
726 #define SEC_FILE 0x00800000
727 #define SEC_IMAGE 0x01000000
728 #define SEC_RESERVE 0x04000000
729 #define SEC_COMMIT 0x08000000
730 #define SEC_NOCACHE 0x10000000
731 #define SEC_LARGE_PAGES 0x80000000
732 #define MEM_IMAGE SEC_IMAGE
734 #define WRITE_WATCH_FLAG_RESET 0x00000001
739 #define MINSHORT 0x8000
740 #define MAXSHORT 0x7fff
741 #define MINLONG 0x80000000
742 #define MAXLONG 0x7fffffff
744 #define MAXWORD 0xffff
745 #define MAXDWORD 0xffffffff
747 #define UNICODE_STRING_MAX_CHARS 32767
749 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
751 #define CONTAINING_RECORD(address, type, field) \
752 ((type *)((PCHAR)(address) - offsetof(type, field)))
756 typedef struct _LIST_ENTRY {
757 struct _LIST_ENTRY *Flink;
758 struct _LIST_ENTRY *Blink;
759 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
761 typedef struct _SINGLE_LIST_ENTRY {
762 struct _SINGLE_LIST_ENTRY *Next;
763 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
767 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
768 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
772 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
779 ULONGLONG Sequence:9;
780 ULONGLONG NextEntry:39;
781 ULONGLONG HeaderType:1;
783 ULONGLONG Reserved:59;
788 ULONGLONG Sequence:48;
789 ULONGLONG HeaderType:1;
791 ULONGLONG Reserved:2;
792 ULONGLONG NextEntry:60;
794 } SLIST_HEADER, *PSLIST_HEADER;
798 #undef SLIST_ENTRY /* for Mac OS */
799 #define SLIST_ENTRY SINGLE_LIST_ENTRY
800 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
801 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
803 typedef union _SLIST_HEADER {
810 } SLIST_HEADER, *PSLIST_HEADER;
814 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
815 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
816 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
817 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
818 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
819 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
824 #define HEAP_NO_SERIALIZE 0x00000001
825 #define HEAP_GROWABLE 0x00000002
826 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
827 #define HEAP_ZERO_MEMORY 0x00000008
828 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
829 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
830 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
831 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
832 #define HEAP_CREATE_ALIGN_16 0x00010000
833 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
834 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
836 /* This flag allows it to create heaps shared by all processes under win95,
837 FIXME: correct name */
838 #define HEAP_SHARED 0x04000000
840 typedef enum _HEAP_INFORMATION_CLASS {
841 HeapCompatibilityInformation,
842 } HEAP_INFORMATION_CLASS;
844 /* Processor feature flags. */
845 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
846 #define PF_FLOATING_POINT_EMULATED 1
847 #define PF_COMPARE_EXCHANGE_DOUBLE 2
848 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
849 #define PF_PPC_MOVEMEM_64BIT_OK 4
850 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
851 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
852 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
853 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
854 #define PF_PAE_ENABLED 9
855 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
856 #define PF_SSE_DAZ_MODE_AVAILABLE 11
857 #define PF_NX_ENABLED 12
858 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
859 #define PF_COMPARE_EXCHANGE128 14
860 #define PF_COMPARE64_EXCHANGE128 15
861 #define PF_CHANNELS_ENABLED 16
862 #define PF_XSAVE_ENABLED 17
863 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
864 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
865 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
866 #define PF_VIRT_FIRMWARE_ENABLED 21
867 #define PF_RDWRFSGSBASE_AVAILABLE 22
870 /* Execution state flags */
871 #define ES_SYSTEM_REQUIRED 0x00000001
872 #define ES_DISPLAY_REQUIRED 0x00000002
873 #define ES_USER_PRESENT 0x00000004
874 #define ES_CONTINUOUS 0x80000000
876 /* The Win32 register context */
878 /* i386 context definitions */
881 #define SIZE_OF_80387_REGISTERS 80
883 typedef struct _FLOATING_SAVE_AREA
892 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
894 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
896 #define MAXIMUM_SUPPORTED_EXTENSION 512
898 typedef struct _CONTEXT
902 /* These are selected by CONTEXT_DEBUG_REGISTERS */
910 /* These are selected by CONTEXT_FLOATING_POINT */
911 FLOATING_SAVE_AREA FloatSave;
913 /* These are selected by CONTEXT_SEGMENTS */
919 /* These are selected by CONTEXT_INTEGER */
927 /* These are selected by CONTEXT_CONTROL */
935 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
938 #define CONTEXT_X86 0x00010000
939 #define CONTEXT_i386 CONTEXT_X86
940 #define CONTEXT_i486 CONTEXT_X86
942 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
943 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
944 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
945 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
946 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
947 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
948 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
949 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
950 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
952 #define EXCEPTION_READ_FAULT 0
953 #define EXCEPTION_WRITE_FAULT 1
954 #define EXCEPTION_EXECUTE_FAULT 8
956 #endif /* __i386__ */
958 typedef struct _LDT_ENTRY {
973 unsigned LimitHi : 4;
975 unsigned Reserved_0 : 1;
976 unsigned Default_Big : 1;
977 unsigned Granularity : 1;
981 } LDT_ENTRY, *PLDT_ENTRY;
983 /* x86-64 context definitions */
984 #if defined(__x86_64__)
986 #define CONTEXT_AMD64 0x00100000
988 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
989 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
990 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
991 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
992 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
993 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
994 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
996 #define EXCEPTION_READ_FAULT 0
997 #define EXCEPTION_WRITE_FAULT 1
998 #define EXCEPTION_EXECUTE_FAULT 8
1000 typedef struct DECLSPEC_ALIGN(16) _M128A {
1005 typedef struct _XMM_SAVE_AREA32 {
1006 WORD ControlWord; /* 000 */
1007 WORD StatusWord; /* 002 */
1008 BYTE TagWord; /* 004 */
1009 BYTE Reserved1; /* 005 */
1010 WORD ErrorOpcode; /* 006 */
1011 DWORD ErrorOffset; /* 008 */
1012 WORD ErrorSelector; /* 00c */
1013 WORD Reserved2; /* 00e */
1014 DWORD DataOffset; /* 010 */
1015 WORD DataSelector; /* 014 */
1016 WORD Reserved3; /* 016 */
1017 DWORD MxCsr; /* 018 */
1018 DWORD MxCsr_Mask; /* 01c */
1019 M128A FloatRegisters[8]; /* 020 */
1020 M128A XmmRegisters[16]; /* 0a0 */
1021 BYTE Reserved4[96]; /* 1a0 */
1022 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1024 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1025 DWORD64 P1Home; /* 000 */
1026 DWORD64 P2Home; /* 008 */
1027 DWORD64 P3Home; /* 010 */
1028 DWORD64 P4Home; /* 018 */
1029 DWORD64 P5Home; /* 020 */
1030 DWORD64 P6Home; /* 028 */
1033 DWORD ContextFlags; /* 030 */
1034 DWORD MxCsr; /* 034 */
1037 WORD SegCs; /* 038 */
1038 WORD SegDs; /* 03a */
1039 WORD SegEs; /* 03c */
1040 WORD SegFs; /* 03e */
1041 WORD SegGs; /* 040 */
1042 WORD SegSs; /* 042 */
1043 DWORD EFlags; /* 044 */
1046 DWORD64 Dr0; /* 048 */
1047 DWORD64 Dr1; /* 050 */
1048 DWORD64 Dr2; /* 058 */
1049 DWORD64 Dr3; /* 060 */
1050 DWORD64 Dr6; /* 068 */
1051 DWORD64 Dr7; /* 070 */
1054 DWORD64 Rax; /* 078 */
1055 DWORD64 Rcx; /* 080 */
1056 DWORD64 Rdx; /* 088 */
1057 DWORD64 Rbx; /* 090 */
1058 DWORD64 Rsp; /* 098 */
1059 DWORD64 Rbp; /* 0a0 */
1060 DWORD64 Rsi; /* 0a8 */
1061 DWORD64 Rdi; /* 0b0 */
1062 DWORD64 R8; /* 0b8 */
1063 DWORD64 R9; /* 0c0 */
1064 DWORD64 R10; /* 0c8 */
1065 DWORD64 R11; /* 0d0 */
1066 DWORD64 R12; /* 0d8 */
1067 DWORD64 R13; /* 0e0 */
1068 DWORD64 R14; /* 0e8 */
1069 DWORD64 R15; /* 0f0 */
1072 DWORD64 Rip; /* 0f8 */
1074 /* Floating point */
1076 XMM_SAVE_AREA32 FltSave; /* 100 */
1078 M128A Header[2]; /* 100 */
1079 M128A Legacy[8]; /* 120 */
1080 M128A Xmm0; /* 1a0 */
1081 M128A Xmm1; /* 1b0 */
1082 M128A Xmm2; /* 1c0 */
1083 M128A Xmm3; /* 1d0 */
1084 M128A Xmm4; /* 1e0 */
1085 M128A Xmm5; /* 1f0 */
1086 M128A Xmm6; /* 200 */
1087 M128A Xmm7; /* 210 */
1088 M128A Xmm8; /* 220 */
1089 M128A Xmm9; /* 230 */
1090 M128A Xmm10; /* 240 */
1091 M128A Xmm11; /* 250 */
1092 M128A Xmm12; /* 260 */
1093 M128A Xmm13; /* 270 */
1094 M128A Xmm14; /* 280 */
1095 M128A Xmm15; /* 290 */
1100 M128A VectorRegister[26]; /* 300 */
1101 DWORD64 VectorControl; /* 4a0 */
1104 DWORD64 DebugControl; /* 4a8 */
1105 DWORD64 LastBranchToRip; /* 4b0 */
1106 DWORD64 LastBranchFromRip; /* 4b8 */
1107 DWORD64 LastExceptionToRip; /* 4c0 */
1108 DWORD64 LastExceptionFromRip; /* 4c8 */
1111 typedef struct _RUNTIME_FUNCTION
1116 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1118 #define UNWIND_HISTORY_TABLE_SIZE 12
1120 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1123 PRUNTIME_FUNCTION FunctionEntry;
1124 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1126 #define UNWIND_HISTORY_TABLE_NONE 0
1127 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1128 #define UNWIND_HISTORY_TABLE_LOCAL 2
1130 typedef struct _UNWIND_HISTORY_TABLE
1135 ULONG64 HighAddress;
1136 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1137 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1139 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1143 PM128A FloatingContext[16];
1167 PULONG64 IntegerContext[16];
1188 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1190 BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD64);
1191 BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1192 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD64,DWORD64*,UNWIND_HISTORY_TABLE*);
1193 PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1195 #define UNW_FLAG_NHANDLER 0
1196 #define UNW_FLAG_EHANDLER 1
1197 #define UNW_FLAG_UHANDLER 2
1198 #define UNW_FLAG_CHAININFO 4
1200 #endif /* __x86_64__ */
1202 /* IA64 context definitions */
1205 #define CONTEXT_IA64 0x00080000
1206 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1207 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1208 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1209 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1210 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1211 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1212 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1213 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1214 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1216 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1217 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1218 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1219 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1221 typedef struct _CONTEXT
1416 ULONGLONG RsBSPSTORE;
1430 ULONGLONG UNUSEDPACK;
1431 } CONTEXT, *PCONTEXT;
1433 typedef struct _RUNTIME_FUNCTION
1437 ULONG UnwindInfoAddress;
1438 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1440 typedef struct _FRAME_POINTERS {
1441 ULONGLONG MemoryStackFp;
1442 ULONGLONG BackingStoreFp;
1443 } FRAME_POINTERS, *PFRAME_POINTERS;
1445 #define UNWIND_HISTORY_TABLE_SIZE 12
1447 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
1450 PRUNTIME_FUNCTION FunctionEntry;
1451 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1453 typedef struct _UNWIND_HISTORY_TABLE {
1457 ULONG64 HighAddress;
1458 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1459 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1461 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1467 PFLOAT128 HighFloatingContext[10];
1489 PULONGLONG IntS0Nat;
1490 PULONGLONG IntS1Nat;
1491 PULONGLONG IntS2Nat;
1492 PULONGLONG IntS3Nat;
1493 PULONGLONG IntSpNat;
1509 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1511 ULONGLONG WINAPI RtlVirtualUnwind(ULONGLONG,ULONGLONG,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,FRAME_POINTERS*,KNONVOLATILE_CONTEXT_POINTERS*);
1513 #endif /* __ia64__ */
1515 /* Alpha context definitions */
1516 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1518 #define CONTEXT_ALPHA 0x00020000
1520 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1521 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1522 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1523 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1525 #define EXCEPTION_READ_FAULT 0
1526 #define EXCEPTION_WRITE_FAULT 1
1527 #define EXCEPTION_EXECUTE_FAULT 8
1529 typedef struct _CONTEXT
1531 /* selected by CONTEXT_FLOATING_POINT */
1565 /* selected by CONTEXT_INTEGER */
1599 /* selected by CONTEXT_FLOATING_POINT */
1603 /* selected by CONTEXT_CONTROL */
1610 #define _QUAD_PSR_OFFSET HighSoftFpcr
1611 #define _QUAD_FLAGS_OFFSET HighFir
1613 #endif /* _ALPHA_ */
1617 /* The following flags control the contents of the CONTEXT structure. */
1619 #define CONTEXT_ARM 0x0200000
1620 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1621 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1622 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1623 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1625 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1627 #define EXCEPTION_READ_FAULT 0
1628 #define EXCEPTION_WRITE_FAULT 1
1629 #define EXCEPTION_EXECUTE_FAULT 8
1631 typedef struct _CONTEXT {
1632 /* The flags values within this flag control the contents of
1635 If the context record is used as an input parameter, then
1636 for each portion of the context record controlled by a flag
1637 whose value is set, it is assumed that that portion of the
1638 context record contains valid context. If the context record
1639 is being used to modify a thread's context, then only that
1640 portion of the threads context will be modified.
1642 If the context record is used as an IN OUT parameter to capture
1643 the context of a thread, then only those portions of the thread's
1644 context corresponding to set flags will be returned.
1646 The context record is never used as an OUT only parameter. */
1650 /* This section is specified/returned if the ContextFlags word contains
1651 the flag CONTEXT_INTEGER. */
1666 /* These are selected by CONTEXT_CONTROL */
1673 #endif /* __arm__ */
1676 /* Mips context definitions */
1677 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
1679 #define CONTEXT_R4000 0x00010000
1681 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
1682 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
1683 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
1685 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1687 #define EXCEPTION_READ_FAULT 0
1688 #define EXCEPTION_WRITE_FAULT 1
1689 #define EXCEPTION_EXECUTE_FAULT 8
1691 typedef struct _CONTEXT
1694 /* These are selected by CONTEXT_FLOATING_POINT */
1728 /* These are selected by CONTEXT_INTEGER */
1764 /* These are selected by CONTEXT_FLOATING_POINT */
1767 /* These are selected by CONTEXT_CONTROL */
1777 /* PowerPC context definitions */
1780 #define CONTEXT_CONTROL 0x0001
1781 #define CONTEXT_FLOATING_POINT 0x0002
1782 #define CONTEXT_INTEGER 0x0004
1783 #define CONTEXT_DEBUG_REGISTERS 0x0008
1784 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1786 #define EXCEPTION_READ_FAULT 0
1787 #define EXCEPTION_WRITE_FAULT 1
1788 #define EXCEPTION_EXECUTE_FAULT 8
1792 /* These are selected by CONTEXT_FLOATING_POINT */
1827 /* These are selected by CONTEXT_INTEGER */
1864 /* These are selected by CONTEXT_CONTROL */
1866 DWORD Iar; /* Instruction Address Register , aka PC ... */
1872 DWORD Dar; /* Fault registers for coredump */
1874 DWORD Trap; /* number of powerpc exception taken */
1876 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1887 typedef struct _STACK_FRAME_HEADER
1904 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
1906 #endif /* __powerpc__ */
1913 * There is no official CONTEXT structure defined for the SPARC
1914 * architecture, so I just made one up.
1916 * This structure is valid only for 32-bit SPARC architectures,
1917 * not for 64-bit SPARC.
1919 * Note that this structure contains only the 'top-level' registers;
1920 * the rest of the register window chain is not visible.
1922 * The layout follows the Solaris 'prgregset_t' structure.
1926 #define CONTEXT_SPARC 0x10000000
1928 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
1929 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
1930 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
1932 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1934 #define EXCEPTION_READ_FAULT 0
1935 #define EXCEPTION_WRITE_FAULT 1
1936 #define EXCEPTION_EXECUTE_FAULT 8
1938 typedef struct _CONTEXT
1942 /* These are selected by CONTEXT_INTEGER */
1976 /* These are selected by CONTEXT_CONTROL */
1984 /* FIXME: floating point registers missing */
1988 #endif /* __sparc__ */
1990 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1991 #error You need to define a CONTEXT for your CPU
1994 typedef CONTEXT *PCONTEXT;
1996 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
2001 #define PRODUCT_UNDEFINED 0x00000000
2002 #define PRODUCT_ULTIMATE 0x00000001
2003 #define PRODUCT_HOME_BASIC 0x00000002
2004 #define PRODUCT_HOME_PREMIUM 0x00000003
2005 #define PRODUCT_ENTERPRISE 0x00000004
2006 #define PRODUCT_HOME_BASIC_N 0x00000005
2007 #define PRODUCT_BUSINESS 0x00000006
2008 #define PRODUCT_STANDARD_SERVER 0x00000007
2009 #define PRODUCT_DATACENTER_SERVER 0x00000008
2010 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2011 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2012 #define PRODUCT_STARTER 0x0000000B
2013 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2014 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2015 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2016 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2017 #define PRODUCT_BUSINESS_N 0x00000010
2018 #define PRODUCT_WEB_SERVER 0x00000011
2019 #define PRODUCT_CLUSTER_SERVER 0x00000012
2020 #define PRODUCT_HOME_SERVER 0x00000013
2021 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2022 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2023 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2024 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2025 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2026 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2027 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2028 #define PRODUCT_ENTERPRISE_N 0x0000001B
2029 #define PRODUCT_ULTIMATE_N 0x0000001C
2030 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2031 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2032 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2033 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2034 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2035 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2036 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2037 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2038 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2039 #define PRODUCT_SERVER_V 0x00000025
2040 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2041 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2042 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2043 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2044 #define PRODUCT_HYPERV 0x0000002A
2045 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2046 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2047 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2048 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2049 #define PRODUCT_STARTER_N 0x0000002F
2050 #define PRODUCT_PROFESSIONAL 0x00000030
2051 #define PRODUCT_PROFESSIONAL_N 0x00000031
2052 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2053 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2054 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2055 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2056 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2057 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2058 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2059 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2060 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2061 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2062 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2063 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2064 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2065 #define PRODUCT_EMBEDDED 0x00000041
2066 #define PRODUCT_STARTER_E 0x00000042
2067 #define PRODUCT_HOME_BASIC_E 0x00000043
2068 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2069 #define PRODUCT_PROFESSIONAL_E 0x00000045
2070 #define PRODUCT_ENTERPRISE_E 0x00000046
2071 #define PRODUCT_ULTIMATE_E 0x00000047
2072 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2073 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2074 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2075 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2076 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2077 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2078 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2079 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2080 #define PRODUCT_CORE_ARM 0x00000061
2081 #define PRODUCT_CORE_N 0x00000062
2082 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2083 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2084 #define PRODUCT_CORE 0x00000065
2085 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2086 #define PRODUCT_UNLICENSED 0xABCDABCD
2093 #define MAKELCID(l, s) (MAKELONG(l, s))
2095 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2096 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2097 #define SUBLANGID(l) ((WORD)(l) >> 10)
2099 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2100 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2102 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2103 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2104 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2105 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2106 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2107 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2108 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2109 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2110 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2111 #define LOCALE_NAME_MAX_LENGTH 85
2114 #define UNREFERENCED_PARAMETER(u) (void)(u)
2115 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2116 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2122 * Definitions for IsTextUnicode()
2125 #define IS_TEXT_UNICODE_ASCII16 0x0001
2126 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2127 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2128 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2129 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2130 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2131 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2132 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2133 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2134 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2135 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2136 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2137 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2138 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2139 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2140 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2142 #define MAXIMUM_WAIT_OBJECTS 64
2143 #define MAXIMUM_SUSPEND_COUNT 127
2145 #define WT_EXECUTEDEFAULT 0x00
2146 #define WT_EXECUTEINIOTHREAD 0x01
2147 #define WT_EXECUTEINUITHREAD 0x02
2148 #define WT_EXECUTEINWAITTHREAD 0x04
2149 #define WT_EXECUTEONLYONCE 0x08
2150 #define WT_EXECUTELONGFUNCTION 0x10
2151 #define WT_EXECUTEINTIMERTHREAD 0x20
2152 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2153 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2154 #define WT_EXECUTEINLONGTHREAD 0x10
2155 #define WT_EXECUTEDELETEWAIT 0x08
2156 #define WT_TRANSFER_IMPERSONATION 0x0100
2159 #define EXCEPTION_CONTINUABLE 0
2160 #define EXCEPTION_NONCONTINUABLE 0x01
2163 * The exception record used by Win32 to give additional information
2164 * about exception to exception handlers.
2167 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2169 typedef struct _EXCEPTION_RECORD
2171 DWORD ExceptionCode;
2172 DWORD ExceptionFlags;
2173 struct _EXCEPTION_RECORD *ExceptionRecord;
2175 PVOID ExceptionAddress;
2176 DWORD NumberParameters;
2177 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2178 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2181 * The exception pointers structure passed to exception filters
2182 * in except() and the UnhandledExceptionFilter().
2185 typedef struct _EXCEPTION_POINTERS
2187 PEXCEPTION_RECORD ExceptionRecord;
2188 PCONTEXT ContextRecord;
2189 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2193 * The exception frame, used for registering exception handlers
2194 * Win32 cares only about this, but compilers generally emit
2195 * larger exception frames for their own use.
2198 struct _EXCEPTION_REGISTRATION_RECORD;
2200 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2201 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2203 typedef struct _EXCEPTION_REGISTRATION_RECORD
2205 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2206 PEXCEPTION_HANDLER Handler;
2207 } EXCEPTION_REGISTRATION_RECORD;
2210 * function pointer to an exception filter
2213 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2215 typedef struct _NT_TIB
2217 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2225 PVOID ArbitraryUserPointer;
2226 struct _NT_TIB *Self;
2231 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2232 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2235 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2238 #elif defined(__i386__) && defined(_MSC_VER)
2239 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2242 __asm mov eax, fs:[0x18];
2246 #elif defined(__x86_64__) && defined(__GNUC__)
2247 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2250 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2254 extern struct _TEB * WINAPI NtCurrentTeb(void);
2257 #ifdef NONAMELESSUNION
2258 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2260 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2262 #define GetFiberData() (*(void **)GetCurrentFiber())
2264 #define TLS_MINIMUM_AVAILABLE 64
2267 * File formats definitions
2270 #include <pshpack2.h>
2271 typedef struct _IMAGE_DOS_HEADER {
2272 WORD e_magic; /* 00: MZ Header signature */
2273 WORD e_cblp; /* 02: Bytes on last page of file */
2274 WORD e_cp; /* 04: Pages in file */
2275 WORD e_crlc; /* 06: Relocations */
2276 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2277 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2278 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2279 WORD e_ss; /* 0e: Initial (relative) SS value */
2280 WORD e_sp; /* 10: Initial SP value */
2281 WORD e_csum; /* 12: Checksum */
2282 WORD e_ip; /* 14: Initial IP value */
2283 WORD e_cs; /* 16: Initial (relative) CS value */
2284 WORD e_lfarlc; /* 18: File address of relocation table */
2285 WORD e_ovno; /* 1a: Overlay number */
2286 WORD e_res[4]; /* 1c: Reserved words */
2287 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2288 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2289 WORD e_res2[10]; /* 28: Reserved words */
2290 DWORD e_lfanew; /* 3c: Offset to extended header */
2291 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2292 #include <poppack.h>
2294 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2295 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2296 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2297 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2298 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2299 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2302 * This is the Windows executable (NE) header.
2303 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2305 #include <pshpack2.h>
2308 WORD ne_magic; /* 00 NE signature 'NE' */
2309 BYTE ne_ver; /* 02 Linker version number */
2310 BYTE ne_rev; /* 03 Linker revision number */
2311 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2312 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2313 LONG ne_crc; /* 08 Checksum */
2314 WORD ne_flags; /* 0c Flags about segments in this file */
2315 WORD ne_autodata; /* 0e Automatic data segment number */
2316 WORD ne_heap; /* 10 Initial size of local heap */
2317 WORD ne_stack; /* 12 Initial size of stack */
2318 DWORD ne_csip; /* 14 Initial CS:IP */
2319 DWORD ne_sssp; /* 18 Initial SS:SP */
2320 WORD ne_cseg; /* 1c # of entries in segment table */
2321 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2322 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2323 WORD ne_segtab; /* 22 Offset to segment table */
2324 WORD ne_rsrctab; /* 24 Offset to resource table */
2325 WORD ne_restab; /* 26 Offset to resident-name table */
2326 WORD ne_modtab; /* 28 Offset to module reference table */
2327 WORD ne_imptab; /* 2a Offset to imported name table */
2328 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2329 WORD ne_cmovent; /* 30 # of movable entry points */
2330 WORD ne_align; /* 32 Logical sector alignment shift count */
2331 WORD ne_cres; /* 34 # of resource segments */
2332 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2333 BYTE ne_flagsothers; /* 37 Additional information flags */
2334 WORD ne_pretthunks; /* 38 Offset to return thunks */
2335 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2336 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2337 WORD ne_expver; /* 3e Expected Windows version number */
2338 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2339 #include <poppack.h>
2341 #include <pshpack2.h>
2342 typedef struct _IMAGE_VXD_HEADER {
2357 DWORD e32_lastpagesize;
2358 DWORD e32_fixupsize;
2375 DWORD e32_impmodcnt;
2381 DWORD e32_cbnrestab;
2384 DWORD e32_debuginfo;
2386 DWORD e32_instpreload;
2387 DWORD e32_instdemand;
2390 DWORD e32_winresoff;
2391 DWORD e32_winreslen;
2394 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2395 #include <poppack.h>
2397 /* These defines describe the meanings of the bits in the Characteristics
2400 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2401 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2402 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2403 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2404 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2405 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2406 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2407 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2408 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2409 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2410 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2411 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2412 #define IMAGE_FILE_SYSTEM 0x1000
2413 #define IMAGE_FILE_DLL 0x2000
2414 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2415 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2417 /* These are the settings of the Machine field. */
2418 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2419 #define IMAGE_FILE_MACHINE_I860 0x014d
2420 #define IMAGE_FILE_MACHINE_I386 0x014c
2421 #define IMAGE_FILE_MACHINE_R3000 0x0162
2422 #define IMAGE_FILE_MACHINE_R4000 0x0166
2423 #define IMAGE_FILE_MACHINE_R10000 0x0168
2424 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2425 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2426 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2427 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2428 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2429 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2430 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2431 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2432 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2433 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2434 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2435 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2436 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2437 #define IMAGE_FILE_MACHINE_IA64 0x0200
2438 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2439 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2440 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2441 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2442 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2443 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2444 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2445 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2446 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2447 #define IMAGE_FILE_MACHINE_M32R 0x9041
2448 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2450 /* Wine extension */
2451 #define IMAGE_FILE_MACHINE_SPARC 0x2000
2453 #define IMAGE_SIZEOF_FILE_HEADER 20
2454 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2455 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2456 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2457 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2458 #define IMAGE_SIZEOF_SHORT_NAME 8
2459 #define IMAGE_SIZEOF_SECTION_HEADER 40
2460 #define IMAGE_SIZEOF_SYMBOL 18
2461 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2462 #define IMAGE_SIZEOF_RELOCATION 10
2463 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2464 #define IMAGE_SIZEOF_LINENUMBER 6
2465 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2467 /* Possible Magic values */
2468 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2469 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2470 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2473 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2474 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2476 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2477 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2480 /* These are indexes into the DataDirectory array */
2481 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2482 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2483 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2484 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2485 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2486 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2487 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2488 #define IMAGE_FILE_DESCRIPTION_STRING 7
2489 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2490 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2491 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2493 /* Directory Entries, indices into the DataDirectory array */
2495 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2496 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2497 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2498 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2499 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2500 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2501 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2502 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2503 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2504 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2505 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2506 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2507 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2508 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2509 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2511 /* Subsystem Values */
2513 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2514 #define IMAGE_SUBSYSTEM_NATIVE 1
2515 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2516 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2517 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2518 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2519 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2520 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2521 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2522 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2523 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2524 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2525 #define IMAGE_SUBSYSTEM_XBOX 14
2526 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2528 /* DLL Characteristics */
2529 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2530 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2531 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2532 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2533 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2534 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2535 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2536 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2538 typedef struct _IMAGE_FILE_HEADER {
2540 WORD NumberOfSections;
2541 DWORD TimeDateStamp;
2542 DWORD PointerToSymbolTable;
2543 DWORD NumberOfSymbols;
2544 WORD SizeOfOptionalHeader;
2545 WORD Characteristics;
2546 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2548 typedef struct _IMAGE_DATA_DIRECTORY {
2549 DWORD VirtualAddress;
2551 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2553 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2555 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2556 WORD Magic; /* 0x20b */
2557 BYTE MajorLinkerVersion;
2558 BYTE MinorLinkerVersion;
2560 DWORD SizeOfInitializedData;
2561 DWORD SizeOfUninitializedData;
2562 DWORD AddressOfEntryPoint;
2564 ULONGLONG ImageBase;
2565 DWORD SectionAlignment;
2566 DWORD FileAlignment;
2567 WORD MajorOperatingSystemVersion;
2568 WORD MinorOperatingSystemVersion;
2569 WORD MajorImageVersion;
2570 WORD MinorImageVersion;
2571 WORD MajorSubsystemVersion;
2572 WORD MinorSubsystemVersion;
2573 DWORD Win32VersionValue;
2575 DWORD SizeOfHeaders;
2578 WORD DllCharacteristics;
2579 ULONGLONG SizeOfStackReserve;
2580 ULONGLONG SizeOfStackCommit;
2581 ULONGLONG SizeOfHeapReserve;
2582 ULONGLONG SizeOfHeapCommit;
2584 DWORD NumberOfRvaAndSizes;
2585 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2586 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2588 typedef struct _IMAGE_NT_HEADERS64 {
2590 IMAGE_FILE_HEADER FileHeader;
2591 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2592 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2594 typedef struct _IMAGE_OPTIONAL_HEADER {
2596 /* Standard fields */
2598 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2599 BYTE MajorLinkerVersion;
2600 BYTE MinorLinkerVersion;
2602 DWORD SizeOfInitializedData;
2603 DWORD SizeOfUninitializedData;
2604 DWORD AddressOfEntryPoint; /* 0x10 */
2608 /* NT additional fields */
2611 DWORD SectionAlignment; /* 0x20 */
2612 DWORD FileAlignment;
2613 WORD MajorOperatingSystemVersion;
2614 WORD MinorOperatingSystemVersion;
2615 WORD MajorImageVersion;
2616 WORD MinorImageVersion;
2617 WORD MajorSubsystemVersion; /* 0x30 */
2618 WORD MinorSubsystemVersion;
2619 DWORD Win32VersionValue;
2621 DWORD SizeOfHeaders;
2622 DWORD CheckSum; /* 0x40 */
2624 WORD DllCharacteristics;
2625 DWORD SizeOfStackReserve;
2626 DWORD SizeOfStackCommit;
2627 DWORD SizeOfHeapReserve; /* 0x50 */
2628 DWORD SizeOfHeapCommit;
2630 DWORD NumberOfRvaAndSizes;
2631 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2633 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2635 typedef struct _IMAGE_NT_HEADERS {
2636 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2637 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2638 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2639 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2642 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2643 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2644 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2645 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2647 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2648 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2649 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2650 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2653 #define IMAGE_SIZEOF_SHORT_NAME 8
2655 typedef struct _IMAGE_SECTION_HEADER {
2656 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2658 DWORD PhysicalAddress;
2661 DWORD VirtualAddress;
2662 DWORD SizeOfRawData;
2663 DWORD PointerToRawData;
2664 DWORD PointerToRelocations;
2665 DWORD PointerToLinenumbers;
2666 WORD NumberOfRelocations;
2667 WORD NumberOfLinenumbers;
2668 DWORD Characteristics;
2669 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2671 #define IMAGE_SIZEOF_SECTION_HEADER 40
2673 #define IMAGE_FIRST_SECTION(ntheader) \
2674 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2675 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2677 /* These defines are for the Characteristics bitfield. */
2678 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2679 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2680 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2681 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2682 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2683 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2685 #define IMAGE_SCN_CNT_CODE 0x00000020
2686 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2687 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2689 #define IMAGE_SCN_LNK_OTHER 0x00000100
2690 #define IMAGE_SCN_LNK_INFO 0x00000200
2691 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2692 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2693 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2695 /* 0x00002000 - Reserved */
2696 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2697 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2699 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2700 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2701 #define IMAGE_SCN_MEM_16BIT 0x00020000
2702 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2703 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2705 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2706 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2707 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2708 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2709 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2710 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2711 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2712 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2713 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2714 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2715 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2716 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2717 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2718 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2719 /* 0x00F00000 - Unused */
2720 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2722 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2725 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2726 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2727 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2728 #define IMAGE_SCN_MEM_SHARED 0x10000000
2729 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2730 #define IMAGE_SCN_MEM_READ 0x40000000
2731 #define IMAGE_SCN_MEM_WRITE 0x80000000
2733 #include <pshpack2.h>
2735 typedef struct _IMAGE_SYMBOL {
2745 SHORT SectionNumber;
2748 BYTE NumberOfAuxSymbols;
2750 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2752 #define IMAGE_SIZEOF_SYMBOL 18
2754 typedef struct _IMAGE_LINENUMBER {
2756 DWORD SymbolTableIndex;
2757 DWORD VirtualAddress;
2761 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2763 #define IMAGE_SIZEOF_LINENUMBER 6
2765 typedef union _IMAGE_AUX_SYMBOL {
2777 DWORD PointerToLinenumber;
2778 DWORD PointerToNextFunction;
2787 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2791 WORD NumberOfRelocations;
2792 WORD NumberOfLinenumbers;
2798 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2800 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2802 #include <poppack.h>
2804 #define IMAGE_SYM_UNDEFINED (SHORT)0
2805 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2806 #define IMAGE_SYM_DEBUG (SHORT)-2
2808 #define IMAGE_SYM_TYPE_NULL 0x0000
2809 #define IMAGE_SYM_TYPE_VOID 0x0001
2810 #define IMAGE_SYM_TYPE_CHAR 0x0002
2811 #define IMAGE_SYM_TYPE_SHORT 0x0003
2812 #define IMAGE_SYM_TYPE_INT 0x0004
2813 #define IMAGE_SYM_TYPE_LONG 0x0005
2814 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2815 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2816 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2817 #define IMAGE_SYM_TYPE_UNION 0x0009
2818 #define IMAGE_SYM_TYPE_ENUM 0x000A
2819 #define IMAGE_SYM_TYPE_MOE 0x000B
2820 #define IMAGE_SYM_TYPE_BYTE 0x000C
2821 #define IMAGE_SYM_TYPE_WORD 0x000D
2822 #define IMAGE_SYM_TYPE_UINT 0x000E
2823 #define IMAGE_SYM_TYPE_DWORD 0x000F
2824 #define IMAGE_SYM_TYPE_PCODE 0x8000
2826 #define IMAGE_SYM_DTYPE_NULL 0
2827 #define IMAGE_SYM_DTYPE_POINTER 1
2828 #define IMAGE_SYM_DTYPE_FUNCTION 2
2829 #define IMAGE_SYM_DTYPE_ARRAY 3
2831 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2832 #define IMAGE_SYM_CLASS_NULL 0x0000
2833 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2834 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2835 #define IMAGE_SYM_CLASS_STATIC 0x0003
2836 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2837 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2838 #define IMAGE_SYM_CLASS_LABEL 0x0006
2839 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2840 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2841 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2842 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2843 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2844 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2845 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2846 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2847 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2848 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2849 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2850 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2852 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2853 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2854 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2855 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2856 #define IMAGE_SYM_CLASS_FILE 0x0067
2857 #define IMAGE_SYM_CLASS_SECTION 0x0068
2858 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2860 #define N_BTMASK 0x000F
2861 #define N_TMASK 0x0030
2862 #define N_TMASK1 0x00C0
2863 #define N_TMASK2 0x00F0
2867 #define BTYPE(x) ((x) & N_BTMASK)
2870 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2874 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2878 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2882 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2886 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2889 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2892 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2893 #define IMAGE_COMDAT_SELECT_ANY 2
2894 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2895 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2896 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2897 #define IMAGE_COMDAT_SELECT_LARGEST 6
2898 #define IMAGE_COMDAT_SELECT_NEWEST 7
2900 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2901 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2902 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2904 /* Export module directory */
2906 typedef struct _IMAGE_EXPORT_DIRECTORY {
2907 DWORD Characteristics;
2908 DWORD TimeDateStamp;
2913 DWORD NumberOfFunctions;
2914 DWORD NumberOfNames;
2915 DWORD AddressOfFunctions;
2916 DWORD AddressOfNames;
2917 DWORD AddressOfNameOrdinals;
2918 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2920 /* Import name entry */
2921 typedef struct _IMAGE_IMPORT_BY_NAME {
2924 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2926 #include <pshpack8.h>
2928 typedef struct _IMAGE_THUNK_DATA64 {
2930 ULONGLONG ForwarderString;
2933 ULONGLONG AddressOfData;
2935 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
2936 #include <poppack.h>
2938 typedef struct _IMAGE_THUNK_DATA32 {
2940 DWORD ForwarderString;
2943 DWORD AddressOfData;
2945 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
2947 /* Import module directory */
2949 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2951 DWORD Characteristics; /* 0 for terminating null import descriptor */
2952 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
2954 DWORD TimeDateStamp; /* 0 if not bound,
2955 * -1 if bound, and real date\time stamp
2956 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2958 * otherwise date/time stamp of DLL bound to
2961 DWORD ForwarderChain; /* -1 if no forwarders */
2963 /* RVA to IAT (if bound this IAT has actual addresses) */
2965 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2967 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
2968 #define IMAGE_ORDINAL_FLAG32 0x80000000
2969 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
2970 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
2971 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
2972 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
2975 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
2976 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
2977 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
2978 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
2979 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
2981 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
2982 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
2983 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
2984 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
2985 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
2988 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2990 DWORD TimeDateStamp;
2991 WORD OffsetModuleName;
2992 WORD NumberOfModuleForwarderRefs;
2993 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2994 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2996 typedef struct _IMAGE_BOUND_FORWARDER_REF
2998 DWORD TimeDateStamp;
2999 WORD OffsetModuleName;
3001 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3003 typedef struct _IMAGE_BASE_RELOCATION
3005 DWORD VirtualAddress;
3007 /* WORD TypeOffset[1]; */
3008 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3010 #include <pshpack2.h>
3012 typedef struct _IMAGE_RELOCATION
3015 DWORD VirtualAddress;
3018 DWORD SymbolTableIndex;
3020 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3022 #include <poppack.h>
3024 #define IMAGE_SIZEOF_RELOCATION 10
3026 /* generic relocation types */
3027 #define IMAGE_REL_BASED_ABSOLUTE 0
3028 #define IMAGE_REL_BASED_HIGH 1
3029 #define IMAGE_REL_BASED_LOW 2
3030 #define IMAGE_REL_BASED_HIGHLOW 3
3031 #define IMAGE_REL_BASED_HIGHADJ 4
3032 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3033 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3034 #define IMAGE_REL_BASED_SECTION 6
3035 #define IMAGE_REL_BASED_REL 7
3036 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3037 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3038 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3039 #define IMAGE_REL_BASED_DIR64 10
3040 #define IMAGE_REL_BASED_HIGH3ADJ 11
3042 /* I386 relocation types */
3043 #define IMAGE_REL_I386_ABSOLUTE 0
3044 #define IMAGE_REL_I386_DIR16 1
3045 #define IMAGE_REL_I386_REL16 2
3046 #define IMAGE_REL_I386_DIR32 6
3047 #define IMAGE_REL_I386_DIR32NB 7
3048 #define IMAGE_REL_I386_SEG12 9
3049 #define IMAGE_REL_I386_SECTION 10
3050 #define IMAGE_REL_I386_SECREL 11
3051 #define IMAGE_REL_I386_TOKEN 12
3052 #define IMAGE_REL_I386_SECREL7 13
3053 #define IMAGE_REL_I386_REL32 20
3055 /* MIPS relocation types */
3056 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3057 #define IMAGE_REL_MIPS_REFHALF 0x0001
3058 #define IMAGE_REL_MIPS_REFWORD 0x0002
3059 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3060 #define IMAGE_REL_MIPS_REFHI 0x0004
3061 #define IMAGE_REL_MIPS_REFLO 0x0005
3062 #define IMAGE_REL_MIPS_GPREL 0x0006
3063 #define IMAGE_REL_MIPS_LITERAL 0x0007
3064 #define IMAGE_REL_MIPS_SECTION 0x000A
3065 #define IMAGE_REL_MIPS_SECREL 0x000B
3066 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3067 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3068 #define IMAGE_REL_MIPS_TOKEN 0x000E
3069 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3070 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3071 #define IMAGE_REL_MIPS_PAIR 0x0025
3073 /* ALPHA relocation types */
3074 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3075 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3076 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3077 #define IMAGE_REL_ALPHA_GPREL 0x0003
3078 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3079 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3080 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3081 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3082 #define IMAGE_REL_ALPHA_HINT 0x0008
3083 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3084 #define IMAGE_REL_ALPHA_REFHI 0x000A
3085 #define IMAGE_REL_ALPHA_REFLO 0x000B
3086 #define IMAGE_REL_ALPHA_PAIR 0x000C
3087 #define IMAGE_REL_ALPHA_MATCH 0x000D
3088 #define IMAGE_REL_ALPHA_SECTION 0x000E
3089 #define IMAGE_REL_ALPHA_SECREL 0x000F
3090 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3091 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3092 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3093 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3094 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3095 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3096 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3097 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3099 /* PowerPC relocation types */
3100 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3101 #define IMAGE_REL_PPC_ADDR64 0x0001
3102 #define IMAGE_REL_PPC_ADDR 0x0002
3103 #define IMAGE_REL_PPC_ADDR24 0x0003
3104 #define IMAGE_REL_PPC_ADDR16 0x0004
3105 #define IMAGE_REL_PPC_ADDR14 0x0005
3106 #define IMAGE_REL_PPC_REL24 0x0006
3107 #define IMAGE_REL_PPC_REL14 0x0007
3108 #define IMAGE_REL_PPC_TOCREL16 0x0008
3109 #define IMAGE_REL_PPC_TOCREL14 0x0009
3110 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3111 #define IMAGE_REL_PPC_SECREL 0x000B
3112 #define IMAGE_REL_PPC_SECTION 0x000C
3113 #define IMAGE_REL_PPC_IFGLUE 0x000D
3114 #define IMAGE_REL_PPC_IMGLUE 0x000E
3115 #define IMAGE_REL_PPC_SECREL16 0x000F
3116 #define IMAGE_REL_PPC_REFHI 0x0010
3117 #define IMAGE_REL_PPC_REFLO 0x0011
3118 #define IMAGE_REL_PPC_PAIR 0x0012
3119 #define IMAGE_REL_PPC_SECRELLO 0x0013
3120 #define IMAGE_REL_PPC_SECRELHI 0x0014
3121 #define IMAGE_REL_PPC_GPREL 0x0015
3122 #define IMAGE_REL_PPC_TOKEN 0x0016
3123 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3125 #define IMAGE_REL_PPC_NEG 0x0100
3126 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3127 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3128 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3130 /* SH3 relocation types */
3131 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3132 #define IMAGE_REL_SH3_DIRECT16 0x0001
3133 #define IMAGE_REL_SH3_DIRECT 0x0002
3134 #define IMAGE_REL_SH3_DIRECT8 0x0003
3135 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3136 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3137 #define IMAGE_REL_SH3_DIRECT4 0x0006
3138 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3139 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3140 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3141 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3142 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3143 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3144 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3145 #define IMAGE_REL_SH3_SECTION 0x000E
3146 #define IMAGE_REL_SH3_SECREL 0x000F
3147 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3148 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3149 #define IMAGE_REL_SH3_TOKEN 0x0012
3151 /* ARM relocation types */
3152 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3153 #define IMAGE_REL_ARM_ADDR 0x0001
3154 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3155 #define IMAGE_REL_ARM_BRANCH24 0x0003
3156 #define IMAGE_REL_ARM_BRANCH11 0x0004
3157 #define IMAGE_REL_ARM_TOKEN 0x0005
3158 #define IMAGE_REL_ARM_GPREL12 0x0006
3159 #define IMAGE_REL_ARM_GPREL7 0x0007
3160 #define IMAGE_REL_ARM_BLX24 0x0008
3161 #define IMAGE_REL_ARM_BLX11 0x0009
3162 #define IMAGE_REL_ARM_SECTION 0x000E
3163 #define IMAGE_REL_ARM_SECREL 0x000F
3164 #define IMAGE_REL_ARM_MOV32A 0x0010
3165 #define IMAGE_REL_ARM_MOV32T 0x0011
3166 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3167 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3168 #define IMAGE_REL_ARM_BLX23T 0x0015
3170 /* IA64 relocation types */
3171 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3172 #define IMAGE_REL_IA64_IMM14 0x0001
3173 #define IMAGE_REL_IA64_IMM22 0x0002
3174 #define IMAGE_REL_IA64_IMM64 0x0003
3175 #define IMAGE_REL_IA64_DIR 0x0004
3176 #define IMAGE_REL_IA64_DIR64 0x0005
3177 #define IMAGE_REL_IA64_PCREL21B 0x0006
3178 #define IMAGE_REL_IA64_PCREL21M 0x0007
3179 #define IMAGE_REL_IA64_PCREL21F 0x0008
3180 #define IMAGE_REL_IA64_GPREL22 0x0009
3181 #define IMAGE_REL_IA64_LTOFF22 0x000A
3182 #define IMAGE_REL_IA64_SECTION 0x000B
3183 #define IMAGE_REL_IA64_SECREL22 0x000C
3184 #define IMAGE_REL_IA64_SECREL64I 0x000D
3185 #define IMAGE_REL_IA64_SECREL 0x000E
3186 #define IMAGE_REL_IA64_LTOFF64 0x000F
3187 #define IMAGE_REL_IA64_DIR32NB 0x0010
3188 #define IMAGE_REL_IA64_SREL14 0x0011
3189 #define IMAGE_REL_IA64_SREL22 0x0012
3190 #define IMAGE_REL_IA64_SREL32 0x0013
3191 #define IMAGE_REL_IA64_UREL32 0x0014
3192 #define IMAGE_REL_IA64_PCREL60X 0x0015
3193 #define IMAGE_REL_IA64_PCREL60B 0x0016
3194 #define IMAGE_REL_IA64_PCREL60F 0x0017
3195 #define IMAGE_REL_IA64_PCREL60I 0x0018
3196 #define IMAGE_REL_IA64_PCREL60M 0x0019
3197 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3198 #define IMAGE_REL_IA64_TOKEN 0x001B
3199 #define IMAGE_REL_IA64_GPREL32 0x001C
3200 #define IMAGE_REL_IA64_ADDEND 0x001F
3202 /* AMD64 relocation types */
3203 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3204 #define IMAGE_REL_AMD64_ADDR64 0x0001
3205 #define IMAGE_REL_AMD64_ADDR32 0x0002
3206 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3207 #define IMAGE_REL_AMD64_REL32 0x0004
3208 #define IMAGE_REL_AMD64_REL32_1 0x0005
3209 #define IMAGE_REL_AMD64_REL32_2 0x0006
3210 #define IMAGE_REL_AMD64_REL32_3 0x0007
3211 #define IMAGE_REL_AMD64_REL32_4 0x0008
3212 #define IMAGE_REL_AMD64_REL32_5 0x0009
3213 #define IMAGE_REL_AMD64_SECTION 0x000A
3214 #define IMAGE_REL_AMD64_SECREL 0x000B
3215 #define IMAGE_REL_AMD64_SECREL7 0x000C
3216 #define IMAGE_REL_AMD64_TOKEN 0x000D
3217 #define IMAGE_REL_AMD64_SREL32 0x000E
3218 #define IMAGE_REL_AMD64_PAIR 0x000F
3219 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3221 /* archive format */
3223 #define IMAGE_ARCHIVE_START_SIZE 8
3224 #define IMAGE_ARCHIVE_START "!<arch>\n"
3225 #define IMAGE_ARCHIVE_END "`\n"
3226 #define IMAGE_ARCHIVE_PAD "\n"
3227 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3228 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3230 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3239 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3241 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3243 typedef struct _IMPORT_OBJECT_HEADER
3249 DWORD TimeDateStamp;
3259 } IMPORT_OBJECT_HEADER;
3261 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3263 typedef enum IMPORT_OBJECT_TYPE
3265 IMPORT_OBJECT_CODE = 0,
3266 IMPORT_OBJECT_DATA = 1,
3267 IMPORT_OBJECT_CONST = 2
3268 } IMPORT_OBJECT_TYPE;
3270 typedef enum IMPORT_OBJECT_NAME_TYPE
3272 IMPORT_OBJECT_ORDINAL = 0,
3273 IMPORT_OBJECT_NAME = 1,
3274 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3275 IMPORT_OBJECT_NAME_UNDECORATE = 3
3276 } IMPORT_OBJECT_NAME_TYPE;
3278 typedef struct _ANON_OBJECT_HEADER
3284 DWORD TimeDateStamp;
3287 } ANON_OBJECT_HEADER;
3290 * Resource directory stuff
3292 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3293 DWORD Characteristics;
3294 DWORD TimeDateStamp;
3297 WORD NumberOfNamedEntries;
3298 WORD NumberOfIdEntries;
3299 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3300 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3302 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3303 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3305 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3308 #ifdef BITFIELDS_BIGENDIAN
3309 unsigned NameIsString:1;
3310 unsigned NameOffset:31;
3312 unsigned NameOffset:31;
3313 unsigned NameIsString:1;
3318 #ifdef WORDS_BIGENDIAN
3330 #ifdef BITFIELDS_BIGENDIAN
3331 unsigned DataIsDirectory:1;
3332 unsigned OffsetToDirectory:31;
3334 unsigned OffsetToDirectory:31;
3335 unsigned DataIsDirectory:1;
3339 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3342 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3344 CHAR NameString[ 1 ];
3345 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3347 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3349 WCHAR NameString[ 1 ];
3350 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3352 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3357 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3360 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3361 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3364 typedef struct _IMAGE_TLS_DIRECTORY64 {
3365 ULONGLONG StartAddressOfRawData;
3366 ULONGLONG EndAddressOfRawData;
3367 ULONGLONG AddressOfIndex;
3368 ULONGLONG AddressOfCallBacks;
3369 DWORD SizeOfZeroFill;
3370 DWORD Characteristics;
3371 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3373 typedef struct _IMAGE_TLS_DIRECTORY32 {
3374 DWORD StartAddressOfRawData;
3375 DWORD EndAddressOfRawData;
3376 DWORD AddressOfIndex;
3377 DWORD AddressOfCallBacks;
3378 DWORD SizeOfZeroFill;
3379 DWORD Characteristics;
3380 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3383 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3384 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3386 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3387 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3390 typedef struct _IMAGE_DEBUG_DIRECTORY {
3391 DWORD Characteristics;
3392 DWORD TimeDateStamp;
3397 DWORD AddressOfRawData;
3398 DWORD PointerToRawData;
3399 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3401 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3402 #define IMAGE_DEBUG_TYPE_COFF 1
3403 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3404 #define IMAGE_DEBUG_TYPE_FPO 3
3405 #define IMAGE_DEBUG_TYPE_MISC 4
3406 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3407 #define IMAGE_DEBUG_TYPE_FIXUP 6
3408 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3409 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3410 #define IMAGE_DEBUG_TYPE_BORLAND 9
3411 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3413 typedef enum ReplacesCorHdrNumericDefines
3415 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3416 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3417 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3418 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3419 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3421 COR_VERSION_MAJOR_V2 = 2,
3422 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3423 COR_VERSION_MINOR = 0,
3424 COR_DELETED_NAME_LENGTH = 8,
3425 COR_VTABLEGAP_NAME_LENGTH = 8,
3427 NATIVE_TYPE_MAX_CB = 1,
3428 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3430 IMAGE_COR_MIH_METHODRVA = 0x01,
3431 IMAGE_COR_MIH_EHRVA = 0x02,
3432 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3434 COR_VTABLE_32BIT = 0x01,
3435 COR_VTABLE_64BIT = 0x02,
3436 COR_VTABLE_FROM_UNMANAGED = 0x04,
3437 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3439 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3441 MAX_CLASS_NAME = 1024,
3442 MAX_PACKAGE_NAME = 1024,
3443 } ReplacesCorHdrNumericDefines;
3445 typedef struct IMAGE_COR20_HEADER
3448 WORD MajorRuntimeVersion;
3449 WORD MinorRuntimeVersion;
3451 IMAGE_DATA_DIRECTORY MetaData;
3454 DWORD EntryPointToken;
3455 DWORD EntryPointRVA;
3458 IMAGE_DATA_DIRECTORY Resources;
3459 IMAGE_DATA_DIRECTORY StrongNameSignature;
3460 IMAGE_DATA_DIRECTORY CodeManagerTable;
3461 IMAGE_DATA_DIRECTORY VTableFixups;
3462 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3463 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3465 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3467 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3468 DWORD NumberOfSymbols;
3469 DWORD LvaToFirstSymbol;
3470 DWORD NumberOfLinenumbers;
3471 DWORD LvaToFirstLinenumber;
3472 DWORD RvaToFirstByteOfCode;
3473 DWORD RvaToLastByteOfCode;
3474 DWORD RvaToFirstByteOfData;
3475 DWORD RvaToLastByteOfData;
3476 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3479 #define FRAME_TRAP 1
3481 #define FRAME_NONFPO 3
3483 typedef struct _FPO_DATA {
3494 } FPO_DATA, *PFPO_DATA;
3496 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
3498 DWORD TimeDateStamp;
3501 DWORD GlobalFlagsClear;
3502 DWORD GlobalFlagsSet;
3503 DWORD CriticalSectionDefaultTimeout;
3504 DWORD DeCommitFreeBlockThreshold;
3505 DWORD DeCommitTotalFreeThreshold;
3506 PVOID LockPrefixTable;
3507 DWORD MaximumAllocationSize;
3508 DWORD VirtualMemoryThreshold;
3509 DWORD ProcessHeapFlags;
3510 DWORD ProcessAffinityMask;
3514 DWORD SecurityCookie;
3515 DWORD SEHandlerTable;
3516 DWORD SEHandlerCount;
3517 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
3519 typedef struct _IMAGE_FUNCTION_ENTRY {
3520 DWORD StartingAddress;
3521 DWORD EndingAddress;
3522 DWORD EndOfPrologue;
3523 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3525 #define IMAGE_DEBUG_MISC_EXENAME 1
3527 typedef struct _IMAGE_DEBUG_MISC {
3533 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3535 /* This is the structure that appears at the very start of a .DBG file. */
3537 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3541 WORD Characteristics;
3542 DWORD TimeDateStamp;
3546 DWORD NumberOfSections;
3547 DWORD ExportedNamesSize;
3548 DWORD DebugDirectorySize;
3549 DWORD SectionAlignment;
3550 DWORD Reserved[ 2 ];
3551 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3553 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3556 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3560 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3561 #define MESSAGE_RESOURCE_UNICODE 0x0001
3563 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3566 DWORD OffsetToEntries;
3567 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3569 typedef struct tagMESSAGE_RESOURCE_DATA {
3570 DWORD NumberOfBlocks;
3571 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
3572 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3575 * Here follows typedefs for security and tokens.
3579 * First a constant for the following typedefs.
3582 #define ANYSIZE_ARRAY 1
3584 /* FIXME: Orphan. What does it point to? */
3585 typedef PVOID PACCESS_TOKEN;
3586 typedef PVOID PSECURITY_DESCRIPTOR;
3589 typedef enum _TOKEN_ELEVATION_TYPE {
3590 TokenElevationTypeDefault = 1,
3591 TokenElevationTypeFull,
3592 TokenElevationTypeLimited
3593 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
3596 * TOKEN_INFORMATION_CLASS
3599 typedef enum _TOKEN_INFORMATION_CLASS {
3608 TokenImpersonationLevel,
3610 TokenRestrictedSids,
3612 TokenGroupsAndPrivileges,
3613 TokenSessionReference,
3620 TokenHasRestrictions,
3621 TokenAccessInformation,
3622 TokenVirtualizationAllowed,
3623 TokenVirtualizationEnabled,
3624 TokenIntegrityLevel,
3626 TokenMandatoryPolicy,
3629 } TOKEN_INFORMATION_CLASS;
3631 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
3632 #define TOKEN_ADJUST_GROUPS 0x0040
3633 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3634 #define TOKEN_ADJUST_SESSIONID 0x0100
3635 #define TOKEN_ASSIGN_PRIMARY 0x0001
3636 #define TOKEN_DUPLICATE 0x0002
3637 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3638 #define TOKEN_IMPERSONATE 0x0004
3639 #define TOKEN_QUERY 0x0008
3640 #define TOKEN_QUERY_SOURCE 0x0010
3641 #define TOKEN_ADJUST_DEFAULT 0x0080
3642 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3643 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3644 TOKEN_ADJUST_PRIVILEGES | \
3645 TOKEN_ADJUST_GROUPS | \
3646 TOKEN_ADJUST_DEFAULT )
3647 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3648 TOKEN_ASSIGN_PRIMARY | \
3650 TOKEN_IMPERSONATE | \
3652 TOKEN_QUERY_SOURCE | \
3653 TOKEN_ADJUST_PRIVILEGES | \
3654 TOKEN_ADJUST_GROUPS | \
3655 TOKEN_ADJUST_SESSIONID | \
3656 TOKEN_ADJUST_DEFAULT )
3658 #ifndef _SECURITY_DEFINED
3659 #define _SECURITY_DEFINED
3662 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3664 typedef struct _GENERIC_MAPPING {
3665 ACCESS_MASK GenericRead;
3666 ACCESS_MASK GenericWrite;
3667 ACCESS_MASK GenericExecute;
3668 ACCESS_MASK GenericAll;
3669 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3671 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3672 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3675 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
3676 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3680 typedef struct _SID {
3682 BYTE SubAuthorityCount;
3683 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3684 DWORD SubAuthority[1];
3686 #endif /* !defined(SID_DEFINED) */
3688 #define SID_REVISION (1) /* Current revision */
3689 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3690 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3692 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3698 #define ACL_REVISION1 1
3699 #define ACL_REVISION2 2
3700 #define ACL_REVISION3 3
3701 #define ACL_REVISION4 4
3703 #define MIN_ACL_REVISION ACL_REVISION2
3704 #define MAX_ACL_REVISION ACL_REVISION4
3706 #define ACL_REVISION 2
3708 typedef struct _ACL {
3716 typedef enum _ACL_INFORMATION_CLASS
3718 AclRevisionInformation = 1,
3720 } ACL_INFORMATION_CLASS;
3722 typedef struct _ACL_REVISION_INFORMATION
3725 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
3727 typedef struct _ACL_SIZE_INFORMATION
3730 DWORD AclBytesInUse;
3732 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
3734 /* SECURITY_DESCRIPTOR */
3735 #define SECURITY_DESCRIPTOR_REVISION 1
3736 #define SECURITY_DESCRIPTOR_REVISION1 1
3742 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
3743 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
3744 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
3745 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
3746 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
3747 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
3748 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
3749 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
3750 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
3751 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
3752 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
3753 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
3754 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
3755 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
3756 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
3757 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
3758 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
3759 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
3760 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
3761 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
3762 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
3763 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
3764 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
3765 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
3766 #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
3767 #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
3768 #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
3769 #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
3770 #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
3772 #define SE_GROUP_MANDATORY 0x00000001
3773 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
3774 #define SE_GROUP_ENABLED 0x00000004
3775 #define SE_GROUP_OWNER 0x00000008
3776 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
3777 #define SE_GROUP_INTEGRITY 0x00000020
3778 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
3779 #define SE_GROUP_LOGON_ID 0xC0000000
3780 #define SE_GROUP_RESOURCE 0x20000000
3781 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
3783 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
3784 #define SE_PRIVILEGE_ENABLED 0x00000002
3785 #define SE_PRIVILEGE_REMOVED 0x00000004
3786 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
3788 #define PRIVILEGE_SET_ALL_NECESSARY 1
3790 #define SE_OWNER_DEFAULTED 0x00000001
3791 #define SE_GROUP_DEFAULTED 0x00000002
3792 #define SE_DACL_PRESENT 0x00000004
3793 #define SE_DACL_DEFAULTED 0x00000008
3794 #define SE_SACL_PRESENT 0x00000010
3795 #define SE_SACL_DEFAULTED 0x00000020
3796 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
3797 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
3798 #define SE_DACL_AUTO_INHERITED 0x00000400
3799 #define SE_SACL_AUTO_INHERITED 0x00000800
3800 #define SE_DACL_PROTECTED 0x00001000
3801 #define SE_SACL_PROTECTED 0x00002000
3802 #define SE_RM_CONTROL_VALID 0x00004000
3803 #define SE_SELF_RELATIVE 0x00008000
3805 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
3806 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
3808 /* The security descriptor structure */
3812 SECURITY_DESCRIPTOR_CONTROL Control;
3817 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
3822 SECURITY_DESCRIPTOR_CONTROL Control;
3827 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
3829 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
3831 #endif /* _SECURITY_DEFINED */
3834 * SID_AND_ATTRIBUTES
3837 typedef struct _SID_AND_ATTRIBUTES {
3840 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
3842 /* security entities */
3843 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
3844 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
3845 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
3847 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
3850 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
3853 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
3856 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
3857 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
3858 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
3859 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
3860 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
3863 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
3866 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
3867 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
3868 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
3869 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
3870 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
3871 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
3872 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
3873 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
3874 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
3875 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
3876 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
3877 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
3878 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
3879 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
3880 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
3881 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
3882 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
3883 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
3884 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
3885 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
3886 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
3887 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
3889 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
3890 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
3891 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
3892 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
3893 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
3894 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
3895 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
3897 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
3898 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
3899 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
3900 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
3901 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
3903 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
3904 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
3905 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
3906 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
3907 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
3908 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
3909 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
3910 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
3911 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
3913 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
3914 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
3915 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
3916 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
3917 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
3918 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
3919 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
3921 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
3922 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
3923 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
3924 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
3926 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
3927 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
3928 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
3929 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
3931 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
3932 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
3933 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
3934 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
3935 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
3936 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
3938 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
3939 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
3940 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
3941 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
3942 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
3944 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
3946 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
3947 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
3953 WinCreatorOwnerSid = 3,
3954 WinCreatorGroupSid = 4,
3955 WinCreatorOwnerServerSid = 5,
3956 WinCreatorGroupServerSid = 6,
3957 WinNtAuthoritySid = 7,
3961 WinInteractiveSid = 11,
3963 WinAnonymousSid = 13,
3965 WinEnterpriseControllersSid = 15,
3967 WinAuthenticatedUserSid = 17,
3968 WinRestrictedCodeSid = 18,
3969 WinTerminalServerSid = 19,
3970 WinRemoteLogonIdSid = 20,
3971 WinLogonIdsSid = 21,
3972 WinLocalSystemSid = 22,
3973 WinLocalServiceSid = 23,
3974 WinNetworkServiceSid = 24,
3975 WinBuiltinDomainSid = 25,
3976 WinBuiltinAdministratorsSid = 26,
3977 WinBuiltinUsersSid = 27,
3978 WinBuiltinGuestsSid = 28,
3979 WinBuiltinPowerUsersSid = 29,
3980 WinBuiltinAccountOperatorsSid = 30,
3981 WinBuiltinSystemOperatorsSid = 31,
3982 WinBuiltinPrintOperatorsSid = 32,
3983 WinBuiltinBackupOperatorsSid = 33,
3984 WinBuiltinReplicatorSid = 34,
3985 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
3986 WinBuiltinRemoteDesktopUsersSid = 36,
3987 WinBuiltinNetworkConfigurationOperatorsSid = 37,
3988 WinAccountAdministratorSid = 38,
3989 WinAccountGuestSid = 39,
3990 WinAccountKrbtgtSid = 40,
3991 WinAccountDomainAdminsSid = 41,
3992 WinAccountDomainUsersSid = 42,
3993 WinAccountDomainGuestsSid = 43,
3994 WinAccountComputersSid = 44,
3995 WinAccountControllersSid = 45,
3996 WinAccountCertAdminsSid = 46,
3997 WinAccountSchemaAdminsSid = 47,
3998 WinAccountEnterpriseAdminsSid = 48,
3999 WinAccountPolicyAdminsSid = 49,
4000 WinAccountRasAndIasServersSid = 50,
4001 WinNTLMAuthenticationSid = 51,
4002 WinDigestAuthenticationSid = 52,
4003 WinSChannelAuthenticationSid = 53,
4004 WinThisOrganizationSid = 54,
4005 WinOtherOrganizationSid = 55,
4006 WinBuiltinIncomingForestTrustBuildersSid = 56,
4007 WinBuiltinPerfMonitoringUsersSid = 57,
4008 WinBuiltinPerfLoggingUsersSid = 58,
4009 WinBuiltinAuthorizationAccessSid = 59,
4010 WinBuiltinTerminalServerLicenseServersSid = 60,
4011 WinBuiltinDCOMUsersSid = 61,
4012 WinBuiltinIUsersSid = 62,
4014 WinBuiltinCryptoOperatorsSid = 64,
4015 WinUntrustedLabelSid = 65,
4016 WinLowLabelSid = 66,
4017 WinMediumLabelSid = 67,
4018 WinHighLabelSid = 68,
4019 WinSystemLabelSid = 69,
4020 WinWriteRestrictedCodeSid = 70,
4021 WinCreatorOwnerRightsSid = 71,
4022 WinCacheablePrincipalsGroupSid = 72,
4023 WinNonCacheablePrincipalsGroupSid = 73,
4024 WinEnterpriseReadonlyControllersSid = 74,
4025 WinAccountReadonlyControllersSid = 75,
4026 WinBuiltinEventLogReadersGroup = 76,
4027 WinNewEnterpriseReadonlyControllersSid = 77,
4028 WinBuiltinCertSvcDComAccessGroup = 78,
4029 WinMediumPlusLabelSid = 79,
4030 WinLocalLogonSid = 80,
4031 WinConsoleLogonSid = 81,
4032 WinThisOrganizationCertificateSid = 82,
4033 } WELL_KNOWN_SID_TYPE;
4039 typedef struct _TOKEN_USER {
4040 SID_AND_ATTRIBUTES User;
4041 } TOKEN_USER, *PTOKEN_USER;
4047 typedef struct _TOKEN_GROUPS {
4049 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4050 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4053 * LUID_AND_ATTRIBUTES
4056 typedef union _LARGE_INTEGER {
4058 #ifdef WORDS_BIGENDIAN
4066 #ifndef NONAMELESSSTRUCT
4068 #ifdef WORDS_BIGENDIAN
4078 } LARGE_INTEGER, *PLARGE_INTEGER;
4080 typedef union _ULARGE_INTEGER {
4082 #ifdef WORDS_BIGENDIAN
4090 #ifndef NONAMELESSSTRUCT
4092 #ifdef WORDS_BIGENDIAN
4102 } ULARGE_INTEGER, *PULARGE_INTEGER;
4105 * Locally Unique Identifier
4108 typedef struct _LUID {
4113 #include <pshpack4.h>
4114 typedef struct _LUID_AND_ATTRIBUTES {
4117 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4118 #include <poppack.h>
4124 typedef struct _PRIVILEGE_SET {
4125 DWORD PrivilegeCount;
4127 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4128 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4134 typedef struct _TOKEN_PRIVILEGES {
4135 DWORD PrivilegeCount;
4136 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4137 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4143 typedef struct _TOKEN_OWNER {
4145 } TOKEN_OWNER, *PTOKEN_OWNER;
4148 * TOKEN_PRIMARY_GROUP
4151 typedef struct _TOKEN_PRIMARY_GROUP {
4153 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4157 * TOKEN_DEFAULT_DACL
4160 typedef struct _TOKEN_DEFAULT_DACL {
4162 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4168 #define TOKEN_SOURCE_LENGTH 8
4170 typedef struct _TOKEN_SOURCE {
4171 char SourceName[TOKEN_SOURCE_LENGTH];
4172 LUID SourceIdentifier;
4173 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4179 typedef enum tagTOKEN_TYPE {
4185 * SECURITY_IMPERSONATION_LEVEL
4188 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4190 SecurityIdentification,
4191 SecurityImpersonation,
4193 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4195 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4196 #define SECURITY_STATIC_TRACKING (FALSE)
4198 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4199 * PSECURITY_CONTEXT_TRACKING_MODE;
4201 * Quality of Service
4204 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4206 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4207 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4208 BOOLEAN EffectiveOnly;
4209 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4215 #include <pshpack4.h>
4216 typedef struct _TOKEN_STATISTICS {
4218 LUID AuthenticationId;
4219 LARGE_INTEGER ExpirationTime;
4220 TOKEN_TYPE TokenType;
4221 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4222 DWORD DynamicCharged;
4223 DWORD DynamicAvailable;
4225 DWORD PrivilegeCount;
4228 #include <poppack.h>
4230 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4233 PSID_AND_ATTRIBUTES Sids;
4234 DWORD RestrictedSidCount;
4235 DWORD RestrictedSidLength;
4236 PSID_AND_ATTRIBUTES RestrictedSids;
4237 DWORD PrivilegeCount;
4238 DWORD PrivilegeLength;
4239 PLUID_AND_ATTRIBUTES Privileges;
4240 LUID AuthenticationId;
4241 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4243 typedef struct _TOKEN_ORIGIN {
4244 LUID OriginatingLogonSession;
4245 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4247 typedef struct _TOKEN_LINKED_TOKEN {
4249 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4251 typedef struct _TOKEN_ELEVATION {
4252 DWORD TokenIsElevated;
4253 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
4255 typedef struct _TOKEN_MANDATORY_LABEL {
4256 SID_AND_ATTRIBUTES Label;
4257 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
4263 /* ACEs, directly starting after an ACL */
4264 typedef struct _ACE_HEADER {
4268 } ACE_HEADER,*PACE_HEADER;
4271 #define ACCESS_ALLOWED_ACE_TYPE 0
4272 #define ACCESS_DENIED_ACE_TYPE 1
4273 #define SYSTEM_AUDIT_ACE_TYPE 2
4274 #define SYSTEM_ALARM_ACE_TYPE 3
4276 /* inherit AceFlags */
4277 #define OBJECT_INHERIT_ACE 0x01
4278 #define CONTAINER_INHERIT_ACE 0x02
4279 #define NO_PROPAGATE_INHERIT_ACE 0x04
4280 #define INHERIT_ONLY_ACE 0x08
4281 #define INHERITED_ACE 0x10
4282 #define VALID_INHERIT_FLAGS 0x1F
4284 /* AceFlags mask for what events we (should) audit */
4285 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4286 #define FAILED_ACCESS_ACE_FLAG 0x80
4288 /* different ACEs depending on AceType
4289 * SidStart marks the begin of a SID
4290 * so the thing finally looks like this:
4295 typedef struct _ACCESS_ALLOWED_ACE {
4299 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
4301 typedef struct _ACCESS_DENIED_ACE {
4305 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
4307 typedef struct _SYSTEM_AUDIT_ACE {
4311 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
4313 typedef struct _SYSTEM_ALARM_ACE {
4317 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
4319 typedef enum tagSID_NAME_USE {
4324 SidTypeWellKnownGroup,
4325 SidTypeDeletedAccount,
4328 } SID_NAME_USE,*PSID_NAME_USE;
4330 #define ACE_OBJECT_TYPE_PRESENT 0x1
4331 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4335 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4337 #define DELETE 0x00010000
4338 #define READ_CONTROL 0x00020000
4339 #define WRITE_DAC 0x00040000
4340 #define WRITE_OWNER 0x00080000
4341 #define SYNCHRONIZE 0x00100000
4342 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4344 #define STANDARD_RIGHTS_READ READ_CONTROL
4345 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4346 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4348 #define STANDARD_RIGHTS_ALL 0x001f0000
4350 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4352 #define GENERIC_READ 0x80000000
4353 #define GENERIC_WRITE 0x40000000
4354 #define GENERIC_EXECUTE 0x20000000
4355 #define GENERIC_ALL 0x10000000
4357 #define MAXIMUM_ALLOWED 0x02000000
4358 #define ACCESS_SYSTEM_SECURITY 0x01000000
4360 #define EVENT_QUERY_STATE 0x0001
4361 #define EVENT_MODIFY_STATE 0x0002
4362 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4364 #define SEMAPHORE_MODIFY_STATE 0x0002
4365 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4367 #define MUTANT_QUERY_STATE 0x0001
4368 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
4370 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
4371 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
4372 #define JOB_OBJECT_QUERY 0x0004
4373 #define JOB_OBJECT_TERMINATE 0x0008
4374 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
4375 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
4377 #define TIMER_QUERY_STATE 0x0001
4378 #define TIMER_MODIFY_STATE 0x0002
4379 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4381 #define PROCESS_TERMINATE 0x0001
4382 #define PROCESS_CREATE_THREAD 0x0002
4383 #define PROCESS_VM_OPERATION 0x0008
4384 #define PROCESS_VM_READ 0x0010
4385 #define PROCESS_VM_WRITE 0x0020
4386 #define PROCESS_DUP_HANDLE 0x0040
4387 #define PROCESS_CREATE_PROCESS 0x0080
4388 #define PROCESS_SET_QUOTA 0x0100
4389 #define PROCESS_SET_INFORMATION 0x0200
4390 #define PROCESS_QUERY_INFORMATION 0x0400
4391 #define PROCESS_SUSPEND_RESUME 0x0800
4392 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
4393 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
4395 #define THREAD_TERMINATE 0x0001
4396 #define THREAD_SUSPEND_RESUME 0x0002
4397 #define THREAD_GET_CONTEXT 0x0008
4398 #define THREAD_SET_CONTEXT 0x0010
4399 #define THREAD_SET_INFORMATION 0x0020
4400 #define THREAD_QUERY_INFORMATION 0x0040
4401 #define THREAD_SET_THREAD_TOKEN 0x0080
4402 #define THREAD_IMPERSONATE 0x0100
4403 #define THREAD_DIRECT_IMPERSONATION 0x0200
4404 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
4406 #define THREAD_BASE_PRIORITY_LOWRT 15
4407 #define THREAD_BASE_PRIORITY_MAX 2
4408 #define THREAD_BASE_PRIORITY_MIN -2
4409 #define THREAD_BASE_PRIORITY_IDLE -15
4411 typedef struct _QUOTA_LIMITS {
4412 SIZE_T PagedPoolLimit;
4413 SIZE_T NonPagedPoolLimit;
4414 SIZE_T MinimumWorkingSetSize;
4415 SIZE_T MaximumWorkingSetSize;
4416 SIZE_T PagefileLimit;
4417 LARGE_INTEGER TimeLimit;
4418 } QUOTA_LIMITS, *PQUOTA_LIMITS;
4420 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
4421 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
4422 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
4423 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
4425 typedef struct _QUOTA_LIMITS_EX {
4426 SIZE_T PagedPoolLimit;
4427 SIZE_T NonPagedPoolLimit;
4428 SIZE_T MinimumWorkingSetSize;
4429 SIZE_T MaximumWorkingSetSize;
4430 SIZE_T PagefileLimit;
4431 LARGE_INTEGER TimeLimit;
4438 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
4440 #define SECTION_QUERY 0x0001
4441 #define SECTION_MAP_WRITE 0x0002
4442 #define SECTION_MAP_READ 0x0004
4443 #define SECTION_MAP_EXECUTE 0x0008
4444 #define SECTION_EXTEND_SIZE 0x0010
4445 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
4446 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
4448 #define FILE_READ_DATA 0x0001 /* file & pipe */
4449 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
4450 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
4451 #define FILE_ADD_FILE 0x0002 /* directory */
4452 #define FILE_APPEND_DATA 0x0004 /* file */
4453 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
4454 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
4455 #define FILE_READ_EA 0x0008 /* file & directory */
4456 #define FILE_READ_PROPERTIES FILE_READ_EA
4457 #define FILE_WRITE_EA 0x0010 /* file & directory */
4458 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
4459 #define FILE_EXECUTE 0x0020 /* file */
4460 #define FILE_TRAVERSE 0x0020 /* directory */
4461 #define FILE_DELETE_CHILD 0x0040 /* directory */
4462 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
4463 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
4464 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
4466 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
4467 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
4469 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
4470 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
4471 FILE_APPEND_DATA | SYNCHRONIZE)
4472 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
4473 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
4475 #define DUPLICATE_CLOSE_SOURCE 0x00000001
4476 #define DUPLICATE_SAME_ACCESS 0x00000002
4478 /* File attribute flags */
4479 #define FILE_SHARE_READ 0x00000001
4480 #define FILE_SHARE_WRITE 0x00000002
4481 #define FILE_SHARE_DELETE 0x00000004
4483 #define FILE_ATTRIBUTE_READONLY 0x00000001
4484 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
4485 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
4486 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
4487 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
4488 #define FILE_ATTRIBUTE_DEVICE 0x00000040
4489 #define FILE_ATTRIBUTE_NORMAL 0x00000080
4490 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
4491 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
4492 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
4493 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
4494 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
4495 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
4496 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
4498 /* File notification flags */
4499 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
4500 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
4501 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
4502 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
4503 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
4504 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
4505 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
4506 #define FILE_NOTIFY_CHANGE_EA 0x00000080
4507 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
4508 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
4509 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
4510 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
4512 #define FILE_ACTION_ADDED 0x00000001
4513 #define FILE_ACTION_REMOVED 0x00000002
4514 #define FILE_ACTION_MODIFIED 0x00000003
4515 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
4516 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
4517 #define FILE_ACTION_ADDED_STREAM 0x00000006
4518 #define FILE_ACTION_REMOVED_STREAM 0x00000007
4519 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
4521 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
4522 #define FILE_CASE_PRESERVED_NAMES 0x00000002
4523 #define FILE_UNICODE_ON_DISK 0x00000004
4524 #define FILE_PERSISTENT_ACLS 0x00000008
4525 #define FILE_FILE_COMPRESSION 0x00000010
4526 #define FILE_VOLUME_QUOTAS 0x00000020
4527 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
4528 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
4529 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
4530 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
4531 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
4532 #define FILE_NAMED_STREAMS 0x00040000
4533 #define FILE_READ_ONLY_VOLUME 0x00080000
4535 /* File alignments (NT) */
4536 #define FILE_BYTE_ALIGNMENT 0x00000000
4537 #define FILE_WORD_ALIGNMENT 0x00000001
4538 #define FILE_LONG_ALIGNMENT 0x00000003
4539 #define FILE_QUAD_ALIGNMENT 0x00000007
4540 #define FILE_OCTA_ALIGNMENT 0x0000000f
4541 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
4542 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
4543 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
4544 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
4545 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
4547 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
4548 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
4550 #define REG_NONE 0 /* no type */
4551 #define REG_SZ 1 /* string type (ASCII) */
4552 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
4553 #define REG_BINARY 3 /* binary format, callerspecific */
4554 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
4555 #define REG_DWORD 4 /* DWORD in little endian format */
4556 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
4557 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
4558 #define REG_LINK 6 /* symbolic link (UNICODE) */
4559 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
4560 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
4561 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
4562 #define REG_RESOURCE_REQUIREMENTS_LIST 10
4563 #define REG_QWORD 11 /* QWORD in little endian format */
4564 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
4566 /* ----------------------------- begin power management --------------------- */
4568 typedef enum _LATENCY_TIME {
4571 } LATENCY_TIME, *PLATENCY_TIME;
4573 #define DISCHARGE_POLICY_CRITICAL 0
4574 #define DISCHARGE_POLICY_LOW 1
4575 #define NUM_DISCHARGE_POLICIES 4
4577 #define PO_THROTTLE_NONE 0
4578 #define PO_THROTTLE_CONSTANT 1
4579 #define PO_THROTTLE_DEGRADE 2
4580 #define PO_THROTTLE_ADAPTIVE 3
4582 typedef enum _POWER_ACTION {
4583 PowerActionNone = 0,
4584 PowerActionReserved,
4586 PowerActionHibernate,
4587 PowerActionShutdown,
4588 PowerActionShutdownReset,
4589 PowerActionShutdownOff,
4590 PowerActionWarmEject
4594 typedef enum _SYSTEM_POWER_STATE {
4595 PowerSystemUnspecified = 0,
4596 PowerSystemWorking = 1,
4597 PowerSystemSleeping1 = 2,
4598 PowerSystemSleeping2 = 3,
4599 PowerSystemSleeping3 = 4,
4600 PowerSystemHibernate = 5,
4601 PowerSystemShutdown = 6,
4602 PowerSystemMaximum = 7
4603 } SYSTEM_POWER_STATE,
4604 *PSYSTEM_POWER_STATE;
4606 typedef enum _DEVICE_POWER_STATE {
4607 PowerDeviceUnspecified,
4613 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
4615 typedef enum _POWER_INFORMATION_LEVEL {
4616 SystemPowerPolicyAc,
4617 SystemPowerPolicyDc,
4618 VerifySystemPolicyAc,
4619 VerifySystemPolicyDc,
4620 SystemPowerCapabilities,
4622 SystemPowerStateHandler,
4623 ProcessorStateHandler,
4624 SystemPowerPolicyCurrent,
4625 AdministratorPowerPolicy,
4626 SystemReserveHiberFile,
4627 ProcessorInformation,
4628 SystemPowerInformation,
4629 ProcessorStateHandler2,
4632 SystemExecutionState,
4633 SystemPowerStateNotifyHandler,
4634 ProcessorPowerPolicyAc,
4635 ProcessorPowerPolicyDc,
4636 VerifyProcessorPowerPolicyAc,
4637 VerifyProcessorPowerPolicyDc,
4638 ProcessorPowerPolicyCurrent
4639 } POWER_INFORMATION_LEVEL;
4641 typedef struct _ADMINISTRATOR_POWER_POLICY {
4642 SYSTEM_POWER_STATE MinSleep;
4643 SYSTEM_POWER_STATE MaxSleep;
4644 ULONG MinVideoTimeout;
4645 ULONG MaxVideoTimeout;
4646 ULONG MinSpindownTimeout;
4647 ULONG MaxSpindownTimeout;
4648 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
4653 } BATTERY_REPORTING_SCALE,
4654 *PBATTERY_REPORTING_SCALE;
4657 POWER_ACTION Action;
4660 } POWER_ACTION_POLICY,
4661 *PPOWER_ACTION_POLICY;
4663 typedef struct _PROCESSOR_POWER_INFORMATION {
4669 ULONG CurrentIdleState;
4670 } PROCESSOR_POWER_INFORMATION,
4671 *PPROCESSOR_POWER_INFORMATION;
4673 typedef struct _PROCESSOR_POWER_POLICY_INFO {
4677 UCHAR DemotePercent;
4678 UCHAR PromotePercent;
4680 ULONG AllowDemotion:1;
4681 ULONG AllowPromotion:1;
4683 } PROCESSOR_POWER_POLICY_INFO,
4684 *PPROCESSOR_POWER_POLICY_INFO;
4686 typedef struct _PROCESSOR_POWER_POLICY {
4688 BYTE DynamicThrottle;
4690 DWORD DisableCStates:1;
4693 PROCESSOR_POWER_POLICY_INFO Policy[3];
4694 } PROCESSOR_POWER_POLICY,
4695 *PPROCESSOR_POWER_POLICY;
4699 BOOLEAN BatteryPresent;
4701 BOOLEAN Discharging;
4704 ULONG RemainingCapacity;
4706 ULONG EstimatedTime;
4707 ULONG DefaultAlert1;
4708 ULONG DefaultAlert2;
4709 } SYSTEM_BATTERY_STATE,
4710 *PSYSTEM_BATTERY_STATE;
4713 BOOLEAN PowerButtonPresent;
4714 BOOLEAN SleepButtonPresent;
4721 BOOLEAN HiberFilePresent;
4723 BOOLEAN VideoDimPresent;
4726 BOOLEAN ThermalControl;
4727 BOOLEAN ProcessorThrottle;
4728 UCHAR ProcessorMinThrottle;
4729 UCHAR ProcessorMaxThrottle;
4731 BOOLEAN DiskSpinDown;
4733 BOOLEAN SystemBatteriesPresent;
4734 BOOLEAN BatteriesAreShortTerm;
4735 BATTERY_REPORTING_SCALE BatteryScale[3];
4736 SYSTEM_POWER_STATE AcOnLineWake;
4737 SYSTEM_POWER_STATE SoftLidWake;
4738 SYSTEM_POWER_STATE RtcWake;
4739 SYSTEM_POWER_STATE MinDeviceWakeState;
4740 SYSTEM_POWER_STATE DefaultLowLatencyWake;
4741 } SYSTEM_POWER_CAPABILITIES,
4742 *PSYSTEM_POWER_CAPABILITIES;
4744 typedef struct _SYSTEM_POWER_INFORMATION {
4745 ULONG MaxIdlenessAllowed;
4747 ULONG TimeRemaining;
4749 } SYSTEM_POWER_INFORMATION,
4750 *PSYSTEM_POWER_INFORMATION;
4752 typedef struct _SYSTEM_POWER_LEVEL {
4756 POWER_ACTION_POLICY PowerPolicy;
4757 SYSTEM_POWER_STATE MinSystemState;
4758 } SYSTEM_POWER_LEVEL,
4759 *PSYSTEM_POWER_LEVEL;
4761 typedef struct _SYSTEM_POWER_POLICY {
4763 POWER_ACTION_POLICY PowerButton;
4764 POWER_ACTION_POLICY SleepButton;
4765 POWER_ACTION_POLICY LidClose;
4766 SYSTEM_POWER_STATE LidOpenWake;
4768 POWER_ACTION_POLICY Idle;
4770 UCHAR IdleSensitivity;
4771 UCHAR DynamicThrottle;
4773 SYSTEM_POWER_STATE MinSleep;
4774 SYSTEM_POWER_STATE MaxSleep;
4775 SYSTEM_POWER_STATE ReducedLatencySleep;
4776 ULONG WinLogonFlags;
4778 ULONG DozeS4Timeout;
4779 ULONG BroadcastCapacityResolution;
4780 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
4782 BOOLEAN VideoDimDisplay;
4783 ULONG VideoReserved[3];
4784 ULONG SpindownTimeout;
4785 BOOLEAN OptimizeForPower;
4786 UCHAR FanThrottleTolerance;
4787 UCHAR ForcedThrottle;
4789 POWER_ACTION_POLICY OverThrottled;
4790 } SYSTEM_POWER_POLICY,
4791 *PSYSTEM_POWER_POLICY;
4793 typedef union _FILE_SEGMENT_ELEMENT {
4795 ULONGLONG Alignment;
4796 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
4798 typedef struct _FILE_NOTIFY_INFORMATION {
4799 DWORD NextEntryOffset;
4801 DWORD FileNameLength;
4803 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
4805 /* ----------------------------- begin tape storage --------------------- */
4807 #define TAPE_FIXED_PARTITIONS 0
4808 #define TAPE_SELECT_PARTITIONS 1
4809 #define TAPE_INITIATOR_PARTITIONS 2
4810 #define TAPE_ERASE_SHORT 0
4811 #define TAPE_ERASE_LONG 1
4813 #define TAPE_UNLOAD 1
4814 #define TAPE_TENSION 2
4816 #define TAPE_UNLOCK 4
4817 #define TAPE_FORMAT 5
4818 #define TAPE_SETMARKS 0
4819 #define TAPE_FILEMARKS 1
4820 #define TAPE_SHORT_FILEMARKS 2
4821 #define TAPE_LONG_FILEMARKS 3
4822 #define TAPE_REWIND 0
4823 #define TAPE_ABSOLUTE_BLOCK 1
4824 #define TAPE_LOGICAL_BLOCK 2
4825 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
4826 #define TAPE_SPACE_END_OF_DATA 4
4827 #define TAPE_SPACE_RELATIVE_BLOCKS 5
4828 #define TAPE_SPACE_FILEMARKS 6
4829 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
4830 #define TAPE_SPACE_SETMARKS 8
4831 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
4833 typedef struct _TAPE_CREATE_PARTITION {
4837 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
4839 typedef struct _TAPE_ERASE {
4842 } TAPE_ERASE, *PTAPE_ERASE;
4844 typedef struct _TAPE_PREPARE {
4847 } TAPE_PREPARE, *PTAPE_PREPARE;
4849 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
4851 BOOLEAN Compression;
4852 BOOLEAN DataPadding;
4853 BOOLEAN ReportSetmarks;
4854 ULONG EOTWarningZoneSize;
4855 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
4857 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
4859 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
4861 typedef struct _TAPE_WRITE_MARKS {
4865 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
4867 typedef struct _TAPE_GET_POSITION {
4872 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
4874 typedef struct _TAPE_SET_POSITION {
4877 LARGE_INTEGER Offset;
4879 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
4881 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
4883 BOOLEAN Compression;
4884 BOOLEAN DataPadding;
4885 BOOLEAN ReportSetmarks;
4886 DWORD DefaultBlockSize;
4887 DWORD MaximumBlockSize;
4888 DWORD MinimumBlockSize;
4889 DWORD MaximumPartitionCount;
4892 DWORD EOTWarningZoneSize;
4893 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
4895 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
4896 LARGE_INTEGER Capacity;
4897 LARGE_INTEGER Remaining;
4899 DWORD PartitionCount;
4900 BOOLEAN WriteProtected;
4901 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
4903 /* ----------------------------- begin registry ----------------------------- */
4905 /* Registry security values */
4906 #define OWNER_SECURITY_INFORMATION 0x00000001
4907 #define GROUP_SECURITY_INFORMATION 0x00000002
4908 #define DACL_SECURITY_INFORMATION 0x00000004
4909 #define SACL_SECURITY_INFORMATION 0x00000008
4911 #define REG_OPTION_RESERVED 0x00000000
4912 #define REG_OPTION_NON_VOLATILE 0x00000000
4913 #define REG_OPTION_VOLATILE 0x00000001
4914 #define REG_OPTION_CREATE_LINK 0x00000002
4915 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
4916 #define REG_OPTION_OPEN_LINK 0x00000008
4917 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
4918 REG_OPTION_NON_VOLATILE| \
4919 REG_OPTION_VOLATILE| \
4920 REG_OPTION_CREATE_LINK| \
4921 REG_OPTION_BACKUP_RESTORE| \
4922 REG_OPTION_OPEN_LINK)
4925 #define REG_CREATED_NEW_KEY 0x00000001
4926 #define REG_OPENED_EXISTING_KEY 0x00000002
4928 /* For RegNotifyChangeKeyValue */
4929 #define REG_NOTIFY_CHANGE_NAME 0x01
4930 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
4931 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
4932 #define REG_NOTIFY_CHANGE_SECURITY 0x08
4934 #define KEY_QUERY_VALUE 0x00000001
4935 #define KEY_SET_VALUE 0x00000002
4936 #define KEY_CREATE_SUB_KEY 0x00000004
4937 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
4938 #define KEY_NOTIFY 0x00000010
4939 #define KEY_CREATE_LINK 0x00000020
4940 #define KEY_WOW64_64KEY 0x00000100
4941 #define KEY_WOW64_32KEY 0x00000200
4942 #define KEY_WOW64_RES 0x00000300
4944 /* for RegKeyRestore flags */
4945 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
4946 #define REG_REFRESH_HIVE 0x00000002
4947 #define REG_NO_LAZY_FLUSH 0x00000004
4948 #define REG_FORCE_RESTORE 0x00000008
4950 #define KEY_READ ((STANDARD_RIGHTS_READ| \
4952 KEY_ENUMERATE_SUB_KEYS| \
4956 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
4958 KEY_CREATE_SUB_KEY) \
4961 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
4962 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
4965 KEY_CREATE_SUB_KEY| \
4966 KEY_ENUMERATE_SUB_KEYS| \
4971 /* ------------------------------ end registry ------------------------------ */
4974 #define EVENTLOG_SUCCESS 0x0000
4975 #define EVENTLOG_ERROR_TYPE 0x0001
4976 #define EVENTLOG_WARNING_TYPE 0x0002
4977 #define EVENTLOG_INFORMATION_TYPE 0x0004
4978 #define EVENTLOG_AUDIT_SUCCESS 0x0008
4979 #define EVENTLOG_AUDIT_FAILURE 0x0010
4981 #define EVENTLOG_SEQUENTIAL_READ 0x0001
4982 #define EVENTLOG_SEEK_READ 0x0002
4983 #define EVENTLOG_FORWARDS_READ 0x0004
4984 #define EVENTLOG_BACKWARDS_READ 0x0008
4986 typedef struct _EVENTLOGRECORD {
4990 DWORD TimeGenerated;
4997 DWORD ClosingRecordNumber;
4999 DWORD UserSidLength;
5000 DWORD UserSidOffset;
5003 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5005 #define SERVICE_BOOT_START 0x00000000
5006 #define SERVICE_SYSTEM_START 0x00000001
5007 #define SERVICE_AUTO_START 0x00000002
5008 #define SERVICE_DEMAND_START 0x00000003
5009 #define SERVICE_DISABLED 0x00000004
5011 #define SERVICE_ERROR_IGNORE 0x00000000
5012 #define SERVICE_ERROR_NORMAL 0x00000001
5013 #define SERVICE_ERROR_SEVERE 0x00000002
5014 #define SERVICE_ERROR_CRITICAL 0x00000003
5017 #define SERVICE_KERNEL_DRIVER 0x00000001
5018 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5019 #define SERVICE_ADAPTER 0x00000004
5020 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5022 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5023 SERVICE_RECOGNIZER_DRIVER )
5025 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5026 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5027 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5029 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5031 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5032 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5035 typedef enum _CM_SERVICE_NODE_TYPE
5037 DriverType = SERVICE_KERNEL_DRIVER,
5038 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
5039 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
5040 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
5041 AdapterType = SERVICE_ADAPTER,
5042 RecognizerType = SERVICE_RECOGNIZER_DRIVER
5043 } SERVICE_NODE_TYPE;
5045 typedef enum _CM_SERVICE_LOAD_TYPE
5047 BootLoad = SERVICE_BOOT_START,
5048 SystemLoad = SERVICE_SYSTEM_START,
5049 AutoLoad = SERVICE_AUTO_START,
5050 DemandLoad = SERVICE_DEMAND_START,
5051 DisableLoad = SERVICE_DISABLED
5052 } SERVICE_LOAD_TYPE;
5054 typedef enum _CM_ERROR_CONTROL_TYPE
5056 IgnoreError = SERVICE_ERROR_IGNORE,
5057 NormalError = SERVICE_ERROR_NORMAL,
5058 SevereError = SERVICE_ERROR_SEVERE,
5059 CriticalError = SERVICE_ERROR_CRITICAL
5060 } SERVICE_ERROR_TYPE;
5064 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5065 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5066 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5067 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5068 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5070 #include <guiddef.h>
5072 typedef struct _OBJECT_TYPE_LIST {
5076 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
5078 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5081 WORD CreatorBackTraceIndex;
5082 struct _RTL_CRITICAL_SECTION *CriticalSection;
5083 LIST_ENTRY ProcessLocksList;
5085 DWORD ContentionCount;
5086 #ifdef __WINESRC__ /* in Wine we store the name here */
5087 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
5091 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
5093 typedef struct _RTL_CRITICAL_SECTION {
5094 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
5096 LONG RecursionCount;
5097 HANDLE OwningThread;
5098 HANDLE LockSemaphore;
5099 ULONG_PTR SpinCount;
5100 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
5102 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5103 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5104 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5105 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5106 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5108 typedef struct _RTL_SRWLOCK {
5110 } RTL_SRWLOCK, *PRTL_SRWLOCK;
5112 #define RTL_SRWLOCK_INIT {0}
5114 typedef struct _RTL_CONDITION_VARIABLE {
5116 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
5117 #define RTL_CONDITION_VARIABLE_INIT {0}
5118 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
5120 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
5121 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
5123 #define RTL_RUN_ONCE_INIT {0}
5124 typedef union _RTL_RUN_ONCE {
5126 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
5128 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
5129 #define RTL_RUN_ONCE_ASYNC 0x00000002
5130 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
5132 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
5133 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
5134 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
5135 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
5137 #include <pshpack8.h>
5138 typedef struct _IO_COUNTERS {
5139 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
5140 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
5141 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
5142 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
5143 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
5144 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
5145 } IO_COUNTERS, *PIO_COUNTERS;
5146 #include <poppack.h>
5149 DWORD dwOSVersionInfoSize;
5150 DWORD dwMajorVersion;
5151 DWORD dwMinorVersion;
5152 DWORD dwBuildNumber;
5154 CHAR szCSDVersion[128];
5155 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5158 DWORD dwOSVersionInfoSize;
5159 DWORD dwMajorVersion;
5160 DWORD dwMinorVersion;
5161 DWORD dwBuildNumber;
5163 WCHAR szCSDVersion[128];
5164 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
5166 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
5167 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
5168 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
5171 DWORD dwOSVersionInfoSize;
5172 DWORD dwMajorVersion;
5173 DWORD dwMinorVersion;
5174 DWORD dwBuildNumber;
5176 CHAR szCSDVersion[128];
5177 WORD wServicePackMajor;
5178 WORD wServicePackMinor;
5182 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5185 DWORD dwOSVersionInfoSize;
5186 DWORD dwMajorVersion;
5187 DWORD dwMinorVersion;
5188 DWORD dwBuildNumber;
5190 WCHAR szCSDVersion[128];
5191 WORD wServicePackMajor;
5192 WORD wServicePackMinor;
5196 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
5198 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
5199 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
5200 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
5202 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
5204 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5206 #define VER_PLATFORM_WIN32s 0
5207 #define VER_PLATFORM_WIN32_WINDOWS 1
5208 #define VER_PLATFORM_WIN32_NT 2
5210 #define VER_MINORVERSION 0x00000001
5211 #define VER_MAJORVERSION 0x00000002
5212 #define VER_BUILDNUMBER 0x00000004
5213 #define VER_PLATFORMID 0x00000008
5214 #define VER_SERVICEPACKMINOR 0x00000010
5215 #define VER_SERVICEPACKMAJOR 0x00000020
5216 #define VER_SUITENAME 0x00000040
5217 #define VER_PRODUCT_TYPE 0x00000080
5219 #define VER_NT_WORKSTATION 1
5220 #define VER_NT_DOMAIN_CONTROLLER 2
5221 #define VER_NT_SERVER 3
5223 #define VER_SUITE_SMALLBUSINESS 0x00000001
5224 #define VER_SUITE_ENTERPRISE 0x00000002
5225 #define VER_SUITE_BACKOFFICE 0x00000004
5226 #define VER_SUITE_COMMUNICATIONS 0x00000008
5227 #define VER_SUITE_TERMINAL 0x00000010
5228 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5229 #define VER_SUITE_EMBEDDEDNT 0x00000040
5230 #define VER_SUITE_DATACENTER 0x00000080
5231 #define VER_SUITE_SINGLEUSERTS 0x00000100
5232 #define VER_SUITE_PERSONAL 0x00000200
5233 #define VER_SUITE_BLADE 0x00000400
5234 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
5235 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
5236 #define VER_SUITE_STORAGE_SERVER 0x00002000
5237 #define VER_SUITE_COMPUTE_SERVER 0x00004000
5238 #define VER_SUITE_WH_SERVER 0x00008000
5241 #define VER_GREATER 2
5242 #define VER_GREATER_EQUAL 3
5244 #define VER_LESS_EQUAL 5
5248 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
5250 DWORD ulFormatVersion;
5251 DWORD ulAssemblyCount;
5252 DWORD ulRootManifestPathType;
5253 DWORD ulRootManifestPathChars;
5254 DWORD ulRootConfigurationPathType;
5255 DWORD ulRootConfigurationPathChars;
5256 DWORD ulAppDirPathType;
5257 DWORD ulAppDirPathChars;
5258 PCWSTR lpRootManifestPath;
5259 PCWSTR lpRootConfigurationPath;
5260 PCWSTR lpAppDirPath;
5261 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
5263 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
5265 DWORD ulEncodedAssemblyIdentityLength;
5266 DWORD ulManifestPathType;
5267 DWORD ulManifestPathLength;
5268 LARGE_INTEGER liManifestLastWriteTime;
5269 DWORD ulPolicyPathType;
5270 DWORD ulPolicyPathLength;
5271 LARGE_INTEGER liPolicyLastWriteTime;
5272 DWORD ulMetadataSatelliteRosterIndex;
5273 DWORD ulManifestVersionMajor;
5274 DWORD ulManifestVersionMinor;
5275 DWORD ulPolicyVersionMajor;
5276 DWORD ulPolicyVersionMinor;
5277 DWORD ulAssemblyDirectoryNameLength;
5278 PCWSTR lpAssemblyEncodedAssemblyIdentity;
5279 PCWSTR lpAssemblyManifestPath;
5280 PCWSTR lpAssemblyPolicyPath;
5281 PCWSTR lpAssemblyDirectoryName;
5283 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
5285 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
5286 DWORD ulAssemblyIndex;
5287 DWORD ulFileIndexInAssembly;
5288 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
5290 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
5292 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
5294 DWORD ulFilenameLength;
5298 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
5300 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
5302 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
5303 ActivationContextBasicInformation = 1,
5304 ActivationContextDetailedInformation = 2,
5305 AssemblyDetailedInformationInActivationContext = 3,
5306 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
5307 MaxActivationContextInfoClass,
5309 AssemblyDetailedInformationInActivationContxt = 3,
5310 FileInformationInAssemblyOfAssemblyInActivationContxt = 4
5311 } ACTIVATION_CONTEXT_INFO_CLASS;
5313 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
5314 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
5315 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
5316 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
5318 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
5319 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
5320 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
5321 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
5322 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
5323 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
5324 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
5325 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
5326 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
5328 typedef enum _JOBOBJECTINFOCLASS
5330 JobObjectBasicAccountingInformation = 1,
5331 JobObjectBasicLimitInformation,
5332 JobObjectBasicProcessIdList,
5333 JobObjectBasicUIRestrictions,
5334 JobObjectSecurityLimitInformation,
5335 JobObjectEndOfJobTimeInformation,
5336 JobObjectAssociateCompletionPortInformation,
5337 JobObjectBasicAndIoAccountingInformation,
5338 JobObjectExtendedLimitInformation,
5339 JobObjectJobSetInformation,
5340 MaxJobObjectInfoClass
5341 } JOBOBJECTINFOCLASS;
5343 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
5345 RelationProcessorCore = 0,
5346 RelationNumaNode = 1,
5348 RelationProcessorPackage = 3,
5350 RelationAll = 0xffff
5351 } LOGICAL_PROCESSOR_RELATIONSHIP;
5353 typedef enum _PROCESSOR_CACHE_TYPE
5359 } PROCESSOR_CACHE_TYPE;
5361 typedef struct _PROCESSOR_GROUP_INFO
5363 BYTE MaximumProcessorCount;
5364 BYTE ActiveProcessorCount;
5366 KAFFINITY ActiveProcessorMask;
5367 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
5369 typedef struct _CACHE_DESCRIPTOR
5375 PROCESSOR_CACHE_TYPE Type;
5376 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
5378 typedef struct _GROUP_AFFINITY
5383 } GROUP_AFFINITY, *PGROUP_AFFINITY;
5385 typedef struct _PROCESSOR_NUMBER
5390 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
5392 typedef struct _PROCESSOR_RELATIONSHIP
5397 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
5398 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
5401 typedef struct _NUMA_NODE_RELATIONSHIP
5405 GROUP_AFFINITY GroupMask;
5406 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
5408 typedef struct _CACHE_RELATIONSHIP
5413 PROCESSOR_CACHE_TYPE Type;
5415 GROUP_AFFINITY GroupMask;
5416 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
5418 typedef struct _GROUP_RELATIONSHIP
5420 WORD MaximumGroupCount;
5421 WORD ActiveGroupCount;
5423 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
5424 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
5426 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
5428 ULONG_PTR ProcessorMask;
5429 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
5440 CACHE_DESCRIPTOR Cache;
5441 ULONGLONG Reserved[2];
5443 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
5445 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
5447 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
5451 PROCESSOR_RELATIONSHIP Processor;
5452 NUMA_NODE_RELATIONSHIP NumaNode;
5453 CACHE_RELATIONSHIP Cache;
5454 GROUP_RELATIONSHIP Group;
5456 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
5458 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
5464 #endif /* _WINNT_ */