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