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