The first 2 parameters of WinMain are HINSTANCEs, not HANDLEs.
[wine] / include / winnt.h
1 /*
2  * Win32 definitions for Windows NT
3  *
4  * Copyright 1996 Alexandre Julliard
5  */
6
7 #ifndef __WINE_WINNT_H
8 #define __WINE_WINNT_H
9
10 #include "basetsd.h"
11
12 #ifndef RC_INVOKED
13 #include <ctype.h>
14 #include <string.h>
15 #include <stddef.h>
16 #endif
17
18
19 /* On Windows winnt.h depends on a few windef.h types and macros and thus 
20  * is not self-contained. Furthermore windef.h includes winnt.h so that it 
21  * would be pointless to try to use winnt.h directly.
22  * But for Wine and Winelib I decided to make winnt.h self-contained by 
23  * moving these definitions to winnt.h. It makes no difference to Winelib 
24  * programs since they are not using winnt.h directly anyway, and it allows 
25  * us to use winnt.h and get a minimal set of definitions.
26  */
27
28 /**** Some Wine specific definitions *****/
29
30 /* Calling conventions definitions */
31
32 #ifdef __i386__
33 # ifndef _X86_
34 #  define _X86_
35 # endif
36 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
37 #  define __stdcall __attribute__((__stdcall__))
38 #  define __cdecl   __attribute__((__cdecl__))
39 # else
40 #  error You need gcc >= 2.7 to build Wine on a 386
41 # endif  /* __GNUC__ */
42 #else  /* __i386__ */
43 # define __stdcall
44 # define __cdecl
45 #endif  /* __i386__ */
46
47 #ifndef __WINE__
48 #define pascal      __stdcall
49 #define _pascal     __stdcall
50 #define _stdcall    __stdcall
51 #define _fastcall   __stdcall
52 #define __fastcall  __stdcall
53 #define __export    __stdcall
54 #define cdecl       __cdecl
55 #define _cdecl      __cdecl
56
57 #define near
58 #define far
59 #define _near
60 #define _far
61 #define NEAR
62 #define FAR
63
64 #ifndef _declspec
65 #define _declspec(x)
66 #endif
67 #ifndef __declspec
68 #define __declspec(x)
69 #endif
70 #endif /* __WINE__ */
71
72 #define CALLBACK    __stdcall
73 #define WINAPI      __stdcall
74 #define APIPRIVATE  __stdcall
75 #define PASCAL      __stdcall
76 #define CDECL       __cdecl
77 #define _CDECL      __cdecl
78 #define WINAPIV     __cdecl
79 #define APIENTRY    WINAPI
80 #define CONST       const
81
82 /* Macro for structure packing and more. */
83
84 #ifdef __GNUC__
85 #define WINE_PACKED   __attribute__((packed))
86 #define WINE_UNUSED   __attribute__((unused))
87 #define WINE_NORETURN __attribute__((noreturn))
88 #else
89 #define WINE_PACKED    /* nothing */
90 #define WINE_UNUSED    /* nothing */
91 #define WINE_NORETURN  /* nothing */
92 #endif
93
94 /* Anonymous union/struct handling */
95
96 #ifdef __WINE__
97 # define NONAMELESSSTRUCT
98 # define NONAMELESSUNION
99 #else
100 /* Anonymous struct support starts with gcc/g++ 2.96 */
101 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
102 #  define NONAMELESSSTRUCT
103 # endif
104 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
105 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
106 #  define NONAMELESSUNION
107 # endif
108 #endif
109
110 #ifndef NONAMELESSSTRUCT
111 #define DUMMYSTRUCTNAME
112 #define DUMMYSTRUCTNAME1
113 #define DUMMYSTRUCTNAME2
114 #define DUMMYSTRUCTNAME3
115 #define DUMMYSTRUCTNAME4
116 #define DUMMYSTRUCTNAME5
117 #else /* !defined(NONAMELESSSTRUCT) */
118 #define DUMMYSTRUCTNAME   s
119 #define DUMMYSTRUCTNAME1  s1
120 #define DUMMYSTRUCTNAME2  s2
121 #define DUMMYSTRUCTNAME3  s3
122 #define DUMMYSTRUCTNAME4  s4
123 #define DUMMYSTRUCTNAME5  s5
124 #endif /* !defined(NONAMELESSSTRUCT) */
125
126 #ifndef NONAMELESSUNION
127 #define DUMMYUNIONNAME
128 #define DUMMYUNIONNAME1
129 #define DUMMYUNIONNAME2
130 #define DUMMYUNIONNAME3
131 #define DUMMYUNIONNAME4
132 #define DUMMYUNIONNAME5
133 #define DUMMYUNIONNAME6
134 #define DUMMYUNIONNAME7
135 #define DUMMYUNIONNAME8
136 #else /* !defined(NONAMELESSUNION) */
137 #define DUMMYUNIONNAME   u
138 #define DUMMYUNIONNAME1  u1
139 #define DUMMYUNIONNAME2  u2
140 #define DUMMYUNIONNAME3  u3
141 #define DUMMYUNIONNAME4  u4
142 #define DUMMYUNIONNAME5  u5
143 #define DUMMYUNIONNAME6  u6
144 #define DUMMYUNIONNAME7  u7
145 #define DUMMYUNIONNAME8  u8
146 #endif /* !defined(NONAMELESSUNION) */
147
148
149 /**** Parts of windef.h that are needed here *****/
150
151 /* Misc. constants. */
152
153 #undef NULL
154 #ifdef __cplusplus
155 #define NULL  0
156 #else
157 #define NULL  ((void*)0)
158 #endif
159
160 #ifdef FALSE
161 #undef FALSE
162 #endif
163 #define FALSE 0
164
165 #ifdef TRUE
166 #undef TRUE
167 #endif
168 #define TRUE  1
169
170 #ifndef IN
171 #define IN
172 #endif
173
174 #ifndef OUT
175 #define OUT
176 #endif
177
178 #ifndef OPTIONAL
179 #define OPTIONAL
180 #endif
181
182 /* Standard data types */
183 typedef const void                  *PCVOID,   *LPCVOID;
184 typedef int             BOOL,       *PBOOL,    *LPBOOL;
185 typedef unsigned char   BYTE,       *PBYTE,    *LPBYTE;
186 typedef unsigned char   UCHAR,      *PUCHAR;
187 typedef unsigned short  USHORT,     *PUSHORT,  *LPUSHORT;
188 typedef unsigned short  WORD,       *PWORD,    *LPWORD;
189 typedef int             INT,        *PINT,     *LPINT;
190 typedef unsigned int    UINT,       *PUINT,    *LPUINT;
191 typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
192 typedef unsigned long   ULONG,      *PULONG,   *LPULONG;
193 typedef float           FLOAT,      *PFLOAT,   *LPFLOAT;
194 typedef double          DOUBLE,     *PDOUBLE,  *LPDOUBLE;
195 typedef double          DATE;
196
197
198 /**** winnt.h proper *****/
199
200 /* Microsoft's macros for declaring functions */
201
202 #ifdef __cplusplus
203 # define EXTERN_C    extern "C"
204 #else
205 # define EXTERN_C    extern
206 #endif
207
208 #ifndef __WINE__
209 #define STDMETHODCALLTYPE       __stdcall
210 #define STDMETHODVCALLTYPE      __cdecl
211 #define STDAPICALLTYPE          __stdcall
212 #define STDAPIVCALLTYPE         __cdecl
213
214 #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
215 #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
216 #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
217 #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
218 #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
219 #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
220 #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
221 #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
222 #endif
223
224 /* Define the basic types */
225 #ifndef VOID
226 #define VOID void
227 #endif
228 typedef VOID           *PVOID,      *LPVOID;
229 typedef BYTE            BOOLEAN,    *PBOOLEAN;
230 typedef char            CHAR,       *PCHAR;
231 typedef short           SHORT,      *PSHORT;
232 typedef long            LONG,       *PLONG,    *LPLONG;
233
234 /* Some systems might have wchar_t, but we really need 16 bit characters */
235 #ifdef WINE_UNICODE_NATIVE
236 typedef wchar_t         WCHAR,      *PWCHAR;
237 #else
238 typedef unsigned short  WCHAR,      *PWCHAR;
239 #endif
240
241 /* 'Extended/Wide' numerical types */
242 #ifndef _ULONGLONG_
243 #define _ULONGLONG_
244 typedef __int64         LONGLONG,   *PLONGLONG;
245 typedef __uint64        ULONGLONG,  *PULONGLONG;
246 #endif
247
248 #ifndef _DWORDLONG_
249 #define _DWORDLONG_
250 typedef ULONGLONG       DWORDLONG,  *PDWORDLONG;
251 #endif
252
253 /* ANSI string types */
254 typedef CHAR           *PCH,        *LPCH;
255 typedef const CHAR     *PCCH,       *LPCCH;
256 typedef CHAR           *PSTR,       *LPSTR;
257 typedef const CHAR     *PCSTR,      *LPCSTR;
258
259 /* Unicode string types */
260 typedef WCHAR          *PWCH,       *LPWCH;
261 typedef const WCHAR    *PCWCH,      *LPCWCH;
262 typedef WCHAR          *PWSTR,      *LPWSTR;
263 typedef const WCHAR    *PCWSTR,     *LPCWSTR;
264
265 /* Neutral character and string types */
266 /* These are only defined for Winelib, i.e. _not_ defined for 
267  * the emulator. The reason is they depend on the UNICODE 
268  * macro which only exists in the user's code.
269  */
270 #ifndef __WINE__
271 # ifdef WINE_UNICODE_REWRITE
272 EXTERN_C unsigned short* wine_rewrite_s4tos2(const wchar_t* str4);
273 #  ifdef __cplusplus
274 inline WCHAR* wine_unicode_text(const wchar_t* str4)
275 {
276   return (WCHAR*)wine_rewrite_s4tos2(str4);
277 }
278 inline WCHAR wine_unicode_text(wchar_t chr4)
279 {
280   return (WCHAR)chr4;
281 }
282 #   define WINE_UNICODE_TEXT(x)       wine_unicode_text(L##x)
283 #  else  /* __cplusplus */
284 #   define WINE_UNICODE_TEXT(x)       ((sizeof(x)==1) || (sizeof(L##x)>4) ? \
285                                       (WCHAR*)wine_rewrite_s4tos2(L##x) : \
286                                       ((WCHAR)L##x))
287 #  endif  /* __cplusplus */
288 # else  /* WINE_UNICODE_REWRITE */
289 /* WINE_UNICODE_NATIVE or nothing at all */
290 #  define WINE_UNICODE_TEXT(string)   L##string
291 # endif  /* WINE_UNICODE_REWRITE */
292
293 # ifdef UNICODE
294 typedef WCHAR           TCHAR,      *PTCHAR;
295 typedef LPWSTR          PTSTR,       LPTSTR;
296 typedef LPCWSTR         PCTSTR,      LPCTSTR;
297 #  define __TEXT(string) WINE_UNICODE_TEXT(string)
298 # else  /* UNICODE */
299 typedef CHAR            TCHAR,      *PTCHAR;
300 typedef LPSTR           PTSTR,       LPTSTR;
301 typedef LPCSTR          PCTSTR,      LPCTSTR;
302 #  define __TEXT(string) string
303 # endif /* UNICODE */
304 # define TEXT(quote) __TEXT(quote)
305 #endif   /* __WINE__ */
306
307 /* Misc common WIN32 types */
308 typedef LONG            HRESULT;
309 typedef DWORD           LCID,       *PLCID;
310 typedef WORD            LANGID;
311
312 /* Handle type */
313
314 /* FIXME: Wine does not compile with strict on, therefore strict
315  * handles are presently only usable on machines where sizeof(UINT) ==
316  * sizeof(void*).  HANDLEs are supposed to be void* but a large amount
317  * of WINE code operates on HANDLES as if they are UINTs. So to WINE
318  * they exist as UINTs but to the Winelib user who turns on strict,
319  * they exist as void*. If there is a size difference between UINT and
320  * void* then things get ugly.
321  *
322  * Here is the plan to convert Wine to STRICT:
323  *
324  * Types will be converted one at a time by volunteers who will compile
325  * Wine with STRICT turned on. Handles that have not been converted yet 
326  * will be declared with DECLARE_OLD_HANDLE. Converted handles are 
327  * declared with DECLARE_HANDLE.
328  * See the bug report 90 for more details:
329  *    http://wine.codeweavers.com/bugzilla/show_bug.cgi?id=90
330  */
331 /*
332  * when compiling Wine we always treat HANDLE as an UINT. Then when 
333  * we're ready we'll remove the '!defined(__WINE__)' (the equivalent 
334  * of converting it from DECLARE_OLD_HANDLE to DECLARE_HANDLE).
335  */
336 #if defined(STRICT) && !defined(__WINE__)
337 typedef VOID*           HANDLE;
338 #define DECLARE_OLD_HANDLE(a) \
339     typedef struct a##__ { int unused; } *a; \
340     typedef a          *P##a,       *LP##a
341
342 #else
343 typedef UINT            HANDLE;
344 #define DECLARE_OLD_HANDLE(a) \
345     typedef HANDLE      a; \
346     typedef a          *P##a,       *LP##a
347 #endif
348 typedef HANDLE         *PHANDLE,    *LPHANDLE;
349
350 #ifdef STRICT
351 #define DECLARE_HANDLE(a) \
352     typedef struct a##__ { int unused; } *a; \
353     typedef a          *P##a,       *LP##a
354 #else /*STRICT*/
355 #define DECLARE_HANDLE(a) \
356     typedef HANDLE      a; \
357     typedef a          *P##a,       *LP##a
358 #endif /*STRICT*/
359
360
361 #include "pshpack1.h"
362 /* Defines */
363
364 /* Argument 1 passed to the DllEntryProc. */
365 #define DLL_PROCESS_DETACH      0       /* detach process (unload library) */
366 #define DLL_PROCESS_ATTACH      1       /* attach process (load library) */
367 #define DLL_THREAD_ATTACH       2       /* attach new thread */
368 #define DLL_THREAD_DETACH       3       /* detach thread */
369
370
371 /* u.x.wProcessorArchitecture (NT) */
372 #define PROCESSOR_ARCHITECTURE_INTEL    0
373 #define PROCESSOR_ARCHITECTURE_MIPS     1
374 #define PROCESSOR_ARCHITECTURE_ALPHA    2
375 #define PROCESSOR_ARCHITECTURE_PPC      3
376 #define PROCESSOR_ARCHITECTURE_SHX      4
377 #define PROCESSOR_ARCHITECTURE_ARM      5
378 #define PROCESSOR_ARCHITECTURE_UNKNOWN  0xFFFF
379
380 /* dwProcessorType */
381 #define PROCESSOR_INTEL_386      386
382 #define PROCESSOR_INTEL_486      486
383 #define PROCESSOR_INTEL_PENTIUM  586
384 #define PROCESSOR_INTEL_860      860
385 #define PROCESSOR_MIPS_R2000     2000
386 #define PROCESSOR_MIPS_R3000     3000
387 #define PROCESSOR_MIPS_R4000     4000
388 #define PROCESSOR_ALPHA_21064    21064
389 #define PROCESSOR_PPC_601        601
390 #define PROCESSOR_PPC_603        603
391 #define PROCESSOR_PPC_604        604
392 #define PROCESSOR_PPC_620        620
393 #define PROCESSOR_HITACHI_SH3    10003
394 #define PROCESSOR_HITACHI_SH3E   10004
395 #define PROCESSOR_HITACHI_SH4    10005
396 #define PROCESSOR_MOTOROLA_821   821
397 #define PROCESSOR_SHx_SH3        103
398 #define PROCESSOR_SHx_SH4        104
399 #define PROCESSOR_STRONGARM      2577
400 #define PROCESSOR_ARM720         1824    /* 0x720 */
401 #define PROCESSOR_ARM820         2080    /* 0x820 */
402 #define PROCESSOR_ARM920         2336    /* 0x920 */
403 #define PROCESSOR_ARM_7TDMI      70001
404
405 typedef struct _MEMORY_BASIC_INFORMATION
406 {
407     LPVOID   BaseAddress;
408     LPVOID   AllocationBase;
409     DWORD    AllocationProtect;
410     DWORD    RegionSize;
411     DWORD    State;
412     DWORD    Protect;
413     DWORD    Type;
414 } MEMORY_BASIC_INFORMATION,*LPMEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
415
416 #define PAGE_NOACCESS           0x01
417 #define PAGE_READONLY           0x02
418 #define PAGE_READWRITE          0x04
419 #define PAGE_WRITECOPY          0x08
420 #define PAGE_EXECUTE            0x10
421 #define PAGE_EXECUTE_READ       0x20
422 #define PAGE_EXECUTE_READWRITE  0x40
423 #define PAGE_EXECUTE_WRITECOPY  0x80
424 #define PAGE_GUARD              0x100
425 #define PAGE_NOCACHE            0x200
426
427 #define MEM_COMMIT              0x00001000
428 #define MEM_RESERVE             0x00002000
429 #define MEM_DECOMMIT            0x00004000
430 #define MEM_RELEASE             0x00008000
431 #define MEM_FREE                0x00010000
432 #define MEM_PRIVATE             0x00020000
433 #define MEM_MAPPED              0x00040000
434 #define MEM_RESET               0x00080000
435 #define MEM_TOP_DOWN            0x00100000
436 #ifdef __WINE__
437 #define MEM_SYSTEM              0x80000000
438 #endif
439
440 #define SEC_FILE                0x00800000
441 #define SEC_IMAGE               0x01000000
442 #define SEC_RESERVE             0x04000000
443 #define SEC_COMMIT              0x08000000
444 #define SEC_NOCACHE             0x10000000
445 #define MEM_IMAGE               SEC_IMAGE
446
447
448 #define MINCHAR       0x80
449 #define MAXCHAR       0x7f
450 #define MINSHORT      0x8000
451 #define MAXSHORT      0x7fff
452 #define MINLONG       0x80000000
453 #define MAXLONG       0x7fffffff
454 #define MAXBYTE       0xff
455 #define MAXWORD       0xffff
456 #define MAXDWORD      0xffffffff
457
458 #define FIELD_OFFSET(type, field) \
459   ((LONG)(INT)&(((type *)0)->field))
460
461 #define CONTAINING_RECORD(address, type, field) \
462   ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
463
464 /* Types */
465
466 typedef struct _LIST_ENTRY {
467   struct _LIST_ENTRY *Flink;
468   struct _LIST_ENTRY *Blink;
469 } LIST_ENTRY, *PLIST_ENTRY;
470
471 typedef struct _SINGLE_LIST_ENTRY {
472   struct _SINGLE_LIST_ENTRY *Next;
473 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
474
475 /* Heap flags */
476
477 #define HEAP_NO_SERIALIZE               0x00000001
478 #define HEAP_GROWABLE                   0x00000002
479 #define HEAP_GENERATE_EXCEPTIONS        0x00000004
480 #define HEAP_ZERO_MEMORY                0x00000008
481 #define HEAP_REALLOC_IN_PLACE_ONLY      0x00000010
482 #define HEAP_TAIL_CHECKING_ENABLED      0x00000020
483 #define HEAP_FREE_CHECKING_ENABLED      0x00000040
484 #define HEAP_DISABLE_COALESCE_ON_FREE   0x00000080
485 #define HEAP_CREATE_ALIGN_16            0x00010000
486 #define HEAP_CREATE_ENABLE_TRACING      0x00020000
487
488 /* This flag allows it to create heaps shared by all processes under win95,
489    FIXME: correct name */
490 #define HEAP_SHARED                     0x04000000  
491
492 #define HEAP_WINE_SEGPTR                0x10000000  /* Not a Win32 flag */
493 #define HEAP_WINE_CODESEG               0x20000000  /* Not a Win32 flag */
494 #define HEAP_WINE_CODE16SEG             0x40000000  /* Not a Win32 flag */
495
496 /* Processor feature flags.  */
497 #define PF_FLOATING_POINT_PRECISION_ERRATA      0
498 #define PF_FLOATING_POINT_EMULATED              1
499 #define PF_COMPARE_EXCHANGE_DOUBLE              2
500 #define PF_MMX_INSTRUCTIONS_AVAILABLE           3
501 #define PF_PPC_MOVEMEM_64BIT_OK                 4
502 #define PF_ALPHA_BYTE_INSTRUCTIONS              5
503
504
505 /* The Win32 register context */
506
507 /* CONTEXT is the CPU-dependent context; it should be used        */
508 /* wherever a platform-specific context is needed (e.g. exception */
509 /* handling, Win32 register functions). */
510
511 /* CONTEXT86 is the i386-specific context; it should be used     */
512 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
513 /* Win16 register functions), so that this code can be compiled  */
514 /* on all platforms. */
515
516 #define SIZE_OF_80387_REGISTERS      80
517
518 typedef struct _FLOATING_SAVE_AREA
519 {
520     DWORD   ControlWord;
521     DWORD   StatusWord;
522     DWORD   TagWord;    
523     DWORD   ErrorOffset;
524     DWORD   ErrorSelector;
525     DWORD   DataOffset;
526     DWORD   DataSelector;    
527     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
528     DWORD   Cr0NpxState;
529 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
530
531 typedef struct _CONTEXT86
532 {
533     DWORD   ContextFlags;
534
535     /* These are selected by CONTEXT_DEBUG_REGISTERS */
536     DWORD   Dr0;
537     DWORD   Dr1;
538     DWORD   Dr2;
539     DWORD   Dr3;
540     DWORD   Dr6;
541     DWORD   Dr7;
542
543     /* These are selected by CONTEXT_FLOATING_POINT */
544     FLOATING_SAVE_AREA FloatSave;
545
546     /* These are selected by CONTEXT_SEGMENTS */
547     DWORD   SegGs;
548     DWORD   SegFs;
549     DWORD   SegEs;
550     DWORD   SegDs;    
551
552     /* These are selected by CONTEXT_INTEGER */
553     DWORD   Edi;
554     DWORD   Esi;
555     DWORD   Ebx;
556     DWORD   Edx;    
557     DWORD   Ecx;
558     DWORD   Eax;
559
560     /* These are selected by CONTEXT_CONTROL */
561     DWORD   Ebp;    
562     DWORD   Eip;
563     DWORD   SegCs;
564     DWORD   EFlags;
565     DWORD   Esp;
566     DWORD   SegSs;
567 } CONTEXT86;
568
569 #define CONTEXT_X86       0x00010000
570 #define CONTEXT_i386      CONTEXT_X86
571 #define CONTEXT_i486      CONTEXT_X86
572
573 #define CONTEXT86_CONTROL   (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
574 #define CONTEXT86_INTEGER   (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
575 #define CONTEXT86_SEGMENTS  (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
576 #define CONTEXT86_FLOATING_POINT  (CONTEXT_i386 | 0x0008L) /* 387 state */
577 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
578 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
579
580 /* i386 context definitions */
581 #ifdef __i386__
582
583 #define CONTEXT_CONTROL         CONTEXT86_CONTROL
584 #define CONTEXT_INTEGER         CONTEXT86_INTEGER
585 #define CONTEXT_SEGMENTS        CONTEXT86_SEGMENTS
586 #define CONTEXT_FLOATING_POINT  CONTEXT86_FLOATING_POINT
587 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
588 #define CONTEXT_FULL            CONTEXT86_FULL
589
590 typedef CONTEXT86 CONTEXT;
591
592 #endif  /* __i386__ */
593
594 /* Alpha context definitions */
595 #ifdef _ALPHA_
596
597 #define CONTEXT_ALPHA   0x00020000
598  
599 #define CONTEXT_CONTROL         (CONTEXT_ALPHA | 0x00000001L)
600 #define CONTEXT_FLOATING_POINT  (CONTEXT_ALPHA | 0x00000002L)
601 #define CONTEXT_INTEGER         (CONTEXT_ALPHA | 0x00000004L)
602 #define CONTEXT_FULL  (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
603
604 typedef struct _CONTEXT
605 {
606     /* selected by CONTEXT_FLOATING_POINT */
607     ULONGLONG FltF0;
608     ULONGLONG FltF1;
609     ULONGLONG FltF2;
610     ULONGLONG FltF3;
611     ULONGLONG FltF4;
612     ULONGLONG FltF5;
613     ULONGLONG FltF6;
614     ULONGLONG FltF7;
615     ULONGLONG FltF8;
616     ULONGLONG FltF9;
617     ULONGLONG FltF10;
618     ULONGLONG FltF11;
619     ULONGLONG FltF12;
620     ULONGLONG FltF13;
621     ULONGLONG FltF14;
622     ULONGLONG FltF15;
623     ULONGLONG FltF16;
624     ULONGLONG FltF17;
625     ULONGLONG FltF18;
626     ULONGLONG FltF19;
627     ULONGLONG FltF20;
628     ULONGLONG FltF21;
629     ULONGLONG FltF22;
630     ULONGLONG FltF23;
631     ULONGLONG FltF24;
632     ULONGLONG FltF25;
633     ULONGLONG FltF26;
634     ULONGLONG FltF27;
635     ULONGLONG FltF28;
636     ULONGLONG FltF29;
637     ULONGLONG FltF30;
638     ULONGLONG FltF31;
639
640     /* selected by CONTEXT_INTEGER */
641     ULONGLONG IntV0;
642     ULONGLONG IntT0;
643     ULONGLONG IntT1;
644     ULONGLONG IntT2;
645     ULONGLONG IntT3;
646     ULONGLONG IntT4;
647     ULONGLONG IntT5;
648     ULONGLONG IntT6;
649     ULONGLONG IntT7;
650     ULONGLONG IntS0;
651     ULONGLONG IntS1;
652     ULONGLONG IntS2;
653     ULONGLONG IntS3;
654     ULONGLONG IntS4;
655     ULONGLONG IntS5;
656     ULONGLONG IntFp;
657     ULONGLONG IntA0;
658     ULONGLONG IntA1;
659     ULONGLONG IntA2;
660     ULONGLONG IntA3;
661     ULONGLONG IntA4;
662     ULONGLONG IntA5;
663     ULONGLONG IntT8;
664     ULONGLONG IntT9;
665     ULONGLONG IntT10;
666     ULONGLONG IntT11;
667     ULONGLONG IntRa;
668     ULONGLONG IntT12;
669     ULONGLONG IntAt;
670     ULONGLONG IntGp;
671     ULONGLONG IntSp;
672     ULONGLONG IntZero;
673
674     /* selected by CONTEXT_FLOATING_POINT */
675     ULONGLONG Fpcr;
676     ULONGLONG SoftFpcr;
677
678     /* selected by CONTEXT_CONTROL */
679     ULONGLONG Fir;
680     DWORD Psr;
681     DWORD ContextFlags;
682     DWORD Fill[4];
683 } CONTEXT;
684
685 #define _QUAD_PSR_OFFSET   HighSoftFpcr
686 #define _QUAD_FLAGS_OFFSET HighFir
687
688 #endif  /* _ALPHA_ */
689
690 /* Mips context definitions */
691 #ifdef _MIPS_
692
693 #define CONTEXT_R4000   0x00010000
694
695 #define CONTEXT_CONTROL         (CONTEXT_R4000 | 0x00000001)
696 #define CONTEXT_FLOATING_POINT  (CONTEXT_R4000 | 0x00000002)
697 #define CONTEXT_INTEGER         (CONTEXT_R4000 | 0x00000004)
698
699 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
700
701 typedef struct _CONTEXT
702 {
703     DWORD Argument[4];
704     /* These are selected by CONTEXT_FLOATING_POINT */
705     DWORD FltF0;
706     DWORD FltF1;
707     DWORD FltF2;
708     DWORD FltF3;
709     DWORD FltF4;
710     DWORD FltF5;
711     DWORD FltF6;
712     DWORD FltF7;
713     DWORD FltF8;
714     DWORD FltF9;
715     DWORD FltF10;
716     DWORD FltF11;
717     DWORD FltF12;
718     DWORD FltF13;
719     DWORD FltF14;
720     DWORD FltF15;
721     DWORD FltF16;
722     DWORD FltF17;
723     DWORD FltF18;
724     DWORD FltF19;
725     DWORD FltF20;
726     DWORD FltF21;
727     DWORD FltF22;
728     DWORD FltF23;
729     DWORD FltF24;
730     DWORD FltF25;
731     DWORD FltF26;
732     DWORD FltF27;
733     DWORD FltF28;
734     DWORD FltF29;
735     DWORD FltF30;
736     DWORD FltF31;
737
738     /* These are selected by CONTEXT_INTEGER */
739     DWORD IntZero;
740     DWORD IntAt;
741     DWORD IntV0;
742     DWORD IntV1;
743     DWORD IntA0;
744     DWORD IntA1;
745     DWORD IntA2;
746     DWORD IntA3;
747     DWORD IntT0;
748     DWORD IntT1;
749     DWORD IntT2;
750     DWORD IntT3;
751     DWORD IntT4;
752     DWORD IntT5;
753     DWORD IntT6;
754     DWORD IntT7;
755     DWORD IntS0;
756     DWORD IntS1;
757     DWORD IntS2;
758     DWORD IntS3;
759     DWORD IntS4;
760     DWORD IntS5;
761     DWORD IntS6;
762     DWORD IntS7;
763     DWORD IntT8;
764     DWORD IntT9;
765     DWORD IntK0;
766     DWORD IntK1;
767     DWORD IntGp;
768     DWORD IntSp;
769     DWORD IntS8;
770     DWORD IntRa;
771     DWORD IntLo;
772     DWORD IntHi;
773
774     /* These are selected by CONTEXT_FLOATING_POINT */
775     DWORD Fsr;
776
777     /* These are selected by CONTEXT_CONTROL */
778     DWORD Fir;
779     DWORD Psr;
780
781     DWORD ContextFlags;
782     DWORD Fill[2];
783 } CONTEXT;
784
785 #endif  /* _MIPS_ */
786
787 /* PowerPC context definitions */
788 #ifdef __PPC__
789
790 #define CONTEXT_CONTROL         0x0001
791 #define CONTEXT_FLOATING_POINT  0x0002
792 #define CONTEXT_INTEGER         0x0004
793 #define CONTEXT_DEBUG_REGISTERS 0x0008
794 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
795
796 typedef struct
797 {
798     /* These are selected by CONTEXT_FLOATING_POINT */
799     double Fpr0;
800     double Fpr1;
801     double Fpr2;
802     double Fpr3;
803     double Fpr4;
804     double Fpr5;
805     double Fpr6;
806     double Fpr7;
807     double Fpr8;
808     double Fpr9;
809     double Fpr10;
810     double Fpr11;
811     double Fpr12;
812     double Fpr13;
813     double Fpr14;
814     double Fpr15;
815     double Fpr16;
816     double Fpr17;
817     double Fpr18;
818     double Fpr19;
819     double Fpr20;
820     double Fpr21;
821     double Fpr22;
822     double Fpr23;
823     double Fpr24;
824     double Fpr25;
825     double Fpr26;
826     double Fpr27;
827     double Fpr28;
828     double Fpr29;
829     double Fpr30;
830     double Fpr31;
831     double Fpscr;
832
833     /* These are selected by CONTEXT_INTEGER */
834     DWORD Gpr0;
835     DWORD Gpr1;
836     DWORD Gpr2;
837     DWORD Gpr3;
838     DWORD Gpr4;
839     DWORD Gpr5;
840     DWORD Gpr6;
841     DWORD Gpr7;
842     DWORD Gpr8;
843     DWORD Gpr9;
844     DWORD Gpr10;
845     DWORD Gpr11;
846     DWORD Gpr12;
847     DWORD Gpr13;
848     DWORD Gpr14;
849     DWORD Gpr15;
850     DWORD Gpr16;
851     DWORD Gpr17;
852     DWORD Gpr18;
853     DWORD Gpr19;
854     DWORD Gpr20;
855     DWORD Gpr21;
856     DWORD Gpr22;
857     DWORD Gpr23;
858     DWORD Gpr24;
859     DWORD Gpr25;
860     DWORD Gpr26;
861     DWORD Gpr27;
862     DWORD Gpr28;
863     DWORD Gpr29;
864     DWORD Gpr30;
865     DWORD Gpr31;
866
867     DWORD Cr;
868     DWORD Xer;
869
870     /* These are selected by CONTEXT_CONTROL */
871     DWORD Msr;
872     DWORD Iar;
873     DWORD Lr;
874     DWORD Ctr;
875
876     DWORD ContextFlags;
877     DWORD Fill[3];
878
879     /* These are selected by CONTEXT_DEBUG_REGISTERS */
880     DWORD Dr0;
881     DWORD Dr1;
882     DWORD Dr2;
883     DWORD Dr3;
884     DWORD Dr4;
885     DWORD Dr5;
886     DWORD Dr6;
887     DWORD Dr7;
888 } CONTEXT;
889
890 typedef struct _STACK_FRAME_HEADER
891 {
892     DWORD BackChain;
893     DWORD GlueSaved1;
894     DWORD GlueSaved2;
895     DWORD Reserved1;
896     DWORD Spare1;
897     DWORD Spare2;
898
899     DWORD Parameter0;
900     DWORD Parameter1;
901     DWORD Parameter2;
902     DWORD Parameter3;
903     DWORD Parameter4;
904     DWORD Parameter5;
905     DWORD Parameter6;
906     DWORD Parameter7;
907 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
908
909 #endif  /* __PPC__ */
910
911 #ifdef __sparc__
912
913 /* 
914  * FIXME:  
915  *
916  * There is no official CONTEXT structure defined for the SPARC 
917  * architecture, so I just made one up.
918  *
919  * This structure is valid only for 32-bit SPARC architectures,
920  * not for 64-bit SPARC.
921  *
922  * Note that this structure contains only the 'top-level' registers;
923  * the rest of the register window chain is not visible.
924  *
925  * The layout follows the Solaris 'prgregset_t' structure.
926  * 
927  */ 
928
929 #define CONTEXT_SPARC            0x10000000
930
931 #define CONTEXT_CONTROL         (CONTEXT_SPARC | 0x00000001)
932 #define CONTEXT_FLOATING_POINT  (CONTEXT_SPARC | 0x00000002)
933 #define CONTEXT_INTEGER         (CONTEXT_SPARC | 0x00000004)
934
935 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
936
937 typedef struct _CONTEXT
938 {
939     DWORD ContextFlags;
940
941     /* These are selected by CONTEXT_INTEGER */
942     DWORD g0;
943     DWORD g1;
944     DWORD g2;
945     DWORD g3;
946     DWORD g4;
947     DWORD g5;
948     DWORD g6;
949     DWORD g7;
950     DWORD o0;
951     DWORD o1;
952     DWORD o2;
953     DWORD o3;
954     DWORD o4;
955     DWORD o5;
956     DWORD o6;
957     DWORD o7;
958     DWORD l0;
959     DWORD l1;
960     DWORD l2;
961     DWORD l3;
962     DWORD l4;
963     DWORD l5;
964     DWORD l6;
965     DWORD l7;
966     DWORD i0;
967     DWORD i1;
968     DWORD i2;
969     DWORD i3;
970     DWORD i4;
971     DWORD i5;
972     DWORD i6;
973     DWORD i7;
974
975     /* These are selected by CONTEXT_CONTROL */
976     DWORD psr;
977     DWORD pc;
978     DWORD npc;
979     DWORD y;
980     DWORD wim;
981     DWORD tbr;
982
983     /* FIXME: floating point registers missing */
984
985 } CONTEXT;
986
987 #endif  /* __sparc__ */
988
989 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
990 #error You need to define a CONTEXT for your CPU
991 #endif
992
993 typedef CONTEXT *PCONTEXT;
994
995 #ifdef __WINE__
996
997 /* Macros for easier access to i386 context registers */
998
999 #define AX_reg(context)      (*(WORD*)&(context)->Eax)
1000 #define BX_reg(context)      (*(WORD*)&(context)->Ebx)
1001 #define CX_reg(context)      (*(WORD*)&(context)->Ecx)
1002 #define DX_reg(context)      (*(WORD*)&(context)->Edx)
1003 #define SI_reg(context)      (*(WORD*)&(context)->Esi)
1004 #define DI_reg(context)      (*(WORD*)&(context)->Edi)
1005 #define BP_reg(context)      (*(WORD*)&(context)->Ebp)
1006
1007 #define AL_reg(context)      (*(BYTE*)&(context)->Eax)
1008 #define AH_reg(context)      (*((BYTE*)&(context)->Eax + 1))
1009 #define BL_reg(context)      (*(BYTE*)&(context)->Ebx)
1010 #define BH_reg(context)      (*((BYTE*)&(context)->Ebx + 1))
1011 #define CL_reg(context)      (*(BYTE*)&(context)->Ecx)
1012 #define CH_reg(context)      (*((BYTE*)&(context)->Ecx + 1))
1013 #define DL_reg(context)      (*(BYTE*)&(context)->Edx)
1014 #define DH_reg(context)      (*((BYTE*)&(context)->Edx + 1))
1015
1016 #define SET_CFLAG(context)   ((context)->EFlags |= 0x0001)
1017 #define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
1018 #define SET_ZFLAG(context)   ((context)->EFlags |= 0x0040)
1019 #define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
1020 #define ISV86(context)       ((context)->EFlags & 0x00020000)
1021
1022
1023 /* Macros to retrieve the current context */
1024
1025 #ifdef NEED_UNDERSCORE_PREFIX
1026 # define __ASM_NAME(name) "_" name
1027 #else
1028 # define __ASM_NAME(name) name
1029 #endif
1030
1031 #ifdef NEED_TYPE_IN_DEF
1032 # define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
1033 #else
1034 # define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
1035 #endif
1036
1037 #ifdef __GNUC__
1038 # define __ASM_GLOBAL_FUNC(name,code) \
1039       __asm__( ".align 4\n\t" \
1040                ".globl " __ASM_NAME(#name) "\n\t" \
1041                __ASM_FUNC(#name) "\n" \
1042                __ASM_NAME(#name) ":\n\t" \
1043                code );
1044 #else  /* __GNUC__ */
1045 # define __ASM_GLOBAL_FUNC(name,code) \
1046       void __asm_dummy_##name(void) { \
1047           asm( ".align 4\n\t" \
1048                ".globl " __ASM_NAME(#name) "\n\t" \
1049                __ASM_FUNC(#name) "\n" \
1050                __ASM_NAME(#name) ":\n\t" \
1051                code ); \
1052       }
1053 #endif  /* __GNUC__ */
1054
1055 #ifdef __i386__
1056
1057 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
1058     __ASM_GLOBAL_FUNC( name, \
1059                        "call " __ASM_NAME("CALL32_Regs") "\n\t" \
1060                        ".long " __ASM_NAME(#fn) "\n\t" \
1061                        ".byte " #args ", " #args )
1062 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1063   extern void WINAPI name(void); \
1064   _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
1065 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1066   extern void WINAPI name( t1 a1 ); \
1067   _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
1068 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1069   extern void WINAPI name( t1 a1, t2 a2 ); \
1070   _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
1071 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1072   extern void WINAPI name( t1 a1, t2 a2, t3 a3 ); \
1073   _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
1074 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1075   extern void WINAPI name( t1 a1, t2 a2, t3 a3, t4 a4 ); \
1076   _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
1077
1078 #endif  /* __i386__ */
1079
1080 #ifdef __sparc__
1081 /* FIXME: use getcontext() to retrieve full context */
1082 #define _GET_CONTEXT \
1083     CONTEXT context;   \
1084     do { memset(&context, 0, sizeof(CONTEXT));            \
1085          context.ContextFlags = CONTEXT_CONTROL;          \
1086          context.pc = (DWORD)__builtin_return_address(0); \
1087        } while (0)
1088
1089 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1090   void WINAPI name ( void ) \
1091   { _GET_CONTEXT; fn( &context ); }
1092 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1093   void WINAPI name ( t1 a1 ) \
1094   { _GET_CONTEXT; fn( a1, &context ); }
1095 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1096   void WINAPI name ( t1 a1, t2 a2 ) \
1097   { _GET_CONTEXT; fn( a1, a2, &context ); }
1098 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1099   void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1100   { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1101 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1102   void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1103   { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1104
1105 #endif /* __sparc__ */
1106
1107 #ifndef DEFINE_REGS_ENTRYPOINT_0
1108 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
1109 #endif
1110
1111 /* Constructor functions */
1112
1113 #ifdef __GNUC__
1114 # define DECL_GLOBAL_CONSTRUCTOR(func) \
1115     static void func(void) __attribute__((constructor)); \
1116     static void func(void)
1117 #else  /* __GNUC__ */
1118 # ifdef __i386__
1119 #  define DECL_GLOBAL_CONSTRUCTOR(func) \
1120     static void __dummy_init_##func(void) { \
1121         asm(".section .init,\"ax\"\n\t" \
1122             "call " #func "\n\t" \
1123             ".previous"); } \
1124     static void func(void)
1125 # else  /* __i386__ */
1126 #  error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
1127 # endif
1128 #endif  /* __GNUC__ */
1129
1130 /* Segment register access */
1131
1132 #ifdef __i386__
1133 # ifdef __GNUC__
1134 #  define __DEFINE_GET_SEG(seg) \
1135     extern inline unsigned short __get_##seg(void) \
1136     { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
1137 #  define __DEFINE_SET_SEG(seg) \
1138     extern inline void __set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
1139 # else  /* __GNUC__ */
1140 #  define __DEFINE_GET_SEG(seg) extern unsigned short __get_##seg(void);
1141 #  define __DEFINE_SET_SEG(seg) extern void __set_##seg(unsigned int);
1142 # endif /* __GNUC__ */
1143 #else  /* __i386__ */
1144 # define __DEFINE_GET_SEG(seg) inline static unsigned short __get_##seg(void) { return 0; }
1145 # define __DEFINE_SET_SEG(seg) /* nothing */
1146 #endif  /* __i386__ */
1147
1148 __DEFINE_GET_SEG(cs)
1149 __DEFINE_GET_SEG(ds)
1150 __DEFINE_GET_SEG(es)
1151 __DEFINE_GET_SEG(fs)
1152 __DEFINE_GET_SEG(gs)
1153 __DEFINE_GET_SEG(ss)
1154 __DEFINE_SET_SEG(fs)
1155 __DEFINE_SET_SEG(gs)
1156 #undef __DEFINE_GET_SEG
1157 #undef __DEFINE_SET_SEG
1158
1159 #endif  /* __WINE__ */
1160
1161
1162
1163 /*
1164  * Language IDs
1165  */
1166
1167 #define MAKELCID(l, s)          (MAKELONG(l, s))
1168
1169 #define MAKELANGID(p, s)        ((((WORD)(s))<<10) | (WORD)(p))
1170 #define PRIMARYLANGID(l)        ((WORD)(l) & 0x3ff)
1171 #define SUBLANGID(l)            ((WORD)(l) >> 10)
1172
1173 #define LANGIDFROMLCID(lcid)    ((WORD)(lcid))
1174 #define SORTIDFROMLCID(lcid)    ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1175
1176 #define LANG_SYSTEM_DEFAULT     (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1177 #define LANG_USER_DEFAULT       (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1178 #define LOCALE_SYSTEM_DEFAULT   (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1179 #define LOCALE_USER_DEFAULT     (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT)) 
1180 #define LOCALE_NEUTRAL          (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1181
1182 /* FIXME: are the symbolic names correct for LIDs:  0x17, 0x20, 0x28,
1183  *        0x2a, 0x2b, 0x2c, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
1184  *        0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3e, 0x3f, 0x41, 0x43, 0x44,
1185  *        0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
1186  *        0x4f, 0x57
1187  */
1188 #define LANG_NEUTRAL                     0x00
1189 #define LANG_AFRIKAANS                   0x36
1190 #define LANG_ALBANIAN                    0x1c
1191 #define LANG_ARABIC                      0x01
1192 #define LANG_ARMENIAN                    0x2b
1193 #define LANG_ASSAMESE                    0x4d
1194 #define LANG_AZERI                       0x2c
1195 #define LANG_BASQUE                      0x2d
1196 #define LANG_BENGALI                     0x45
1197 #define LANG_BULGARIAN                   0x02
1198 #define LANG_BYELORUSSIAN                0x23
1199 #define LANG_CATALAN                     0x03
1200 #define LANG_CHINESE                     0x04
1201 #define LANG_SERBO_CROATIAN              0x1a
1202 #define LANG_CROATIAN     LANG_SERBO_CROATIAN
1203 #define LANG_SERBIAN      LANG_SERBO_CROATIAN
1204 #define LANG_CZECH                       0x05
1205 #define LANG_DANISH                      0x06
1206 #define LANG_DUTCH                       0x13
1207 #define LANG_ENGLISH                     0x09
1208 #define LANG_ESTONIAN                    0x25
1209 #define LANG_FAEROESE                    0x38
1210 #define LANG_FARSI                       0x29
1211 #define LANG_FINNISH                     0x0b
1212 #define LANG_FRENCH                      0x0c
1213 #define LANG_GAELIC                      0x3c
1214 #define LANG_GEORGIAN                    0x37
1215 #define LANG_GERMAN                      0x07
1216 #define LANG_GREEK                       0x08
1217 #define LANG_GUJARATI                    0x47
1218 #define LANG_HEBREW                      0x0D
1219 #define LANG_HINDI                       0x39
1220 #define LANG_HUNGARIAN                   0x0e
1221 #define LANG_ICELANDIC                   0x0f
1222 #define LANG_INDONESIAN                  0x21
1223 #define LANG_ITALIAN                     0x10
1224 #define LANG_JAPANESE                    0x11
1225 #define LANG_KANNADA                     0x4b
1226 #define LANG_KAZAKH                      0x3f
1227 #define LANG_KONKANI                     0x57
1228 #define LANG_KOREAN                      0x12
1229 #define LANG_LATVIAN                     0x26
1230 #define LANG_LITHUANIAN                  0x27
1231 #define LANG_MACEDONIAN                  0x2f
1232 #define LANG_MALAY                       0x3e
1233 #define LANG_MALAYALAM                   0x4c
1234 #define LANG_MALTESE                     0x3a
1235 #define LANG_MAORI                       0x28
1236 #define LANG_MARATHI                     0x4e
1237 #define LANG_NORWEGIAN                   0x14
1238 #define LANG_ORIYA                       0x48
1239 #define LANG_POLISH                      0x15
1240 #define LANG_PORTUGUESE                  0x16
1241 #define LANG_PUNJABI                     0x46
1242 #define LANG_RHAETO_ROMANCE              0x17
1243 #define LANG_ROMANIAN                    0x18
1244 #define LANG_RUSSIAN                     0x19
1245 #define LANG_SAAMI                       0x3b
1246 #define LANG_SANSKRIT                    0x4f
1247 #define LANG_SLOVAK                      0x1b
1248 #define LANG_SLOVENIAN                   0x24
1249 #define LANG_SORBIAN                     0x2e
1250 #define LANG_SPANISH                     0x0a
1251 #define LANG_SUTU                        0x30
1252 #define LANG_SWAHILI                     0x41
1253 #define LANG_SWEDISH                     0x1d
1254 #define LANG_TAMIL                       0x49
1255 #define LANG_TATAR                       0x44
1256 #define LANG_TELUGU                      0x4a
1257 #define LANG_THAI                        0x1e
1258 #define LANG_TSONGA                      0x31
1259 #define LANG_TSWANA                      0x32
1260 #define LANG_TURKISH                     0x1f
1261 #define LANG_UKRAINIAN                   0x22
1262 #define LANG_URDU                        0x20
1263 #define LANG_UZBEK                       0x43
1264 #define LANG_VENDA                       0x33
1265 #define LANG_VIETNAMESE                  0x2a
1266 #define LANG_XHOSA                       0x34
1267 #define LANG_ZULU                        0x35
1268 /* non standard; keep the number high enough (but < 0xff) */
1269 #define LANG_ESPERANTO                   0x8f
1270 #define LANG_WALON                       0x90
1271 #define LANG_CORNISH                     0x91
1272 #define LANG_WELSH                       0x92
1273 #define LANG_BRETON                      0x93
1274
1275 /* Sublanguage definitions */
1276 #define SUBLANG_NEUTRAL                  0x00    /* language neutral */
1277 #define SUBLANG_DEFAULT                  0x01    /* user default */
1278 #define SUBLANG_SYS_DEFAULT              0x02    /* system default */
1279
1280 #define SUBLANG_ARABIC                   0x01
1281 #define SUBLANG_ARABIC_SAUDI_ARABIA      0x01
1282 #define SUBLANG_ARABIC_IRAQ              0x02
1283 #define SUBLANG_ARABIC_EGYPT             0x03
1284 #define SUBLANG_ARABIC_LIBYA             0x04
1285 #define SUBLANG_ARABIC_ALGERIA           0x05
1286 #define SUBLANG_ARABIC_MOROCCO           0x06
1287 #define SUBLANG_ARABIC_TUNISIA           0x07
1288 #define SUBLANG_ARABIC_OMAN              0x08
1289 #define SUBLANG_ARABIC_YEMEN             0x09
1290 #define SUBLANG_ARABIC_SYRIA             0x0a
1291 #define SUBLANG_ARABIC_JORDAN            0x0b
1292 #define SUBLANG_ARABIC_LEBANON           0x0c
1293 #define SUBLANG_ARABIC_KUWAIT            0x0d
1294 #define SUBLANG_ARABIC_UAE               0x0e
1295 #define SUBLANG_ARABIC_BAHRAIN           0x0f
1296 #define SUBLANG_ARABIC_QATAR             0x10
1297 #define SUBLANG_CHINESE_TRADITIONAL      0x01
1298 #define SUBLANG_CHINESE_SIMPLIFIED       0x02
1299 #define SUBLANG_CHINESE_HONGKONG         0x03
1300 #define SUBLANG_CHINESE_SINGAPORE        0x04
1301 #define SUBLANG_CHINESE_MACAU            0x05
1302 #define SUBLANG_DUTCH                    0x01
1303 #define SUBLANG_DUTCH_BELGIAN            0x02
1304 #define SUBLANG_DUTCH_SURINAM            0x03
1305 #define SUBLANG_ENGLISH_US               0x01
1306 #define SUBLANG_ENGLISH_UK               0x02
1307 #define SUBLANG_ENGLISH_AUS              0x03
1308 #define SUBLANG_ENGLISH_CAN              0x04
1309 #define SUBLANG_ENGLISH_NZ               0x05
1310 #define SUBLANG_ENGLISH_EIRE             0x06
1311 #define SUBLANG_ENGLISH_SAFRICA          0x07
1312 #define SUBLANG_ENGLISH_JAMAICA          0x08
1313 #define SUBLANG_ENGLISH_CARRIBEAN        0x09
1314 #define SUBLANG_ENGLISH_BELIZE           0x0a
1315 #define SUBLANG_ENGLISH_TRINIDAD         0x0b
1316 #define SUBLANG_ENGLISH_ZIMBABWE         0x0c
1317 #define SUBLANG_ENGLISH_PHILIPPINES      0x0d
1318 #define SUBLANG_FRENCH                   0x01
1319 #define SUBLANG_FRENCH_BELGIAN           0x02
1320 #define SUBLANG_FRENCH_CANADIAN          0x03
1321 #define SUBLANG_FRENCH_SWISS             0x04
1322 #define SUBLANG_FRENCH_LUXEMBOURG        0x05
1323 #define SUBLANG_FRENCH_MONACO            0x06
1324 #define SUBLANG_GERMAN                   0x01
1325 #define SUBLANG_GERMAN_SWISS             0x02
1326 #define SUBLANG_GERMAN_AUSTRIAN          0x03
1327 #define SUBLANG_GERMAN_LUXEMBOURG        0x04
1328 #define SUBLANG_GERMAN_LIECHTENSTEIN     0x05
1329 #define SUBLANG_ITALIAN                  0x01
1330 #define SUBLANG_ITALIAN_SWISS            0x02
1331 #define SUBLANG_KOREAN                   0x01
1332 #define SUBLANG_KOREAN_JOHAB             0x02
1333 #define SUBLANG_NORWEGIAN_BOKMAL         0x01
1334 #define SUBLANG_NORWEGIAN_NYNORSK        0x02
1335 #define SUBLANG_PORTUGUESE               0x02
1336 #define SUBLANG_PORTUGUESE_BRAZILIAN     0x01
1337 #define SUBLANG_SPANISH                  0x01
1338 #define SUBLANG_SPANISH_MEXICAN          0x02
1339 #define SUBLANG_SPANISH_MODERN           0x03
1340 #define SUBLANG_SPANISH_GUATEMALA        0x04
1341 #define SUBLANG_SPANISH_COSTARICA        0x05
1342 #define SUBLANG_SPANISH_PANAMA           0x06
1343 #define SUBLANG_SPANISH_DOMINICAN        0x07
1344 #define SUBLANG_SPANISH_VENEZUELA        0x08
1345 #define SUBLANG_SPANISH_COLOMBIA         0x09
1346 #define SUBLANG_SPANISH_PERU             0x0a
1347 #define SUBLANG_SPANISH_ARGENTINA        0x0b
1348 #define SUBLANG_SPANISH_ECUADOR          0x0c
1349 #define SUBLANG_SPANISH_CHILE            0x0d
1350 #define SUBLANG_SPANISH_URUGUAY          0x0e
1351 #define SUBLANG_SPANISH_PARAGUAY         0x0f
1352 #define SUBLANG_SPANISH_BOLIVIA          0x10
1353 #define SUBLANG_SPANISH_EL_SALVADOR      0x11
1354 #define SUBLANG_SPANISH_HONDURAS         0x12
1355 #define SUBLANG_SPANISH_NICARAGUA        0x13
1356 #define SUBLANG_SPANISH_PUERTO_RICO      0x14
1357 /* FIXME: I don't know the symbolic names for those */
1358 #define SUBLANG_ROMANIAN                 0x01
1359 #define SUBLANG_ROMANIAN_MOLDAVIA        0x02
1360 #define SUBLANG_RUSSIAN                  0x01
1361 #define SUBLANG_RUSSIAN_MOLDAVIA         0x02
1362 #define SUBLANG_CROATIAN                 0x01
1363 #define SUBLANG_SERBIAN                  0x02
1364 #define SUBLANG_SERBIAN_LATIN            0x03
1365 #define SUBLANG_SWEDISH                  0x01
1366 #define SUBLANG_SWEDISH_FINLAND          0x02
1367 #define SUBLANG_LITHUANIAN               0x01
1368 #define SUBLANG_LITHUANIAN_CLASSIC       0x02
1369 #define SUBLANG_AZERI                    0x01
1370 #define SUBLANG_AZERI_CYRILLIC           0x02
1371 #define SUBLANG_GAELIC                   0x01
1372 #define SUBLANG_GAELIC_SCOTTISH          0x02
1373 #define SUBLANG_GAELIC_MANX              0x03
1374 #define SUBLANG_MALAY                    0x01
1375 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM  0x02
1376 #define SUBLANG_UZBEK                    0x01
1377 #define SUBLANG_UZBEK_CYRILLIC           0x02
1378 #define SUBLANG_URDU_PAKISTAN            0x01
1379
1380
1381
1382 /*
1383  * Sort definitions
1384  */
1385
1386 #define SORT_DEFAULT                     0x0
1387 #define SORT_JAPANESE_XJIS               0x0
1388 #define SORT_JAPANESE_UNICODE            0x1
1389 #define SORT_CHINESE_BIG5                0x0
1390 #define SORT_CHINESE_UNICODE             0x1
1391 #define SORT_KOREAN_KSC                  0x0
1392 #define SORT_KOREAN_UNICODE              0x1
1393
1394
1395
1396 /*
1397  * Definitions for IsTextUnicode()
1398  */
1399
1400 #define IS_TEXT_UNICODE_ASCII16            0x0001
1401 #define IS_TEXT_UNICODE_STATISTICS         0x0002
1402 #define IS_TEXT_UNICODE_CONTROLS           0x0004
1403 #define IS_TEXT_UNICODE_SIGNATURE          0x0008
1404 #define IS_TEXT_UNICODE_UNICODE_MASK       0x000F
1405 #define IS_TEXT_UNICODE_REVERSE_ASCII16    0x0010
1406 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1407 #define IS_TEXT_UNICODE_REVERSE_CONTROLS   0x0040
1408 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE  0x0080
1409 #define IS_TEXT_UNICODE_REVERSE_MASK       0x00F0
1410 #define IS_TEXT_UNICODE_ILLEGAL_CHARS      0x0100
1411 #define IS_TEXT_UNICODE_ODD_LENGTH         0x0200
1412 #define IS_TEXT_UNICODE_DBCS_LEADBYTE      0x0400
1413 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK   0x0F00
1414 #define IS_TEXT_UNICODE_NULL_BYTES         0x1000
1415 #define IS_TEXT_UNICODE_NOT_ASCII_MASK     0xF000
1416
1417
1418
1419 /*
1420  * Exception codes
1421  */
1422
1423 #define STATUS_SUCCESS                   0x00000000
1424 #define STATUS_WAIT_0                    0x00000000
1425 #define STATUS_ABANDONED_WAIT_0          0x00000080
1426 #define STATUS_USER_APC                  0x000000C0
1427 #define STATUS_TIMEOUT                   0x00000102
1428 #define STATUS_PENDING                   0x00000103
1429
1430 #define STATUS_GUARD_PAGE_VIOLATION      0x80000001    
1431 #define STATUS_DATATYPE_MISALIGNMENT     0x80000002
1432 #define STATUS_BREAKPOINT                0x80000003
1433 #define STATUS_SINGLE_STEP               0x80000004
1434 #define STATUS_BUFFER_OVERFLOW           0x80000005
1435 #define STATUS_NO_MORE_FILES             0x80000006
1436 #define STATUS_WAKE_SYSTEM_DEBUGGER      0x80000007
1437
1438 #define STATUS_HANDLES_CLOSED            0x8000000A
1439 #define STATUS_NO_INHERITANCE            0x8000000B
1440 #define STATUS_GUID_SUBSTITUTION_MADE    0x8000000C
1441 #define STATUS_PARTIAL_COPY              0x8000000D
1442 #define STATUS_DEVICE_PAPER_EMPTY        0x8000000E
1443 #define STATUS_DEVICE_POWERED_OFF        0x8000000F
1444 #define STATUS_DEVICE_OFF_LINE           0x80000010
1445 #define STATUS_DEVICE_BUSY               0x80000011
1446 #define STATUS_NO_MORE_EAS               0x80000012
1447 #define STATUS_INVALID_EA_NAME           0x80000013
1448 #define STATUS_EA_LIST_INCONSISTENT      0x80000014
1449 #define STATUS_INVALID_EA_FLAG           0x80000015
1450 #define STATUS_VERIFY_REQUIRED           0x80000016
1451 #define STATUS_EXTRANEOUS_INFORMATION    0x80000017
1452 #define STATUS_RXACT_COMMIT_NECESSARY    0x80000018
1453 #define STATUS_NO_MORE_ENTRIES           0x8000001A
1454 #define STATUS_FILEMARK_DETECTED         0x8000001B
1455 #define STATUS_MEDIA_CHANGED             0x8000001C
1456 #define STATUS_BUS_RESET                 0x8000001D
1457 #define STATUS_END_OF_MEDIA              0x8000001E
1458 #define STATUS_BEGINNING_OF_MEDIA        0x8000001F
1459 #define STATUS_MEDIA_CHECK               0x80000020
1460 #define STATUS_SETMARK_DETECTED          0x80000021
1461 #define STATUS_NO_DATA_DETECTED          0x80000022
1462 #define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
1463 #define STATUS_SERVER_HAS_OPEN_HANDLES   0x80000024
1464 #define STATUS_ALREADY_DISCONNECTED      0x80000025
1465 #define STATUS_LONGJUMP                  0x80000026
1466
1467 #define STATUS_UNSUCCESSFUL              0xC0000001
1468 #define STATUS_NOT_IMPLEMENTED           0xC0000002
1469 #define STATUS_INVALID_INFO_CLASS        0xC0000003
1470 #define STATUS_INFO_LENGTH_MISMATCH      0xC0000004
1471 #define STATUS_ACCESS_VIOLATION          0xC0000005
1472 #define STATUS_IN_PAGE_ERROR             0xC0000006
1473 #define STATUS_PAGEFILE_QUOTA            0xC0000007
1474 #define STATUS_INVALID_HANDLE            0xC0000008
1475 #define STATUS_BAD_INITIAL_STACK         0xC0000009
1476 #define STATUS_BAD_INITIAL_PC            0xC000000A
1477 #define STATUS_INVALID_CID               0xC000000B
1478 #define STATUS_TIMER_NOT_CANCELED        0xC000000C
1479 #define STATUS_INVALID_PARAMETER         0xC000000D
1480 #define STATUS_NO_SUCH_DEVICE            0xC000000E
1481 #define STATUS_NO_SUCH_FILE              0xC000000F
1482 #define STATUS_INVALID_DEVICE_REQUEST    0xC0000010
1483 #define STATUS_END_OF_FILE               0xC0000011
1484 #define STATUS_WRONG_VOLUME              0xC0000012
1485 #define STATUS_NO_MEDIA_IN_DEVICE        0xC0000013
1486 #define STATUS_UNRECOGNIZED_MEDIA        0xC0000014
1487 #define STATUS_NONEXISTENT_SECTOR        0xC0000015
1488 #define STATUS_MORE_PROCESSING_REQUIRED  0xC0000016
1489 #define STATUS_NO_MEMORY                 0xC0000017
1490 #define STATUS_CONFLICTING_ADDRESSES     0xC0000018
1491 #define STATUS_NOT_MAPPED_VIEW           0xC0000019
1492 #define STATUS_UNABLE_TO_FREE_VM         0xC000001A
1493 #define STATUS_UNABLE_TO_DELETE_SECTION  0xC000001B
1494 #define STATUS_INVALID_SYSTEM_SERVICE    0xC000001C
1495 #define STATUS_ILLEGAL_INSTRUCTION       0xC000001D
1496 #define STATUS_INVALID_LOCK_SEQUENCE     0xC000001E
1497 #define STATUS_INVALID_VIEW_SIZE         0xC000001F
1498 #define STATUS_INVALID_FILE_FOR_SECTION  0xC0000020
1499 #define STATUS_ALREADY_COMMITTED         0xC0000021
1500 #define STATUS_ACCESS_DENIED             0xC0000022
1501 #define STATUS_BUFFER_TOO_SMALL          0xC0000023
1502 #define STATUS_OBJECT_TYPE_MISMATCH      0xC0000024
1503 #define STATUS_NONCONTINUABLE_EXCEPTION  0xC0000025
1504 #define STATUS_INVALID_DISPOSITION       0xC0000026
1505 #define STATUS_UNWIND                    0xC0000027
1506 #define STATUS_BAD_STACK                 0xC0000028
1507 #define STATUS_INVALID_UNWIND_TARGET     0xC0000029
1508 #define STATUS_NOT_LOCKED                0xC000002A
1509 #define STATUS_PARITY_ERROR              0xC000002B
1510 #define STATUS_UNABLE_TO_DECOMMIT_VM     0xC000002C
1511 #define STATUS_NOT_COMMITTED             0xC000002D
1512 #define STATUS_INVALID_PORT_ATTRIBUTES   0xC000002E
1513 #define STATUS_PORT_MESSAGE_TOO_LONG     0xC000002F
1514 #define STATUS_INVALID_PARAMETER_MIX     0xC0000030
1515 #define STATUS_INVALID_QUOTA_LOWER       0xC0000031
1516 #define STATUS_DISK_CORRUPT_ERROR        0xC0000032
1517 #define STATUS_OBJECT_NAME_INVALID       0xC0000033
1518 #define STATUS_OBJECT_NAME_NOT_FOUND     0xC0000034
1519 #define STATUS_OBJECT_NAME_COLLISION     0xC0000035
1520 #define STATUS_PORT_DISCONNECTED         0xC0000037
1521 #define STATUS_DEVICE_ALREADY_ATTACHED   0xC0000038
1522 #define STATUS_OBJECT_PATH_INVALID       0xC0000039
1523 #define STATUS_OBJECT_PATH_NOT_FOUND     0xC000003A
1524 #define STATUS_PATH_SYNTAX_BAD           0xC000003B
1525 #define STATUS_DATA_OVERRUN              0xC000003C
1526 #define STATUS_DATA_LATE_ERROR           0xC000003D
1527 #define STATUS_DATA_ERROR                0xC000003E
1528 #define STATUS_CRC_ERROR                 0xC000003F
1529 #define STATUS_SECTION_TOO_BIG           0xC0000040
1530 #define STATUS_PORT_CONNECTION_REFUSED   0xC0000041
1531 #define STATUS_INVALID_PORT_HANDLE       0xC0000042
1532 #define STATUS_SHARING_VIOLATION         0xC0000043
1533 #define STATUS_QUOTA_EXCEEDED            0xC0000044
1534 #define STATUS_INVALID_PAGE_PROTECTION   0xC0000045
1535 #define STATUS_MUTANT_NOT_OWNED          0xC0000046
1536 #define STATUS_SEMAPHORE_LIMIT_EXCEEDED  0xC0000047
1537 #define STATUS_PORT_ALREADY_SET          0xC0000048
1538 #define STATUS_SUSPEND_COUNT_EXCEEDED    0xC000004A
1539 #define STATUS_LOCK_NOT_GRANTED          0xC0000054  /* FIXME: not sure */
1540 #define STATUS_FILE_LOCK_CONFLICT        0xC0000055  /* FIXME: not sure */
1541 #define STATUS_UNKNOWN_REVISION          0xC0000058
1542 #define STATUS_INVALID_SECURITY_DESCR    0xC0000079
1543 #define STATUS_DISK_FULL                 0xC000007F 
1544 #define STATUS_SECTION_NOT_EXTENDED      0xC0000087
1545 #define STATUS_ARRAY_BOUNDS_EXCEEDED     0xC000008C
1546 #define STATUS_FLOAT_DENORMAL_OPERAND    0xC000008D
1547 #define STATUS_FLOAT_DIVIDE_BY_ZERO      0xC000008E
1548 #define STATUS_FLOAT_INEXACT_RESULT      0xC000008F
1549 #define STATUS_FLOAT_INVALID_OPERATION   0xC0000090
1550 #define STATUS_FLOAT_OVERFLOW            0xC0000091
1551 #define STATUS_FLOAT_STACK_CHECK         0xC0000092
1552 #define STATUS_FLOAT_UNDERFLOW           0xC0000093
1553 #define STATUS_INTEGER_DIVIDE_BY_ZERO    0xC0000094
1554 #define STATUS_INTEGER_OVERFLOW          0xC0000095
1555 #define STATUS_PRIVILEGED_INSTRUCTION    0xC0000096
1556 #define STATUS_MEDIA_WRITE_PROTECTED     0XC00000A2
1557 #define STATUS_INVALID_PARAMETER_2       0xC00000F0
1558 #define STATUS_STACK_OVERFLOW            0xC00000FD
1559 #define STATUS_DIRECTORY_NOT_EMPTY       0xC0000101
1560 #define STATUS_TOO_MANY_OPENED_FILES     0xC000011F
1561 #define STATUS_CONTROL_C_EXIT            0xC000013A
1562 #define STATUS_PIPE_BROKEN               0xC000014B
1563 #define STATUS_NOT_REGISTRY_FILE         0xC000015C
1564 #define STATUS_PARTITION_FAILURE         0xC0000172
1565 #define STATUS_INVALID_BLOCK_LENGTH      0xC0000173
1566 #define STATUS_DEVICE_NOT_PARTITIONED    0xC0000174
1567 #define STATUS_UNABLE_TO_LOCK_MEDIA      0xC0000175
1568 #define STATUS_UNABLE_TO_UNLOAD_MEDIA    0xC0000176
1569 #define STATUS_EOM_OVERFLOW              0xC0000177
1570 #define STATUS_NO_MEDIA                  0xC0000178
1571 #define STATUS_NO_SUCH_MEMBER            0xC000017A
1572 #define STATUS_INVALID_MEMBER            0xC000017B
1573 #define STATUS_KEY_DELETED               0xC000017C
1574 #define STATUS_NO_LOG_SPACE              0xC000017D
1575 #define STATUS_TOO_MANY_SIDS             0xC000017E
1576 #define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
1577 #define STATUS_KEY_HAS_CHILDREN          0xC0000180
1578 #define STATUS_CHILD_MUST_BE_VOLATILE    0xC0000181
1579 #define STATUS_DEVICE_CONFIGURATION_ERROR0xC0000182
1580 #define STATUS_DRIVER_INTERNAL_ERROR     0xC0000183
1581 #define STATUS_INVALID_DEVICE_STATE      0xC0000184
1582 #define STATUS_IO_DEVICE_ERROR           0xC0000185
1583 #define STATUS_DEVICE_PROTOCOL_ERROR     0xC0000186
1584 #define STATUS_BACKUP_CONTROLLER         0xC0000187
1585 #define STATUS_LOG_FILE_FULL             0xC0000188
1586 #define STATUS_TOO_LATE                  0xC0000189
1587 #define STATUS_NO_TRUST_LSA_SECRET       0xC000018A
1588 #define STATUS_NO_TRUST_SAM_ACCOUNT      0xC000018B
1589 #define STATUS_TRUSTED_DOMAIN_FAILURE    0xC000018C
1590 #define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
1591 #define STATUS_EVENTLOG_FILE_CORRUPT     0xC000018E
1592 #define STATUS_EVENTLOG_CANT_START       0xC000018F
1593 #define STATUS_TRUST_FAILURE             0xC0000190
1594 #define STATUS_MUTANT_LIMIT_EXCEEDED     0xC0000191
1595 #define STATUS_NETLOGON_NOT_STARTED      0xC0000192
1596 #define STATUS_ACCOUNT_EXPIRED           0xC0000193
1597 #define STATUS_POSSIBLE_DEADLOCK         0xC0000194
1598 #define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
1599 #define STATUS_REMOTE_SESSION_LIMIT      0xC0000196
1600 #define STATUS_EVENTLOG_FILE_CHANGED     0xC0000197
1601 #define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
1602 #define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
1603 #define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
1604 #define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
1605 #define STATUS_FS_DRIVER_REQUIRED        0xC000019C
1606
1607 #define STATUS_RESOURCE_LANG_NOT_FOUND   0xC0000204
1608
1609 #define MAXIMUM_WAIT_OBJECTS 64
1610 #define MAXIMUM_SUSPEND_COUNT 127
1611
1612
1613 /*
1614  * Return values from the actual exception handlers
1615  */
1616
1617 #define ExceptionContinueExecution 0
1618 #define ExceptionContinueSearch    1
1619 #define ExceptionNestedException   2
1620 #define ExceptionCollidedUnwind    3
1621  
1622 /*
1623  * Return values from filters in except() and from UnhandledExceptionFilter
1624  */
1625  
1626 #define EXCEPTION_EXECUTE_HANDLER        1
1627 #define EXCEPTION_CONTINUE_SEARCH        0
1628 #define EXCEPTION_CONTINUE_EXECUTION    -1
1629
1630 /*
1631  * From OS/2 2.0 exception handling
1632  * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1633  */
1634
1635 #define EH_NONCONTINUABLE   0x01
1636 #define EH_UNWINDING        0x02
1637 #define EH_EXIT_UNWIND      0x04
1638 #define EH_STACK_INVALID    0x08
1639 #define EH_NESTED_CALL      0x10
1640
1641 #define EXCEPTION_CONTINUABLE        0
1642 #define EXCEPTION_NONCONTINUABLE     EH_NONCONTINUABLE
1643  
1644 /*
1645  * The exception record used by Win32 to give additional information 
1646  * about exception to exception handlers.
1647  */
1648
1649 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1650
1651 typedef struct __EXCEPTION_RECORD
1652 {
1653     DWORD    ExceptionCode;
1654     DWORD    ExceptionFlags;
1655     struct __EXCEPTION_RECORD *ExceptionRecord;
1656
1657     LPVOID   ExceptionAddress;
1658     DWORD    NumberParameters;
1659     DWORD    ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1660 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1661
1662 /*
1663  * The exception pointers structure passed to exception filters
1664  * in except() and the UnhandledExceptionFilter().
1665  */
1666  
1667 typedef struct _EXCEPTION_POINTERS 
1668 {
1669   PEXCEPTION_RECORD  ExceptionRecord;
1670   PCONTEXT           ContextRecord;
1671 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1672
1673
1674 /*
1675  * The exception frame, used for registering exception handlers 
1676  * Win32 cares only about this, but compilers generally emit 
1677  * larger exception frames for their own use.
1678  */
1679
1680 struct __EXCEPTION_FRAME;
1681
1682 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
1683                                     PCONTEXT,struct __EXCEPTION_FRAME **);
1684
1685 typedef struct __EXCEPTION_FRAME
1686 {
1687   struct __EXCEPTION_FRAME *Prev;
1688   PEXCEPTION_HANDLER       Handler;
1689 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
1690
1691 #include "poppack.h"
1692
1693 /*
1694  * function pointer to a exception filter
1695  */
1696
1697 typedef LONG CALLBACK (*PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1698 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1699
1700 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1701 LPTOP_LEVEL_EXCEPTION_FILTER
1702 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1703
1704 /* status values for ContinueDebugEvent */
1705 #define DBG_CONTINUE                0x00010002
1706 #define DBG_TERMINATE_THREAD        0x40010003
1707 #define DBG_TERMINATE_PROCESS       0x40010004
1708 #define DBG_CONTROL_C               0x40010005
1709 #define DBG_CONTROL_BREAK           0x40010008
1710 #define DBG_EXCEPTION_NOT_HANDLED   0x80010001
1711
1712 typedef struct _NT_TIB 
1713 {
1714         struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1715         PVOID StackBase;
1716         PVOID StackLimit;
1717         PVOID SubSystemTib;
1718         union {
1719           PVOID FiberData;
1720           DWORD Version;
1721         } DUMMYUNIONNAME;
1722         PVOID ArbitraryUserPointer;
1723         struct _NT_TIB *Self;
1724 } NT_TIB, *PNT_TIB;
1725
1726 struct _TEB;
1727
1728 #if defined(__i386__) && defined(__GNUC__)
1729 extern inline struct _TEB WINAPI *NtCurrentTeb(void);
1730 extern inline struct _TEB WINAPI *NtCurrentTeb(void)
1731 {
1732     struct _TEB *teb;
1733     __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1734     return teb;
1735 }
1736 #else
1737 extern struct _TEB WINAPI *NtCurrentTeb(void);
1738 #endif
1739
1740
1741 /*
1742  * File formats definitions
1743  */
1744
1745 typedef struct _IMAGE_DOS_HEADER {
1746     WORD  e_magic;      /* 00: MZ Header signature */
1747     WORD  e_cblp;       /* 02: Bytes on last page of file */
1748     WORD  e_cp;         /* 04: Pages in file */
1749     WORD  e_crlc;       /* 06: Relocations */
1750     WORD  e_cparhdr;    /* 08: Size of header in paragraphs */
1751     WORD  e_minalloc;   /* 0a: Minimum extra paragraphs needed */
1752     WORD  e_maxalloc;   /* 0c: Maximum extra paragraphs needed */
1753     WORD  e_ss;         /* 0e: Initial (relative) SS value */
1754     WORD  e_sp;         /* 10: Initial SP value */
1755     WORD  e_csum;       /* 12: Checksum */
1756     WORD  e_ip;         /* 14: Initial IP value */
1757     WORD  e_cs;         /* 16: Initial (relative) CS value */
1758     WORD  e_lfarlc;     /* 18: File address of relocation table */
1759     WORD  e_ovno;       /* 1a: Overlay number */
1760     WORD  e_res[4];     /* 1c: Reserved words */
1761     WORD  e_oemid;      /* 24: OEM identifier (for e_oeminfo) */
1762     WORD  e_oeminfo;    /* 26: OEM information; e_oemid specific */
1763     WORD  e_res2[10];   /* 28: Reserved words */
1764     DWORD e_lfanew;     /* 3c: Offset to extended header */
1765 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1766
1767 #define IMAGE_DOS_SIGNATURE    0x5A4D     /* MZ   */
1768 #define IMAGE_OS2_SIGNATURE    0x454E     /* NE   */
1769 #define IMAGE_OS2_SIGNATURE_LE 0x454C     /* LE   */
1770 #define IMAGE_OS2_SIGNATURE_LX 0x584C     /* LX */
1771 #define IMAGE_VXD_SIGNATURE    0x454C     /* LE   */
1772 #define IMAGE_NT_SIGNATURE     0x00004550 /* PE00 */
1773
1774 /*
1775  * This is the Windows executable (NE) header.
1776  * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
1777  */
1778 typedef struct 
1779 {
1780     WORD  ne_magic;             /* 00 NE signature 'NE' */
1781     BYTE  ne_ver;               /* 02 Linker version number */
1782     BYTE  ne_rev;               /* 03 Linker revision number */
1783     WORD  ne_enttab;            /* 04 Offset to entry table relative to NE */
1784     WORD  ne_cbenttab;          /* 06 Length of entry table in bytes */
1785     LONG  ne_crc;               /* 08 Checksum */
1786     WORD  ne_flags;             /* 0c Flags about segments in this file */
1787     WORD  ne_autodata;          /* 0e Automatic data segment number */
1788     WORD  ne_heap;              /* 10 Initial size of local heap */
1789     WORD  ne_stack;             /* 12 Initial size of stack */
1790     DWORD ne_csip;              /* 14 Initial CS:IP */
1791     DWORD ne_sssp;              /* 18 Initial SS:SP */
1792     WORD  ne_cseg;              /* 1c # of entries in segment table */
1793     WORD  ne_cmod;              /* 1e # of entries in module reference tab. */
1794     WORD  ne_cbnrestab;         /* 20 Length of nonresident-name table     */
1795     WORD  ne_segtab;            /* 22 Offset to segment table */
1796     WORD  ne_rsrctab;           /* 24 Offset to resource table */
1797     WORD  ne_restab;            /* 26 Offset to resident-name table */
1798     WORD  ne_modtab;            /* 28 Offset to module reference table */
1799     WORD  ne_imptab;            /* 2a Offset to imported name table */
1800     DWORD ne_nrestab;           /* 2c Offset to nonresident-name table */
1801     WORD  ne_cmovent;           /* 30 # of movable entry points */
1802     WORD  ne_align;             /* 32 Logical sector alignment shift count */
1803     WORD  ne_cres;              /* 34 # of resource segments */
1804     BYTE  ne_exetyp;            /* 36 Flags indicating target OS */
1805     BYTE  ne_flagsothers;       /* 37 Additional information flags */
1806     WORD  fastload_offset;      /* 38 Offset to fast load area (should be ne_pretthunks)*/
1807     WORD  fastload_length;      /* 3a Length of fast load area (should be ne_psegrefbytes) */
1808     WORD  ne_swaparea;          /* 3c Reserved by Microsoft */
1809     WORD  ne_expver;            /* 3e Expected Windows version number */
1810 } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
1811
1812 typedef struct _IMAGE_VXD_HEADER {
1813   WORD  e32_magic;
1814   BYTE  e32_border;
1815   BYTE  e32_worder;
1816   DWORD e32_level;
1817   WORD  e32_cpu;
1818   WORD  e32_os;
1819   DWORD e32_ver;
1820   DWORD e32_mflags;
1821   DWORD e32_mpages;
1822   DWORD e32_startobj;
1823   DWORD e32_eip;
1824   DWORD e32_stackobj;
1825   DWORD e32_esp;
1826   DWORD e32_pagesize;
1827   DWORD e32_lastpagesize;
1828   DWORD e32_fixupsize;
1829   DWORD e32_fixupsum;
1830   DWORD e32_ldrsize;
1831   DWORD e32_ldrsum;
1832   DWORD e32_objtab;
1833   DWORD e32_objcnt;
1834   DWORD e32_objmap;
1835   DWORD e32_itermap;
1836   DWORD e32_rsrctab;
1837   DWORD e32_rsrccnt;
1838   DWORD e32_restab;
1839   DWORD e32_enttab;
1840   DWORD e32_dirtab;
1841   DWORD e32_dircnt;
1842   DWORD e32_fpagetab;
1843   DWORD e32_frectab;
1844   DWORD e32_impmod;
1845   DWORD e32_impmodcnt;
1846   DWORD e32_impproc;
1847   DWORD e32_pagesum;
1848   DWORD e32_datapage;
1849   DWORD e32_preload;
1850   DWORD e32_nrestab;
1851   DWORD e32_cbnrestab;
1852   DWORD e32_nressum;
1853   DWORD e32_autodata;
1854   DWORD e32_debuginfo;
1855   DWORD e32_debuglen;
1856   DWORD e32_instpreload;
1857   DWORD e32_instdemand;
1858   DWORD e32_heapsize;
1859   BYTE   e32_res3[12];
1860   DWORD e32_winresoff;
1861   DWORD e32_winreslen;
1862   WORD  e32_devid;
1863   WORD  e32_ddkver;
1864 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1865
1866
1867 /* These defines describe the meanings of the bits in the Characteristics
1868    field */
1869
1870 #define IMAGE_FILE_RELOCS_STRIPPED      0x0001 /* No relocation info */
1871 #define IMAGE_FILE_EXECUTABLE_IMAGE     0x0002
1872 #define IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004
1873 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
1874 #define IMAGE_FILE_16BIT_MACHINE        0x0040
1875 #define IMAGE_FILE_BYTES_REVERSED_LO    0x0080
1876 #define IMAGE_FILE_32BIT_MACHINE        0x0100
1877 #define IMAGE_FILE_DEBUG_STRIPPED       0x0200
1878 #define IMAGE_FILE_SYSTEM               0x1000
1879 #define IMAGE_FILE_DLL                  0x2000
1880 #define IMAGE_FILE_BYTES_REVERSED_HI    0x8000
1881
1882 /* These are the settings of the Machine field. */
1883 #define IMAGE_FILE_MACHINE_UNKNOWN      0
1884 #define IMAGE_FILE_MACHINE_I860         0x14d
1885 #define IMAGE_FILE_MACHINE_I386         0x14c
1886 #define IMAGE_FILE_MACHINE_R3000        0x162
1887 #define IMAGE_FILE_MACHINE_R4000        0x166
1888 #define IMAGE_FILE_MACHINE_R10000       0x168
1889 #define IMAGE_FILE_MACHINE_ALPHA        0x184
1890 #define IMAGE_FILE_MACHINE_POWERPC      0x1F0  
1891
1892 #define IMAGE_SIZEOF_FILE_HEADER        20
1893
1894 /* Possible Magic values */
1895 #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
1896 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC       0x107
1897
1898 /* These are indexes into the DataDirectory array */
1899 #define IMAGE_FILE_EXPORT_DIRECTORY             0
1900 #define IMAGE_FILE_IMPORT_DIRECTORY             1
1901 #define IMAGE_FILE_RESOURCE_DIRECTORY           2
1902 #define IMAGE_FILE_EXCEPTION_DIRECTORY          3
1903 #define IMAGE_FILE_SECURITY_DIRECTORY           4
1904 #define IMAGE_FILE_BASE_RELOCATION_TABLE        5
1905 #define IMAGE_FILE_DEBUG_DIRECTORY              6
1906 #define IMAGE_FILE_DESCRIPTION_STRING           7
1907 #define IMAGE_FILE_MACHINE_VALUE                8  /* Mips */
1908 #define IMAGE_FILE_THREAD_LOCAL_STORAGE         9
1909 #define IMAGE_FILE_CALLBACK_DIRECTORY           10
1910
1911 /* Directory Entries, indices into the DataDirectory array */
1912
1913 #define IMAGE_DIRECTORY_ENTRY_EXPORT            0
1914 #define IMAGE_DIRECTORY_ENTRY_IMPORT            1
1915 #define IMAGE_DIRECTORY_ENTRY_RESOURCE          2
1916 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION         3
1917 #define IMAGE_DIRECTORY_ENTRY_SECURITY          4
1918 #define IMAGE_DIRECTORY_ENTRY_BASERELOC         5
1919 #define IMAGE_DIRECTORY_ENTRY_DEBUG             6
1920 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT         7
1921 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR         8   /* (MIPS GP) */
1922 #define IMAGE_DIRECTORY_ENTRY_TLS               9
1923 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG       10
1924 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT      11
1925 #define IMAGE_DIRECTORY_ENTRY_IAT               12  /* Import Address Table */
1926 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT      13
1927 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR    14
1928
1929 /* Subsystem Values */
1930
1931 #define IMAGE_SUBSYSTEM_UNKNOWN         0
1932 #define IMAGE_SUBSYSTEM_NATIVE          1
1933 #define IMAGE_SUBSYSTEM_WINDOWS_GUI     2       /* Windows GUI subsystem */
1934 #define IMAGE_SUBSYSTEM_WINDOWS_CUI     3       /* Windows character subsystem*/
1935 #define IMAGE_SUBSYSTEM_OS2_CUI         5
1936 #define IMAGE_SUBSYSTEM_POSIX_CUI       7
1937
1938 typedef struct _IMAGE_FILE_HEADER {
1939   WORD  Machine;
1940   WORD  NumberOfSections;
1941   DWORD TimeDateStamp;
1942   DWORD PointerToSymbolTable;
1943   DWORD NumberOfSymbols;
1944   WORD  SizeOfOptionalHeader;
1945   WORD  Characteristics;
1946 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1947
1948 typedef struct _IMAGE_DATA_DIRECTORY {
1949   DWORD VirtualAddress;
1950   DWORD Size;
1951 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1952
1953 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
1954
1955 typedef struct _IMAGE_OPTIONAL_HEADER {
1956
1957   /* Standard fields */
1958
1959   WORD  Magic;
1960   BYTE  MajorLinkerVersion;
1961   BYTE  MinorLinkerVersion;
1962   DWORD SizeOfCode;
1963   DWORD SizeOfInitializedData;
1964   DWORD SizeOfUninitializedData;
1965   DWORD AddressOfEntryPoint;
1966   DWORD BaseOfCode;
1967   DWORD BaseOfData;
1968
1969   /* NT additional fields */
1970
1971   DWORD ImageBase;
1972   DWORD SectionAlignment;
1973   DWORD FileAlignment;
1974   WORD  MajorOperatingSystemVersion;
1975   WORD  MinorOperatingSystemVersion;
1976   WORD  MajorImageVersion;
1977   WORD  MinorImageVersion;
1978   WORD  MajorSubsystemVersion;
1979   WORD  MinorSubsystemVersion;
1980   DWORD Win32VersionValue;
1981   DWORD SizeOfImage;
1982   DWORD SizeOfHeaders;
1983   DWORD CheckSum;
1984   WORD  Subsystem;
1985   WORD  DllCharacteristics;
1986   DWORD SizeOfStackReserve;
1987   DWORD SizeOfStackCommit;
1988   DWORD SizeOfHeapReserve;
1989   DWORD SizeOfHeapCommit;
1990   DWORD LoaderFlags;
1991   DWORD NumberOfRvaAndSizes;
1992   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
1993 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
1994
1995 typedef struct _IMAGE_NT_HEADERS {
1996   DWORD Signature;
1997   IMAGE_FILE_HEADER FileHeader;
1998   IMAGE_OPTIONAL_HEADER OptionalHeader;
1999 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
2000
2001 #define IMAGE_SIZEOF_SHORT_NAME 8
2002
2003 typedef struct _IMAGE_SECTION_HEADER {
2004   BYTE  Name[IMAGE_SIZEOF_SHORT_NAME];
2005   union {
2006     DWORD PhysicalAddress;
2007     DWORD VirtualSize;
2008   } Misc;
2009   DWORD VirtualAddress;
2010   DWORD SizeOfRawData;
2011   DWORD PointerToRawData;
2012   DWORD PointerToRelocations;
2013   DWORD PointerToLinenumbers;
2014   WORD  NumberOfRelocations;
2015   WORD  NumberOfLinenumbers;
2016   DWORD Characteristics;
2017 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2018
2019 #define IMAGE_SIZEOF_SECTION_HEADER 40
2020
2021 #define IMAGE_FIRST_SECTION(ntheader) \
2022   ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2023                            ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2024
2025 /* These defines are for the Characteristics bitfield. */
2026 /* #define IMAGE_SCN_TYPE_REG                   0x00000000 - Reserved */
2027 /* #define IMAGE_SCN_TYPE_DSECT                 0x00000001 - Reserved */
2028 /* #define IMAGE_SCN_TYPE_NOLOAD                0x00000002 - Reserved */
2029 /* #define IMAGE_SCN_TYPE_GROUP                 0x00000004 - Reserved */
2030 /* #define IMAGE_SCN_TYPE_NO_PAD                0x00000008 - Reserved */
2031 /* #define IMAGE_SCN_TYPE_COPY                  0x00000010 - Reserved */
2032
2033 #define IMAGE_SCN_CNT_CODE                      0x00000020
2034 #define IMAGE_SCN_CNT_INITIALIZED_DATA          0x00000040
2035 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA        0x00000080
2036
2037 #define IMAGE_SCN_LNK_OTHER                     0x00000100 
2038 #define IMAGE_SCN_LNK_INFO                      0x00000200  
2039 /* #define      IMAGE_SCN_TYPE_OVER             0x00000400 - Reserved */
2040 #define IMAGE_SCN_LNK_REMOVE                    0x00000800
2041 #define IMAGE_SCN_LNK_COMDAT                    0x00001000
2042
2043 /*                                              0x00002000 - Reserved */
2044 /* #define IMAGE_SCN_MEM_PROTECTED              0x00004000 - Obsolete */
2045 #define IMAGE_SCN_MEM_FARDATA                   0x00008000
2046
2047 /* #define IMAGE_SCN_MEM_SYSHEAP                0x00010000 - Obsolete */
2048 #define IMAGE_SCN_MEM_PURGEABLE                 0x00020000
2049 #define IMAGE_SCN_MEM_16BIT                     0x00020000
2050 #define IMAGE_SCN_MEM_LOCKED                    0x00040000
2051 #define IMAGE_SCN_MEM_PRELOAD                   0x00080000
2052
2053 #define IMAGE_SCN_ALIGN_1BYTES                  0x00100000
2054 #define IMAGE_SCN_ALIGN_2BYTES                  0x00200000
2055 #define IMAGE_SCN_ALIGN_4BYTES                  0x00300000
2056 #define IMAGE_SCN_ALIGN_8BYTES                  0x00400000
2057 #define IMAGE_SCN_ALIGN_16BYTES                 0x00500000  /* Default */
2058 #define IMAGE_SCN_ALIGN_32BYTES                 0x00600000
2059 #define IMAGE_SCN_ALIGN_64BYTES                 0x00700000
2060 /*                                              0x00800000 - Unused */
2061
2062 #define IMAGE_SCN_LNK_NRELOC_OVFL               0x01000000
2063
2064
2065 #define IMAGE_SCN_MEM_DISCARDABLE               0x02000000
2066 #define IMAGE_SCN_MEM_NOT_CACHED                0x04000000
2067 #define IMAGE_SCN_MEM_NOT_PAGED                 0x08000000
2068 #define IMAGE_SCN_MEM_SHARED                    0x10000000
2069 #define IMAGE_SCN_MEM_EXECUTE                   0x20000000
2070 #define IMAGE_SCN_MEM_READ                      0x40000000
2071 #define IMAGE_SCN_MEM_WRITE                     0x80000000
2072
2073 #include "pshpack2.h"
2074
2075 typedef struct _IMAGE_SYMBOL {
2076     union {
2077         BYTE    ShortName[8];
2078         struct {
2079             DWORD   Short;
2080             DWORD   Long;
2081         } Name;
2082         DWORD   LongName[2];
2083     } N;
2084     DWORD   Value;
2085     SHORT   SectionNumber;
2086     WORD    Type;
2087     BYTE    StorageClass;
2088     BYTE    NumberOfAuxSymbols;
2089 } IMAGE_SYMBOL;
2090 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2091
2092 #define IMAGE_SIZEOF_SYMBOL 18
2093
2094 typedef struct _IMAGE_LINENUMBER {
2095     union {
2096         DWORD   SymbolTableIndex;
2097         DWORD   VirtualAddress;
2098     } Type;
2099     WORD    Linenumber;
2100 } IMAGE_LINENUMBER;
2101 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2102
2103 #define IMAGE_SIZEOF_LINENUMBER  6
2104
2105 typedef union _IMAGE_AUX_SYMBOL {
2106     struct {
2107         DWORD    TagIndex;
2108         union {
2109             struct {
2110                 WORD    Linenumber;
2111                 WORD    Size;
2112             } LnSz;
2113            DWORD    TotalSize;
2114         } Misc;
2115         union {
2116             struct {
2117                 DWORD    PointerToLinenumber;
2118                 DWORD    PointerToNextFunction;
2119             } Function;
2120             struct {
2121                 WORD     Dimension[4];
2122             } Array;
2123         } FcnAry;
2124         WORD    TvIndex;
2125     } Sym;
2126     struct {
2127         BYTE    Name[IMAGE_SIZEOF_SYMBOL];
2128     } File;
2129     struct {
2130         DWORD   Length;
2131         WORD    NumberOfRelocations;
2132         WORD    NumberOfLinenumbers;
2133         DWORD   CheckSum;
2134         SHORT   Number;
2135         BYTE    Selection;
2136     } Section;
2137 } IMAGE_AUX_SYMBOL;
2138 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2139
2140 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2141
2142 #include "poppack.h"
2143
2144 #define IMAGE_SYM_UNDEFINED           (SHORT)0
2145 #define IMAGE_SYM_ABSOLUTE            (SHORT)-1
2146 #define IMAGE_SYM_DEBUG               (SHORT)-2
2147
2148 #define IMAGE_SYM_TYPE_NULL                 0x0000
2149 #define IMAGE_SYM_TYPE_VOID                 0x0001
2150 #define IMAGE_SYM_TYPE_CHAR                 0x0002
2151 #define IMAGE_SYM_TYPE_SHORT                0x0003
2152 #define IMAGE_SYM_TYPE_INT                  0x0004
2153 #define IMAGE_SYM_TYPE_LONG                 0x0005
2154 #define IMAGE_SYM_TYPE_FLOAT                0x0006
2155 #define IMAGE_SYM_TYPE_DOUBLE               0x0007
2156 #define IMAGE_SYM_TYPE_STRUCT               0x0008
2157 #define IMAGE_SYM_TYPE_UNION                0x0009
2158 #define IMAGE_SYM_TYPE_ENUM                 0x000A
2159 #define IMAGE_SYM_TYPE_MOE                  0x000B
2160 #define IMAGE_SYM_TYPE_BYTE                 0x000C
2161 #define IMAGE_SYM_TYPE_WORD                 0x000D
2162 #define IMAGE_SYM_TYPE_UINT                 0x000E
2163 #define IMAGE_SYM_TYPE_DWORD                0x000F
2164 #define IMAGE_SYM_TYPE_PCODE                0x8000
2165
2166 #define IMAGE_SYM_DTYPE_NULL                0
2167 #define IMAGE_SYM_DTYPE_POINTER             1
2168 #define IMAGE_SYM_DTYPE_FUNCTION            2
2169 #define IMAGE_SYM_DTYPE_ARRAY               3
2170
2171 #define IMAGE_SYM_CLASS_END_OF_FUNCTION     (BYTE )-1
2172 #define IMAGE_SYM_CLASS_NULL                0x0000
2173 #define IMAGE_SYM_CLASS_AUTOMATIC           0x0001
2174 #define IMAGE_SYM_CLASS_EXTERNAL            0x0002
2175 #define IMAGE_SYM_CLASS_STATIC              0x0003
2176 #define IMAGE_SYM_CLASS_REGISTER            0x0004
2177 #define IMAGE_SYM_CLASS_EXTERNAL_DEF        0x0005
2178 #define IMAGE_SYM_CLASS_LABEL               0x0006
2179 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL     0x0007
2180 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT    0x0008
2181 #define IMAGE_SYM_CLASS_ARGUMENT            0x0009
2182 #define IMAGE_SYM_CLASS_STRUCT_TAG          0x000A
2183 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION     0x000B
2184 #define IMAGE_SYM_CLASS_UNION_TAG           0x000C
2185 #define IMAGE_SYM_CLASS_TYPE_DEFINITION     0x000D
2186 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC    0x000E
2187 #define IMAGE_SYM_CLASS_ENUM_TAG            0x000F
2188 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM      0x0010
2189 #define IMAGE_SYM_CLASS_REGISTER_PARAM      0x0011
2190 #define IMAGE_SYM_CLASS_BIT_FIELD           0x0012
2191
2192 #define IMAGE_SYM_CLASS_FAR_EXTERNAL        0x0044
2193 #define IMAGE_SYM_CLASS_BLOCK               0x0064
2194 #define IMAGE_SYM_CLASS_FUNCTION            0x0065
2195 #define IMAGE_SYM_CLASS_END_OF_STRUCT       0x0066
2196 #define IMAGE_SYM_CLASS_FILE                0x0067
2197 #define IMAGE_SYM_CLASS_SECTION             0x0068
2198 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL       0x0069
2199
2200 #define N_BTMASK                            0x000F
2201 #define N_TMASK                             0x0030
2202 #define N_TMASK1                            0x00C0
2203 #define N_TMASK2                            0x00F0
2204 #define N_BTSHFT                            4
2205 #define N_TSHIFT                            2
2206
2207 #define BTYPE(x) ((x) & N_BTMASK)
2208
2209 #ifndef ISPTR
2210 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2211 #endif
2212
2213 #ifndef ISFCN
2214 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2215 #endif
2216
2217 #ifndef ISARY
2218 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2219 #endif
2220
2221 #ifndef ISTAG
2222 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2223 #endif
2224
2225 #ifndef INCREF
2226 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2227 #endif
2228 #ifndef DECREF
2229 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2230 #endif
2231
2232 #define IMAGE_COMDAT_SELECT_NODUPLICATES    1
2233 #define IMAGE_COMDAT_SELECT_ANY             2
2234 #define IMAGE_COMDAT_SELECT_SAME_SIZE       3
2235 #define IMAGE_COMDAT_SELECT_EXACT_MATCH     4
2236 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE     5
2237 #define IMAGE_COMDAT_SELECT_LARGEST         6
2238 #define IMAGE_COMDAT_SELECT_NEWEST          7
2239
2240 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1
2241 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2
2242 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3
2243
2244 /* Export module directory */
2245
2246 typedef struct _IMAGE_EXPORT_DIRECTORY {
2247         DWORD   Characteristics;
2248         DWORD   TimeDateStamp;
2249         WORD    MajorVersion;
2250         WORD    MinorVersion;
2251         DWORD   Name;
2252         DWORD   Base;
2253         DWORD   NumberOfFunctions;
2254         DWORD   NumberOfNames;
2255         DWORD   AddressOfFunctions;
2256         DWORD   AddressOfNames;
2257         DWORD   AddressOfNameOrdinals;
2258 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2259
2260 /* Import name entry */
2261 typedef struct _IMAGE_IMPORT_BY_NAME {
2262         WORD    Hint;
2263         BYTE    Name[1];
2264 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2265
2266 /* Import thunk */
2267 typedef struct _IMAGE_THUNK_DATA {
2268         union {
2269                 LPBYTE    ForwarderString;
2270                 PDWORD    Function;
2271                 DWORD     Ordinal;
2272                 PIMAGE_IMPORT_BY_NAME   AddressOfData;
2273         } u1;
2274 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2275
2276 /* Import module directory */
2277
2278 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2279         union {
2280                 DWORD   Characteristics; /* 0 for terminating null import descriptor  */
2281                 PIMAGE_THUNK_DATA OriginalFirstThunk;   /* RVA to original unbound IAT */
2282         } u;
2283         DWORD   TimeDateStamp;  /* 0 if not bound,
2284                                  * -1 if bound, and real date\time stamp
2285                                  *    in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2286                                  * (new BIND)
2287                                  * otherwise date/time stamp of DLL bound to
2288                                  * (Old BIND)
2289                                  */
2290         DWORD   ForwarderChain; /* -1 if no forwarders */
2291         DWORD   Name;
2292         /* RVA to IAT (if bound this IAT has actual addresses) */
2293         PIMAGE_THUNK_DATA FirstThunk;   
2294 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2295
2296 #define IMAGE_ORDINAL_FLAG              0x80000000
2297 #define IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2298 #define IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)
2299
2300 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2301 {
2302     DWORD   TimeDateStamp;
2303     WORD    OffsetModuleName;
2304     WORD    NumberOfModuleForwarderRefs;
2305 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2306 } IMAGE_BOUND_IMPORT_DESCRIPTOR,  *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2307
2308 typedef struct _IMAGE_BOUND_FORWARDER_REF
2309 {
2310     DWORD   TimeDateStamp;
2311     WORD    OffsetModuleName;
2312     WORD    Reserved;
2313 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2314
2315 typedef struct _IMAGE_BASE_RELOCATION
2316 {
2317         DWORD   VirtualAddress;
2318         DWORD   SizeOfBlock;
2319         WORD    TypeOffset[1];
2320 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2321
2322 typedef struct _IMAGE_RELOCATION
2323 {
2324     union {
2325         DWORD   VirtualAddress;
2326         DWORD   RelocCount;
2327     } u;
2328     DWORD   SymbolTableIndex;
2329     WORD    Type;
2330 } IMAGE_RELOCATION;
2331 typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
2332
2333 #define IMAGE_SIZEOF_RELOCATION 10
2334
2335 /* generic relocation types */
2336 #define IMAGE_REL_BASED_ABSOLUTE                0
2337 #define IMAGE_REL_BASED_HIGH                    1
2338 #define IMAGE_REL_BASED_LOW                     2
2339 #define IMAGE_REL_BASED_HIGHLOW                 3
2340 #define IMAGE_REL_BASED_HIGHADJ                 4
2341 #define IMAGE_REL_BASED_MIPS_JMPADDR            5
2342 #define IMAGE_REL_BASED_SECTION                 6
2343 #define IMAGE_REL_BASED_REL                     7
2344 #define IMAGE_REL_BASED_MIPS_JMPADDR16          9
2345 #define IMAGE_REL_BASED_IA64_IMM64              9 /* yes, 9 too */
2346 #define IMAGE_REL_BASED_DIR64                   10
2347 #define IMAGE_REL_BASED_HIGH3ADJ                11
2348
2349 /* I386 relocation types */
2350 #define IMAGE_REL_I386_ABSOLUTE                 0
2351 #define IMAGE_REL_I386_DIR16                    1
2352 #define IMAGE_REL_I386_REL16                    2
2353 #define IMAGE_REL_I386_DIR32                    6
2354 #define IMAGE_REL_I386_DIR32NB                  7
2355 #define IMAGE_REL_I386_SEG12                    9
2356 #define IMAGE_REL_I386_SECTION                  10
2357 #define IMAGE_REL_I386_SECREL                   11
2358 #define IMAGE_REL_I386_REL32                    20
2359
2360 /* MIPS relocation types */
2361 #define IMAGE_REL_MIPS_ABSOLUTE         0x0000
2362 #define IMAGE_REL_MIPS_REFHALF          0x0001
2363 #define IMAGE_REL_MIPS_REFWORD          0x0002
2364 #define IMAGE_REL_MIPS_JMPADDR          0x0003
2365 #define IMAGE_REL_MIPS_REFHI            0x0004
2366 #define IMAGE_REL_MIPS_REFLO            0x0005
2367 #define IMAGE_REL_MIPS_GPREL            0x0006
2368 #define IMAGE_REL_MIPS_LITERAL          0x0007
2369 #define IMAGE_REL_MIPS_SECTION          0x000A
2370 #define IMAGE_REL_MIPS_SECREL           0x000B
2371 #define IMAGE_REL_MIPS_SECRELLO         0x000C
2372 #define IMAGE_REL_MIPS_SECRELHI         0x000D
2373 #define IMAGE_REL_MIPS_JMPADDR16        0x0010
2374 #define IMAGE_REL_MIPS_REFWORDNB        0x0022
2375 #define IMAGE_REL_MIPS_PAIR             0x0025
2376
2377 /* ALPHA relocation types */
2378 #define IMAGE_REL_ALPHA_ABSOLUTE        0x0000
2379 #define IMAGE_REL_ALPHA_REFLONG         0x0001
2380 #define IMAGE_REL_ALPHA_REFQUAD         0x0002
2381 #define IMAGE_REL_ALPHA_GPREL           0x0003
2382 #define IMAGE_REL_ALPHA_LITERAL         0x0004
2383 #define IMAGE_REL_ALPHA_LITUSE          0x0005
2384 #define IMAGE_REL_ALPHA_GPDISP          0x0006
2385 #define IMAGE_REL_ALPHA_BRADDR          0x0007
2386 #define IMAGE_REL_ALPHA_HINT            0x0008
2387 #define IMAGE_REL_ALPHA_INLINE_REFLONG  0x0009
2388 #define IMAGE_REL_ALPHA_REFHI           0x000A
2389 #define IMAGE_REL_ALPHA_REFLO           0x000B
2390 #define IMAGE_REL_ALPHA_PAIR            0x000C
2391 #define IMAGE_REL_ALPHA_MATCH           0x000D
2392 #define IMAGE_REL_ALPHA_SECTION         0x000E
2393 #define IMAGE_REL_ALPHA_SECREL          0x000F
2394 #define IMAGE_REL_ALPHA_REFLONGNB       0x0010
2395 #define IMAGE_REL_ALPHA_SECRELLO        0x0011
2396 #define IMAGE_REL_ALPHA_SECRELHI        0x0012
2397 #define IMAGE_REL_ALPHA_REFQ3           0x0013
2398 #define IMAGE_REL_ALPHA_REFQ2           0x0014
2399 #define IMAGE_REL_ALPHA_REFQ1           0x0015
2400 #define IMAGE_REL_ALPHA_GPRELLO         0x0016
2401 #define IMAGE_REL_ALPHA_GPRELHI         0x0017
2402
2403 /* PowerPC relocation types */
2404 #define IMAGE_REL_PPC_ABSOLUTE          0x0000
2405 #define IMAGE_REL_PPC_ADDR64            0x0001
2406 #define IMAGE_REL_PPC_ADDR            0x0002
2407 #define IMAGE_REL_PPC_ADDR24            0x0003
2408 #define IMAGE_REL_PPC_ADDR16            0x0004
2409 #define IMAGE_REL_PPC_ADDR14            0x0005
2410 #define IMAGE_REL_PPC_REL24             0x0006
2411 #define IMAGE_REL_PPC_REL14             0x0007
2412 #define IMAGE_REL_PPC_TOCREL16          0x0008
2413 #define IMAGE_REL_PPC_TOCREL14          0x0009
2414 #define IMAGE_REL_PPC_ADDR32NB          0x000A
2415 #define IMAGE_REL_PPC_SECREL            0x000B
2416 #define IMAGE_REL_PPC_SECTION           0x000C
2417 #define IMAGE_REL_PPC_IFGLUE            0x000D
2418 #define IMAGE_REL_PPC_IMGLUE            0x000E
2419 #define IMAGE_REL_PPC_SECREL16          0x000F
2420 #define IMAGE_REL_PPC_REFHI             0x0010
2421 #define IMAGE_REL_PPC_REFLO             0x0011
2422 #define IMAGE_REL_PPC_PAIR              0x0012
2423 #define IMAGE_REL_PPC_SECRELLO          0x0013
2424 #define IMAGE_REL_PPC_SECRELHI          0x0014
2425 #define IMAGE_REL_PPC_GPREL             0x0015
2426 #define IMAGE_REL_PPC_TYPEMASK          0x00FF
2427 /* modifier bits */
2428 #define IMAGE_REL_PPC_NEG               0x0100
2429 #define IMAGE_REL_PPC_BRTAKEN           0x0200
2430 #define IMAGE_REL_PPC_BRNTAKEN          0x0400
2431 #define IMAGE_REL_PPC_TOCDEFN           0x0800
2432
2433 /* SH3 ? relocation type */
2434 #define IMAGE_REL_SH3_ABSOLUTE          0x0000
2435 #define IMAGE_REL_SH3_DIRECT16          0x0001
2436 #define IMAGE_REL_SH3_DIRECT          0x0002
2437 #define IMAGE_REL_SH3_DIRECT8           0x0003
2438 #define IMAGE_REL_SH3_DIRECT8_WORD      0x0004
2439 #define IMAGE_REL_SH3_DIRECT8_LONG      0x0005
2440 #define IMAGE_REL_SH3_DIRECT4           0x0006
2441 #define IMAGE_REL_SH3_DIRECT4_WORD      0x0007
2442 #define IMAGE_REL_SH3_DIRECT4_LONG      0x0008
2443 #define IMAGE_REL_SH3_PCREL8_WORD       0x0009
2444 #define IMAGE_REL_SH3_PCREL8_LONG       0x000A
2445 #define IMAGE_REL_SH3_PCREL12_WORD      0x000B
2446 #define IMAGE_REL_SH3_STARTOF_SECTION   0x000C
2447 #define IMAGE_REL_SH3_SIZEOF_SECTION    0x000D
2448 #define IMAGE_REL_SH3_SECTION           0x000E
2449 #define IMAGE_REL_SH3_SECREL            0x000F
2450 #define IMAGE_REL_SH3_DIRECT32_NB       0x0010
2451
2452 /* ARM (Archimedes?) relocation types */
2453 #define IMAGE_REL_ARM_ABSOLUTE          0x0000
2454 #define IMAGE_REL_ARM_ADDR              0x0001
2455 #define IMAGE_REL_ARM_ADDR32NB          0x0002
2456 #define IMAGE_REL_ARM_BRANCH24          0x0003
2457 #define IMAGE_REL_ARM_BRANCH11          0x0004
2458 #define IMAGE_REL_ARM_SECTION           0x000E
2459 #define IMAGE_REL_ARM_SECREL            0x000F
2460
2461 /* IA64 relocation types */
2462 #define IMAGE_REL_IA64_ABSOLUTE         0x0000
2463 #define IMAGE_REL_IA64_IMM14            0x0001
2464 #define IMAGE_REL_IA64_IMM22            0x0002
2465 #define IMAGE_REL_IA64_IMM64            0x0003
2466 #define IMAGE_REL_IA64_DIR              0x0004
2467 #define IMAGE_REL_IA64_DIR64            0x0005
2468 #define IMAGE_REL_IA64_PCREL21B         0x0006
2469 #define IMAGE_REL_IA64_PCREL21M         0x0007
2470 #define IMAGE_REL_IA64_PCREL21F         0x0008
2471 #define IMAGE_REL_IA64_GPREL22          0x0009
2472 #define IMAGE_REL_IA64_LTOFF22          0x000A
2473 #define IMAGE_REL_IA64_SECTION          0x000B
2474 #define IMAGE_REL_IA64_SECREL22         0x000C
2475 #define IMAGE_REL_IA64_SECREL64I        0x000D
2476 #define IMAGE_REL_IA64_SECREL           0x000E
2477 #define IMAGE_REL_IA64_LTOFF64          0x000F
2478 #define IMAGE_REL_IA64_DIR32NB          0x0010
2479 #define IMAGE_REL_IA64_RESERVED_11      0x0011
2480 #define IMAGE_REL_IA64_RESERVED_12      0x0012
2481 #define IMAGE_REL_IA64_RESERVED_13      0x0013
2482 #define IMAGE_REL_IA64_RESERVED_14      0x0014
2483 #define IMAGE_REL_IA64_RESERVED_15      0x0015
2484 #define IMAGE_REL_IA64_RESERVED_16      0x0016
2485 #define IMAGE_REL_IA64_ADDEND           0x001F
2486
2487 /* archive format */
2488
2489 #define IMAGE_ARCHIVE_START_SIZE             8
2490 #define IMAGE_ARCHIVE_START                  "!<arch>\n"
2491 #define IMAGE_ARCHIVE_END                    "`\n"
2492 #define IMAGE_ARCHIVE_PAD                    "\n"
2493 #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
2494 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
2495
2496 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2497 {
2498     BYTE     Name[16];
2499     BYTE     Date[12];
2500     BYTE     UserID[6];
2501     BYTE     GroupID[6];
2502     BYTE     Mode[8];
2503     BYTE     Size[10];
2504     BYTE     EndHeader[2];
2505 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2506
2507 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2508
2509 /*
2510  * Resource directory stuff
2511  */
2512 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2513         DWORD   Characteristics;
2514         DWORD   TimeDateStamp;
2515         WORD    MajorVersion;
2516         WORD    MinorVersion;
2517         WORD    NumberOfNamedEntries;
2518         WORD    NumberOfIdEntries;
2519         /*  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2520 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2521
2522 #define IMAGE_RESOURCE_NAME_IS_STRING           0x80000000
2523 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY        0x80000000
2524
2525 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2526         union {
2527                 struct {
2528 #ifdef BITFIELDS_BIGENDIAN
2529                         unsigned NameIsString:1;
2530                         unsigned NameOffset:31;
2531 #else
2532                         unsigned NameOffset:31;
2533                         unsigned NameIsString:1;
2534 #endif
2535                 } DUMMYSTRUCTNAME1;
2536                 DWORD   Name;
2537                 struct {
2538 #ifdef WORDS_BIGENDIAN
2539                         WORD    __pad;
2540                         WORD    Id;
2541 #else
2542                         WORD    Id;
2543                         WORD    __pad;
2544 #endif
2545                 } DUMMYSTRUCTNAME2;
2546         } DUMMYUNIONNAME1;
2547         union {
2548                 DWORD   OffsetToData;
2549                 struct {
2550 #ifdef BITFIELDS_BIGENDIAN
2551                         unsigned DataIsDirectory:1;
2552                         unsigned OffsetToDirectory:31;
2553 #else
2554                         unsigned OffsetToDirectory:31;
2555                         unsigned DataIsDirectory:1;
2556 #endif
2557                 } DUMMYSTRUCTNAME3;
2558         } DUMMYUNIONNAME2;
2559 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2560
2561
2562 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2563         WORD    Length;
2564         CHAR    NameString[ 1 ];
2565 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2566
2567 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2568         WORD    Length;
2569         WCHAR   NameString[ 1 ];
2570 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2571
2572 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2573         DWORD   OffsetToData;
2574         DWORD   Size;
2575         DWORD   CodePage;
2576         DWORD   ResourceHandle;
2577 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2578
2579
2580 typedef VOID CALLBACK (*PIMAGE_TLS_CALLBACK)(
2581         LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2582 );
2583
2584 typedef struct _IMAGE_TLS_DIRECTORY {
2585         DWORD   StartAddressOfRawData;
2586         DWORD   EndAddressOfRawData;
2587         LPDWORD AddressOfIndex;
2588         PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
2589         DWORD   SizeOfZeroFill;
2590         DWORD   Characteristics;
2591 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
2592
2593 typedef struct _IMAGE_DEBUG_DIRECTORY {
2594   DWORD Characteristics;
2595   DWORD TimeDateStamp;
2596   WORD  MajorVersion;
2597   WORD  MinorVersion;
2598   DWORD Type;
2599   DWORD SizeOfData;
2600   DWORD AddressOfRawData;
2601   DWORD PointerToRawData;
2602 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2603
2604 #define IMAGE_DEBUG_TYPE_UNKNOWN        0
2605 #define IMAGE_DEBUG_TYPE_COFF           1
2606 #define IMAGE_DEBUG_TYPE_CODEVIEW       2
2607 #define IMAGE_DEBUG_TYPE_FPO            3
2608 #define IMAGE_DEBUG_TYPE_MISC           4
2609 #define IMAGE_DEBUG_TYPE_EXCEPTION      5
2610 #define IMAGE_DEBUG_TYPE_FIXUP          6
2611 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC    7
2612 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC  8
2613 #define IMAGE_DEBUG_TYPE_BORLAND        9
2614 #define IMAGE_DEBUG_TYPE_RESERVED10    10
2615
2616 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2617   DWORD NumberOfSymbols;
2618   DWORD LvaToFirstSymbol;
2619   DWORD NumberOfLinenumbers;
2620   DWORD LvaToFirstLinenumber;
2621   DWORD RvaToFirstByteOfCode;
2622   DWORD RvaToLastByteOfCode;
2623   DWORD RvaToFirstByteOfData;
2624   DWORD RvaToLastByteOfData;
2625 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2626
2627 #define FRAME_FPO       0
2628 #define FRAME_TRAP      1
2629 #define FRAME_TSS       2
2630 #define FRAME_NONFPO    3
2631
2632 typedef struct _FPO_DATA {
2633   DWORD ulOffStart;
2634   DWORD cbProcSize;
2635   DWORD cdwLocals;
2636   WORD  cdwParams;
2637   unsigned cbProlog : 8;
2638   unsigned cbRegs   : 3;
2639   unsigned fHasSEH  : 1;
2640   unsigned fUseBP   : 1;
2641   unsigned reserved : 1;
2642   unsigned cbFrame  : 2;
2643 } FPO_DATA, *PFPO_DATA;
2644
2645 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2646   DWORD Characteristics;
2647   DWORD TimeDateStamp;
2648   WORD  MajorVersion;
2649   WORD  MinorVersion;
2650   DWORD GlobalFlagsClear;
2651   DWORD GlobalFlagsSet;
2652   DWORD CriticalSectionDefaultTimeout;
2653   DWORD DeCommitFreeBlockThreshold;
2654   DWORD DeCommitTotalFreeThreshold;
2655   PVOID LockPrefixTable;
2656   DWORD MaximumAllocationSize;
2657   DWORD VirtualMemoryThreshold;
2658   DWORD ProcessHeapFlags;
2659   DWORD ProcessAffinityMask;
2660   WORD  CSDVersion;
2661   WORD  Reserved1;
2662   PVOID EditList;
2663   DWORD Reserved[1];
2664 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2665
2666 typedef struct _IMAGE_FUNCTION_ENTRY {
2667   DWORD StartingAddress;
2668   DWORD EndingAddress;
2669   DWORD EndOfPrologue;
2670 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2671
2672 #define IMAGE_DEBUG_MISC_EXENAME    1
2673  
2674 typedef struct _IMAGE_DEBUG_MISC {
2675     DWORD       DataType;
2676     DWORD       Length;
2677     BYTE        Unicode;
2678     BYTE        Reserved[ 3 ];
2679     BYTE        Data[ 1 ];
2680 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2681
2682 /* This is the structure that appears at the very start of a .DBG file. */
2683
2684 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2685         WORD    Signature;
2686         WORD    Flags;
2687         WORD    Machine;
2688         WORD    Characteristics;
2689         DWORD   TimeDateStamp;
2690         DWORD   CheckSum;
2691         DWORD   ImageBase;
2692         DWORD   SizeOfImage;
2693         DWORD   NumberOfSections;
2694         DWORD   ExportedNamesSize;
2695         DWORD   DebugDirectorySize;
2696         DWORD   SectionAlignment;
2697         DWORD   Reserved[ 2 ];
2698 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2699
2700 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2701
2702
2703 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2704         WORD    Length;
2705         WORD    Flags;
2706         BYTE    Text[1];
2707 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2708 #define MESSAGE_RESOURCE_UNICODE        0x0001
2709
2710 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2711         DWORD   LowId;
2712         DWORD   HighId;
2713         DWORD   OffsetToEntries;
2714 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2715
2716 typedef struct tagMESSAGE_RESOURCE_DATA {
2717         DWORD                   NumberOfBlocks;
2718         MESSAGE_RESOURCE_BLOCK  Blocks[ 1 ];
2719 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2720
2721 /*
2722  * Here follows typedefs for security and tokens.
2723  */ 
2724
2725 /*
2726  * First a constant for the following typdefs.
2727  */
2728
2729 #define ANYSIZE_ARRAY   1
2730
2731 /* FIXME:  Orphan.  What does it point to? */
2732 typedef PVOID PACCESS_TOKEN;
2733
2734 /*
2735  * TOKEN_INFORMATION_CLASS
2736  */
2737
2738 typedef enum _TOKEN_INFORMATION_CLASS {
2739   TokenUser = 1, 
2740   TokenGroups, 
2741   TokenPrivileges, 
2742   TokenOwner, 
2743   TokenPrimaryGroup, 
2744   TokenDefaultDacl, 
2745   TokenSource, 
2746   TokenType, 
2747   TokenImpersonationLevel, 
2748   TokenStatistics 
2749 } TOKEN_INFORMATION_CLASS; 
2750
2751 #ifndef _SECURITY_DEFINED
2752 #define _SECURITY_DEFINED
2753
2754 #include "pshpack1.h"
2755
2756 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2757
2758 typedef struct _GENERIC_MAPPING {
2759     ACCESS_MASK GenericRead;
2760     ACCESS_MASK GenericWrite;
2761     ACCESS_MASK GenericExecute;
2762     ACCESS_MASK GenericAll;
2763 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2764
2765 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2766 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2767 typedef struct {
2768     BYTE Value[6];
2769 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
2770 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2771
2772 #ifndef SID_DEFINED
2773 #define SID_DEFINED
2774 typedef struct _SID {
2775     BYTE Revision;
2776     BYTE SubAuthorityCount;
2777     SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2778     DWORD SubAuthority[1];
2779 } SID,*PSID;
2780 #endif /* !defined(SID_DEFINED) */
2781
2782 #define SID_REVISION                    (1)     /* Current revision */
2783 #define SID_MAX_SUB_AUTHORITIES         (15)    /* current max subauths */
2784 #define SID_RECOMMENDED_SUB_AUTHORITIES (1)     /* recommended subauths */
2785
2786
2787 /* 
2788  * ACL 
2789  */
2790
2791 #define ACL_REVISION1 1
2792 #define ACL_REVISION2 2
2793 #define ACL_REVISION3 3
2794 #define ACL_REVISION4 4
2795
2796 #define MIN_ACL_REVISION ACL_REVISION2
2797 #define MAX_ACL_REVISION ACL_REVISION4
2798
2799 typedef struct _ACL {
2800     BYTE AclRevision;
2801     BYTE Sbz1;
2802     WORD AclSize;
2803     WORD AceCount;
2804     WORD Sbz2;
2805 } ACL, *PACL;
2806
2807 /* SECURITY_DESCRIPTOR */
2808 #define SECURITY_DESCRIPTOR_REVISION    1
2809 #define SECURITY_DESCRIPTOR_REVISION1   1
2810
2811
2812 #define SE_OWNER_DEFAULTED      0x0001
2813 #define SE_GROUP_DEFAULTED      0x0002
2814 #define SE_DACL_PRESENT         0x0004
2815 #define SE_DACL_DEFAULTED       0x0008
2816 #define SE_SACL_PRESENT         0x0010
2817 #define SE_SACL_DEFAULTED       0x0020
2818 #define SE_SELF_RELATIVE        0x8000
2819
2820 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2821 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
2822
2823 /* The security descriptor structure */
2824 typedef struct {
2825     BYTE Revision;
2826     BYTE Sbz1;
2827     SECURITY_DESCRIPTOR_CONTROL Control;
2828     DWORD Owner;
2829     DWORD Group;
2830     DWORD Sacl;
2831     DWORD Dacl;
2832 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
2833
2834 typedef struct {
2835     BYTE Revision;
2836     BYTE Sbz1;
2837     SECURITY_DESCRIPTOR_CONTROL Control;
2838     PSID Owner;
2839     PSID Group;
2840     PACL Sacl;
2841     PACL Dacl;
2842 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
2843
2844 #define SECURITY_DESCRIPTOR_MIN_LENGTH   (sizeof(SECURITY_DESCRIPTOR)) 
2845
2846 #include "poppack.h"
2847
2848 #endif /* _SECURITY_DEFINED */
2849
2850 #include "pshpack1.h"
2851
2852 /* 
2853  * SID_AND_ATTRIBUTES
2854  */
2855
2856 typedef struct _SID_AND_ATTRIBUTES {
2857   PSID  Sid; 
2858   DWORD Attributes; 
2859 } SID_AND_ATTRIBUTES ; 
2860  
2861 /* security entities */
2862 #define SECURITY_NULL_RID                       (0x00000000L)
2863 #define SECURITY_WORLD_RID                      (0x00000000L)
2864 #define SECURITY_LOCAL_RID                      (0X00000000L)
2865
2866 #define SECURITY_NULL_SID_AUTHORITY             {0,0,0,0,0,0}
2867
2868 /* S-1-1 */
2869 #define SECURITY_WORLD_SID_AUTHORITY            {0,0,0,0,0,1}
2870
2871 /* S-1-2 */
2872 #define SECURITY_LOCAL_SID_AUTHORITY            {0,0,0,0,0,2}
2873
2874 /* S-1-3 */
2875 #define SECURITY_CREATOR_SID_AUTHORITY          {0,0,0,0,0,3}
2876 #define SECURITY_CREATOR_OWNER_RID              (0x00000000L) 
2877 #define SECURITY_CREATOR_GROUP_RID              (0x00000001L)
2878 #define SECURITY_CREATOR_OWNER_SERVER_RID       (0x00000002L)
2879 #define SECURITY_CREATOR_GROUP_SERVER_RID       (0x00000003L)
2880
2881 /* S-1-4 */
2882 #define SECURITY_NON_UNIQUE_AUTHORITY           {0,0,0,0,0,4}
2883
2884 /* S-1-5 */
2885 #define SECURITY_NT_AUTHORITY                   {0,0,0,0,0,5} 
2886 #define SECURITY_DIALUP_RID                     0x00000001L
2887 #define SECURITY_NETWORK_RID                    0x00000002L
2888 #define SECURITY_BATCH_RID                      0x00000003L
2889 #define SECURITY_INTERACTIVE_RID                0x00000004L
2890 #define SECURITY_LOGON_IDS_RID                  0x00000005L
2891 #define SECURITY_SERVICE_RID                    0x00000006L
2892 #define SECURITY_ANONYMOUS_LOGON_RID            0x00000007L
2893 #define SECURITY_PROXY_RID                      0x00000008L
2894 #define SECURITY_ENTERPRISE_CONTROLLERS_RID     0x00000009L
2895 #define SECURITY_PRINCIPAL_SELF_RID             0x0000000AL
2896 #define SECURITY_AUTHENTICATED_USER_RID         0x0000000BL
2897 #define SECURITY_RESTRICTED_CODE_RID            0x0000000CL
2898 #define SECURITY_TERMINAL_SERVER_RID            0x0000000DL
2899 #define SECURITY_LOCAL_SYSTEM_RID               0x00000012L
2900 #define SECURITY_NT_NON_UNIQUE                  0x00000015L
2901 #define SECURITY_BUILTIN_DOMAIN_RID             0x00000020L
2902
2903 #define DOMAIN_GROUP_RID_ADMINS                 0x00000200L
2904 #define DOMAIN_GROUP_RID_USERS                  0x00000201L
2905 #define DOMAIN_GROUP_RID_GUESTS                 0x00000202L
2906
2907 #define DOMAIN_ALIAS_RID_ADMINS                 0x00000220L
2908 #define DOMAIN_ALIAS_RID_USERS                  0x00000221L
2909 #define DOMAIN_ALIAS_RID_GUESTS                 0x00000222L
2910
2911 #define SECURITY_SERVER_LOGON_RID               SECURITY_ENTERPRISE_CONTROLLERS_RID
2912
2913 #define SECURITY_LOGON_IDS_RID_COUNT            (3L)
2914
2915 /*
2916  * TOKEN_USER
2917  */
2918
2919 typedef struct _TOKEN_USER {
2920   SID_AND_ATTRIBUTES User; 
2921 } TOKEN_USER; 
2922
2923 /*
2924  * TOKEN_GROUPS
2925  */
2926
2927 typedef struct _TOKEN_GROUPS  {
2928   DWORD GroupCount; 
2929   SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; 
2930 } TOKEN_GROUPS; 
2931
2932 /*
2933  * LUID_AND_ATTRIBUTES
2934  */
2935
2936 typedef union _LARGE_INTEGER {
2937     struct {
2938         DWORD    LowPart;
2939         LONG     HighPart;
2940     } DUMMYSTRUCTNAME;
2941     LONGLONG QuadPart;
2942 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
2943
2944 typedef union _ULARGE_INTEGER {
2945     struct {
2946         DWORD    LowPart;
2947         DWORD    HighPart;
2948     } DUMMYSTRUCTNAME;
2949     ULONGLONG QuadPart;
2950 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
2951
2952 /*
2953  * Locally Unique Identifier
2954  */
2955
2956 typedef LARGE_INTEGER LUID,*PLUID;
2957
2958 typedef struct _LUID_AND_ATTRIBUTES {
2959   LUID   Luid; 
2960   DWORD  Attributes; 
2961 } LUID_AND_ATTRIBUTES; 
2962
2963 /*
2964  * PRIVILEGE_SET
2965  */
2966
2967 typedef struct _PRIVILEGE_SET {
2968     DWORD PrivilegeCount;
2969     DWORD Control;
2970     LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2971 } PRIVILEGE_SET, *PPRIVILEGE_SET;
2972
2973 /*
2974  * TOKEN_PRIVILEGES
2975  */
2976
2977 typedef struct _TOKEN_PRIVILEGES {
2978   DWORD PrivilegeCount; 
2979   LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]; 
2980 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES; 
2981
2982 /*
2983  * TOKEN_OWNER
2984  */
2985
2986 typedef struct _TOKEN_OWNER {
2987   PSID Owner; 
2988 } TOKEN_OWNER; 
2989
2990 /*
2991  * TOKEN_PRIMARY_GROUP
2992  */
2993
2994 typedef struct _TOKEN_PRIMARY_GROUP {
2995   PSID PrimaryGroup; 
2996 } TOKEN_PRIMARY_GROUP; 
2997
2998
2999 /*
3000  * TOKEN_DEFAULT_DACL
3001  */
3002
3003 typedef struct _TOKEN_DEFAULT_DACL { 
3004   PACL DefaultDacl; 
3005 } TOKEN_DEFAULT_DACL; 
3006
3007 /*
3008  * TOKEN_SOURCEL
3009  */
3010
3011 typedef struct _TOKEN_SOURCE {
3012   char Sourcename[8]; 
3013   LUID SourceIdentifier; 
3014 } TOKEN_SOURCE; 
3015
3016 /*
3017  * TOKEN_TYPE
3018  */
3019
3020 typedef enum tagTOKEN_TYPE {
3021   TokenPrimary = 1, 
3022   TokenImpersonation 
3023 } TOKEN_TYPE; 
3024
3025 /*
3026  * SECURITY_IMPERSONATION_LEVEL
3027  */
3028
3029 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3030   SecurityAnonymous, 
3031   SecurityIdentification, 
3032   SecurityImpersonation, 
3033   SecurityDelegation 
3034 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL; 
3035
3036
3037 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3038         * PSECURITY_CONTEXT_TRACKING_MODE;
3039 /*
3040  *      Quality of Service
3041  */
3042
3043 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3044   DWORD                         Length;
3045   SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel;
3046   SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3047   BOOL                          EffectiveOnly;
3048 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3049
3050 /*
3051  * TOKEN_STATISTICS
3052  */
3053
3054 typedef struct _TOKEN_STATISTICS {
3055   LUID  TokenId; 
3056   LUID  AuthenticationId; 
3057   LARGE_INTEGER ExpirationTime; 
3058   TOKEN_TYPE    TokenType; 
3059   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 
3060   DWORD DynamicCharged; 
3061   DWORD DynamicAvailable; 
3062   DWORD GroupCount; 
3063   DWORD PrivilegeCount; 
3064   LUID  ModifiedId; 
3065 } TOKEN_STATISTICS; 
3066
3067 /* 
3068  *      ACLs of NT 
3069  */
3070
3071 #define ACL_REVISION    2
3072
3073 #define ACL_REVISION1   1
3074 #define ACL_REVISION2   2
3075
3076 /* ACEs, directly starting after an ACL */
3077 typedef struct _ACE_HEADER {
3078         BYTE    AceType;
3079         BYTE    AceFlags;
3080         WORD    AceSize;
3081 } ACE_HEADER,*PACE_HEADER;
3082
3083 /* AceType */
3084 #define ACCESS_ALLOWED_ACE_TYPE         0
3085 #define ACCESS_DENIED_ACE_TYPE          1
3086 #define SYSTEM_AUDIT_ACE_TYPE           2
3087 #define SYSTEM_ALARM_ACE_TYPE           3
3088
3089 /* inherit AceFlags */
3090 #define OBJECT_INHERIT_ACE              0x01
3091 #define CONTAINER_INHERIT_ACE           0x02
3092 #define NO_PROPAGATE_INHERIT_ACE        0x04
3093 #define INHERIT_ONLY_ACE                0x08
3094 #define VALID_INHERIT_FLAGS             0x0F
3095
3096 /* AceFlags mask for what events we (should) audit */
3097 #define SUCCESSFUL_ACCESS_ACE_FLAG      0x40
3098 #define FAILED_ACCESS_ACE_FLAG          0x80
3099
3100 /* different ACEs depending on AceType 
3101  * SidStart marks the begin of a SID
3102  * so the thing finally looks like this:
3103  * 0: ACE_HEADER
3104  * 4: ACCESS_MASK
3105  * 8... : SID
3106  */
3107 typedef struct _ACCESS_ALLOWED_ACE {
3108         ACE_HEADER      Header;
3109         DWORD           Mask;
3110         DWORD           SidStart;
3111 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3112
3113 typedef struct _ACCESS_DENIED_ACE {
3114         ACE_HEADER      Header;
3115         DWORD           Mask;
3116         DWORD           SidStart;
3117 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3118
3119 typedef struct _SYSTEM_AUDIT_ACE {
3120         ACE_HEADER      Header;
3121         DWORD           Mask;
3122         DWORD           SidStart;
3123 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3124
3125 typedef struct _SYSTEM_ALARM_ACE {
3126         ACE_HEADER      Header;
3127         DWORD           Mask;
3128         DWORD           SidStart;
3129 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3130
3131 typedef enum tagSID_NAME_USE {
3132         SidTypeUser = 1,
3133         SidTypeGroup,
3134         SidTypeDomain,
3135         SidTypeAlias,
3136         SidTypeWellKnownGroup,
3137         SidTypeDeletedAccount,
3138         SidTypeInvalid,
3139         SidTypeUnknown
3140 } SID_NAME_USE,*PSID_NAME_USE;
3141
3142 /* Access rights */
3143
3144 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3145 #undef  DELETE
3146 #define DELETE                     0x00010000
3147 #define READ_CONTROL               0x00020000
3148 #define WRITE_DAC                  0x00040000
3149 #define WRITE_OWNER                0x00080000
3150 #define SYNCHRONIZE                0x00100000
3151 #define STANDARD_RIGHTS_REQUIRED   0x000f0000
3152
3153 #define STANDARD_RIGHTS_READ       READ_CONTROL
3154 #define STANDARD_RIGHTS_WRITE      READ_CONTROL
3155 #define STANDARD_RIGHTS_EXECUTE    READ_CONTROL
3156
3157 #define STANDARD_RIGHTS_ALL        0x001f0000
3158
3159 #define SPECIFIC_RIGHTS_ALL        0x0000ffff
3160
3161 #define GENERIC_READ               0x80000000
3162 #define GENERIC_WRITE              0x40000000
3163 #define GENERIC_EXECUTE            0x20000000
3164 #define GENERIC_ALL                0x10000000
3165
3166 #define MAXIMUM_ALLOWED            0x02000000
3167 #define ACCESS_SYSTEM_SECURITY     0x01000000
3168
3169 #define EVENT_MODIFY_STATE         0x0002
3170 #define EVENT_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3171
3172 #define SEMAPHORE_MODIFY_STATE     0x0002
3173 #define SEMAPHORE_ALL_ACCESS       (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3174
3175 #define MUTEX_MODIFY_STATE         0x0001
3176 #define MUTEX_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3177
3178 #define TIMER_QUERY_STATE          0x0001
3179 #define TIMER_MODIFY_STATE         0x0002
3180 #define TIMER_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3181
3182 #define PROCESS_TERMINATE          0x0001
3183 #define PROCESS_CREATE_THREAD      0x0002
3184 #define PROCESS_VM_OPERATION       0x0008
3185 #define PROCESS_VM_READ            0x0010
3186 #define PROCESS_VM_WRITE           0x0020
3187 #define PROCESS_DUP_HANDLE         0x0040
3188 #define PROCESS_CREATE_PROCESS     0x0080
3189 #define PROCESS_SET_QUOTA          0x0100
3190 #define PROCESS_SET_INFORMATION    0x0200
3191 #define PROCESS_QUERY_INFORMATION  0x0400
3192 #define PROCESS_ALL_ACCESS         (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3193
3194 #define THREAD_TERMINATE           0x0001
3195 #define THREAD_SUSPEND_RESUME      0x0002
3196 #define THREAD_GET_CONTEXT         0x0008
3197 #define THREAD_SET_CONTEXT         0x0010
3198 #define THREAD_SET_INFORMATION     0x0020
3199 #define THREAD_QUERY_INFORMATION   0x0040
3200 #define THREAD_SET_THREAD_TOKEN    0x0080
3201 #define THREAD_IMPERSONATE         0x0100
3202 #define THREAD_DIRECT_IMPERSONATION 0x0200
3203 #define THREAD_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3204
3205 #define THREAD_BASE_PRIORITY_LOWRT  15 
3206 #define THREAD_BASE_PRIORITY_MAX    2 
3207 #define THREAD_BASE_PRIORITY_MIN   -2
3208 #define THREAD_BASE_PRIORITY_IDLE  -15
3209
3210 #define FILE_READ_DATA            0x0001    /* file & pipe */
3211 #define FILE_LIST_DIRECTORY       0x0001    /* directory */
3212 #define FILE_WRITE_DATA           0x0002    /* file & pipe */
3213 #define FILE_ADD_FILE             0x0002    /* directory */
3214 #define FILE_APPEND_DATA          0x0004    /* file */
3215 #define FILE_ADD_SUBDIRECTORY     0x0004    /* directory */
3216 #define FILE_CREATE_PIPE_INSTANCE 0x0004    /* named pipe */
3217 #define FILE_READ_EA              0x0008    /* file & directory */
3218 #define FILE_READ_PROPERTIES      FILE_READ_EA
3219 #define FILE_WRITE_EA             0x0010    /* file & directory */
3220 #define FILE_WRITE_PROPERTIES     FILE_WRITE_EA
3221 #define FILE_EXECUTE              0x0020    /* file */
3222 #define FILE_TRAVERSE             0x0020    /* directory */
3223 #define FILE_DELETE_CHILD         0x0040    /* directory */
3224 #define FILE_READ_ATTRIBUTES      0x0080    /* all */
3225 #define FILE_WRITE_ATTRIBUTES     0x0100    /* all */
3226 #define FILE_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3227
3228 #define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3229                                    FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3230                                    SYNCHRONIZE)
3231 #define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3232                                    FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3233                                    FILE_APPEND_DATA | SYNCHRONIZE)
3234 #define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3235                                    FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3236
3237
3238 /* File attribute flags */
3239 #define FILE_SHARE_READ                 0x00000001L
3240 #define FILE_SHARE_WRITE                0x00000002L
3241 #define FILE_SHARE_DELETE               0x00000004L
3242 #define FILE_ATTRIBUTE_READONLY         0x00000001L
3243 #define FILE_ATTRIBUTE_HIDDEN           0x00000002L
3244 #define FILE_ATTRIBUTE_SYSTEM           0x00000004L
3245 #define FILE_ATTRIBUTE_LABEL            0x00000008L  /* Not in Windows API */
3246 #define FILE_ATTRIBUTE_DIRECTORY        0x00000010L
3247 #define FILE_ATTRIBUTE_ARCHIVE          0x00000020L
3248 #define FILE_ATTRIBUTE_NORMAL           0x00000080L
3249 #define FILE_ATTRIBUTE_TEMPORARY        0x00000100L
3250 #define FILE_ATTRIBUTE_ATOMIC_WRITE     0x00000200L
3251 #define FILE_ATTRIBUTE_XACTION_WRITE    0x00000400L
3252 #define FILE_ATTRIBUTE_COMPRESSED       0x00000800L
3253 #define FILE_ATTRIBUTE_OFFLINE          0x00001000L
3254 #define FILE_ATTRIBUTE_SYMLINK          0x80000000L  /* Not in Windows API */
3255
3256 /* File notification flags */
3257 #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
3258 #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
3259 #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
3260 #define FILE_NOTIFY_CHANGE_SIZE         0x00000008
3261 #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
3262 #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
3263 #define FILE_NOTIFY_CHANGE_CREATION     0x00000040
3264 #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
3265
3266 #define FILE_ACTION_ADDED               0x00000001
3267 #define FILE_ACTION_REMOVED             0x00000002
3268 #define FILE_ACTION_MODIFIED            0x00000003
3269 #define FILE_ACTION_RENAMED_OLD_NAME    0x00000004
3270 #define FILE_ACTION_RENAMED_NEW_NAME    0x00000005
3271
3272
3273 #define FILE_CASE_SENSITIVE_SEARCH      0x00000001
3274 #define FILE_CASE_PRESERVED_NAMES       0x00000002
3275 #define FILE_UNICODE_ON_DISK            0x00000004
3276 #define FILE_PERSISTENT_ACLS            0x00000008
3277 #define FILE_FILE_COMPRESSION           0x00000010
3278 #define FILE_VOLUME_IS_COMPRESSED       0x00008000
3279
3280 /* File alignments (NT) */
3281 #define FILE_BYTE_ALIGNMENT             0x00000000
3282 #define FILE_WORD_ALIGNMENT             0x00000001
3283 #define FILE_LONG_ALIGNMENT             0x00000003
3284 #define FILE_QUAD_ALIGNMENT             0x00000007
3285 #define FILE_OCTA_ALIGNMENT             0x0000000f
3286 #define FILE_32_BYTE_ALIGNMENT          0x0000001f
3287 #define FILE_64_BYTE_ALIGNMENT          0x0000003f
3288 #define FILE_128_BYTE_ALIGNMENT         0x0000007f
3289 #define FILE_256_BYTE_ALIGNMENT         0x000000ff
3290 #define FILE_512_BYTE_ALIGNMENT         0x000001ff
3291
3292 #define REG_NONE                0       /* no type */
3293 #define REG_SZ                  1       /* string type (ASCII) */
3294 #define REG_EXPAND_SZ           2       /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3295 #define REG_BINARY              3       /* binary format, callerspecific */
3296 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3297 #define REG_DWORD               4       /* DWORD in little endian format */
3298 #define REG_DWORD_LITTLE_ENDIAN 4       /* DWORD in little endian format */
3299 #define REG_DWORD_BIG_ENDIAN    5       /* DWORD in big endian format  */
3300 #define REG_LINK                6       /* symbolic link (UNICODE) */
3301 #define REG_MULTI_SZ            7       /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3302 #define REG_RESOURCE_LIST       8       /* resource list? huh? */
3303 #define REG_FULL_RESOURCE_DESCRIPTOR    9       /* full resource descriptor? huh? */
3304 #define REG_RESOURCE_REQUIREMENTS_LIST  10
3305
3306 /* ----------------------------- begin registry ----------------------------- */
3307
3308 /* Registry security values */
3309 #define OWNER_SECURITY_INFORMATION      0x00000001
3310 #define GROUP_SECURITY_INFORMATION      0x00000002
3311 #define DACL_SECURITY_INFORMATION       0x00000004
3312 #define SACL_SECURITY_INFORMATION       0x00000008
3313
3314 #define REG_OPTION_RESERVED             0x00000000
3315 #define REG_OPTION_NON_VOLATILE         0x00000000
3316 #define REG_OPTION_VOLATILE             0x00000001
3317 #define REG_OPTION_CREATE_LINK          0x00000002
3318 #define REG_OPTION_BACKUP_RESTORE       0x00000004 /* FIXME */
3319 #define REG_OPTION_OPEN_LINK            0x00000008
3320 #define REG_LEGAL_OPTION               (REG_OPTION_RESERVED|  \
3321                                         REG_OPTION_NON_VOLATILE|  \
3322                                         REG_OPTION_VOLATILE|  \
3323                                         REG_OPTION_CREATE_LINK|  \
3324                                         REG_OPTION_BACKUP_RESTORE|  \
3325                                         REG_OPTION_OPEN_LINK)
3326
3327
3328 #define REG_CREATED_NEW_KEY     0x00000001
3329 #define REG_OPENED_EXISTING_KEY 0x00000002
3330
3331 /* For RegNotifyChangeKeyValue */
3332 #define REG_NOTIFY_CHANGE_NAME  0x1
3333
3334 #define KEY_QUERY_VALUE         0x00000001
3335 #define KEY_SET_VALUE           0x00000002
3336 #define KEY_CREATE_SUB_KEY      0x00000004
3337 #define KEY_ENUMERATE_SUB_KEYS  0x00000008
3338 #define KEY_NOTIFY              0x00000010
3339 #define KEY_CREATE_LINK         0x00000020
3340
3341 #define KEY_READ              ((STANDARD_RIGHTS_READ|  \
3342                                 KEY_QUERY_VALUE|  \
3343                                 KEY_ENUMERATE_SUB_KEYS|  \
3344                                 KEY_NOTIFY)  \
3345                                 & (~SYNCHRONIZE)  \
3346                               )
3347 #define KEY_WRITE             ((STANDARD_RIGHTS_WRITE|  \
3348                                 KEY_SET_VALUE|  \
3349                                 KEY_CREATE_SUB_KEY)  \
3350                                 & (~SYNCHRONIZE)  \
3351                               )
3352 #define KEY_EXECUTE           ((KEY_READ)  \
3353                                 & (~SYNCHRONIZE))  \
3354                               )
3355 #define KEY_ALL_ACCESS        ((STANDARD_RIGHTS_ALL|  \
3356                                 KEY_QUERY_VALUE|  \
3357                                 KEY_SET_VALUE|  \
3358                                 KEY_CREATE_SUB_KEY|  \
3359                                 KEY_ENUMERATE_SUB_KEYS|  \
3360                                 KEY_NOTIFY|  \
3361                                 KEY_CREATE_LINK)  \
3362                                 & (~SYNCHRONIZE)  \
3363                               )
3364 /* ------------------------------ end registry ------------------------------ */
3365
3366
3367 typedef struct _RTL_CRITICAL_SECTION_DEBUG 
3368 {
3369   WORD   Type;
3370   WORD   CreatorBackTraceIndex;
3371   struct _RTL_CRITICAL_SECTION *CriticalSection;
3372   LIST_ENTRY ProcessLocksList;
3373   DWORD EntryCount;
3374   DWORD ContentionCount;
3375   DWORD Spare[ 2 ];
3376 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
3377
3378 typedef struct _RTL_CRITICAL_SECTION {
3379     PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
3380     LONG LockCount;
3381     LONG RecursionCount;
3382     HANDLE OwningThread;
3383     HANDLE LockSemaphore;
3384     ULONG_PTR SpinCount;
3385 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
3386
3387
3388 #define EVENTLOG_SUCCESS                0x0000
3389 #define EVENTLOG_ERROR_TYPE             0x0001
3390 #define EVENTLOG_WARNING_TYPE           0x0002
3391 #define EVENTLOG_INFORMATION_TYPE       0x0004
3392 #define EVENTLOG_AUDIT_SUCCESS          0x0008
3393 #define EVENTLOG_AUDIT_FAILURE          0x0010
3394
3395 #define SERVICE_BOOT_START   0x00000000
3396 #define SERVICE_SYSTEM_START 0x00000001
3397 #define SERVICE_AUTO_START   0x00000002
3398 #define SERVICE_DEMAND_START 0x00000003
3399 #define SERVICE_DISABLED     0x00000004
3400
3401 #define SERVICE_ERROR_IGNORE   0x00000000
3402 #define SERVICE_ERROR_NORMAL   0x00000001
3403 #define SERVICE_ERROR_SEVERE   0x00000002
3404 #define SERVICE_ERROR_CRITICAL 0x00000003
3405
3406 /* Service types */
3407 #define SERVICE_KERNEL_DRIVER      0x00000001
3408 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
3409 #define SERVICE_ADAPTER            0x00000004
3410 #define SERVICE_RECOGNIZER_DRIVER  0x00000008
3411
3412 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
3413                          SERVICE_RECOGNIZER_DRIVER )
3414
3415 #define SERVICE_WIN32_OWN_PROCESS   0x00000010
3416 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
3417 #define SERVICE_WIN32  (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
3418
3419 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
3420
3421 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
3422                            SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
3423
3424
3425 typedef enum _CM_SERVICE_NODE_TYPE 
3426 {
3427   DriverType               = SERVICE_KERNEL_DRIVER,
3428   FileSystemType           = SERVICE_FILE_SYSTEM_DRIVER,
3429   Win32ServiceOwnProcess   = SERVICE_WIN32_OWN_PROCESS,
3430   Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3431   AdapterType              = SERVICE_ADAPTER,
3432   RecognizerType           = SERVICE_RECOGNIZER_DRIVER
3433 } SERVICE_NODE_TYPE;
3434
3435 typedef enum _CM_SERVICE_LOAD_TYPE 
3436 {
3437   BootLoad    = SERVICE_BOOT_START,
3438   SystemLoad  = SERVICE_SYSTEM_START,
3439   AutoLoad    = SERVICE_AUTO_START,
3440   DemandLoad  = SERVICE_DEMAND_START,
3441   DisableLoad = SERVICE_DISABLED
3442 } SERVICE_LOAD_TYPE;
3443
3444 typedef enum _CM_ERROR_CONTROL_TYPE 
3445 {
3446   IgnoreError   = SERVICE_ERROR_IGNORE,
3447   NormalError   = SERVICE_ERROR_NORMAL,
3448   SevereError   = SERVICE_ERROR_SEVERE,
3449   CriticalError = SERVICE_ERROR_CRITICAL
3450 } SERVICE_ERROR_TYPE;
3451
3452
3453
3454 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
3455 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
3456 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
3457 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
3458 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
3459
3460 #include "guiddef.h"
3461
3462 #include "poppack.h"
3463
3464 #endif  /* __WINE_WINNT_H */