2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
18 /* On Windows winnt.h depends on a few windef.h types and macros and thus
19 * is not self-contained. Furthermore windef.h includes winnt.h so that it
20 * would be pointless to try to use winnt.h directly.
21 * But for Wine and Winelib I decided to make winnt.h self-contained by
22 * moving these definitions to winnt.h. It makes no difference to Winelib
23 * programs since they are not using winnt.h directly anyway, and it allows
24 * us to use winnt.h and get a minimal set of definitions.
27 /**** Some Wine specific definitions *****/
29 /* Architecture dependent settings. */
30 /* These are hardcoded to avoid dependencies on config.h in Winelib apps. */
32 # undef WORDS_BIGENDIAN
33 # undef BITFIELDS_BIGENDIAN
34 # define ALLOW_UNALIGNED_ACCESS
35 #elif defined(__sparc__)
36 # define WORDS_BIGENDIAN
37 # define BITFIELDS_BIGENDIAN
38 # undef ALLOW_UNALIGNED_ACCESS
39 #elif !defined(RC_INVOKED)
40 # error Unknown CPU architecture!
44 /* Calling conventions definitions */
50 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
51 # define __stdcall __attribute__((__stdcall__))
52 # define __cdecl __attribute__((__cdecl__))
54 # error You need gcc >= 2.7 to build Wine on a 386
55 # endif /* __GNUC__ */
62 #define pascal __stdcall
63 #define _pascal __stdcall
64 #define _stdcall __stdcall
65 #define _fastcall __stdcall
66 #define __fastcall __stdcall
67 #define __export __stdcall
69 #define _cdecl __cdecl
86 #define CALLBACK __stdcall
87 #define WINAPI __stdcall
88 #define APIPRIVATE __stdcall
89 #define PASCAL __stdcall
91 #define _CDECL __cdecl
92 #define WINAPIV __cdecl
93 #define APIENTRY WINAPI
96 /* Macro for structure packing and more. */
99 #define WINE_PACKED __attribute__((packed))
100 #define WINE_UNUSED __attribute__((unused))
101 #define WINE_NORETURN __attribute__((noreturn))
103 #define WINE_PACKED /* nothing */
104 #define WINE_UNUSED /* nothing */
105 #define WINE_NORETURN /* nothing */
108 /* Anonymous union/struct handling */
111 # define NONAMELESSSTRUCT
112 # define NONAMELESSUNION
114 /* Anonymous struct support starts with gcc/g++ 2.96 */
115 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
116 # define NONAMELESSSTRUCT
118 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
119 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
120 # define NONAMELESSUNION
124 #ifndef NONAMELESSSTRUCT
125 #define DUMMYSTRUCTNAME
126 #define DUMMYSTRUCTNAME1
127 #define DUMMYSTRUCTNAME2
128 #define DUMMYSTRUCTNAME3
129 #define DUMMYSTRUCTNAME4
130 #define DUMMYSTRUCTNAME5
131 #else /* !defined(NONAMELESSSTRUCT) */
132 #define DUMMYSTRUCTNAME s
133 #define DUMMYSTRUCTNAME1 s1
134 #define DUMMYSTRUCTNAME2 s2
135 #define DUMMYSTRUCTNAME3 s3
136 #define DUMMYSTRUCTNAME4 s4
137 #define DUMMYSTRUCTNAME5 s5
138 #endif /* !defined(NONAMELESSSTRUCT) */
140 #ifndef NONAMELESSUNION
141 #define DUMMYUNIONNAME
142 #define DUMMYUNIONNAME1
143 #define DUMMYUNIONNAME2
144 #define DUMMYUNIONNAME3
145 #define DUMMYUNIONNAME4
146 #define DUMMYUNIONNAME5
147 #define DUMMYUNIONNAME6
148 #define DUMMYUNIONNAME7
149 #define DUMMYUNIONNAME8
150 #else /* !defined(NONAMELESSUNION) */
151 #define DUMMYUNIONNAME u
152 #define DUMMYUNIONNAME1 u1
153 #define DUMMYUNIONNAME2 u2
154 #define DUMMYUNIONNAME3 u3
155 #define DUMMYUNIONNAME4 u4
156 #define DUMMYUNIONNAME5 u5
157 #define DUMMYUNIONNAME6 u6
158 #define DUMMYUNIONNAME7 u7
159 #define DUMMYUNIONNAME8 u8
160 #endif /* !defined(NONAMELESSUNION) */
163 /**** Parts of windef.h that are needed here *****/
165 /* Misc. constants. */
171 #define NULL ((void*)0)
196 /* Standard data types */
197 typedef const void *PCVOID, *LPCVOID;
198 typedef int BOOL, *PBOOL, *LPBOOL;
199 typedef unsigned char BYTE, *PBYTE, *LPBYTE;
200 typedef unsigned char UCHAR, *PUCHAR;
201 typedef unsigned short USHORT, *PUSHORT, *LPUSHORT;
202 typedef unsigned short WORD, *PWORD, *LPWORD;
203 typedef int INT, *PINT, *LPINT;
204 typedef unsigned int UINT, *PUINT, *LPUINT;
205 typedef unsigned long DWORD, *PDWORD, *LPDWORD;
206 typedef unsigned long ULONG, *PULONG, *LPULONG;
207 typedef float FLOAT, *PFLOAT, *LPFLOAT;
208 typedef double DOUBLE, *PDOUBLE, *LPDOUBLE;
212 /**** winnt.h proper *****/
214 /* Microsoft's macros for declaring functions */
217 # define EXTERN_C extern "C"
219 # define EXTERN_C extern
223 #define STDMETHODCALLTYPE __stdcall
224 #define STDMETHODVCALLTYPE __cdecl
225 #define STDAPICALLTYPE __stdcall
226 #define STDAPIVCALLTYPE __cdecl
228 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
229 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
230 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
231 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
232 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
233 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
234 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
235 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
238 /* Define the basic types */
242 typedef VOID *PVOID, *LPVOID;
243 typedef BYTE BOOLEAN, *PBOOLEAN;
244 typedef char CHAR, *PCHAR;
245 typedef short SHORT, *PSHORT;
246 typedef long LONG, *PLONG, *LPLONG;
248 /* Some systems might have wchar_t, but we really need 16 bit characters */
249 #ifdef WINE_UNICODE_NATIVE
250 typedef wchar_t WCHAR, *PWCHAR;
252 typedef unsigned short WCHAR, *PWCHAR;
255 /* 'Extended/Wide' numerical types */
258 typedef __int64 LONGLONG, *PLONGLONG;
259 typedef __uint64 ULONGLONG, *PULONGLONG;
264 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
267 /* ANSI string types */
268 typedef CHAR *PCH, *LPCH;
269 typedef const CHAR *PCCH, *LPCCH;
270 typedef CHAR *PSTR, *LPSTR;
271 typedef const CHAR *PCSTR, *LPCSTR;
273 /* Unicode string types */
274 typedef WCHAR *PWCH, *LPWCH;
275 typedef const WCHAR *PCWCH, *LPCWCH;
276 typedef WCHAR *PWSTR, *LPWSTR;
277 typedef const WCHAR *PCWSTR, *LPCWSTR;
279 /* Neutral character and string types */
280 /* These are only defined for Winelib, i.e. _not_ defined for
281 * the emulator. The reason is they depend on the UNICODE
282 * macro which only exists in the user's code.
285 # ifdef WINE_UNICODE_REWRITE
286 EXTERN_C unsigned short* wine_rewrite_s4tos2(const wchar_t* str4);
288 inline WCHAR* wine_unicode_text(const wchar_t* str4)
290 return (WCHAR*)wine_rewrite_s4tos2(str4);
292 inline WCHAR wine_unicode_text(wchar_t chr4)
296 # define WINE_UNICODE_TEXT(x) wine_unicode_text(L##x)
297 # else /* __cplusplus */
298 # define WINE_UNICODE_TEXT(x) ((sizeof(x)==1) || (sizeof(L##x)>4) ? \
299 (WCHAR*)wine_rewrite_s4tos2(L##x) : \
301 # endif /* __cplusplus */
302 # else /* WINE_UNICODE_REWRITE */
303 /* WINE_UNICODE_NATIVE or nothing at all */
304 # define WINE_UNICODE_TEXT(string) L##string
305 # endif /* WINE_UNICODE_REWRITE */
308 typedef WCHAR TCHAR, *PTCHAR;
309 typedef LPWSTR PTSTR, LPTSTR;
310 typedef LPCWSTR PCTSTR, LPCTSTR;
311 # define __TEXT(string) WINE_UNICODE_TEXT(string)
313 typedef CHAR TCHAR, *PTCHAR;
314 typedef LPSTR PTSTR, LPTSTR;
315 typedef LPCSTR PCTSTR, LPCTSTR;
316 # define __TEXT(string) string
317 # endif /* UNICODE */
318 # define TEXT(quote) __TEXT(quote)
319 #endif /* __WINE__ */
321 /* Misc common WIN32 types */
322 typedef LONG HRESULT;
323 typedef DWORD LCID, *PLCID;
328 /* FIXME: Wine does not compile with strict on, therefore strict
329 * handles are presently only usable on machines where sizeof(UINT) ==
330 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
331 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
332 * they exist as UINTs but to the Winelib user who turns on strict,
333 * they exist as void*. If there is a size difference between UINT and
334 * void* then things get ugly.
336 * Here is the plan to convert Wine to STRICT:
338 * Types will be converted one at a time by volunteers who will compile
339 * Wine with STRICT turned on. Handles that have not been converted yet
340 * will be declared with DECLARE_OLD_HANDLE. Converted handles are
341 * declared with DECLARE_HANDLE.
342 * See the bug report 90 for more details:
343 * http://wine.codeweavers.com/bugzilla/show_bug.cgi?id=90
346 * when compiling Wine we always treat HANDLE as an UINT. Then when
347 * we're ready we'll remove the '!defined(__WINE__)' (the equivalent
348 * of converting it from DECLARE_OLD_HANDLE to DECLARE_HANDLE).
350 #if defined(STRICT) && !defined(__WINE__)
351 typedef VOID* HANDLE;
352 #define DECLARE_OLD_HANDLE(a) \
353 typedef struct a##__ { int unused; } *a; \
354 typedef a *P##a, *LP##a
358 #define DECLARE_OLD_HANDLE(a) \
360 typedef a *P##a, *LP##a
362 typedef HANDLE *PHANDLE, *LPHANDLE;
365 #define DECLARE_HANDLE(a) \
366 typedef struct a##__ { int unused; } *a; \
367 typedef a *P##a, *LP##a
369 #define DECLARE_HANDLE(a) \
371 typedef a *P##a, *LP##a
375 #include "pshpack1.h"
378 /* Argument 1 passed to the DllEntryProc. */
379 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
380 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
381 #define DLL_THREAD_ATTACH 2 /* attach new thread */
382 #define DLL_THREAD_DETACH 3 /* detach thread */
385 /* u.x.wProcessorArchitecture (NT) */
386 #define PROCESSOR_ARCHITECTURE_INTEL 0
387 #define PROCESSOR_ARCHITECTURE_MIPS 1
388 #define PROCESSOR_ARCHITECTURE_ALPHA 2
389 #define PROCESSOR_ARCHITECTURE_PPC 3
390 #define PROCESSOR_ARCHITECTURE_SHX 4
391 #define PROCESSOR_ARCHITECTURE_ARM 5
392 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
394 /* dwProcessorType */
395 #define PROCESSOR_INTEL_386 386
396 #define PROCESSOR_INTEL_486 486
397 #define PROCESSOR_INTEL_PENTIUM 586
398 #define PROCESSOR_INTEL_860 860
399 #define PROCESSOR_MIPS_R2000 2000
400 #define PROCESSOR_MIPS_R3000 3000
401 #define PROCESSOR_MIPS_R4000 4000
402 #define PROCESSOR_ALPHA_21064 21064
403 #define PROCESSOR_PPC_601 601
404 #define PROCESSOR_PPC_603 603
405 #define PROCESSOR_PPC_604 604
406 #define PROCESSOR_PPC_620 620
407 #define PROCESSOR_HITACHI_SH3 10003
408 #define PROCESSOR_HITACHI_SH3E 10004
409 #define PROCESSOR_HITACHI_SH4 10005
410 #define PROCESSOR_MOTOROLA_821 821
411 #define PROCESSOR_SHx_SH3 103
412 #define PROCESSOR_SHx_SH4 104
413 #define PROCESSOR_STRONGARM 2577
414 #define PROCESSOR_ARM720 1824 /* 0x720 */
415 #define PROCESSOR_ARM820 2080 /* 0x820 */
416 #define PROCESSOR_ARM920 2336 /* 0x920 */
417 #define PROCESSOR_ARM_7TDMI 70001
419 typedef struct _MEMORY_BASIC_INFORMATION
422 LPVOID AllocationBase;
423 DWORD AllocationProtect;
428 } MEMORY_BASIC_INFORMATION,*LPMEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
430 #define PAGE_NOACCESS 0x01
431 #define PAGE_READONLY 0x02
432 #define PAGE_READWRITE 0x04
433 #define PAGE_WRITECOPY 0x08
434 #define PAGE_EXECUTE 0x10
435 #define PAGE_EXECUTE_READ 0x20
436 #define PAGE_EXECUTE_READWRITE 0x40
437 #define PAGE_EXECUTE_WRITECOPY 0x80
438 #define PAGE_GUARD 0x100
439 #define PAGE_NOCACHE 0x200
441 #define MEM_COMMIT 0x00001000
442 #define MEM_RESERVE 0x00002000
443 #define MEM_DECOMMIT 0x00004000
444 #define MEM_RELEASE 0x00008000
445 #define MEM_FREE 0x00010000
446 #define MEM_PRIVATE 0x00020000
447 #define MEM_MAPPED 0x00040000
448 #define MEM_RESET 0x00080000
449 #define MEM_TOP_DOWN 0x00100000
451 #define MEM_SYSTEM 0x80000000
454 #define SEC_FILE 0x00800000
455 #define SEC_IMAGE 0x01000000
456 #define SEC_RESERVE 0x04000000
457 #define SEC_COMMIT 0x08000000
458 #define SEC_NOCACHE 0x10000000
459 #define MEM_IMAGE SEC_IMAGE
464 #define MINSHORT 0x8000
465 #define MAXSHORT 0x7fff
466 #define MINLONG 0x80000000
467 #define MAXLONG 0x7fffffff
469 #define MAXWORD 0xffff
470 #define MAXDWORD 0xffffffff
472 #define FIELD_OFFSET(type, field) \
473 ((LONG)(INT)&(((type *)0)->field))
475 #define CONTAINING_RECORD(address, type, field) \
476 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
480 typedef struct _LIST_ENTRY {
481 struct _LIST_ENTRY *Flink;
482 struct _LIST_ENTRY *Blink;
483 } LIST_ENTRY, *PLIST_ENTRY;
485 typedef struct _SINGLE_LIST_ENTRY {
486 struct _SINGLE_LIST_ENTRY *Next;
487 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
491 #define HEAP_NO_SERIALIZE 0x00000001
492 #define HEAP_GROWABLE 0x00000002
493 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
494 #define HEAP_ZERO_MEMORY 0x00000008
495 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
496 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
497 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
498 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
499 #define HEAP_CREATE_ALIGN_16 0x00010000
500 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
502 /* This flag allows it to create heaps shared by all processes under win95,
503 FIXME: correct name */
504 #define HEAP_SHARED 0x04000000
506 #define HEAP_WINE_SEGPTR 0x10000000 /* Not a Win32 flag */
507 #define HEAP_WINE_CODESEG 0x20000000 /* Not a Win32 flag */
508 #define HEAP_WINE_CODE16SEG 0x40000000 /* Not a Win32 flag */
510 /* Processor feature flags. */
511 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
512 #define PF_FLOATING_POINT_EMULATED 1
513 #define PF_COMPARE_EXCHANGE_DOUBLE 2
514 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
515 #define PF_PPC_MOVEMEM_64BIT_OK 4
516 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
519 /* The Win32 register context */
521 /* CONTEXT is the CPU-dependent context; it should be used */
522 /* wherever a platform-specific context is needed (e.g. exception */
523 /* handling, Win32 register functions). */
525 /* CONTEXT86 is the i386-specific context; it should be used */
526 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
527 /* Win16 register functions), so that this code can be compiled */
528 /* on all platforms. */
530 #define SIZE_OF_80387_REGISTERS 80
532 typedef struct _FLOATING_SAVE_AREA
541 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
543 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
545 typedef struct _CONTEXT86
549 /* These are selected by CONTEXT_DEBUG_REGISTERS */
557 /* These are selected by CONTEXT_FLOATING_POINT */
558 FLOATING_SAVE_AREA FloatSave;
560 /* These are selected by CONTEXT_SEGMENTS */
566 /* These are selected by CONTEXT_INTEGER */
574 /* These are selected by CONTEXT_CONTROL */
583 #define CONTEXT_X86 0x00010000
584 #define CONTEXT_i386 CONTEXT_X86
585 #define CONTEXT_i486 CONTEXT_X86
587 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
588 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
589 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
590 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
591 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
592 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
594 /* i386 context definitions */
597 #define CONTEXT_CONTROL CONTEXT86_CONTROL
598 #define CONTEXT_INTEGER CONTEXT86_INTEGER
599 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
600 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
601 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
602 #define CONTEXT_FULL CONTEXT86_FULL
604 typedef CONTEXT86 CONTEXT;
606 #endif /* __i386__ */
608 /* Alpha context definitions */
611 #define CONTEXT_ALPHA 0x00020000
613 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
614 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
615 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
616 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
618 typedef struct _CONTEXT
620 /* selected by CONTEXT_FLOATING_POINT */
654 /* selected by CONTEXT_INTEGER */
688 /* selected by CONTEXT_FLOATING_POINT */
692 /* selected by CONTEXT_CONTROL */
699 #define _QUAD_PSR_OFFSET HighSoftFpcr
700 #define _QUAD_FLAGS_OFFSET HighFir
704 /* Mips context definitions */
707 #define CONTEXT_R4000 0x00010000
709 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
710 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
711 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
713 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
715 typedef struct _CONTEXT
718 /* These are selected by CONTEXT_FLOATING_POINT */
752 /* These are selected by CONTEXT_INTEGER */
788 /* These are selected by CONTEXT_FLOATING_POINT */
791 /* These are selected by CONTEXT_CONTROL */
801 /* PowerPC context definitions */
804 #define CONTEXT_CONTROL 0x0001
805 #define CONTEXT_FLOATING_POINT 0x0002
806 #define CONTEXT_INTEGER 0x0004
807 #define CONTEXT_DEBUG_REGISTERS 0x0008
808 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
812 /* These are selected by CONTEXT_FLOATING_POINT */
847 /* These are selected by CONTEXT_INTEGER */
884 /* These are selected by CONTEXT_CONTROL */
893 /* These are selected by CONTEXT_DEBUG_REGISTERS */
904 typedef struct _STACK_FRAME_HEADER
921 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
930 * There is no official CONTEXT structure defined for the SPARC
931 * architecture, so I just made one up.
933 * This structure is valid only for 32-bit SPARC architectures,
934 * not for 64-bit SPARC.
936 * Note that this structure contains only the 'top-level' registers;
937 * the rest of the register window chain is not visible.
939 * The layout follows the Solaris 'prgregset_t' structure.
943 #define CONTEXT_SPARC 0x10000000
945 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
946 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
947 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
949 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
951 typedef struct _CONTEXT
955 /* These are selected by CONTEXT_INTEGER */
989 /* These are selected by CONTEXT_CONTROL */
997 /* FIXME: floating point registers missing */
1001 #endif /* __sparc__ */
1003 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1004 #error You need to define a CONTEXT for your CPU
1007 typedef CONTEXT *PCONTEXT;
1011 /* Macros for easier access to i386 context registers */
1013 #define AX_reg(context) (*(WORD*)&(context)->Eax)
1014 #define BX_reg(context) (*(WORD*)&(context)->Ebx)
1015 #define CX_reg(context) (*(WORD*)&(context)->Ecx)
1016 #define DX_reg(context) (*(WORD*)&(context)->Edx)
1017 #define SI_reg(context) (*(WORD*)&(context)->Esi)
1018 #define DI_reg(context) (*(WORD*)&(context)->Edi)
1019 #define BP_reg(context) (*(WORD*)&(context)->Ebp)
1021 #define AL_reg(context) (*(BYTE*)&(context)->Eax)
1022 #define AH_reg(context) (*((BYTE*)&(context)->Eax + 1))
1023 #define BL_reg(context) (*(BYTE*)&(context)->Ebx)
1024 #define BH_reg(context) (*((BYTE*)&(context)->Ebx + 1))
1025 #define CL_reg(context) (*(BYTE*)&(context)->Ecx)
1026 #define CH_reg(context) (*((BYTE*)&(context)->Ecx + 1))
1027 #define DL_reg(context) (*(BYTE*)&(context)->Edx)
1028 #define DH_reg(context) (*((BYTE*)&(context)->Edx + 1))
1030 #define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
1031 #define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
1032 #define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
1033 #define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
1034 #define ISV86(context) ((context)->EFlags & 0x00020000)
1037 /* Macros to retrieve the current context */
1039 #ifdef NEED_UNDERSCORE_PREFIX
1040 # define __ASM_NAME(name) "_" name
1042 # define __ASM_NAME(name) name
1045 #ifdef NEED_TYPE_IN_DEF
1046 # define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
1048 # define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
1052 # define __ASM_GLOBAL_FUNC(name,code) \
1053 __asm__( ".align 4\n\t" \
1054 ".globl " __ASM_NAME(#name) "\n\t" \
1055 __ASM_FUNC(#name) "\n" \
1056 __ASM_NAME(#name) ":\n\t" \
1058 #else /* __GNUC__ */
1059 # define __ASM_GLOBAL_FUNC(name,code) \
1060 void __asm_dummy_##name(void) { \
1061 asm( ".align 4\n\t" \
1062 ".globl " __ASM_NAME(#name) "\n\t" \
1063 __ASM_FUNC(#name) "\n" \
1064 __ASM_NAME(#name) ":\n\t" \
1067 #endif /* __GNUC__ */
1071 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
1072 __ASM_GLOBAL_FUNC( name, \
1073 "call " __ASM_NAME("CALL32_Regs") "\n\t" \
1074 ".long " __ASM_NAME(#fn) "\n\t" \
1075 ".byte " #args ", " #args )
1076 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1077 extern void WINAPI name(void); \
1078 _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
1079 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1080 extern void WINAPI name( t1 a1 ); \
1081 _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
1082 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1083 extern void WINAPI name( t1 a1, t2 a2 ); \
1084 _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
1085 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1086 extern void WINAPI name( t1 a1, t2 a2, t3 a3 ); \
1087 _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
1088 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1089 extern void WINAPI name( t1 a1, t2 a2, t3 a3, t4 a4 ); \
1090 _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
1092 #endif /* __i386__ */
1095 /* FIXME: use getcontext() to retrieve full context */
1096 #define _GET_CONTEXT \
1098 do { memset(&context, 0, sizeof(CONTEXT)); \
1099 context.ContextFlags = CONTEXT_CONTROL; \
1100 context.pc = (DWORD)__builtin_return_address(0); \
1103 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1104 void WINAPI name ( void ) \
1105 { _GET_CONTEXT; fn( &context ); }
1106 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1107 void WINAPI name ( t1 a1 ) \
1108 { _GET_CONTEXT; fn( a1, &context ); }
1109 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1110 void WINAPI name ( t1 a1, t2 a2 ) \
1111 { _GET_CONTEXT; fn( a1, a2, &context ); }
1112 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1113 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1114 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1115 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1116 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1117 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1119 #endif /* __sparc__ */
1121 #ifndef DEFINE_REGS_ENTRYPOINT_0
1122 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
1125 /* Constructor functions */
1128 # define DECL_GLOBAL_CONSTRUCTOR(func) \
1129 static void func(void) __attribute__((constructor)); \
1130 static void func(void)
1131 #else /* __GNUC__ */
1133 # define DECL_GLOBAL_CONSTRUCTOR(func) \
1134 static void __dummy_init_##func(void) { \
1135 asm(".section .init,\"ax\"\n\t" \
1136 "call " #func "\n\t" \
1138 static void func(void)
1139 # else /* __i386__ */
1140 # error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
1142 #endif /* __GNUC__ */
1144 /* Segment register access */
1148 # define __DEFINE_GET_SEG(seg) \
1149 extern inline unsigned short __get_##seg(void) \
1150 { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
1151 # define __DEFINE_SET_SEG(seg) \
1152 extern inline void __set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
1153 # else /* __GNUC__ */
1154 # define __DEFINE_GET_SEG(seg) extern unsigned short __get_##seg(void);
1155 # define __DEFINE_SET_SEG(seg) extern void __set_##seg(unsigned int);
1156 # endif /* __GNUC__ */
1157 #else /* __i386__ */
1158 # define __DEFINE_GET_SEG(seg) inline static unsigned short __get_##seg(void) { return 0; }
1159 # define __DEFINE_SET_SEG(seg) /* nothing */
1160 #endif /* __i386__ */
1162 __DEFINE_GET_SEG(cs)
1163 __DEFINE_GET_SEG(ds)
1164 __DEFINE_GET_SEG(es)
1165 __DEFINE_GET_SEG(fs)
1166 __DEFINE_GET_SEG(gs)
1167 __DEFINE_GET_SEG(ss)
1168 __DEFINE_SET_SEG(fs)
1169 __DEFINE_SET_SEG(gs)
1170 #undef __DEFINE_GET_SEG
1171 #undef __DEFINE_SET_SEG
1173 #endif /* __WINE__ */
1181 #define MAKELCID(l, s) (MAKELONG(l, s))
1183 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1184 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1185 #define SUBLANGID(l) ((WORD)(l) >> 10)
1187 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1188 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1190 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1191 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1192 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1193 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1194 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1196 /* FIXME: are the symbolic names correct for LIDs: 0x17, 0x20, 0x28,
1197 * 0x2a, 0x2b, 0x2c, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
1198 * 0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3e, 0x3f, 0x41, 0x43, 0x44,
1199 * 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
1202 #define LANG_NEUTRAL 0x00
1203 #define LANG_AFRIKAANS 0x36
1204 #define LANG_ALBANIAN 0x1c
1205 #define LANG_ARABIC 0x01
1206 #define LANG_ARMENIAN 0x2b
1207 #define LANG_ASSAMESE 0x4d
1208 #define LANG_AZERI 0x2c
1209 #define LANG_BASQUE 0x2d
1210 #define LANG_BENGALI 0x45
1211 #define LANG_BULGARIAN 0x02
1212 #define LANG_BYELORUSSIAN 0x23
1213 #define LANG_CATALAN 0x03
1214 #define LANG_CHINESE 0x04
1215 #define LANG_SERBO_CROATIAN 0x1a
1216 #define LANG_CROATIAN LANG_SERBO_CROATIAN
1217 #define LANG_SERBIAN LANG_SERBO_CROATIAN
1218 #define LANG_CZECH 0x05
1219 #define LANG_DANISH 0x06
1220 #define LANG_DUTCH 0x13
1221 #define LANG_ENGLISH 0x09
1222 #define LANG_ESTONIAN 0x25
1223 #define LANG_FAEROESE 0x38
1224 #define LANG_FARSI 0x29
1225 #define LANG_FINNISH 0x0b
1226 #define LANG_FRENCH 0x0c
1227 #define LANG_GAELIC 0x3c
1228 #define LANG_GEORGIAN 0x37
1229 #define LANG_GERMAN 0x07
1230 #define LANG_GREEK 0x08
1231 #define LANG_GUJARATI 0x47
1232 #define LANG_HEBREW 0x0D
1233 #define LANG_HINDI 0x39
1234 #define LANG_HUNGARIAN 0x0e
1235 #define LANG_ICELANDIC 0x0f
1236 #define LANG_INDONESIAN 0x21
1237 #define LANG_ITALIAN 0x10
1238 #define LANG_JAPANESE 0x11
1239 #define LANG_KANNADA 0x4b
1240 #define LANG_KAZAKH 0x3f
1241 #define LANG_KONKANI 0x57
1242 #define LANG_KOREAN 0x12
1243 #define LANG_LATVIAN 0x26
1244 #define LANG_LITHUANIAN 0x27
1245 #define LANG_MACEDONIAN 0x2f
1246 #define LANG_MALAY 0x3e
1247 #define LANG_MALAYALAM 0x4c
1248 #define LANG_MALTESE 0x3a
1249 #define LANG_MAORI 0x28
1250 #define LANG_MARATHI 0x4e
1251 #define LANG_NORWEGIAN 0x14
1252 #define LANG_ORIYA 0x48
1253 #define LANG_POLISH 0x15
1254 #define LANG_PORTUGUESE 0x16
1255 #define LANG_PUNJABI 0x46
1256 #define LANG_RHAETO_ROMANCE 0x17
1257 #define LANG_ROMANIAN 0x18
1258 #define LANG_RUSSIAN 0x19
1259 #define LANG_SAAMI 0x3b
1260 #define LANG_SANSKRIT 0x4f
1261 #define LANG_SLOVAK 0x1b
1262 #define LANG_SLOVENIAN 0x24
1263 #define LANG_SORBIAN 0x2e
1264 #define LANG_SPANISH 0x0a
1265 #define LANG_SUTU 0x30
1266 #define LANG_SWAHILI 0x41
1267 #define LANG_SWEDISH 0x1d
1268 #define LANG_TAMIL 0x49
1269 #define LANG_TATAR 0x44
1270 #define LANG_TELUGU 0x4a
1271 #define LANG_THAI 0x1e
1272 #define LANG_TSONGA 0x31
1273 #define LANG_TSWANA 0x32
1274 #define LANG_TURKISH 0x1f
1275 #define LANG_UKRAINIAN 0x22
1276 #define LANG_URDU 0x20
1277 #define LANG_UZBEK 0x43
1278 #define LANG_VENDA 0x33
1279 #define LANG_VIETNAMESE 0x2a
1280 #define LANG_XHOSA 0x34
1281 #define LANG_ZULU 0x35
1282 /* non standard; keep the number high enough (but < 0xff) */
1283 #define LANG_ESPERANTO 0x8f
1284 #define LANG_WALON 0x90
1285 #define LANG_CORNISH 0x91
1286 #define LANG_WELSH 0x92
1287 #define LANG_BRETON 0x93
1289 /* Sublanguage definitions */
1290 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
1291 #define SUBLANG_DEFAULT 0x01 /* user default */
1292 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
1294 #define SUBLANG_ARABIC 0x01
1295 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
1296 #define SUBLANG_ARABIC_IRAQ 0x02
1297 #define SUBLANG_ARABIC_EGYPT 0x03
1298 #define SUBLANG_ARABIC_LIBYA 0x04
1299 #define SUBLANG_ARABIC_ALGERIA 0x05
1300 #define SUBLANG_ARABIC_MOROCCO 0x06
1301 #define SUBLANG_ARABIC_TUNISIA 0x07
1302 #define SUBLANG_ARABIC_OMAN 0x08
1303 #define SUBLANG_ARABIC_YEMEN 0x09
1304 #define SUBLANG_ARABIC_SYRIA 0x0a
1305 #define SUBLANG_ARABIC_JORDAN 0x0b
1306 #define SUBLANG_ARABIC_LEBANON 0x0c
1307 #define SUBLANG_ARABIC_KUWAIT 0x0d
1308 #define SUBLANG_ARABIC_UAE 0x0e
1309 #define SUBLANG_ARABIC_BAHRAIN 0x0f
1310 #define SUBLANG_ARABIC_QATAR 0x10
1311 #define SUBLANG_CHINESE_TRADITIONAL 0x01
1312 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
1313 #define SUBLANG_CHINESE_HONGKONG 0x03
1314 #define SUBLANG_CHINESE_SINGAPORE 0x04
1315 #define SUBLANG_CHINESE_MACAU 0x05
1316 #define SUBLANG_DUTCH 0x01
1317 #define SUBLANG_DUTCH_BELGIAN 0x02
1318 #define SUBLANG_DUTCH_SURINAM 0x03
1319 #define SUBLANG_ENGLISH_US 0x01
1320 #define SUBLANG_ENGLISH_UK 0x02
1321 #define SUBLANG_ENGLISH_AUS 0x03
1322 #define SUBLANG_ENGLISH_CAN 0x04
1323 #define SUBLANG_ENGLISH_NZ 0x05
1324 #define SUBLANG_ENGLISH_EIRE 0x06
1325 #define SUBLANG_ENGLISH_SAFRICA 0x07
1326 #define SUBLANG_ENGLISH_JAMAICA 0x08
1327 #define SUBLANG_ENGLISH_CARRIBEAN 0x09
1328 #define SUBLANG_ENGLISH_BELIZE 0x0a
1329 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
1330 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
1331 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
1332 #define SUBLANG_FRENCH 0x01
1333 #define SUBLANG_FRENCH_BELGIAN 0x02
1334 #define SUBLANG_FRENCH_CANADIAN 0x03
1335 #define SUBLANG_FRENCH_SWISS 0x04
1336 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
1337 #define SUBLANG_FRENCH_MONACO 0x06
1338 #define SUBLANG_GERMAN 0x01
1339 #define SUBLANG_GERMAN_SWISS 0x02
1340 #define SUBLANG_GERMAN_AUSTRIAN 0x03
1341 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
1342 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
1343 #define SUBLANG_ITALIAN 0x01
1344 #define SUBLANG_ITALIAN_SWISS 0x02
1345 #define SUBLANG_KOREAN 0x01
1346 #define SUBLANG_KOREAN_JOHAB 0x02
1347 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
1348 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
1349 #define SUBLANG_PORTUGUESE 0x02
1350 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
1351 #define SUBLANG_SPANISH 0x01
1352 #define SUBLANG_SPANISH_MEXICAN 0x02
1353 #define SUBLANG_SPANISH_MODERN 0x03
1354 #define SUBLANG_SPANISH_GUATEMALA 0x04
1355 #define SUBLANG_SPANISH_COSTARICA 0x05
1356 #define SUBLANG_SPANISH_PANAMA 0x06
1357 #define SUBLANG_SPANISH_DOMINICAN 0x07
1358 #define SUBLANG_SPANISH_VENEZUELA 0x08
1359 #define SUBLANG_SPANISH_COLOMBIA 0x09
1360 #define SUBLANG_SPANISH_PERU 0x0a
1361 #define SUBLANG_SPANISH_ARGENTINA 0x0b
1362 #define SUBLANG_SPANISH_ECUADOR 0x0c
1363 #define SUBLANG_SPANISH_CHILE 0x0d
1364 #define SUBLANG_SPANISH_URUGUAY 0x0e
1365 #define SUBLANG_SPANISH_PARAGUAY 0x0f
1366 #define SUBLANG_SPANISH_BOLIVIA 0x10
1367 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
1368 #define SUBLANG_SPANISH_HONDURAS 0x12
1369 #define SUBLANG_SPANISH_NICARAGUA 0x13
1370 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
1371 /* FIXME: I don't know the symbolic names for those */
1372 #define SUBLANG_ROMANIAN 0x01
1373 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
1374 #define SUBLANG_RUSSIAN 0x01
1375 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
1376 #define SUBLANG_CROATIAN 0x01
1377 #define SUBLANG_SERBIAN 0x02
1378 #define SUBLANG_SERBIAN_LATIN 0x03
1379 #define SUBLANG_SWEDISH 0x01
1380 #define SUBLANG_SWEDISH_FINLAND 0x02
1381 #define SUBLANG_LITHUANIAN 0x01
1382 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
1383 #define SUBLANG_AZERI 0x01
1384 #define SUBLANG_AZERI_CYRILLIC 0x02
1385 #define SUBLANG_GAELIC 0x01
1386 #define SUBLANG_GAELIC_SCOTTISH 0x02
1387 #define SUBLANG_GAELIC_MANX 0x03
1388 #define SUBLANG_MALAY 0x01
1389 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
1390 #define SUBLANG_UZBEK 0x01
1391 #define SUBLANG_UZBEK_CYRILLIC 0x02
1392 #define SUBLANG_URDU_PAKISTAN 0x01
1400 #define SORT_DEFAULT 0x0
1401 #define SORT_JAPANESE_XJIS 0x0
1402 #define SORT_JAPANESE_UNICODE 0x1
1403 #define SORT_CHINESE_BIG5 0x0
1404 #define SORT_CHINESE_UNICODE 0x1
1405 #define SORT_KOREAN_KSC 0x0
1406 #define SORT_KOREAN_UNICODE 0x1
1411 * Definitions for IsTextUnicode()
1414 #define IS_TEXT_UNICODE_ASCII16 0x0001
1415 #define IS_TEXT_UNICODE_STATISTICS 0x0002
1416 #define IS_TEXT_UNICODE_CONTROLS 0x0004
1417 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
1418 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
1419 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
1420 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1421 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
1422 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
1423 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
1424 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
1425 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
1426 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
1427 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
1428 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
1429 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
1437 #define STATUS_SUCCESS 0x00000000
1438 #define STATUS_WAIT_0 0x00000000
1439 #define STATUS_ABANDONED_WAIT_0 0x00000080
1440 #define STATUS_USER_APC 0x000000C0
1441 #define STATUS_TIMEOUT 0x00000102
1442 #define STATUS_PENDING 0x00000103
1444 #define STATUS_GUARD_PAGE_VIOLATION 0x80000001
1445 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
1446 #define STATUS_BREAKPOINT 0x80000003
1447 #define STATUS_SINGLE_STEP 0x80000004
1448 #define STATUS_BUFFER_OVERFLOW 0x80000005
1449 #define STATUS_NO_MORE_FILES 0x80000006
1450 #define STATUS_WAKE_SYSTEM_DEBUGGER 0x80000007
1452 #define STATUS_HANDLES_CLOSED 0x8000000A
1453 #define STATUS_NO_INHERITANCE 0x8000000B
1454 #define STATUS_GUID_SUBSTITUTION_MADE 0x8000000C
1455 #define STATUS_PARTIAL_COPY 0x8000000D
1456 #define STATUS_DEVICE_PAPER_EMPTY 0x8000000E
1457 #define STATUS_DEVICE_POWERED_OFF 0x8000000F
1458 #define STATUS_DEVICE_OFF_LINE 0x80000010
1459 #define STATUS_DEVICE_BUSY 0x80000011
1460 #define STATUS_NO_MORE_EAS 0x80000012
1461 #define STATUS_INVALID_EA_NAME 0x80000013
1462 #define STATUS_EA_LIST_INCONSISTENT 0x80000014
1463 #define STATUS_INVALID_EA_FLAG 0x80000015
1464 #define STATUS_VERIFY_REQUIRED 0x80000016
1465 #define STATUS_EXTRANEOUS_INFORMATION 0x80000017
1466 #define STATUS_RXACT_COMMIT_NECESSARY 0x80000018
1467 #define STATUS_NO_MORE_ENTRIES 0x8000001A
1468 #define STATUS_FILEMARK_DETECTED 0x8000001B
1469 #define STATUS_MEDIA_CHANGED 0x8000001C
1470 #define STATUS_BUS_RESET 0x8000001D
1471 #define STATUS_END_OF_MEDIA 0x8000001E
1472 #define STATUS_BEGINNING_OF_MEDIA 0x8000001F
1473 #define STATUS_MEDIA_CHECK 0x80000020
1474 #define STATUS_SETMARK_DETECTED 0x80000021
1475 #define STATUS_NO_DATA_DETECTED 0x80000022
1476 #define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
1477 #define STATUS_SERVER_HAS_OPEN_HANDLES 0x80000024
1478 #define STATUS_ALREADY_DISCONNECTED 0x80000025
1479 #define STATUS_LONGJUMP 0x80000026
1481 #define STATUS_UNSUCCESSFUL 0xC0000001
1482 #define STATUS_NOT_IMPLEMENTED 0xC0000002
1483 #define STATUS_INVALID_INFO_CLASS 0xC0000003
1484 #define STATUS_INFO_LENGTH_MISMATCH 0xC0000004
1485 #define STATUS_ACCESS_VIOLATION 0xC0000005
1486 #define STATUS_IN_PAGE_ERROR 0xC0000006
1487 #define STATUS_PAGEFILE_QUOTA 0xC0000007
1488 #define STATUS_INVALID_HANDLE 0xC0000008
1489 #define STATUS_BAD_INITIAL_STACK 0xC0000009
1490 #define STATUS_BAD_INITIAL_PC 0xC000000A
1491 #define STATUS_INVALID_CID 0xC000000B
1492 #define STATUS_TIMER_NOT_CANCELED 0xC000000C
1493 #define STATUS_INVALID_PARAMETER 0xC000000D
1494 #define STATUS_NO_SUCH_DEVICE 0xC000000E
1495 #define STATUS_NO_SUCH_FILE 0xC000000F
1496 #define STATUS_INVALID_DEVICE_REQUEST 0xC0000010
1497 #define STATUS_END_OF_FILE 0xC0000011
1498 #define STATUS_WRONG_VOLUME 0xC0000012
1499 #define STATUS_NO_MEDIA_IN_DEVICE 0xC0000013
1500 #define STATUS_UNRECOGNIZED_MEDIA 0xC0000014
1501 #define STATUS_NONEXISTENT_SECTOR 0xC0000015
1502 #define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
1503 #define STATUS_NO_MEMORY 0xC0000017
1504 #define STATUS_CONFLICTING_ADDRESSES 0xC0000018
1505 #define STATUS_NOT_MAPPED_VIEW 0xC0000019
1506 #define STATUS_UNABLE_TO_FREE_VM 0xC000001A
1507 #define STATUS_UNABLE_TO_DELETE_SECTION 0xC000001B
1508 #define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
1509 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
1510 #define STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
1511 #define STATUS_INVALID_VIEW_SIZE 0xC000001F
1512 #define STATUS_INVALID_FILE_FOR_SECTION 0xC0000020
1513 #define STATUS_ALREADY_COMMITTED 0xC0000021
1514 #define STATUS_ACCESS_DENIED 0xC0000022
1515 #define STATUS_BUFFER_TOO_SMALL 0xC0000023
1516 #define STATUS_OBJECT_TYPE_MISMATCH 0xC0000024
1517 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
1518 #define STATUS_INVALID_DISPOSITION 0xC0000026
1519 #define STATUS_UNWIND 0xC0000027
1520 #define STATUS_BAD_STACK 0xC0000028
1521 #define STATUS_INVALID_UNWIND_TARGET 0xC0000029
1522 #define STATUS_NOT_LOCKED 0xC000002A
1523 #define STATUS_PARITY_ERROR 0xC000002B
1524 #define STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002C
1525 #define STATUS_NOT_COMMITTED 0xC000002D
1526 #define STATUS_INVALID_PORT_ATTRIBUTES 0xC000002E
1527 #define STATUS_PORT_MESSAGE_TOO_LONG 0xC000002F
1528 #define STATUS_INVALID_PARAMETER_MIX 0xC0000030
1529 #define STATUS_INVALID_QUOTA_LOWER 0xC0000031
1530 #define STATUS_DISK_CORRUPT_ERROR 0xC0000032
1531 #define STATUS_OBJECT_NAME_INVALID 0xC0000033
1532 #define STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034
1533 #define STATUS_OBJECT_NAME_COLLISION 0xC0000035
1534 #define STATUS_PORT_DISCONNECTED 0xC0000037
1535 #define STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038
1536 #define STATUS_OBJECT_PATH_INVALID 0xC0000039
1537 #define STATUS_OBJECT_PATH_NOT_FOUND 0xC000003A
1538 #define STATUS_PATH_SYNTAX_BAD 0xC000003B
1539 #define STATUS_DATA_OVERRUN 0xC000003C
1540 #define STATUS_DATA_LATE_ERROR 0xC000003D
1541 #define STATUS_DATA_ERROR 0xC000003E
1542 #define STATUS_CRC_ERROR 0xC000003F
1543 #define STATUS_SECTION_TOO_BIG 0xC0000040
1544 #define STATUS_PORT_CONNECTION_REFUSED 0xC0000041
1545 #define STATUS_INVALID_PORT_HANDLE 0xC0000042
1546 #define STATUS_SHARING_VIOLATION 0xC0000043
1547 #define STATUS_QUOTA_EXCEEDED 0xC0000044
1548 #define STATUS_INVALID_PAGE_PROTECTION 0xC0000045
1549 #define STATUS_MUTANT_NOT_OWNED 0xC0000046
1550 #define STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047
1551 #define STATUS_PORT_ALREADY_SET 0xC0000048
1552 #define STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004A
1553 #define STATUS_LOCK_NOT_GRANTED 0xC0000054 /* FIXME: not sure */
1554 #define STATUS_FILE_LOCK_CONFLICT 0xC0000055 /* FIXME: not sure */
1555 #define STATUS_UNKNOWN_REVISION 0xC0000058
1556 #define STATUS_INVALID_SECURITY_DESCR 0xC0000079
1557 #define STATUS_DISK_FULL 0xC000007F
1558 #define STATUS_SECTION_NOT_EXTENDED 0xC0000087
1559 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
1560 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
1561 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
1562 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
1563 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
1564 #define STATUS_FLOAT_OVERFLOW 0xC0000091
1565 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
1566 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
1567 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
1568 #define STATUS_INTEGER_OVERFLOW 0xC0000095
1569 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
1570 #define STATUS_MEDIA_WRITE_PROTECTED 0XC00000A2
1571 #define STATUS_INVALID_PARAMETER_2 0xC00000F0
1572 #define STATUS_STACK_OVERFLOW 0xC00000FD
1573 #define STATUS_DIRECTORY_NOT_EMPTY 0xC0000101
1574 #define STATUS_TOO_MANY_OPENED_FILES 0xC000011F
1575 #define STATUS_CONTROL_C_EXIT 0xC000013A
1576 #define STATUS_PIPE_BROKEN 0xC000014B
1577 #define STATUS_NOT_REGISTRY_FILE 0xC000015C
1578 #define STATUS_PARTITION_FAILURE 0xC0000172
1579 #define STATUS_INVALID_BLOCK_LENGTH 0xC0000173
1580 #define STATUS_DEVICE_NOT_PARTITIONED 0xC0000174
1581 #define STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175
1582 #define STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176
1583 #define STATUS_EOM_OVERFLOW 0xC0000177
1584 #define STATUS_NO_MEDIA 0xC0000178
1585 #define STATUS_NO_SUCH_MEMBER 0xC000017A
1586 #define STATUS_INVALID_MEMBER 0xC000017B
1587 #define STATUS_KEY_DELETED 0xC000017C
1588 #define STATUS_NO_LOG_SPACE 0xC000017D
1589 #define STATUS_TOO_MANY_SIDS 0xC000017E
1590 #define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
1591 #define STATUS_KEY_HAS_CHILDREN 0xC0000180
1592 #define STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181
1593 #define STATUS_DEVICE_CONFIGURATION_ERROR0xC0000182
1594 #define STATUS_DRIVER_INTERNAL_ERROR 0xC0000183
1595 #define STATUS_INVALID_DEVICE_STATE 0xC0000184
1596 #define STATUS_IO_DEVICE_ERROR 0xC0000185
1597 #define STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186
1598 #define STATUS_BACKUP_CONTROLLER 0xC0000187
1599 #define STATUS_LOG_FILE_FULL 0xC0000188
1600 #define STATUS_TOO_LATE 0xC0000189
1601 #define STATUS_NO_TRUST_LSA_SECRET 0xC000018A
1602 #define STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018B
1603 #define STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018C
1604 #define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
1605 #define STATUS_EVENTLOG_FILE_CORRUPT 0xC000018E
1606 #define STATUS_EVENTLOG_CANT_START 0xC000018F
1607 #define STATUS_TRUST_FAILURE 0xC0000190
1608 #define STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191
1609 #define STATUS_NETLOGON_NOT_STARTED 0xC0000192
1610 #define STATUS_ACCOUNT_EXPIRED 0xC0000193
1611 #define STATUS_POSSIBLE_DEADLOCK 0xC0000194
1612 #define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
1613 #define STATUS_REMOTE_SESSION_LIMIT 0xC0000196
1614 #define STATUS_EVENTLOG_FILE_CHANGED 0xC0000197
1615 #define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
1616 #define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
1617 #define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
1618 #define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
1619 #define STATUS_FS_DRIVER_REQUIRED 0xC000019C
1621 #define STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204
1623 #define MAXIMUM_WAIT_OBJECTS 64
1624 #define MAXIMUM_SUSPEND_COUNT 127
1628 * Return values from the actual exception handlers
1631 #define ExceptionContinueExecution 0
1632 #define ExceptionContinueSearch 1
1633 #define ExceptionNestedException 2
1634 #define ExceptionCollidedUnwind 3
1637 * Return values from filters in except() and from UnhandledExceptionFilter
1640 #define EXCEPTION_EXECUTE_HANDLER 1
1641 #define EXCEPTION_CONTINUE_SEARCH 0
1642 #define EXCEPTION_CONTINUE_EXECUTION -1
1645 * From OS/2 2.0 exception handling
1646 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1649 #define EH_NONCONTINUABLE 0x01
1650 #define EH_UNWINDING 0x02
1651 #define EH_EXIT_UNWIND 0x04
1652 #define EH_STACK_INVALID 0x08
1653 #define EH_NESTED_CALL 0x10
1655 #define EXCEPTION_CONTINUABLE 0
1656 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
1659 * The exception record used by Win32 to give additional information
1660 * about exception to exception handlers.
1663 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1665 typedef struct __EXCEPTION_RECORD
1667 DWORD ExceptionCode;
1668 DWORD ExceptionFlags;
1669 struct __EXCEPTION_RECORD *ExceptionRecord;
1671 LPVOID ExceptionAddress;
1672 DWORD NumberParameters;
1673 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1674 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1677 * The exception pointers structure passed to exception filters
1678 * in except() and the UnhandledExceptionFilter().
1681 typedef struct _EXCEPTION_POINTERS
1683 PEXCEPTION_RECORD ExceptionRecord;
1684 PCONTEXT ContextRecord;
1685 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1689 * The exception frame, used for registering exception handlers
1690 * Win32 cares only about this, but compilers generally emit
1691 * larger exception frames for their own use.
1694 struct __EXCEPTION_FRAME;
1696 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
1697 PCONTEXT,struct __EXCEPTION_FRAME **);
1699 typedef struct __EXCEPTION_FRAME
1701 struct __EXCEPTION_FRAME *Prev;
1702 PEXCEPTION_HANDLER Handler;
1703 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
1705 #include "poppack.h"
1708 * function pointer to a exception filter
1711 typedef LONG CALLBACK (*PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1712 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1714 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1715 LPTOP_LEVEL_EXCEPTION_FILTER
1716 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1718 /* status values for ContinueDebugEvent */
1719 #define DBG_CONTINUE 0x00010002
1720 #define DBG_TERMINATE_THREAD 0x40010003
1721 #define DBG_TERMINATE_PROCESS 0x40010004
1722 #define DBG_CONTROL_C 0x40010005
1723 #define DBG_CONTROL_BREAK 0x40010008
1724 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
1726 typedef struct _NT_TIB
1728 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1736 PVOID ArbitraryUserPointer;
1737 struct _NT_TIB *Self;
1742 #if defined(__i386__) && defined(__GNUC__)
1743 extern inline struct _TEB WINAPI *NtCurrentTeb(void);
1744 extern inline struct _TEB WINAPI *NtCurrentTeb(void)
1747 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1751 extern struct _TEB WINAPI *NtCurrentTeb(void);
1756 * File formats definitions
1759 typedef struct _IMAGE_DOS_HEADER {
1760 WORD e_magic; /* 00: MZ Header signature */
1761 WORD e_cblp; /* 02: Bytes on last page of file */
1762 WORD e_cp; /* 04: Pages in file */
1763 WORD e_crlc; /* 06: Relocations */
1764 WORD e_cparhdr; /* 08: Size of header in paragraphs */
1765 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
1766 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
1767 WORD e_ss; /* 0e: Initial (relative) SS value */
1768 WORD e_sp; /* 10: Initial SP value */
1769 WORD e_csum; /* 12: Checksum */
1770 WORD e_ip; /* 14: Initial IP value */
1771 WORD e_cs; /* 16: Initial (relative) CS value */
1772 WORD e_lfarlc; /* 18: File address of relocation table */
1773 WORD e_ovno; /* 1a: Overlay number */
1774 WORD e_res[4]; /* 1c: Reserved words */
1775 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
1776 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
1777 WORD e_res2[10]; /* 28: Reserved words */
1778 DWORD e_lfanew; /* 3c: Offset to extended header */
1779 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1781 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
1782 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
1783 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
1784 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
1785 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
1786 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
1789 * This is the Windows executable (NE) header.
1790 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
1794 WORD ne_magic; /* 00 NE signature 'NE' */
1795 BYTE ne_ver; /* 02 Linker version number */
1796 BYTE ne_rev; /* 03 Linker revision number */
1797 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
1798 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
1799 LONG ne_crc; /* 08 Checksum */
1800 WORD ne_flags; /* 0c Flags about segments in this file */
1801 WORD ne_autodata; /* 0e Automatic data segment number */
1802 WORD ne_heap; /* 10 Initial size of local heap */
1803 WORD ne_stack; /* 12 Initial size of stack */
1804 DWORD ne_csip; /* 14 Initial CS:IP */
1805 DWORD ne_sssp; /* 18 Initial SS:SP */
1806 WORD ne_cseg; /* 1c # of entries in segment table */
1807 WORD ne_cmod; /* 1e # of entries in module reference tab. */
1808 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
1809 WORD ne_segtab; /* 22 Offset to segment table */
1810 WORD ne_rsrctab; /* 24 Offset to resource table */
1811 WORD ne_restab; /* 26 Offset to resident-name table */
1812 WORD ne_modtab; /* 28 Offset to module reference table */
1813 WORD ne_imptab; /* 2a Offset to imported name table */
1814 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
1815 WORD ne_cmovent; /* 30 # of movable entry points */
1816 WORD ne_align; /* 32 Logical sector alignment shift count */
1817 WORD ne_cres; /* 34 # of resource segments */
1818 BYTE ne_exetyp; /* 36 Flags indicating target OS */
1819 BYTE ne_flagsothers; /* 37 Additional information flags */
1820 WORD fastload_offset; /* 38 Offset to fast load area (should be ne_pretthunks)*/
1821 WORD fastload_length; /* 3a Length of fast load area (should be ne_psegrefbytes) */
1822 WORD ne_swaparea; /* 3c Reserved by Microsoft */
1823 WORD ne_expver; /* 3e Expected Windows version number */
1824 } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
1826 typedef struct _IMAGE_VXD_HEADER {
1841 DWORD e32_lastpagesize;
1842 DWORD e32_fixupsize;
1859 DWORD e32_impmodcnt;
1865 DWORD e32_cbnrestab;
1868 DWORD e32_debuginfo;
1870 DWORD e32_instpreload;
1871 DWORD e32_instdemand;
1874 DWORD e32_winresoff;
1875 DWORD e32_winreslen;
1878 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1881 /* These defines describe the meanings of the bits in the Characteristics
1884 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
1885 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
1886 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
1887 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
1888 #define IMAGE_FILE_16BIT_MACHINE 0x0040
1889 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
1890 #define IMAGE_FILE_32BIT_MACHINE 0x0100
1891 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
1892 #define IMAGE_FILE_SYSTEM 0x1000
1893 #define IMAGE_FILE_DLL 0x2000
1894 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
1896 /* These are the settings of the Machine field. */
1897 #define IMAGE_FILE_MACHINE_UNKNOWN 0
1898 #define IMAGE_FILE_MACHINE_I860 0x14d
1899 #define IMAGE_FILE_MACHINE_I386 0x14c
1900 #define IMAGE_FILE_MACHINE_R3000 0x162
1901 #define IMAGE_FILE_MACHINE_R4000 0x166
1902 #define IMAGE_FILE_MACHINE_R10000 0x168
1903 #define IMAGE_FILE_MACHINE_ALPHA 0x184
1904 #define IMAGE_FILE_MACHINE_POWERPC 0x1F0
1906 #define IMAGE_SIZEOF_FILE_HEADER 20
1908 /* Possible Magic values */
1909 #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
1910 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
1912 /* These are indexes into the DataDirectory array */
1913 #define IMAGE_FILE_EXPORT_DIRECTORY 0
1914 #define IMAGE_FILE_IMPORT_DIRECTORY 1
1915 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
1916 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
1917 #define IMAGE_FILE_SECURITY_DIRECTORY 4
1918 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
1919 #define IMAGE_FILE_DEBUG_DIRECTORY 6
1920 #define IMAGE_FILE_DESCRIPTION_STRING 7
1921 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
1922 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
1923 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
1925 /* Directory Entries, indices into the DataDirectory array */
1927 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
1928 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
1929 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
1930 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
1931 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
1932 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
1933 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
1934 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
1935 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
1936 #define IMAGE_DIRECTORY_ENTRY_TLS 9
1937 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
1938 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
1939 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
1940 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
1941 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
1943 /* Subsystem Values */
1945 #define IMAGE_SUBSYSTEM_UNKNOWN 0
1946 #define IMAGE_SUBSYSTEM_NATIVE 1
1947 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
1948 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem*/
1949 #define IMAGE_SUBSYSTEM_OS2_CUI 5
1950 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
1952 typedef struct _IMAGE_FILE_HEADER {
1954 WORD NumberOfSections;
1955 DWORD TimeDateStamp;
1956 DWORD PointerToSymbolTable;
1957 DWORD NumberOfSymbols;
1958 WORD SizeOfOptionalHeader;
1959 WORD Characteristics;
1960 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1962 typedef struct _IMAGE_DATA_DIRECTORY {
1963 DWORD VirtualAddress;
1965 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1967 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
1969 typedef struct _IMAGE_OPTIONAL_HEADER {
1971 /* Standard fields */
1974 BYTE MajorLinkerVersion;
1975 BYTE MinorLinkerVersion;
1977 DWORD SizeOfInitializedData;
1978 DWORD SizeOfUninitializedData;
1979 DWORD AddressOfEntryPoint;
1983 /* NT additional fields */
1986 DWORD SectionAlignment;
1987 DWORD FileAlignment;
1988 WORD MajorOperatingSystemVersion;
1989 WORD MinorOperatingSystemVersion;
1990 WORD MajorImageVersion;
1991 WORD MinorImageVersion;
1992 WORD MajorSubsystemVersion;
1993 WORD MinorSubsystemVersion;
1994 DWORD Win32VersionValue;
1996 DWORD SizeOfHeaders;
1999 WORD DllCharacteristics;
2000 DWORD SizeOfStackReserve;
2001 DWORD SizeOfStackCommit;
2002 DWORD SizeOfHeapReserve;
2003 DWORD SizeOfHeapCommit;
2005 DWORD NumberOfRvaAndSizes;
2006 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2007 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
2009 typedef struct _IMAGE_NT_HEADERS {
2011 IMAGE_FILE_HEADER FileHeader;
2012 IMAGE_OPTIONAL_HEADER OptionalHeader;
2013 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
2015 #define IMAGE_SIZEOF_SHORT_NAME 8
2017 typedef struct _IMAGE_SECTION_HEADER {
2018 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2020 DWORD PhysicalAddress;
2023 DWORD VirtualAddress;
2024 DWORD SizeOfRawData;
2025 DWORD PointerToRawData;
2026 DWORD PointerToRelocations;
2027 DWORD PointerToLinenumbers;
2028 WORD NumberOfRelocations;
2029 WORD NumberOfLinenumbers;
2030 DWORD Characteristics;
2031 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2033 #define IMAGE_SIZEOF_SECTION_HEADER 40
2035 #define IMAGE_FIRST_SECTION(ntheader) \
2036 ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2037 ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2039 /* These defines are for the Characteristics bitfield. */
2040 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2041 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2042 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2043 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2044 /* #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved */
2045 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2047 #define IMAGE_SCN_CNT_CODE 0x00000020
2048 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2049 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2051 #define IMAGE_SCN_LNK_OTHER 0x00000100
2052 #define IMAGE_SCN_LNK_INFO 0x00000200
2053 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2054 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2055 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2057 /* 0x00002000 - Reserved */
2058 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2059 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2061 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2062 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2063 #define IMAGE_SCN_MEM_16BIT 0x00020000
2064 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2065 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2067 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2068 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2069 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2070 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2071 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2072 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2073 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2074 /* 0x00800000 - Unused */
2076 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2079 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2080 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2081 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2082 #define IMAGE_SCN_MEM_SHARED 0x10000000
2083 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2084 #define IMAGE_SCN_MEM_READ 0x40000000
2085 #define IMAGE_SCN_MEM_WRITE 0x80000000
2087 #include "pshpack2.h"
2089 typedef struct _IMAGE_SYMBOL {
2099 SHORT SectionNumber;
2102 BYTE NumberOfAuxSymbols;
2104 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2106 #define IMAGE_SIZEOF_SYMBOL 18
2108 typedef struct _IMAGE_LINENUMBER {
2110 DWORD SymbolTableIndex;
2111 DWORD VirtualAddress;
2115 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2117 #define IMAGE_SIZEOF_LINENUMBER 6
2119 typedef union _IMAGE_AUX_SYMBOL {
2131 DWORD PointerToLinenumber;
2132 DWORD PointerToNextFunction;
2141 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2145 WORD NumberOfRelocations;
2146 WORD NumberOfLinenumbers;
2152 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2154 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2156 #include "poppack.h"
2158 #define IMAGE_SYM_UNDEFINED (SHORT)0
2159 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2160 #define IMAGE_SYM_DEBUG (SHORT)-2
2162 #define IMAGE_SYM_TYPE_NULL 0x0000
2163 #define IMAGE_SYM_TYPE_VOID 0x0001
2164 #define IMAGE_SYM_TYPE_CHAR 0x0002
2165 #define IMAGE_SYM_TYPE_SHORT 0x0003
2166 #define IMAGE_SYM_TYPE_INT 0x0004
2167 #define IMAGE_SYM_TYPE_LONG 0x0005
2168 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2169 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2170 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2171 #define IMAGE_SYM_TYPE_UNION 0x0009
2172 #define IMAGE_SYM_TYPE_ENUM 0x000A
2173 #define IMAGE_SYM_TYPE_MOE 0x000B
2174 #define IMAGE_SYM_TYPE_BYTE 0x000C
2175 #define IMAGE_SYM_TYPE_WORD 0x000D
2176 #define IMAGE_SYM_TYPE_UINT 0x000E
2177 #define IMAGE_SYM_TYPE_DWORD 0x000F
2178 #define IMAGE_SYM_TYPE_PCODE 0x8000
2180 #define IMAGE_SYM_DTYPE_NULL 0
2181 #define IMAGE_SYM_DTYPE_POINTER 1
2182 #define IMAGE_SYM_DTYPE_FUNCTION 2
2183 #define IMAGE_SYM_DTYPE_ARRAY 3
2185 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2186 #define IMAGE_SYM_CLASS_NULL 0x0000
2187 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2188 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2189 #define IMAGE_SYM_CLASS_STATIC 0x0003
2190 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2191 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2192 #define IMAGE_SYM_CLASS_LABEL 0x0006
2193 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2194 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2195 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2196 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2197 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2198 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2199 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2200 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2201 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2202 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2203 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2204 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2206 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2207 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2208 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2209 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2210 #define IMAGE_SYM_CLASS_FILE 0x0067
2211 #define IMAGE_SYM_CLASS_SECTION 0x0068
2212 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2214 #define N_BTMASK 0x000F
2215 #define N_TMASK 0x0030
2216 #define N_TMASK1 0x00C0
2217 #define N_TMASK2 0x00F0
2221 #define BTYPE(x) ((x) & N_BTMASK)
2224 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2228 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2232 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2236 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2240 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2243 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2246 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2247 #define IMAGE_COMDAT_SELECT_ANY 2
2248 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2249 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2250 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2251 #define IMAGE_COMDAT_SELECT_LARGEST 6
2252 #define IMAGE_COMDAT_SELECT_NEWEST 7
2254 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2255 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2256 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2258 /* Export module directory */
2260 typedef struct _IMAGE_EXPORT_DIRECTORY {
2261 DWORD Characteristics;
2262 DWORD TimeDateStamp;
2267 DWORD NumberOfFunctions;
2268 DWORD NumberOfNames;
2269 DWORD AddressOfFunctions;
2270 DWORD AddressOfNames;
2271 DWORD AddressOfNameOrdinals;
2272 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2274 /* Import name entry */
2275 typedef struct _IMAGE_IMPORT_BY_NAME {
2278 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2281 typedef struct _IMAGE_THUNK_DATA {
2283 LPBYTE ForwarderString;
2286 PIMAGE_IMPORT_BY_NAME AddressOfData;
2288 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2290 /* Import module directory */
2292 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2294 DWORD Characteristics; /* 0 for terminating null import descriptor */
2295 PIMAGE_THUNK_DATA OriginalFirstThunk; /* RVA to original unbound IAT */
2297 DWORD TimeDateStamp; /* 0 if not bound,
2298 * -1 if bound, and real date\time stamp
2299 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2301 * otherwise date/time stamp of DLL bound to
2304 DWORD ForwarderChain; /* -1 if no forwarders */
2306 /* RVA to IAT (if bound this IAT has actual addresses) */
2307 PIMAGE_THUNK_DATA FirstThunk;
2308 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2310 #define IMAGE_ORDINAL_FLAG 0x80000000
2311 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2312 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
2314 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2316 DWORD TimeDateStamp;
2317 WORD OffsetModuleName;
2318 WORD NumberOfModuleForwarderRefs;
2319 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2320 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2322 typedef struct _IMAGE_BOUND_FORWARDER_REF
2324 DWORD TimeDateStamp;
2325 WORD OffsetModuleName;
2327 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2329 typedef struct _IMAGE_BASE_RELOCATION
2331 DWORD VirtualAddress;
2334 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2336 typedef struct _IMAGE_RELOCATION
2339 DWORD VirtualAddress;
2342 DWORD SymbolTableIndex;
2345 typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
2347 #define IMAGE_SIZEOF_RELOCATION 10
2349 /* generic relocation types */
2350 #define IMAGE_REL_BASED_ABSOLUTE 0
2351 #define IMAGE_REL_BASED_HIGH 1
2352 #define IMAGE_REL_BASED_LOW 2
2353 #define IMAGE_REL_BASED_HIGHLOW 3
2354 #define IMAGE_REL_BASED_HIGHADJ 4
2355 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
2356 #define IMAGE_REL_BASED_SECTION 6
2357 #define IMAGE_REL_BASED_REL 7
2358 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
2359 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
2360 #define IMAGE_REL_BASED_DIR64 10
2361 #define IMAGE_REL_BASED_HIGH3ADJ 11
2363 /* I386 relocation types */
2364 #define IMAGE_REL_I386_ABSOLUTE 0
2365 #define IMAGE_REL_I386_DIR16 1
2366 #define IMAGE_REL_I386_REL16 2
2367 #define IMAGE_REL_I386_DIR32 6
2368 #define IMAGE_REL_I386_DIR32NB 7
2369 #define IMAGE_REL_I386_SEG12 9
2370 #define IMAGE_REL_I386_SECTION 10
2371 #define IMAGE_REL_I386_SECREL 11
2372 #define IMAGE_REL_I386_REL32 20
2374 /* MIPS relocation types */
2375 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
2376 #define IMAGE_REL_MIPS_REFHALF 0x0001
2377 #define IMAGE_REL_MIPS_REFWORD 0x0002
2378 #define IMAGE_REL_MIPS_JMPADDR 0x0003
2379 #define IMAGE_REL_MIPS_REFHI 0x0004
2380 #define IMAGE_REL_MIPS_REFLO 0x0005
2381 #define IMAGE_REL_MIPS_GPREL 0x0006
2382 #define IMAGE_REL_MIPS_LITERAL 0x0007
2383 #define IMAGE_REL_MIPS_SECTION 0x000A
2384 #define IMAGE_REL_MIPS_SECREL 0x000B
2385 #define IMAGE_REL_MIPS_SECRELLO 0x000C
2386 #define IMAGE_REL_MIPS_SECRELHI 0x000D
2387 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
2388 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
2389 #define IMAGE_REL_MIPS_PAIR 0x0025
2391 /* ALPHA relocation types */
2392 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
2393 #define IMAGE_REL_ALPHA_REFLONG 0x0001
2394 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
2395 #define IMAGE_REL_ALPHA_GPREL 0x0003
2396 #define IMAGE_REL_ALPHA_LITERAL 0x0004
2397 #define IMAGE_REL_ALPHA_LITUSE 0x0005
2398 #define IMAGE_REL_ALPHA_GPDISP 0x0006
2399 #define IMAGE_REL_ALPHA_BRADDR 0x0007
2400 #define IMAGE_REL_ALPHA_HINT 0x0008
2401 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
2402 #define IMAGE_REL_ALPHA_REFHI 0x000A
2403 #define IMAGE_REL_ALPHA_REFLO 0x000B
2404 #define IMAGE_REL_ALPHA_PAIR 0x000C
2405 #define IMAGE_REL_ALPHA_MATCH 0x000D
2406 #define IMAGE_REL_ALPHA_SECTION 0x000E
2407 #define IMAGE_REL_ALPHA_SECREL 0x000F
2408 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
2409 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
2410 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
2411 #define IMAGE_REL_ALPHA_REFQ3 0x0013
2412 #define IMAGE_REL_ALPHA_REFQ2 0x0014
2413 #define IMAGE_REL_ALPHA_REFQ1 0x0015
2414 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
2415 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
2417 /* PowerPC relocation types */
2418 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
2419 #define IMAGE_REL_PPC_ADDR64 0x0001
2420 #define IMAGE_REL_PPC_ADDR 0x0002
2421 #define IMAGE_REL_PPC_ADDR24 0x0003
2422 #define IMAGE_REL_PPC_ADDR16 0x0004
2423 #define IMAGE_REL_PPC_ADDR14 0x0005
2424 #define IMAGE_REL_PPC_REL24 0x0006
2425 #define IMAGE_REL_PPC_REL14 0x0007
2426 #define IMAGE_REL_PPC_TOCREL16 0x0008
2427 #define IMAGE_REL_PPC_TOCREL14 0x0009
2428 #define IMAGE_REL_PPC_ADDR32NB 0x000A
2429 #define IMAGE_REL_PPC_SECREL 0x000B
2430 #define IMAGE_REL_PPC_SECTION 0x000C
2431 #define IMAGE_REL_PPC_IFGLUE 0x000D
2432 #define IMAGE_REL_PPC_IMGLUE 0x000E
2433 #define IMAGE_REL_PPC_SECREL16 0x000F
2434 #define IMAGE_REL_PPC_REFHI 0x0010
2435 #define IMAGE_REL_PPC_REFLO 0x0011
2436 #define IMAGE_REL_PPC_PAIR 0x0012
2437 #define IMAGE_REL_PPC_SECRELLO 0x0013
2438 #define IMAGE_REL_PPC_SECRELHI 0x0014
2439 #define IMAGE_REL_PPC_GPREL 0x0015
2440 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
2442 #define IMAGE_REL_PPC_NEG 0x0100
2443 #define IMAGE_REL_PPC_BRTAKEN 0x0200
2444 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
2445 #define IMAGE_REL_PPC_TOCDEFN 0x0800
2447 /* SH3 ? relocation type */
2448 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
2449 #define IMAGE_REL_SH3_DIRECT16 0x0001
2450 #define IMAGE_REL_SH3_DIRECT 0x0002
2451 #define IMAGE_REL_SH3_DIRECT8 0x0003
2452 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
2453 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
2454 #define IMAGE_REL_SH3_DIRECT4 0x0006
2455 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
2456 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
2457 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
2458 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
2459 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
2460 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
2461 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
2462 #define IMAGE_REL_SH3_SECTION 0x000E
2463 #define IMAGE_REL_SH3_SECREL 0x000F
2464 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
2466 /* ARM (Archimedes?) relocation types */
2467 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
2468 #define IMAGE_REL_ARM_ADDR 0x0001
2469 #define IMAGE_REL_ARM_ADDR32NB 0x0002
2470 #define IMAGE_REL_ARM_BRANCH24 0x0003
2471 #define IMAGE_REL_ARM_BRANCH11 0x0004
2472 #define IMAGE_REL_ARM_SECTION 0x000E
2473 #define IMAGE_REL_ARM_SECREL 0x000F
2475 /* IA64 relocation types */
2476 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
2477 #define IMAGE_REL_IA64_IMM14 0x0001
2478 #define IMAGE_REL_IA64_IMM22 0x0002
2479 #define IMAGE_REL_IA64_IMM64 0x0003
2480 #define IMAGE_REL_IA64_DIR 0x0004
2481 #define IMAGE_REL_IA64_DIR64 0x0005
2482 #define IMAGE_REL_IA64_PCREL21B 0x0006
2483 #define IMAGE_REL_IA64_PCREL21M 0x0007
2484 #define IMAGE_REL_IA64_PCREL21F 0x0008
2485 #define IMAGE_REL_IA64_GPREL22 0x0009
2486 #define IMAGE_REL_IA64_LTOFF22 0x000A
2487 #define IMAGE_REL_IA64_SECTION 0x000B
2488 #define IMAGE_REL_IA64_SECREL22 0x000C
2489 #define IMAGE_REL_IA64_SECREL64I 0x000D
2490 #define IMAGE_REL_IA64_SECREL 0x000E
2491 #define IMAGE_REL_IA64_LTOFF64 0x000F
2492 #define IMAGE_REL_IA64_DIR32NB 0x0010
2493 #define IMAGE_REL_IA64_RESERVED_11 0x0011
2494 #define IMAGE_REL_IA64_RESERVED_12 0x0012
2495 #define IMAGE_REL_IA64_RESERVED_13 0x0013
2496 #define IMAGE_REL_IA64_RESERVED_14 0x0014
2497 #define IMAGE_REL_IA64_RESERVED_15 0x0015
2498 #define IMAGE_REL_IA64_RESERVED_16 0x0016
2499 #define IMAGE_REL_IA64_ADDEND 0x001F
2501 /* archive format */
2503 #define IMAGE_ARCHIVE_START_SIZE 8
2504 #define IMAGE_ARCHIVE_START "!<arch>\n"
2505 #define IMAGE_ARCHIVE_END "`\n"
2506 #define IMAGE_ARCHIVE_PAD "\n"
2507 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
2508 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
2510 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2519 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2521 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2524 * Resource directory stuff
2526 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2527 DWORD Characteristics;
2528 DWORD TimeDateStamp;
2531 WORD NumberOfNamedEntries;
2532 WORD NumberOfIdEntries;
2533 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2534 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2536 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
2537 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
2539 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2542 #ifdef BITFIELDS_BIGENDIAN
2543 unsigned NameIsString:1;
2544 unsigned NameOffset:31;
2546 unsigned NameOffset:31;
2547 unsigned NameIsString:1;
2552 #ifdef WORDS_BIGENDIAN
2564 #ifdef BITFIELDS_BIGENDIAN
2565 unsigned DataIsDirectory:1;
2566 unsigned OffsetToDirectory:31;
2568 unsigned OffsetToDirectory:31;
2569 unsigned DataIsDirectory:1;
2573 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2576 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2578 CHAR NameString[ 1 ];
2579 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2581 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2583 WCHAR NameString[ 1 ];
2584 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2586 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2590 DWORD ResourceHandle;
2591 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2594 typedef VOID CALLBACK (*PIMAGE_TLS_CALLBACK)(
2595 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2598 typedef struct _IMAGE_TLS_DIRECTORY {
2599 DWORD StartAddressOfRawData;
2600 DWORD EndAddressOfRawData;
2601 LPDWORD AddressOfIndex;
2602 PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
2603 DWORD SizeOfZeroFill;
2604 DWORD Characteristics;
2605 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
2607 typedef struct _IMAGE_DEBUG_DIRECTORY {
2608 DWORD Characteristics;
2609 DWORD TimeDateStamp;
2614 DWORD AddressOfRawData;
2615 DWORD PointerToRawData;
2616 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2618 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
2619 #define IMAGE_DEBUG_TYPE_COFF 1
2620 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
2621 #define IMAGE_DEBUG_TYPE_FPO 3
2622 #define IMAGE_DEBUG_TYPE_MISC 4
2623 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
2624 #define IMAGE_DEBUG_TYPE_FIXUP 6
2625 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
2626 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
2627 #define IMAGE_DEBUG_TYPE_BORLAND 9
2628 #define IMAGE_DEBUG_TYPE_RESERVED10 10
2630 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2631 DWORD NumberOfSymbols;
2632 DWORD LvaToFirstSymbol;
2633 DWORD NumberOfLinenumbers;
2634 DWORD LvaToFirstLinenumber;
2635 DWORD RvaToFirstByteOfCode;
2636 DWORD RvaToLastByteOfCode;
2637 DWORD RvaToFirstByteOfData;
2638 DWORD RvaToLastByteOfData;
2639 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2642 #define FRAME_TRAP 1
2644 #define FRAME_NONFPO 3
2646 typedef struct _FPO_DATA {
2651 unsigned cbProlog : 8;
2652 unsigned cbRegs : 3;
2653 unsigned fHasSEH : 1;
2654 unsigned fUseBP : 1;
2655 unsigned reserved : 1;
2656 unsigned cbFrame : 2;
2657 } FPO_DATA, *PFPO_DATA;
2659 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2660 DWORD Characteristics;
2661 DWORD TimeDateStamp;
2664 DWORD GlobalFlagsClear;
2665 DWORD GlobalFlagsSet;
2666 DWORD CriticalSectionDefaultTimeout;
2667 DWORD DeCommitFreeBlockThreshold;
2668 DWORD DeCommitTotalFreeThreshold;
2669 PVOID LockPrefixTable;
2670 DWORD MaximumAllocationSize;
2671 DWORD VirtualMemoryThreshold;
2672 DWORD ProcessHeapFlags;
2673 DWORD ProcessAffinityMask;
2678 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2680 typedef struct _IMAGE_FUNCTION_ENTRY {
2681 DWORD StartingAddress;
2682 DWORD EndingAddress;
2683 DWORD EndOfPrologue;
2684 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2686 #define IMAGE_DEBUG_MISC_EXENAME 1
2688 typedef struct _IMAGE_DEBUG_MISC {
2694 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2696 /* This is the structure that appears at the very start of a .DBG file. */
2698 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2702 WORD Characteristics;
2703 DWORD TimeDateStamp;
2707 DWORD NumberOfSections;
2708 DWORD ExportedNamesSize;
2709 DWORD DebugDirectorySize;
2710 DWORD SectionAlignment;
2711 DWORD Reserved[ 2 ];
2712 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2714 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2717 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2721 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2722 #define MESSAGE_RESOURCE_UNICODE 0x0001
2724 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2727 DWORD OffsetToEntries;
2728 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2730 typedef struct tagMESSAGE_RESOURCE_DATA {
2731 DWORD NumberOfBlocks;
2732 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
2733 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2736 * Here follows typedefs for security and tokens.
2740 * First a constant for the following typdefs.
2743 #define ANYSIZE_ARRAY 1
2745 /* FIXME: Orphan. What does it point to? */
2746 typedef PVOID PACCESS_TOKEN;
2749 * TOKEN_INFORMATION_CLASS
2752 typedef enum _TOKEN_INFORMATION_CLASS {
2761 TokenImpersonationLevel,
2763 } TOKEN_INFORMATION_CLASS;
2765 #ifndef _SECURITY_DEFINED
2766 #define _SECURITY_DEFINED
2768 #include "pshpack1.h"
2770 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2772 typedef struct _GENERIC_MAPPING {
2773 ACCESS_MASK GenericRead;
2774 ACCESS_MASK GenericWrite;
2775 ACCESS_MASK GenericExecute;
2776 ACCESS_MASK GenericAll;
2777 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2779 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2780 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2783 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
2784 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2788 typedef struct _SID {
2790 BYTE SubAuthorityCount;
2791 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2792 DWORD SubAuthority[1];
2794 #endif /* !defined(SID_DEFINED) */
2796 #define SID_REVISION (1) /* Current revision */
2797 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
2798 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
2805 #define ACL_REVISION1 1
2806 #define ACL_REVISION2 2
2807 #define ACL_REVISION3 3
2808 #define ACL_REVISION4 4
2810 #define MIN_ACL_REVISION ACL_REVISION2
2811 #define MAX_ACL_REVISION ACL_REVISION4
2813 typedef struct _ACL {
2821 /* SECURITY_DESCRIPTOR */
2822 #define SECURITY_DESCRIPTOR_REVISION 1
2823 #define SECURITY_DESCRIPTOR_REVISION1 1
2826 #define SE_OWNER_DEFAULTED 0x0001
2827 #define SE_GROUP_DEFAULTED 0x0002
2828 #define SE_DACL_PRESENT 0x0004
2829 #define SE_DACL_DEFAULTED 0x0008
2830 #define SE_SACL_PRESENT 0x0010
2831 #define SE_SACL_DEFAULTED 0x0020
2832 #define SE_SELF_RELATIVE 0x8000
2834 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2835 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
2837 /* The security descriptor structure */
2841 SECURITY_DESCRIPTOR_CONTROL Control;
2846 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
2851 SECURITY_DESCRIPTOR_CONTROL Control;
2856 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
2858 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
2860 #include "poppack.h"
2862 #endif /* _SECURITY_DEFINED */
2864 #include "pshpack1.h"
2867 * SID_AND_ATTRIBUTES
2870 typedef struct _SID_AND_ATTRIBUTES {
2873 } SID_AND_ATTRIBUTES ;
2875 /* security entities */
2876 #define SECURITY_NULL_RID (0x00000000L)
2877 #define SECURITY_WORLD_RID (0x00000000L)
2878 #define SECURITY_LOCAL_RID (0X00000000L)
2880 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
2883 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
2886 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
2889 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
2890 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
2891 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
2892 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
2893 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
2896 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
2899 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
2900 #define SECURITY_DIALUP_RID 0x00000001L
2901 #define SECURITY_NETWORK_RID 0x00000002L
2902 #define SECURITY_BATCH_RID 0x00000003L
2903 #define SECURITY_INTERACTIVE_RID 0x00000004L
2904 #define SECURITY_LOGON_IDS_RID 0x00000005L
2905 #define SECURITY_SERVICE_RID 0x00000006L
2906 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
2907 #define SECURITY_PROXY_RID 0x00000008L
2908 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
2909 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
2910 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
2911 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
2912 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
2913 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
2914 #define SECURITY_NT_NON_UNIQUE 0x00000015L
2915 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
2917 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
2918 #define DOMAIN_GROUP_RID_USERS 0x00000201L
2919 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
2921 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
2922 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
2923 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
2925 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
2927 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
2933 typedef struct _TOKEN_USER {
2934 SID_AND_ATTRIBUTES User;
2941 typedef struct _TOKEN_GROUPS {
2943 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
2947 * LUID_AND_ATTRIBUTES
2950 typedef union _LARGE_INTEGER {
2956 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
2958 typedef union _ULARGE_INTEGER {
2964 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
2967 * Locally Unique Identifier
2970 typedef LARGE_INTEGER LUID,*PLUID;
2972 typedef struct _LUID_AND_ATTRIBUTES {
2975 } LUID_AND_ATTRIBUTES;
2981 typedef struct _PRIVILEGE_SET {
2982 DWORD PrivilegeCount;
2984 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2985 } PRIVILEGE_SET, *PPRIVILEGE_SET;
2991 typedef struct _TOKEN_PRIVILEGES {
2992 DWORD PrivilegeCount;
2993 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
2994 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
3000 typedef struct _TOKEN_OWNER {
3005 * TOKEN_PRIMARY_GROUP
3008 typedef struct _TOKEN_PRIMARY_GROUP {
3010 } TOKEN_PRIMARY_GROUP;
3014 * TOKEN_DEFAULT_DACL
3017 typedef struct _TOKEN_DEFAULT_DACL {
3019 } TOKEN_DEFAULT_DACL;
3025 typedef struct _TOKEN_SOURCE {
3027 LUID SourceIdentifier;
3034 typedef enum tagTOKEN_TYPE {
3040 * SECURITY_IMPERSONATION_LEVEL
3043 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3045 SecurityIdentification,
3046 SecurityImpersonation,
3048 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
3051 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3052 * PSECURITY_CONTEXT_TRACKING_MODE;
3054 * Quality of Service
3057 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3059 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3060 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3062 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3068 typedef struct _TOKEN_STATISTICS {
3070 LUID AuthenticationId;
3071 LARGE_INTEGER ExpirationTime;
3072 TOKEN_TYPE TokenType;
3073 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3074 DWORD DynamicCharged;
3075 DWORD DynamicAvailable;
3077 DWORD PrivilegeCount;
3085 #define ACL_REVISION 2
3087 #define ACL_REVISION1 1
3088 #define ACL_REVISION2 2
3090 /* ACEs, directly starting after an ACL */
3091 typedef struct _ACE_HEADER {
3095 } ACE_HEADER,*PACE_HEADER;
3098 #define ACCESS_ALLOWED_ACE_TYPE 0
3099 #define ACCESS_DENIED_ACE_TYPE 1
3100 #define SYSTEM_AUDIT_ACE_TYPE 2
3101 #define SYSTEM_ALARM_ACE_TYPE 3
3103 /* inherit AceFlags */
3104 #define OBJECT_INHERIT_ACE 0x01
3105 #define CONTAINER_INHERIT_ACE 0x02
3106 #define NO_PROPAGATE_INHERIT_ACE 0x04
3107 #define INHERIT_ONLY_ACE 0x08
3108 #define VALID_INHERIT_FLAGS 0x0F
3110 /* AceFlags mask for what events we (should) audit */
3111 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
3112 #define FAILED_ACCESS_ACE_FLAG 0x80
3114 /* different ACEs depending on AceType
3115 * SidStart marks the begin of a SID
3116 * so the thing finally looks like this:
3121 typedef struct _ACCESS_ALLOWED_ACE {
3125 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3127 typedef struct _ACCESS_DENIED_ACE {
3131 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3133 typedef struct _SYSTEM_AUDIT_ACE {
3137 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3139 typedef struct _SYSTEM_ALARM_ACE {
3143 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3145 typedef enum tagSID_NAME_USE {
3150 SidTypeWellKnownGroup,
3151 SidTypeDeletedAccount,
3154 } SID_NAME_USE,*PSID_NAME_USE;
3158 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3160 #define DELETE 0x00010000
3161 #define READ_CONTROL 0x00020000
3162 #define WRITE_DAC 0x00040000
3163 #define WRITE_OWNER 0x00080000
3164 #define SYNCHRONIZE 0x00100000
3165 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
3167 #define STANDARD_RIGHTS_READ READ_CONTROL
3168 #define STANDARD_RIGHTS_WRITE READ_CONTROL
3169 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
3171 #define STANDARD_RIGHTS_ALL 0x001f0000
3173 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
3175 #define GENERIC_READ 0x80000000
3176 #define GENERIC_WRITE 0x40000000
3177 #define GENERIC_EXECUTE 0x20000000
3178 #define GENERIC_ALL 0x10000000
3180 #define MAXIMUM_ALLOWED 0x02000000
3181 #define ACCESS_SYSTEM_SECURITY 0x01000000
3183 #define EVENT_MODIFY_STATE 0x0002
3184 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3186 #define SEMAPHORE_MODIFY_STATE 0x0002
3187 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3189 #define MUTEX_MODIFY_STATE 0x0001
3190 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3192 #define TIMER_QUERY_STATE 0x0001
3193 #define TIMER_MODIFY_STATE 0x0002
3194 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3196 #define PROCESS_TERMINATE 0x0001
3197 #define PROCESS_CREATE_THREAD 0x0002
3198 #define PROCESS_VM_OPERATION 0x0008
3199 #define PROCESS_VM_READ 0x0010
3200 #define PROCESS_VM_WRITE 0x0020
3201 #define PROCESS_DUP_HANDLE 0x0040
3202 #define PROCESS_CREATE_PROCESS 0x0080
3203 #define PROCESS_SET_QUOTA 0x0100
3204 #define PROCESS_SET_INFORMATION 0x0200
3205 #define PROCESS_QUERY_INFORMATION 0x0400
3206 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3208 #define THREAD_TERMINATE 0x0001
3209 #define THREAD_SUSPEND_RESUME 0x0002
3210 #define THREAD_GET_CONTEXT 0x0008
3211 #define THREAD_SET_CONTEXT 0x0010
3212 #define THREAD_SET_INFORMATION 0x0020
3213 #define THREAD_QUERY_INFORMATION 0x0040
3214 #define THREAD_SET_THREAD_TOKEN 0x0080
3215 #define THREAD_IMPERSONATE 0x0100
3216 #define THREAD_DIRECT_IMPERSONATION 0x0200
3217 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3219 #define THREAD_BASE_PRIORITY_LOWRT 15
3220 #define THREAD_BASE_PRIORITY_MAX 2
3221 #define THREAD_BASE_PRIORITY_MIN -2
3222 #define THREAD_BASE_PRIORITY_IDLE -15
3224 #define FILE_READ_DATA 0x0001 /* file & pipe */
3225 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
3226 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
3227 #define FILE_ADD_FILE 0x0002 /* directory */
3228 #define FILE_APPEND_DATA 0x0004 /* file */
3229 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
3230 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
3231 #define FILE_READ_EA 0x0008 /* file & directory */
3232 #define FILE_READ_PROPERTIES FILE_READ_EA
3233 #define FILE_WRITE_EA 0x0010 /* file & directory */
3234 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
3235 #define FILE_EXECUTE 0x0020 /* file */
3236 #define FILE_TRAVERSE 0x0020 /* directory */
3237 #define FILE_DELETE_CHILD 0x0040 /* directory */
3238 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
3239 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
3240 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3242 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3243 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3245 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3246 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3247 FILE_APPEND_DATA | SYNCHRONIZE)
3248 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3249 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3252 /* File attribute flags */
3253 #define FILE_SHARE_READ 0x00000001L
3254 #define FILE_SHARE_WRITE 0x00000002L
3255 #define FILE_SHARE_DELETE 0x00000004L
3256 #define FILE_ATTRIBUTE_READONLY 0x00000001L
3257 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
3258 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
3259 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
3260 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
3261 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
3262 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
3263 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
3264 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
3265 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
3266 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
3267 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
3268 #define FILE_ATTRIBUTE_SYMLINK 0x80000000L /* Not in Windows API */
3270 /* File notification flags */
3271 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
3272 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
3273 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
3274 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
3275 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
3276 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
3277 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
3278 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
3280 #define FILE_ACTION_ADDED 0x00000001
3281 #define FILE_ACTION_REMOVED 0x00000002
3282 #define FILE_ACTION_MODIFIED 0x00000003
3283 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
3284 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
3287 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
3288 #define FILE_CASE_PRESERVED_NAMES 0x00000002
3289 #define FILE_UNICODE_ON_DISK 0x00000004
3290 #define FILE_PERSISTENT_ACLS 0x00000008
3291 #define FILE_FILE_COMPRESSION 0x00000010
3292 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
3294 /* File alignments (NT) */
3295 #define FILE_BYTE_ALIGNMENT 0x00000000
3296 #define FILE_WORD_ALIGNMENT 0x00000001
3297 #define FILE_LONG_ALIGNMENT 0x00000003
3298 #define FILE_QUAD_ALIGNMENT 0x00000007
3299 #define FILE_OCTA_ALIGNMENT 0x0000000f
3300 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
3301 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
3302 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
3303 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
3304 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
3306 #define REG_NONE 0 /* no type */
3307 #define REG_SZ 1 /* string type (ASCII) */
3308 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3309 #define REG_BINARY 3 /* binary format, callerspecific */
3310 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3311 #define REG_DWORD 4 /* DWORD in little endian format */
3312 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
3313 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
3314 #define REG_LINK 6 /* symbolic link (UNICODE) */
3315 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3316 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
3317 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
3318 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3320 /* ----------------------------- begin registry ----------------------------- */
3322 /* Registry security values */
3323 #define OWNER_SECURITY_INFORMATION 0x00000001
3324 #define GROUP_SECURITY_INFORMATION 0x00000002
3325 #define DACL_SECURITY_INFORMATION 0x00000004
3326 #define SACL_SECURITY_INFORMATION 0x00000008
3328 #define REG_OPTION_RESERVED 0x00000000
3329 #define REG_OPTION_NON_VOLATILE 0x00000000
3330 #define REG_OPTION_VOLATILE 0x00000001
3331 #define REG_OPTION_CREATE_LINK 0x00000002
3332 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
3333 #define REG_OPTION_OPEN_LINK 0x00000008
3334 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
3335 REG_OPTION_NON_VOLATILE| \
3336 REG_OPTION_VOLATILE| \
3337 REG_OPTION_CREATE_LINK| \
3338 REG_OPTION_BACKUP_RESTORE| \
3339 REG_OPTION_OPEN_LINK)
3342 #define REG_CREATED_NEW_KEY 0x00000001
3343 #define REG_OPENED_EXISTING_KEY 0x00000002
3345 /* For RegNotifyChangeKeyValue */
3346 #define REG_NOTIFY_CHANGE_NAME 0x1
3348 #define KEY_QUERY_VALUE 0x00000001
3349 #define KEY_SET_VALUE 0x00000002
3350 #define KEY_CREATE_SUB_KEY 0x00000004
3351 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
3352 #define KEY_NOTIFY 0x00000010
3353 #define KEY_CREATE_LINK 0x00000020
3355 #define KEY_READ ((STANDARD_RIGHTS_READ| \
3357 KEY_ENUMERATE_SUB_KEYS| \
3361 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
3363 KEY_CREATE_SUB_KEY) \
3366 #define KEY_EXECUTE ((KEY_READ) \
3369 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
3372 KEY_CREATE_SUB_KEY| \
3373 KEY_ENUMERATE_SUB_KEYS| \
3378 /* ------------------------------ end registry ------------------------------ */
3381 typedef struct _RTL_CRITICAL_SECTION_DEBUG
3384 WORD CreatorBackTraceIndex;
3385 struct _RTL_CRITICAL_SECTION *CriticalSection;
3386 LIST_ENTRY ProcessLocksList;
3388 DWORD ContentionCount;
3390 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
3392 typedef struct _RTL_CRITICAL_SECTION {
3393 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
3395 LONG RecursionCount;
3396 HANDLE OwningThread;
3397 HANDLE LockSemaphore;
3398 ULONG_PTR SpinCount;
3399 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
3402 #define EVENTLOG_SUCCESS 0x0000
3403 #define EVENTLOG_ERROR_TYPE 0x0001
3404 #define EVENTLOG_WARNING_TYPE 0x0002
3405 #define EVENTLOG_INFORMATION_TYPE 0x0004
3406 #define EVENTLOG_AUDIT_SUCCESS 0x0008
3407 #define EVENTLOG_AUDIT_FAILURE 0x0010
3409 #define SERVICE_BOOT_START 0x00000000
3410 #define SERVICE_SYSTEM_START 0x00000001
3411 #define SERVICE_AUTO_START 0x00000002
3412 #define SERVICE_DEMAND_START 0x00000003
3413 #define SERVICE_DISABLED 0x00000004
3415 #define SERVICE_ERROR_IGNORE 0x00000000
3416 #define SERVICE_ERROR_NORMAL 0x00000001
3417 #define SERVICE_ERROR_SEVERE 0x00000002
3418 #define SERVICE_ERROR_CRITICAL 0x00000003
3421 #define SERVICE_KERNEL_DRIVER 0x00000001
3422 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
3423 #define SERVICE_ADAPTER 0x00000004
3424 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
3426 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
3427 SERVICE_RECOGNIZER_DRIVER )
3429 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
3430 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
3431 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
3433 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
3435 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
3436 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
3439 typedef enum _CM_SERVICE_NODE_TYPE
3441 DriverType = SERVICE_KERNEL_DRIVER,
3442 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
3443 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
3444 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3445 AdapterType = SERVICE_ADAPTER,
3446 RecognizerType = SERVICE_RECOGNIZER_DRIVER
3447 } SERVICE_NODE_TYPE;
3449 typedef enum _CM_SERVICE_LOAD_TYPE
3451 BootLoad = SERVICE_BOOT_START,
3452 SystemLoad = SERVICE_SYSTEM_START,
3453 AutoLoad = SERVICE_AUTO_START,
3454 DemandLoad = SERVICE_DEMAND_START,
3455 DisableLoad = SERVICE_DISABLED
3456 } SERVICE_LOAD_TYPE;
3458 typedef enum _CM_ERROR_CONTROL_TYPE
3460 IgnoreError = SERVICE_ERROR_IGNORE,
3461 NormalError = SERVICE_ERROR_NORMAL,
3462 SevereError = SERVICE_ERROR_SEVERE,
3463 CriticalError = SERVICE_ERROR_CRITICAL
3464 } SERVICE_ERROR_TYPE;
3468 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
3469 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
3470 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
3471 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
3472 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
3474 #include "guiddef.h"
3476 #include "poppack.h"
3478 #endif /* __WINE_WINNT_H */