Fix large item label calculation when not focused.
[wine.git] / include / winnt.h
blobeacde738404379223a4d0dbef066fc3d73c8609d
1 /*
2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_WINNT_H
22 #define __WINE_WINNT_H
24 #include "basetsd.h"
26 #ifndef RC_INVOKED
27 #include <ctype.h>
28 #include <stddef.h>
29 #include <string.h>
30 #endif
33 /* On Windows winnt.h depends on a few windef.h types and macros and thus
34 * is not self-contained. Furthermore windef.h includes winnt.h so that it
35 * would be pointless to try to use winnt.h directly.
36 * But for Wine and Winelib I decided to make winnt.h self-contained by
37 * moving these definitions to winnt.h. It makes no difference to Winelib
38 * programs since they are not using winnt.h directly anyway, and it allows
39 * us to use winnt.h and get a minimal set of definitions.
42 /**** Some Wine specific definitions *****/
44 /* Calling conventions definitions */
46 #ifdef __i386__
47 # ifndef _X86_
48 # define _X86_
49 # endif
50 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
51 # define __stdcall __attribute__((__stdcall__))
52 # define __cdecl __attribute__((__cdecl__))
53 # elif defined(_MSC_VER)
54 /* Nothing needs to be done. __cdecl/__stdcall already exists */
55 # else
56 # error You need gcc >= 2.7 to build Wine on a 386
57 # endif /* __GNUC__ */
58 #else /* __i386__ */
59 # define __stdcall
60 # define __cdecl
61 #endif /* __i386__ */
63 #ifndef __WINE__
65 #ifndef pascal
66 #define pascal __stdcall
67 #endif
68 #ifndef _pascal
69 #define _pascal __stdcall
70 #endif
71 #ifndef _stdcall
72 #define _stdcall __stdcall
73 #endif
74 #ifndef _fastcall
75 #define _fastcall __stdcall
76 #endif
77 #ifndef __fastcall
78 #define __fastcall __stdcall
79 #endif
80 #ifndef __export
81 #define __export __stdcall
82 #endif
83 #ifndef cdecl
84 #define cdecl __cdecl
85 #endif
86 #ifndef _cdecl
87 #define _cdecl __cdecl
88 #endif
90 #ifndef near
91 #define near
92 #endif
93 #ifndef far
94 #define far
95 #endif
96 #ifndef _near
97 #define _near
98 #endif
99 #ifndef _far
100 #define _far
101 #endif
102 #ifndef NEAR
103 #define NEAR
104 #endif
105 #ifndef FAR
106 #define FAR
107 #endif
109 #ifndef _declspec
110 #define _declspec(x)
111 #endif
112 #ifndef __declspec
113 #define __declspec(x)
114 #endif
116 #endif /* __WINE__ */
118 #define CALLBACK __stdcall
119 #define WINAPI __stdcall
120 #define NTAPI __stdcall
121 #define APIPRIVATE __stdcall
122 #define PASCAL __stdcall
123 #define CDECL __cdecl
124 #define _CDECL __cdecl
125 #define WINAPIV __cdecl
126 #define APIENTRY WINAPI
127 #define CONST const
129 /* Macro for structure packing and more. */
131 #ifdef __GNUC__
132 #define WINE_PACKED __attribute__((packed))
133 #define WINE_UNUSED __attribute__((unused))
134 #else
135 #define WINE_PACKED /* nothing */
136 #define WINE_UNUSED /* nothing */
137 #endif
139 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64)) && !defined(MIDL_PASS)
140 # define DECLSPEC_IMPORT __declspec(dllimport)
141 #else
142 # define DECLSPEC_IMPORT
143 #endif
145 #ifndef DECLSPEC_NORETURN
146 # if (_MSVC_VER >= 1200) && !defined(MIDL_PASS)
147 # define DECLSPEC_NORETURN __declspec(noreturn)
148 # elif defined(__GNUC__)
149 # define DECLSPEC_NORETURN __attribute__((noreturn))
150 # else
151 # define DECLSPEC_NORETURN
152 # endif
153 #endif
155 #ifndef DECLSPEC_ALIGN
156 # if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
157 # define DECLSPEC_ALIGN(x) __declspec(align(x))
158 # elif defined(__GNUC__)
159 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
160 # else
161 # define DECLSPEC_ALIGN(x)
162 # endif
163 #endif
165 #ifndef DECLSPEC_CACHEALIGN
166 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
167 #endif
169 #ifndef DECLSPEC_UUID
170 # if (_MSC_VER >= 1100) && defined (__cplusplus)
171 # define DECLSPEC_UUID(x) __declspec(uuid(x))
172 # else
173 # define DECLSPEC_UUID(x)
174 # endif
175 #endif
177 #ifndef DECLSPEC_NOVTABLE
178 # if (_MSC_VER >= 1100) && defined(__cplusplus)
179 # define DECLSPEC_NOVTABLE __declspec(novtable)
180 # else
181 # define DECLSPEC_NOVTABLE
182 # endif
183 #endif
185 #ifndef DECLSPEC_SELECTANY
186 #if (_MSC_VER >= 1100)
187 #define DECLSPEC_SELECTANY __declspec(selectany)
188 #else
189 #define DECLSPEC_SELECTANY
190 #endif
191 #endif
193 #ifndef NOP_FUNCTION
194 # if (_MSC_VER >= 1210)
195 # define NOP_FUNCTION __noop
196 # else
197 # define NOP_FUNCTION (void)0
198 # endif
199 #endif
201 #ifndef DECLSPEC_ADDRSAFE
202 # if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
203 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
204 # else
205 # define DECLSPEC_ADDRSAFE
206 # endif
207 #endif
209 #ifndef FORCEINLINE
210 # if (_MSC_VER >= 1200)
211 # define FORCEINLINE __forceinline
212 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
213 # define FORCEINLINE __attribute__((always_inline))
214 # else
215 # define FORCEINLINE inline
216 # endif
217 #endif
219 #ifndef DECLSPEC_DEPRECATED
220 # if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
221 # define DECLSPEC_DEPRECATED __declspec(deprecated)
222 # define DEPRECATE_SUPPORTED
223 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
224 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
225 # define DEPRECATE_SUPPORTED
226 # else
227 # define DECLSPEC_DEPRECATED
228 # undef DEPRECATE_SUPPORTED
229 # endif
230 #endif
232 /* Anonymous union/struct handling */
234 #ifdef __WINE__
235 # define NONAMELESSSTRUCT
236 # define NONAMELESSUNION
237 #else
238 /* Anonymous struct support starts with gcc/g++ 2.96 */
239 # if !defined(NONAMELESSSTRUCT) && (defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
240 # define NONAMELESSSTRUCT
241 # endif
242 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
243 # if !defined(NONAMELESSUNION) && (defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
244 # define NONAMELESSUNION
245 # endif
246 #endif
248 #ifndef NONAMELESSSTRUCT
249 #define DUMMYSTRUCTNAME
250 #define DUMMYSTRUCTNAME1
251 #define DUMMYSTRUCTNAME2
252 #define DUMMYSTRUCTNAME3
253 #define DUMMYSTRUCTNAME4
254 #define DUMMYSTRUCTNAME5
255 #else /* !defined(NONAMELESSSTRUCT) */
256 #define DUMMYSTRUCTNAME s
257 #define DUMMYSTRUCTNAME1 s1
258 #define DUMMYSTRUCTNAME2 s2
259 #define DUMMYSTRUCTNAME3 s3
260 #define DUMMYSTRUCTNAME4 s4
261 #define DUMMYSTRUCTNAME5 s5
262 #endif /* !defined(NONAMELESSSTRUCT) */
264 #ifndef NONAMELESSUNION
265 #define DUMMYUNIONNAME
266 #define DUMMYUNIONNAME1
267 #define DUMMYUNIONNAME2
268 #define DUMMYUNIONNAME3
269 #define DUMMYUNIONNAME4
270 #define DUMMYUNIONNAME5
271 #define DUMMYUNIONNAME6
272 #define DUMMYUNIONNAME7
273 #define DUMMYUNIONNAME8
274 #else /* !defined(NONAMELESSUNION) */
275 #define DUMMYUNIONNAME u
276 #define DUMMYUNIONNAME1 u1
277 #define DUMMYUNIONNAME2 u2
278 #define DUMMYUNIONNAME3 u3
279 #define DUMMYUNIONNAME4 u4
280 #define DUMMYUNIONNAME5 u5
281 #define DUMMYUNIONNAME6 u6
282 #define DUMMYUNIONNAME7 u7
283 #define DUMMYUNIONNAME8 u8
284 #endif /* !defined(NONAMELESSUNION) */
286 /* C99 restrict support */
288 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
289 # if defined(_MSC_VER) && defined(_M_MRX000)
290 # define RESTRICTED_POINTER __restrict
291 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
292 # define RESTRICTED_POINTER __restrict
293 # else
294 # define RESTRICTED_POINTER
295 # endif
296 #else
297 # define RESTRICTED_POINTER
298 #endif
300 /* C99 unaligned support */
302 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
303 # define UNALIGNED __unaligned
304 # ifdef _WIN64
305 # define UNALIGNED64 __unaligned
306 # else
307 # define UNALIGNED64
308 # endif
309 #else
310 # define UNALIGNED
311 # define UNALIGNED64
312 #endif
314 /* Alignment macros */
316 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
317 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
318 #define MEMORY_ALLOCATION_ALIGNMENT 16
319 #else
320 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
321 #define MEMORY_ALLOCATION_ALIGNMENT 8
322 #endif
324 #if (_MSC_VER >= 1300) && defined(__cplusplus)
325 # define TYPE_ALIGNMENT(t) __alignof(t)
326 #elif defined(__GNUC__)
327 # define TYPE_ALIGNMENT(t) __alignof__(t)
328 #else
329 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
330 #endif
332 #ifdef _WIN64
333 # define PROBE_ALIGNMENT(_s) \
334 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
335 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
336 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
337 #else
338 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
339 #endif
341 /* Compile time assertion */
343 #if defined(_MSC_VER)
344 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
345 #elif defined(__GNUC__)
346 # define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1]
347 #endif
349 /**** Parts of windef.h that are needed here *****/
351 /* Misc. constants. */
353 #undef NULL
354 #ifdef __cplusplus
355 #define NULL 0
356 #else
357 #define NULL ((void*)0)
358 #endif
360 #ifdef FALSE
361 #undef FALSE
362 #endif
363 #define FALSE 0
365 #ifdef TRUE
366 #undef TRUE
367 #endif
368 #define TRUE 1
370 #ifndef IN
371 #define IN
372 #endif
374 #ifndef OUT
375 #define OUT
376 #endif
378 #ifndef OPTIONAL
379 #define OPTIONAL
380 #endif
382 /* Error Masks */
383 #define APPLICATION_ERROR_MASK 0x20000000
384 #define ERROR_SEVERITY_SUCCESS 0x00000000
385 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
386 #define ERROR_SEVERITY_WARNING 0x80000000
387 #define ERROR_SEVERITY_ERROR 0xC0000000
389 /* Standard data types */
390 typedef const void *LPCVOID;
391 typedef int BOOL, *PBOOL, *LPBOOL;
392 typedef unsigned char BYTE, *PBYTE, *LPBYTE;
393 typedef unsigned char UCHAR, *PUCHAR;
394 typedef unsigned short USHORT, *PUSHORT;
395 typedef unsigned short WORD, *PWORD, *LPWORD;
396 typedef int INT, *PINT, *LPINT;
397 typedef unsigned int UINT, *PUINT;
398 typedef unsigned long DWORD, *PDWORD, *LPDWORD;
399 typedef unsigned long ULONG, *PULONG;
400 typedef float FLOAT, *PFLOAT;
401 typedef double DOUBLE;
402 typedef double DATE;
405 /**** winnt.h proper *****/
407 /* Microsoft's macros for declaring functions */
409 #ifdef __cplusplus
410 # define EXTERN_C extern "C"
411 #else
412 # define EXTERN_C extern
413 #endif
415 #ifndef __WINE__
416 #define STDMETHODCALLTYPE __stdcall
417 #define STDMETHODVCALLTYPE __cdecl
418 #define STDAPICALLTYPE __stdcall
419 #define STDAPIVCALLTYPE __cdecl
421 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
422 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
423 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
424 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
425 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
426 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
427 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
428 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
429 #endif
431 /* Define the basic types */
432 #ifndef VOID
433 #define VOID void
434 #endif
435 typedef VOID *PVOID, *LPVOID;
436 typedef BYTE BOOLEAN, *PBOOLEAN;
437 typedef char CHAR, *PCHAR;
438 typedef short SHORT, *PSHORT;
439 typedef long LONG, *PLONG, *LPLONG;
441 /* Some systems might have wchar_t, but we really need 16 bit characters */
442 #ifndef WINE_WCHAR_DEFINED
443 #ifdef WINE_UNICODE_NATIVE
444 typedef wchar_t WCHAR, *PWCHAR;
445 #else
446 typedef unsigned short WCHAR, *PWCHAR;
447 #endif
448 #define WINE_WCHAR_DEFINED
449 #endif
451 /* 'Extended/Wide' numerical types */
452 #ifndef _ULONGLONG_
453 #define _ULONGLONG_
454 typedef signed __int64 LONGLONG, *PLONGLONG;
455 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
456 #endif
458 #ifndef _DWORDLONG_
459 #define _DWORDLONG_
460 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
461 #endif
463 /* ANSI string types */
464 typedef CHAR *PCH, *LPCH;
465 typedef const CHAR *PCCH, *LPCCH;
466 typedef CHAR *PSTR, *LPSTR;
467 typedef const CHAR *PCSTR, *LPCSTR;
469 /* Unicode string types */
470 typedef WCHAR *PWCH, *LPWCH;
471 typedef const WCHAR *PCWCH, *LPCWCH;
472 typedef WCHAR *PWSTR, *LPWSTR;
473 typedef const WCHAR *PCWSTR, *LPCWSTR;
475 /* Neutral character and string types */
476 /* These are only defined for Winelib, i.e. _not_ defined for
477 * the emulator. The reason is they depend on the UNICODE
478 * macro which only exists in the user's code.
480 #ifndef __WINE__
481 # ifdef WINE_UNICODE_REWRITE
483 /* Use this if your compiler does not provide a 16bit wchar_t type.
484 * Note that you will need to specify -fwritable-strings or an option
485 * to this effect.
486 * In C++ both WINE_UNICODE_TEXT('c') and WINE_UNICODE_TEXT("str") are
487 * supported, but only the string form can be supported in C.
489 EXTERN_C unsigned short* wine_rewrite_s4tos2(const wchar_t* str4);
490 # ifdef __cplusplus
491 inline WCHAR* wine_unicode_text(const wchar_t* str4)
493 return (WCHAR*)wine_rewrite_s4tos2(str4);
495 inline WCHAR wine_unicode_text(wchar_t chr4)
497 return (WCHAR)chr4;
499 # define WINE_UNICODE_TEXT(x) wine_unicode_text(L##x)
500 # else /* __cplusplus */
501 # define WINE_UNICODE_TEXT(x) ((WCHAR*)wine_rewrite_s4tos2(L##x))
502 # endif /* __cplusplus */
504 # else /* WINE_UNICODE_REWRITE */
506 /* Define WINE_UNICODE_NATIVE if:
507 * - your compiler provides a 16bit wchar_t type, e.g. gcc >= 2.96 with
508 * -fshort-wchar option
509 * - or if you decide to use the native 32bit Unix wchar_t type. Be aware
510 * though that the Wine APIs only support 16bit WCHAR characters for
511 * binary compatibility reasons.
512 * - or define nothing at all if you don't use Unicode, and blissfully
513 * ignore the issue :-)
515 # define WINE_UNICODE_TEXT(string) L##string
517 # endif /* WINE_UNICODE_REWRITE */
519 # ifdef UNICODE
520 typedef WCHAR TCHAR, *PTCHAR;
521 typedef LPWSTR PTSTR, LPTSTR;
522 typedef LPCWSTR PCTSTR, LPCTSTR;
523 # define __TEXT(string) WINE_UNICODE_TEXT(string)
524 # else /* UNICODE */
525 typedef CHAR TCHAR, *PTCHAR;
526 typedef LPSTR PTSTR, LPTSTR;
527 typedef LPCSTR PCTSTR, LPCTSTR;
528 # define __TEXT(string) string
529 # endif /* UNICODE */
530 # define TEXT(quote) __TEXT(quote)
531 #endif /* __WINE__ */
533 /* Misc common WIN32 types */
534 typedef char CCHAR;
535 typedef LONG HRESULT;
536 typedef DWORD LCID, *PLCID;
537 typedef WORD LANGID;
538 typedef DWORD EXECUTION_STATE;
540 /* Handle type */
542 /* FIXME: Wine does not compile with strict on, therefore strict
543 * handles are presently only usable on machines where sizeof(UINT) ==
544 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
545 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
546 * they exist as UINTs but to the Winelib user who turns on strict,
547 * they exist as void*. If there is a size difference between UINT and
548 * void* then things get ugly.
550 * Here is the plan to convert Wine to STRICT:
552 * Types will be converted one at a time by volunteers who will compile
553 * Wine with STRICT turned on. Handles that have not been converted yet
554 * will be declared with DECLARE_OLD_HANDLE. Converted handles are
555 * declared with DECLARE_HANDLE.
556 * See the bug report 90 for more details:
557 * http://wine.codeweavers.com/bugzilla/show_bug.cgi?id=90
560 * when compiling Wine we always treat HANDLE as an UINT. Then when
561 * we're ready we'll remove the '!defined(__WINE__)' (the equivalent
562 * of converting it from DECLARE_OLD_HANDLE to DECLARE_HANDLE).
564 #if defined(STRICT) && !defined(__WINE__)
565 typedef VOID* HANDLE;
566 #define DECLARE_OLD_HANDLE(a) \
567 typedef struct a##__ { int unused; } *a; \
568 typedef a *P##a
569 #else
570 typedef UINT HANDLE;
571 #define DECLARE_OLD_HANDLE(a) \
572 typedef HANDLE a; \
573 typedef a *P##a
574 #endif
575 typedef HANDLE *PHANDLE, *LPHANDLE;
577 #ifdef STRICT
578 #define DECLARE_HANDLE(a) \
579 typedef struct a##__ { int unused; } *a; \
580 typedef a *P##a
581 #else /*STRICT*/
582 #define DECLARE_HANDLE(a) \
583 typedef HANDLE a; \
584 typedef a *P##a
585 #endif /*STRICT*/
587 /* Defines */
589 /* Argument 1 passed to the DllEntryProc. */
590 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
591 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
592 #define DLL_THREAD_ATTACH 2 /* attach new thread */
593 #define DLL_THREAD_DETACH 3 /* detach thread */
596 /* u.x.wProcessorArchitecture (NT) */
597 #define PROCESSOR_ARCHITECTURE_INTEL 0
598 #define PROCESSOR_ARCHITECTURE_MIPS 1
599 #define PROCESSOR_ARCHITECTURE_ALPHA 2
600 #define PROCESSOR_ARCHITECTURE_PPC 3
601 #define PROCESSOR_ARCHITECTURE_SHX 4
602 #define PROCESSOR_ARCHITECTURE_ARM 5
603 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
605 /* dwProcessorType */
606 #define PROCESSOR_INTEL_386 386
607 #define PROCESSOR_INTEL_486 486
608 #define PROCESSOR_INTEL_PENTIUM 586
609 #define PROCESSOR_INTEL_860 860
610 #define PROCESSOR_MIPS_R2000 2000
611 #define PROCESSOR_MIPS_R3000 3000
612 #define PROCESSOR_MIPS_R4000 4000
613 #define PROCESSOR_ALPHA_21064 21064
614 #define PROCESSOR_PPC_601 601
615 #define PROCESSOR_PPC_603 603
616 #define PROCESSOR_PPC_604 604
617 #define PROCESSOR_PPC_620 620
618 #define PROCESSOR_HITACHI_SH3 10003
619 #define PROCESSOR_HITACHI_SH3E 10004
620 #define PROCESSOR_HITACHI_SH4 10005
621 #define PROCESSOR_MOTOROLA_821 821
622 #define PROCESSOR_SHx_SH3 103
623 #define PROCESSOR_SHx_SH4 104
624 #define PROCESSOR_STRONGARM 2577
625 #define PROCESSOR_ARM720 1824 /* 0x720 */
626 #define PROCESSOR_ARM820 2080 /* 0x820 */
627 #define PROCESSOR_ARM920 2336 /* 0x920 */
628 #define PROCESSOR_ARM_7TDMI 70001
630 #define MAXIMUM_PROCESSORS 32
631 typedef struct _MEMORY_BASIC_INFORMATION
633 LPVOID BaseAddress;
634 LPVOID AllocationBase;
635 DWORD AllocationProtect;
636 DWORD RegionSize;
637 DWORD State;
638 DWORD Protect;
639 DWORD Type;
640 } MEMORY_BASIC_INFORMATION,*LPMEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
642 #define PAGE_NOACCESS 0x01
643 #define PAGE_READONLY 0x02
644 #define PAGE_READWRITE 0x04
645 #define PAGE_WRITECOPY 0x08
646 #define PAGE_EXECUTE 0x10
647 #define PAGE_EXECUTE_READ 0x20
648 #define PAGE_EXECUTE_READWRITE 0x40
649 #define PAGE_EXECUTE_WRITECOPY 0x80
650 #define PAGE_GUARD 0x100
651 #define PAGE_NOCACHE 0x200
653 #define MEM_COMMIT 0x00001000
654 #define MEM_RESERVE 0x00002000
655 #define MEM_DECOMMIT 0x00004000
656 #define MEM_RELEASE 0x00008000
657 #define MEM_FREE 0x00010000
658 #define MEM_PRIVATE 0x00020000
659 #define MEM_MAPPED 0x00040000
660 #define MEM_RESET 0x00080000
661 #define MEM_TOP_DOWN 0x00100000
662 #ifdef __WINE__
663 #define MEM_SYSTEM 0x80000000
664 #endif
666 #define SEC_FILE 0x00800000
667 #define SEC_IMAGE 0x01000000
668 #define SEC_RESERVE 0x04000000
669 #define SEC_COMMIT 0x08000000
670 #define SEC_NOCACHE 0x10000000
671 #define MEM_IMAGE SEC_IMAGE
674 #define MINCHAR 0x80
675 #define MAXCHAR 0x7f
676 #define MINSHORT 0x8000
677 #define MAXSHORT 0x7fff
678 #define MINLONG 0x80000000
679 #define MAXLONG 0x7fffffff
680 #define MAXBYTE 0xff
681 #define MAXWORD 0xffff
682 #define MAXDWORD 0xffffffff
684 #define FIELD_OFFSET(type, field) \
685 ((LONG)(INT)&(((type *)0)->field))
687 #define CONTAINING_RECORD(address, type, field) \
688 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
690 /* Types */
692 typedef struct _LIST_ENTRY {
693 struct _LIST_ENTRY *Flink;
694 struct _LIST_ENTRY *Blink;
695 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
697 typedef struct _SINGLE_LIST_ENTRY {
698 struct _SINGLE_LIST_ENTRY *Next;
699 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
701 /* Heap flags */
703 #define HEAP_NO_SERIALIZE 0x00000001
704 #define HEAP_GROWABLE 0x00000002
705 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
706 #define HEAP_ZERO_MEMORY 0x00000008
707 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
708 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
709 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
710 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
711 #define HEAP_CREATE_ALIGN_16 0x00010000
712 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
714 /* This flag allows it to create heaps shared by all processes under win95,
715 FIXME: correct name */
716 #define HEAP_SHARED 0x04000000
718 /* Processor feature flags. */
719 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
720 #define PF_FLOATING_POINT_EMULATED 1
721 #define PF_COMPARE_EXCHANGE_DOUBLE 2
722 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
723 #define PF_PPC_MOVEMEM_64BIT_OK 4
724 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
725 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
726 #define PF_AMD3D_INSTRUCTIONS_AVAILABLE 7
727 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
730 /* Execution state flags */
731 #define ES_SYSTEM_REQUIRED 0x00000001
732 #define ES_DISPLAY_REQUIRED 0x00000002
733 #define ES_USER_PRESENT 0x00000004
734 #define ES_CONTINUOUS 0x80000000
736 /* The Win32 register context */
738 /* CONTEXT is the CPU-dependent context; it should be used */
739 /* wherever a platform-specific context is needed (e.g. exception */
740 /* handling, Win32 register functions). */
742 /* CONTEXT86 is the i386-specific context; it should be used */
743 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
744 /* Win16 register functions), so that this code can be compiled */
745 /* on all platforms. */
747 #define SIZE_OF_80387_REGISTERS 80
749 typedef struct _FLOATING_SAVE_AREA
751 DWORD ControlWord;
752 DWORD StatusWord;
753 DWORD TagWord;
754 DWORD ErrorOffset;
755 DWORD ErrorSelector;
756 DWORD DataOffset;
757 DWORD DataSelector;
758 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
759 DWORD Cr0NpxState;
760 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
762 #define MAXIMUM_SUPPORTED_EXTENSION 512
764 typedef struct _CONTEXT86
766 DWORD ContextFlags;
768 /* These are selected by CONTEXT_DEBUG_REGISTERS */
769 DWORD Dr0;
770 DWORD Dr1;
771 DWORD Dr2;
772 DWORD Dr3;
773 DWORD Dr6;
774 DWORD Dr7;
776 /* These are selected by CONTEXT_FLOATING_POINT */
777 FLOATING_SAVE_AREA FloatSave;
779 /* These are selected by CONTEXT_SEGMENTS */
780 DWORD SegGs;
781 DWORD SegFs;
782 DWORD SegEs;
783 DWORD SegDs;
785 /* These are selected by CONTEXT_INTEGER */
786 DWORD Edi;
787 DWORD Esi;
788 DWORD Ebx;
789 DWORD Edx;
790 DWORD Ecx;
791 DWORD Eax;
793 /* These are selected by CONTEXT_CONTROL */
794 DWORD Ebp;
795 DWORD Eip;
796 DWORD SegCs;
797 DWORD EFlags;
798 DWORD Esp;
799 DWORD SegSs;
801 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
802 } CONTEXT86;
804 #define CONTEXT_X86 0x00010000
805 #define CONTEXT_i386 CONTEXT_X86
806 #define CONTEXT_i486 CONTEXT_X86
808 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
809 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
810 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
811 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
812 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
813 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
815 /* i386 context definitions */
816 #ifdef __i386__
818 #define CONTEXT_CONTROL CONTEXT86_CONTROL
819 #define CONTEXT_INTEGER CONTEXT86_INTEGER
820 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
821 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
822 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
823 #define CONTEXT_FULL CONTEXT86_FULL
825 typedef CONTEXT86 CONTEXT;
827 #endif /* __i386__ */
829 /* Alpha context definitions */
830 #ifdef _ALPHA_
832 #define CONTEXT_ALPHA 0x00020000
834 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
835 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
836 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
837 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
839 typedef struct _CONTEXT
841 /* selected by CONTEXT_FLOATING_POINT */
842 ULONGLONG FltF0;
843 ULONGLONG FltF1;
844 ULONGLONG FltF2;
845 ULONGLONG FltF3;
846 ULONGLONG FltF4;
847 ULONGLONG FltF5;
848 ULONGLONG FltF6;
849 ULONGLONG FltF7;
850 ULONGLONG FltF8;
851 ULONGLONG FltF9;
852 ULONGLONG FltF10;
853 ULONGLONG FltF11;
854 ULONGLONG FltF12;
855 ULONGLONG FltF13;
856 ULONGLONG FltF14;
857 ULONGLONG FltF15;
858 ULONGLONG FltF16;
859 ULONGLONG FltF17;
860 ULONGLONG FltF18;
861 ULONGLONG FltF19;
862 ULONGLONG FltF20;
863 ULONGLONG FltF21;
864 ULONGLONG FltF22;
865 ULONGLONG FltF23;
866 ULONGLONG FltF24;
867 ULONGLONG FltF25;
868 ULONGLONG FltF26;
869 ULONGLONG FltF27;
870 ULONGLONG FltF28;
871 ULONGLONG FltF29;
872 ULONGLONG FltF30;
873 ULONGLONG FltF31;
875 /* selected by CONTEXT_INTEGER */
876 ULONGLONG IntV0;
877 ULONGLONG IntT0;
878 ULONGLONG IntT1;
879 ULONGLONG IntT2;
880 ULONGLONG IntT3;
881 ULONGLONG IntT4;
882 ULONGLONG IntT5;
883 ULONGLONG IntT6;
884 ULONGLONG IntT7;
885 ULONGLONG IntS0;
886 ULONGLONG IntS1;
887 ULONGLONG IntS2;
888 ULONGLONG IntS3;
889 ULONGLONG IntS4;
890 ULONGLONG IntS5;
891 ULONGLONG IntFp;
892 ULONGLONG IntA0;
893 ULONGLONG IntA1;
894 ULONGLONG IntA2;
895 ULONGLONG IntA3;
896 ULONGLONG IntA4;
897 ULONGLONG IntA5;
898 ULONGLONG IntT8;
899 ULONGLONG IntT9;
900 ULONGLONG IntT10;
901 ULONGLONG IntT11;
902 ULONGLONG IntRa;
903 ULONGLONG IntT12;
904 ULONGLONG IntAt;
905 ULONGLONG IntGp;
906 ULONGLONG IntSp;
907 ULONGLONG IntZero;
909 /* selected by CONTEXT_FLOATING_POINT */
910 ULONGLONG Fpcr;
911 ULONGLONG SoftFpcr;
913 /* selected by CONTEXT_CONTROL */
914 ULONGLONG Fir;
915 DWORD Psr;
916 DWORD ContextFlags;
917 DWORD Fill[4];
918 } CONTEXT;
920 #define _QUAD_PSR_OFFSET HighSoftFpcr
921 #define _QUAD_FLAGS_OFFSET HighFir
923 #endif /* _ALPHA_ */
925 /* Mips context definitions */
926 #ifdef _MIPS_
928 #define CONTEXT_R4000 0x00010000
930 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
931 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
932 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
934 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
936 typedef struct _CONTEXT
938 DWORD Argument[4];
939 /* These are selected by CONTEXT_FLOATING_POINT */
940 DWORD FltF0;
941 DWORD FltF1;
942 DWORD FltF2;
943 DWORD FltF3;
944 DWORD FltF4;
945 DWORD FltF5;
946 DWORD FltF6;
947 DWORD FltF7;
948 DWORD FltF8;
949 DWORD FltF9;
950 DWORD FltF10;
951 DWORD FltF11;
952 DWORD FltF12;
953 DWORD FltF13;
954 DWORD FltF14;
955 DWORD FltF15;
956 DWORD FltF16;
957 DWORD FltF17;
958 DWORD FltF18;
959 DWORD FltF19;
960 DWORD FltF20;
961 DWORD FltF21;
962 DWORD FltF22;
963 DWORD FltF23;
964 DWORD FltF24;
965 DWORD FltF25;
966 DWORD FltF26;
967 DWORD FltF27;
968 DWORD FltF28;
969 DWORD FltF29;
970 DWORD FltF30;
971 DWORD FltF31;
973 /* These are selected by CONTEXT_INTEGER */
974 DWORD IntZero;
975 DWORD IntAt;
976 DWORD IntV0;
977 DWORD IntV1;
978 DWORD IntA0;
979 DWORD IntA1;
980 DWORD IntA2;
981 DWORD IntA3;
982 DWORD IntT0;
983 DWORD IntT1;
984 DWORD IntT2;
985 DWORD IntT3;
986 DWORD IntT4;
987 DWORD IntT5;
988 DWORD IntT6;
989 DWORD IntT7;
990 DWORD IntS0;
991 DWORD IntS1;
992 DWORD IntS2;
993 DWORD IntS3;
994 DWORD IntS4;
995 DWORD IntS5;
996 DWORD IntS6;
997 DWORD IntS7;
998 DWORD IntT8;
999 DWORD IntT9;
1000 DWORD IntK0;
1001 DWORD IntK1;
1002 DWORD IntGp;
1003 DWORD IntSp;
1004 DWORD IntS8;
1005 DWORD IntRa;
1006 DWORD IntLo;
1007 DWORD IntHi;
1009 /* These are selected by CONTEXT_FLOATING_POINT */
1010 DWORD Fsr;
1012 /* These are selected by CONTEXT_CONTROL */
1013 DWORD Fir;
1014 DWORD Psr;
1016 DWORD ContextFlags;
1017 DWORD Fill[2];
1018 } CONTEXT;
1020 #endif /* _MIPS_ */
1022 /* PowerPC context definitions */
1023 #ifdef __PPC__
1025 #define CONTEXT_CONTROL 0x0001
1026 #define CONTEXT_FLOATING_POINT 0x0002
1027 #define CONTEXT_INTEGER 0x0004
1028 #define CONTEXT_DEBUG_REGISTERS 0x0008
1029 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1031 typedef struct
1033 /* These are selected by CONTEXT_FLOATING_POINT */
1034 double Fpr0;
1035 double Fpr1;
1036 double Fpr2;
1037 double Fpr3;
1038 double Fpr4;
1039 double Fpr5;
1040 double Fpr6;
1041 double Fpr7;
1042 double Fpr8;
1043 double Fpr9;
1044 double Fpr10;
1045 double Fpr11;
1046 double Fpr12;
1047 double Fpr13;
1048 double Fpr14;
1049 double Fpr15;
1050 double Fpr16;
1051 double Fpr17;
1052 double Fpr18;
1053 double Fpr19;
1054 double Fpr20;
1055 double Fpr21;
1056 double Fpr22;
1057 double Fpr23;
1058 double Fpr24;
1059 double Fpr25;
1060 double Fpr26;
1061 double Fpr27;
1062 double Fpr28;
1063 double Fpr29;
1064 double Fpr30;
1065 double Fpr31;
1066 double Fpscr;
1068 /* These are selected by CONTEXT_INTEGER */
1069 DWORD Gpr0;
1070 DWORD Gpr1;
1071 DWORD Gpr2;
1072 DWORD Gpr3;
1073 DWORD Gpr4;
1074 DWORD Gpr5;
1075 DWORD Gpr6;
1076 DWORD Gpr7;
1077 DWORD Gpr8;
1078 DWORD Gpr9;
1079 DWORD Gpr10;
1080 DWORD Gpr11;
1081 DWORD Gpr12;
1082 DWORD Gpr13;
1083 DWORD Gpr14;
1084 DWORD Gpr15;
1085 DWORD Gpr16;
1086 DWORD Gpr17;
1087 DWORD Gpr18;
1088 DWORD Gpr19;
1089 DWORD Gpr20;
1090 DWORD Gpr21;
1091 DWORD Gpr22;
1092 DWORD Gpr23;
1093 DWORD Gpr24;
1094 DWORD Gpr25;
1095 DWORD Gpr26;
1096 DWORD Gpr27;
1097 DWORD Gpr28;
1098 DWORD Gpr29;
1099 DWORD Gpr30;
1100 DWORD Gpr31;
1102 DWORD Cr;
1103 DWORD Xer;
1105 /* These are selected by CONTEXT_CONTROL */
1106 DWORD Msr;
1107 DWORD Iar; /* Instruction Address Register , aka PC ... */
1108 DWORD Lr;
1109 DWORD Ctr;
1111 DWORD ContextFlags;
1112 DWORD Fill[3];
1114 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1115 DWORD Dr0;
1116 DWORD Dr1;
1117 DWORD Dr2;
1118 DWORD Dr3;
1119 DWORD Dr4;
1120 DWORD Dr5;
1121 DWORD Dr6;
1122 DWORD Dr7;
1123 } CONTEXT;
1125 typedef struct _STACK_FRAME_HEADER
1127 DWORD BackChain;
1128 DWORD GlueSaved1;
1129 DWORD GlueSaved2;
1130 DWORD Reserved1;
1131 DWORD Spare1;
1132 DWORD Spare2;
1134 DWORD Parameter0;
1135 DWORD Parameter1;
1136 DWORD Parameter2;
1137 DWORD Parameter3;
1138 DWORD Parameter4;
1139 DWORD Parameter5;
1140 DWORD Parameter6;
1141 DWORD Parameter7;
1142 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
1144 #endif /* __PPC__ */
1146 #ifdef __sparc__
1149 * FIXME:
1151 * There is no official CONTEXT structure defined for the SPARC
1152 * architecture, so I just made one up.
1154 * This structure is valid only for 32-bit SPARC architectures,
1155 * not for 64-bit SPARC.
1157 * Note that this structure contains only the 'top-level' registers;
1158 * the rest of the register window chain is not visible.
1160 * The layout follows the Solaris 'prgregset_t' structure.
1164 #define CONTEXT_SPARC 0x10000000
1166 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
1167 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
1168 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
1170 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1172 typedef struct _CONTEXT
1174 DWORD ContextFlags;
1176 /* These are selected by CONTEXT_INTEGER */
1177 DWORD g0;
1178 DWORD g1;
1179 DWORD g2;
1180 DWORD g3;
1181 DWORD g4;
1182 DWORD g5;
1183 DWORD g6;
1184 DWORD g7;
1185 DWORD o0;
1186 DWORD o1;
1187 DWORD o2;
1188 DWORD o3;
1189 DWORD o4;
1190 DWORD o5;
1191 DWORD o6;
1192 DWORD o7;
1193 DWORD l0;
1194 DWORD l1;
1195 DWORD l2;
1196 DWORD l3;
1197 DWORD l4;
1198 DWORD l5;
1199 DWORD l6;
1200 DWORD l7;
1201 DWORD i0;
1202 DWORD i1;
1203 DWORD i2;
1204 DWORD i3;
1205 DWORD i4;
1206 DWORD i5;
1207 DWORD i6;
1208 DWORD i7;
1210 /* These are selected by CONTEXT_CONTROL */
1211 DWORD psr;
1212 DWORD pc;
1213 DWORD npc;
1214 DWORD y;
1215 DWORD wim;
1216 DWORD tbr;
1218 /* FIXME: floating point registers missing */
1220 } CONTEXT;
1222 #endif /* __sparc__ */
1224 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1225 #error You need to define a CONTEXT for your CPU
1226 #endif
1228 typedef CONTEXT *PCONTEXT;
1230 #ifdef __WINE__
1232 /* Macros to retrieve the current context */
1234 #ifdef __i386__
1236 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
1237 __ASM_GLOBAL_FUNC( name, \
1238 "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
1239 ".long " __ASM_NAME(#fn) "\n\t" \
1240 ".byte " #args ", " #args )
1241 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1242 extern void WINAPI name(void); \
1243 _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
1244 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1245 extern void WINAPI name( t1 a1 ); \
1246 _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
1247 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1248 extern void WINAPI name( t1 a1, t2 a2 ); \
1249 _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
1250 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1251 extern void WINAPI name( t1 a1, t2 a2, t3 a3 ); \
1252 _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
1253 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1254 extern void WINAPI name( t1 a1, t2 a2, t3 a3, t4 a4 ); \
1255 _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
1257 #endif /* __i386__ */
1259 #ifdef __sparc__
1261 #ifdef __SUNPRO_C
1262 static DWORD __builtin_return_address(int p_iDepth)
1264 asm("ta 3");
1265 asm("tst %i0");
1266 asm("be End");
1267 asm("mov %fp, %l0");
1268 asm("Start:");
1269 asm("sub %i0, 1, %i0");
1270 asm("tst %i0");
1271 asm("bne Start");
1272 asm("ld [%l0+56], %l0");
1273 asm("End:");
1274 asm("ld [%l0+60], %i0");
1276 #endif
1278 /* FIXME: use getcontext() to retrieve full context */
1279 #define _GET_CONTEXT \
1280 CONTEXT context; \
1281 do { memset(&context, 0, sizeof(CONTEXT)); \
1282 context.ContextFlags = CONTEXT_CONTROL; \
1283 context.pc = (DWORD)__builtin_return_address(0); \
1284 } while (0)
1286 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1287 void WINAPI name ( void ) \
1288 { _GET_CONTEXT; fn( &context ); }
1289 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1290 void WINAPI name ( t1 a1 ) \
1291 { _GET_CONTEXT; fn( a1, &context ); }
1292 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1293 void WINAPI name ( t1 a1, t2 a2 ) \
1294 { _GET_CONTEXT; fn( a1, a2, &context ); }
1295 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1296 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1297 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1298 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1299 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1300 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1302 #endif /* __sparc__ */
1304 #ifdef __PPC__
1306 /* FIXME: use getcontext() to retrieve full context */
1307 #define _GET_CONTEXT \
1308 CONTEXT context; \
1309 do { memset(&context, 0, sizeof(CONTEXT)); \
1310 context.ContextFlags = CONTEXT_CONTROL; \
1311 } while (0)
1313 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1314 void WINAPI name ( void ) \
1315 { _GET_CONTEXT; fn( &context ); }
1316 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1317 void WINAPI name ( t1 a1 ) \
1318 { _GET_CONTEXT; fn( a1, &context ); }
1319 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1320 void WINAPI name ( t1 a1, t2 a2 ) \
1321 { _GET_CONTEXT; fn( a1, a2, &context ); }
1322 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1323 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1324 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1325 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1326 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1327 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1329 #endif /* __PPC__ */
1332 #ifndef DEFINE_REGS_ENTRYPOINT_0
1333 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
1334 #endif
1336 #endif /* __WINE__ */
1341 * Language IDs
1344 #define MAKELCID(l, s) (MAKELONG(l, s))
1346 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1347 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1348 #define SUBLANGID(l) ((WORD)(l) >> 10)
1350 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1351 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1353 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1354 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1355 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1356 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1357 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1359 #define UNREFERENCED_PARAMETER(u) (u)
1360 #define DBG_UNREFERENCED_PARAMETER(u) (u)
1361 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (u)
1363 /* FIXME: are the symbolic names correct for LIDs: 0x17, 0x28,
1364 * 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x3a, 0x3b, 0x3c
1366 #define LANG_NEUTRAL 0x00
1367 #define LANG_INVARIANT 0x7f
1369 #define LANG_AFRIKAANS 0x36
1370 #define LANG_ALBANIAN 0x1c
1371 #define LANG_ARABIC 0x01
1372 #define LANG_ARMENIAN 0x2b
1373 #define LANG_ASSAMESE 0x4d
1374 #define LANG_AZERI 0x2c
1375 #define LANG_BASQUE 0x2d
1376 #define LANG_BELARUSIAN 0x23
1377 #define LANG_BENGALI 0x45
1378 #define LANG_BULGARIAN 0x02
1379 #define LANG_CATALAN 0x03
1380 #define LANG_CHINESE 0x04
1381 #define LANG_CROATIAN 0x1a
1382 #define LANG_CZECH 0x05
1383 #define LANG_DANISH 0x06
1384 #define LANG_DIVEHI 0x65
1385 #define LANG_DUTCH 0x13
1386 #define LANG_ENGLISH 0x09
1387 #define LANG_ESTONIAN 0x25
1388 #define LANG_FAEROESE 0x38
1389 #define LANG_FARSI 0x29
1390 #define LANG_FINNISH 0x0b
1391 #define LANG_FRENCH 0x0c
1392 #define LANG_GALICIAN 0x56
1393 #define LANG_GEORGIAN 0x37
1394 #define LANG_GERMAN 0x07
1395 #define LANG_GREEK 0x08
1396 #define LANG_GUJARATI 0x47
1397 #define LANG_HEBREW 0x0d
1398 #define LANG_HINDI 0x39
1399 #define LANG_HUNGARIAN 0x0e
1400 #define LANG_ICELANDIC 0x0f
1401 #define LANG_INDONESIAN 0x21
1402 #define LANG_ITALIAN 0x10
1403 #define LANG_JAPANESE 0x11
1404 #define LANG_KANNADA 0x4b
1405 #define LANG_KASHMIRI 0x60
1406 #define LANG_KAZAK 0x3f
1407 #define LANG_KONKANI 0x57
1408 #define LANG_KOREAN 0x12
1409 #define LANG_KYRGYZ 0x40
1410 #define LANG_LATVIAN 0x26
1411 #define LANG_LITHUANIAN 0x27
1412 #define LANG_MACEDONIAN 0x2f
1413 #define LANG_MALAY 0x3e
1414 #define LANG_MALAYALAM 0x4c
1415 #define LANG_MANIPURI 0x58
1416 #define LANG_MARATHI 0x4e
1417 #define LANG_MONGOLIAN 0x50
1418 #define LANG_NEPALI 0x61
1419 #define LANG_NORWEGIAN 0x14
1420 #define LANG_ORIYA 0x48
1421 #define LANG_POLISH 0x15
1422 #define LANG_PORTUGUESE 0x16
1423 #define LANG_PUNJABI 0x46
1424 #define LANG_ROMANIAN 0x18
1425 #define LANG_RUSSIAN 0x19
1426 #define LANG_SANSKRIT 0x4f
1427 #define LANG_SERBIAN 0x1a
1428 #define LANG_SINDHI 0x59
1429 #define LANG_SLOVAK 0x1b
1430 #define LANG_SLOVENIAN 0x24
1431 #define LANG_SPANISH 0x0a
1432 #define LANG_SWAHILI 0x41
1433 #define LANG_SWEDISH 0x1d
1434 #define LANG_SYRIAC 0x5a
1435 #define LANG_TAMIL 0x49
1436 #define LANG_TATAR 0x44
1437 #define LANG_TELUGU 0x4a
1438 #define LANG_THAI 0x1e
1439 #define LANG_TURKISH 0x1f
1440 #define LANG_UKRAINIAN 0x22
1441 #define LANG_URDU 0x20
1442 #define LANG_UZBEK 0x43
1443 #define LANG_VIETNAMESE 0x2a
1445 /* FIXME: these are not in the Windows header */
1446 #define LANG_GAELIC 0x3c
1447 #define LANG_MALTESE 0x3a
1448 #define LANG_MAORI 0x28
1449 #define LANG_RHAETO_ROMANCE 0x17
1450 #define LANG_SAAMI 0x3b
1451 #define LANG_SORBIAN 0x2e
1452 #define LANG_SUTU 0x30
1453 #define LANG_TSONGA 0x31
1454 #define LANG_TSWANA 0x32
1455 #define LANG_VENDA 0x33
1456 #define LANG_XHOSA 0x34
1457 #define LANG_ZULU 0x35
1459 /* non standard; keep the number high enough (but < 0xff) */
1460 #define LANG_ESPERANTO 0x8f
1461 #define LANG_WALON 0x90
1462 #define LANG_CORNISH 0x91
1463 #define LANG_WELSH 0x92
1464 #define LANG_BRETON 0x93
1466 /* Sublanguage definitions */
1467 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
1468 #define SUBLANG_DEFAULT 0x01 /* user default */
1469 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
1471 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
1472 #define SUBLANG_ARABIC_IRAQ 0x02
1473 #define SUBLANG_ARABIC_EGYPT 0x03
1474 #define SUBLANG_ARABIC_LIBYA 0x04
1475 #define SUBLANG_ARABIC_ALGERIA 0x05
1476 #define SUBLANG_ARABIC_MOROCCO 0x06
1477 #define SUBLANG_ARABIC_TUNISIA 0x07
1478 #define SUBLANG_ARABIC_OMAN 0x08
1479 #define SUBLANG_ARABIC_YEMEN 0x09
1480 #define SUBLANG_ARABIC_SYRIA 0x0a
1481 #define SUBLANG_ARABIC_JORDAN 0x0b
1482 #define SUBLANG_ARABIC_LEBANON 0x0c
1483 #define SUBLANG_ARABIC_KUWAIT 0x0d
1484 #define SUBLANG_ARABIC_UAE 0x0e
1485 #define SUBLANG_ARABIC_BAHRAIN 0x0f
1486 #define SUBLANG_ARABIC_QATAR 0x10
1487 #define SUBLANG_AZERI_LATIN 0x01
1488 #define SUBLANG_AZERI_CYRILLIC 0x02
1489 #define SUBLANG_CHINESE_TRADITIONAL 0x01
1490 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
1491 #define SUBLANG_CHINESE_HONGKONG 0x03
1492 #define SUBLANG_CHINESE_SINGAPORE 0x04
1493 #define SUBLANG_CHINESE_MACAU 0x05
1494 #define SUBLANG_DUTCH 0x01
1495 #define SUBLANG_DUTCH_BELGIAN 0x02
1496 #define SUBLANG_ENGLISH_US 0x01
1497 #define SUBLANG_ENGLISH_UK 0x02
1498 #define SUBLANG_ENGLISH_AUS 0x03
1499 #define SUBLANG_ENGLISH_CAN 0x04
1500 #define SUBLANG_ENGLISH_NZ 0x05
1501 #define SUBLANG_ENGLISH_EIRE 0x06
1502 #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
1503 #define SUBLANG_ENGLISH_JAMAICA 0x08
1504 #define SUBLANG_ENGLISH_CARIBBEAN 0x09
1505 #define SUBLANG_ENGLISH_BELIZE 0x0a
1506 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
1507 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
1508 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
1509 #define SUBLANG_FRENCH 0x01
1510 #define SUBLANG_FRENCH_BELGIAN 0x02
1511 #define SUBLANG_FRENCH_CANADIAN 0x03
1512 #define SUBLANG_FRENCH_SWISS 0x04
1513 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
1514 #define SUBLANG_FRENCH_MONACO 0x06
1515 #define SUBLANG_GERMAN 0x01
1516 #define SUBLANG_GERMAN_SWISS 0x02
1517 #define SUBLANG_GERMAN_AUSTRIAN 0x03
1518 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
1519 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
1520 #define SUBLANG_ITALIAN 0x01
1521 #define SUBLANG_ITALIAN_SWISS 0x02
1522 #define SUBLANG_KASHMIRI_SASIA 0x02
1523 #define SUBLANG_KASHMIRI_INDIA 0x02
1524 #define SUBLANG_KOREAN 0x01
1525 #define SUBLANG_LITHUANIAN 0x01
1526 #define SUBLANG_MALAY_MALAYSIA 0x01
1527 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
1528 #define SUBLANG_NEPALI_INDIA 0x02
1529 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
1530 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
1531 #define SUBLANG_PORTUGUESE 0x02
1532 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
1533 #define SUBLANG_SERBIAN_LATIN 0x02
1534 #define SUBLANG_SERBIAN_CYRILLIC 0x03
1535 #define SUBLANG_SPANISH 0x01
1536 #define SUBLANG_SPANISH_MEXICAN 0x02
1537 #define SUBLANG_SPANISH_MODERN 0x03
1538 #define SUBLANG_SPANISH_GUATEMALA 0x04
1539 #define SUBLANG_SPANISH_COSTA_RICA 0x05
1540 #define SUBLANG_SPANISH_PANAMA 0x06
1541 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
1542 #define SUBLANG_SPANISH_VENEZUELA 0x08
1543 #define SUBLANG_SPANISH_COLOMBIA 0x09
1544 #define SUBLANG_SPANISH_PERU 0x0a
1545 #define SUBLANG_SPANISH_ARGENTINA 0x0b
1546 #define SUBLANG_SPANISH_ECUADOR 0x0c
1547 #define SUBLANG_SPANISH_CHILE 0x0d
1548 #define SUBLANG_SPANISH_URUGUAY 0x0e
1549 #define SUBLANG_SPANISH_PARAGUAY 0x0f
1550 #define SUBLANG_SPANISH_BOLIVIA 0x10
1551 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
1552 #define SUBLANG_SPANISH_HONDURAS 0x12
1553 #define SUBLANG_SPANISH_NICARAGUA 0x13
1554 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
1555 #define SUBLANG_SWEDISH 0x01
1556 #define SUBLANG_SWEDISH_FINLAND 0x02
1557 #define SUBLANG_URDU_PAKISTAN 0x01
1558 #define SUBLANG_URDU_INDIA 0x02
1559 #define SUBLANG_UZBEK_LATIN 0x01
1560 #define SUBLANG_UZBEK_CYRILLIC 0x02
1562 /* FIXME: these are not in the Windows header */
1563 #define SUBLANG_DUTCH_SURINAM 0x03
1564 #define SUBLANG_ROMANIAN 0x01
1565 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
1566 #define SUBLANG_RUSSIAN 0x01
1567 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
1568 #define SUBLANG_CROATIAN 0x01
1569 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
1570 #define SUBLANG_GAELIC 0x01
1571 #define SUBLANG_GAELIC_SCOTTISH 0x02
1572 #define SUBLANG_GAELIC_MANX 0x03
1576 * Sort definitions
1579 #define SORT_DEFAULT 0x0
1580 #define SORT_JAPANESE_XJIS 0x0
1581 #define SORT_JAPANESE_UNICODE 0x1
1582 #define SORT_CHINESE_BIG5 0x0
1583 #define SORT_CHINESE_UNICODE 0x1
1584 #define SORT_KOREAN_KSC 0x0
1585 #define SORT_KOREAN_UNICODE 0x1
1590 * Definitions for IsTextUnicode()
1593 #define IS_TEXT_UNICODE_ASCII16 0x0001
1594 #define IS_TEXT_UNICODE_STATISTICS 0x0002
1595 #define IS_TEXT_UNICODE_CONTROLS 0x0004
1596 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
1597 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
1598 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
1599 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1600 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
1601 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
1602 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
1603 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
1604 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
1605 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
1606 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
1607 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
1608 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
1610 #include "ntstatus.h"
1612 #define MAXIMUM_WAIT_OBJECTS 64
1613 #define MAXIMUM_SUSPEND_COUNT 127
1617 * From OS/2 2.0 exception handling
1618 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1621 #define EH_NONCONTINUABLE 0x01
1622 #define EH_UNWINDING 0x02
1623 #define EH_EXIT_UNWIND 0x04
1624 #define EH_STACK_INVALID 0x08
1625 #define EH_NESTED_CALL 0x10
1627 #define EXCEPTION_CONTINUABLE 0
1628 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
1631 * The exception record used by Win32 to give additional information
1632 * about exception to exception handlers.
1635 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1637 typedef struct __EXCEPTION_RECORD
1639 DWORD ExceptionCode;
1640 DWORD ExceptionFlags;
1641 struct __EXCEPTION_RECORD *ExceptionRecord;
1643 LPVOID ExceptionAddress;
1644 DWORD NumberParameters;
1645 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1646 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1649 * The exception pointers structure passed to exception filters
1650 * in except() and the UnhandledExceptionFilter().
1653 typedef struct _EXCEPTION_POINTERS
1655 PEXCEPTION_RECORD ExceptionRecord;
1656 PCONTEXT ContextRecord;
1657 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1661 * The exception frame, used for registering exception handlers
1662 * Win32 cares only about this, but compilers generally emit
1663 * larger exception frames for their own use.
1666 struct __EXCEPTION_FRAME;
1668 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
1669 PCONTEXT,struct __EXCEPTION_FRAME **);
1671 typedef struct __EXCEPTION_FRAME
1673 struct __EXCEPTION_FRAME *Prev;
1674 PEXCEPTION_HANDLER Handler;
1675 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
1678 * function pointer to a exception filter
1681 typedef LONG (CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1682 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1684 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1685 LPTOP_LEVEL_EXCEPTION_FILTER
1686 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1688 /* status values for ContinueDebugEvent */
1689 #define DBG_CONTINUE 0x00010002
1690 #define DBG_TERMINATE_THREAD 0x40010003
1691 #define DBG_TERMINATE_PROCESS 0x40010004
1692 #define DBG_CONTROL_C 0x40010005
1693 #define DBG_CONTROL_BREAK 0x40010008
1694 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
1696 typedef struct _NT_TIB
1698 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1699 PVOID StackBase;
1700 PVOID StackLimit;
1701 PVOID SubSystemTib;
1702 union {
1703 PVOID FiberData;
1704 DWORD Version;
1705 } DUMMYUNIONNAME;
1706 PVOID ArbitraryUserPointer;
1707 struct _NT_TIB *Self;
1708 } NT_TIB, *PNT_TIB;
1710 struct _TEB;
1712 #if defined(__i386__) && defined(__GNUC__)
1713 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1714 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1716 struct _TEB *teb;
1717 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1718 return teb;
1720 #elif defined(__i386__) && defined(_MSC_VER)
1721 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1723 struct _TEB *teb;
1724 __asm mov eax, fs:[0x18];
1725 __asm mov teb, eax;
1726 return teb;
1728 #elif defined(__powerpc__)
1729 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1730 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1732 struct _TEB *teb;
1733 __asm__("\tmr %0, 2" : "=r" (teb));
1734 return teb;
1736 #else
1737 extern struct _TEB * WINAPI NtCurrentTeb(void);
1738 #endif
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.
1778 typedef struct
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 {
1813 WORD e32_magic;
1814 BYTE e32_border;
1815 BYTE e32_worder;
1816 DWORD e32_level;
1817 WORD e32_cpu;
1818 WORD e32_os;
1819 DWORD e32_ver;
1820 DWORD e32_mflags;
1821 DWORD e32_mpages;
1822 DWORD e32_startobj;
1823 DWORD e32_eip;
1824 DWORD e32_stackobj;
1825 DWORD e32_esp;
1826 DWORD e32_pagesize;
1827 DWORD e32_lastpagesize;
1828 DWORD e32_fixupsize;
1829 DWORD e32_fixupsum;
1830 DWORD e32_ldrsize;
1831 DWORD e32_ldrsum;
1832 DWORD e32_objtab;
1833 DWORD e32_objcnt;
1834 DWORD e32_objmap;
1835 DWORD e32_itermap;
1836 DWORD e32_rsrctab;
1837 DWORD e32_rsrccnt;
1838 DWORD e32_restab;
1839 DWORD e32_enttab;
1840 DWORD e32_dirtab;
1841 DWORD e32_dircnt;
1842 DWORD e32_fpagetab;
1843 DWORD e32_frectab;
1844 DWORD e32_impmod;
1845 DWORD e32_impmodcnt;
1846 DWORD e32_impproc;
1847 DWORD e32_pagesum;
1848 DWORD e32_datapage;
1849 DWORD e32_preload;
1850 DWORD e32_nrestab;
1851 DWORD e32_cbnrestab;
1852 DWORD e32_nressum;
1853 DWORD e32_autodata;
1854 DWORD e32_debuginfo;
1855 DWORD e32_debuglen;
1856 DWORD e32_instpreload;
1857 DWORD e32_instdemand;
1858 DWORD e32_heapsize;
1859 BYTE e32_res3[12];
1860 DWORD e32_winresoff;
1861 DWORD e32_winreslen;
1862 WORD e32_devid;
1863 WORD e32_ddkver;
1864 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1867 /* These defines describe the meanings of the bits in the Characteristics
1868 field */
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_AGGRESIVE_WS_TRIM 0x0010
1875 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
1876 #define IMAGE_FILE_16BIT_MACHINE 0x0040
1877 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
1878 #define IMAGE_FILE_32BIT_MACHINE 0x0100
1879 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
1880 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
1881 #define IMAGE_FILE_SYSTEM 0x1000
1882 #define IMAGE_FILE_DLL 0x2000
1883 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
1884 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
1886 /* These are the settings of the Machine field. */
1887 #define IMAGE_FILE_MACHINE_UNKNOWN 0
1888 #define IMAGE_FILE_MACHINE_I860 0x14d
1889 #define IMAGE_FILE_MACHINE_I386 0x14c
1890 #define IMAGE_FILE_MACHINE_R3000 0x162
1891 #define IMAGE_FILE_MACHINE_R4000 0x166
1892 #define IMAGE_FILE_MACHINE_R10000 0x168
1893 #define IMAGE_FILE_MACHINE_ALPHA 0x184
1894 #define IMAGE_FILE_MACHINE_POWERPC 0x1F0
1896 #define IMAGE_SIZEOF_FILE_HEADER 20
1898 /* Possible Magic values */
1899 #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
1900 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
1902 /* These are indexes into the DataDirectory array */
1903 #define IMAGE_FILE_EXPORT_DIRECTORY 0
1904 #define IMAGE_FILE_IMPORT_DIRECTORY 1
1905 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
1906 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
1907 #define IMAGE_FILE_SECURITY_DIRECTORY 4
1908 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
1909 #define IMAGE_FILE_DEBUG_DIRECTORY 6
1910 #define IMAGE_FILE_DESCRIPTION_STRING 7
1911 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
1912 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
1913 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
1915 /* Directory Entries, indices into the DataDirectory array */
1917 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
1918 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
1919 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
1920 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
1921 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
1922 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
1923 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
1924 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
1925 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
1926 #define IMAGE_DIRECTORY_ENTRY_TLS 9
1927 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
1928 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
1929 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
1930 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
1931 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
1933 /* Subsystem Values */
1935 #define IMAGE_SUBSYSTEM_UNKNOWN 0
1936 #define IMAGE_SUBSYSTEM_NATIVE 1
1937 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
1938 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem*/
1939 #define IMAGE_SUBSYSTEM_OS2_CUI 5
1940 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
1942 typedef struct _IMAGE_FILE_HEADER {
1943 WORD Machine;
1944 WORD NumberOfSections;
1945 DWORD TimeDateStamp;
1946 DWORD PointerToSymbolTable;
1947 DWORD NumberOfSymbols;
1948 WORD SizeOfOptionalHeader;
1949 WORD Characteristics;
1950 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1952 typedef struct _IMAGE_DATA_DIRECTORY {
1953 DWORD VirtualAddress;
1954 DWORD Size;
1955 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1957 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
1959 typedef struct _IMAGE_OPTIONAL_HEADER {
1961 /* Standard fields */
1963 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
1964 BYTE MajorLinkerVersion;
1965 BYTE MinorLinkerVersion;
1966 DWORD SizeOfCode;
1967 DWORD SizeOfInitializedData;
1968 DWORD SizeOfUninitializedData;
1969 DWORD AddressOfEntryPoint; /* 0x10 */
1970 DWORD BaseOfCode;
1971 DWORD BaseOfData;
1973 /* NT additional fields */
1975 DWORD ImageBase;
1976 DWORD SectionAlignment; /* 0x20 */
1977 DWORD FileAlignment;
1978 WORD MajorOperatingSystemVersion;
1979 WORD MinorOperatingSystemVersion;
1980 WORD MajorImageVersion;
1981 WORD MinorImageVersion;
1982 WORD MajorSubsystemVersion; /* 0x30 */
1983 WORD MinorSubsystemVersion;
1984 DWORD Win32VersionValue;
1985 DWORD SizeOfImage;
1986 DWORD SizeOfHeaders;
1987 DWORD CheckSum; /* 0x40 */
1988 WORD Subsystem;
1989 WORD DllCharacteristics;
1990 DWORD SizeOfStackReserve;
1991 DWORD SizeOfStackCommit;
1992 DWORD SizeOfHeapReserve; /* 0x50 */
1993 DWORD SizeOfHeapCommit;
1994 DWORD LoaderFlags;
1995 DWORD NumberOfRvaAndSizes;
1996 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
1997 /* 0xE0 */
1998 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
2000 typedef struct _IMAGE_NT_HEADERS {
2001 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2002 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2003 IMAGE_OPTIONAL_HEADER OptionalHeader; /* 0x18 */
2004 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
2006 #define IMAGE_SIZEOF_SHORT_NAME 8
2008 typedef struct _IMAGE_SECTION_HEADER {
2009 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2010 union {
2011 DWORD PhysicalAddress;
2012 DWORD VirtualSize;
2013 } Misc;
2014 DWORD VirtualAddress;
2015 DWORD SizeOfRawData;
2016 DWORD PointerToRawData;
2017 DWORD PointerToRelocations;
2018 DWORD PointerToLinenumbers;
2019 WORD NumberOfRelocations;
2020 WORD NumberOfLinenumbers;
2021 DWORD Characteristics;
2022 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2024 #define IMAGE_SIZEOF_SECTION_HEADER 40
2026 #define IMAGE_FIRST_SECTION(ntheader) \
2027 ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2028 ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2030 /* These defines are for the Characteristics bitfield. */
2031 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2032 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2033 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2034 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2035 /* #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved */
2036 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2038 #define IMAGE_SCN_CNT_CODE 0x00000020
2039 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2040 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2042 #define IMAGE_SCN_LNK_OTHER 0x00000100
2043 #define IMAGE_SCN_LNK_INFO 0x00000200
2044 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2045 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2046 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2048 /* 0x00002000 - Reserved */
2049 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2050 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2052 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2053 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2054 #define IMAGE_SCN_MEM_16BIT 0x00020000
2055 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2056 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2058 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2059 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2060 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2061 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2062 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2063 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2064 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2065 /* 0x00800000 - Unused */
2067 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2070 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2071 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2072 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2073 #define IMAGE_SCN_MEM_SHARED 0x10000000
2074 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2075 #define IMAGE_SCN_MEM_READ 0x40000000
2076 #define IMAGE_SCN_MEM_WRITE 0x80000000
2078 #include "pshpack2.h"
2080 typedef struct _IMAGE_SYMBOL {
2081 union {
2082 BYTE ShortName[8];
2083 struct {
2084 DWORD Short;
2085 DWORD Long;
2086 } Name;
2087 DWORD LongName[2];
2088 } N;
2089 DWORD Value;
2090 SHORT SectionNumber;
2091 WORD Type;
2092 BYTE StorageClass;
2093 BYTE NumberOfAuxSymbols;
2094 } IMAGE_SYMBOL;
2095 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2097 #define IMAGE_SIZEOF_SYMBOL 18
2099 typedef struct _IMAGE_LINENUMBER {
2100 union {
2101 DWORD SymbolTableIndex;
2102 DWORD VirtualAddress;
2103 } Type;
2104 WORD Linenumber;
2105 } IMAGE_LINENUMBER;
2106 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2108 #define IMAGE_SIZEOF_LINENUMBER 6
2110 typedef union _IMAGE_AUX_SYMBOL {
2111 struct {
2112 DWORD TagIndex;
2113 union {
2114 struct {
2115 WORD Linenumber;
2116 WORD Size;
2117 } LnSz;
2118 DWORD TotalSize;
2119 } Misc;
2120 union {
2121 struct {
2122 DWORD PointerToLinenumber;
2123 DWORD PointerToNextFunction;
2124 } Function;
2125 struct {
2126 WORD Dimension[4];
2127 } Array;
2128 } FcnAry;
2129 WORD TvIndex;
2130 } Sym;
2131 struct {
2132 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2133 } File;
2134 struct {
2135 DWORD Length;
2136 WORD NumberOfRelocations;
2137 WORD NumberOfLinenumbers;
2138 DWORD CheckSum;
2139 SHORT Number;
2140 BYTE Selection;
2141 } Section;
2142 } IMAGE_AUX_SYMBOL;
2143 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2145 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2147 #include "poppack.h"
2149 #define IMAGE_SYM_UNDEFINED (SHORT)0
2150 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2151 #define IMAGE_SYM_DEBUG (SHORT)-2
2153 #define IMAGE_SYM_TYPE_NULL 0x0000
2154 #define IMAGE_SYM_TYPE_VOID 0x0001
2155 #define IMAGE_SYM_TYPE_CHAR 0x0002
2156 #define IMAGE_SYM_TYPE_SHORT 0x0003
2157 #define IMAGE_SYM_TYPE_INT 0x0004
2158 #define IMAGE_SYM_TYPE_LONG 0x0005
2159 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2160 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2161 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2162 #define IMAGE_SYM_TYPE_UNION 0x0009
2163 #define IMAGE_SYM_TYPE_ENUM 0x000A
2164 #define IMAGE_SYM_TYPE_MOE 0x000B
2165 #define IMAGE_SYM_TYPE_BYTE 0x000C
2166 #define IMAGE_SYM_TYPE_WORD 0x000D
2167 #define IMAGE_SYM_TYPE_UINT 0x000E
2168 #define IMAGE_SYM_TYPE_DWORD 0x000F
2169 #define IMAGE_SYM_TYPE_PCODE 0x8000
2171 #define IMAGE_SYM_DTYPE_NULL 0
2172 #define IMAGE_SYM_DTYPE_POINTER 1
2173 #define IMAGE_SYM_DTYPE_FUNCTION 2
2174 #define IMAGE_SYM_DTYPE_ARRAY 3
2176 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2177 #define IMAGE_SYM_CLASS_NULL 0x0000
2178 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2179 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2180 #define IMAGE_SYM_CLASS_STATIC 0x0003
2181 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2182 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2183 #define IMAGE_SYM_CLASS_LABEL 0x0006
2184 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2185 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2186 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2187 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2188 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2189 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2190 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2191 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2192 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2193 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2194 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2195 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2197 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2198 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2199 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2200 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2201 #define IMAGE_SYM_CLASS_FILE 0x0067
2202 #define IMAGE_SYM_CLASS_SECTION 0x0068
2203 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2205 #define N_BTMASK 0x000F
2206 #define N_TMASK 0x0030
2207 #define N_TMASK1 0x00C0
2208 #define N_TMASK2 0x00F0
2209 #define N_BTSHFT 4
2210 #define N_TSHIFT 2
2212 #define BTYPE(x) ((x) & N_BTMASK)
2214 #ifndef ISPTR
2215 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2216 #endif
2218 #ifndef ISFCN
2219 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2220 #endif
2222 #ifndef ISARY
2223 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2224 #endif
2226 #ifndef ISTAG
2227 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2228 #endif
2230 #ifndef INCREF
2231 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2232 #endif
2233 #ifndef DECREF
2234 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2235 #endif
2237 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2238 #define IMAGE_COMDAT_SELECT_ANY 2
2239 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2240 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2241 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2242 #define IMAGE_COMDAT_SELECT_LARGEST 6
2243 #define IMAGE_COMDAT_SELECT_NEWEST 7
2245 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2246 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2247 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2249 /* Export module directory */
2251 typedef struct _IMAGE_EXPORT_DIRECTORY {
2252 DWORD Characteristics;
2253 DWORD TimeDateStamp;
2254 WORD MajorVersion;
2255 WORD MinorVersion;
2256 DWORD Name;
2257 DWORD Base;
2258 DWORD NumberOfFunctions;
2259 DWORD NumberOfNames;
2260 DWORD AddressOfFunctions;
2261 DWORD AddressOfNames;
2262 DWORD AddressOfNameOrdinals;
2263 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2265 /* Import name entry */
2266 typedef struct _IMAGE_IMPORT_BY_NAME {
2267 WORD Hint;
2268 BYTE Name[1];
2269 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2271 /* Import thunk */
2272 typedef struct _IMAGE_THUNK_DATA {
2273 union {
2274 LPBYTE ForwarderString;
2275 PDWORD Function;
2276 DWORD Ordinal;
2277 PIMAGE_IMPORT_BY_NAME AddressOfData;
2278 } u1;
2279 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2281 /* Import module directory */
2283 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2284 union {
2285 DWORD Characteristics; /* 0 for terminating null import descriptor */
2286 PIMAGE_THUNK_DATA OriginalFirstThunk; /* RVA to original unbound IAT */
2287 } u;
2288 DWORD TimeDateStamp; /* 0 if not bound,
2289 * -1 if bound, and real date\time stamp
2290 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2291 * (new BIND)
2292 * otherwise date/time stamp of DLL bound to
2293 * (Old BIND)
2295 DWORD ForwarderChain; /* -1 if no forwarders */
2296 DWORD Name;
2297 /* RVA to IAT (if bound this IAT has actual addresses) */
2298 PIMAGE_THUNK_DATA FirstThunk;
2299 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2301 #define IMAGE_ORDINAL_FLAG 0x80000000
2302 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2303 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
2305 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2307 DWORD TimeDateStamp;
2308 WORD OffsetModuleName;
2309 WORD NumberOfModuleForwarderRefs;
2310 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2311 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2313 typedef struct _IMAGE_BOUND_FORWARDER_REF
2315 DWORD TimeDateStamp;
2316 WORD OffsetModuleName;
2317 WORD Reserved;
2318 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2320 #include "pshpack2.h"
2322 typedef struct _IMAGE_BASE_RELOCATION
2324 DWORD VirtualAddress;
2325 DWORD SizeOfBlock;
2326 /* WORD TypeOffset[1]; */
2327 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2329 typedef struct _IMAGE_RELOCATION
2331 union {
2332 DWORD VirtualAddress;
2333 DWORD RelocCount;
2334 } u;
2335 DWORD SymbolTableIndex;
2336 WORD Type;
2337 } IMAGE_RELOCATION;
2338 typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
2340 #include "poppack.h"
2342 #define IMAGE_SIZEOF_RELOCATION 10
2344 /* generic relocation types */
2345 #define IMAGE_REL_BASED_ABSOLUTE 0
2346 #define IMAGE_REL_BASED_HIGH 1
2347 #define IMAGE_REL_BASED_LOW 2
2348 #define IMAGE_REL_BASED_HIGHLOW 3
2349 #define IMAGE_REL_BASED_HIGHADJ 4
2350 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
2351 #define IMAGE_REL_BASED_SECTION 6
2352 #define IMAGE_REL_BASED_REL 7
2353 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
2354 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
2355 #define IMAGE_REL_BASED_DIR64 10
2356 #define IMAGE_REL_BASED_HIGH3ADJ 11
2358 /* I386 relocation types */
2359 #define IMAGE_REL_I386_ABSOLUTE 0
2360 #define IMAGE_REL_I386_DIR16 1
2361 #define IMAGE_REL_I386_REL16 2
2362 #define IMAGE_REL_I386_DIR32 6
2363 #define IMAGE_REL_I386_DIR32NB 7
2364 #define IMAGE_REL_I386_SEG12 9
2365 #define IMAGE_REL_I386_SECTION 10
2366 #define IMAGE_REL_I386_SECREL 11
2367 #define IMAGE_REL_I386_REL32 20
2369 /* MIPS relocation types */
2370 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
2371 #define IMAGE_REL_MIPS_REFHALF 0x0001
2372 #define IMAGE_REL_MIPS_REFWORD 0x0002
2373 #define IMAGE_REL_MIPS_JMPADDR 0x0003
2374 #define IMAGE_REL_MIPS_REFHI 0x0004
2375 #define IMAGE_REL_MIPS_REFLO 0x0005
2376 #define IMAGE_REL_MIPS_GPREL 0x0006
2377 #define IMAGE_REL_MIPS_LITERAL 0x0007
2378 #define IMAGE_REL_MIPS_SECTION 0x000A
2379 #define IMAGE_REL_MIPS_SECREL 0x000B
2380 #define IMAGE_REL_MIPS_SECRELLO 0x000C
2381 #define IMAGE_REL_MIPS_SECRELHI 0x000D
2382 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
2383 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
2384 #define IMAGE_REL_MIPS_PAIR 0x0025
2386 /* ALPHA relocation types */
2387 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
2388 #define IMAGE_REL_ALPHA_REFLONG 0x0001
2389 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
2390 #define IMAGE_REL_ALPHA_GPREL 0x0003
2391 #define IMAGE_REL_ALPHA_LITERAL 0x0004
2392 #define IMAGE_REL_ALPHA_LITUSE 0x0005
2393 #define IMAGE_REL_ALPHA_GPDISP 0x0006
2394 #define IMAGE_REL_ALPHA_BRADDR 0x0007
2395 #define IMAGE_REL_ALPHA_HINT 0x0008
2396 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
2397 #define IMAGE_REL_ALPHA_REFHI 0x000A
2398 #define IMAGE_REL_ALPHA_REFLO 0x000B
2399 #define IMAGE_REL_ALPHA_PAIR 0x000C
2400 #define IMAGE_REL_ALPHA_MATCH 0x000D
2401 #define IMAGE_REL_ALPHA_SECTION 0x000E
2402 #define IMAGE_REL_ALPHA_SECREL 0x000F
2403 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
2404 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
2405 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
2406 #define IMAGE_REL_ALPHA_REFQ3 0x0013
2407 #define IMAGE_REL_ALPHA_REFQ2 0x0014
2408 #define IMAGE_REL_ALPHA_REFQ1 0x0015
2409 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
2410 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
2412 /* PowerPC relocation types */
2413 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
2414 #define IMAGE_REL_PPC_ADDR64 0x0001
2415 #define IMAGE_REL_PPC_ADDR 0x0002
2416 #define IMAGE_REL_PPC_ADDR24 0x0003
2417 #define IMAGE_REL_PPC_ADDR16 0x0004
2418 #define IMAGE_REL_PPC_ADDR14 0x0005
2419 #define IMAGE_REL_PPC_REL24 0x0006
2420 #define IMAGE_REL_PPC_REL14 0x0007
2421 #define IMAGE_REL_PPC_TOCREL16 0x0008
2422 #define IMAGE_REL_PPC_TOCREL14 0x0009
2423 #define IMAGE_REL_PPC_ADDR32NB 0x000A
2424 #define IMAGE_REL_PPC_SECREL 0x000B
2425 #define IMAGE_REL_PPC_SECTION 0x000C
2426 #define IMAGE_REL_PPC_IFGLUE 0x000D
2427 #define IMAGE_REL_PPC_IMGLUE 0x000E
2428 #define IMAGE_REL_PPC_SECREL16 0x000F
2429 #define IMAGE_REL_PPC_REFHI 0x0010
2430 #define IMAGE_REL_PPC_REFLO 0x0011
2431 #define IMAGE_REL_PPC_PAIR 0x0012
2432 #define IMAGE_REL_PPC_SECRELLO 0x0013
2433 #define IMAGE_REL_PPC_SECRELHI 0x0014
2434 #define IMAGE_REL_PPC_GPREL 0x0015
2435 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
2436 /* modifier bits */
2437 #define IMAGE_REL_PPC_NEG 0x0100
2438 #define IMAGE_REL_PPC_BRTAKEN 0x0200
2439 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
2440 #define IMAGE_REL_PPC_TOCDEFN 0x0800
2442 /* SH3 ? relocation type */
2443 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
2444 #define IMAGE_REL_SH3_DIRECT16 0x0001
2445 #define IMAGE_REL_SH3_DIRECT 0x0002
2446 #define IMAGE_REL_SH3_DIRECT8 0x0003
2447 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
2448 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
2449 #define IMAGE_REL_SH3_DIRECT4 0x0006
2450 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
2451 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
2452 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
2453 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
2454 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
2455 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
2456 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
2457 #define IMAGE_REL_SH3_SECTION 0x000E
2458 #define IMAGE_REL_SH3_SECREL 0x000F
2459 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
2461 /* ARM (Archimedes?) relocation types */
2462 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
2463 #define IMAGE_REL_ARM_ADDR 0x0001
2464 #define IMAGE_REL_ARM_ADDR32NB 0x0002
2465 #define IMAGE_REL_ARM_BRANCH24 0x0003
2466 #define IMAGE_REL_ARM_BRANCH11 0x0004
2467 #define IMAGE_REL_ARM_SECTION 0x000E
2468 #define IMAGE_REL_ARM_SECREL 0x000F
2470 /* IA64 relocation types */
2471 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
2472 #define IMAGE_REL_IA64_IMM14 0x0001
2473 #define IMAGE_REL_IA64_IMM22 0x0002
2474 #define IMAGE_REL_IA64_IMM64 0x0003
2475 #define IMAGE_REL_IA64_DIR 0x0004
2476 #define IMAGE_REL_IA64_DIR64 0x0005
2477 #define IMAGE_REL_IA64_PCREL21B 0x0006
2478 #define IMAGE_REL_IA64_PCREL21M 0x0007
2479 #define IMAGE_REL_IA64_PCREL21F 0x0008
2480 #define IMAGE_REL_IA64_GPREL22 0x0009
2481 #define IMAGE_REL_IA64_LTOFF22 0x000A
2482 #define IMAGE_REL_IA64_SECTION 0x000B
2483 #define IMAGE_REL_IA64_SECREL22 0x000C
2484 #define IMAGE_REL_IA64_SECREL64I 0x000D
2485 #define IMAGE_REL_IA64_SECREL 0x000E
2486 #define IMAGE_REL_IA64_LTOFF64 0x000F
2487 #define IMAGE_REL_IA64_DIR32NB 0x0010
2488 #define IMAGE_REL_IA64_RESERVED_11 0x0011
2489 #define IMAGE_REL_IA64_RESERVED_12 0x0012
2490 #define IMAGE_REL_IA64_RESERVED_13 0x0013
2491 #define IMAGE_REL_IA64_RESERVED_14 0x0014
2492 #define IMAGE_REL_IA64_RESERVED_15 0x0015
2493 #define IMAGE_REL_IA64_RESERVED_16 0x0016
2494 #define IMAGE_REL_IA64_ADDEND 0x001F
2496 /* archive format */
2498 #define IMAGE_ARCHIVE_START_SIZE 8
2499 #define IMAGE_ARCHIVE_START "!<arch>\n"
2500 #define IMAGE_ARCHIVE_END "`\n"
2501 #define IMAGE_ARCHIVE_PAD "\n"
2502 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
2503 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
2505 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2507 BYTE Name[16];
2508 BYTE Date[12];
2509 BYTE UserID[6];
2510 BYTE GroupID[6];
2511 BYTE Mode[8];
2512 BYTE Size[10];
2513 BYTE EndHeader[2];
2514 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2516 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2519 * Resource directory stuff
2521 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2522 DWORD Characteristics;
2523 DWORD TimeDateStamp;
2524 WORD MajorVersion;
2525 WORD MinorVersion;
2526 WORD NumberOfNamedEntries;
2527 WORD NumberOfIdEntries;
2528 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2529 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2531 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
2532 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
2534 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2535 union {
2536 struct {
2537 #ifdef BITFIELDS_BIGENDIAN
2538 unsigned NameIsString:1;
2539 unsigned NameOffset:31;
2540 #else
2541 unsigned NameOffset:31;
2542 unsigned NameIsString:1;
2543 #endif
2544 } DUMMYSTRUCTNAME1;
2545 DWORD Name;
2546 struct {
2547 #ifdef WORDS_BIGENDIAN
2548 WORD __pad;
2549 WORD Id;
2550 #else
2551 WORD Id;
2552 WORD __pad;
2553 #endif
2554 } DUMMYSTRUCTNAME2;
2555 } DUMMYUNIONNAME1;
2556 union {
2557 DWORD OffsetToData;
2558 struct {
2559 #ifdef BITFIELDS_BIGENDIAN
2560 unsigned DataIsDirectory:1;
2561 unsigned OffsetToDirectory:31;
2562 #else
2563 unsigned OffsetToDirectory:31;
2564 unsigned DataIsDirectory:1;
2565 #endif
2566 } DUMMYSTRUCTNAME3;
2567 } DUMMYUNIONNAME2;
2568 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2571 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2572 WORD Length;
2573 CHAR NameString[ 1 ];
2574 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2576 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2577 WORD Length;
2578 WCHAR NameString[ 1 ];
2579 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2581 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2582 DWORD OffsetToData;
2583 DWORD Size;
2584 DWORD CodePage;
2585 DWORD ResourceHandle;
2586 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2589 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
2590 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2593 typedef struct _IMAGE_TLS_DIRECTORY {
2594 DWORD StartAddressOfRawData;
2595 DWORD EndAddressOfRawData;
2596 LPDWORD AddressOfIndex;
2597 PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
2598 DWORD SizeOfZeroFill;
2599 DWORD Characteristics;
2600 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
2602 typedef struct _IMAGE_DEBUG_DIRECTORY {
2603 DWORD Characteristics;
2604 DWORD TimeDateStamp;
2605 WORD MajorVersion;
2606 WORD MinorVersion;
2607 DWORD Type;
2608 DWORD SizeOfData;
2609 DWORD AddressOfRawData;
2610 DWORD PointerToRawData;
2611 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2613 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
2614 #define IMAGE_DEBUG_TYPE_COFF 1
2615 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
2616 #define IMAGE_DEBUG_TYPE_FPO 3
2617 #define IMAGE_DEBUG_TYPE_MISC 4
2618 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
2619 #define IMAGE_DEBUG_TYPE_FIXUP 6
2620 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
2621 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
2622 #define IMAGE_DEBUG_TYPE_BORLAND 9
2623 #define IMAGE_DEBUG_TYPE_RESERVED10 10
2625 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2626 DWORD NumberOfSymbols;
2627 DWORD LvaToFirstSymbol;
2628 DWORD NumberOfLinenumbers;
2629 DWORD LvaToFirstLinenumber;
2630 DWORD RvaToFirstByteOfCode;
2631 DWORD RvaToLastByteOfCode;
2632 DWORD RvaToFirstByteOfData;
2633 DWORD RvaToLastByteOfData;
2634 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2636 #define FRAME_FPO 0
2637 #define FRAME_TRAP 1
2638 #define FRAME_TSS 2
2639 #define FRAME_NONFPO 3
2641 typedef struct _FPO_DATA {
2642 DWORD ulOffStart;
2643 DWORD cbProcSize;
2644 DWORD cdwLocals;
2645 WORD cdwParams;
2646 unsigned cbProlog : 8;
2647 unsigned cbRegs : 3;
2648 unsigned fHasSEH : 1;
2649 unsigned fUseBP : 1;
2650 unsigned reserved : 1;
2651 unsigned cbFrame : 2;
2652 } FPO_DATA, *PFPO_DATA;
2654 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2655 DWORD Characteristics;
2656 DWORD TimeDateStamp;
2657 WORD MajorVersion;
2658 WORD MinorVersion;
2659 DWORD GlobalFlagsClear;
2660 DWORD GlobalFlagsSet;
2661 DWORD CriticalSectionDefaultTimeout;
2662 DWORD DeCommitFreeBlockThreshold;
2663 DWORD DeCommitTotalFreeThreshold;
2664 PVOID LockPrefixTable;
2665 DWORD MaximumAllocationSize;
2666 DWORD VirtualMemoryThreshold;
2667 DWORD ProcessHeapFlags;
2668 DWORD ProcessAffinityMask;
2669 WORD CSDVersion;
2670 WORD Reserved1;
2671 PVOID EditList;
2672 DWORD Reserved[1];
2673 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2675 typedef struct _IMAGE_FUNCTION_ENTRY {
2676 DWORD StartingAddress;
2677 DWORD EndingAddress;
2678 DWORD EndOfPrologue;
2679 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2681 #define IMAGE_DEBUG_MISC_EXENAME 1
2683 typedef struct _IMAGE_DEBUG_MISC {
2684 DWORD DataType;
2685 DWORD Length;
2686 BYTE Unicode;
2687 BYTE Reserved[ 3 ];
2688 BYTE Data[ 1 ];
2689 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2691 /* This is the structure that appears at the very start of a .DBG file. */
2693 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2694 WORD Signature;
2695 WORD Flags;
2696 WORD Machine;
2697 WORD Characteristics;
2698 DWORD TimeDateStamp;
2699 DWORD CheckSum;
2700 DWORD ImageBase;
2701 DWORD SizeOfImage;
2702 DWORD NumberOfSections;
2703 DWORD ExportedNamesSize;
2704 DWORD DebugDirectorySize;
2705 DWORD SectionAlignment;
2706 DWORD Reserved[ 2 ];
2707 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2709 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2712 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2713 WORD Length;
2714 WORD Flags;
2715 BYTE Text[1];
2716 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2717 #define MESSAGE_RESOURCE_UNICODE 0x0001
2719 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2720 DWORD LowId;
2721 DWORD HighId;
2722 DWORD OffsetToEntries;
2723 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2725 typedef struct tagMESSAGE_RESOURCE_DATA {
2726 DWORD NumberOfBlocks;
2727 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
2728 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2731 * Here follows typedefs for security and tokens.
2735 * First a constant for the following typdefs.
2738 #define ANYSIZE_ARRAY 1
2740 /* FIXME: Orphan. What does it point to? */
2741 typedef PVOID PACCESS_TOKEN;
2744 * TOKEN_INFORMATION_CLASS
2747 typedef enum _TOKEN_INFORMATION_CLASS {
2748 TokenUser = 1,
2749 TokenGroups,
2750 TokenPrivileges,
2751 TokenOwner,
2752 TokenPrimaryGroup,
2753 TokenDefaultDacl,
2754 TokenSource,
2755 TokenType,
2756 TokenImpersonationLevel,
2757 TokenStatistics,
2758 TokenRestrictedSids,
2759 TokenSessionId,
2760 TokenGroupsAndPrivileges,
2761 TokenSessionReference,
2762 TokenSandBoxInert
2763 } TOKEN_INFORMATION_CLASS;
2765 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
2766 #define TOKEN_ADJUST_GROUPS 0x0040
2767 #define TOKEN_ADJUST_PRIVILEGES 0x0020
2768 #define TOKEN_ADJUST_SESSIONID 0x0100
2769 #define TOKEN_ASSIGN_PRIMARY 0x0001
2770 #define TOKEN_DUPLICATE 0x0002
2771 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
2772 #define TOKEN_IMPERSONATE 0x0004
2773 #define TOKEN_QUERY 0x0008
2774 #define TOKEN_QUERY_SOURCE 0x0010
2775 #define TOKEN_ADJUST_DEFAULT 0x0080
2776 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
2777 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
2778 TOKEN_ADJUST_PRIVILEGES | \
2779 TOKEN_ADJUST_GROUPS | \
2780 TOKEN_ADJUST_DEFAULT )
2781 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
2782 TOKEN_ASSIGN_PRIMARY | \
2783 TOKEN_DUPLICATE | \
2784 TOKEN_IMPERSONATE | \
2785 TOKEN_QUERY | \
2786 TOKEN_QUERY_SOURCE | \
2787 TOKEN_ADJUST_PRIVILEGES | \
2788 TOKEN_ADJUST_GROUPS | \
2789 TOKEN_ADJUST_SESSIONID | \
2790 TOKEN_ADJUST_DEFAULT )
2792 #ifndef _SECURITY_DEFINED
2793 #define _SECURITY_DEFINED
2796 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2798 typedef struct _GENERIC_MAPPING {
2799 ACCESS_MASK GenericRead;
2800 ACCESS_MASK GenericWrite;
2801 ACCESS_MASK GenericExecute;
2802 ACCESS_MASK GenericAll;
2803 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2805 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2806 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2807 typedef struct {
2808 BYTE Value[6];
2809 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
2810 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2812 #ifndef SID_DEFINED
2813 #define SID_DEFINED
2814 typedef struct _SID {
2815 BYTE Revision;
2816 BYTE SubAuthorityCount;
2817 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2818 DWORD SubAuthority[1];
2819 } SID,*PSID;
2820 #endif /* !defined(SID_DEFINED) */
2822 #define SID_REVISION (1) /* Current revision */
2823 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
2824 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
2828 * ACL
2831 #define ACL_REVISION1 1
2832 #define ACL_REVISION2 2
2833 #define ACL_REVISION3 3
2834 #define ACL_REVISION4 4
2836 #define MIN_ACL_REVISION ACL_REVISION2
2837 #define MAX_ACL_REVISION ACL_REVISION4
2839 typedef struct _ACL {
2840 BYTE AclRevision;
2841 BYTE Sbz1;
2842 WORD AclSize;
2843 WORD AceCount;
2844 WORD Sbz2;
2845 } ACL, *PACL;
2847 /* SECURITY_DESCRIPTOR */
2848 #define SECURITY_DESCRIPTOR_REVISION 1
2849 #define SECURITY_DESCRIPTOR_REVISION1 1
2852 #define SE_OWNER_DEFAULTED 0x0001
2853 #define SE_GROUP_DEFAULTED 0x0002
2854 #define SE_DACL_PRESENT 0x0004
2855 #define SE_DACL_DEFAULTED 0x0008
2856 #define SE_SACL_PRESENT 0x0010
2857 #define SE_SACL_DEFAULTED 0x0020
2858 #define SE_SELF_RELATIVE 0x8000
2860 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2861 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
2863 /* The security descriptor structure */
2864 typedef struct {
2865 BYTE Revision;
2866 BYTE Sbz1;
2867 SECURITY_DESCRIPTOR_CONTROL Control;
2868 DWORD Owner;
2869 DWORD Group;
2870 DWORD Sacl;
2871 DWORD Dacl;
2872 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
2874 typedef struct {
2875 BYTE Revision;
2876 BYTE Sbz1;
2877 SECURITY_DESCRIPTOR_CONTROL Control;
2878 PSID Owner;
2879 PSID Group;
2880 PACL Sacl;
2881 PACL Dacl;
2882 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
2884 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
2886 #endif /* _SECURITY_DEFINED */
2889 * SID_AND_ATTRIBUTES
2892 typedef struct _SID_AND_ATTRIBUTES {
2893 PSID Sid;
2894 DWORD Attributes;
2895 } SID_AND_ATTRIBUTES ;
2897 /* security entities */
2898 #define SECURITY_NULL_RID (0x00000000L)
2899 #define SECURITY_WORLD_RID (0x00000000L)
2900 #define SECURITY_LOCAL_RID (0X00000000L)
2902 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
2904 /* S-1-1 */
2905 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
2907 /* S-1-2 */
2908 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
2910 /* S-1-3 */
2911 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
2912 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
2913 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
2914 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
2915 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
2917 /* S-1-4 */
2918 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
2920 /* S-1-5 */
2921 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
2922 #define SECURITY_DIALUP_RID 0x00000001L
2923 #define SECURITY_NETWORK_RID 0x00000002L
2924 #define SECURITY_BATCH_RID 0x00000003L
2925 #define SECURITY_INTERACTIVE_RID 0x00000004L
2926 #define SECURITY_LOGON_IDS_RID 0x00000005L
2927 #define SECURITY_SERVICE_RID 0x00000006L
2928 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
2929 #define SECURITY_PROXY_RID 0x00000008L
2930 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
2931 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
2932 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
2933 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
2934 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
2935 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
2936 #define SECURITY_NT_NON_UNIQUE 0x00000015L
2937 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
2939 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
2940 #define DOMAIN_GROUP_RID_USERS 0x00000201L
2941 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
2943 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
2944 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
2945 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
2947 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
2949 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
2952 * TOKEN_USER
2955 typedef struct _TOKEN_USER {
2956 SID_AND_ATTRIBUTES User;
2957 } TOKEN_USER;
2960 * TOKEN_GROUPS
2963 typedef struct _TOKEN_GROUPS {
2964 DWORD GroupCount;
2965 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
2966 } TOKEN_GROUPS;
2969 * LUID_AND_ATTRIBUTES
2972 typedef union _LARGE_INTEGER {
2973 struct {
2974 #ifdef WORDS_BIGENDIAN
2975 LONG HighPart;
2976 DWORD LowPart;
2977 #else
2978 DWORD LowPart;
2979 LONG HighPart;
2980 #endif
2981 } DUMMYSTRUCTNAME;
2982 LONGLONG QuadPart;
2983 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
2985 typedef union _ULARGE_INTEGER {
2986 struct {
2987 #ifdef WORDS_BIGENDIAN
2988 DWORD HighPart;
2989 DWORD LowPart;
2990 #else
2991 DWORD LowPart;
2992 DWORD HighPart;
2993 #endif
2994 } DUMMYSTRUCTNAME;
2995 ULONGLONG QuadPart;
2996 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
2999 * Locally Unique Identifier
3002 typedef struct _LUID {
3003 DWORD LowPart;
3004 LONG HighPart;
3005 } LUID, *PLUID;
3007 #include "pshpack4.h"
3008 typedef struct _LUID_AND_ATTRIBUTES {
3009 LUID Luid;
3010 DWORD Attributes;
3011 } LUID_AND_ATTRIBUTES;
3012 #include "poppack.h"
3015 * PRIVILEGE_SET
3018 typedef struct _PRIVILEGE_SET {
3019 DWORD PrivilegeCount;
3020 DWORD Control;
3021 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
3022 } PRIVILEGE_SET, *PPRIVILEGE_SET;
3025 * TOKEN_PRIVILEGES
3028 typedef struct _TOKEN_PRIVILEGES {
3029 DWORD PrivilegeCount;
3030 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
3031 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
3034 * TOKEN_OWNER
3037 typedef struct _TOKEN_OWNER {
3038 PSID Owner;
3039 } TOKEN_OWNER;
3042 * TOKEN_PRIMARY_GROUP
3045 typedef struct _TOKEN_PRIMARY_GROUP {
3046 PSID PrimaryGroup;
3047 } TOKEN_PRIMARY_GROUP;
3051 * TOKEN_DEFAULT_DACL
3054 typedef struct _TOKEN_DEFAULT_DACL {
3055 PACL DefaultDacl;
3056 } TOKEN_DEFAULT_DACL;
3059 * TOKEN_SOURCEL
3062 typedef struct _TOKEN_SOURCE {
3063 char Sourcename[8];
3064 LUID SourceIdentifier;
3065 } TOKEN_SOURCE;
3068 * TOKEN_TYPE
3071 typedef enum tagTOKEN_TYPE {
3072 TokenPrimary = 1,
3073 TokenImpersonation
3074 } TOKEN_TYPE;
3077 * SECURITY_IMPERSONATION_LEVEL
3080 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3081 SecurityAnonymous,
3082 SecurityIdentification,
3083 SecurityImpersonation,
3084 SecurityDelegation
3085 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
3088 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3089 * PSECURITY_CONTEXT_TRACKING_MODE;
3091 * Quality of Service
3094 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3095 DWORD Length;
3096 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3097 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3098 BOOLEAN EffectiveOnly;
3099 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3102 * TOKEN_STATISTICS
3105 typedef struct _TOKEN_STATISTICS {
3106 LUID TokenId;
3107 LUID AuthenticationId;
3108 LARGE_INTEGER ExpirationTime;
3109 TOKEN_TYPE TokenType;
3110 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3111 DWORD DynamicCharged;
3112 DWORD DynamicAvailable;
3113 DWORD GroupCount;
3114 DWORD PrivilegeCount;
3115 LUID ModifiedId;
3116 } TOKEN_STATISTICS;
3119 * ACLs of NT
3122 #define ACL_REVISION 2
3124 #define ACL_REVISION1 1
3125 #define ACL_REVISION2 2
3127 /* ACEs, directly starting after an ACL */
3128 typedef struct _ACE_HEADER {
3129 BYTE AceType;
3130 BYTE AceFlags;
3131 WORD AceSize;
3132 } ACE_HEADER,*PACE_HEADER;
3134 /* AceType */
3135 #define ACCESS_ALLOWED_ACE_TYPE 0
3136 #define ACCESS_DENIED_ACE_TYPE 1
3137 #define SYSTEM_AUDIT_ACE_TYPE 2
3138 #define SYSTEM_ALARM_ACE_TYPE 3
3140 /* inherit AceFlags */
3141 #define OBJECT_INHERIT_ACE 0x01
3142 #define CONTAINER_INHERIT_ACE 0x02
3143 #define NO_PROPAGATE_INHERIT_ACE 0x04
3144 #define INHERIT_ONLY_ACE 0x08
3145 #define VALID_INHERIT_FLAGS 0x0F
3147 /* AceFlags mask for what events we (should) audit */
3148 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
3149 #define FAILED_ACCESS_ACE_FLAG 0x80
3151 /* different ACEs depending on AceType
3152 * SidStart marks the begin of a SID
3153 * so the thing finally looks like this:
3154 * 0: ACE_HEADER
3155 * 4: ACCESS_MASK
3156 * 8... : SID
3158 typedef struct _ACCESS_ALLOWED_ACE {
3159 ACE_HEADER Header;
3160 DWORD Mask;
3161 DWORD SidStart;
3162 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3164 typedef struct _ACCESS_DENIED_ACE {
3165 ACE_HEADER Header;
3166 DWORD Mask;
3167 DWORD SidStart;
3168 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3170 typedef struct _SYSTEM_AUDIT_ACE {
3171 ACE_HEADER Header;
3172 DWORD Mask;
3173 DWORD SidStart;
3174 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3176 typedef struct _SYSTEM_ALARM_ACE {
3177 ACE_HEADER Header;
3178 DWORD Mask;
3179 DWORD SidStart;
3180 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3182 typedef enum tagSID_NAME_USE {
3183 SidTypeUser = 1,
3184 SidTypeGroup,
3185 SidTypeDomain,
3186 SidTypeAlias,
3187 SidTypeWellKnownGroup,
3188 SidTypeDeletedAccount,
3189 SidTypeInvalid,
3190 SidTypeUnknown
3191 } SID_NAME_USE,*PSID_NAME_USE;
3193 /* Access rights */
3195 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3196 #undef DELETE
3197 #define DELETE 0x00010000
3198 #define READ_CONTROL 0x00020000
3199 #define WRITE_DAC 0x00040000
3200 #define WRITE_OWNER 0x00080000
3201 #define SYNCHRONIZE 0x00100000
3202 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
3204 #define STANDARD_RIGHTS_READ READ_CONTROL
3205 #define STANDARD_RIGHTS_WRITE READ_CONTROL
3206 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
3208 #define STANDARD_RIGHTS_ALL 0x001f0000
3210 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
3212 #define GENERIC_READ 0x80000000
3213 #define GENERIC_WRITE 0x40000000
3214 #define GENERIC_EXECUTE 0x20000000
3215 #define GENERIC_ALL 0x10000000
3217 #define MAXIMUM_ALLOWED 0x02000000
3218 #define ACCESS_SYSTEM_SECURITY 0x01000000
3220 #define EVENT_MODIFY_STATE 0x0002
3221 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3223 #define SEMAPHORE_MODIFY_STATE 0x0002
3224 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3226 #define MUTEX_MODIFY_STATE 0x0001
3227 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3229 #define TIMER_QUERY_STATE 0x0001
3230 #define TIMER_MODIFY_STATE 0x0002
3231 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3233 #define PROCESS_TERMINATE 0x0001
3234 #define PROCESS_CREATE_THREAD 0x0002
3235 #define PROCESS_VM_OPERATION 0x0008
3236 #define PROCESS_VM_READ 0x0010
3237 #define PROCESS_VM_WRITE 0x0020
3238 #define PROCESS_DUP_HANDLE 0x0040
3239 #define PROCESS_CREATE_PROCESS 0x0080
3240 #define PROCESS_SET_QUOTA 0x0100
3241 #define PROCESS_SET_INFORMATION 0x0200
3242 #define PROCESS_QUERY_INFORMATION 0x0400
3243 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3245 #define THREAD_TERMINATE 0x0001
3246 #define THREAD_SUSPEND_RESUME 0x0002
3247 #define THREAD_GET_CONTEXT 0x0008
3248 #define THREAD_SET_CONTEXT 0x0010
3249 #define THREAD_SET_INFORMATION 0x0020
3250 #define THREAD_QUERY_INFORMATION 0x0040
3251 #define THREAD_SET_THREAD_TOKEN 0x0080
3252 #define THREAD_IMPERSONATE 0x0100
3253 #define THREAD_DIRECT_IMPERSONATION 0x0200
3254 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3256 #define THREAD_BASE_PRIORITY_LOWRT 15
3257 #define THREAD_BASE_PRIORITY_MAX 2
3258 #define THREAD_BASE_PRIORITY_MIN -2
3259 #define THREAD_BASE_PRIORITY_IDLE -15
3261 #define SECTION_QUERY 0x0001
3262 #define SECTION_MAP_WRITE 0x0002
3263 #define SECTION_MAP_READ 0x0004
3264 #define SECTION_MAP_EXECUTE 0x0008
3265 #define SECTION_EXTEND_SIZE 0x0010
3266 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
3268 #define FILE_READ_DATA 0x0001 /* file & pipe */
3269 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
3270 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
3271 #define FILE_ADD_FILE 0x0002 /* directory */
3272 #define FILE_APPEND_DATA 0x0004 /* file */
3273 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
3274 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
3275 #define FILE_READ_EA 0x0008 /* file & directory */
3276 #define FILE_READ_PROPERTIES FILE_READ_EA
3277 #define FILE_WRITE_EA 0x0010 /* file & directory */
3278 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
3279 #define FILE_EXECUTE 0x0020 /* file */
3280 #define FILE_TRAVERSE 0x0020 /* directory */
3281 #define FILE_DELETE_CHILD 0x0040 /* directory */
3282 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
3283 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
3284 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3286 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3287 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3288 SYNCHRONIZE)
3289 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3290 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3291 FILE_APPEND_DATA | SYNCHRONIZE)
3292 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3293 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3296 /* File attribute flags */
3297 #define FILE_SHARE_READ 0x00000001L
3298 #define FILE_SHARE_WRITE 0x00000002L
3299 #define FILE_SHARE_DELETE 0x00000004L
3300 #define FILE_ATTRIBUTE_READONLY 0x00000001L
3301 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
3302 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
3303 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
3304 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
3305 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
3306 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
3307 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
3308 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
3309 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
3310 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
3311 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
3312 #define FILE_ATTRIBUTE_SYMLINK 0x80000000L /* Not in Windows API */
3314 /* File notification flags */
3315 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
3316 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
3317 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
3318 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
3319 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
3320 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
3321 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
3322 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
3324 #define FILE_ACTION_ADDED 0x00000001
3325 #define FILE_ACTION_REMOVED 0x00000002
3326 #define FILE_ACTION_MODIFIED 0x00000003
3327 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
3328 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
3331 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
3332 #define FILE_CASE_PRESERVED_NAMES 0x00000002
3333 #define FILE_UNICODE_ON_DISK 0x00000004
3334 #define FILE_PERSISTENT_ACLS 0x00000008
3335 #define FILE_FILE_COMPRESSION 0x00000010
3336 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
3338 /* File alignments (NT) */
3339 #define FILE_BYTE_ALIGNMENT 0x00000000
3340 #define FILE_WORD_ALIGNMENT 0x00000001
3341 #define FILE_LONG_ALIGNMENT 0x00000003
3342 #define FILE_QUAD_ALIGNMENT 0x00000007
3343 #define FILE_OCTA_ALIGNMENT 0x0000000f
3344 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
3345 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
3346 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
3347 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
3348 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
3350 #define REG_NONE 0 /* no type */
3351 #define REG_SZ 1 /* string type (ASCII) */
3352 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3353 #define REG_BINARY 3 /* binary format, callerspecific */
3354 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3355 #define REG_DWORD 4 /* DWORD in little endian format */
3356 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
3357 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
3358 #define REG_LINK 6 /* symbolic link (UNICODE) */
3359 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3360 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
3361 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
3362 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3364 /* ----------------------------- begin registry ----------------------------- */
3366 /* Registry security values */
3367 #define OWNER_SECURITY_INFORMATION 0x00000001
3368 #define GROUP_SECURITY_INFORMATION 0x00000002
3369 #define DACL_SECURITY_INFORMATION 0x00000004
3370 #define SACL_SECURITY_INFORMATION 0x00000008
3372 #define REG_OPTION_RESERVED 0x00000000
3373 #define REG_OPTION_NON_VOLATILE 0x00000000
3374 #define REG_OPTION_VOLATILE 0x00000001
3375 #define REG_OPTION_CREATE_LINK 0x00000002
3376 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
3377 #define REG_OPTION_OPEN_LINK 0x00000008
3378 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
3379 REG_OPTION_NON_VOLATILE| \
3380 REG_OPTION_VOLATILE| \
3381 REG_OPTION_CREATE_LINK| \
3382 REG_OPTION_BACKUP_RESTORE| \
3383 REG_OPTION_OPEN_LINK)
3386 #define REG_CREATED_NEW_KEY 0x00000001
3387 #define REG_OPENED_EXISTING_KEY 0x00000002
3389 /* For RegNotifyChangeKeyValue */
3390 #define REG_NOTIFY_CHANGE_NAME 0x1
3392 #define KEY_QUERY_VALUE 0x00000001
3393 #define KEY_SET_VALUE 0x00000002
3394 #define KEY_CREATE_SUB_KEY 0x00000004
3395 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
3396 #define KEY_NOTIFY 0x00000010
3397 #define KEY_CREATE_LINK 0x00000020
3399 #define KEY_READ ((STANDARD_RIGHTS_READ| \
3400 KEY_QUERY_VALUE| \
3401 KEY_ENUMERATE_SUB_KEYS| \
3402 KEY_NOTIFY) \
3403 & (~SYNCHRONIZE) \
3405 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
3406 KEY_SET_VALUE| \
3407 KEY_CREATE_SUB_KEY) \
3408 & (~SYNCHRONIZE) \
3410 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
3411 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
3412 KEY_QUERY_VALUE| \
3413 KEY_SET_VALUE| \
3414 KEY_CREATE_SUB_KEY| \
3415 KEY_ENUMERATE_SUB_KEYS| \
3416 KEY_NOTIFY| \
3417 KEY_CREATE_LINK) \
3418 & (~SYNCHRONIZE) \
3420 /* ------------------------------ end registry ------------------------------ */
3423 #define EVENTLOG_SUCCESS 0x0000
3424 #define EVENTLOG_ERROR_TYPE 0x0001
3425 #define EVENTLOG_WARNING_TYPE 0x0002
3426 #define EVENTLOG_INFORMATION_TYPE 0x0004
3427 #define EVENTLOG_AUDIT_SUCCESS 0x0008
3428 #define EVENTLOG_AUDIT_FAILURE 0x0010
3430 #define SERVICE_BOOT_START 0x00000000
3431 #define SERVICE_SYSTEM_START 0x00000001
3432 #define SERVICE_AUTO_START 0x00000002
3433 #define SERVICE_DEMAND_START 0x00000003
3434 #define SERVICE_DISABLED 0x00000004
3436 #define SERVICE_ERROR_IGNORE 0x00000000
3437 #define SERVICE_ERROR_NORMAL 0x00000001
3438 #define SERVICE_ERROR_SEVERE 0x00000002
3439 #define SERVICE_ERROR_CRITICAL 0x00000003
3441 /* Service types */
3442 #define SERVICE_KERNEL_DRIVER 0x00000001
3443 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
3444 #define SERVICE_ADAPTER 0x00000004
3445 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
3447 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
3448 SERVICE_RECOGNIZER_DRIVER )
3450 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
3451 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
3452 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
3454 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
3456 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
3457 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
3460 typedef enum _CM_SERVICE_NODE_TYPE
3462 DriverType = SERVICE_KERNEL_DRIVER,
3463 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
3464 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
3465 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3466 AdapterType = SERVICE_ADAPTER,
3467 RecognizerType = SERVICE_RECOGNIZER_DRIVER
3468 } SERVICE_NODE_TYPE;
3470 typedef enum _CM_SERVICE_LOAD_TYPE
3472 BootLoad = SERVICE_BOOT_START,
3473 SystemLoad = SERVICE_SYSTEM_START,
3474 AutoLoad = SERVICE_AUTO_START,
3475 DemandLoad = SERVICE_DEMAND_START,
3476 DisableLoad = SERVICE_DISABLED
3477 } SERVICE_LOAD_TYPE;
3479 typedef enum _CM_ERROR_CONTROL_TYPE
3481 IgnoreError = SERVICE_ERROR_IGNORE,
3482 NormalError = SERVICE_ERROR_NORMAL,
3483 SevereError = SERVICE_ERROR_SEVERE,
3484 CriticalError = SERVICE_ERROR_CRITICAL
3485 } SERVICE_ERROR_TYPE;
3489 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
3490 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
3491 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
3492 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
3493 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
3495 #include "guiddef.h"
3497 typedef struct _RTL_CRITICAL_SECTION_DEBUG
3499 WORD Type;
3500 WORD CreatorBackTraceIndex;
3501 struct _RTL_CRITICAL_SECTION *CriticalSection;
3502 LIST_ENTRY ProcessLocksList;
3503 DWORD EntryCount;
3504 DWORD ContentionCount;
3505 DWORD Spare[ 2 ];
3506 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
3508 typedef struct _RTL_CRITICAL_SECTION {
3509 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
3510 LONG LockCount;
3511 LONG RecursionCount;
3512 HANDLE OwningThread;
3513 HANDLE LockSemaphore;
3514 ULONG_PTR SpinCount;
3515 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
3517 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
3519 #endif /* __WINE_WINNT_H */