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