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