2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
19 /* On Windows winnt.h depends on a few windef.h types and macros and thus
20 * is not self-contained. Furthermore windef.h includes winnt.h so that it
21 * would be pointless to try to use winnt.h directly.
22 * But for Wine and Winelib I decided to make winnt.h self-contained by
23 * moving these definitions to winnt.h. It makes no difference to Winelib
24 * programs since they are not using winnt.h directly anyway, and it allows
25 * us to use winnt.h and get a minimal set of definitions.
28 /**** Some Wine specific definitions *****/
30 /* Calling conventions definitions */
36 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
37 # define __stdcall __attribute__((__stdcall__))
38 # define __cdecl __attribute__((__cdecl__))
40 # error You need gcc >= 2.7 to build Wine on a 386
41 # endif /* __GNUC__ */
48 #define pascal __stdcall
49 #define _pascal __stdcall
50 #define _stdcall __stdcall
51 #define _fastcall __stdcall
52 #define __fastcall __stdcall
53 #define __export __stdcall
55 #define _cdecl __cdecl
72 #define CALLBACK __stdcall
73 #define WINAPI __stdcall
74 #define APIPRIVATE __stdcall
75 #define PASCAL __stdcall
77 #define _CDECL __cdecl
78 #define WINAPIV __cdecl
79 #define APIENTRY WINAPI
82 /* Macro for structure packing and more. */
85 #define WINE_PACKED __attribute__((packed))
86 #define WINE_UNUSED __attribute__((unused))
87 #define WINE_NORETURN __attribute__((noreturn))
89 #define WINE_PACKED /* nothing */
90 #define WINE_UNUSED /* nothing */
91 #define WINE_NORETURN /* nothing */
94 /* Anonymous union/struct handling */
97 # define NONAMELESSSTRUCT
98 # define NONAMELESSUNION
100 /* Anonymous struct support starts with gcc/g++ 2.96 */
101 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
102 # define NONAMELESSSTRUCT
104 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
105 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
106 # define NONAMELESSUNION
110 #ifndef NONAMELESSSTRUCT
111 #define DUMMYSTRUCTNAME
112 #define DUMMYSTRUCTNAME1
113 #define DUMMYSTRUCTNAME2
114 #define DUMMYSTRUCTNAME3
115 #define DUMMYSTRUCTNAME4
116 #define DUMMYSTRUCTNAME5
117 #else /* !defined(NONAMELESSSTRUCT) */
118 #define DUMMYSTRUCTNAME s
119 #define DUMMYSTRUCTNAME1 s1
120 #define DUMMYSTRUCTNAME2 s2
121 #define DUMMYSTRUCTNAME3 s3
122 #define DUMMYSTRUCTNAME4 s4
123 #define DUMMYSTRUCTNAME5 s5
124 #endif /* !defined(NONAMELESSSTRUCT) */
126 #ifndef NONAMELESSUNION
127 #define DUMMYUNIONNAME
128 #define DUMMYUNIONNAME1
129 #define DUMMYUNIONNAME2
130 #define DUMMYUNIONNAME3
131 #define DUMMYUNIONNAME4
132 #define DUMMYUNIONNAME5
133 #define DUMMYUNIONNAME6
134 #define DUMMYUNIONNAME7
135 #define DUMMYUNIONNAME8
136 #else /* !defined(NONAMELESSUNION) */
137 #define DUMMYUNIONNAME u
138 #define DUMMYUNIONNAME1 u1
139 #define DUMMYUNIONNAME2 u2
140 #define DUMMYUNIONNAME3 u3
141 #define DUMMYUNIONNAME4 u4
142 #define DUMMYUNIONNAME5 u5
143 #define DUMMYUNIONNAME6 u6
144 #define DUMMYUNIONNAME7 u7
145 #define DUMMYUNIONNAME8 u8
146 #endif /* !defined(NONAMELESSUNION) */
149 /**** Parts of windef.h that are needed here *****/
151 /* Misc. constants. */
157 #define NULL ((void*)0)
182 /* Standard data types */
183 typedef const void *PCVOID, *LPCVOID;
184 typedef int BOOL, *PBOOL, *LPBOOL;
185 typedef unsigned char BYTE, *PBYTE, *LPBYTE;
186 typedef unsigned char UCHAR, *PUCHAR;
187 typedef unsigned short USHORT, *PUSHORT, *LPUSHORT;
188 typedef unsigned short WORD, *PWORD, *LPWORD;
189 typedef int INT, *PINT, *LPINT;
190 typedef unsigned int UINT, *PUINT, *LPUINT;
191 typedef unsigned long DWORD, *PDWORD, *LPDWORD;
192 typedef unsigned long ULONG, *PULONG, *LPULONG;
193 typedef float FLOAT, *PFLOAT, *LPFLOAT;
194 typedef double DOUBLE, *PDOUBLE, *LPDOUBLE;
198 /**** winnt.h proper *****/
200 /* Microsoft's macros for declaring functions */
203 # define EXTERN_C extern "C"
205 # define EXTERN_C extern
209 #define STDMETHODCALLTYPE __stdcall
210 #define STDMETHODVCALLTYPE __cdecl
211 #define STDAPICALLTYPE __stdcall
212 #define STDAPIVCALLTYPE __cdecl
214 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
215 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
216 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
217 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
218 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
219 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
220 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
221 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
224 /* Define the basic types */
228 typedef VOID *PVOID, *LPVOID;
229 typedef BYTE BOOLEAN, *PBOOLEAN;
230 typedef char CHAR, *PCHAR;
231 typedef short SHORT, *PSHORT;
232 typedef long LONG, *PLONG, *LPLONG;
234 /* Some systems might have wchar_t, but we really need 16 bit characters */
235 #ifdef WINE_UNICODE_NATIVE
236 typedef wchar_t WCHAR, *PWCHAR;
238 typedef unsigned short WCHAR, *PWCHAR;
241 /* 'Extended/Wide' numerical types */
244 typedef __int64 LONGLONG, *PLONGLONG;
245 typedef __uint64 ULONGLONG, *PULONGLONG;
250 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
253 /* ANSI string types */
254 typedef CHAR *PCH, *LPCH;
255 typedef const CHAR *PCCH, *LPCCH;
256 typedef CHAR *PSTR, *LPSTR;
257 typedef const CHAR *PCSTR, *LPCSTR;
259 /* Unicode string types */
260 typedef WCHAR *PWCH, *LPWCH;
261 typedef const WCHAR *PCWCH, *LPCWCH;
262 typedef WCHAR *PWSTR, *LPWSTR;
263 typedef const WCHAR *PCWSTR, *LPCWSTR;
265 /* Neutral character and string types */
266 /* These are only defined for Winelib, i.e. _not_ defined for
267 * the emulator. The reason is they depend on the UNICODE
268 * macro which only exists in the user's code.
271 # ifdef WINE_UNICODE_REWRITE
272 EXTERN_C unsigned short* wine_rewrite_s4tos2(const wchar_t* str4);
274 inline WCHAR* wine_unicode_text(const wchar_t* str4)
276 return (WCHAR*)wine_rewrite_s4tos2(str4);
278 inline WCHAR wine_unicode_text(wchar_t chr4)
282 # define WINE_UNICODE_TEXT(x) wine_unicode_text(L##x)
283 # else /* __cplusplus */
284 # define WINE_UNICODE_TEXT(x) ((sizeof(x)==1) || (sizeof(L##x)>4) ? \
285 (WCHAR*)wine_rewrite_s4tos2(L##x) : \
287 # endif /* __cplusplus */
288 # else /* WINE_UNICODE_REWRITE */
289 /* WINE_UNICODE_NATIVE or nothing at all */
290 # define WINE_UNICODE_TEXT(string) L##string
291 # endif /* WINE_UNICODE_REWRITE */
294 typedef WCHAR TCHAR, *PTCHAR;
295 typedef LPWSTR PTSTR, LPTSTR;
296 typedef LPCWSTR PCTSTR, LPCTSTR;
297 # define __TEXT(string) WINE_UNICODE_TEXT(string)
299 typedef CHAR TCHAR, *PTCHAR;
300 typedef LPSTR PTSTR, LPTSTR;
301 typedef LPCSTR PCTSTR, LPCTSTR;
302 # define __TEXT(string) string
303 # endif /* UNICODE */
304 # define TEXT(quote) __TEXT(quote)
305 #endif /* __WINE__ */
307 /* Misc common WIN32 types */
308 typedef LONG HRESULT;
309 typedef DWORD LCID, *PLCID;
314 /* FIXME: Wine does not compile with strict on, therefore strict
315 * handles are presently only usable on machines where sizeof(UINT) ==
316 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
317 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
318 * they exist as UINTs but to the Winelib user who turns on strict,
319 * they exist as void*. If there is a size difference between UINT and
320 * void* then things get ugly.
322 * Here is the plan to convert Wine to STRICT:
324 * Types will be converted one at a time by volunteers who will compile
325 * Wine with STRICT turned on. Handles that have not been converted yet
326 * will be declared with DECLARE_OLD_HANDLE. Converted handles are
327 * declared with DECLARE_HANDLE.
328 * See the bug report 90 for more details:
329 * http://wine.codeweavers.com/bugzilla/show_bug.cgi?id=90
332 * when compiling Wine we always treat HANDLE as an UINT. Then when
333 * we're ready we'll remove the '!defined(__WINE__)' (the equivalent
334 * of converting it from DECLARE_OLD_HANDLE to DECLARE_HANDLE).
336 #if defined(STRICT) && !defined(__WINE__)
337 typedef VOID* HANDLE;
338 #define DECLARE_OLD_HANDLE(a) \
339 typedef struct a##__ { int unused; } *a; \
340 typedef a *P##a, *LP##a
344 #define DECLARE_OLD_HANDLE(a) \
346 typedef a *P##a, *LP##a
348 typedef HANDLE *PHANDLE, *LPHANDLE;
351 #define DECLARE_HANDLE(a) \
352 typedef struct a##__ { int unused; } *a; \
353 typedef a *P##a, *LP##a
355 #define DECLARE_HANDLE(a) \
357 typedef a *P##a, *LP##a
361 #include "pshpack1.h"
364 /* Argument 1 passed to the DllEntryProc. */
365 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
366 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
367 #define DLL_THREAD_ATTACH 2 /* attach new thread */
368 #define DLL_THREAD_DETACH 3 /* detach thread */
371 /* u.x.wProcessorArchitecture (NT) */
372 #define PROCESSOR_ARCHITECTURE_INTEL 0
373 #define PROCESSOR_ARCHITECTURE_MIPS 1
374 #define PROCESSOR_ARCHITECTURE_ALPHA 2
375 #define PROCESSOR_ARCHITECTURE_PPC 3
376 #define PROCESSOR_ARCHITECTURE_SHX 4
377 #define PROCESSOR_ARCHITECTURE_ARM 5
378 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
380 /* dwProcessorType */
381 #define PROCESSOR_INTEL_386 386
382 #define PROCESSOR_INTEL_486 486
383 #define PROCESSOR_INTEL_PENTIUM 586
384 #define PROCESSOR_INTEL_860 860
385 #define PROCESSOR_MIPS_R2000 2000
386 #define PROCESSOR_MIPS_R3000 3000
387 #define PROCESSOR_MIPS_R4000 4000
388 #define PROCESSOR_ALPHA_21064 21064
389 #define PROCESSOR_PPC_601 601
390 #define PROCESSOR_PPC_603 603
391 #define PROCESSOR_PPC_604 604
392 #define PROCESSOR_PPC_620 620
393 #define PROCESSOR_HITACHI_SH3 10003
394 #define PROCESSOR_HITACHI_SH3E 10004
395 #define PROCESSOR_HITACHI_SH4 10005
396 #define PROCESSOR_MOTOROLA_821 821
397 #define PROCESSOR_SHx_SH3 103
398 #define PROCESSOR_SHx_SH4 104
399 #define PROCESSOR_STRONGARM 2577
400 #define PROCESSOR_ARM720 1824 /* 0x720 */
401 #define PROCESSOR_ARM820 2080 /* 0x820 */
402 #define PROCESSOR_ARM920 2336 /* 0x920 */
403 #define PROCESSOR_ARM_7TDMI 70001
405 typedef struct _MEMORY_BASIC_INFORMATION
408 LPVOID AllocationBase;
409 DWORD AllocationProtect;
414 } MEMORY_BASIC_INFORMATION,*LPMEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
416 #define PAGE_NOACCESS 0x01
417 #define PAGE_READONLY 0x02
418 #define PAGE_READWRITE 0x04
419 #define PAGE_WRITECOPY 0x08
420 #define PAGE_EXECUTE 0x10
421 #define PAGE_EXECUTE_READ 0x20
422 #define PAGE_EXECUTE_READWRITE 0x40
423 #define PAGE_EXECUTE_WRITECOPY 0x80
424 #define PAGE_GUARD 0x100
425 #define PAGE_NOCACHE 0x200
427 #define MEM_COMMIT 0x00001000
428 #define MEM_RESERVE 0x00002000
429 #define MEM_DECOMMIT 0x00004000
430 #define MEM_RELEASE 0x00008000
431 #define MEM_FREE 0x00010000
432 #define MEM_PRIVATE 0x00020000
433 #define MEM_MAPPED 0x00040000
434 #define MEM_RESET 0x00080000
435 #define MEM_TOP_DOWN 0x00100000
437 #define MEM_SYSTEM 0x80000000
440 #define SEC_FILE 0x00800000
441 #define SEC_IMAGE 0x01000000
442 #define SEC_RESERVE 0x04000000
443 #define SEC_COMMIT 0x08000000
444 #define SEC_NOCACHE 0x10000000
445 #define MEM_IMAGE SEC_IMAGE
450 #define MINSHORT 0x8000
451 #define MAXSHORT 0x7fff
452 #define MINLONG 0x80000000
453 #define MAXLONG 0x7fffffff
455 #define MAXWORD 0xffff
456 #define MAXDWORD 0xffffffff
458 #define FIELD_OFFSET(type, field) \
459 ((LONG)(INT)&(((type *)0)->field))
461 #define CONTAINING_RECORD(address, type, field) \
462 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
466 typedef struct _LIST_ENTRY {
467 struct _LIST_ENTRY *Flink;
468 struct _LIST_ENTRY *Blink;
469 } LIST_ENTRY, *PLIST_ENTRY;
471 typedef struct _SINGLE_LIST_ENTRY {
472 struct _SINGLE_LIST_ENTRY *Next;
473 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
477 #define HEAP_NO_SERIALIZE 0x00000001
478 #define HEAP_GROWABLE 0x00000002
479 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
480 #define HEAP_ZERO_MEMORY 0x00000008
481 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
482 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
483 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
484 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
485 #define HEAP_CREATE_ALIGN_16 0x00010000
486 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
488 /* This flag allows it to create heaps shared by all processes under win95,
489 FIXME: correct name */
490 #define HEAP_SHARED 0x04000000
492 #define HEAP_WINE_SEGPTR 0x10000000 /* Not a Win32 flag */
493 #define HEAP_WINE_CODESEG 0x20000000 /* Not a Win32 flag */
494 #define HEAP_WINE_CODE16SEG 0x40000000 /* Not a Win32 flag */
496 /* Processor feature flags. */
497 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
498 #define PF_FLOATING_POINT_EMULATED 1
499 #define PF_COMPARE_EXCHANGE_DOUBLE 2
500 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
501 #define PF_PPC_MOVEMEM_64BIT_OK 4
502 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
505 /* The Win32 register context */
507 /* CONTEXT is the CPU-dependent context; it should be used */
508 /* wherever a platform-specific context is needed (e.g. exception */
509 /* handling, Win32 register functions). */
511 /* CONTEXT86 is the i386-specific context; it should be used */
512 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
513 /* Win16 register functions), so that this code can be compiled */
514 /* on all platforms. */
516 #define SIZE_OF_80387_REGISTERS 80
518 typedef struct _FLOATING_SAVE_AREA
527 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
529 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
531 typedef struct _CONTEXT86
535 /* These are selected by CONTEXT_DEBUG_REGISTERS */
543 /* These are selected by CONTEXT_FLOATING_POINT */
544 FLOATING_SAVE_AREA FloatSave;
546 /* These are selected by CONTEXT_SEGMENTS */
552 /* These are selected by CONTEXT_INTEGER */
560 /* These are selected by CONTEXT_CONTROL */
569 #define CONTEXT_X86 0x00010000
570 #define CONTEXT_i386 CONTEXT_X86
571 #define CONTEXT_i486 CONTEXT_X86
573 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
574 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
575 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
576 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
577 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
578 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
580 /* i386 context definitions */
583 #define CONTEXT_CONTROL CONTEXT86_CONTROL
584 #define CONTEXT_INTEGER CONTEXT86_INTEGER
585 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
586 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
587 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
588 #define CONTEXT_FULL CONTEXT86_FULL
590 typedef CONTEXT86 CONTEXT;
592 #endif /* __i386__ */
594 /* Alpha context definitions */
597 #define CONTEXT_ALPHA 0x00020000
599 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
600 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
601 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
602 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
604 typedef struct _CONTEXT
606 /* selected by CONTEXT_FLOATING_POINT */
640 /* selected by CONTEXT_INTEGER */
674 /* selected by CONTEXT_FLOATING_POINT */
678 /* selected by CONTEXT_CONTROL */
685 #define _QUAD_PSR_OFFSET HighSoftFpcr
686 #define _QUAD_FLAGS_OFFSET HighFir
690 /* Mips context definitions */
693 #define CONTEXT_R4000 0x00010000
695 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
696 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
697 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
699 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
701 typedef struct _CONTEXT
704 /* These are selected by CONTEXT_FLOATING_POINT */
738 /* These are selected by CONTEXT_INTEGER */
774 /* These are selected by CONTEXT_FLOATING_POINT */
777 /* These are selected by CONTEXT_CONTROL */
787 /* PowerPC context definitions */
790 #define CONTEXT_CONTROL 0x0001
791 #define CONTEXT_FLOATING_POINT 0x0002
792 #define CONTEXT_INTEGER 0x0004
793 #define CONTEXT_DEBUG_REGISTERS 0x0008
794 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
798 /* These are selected by CONTEXT_FLOATING_POINT */
833 /* These are selected by CONTEXT_INTEGER */
870 /* These are selected by CONTEXT_CONTROL */
879 /* These are selected by CONTEXT_DEBUG_REGISTERS */
890 typedef struct _STACK_FRAME_HEADER
907 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
916 * There is no official CONTEXT structure defined for the SPARC
917 * architecture, so I just made one up.
919 * This structure is valid only for 32-bit SPARC architectures,
920 * not for 64-bit SPARC.
922 * Note that this structure contains only the 'top-level' registers;
923 * the rest of the register window chain is not visible.
925 * The layout follows the Solaris 'prgregset_t' structure.
929 #define CONTEXT_SPARC 0x10000000
931 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
932 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
933 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
935 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
937 typedef struct _CONTEXT
941 /* These are selected by CONTEXT_INTEGER */
975 /* These are selected by CONTEXT_CONTROL */
983 /* FIXME: floating point registers missing */
987 #endif /* __sparc__ */
989 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
990 #error You need to define a CONTEXT for your CPU
993 typedef CONTEXT *PCONTEXT;
997 /* Macros for easier access to i386 context registers */
999 #define AX_reg(context) (*(WORD*)&(context)->Eax)
1000 #define BX_reg(context) (*(WORD*)&(context)->Ebx)
1001 #define CX_reg(context) (*(WORD*)&(context)->Ecx)
1002 #define DX_reg(context) (*(WORD*)&(context)->Edx)
1003 #define SI_reg(context) (*(WORD*)&(context)->Esi)
1004 #define DI_reg(context) (*(WORD*)&(context)->Edi)
1005 #define BP_reg(context) (*(WORD*)&(context)->Ebp)
1007 #define AL_reg(context) (*(BYTE*)&(context)->Eax)
1008 #define AH_reg(context) (*((BYTE*)&(context)->Eax + 1))
1009 #define BL_reg(context) (*(BYTE*)&(context)->Ebx)
1010 #define BH_reg(context) (*((BYTE*)&(context)->Ebx + 1))
1011 #define CL_reg(context) (*(BYTE*)&(context)->Ecx)
1012 #define CH_reg(context) (*((BYTE*)&(context)->Ecx + 1))
1013 #define DL_reg(context) (*(BYTE*)&(context)->Edx)
1014 #define DH_reg(context) (*((BYTE*)&(context)->Edx + 1))
1016 #define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
1017 #define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
1018 #define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
1019 #define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
1020 #define ISV86(context) ((context)->EFlags & 0x00020000)
1023 /* Macros to retrieve the current context */
1025 #ifdef NEED_UNDERSCORE_PREFIX
1026 # define __ASM_NAME(name) "_" name
1028 # define __ASM_NAME(name) name
1031 #ifdef NEED_TYPE_IN_DEF
1032 # define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
1034 # define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
1038 # define __ASM_GLOBAL_FUNC(name,code) \
1039 __asm__( ".align 4\n\t" \
1040 ".globl " __ASM_NAME(#name) "\n\t" \
1041 __ASM_FUNC(#name) "\n" \
1042 __ASM_NAME(#name) ":\n\t" \
1044 #else /* __GNUC__ */
1045 # define __ASM_GLOBAL_FUNC(name,code) \
1046 void __asm_dummy_##name(void) { \
1047 asm( ".align 4\n\t" \
1048 ".globl " __ASM_NAME(#name) "\n\t" \
1049 __ASM_FUNC(#name) "\n" \
1050 __ASM_NAME(#name) ":\n\t" \
1053 #endif /* __GNUC__ */
1057 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
1058 __ASM_GLOBAL_FUNC( name, \
1059 "call " __ASM_NAME("CALL32_Regs") "\n\t" \
1060 ".long " __ASM_NAME(#fn) "\n\t" \
1061 ".byte " #args ", " #args )
1062 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1063 extern void WINAPI name(void); \
1064 _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
1065 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1066 extern void WINAPI name( t1 a1 ); \
1067 _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
1068 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1069 extern void WINAPI name( t1 a1, t2 a2 ); \
1070 _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
1071 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1072 extern void WINAPI name( t1 a1, t2 a2, t3 a3 ); \
1073 _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
1074 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1075 extern void WINAPI name( t1 a1, t2 a2, t3 a3, t4 a4 ); \
1076 _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
1078 #endif /* __i386__ */
1081 /* FIXME: use getcontext() to retrieve full context */
1082 #define _GET_CONTEXT \
1084 do { memset(&context, 0, sizeof(CONTEXT)); \
1085 context.ContextFlags = CONTEXT_CONTROL; \
1086 context.pc = (DWORD)__builtin_return_address(0); \
1089 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1090 void WINAPI name ( void ) \
1091 { _GET_CONTEXT; fn( &context ); }
1092 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1093 void WINAPI name ( t1 a1 ) \
1094 { _GET_CONTEXT; fn( a1, &context ); }
1095 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1096 void WINAPI name ( t1 a1, t2 a2 ) \
1097 { _GET_CONTEXT; fn( a1, a2, &context ); }
1098 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1099 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1100 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1101 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1102 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1103 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1105 #endif /* __sparc__ */
1107 #ifndef DEFINE_REGS_ENTRYPOINT_0
1108 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
1111 /* Constructor functions */
1114 # define DECL_GLOBAL_CONSTRUCTOR(func) \
1115 static void func(void) __attribute__((constructor)); \
1116 static void func(void)
1117 #else /* __GNUC__ */
1119 # define DECL_GLOBAL_CONSTRUCTOR(func) \
1120 static void __dummy_init_##func(void) { \
1121 asm(".section .init,\"ax\"\n\t" \
1122 "call " #func "\n\t" \
1124 static void func(void)
1125 # else /* __i386__ */
1126 # error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
1128 #endif /* __GNUC__ */
1130 /* Segment register access */
1134 # define __DEFINE_GET_SEG(seg) \
1135 extern inline unsigned short __get_##seg(void) \
1136 { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
1137 # define __DEFINE_SET_SEG(seg) \
1138 extern inline void __set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
1139 # else /* __GNUC__ */
1140 # define __DEFINE_GET_SEG(seg) extern unsigned short __get_##seg(void);
1141 # define __DEFINE_SET_SEG(seg) extern void __set_##seg(unsigned int);
1142 # endif /* __GNUC__ */
1143 #else /* __i386__ */
1144 # define __DEFINE_GET_SEG(seg) inline static unsigned short __get_##seg(void) { return 0; }
1145 # define __DEFINE_SET_SEG(seg) /* nothing */
1146 #endif /* __i386__ */
1148 __DEFINE_GET_SEG(cs)
1149 __DEFINE_GET_SEG(ds)
1150 __DEFINE_GET_SEG(es)
1151 __DEFINE_GET_SEG(fs)
1152 __DEFINE_GET_SEG(gs)
1153 __DEFINE_GET_SEG(ss)
1154 __DEFINE_SET_SEG(fs)
1155 __DEFINE_SET_SEG(gs)
1156 #undef __DEFINE_GET_SEG
1157 #undef __DEFINE_SET_SEG
1159 #endif /* __WINE__ */
1167 #define MAKELCID(l, s) (MAKELONG(l, s))
1169 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1170 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1171 #define SUBLANGID(l) ((WORD)(l) >> 10)
1173 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1174 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1176 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1177 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1178 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1179 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1180 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1182 /* FIXME: are the symbolic names correct for LIDs: 0x17, 0x20, 0x28,
1183 * 0x2a, 0x2b, 0x2c, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
1184 * 0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3e, 0x3f, 0x41, 0x43, 0x44,
1185 * 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
1188 #define LANG_NEUTRAL 0x00
1189 #define LANG_AFRIKAANS 0x36
1190 #define LANG_ALBANIAN 0x1c
1191 #define LANG_ARABIC 0x01
1192 #define LANG_ARMENIAN 0x2b
1193 #define LANG_ASSAMESE 0x4d
1194 #define LANG_AZERI 0x2c
1195 #define LANG_BASQUE 0x2d
1196 #define LANG_BENGALI 0x45
1197 #define LANG_BULGARIAN 0x02
1198 #define LANG_BYELORUSSIAN 0x23
1199 #define LANG_CATALAN 0x03
1200 #define LANG_CHINESE 0x04
1201 #define LANG_SERBO_CROATIAN 0x1a
1202 #define LANG_CROATIAN LANG_SERBO_CROATIAN
1203 #define LANG_SERBIAN LANG_SERBO_CROATIAN
1204 #define LANG_CZECH 0x05
1205 #define LANG_DANISH 0x06
1206 #define LANG_DUTCH 0x13
1207 #define LANG_ENGLISH 0x09
1208 #define LANG_ESTONIAN 0x25
1209 #define LANG_FAEROESE 0x38
1210 #define LANG_FARSI 0x29
1211 #define LANG_FINNISH 0x0b
1212 #define LANG_FRENCH 0x0c
1213 #define LANG_GAELIC 0x3c
1214 #define LANG_GEORGIAN 0x37
1215 #define LANG_GERMAN 0x07
1216 #define LANG_GREEK 0x08
1217 #define LANG_GUJARATI 0x47
1218 #define LANG_HEBREW 0x0D
1219 #define LANG_HINDI 0x39
1220 #define LANG_HUNGARIAN 0x0e
1221 #define LANG_ICELANDIC 0x0f
1222 #define LANG_INDONESIAN 0x21
1223 #define LANG_ITALIAN 0x10
1224 #define LANG_JAPANESE 0x11
1225 #define LANG_KANNADA 0x4b
1226 #define LANG_KAZAKH 0x3f
1227 #define LANG_KONKANI 0x57
1228 #define LANG_KOREAN 0x12
1229 #define LANG_LATVIAN 0x26
1230 #define LANG_LITHUANIAN 0x27
1231 #define LANG_MACEDONIAN 0x2f
1232 #define LANG_MALAY 0x3e
1233 #define LANG_MALAYALAM 0x4c
1234 #define LANG_MALTESE 0x3a
1235 #define LANG_MAORI 0x28
1236 #define LANG_MARATHI 0x4e
1237 #define LANG_NORWEGIAN 0x14
1238 #define LANG_ORIYA 0x48
1239 #define LANG_POLISH 0x15
1240 #define LANG_PORTUGUESE 0x16
1241 #define LANG_PUNJABI 0x46
1242 #define LANG_RHAETO_ROMANCE 0x17
1243 #define LANG_ROMANIAN 0x18
1244 #define LANG_RUSSIAN 0x19
1245 #define LANG_SAAMI 0x3b
1246 #define LANG_SANSKRIT 0x4f
1247 #define LANG_SLOVAK 0x1b
1248 #define LANG_SLOVENIAN 0x24
1249 #define LANG_SORBIAN 0x2e
1250 #define LANG_SPANISH 0x0a
1251 #define LANG_SUTU 0x30
1252 #define LANG_SWAHILI 0x41
1253 #define LANG_SWEDISH 0x1d
1254 #define LANG_TAMIL 0x49
1255 #define LANG_TATAR 0x44
1256 #define LANG_TELUGU 0x4a
1257 #define LANG_THAI 0x1e
1258 #define LANG_TSONGA 0x31
1259 #define LANG_TSWANA 0x32
1260 #define LANG_TURKISH 0x1f
1261 #define LANG_UKRAINIAN 0x22
1262 #define LANG_URDU 0x20
1263 #define LANG_UZBEK 0x43
1264 #define LANG_VENDA 0x33
1265 #define LANG_VIETNAMESE 0x2a
1266 #define LANG_XHOSA 0x34
1267 #define LANG_ZULU 0x35
1268 /* non standard; keep the number high enough (but < 0xff) */
1269 #define LANG_ESPERANTO 0x8f
1270 #define LANG_WALON 0x90
1271 #define LANG_CORNISH 0x91
1272 #define LANG_WELSH 0x92
1273 #define LANG_BRETON 0x93
1275 /* Sublanguage definitions */
1276 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
1277 #define SUBLANG_DEFAULT 0x01 /* user default */
1278 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
1280 #define SUBLANG_ARABIC 0x01
1281 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
1282 #define SUBLANG_ARABIC_IRAQ 0x02
1283 #define SUBLANG_ARABIC_EGYPT 0x03
1284 #define SUBLANG_ARABIC_LIBYA 0x04
1285 #define SUBLANG_ARABIC_ALGERIA 0x05
1286 #define SUBLANG_ARABIC_MOROCCO 0x06
1287 #define SUBLANG_ARABIC_TUNISIA 0x07
1288 #define SUBLANG_ARABIC_OMAN 0x08
1289 #define SUBLANG_ARABIC_YEMEN 0x09
1290 #define SUBLANG_ARABIC_SYRIA 0x0a
1291 #define SUBLANG_ARABIC_JORDAN 0x0b
1292 #define SUBLANG_ARABIC_LEBANON 0x0c
1293 #define SUBLANG_ARABIC_KUWAIT 0x0d
1294 #define SUBLANG_ARABIC_UAE 0x0e
1295 #define SUBLANG_ARABIC_BAHRAIN 0x0f
1296 #define SUBLANG_ARABIC_QATAR 0x10
1297 #define SUBLANG_CHINESE_TRADITIONAL 0x01
1298 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
1299 #define SUBLANG_CHINESE_HONGKONG 0x03
1300 #define SUBLANG_CHINESE_SINGAPORE 0x04
1301 #define SUBLANG_CHINESE_MACAU 0x05
1302 #define SUBLANG_DUTCH 0x01
1303 #define SUBLANG_DUTCH_BELGIAN 0x02
1304 #define SUBLANG_DUTCH_SURINAM 0x03
1305 #define SUBLANG_ENGLISH_US 0x01
1306 #define SUBLANG_ENGLISH_UK 0x02
1307 #define SUBLANG_ENGLISH_AUS 0x03
1308 #define SUBLANG_ENGLISH_CAN 0x04
1309 #define SUBLANG_ENGLISH_NZ 0x05
1310 #define SUBLANG_ENGLISH_EIRE 0x06
1311 #define SUBLANG_ENGLISH_SAFRICA 0x07
1312 #define SUBLANG_ENGLISH_JAMAICA 0x08
1313 #define SUBLANG_ENGLISH_CARRIBEAN 0x09
1314 #define SUBLANG_ENGLISH_BELIZE 0x0a
1315 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
1316 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
1317 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
1318 #define SUBLANG_FRENCH 0x01
1319 #define SUBLANG_FRENCH_BELGIAN 0x02
1320 #define SUBLANG_FRENCH_CANADIAN 0x03
1321 #define SUBLANG_FRENCH_SWISS 0x04
1322 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
1323 #define SUBLANG_FRENCH_MONACO 0x06
1324 #define SUBLANG_GERMAN 0x01
1325 #define SUBLANG_GERMAN_SWISS 0x02
1326 #define SUBLANG_GERMAN_AUSTRIAN 0x03
1327 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
1328 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
1329 #define SUBLANG_ITALIAN 0x01
1330 #define SUBLANG_ITALIAN_SWISS 0x02
1331 #define SUBLANG_KOREAN 0x01
1332 #define SUBLANG_KOREAN_JOHAB 0x02
1333 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
1334 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
1335 #define SUBLANG_PORTUGUESE 0x02
1336 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
1337 #define SUBLANG_SPANISH 0x01
1338 #define SUBLANG_SPANISH_MEXICAN 0x02
1339 #define SUBLANG_SPANISH_MODERN 0x03
1340 #define SUBLANG_SPANISH_GUATEMALA 0x04
1341 #define SUBLANG_SPANISH_COSTARICA 0x05
1342 #define SUBLANG_SPANISH_PANAMA 0x06
1343 #define SUBLANG_SPANISH_DOMINICAN 0x07
1344 #define SUBLANG_SPANISH_VENEZUELA 0x08
1345 #define SUBLANG_SPANISH_COLOMBIA 0x09
1346 #define SUBLANG_SPANISH_PERU 0x0a
1347 #define SUBLANG_SPANISH_ARGENTINA 0x0b
1348 #define SUBLANG_SPANISH_ECUADOR 0x0c
1349 #define SUBLANG_SPANISH_CHILE 0x0d
1350 #define SUBLANG_SPANISH_URUGUAY 0x0e
1351 #define SUBLANG_SPANISH_PARAGUAY 0x0f
1352 #define SUBLANG_SPANISH_BOLIVIA 0x10
1353 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
1354 #define SUBLANG_SPANISH_HONDURAS 0x12
1355 #define SUBLANG_SPANISH_NICARAGUA 0x13
1356 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
1357 /* FIXME: I don't know the symbolic names for those */
1358 #define SUBLANG_ROMANIAN 0x01
1359 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
1360 #define SUBLANG_RUSSIAN 0x01
1361 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
1362 #define SUBLANG_CROATIAN 0x01
1363 #define SUBLANG_SERBIAN 0x02
1364 #define SUBLANG_SERBIAN_LATIN 0x03
1365 #define SUBLANG_SWEDISH 0x01
1366 #define SUBLANG_SWEDISH_FINLAND 0x02
1367 #define SUBLANG_LITHUANIAN 0x01
1368 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
1369 #define SUBLANG_AZERI 0x01
1370 #define SUBLANG_AZERI_CYRILLIC 0x02
1371 #define SUBLANG_GAELIC 0x01
1372 #define SUBLANG_GAELIC_SCOTTISH 0x02
1373 #define SUBLANG_GAELIC_MANX 0x03
1374 #define SUBLANG_MALAY 0x01
1375 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
1376 #define SUBLANG_UZBEK 0x01
1377 #define SUBLANG_UZBEK_CYRILLIC 0x02
1378 #define SUBLANG_URDU_PAKISTAN 0x01
1386 #define SORT_DEFAULT 0x0
1387 #define SORT_JAPANESE_XJIS 0x0
1388 #define SORT_JAPANESE_UNICODE 0x1
1389 #define SORT_CHINESE_BIG5 0x0
1390 #define SORT_CHINESE_UNICODE 0x1
1391 #define SORT_KOREAN_KSC 0x0
1392 #define SORT_KOREAN_UNICODE 0x1
1397 * Definitions for IsTextUnicode()
1400 #define IS_TEXT_UNICODE_ASCII16 0x0001
1401 #define IS_TEXT_UNICODE_STATISTICS 0x0002
1402 #define IS_TEXT_UNICODE_CONTROLS 0x0004
1403 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
1404 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
1405 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
1406 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1407 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
1408 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
1409 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
1410 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
1411 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
1412 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
1413 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
1414 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
1415 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
1423 #define STATUS_SUCCESS 0x00000000
1424 #define STATUS_WAIT_0 0x00000000
1425 #define STATUS_ABANDONED_WAIT_0 0x00000080
1426 #define STATUS_USER_APC 0x000000C0
1427 #define STATUS_TIMEOUT 0x00000102
1428 #define STATUS_PENDING 0x00000103
1430 #define STATUS_GUARD_PAGE_VIOLATION 0x80000001
1431 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
1432 #define STATUS_BREAKPOINT 0x80000003
1433 #define STATUS_SINGLE_STEP 0x80000004
1434 #define STATUS_BUFFER_OVERFLOW 0x80000005
1435 #define STATUS_NO_MORE_FILES 0x80000006
1436 #define STATUS_WAKE_SYSTEM_DEBUGGER 0x80000007
1438 #define STATUS_HANDLES_CLOSED 0x8000000A
1439 #define STATUS_NO_INHERITANCE 0x8000000B
1440 #define STATUS_GUID_SUBSTITUTION_MADE 0x8000000C
1441 #define STATUS_PARTIAL_COPY 0x8000000D
1442 #define STATUS_DEVICE_PAPER_EMPTY 0x8000000E
1443 #define STATUS_DEVICE_POWERED_OFF 0x8000000F
1444 #define STATUS_DEVICE_OFF_LINE 0x80000010
1445 #define STATUS_DEVICE_BUSY 0x80000011
1446 #define STATUS_NO_MORE_EAS 0x80000012
1447 #define STATUS_INVALID_EA_NAME 0x80000013
1448 #define STATUS_EA_LIST_INCONSISTENT 0x80000014
1449 #define STATUS_INVALID_EA_FLAG 0x80000015
1450 #define STATUS_VERIFY_REQUIRED 0x80000016
1451 #define STATUS_EXTRANEOUS_INFORMATION 0x80000017
1452 #define STATUS_RXACT_COMMIT_NECESSARY 0x80000018
1453 #define STATUS_NO_MORE_ENTRIES 0x8000001A
1454 #define STATUS_FILEMARK_DETECTED 0x8000001B
1455 #define STATUS_MEDIA_CHANGED 0x8000001C
1456 #define STATUS_BUS_RESET 0x8000001D
1457 #define STATUS_END_OF_MEDIA 0x8000001E
1458 #define STATUS_BEGINNING_OF_MEDIA 0x8000001F
1459 #define STATUS_MEDIA_CHECK 0x80000020
1460 #define STATUS_SETMARK_DETECTED 0x80000021
1461 #define STATUS_NO_DATA_DETECTED 0x80000022
1462 #define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
1463 #define STATUS_SERVER_HAS_OPEN_HANDLES 0x80000024
1464 #define STATUS_ALREADY_DISCONNECTED 0x80000025
1465 #define STATUS_LONGJUMP 0x80000026
1467 #define STATUS_UNSUCCESSFUL 0xC0000001
1468 #define STATUS_NOT_IMPLEMENTED 0xC0000002
1469 #define STATUS_INVALID_INFO_CLASS 0xC0000003
1470 #define STATUS_INFO_LENGTH_MISMATCH 0xC0000004
1471 #define STATUS_ACCESS_VIOLATION 0xC0000005
1472 #define STATUS_IN_PAGE_ERROR 0xC0000006
1473 #define STATUS_PAGEFILE_QUOTA 0xC0000007
1474 #define STATUS_INVALID_HANDLE 0xC0000008
1475 #define STATUS_BAD_INITIAL_STACK 0xC0000009
1476 #define STATUS_BAD_INITIAL_PC 0xC000000A
1477 #define STATUS_INVALID_CID 0xC000000B
1478 #define STATUS_TIMER_NOT_CANCELED 0xC000000C
1479 #define STATUS_INVALID_PARAMETER 0xC000000D
1480 #define STATUS_NO_SUCH_DEVICE 0xC000000E
1481 #define STATUS_NO_SUCH_FILE 0xC000000F
1482 #define STATUS_INVALID_DEVICE_REQUEST 0xC0000010
1483 #define STATUS_END_OF_FILE 0xC0000011
1484 #define STATUS_WRONG_VOLUME 0xC0000012
1485 #define STATUS_NO_MEDIA_IN_DEVICE 0xC0000013
1486 #define STATUS_UNRECOGNIZED_MEDIA 0xC0000014
1487 #define STATUS_NONEXISTENT_SECTOR 0xC0000015
1488 #define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
1489 #define STATUS_NO_MEMORY 0xC0000017
1490 #define STATUS_CONFLICTING_ADDRESSES 0xC0000018
1491 #define STATUS_NOT_MAPPED_VIEW 0xC0000019
1492 #define STATUS_UNABLE_TO_FREE_VM 0xC000001A
1493 #define STATUS_UNABLE_TO_DELETE_SECTION 0xC000001B
1494 #define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
1495 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
1496 #define STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
1497 #define STATUS_INVALID_VIEW_SIZE 0xC000001F
1498 #define STATUS_INVALID_FILE_FOR_SECTION 0xC0000020
1499 #define STATUS_ALREADY_COMMITTED 0xC0000021
1500 #define STATUS_ACCESS_DENIED 0xC0000022
1501 #define STATUS_BUFFER_TOO_SMALL 0xC0000023
1502 #define STATUS_OBJECT_TYPE_MISMATCH 0xC0000024
1503 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
1504 #define STATUS_INVALID_DISPOSITION 0xC0000026
1505 #define STATUS_UNWIND 0xC0000027
1506 #define STATUS_BAD_STACK 0xC0000028
1507 #define STATUS_INVALID_UNWIND_TARGET 0xC0000029
1508 #define STATUS_NOT_LOCKED 0xC000002A
1509 #define STATUS_PARITY_ERROR 0xC000002B
1510 #define STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002C
1511 #define STATUS_NOT_COMMITTED 0xC000002D
1512 #define STATUS_INVALID_PORT_ATTRIBUTES 0xC000002E
1513 #define STATUS_PORT_MESSAGE_TOO_LONG 0xC000002F
1514 #define STATUS_INVALID_PARAMETER_MIX 0xC0000030
1515 #define STATUS_INVALID_QUOTA_LOWER 0xC0000031
1516 #define STATUS_DISK_CORRUPT_ERROR 0xC0000032
1517 #define STATUS_OBJECT_NAME_INVALID 0xC0000033
1518 #define STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034
1519 #define STATUS_OBJECT_NAME_COLLISION 0xC0000035
1520 #define STATUS_PORT_DISCONNECTED 0xC0000037
1521 #define STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038
1522 #define STATUS_OBJECT_PATH_INVALID 0xC0000039
1523 #define STATUS_OBJECT_PATH_NOT_FOUND 0xC000003A
1524 #define STATUS_PATH_SYNTAX_BAD 0xC000003B
1525 #define STATUS_DATA_OVERRUN 0xC000003C
1526 #define STATUS_DATA_LATE_ERROR 0xC000003D
1527 #define STATUS_DATA_ERROR 0xC000003E
1528 #define STATUS_CRC_ERROR 0xC000003F
1529 #define STATUS_SECTION_TOO_BIG 0xC0000040
1530 #define STATUS_PORT_CONNECTION_REFUSED 0xC0000041
1531 #define STATUS_INVALID_PORT_HANDLE 0xC0000042
1532 #define STATUS_SHARING_VIOLATION 0xC0000043
1533 #define STATUS_QUOTA_EXCEEDED 0xC0000044
1534 #define STATUS_INVALID_PAGE_PROTECTION 0xC0000045
1535 #define STATUS_MUTANT_NOT_OWNED 0xC0000046
1536 #define STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047
1537 #define STATUS_PORT_ALREADY_SET 0xC0000048
1538 #define STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004A
1539 #define STATUS_LOCK_NOT_GRANTED 0xC0000054 /* FIXME: not sure */
1540 #define STATUS_FILE_LOCK_CONFLICT 0xC0000055 /* FIXME: not sure */
1541 #define STATUS_UNKNOWN_REVISION 0xC0000058
1542 #define STATUS_INVALID_SECURITY_DESCR 0xC0000079
1543 #define STATUS_DISK_FULL 0xC000007F
1544 #define STATUS_SECTION_NOT_EXTENDED 0xC0000087
1545 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
1546 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
1547 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
1548 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
1549 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
1550 #define STATUS_FLOAT_OVERFLOW 0xC0000091
1551 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
1552 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
1553 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
1554 #define STATUS_INTEGER_OVERFLOW 0xC0000095
1555 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
1556 #define STATUS_MEDIA_WRITE_PROTECTED 0XC00000A2
1557 #define STATUS_INVALID_PARAMETER_2 0xC00000F0
1558 #define STATUS_STACK_OVERFLOW 0xC00000FD
1559 #define STATUS_DIRECTORY_NOT_EMPTY 0xC0000101
1560 #define STATUS_TOO_MANY_OPENED_FILES 0xC000011F
1561 #define STATUS_CONTROL_C_EXIT 0xC000013A
1562 #define STATUS_PIPE_BROKEN 0xC000014B
1563 #define STATUS_NOT_REGISTRY_FILE 0xC000015C
1564 #define STATUS_PARTITION_FAILURE 0xC0000172
1565 #define STATUS_INVALID_BLOCK_LENGTH 0xC0000173
1566 #define STATUS_DEVICE_NOT_PARTITIONED 0xC0000174
1567 #define STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175
1568 #define STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176
1569 #define STATUS_EOM_OVERFLOW 0xC0000177
1570 #define STATUS_NO_MEDIA 0xC0000178
1571 #define STATUS_NO_SUCH_MEMBER 0xC000017A
1572 #define STATUS_INVALID_MEMBER 0xC000017B
1573 #define STATUS_KEY_DELETED 0xC000017C
1574 #define STATUS_NO_LOG_SPACE 0xC000017D
1575 #define STATUS_TOO_MANY_SIDS 0xC000017E
1576 #define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
1577 #define STATUS_KEY_HAS_CHILDREN 0xC0000180
1578 #define STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181
1579 #define STATUS_DEVICE_CONFIGURATION_ERROR0xC0000182
1580 #define STATUS_DRIVER_INTERNAL_ERROR 0xC0000183
1581 #define STATUS_INVALID_DEVICE_STATE 0xC0000184
1582 #define STATUS_IO_DEVICE_ERROR 0xC0000185
1583 #define STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186
1584 #define STATUS_BACKUP_CONTROLLER 0xC0000187
1585 #define STATUS_LOG_FILE_FULL 0xC0000188
1586 #define STATUS_TOO_LATE 0xC0000189
1587 #define STATUS_NO_TRUST_LSA_SECRET 0xC000018A
1588 #define STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018B
1589 #define STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018C
1590 #define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
1591 #define STATUS_EVENTLOG_FILE_CORRUPT 0xC000018E
1592 #define STATUS_EVENTLOG_CANT_START 0xC000018F
1593 #define STATUS_TRUST_FAILURE 0xC0000190
1594 #define STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191
1595 #define STATUS_NETLOGON_NOT_STARTED 0xC0000192
1596 #define STATUS_ACCOUNT_EXPIRED 0xC0000193
1597 #define STATUS_POSSIBLE_DEADLOCK 0xC0000194
1598 #define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
1599 #define STATUS_REMOTE_SESSION_LIMIT 0xC0000196
1600 #define STATUS_EVENTLOG_FILE_CHANGED 0xC0000197
1601 #define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
1602 #define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
1603 #define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
1604 #define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
1605 #define STATUS_FS_DRIVER_REQUIRED 0xC000019C
1607 #define STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204
1609 #define MAXIMUM_WAIT_OBJECTS 64
1610 #define MAXIMUM_SUSPEND_COUNT 127
1614 * Return values from the actual exception handlers
1617 #define ExceptionContinueExecution 0
1618 #define ExceptionContinueSearch 1
1619 #define ExceptionNestedException 2
1620 #define ExceptionCollidedUnwind 3
1623 * Return values from filters in except() and from UnhandledExceptionFilter
1626 #define EXCEPTION_EXECUTE_HANDLER 1
1627 #define EXCEPTION_CONTINUE_SEARCH 0
1628 #define EXCEPTION_CONTINUE_EXECUTION -1
1631 * From OS/2 2.0 exception handling
1632 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1635 #define EH_NONCONTINUABLE 0x01
1636 #define EH_UNWINDING 0x02
1637 #define EH_EXIT_UNWIND 0x04
1638 #define EH_STACK_INVALID 0x08
1639 #define EH_NESTED_CALL 0x10
1641 #define EXCEPTION_CONTINUABLE 0
1642 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
1645 * The exception record used by Win32 to give additional information
1646 * about exception to exception handlers.
1649 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1651 typedef struct __EXCEPTION_RECORD
1653 DWORD ExceptionCode;
1654 DWORD ExceptionFlags;
1655 struct __EXCEPTION_RECORD *ExceptionRecord;
1657 LPVOID ExceptionAddress;
1658 DWORD NumberParameters;
1659 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1660 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1663 * The exception pointers structure passed to exception filters
1664 * in except() and the UnhandledExceptionFilter().
1667 typedef struct _EXCEPTION_POINTERS
1669 PEXCEPTION_RECORD ExceptionRecord;
1670 PCONTEXT ContextRecord;
1671 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1675 * The exception frame, used for registering exception handlers
1676 * Win32 cares only about this, but compilers generally emit
1677 * larger exception frames for their own use.
1680 struct __EXCEPTION_FRAME;
1682 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
1683 PCONTEXT,struct __EXCEPTION_FRAME **);
1685 typedef struct __EXCEPTION_FRAME
1687 struct __EXCEPTION_FRAME *Prev;
1688 PEXCEPTION_HANDLER Handler;
1689 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
1691 #include "poppack.h"
1694 * function pointer to a exception filter
1697 typedef LONG CALLBACK (*PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1698 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1700 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1701 LPTOP_LEVEL_EXCEPTION_FILTER
1702 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1704 /* status values for ContinueDebugEvent */
1705 #define DBG_CONTINUE 0x00010002
1706 #define DBG_TERMINATE_THREAD 0x40010003
1707 #define DBG_TERMINATE_PROCESS 0x40010004
1708 #define DBG_CONTROL_C 0x40010005
1709 #define DBG_CONTROL_BREAK 0x40010008
1710 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
1712 typedef struct _NT_TIB
1714 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1722 PVOID ArbitraryUserPointer;
1723 struct _NT_TIB *Self;
1728 #if defined(__i386__) && defined(__GNUC__)
1729 extern inline struct _TEB WINAPI *NtCurrentTeb(void);
1730 extern inline struct _TEB WINAPI *NtCurrentTeb(void)
1733 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1737 extern struct _TEB WINAPI *NtCurrentTeb(void);
1742 * File formats definitions
1745 typedef struct _IMAGE_DOS_HEADER {
1746 WORD e_magic; /* 00: MZ Header signature */
1747 WORD e_cblp; /* 02: Bytes on last page of file */
1748 WORD e_cp; /* 04: Pages in file */
1749 WORD e_crlc; /* 06: Relocations */
1750 WORD e_cparhdr; /* 08: Size of header in paragraphs */
1751 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
1752 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
1753 WORD e_ss; /* 0e: Initial (relative) SS value */
1754 WORD e_sp; /* 10: Initial SP value */
1755 WORD e_csum; /* 12: Checksum */
1756 WORD e_ip; /* 14: Initial IP value */
1757 WORD e_cs; /* 16: Initial (relative) CS value */
1758 WORD e_lfarlc; /* 18: File address of relocation table */
1759 WORD e_ovno; /* 1a: Overlay number */
1760 WORD e_res[4]; /* 1c: Reserved words */
1761 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
1762 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
1763 WORD e_res2[10]; /* 28: Reserved words */
1764 DWORD e_lfanew; /* 3c: Offset to extended header */
1765 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1767 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
1768 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
1769 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
1770 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
1771 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
1772 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
1775 * This is the Windows executable (NE) header.
1776 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
1780 WORD ne_magic; /* 00 NE signature 'NE' */
1781 BYTE ne_ver; /* 02 Linker version number */
1782 BYTE ne_rev; /* 03 Linker revision number */
1783 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
1784 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
1785 LONG ne_crc; /* 08 Checksum */
1786 WORD ne_flags; /* 0c Flags about segments in this file */
1787 WORD ne_autodata; /* 0e Automatic data segment number */
1788 WORD ne_heap; /* 10 Initial size of local heap */
1789 WORD ne_stack; /* 12 Initial size of stack */
1790 DWORD ne_csip; /* 14 Initial CS:IP */
1791 DWORD ne_sssp; /* 18 Initial SS:SP */
1792 WORD ne_cseg; /* 1c # of entries in segment table */
1793 WORD ne_cmod; /* 1e # of entries in module reference tab. */
1794 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
1795 WORD ne_segtab; /* 22 Offset to segment table */
1796 WORD ne_rsrctab; /* 24 Offset to resource table */
1797 WORD ne_restab; /* 26 Offset to resident-name table */
1798 WORD ne_modtab; /* 28 Offset to module reference table */
1799 WORD ne_imptab; /* 2a Offset to imported name table */
1800 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
1801 WORD ne_cmovent; /* 30 # of movable entry points */
1802 WORD ne_align; /* 32 Logical sector alignment shift count */
1803 WORD ne_cres; /* 34 # of resource segments */
1804 BYTE ne_exetyp; /* 36 Flags indicating target OS */
1805 BYTE ne_flagsothers; /* 37 Additional information flags */
1806 WORD fastload_offset; /* 38 Offset to fast load area (should be ne_pretthunks)*/
1807 WORD fastload_length; /* 3a Length of fast load area (should be ne_psegrefbytes) */
1808 WORD ne_swaparea; /* 3c Reserved by Microsoft */
1809 WORD ne_expver; /* 3e Expected Windows version number */
1810 } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
1812 typedef struct _IMAGE_VXD_HEADER {
1827 DWORD e32_lastpagesize;
1828 DWORD e32_fixupsize;
1845 DWORD e32_impmodcnt;
1851 DWORD e32_cbnrestab;
1854 DWORD e32_debuginfo;
1856 DWORD e32_instpreload;
1857 DWORD e32_instdemand;
1860 DWORD e32_winresoff;
1861 DWORD e32_winreslen;
1864 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1867 /* These defines describe the meanings of the bits in the Characteristics
1870 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
1871 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
1872 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
1873 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
1874 #define IMAGE_FILE_16BIT_MACHINE 0x0040
1875 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
1876 #define IMAGE_FILE_32BIT_MACHINE 0x0100
1877 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
1878 #define IMAGE_FILE_SYSTEM 0x1000
1879 #define IMAGE_FILE_DLL 0x2000
1880 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
1882 /* These are the settings of the Machine field. */
1883 #define IMAGE_FILE_MACHINE_UNKNOWN 0
1884 #define IMAGE_FILE_MACHINE_I860 0x14d
1885 #define IMAGE_FILE_MACHINE_I386 0x14c
1886 #define IMAGE_FILE_MACHINE_R3000 0x162
1887 #define IMAGE_FILE_MACHINE_R4000 0x166
1888 #define IMAGE_FILE_MACHINE_R10000 0x168
1889 #define IMAGE_FILE_MACHINE_ALPHA 0x184
1890 #define IMAGE_FILE_MACHINE_POWERPC 0x1F0
1892 #define IMAGE_SIZEOF_FILE_HEADER 20
1894 /* Possible Magic values */
1895 #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
1896 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
1898 /* These are indexes into the DataDirectory array */
1899 #define IMAGE_FILE_EXPORT_DIRECTORY 0
1900 #define IMAGE_FILE_IMPORT_DIRECTORY 1
1901 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
1902 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
1903 #define IMAGE_FILE_SECURITY_DIRECTORY 4
1904 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
1905 #define IMAGE_FILE_DEBUG_DIRECTORY 6
1906 #define IMAGE_FILE_DESCRIPTION_STRING 7
1907 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
1908 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
1909 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
1911 /* Directory Entries, indices into the DataDirectory array */
1913 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
1914 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
1915 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
1916 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
1917 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
1918 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
1919 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
1920 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
1921 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
1922 #define IMAGE_DIRECTORY_ENTRY_TLS 9
1923 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
1924 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
1925 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
1926 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
1927 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
1929 /* Subsystem Values */
1931 #define IMAGE_SUBSYSTEM_UNKNOWN 0
1932 #define IMAGE_SUBSYSTEM_NATIVE 1
1933 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
1934 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem*/
1935 #define IMAGE_SUBSYSTEM_OS2_CUI 5
1936 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
1938 typedef struct _IMAGE_FILE_HEADER {
1940 WORD NumberOfSections;
1941 DWORD TimeDateStamp;
1942 DWORD PointerToSymbolTable;
1943 DWORD NumberOfSymbols;
1944 WORD SizeOfOptionalHeader;
1945 WORD Characteristics;
1946 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1948 typedef struct _IMAGE_DATA_DIRECTORY {
1949 DWORD VirtualAddress;
1951 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1953 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
1955 typedef struct _IMAGE_OPTIONAL_HEADER {
1957 /* Standard fields */
1960 BYTE MajorLinkerVersion;
1961 BYTE MinorLinkerVersion;
1963 DWORD SizeOfInitializedData;
1964 DWORD SizeOfUninitializedData;
1965 DWORD AddressOfEntryPoint;
1969 /* NT additional fields */
1972 DWORD SectionAlignment;
1973 DWORD FileAlignment;
1974 WORD MajorOperatingSystemVersion;
1975 WORD MinorOperatingSystemVersion;
1976 WORD MajorImageVersion;
1977 WORD MinorImageVersion;
1978 WORD MajorSubsystemVersion;
1979 WORD MinorSubsystemVersion;
1980 DWORD Win32VersionValue;
1982 DWORD SizeOfHeaders;
1985 WORD DllCharacteristics;
1986 DWORD SizeOfStackReserve;
1987 DWORD SizeOfStackCommit;
1988 DWORD SizeOfHeapReserve;
1989 DWORD SizeOfHeapCommit;
1991 DWORD NumberOfRvaAndSizes;
1992 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
1993 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
1995 typedef struct _IMAGE_NT_HEADERS {
1997 IMAGE_FILE_HEADER FileHeader;
1998 IMAGE_OPTIONAL_HEADER OptionalHeader;
1999 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
2001 #define IMAGE_SIZEOF_SHORT_NAME 8
2003 typedef struct _IMAGE_SECTION_HEADER {
2004 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2006 DWORD PhysicalAddress;
2009 DWORD VirtualAddress;
2010 DWORD SizeOfRawData;
2011 DWORD PointerToRawData;
2012 DWORD PointerToRelocations;
2013 DWORD PointerToLinenumbers;
2014 WORD NumberOfRelocations;
2015 WORD NumberOfLinenumbers;
2016 DWORD Characteristics;
2017 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2019 #define IMAGE_SIZEOF_SECTION_HEADER 40
2021 #define IMAGE_FIRST_SECTION(ntheader) \
2022 ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2023 ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2025 /* These defines are for the Characteristics bitfield. */
2026 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2027 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2028 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2029 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2030 /* #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved */
2031 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2033 #define IMAGE_SCN_CNT_CODE 0x00000020
2034 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2035 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2037 #define IMAGE_SCN_LNK_OTHER 0x00000100
2038 #define IMAGE_SCN_LNK_INFO 0x00000200
2039 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2040 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2041 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2043 /* 0x00002000 - Reserved */
2044 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2045 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2047 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2048 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2049 #define IMAGE_SCN_MEM_16BIT 0x00020000
2050 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2051 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2053 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2054 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2055 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2056 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2057 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2058 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2059 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2060 /* 0x00800000 - Unused */
2062 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2065 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2066 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2067 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2068 #define IMAGE_SCN_MEM_SHARED 0x10000000
2069 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2070 #define IMAGE_SCN_MEM_READ 0x40000000
2071 #define IMAGE_SCN_MEM_WRITE 0x80000000
2073 #include "pshpack2.h"
2075 typedef struct _IMAGE_SYMBOL {
2085 SHORT SectionNumber;
2088 BYTE NumberOfAuxSymbols;
2090 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2092 #define IMAGE_SIZEOF_SYMBOL 18
2094 typedef struct _IMAGE_LINENUMBER {
2096 DWORD SymbolTableIndex;
2097 DWORD VirtualAddress;
2101 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2103 #define IMAGE_SIZEOF_LINENUMBER 6
2105 typedef union _IMAGE_AUX_SYMBOL {
2117 DWORD PointerToLinenumber;
2118 DWORD PointerToNextFunction;
2127 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2131 WORD NumberOfRelocations;
2132 WORD NumberOfLinenumbers;
2138 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2140 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2142 #include "poppack.h"
2144 #define IMAGE_SYM_UNDEFINED (SHORT)0
2145 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2146 #define IMAGE_SYM_DEBUG (SHORT)-2
2148 #define IMAGE_SYM_TYPE_NULL 0x0000
2149 #define IMAGE_SYM_TYPE_VOID 0x0001
2150 #define IMAGE_SYM_TYPE_CHAR 0x0002
2151 #define IMAGE_SYM_TYPE_SHORT 0x0003
2152 #define IMAGE_SYM_TYPE_INT 0x0004
2153 #define IMAGE_SYM_TYPE_LONG 0x0005
2154 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2155 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2156 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2157 #define IMAGE_SYM_TYPE_UNION 0x0009
2158 #define IMAGE_SYM_TYPE_ENUM 0x000A
2159 #define IMAGE_SYM_TYPE_MOE 0x000B
2160 #define IMAGE_SYM_TYPE_BYTE 0x000C
2161 #define IMAGE_SYM_TYPE_WORD 0x000D
2162 #define IMAGE_SYM_TYPE_UINT 0x000E
2163 #define IMAGE_SYM_TYPE_DWORD 0x000F
2164 #define IMAGE_SYM_TYPE_PCODE 0x8000
2166 #define IMAGE_SYM_DTYPE_NULL 0
2167 #define IMAGE_SYM_DTYPE_POINTER 1
2168 #define IMAGE_SYM_DTYPE_FUNCTION 2
2169 #define IMAGE_SYM_DTYPE_ARRAY 3
2171 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2172 #define IMAGE_SYM_CLASS_NULL 0x0000
2173 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2174 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2175 #define IMAGE_SYM_CLASS_STATIC 0x0003
2176 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2177 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2178 #define IMAGE_SYM_CLASS_LABEL 0x0006
2179 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2180 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2181 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2182 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2183 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2184 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2185 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2186 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2187 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2188 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2189 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2190 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2192 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2193 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2194 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2195 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2196 #define IMAGE_SYM_CLASS_FILE 0x0067
2197 #define IMAGE_SYM_CLASS_SECTION 0x0068
2198 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2200 #define N_BTMASK 0x000F
2201 #define N_TMASK 0x0030
2202 #define N_TMASK1 0x00C0
2203 #define N_TMASK2 0x00F0
2207 #define BTYPE(x) ((x) & N_BTMASK)
2210 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2214 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2218 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2222 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2226 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2229 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2232 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2233 #define IMAGE_COMDAT_SELECT_ANY 2
2234 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2235 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2236 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2237 #define IMAGE_COMDAT_SELECT_LARGEST 6
2238 #define IMAGE_COMDAT_SELECT_NEWEST 7
2240 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2241 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2242 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2244 /* Export module directory */
2246 typedef struct _IMAGE_EXPORT_DIRECTORY {
2247 DWORD Characteristics;
2248 DWORD TimeDateStamp;
2253 DWORD NumberOfFunctions;
2254 DWORD NumberOfNames;
2255 DWORD AddressOfFunctions;
2256 DWORD AddressOfNames;
2257 DWORD AddressOfNameOrdinals;
2258 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2260 /* Import name entry */
2261 typedef struct _IMAGE_IMPORT_BY_NAME {
2264 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2267 typedef struct _IMAGE_THUNK_DATA {
2269 LPBYTE ForwarderString;
2272 PIMAGE_IMPORT_BY_NAME AddressOfData;
2274 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2276 /* Import module directory */
2278 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2280 DWORD Characteristics; /* 0 for terminating null import descriptor */
2281 PIMAGE_THUNK_DATA OriginalFirstThunk; /* RVA to original unbound IAT */
2283 DWORD TimeDateStamp; /* 0 if not bound,
2284 * -1 if bound, and real date\time stamp
2285 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2287 * otherwise date/time stamp of DLL bound to
2290 DWORD ForwarderChain; /* -1 if no forwarders */
2292 /* RVA to IAT (if bound this IAT has actual addresses) */
2293 PIMAGE_THUNK_DATA FirstThunk;
2294 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2296 #define IMAGE_ORDINAL_FLAG 0x80000000
2297 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2298 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
2300 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2302 DWORD TimeDateStamp;
2303 WORD OffsetModuleName;
2304 WORD NumberOfModuleForwarderRefs;
2305 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2306 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2308 typedef struct _IMAGE_BOUND_FORWARDER_REF
2310 DWORD TimeDateStamp;
2311 WORD OffsetModuleName;
2313 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2315 typedef struct _IMAGE_BASE_RELOCATION
2317 DWORD VirtualAddress;
2320 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2322 typedef struct _IMAGE_RELOCATION
2325 DWORD VirtualAddress;
2328 DWORD SymbolTableIndex;
2331 typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
2333 #define IMAGE_SIZEOF_RELOCATION 10
2335 /* generic relocation types */
2336 #define IMAGE_REL_BASED_ABSOLUTE 0
2337 #define IMAGE_REL_BASED_HIGH 1
2338 #define IMAGE_REL_BASED_LOW 2
2339 #define IMAGE_REL_BASED_HIGHLOW 3
2340 #define IMAGE_REL_BASED_HIGHADJ 4
2341 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
2342 #define IMAGE_REL_BASED_SECTION 6
2343 #define IMAGE_REL_BASED_REL 7
2344 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
2345 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
2346 #define IMAGE_REL_BASED_DIR64 10
2347 #define IMAGE_REL_BASED_HIGH3ADJ 11
2349 /* I386 relocation types */
2350 #define IMAGE_REL_I386_ABSOLUTE 0
2351 #define IMAGE_REL_I386_DIR16 1
2352 #define IMAGE_REL_I386_REL16 2
2353 #define IMAGE_REL_I386_DIR32 6
2354 #define IMAGE_REL_I386_DIR32NB 7
2355 #define IMAGE_REL_I386_SEG12 9
2356 #define IMAGE_REL_I386_SECTION 10
2357 #define IMAGE_REL_I386_SECREL 11
2358 #define IMAGE_REL_I386_REL32 20
2360 /* MIPS relocation types */
2361 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
2362 #define IMAGE_REL_MIPS_REFHALF 0x0001
2363 #define IMAGE_REL_MIPS_REFWORD 0x0002
2364 #define IMAGE_REL_MIPS_JMPADDR 0x0003
2365 #define IMAGE_REL_MIPS_REFHI 0x0004
2366 #define IMAGE_REL_MIPS_REFLO 0x0005
2367 #define IMAGE_REL_MIPS_GPREL 0x0006
2368 #define IMAGE_REL_MIPS_LITERAL 0x0007
2369 #define IMAGE_REL_MIPS_SECTION 0x000A
2370 #define IMAGE_REL_MIPS_SECREL 0x000B
2371 #define IMAGE_REL_MIPS_SECRELLO 0x000C
2372 #define IMAGE_REL_MIPS_SECRELHI 0x000D
2373 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
2374 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
2375 #define IMAGE_REL_MIPS_PAIR 0x0025
2377 /* ALPHA relocation types */
2378 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
2379 #define IMAGE_REL_ALPHA_REFLONG 0x0001
2380 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
2381 #define IMAGE_REL_ALPHA_GPREL 0x0003
2382 #define IMAGE_REL_ALPHA_LITERAL 0x0004
2383 #define IMAGE_REL_ALPHA_LITUSE 0x0005
2384 #define IMAGE_REL_ALPHA_GPDISP 0x0006
2385 #define IMAGE_REL_ALPHA_BRADDR 0x0007
2386 #define IMAGE_REL_ALPHA_HINT 0x0008
2387 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
2388 #define IMAGE_REL_ALPHA_REFHI 0x000A
2389 #define IMAGE_REL_ALPHA_REFLO 0x000B
2390 #define IMAGE_REL_ALPHA_PAIR 0x000C
2391 #define IMAGE_REL_ALPHA_MATCH 0x000D
2392 #define IMAGE_REL_ALPHA_SECTION 0x000E
2393 #define IMAGE_REL_ALPHA_SECREL 0x000F
2394 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
2395 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
2396 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
2397 #define IMAGE_REL_ALPHA_REFQ3 0x0013
2398 #define IMAGE_REL_ALPHA_REFQ2 0x0014
2399 #define IMAGE_REL_ALPHA_REFQ1 0x0015
2400 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
2401 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
2403 /* PowerPC relocation types */
2404 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
2405 #define IMAGE_REL_PPC_ADDR64 0x0001
2406 #define IMAGE_REL_PPC_ADDR 0x0002
2407 #define IMAGE_REL_PPC_ADDR24 0x0003
2408 #define IMAGE_REL_PPC_ADDR16 0x0004
2409 #define IMAGE_REL_PPC_ADDR14 0x0005
2410 #define IMAGE_REL_PPC_REL24 0x0006
2411 #define IMAGE_REL_PPC_REL14 0x0007
2412 #define IMAGE_REL_PPC_TOCREL16 0x0008
2413 #define IMAGE_REL_PPC_TOCREL14 0x0009
2414 #define IMAGE_REL_PPC_ADDR32NB 0x000A
2415 #define IMAGE_REL_PPC_SECREL 0x000B
2416 #define IMAGE_REL_PPC_SECTION 0x000C
2417 #define IMAGE_REL_PPC_IFGLUE 0x000D
2418 #define IMAGE_REL_PPC_IMGLUE 0x000E
2419 #define IMAGE_REL_PPC_SECREL16 0x000F
2420 #define IMAGE_REL_PPC_REFHI 0x0010
2421 #define IMAGE_REL_PPC_REFLO 0x0011
2422 #define IMAGE_REL_PPC_PAIR 0x0012
2423 #define IMAGE_REL_PPC_SECRELLO 0x0013
2424 #define IMAGE_REL_PPC_SECRELHI 0x0014
2425 #define IMAGE_REL_PPC_GPREL 0x0015
2426 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
2428 #define IMAGE_REL_PPC_NEG 0x0100
2429 #define IMAGE_REL_PPC_BRTAKEN 0x0200
2430 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
2431 #define IMAGE_REL_PPC_TOCDEFN 0x0800
2433 /* SH3 ? relocation type */
2434 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
2435 #define IMAGE_REL_SH3_DIRECT16 0x0001
2436 #define IMAGE_REL_SH3_DIRECT 0x0002
2437 #define IMAGE_REL_SH3_DIRECT8 0x0003
2438 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
2439 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
2440 #define IMAGE_REL_SH3_DIRECT4 0x0006
2441 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
2442 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
2443 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
2444 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
2445 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
2446 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
2447 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
2448 #define IMAGE_REL_SH3_SECTION 0x000E
2449 #define IMAGE_REL_SH3_SECREL 0x000F
2450 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
2452 /* ARM (Archimedes?) relocation types */
2453 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
2454 #define IMAGE_REL_ARM_ADDR 0x0001
2455 #define IMAGE_REL_ARM_ADDR32NB 0x0002
2456 #define IMAGE_REL_ARM_BRANCH24 0x0003
2457 #define IMAGE_REL_ARM_BRANCH11 0x0004
2458 #define IMAGE_REL_ARM_SECTION 0x000E
2459 #define IMAGE_REL_ARM_SECREL 0x000F
2461 /* IA64 relocation types */
2462 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
2463 #define IMAGE_REL_IA64_IMM14 0x0001
2464 #define IMAGE_REL_IA64_IMM22 0x0002
2465 #define IMAGE_REL_IA64_IMM64 0x0003
2466 #define IMAGE_REL_IA64_DIR 0x0004
2467 #define IMAGE_REL_IA64_DIR64 0x0005
2468 #define IMAGE_REL_IA64_PCREL21B 0x0006
2469 #define IMAGE_REL_IA64_PCREL21M 0x0007
2470 #define IMAGE_REL_IA64_PCREL21F 0x0008
2471 #define IMAGE_REL_IA64_GPREL22 0x0009
2472 #define IMAGE_REL_IA64_LTOFF22 0x000A
2473 #define IMAGE_REL_IA64_SECTION 0x000B
2474 #define IMAGE_REL_IA64_SECREL22 0x000C
2475 #define IMAGE_REL_IA64_SECREL64I 0x000D
2476 #define IMAGE_REL_IA64_SECREL 0x000E
2477 #define IMAGE_REL_IA64_LTOFF64 0x000F
2478 #define IMAGE_REL_IA64_DIR32NB 0x0010
2479 #define IMAGE_REL_IA64_RESERVED_11 0x0011
2480 #define IMAGE_REL_IA64_RESERVED_12 0x0012
2481 #define IMAGE_REL_IA64_RESERVED_13 0x0013
2482 #define IMAGE_REL_IA64_RESERVED_14 0x0014
2483 #define IMAGE_REL_IA64_RESERVED_15 0x0015
2484 #define IMAGE_REL_IA64_RESERVED_16 0x0016
2485 #define IMAGE_REL_IA64_ADDEND 0x001F
2487 /* archive format */
2489 #define IMAGE_ARCHIVE_START_SIZE 8
2490 #define IMAGE_ARCHIVE_START "!<arch>\n"
2491 #define IMAGE_ARCHIVE_END "`\n"
2492 #define IMAGE_ARCHIVE_PAD "\n"
2493 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
2494 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
2496 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2505 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2507 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2510 * Resource directory stuff
2512 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2513 DWORD Characteristics;
2514 DWORD TimeDateStamp;
2517 WORD NumberOfNamedEntries;
2518 WORD NumberOfIdEntries;
2519 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2520 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2522 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
2523 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
2525 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2528 #ifdef BITFIELDS_BIGENDIAN
2529 unsigned NameIsString:1;
2530 unsigned NameOffset:31;
2532 unsigned NameOffset:31;
2533 unsigned NameIsString:1;
2538 #ifdef WORDS_BIGENDIAN
2550 #ifdef BITFIELDS_BIGENDIAN
2551 unsigned DataIsDirectory:1;
2552 unsigned OffsetToDirectory:31;
2554 unsigned OffsetToDirectory:31;
2555 unsigned DataIsDirectory:1;
2559 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2562 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2564 CHAR NameString[ 1 ];
2565 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2567 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2569 WCHAR NameString[ 1 ];
2570 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2572 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2576 DWORD ResourceHandle;
2577 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2580 typedef VOID CALLBACK (*PIMAGE_TLS_CALLBACK)(
2581 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2584 typedef struct _IMAGE_TLS_DIRECTORY {
2585 DWORD StartAddressOfRawData;
2586 DWORD EndAddressOfRawData;
2587 LPDWORD AddressOfIndex;
2588 PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
2589 DWORD SizeOfZeroFill;
2590 DWORD Characteristics;
2591 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
2593 typedef struct _IMAGE_DEBUG_DIRECTORY {
2594 DWORD Characteristics;
2595 DWORD TimeDateStamp;
2600 DWORD AddressOfRawData;
2601 DWORD PointerToRawData;
2602 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2604 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
2605 #define IMAGE_DEBUG_TYPE_COFF 1
2606 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
2607 #define IMAGE_DEBUG_TYPE_FPO 3
2608 #define IMAGE_DEBUG_TYPE_MISC 4
2609 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
2610 #define IMAGE_DEBUG_TYPE_FIXUP 6
2611 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
2612 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
2613 #define IMAGE_DEBUG_TYPE_BORLAND 9
2614 #define IMAGE_DEBUG_TYPE_RESERVED10 10
2616 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2617 DWORD NumberOfSymbols;
2618 DWORD LvaToFirstSymbol;
2619 DWORD NumberOfLinenumbers;
2620 DWORD LvaToFirstLinenumber;
2621 DWORD RvaToFirstByteOfCode;
2622 DWORD RvaToLastByteOfCode;
2623 DWORD RvaToFirstByteOfData;
2624 DWORD RvaToLastByteOfData;
2625 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2628 #define FRAME_TRAP 1
2630 #define FRAME_NONFPO 3
2632 typedef struct _FPO_DATA {
2637 unsigned cbProlog : 8;
2638 unsigned cbRegs : 3;
2639 unsigned fHasSEH : 1;
2640 unsigned fUseBP : 1;
2641 unsigned reserved : 1;
2642 unsigned cbFrame : 2;
2643 } FPO_DATA, *PFPO_DATA;
2645 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2646 DWORD Characteristics;
2647 DWORD TimeDateStamp;
2650 DWORD GlobalFlagsClear;
2651 DWORD GlobalFlagsSet;
2652 DWORD CriticalSectionDefaultTimeout;
2653 DWORD DeCommitFreeBlockThreshold;
2654 DWORD DeCommitTotalFreeThreshold;
2655 PVOID LockPrefixTable;
2656 DWORD MaximumAllocationSize;
2657 DWORD VirtualMemoryThreshold;
2658 DWORD ProcessHeapFlags;
2659 DWORD ProcessAffinityMask;
2664 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2666 typedef struct _IMAGE_FUNCTION_ENTRY {
2667 DWORD StartingAddress;
2668 DWORD EndingAddress;
2669 DWORD EndOfPrologue;
2670 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2672 #define IMAGE_DEBUG_MISC_EXENAME 1
2674 typedef struct _IMAGE_DEBUG_MISC {
2680 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2682 /* This is the structure that appears at the very start of a .DBG file. */
2684 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2688 WORD Characteristics;
2689 DWORD TimeDateStamp;
2693 DWORD NumberOfSections;
2694 DWORD ExportedNamesSize;
2695 DWORD DebugDirectorySize;
2696 DWORD SectionAlignment;
2697 DWORD Reserved[ 2 ];
2698 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2700 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2703 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2707 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2708 #define MESSAGE_RESOURCE_UNICODE 0x0001
2710 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2713 DWORD OffsetToEntries;
2714 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2716 typedef struct tagMESSAGE_RESOURCE_DATA {
2717 DWORD NumberOfBlocks;
2718 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
2719 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2722 * Here follows typedefs for security and tokens.
2726 * First a constant for the following typdefs.
2729 #define ANYSIZE_ARRAY 1
2731 /* FIXME: Orphan. What does it point to? */
2732 typedef PVOID PACCESS_TOKEN;
2735 * TOKEN_INFORMATION_CLASS
2738 typedef enum _TOKEN_INFORMATION_CLASS {
2747 TokenImpersonationLevel,
2749 } TOKEN_INFORMATION_CLASS;
2751 #ifndef _SECURITY_DEFINED
2752 #define _SECURITY_DEFINED
2754 #include "pshpack1.h"
2756 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2758 typedef struct _GENERIC_MAPPING {
2759 ACCESS_MASK GenericRead;
2760 ACCESS_MASK GenericWrite;
2761 ACCESS_MASK GenericExecute;
2762 ACCESS_MASK GenericAll;
2763 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2765 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2766 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2769 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
2770 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2774 typedef struct _SID {
2776 BYTE SubAuthorityCount;
2777 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2778 DWORD SubAuthority[1];
2780 #endif /* !defined(SID_DEFINED) */
2782 #define SID_REVISION (1) /* Current revision */
2783 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
2784 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
2791 #define ACL_REVISION1 1
2792 #define ACL_REVISION2 2
2793 #define ACL_REVISION3 3
2794 #define ACL_REVISION4 4
2796 #define MIN_ACL_REVISION ACL_REVISION2
2797 #define MAX_ACL_REVISION ACL_REVISION4
2799 typedef struct _ACL {
2807 /* SECURITY_DESCRIPTOR */
2808 #define SECURITY_DESCRIPTOR_REVISION 1
2809 #define SECURITY_DESCRIPTOR_REVISION1 1
2812 #define SE_OWNER_DEFAULTED 0x0001
2813 #define SE_GROUP_DEFAULTED 0x0002
2814 #define SE_DACL_PRESENT 0x0004
2815 #define SE_DACL_DEFAULTED 0x0008
2816 #define SE_SACL_PRESENT 0x0010
2817 #define SE_SACL_DEFAULTED 0x0020
2818 #define SE_SELF_RELATIVE 0x8000
2820 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2821 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
2823 /* The security descriptor structure */
2827 SECURITY_DESCRIPTOR_CONTROL Control;
2832 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
2837 SECURITY_DESCRIPTOR_CONTROL Control;
2842 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
2844 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
2846 #include "poppack.h"
2848 #endif /* _SECURITY_DEFINED */
2850 #include "pshpack1.h"
2853 * SID_AND_ATTRIBUTES
2856 typedef struct _SID_AND_ATTRIBUTES {
2859 } SID_AND_ATTRIBUTES ;
2861 /* security entities */
2862 #define SECURITY_NULL_RID (0x00000000L)
2863 #define SECURITY_WORLD_RID (0x00000000L)
2864 #define SECURITY_LOCAL_RID (0X00000000L)
2866 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
2869 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
2872 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
2875 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
2876 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
2877 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
2878 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
2879 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
2882 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
2885 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
2886 #define SECURITY_DIALUP_RID 0x00000001L
2887 #define SECURITY_NETWORK_RID 0x00000002L
2888 #define SECURITY_BATCH_RID 0x00000003L
2889 #define SECURITY_INTERACTIVE_RID 0x00000004L
2890 #define SECURITY_LOGON_IDS_RID 0x00000005L
2891 #define SECURITY_SERVICE_RID 0x00000006L
2892 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
2893 #define SECURITY_PROXY_RID 0x00000008L
2894 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
2895 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
2896 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
2897 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
2898 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
2899 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
2900 #define SECURITY_NT_NON_UNIQUE 0x00000015L
2901 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
2903 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
2904 #define DOMAIN_GROUP_RID_USERS 0x00000201L
2905 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
2907 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
2908 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
2909 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
2911 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
2913 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
2919 typedef struct _TOKEN_USER {
2920 SID_AND_ATTRIBUTES User;
2927 typedef struct _TOKEN_GROUPS {
2929 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
2933 * LUID_AND_ATTRIBUTES
2936 typedef union _LARGE_INTEGER {
2942 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
2944 typedef union _ULARGE_INTEGER {
2950 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
2953 * Locally Unique Identifier
2956 typedef LARGE_INTEGER LUID,*PLUID;
2958 typedef struct _LUID_AND_ATTRIBUTES {
2961 } LUID_AND_ATTRIBUTES;
2967 typedef struct _PRIVILEGE_SET {
2968 DWORD PrivilegeCount;
2970 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2971 } PRIVILEGE_SET, *PPRIVILEGE_SET;
2977 typedef struct _TOKEN_PRIVILEGES {
2978 DWORD PrivilegeCount;
2979 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
2980 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
2986 typedef struct _TOKEN_OWNER {
2991 * TOKEN_PRIMARY_GROUP
2994 typedef struct _TOKEN_PRIMARY_GROUP {
2996 } TOKEN_PRIMARY_GROUP;
3000 * TOKEN_DEFAULT_DACL
3003 typedef struct _TOKEN_DEFAULT_DACL {
3005 } TOKEN_DEFAULT_DACL;
3011 typedef struct _TOKEN_SOURCE {
3013 LUID SourceIdentifier;
3020 typedef enum tagTOKEN_TYPE {
3026 * SECURITY_IMPERSONATION_LEVEL
3029 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3031 SecurityIdentification,
3032 SecurityImpersonation,
3034 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
3037 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3038 * PSECURITY_CONTEXT_TRACKING_MODE;
3040 * Quality of Service
3043 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3045 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3046 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3048 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3054 typedef struct _TOKEN_STATISTICS {
3056 LUID AuthenticationId;
3057 LARGE_INTEGER ExpirationTime;
3058 TOKEN_TYPE TokenType;
3059 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3060 DWORD DynamicCharged;
3061 DWORD DynamicAvailable;
3063 DWORD PrivilegeCount;
3071 #define ACL_REVISION 2
3073 #define ACL_REVISION1 1
3074 #define ACL_REVISION2 2
3076 /* ACEs, directly starting after an ACL */
3077 typedef struct _ACE_HEADER {
3081 } ACE_HEADER,*PACE_HEADER;
3084 #define ACCESS_ALLOWED_ACE_TYPE 0
3085 #define ACCESS_DENIED_ACE_TYPE 1
3086 #define SYSTEM_AUDIT_ACE_TYPE 2
3087 #define SYSTEM_ALARM_ACE_TYPE 3
3089 /* inherit AceFlags */
3090 #define OBJECT_INHERIT_ACE 0x01
3091 #define CONTAINER_INHERIT_ACE 0x02
3092 #define NO_PROPAGATE_INHERIT_ACE 0x04
3093 #define INHERIT_ONLY_ACE 0x08
3094 #define VALID_INHERIT_FLAGS 0x0F
3096 /* AceFlags mask for what events we (should) audit */
3097 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
3098 #define FAILED_ACCESS_ACE_FLAG 0x80
3100 /* different ACEs depending on AceType
3101 * SidStart marks the begin of a SID
3102 * so the thing finally looks like this:
3107 typedef struct _ACCESS_ALLOWED_ACE {
3111 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3113 typedef struct _ACCESS_DENIED_ACE {
3117 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3119 typedef struct _SYSTEM_AUDIT_ACE {
3123 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3125 typedef struct _SYSTEM_ALARM_ACE {
3129 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3131 typedef enum tagSID_NAME_USE {
3136 SidTypeWellKnownGroup,
3137 SidTypeDeletedAccount,
3140 } SID_NAME_USE,*PSID_NAME_USE;
3144 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3146 #define DELETE 0x00010000
3147 #define READ_CONTROL 0x00020000
3148 #define WRITE_DAC 0x00040000
3149 #define WRITE_OWNER 0x00080000
3150 #define SYNCHRONIZE 0x00100000
3151 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
3153 #define STANDARD_RIGHTS_READ READ_CONTROL
3154 #define STANDARD_RIGHTS_WRITE READ_CONTROL
3155 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
3157 #define STANDARD_RIGHTS_ALL 0x001f0000
3159 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
3161 #define GENERIC_READ 0x80000000
3162 #define GENERIC_WRITE 0x40000000
3163 #define GENERIC_EXECUTE 0x20000000
3164 #define GENERIC_ALL 0x10000000
3166 #define MAXIMUM_ALLOWED 0x02000000
3167 #define ACCESS_SYSTEM_SECURITY 0x01000000
3169 #define EVENT_MODIFY_STATE 0x0002
3170 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3172 #define SEMAPHORE_MODIFY_STATE 0x0002
3173 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3175 #define MUTEX_MODIFY_STATE 0x0001
3176 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3178 #define TIMER_QUERY_STATE 0x0001
3179 #define TIMER_MODIFY_STATE 0x0002
3180 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3182 #define PROCESS_TERMINATE 0x0001
3183 #define PROCESS_CREATE_THREAD 0x0002
3184 #define PROCESS_VM_OPERATION 0x0008
3185 #define PROCESS_VM_READ 0x0010
3186 #define PROCESS_VM_WRITE 0x0020
3187 #define PROCESS_DUP_HANDLE 0x0040
3188 #define PROCESS_CREATE_PROCESS 0x0080
3189 #define PROCESS_SET_QUOTA 0x0100
3190 #define PROCESS_SET_INFORMATION 0x0200
3191 #define PROCESS_QUERY_INFORMATION 0x0400
3192 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3194 #define THREAD_TERMINATE 0x0001
3195 #define THREAD_SUSPEND_RESUME 0x0002
3196 #define THREAD_GET_CONTEXT 0x0008
3197 #define THREAD_SET_CONTEXT 0x0010
3198 #define THREAD_SET_INFORMATION 0x0020
3199 #define THREAD_QUERY_INFORMATION 0x0040
3200 #define THREAD_SET_THREAD_TOKEN 0x0080
3201 #define THREAD_IMPERSONATE 0x0100
3202 #define THREAD_DIRECT_IMPERSONATION 0x0200
3203 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3205 #define THREAD_BASE_PRIORITY_LOWRT 15
3206 #define THREAD_BASE_PRIORITY_MAX 2
3207 #define THREAD_BASE_PRIORITY_MIN -2
3208 #define THREAD_BASE_PRIORITY_IDLE -15
3210 #define FILE_READ_DATA 0x0001 /* file & pipe */
3211 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
3212 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
3213 #define FILE_ADD_FILE 0x0002 /* directory */
3214 #define FILE_APPEND_DATA 0x0004 /* file */
3215 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
3216 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
3217 #define FILE_READ_EA 0x0008 /* file & directory */
3218 #define FILE_READ_PROPERTIES FILE_READ_EA
3219 #define FILE_WRITE_EA 0x0010 /* file & directory */
3220 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
3221 #define FILE_EXECUTE 0x0020 /* file */
3222 #define FILE_TRAVERSE 0x0020 /* directory */
3223 #define FILE_DELETE_CHILD 0x0040 /* directory */
3224 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
3225 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
3226 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3228 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3229 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3231 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3232 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3233 FILE_APPEND_DATA | SYNCHRONIZE)
3234 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3235 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3238 /* File attribute flags */
3239 #define FILE_SHARE_READ 0x00000001L
3240 #define FILE_SHARE_WRITE 0x00000002L
3241 #define FILE_SHARE_DELETE 0x00000004L
3242 #define FILE_ATTRIBUTE_READONLY 0x00000001L
3243 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
3244 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
3245 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
3246 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
3247 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
3248 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
3249 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
3250 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
3251 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
3252 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
3253 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
3254 #define FILE_ATTRIBUTE_SYMLINK 0x80000000L /* Not in Windows API */
3256 /* File notification flags */
3257 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
3258 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
3259 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
3260 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
3261 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
3262 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
3263 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
3264 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
3266 #define FILE_ACTION_ADDED 0x00000001
3267 #define FILE_ACTION_REMOVED 0x00000002
3268 #define FILE_ACTION_MODIFIED 0x00000003
3269 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
3270 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
3273 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
3274 #define FILE_CASE_PRESERVED_NAMES 0x00000002
3275 #define FILE_UNICODE_ON_DISK 0x00000004
3276 #define FILE_PERSISTENT_ACLS 0x00000008
3277 #define FILE_FILE_COMPRESSION 0x00000010
3278 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
3280 /* File alignments (NT) */
3281 #define FILE_BYTE_ALIGNMENT 0x00000000
3282 #define FILE_WORD_ALIGNMENT 0x00000001
3283 #define FILE_LONG_ALIGNMENT 0x00000003
3284 #define FILE_QUAD_ALIGNMENT 0x00000007
3285 #define FILE_OCTA_ALIGNMENT 0x0000000f
3286 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
3287 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
3288 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
3289 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
3290 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
3292 #define REG_NONE 0 /* no type */
3293 #define REG_SZ 1 /* string type (ASCII) */
3294 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3295 #define REG_BINARY 3 /* binary format, callerspecific */
3296 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3297 #define REG_DWORD 4 /* DWORD in little endian format */
3298 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
3299 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
3300 #define REG_LINK 6 /* symbolic link (UNICODE) */
3301 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3302 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
3303 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
3304 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3306 /* ----------------------------- begin registry ----------------------------- */
3308 /* Registry security values */
3309 #define OWNER_SECURITY_INFORMATION 0x00000001
3310 #define GROUP_SECURITY_INFORMATION 0x00000002
3311 #define DACL_SECURITY_INFORMATION 0x00000004
3312 #define SACL_SECURITY_INFORMATION 0x00000008
3314 #define REG_OPTION_RESERVED 0x00000000
3315 #define REG_OPTION_NON_VOLATILE 0x00000000
3316 #define REG_OPTION_VOLATILE 0x00000001
3317 #define REG_OPTION_CREATE_LINK 0x00000002
3318 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
3319 #define REG_OPTION_OPEN_LINK 0x00000008
3320 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
3321 REG_OPTION_NON_VOLATILE| \
3322 REG_OPTION_VOLATILE| \
3323 REG_OPTION_CREATE_LINK| \
3324 REG_OPTION_BACKUP_RESTORE| \
3325 REG_OPTION_OPEN_LINK)
3328 #define REG_CREATED_NEW_KEY 0x00000001
3329 #define REG_OPENED_EXISTING_KEY 0x00000002
3331 /* For RegNotifyChangeKeyValue */
3332 #define REG_NOTIFY_CHANGE_NAME 0x1
3334 #define KEY_QUERY_VALUE 0x00000001
3335 #define KEY_SET_VALUE 0x00000002
3336 #define KEY_CREATE_SUB_KEY 0x00000004
3337 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
3338 #define KEY_NOTIFY 0x00000010
3339 #define KEY_CREATE_LINK 0x00000020
3341 #define KEY_READ ((STANDARD_RIGHTS_READ| \
3343 KEY_ENUMERATE_SUB_KEYS| \
3347 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
3349 KEY_CREATE_SUB_KEY) \
3352 #define KEY_EXECUTE ((KEY_READ) \
3355 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
3358 KEY_CREATE_SUB_KEY| \
3359 KEY_ENUMERATE_SUB_KEYS| \
3364 /* ------------------------------ end registry ------------------------------ */
3367 typedef struct _RTL_CRITICAL_SECTION_DEBUG
3370 WORD CreatorBackTraceIndex;
3371 struct _RTL_CRITICAL_SECTION *CriticalSection;
3372 LIST_ENTRY ProcessLocksList;
3374 DWORD ContentionCount;
3376 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
3378 typedef struct _RTL_CRITICAL_SECTION {
3379 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
3381 LONG RecursionCount;
3382 HANDLE OwningThread;
3383 HANDLE LockSemaphore;
3384 ULONG_PTR SpinCount;
3385 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
3388 #define EVENTLOG_SUCCESS 0x0000
3389 #define EVENTLOG_ERROR_TYPE 0x0001
3390 #define EVENTLOG_WARNING_TYPE 0x0002
3391 #define EVENTLOG_INFORMATION_TYPE 0x0004
3392 #define EVENTLOG_AUDIT_SUCCESS 0x0008
3393 #define EVENTLOG_AUDIT_FAILURE 0x0010
3395 #define SERVICE_BOOT_START 0x00000000
3396 #define SERVICE_SYSTEM_START 0x00000001
3397 #define SERVICE_AUTO_START 0x00000002
3398 #define SERVICE_DEMAND_START 0x00000003
3399 #define SERVICE_DISABLED 0x00000004
3401 #define SERVICE_ERROR_IGNORE 0x00000000
3402 #define SERVICE_ERROR_NORMAL 0x00000001
3403 #define SERVICE_ERROR_SEVERE 0x00000002
3404 #define SERVICE_ERROR_CRITICAL 0x00000003
3407 #define SERVICE_KERNEL_DRIVER 0x00000001
3408 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
3409 #define SERVICE_ADAPTER 0x00000004
3410 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
3412 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
3413 SERVICE_RECOGNIZER_DRIVER )
3415 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
3416 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
3417 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
3419 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
3421 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
3422 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
3425 typedef enum _CM_SERVICE_NODE_TYPE
3427 DriverType = SERVICE_KERNEL_DRIVER,
3428 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
3429 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
3430 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3431 AdapterType = SERVICE_ADAPTER,
3432 RecognizerType = SERVICE_RECOGNIZER_DRIVER
3433 } SERVICE_NODE_TYPE;
3435 typedef enum _CM_SERVICE_LOAD_TYPE
3437 BootLoad = SERVICE_BOOT_START,
3438 SystemLoad = SERVICE_SYSTEM_START,
3439 AutoLoad = SERVICE_AUTO_START,
3440 DemandLoad = SERVICE_DEMAND_START,
3441 DisableLoad = SERVICE_DISABLED
3442 } SERVICE_LOAD_TYPE;
3444 typedef enum _CM_ERROR_CONTROL_TYPE
3446 IgnoreError = SERVICE_ERROR_IGNORE,
3447 NormalError = SERVICE_ERROR_NORMAL,
3448 SevereError = SERVICE_ERROR_SEVERE,
3449 CriticalError = SERVICE_ERROR_CRITICAL
3450 } SERVICE_ERROR_TYPE;
3454 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
3455 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
3456 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
3457 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
3458 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
3460 #include "guiddef.h"
3462 #include "poppack.h"
3464 #endif /* __WINE_WINNT_H */