VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winnt.h@ 33252

Last change on this file since 33252 was 25949, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette