Fixed mingw32 warning about stdcall and fastcall being redefined.
[wine] / include / winnt.h
1 /*
2  * Win32 definitions for Windows NT
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_WINNT_H
22 #define __WINE_WINNT_H
23
24 #include "basetsd.h"
25
26 #ifndef RC_INVOKED
27 #include <ctype.h>
28 #include <stddef.h>
29 #include <string.h>
30 #endif
31
32
33 /* On Windows winnt.h depends on a few windef.h types and macros and thus 
34  * is not self-contained. Furthermore windef.h includes winnt.h so that it 
35  * would be pointless to try to use winnt.h directly.
36  * But for Wine and Winelib I decided to make winnt.h self-contained by 
37  * moving these definitions to winnt.h. It makes no difference to Winelib 
38  * programs since they are not using winnt.h directly anyway, and it allows 
39  * us to use winnt.h and get a minimal set of definitions.
40  */
41
42 /**** Some Wine specific definitions *****/
43
44 /* Architecture dependent settings. */
45 /* These are hardcoded to avoid dependencies on config.h in Winelib apps. */
46 #if defined(__i386__)
47 # undef  WORDS_BIGENDIAN
48 # undef  BITFIELDS_BIGENDIAN
49 # define ALLOW_UNALIGNED_ACCESS
50 #elif defined(__sparc__)
51 # define WORDS_BIGENDIAN
52 # define BITFIELDS_BIGENDIAN
53 # undef  ALLOW_UNALIGNED_ACCESS
54 #elif defined(__PPC__)
55 # define WORDS_BIGENDIAN
56 # define BITFIELDS_BIGENDIAN
57 # undef  ALLOW_UNALIGNED_ACCESS
58 #elif !defined(RC_INVOKED)
59 # error Unknown CPU architecture!
60 #endif
61
62
63 /* Calling conventions definitions */
64
65 #ifdef __i386__
66 # ifndef _X86_
67 #  define _X86_
68 # endif
69 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
70 #  define __stdcall __attribute__((__stdcall__))
71 #  define __cdecl   __attribute__((__cdecl__))
72 # else
73 #  error You need gcc >= 2.7 to build Wine on a 386
74 # endif  /* __GNUC__ */
75 #else  /* __i386__ */
76 # define __stdcall
77 # define __cdecl
78 #endif  /* __i386__ */
79
80 #ifndef __WINE__
81
82 #ifndef pascal
83 #define pascal      __stdcall
84 #endif
85 #ifndef _pascal
86 #define _pascal     __stdcall
87 #endif
88 #ifndef _stdcall
89 #define _stdcall    __stdcall
90 #endif
91 #ifndef _fastcall
92 #define _fastcall   __stdcall
93 #endif
94 #ifndef __fastcall
95 #define __fastcall  __stdcall
96 #endif
97 #ifndef __export
98 #define __export    __stdcall
99 #endif
100 #ifndef cdecl
101 #define cdecl       __cdecl
102 #endif
103 #ifndef _cdecl
104 #define _cdecl      __cdecl
105 #endif
106
107 #ifndef near
108 #define near
109 #endif
110 #ifndef far
111 #define far
112 #endif
113 #ifndef _near
114 #define _near
115 #endif
116 #ifndef _far
117 #define _far
118 #endif
119 #ifndef NEAR
120 #define NEAR
121 #endif
122 #ifndef FAR
123 #define FAR
124 #endif
125
126 #ifndef _declspec
127 #define _declspec(x)
128 #endif
129 #ifndef __declspec
130 #define __declspec(x)
131 #endif
132
133 #endif /* __WINE__ */
134
135 #define CALLBACK    __stdcall
136 #define WINAPI      __stdcall
137 #define APIPRIVATE  __stdcall
138 #define PASCAL      __stdcall
139 #define CDECL       __cdecl
140 #define _CDECL      __cdecl
141 #define WINAPIV     __cdecl
142 #define APIENTRY    WINAPI
143 #define CONST       const
144
145 /* Macro for structure packing and more. */
146
147 #ifdef __GNUC__
148 #define WINE_PACKED   __attribute__((packed))
149 #define WINE_UNUSED   __attribute__((unused))
150 #define WINE_NORETURN __attribute__((noreturn))
151 #else
152 #define WINE_PACKED    /* nothing */
153 #define WINE_UNUSED    /* nothing */
154 #define WINE_NORETURN  /* nothing */
155 #endif
156
157 /* Anonymous union/struct handling */
158
159 #ifdef __WINE__
160 # define NONAMELESSSTRUCT
161 # define NONAMELESSUNION
162 #else
163 /* Anonymous struct support starts with gcc/g++ 2.96 */
164 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
165 #  define NONAMELESSSTRUCT
166 # endif
167 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
168 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
169 #  define NONAMELESSUNION
170 # endif
171 #endif
172
173 #ifndef NONAMELESSSTRUCT
174 #define DUMMYSTRUCTNAME
175 #define DUMMYSTRUCTNAME1
176 #define DUMMYSTRUCTNAME2
177 #define DUMMYSTRUCTNAME3
178 #define DUMMYSTRUCTNAME4
179 #define DUMMYSTRUCTNAME5
180 #else /* !defined(NONAMELESSSTRUCT) */
181 #define DUMMYSTRUCTNAME   s
182 #define DUMMYSTRUCTNAME1  s1
183 #define DUMMYSTRUCTNAME2  s2
184 #define DUMMYSTRUCTNAME3  s3
185 #define DUMMYSTRUCTNAME4  s4
186 #define DUMMYSTRUCTNAME5  s5
187 #endif /* !defined(NONAMELESSSTRUCT) */
188
189 #ifndef NONAMELESSUNION
190 #define DUMMYUNIONNAME
191 #define DUMMYUNIONNAME1
192 #define DUMMYUNIONNAME2
193 #define DUMMYUNIONNAME3
194 #define DUMMYUNIONNAME4
195 #define DUMMYUNIONNAME5
196 #define DUMMYUNIONNAME6
197 #define DUMMYUNIONNAME7
198 #define DUMMYUNIONNAME8
199 #else /* !defined(NONAMELESSUNION) */
200 #define DUMMYUNIONNAME   u
201 #define DUMMYUNIONNAME1  u1
202 #define DUMMYUNIONNAME2  u2
203 #define DUMMYUNIONNAME3  u3
204 #define DUMMYUNIONNAME4  u4
205 #define DUMMYUNIONNAME5  u5
206 #define DUMMYUNIONNAME6  u6
207 #define DUMMYUNIONNAME7  u7
208 #define DUMMYUNIONNAME8  u8
209 #endif /* !defined(NONAMELESSUNION) */
210
211
212 /**** Parts of windef.h that are needed here *****/
213
214 /* Misc. constants. */
215
216 #undef NULL
217 #ifdef __cplusplus
218 #define NULL  0
219 #else
220 #define NULL  ((void*)0)
221 #endif
222
223 #ifdef FALSE
224 #undef FALSE
225 #endif
226 #define FALSE 0
227
228 #ifdef TRUE
229 #undef TRUE
230 #endif
231 #define TRUE  1
232
233 #ifndef IN
234 #define IN
235 #endif
236
237 #ifndef OUT
238 #define OUT
239 #endif
240
241 #ifndef OPTIONAL
242 #define OPTIONAL
243 #endif
244
245 /* Error Masks */
246 #define APPLICATION_ERROR_MASK       0x20000000
247 #define ERROR_SEVERITY_SUCCESS       0x00000000
248 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
249 #define ERROR_SEVERITY_WARNING       0x80000000
250 #define ERROR_SEVERITY_ERROR         0xC0000000
251
252 /* Standard data types */
253 typedef const void                  *PCVOID,   *LPCVOID;
254 typedef int             BOOL,       *PBOOL,    *LPBOOL;
255 typedef unsigned char   BYTE,       *PBYTE,    *LPBYTE;
256 typedef unsigned char   UCHAR,      *PUCHAR;
257 typedef unsigned short  USHORT,     *PUSHORT,  *LPUSHORT;
258 typedef unsigned short  WORD,       *PWORD,    *LPWORD;
259 typedef int             INT,        *PINT,     *LPINT;
260 typedef unsigned int    UINT,       *PUINT,    *LPUINT;
261 typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
262 typedef unsigned long   ULONG,      *PULONG,   *LPULONG;
263 typedef float           FLOAT,      *PFLOAT,   *LPFLOAT;
264 typedef double          DOUBLE,     *PDOUBLE,  *LPDOUBLE;
265 typedef double          DATE;
266
267
268 /**** winnt.h proper *****/
269
270 /* Microsoft's macros for declaring functions */
271
272 #ifdef __cplusplus
273 # define EXTERN_C    extern "C"
274 #else
275 # define EXTERN_C    extern
276 #endif
277
278 #ifndef __WINE__
279 #define STDMETHODCALLTYPE       __stdcall
280 #define STDMETHODVCALLTYPE      __cdecl
281 #define STDAPICALLTYPE          __stdcall
282 #define STDAPIVCALLTYPE         __cdecl
283
284 #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
285 #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
286 #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
287 #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
288 #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
289 #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
290 #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
291 #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
292 #endif
293
294 /* Define the basic types */
295 #ifndef VOID
296 #define VOID void
297 #endif
298 typedef VOID           *PVOID,      *LPVOID;
299 typedef BYTE            BOOLEAN,    *PBOOLEAN;
300 typedef char            CHAR,       *PCHAR;
301 typedef short           SHORT,      *PSHORT;
302 typedef long            LONG,       *PLONG,    *LPLONG;
303
304 /* Some systems might have wchar_t, but we really need 16 bit characters */
305 #ifndef WINE_WCHAR_DEFINED
306 #ifdef WINE_UNICODE_NATIVE
307 typedef wchar_t         WCHAR,      *PWCHAR;
308 #else
309 typedef unsigned short  WCHAR,      *PWCHAR;
310 #endif
311 #define WINE_WCHAR_DEFINED
312 #endif
313
314 /* 'Extended/Wide' numerical types */
315 #ifndef _ULONGLONG_
316 #define _ULONGLONG_
317 typedef __int64         LONGLONG,   *PLONGLONG;
318 typedef __uint64        ULONGLONG,  *PULONGLONG;
319 #endif
320
321 #ifndef _DWORDLONG_
322 #define _DWORDLONG_
323 typedef ULONGLONG       DWORDLONG,  *PDWORDLONG;
324 #endif
325
326 /* ANSI string types */
327 typedef CHAR           *PCH,        *LPCH;
328 typedef const CHAR     *PCCH,       *LPCCH;
329 typedef CHAR           *PSTR,       *LPSTR;
330 typedef const CHAR     *PCSTR,      *LPCSTR;
331
332 /* Unicode string types */
333 typedef WCHAR          *PWCH,       *LPWCH;
334 typedef const WCHAR    *PCWCH,      *LPCWCH;
335 typedef WCHAR          *PWSTR,      *LPWSTR;
336 typedef const WCHAR    *PCWSTR,     *LPCWSTR;
337
338 /* Neutral character and string types */
339 /* These are only defined for Winelib, i.e. _not_ defined for 
340  * the emulator. The reason is they depend on the UNICODE 
341  * macro which only exists in the user's code.
342  */
343 #ifndef __WINE__
344 # ifdef WINE_UNICODE_REWRITE
345
346 /* Use this if your compiler does not provide a 16bit wchar_t type. 
347  * Note that you will need to specify -fwritable-strings or an option
348  * to this effect.
349  * In C++ both WINE_UNICODE_TEXT('c') and WINE_UNICODE_TEXT("str") are 
350  * supported, but only the string form can be supported in C.
351  */
352 EXTERN_C unsigned short* wine_rewrite_s4tos2(const wchar_t* str4);
353 #  ifdef __cplusplus
354 inline WCHAR* wine_unicode_text(const wchar_t* str4)
355 {
356   return (WCHAR*)wine_rewrite_s4tos2(str4);
357 }
358 inline WCHAR wine_unicode_text(wchar_t chr4)
359 {
360   return (WCHAR)chr4;
361 }
362 #   define WINE_UNICODE_TEXT(x)       wine_unicode_text(L##x)
363 #  else  /* __cplusplus */
364 #   define WINE_UNICODE_TEXT(x)       ((WCHAR*)wine_rewrite_s4tos2(L##x))
365 #  endif  /* __cplusplus */
366
367 # else  /* WINE_UNICODE_REWRITE */
368
369 /* Define WINE_UNICODE_NATIVE if:
370  * - your compiler provides a 16bit wchar_t type, e.g. gcc >= 2.96 with 
371  *   -fshort-wchar option
372  * - or if you decide to use the native 32bit Unix wchar_t type. Be aware 
373  *   though that the Wine APIs only support 16bit WCHAR characters for 
374  *   binary compatibility reasons.
375  * - or define nothing at all if you don't use Unicode, and blissfully 
376  *   ignore the issue :-)
377  */
378 #  define WINE_UNICODE_TEXT(string)   L##string
379
380 # endif  /* WINE_UNICODE_REWRITE */
381
382 # ifdef UNICODE
383 typedef WCHAR           TCHAR,      *PTCHAR;
384 typedef LPWSTR          PTSTR,       LPTSTR;
385 typedef LPCWSTR         PCTSTR,      LPCTSTR;
386 #  define __TEXT(string) WINE_UNICODE_TEXT(string)
387 # else  /* UNICODE */
388 typedef CHAR            TCHAR,      *PTCHAR;
389 typedef LPSTR           PTSTR,       LPTSTR;
390 typedef LPCSTR          PCTSTR,      LPCTSTR;
391 #  define __TEXT(string) string
392 # endif /* UNICODE */
393 # define TEXT(quote) __TEXT(quote)
394 #endif   /* __WINE__ */
395
396 /* Misc common WIN32 types */
397 typedef LONG            HRESULT;
398 typedef DWORD           LCID,       *PLCID;
399 typedef WORD            LANGID;
400 typedef DWORD           EXECUTION_STATE;
401
402 /* Handle type */
403
404 /* FIXME: Wine does not compile with strict on, therefore strict
405  * handles are presently only usable on machines where sizeof(UINT) ==
406  * sizeof(void*).  HANDLEs are supposed to be void* but a large amount
407  * of WINE code operates on HANDLES as if they are UINTs. So to WINE
408  * they exist as UINTs but to the Winelib user who turns on strict,
409  * they exist as void*. If there is a size difference between UINT and
410  * void* then things get ugly.
411  *
412  * Here is the plan to convert Wine to STRICT:
413  *
414  * Types will be converted one at a time by volunteers who will compile
415  * Wine with STRICT turned on. Handles that have not been converted yet 
416  * will be declared with DECLARE_OLD_HANDLE. Converted handles are 
417  * declared with DECLARE_HANDLE.
418  * See the bug report 90 for more details:
419  *    http://wine.codeweavers.com/bugzilla/show_bug.cgi?id=90
420  */
421 /*
422  * when compiling Wine we always treat HANDLE as an UINT. Then when 
423  * we're ready we'll remove the '!defined(__WINE__)' (the equivalent 
424  * of converting it from DECLARE_OLD_HANDLE to DECLARE_HANDLE).
425  */
426 #if defined(STRICT) && !defined(__WINE__)
427 typedef VOID*           HANDLE;
428 #define DECLARE_OLD_HANDLE(a) \
429     typedef struct a##__ { int unused; } *a; \
430     typedef a          *P##a,       *LP##a
431
432 #else
433 typedef UINT            HANDLE;
434 #define DECLARE_OLD_HANDLE(a) \
435     typedef HANDLE      a; \
436     typedef a          *P##a,       *LP##a
437 #endif
438 typedef HANDLE         *PHANDLE,    *LPHANDLE;
439
440 #ifdef STRICT
441 #define DECLARE_HANDLE(a) \
442     typedef struct a##__ { int unused; } *a; \
443     typedef a          *P##a,       *LP##a
444 #else /*STRICT*/
445 #define DECLARE_HANDLE(a) \
446     typedef HANDLE      a; \
447     typedef a          *P##a,       *LP##a
448 #endif /*STRICT*/
449
450 /* Defines */
451
452 /* Argument 1 passed to the DllEntryProc. */
453 #define DLL_PROCESS_DETACH      0       /* detach process (unload library) */
454 #define DLL_PROCESS_ATTACH      1       /* attach process (load library) */
455 #define DLL_THREAD_ATTACH       2       /* attach new thread */
456 #define DLL_THREAD_DETACH       3       /* detach thread */
457
458
459 /* u.x.wProcessorArchitecture (NT) */
460 #define PROCESSOR_ARCHITECTURE_INTEL    0
461 #define PROCESSOR_ARCHITECTURE_MIPS     1
462 #define PROCESSOR_ARCHITECTURE_ALPHA    2
463 #define PROCESSOR_ARCHITECTURE_PPC      3
464 #define PROCESSOR_ARCHITECTURE_SHX      4
465 #define PROCESSOR_ARCHITECTURE_ARM      5
466 #define PROCESSOR_ARCHITECTURE_UNKNOWN  0xFFFF
467
468 /* dwProcessorType */
469 #define PROCESSOR_INTEL_386      386
470 #define PROCESSOR_INTEL_486      486
471 #define PROCESSOR_INTEL_PENTIUM  586
472 #define PROCESSOR_INTEL_860      860
473 #define PROCESSOR_MIPS_R2000     2000
474 #define PROCESSOR_MIPS_R3000     3000
475 #define PROCESSOR_MIPS_R4000     4000
476 #define PROCESSOR_ALPHA_21064    21064
477 #define PROCESSOR_PPC_601        601
478 #define PROCESSOR_PPC_603        603
479 #define PROCESSOR_PPC_604        604
480 #define PROCESSOR_PPC_620        620
481 #define PROCESSOR_HITACHI_SH3    10003
482 #define PROCESSOR_HITACHI_SH3E   10004
483 #define PROCESSOR_HITACHI_SH4    10005
484 #define PROCESSOR_MOTOROLA_821   821
485 #define PROCESSOR_SHx_SH3        103
486 #define PROCESSOR_SHx_SH4        104
487 #define PROCESSOR_STRONGARM      2577
488 #define PROCESSOR_ARM720         1824    /* 0x720 */
489 #define PROCESSOR_ARM820         2080    /* 0x820 */
490 #define PROCESSOR_ARM920         2336    /* 0x920 */
491 #define PROCESSOR_ARM_7TDMI      70001
492
493 #define MAXIMUM_PROCESSORS       32
494 typedef struct _MEMORY_BASIC_INFORMATION
495 {
496     LPVOID   BaseAddress;
497     LPVOID   AllocationBase;
498     DWORD    AllocationProtect;
499     DWORD    RegionSize;
500     DWORD    State;
501     DWORD    Protect;
502     DWORD    Type;
503 } MEMORY_BASIC_INFORMATION,*LPMEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
504
505 #define PAGE_NOACCESS           0x01
506 #define PAGE_READONLY           0x02
507 #define PAGE_READWRITE          0x04
508 #define PAGE_WRITECOPY          0x08
509 #define PAGE_EXECUTE            0x10
510 #define PAGE_EXECUTE_READ       0x20
511 #define PAGE_EXECUTE_READWRITE  0x40
512 #define PAGE_EXECUTE_WRITECOPY  0x80
513 #define PAGE_GUARD              0x100
514 #define PAGE_NOCACHE            0x200
515
516 #define MEM_COMMIT              0x00001000
517 #define MEM_RESERVE             0x00002000
518 #define MEM_DECOMMIT            0x00004000
519 #define MEM_RELEASE             0x00008000
520 #define MEM_FREE                0x00010000
521 #define MEM_PRIVATE             0x00020000
522 #define MEM_MAPPED              0x00040000
523 #define MEM_RESET               0x00080000
524 #define MEM_TOP_DOWN            0x00100000
525 #ifdef __WINE__
526 #define MEM_SYSTEM              0x80000000
527 #endif
528
529 #define SEC_FILE                0x00800000
530 #define SEC_IMAGE               0x01000000
531 #define SEC_RESERVE             0x04000000
532 #define SEC_COMMIT              0x08000000
533 #define SEC_NOCACHE             0x10000000
534 #define MEM_IMAGE               SEC_IMAGE
535
536
537 #define MINCHAR       0x80
538 #define MAXCHAR       0x7f
539 #define MINSHORT      0x8000
540 #define MAXSHORT      0x7fff
541 #define MINLONG       0x80000000
542 #define MAXLONG       0x7fffffff
543 #define MAXBYTE       0xff
544 #define MAXWORD       0xffff
545 #define MAXDWORD      0xffffffff
546
547 #define FIELD_OFFSET(type, field) \
548   ((LONG)(INT)&(((type *)0)->field))
549
550 #define CONTAINING_RECORD(address, type, field) \
551   ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
552
553 /* Types */
554
555 typedef struct _LIST_ENTRY {
556   struct _LIST_ENTRY *Flink;
557   struct _LIST_ENTRY *Blink;
558 } LIST_ENTRY, *PLIST_ENTRY;
559
560 typedef struct _SINGLE_LIST_ENTRY {
561   struct _SINGLE_LIST_ENTRY *Next;
562 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
563
564 /* Heap flags */
565
566 #define HEAP_NO_SERIALIZE               0x00000001
567 #define HEAP_GROWABLE                   0x00000002
568 #define HEAP_GENERATE_EXCEPTIONS        0x00000004
569 #define HEAP_ZERO_MEMORY                0x00000008
570 #define HEAP_REALLOC_IN_PLACE_ONLY      0x00000010
571 #define HEAP_TAIL_CHECKING_ENABLED      0x00000020
572 #define HEAP_FREE_CHECKING_ENABLED      0x00000040
573 #define HEAP_DISABLE_COALESCE_ON_FREE   0x00000080
574 #define HEAP_CREATE_ALIGN_16            0x00010000
575 #define HEAP_CREATE_ENABLE_TRACING      0x00020000
576
577 /* This flag allows it to create heaps shared by all processes under win95,
578    FIXME: correct name */
579 #define HEAP_SHARED                     0x04000000
580
581 /* Processor feature flags.  */
582 #define PF_FLOATING_POINT_PRECISION_ERRATA      0
583 #define PF_FLOATING_POINT_EMULATED              1
584 #define PF_COMPARE_EXCHANGE_DOUBLE              2
585 #define PF_MMX_INSTRUCTIONS_AVAILABLE           3
586 #define PF_PPC_MOVEMEM_64BIT_OK                 4
587 #define PF_ALPHA_BYTE_INSTRUCTIONS              5
588 #define PF_XMMI_INSTRUCTIONS_AVAILABLE          6
589 #define PF_AMD3D_INSTRUCTIONS_AVAILABLE         7
590 #define PF_RDTSC_INSTRUCTION_AVAILABLE          8
591
592
593 /* Execution state flags */
594 #define ES_SYSTEM_REQUIRED    0x00000001
595 #define ES_DISPLAY_REQUIRED   0x00000002
596 #define ES_USER_PRESENT       0x00000004
597 #define ES_CONTINUOUS         0x80000000
598
599 /* The Win32 register context */
600
601 /* CONTEXT is the CPU-dependent context; it should be used        */
602 /* wherever a platform-specific context is needed (e.g. exception */
603 /* handling, Win32 register functions). */
604
605 /* CONTEXT86 is the i386-specific context; it should be used     */
606 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
607 /* Win16 register functions), so that this code can be compiled  */
608 /* on all platforms. */
609
610 #define SIZE_OF_80387_REGISTERS      80
611
612 typedef struct _FLOATING_SAVE_AREA
613 {
614     DWORD   ControlWord;
615     DWORD   StatusWord;
616     DWORD   TagWord;    
617     DWORD   ErrorOffset;
618     DWORD   ErrorSelector;
619     DWORD   DataOffset;
620     DWORD   DataSelector;    
621     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
622     DWORD   Cr0NpxState;
623 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
624
625 #define MAXIMUM_SUPPORTED_EXTENSION     512
626
627 typedef struct _CONTEXT86
628 {
629     DWORD   ContextFlags;
630
631     /* These are selected by CONTEXT_DEBUG_REGISTERS */
632     DWORD   Dr0;
633     DWORD   Dr1;
634     DWORD   Dr2;
635     DWORD   Dr3;
636     DWORD   Dr6;
637     DWORD   Dr7;
638
639     /* These are selected by CONTEXT_FLOATING_POINT */
640     FLOATING_SAVE_AREA FloatSave;
641
642     /* These are selected by CONTEXT_SEGMENTS */
643     DWORD   SegGs;
644     DWORD   SegFs;
645     DWORD   SegEs;
646     DWORD   SegDs;    
647
648     /* These are selected by CONTEXT_INTEGER */
649     DWORD   Edi;
650     DWORD   Esi;
651     DWORD   Ebx;
652     DWORD   Edx;    
653     DWORD   Ecx;
654     DWORD   Eax;
655
656     /* These are selected by CONTEXT_CONTROL */
657     DWORD   Ebp;    
658     DWORD   Eip;
659     DWORD   SegCs;
660     DWORD   EFlags;
661     DWORD   Esp;
662     DWORD   SegSs;
663
664     BYTE    ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
665 } CONTEXT86;
666
667 #define CONTEXT_X86       0x00010000
668 #define CONTEXT_i386      CONTEXT_X86
669 #define CONTEXT_i486      CONTEXT_X86
670
671 #define CONTEXT86_CONTROL   (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
672 #define CONTEXT86_INTEGER   (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
673 #define CONTEXT86_SEGMENTS  (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
674 #define CONTEXT86_FLOATING_POINT  (CONTEXT_i386 | 0x0008L) /* 387 state */
675 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
676 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
677
678 /* i386 context definitions */
679 #ifdef __i386__
680
681 #define CONTEXT_CONTROL         CONTEXT86_CONTROL
682 #define CONTEXT_INTEGER         CONTEXT86_INTEGER
683 #define CONTEXT_SEGMENTS        CONTEXT86_SEGMENTS
684 #define CONTEXT_FLOATING_POINT  CONTEXT86_FLOATING_POINT
685 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
686 #define CONTEXT_FULL            CONTEXT86_FULL
687
688 typedef CONTEXT86 CONTEXT;
689
690 #endif  /* __i386__ */
691
692 /* Alpha context definitions */
693 #ifdef _ALPHA_
694
695 #define CONTEXT_ALPHA   0x00020000
696  
697 #define CONTEXT_CONTROL         (CONTEXT_ALPHA | 0x00000001L)
698 #define CONTEXT_FLOATING_POINT  (CONTEXT_ALPHA | 0x00000002L)
699 #define CONTEXT_INTEGER         (CONTEXT_ALPHA | 0x00000004L)
700 #define CONTEXT_FULL  (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
701
702 typedef struct _CONTEXT
703 {
704     /* selected by CONTEXT_FLOATING_POINT */
705     ULONGLONG FltF0;
706     ULONGLONG FltF1;
707     ULONGLONG FltF2;
708     ULONGLONG FltF3;
709     ULONGLONG FltF4;
710     ULONGLONG FltF5;
711     ULONGLONG FltF6;
712     ULONGLONG FltF7;
713     ULONGLONG FltF8;
714     ULONGLONG FltF9;
715     ULONGLONG FltF10;
716     ULONGLONG FltF11;
717     ULONGLONG FltF12;
718     ULONGLONG FltF13;
719     ULONGLONG FltF14;
720     ULONGLONG FltF15;
721     ULONGLONG FltF16;
722     ULONGLONG FltF17;
723     ULONGLONG FltF18;
724     ULONGLONG FltF19;
725     ULONGLONG FltF20;
726     ULONGLONG FltF21;
727     ULONGLONG FltF22;
728     ULONGLONG FltF23;
729     ULONGLONG FltF24;
730     ULONGLONG FltF25;
731     ULONGLONG FltF26;
732     ULONGLONG FltF27;
733     ULONGLONG FltF28;
734     ULONGLONG FltF29;
735     ULONGLONG FltF30;
736     ULONGLONG FltF31;
737
738     /* selected by CONTEXT_INTEGER */
739     ULONGLONG IntV0;
740     ULONGLONG IntT0;
741     ULONGLONG IntT1;
742     ULONGLONG IntT2;
743     ULONGLONG IntT3;
744     ULONGLONG IntT4;
745     ULONGLONG IntT5;
746     ULONGLONG IntT6;
747     ULONGLONG IntT7;
748     ULONGLONG IntS0;
749     ULONGLONG IntS1;
750     ULONGLONG IntS2;
751     ULONGLONG IntS3;
752     ULONGLONG IntS4;
753     ULONGLONG IntS5;
754     ULONGLONG IntFp;
755     ULONGLONG IntA0;
756     ULONGLONG IntA1;
757     ULONGLONG IntA2;
758     ULONGLONG IntA3;
759     ULONGLONG IntA4;
760     ULONGLONG IntA5;
761     ULONGLONG IntT8;
762     ULONGLONG IntT9;
763     ULONGLONG IntT10;
764     ULONGLONG IntT11;
765     ULONGLONG IntRa;
766     ULONGLONG IntT12;
767     ULONGLONG IntAt;
768     ULONGLONG IntGp;
769     ULONGLONG IntSp;
770     ULONGLONG IntZero;
771
772     /* selected by CONTEXT_FLOATING_POINT */
773     ULONGLONG Fpcr;
774     ULONGLONG SoftFpcr;
775
776     /* selected by CONTEXT_CONTROL */
777     ULONGLONG Fir;
778     DWORD Psr;
779     DWORD ContextFlags;
780     DWORD Fill[4];
781 } CONTEXT;
782
783 #define _QUAD_PSR_OFFSET   HighSoftFpcr
784 #define _QUAD_FLAGS_OFFSET HighFir
785
786 #endif  /* _ALPHA_ */
787
788 /* Mips context definitions */
789 #ifdef _MIPS_
790
791 #define CONTEXT_R4000   0x00010000
792
793 #define CONTEXT_CONTROL         (CONTEXT_R4000 | 0x00000001)
794 #define CONTEXT_FLOATING_POINT  (CONTEXT_R4000 | 0x00000002)
795 #define CONTEXT_INTEGER         (CONTEXT_R4000 | 0x00000004)
796
797 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
798
799 typedef struct _CONTEXT
800 {
801     DWORD Argument[4];
802     /* These are selected by CONTEXT_FLOATING_POINT */
803     DWORD FltF0;
804     DWORD FltF1;
805     DWORD FltF2;
806     DWORD FltF3;
807     DWORD FltF4;
808     DWORD FltF5;
809     DWORD FltF6;
810     DWORD FltF7;
811     DWORD FltF8;
812     DWORD FltF9;
813     DWORD FltF10;
814     DWORD FltF11;
815     DWORD FltF12;
816     DWORD FltF13;
817     DWORD FltF14;
818     DWORD FltF15;
819     DWORD FltF16;
820     DWORD FltF17;
821     DWORD FltF18;
822     DWORD FltF19;
823     DWORD FltF20;
824     DWORD FltF21;
825     DWORD FltF22;
826     DWORD FltF23;
827     DWORD FltF24;
828     DWORD FltF25;
829     DWORD FltF26;
830     DWORD FltF27;
831     DWORD FltF28;
832     DWORD FltF29;
833     DWORD FltF30;
834     DWORD FltF31;
835
836     /* These are selected by CONTEXT_INTEGER */
837     DWORD IntZero;
838     DWORD IntAt;
839     DWORD IntV0;
840     DWORD IntV1;
841     DWORD IntA0;
842     DWORD IntA1;
843     DWORD IntA2;
844     DWORD IntA3;
845     DWORD IntT0;
846     DWORD IntT1;
847     DWORD IntT2;
848     DWORD IntT3;
849     DWORD IntT4;
850     DWORD IntT5;
851     DWORD IntT6;
852     DWORD IntT7;
853     DWORD IntS0;
854     DWORD IntS1;
855     DWORD IntS2;
856     DWORD IntS3;
857     DWORD IntS4;
858     DWORD IntS5;
859     DWORD IntS6;
860     DWORD IntS7;
861     DWORD IntT8;
862     DWORD IntT9;
863     DWORD IntK0;
864     DWORD IntK1;
865     DWORD IntGp;
866     DWORD IntSp;
867     DWORD IntS8;
868     DWORD IntRa;
869     DWORD IntLo;
870     DWORD IntHi;
871
872     /* These are selected by CONTEXT_FLOATING_POINT */
873     DWORD Fsr;
874
875     /* These are selected by CONTEXT_CONTROL */
876     DWORD Fir;
877     DWORD Psr;
878
879     DWORD ContextFlags;
880     DWORD Fill[2];
881 } CONTEXT;
882
883 #endif  /* _MIPS_ */
884
885 /* PowerPC context definitions */
886 #ifdef __PPC__
887
888 #define CONTEXT_CONTROL         0x0001
889 #define CONTEXT_FLOATING_POINT  0x0002
890 #define CONTEXT_INTEGER         0x0004
891 #define CONTEXT_DEBUG_REGISTERS 0x0008
892 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
893
894 typedef struct
895 {
896     /* These are selected by CONTEXT_FLOATING_POINT */
897     double Fpr0;
898     double Fpr1;
899     double Fpr2;
900     double Fpr3;
901     double Fpr4;
902     double Fpr5;
903     double Fpr6;
904     double Fpr7;
905     double Fpr8;
906     double Fpr9;
907     double Fpr10;
908     double Fpr11;
909     double Fpr12;
910     double Fpr13;
911     double Fpr14;
912     double Fpr15;
913     double Fpr16;
914     double Fpr17;
915     double Fpr18;
916     double Fpr19;
917     double Fpr20;
918     double Fpr21;
919     double Fpr22;
920     double Fpr23;
921     double Fpr24;
922     double Fpr25;
923     double Fpr26;
924     double Fpr27;
925     double Fpr28;
926     double Fpr29;
927     double Fpr30;
928     double Fpr31;
929     double Fpscr;
930
931     /* These are selected by CONTEXT_INTEGER */
932     DWORD Gpr0;
933     DWORD Gpr1;
934     DWORD Gpr2;
935     DWORD Gpr3;
936     DWORD Gpr4;
937     DWORD Gpr5;
938     DWORD Gpr6;
939     DWORD Gpr7;
940     DWORD Gpr8;
941     DWORD Gpr9;
942     DWORD Gpr10;
943     DWORD Gpr11;
944     DWORD Gpr12;
945     DWORD Gpr13;
946     DWORD Gpr14;
947     DWORD Gpr15;
948     DWORD Gpr16;
949     DWORD Gpr17;
950     DWORD Gpr18;
951     DWORD Gpr19;
952     DWORD Gpr20;
953     DWORD Gpr21;
954     DWORD Gpr22;
955     DWORD Gpr23;
956     DWORD Gpr24;
957     DWORD Gpr25;
958     DWORD Gpr26;
959     DWORD Gpr27;
960     DWORD Gpr28;
961     DWORD Gpr29;
962     DWORD Gpr30;
963     DWORD Gpr31;
964
965     DWORD Cr;
966     DWORD Xer;
967
968     /* These are selected by CONTEXT_CONTROL */
969     DWORD Msr;
970     DWORD Iar;
971     DWORD Lr;
972     DWORD Ctr;
973
974     DWORD ContextFlags;
975     DWORD Fill[3];
976
977     /* These are selected by CONTEXT_DEBUG_REGISTERS */
978     DWORD Dr0;
979     DWORD Dr1;
980     DWORD Dr2;
981     DWORD Dr3;
982     DWORD Dr4;
983     DWORD Dr5;
984     DWORD Dr6;
985     DWORD Dr7;
986 } CONTEXT;
987
988 typedef struct _STACK_FRAME_HEADER
989 {
990     DWORD BackChain;
991     DWORD GlueSaved1;
992     DWORD GlueSaved2;
993     DWORD Reserved1;
994     DWORD Spare1;
995     DWORD Spare2;
996
997     DWORD Parameter0;
998     DWORD Parameter1;
999     DWORD Parameter2;
1000     DWORD Parameter3;
1001     DWORD Parameter4;
1002     DWORD Parameter5;
1003     DWORD Parameter6;
1004     DWORD Parameter7;
1005 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
1006
1007 #endif  /* __PPC__ */
1008
1009 #ifdef __sparc__
1010
1011 /* 
1012  * FIXME:  
1013  *
1014  * There is no official CONTEXT structure defined for the SPARC 
1015  * architecture, so I just made one up.
1016  *
1017  * This structure is valid only for 32-bit SPARC architectures,
1018  * not for 64-bit SPARC.
1019  *
1020  * Note that this structure contains only the 'top-level' registers;
1021  * the rest of the register window chain is not visible.
1022  *
1023  * The layout follows the Solaris 'prgregset_t' structure.
1024  * 
1025  */ 
1026
1027 #define CONTEXT_SPARC            0x10000000
1028
1029 #define CONTEXT_CONTROL         (CONTEXT_SPARC | 0x00000001)
1030 #define CONTEXT_FLOATING_POINT  (CONTEXT_SPARC | 0x00000002)
1031 #define CONTEXT_INTEGER         (CONTEXT_SPARC | 0x00000004)
1032
1033 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1034
1035 typedef struct _CONTEXT
1036 {
1037     DWORD ContextFlags;
1038
1039     /* These are selected by CONTEXT_INTEGER */
1040     DWORD g0;
1041     DWORD g1;
1042     DWORD g2;
1043     DWORD g3;
1044     DWORD g4;
1045     DWORD g5;
1046     DWORD g6;
1047     DWORD g7;
1048     DWORD o0;
1049     DWORD o1;
1050     DWORD o2;
1051     DWORD o3;
1052     DWORD o4;
1053     DWORD o5;
1054     DWORD o6;
1055     DWORD o7;
1056     DWORD l0;
1057     DWORD l1;
1058     DWORD l2;
1059     DWORD l3;
1060     DWORD l4;
1061     DWORD l5;
1062     DWORD l6;
1063     DWORD l7;
1064     DWORD i0;
1065     DWORD i1;
1066     DWORD i2;
1067     DWORD i3;
1068     DWORD i4;
1069     DWORD i5;
1070     DWORD i6;
1071     DWORD i7;
1072
1073     /* These are selected by CONTEXT_CONTROL */
1074     DWORD psr;
1075     DWORD pc;
1076     DWORD npc;
1077     DWORD y;
1078     DWORD wim;
1079     DWORD tbr;
1080
1081     /* FIXME: floating point registers missing */
1082
1083 } CONTEXT;
1084
1085 #endif  /* __sparc__ */
1086
1087 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1088 #error You need to define a CONTEXT for your CPU
1089 #endif
1090
1091 typedef CONTEXT *PCONTEXT;
1092
1093 #ifdef __WINE__
1094
1095 /* Macros for easier access to i386 context registers */
1096
1097 #define AX_reg(context)      (*(WORD*)&(context)->Eax)
1098 #define BX_reg(context)      (*(WORD*)&(context)->Ebx)
1099 #define CX_reg(context)      (*(WORD*)&(context)->Ecx)
1100 #define DX_reg(context)      (*(WORD*)&(context)->Edx)
1101 #define SI_reg(context)      (*(WORD*)&(context)->Esi)
1102 #define DI_reg(context)      (*(WORD*)&(context)->Edi)
1103 #define BP_reg(context)      (*(WORD*)&(context)->Ebp)
1104
1105 #define AL_reg(context)      (*(BYTE*)&(context)->Eax)
1106 #define AH_reg(context)      (*((BYTE*)&(context)->Eax + 1))
1107 #define BL_reg(context)      (*(BYTE*)&(context)->Ebx)
1108 #define BH_reg(context)      (*((BYTE*)&(context)->Ebx + 1))
1109 #define CL_reg(context)      (*(BYTE*)&(context)->Ecx)
1110 #define CH_reg(context)      (*((BYTE*)&(context)->Ecx + 1))
1111 #define DL_reg(context)      (*(BYTE*)&(context)->Edx)
1112 #define DH_reg(context)      (*((BYTE*)&(context)->Edx + 1))
1113
1114 #define SET_CFLAG(context)   ((context)->EFlags |= 0x0001)
1115 #define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
1116 #define SET_ZFLAG(context)   ((context)->EFlags |= 0x0040)
1117 #define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
1118 #define ISV86(context)       ((context)->EFlags & 0x00020000)
1119
1120
1121 /* Macros to retrieve the current context */
1122
1123 #ifdef NEED_UNDERSCORE_PREFIX
1124 # define __ASM_NAME(name) "_" name
1125 #else
1126 # define __ASM_NAME(name) name
1127 #endif
1128
1129 #ifdef NEED_TYPE_IN_DEF
1130 # define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
1131 #else
1132 # define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
1133 #endif
1134
1135 #ifdef __GNUC__
1136 # define __ASM_GLOBAL_FUNC(name,code) \
1137       __asm__( ".align 4\n\t" \
1138                ".globl " __ASM_NAME(#name) "\n\t" \
1139                __ASM_FUNC(#name) "\n" \
1140                __ASM_NAME(#name) ":\n\t" \
1141                code );
1142 #else  /* __GNUC__ */
1143 # define __ASM_GLOBAL_FUNC(name,code) \
1144       void __asm_dummy_##name(void) { \
1145           asm( ".align 4\n\t" \
1146                ".globl " __ASM_NAME(#name) "\n\t" \
1147                __ASM_FUNC(#name) "\n" \
1148                __ASM_NAME(#name) ":\n\t" \
1149                code ); \
1150       }
1151 #endif  /* __GNUC__ */
1152
1153 #ifdef __i386__
1154
1155 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
1156     __ASM_GLOBAL_FUNC( name, \
1157                        "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
1158                        ".long " __ASM_NAME(#fn) "\n\t" \
1159                        ".byte " #args ", " #args )
1160 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1161   extern void WINAPI name(void); \
1162   _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
1163 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1164   extern void WINAPI name( t1 a1 ); \
1165   _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
1166 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1167   extern void WINAPI name( t1 a1, t2 a2 ); \
1168   _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
1169 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1170   extern void WINAPI name( t1 a1, t2 a2, t3 a3 ); \
1171   _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
1172 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1173   extern void WINAPI name( t1 a1, t2 a2, t3 a3, t4 a4 ); \
1174   _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
1175
1176 #endif  /* __i386__ */
1177
1178 #ifdef __sparc__
1179 /* FIXME: use getcontext() to retrieve full context */
1180 #define _GET_CONTEXT \
1181     CONTEXT context;   \
1182     do { memset(&context, 0, sizeof(CONTEXT));            \
1183          context.ContextFlags = CONTEXT_CONTROL;          \
1184          context.pc = (DWORD)__builtin_return_address(0); \
1185        } while (0)
1186
1187 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1188   void WINAPI name ( void ) \
1189   { _GET_CONTEXT; fn( &context ); }
1190 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1191   void WINAPI name ( t1 a1 ) \
1192   { _GET_CONTEXT; fn( a1, &context ); }
1193 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1194   void WINAPI name ( t1 a1, t2 a2 ) \
1195   { _GET_CONTEXT; fn( a1, a2, &context ); }
1196 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1197   void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1198   { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1199 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1200   void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1201   { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1202
1203 #endif /* __sparc__ */
1204
1205 #ifdef __PPC__
1206
1207 /* FIXME: use getcontext() to retrieve full context */
1208 #define _GET_CONTEXT \
1209     CONTEXT context;   \
1210     do { memset(&context, 0, sizeof(CONTEXT));            \
1211          context.ContextFlags = CONTEXT_CONTROL;          \
1212        } while (0)
1213
1214 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1215   void WINAPI name ( void ) \
1216   { _GET_CONTEXT; fn( &context ); }
1217 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1218   void WINAPI name ( t1 a1 ) \
1219   { _GET_CONTEXT; fn( a1, &context ); }
1220 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1221   void WINAPI name ( t1 a1, t2 a2 ) \
1222   { _GET_CONTEXT; fn( a1, a2, &context ); }
1223 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1224   void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1225   { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1226 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1227   void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1228   { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1229
1230 #endif /* __PPC__ */
1231
1232
1233 #ifndef DEFINE_REGS_ENTRYPOINT_0
1234 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
1235 #endif
1236
1237 /* Constructor functions */
1238
1239 #ifdef __GNUC__
1240 # define DECL_GLOBAL_CONSTRUCTOR(func) \
1241     static void func(void) __attribute__((constructor)); \
1242     static void func(void)
1243 #else  /* __GNUC__ */
1244 # ifdef __i386__
1245 #  define DECL_GLOBAL_CONSTRUCTOR(func) \
1246     static void __dummy_init_##func(void) { \
1247         asm(".section .init,\"ax\"\n\t" \
1248             "call " #func "\n\t" \
1249             ".previous"); } \
1250     static void func(void)
1251 # else  /* __i386__ */
1252 #  error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
1253 # endif
1254 #endif  /* __GNUC__ */
1255
1256 /* Segment register access */
1257
1258 #ifdef __i386__
1259 # ifdef __GNUC__
1260 #  define __DEFINE_GET_SEG(seg) \
1261     extern inline unsigned short __get_##seg(void) \
1262     { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
1263 #  define __DEFINE_SET_SEG(seg) \
1264     extern inline void __set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
1265 # else  /* __GNUC__ */
1266 #  define __DEFINE_GET_SEG(seg) extern unsigned short __get_##seg(void);
1267 #  define __DEFINE_SET_SEG(seg) extern void __set_##seg(unsigned int);
1268 # endif /* __GNUC__ */
1269 #else  /* __i386__ */
1270 # define __DEFINE_GET_SEG(seg) inline static unsigned short __get_##seg(void) { return 0; }
1271 # define __DEFINE_SET_SEG(seg) /* nothing */
1272 #endif  /* __i386__ */
1273
1274 __DEFINE_GET_SEG(cs)
1275 __DEFINE_GET_SEG(ds)
1276 __DEFINE_GET_SEG(es)
1277 __DEFINE_GET_SEG(fs)
1278 __DEFINE_GET_SEG(gs)
1279 __DEFINE_GET_SEG(ss)
1280 __DEFINE_SET_SEG(fs)
1281 __DEFINE_SET_SEG(gs)
1282 #undef __DEFINE_GET_SEG
1283 #undef __DEFINE_SET_SEG
1284
1285 #endif  /* __WINE__ */
1286
1287
1288
1289 /*
1290  * Language IDs
1291  */
1292
1293 #define MAKELCID(l, s)          (MAKELONG(l, s))
1294
1295 #define MAKELANGID(p, s)        ((((WORD)(s))<<10) | (WORD)(p))
1296 #define PRIMARYLANGID(l)        ((WORD)(l) & 0x3ff)
1297 #define SUBLANGID(l)            ((WORD)(l) >> 10)
1298
1299 #define LANGIDFROMLCID(lcid)    ((WORD)(lcid))
1300 #define SORTIDFROMLCID(lcid)    ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1301
1302 #define LANG_SYSTEM_DEFAULT     (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1303 #define LANG_USER_DEFAULT       (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1304 #define LOCALE_SYSTEM_DEFAULT   (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1305 #define LOCALE_USER_DEFAULT     (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT)) 
1306 #define LOCALE_NEUTRAL          (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1307
1308 /* FIXME: are the symbolic names correct for LIDs:  0x17, 0x20, 0x28,
1309  *        0x2a, 0x2b, 0x2c, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
1310  *        0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3e, 0x3f, 0x41, 0x43, 0x44,
1311  *        0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
1312  *        0x4f, 0x57
1313  */
1314 #define LANG_NEUTRAL                     0x00
1315 #define LANG_AFRIKAANS                   0x36
1316 #define LANG_ALBANIAN                    0x1c
1317 #define LANG_ARABIC                      0x01
1318 #define LANG_ARMENIAN                    0x2b
1319 #define LANG_ASSAMESE                    0x4d
1320 #define LANG_AZERI                       0x2c
1321 #define LANG_BASQUE                      0x2d
1322 #define LANG_BENGALI                     0x45
1323 #define LANG_BULGARIAN                   0x02
1324 #define LANG_BYELORUSSIAN                0x23
1325 #define LANG_CATALAN                     0x03
1326 #define LANG_CHINESE                     0x04
1327 #define LANG_SERBO_CROATIAN              0x1a
1328 #define LANG_CROATIAN     LANG_SERBO_CROATIAN
1329 #define LANG_SERBIAN      LANG_SERBO_CROATIAN
1330 #define LANG_CZECH                       0x05
1331 #define LANG_DANISH                      0x06
1332 #define LANG_DUTCH                       0x13
1333 #define LANG_ENGLISH                     0x09
1334 #define LANG_ESTONIAN                    0x25
1335 #define LANG_FAEROESE                    0x38
1336 #define LANG_FARSI                       0x29
1337 #define LANG_FINNISH                     0x0b
1338 #define LANG_FRENCH                      0x0c
1339 #define LANG_GAELIC                      0x3c
1340 #define LANG_GEORGIAN                    0x37
1341 #define LANG_GERMAN                      0x07
1342 #define LANG_GREEK                       0x08
1343 #define LANG_GUJARATI                    0x47
1344 #define LANG_HEBREW                      0x0D
1345 #define LANG_HINDI                       0x39
1346 #define LANG_HUNGARIAN                   0x0e
1347 #define LANG_ICELANDIC                   0x0f
1348 #define LANG_INDONESIAN                  0x21
1349 #define LANG_ITALIAN                     0x10
1350 #define LANG_JAPANESE                    0x11
1351 #define LANG_KANNADA                     0x4b
1352 #define LANG_KAZAKH                      0x3f
1353 #define LANG_KONKANI                     0x57
1354 #define LANG_KOREAN                      0x12
1355 #define LANG_LATVIAN                     0x26
1356 #define LANG_LITHUANIAN                  0x27
1357 #define LANG_MACEDONIAN                  0x2f
1358 #define LANG_MALAY                       0x3e
1359 #define LANG_MALAYALAM                   0x4c
1360 #define LANG_MALTESE                     0x3a
1361 #define LANG_MAORI                       0x28
1362 #define LANG_MARATHI                     0x4e
1363 #define LANG_NORWEGIAN                   0x14
1364 #define LANG_ORIYA                       0x48
1365 #define LANG_POLISH                      0x15
1366 #define LANG_PORTUGUESE                  0x16
1367 #define LANG_PUNJABI                     0x46
1368 #define LANG_RHAETO_ROMANCE              0x17
1369 #define LANG_ROMANIAN                    0x18
1370 #define LANG_RUSSIAN                     0x19
1371 #define LANG_SAAMI                       0x3b
1372 #define LANG_SANSKRIT                    0x4f
1373 #define LANG_SLOVAK                      0x1b
1374 #define LANG_SLOVENIAN                   0x24
1375 #define LANG_SORBIAN                     0x2e
1376 #define LANG_SPANISH                     0x0a
1377 #define LANG_SUTU                        0x30
1378 #define LANG_SWAHILI                     0x41
1379 #define LANG_SWEDISH                     0x1d
1380 #define LANG_TAMIL                       0x49
1381 #define LANG_TATAR                       0x44
1382 #define LANG_TELUGU                      0x4a
1383 #define LANG_THAI                        0x1e
1384 #define LANG_TSONGA                      0x31
1385 #define LANG_TSWANA                      0x32
1386 #define LANG_TURKISH                     0x1f
1387 #define LANG_UKRAINIAN                   0x22
1388 #define LANG_URDU                        0x20
1389 #define LANG_UZBEK                       0x43
1390 #define LANG_VENDA                       0x33
1391 #define LANG_VIETNAMESE                  0x2a
1392 #define LANG_XHOSA                       0x34
1393 #define LANG_ZULU                        0x35
1394 /* non standard; keep the number high enough (but < 0xff) */
1395 #define LANG_ESPERANTO                   0x8f
1396 #define LANG_WALON                       0x90
1397 #define LANG_CORNISH                     0x91
1398 #define LANG_WELSH                       0x92
1399 #define LANG_BRETON                      0x93
1400
1401 /* Sublanguage definitions */
1402 #define SUBLANG_NEUTRAL                  0x00    /* language neutral */
1403 #define SUBLANG_DEFAULT                  0x01    /* user default */
1404 #define SUBLANG_SYS_DEFAULT              0x02    /* system default */
1405
1406 #define SUBLANG_ARABIC                   0x01
1407 #define SUBLANG_ARABIC_SAUDI_ARABIA      0x01
1408 #define SUBLANG_ARABIC_IRAQ              0x02
1409 #define SUBLANG_ARABIC_EGYPT             0x03
1410 #define SUBLANG_ARABIC_LIBYA             0x04
1411 #define SUBLANG_ARABIC_ALGERIA           0x05
1412 #define SUBLANG_ARABIC_MOROCCO           0x06
1413 #define SUBLANG_ARABIC_TUNISIA           0x07
1414 #define SUBLANG_ARABIC_OMAN              0x08
1415 #define SUBLANG_ARABIC_YEMEN             0x09
1416 #define SUBLANG_ARABIC_SYRIA             0x0a
1417 #define SUBLANG_ARABIC_JORDAN            0x0b
1418 #define SUBLANG_ARABIC_LEBANON           0x0c
1419 #define SUBLANG_ARABIC_KUWAIT            0x0d
1420 #define SUBLANG_ARABIC_UAE               0x0e
1421 #define SUBLANG_ARABIC_BAHRAIN           0x0f
1422 #define SUBLANG_ARABIC_QATAR             0x10
1423 #define SUBLANG_CHINESE_TRADITIONAL      0x01
1424 #define SUBLANG_CHINESE_SIMPLIFIED       0x02
1425 #define SUBLANG_CHINESE_HONGKONG         0x03
1426 #define SUBLANG_CHINESE_SINGAPORE        0x04
1427 #define SUBLANG_CHINESE_MACAU            0x05
1428 #define SUBLANG_DUTCH                    0x01
1429 #define SUBLANG_DUTCH_BELGIAN            0x02
1430 #define SUBLANG_DUTCH_SURINAM            0x03
1431 #define SUBLANG_ENGLISH_US               0x01
1432 #define SUBLANG_ENGLISH_UK               0x02
1433 #define SUBLANG_ENGLISH_AUS              0x03
1434 #define SUBLANG_ENGLISH_CAN              0x04
1435 #define SUBLANG_ENGLISH_NZ               0x05
1436 #define SUBLANG_ENGLISH_EIRE             0x06
1437 #define SUBLANG_ENGLISH_SAFRICA          0x07
1438 #define SUBLANG_ENGLISH_JAMAICA          0x08
1439 #define SUBLANG_ENGLISH_CARRIBEAN        0x09
1440 #define SUBLANG_ENGLISH_BELIZE           0x0a
1441 #define SUBLANG_ENGLISH_TRINIDAD         0x0b
1442 #define SUBLANG_ENGLISH_ZIMBABWE         0x0c
1443 #define SUBLANG_ENGLISH_PHILIPPINES      0x0d
1444 #define SUBLANG_FRENCH                   0x01
1445 #define SUBLANG_FRENCH_BELGIAN           0x02
1446 #define SUBLANG_FRENCH_CANADIAN          0x03
1447 #define SUBLANG_FRENCH_SWISS             0x04
1448 #define SUBLANG_FRENCH_LUXEMBOURG        0x05
1449 #define SUBLANG_FRENCH_MONACO            0x06
1450 #define SUBLANG_GERMAN                   0x01
1451 #define SUBLANG_GERMAN_SWISS             0x02
1452 #define SUBLANG_GERMAN_AUSTRIAN          0x03
1453 #define SUBLANG_GERMAN_LUXEMBOURG        0x04
1454 #define SUBLANG_GERMAN_LIECHTENSTEIN     0x05
1455 #define SUBLANG_ITALIAN                  0x01
1456 #define SUBLANG_ITALIAN_SWISS            0x02
1457 #define SUBLANG_KOREAN                   0x01
1458 #define SUBLANG_KOREAN_JOHAB             0x02
1459 #define SUBLANG_NORWEGIAN_BOKMAL         0x01
1460 #define SUBLANG_NORWEGIAN_NYNORSK        0x02
1461 #define SUBLANG_PORTUGUESE               0x02
1462 #define SUBLANG_PORTUGUESE_BRAZILIAN     0x01
1463 #define SUBLANG_SPANISH                  0x01
1464 #define SUBLANG_SPANISH_MEXICAN          0x02
1465 #define SUBLANG_SPANISH_MODERN           0x03
1466 #define SUBLANG_SPANISH_GUATEMALA        0x04
1467 #define SUBLANG_SPANISH_COSTARICA        0x05
1468 #define SUBLANG_SPANISH_PANAMA           0x06
1469 #define SUBLANG_SPANISH_DOMINICAN        0x07
1470 #define SUBLANG_SPANISH_VENEZUELA        0x08
1471 #define SUBLANG_SPANISH_COLOMBIA         0x09
1472 #define SUBLANG_SPANISH_PERU             0x0a
1473 #define SUBLANG_SPANISH_ARGENTINA        0x0b
1474 #define SUBLANG_SPANISH_ECUADOR          0x0c
1475 #define SUBLANG_SPANISH_CHILE            0x0d
1476 #define SUBLANG_SPANISH_URUGUAY          0x0e
1477 #define SUBLANG_SPANISH_PARAGUAY         0x0f
1478 #define SUBLANG_SPANISH_BOLIVIA          0x10
1479 #define SUBLANG_SPANISH_EL_SALVADOR      0x11
1480 #define SUBLANG_SPANISH_HONDURAS         0x12
1481 #define SUBLANG_SPANISH_NICARAGUA        0x13
1482 #define SUBLANG_SPANISH_PUERTO_RICO      0x14
1483 /* FIXME: I don't know the symbolic names for those */
1484 #define SUBLANG_ROMANIAN                 0x01
1485 #define SUBLANG_ROMANIAN_MOLDAVIA        0x02
1486 #define SUBLANG_RUSSIAN                  0x01
1487 #define SUBLANG_RUSSIAN_MOLDAVIA         0x02
1488 #define SUBLANG_CROATIAN                 0x01
1489 #define SUBLANG_SERBIAN                  0x02
1490 #define SUBLANG_SERBIAN_LATIN            0x03
1491 #define SUBLANG_SWEDISH                  0x01
1492 #define SUBLANG_SWEDISH_FINLAND          0x02
1493 #define SUBLANG_LITHUANIAN               0x01
1494 #define SUBLANG_LITHUANIAN_CLASSIC       0x02
1495 #define SUBLANG_AZERI                    0x01
1496 #define SUBLANG_AZERI_CYRILLIC           0x02
1497 #define SUBLANG_GAELIC                   0x01
1498 #define SUBLANG_GAELIC_SCOTTISH          0x02
1499 #define SUBLANG_GAELIC_MANX              0x03
1500 #define SUBLANG_MALAY                    0x01
1501 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM  0x02
1502 #define SUBLANG_UZBEK                    0x01
1503 #define SUBLANG_UZBEK_CYRILLIC           0x02
1504 #define SUBLANG_URDU_PAKISTAN            0x01
1505
1506
1507
1508 /*
1509  * Sort definitions
1510  */
1511
1512 #define SORT_DEFAULT                     0x0
1513 #define SORT_JAPANESE_XJIS               0x0
1514 #define SORT_JAPANESE_UNICODE            0x1
1515 #define SORT_CHINESE_BIG5                0x0
1516 #define SORT_CHINESE_UNICODE             0x1
1517 #define SORT_KOREAN_KSC                  0x0
1518 #define SORT_KOREAN_UNICODE              0x1
1519
1520
1521
1522 /*
1523  * Definitions for IsTextUnicode()
1524  */
1525
1526 #define IS_TEXT_UNICODE_ASCII16            0x0001
1527 #define IS_TEXT_UNICODE_STATISTICS         0x0002
1528 #define IS_TEXT_UNICODE_CONTROLS           0x0004
1529 #define IS_TEXT_UNICODE_SIGNATURE          0x0008
1530 #define IS_TEXT_UNICODE_UNICODE_MASK       0x000F
1531 #define IS_TEXT_UNICODE_REVERSE_ASCII16    0x0010
1532 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1533 #define IS_TEXT_UNICODE_REVERSE_CONTROLS   0x0040
1534 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE  0x0080
1535 #define IS_TEXT_UNICODE_REVERSE_MASK       0x00F0
1536 #define IS_TEXT_UNICODE_ILLEGAL_CHARS      0x0100
1537 #define IS_TEXT_UNICODE_ODD_LENGTH         0x0200
1538 #define IS_TEXT_UNICODE_DBCS_LEADBYTE      0x0400
1539 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK   0x0F00
1540 #define IS_TEXT_UNICODE_NULL_BYTES         0x1000
1541 #define IS_TEXT_UNICODE_NOT_ASCII_MASK     0xF000
1542
1543
1544
1545 /*
1546  * Exception codes
1547  */
1548
1549 #define STATUS_SUCCESS                   0x00000000
1550 #define STATUS_WAIT_0                    0x00000000
1551 #define STATUS_ABANDONED_WAIT_0          0x00000080
1552 #define STATUS_ABANDONED_WAIT_63         0x000000BF
1553 #define STATUS_USER_APC                  0x000000C0
1554 #define STATUS_ALERTED                   0x00000101
1555 #define STATUS_TIMEOUT                   0x00000102
1556 #define STATUS_PENDING                   0x00000103
1557 #define STATUS_REPARSE                   0x00000104
1558 #define STATUS_MORE_ENTRIES              0x00000105
1559 #define STATUS_NOT_ALL_ASSIGNED          0x00000106
1560 #define STATUS_SOME_NOT_MAPPED           0x00000107
1561 #define STATUS_OPLOCK_BREAK_IN_PROGRESS  0x00000108
1562 #define STATUS_VOLUME_MOUNTED            0x00000109
1563 #define STATUS_RXACT_COMMITTED           0x0000010A
1564 #define STATUS_NOTIFY_CLEANUP            0x0000010B
1565 #define STATUS_NOTIFY_ENUM_DIR           0x0000010C
1566 #define STATUS_NO_QUOTAS_FOR_ACCOUNT     0x0000010D
1567 #define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED 0x0000010E
1568 #define STATUS_PAGE_FAULT_TRANSITION     0x00000110
1569 #define STATUS_PAGE_FAULT_DEMAND_ZERO    0x00000111
1570 #define STATUS_PAGE_FAULT_COPY_ON_WRITE  0x00000112
1571 #define STATUS_PAGE_FAULT_GUARD_PAGE     0x00000113
1572 #define STATUS_PAGE_FAULT_PAGING_FILE    0x00000114
1573 #define STATUS_CACHE_PAGE_LOCKED         0x00000115
1574 #define STATUS_CRASH_DUMP                0x00000116
1575 #define STATUS_BUFFER_ALL_ZEROS          0x00000117
1576 #define STATUS_REPARSE_OBJECT            0x00000118
1577
1578 #define STATUS_THREAD_WAS_SUSPENDED      0x40000001
1579 #define STATUS_WORKING_SET_LIMIT_RANGE   0x40000002
1580 #define STATUS_IMAGE_NOT_AT_BASE         0x40000003
1581 #define STATUS_RXACT_STATE_CREATED       0x40000004
1582 #define STATUS_SEGMENT_NOTIFICATION      0x40000005
1583 #define STATUS_LOCAL_USER_SESSION_KEY    0x40000006
1584 #define STATUS_BAD_CURRENT_DIRECTORY     0x40000007
1585 #define STATUS_SERIAL_MORE_WRITES        0x40000008
1586 #define STATUS_REGISTRY_RECOVERED        0x40000009
1587 #define STATUS_FT_READ_RECOVERY_FROM_BACKUP 0x4000000A
1588 #define STATUS_FT_WRITE_RECOVERY         0x4000000B
1589 #define STATUS_SERIAL_COUNTER_TIMEOUT    0x4000000C
1590 #define STATUS_NULL_LM_PASSWORD          0x4000000D
1591 #define STATUS_IMAGE_MACHINE_TYPE_MISMATCH 0x4000000E
1592 #define STATUS_RECEIVE_PARTIAL           0x4000000F
1593 #define STATUS_RECEIVE_EXPEDITED         0x40000010
1594 #define STATUS_RECEIVE_PARTIAL_EXPEDITED 0x40000011
1595 #define STATUS_EVENT_DONE                0x40000012
1596 #define STATUS_EVENT_PENDING             0x40000013
1597 #define STATUS_CHECKING_FILE_SYSTEM      0x40000014
1598 #define STATUS_FATAL_APP_EXIT            0x40000015
1599 #define STATUS_PREDEFINED_HANDLE         0x40000016
1600 #define STATUS_WAS_UNLOCKED              0x40000017
1601 #define STATUS_SERVICE_NOTIFICATION      0x40000018
1602 #define STATUS_WAS_LOCKED                0x40000019
1603 #define STATUS_LOG_HARD_ERROR            0x4000001A
1604 #define STATUS_ALREADY_WIN32             0x4000001B
1605 #define STATUS_WX86_UNSIMULATE           0x4000001C
1606 #define STATUS_WX86_CONTINUE             0x4000001D
1607 #define STATUS_WX86_SINGLE_STEP          0x4000001E
1608 #define STATUS_WX86_BREAKPOINT           0x4000001F
1609 #define STATUS_WX86_EXCEPTION_CONTINUE   0x40000020
1610 #define STATUS_WX86_EXCEPTION_LASTCHANCE 0x40000021
1611 #define STATUS_WX86_EXCEPTION_CHAIN      0x40000022
1612 #define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE 0x40000023
1613 #define STATUS_NO_YIELD_PERFORMED        0x40000024
1614 #define STATUS_TIMER_RESUME_IGNORED      0x40000025
1615         
1616 #define STATUS_GUARD_PAGE_VIOLATION      0x80000001    
1617 #define STATUS_DATATYPE_MISALIGNMENT     0x80000002
1618 #define STATUS_BREAKPOINT                0x80000003
1619 #define STATUS_SINGLE_STEP               0x80000004
1620 #define STATUS_BUFFER_OVERFLOW           0x80000005
1621 #define STATUS_NO_MORE_FILES             0x80000006
1622 #define STATUS_WAKE_SYSTEM_DEBUGGER      0x80000007
1623
1624 #define STATUS_HANDLES_CLOSED            0x8000000A
1625 #define STATUS_NO_INHERITANCE            0x8000000B
1626 #define STATUS_GUID_SUBSTITUTION_MADE    0x8000000C
1627 #define STATUS_PARTIAL_COPY              0x8000000D
1628 #define STATUS_DEVICE_PAPER_EMPTY        0x8000000E
1629 #define STATUS_DEVICE_POWERED_OFF        0x8000000F
1630 #define STATUS_DEVICE_OFF_LINE           0x80000010
1631 #define STATUS_DEVICE_BUSY               0x80000011
1632 #define STATUS_NO_MORE_EAS               0x80000012
1633 #define STATUS_INVALID_EA_NAME           0x80000013
1634 #define STATUS_EA_LIST_INCONSISTENT      0x80000014
1635 #define STATUS_INVALID_EA_FLAG           0x80000015
1636 #define STATUS_VERIFY_REQUIRED           0x80000016
1637 #define STATUS_EXTRANEOUS_INFORMATION    0x80000017
1638 #define STATUS_RXACT_COMMIT_NECESSARY    0x80000018
1639 #define STATUS_NO_MORE_ENTRIES           0x8000001A
1640 #define STATUS_FILEMARK_DETECTED         0x8000001B
1641 #define STATUS_MEDIA_CHANGED             0x8000001C
1642 #define STATUS_BUS_RESET                 0x8000001D
1643 #define STATUS_END_OF_MEDIA              0x8000001E
1644 #define STATUS_BEGINNING_OF_MEDIA        0x8000001F
1645 #define STATUS_MEDIA_CHECK               0x80000020
1646 #define STATUS_SETMARK_DETECTED          0x80000021
1647 #define STATUS_NO_DATA_DETECTED          0x80000022
1648 #define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
1649 #define STATUS_SERVER_HAS_OPEN_HANDLES   0x80000024
1650 #define STATUS_ALREADY_DISCONNECTED      0x80000025
1651 #define STATUS_LONGJUMP                  0x80000026
1652
1653 #define STATUS_UNSUCCESSFUL              0xC0000001
1654 #define STATUS_NOT_IMPLEMENTED           0xC0000002
1655 #define STATUS_INVALID_INFO_CLASS        0xC0000003
1656 #define STATUS_INFO_LENGTH_MISMATCH      0xC0000004
1657 #define STATUS_ACCESS_VIOLATION          0xC0000005
1658 #define STATUS_IN_PAGE_ERROR             0xC0000006
1659 #define STATUS_PAGEFILE_QUOTA            0xC0000007
1660 #define STATUS_INVALID_HANDLE            0xC0000008
1661 #define STATUS_BAD_INITIAL_STACK         0xC0000009
1662 #define STATUS_BAD_INITIAL_PC            0xC000000A
1663 #define STATUS_INVALID_CID               0xC000000B
1664 #define STATUS_TIMER_NOT_CANCELED        0xC000000C
1665 #define STATUS_INVALID_PARAMETER         0xC000000D
1666 #define STATUS_NO_SUCH_DEVICE            0xC000000E
1667 #define STATUS_NO_SUCH_FILE              0xC000000F
1668 #define STATUS_INVALID_DEVICE_REQUEST    0xC0000010
1669 #define STATUS_END_OF_FILE               0xC0000011
1670 #define STATUS_WRONG_VOLUME              0xC0000012
1671 #define STATUS_NO_MEDIA_IN_DEVICE        0xC0000013
1672 #define STATUS_UNRECOGNIZED_MEDIA        0xC0000014
1673 #define STATUS_NONEXISTENT_SECTOR        0xC0000015
1674 #define STATUS_MORE_PROCESSING_REQUIRED  0xC0000016
1675 #define STATUS_NO_MEMORY                 0xC0000017
1676 #define STATUS_CONFLICTING_ADDRESSES     0xC0000018
1677 #define STATUS_NOT_MAPPED_VIEW           0xC0000019
1678 #define STATUS_UNABLE_TO_FREE_VM         0xC000001A
1679 #define STATUS_UNABLE_TO_DELETE_SECTION  0xC000001B
1680 #define STATUS_INVALID_SYSTEM_SERVICE    0xC000001C
1681 #define STATUS_ILLEGAL_INSTRUCTION       0xC000001D
1682 #define STATUS_INVALID_LOCK_SEQUENCE     0xC000001E
1683 #define STATUS_INVALID_VIEW_SIZE         0xC000001F
1684 #define STATUS_INVALID_FILE_FOR_SECTION  0xC0000020
1685 #define STATUS_ALREADY_COMMITTED         0xC0000021
1686 #define STATUS_ACCESS_DENIED             0xC0000022
1687 #define STATUS_BUFFER_TOO_SMALL          0xC0000023
1688 #define STATUS_OBJECT_TYPE_MISMATCH      0xC0000024
1689 #define STATUS_NONCONTINUABLE_EXCEPTION  0xC0000025
1690 #define STATUS_INVALID_DISPOSITION       0xC0000026
1691 #define STATUS_UNWIND                    0xC0000027
1692 #define STATUS_BAD_STACK                 0xC0000028
1693 #define STATUS_INVALID_UNWIND_TARGET     0xC0000029
1694 #define STATUS_NOT_LOCKED                0xC000002A
1695 #define STATUS_PARITY_ERROR              0xC000002B
1696 #define STATUS_UNABLE_TO_DECOMMIT_VM     0xC000002C
1697 #define STATUS_NOT_COMMITTED             0xC000002D
1698 #define STATUS_INVALID_PORT_ATTRIBUTES   0xC000002E
1699 #define STATUS_PORT_MESSAGE_TOO_LONG     0xC000002F
1700 #define STATUS_INVALID_PARAMETER_MIX     0xC0000030
1701 #define STATUS_INVALID_QUOTA_LOWER       0xC0000031
1702 #define STATUS_DISK_CORRUPT_ERROR        0xC0000032
1703 #define STATUS_OBJECT_NAME_INVALID       0xC0000033
1704 #define STATUS_OBJECT_NAME_NOT_FOUND     0xC0000034
1705 #define STATUS_OBJECT_NAME_COLLISION     0xC0000035
1706 #define STATUS_PORT_DISCONNECTED         0xC0000037
1707 #define STATUS_DEVICE_ALREADY_ATTACHED   0xC0000038
1708 #define STATUS_OBJECT_PATH_INVALID       0xC0000039
1709 #define STATUS_OBJECT_PATH_NOT_FOUND     0xC000003A
1710 #define STATUS_PATH_SYNTAX_BAD           0xC000003B
1711 #define STATUS_DATA_OVERRUN              0xC000003C
1712 #define STATUS_DATA_LATE_ERROR           0xC000003D
1713 #define STATUS_DATA_ERROR                0xC000003E
1714 #define STATUS_CRC_ERROR                 0xC000003F
1715 #define STATUS_SECTION_TOO_BIG           0xC0000040
1716 #define STATUS_PORT_CONNECTION_REFUSED   0xC0000041
1717 #define STATUS_INVALID_PORT_HANDLE       0xC0000042
1718 #define STATUS_SHARING_VIOLATION         0xC0000043
1719 #define STATUS_QUOTA_EXCEEDED            0xC0000044
1720 #define STATUS_INVALID_PAGE_PROTECTION   0xC0000045
1721 #define STATUS_MUTANT_NOT_OWNED          0xC0000046
1722 #define STATUS_SEMAPHORE_LIMIT_EXCEEDED  0xC0000047
1723 #define STATUS_PORT_ALREADY_SET          0xC0000048
1724 #define STATUS_SECTION_NOT_IMAGE         0xC0000049
1725 #define STATUS_SUSPEND_COUNT_EXCEEDED    0xC000004A
1726 #define STATUS_THREAD_IS_TERMINATING     0xC000004B
1727 #define STATUS_BAD_WORKING_SET_LIMIT     0xC000004C
1728 #define STATUS_INCOMPATIBLE_FILE_MAP     0xC000004D
1729 #define STATUS_SECTION_PROTECTION        0xC000004E
1730 #define STATUS_EAS_NOT_SUPPORTED         0xC000004F
1731 #define STATUS_EA_TOO_LARGE              0xC0000050
1732 #define STATUS_NONEXISTENT_EA_ENTRY      0xC0000051
1733 #define STATUS_NO_EAS_ON_FILE            0xC0000052
1734 #define STATUS_EA_CORRUPT_ERROR          0xC0000053
1735 #define STATUS_LOCK_NOT_GRANTED          0xC0000054  /* FIXME: not sure */
1736 #define STATUS_FILE_LOCK_CONFLICT        0xC0000055  /* FIXME: not sure */
1737 #define STATUS_DELETE_PENDING            0xC0000056
1738 #define STATUS_CTL_FILE_NOT_SUPPORTED    0xC0000057
1739 #define STATUS_UNKNOWN_REVISION          0xC0000058
1740 #define STATUS_REVISION_MISMATCH         0xC0000059
1741 #define STATUS_INVALID_OWNER             0xC000005A
1742 #define STATUS_INVALID_PRIMARY_GROUP     0xC000005B
1743 #define STATUS_NO_IMPERSONATION_TOKEN    0xC000005C
1744 #define STATUS_CANT_DISABLE_MANDATORY    0xC000005D
1745 #define STATUS_NO_LOGON_SERVERS          0xC000005E
1746 #define STATUS_NO_SUCH_LOGON_SESSION     0xC000005F
1747 #define STATUS_NO_SUCH_PRIVILEGE         0xC0000060
1748 #define STATUS_PRIVILEGE_NOT_HELD        0xC0000061
1749 #define STATUS_INVALID_ACCOUNT_NAME      0xC0000062
1750 #define STATUS_USER_EXISTS               0xC0000063
1751 #define STATUS_NO_SUCH_USER              0xC0000064
1752 #define STATUS_GROUP_EXISTS              0xC0000065
1753 #define STATUS_NO_SUCH_GROUP             0xC0000066
1754 #define STATUS_MEMBER_IN_GROUP           0xC0000067
1755 #define STATUS_MEMBER_NOT_IN_GROUP       0xC0000068
1756 #define STATUS_LAST_ADMIN                0xC0000069
1757 #define STATUS_WRONG_PASSWORD            0xC000006A
1758 #define STATUS_ILL_FORMED_PASSWORD       0xC000006B
1759 #define STATUS_PASSWORD_RESTRICTION      0xC000006C
1760 #define STATUS_LOGON_FAILURE             0xC000006D
1761 #define STATUS_ACCOUNT_RESTRICTION       0xC000006E
1762 #define STATUS_INVALID_LOGON_HOURS       0xC000006F
1763 #define STATUS_INVALID_WORKSTATION       0xC0000070
1764 #define STATUS_PASSWORD_EXPIRED          0xC0000071
1765 #define STATUS_ACCOUNT_DISABLED          0xC0000072
1766 #define STATUS_NONE_MAPPED               0xC0000073
1767 #define STATUS_TOO_MANY_LUIDS_REQUESTED  0xC0000074
1768 #define STATUS_LUIDS_EXHAUSTED           0xC0000075
1769 #define STATUS_INVALID_SUB_AUTHORITY     0xC0000076
1770 #define STATUS_INVALID_ACL               0xC0000077
1771 #define STATUS_INVALID_SID               0xC0000078
1772 #define STATUS_INVALID_SECURITY_DESCR    0xC0000079
1773 #define STATUS_PROCEDURE_NOT_FOUND       0xC000007A
1774 #define STATUS_INVALID_IMAGE_FORMAT      0xC000007B
1775 #define STATUS_NO_TOKEN                  0xC000007C
1776 #define STATUS_BAD_INHERITANCE_ACL       0xC000007D
1777 #define STATUS_RANGE_NOT_LOCKED          0xC000007E
1778 #define STATUS_DISK_FULL                 0xC000007F 
1779 #define STATUS_SERVER_DISABLED           0xC0000080
1780 #define STATUS_SERVER_NOT_DISABLED       0xC0000081
1781 #define STATUS_TOO_MANY_GUIDS_REQUESTED  0xC0000082
1782 #define STATUS_GUIDS_EXHAUSTED           0xC0000083
1783 #define STATUS_INVALID_ID_AUTHORITY      0xC0000084
1784 #define STATUS_AGENTS_EXHAUSTED          0xC0000085
1785 #define STATUS_INVALID_VOLUME_LABEL      0xC0000086
1786 #define STATUS_SECTION_NOT_EXTENDED      0xC0000087
1787 #define STATUS_NOT_MAPPED_DATA           0xC0000088
1788 #define STATUS_RESOURCE_DATA_NOT_FOUND   0xC0000089
1789 #define STATUS_RESOURCE_TYPE_NOT_FOUND   0xC000008A
1790 #define STATUS_RESOURCE_NAME_NOT_FOUND   0xC000008B
1791 #define STATUS_ARRAY_BOUNDS_EXCEEDED     0xC000008C
1792 #define STATUS_FLOAT_DENORMAL_OPERAND    0xC000008D
1793 #define STATUS_FLOAT_DIVIDE_BY_ZERO      0xC000008E
1794 #define STATUS_FLOAT_INEXACT_RESULT      0xC000008F
1795 #define STATUS_FLOAT_INVALID_OPERATION   0xC0000090
1796 #define STATUS_FLOAT_OVERFLOW            0xC0000091
1797 #define STATUS_FLOAT_STACK_CHECK         0xC0000092
1798 #define STATUS_FLOAT_UNDERFLOW           0xC0000093
1799 #define STATUS_INTEGER_DIVIDE_BY_ZERO    0xC0000094
1800 #define STATUS_INTEGER_OVERFLOW          0xC0000095
1801 #define STATUS_PRIVILEGED_INSTRUCTION    0xC0000096
1802 #define STATUS_TOO_MANY_PAGING_FILES     0xC0000097
1803 #define STATUS_FILE_INVALID              0xC0000098
1804 #define STATUS_ALLOTTED_SPACE_EXCEEDED   0xC0000099
1805 #define STATUS_INSUFFICIENT_RESOURCES    0xC000009A
1806 #define STATUS_DFS_EXIT_PATH_FOUND       0xC000009B
1807 #define STATUS_DEVICE_DATA_ERROR         0xC000009C
1808 #define STATUS_DEVICE_NOT_CONNECTED      0xC000009D
1809 #define STATUS_DEVICE_POWER_FAILURE      0xC000009E
1810 #define STATUS_FREE_VM_NOT_AT_BASE       0xC000009F
1811 #define STATUS_MEMORY_NOT_ALLOCATED      0xC00000A0
1812 #define STATUS_WORKING_SET_QUOTA         0xC00000A1
1813 #define STATUS_MEDIA_WRITE_PROTECTED     0xC00000A2
1814 #define STATUS_DEVICE_NOT_READY          0xC00000A3
1815 #define STATUS_INVALID_GROUP_ATTRIBUTES  0xC00000A4
1816 #define STATUS_BAD_IMPERSONATION_LEVEL   0xC00000A5
1817 #define STATUS_CANT_OPEN_ANONYMOUS       0xC00000A6
1818 #define STATUS_BAD_VALIDATION_CLASS      0xC00000A7
1819 #define STATUS_BAD_TOKEN_TYPE            0xC00000A8
1820 #define STATUS_BAD_MASTER_BOOT_RECORD    0xC00000A9
1821 #define STATUS_INSTRUCTION_MISALIGNMENT  0xC00000AA
1822 #define STATUS_INSTANCE_NOT_AVAILABLE    0xC00000AB
1823 #define STATUS_PIPE_NOT_AVAILABLE        0xC00000AC
1824 #define STATUS_INVALID_PIPE_STATE        0xC00000AD
1825 #define STATUS_PIPE_BUSY                 0xC00000AE
1826 #define STATUS_ILLEGAL_FUNCTION          0xC00000AF
1827 #define STATUS_PIPE_DISCONNECTED         0xC00000B0
1828 #define STATUS_PIPE_CLOSING              0xC00000B1
1829 #define STATUS_PIPE_CONNECTED            0xC00000B2
1830 #define STATUS_PIPE_LISTENING            0xC00000B3
1831 #define STATUS_INVALID_READ_MODE         0xC00000B4
1832 #define STATUS_IO_TIMEOUT                0xC00000B5
1833 #define STATUS_FILE_FORCED_CLOSED        0xC00000B6
1834 #define STATUS_PROFILING_NOT_STARTED     0xC00000B7
1835 #define STATUS_PROFILING_NOT_STOPPED     0xC00000B8
1836 #define STATUS_COULD_NOT_INTERPRET       0xC00000B9
1837 #define STATUS_FILE_IS_A_DIRECTORY       0xC00000BA
1838 #define STATUS_NOT_SUPPORTED             0xC00000BB
1839 #define STATUS_REMOTE_NOT_LISTENING      0xC00000BC
1840 #define STATUS_DUPLICATE_NAME            0xC00000BD
1841 #define STATUS_BAD_NETWORK_PATH          0xC00000BE
1842 #define STATUS_NETWORK_BUSY              0xC00000BF
1843 #define STATUS_DEVICE_DOES_NOT_EXIST     0xC00000C0
1844 #define STATUS_TOO_MANY_COMMANDS         0xC00000C1
1845 #define STATUS_ADAPTER_HARDWARE_ERROR    0xC00000C2
1846 #define STATUS_INVALID_NETWORK_RESPONSE  0xC00000C3
1847 #define STATUS_UNEXPECTED_NETWORK_ERROR  0xC00000C4
1848 #define STATUS_BAD_REMOTE_ADAPTER        0xC00000C5
1849 #define STATUS_PRINT_QUEUE_FULL          0xC00000C6
1850 #define STATUS_NO_SPOOL_SPACE            0xC00000C7
1851 #define STATUS_PRINT_CANCELLED           0xC00000C8
1852 #define STATUS_NETWORK_NAME_DELETED      0xC00000C9
1853 #define STATUS_NETWORK_ACCESS_DENIED     0xC00000CA
1854 #define STATUS_BAD_DEVICE_TYPE           0xC00000CB
1855 #define STATUS_BAD_NETWORK_NAME          0xC00000CC
1856 #define STATUS_TOO_MANY_NAMES            0xC00000CD
1857 #define STATUS_TOO_MANY_SESSIONS         0xC00000CE
1858 #define STATUS_SHARING_PAUSED            0xC00000CF
1859 #define STATUS_REQUEST_NOT_ACCEPTED      0xC00000D0
1860 #define STATUS_REDIRECTOR_PAUSED         0xC00000D1
1861 #define STATUS_NET_WRITE_FAULT           0xC00000D2
1862 #define STATUS_PROFILING_AT_LIMIT        0xC00000D3
1863 #define STATUS_NOT_SAME_DEVICE           0xC00000D4
1864 #define STATUS_FILE_RENAMED              0xC00000D5
1865 #define STATUS_VIRTUAL_CIRCUIT_CLOSED    0xC00000D6
1866 #define STATUS_NO_SECURITY_ON_OBJECT     0xC00000D7
1867 #define STATUS_CANT_WAIT                 0xC00000D8
1868 #define STATUS_PIPE_EMPTY                0xC00000D9
1869 #define STATUS_CANT_ACCESS_DOMAIN_INFO   0xC00000DA
1870 #define STATUS_CANT_TERMINATE_SELF       0xC00000DB
1871 #define STATUS_INVALID_SERVER_STATE      0xC00000DC
1872 #define STATUS_INVALID_DOMAIN_STATE      0xC00000DD
1873 #define STATUS_INVALID_DOMAIN_ROLE       0xC00000DE
1874 #define STATUS_NO_SUCH_DOMAIN            0xC00000DF
1875 #define STATUS_DOMAIN_EXISTS             0xC00000E0
1876 #define STATUS_DOMAIN_LIMIT_EXCEEDED     0xC00000E1
1877 #define STATUS_OPLOCK_NOT_GRANTED        0xC00000E2
1878 #define STATUS_INVALID_OPLOCK_PROTOCOL   0xC00000E3
1879 #define STATUS_INTERNAL_DB_CORRUPTION    0xC00000E4
1880 #define STATUS_INTERNAL_ERROR            0xC00000E5
1881 #define STATUS_GENERIC_NOT_MAPPED        0xC00000E6
1882 #define STATUS_BAD_DESCRIPTOR_FORMAT     0xC00000E7
1883 #define STATUS_INVALID_USER_BUFFER       0xC00000E8
1884 #define STATUS_UNEXPECTED_IO_ERROR       0xC00000E9
1885 #define STATUS_UNEXPECTED_MM_CREATE_ERR  0xC00000EA
1886 #define STATUS_UNEXPECTED_MM_MAP_ERROR   0xC00000EB
1887 #define STATUS_UNEXPECTED_MM_EXTEND_ERR  0xC00000EC
1888 #define STATUS_NOT_LOGON_PROCESS         0xC00000ED
1889 #define STATUS_LOGON_SESSION_EXISTS      0xC00000EE
1890 #define STATUS_INVALID_PARAMETER_1       0xC00000EF
1891 #define STATUS_INVALID_PARAMETER_2       0xC00000F0
1892 #define STATUS_INVALID_PARAMETER_3       0xC00000F1
1893 #define STATUS_INVALID_PARAMETER_4       0xC00000F2
1894 #define STATUS_INVALID_PARAMETER_5       0xC00000F3
1895 #define STATUS_INVALID_PARAMETER_6       0xC00000F4
1896 #define STATUS_INVALID_PARAMETER_7       0xC00000F5
1897 #define STATUS_INVALID_PARAMETER_8       0xC00000F6
1898 #define STATUS_INVALID_PARAMETER_9       0xC00000F7
1899 #define STATUS_INVALID_PARAMETER_10      0xC00000F8
1900 #define STATUS_INVALID_PARAMETER_11      0xC00000F9
1901 #define STATUS_INVALID_PARAMETER_12      0xC00000FA
1902 #define STATUS_REDIRECTOR_NOT_STARTED    0xC00000FB
1903 #define STATUS_REDIRECTOR_STARTED        0xC00000FC
1904 #define STATUS_STACK_OVERFLOW            0xC00000FD
1905 #define STATUS_BAD_FUNCTION_TABLE        0xC00000FF
1906 #define STATUS_VARIABLE_NOT_FOUND        0xC0000100
1907 #define STATUS_DIRECTORY_NOT_EMPTY       0xC0000101
1908 #define STATUS_FILE_CORRUPT_ERROR        0xC0000102
1909 #define STATUS_NOT_A_DIRECTORY           0xC0000103
1910 #define STATUS_BAD_LOGON_SESSION_STATE   0xC0000104
1911 #define STATUS_LOGON_SESSION_COLLISION   0xC0000105
1912 #define STATUS_NAME_TOO_LONG             0xC0000106
1913 #define STATUS_FILES_OPEN                0xC0000107
1914 #define STATUS_CONNECTION_IN_USE         0xC0000108
1915 #define STATUS_MESSAGE_NOT_FOUND         0xC0000109
1916 #define STATUS_PROCESS_IS_TERMINATING    0xC000010A
1917 #define STATUS_INVALID_LOGON_TYPE        0xC000010B
1918 #define STATUS_NO_GUID_TRANSLATION       0xC000010C
1919 #define STATUS_CANNOT_IMPERSONATE        0xC000010D
1920 #define STATUS_IMAGE_ALREADY_LOADED      0xC000010E
1921 #define STATUS_ABIOS_NOT_PRESENT         0xC000010F
1922 #define STATUS_ABIOS_LID_NOT_EXIST       0xC0000110
1923 #define STATUS_ABIOS_LID_ALREADY_OWNED   0xC0000111
1924 #define STATUS_ABIOS_NOT_LID_OWNER       0xC0000112
1925 #define STATUS_ABIOS_INVALID_COMMAND     0xC0000113
1926 #define STATUS_ABIOS_INVALID_LID         0xC0000114
1927 #define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000115
1928 #define STATUS_ABIOS_INVALID_SELECTOR    0xC0000116
1929 #define STATUS_NO_LDT                    0xC0000117
1930 #define STATUS_INVALID_LDT_SIZE          0xC0000118
1931 #define STATUS_INVALID_LDT_OFFSET        0xC0000119
1932 #define STATUS_INVALID_LDT_DESCRIPTOR    0xC000011A
1933 #define STATUS_INVALID_IMAGE_NE_FORMAT   0xC000011B
1934 #define STATUS_RXACT_INVALID_STATE       0xC000011C
1935 #define STATUS_RXACT_COMMIT_FAILURE      0xC000011D
1936 #define STATUS_MAPPED_FILE_SIZE_ZERO     0xC000011E
1937 #define STATUS_TOO_MANY_OPENED_FILES     0xC000011F
1938 #define STATUS_CANCELLED                 0xC0000120
1939 #define STATUS_CANNOT_DELETE             0xC0000121
1940 #define STATUS_INVALID_COMPUTER_NAME     0xC0000122
1941 #define STATUS_FILE_DELETED              0xC0000123
1942 #define STATUS_SPECIAL_ACCOUNT           0xC0000124
1943 #define STATUS_SPECIAL_GROUP             0xC0000125
1944 #define STATUS_SPECIAL_USER              0xC0000126
1945 #define STATUS_MEMBERS_PRIMARY_GROUP     0xC0000127
1946 #define STATUS_FILE_CLOSED               0xC0000128
1947 #define STATUS_TOO_MANY_THREADS          0xC0000129
1948 #define STATUS_THREAD_NOT_IN_PROCESS     0xC000012A
1949 #define STATUS_TOKEN_ALREADY_IN_USE      0xC000012B
1950 #define STATUS_PAGEFILE_QUOTA_EXCEEDED   0xC000012C
1951 #define STATUS_COMMITMENT_LIMIT          0xC000012D
1952 #define STATUS_INVALID_IMAGE_LE_FORMAT   0xC000012E
1953 #define STATUS_INVALID_IMAGE_NOT_MZ      0xC000012F
1954 #define STATUS_INVALID_IMAGE_PROTECT     0xC0000130
1955 #define STATUS_INVALID_IMAGE_WIN_16      0xC0000131
1956 #define STATUS_LOGON_SERVER_CONFLICT     0xC0000132
1957 #define STATUS_TIME_DIFFERENCE_AT_DC     0xC0000133
1958 #define STATUS_SYNCHRONIZATION_REQUIRED  0xC0000134
1959 #define STATUS_DLL_NOT_FOUND             0xC0000135
1960 #define STATUS_OPEN_FAILED               0xC0000136
1961 #define STATUS_IO_PRIVILEGE_FAILED       0xC0000137
1962 #define STATUS_ORDINAL_NOT_FOUND         0xC0000138
1963 #define STATUS_ENTRYPOINT_NOT_FOUND      0xC0000139
1964 #define STATUS_CONTROL_C_EXIT            0xC000013A
1965 #define STATUS_LOCAL_DISCONNECT          0xC000013B
1966 #define STATUS_REMOTE_DISCONNECT         0xC000013C
1967 #define STATUS_REMOTE_RESOURCES          0xC000013D
1968 #define STATUS_LINK_FAILED               0xC000013E
1969 #define STATUS_LINK_TIMEOUT              0xC000013F
1970 #define STATUS_INVALID_CONNECTION        0xC0000140
1971 #define STATUS_INVALID_ADDRESS           0xC0000141
1972 #define STATUS_DLL_INIT_FAILED           0xC0000142
1973 #define STATUS_MISSING_SYSTEMFILE        0xC0000143
1974 #define STATUS_UNHANDLED_EXCEPTION       0xC0000144
1975 #define STATUS_APP_INIT_FAILURE          0xC0000145
1976 #define STATUS_PAGEFILE_CREATE_FAILED    0xC0000146
1977 #define STATUS_NO_PAGEFILE               0xC0000147
1978 #define STATUS_INVALID_LEVEL             0xC0000148
1979 #define STATUS_WRONG_PASSWORD_CORE       0xC0000149
1980 #define STATUS_ILLEGAL_FLOAT_CONTEXT     0xC000014A
1981 #define STATUS_PIPE_BROKEN               0xC000014B
1982 #define STATUS_REGISTRY_CORRUPT          0xC000014C
1983 #define STATUS_REGISTRY_IO_FAILED        0xC000014D
1984 #define STATUS_NO_EVENT_PAIR             0xC000014E
1985 #define STATUS_UNRECOGNIZED_VOLUME       0xC000014F
1986 #define STATUS_SERIAL_NO_DEVICE_INITED   0xC0000150
1987 #define STATUS_NO_SUCH_ALIAS             0xC0000151
1988 #define STATUS_MEMBER_NOT_IN_ALIAS       0xC0000152
1989 #define STATUS_MEMBER_IN_ALIAS           0xC0000153
1990 #define STATUS_ALIAS_EXISTS              0xC0000154
1991 #define STATUS_LOGON_NOT_GRANTED         0xC0000155
1992 #define STATUS_TOO_MANY_SECRETS          0xC0000156
1993 #define STATUS_SECRET_TOO_LONG           0xC0000157
1994 #define STATUS_INTERNAL_DB_ERROR         0xC0000158
1995 #define STATUS_FULLSCREEN_MODE           0xC0000159
1996 #define STATUS_TOO_MANY_CONTEXT_IDS      0xC000015A
1997 #define STATUS_LOGON_TYPE_NOT_GRANTED    0xC000015B
1998 #define STATUS_NOT_REGISTRY_FILE         0xC000015C
1999 #define STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC000015D
2000 #define STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC000015E
2001 #define STATUS_FT_MISSING_MEMBER         0xC000015F
2002 #define STATUS_ILL_FORMED_SERVICE_ENTRY  0xC0000160
2003 #define STATUS_ILLEGAL_CHARACTER         0xC0000161
2004 #define STATUS_UNMAPPABLE_CHARACTER      0xC0000162
2005 #define STATUS_UNDEFINED_CHARACTER       0xC0000163
2006 #define STATUS_FLOPPY_VOLUME             0xC0000164
2007 #define STATUS_FLOPPY_ID_MARK_NOT_FOUND  0xC0000165
2008 #define STATUS_FLOPPY_WRONG_CYLINDER     0xC0000166
2009 #define STATUS_FLOPPY_UNKNOWN_ERROR      0xC0000167
2010 #define STATUS_FLOPPY_BAD_REGISTERS      0xC0000168
2011 #define STATUS_DISK_RECALIBRATE_FAILED   0xC0000169
2012 #define STATUS_DISK_OPERATION_FAILED     0xC000016A
2013 #define STATUS_DISK_RESET_FAILED         0xC000016B
2014 #define STATUS_SHARED_IRQ_BUSY           0xC000016C
2015 #define STATUS_FT_ORPHANING              0xC000016D
2016 #define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT 0xC000016E
2017
2018 #define STATUS_PARTITION_FAILURE         0xC0000172
2019 #define STATUS_INVALID_BLOCK_LENGTH      0xC0000173
2020 #define STATUS_DEVICE_NOT_PARTITIONED    0xC0000174
2021 #define STATUS_UNABLE_TO_LOCK_MEDIA      0xC0000175
2022 #define STATUS_UNABLE_TO_UNLOAD_MEDIA    0xC0000176
2023 #define STATUS_EOM_OVERFLOW              0xC0000177
2024 #define STATUS_NO_MEDIA                  0xC0000178
2025 #define STATUS_NO_SUCH_MEMBER            0xC000017A
2026 #define STATUS_INVALID_MEMBER            0xC000017B
2027 #define STATUS_KEY_DELETED               0xC000017C
2028 #define STATUS_NO_LOG_SPACE              0xC000017D
2029 #define STATUS_TOO_MANY_SIDS             0xC000017E
2030 #define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
2031 #define STATUS_KEY_HAS_CHILDREN          0xC0000180
2032 #define STATUS_CHILD_MUST_BE_VOLATILE    0xC0000181
2033 #define STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000182
2034 #define STATUS_DRIVER_INTERNAL_ERROR     0xC0000183
2035 #define STATUS_INVALID_DEVICE_STATE      0xC0000184
2036 #define STATUS_IO_DEVICE_ERROR           0xC0000185
2037 #define STATUS_DEVICE_PROTOCOL_ERROR     0xC0000186
2038 #define STATUS_BACKUP_CONTROLLER         0xC0000187
2039 #define STATUS_LOG_FILE_FULL             0xC0000188
2040 #define STATUS_TOO_LATE                  0xC0000189
2041 #define STATUS_NO_TRUST_LSA_SECRET       0xC000018A
2042 #define STATUS_NO_TRUST_SAM_ACCOUNT      0xC000018B
2043 #define STATUS_TRUSTED_DOMAIN_FAILURE    0xC000018C
2044 #define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
2045 #define STATUS_EVENTLOG_FILE_CORRUPT     0xC000018E
2046 #define STATUS_EVENTLOG_CANT_START       0xC000018F
2047 #define STATUS_TRUST_FAILURE             0xC0000190
2048 #define STATUS_MUTANT_LIMIT_EXCEEDED     0xC0000191
2049 #define STATUS_NETLOGON_NOT_STARTED      0xC0000192
2050 #define STATUS_ACCOUNT_EXPIRED           0xC0000193
2051 #define STATUS_POSSIBLE_DEADLOCK         0xC0000194
2052 #define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
2053 #define STATUS_REMOTE_SESSION_LIMIT      0xC0000196
2054 #define STATUS_EVENTLOG_FILE_CHANGED     0xC0000197
2055 #define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
2056 #define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
2057 #define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
2058 #define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
2059 #define STATUS_FS_DRIVER_REQUIRED        0xC000019C
2060
2061 #define STATUS_NO_USER_SESSION_KEY       0xC0000202
2062 #define STATUS_USER_SESSION_DELETED      0xC0000203
2063 #define STATUS_RESOURCE_LANG_NOT_FOUND   0xC0000204
2064 #define STATUS_INSUFF_SERVER_RESOURCES   0xC0000205
2065 #define STATUS_INVALID_BUFFER_SIZE       0xC0000206
2066 #define STATUS_INVALID_ADDRESS_COMPONENT 0xC0000207
2067 #define STATUS_INVALID_ADDRESS_WILDCARD  0xC0000208
2068 #define STATUS_TOO_MANY_ADDRESSES        0xC0000209
2069 #define STATUS_ADDRESS_ALREADY_EXISTS    0xC000020A
2070 #define STATUS_ADDRESS_CLOSED            0xC000020B
2071 #define STATUS_CONNECTION_DISCONNECTED   0xC000020C
2072 #define STATUS_CONNECTION_RESET          0xC000020D
2073 #define STATUS_TOO_MANY_NODES            0xC000020E
2074 #define STATUS_TRANSACTION_ABORTED       0xC000020F
2075 #define STATUS_TRANSACTION_TIMED_OUT     0xC0000210
2076 #define STATUS_TRANSACTION_NO_RELEASE    0xC0000211
2077 #define STATUS_TRANSACTION_NO_MATCH      0xC0000212
2078 #define STATUS_TRANSACTION_RESPONDED     0xC0000213
2079 #define STATUS_TRANSACTION_INVALID_ID    0xC0000214
2080 #define STATUS_TRANSACTION_INVALID_TYPE  0xC0000215
2081 #define STATUS_NOT_SERVER_SESSION        0xC0000216
2082 #define STATUS_NOT_CLIENT_SESSION        0xC0000217
2083 #define STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000218
2084 #define STATUS_DEBUG_ATTACH_FAILED       0xC0000219
2085 #define STATUS_SYSTEM_PROCESS_TERMINATED 0xC000021A
2086 #define STATUS_DATA_NOT_ACCEPTED         0xC000021B
2087 #define STATUS_NO_BROWSER_SERVERS_FOUND  0xC000021C
2088 #define STATUS_VDM_HARD_ERROR            0xC000021D
2089 #define STATUS_DRIVER_CANCEL_TIMEOUT     0xC000021E
2090 #define STATUS_REPLY_MESSAGE_MISMATCH    0xC000021F
2091 #define STATUS_MAPPED_ALIGNMENT          0xC0000220
2092 #define STATUS_IMAGE_CHECKSUM_MISMATCH   0xC0000221
2093 #define STATUS_LOST_WRITEBEHIND_DATA     0xC0000222
2094 #define STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000223
2095 #define STATUS_PASSWORD_MUST_CHANGE      0xC0000224
2096 #define STATUS_NOT_FOUND                 0xC0000225
2097 #define STATUS_NOT_TINY_STREAM           0xC0000226
2098 #define STATUS_RECOVERY_FAILURE          0xC0000227
2099 #define STATUS_STACK_OVERFLOW_READ       0xC0000228
2100 #define STATUS_FAIL_CHECK                0xC0000229
2101 #define STATUS_DUPLICATE_OBJECTID        0xC000022A
2102 #define STATUS_OBJECTID_EXISTS           0xC000022B
2103 #define STATUS_CONVERT_TO_LARGE          0xC000022C
2104 #define STATUS_RETRY                     0xC000022D
2105 #define STATUS_FOUND_OUT_OF_SCOPE        0xC000022E
2106 #define STATUS_ALLOCATE_BUCKET           0xC000022F
2107 #define STATUS_PROPSET_NOT_FOUND         0xC0000230
2108 #define STATUS_MARSHALL_OVERFLOW         0xC0000231
2109 #define STATUS_INVALID_VARIANT           0xC0000232
2110 #define STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000233
2111 #define STATUS_ACCOUNT_LOCKED_OUT        0xC0000234
2112 #define STATUS_HANDLE_NOT_CLOSABLE       0xC0000235
2113 #define STATUS_CONNECTION_REFUSED        0xC0000236
2114 #define STATUS_GRACEFUL_DISCONNECT       0xC0000237
2115 #define STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000238
2116 #define STATUS_ADDRESS_NOT_ASSOCIATED    0xC0000239
2117 #define STATUS_CONNECTION_INVALID        0xC000023A
2118 #define STATUS_CONNECTION_ACTIVE         0xC000023B
2119 #define STATUS_NETWORK_UNREACHABLE       0xC000023C
2120 #define STATUS_HOST_UNREACHABLE          0xC000023D
2121 #define STATUS_PROTOCOL_UNREACHABLE      0xC000023E
2122 #define STATUS_PORT_UNREACHABLE          0xC000023F
2123 #define STATUS_REQUEST_ABORTED           0xC0000240
2124 #define STATUS_CONNECTION_ABORTED        0xC0000241
2125 #define STATUS_BAD_COMPRESSION_BUFFER    0xC0000242
2126 #define STATUS_USER_MAPPED_FILE          0xC0000243
2127 #define STATUS_AUDIT_FAILED              0xC0000244
2128 #define STATUS_TIMER_RESOLUTION_NOT_SET  0xC0000245
2129 #define STATUS_CONNECTION_COUNT_LIMIT    0xC0000246
2130 #define STATUS_LOGIN_TIME_RESTRICTION    0xC0000247
2131 #define STATUS_LOGIN_WKSTA_RESTRICTION   0xC0000248
2132 #define STATUS_IMAGE_MP_UP_MISMATCH      0xC0000249
2133 #define STATUS_INSUFFICIENT_LOGON_INFO   0xC0000250
2134 #define STATUS_BAD_DLL_ENTRYPOINT        0xC0000251
2135 #define STATUS_BAD_SERVICE_ENTRYPOINT    0xC0000252
2136 #define STATUS_LPC_REPLY_LOST            0xC0000253
2137 #define STATUS_IP_ADDRESS_CONFLICT1      0xC0000254
2138 #define STATUS_IP_ADDRESS_CONFLICT2      0xC0000255
2139 #define STATUS_REGISTRY_QUOTA_LIMIT      0xC0000256
2140 #define STATUS_PATH_NOT_COVERED          0xC0000257
2141 #define STATUS_NO_CALLBACK_ACTIVE        0xC0000258
2142 #define STATUS_LICENSE_QUOTA_EXCEEDED    0xC0000259
2143 #define STATUS_PWD_TOO_SHORT             0xC000025A
2144 #define STATUS_PWD_TOO_RECENT            0xC000025B
2145 #define STATUS_PWD_HISTORY_CONFLICT      0xC000025C
2146 #define STATUS_PLUGPLAY_NO_DEVICE        0xC000025E
2147 #define STATUS_UNSUPPORTED_COMPRESSION   0xC000025F
2148 #define STATUS_INVALID_HW_PROFILE        0xC0000260
2149 #define STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000261
2150 #define STATUS_DRIVER_ORDINAL_NOT_FOUND  0xC0000262
2151 #define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000263
2152 #define STATUS_RESOURCE_NOT_OWNED        0xC0000264
2153 #define STATUS_TOO_MANY_LINKS            0xC0000265
2154 #define STATUS_QUOTA_LIST_INCONSISTENT   0xC0000266
2155 #define STATUS_FILE_IS_OFFLINE           0xC0000267
2156 #define STATUS_EVALUATION_EXPIRATION     0xC0000268
2157 #define STATUS_ILLEGAL_DLL_RELOCATION    0xC0000269
2158 #define STATUS_LICENSE_VIOLATION         0xC000026A
2159 #define STATUS_DLL_INIT_FAILED_LOGOFF    0xC000026B
2160 #define STATUS_DRIVER_UNABLE_TO_LOAD     0xC000026C
2161 #define STATUS_DFS_UNAVAILABLE           0xC000026D
2162 #define STATUS_VOLUME_DISMOUNTED         0xC000026E
2163 #define STATUS_WX86_INTERNAL_ERROR       0xC000026F
2164 #define STATUS_WX86_FLOAT_STACK_CHECK    0xC0000270
2165 #define STATUS_WOW_ASSERTION             0xC0009898
2166 #define RPC_NT_INVALID_STRING_BINDING    0xC0020001
2167 #define RPC_NT_WRONG_KIND_OF_BINDING     0xC0020002
2168 #define RPC_NT_INVALID_BINDING           0xC0020003
2169 #define RPC_NT_PROTSEQ_NOT_SUPPORTED     0xC0020004
2170 #define RPC_NT_INVALID_RPC_PROTSEQ       0xC0020005
2171 #define RPC_NT_INVALID_STRING_UUID       0xC0020006
2172 #define RPC_NT_INVALID_ENDPOINT_FORMAT   0xC0020007
2173 #define RPC_NT_INVALID_NET_ADDR          0xC0020008
2174 #define RPC_NT_NO_ENDPOINT_FOUND         0xC0020009
2175 #define RPC_NT_INVALID_TIMEOUT           0xC002000A
2176 #define RPC_NT_OBJECT_NOT_FOUND          0xC002000B
2177 #define RPC_NT_ALREADY_REGISTERED        0xC002000C
2178 #define RPC_NT_TYPE_ALREADY_REGISTERED   0xC002000D
2179 #define RPC_NT_ALREADY_LISTENING         0xC002000E
2180 #define RPC_NT_NO_PROTSEQS_REGISTERED    0xC002000F
2181 #define RPC_NT_NOT_LISTENING             0xC0020010
2182 #define RPC_NT_UNKNOWN_MGR_TYPE          0xC0020011
2183 #define RPC_NT_UNKNOWN_IF                0xC0020012
2184 #define RPC_NT_NO_BINDINGS               0xC0020013
2185 #define RPC_NT_NO_PROTSEQS               0xC0020014
2186 #define RPC_NT_CANT_CREATE_ENDPOINT      0xC0020015
2187 #define RPC_NT_OUT_OF_RESOURCES          0xC0020016
2188 #define RPC_NT_SERVER_UNAVAILABLE        0xC0020017
2189 #define RPC_NT_SERVER_TOO_BUSY           0xC0020018
2190 #define RPC_NT_INVALID_NETWORK_OPTIONS   0xC0020019
2191 #define RPC_NT_NO_CALL_ACTIVE            0xC002001A
2192 #define RPC_NT_CALL_FAILED               0xC002001B
2193 #define RPC_NT_CALL_FAILED_DNE           0xC002001C
2194 #define RPC_NT_PROTOCOL_ERROR            0xC002001D
2195 #define RPC_NT_UNSUPPORTED_TRANS_SYN     0xC002001F
2196 #define RPC_NT_UNSUPPORTED_TYPE          0xC0020021
2197 #define RPC_NT_INVALID_TAG               0xC0020022
2198 #define RPC_NT_INVALID_BOUND             0xC0020023
2199 #define RPC_NT_NO_ENTRY_NAME             0xC0020024
2200 #define RPC_NT_INVALID_NAME_SYNTAX       0xC0020025
2201 #define RPC_NT_UNSUPPORTED_NAME_SYNTAX   0xC0020026
2202 #define RPC_NT_UUID_NO_ADDRESS           0xC0020028
2203 #define RPC_NT_DUPLICATE_ENDPOINT        0xC0020029
2204 #define RPC_NT_UNKNOWN_AUTHN_TYPE        0xC002002A
2205 #define RPC_NT_MAX_CALLS_TOO_SMALL       0xC002002B
2206 #define RPC_NT_STRING_TOO_LONG           0xC002002C
2207 #define RPC_NT_PROTSEQ_NOT_FOUND         0xC002002D
2208 #define RPC_NT_PROCNUM_OUT_OF_RANGE      0xC002002E
2209 #define RPC_NT_BINDING_HAS_NO_AUTH       0xC002002F
2210 #define RPC_NT_UNKNOWN_AUTHN_SERVICE     0xC0020030
2211 #define RPC_NT_UNKNOWN_AUTHN_LEVEL       0xC0020031
2212 #define RPC_NT_INVALID_AUTH_IDENTITY     0xC0020032
2213 #define RPC_NT_UNKNOWN_AUTHZ_SERVICE     0xC0020033
2214 #define EPT_NT_INVALID_ENTRY             0xC0020034
2215 #define EPT_NT_CANT_PERFORM_OP           0xC0020035
2216 #define EPT_NT_NOT_REGISTERED            0xC0020036
2217 #define RPC_NT_NOTHING_TO_EXPORT         0xC0020037
2218 #define RPC_NT_INCOMPLETE_NAME           0xC0020038
2219 #define RPC_NT_INVALID_VERS_OPTION       0xC0020039
2220 #define RPC_NT_NO_MORE_MEMBERS           0xC002003A
2221 #define RPC_NT_NOT_ALL_OBJS_UNEXPORTED   0xC002003B
2222 #define RPC_NT_INTERFACE_NOT_FOUND       0xC002003C
2223 #define RPC_NT_ENTRY_ALREADY_EXISTS      0xC002003D
2224 #define RPC_NT_ENTRY_NOT_FOUND           0xC002003E
2225 #define RPC_NT_NAME_SERVICE_UNAVAILABLE  0xC002003F
2226 #define RPC_NT_INVALID_NAF_ID            0xC0020040
2227 #define RPC_NT_CANNOT_SUPPORT            0xC0020041
2228 #define RPC_NT_NO_CONTEXT_AVAILABLE      0xC0020042
2229 #define RPC_NT_INTERNAL_ERROR            0xC0020043
2230 #define RPC_NT_ZERO_DIVIDE               0xC0020044
2231 #define RPC_NT_ADDRESS_ERROR             0xC0020045
2232 #define RPC_NT_FP_DIV_ZERO               0xC0020046
2233 #define RPC_NT_FP_UNDERFLOW              0xC0020047
2234 #define RPC_NT_FP_OVERFLOW               0xC0020048
2235 #define RPC_NT_NO_MORE_ENTRIES           0xC0030001
2236 #define RPC_NT_SS_CHAR_TRANS_OPEN_FAIL   0xC0030002
2237 #define RPC_NT_SS_CHAR_TRANS_SHORT_FILE  0xC0030003
2238 #define RPC_NT_SS_IN_NULL_CONTEXT        0xC0030004
2239 #define RPC_NT_SS_CONTEXT_MISMATCH       0xC0030005
2240 #define RPC_NT_SS_CONTEXT_DAMAGED        0xC0030006
2241 #define RPC_NT_SS_HANDLES_MISMATCH       0xC0030007
2242 #define RPC_NT_SS_CANNOT_GET_CALL_HANDLE 0xC0030008
2243 #define RPC_NT_NULL_REF_POINTER          0xC0030009
2244 #define RPC_NT_ENUM_VALUE_OUT_OF_RANGE   0xC003000A
2245 #define RPC_NT_BYTE_COUNT_TOO_SMALL      0xC003000B
2246 #define RPC_NT_BAD_STUB_DATA             0xC003000C
2247 #define RPC_NT_CALL_IN_PROGRESS          0xC0020049
2248 #define RPC_NT_NO_MORE_BINDINGS          0xC002004A
2249 #define RPC_NT_GROUP_MEMBER_NOT_FOUND    0xC002004B
2250 #define EPT_NT_CANT_CREATE               0xC002004C
2251 #define RPC_NT_INVALID_OBJECT            0xC002004D
2252 #define RPC_NT_NO_INTERFACES             0xC002004F
2253 #define RPC_NT_CALL_CANCELLED            0xC0020050
2254 #define RPC_NT_BINDING_INCOMPLETE        0xC0020051
2255 #define RPC_NT_COMM_FAILURE              0xC0020052
2256 #define RPC_NT_UNSUPPORTED_AUTHN_LEVEL   0xC0020053
2257 #define RPC_NT_NO_PRINC_NAME             0xC0020054
2258 #define RPC_NT_NOT_RPC_ERROR             0xC0020055
2259 #define RPC_NT_UUID_LOCAL_ONLY           0x40020056
2260 #define RPC_NT_SEC_PKG_ERROR             0xC0020057
2261 #define RPC_NT_NOT_CANCELLED             0xC0020058
2262 #define RPC_NT_INVALID_ES_ACTION         0xC0030059
2263 #define RPC_NT_WRONG_ES_VERSION          0xC003005A
2264 #define RPC_NT_WRONG_STUB_VERSION        0xC003005B
2265 #define RPC_NT_INVALID_PIPE_OBJECT       0xC003005C
2266 #define RPC_NT_INVALID_PIPE_OPERATION    0xC003005D
2267 #define RPC_NT_WRONG_PIPE_VERSION        0xC003005E
2268 #define RPC_NT_SEND_INCOMPLETE           0x400200AF
2269
2270 #define MAXIMUM_WAIT_OBJECTS 64
2271 #define MAXIMUM_SUSPEND_COUNT 127
2272
2273
2274 /*
2275  * From OS/2 2.0 exception handling
2276  * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
2277  */
2278
2279 #define EH_NONCONTINUABLE   0x01
2280 #define EH_UNWINDING        0x02
2281 #define EH_EXIT_UNWIND      0x04
2282 #define EH_STACK_INVALID    0x08
2283 #define EH_NESTED_CALL      0x10
2284
2285 #define EXCEPTION_CONTINUABLE        0
2286 #define EXCEPTION_NONCONTINUABLE     EH_NONCONTINUABLE
2287  
2288 /*
2289  * The exception record used by Win32 to give additional information 
2290  * about exception to exception handlers.
2291  */
2292
2293 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2294
2295 typedef struct __EXCEPTION_RECORD
2296 {
2297     DWORD    ExceptionCode;
2298     DWORD    ExceptionFlags;
2299     struct __EXCEPTION_RECORD *ExceptionRecord;
2300
2301     LPVOID   ExceptionAddress;
2302     DWORD    NumberParameters;
2303     DWORD    ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2304 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2305
2306 /*
2307  * The exception pointers structure passed to exception filters
2308  * in except() and the UnhandledExceptionFilter().
2309  */
2310  
2311 typedef struct _EXCEPTION_POINTERS 
2312 {
2313   PEXCEPTION_RECORD  ExceptionRecord;
2314   PCONTEXT           ContextRecord;
2315 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2316
2317
2318 /*
2319  * The exception frame, used for registering exception handlers 
2320  * Win32 cares only about this, but compilers generally emit 
2321  * larger exception frames for their own use.
2322  */
2323
2324 struct __EXCEPTION_FRAME;
2325
2326 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
2327                                     PCONTEXT,struct __EXCEPTION_FRAME **);
2328
2329 typedef struct __EXCEPTION_FRAME
2330 {
2331   struct __EXCEPTION_FRAME *Prev;
2332   PEXCEPTION_HANDLER       Handler;
2333 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
2334
2335 /*
2336  * function pointer to a exception filter
2337  */
2338
2339 typedef LONG (CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
2340 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
2341
2342 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
2343 LPTOP_LEVEL_EXCEPTION_FILTER
2344 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
2345
2346 /* status values for ContinueDebugEvent */
2347 #define DBG_CONTINUE                0x00010002
2348 #define DBG_TERMINATE_THREAD        0x40010003
2349 #define DBG_TERMINATE_PROCESS       0x40010004
2350 #define DBG_CONTROL_C               0x40010005
2351 #define DBG_CONTROL_BREAK           0x40010008
2352 #define DBG_EXCEPTION_NOT_HANDLED   0x80010001
2353
2354 typedef struct _NT_TIB 
2355 {
2356         struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2357         PVOID StackBase;
2358         PVOID StackLimit;
2359         PVOID SubSystemTib;
2360         union {
2361           PVOID FiberData;
2362           DWORD Version;
2363         } DUMMYUNIONNAME;
2364         PVOID ArbitraryUserPointer;
2365         struct _NT_TIB *Self;
2366 } NT_TIB, *PNT_TIB;
2367
2368 struct _TEB;
2369
2370 #if defined(__i386__) && defined(__GNUC__)
2371 extern inline struct _TEB WINAPI *NtCurrentTeb(void);
2372 extern inline struct _TEB WINAPI *NtCurrentTeb(void)
2373 {
2374     struct _TEB *teb;
2375     __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2376     return teb;
2377 }
2378 #else
2379 extern struct _TEB WINAPI *NtCurrentTeb(void);
2380 #endif
2381
2382
2383 /*
2384  * File formats definitions
2385  */
2386
2387 typedef struct _IMAGE_DOS_HEADER {
2388     WORD  e_magic;      /* 00: MZ Header signature */
2389     WORD  e_cblp;       /* 02: Bytes on last page of file */
2390     WORD  e_cp;         /* 04: Pages in file */
2391     WORD  e_crlc;       /* 06: Relocations */
2392     WORD  e_cparhdr;    /* 08: Size of header in paragraphs */
2393     WORD  e_minalloc;   /* 0a: Minimum extra paragraphs needed */
2394     WORD  e_maxalloc;   /* 0c: Maximum extra paragraphs needed */
2395     WORD  e_ss;         /* 0e: Initial (relative) SS value */
2396     WORD  e_sp;         /* 10: Initial SP value */
2397     WORD  e_csum;       /* 12: Checksum */
2398     WORD  e_ip;         /* 14: Initial IP value */
2399     WORD  e_cs;         /* 16: Initial (relative) CS value */
2400     WORD  e_lfarlc;     /* 18: File address of relocation table */
2401     WORD  e_ovno;       /* 1a: Overlay number */
2402     WORD  e_res[4];     /* 1c: Reserved words */
2403     WORD  e_oemid;      /* 24: OEM identifier (for e_oeminfo) */
2404     WORD  e_oeminfo;    /* 26: OEM information; e_oemid specific */
2405     WORD  e_res2[10];   /* 28: Reserved words */
2406     DWORD e_lfanew;     /* 3c: Offset to extended header */
2407 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2408
2409 #define IMAGE_DOS_SIGNATURE    0x5A4D     /* MZ   */
2410 #define IMAGE_OS2_SIGNATURE    0x454E     /* NE   */
2411 #define IMAGE_OS2_SIGNATURE_LE 0x454C     /* LE   */
2412 #define IMAGE_OS2_SIGNATURE_LX 0x584C     /* LX */
2413 #define IMAGE_VXD_SIGNATURE    0x454C     /* LE   */
2414 #define IMAGE_NT_SIGNATURE     0x00004550 /* PE00 */
2415
2416 /*
2417  * This is the Windows executable (NE) header.
2418  * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2419  */
2420 typedef struct 
2421 {
2422     WORD  ne_magic;             /* 00 NE signature 'NE' */
2423     BYTE  ne_ver;               /* 02 Linker version number */
2424     BYTE  ne_rev;               /* 03 Linker revision number */
2425     WORD  ne_enttab;            /* 04 Offset to entry table relative to NE */
2426     WORD  ne_cbenttab;          /* 06 Length of entry table in bytes */
2427     LONG  ne_crc;               /* 08 Checksum */
2428     WORD  ne_flags;             /* 0c Flags about segments in this file */
2429     WORD  ne_autodata;          /* 0e Automatic data segment number */
2430     WORD  ne_heap;              /* 10 Initial size of local heap */
2431     WORD  ne_stack;             /* 12 Initial size of stack */
2432     DWORD ne_csip;              /* 14 Initial CS:IP */
2433     DWORD ne_sssp;              /* 18 Initial SS:SP */
2434     WORD  ne_cseg;              /* 1c # of entries in segment table */
2435     WORD  ne_cmod;              /* 1e # of entries in module reference tab. */
2436     WORD  ne_cbnrestab;         /* 20 Length of nonresident-name table     */
2437     WORD  ne_segtab;            /* 22 Offset to segment table */
2438     WORD  ne_rsrctab;           /* 24 Offset to resource table */
2439     WORD  ne_restab;            /* 26 Offset to resident-name table */
2440     WORD  ne_modtab;            /* 28 Offset to module reference table */
2441     WORD  ne_imptab;            /* 2a Offset to imported name table */
2442     DWORD ne_nrestab;           /* 2c Offset to nonresident-name table */
2443     WORD  ne_cmovent;           /* 30 # of movable entry points */
2444     WORD  ne_align;             /* 32 Logical sector alignment shift count */
2445     WORD  ne_cres;              /* 34 # of resource segments */
2446     BYTE  ne_exetyp;            /* 36 Flags indicating target OS */
2447     BYTE  ne_flagsothers;       /* 37 Additional information flags */
2448     WORD  fastload_offset;      /* 38 Offset to fast load area (should be ne_pretthunks)*/
2449     WORD  fastload_length;      /* 3a Length of fast load area (should be ne_psegrefbytes) */
2450     WORD  ne_swaparea;          /* 3c Reserved by Microsoft */
2451     WORD  ne_expver;            /* 3e Expected Windows version number */
2452 } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
2453
2454 typedef struct _IMAGE_VXD_HEADER {
2455   WORD  e32_magic;
2456   BYTE  e32_border;
2457   BYTE  e32_worder;
2458   DWORD e32_level;
2459   WORD  e32_cpu;
2460   WORD  e32_os;
2461   DWORD e32_ver;
2462   DWORD e32_mflags;
2463   DWORD e32_mpages;
2464   DWORD e32_startobj;
2465   DWORD e32_eip;
2466   DWORD e32_stackobj;
2467   DWORD e32_esp;
2468   DWORD e32_pagesize;
2469   DWORD e32_lastpagesize;
2470   DWORD e32_fixupsize;
2471   DWORD e32_fixupsum;
2472   DWORD e32_ldrsize;
2473   DWORD e32_ldrsum;
2474   DWORD e32_objtab;
2475   DWORD e32_objcnt;
2476   DWORD e32_objmap;
2477   DWORD e32_itermap;
2478   DWORD e32_rsrctab;
2479   DWORD e32_rsrccnt;
2480   DWORD e32_restab;
2481   DWORD e32_enttab;
2482   DWORD e32_dirtab;
2483   DWORD e32_dircnt;
2484   DWORD e32_fpagetab;
2485   DWORD e32_frectab;
2486   DWORD e32_impmod;
2487   DWORD e32_impmodcnt;
2488   DWORD e32_impproc;
2489   DWORD e32_pagesum;
2490   DWORD e32_datapage;
2491   DWORD e32_preload;
2492   DWORD e32_nrestab;
2493   DWORD e32_cbnrestab;
2494   DWORD e32_nressum;
2495   DWORD e32_autodata;
2496   DWORD e32_debuginfo;
2497   DWORD e32_debuglen;
2498   DWORD e32_instpreload;
2499   DWORD e32_instdemand;
2500   DWORD e32_heapsize;
2501   BYTE   e32_res3[12];
2502   DWORD e32_winresoff;
2503   DWORD e32_winreslen;
2504   WORD  e32_devid;
2505   WORD  e32_ddkver;
2506 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2507
2508
2509 /* These defines describe the meanings of the bits in the Characteristics
2510    field */
2511
2512 #define IMAGE_FILE_RELOCS_STRIPPED      0x0001 /* No relocation info */
2513 #define IMAGE_FILE_EXECUTABLE_IMAGE     0x0002
2514 #define IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004
2515 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
2516 #define IMAGE_FILE_AGGRESIVE_WS_TRIM    0x0010
2517 #define IMAGE_FILE_LARGE_ADDRESS_AWARE  0x0020
2518 #define IMAGE_FILE_16BIT_MACHINE        0x0040
2519 #define IMAGE_FILE_BYTES_REVERSED_LO    0x0080
2520 #define IMAGE_FILE_32BIT_MACHINE        0x0100
2521 #define IMAGE_FILE_DEBUG_STRIPPED       0x0200
2522 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP      0x0400
2523 #define IMAGE_FILE_SYSTEM               0x1000
2524 #define IMAGE_FILE_DLL                  0x2000
2525 #define IMAGE_FILE_UP_SYSTEM_ONLY       0x4000
2526 #define IMAGE_FILE_BYTES_REVERSED_HI    0x8000
2527
2528 /* These are the settings of the Machine field. */
2529 #define IMAGE_FILE_MACHINE_UNKNOWN      0
2530 #define IMAGE_FILE_MACHINE_I860         0x14d
2531 #define IMAGE_FILE_MACHINE_I386         0x14c
2532 #define IMAGE_FILE_MACHINE_R3000        0x162
2533 #define IMAGE_FILE_MACHINE_R4000        0x166
2534 #define IMAGE_FILE_MACHINE_R10000       0x168
2535 #define IMAGE_FILE_MACHINE_ALPHA        0x184
2536 #define IMAGE_FILE_MACHINE_POWERPC      0x1F0  
2537
2538 #define IMAGE_SIZEOF_FILE_HEADER        20
2539
2540 /* Possible Magic values */
2541 #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
2542 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC       0x107
2543
2544 /* These are indexes into the DataDirectory array */
2545 #define IMAGE_FILE_EXPORT_DIRECTORY             0
2546 #define IMAGE_FILE_IMPORT_DIRECTORY             1
2547 #define IMAGE_FILE_RESOURCE_DIRECTORY           2
2548 #define IMAGE_FILE_EXCEPTION_DIRECTORY          3
2549 #define IMAGE_FILE_SECURITY_DIRECTORY           4
2550 #define IMAGE_FILE_BASE_RELOCATION_TABLE        5
2551 #define IMAGE_FILE_DEBUG_DIRECTORY              6
2552 #define IMAGE_FILE_DESCRIPTION_STRING           7
2553 #define IMAGE_FILE_MACHINE_VALUE                8  /* Mips */
2554 #define IMAGE_FILE_THREAD_LOCAL_STORAGE         9
2555 #define IMAGE_FILE_CALLBACK_DIRECTORY           10
2556
2557 /* Directory Entries, indices into the DataDirectory array */
2558
2559 #define IMAGE_DIRECTORY_ENTRY_EXPORT            0
2560 #define IMAGE_DIRECTORY_ENTRY_IMPORT            1
2561 #define IMAGE_DIRECTORY_ENTRY_RESOURCE          2
2562 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION         3
2563 #define IMAGE_DIRECTORY_ENTRY_SECURITY          4
2564 #define IMAGE_DIRECTORY_ENTRY_BASERELOC         5
2565 #define IMAGE_DIRECTORY_ENTRY_DEBUG             6
2566 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT         7
2567 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR         8   /* (MIPS GP) */
2568 #define IMAGE_DIRECTORY_ENTRY_TLS               9
2569 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG       10
2570 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT      11
2571 #define IMAGE_DIRECTORY_ENTRY_IAT               12  /* Import Address Table */
2572 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT      13
2573 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR    14
2574
2575 /* Subsystem Values */
2576
2577 #define IMAGE_SUBSYSTEM_UNKNOWN         0
2578 #define IMAGE_SUBSYSTEM_NATIVE          1
2579 #define IMAGE_SUBSYSTEM_WINDOWS_GUI     2       /* Windows GUI subsystem */
2580 #define IMAGE_SUBSYSTEM_WINDOWS_CUI     3       /* Windows character subsystem*/
2581 #define IMAGE_SUBSYSTEM_OS2_CUI         5
2582 #define IMAGE_SUBSYSTEM_POSIX_CUI       7
2583
2584 typedef struct _IMAGE_FILE_HEADER {
2585   WORD  Machine;
2586   WORD  NumberOfSections;
2587   DWORD TimeDateStamp;
2588   DWORD PointerToSymbolTable;
2589   DWORD NumberOfSymbols;
2590   WORD  SizeOfOptionalHeader;
2591   WORD  Characteristics;
2592 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2593
2594 typedef struct _IMAGE_DATA_DIRECTORY {
2595   DWORD VirtualAddress;
2596   DWORD Size;
2597 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2598
2599 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2600
2601 typedef struct _IMAGE_OPTIONAL_HEADER {
2602
2603   /* Standard fields */
2604
2605   WORD  Magic; /* 0x10b or 0x107 */     /* 0x00 */
2606   BYTE  MajorLinkerVersion;
2607   BYTE  MinorLinkerVersion;
2608   DWORD SizeOfCode;
2609   DWORD SizeOfInitializedData;
2610   DWORD SizeOfUninitializedData;
2611   DWORD AddressOfEntryPoint;            /* 0x10 */
2612   DWORD BaseOfCode;
2613   DWORD BaseOfData;
2614
2615   /* NT additional fields */
2616
2617   DWORD ImageBase;
2618   DWORD SectionAlignment;               /* 0x20 */
2619   DWORD FileAlignment;
2620   WORD  MajorOperatingSystemVersion;
2621   WORD  MinorOperatingSystemVersion;
2622   WORD  MajorImageVersion;
2623   WORD  MinorImageVersion;
2624   WORD  MajorSubsystemVersion;          /* 0x30 */
2625   WORD  MinorSubsystemVersion;
2626   DWORD Win32VersionValue;
2627   DWORD SizeOfImage;
2628   DWORD SizeOfHeaders;
2629   DWORD CheckSum;                       /* 0x40 */
2630   WORD  Subsystem;
2631   WORD  DllCharacteristics;
2632   DWORD SizeOfStackReserve;
2633   DWORD SizeOfStackCommit;
2634   DWORD SizeOfHeapReserve;              /* 0x50 */
2635   DWORD SizeOfHeapCommit;
2636   DWORD LoaderFlags;
2637   DWORD NumberOfRvaAndSizes;
2638   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2639   /* 0xE0 */
2640 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
2641
2642 typedef struct _IMAGE_NT_HEADERS {
2643   DWORD Signature; /* "PE"\0\0 */       /* 0x00 */
2644   IMAGE_FILE_HEADER FileHeader;         /* 0x04 */
2645   IMAGE_OPTIONAL_HEADER OptionalHeader; /* 0x18 */
2646 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
2647
2648 #define IMAGE_SIZEOF_SHORT_NAME 8
2649
2650 typedef struct _IMAGE_SECTION_HEADER {
2651   BYTE  Name[IMAGE_SIZEOF_SHORT_NAME];
2652   union {
2653     DWORD PhysicalAddress;
2654     DWORD VirtualSize;
2655   } Misc;
2656   DWORD VirtualAddress;
2657   DWORD SizeOfRawData;
2658   DWORD PointerToRawData;
2659   DWORD PointerToRelocations;
2660   DWORD PointerToLinenumbers;
2661   WORD  NumberOfRelocations;
2662   WORD  NumberOfLinenumbers;
2663   DWORD Characteristics;
2664 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2665
2666 #define IMAGE_SIZEOF_SECTION_HEADER 40
2667
2668 #define IMAGE_FIRST_SECTION(ntheader) \
2669   ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2670                            ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2671
2672 /* These defines are for the Characteristics bitfield. */
2673 /* #define IMAGE_SCN_TYPE_REG                   0x00000000 - Reserved */
2674 /* #define IMAGE_SCN_TYPE_DSECT                 0x00000001 - Reserved */
2675 /* #define IMAGE_SCN_TYPE_NOLOAD                0x00000002 - Reserved */
2676 /* #define IMAGE_SCN_TYPE_GROUP                 0x00000004 - Reserved */
2677 /* #define IMAGE_SCN_TYPE_NO_PAD                0x00000008 - Reserved */
2678 /* #define IMAGE_SCN_TYPE_COPY                  0x00000010 - Reserved */
2679
2680 #define IMAGE_SCN_CNT_CODE                      0x00000020
2681 #define IMAGE_SCN_CNT_INITIALIZED_DATA          0x00000040
2682 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA        0x00000080
2683
2684 #define IMAGE_SCN_LNK_OTHER                     0x00000100 
2685 #define IMAGE_SCN_LNK_INFO                      0x00000200  
2686 /* #define      IMAGE_SCN_TYPE_OVER             0x00000400 - Reserved */
2687 #define IMAGE_SCN_LNK_REMOVE                    0x00000800
2688 #define IMAGE_SCN_LNK_COMDAT                    0x00001000
2689
2690 /*                                              0x00002000 - Reserved */
2691 /* #define IMAGE_SCN_MEM_PROTECTED              0x00004000 - Obsolete */
2692 #define IMAGE_SCN_MEM_FARDATA                   0x00008000
2693
2694 /* #define IMAGE_SCN_MEM_SYSHEAP                0x00010000 - Obsolete */
2695 #define IMAGE_SCN_MEM_PURGEABLE                 0x00020000
2696 #define IMAGE_SCN_MEM_16BIT                     0x00020000
2697 #define IMAGE_SCN_MEM_LOCKED                    0x00040000
2698 #define IMAGE_SCN_MEM_PRELOAD                   0x00080000
2699
2700 #define IMAGE_SCN_ALIGN_1BYTES                  0x00100000
2701 #define IMAGE_SCN_ALIGN_2BYTES                  0x00200000
2702 #define IMAGE_SCN_ALIGN_4BYTES                  0x00300000
2703 #define IMAGE_SCN_ALIGN_8BYTES                  0x00400000
2704 #define IMAGE_SCN_ALIGN_16BYTES                 0x00500000  /* Default */
2705 #define IMAGE_SCN_ALIGN_32BYTES                 0x00600000
2706 #define IMAGE_SCN_ALIGN_64BYTES                 0x00700000
2707 /*                                              0x00800000 - Unused */
2708
2709 #define IMAGE_SCN_LNK_NRELOC_OVFL               0x01000000
2710
2711
2712 #define IMAGE_SCN_MEM_DISCARDABLE               0x02000000
2713 #define IMAGE_SCN_MEM_NOT_CACHED                0x04000000
2714 #define IMAGE_SCN_MEM_NOT_PAGED                 0x08000000
2715 #define IMAGE_SCN_MEM_SHARED                    0x10000000
2716 #define IMAGE_SCN_MEM_EXECUTE                   0x20000000
2717 #define IMAGE_SCN_MEM_READ                      0x40000000
2718 #define IMAGE_SCN_MEM_WRITE                     0x80000000
2719
2720 #include "pshpack2.h"
2721
2722 typedef struct _IMAGE_SYMBOL {
2723     union {
2724         BYTE    ShortName[8];
2725         struct {
2726             DWORD   Short;
2727             DWORD   Long;
2728         } Name;
2729         DWORD   LongName[2];
2730     } N;
2731     DWORD   Value;
2732     SHORT   SectionNumber;
2733     WORD    Type;
2734     BYTE    StorageClass;
2735     BYTE    NumberOfAuxSymbols;
2736 } IMAGE_SYMBOL;
2737 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2738
2739 #define IMAGE_SIZEOF_SYMBOL 18
2740
2741 typedef struct _IMAGE_LINENUMBER {
2742     union {
2743         DWORD   SymbolTableIndex;
2744         DWORD   VirtualAddress;
2745     } Type;
2746     WORD    Linenumber;
2747 } IMAGE_LINENUMBER;
2748 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2749
2750 #define IMAGE_SIZEOF_LINENUMBER  6
2751
2752 typedef union _IMAGE_AUX_SYMBOL {
2753     struct {
2754         DWORD    TagIndex;
2755         union {
2756             struct {
2757                 WORD    Linenumber;
2758                 WORD    Size;
2759             } LnSz;
2760            DWORD    TotalSize;
2761         } Misc;
2762         union {
2763             struct {
2764                 DWORD    PointerToLinenumber;
2765                 DWORD    PointerToNextFunction;
2766             } Function;
2767             struct {
2768                 WORD     Dimension[4];
2769             } Array;
2770         } FcnAry;
2771         WORD    TvIndex;
2772     } Sym;
2773     struct {
2774         BYTE    Name[IMAGE_SIZEOF_SYMBOL];
2775     } File;
2776     struct {
2777         DWORD   Length;
2778         WORD    NumberOfRelocations;
2779         WORD    NumberOfLinenumbers;
2780         DWORD   CheckSum;
2781         SHORT   Number;
2782         BYTE    Selection;
2783     } Section;
2784 } IMAGE_AUX_SYMBOL;
2785 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2786
2787 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2788
2789 #include "poppack.h"
2790
2791 #define IMAGE_SYM_UNDEFINED           (SHORT)0
2792 #define IMAGE_SYM_ABSOLUTE            (SHORT)-1
2793 #define IMAGE_SYM_DEBUG               (SHORT)-2
2794
2795 #define IMAGE_SYM_TYPE_NULL                 0x0000
2796 #define IMAGE_SYM_TYPE_VOID                 0x0001
2797 #define IMAGE_SYM_TYPE_CHAR                 0x0002
2798 #define IMAGE_SYM_TYPE_SHORT                0x0003
2799 #define IMAGE_SYM_TYPE_INT                  0x0004
2800 #define IMAGE_SYM_TYPE_LONG                 0x0005
2801 #define IMAGE_SYM_TYPE_FLOAT                0x0006
2802 #define IMAGE_SYM_TYPE_DOUBLE               0x0007
2803 #define IMAGE_SYM_TYPE_STRUCT               0x0008
2804 #define IMAGE_SYM_TYPE_UNION                0x0009
2805 #define IMAGE_SYM_TYPE_ENUM                 0x000A
2806 #define IMAGE_SYM_TYPE_MOE                  0x000B
2807 #define IMAGE_SYM_TYPE_BYTE                 0x000C
2808 #define IMAGE_SYM_TYPE_WORD                 0x000D
2809 #define IMAGE_SYM_TYPE_UINT                 0x000E
2810 #define IMAGE_SYM_TYPE_DWORD                0x000F
2811 #define IMAGE_SYM_TYPE_PCODE                0x8000
2812
2813 #define IMAGE_SYM_DTYPE_NULL                0
2814 #define IMAGE_SYM_DTYPE_POINTER             1
2815 #define IMAGE_SYM_DTYPE_FUNCTION            2
2816 #define IMAGE_SYM_DTYPE_ARRAY               3
2817
2818 #define IMAGE_SYM_CLASS_END_OF_FUNCTION     (BYTE )-1
2819 #define IMAGE_SYM_CLASS_NULL                0x0000
2820 #define IMAGE_SYM_CLASS_AUTOMATIC           0x0001
2821 #define IMAGE_SYM_CLASS_EXTERNAL            0x0002
2822 #define IMAGE_SYM_CLASS_STATIC              0x0003
2823 #define IMAGE_SYM_CLASS_REGISTER            0x0004
2824 #define IMAGE_SYM_CLASS_EXTERNAL_DEF        0x0005
2825 #define IMAGE_SYM_CLASS_LABEL               0x0006
2826 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL     0x0007
2827 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT    0x0008
2828 #define IMAGE_SYM_CLASS_ARGUMENT            0x0009
2829 #define IMAGE_SYM_CLASS_STRUCT_TAG          0x000A
2830 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION     0x000B
2831 #define IMAGE_SYM_CLASS_UNION_TAG           0x000C
2832 #define IMAGE_SYM_CLASS_TYPE_DEFINITION     0x000D
2833 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC    0x000E
2834 #define IMAGE_SYM_CLASS_ENUM_TAG            0x000F
2835 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM      0x0010
2836 #define IMAGE_SYM_CLASS_REGISTER_PARAM      0x0011
2837 #define IMAGE_SYM_CLASS_BIT_FIELD           0x0012
2838
2839 #define IMAGE_SYM_CLASS_FAR_EXTERNAL        0x0044
2840 #define IMAGE_SYM_CLASS_BLOCK               0x0064
2841 #define IMAGE_SYM_CLASS_FUNCTION            0x0065
2842 #define IMAGE_SYM_CLASS_END_OF_STRUCT       0x0066
2843 #define IMAGE_SYM_CLASS_FILE                0x0067
2844 #define IMAGE_SYM_CLASS_SECTION             0x0068
2845 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL       0x0069
2846
2847 #define N_BTMASK                            0x000F
2848 #define N_TMASK                             0x0030
2849 #define N_TMASK1                            0x00C0
2850 #define N_TMASK2                            0x00F0
2851 #define N_BTSHFT                            4
2852 #define N_TSHIFT                            2
2853
2854 #define BTYPE(x) ((x) & N_BTMASK)
2855
2856 #ifndef ISPTR
2857 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2858 #endif
2859
2860 #ifndef ISFCN
2861 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2862 #endif
2863
2864 #ifndef ISARY
2865 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2866 #endif
2867
2868 #ifndef ISTAG
2869 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2870 #endif
2871
2872 #ifndef INCREF
2873 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2874 #endif
2875 #ifndef DECREF
2876 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2877 #endif
2878
2879 #define IMAGE_COMDAT_SELECT_NODUPLICATES    1
2880 #define IMAGE_COMDAT_SELECT_ANY             2
2881 #define IMAGE_COMDAT_SELECT_SAME_SIZE       3
2882 #define IMAGE_COMDAT_SELECT_EXACT_MATCH     4
2883 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE     5
2884 #define IMAGE_COMDAT_SELECT_LARGEST         6
2885 #define IMAGE_COMDAT_SELECT_NEWEST          7
2886
2887 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1
2888 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2
2889 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3
2890
2891 /* Export module directory */
2892
2893 typedef struct _IMAGE_EXPORT_DIRECTORY {
2894         DWORD   Characteristics;
2895         DWORD   TimeDateStamp;
2896         WORD    MajorVersion;
2897         WORD    MinorVersion;
2898         DWORD   Name;
2899         DWORD   Base;
2900         DWORD   NumberOfFunctions;
2901         DWORD   NumberOfNames;
2902         DWORD   AddressOfFunctions;
2903         DWORD   AddressOfNames;
2904         DWORD   AddressOfNameOrdinals;
2905 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2906
2907 /* Import name entry */
2908 typedef struct _IMAGE_IMPORT_BY_NAME {
2909         WORD    Hint;
2910         BYTE    Name[1];
2911 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2912
2913 /* Import thunk */
2914 typedef struct _IMAGE_THUNK_DATA {
2915         union {
2916                 LPBYTE    ForwarderString;
2917                 PDWORD    Function;
2918                 DWORD     Ordinal;
2919                 PIMAGE_IMPORT_BY_NAME   AddressOfData;
2920         } u1;
2921 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2922
2923 /* Import module directory */
2924
2925 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2926         union {
2927                 DWORD   Characteristics; /* 0 for terminating null import descriptor  */
2928                 PIMAGE_THUNK_DATA OriginalFirstThunk;   /* RVA to original unbound IAT */
2929         } u;
2930         DWORD   TimeDateStamp;  /* 0 if not bound,
2931                                  * -1 if bound, and real date\time stamp
2932                                  *    in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2933                                  * (new BIND)
2934                                  * otherwise date/time stamp of DLL bound to
2935                                  * (Old BIND)
2936                                  */
2937         DWORD   ForwarderChain; /* -1 if no forwarders */
2938         DWORD   Name;
2939         /* RVA to IAT (if bound this IAT has actual addresses) */
2940         PIMAGE_THUNK_DATA FirstThunk;   
2941 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2942
2943 #define IMAGE_ORDINAL_FLAG              0x80000000
2944 #define IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2945 #define IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)
2946
2947 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2948 {
2949     DWORD   TimeDateStamp;
2950     WORD    OffsetModuleName;
2951     WORD    NumberOfModuleForwarderRefs;
2952 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2953 } IMAGE_BOUND_IMPORT_DESCRIPTOR,  *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2954
2955 typedef struct _IMAGE_BOUND_FORWARDER_REF
2956 {
2957     DWORD   TimeDateStamp;
2958     WORD    OffsetModuleName;
2959     WORD    Reserved;
2960 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2961
2962 #include "pshpack2.h"
2963
2964 typedef struct _IMAGE_BASE_RELOCATION
2965 {
2966         DWORD   VirtualAddress;
2967         DWORD   SizeOfBlock;
2968         /* WORD TypeOffset[1]; */
2969 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2970
2971 typedef struct _IMAGE_RELOCATION
2972 {
2973     union {
2974         DWORD   VirtualAddress;
2975         DWORD   RelocCount;
2976     } u;
2977     DWORD   SymbolTableIndex;
2978     WORD    Type;
2979 } IMAGE_RELOCATION;
2980 typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
2981
2982 #include "poppack.h"
2983
2984 #define IMAGE_SIZEOF_RELOCATION 10
2985
2986 /* generic relocation types */
2987 #define IMAGE_REL_BASED_ABSOLUTE                0
2988 #define IMAGE_REL_BASED_HIGH                    1
2989 #define IMAGE_REL_BASED_LOW                     2
2990 #define IMAGE_REL_BASED_HIGHLOW                 3
2991 #define IMAGE_REL_BASED_HIGHADJ                 4
2992 #define IMAGE_REL_BASED_MIPS_JMPADDR            5
2993 #define IMAGE_REL_BASED_SECTION                 6
2994 #define IMAGE_REL_BASED_REL                     7
2995 #define IMAGE_REL_BASED_MIPS_JMPADDR16          9
2996 #define IMAGE_REL_BASED_IA64_IMM64              9 /* yes, 9 too */
2997 #define IMAGE_REL_BASED_DIR64                   10
2998 #define IMAGE_REL_BASED_HIGH3ADJ                11
2999
3000 /* I386 relocation types */
3001 #define IMAGE_REL_I386_ABSOLUTE                 0
3002 #define IMAGE_REL_I386_DIR16                    1
3003 #define IMAGE_REL_I386_REL16                    2
3004 #define IMAGE_REL_I386_DIR32                    6
3005 #define IMAGE_REL_I386_DIR32NB                  7
3006 #define IMAGE_REL_I386_SEG12                    9
3007 #define IMAGE_REL_I386_SECTION                  10
3008 #define IMAGE_REL_I386_SECREL                   11
3009 #define IMAGE_REL_I386_REL32                    20
3010
3011 /* MIPS relocation types */
3012 #define IMAGE_REL_MIPS_ABSOLUTE         0x0000
3013 #define IMAGE_REL_MIPS_REFHALF          0x0001
3014 #define IMAGE_REL_MIPS_REFWORD          0x0002
3015 #define IMAGE_REL_MIPS_JMPADDR          0x0003
3016 #define IMAGE_REL_MIPS_REFHI            0x0004
3017 #define IMAGE_REL_MIPS_REFLO            0x0005
3018 #define IMAGE_REL_MIPS_GPREL            0x0006
3019 #define IMAGE_REL_MIPS_LITERAL          0x0007
3020 #define IMAGE_REL_MIPS_SECTION          0x000A
3021 #define IMAGE_REL_MIPS_SECREL           0x000B
3022 #define IMAGE_REL_MIPS_SECRELLO         0x000C
3023 #define IMAGE_REL_MIPS_SECRELHI         0x000D
3024 #define IMAGE_REL_MIPS_JMPADDR16        0x0010
3025 #define IMAGE_REL_MIPS_REFWORDNB        0x0022
3026 #define IMAGE_REL_MIPS_PAIR             0x0025
3027
3028 /* ALPHA relocation types */
3029 #define IMAGE_REL_ALPHA_ABSOLUTE        0x0000
3030 #define IMAGE_REL_ALPHA_REFLONG         0x0001
3031 #define IMAGE_REL_ALPHA_REFQUAD         0x0002
3032 #define IMAGE_REL_ALPHA_GPREL           0x0003
3033 #define IMAGE_REL_ALPHA_LITERAL         0x0004
3034 #define IMAGE_REL_ALPHA_LITUSE          0x0005
3035 #define IMAGE_REL_ALPHA_GPDISP          0x0006
3036 #define IMAGE_REL_ALPHA_BRADDR          0x0007
3037 #define IMAGE_REL_ALPHA_HINT            0x0008
3038 #define IMAGE_REL_ALPHA_INLINE_REFLONG  0x0009
3039 #define IMAGE_REL_ALPHA_REFHI           0x000A
3040 #define IMAGE_REL_ALPHA_REFLO           0x000B
3041 #define IMAGE_REL_ALPHA_PAIR            0x000C
3042 #define IMAGE_REL_ALPHA_MATCH           0x000D
3043 #define IMAGE_REL_ALPHA_SECTION         0x000E
3044 #define IMAGE_REL_ALPHA_SECREL          0x000F
3045 #define IMAGE_REL_ALPHA_REFLONGNB       0x0010
3046 #define IMAGE_REL_ALPHA_SECRELLO        0x0011
3047 #define IMAGE_REL_ALPHA_SECRELHI        0x0012
3048 #define IMAGE_REL_ALPHA_REFQ3           0x0013
3049 #define IMAGE_REL_ALPHA_REFQ2           0x0014
3050 #define IMAGE_REL_ALPHA_REFQ1           0x0015
3051 #define IMAGE_REL_ALPHA_GPRELLO         0x0016
3052 #define IMAGE_REL_ALPHA_GPRELHI         0x0017
3053
3054 /* PowerPC relocation types */
3055 #define IMAGE_REL_PPC_ABSOLUTE          0x0000
3056 #define IMAGE_REL_PPC_ADDR64            0x0001
3057 #define IMAGE_REL_PPC_ADDR            0x0002
3058 #define IMAGE_REL_PPC_ADDR24            0x0003
3059 #define IMAGE_REL_PPC_ADDR16            0x0004
3060 #define IMAGE_REL_PPC_ADDR14            0x0005
3061 #define IMAGE_REL_PPC_REL24             0x0006
3062 #define IMAGE_REL_PPC_REL14             0x0007
3063 #define IMAGE_REL_PPC_TOCREL16          0x0008
3064 #define IMAGE_REL_PPC_TOCREL14          0x0009
3065 #define IMAGE_REL_PPC_ADDR32NB          0x000A
3066 #define IMAGE_REL_PPC_SECREL            0x000B
3067 #define IMAGE_REL_PPC_SECTION           0x000C
3068 #define IMAGE_REL_PPC_IFGLUE            0x000D
3069 #define IMAGE_REL_PPC_IMGLUE            0x000E
3070 #define IMAGE_REL_PPC_SECREL16          0x000F
3071 #define IMAGE_REL_PPC_REFHI             0x0010
3072 #define IMAGE_REL_PPC_REFLO             0x0011
3073 #define IMAGE_REL_PPC_PAIR              0x0012
3074 #define IMAGE_REL_PPC_SECRELLO          0x0013
3075 #define IMAGE_REL_PPC_SECRELHI          0x0014
3076 #define IMAGE_REL_PPC_GPREL             0x0015
3077 #define IMAGE_REL_PPC_TYPEMASK          0x00FF
3078 /* modifier bits */
3079 #define IMAGE_REL_PPC_NEG               0x0100
3080 #define IMAGE_REL_PPC_BRTAKEN           0x0200
3081 #define IMAGE_REL_PPC_BRNTAKEN          0x0400
3082 #define IMAGE_REL_PPC_TOCDEFN           0x0800
3083
3084 /* SH3 ? relocation type */
3085 #define IMAGE_REL_SH3_ABSOLUTE          0x0000
3086 #define IMAGE_REL_SH3_DIRECT16          0x0001
3087 #define IMAGE_REL_SH3_DIRECT          0x0002
3088 #define IMAGE_REL_SH3_DIRECT8           0x0003
3089 #define IMAGE_REL_SH3_DIRECT8_WORD      0x0004
3090 #define IMAGE_REL_SH3_DIRECT8_LONG      0x0005
3091 #define IMAGE_REL_SH3_DIRECT4           0x0006
3092 #define IMAGE_REL_SH3_DIRECT4_WORD      0x0007
3093 #define IMAGE_REL_SH3_DIRECT4_LONG      0x0008
3094 #define IMAGE_REL_SH3_PCREL8_WORD       0x0009
3095 #define IMAGE_REL_SH3_PCREL8_LONG       0x000A
3096 #define IMAGE_REL_SH3_PCREL12_WORD      0x000B
3097 #define IMAGE_REL_SH3_STARTOF_SECTION   0x000C
3098 #define IMAGE_REL_SH3_SIZEOF_SECTION    0x000D
3099 #define IMAGE_REL_SH3_SECTION           0x000E
3100 #define IMAGE_REL_SH3_SECREL            0x000F
3101 #define IMAGE_REL_SH3_DIRECT32_NB       0x0010
3102
3103 /* ARM (Archimedes?) relocation types */
3104 #define IMAGE_REL_ARM_ABSOLUTE          0x0000
3105 #define IMAGE_REL_ARM_ADDR              0x0001
3106 #define IMAGE_REL_ARM_ADDR32NB          0x0002
3107 #define IMAGE_REL_ARM_BRANCH24          0x0003
3108 #define IMAGE_REL_ARM_BRANCH11          0x0004
3109 #define IMAGE_REL_ARM_SECTION           0x000E
3110 #define IMAGE_REL_ARM_SECREL            0x000F
3111
3112 /* IA64 relocation types */
3113 #define IMAGE_REL_IA64_ABSOLUTE         0x0000
3114 #define IMAGE_REL_IA64_IMM14            0x0001
3115 #define IMAGE_REL_IA64_IMM22            0x0002
3116 #define IMAGE_REL_IA64_IMM64            0x0003
3117 #define IMAGE_REL_IA64_DIR              0x0004
3118 #define IMAGE_REL_IA64_DIR64            0x0005
3119 #define IMAGE_REL_IA64_PCREL21B         0x0006
3120 #define IMAGE_REL_IA64_PCREL21M         0x0007
3121 #define IMAGE_REL_IA64_PCREL21F         0x0008
3122 #define IMAGE_REL_IA64_GPREL22          0x0009
3123 #define IMAGE_REL_IA64_LTOFF22          0x000A
3124 #define IMAGE_REL_IA64_SECTION          0x000B
3125 #define IMAGE_REL_IA64_SECREL22         0x000C
3126 #define IMAGE_REL_IA64_SECREL64I        0x000D
3127 #define IMAGE_REL_IA64_SECREL           0x000E
3128 #define IMAGE_REL_IA64_LTOFF64          0x000F
3129 #define IMAGE_REL_IA64_DIR32NB          0x0010
3130 #define IMAGE_REL_IA64_RESERVED_11      0x0011
3131 #define IMAGE_REL_IA64_RESERVED_12      0x0012
3132 #define IMAGE_REL_IA64_RESERVED_13      0x0013
3133 #define IMAGE_REL_IA64_RESERVED_14      0x0014
3134 #define IMAGE_REL_IA64_RESERVED_15      0x0015
3135 #define IMAGE_REL_IA64_RESERVED_16      0x0016
3136 #define IMAGE_REL_IA64_ADDEND           0x001F
3137
3138 /* archive format */
3139
3140 #define IMAGE_ARCHIVE_START_SIZE             8
3141 #define IMAGE_ARCHIVE_START                  "!<arch>\n"
3142 #define IMAGE_ARCHIVE_END                    "`\n"
3143 #define IMAGE_ARCHIVE_PAD                    "\n"
3144 #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
3145 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
3146
3147 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3148 {
3149     BYTE     Name[16];
3150     BYTE     Date[12];
3151     BYTE     UserID[6];
3152     BYTE     GroupID[6];
3153     BYTE     Mode[8];
3154     BYTE     Size[10];
3155     BYTE     EndHeader[2];
3156 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3157
3158 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3159
3160 /*
3161  * Resource directory stuff
3162  */
3163 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3164         DWORD   Characteristics;
3165         DWORD   TimeDateStamp;
3166         WORD    MajorVersion;
3167         WORD    MinorVersion;
3168         WORD    NumberOfNamedEntries;
3169         WORD    NumberOfIdEntries;
3170         /*  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3171 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3172
3173 #define IMAGE_RESOURCE_NAME_IS_STRING           0x80000000
3174 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY        0x80000000
3175
3176 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3177         union {
3178                 struct {
3179 #ifdef BITFIELDS_BIGENDIAN
3180                         unsigned NameIsString:1;
3181                         unsigned NameOffset:31;
3182 #else
3183                         unsigned NameOffset:31;
3184                         unsigned NameIsString:1;
3185 #endif
3186                 } DUMMYSTRUCTNAME1;
3187                 DWORD   Name;
3188                 struct {
3189 #ifdef WORDS_BIGENDIAN
3190                         WORD    __pad;
3191                         WORD    Id;
3192 #else
3193                         WORD    Id;
3194                         WORD    __pad;
3195 #endif
3196                 } DUMMYSTRUCTNAME2;
3197         } DUMMYUNIONNAME1;
3198         union {
3199                 DWORD   OffsetToData;
3200                 struct {
3201 #ifdef BITFIELDS_BIGENDIAN
3202                         unsigned DataIsDirectory:1;
3203                         unsigned OffsetToDirectory:31;
3204 #else
3205                         unsigned OffsetToDirectory:31;
3206                         unsigned DataIsDirectory:1;
3207 #endif
3208                 } DUMMYSTRUCTNAME3;
3209         } DUMMYUNIONNAME2;
3210 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3211
3212
3213 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3214         WORD    Length;
3215         CHAR    NameString[ 1 ];
3216 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3217
3218 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3219         WORD    Length;
3220         WCHAR   NameString[ 1 ];
3221 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3222
3223 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3224         DWORD   OffsetToData;
3225         DWORD   Size;
3226         DWORD   CodePage;
3227         DWORD   ResourceHandle;
3228 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3229
3230
3231 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3232         LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3233 );
3234
3235 typedef struct _IMAGE_TLS_DIRECTORY {
3236         DWORD   StartAddressOfRawData;
3237         DWORD   EndAddressOfRawData;
3238         LPDWORD AddressOfIndex;
3239         PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
3240         DWORD   SizeOfZeroFill;
3241         DWORD   Characteristics;
3242 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
3243
3244 typedef struct _IMAGE_DEBUG_DIRECTORY {
3245   DWORD Characteristics;
3246   DWORD TimeDateStamp;
3247   WORD  MajorVersion;
3248   WORD  MinorVersion;
3249   DWORD Type;
3250   DWORD SizeOfData;
3251   DWORD AddressOfRawData;
3252   DWORD PointerToRawData;
3253 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3254
3255 #define IMAGE_DEBUG_TYPE_UNKNOWN        0
3256 #define IMAGE_DEBUG_TYPE_COFF           1
3257 #define IMAGE_DEBUG_TYPE_CODEVIEW       2
3258 #define IMAGE_DEBUG_TYPE_FPO            3
3259 #define IMAGE_DEBUG_TYPE_MISC           4
3260 #define IMAGE_DEBUG_TYPE_EXCEPTION      5
3261 #define IMAGE_DEBUG_TYPE_FIXUP          6
3262 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC    7
3263 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC  8
3264 #define IMAGE_DEBUG_TYPE_BORLAND        9
3265 #define IMAGE_DEBUG_TYPE_RESERVED10    10
3266
3267 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3268   DWORD NumberOfSymbols;
3269   DWORD LvaToFirstSymbol;
3270   DWORD NumberOfLinenumbers;
3271   DWORD LvaToFirstLinenumber;
3272   DWORD RvaToFirstByteOfCode;
3273   DWORD RvaToLastByteOfCode;
3274   DWORD RvaToFirstByteOfData;
3275   DWORD RvaToLastByteOfData;
3276 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3277
3278 #define FRAME_FPO       0
3279 #define FRAME_TRAP      1
3280 #define FRAME_TSS       2
3281 #define FRAME_NONFPO    3
3282
3283 typedef struct _FPO_DATA {
3284   DWORD ulOffStart;
3285   DWORD cbProcSize;
3286   DWORD cdwLocals;
3287   WORD  cdwParams;
3288   unsigned cbProlog : 8;
3289   unsigned cbRegs   : 3;
3290   unsigned fHasSEH  : 1;
3291   unsigned fUseBP   : 1;
3292   unsigned reserved : 1;
3293   unsigned cbFrame  : 2;
3294 } FPO_DATA, *PFPO_DATA;
3295
3296 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
3297   DWORD Characteristics;
3298   DWORD TimeDateStamp;
3299   WORD  MajorVersion;
3300   WORD  MinorVersion;
3301   DWORD GlobalFlagsClear;
3302   DWORD GlobalFlagsSet;
3303   DWORD CriticalSectionDefaultTimeout;
3304   DWORD DeCommitFreeBlockThreshold;
3305   DWORD DeCommitTotalFreeThreshold;
3306   PVOID LockPrefixTable;
3307   DWORD MaximumAllocationSize;
3308   DWORD VirtualMemoryThreshold;
3309   DWORD ProcessHeapFlags;
3310   DWORD ProcessAffinityMask;
3311   WORD  CSDVersion;
3312   WORD  Reserved1;
3313   PVOID EditList;
3314   DWORD Reserved[1];
3315 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
3316
3317 typedef struct _IMAGE_FUNCTION_ENTRY {
3318   DWORD StartingAddress;
3319   DWORD EndingAddress;
3320   DWORD EndOfPrologue;
3321 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3322
3323 #define IMAGE_DEBUG_MISC_EXENAME    1
3324  
3325 typedef struct _IMAGE_DEBUG_MISC {
3326     DWORD       DataType;
3327     DWORD       Length;
3328     BYTE        Unicode;
3329     BYTE        Reserved[ 3 ];
3330     BYTE        Data[ 1 ];
3331 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3332
3333 /* This is the structure that appears at the very start of a .DBG file. */
3334
3335 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3336         WORD    Signature;
3337         WORD    Flags;
3338         WORD    Machine;
3339         WORD    Characteristics;
3340         DWORD   TimeDateStamp;
3341         DWORD   CheckSum;
3342         DWORD   ImageBase;
3343         DWORD   SizeOfImage;
3344         DWORD   NumberOfSections;
3345         DWORD   ExportedNamesSize;
3346         DWORD   DebugDirectorySize;
3347         DWORD   SectionAlignment;
3348         DWORD   Reserved[ 2 ];
3349 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3350
3351 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3352
3353
3354 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3355         WORD    Length;
3356         WORD    Flags;
3357         BYTE    Text[1];
3358 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3359 #define MESSAGE_RESOURCE_UNICODE        0x0001
3360
3361 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3362         DWORD   LowId;
3363         DWORD   HighId;
3364         DWORD   OffsetToEntries;
3365 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3366
3367 typedef struct tagMESSAGE_RESOURCE_DATA {
3368         DWORD                   NumberOfBlocks;
3369         MESSAGE_RESOURCE_BLOCK  Blocks[ 1 ];
3370 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3371
3372 /*
3373  * Here follows typedefs for security and tokens.
3374  */ 
3375
3376 /*
3377  * First a constant for the following typdefs.
3378  */
3379
3380 #define ANYSIZE_ARRAY   1
3381
3382 /* FIXME:  Orphan.  What does it point to? */
3383 typedef PVOID PACCESS_TOKEN;
3384
3385 /*
3386  * TOKEN_INFORMATION_CLASS
3387  */
3388
3389 typedef enum _TOKEN_INFORMATION_CLASS {
3390   TokenUser = 1, 
3391   TokenGroups, 
3392   TokenPrivileges, 
3393   TokenOwner, 
3394   TokenPrimaryGroup, 
3395   TokenDefaultDacl, 
3396   TokenSource, 
3397   TokenType, 
3398   TokenImpersonationLevel, 
3399   TokenStatistics 
3400 } TOKEN_INFORMATION_CLASS; 
3401
3402 #define TOKEN_TOKEN_ADJUST_DEFAULT   0x0080
3403 #define TOKEN_ADJUST_GROUPS          0x0040
3404 #define TOKEN_ADJUST_PRIVILEGES      0x0020
3405 #define TOKEN_ADJUST_SESSIONID       0x0100
3406 #define TOKEN_ASSIGN_PRIMARY         0x0001
3407 #define TOKEN_DUPLICATE              0x0002
3408 #define TOKEN_EXECUTE                STANDARD_RIGHTS_EXECUTE
3409 #define TOKEN_IMPERSONATE            0x0004
3410 #define TOKEN_QUERY                  0x0008
3411 #define TOKEN_QUERY_SOURCE           0x0010
3412 #define TOKEN_ADJUST_DEFAULT         0x0080
3413 #define TOKEN_READ                   (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3414 #define TOKEN_WRITE                  (STANDARD_RIGHTS_WRITE     | \
3415                                         TOKEN_ADJUST_PRIVILEGES | \
3416                                         TOKEN_ADJUST_GROUPS | \
3417                                         TOKEN_ADJUST_DEFAULT )
3418 #define TOKEN_ALL_ACCESS             (STANDARD_RIGHTS_REQUIRED | \
3419                                         TOKEN_ASSIGN_PRIMARY | \
3420                                         TOKEN_DUPLICATE | \
3421                                         TOKEN_IMPERSONATE | \
3422                                         TOKEN_QUERY | \
3423                                         TOKEN_QUERY_SOURCE | \
3424                                         TOKEN_ADJUST_PRIVILEGES | \
3425                                         TOKEN_ADJUST_GROUPS | \
3426                                         TOKEN_ADJUST_SESSIONID | \
3427                                         TOKEN_ADJUST_DEFAULT )
3428
3429 #ifndef _SECURITY_DEFINED
3430 #define _SECURITY_DEFINED
3431
3432
3433 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3434
3435 typedef struct _GENERIC_MAPPING {
3436     ACCESS_MASK GenericRead;
3437     ACCESS_MASK GenericWrite;
3438     ACCESS_MASK GenericExecute;
3439     ACCESS_MASK GenericAll;
3440 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3441
3442 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3443 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3444 typedef struct {
3445     BYTE Value[6];
3446 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
3447 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3448
3449 #ifndef SID_DEFINED
3450 #define SID_DEFINED
3451 typedef struct _SID {
3452     BYTE Revision;
3453     BYTE SubAuthorityCount;
3454     SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3455     DWORD SubAuthority[1];
3456 } SID,*PSID;
3457 #endif /* !defined(SID_DEFINED) */
3458
3459 #define SID_REVISION                    (1)     /* Current revision */
3460 #define SID_MAX_SUB_AUTHORITIES         (15)    /* current max subauths */
3461 #define SID_RECOMMENDED_SUB_AUTHORITIES (1)     /* recommended subauths */
3462
3463
3464 /* 
3465  * ACL 
3466  */
3467
3468 #define ACL_REVISION1 1
3469 #define ACL_REVISION2 2
3470 #define ACL_REVISION3 3
3471 #define ACL_REVISION4 4
3472
3473 #define MIN_ACL_REVISION ACL_REVISION2
3474 #define MAX_ACL_REVISION ACL_REVISION4
3475
3476 typedef struct _ACL {
3477     BYTE AclRevision;
3478     BYTE Sbz1;
3479     WORD AclSize;
3480     WORD AceCount;
3481     WORD Sbz2;
3482 } ACL, *PACL;
3483
3484 /* SECURITY_DESCRIPTOR */
3485 #define SECURITY_DESCRIPTOR_REVISION    1
3486 #define SECURITY_DESCRIPTOR_REVISION1   1
3487
3488
3489 #define SE_OWNER_DEFAULTED      0x0001
3490 #define SE_GROUP_DEFAULTED      0x0002
3491 #define SE_DACL_PRESENT         0x0004
3492 #define SE_DACL_DEFAULTED       0x0008
3493 #define SE_SACL_PRESENT         0x0010
3494 #define SE_SACL_DEFAULTED       0x0020
3495 #define SE_SELF_RELATIVE        0x8000
3496
3497 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
3498 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
3499
3500 /* The security descriptor structure */
3501 typedef struct {
3502     BYTE Revision;
3503     BYTE Sbz1;
3504     SECURITY_DESCRIPTOR_CONTROL Control;
3505     DWORD Owner;
3506     DWORD Group;
3507     DWORD Sacl;
3508     DWORD Dacl;
3509 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
3510
3511 typedef struct {
3512     BYTE Revision;
3513     BYTE Sbz1;
3514     SECURITY_DESCRIPTOR_CONTROL Control;
3515     PSID Owner;
3516     PSID Group;
3517     PACL Sacl;
3518     PACL Dacl;
3519 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
3520
3521 #define SECURITY_DESCRIPTOR_MIN_LENGTH   (sizeof(SECURITY_DESCRIPTOR)) 
3522
3523 #endif /* _SECURITY_DEFINED */
3524
3525 /* 
3526  * SID_AND_ATTRIBUTES
3527  */
3528
3529 typedef struct _SID_AND_ATTRIBUTES {
3530   PSID  Sid; 
3531   DWORD Attributes; 
3532 } SID_AND_ATTRIBUTES ; 
3533  
3534 /* security entities */
3535 #define SECURITY_NULL_RID                       (0x00000000L)
3536 #define SECURITY_WORLD_RID                      (0x00000000L)
3537 #define SECURITY_LOCAL_RID                      (0X00000000L)
3538
3539 #define SECURITY_NULL_SID_AUTHORITY             {0,0,0,0,0,0}
3540
3541 /* S-1-1 */
3542 #define SECURITY_WORLD_SID_AUTHORITY            {0,0,0,0,0,1}
3543
3544 /* S-1-2 */
3545 #define SECURITY_LOCAL_SID_AUTHORITY            {0,0,0,0,0,2}
3546
3547 /* S-1-3 */
3548 #define SECURITY_CREATOR_SID_AUTHORITY          {0,0,0,0,0,3}
3549 #define SECURITY_CREATOR_OWNER_RID              (0x00000000L) 
3550 #define SECURITY_CREATOR_GROUP_RID              (0x00000001L)
3551 #define SECURITY_CREATOR_OWNER_SERVER_RID       (0x00000002L)
3552 #define SECURITY_CREATOR_GROUP_SERVER_RID       (0x00000003L)
3553
3554 /* S-1-4 */
3555 #define SECURITY_NON_UNIQUE_AUTHORITY           {0,0,0,0,0,4}
3556
3557 /* S-1-5 */
3558 #define SECURITY_NT_AUTHORITY                   {0,0,0,0,0,5} 
3559 #define SECURITY_DIALUP_RID                     0x00000001L
3560 #define SECURITY_NETWORK_RID                    0x00000002L
3561 #define SECURITY_BATCH_RID                      0x00000003L
3562 #define SECURITY_INTERACTIVE_RID                0x00000004L
3563 #define SECURITY_LOGON_IDS_RID                  0x00000005L
3564 #define SECURITY_SERVICE_RID                    0x00000006L
3565 #define SECURITY_ANONYMOUS_LOGON_RID            0x00000007L
3566 #define SECURITY_PROXY_RID                      0x00000008L
3567 #define SECURITY_ENTERPRISE_CONTROLLERS_RID     0x00000009L
3568 #define SECURITY_PRINCIPAL_SELF_RID             0x0000000AL
3569 #define SECURITY_AUTHENTICATED_USER_RID         0x0000000BL
3570 #define SECURITY_RESTRICTED_CODE_RID            0x0000000CL
3571 #define SECURITY_TERMINAL_SERVER_RID            0x0000000DL
3572 #define SECURITY_LOCAL_SYSTEM_RID               0x00000012L
3573 #define SECURITY_NT_NON_UNIQUE                  0x00000015L
3574 #define SECURITY_BUILTIN_DOMAIN_RID             0x00000020L
3575
3576 #define DOMAIN_GROUP_RID_ADMINS                 0x00000200L
3577 #define DOMAIN_GROUP_RID_USERS                  0x00000201L
3578 #define DOMAIN_GROUP_RID_GUESTS                 0x00000202L
3579
3580 #define DOMAIN_ALIAS_RID_ADMINS                 0x00000220L
3581 #define DOMAIN_ALIAS_RID_USERS                  0x00000221L
3582 #define DOMAIN_ALIAS_RID_GUESTS                 0x00000222L
3583
3584 #define SECURITY_SERVER_LOGON_RID               SECURITY_ENTERPRISE_CONTROLLERS_RID
3585
3586 #define SECURITY_LOGON_IDS_RID_COUNT            (3L)
3587
3588 /*
3589  * TOKEN_USER
3590  */
3591
3592 typedef struct _TOKEN_USER {
3593   SID_AND_ATTRIBUTES User; 
3594 } TOKEN_USER; 
3595
3596 /*
3597  * TOKEN_GROUPS
3598  */
3599
3600 typedef struct _TOKEN_GROUPS  {
3601   DWORD GroupCount; 
3602   SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; 
3603 } TOKEN_GROUPS; 
3604
3605 /*
3606  * LUID_AND_ATTRIBUTES
3607  */
3608
3609 typedef union _LARGE_INTEGER {
3610     struct {
3611         DWORD    LowPart;
3612         LONG     HighPart;
3613     } DUMMYSTRUCTNAME;
3614     LONGLONG QuadPart;
3615 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
3616
3617 typedef union _ULARGE_INTEGER {
3618     struct {
3619         DWORD    LowPart;
3620         DWORD    HighPart;
3621     } DUMMYSTRUCTNAME;
3622     ULONGLONG QuadPart;
3623 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
3624
3625 /*
3626  * Locally Unique Identifier
3627  */
3628
3629 typedef struct _LUID {
3630     DWORD LowPart;
3631     LONG HighPart;
3632 } LUID, *PLUID;
3633
3634 #include "pshpack4.h"
3635 typedef struct _LUID_AND_ATTRIBUTES {
3636   LUID   Luid;
3637   DWORD  Attributes;
3638 } LUID_AND_ATTRIBUTES;
3639 #include "poppack.h"
3640
3641 /*
3642  * PRIVILEGE_SET
3643  */
3644
3645 typedef struct _PRIVILEGE_SET {
3646     DWORD PrivilegeCount;
3647     DWORD Control;
3648     LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
3649 } PRIVILEGE_SET, *PPRIVILEGE_SET;
3650
3651 /*
3652  * TOKEN_PRIVILEGES
3653  */
3654
3655 typedef struct _TOKEN_PRIVILEGES {
3656   DWORD PrivilegeCount; 
3657   LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]; 
3658 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES; 
3659
3660 /*
3661  * TOKEN_OWNER
3662  */
3663
3664 typedef struct _TOKEN_OWNER {
3665   PSID Owner; 
3666 } TOKEN_OWNER; 
3667
3668 /*
3669  * TOKEN_PRIMARY_GROUP
3670  */
3671
3672 typedef struct _TOKEN_PRIMARY_GROUP {
3673   PSID PrimaryGroup; 
3674 } TOKEN_PRIMARY_GROUP; 
3675
3676
3677 /*
3678  * TOKEN_DEFAULT_DACL
3679  */
3680
3681 typedef struct _TOKEN_DEFAULT_DACL { 
3682   PACL DefaultDacl; 
3683 } TOKEN_DEFAULT_DACL; 
3684
3685 /*
3686  * TOKEN_SOURCEL
3687  */
3688
3689 typedef struct _TOKEN_SOURCE {
3690   char Sourcename[8]; 
3691   LUID SourceIdentifier; 
3692 } TOKEN_SOURCE; 
3693
3694 /*
3695  * TOKEN_TYPE
3696  */
3697
3698 typedef enum tagTOKEN_TYPE {
3699   TokenPrimary = 1, 
3700   TokenImpersonation 
3701 } TOKEN_TYPE; 
3702
3703 /*
3704  * SECURITY_IMPERSONATION_LEVEL
3705  */
3706
3707 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3708   SecurityAnonymous, 
3709   SecurityIdentification, 
3710   SecurityImpersonation, 
3711   SecurityDelegation 
3712 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL; 
3713
3714
3715 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3716         * PSECURITY_CONTEXT_TRACKING_MODE;
3717 /*
3718  *      Quality of Service
3719  */
3720
3721 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3722   DWORD                         Length;
3723   SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel;
3724   SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3725   BOOLEAN                       EffectiveOnly;
3726 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3727
3728 /*
3729  * TOKEN_STATISTICS
3730  */
3731
3732 typedef struct _TOKEN_STATISTICS {
3733   LUID  TokenId; 
3734   LUID  AuthenticationId; 
3735   LARGE_INTEGER ExpirationTime; 
3736   TOKEN_TYPE    TokenType; 
3737   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 
3738   DWORD DynamicCharged; 
3739   DWORD DynamicAvailable; 
3740   DWORD GroupCount; 
3741   DWORD PrivilegeCount; 
3742   LUID  ModifiedId; 
3743 } TOKEN_STATISTICS; 
3744
3745 /* 
3746  *      ACLs of NT 
3747  */
3748
3749 #define ACL_REVISION    2
3750
3751 #define ACL_REVISION1   1
3752 #define ACL_REVISION2   2
3753
3754 /* ACEs, directly starting after an ACL */
3755 typedef struct _ACE_HEADER {
3756         BYTE    AceType;
3757         BYTE    AceFlags;
3758         WORD    AceSize;
3759 } ACE_HEADER,*PACE_HEADER;
3760
3761 /* AceType */
3762 #define ACCESS_ALLOWED_ACE_TYPE         0
3763 #define ACCESS_DENIED_ACE_TYPE          1
3764 #define SYSTEM_AUDIT_ACE_TYPE           2
3765 #define SYSTEM_ALARM_ACE_TYPE           3
3766
3767 /* inherit AceFlags */
3768 #define OBJECT_INHERIT_ACE              0x01
3769 #define CONTAINER_INHERIT_ACE           0x02
3770 #define NO_PROPAGATE_INHERIT_ACE        0x04
3771 #define INHERIT_ONLY_ACE                0x08
3772 #define VALID_INHERIT_FLAGS             0x0F
3773
3774 /* AceFlags mask for what events we (should) audit */
3775 #define SUCCESSFUL_ACCESS_ACE_FLAG      0x40
3776 #define FAILED_ACCESS_ACE_FLAG          0x80
3777
3778 /* different ACEs depending on AceType 
3779  * SidStart marks the begin of a SID
3780  * so the thing finally looks like this:
3781  * 0: ACE_HEADER
3782  * 4: ACCESS_MASK
3783  * 8... : SID
3784  */
3785 typedef struct _ACCESS_ALLOWED_ACE {
3786         ACE_HEADER      Header;
3787         DWORD           Mask;
3788         DWORD           SidStart;
3789 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3790
3791 typedef struct _ACCESS_DENIED_ACE {
3792         ACE_HEADER      Header;
3793         DWORD           Mask;
3794         DWORD           SidStart;
3795 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3796
3797 typedef struct _SYSTEM_AUDIT_ACE {
3798         ACE_HEADER      Header;
3799         DWORD           Mask;
3800         DWORD           SidStart;
3801 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3802
3803 typedef struct _SYSTEM_ALARM_ACE {
3804         ACE_HEADER      Header;
3805         DWORD           Mask;
3806         DWORD           SidStart;
3807 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3808
3809 typedef enum tagSID_NAME_USE {
3810         SidTypeUser = 1,
3811         SidTypeGroup,
3812         SidTypeDomain,
3813         SidTypeAlias,
3814         SidTypeWellKnownGroup,
3815         SidTypeDeletedAccount,
3816         SidTypeInvalid,
3817         SidTypeUnknown
3818 } SID_NAME_USE,*PSID_NAME_USE;
3819
3820 /* Access rights */
3821
3822 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3823 #undef  DELETE
3824 #define DELETE                     0x00010000
3825 #define READ_CONTROL               0x00020000
3826 #define WRITE_DAC                  0x00040000
3827 #define WRITE_OWNER                0x00080000
3828 #define SYNCHRONIZE                0x00100000
3829 #define STANDARD_RIGHTS_REQUIRED   0x000f0000
3830
3831 #define STANDARD_RIGHTS_READ       READ_CONTROL
3832 #define STANDARD_RIGHTS_WRITE      READ_CONTROL
3833 #define STANDARD_RIGHTS_EXECUTE    READ_CONTROL
3834
3835 #define STANDARD_RIGHTS_ALL        0x001f0000
3836
3837 #define SPECIFIC_RIGHTS_ALL        0x0000ffff
3838
3839 #define GENERIC_READ               0x80000000
3840 #define GENERIC_WRITE              0x40000000
3841 #define GENERIC_EXECUTE            0x20000000
3842 #define GENERIC_ALL                0x10000000
3843
3844 #define MAXIMUM_ALLOWED            0x02000000
3845 #define ACCESS_SYSTEM_SECURITY     0x01000000
3846
3847 #define EVENT_MODIFY_STATE         0x0002
3848 #define EVENT_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3849
3850 #define SEMAPHORE_MODIFY_STATE     0x0002
3851 #define SEMAPHORE_ALL_ACCESS       (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3852
3853 #define MUTEX_MODIFY_STATE         0x0001
3854 #define MUTEX_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3855
3856 #define TIMER_QUERY_STATE          0x0001
3857 #define TIMER_MODIFY_STATE         0x0002
3858 #define TIMER_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3859
3860 #define PROCESS_TERMINATE          0x0001
3861 #define PROCESS_CREATE_THREAD      0x0002
3862 #define PROCESS_VM_OPERATION       0x0008
3863 #define PROCESS_VM_READ            0x0010
3864 #define PROCESS_VM_WRITE           0x0020
3865 #define PROCESS_DUP_HANDLE         0x0040
3866 #define PROCESS_CREATE_PROCESS     0x0080
3867 #define PROCESS_SET_QUOTA          0x0100
3868 #define PROCESS_SET_INFORMATION    0x0200
3869 #define PROCESS_QUERY_INFORMATION  0x0400
3870 #define PROCESS_ALL_ACCESS         (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3871
3872 #define THREAD_TERMINATE           0x0001
3873 #define THREAD_SUSPEND_RESUME      0x0002
3874 #define THREAD_GET_CONTEXT         0x0008
3875 #define THREAD_SET_CONTEXT         0x0010
3876 #define THREAD_SET_INFORMATION     0x0020
3877 #define THREAD_QUERY_INFORMATION   0x0040
3878 #define THREAD_SET_THREAD_TOKEN    0x0080
3879 #define THREAD_IMPERSONATE         0x0100
3880 #define THREAD_DIRECT_IMPERSONATION 0x0200
3881 #define THREAD_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3882
3883 #define THREAD_BASE_PRIORITY_LOWRT  15 
3884 #define THREAD_BASE_PRIORITY_MAX    2 
3885 #define THREAD_BASE_PRIORITY_MIN   -2
3886 #define THREAD_BASE_PRIORITY_IDLE  -15
3887
3888 #define FILE_READ_DATA            0x0001    /* file & pipe */
3889 #define FILE_LIST_DIRECTORY       0x0001    /* directory */
3890 #define FILE_WRITE_DATA           0x0002    /* file & pipe */
3891 #define FILE_ADD_FILE             0x0002    /* directory */
3892 #define FILE_APPEND_DATA          0x0004    /* file */
3893 #define FILE_ADD_SUBDIRECTORY     0x0004    /* directory */
3894 #define FILE_CREATE_PIPE_INSTANCE 0x0004    /* named pipe */
3895 #define FILE_READ_EA              0x0008    /* file & directory */
3896 #define FILE_READ_PROPERTIES      FILE_READ_EA
3897 #define FILE_WRITE_EA             0x0010    /* file & directory */
3898 #define FILE_WRITE_PROPERTIES     FILE_WRITE_EA
3899 #define FILE_EXECUTE              0x0020    /* file */
3900 #define FILE_TRAVERSE             0x0020    /* directory */
3901 #define FILE_DELETE_CHILD         0x0040    /* directory */
3902 #define FILE_READ_ATTRIBUTES      0x0080    /* all */
3903 #define FILE_WRITE_ATTRIBUTES     0x0100    /* all */
3904 #define FILE_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3905
3906 #define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3907                                    FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3908                                    SYNCHRONIZE)
3909 #define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3910                                    FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3911                                    FILE_APPEND_DATA | SYNCHRONIZE)
3912 #define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3913                                    FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3914
3915
3916 /* File attribute flags */
3917 #define FILE_SHARE_READ                 0x00000001L
3918 #define FILE_SHARE_WRITE                0x00000002L
3919 #define FILE_SHARE_DELETE               0x00000004L
3920 #define FILE_ATTRIBUTE_READONLY         0x00000001L
3921 #define FILE_ATTRIBUTE_HIDDEN           0x00000002L
3922 #define FILE_ATTRIBUTE_SYSTEM           0x00000004L
3923 #define FILE_ATTRIBUTE_LABEL            0x00000008L  /* Not in Windows API */
3924 #define FILE_ATTRIBUTE_DIRECTORY        0x00000010L
3925 #define FILE_ATTRIBUTE_ARCHIVE          0x00000020L
3926 #define FILE_ATTRIBUTE_NORMAL           0x00000080L
3927 #define FILE_ATTRIBUTE_TEMPORARY        0x00000100L
3928 #define FILE_ATTRIBUTE_ATOMIC_WRITE     0x00000200L
3929 #define FILE_ATTRIBUTE_XACTION_WRITE    0x00000400L
3930 #define FILE_ATTRIBUTE_COMPRESSED       0x00000800L
3931 #define FILE_ATTRIBUTE_OFFLINE          0x00001000L
3932 #define FILE_ATTRIBUTE_SYMLINK          0x80000000L  /* Not in Windows API */
3933
3934 /* File notification flags */
3935 #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
3936 #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
3937 #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
3938 #define FILE_NOTIFY_CHANGE_SIZE         0x00000008
3939 #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
3940 #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
3941 #define FILE_NOTIFY_CHANGE_CREATION     0x00000040
3942 #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
3943
3944 #define FILE_ACTION_ADDED               0x00000001
3945 #define FILE_ACTION_REMOVED             0x00000002
3946 #define FILE_ACTION_MODIFIED            0x00000003
3947 #define FILE_ACTION_RENAMED_OLD_NAME    0x00000004
3948 #define FILE_ACTION_RENAMED_NEW_NAME    0x00000005
3949
3950
3951 #define FILE_CASE_SENSITIVE_SEARCH      0x00000001
3952 #define FILE_CASE_PRESERVED_NAMES       0x00000002
3953 #define FILE_UNICODE_ON_DISK            0x00000004
3954 #define FILE_PERSISTENT_ACLS            0x00000008
3955 #define FILE_FILE_COMPRESSION           0x00000010
3956 #define FILE_VOLUME_IS_COMPRESSED       0x00008000
3957
3958 /* File alignments (NT) */
3959 #define FILE_BYTE_ALIGNMENT             0x00000000
3960 #define FILE_WORD_ALIGNMENT             0x00000001
3961 #define FILE_LONG_ALIGNMENT             0x00000003
3962 #define FILE_QUAD_ALIGNMENT             0x00000007
3963 #define FILE_OCTA_ALIGNMENT             0x0000000f
3964 #define FILE_32_BYTE_ALIGNMENT          0x0000001f
3965 #define FILE_64_BYTE_ALIGNMENT          0x0000003f
3966 #define FILE_128_BYTE_ALIGNMENT         0x0000007f
3967 #define FILE_256_BYTE_ALIGNMENT         0x000000ff
3968 #define FILE_512_BYTE_ALIGNMENT         0x000001ff
3969
3970 #define REG_NONE                0       /* no type */
3971 #define REG_SZ                  1       /* string type (ASCII) */
3972 #define REG_EXPAND_SZ           2       /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3973 #define REG_BINARY              3       /* binary format, callerspecific */
3974 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3975 #define REG_DWORD               4       /* DWORD in little endian format */
3976 #define REG_DWORD_LITTLE_ENDIAN 4       /* DWORD in little endian format */
3977 #define REG_DWORD_BIG_ENDIAN    5       /* DWORD in big endian format  */
3978 #define REG_LINK                6       /* symbolic link (UNICODE) */
3979 #define REG_MULTI_SZ            7       /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3980 #define REG_RESOURCE_LIST       8       /* resource list? huh? */
3981 #define REG_FULL_RESOURCE_DESCRIPTOR    9       /* full resource descriptor? huh? */
3982 #define REG_RESOURCE_REQUIREMENTS_LIST  10
3983
3984 /* ----------------------------- begin registry ----------------------------- */
3985
3986 /* Registry security values */
3987 #define OWNER_SECURITY_INFORMATION      0x00000001
3988 #define GROUP_SECURITY_INFORMATION      0x00000002
3989 #define DACL_SECURITY_INFORMATION       0x00000004
3990 #define SACL_SECURITY_INFORMATION       0x00000008
3991
3992 #define REG_OPTION_RESERVED             0x00000000
3993 #define REG_OPTION_NON_VOLATILE         0x00000000
3994 #define REG_OPTION_VOLATILE             0x00000001
3995 #define REG_OPTION_CREATE_LINK          0x00000002
3996 #define REG_OPTION_BACKUP_RESTORE       0x00000004 /* FIXME */
3997 #define REG_OPTION_OPEN_LINK            0x00000008
3998 #define REG_LEGAL_OPTION               (REG_OPTION_RESERVED|  \
3999                                         REG_OPTION_NON_VOLATILE|  \
4000                                         REG_OPTION_VOLATILE|  \
4001                                         REG_OPTION_CREATE_LINK|  \
4002                                         REG_OPTION_BACKUP_RESTORE|  \
4003                                         REG_OPTION_OPEN_LINK)
4004
4005
4006 #define REG_CREATED_NEW_KEY     0x00000001
4007 #define REG_OPENED_EXISTING_KEY 0x00000002
4008
4009 /* For RegNotifyChangeKeyValue */
4010 #define REG_NOTIFY_CHANGE_NAME  0x1
4011
4012 #define KEY_QUERY_VALUE         0x00000001
4013 #define KEY_SET_VALUE           0x00000002
4014 #define KEY_CREATE_SUB_KEY      0x00000004
4015 #define KEY_ENUMERATE_SUB_KEYS  0x00000008
4016 #define KEY_NOTIFY              0x00000010
4017 #define KEY_CREATE_LINK         0x00000020
4018
4019 #define KEY_READ              ((STANDARD_RIGHTS_READ|  \
4020                                 KEY_QUERY_VALUE|  \
4021                                 KEY_ENUMERATE_SUB_KEYS|  \
4022                                 KEY_NOTIFY)  \
4023                                 & (~SYNCHRONIZE)  \
4024                               )
4025 #define KEY_WRITE             ((STANDARD_RIGHTS_WRITE|  \
4026                                 KEY_SET_VALUE|  \
4027                                 KEY_CREATE_SUB_KEY)  \
4028                                 & (~SYNCHRONIZE)  \
4029                               )
4030 #define KEY_EXECUTE           ((KEY_READ) & (~SYNCHRONIZE))
4031 #define KEY_ALL_ACCESS        ((STANDARD_RIGHTS_ALL|  \
4032                                 KEY_QUERY_VALUE|  \
4033                                 KEY_SET_VALUE|  \
4034                                 KEY_CREATE_SUB_KEY|  \
4035                                 KEY_ENUMERATE_SUB_KEYS|  \
4036                                 KEY_NOTIFY|  \
4037                                 KEY_CREATE_LINK)  \
4038                                 & (~SYNCHRONIZE)  \
4039                               )
4040 /* ------------------------------ end registry ------------------------------ */
4041
4042
4043 #define EVENTLOG_SUCCESS                0x0000
4044 #define EVENTLOG_ERROR_TYPE             0x0001
4045 #define EVENTLOG_WARNING_TYPE           0x0002
4046 #define EVENTLOG_INFORMATION_TYPE       0x0004
4047 #define EVENTLOG_AUDIT_SUCCESS          0x0008
4048 #define EVENTLOG_AUDIT_FAILURE          0x0010
4049
4050 #define SERVICE_BOOT_START   0x00000000
4051 #define SERVICE_SYSTEM_START 0x00000001
4052 #define SERVICE_AUTO_START   0x00000002
4053 #define SERVICE_DEMAND_START 0x00000003
4054 #define SERVICE_DISABLED     0x00000004
4055
4056 #define SERVICE_ERROR_IGNORE   0x00000000
4057 #define SERVICE_ERROR_NORMAL   0x00000001
4058 #define SERVICE_ERROR_SEVERE   0x00000002
4059 #define SERVICE_ERROR_CRITICAL 0x00000003
4060
4061 /* Service types */
4062 #define SERVICE_KERNEL_DRIVER      0x00000001
4063 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
4064 #define SERVICE_ADAPTER            0x00000004
4065 #define SERVICE_RECOGNIZER_DRIVER  0x00000008
4066
4067 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
4068                          SERVICE_RECOGNIZER_DRIVER )
4069
4070 #define SERVICE_WIN32_OWN_PROCESS   0x00000010
4071 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
4072 #define SERVICE_WIN32  (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
4073
4074 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
4075
4076 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
4077                            SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
4078
4079
4080 typedef enum _CM_SERVICE_NODE_TYPE 
4081 {
4082   DriverType               = SERVICE_KERNEL_DRIVER,
4083   FileSystemType           = SERVICE_FILE_SYSTEM_DRIVER,
4084   Win32ServiceOwnProcess   = SERVICE_WIN32_OWN_PROCESS,
4085   Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
4086   AdapterType              = SERVICE_ADAPTER,
4087   RecognizerType           = SERVICE_RECOGNIZER_DRIVER
4088 } SERVICE_NODE_TYPE;
4089
4090 typedef enum _CM_SERVICE_LOAD_TYPE 
4091 {
4092   BootLoad    = SERVICE_BOOT_START,
4093   SystemLoad  = SERVICE_SYSTEM_START,
4094   AutoLoad    = SERVICE_AUTO_START,
4095   DemandLoad  = SERVICE_DEMAND_START,
4096   DisableLoad = SERVICE_DISABLED
4097 } SERVICE_LOAD_TYPE;
4098
4099 typedef enum _CM_ERROR_CONTROL_TYPE 
4100 {
4101   IgnoreError   = SERVICE_ERROR_IGNORE,
4102   NormalError   = SERVICE_ERROR_NORMAL,
4103   SevereError   = SERVICE_ERROR_SEVERE,
4104   CriticalError = SERVICE_ERROR_CRITICAL
4105 } SERVICE_ERROR_TYPE;
4106
4107
4108
4109 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
4110 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
4111 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
4112 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
4113 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
4114
4115 #include "guiddef.h"
4116
4117 typedef struct _RTL_CRITICAL_SECTION_DEBUG 
4118 {
4119   WORD   Type;
4120   WORD   CreatorBackTraceIndex;
4121   struct _RTL_CRITICAL_SECTION *CriticalSection;
4122   LIST_ENTRY ProcessLocksList;
4123   DWORD EntryCount;
4124   DWORD ContentionCount;
4125   DWORD Spare[ 2 ];
4126 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
4127
4128 typedef struct _RTL_CRITICAL_SECTION {
4129     PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
4130     LONG LockCount;
4131     LONG RecursionCount;
4132     HANDLE OwningThread;
4133     HANDLE LockSemaphore;
4134     ULONG_PTR SpinCount;
4135 }  RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
4136
4137 #endif  /* __WINE_WINNT_H */