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