Alpha porting fixes.
[wine/wine-kai.git] / include / winnt.h
blobed70ef1fe3cbfaa15e6b6263ca49f549ba893a59
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 2.96 */
239 # if !defined(NONAMELESSSTRUCT) && (defined(__GNUC__) && (defined(__cplusplus) || ((__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 typedef void *HANDLE;
543 typedef HANDLE *PHANDLE, *LPHANDLE;
545 #if (defined(STRICT) || defined(__WINE__))
546 #define DECLARE_HANDLE(a) \
547 typedef struct a##__ { int unused; } *a; \
548 typedef a *P##a
549 #else /*STRICT*/
550 #define DECLARE_HANDLE(a) \
551 typedef HANDLE a; \
552 typedef a *P##a
553 #endif /*STRICT*/
555 /* Defines */
557 /* Argument 1 passed to the DllEntryProc. */
558 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
559 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
560 #define DLL_THREAD_ATTACH 2 /* attach new thread */
561 #define DLL_THREAD_DETACH 3 /* detach thread */
564 /* u.x.wProcessorArchitecture (NT) */
565 #define PROCESSOR_ARCHITECTURE_INTEL 0
566 #define PROCESSOR_ARCHITECTURE_MIPS 1
567 #define PROCESSOR_ARCHITECTURE_ALPHA 2
568 #define PROCESSOR_ARCHITECTURE_PPC 3
569 #define PROCESSOR_ARCHITECTURE_SHX 4
570 #define PROCESSOR_ARCHITECTURE_ARM 5
571 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
573 /* dwProcessorType */
574 #define PROCESSOR_INTEL_386 386
575 #define PROCESSOR_INTEL_486 486
576 #define PROCESSOR_INTEL_PENTIUM 586
577 #define PROCESSOR_INTEL_860 860
578 #define PROCESSOR_MIPS_R2000 2000
579 #define PROCESSOR_MIPS_R3000 3000
580 #define PROCESSOR_MIPS_R4000 4000
581 #define PROCESSOR_ALPHA_21064 21064
582 #define PROCESSOR_PPC_601 601
583 #define PROCESSOR_PPC_603 603
584 #define PROCESSOR_PPC_604 604
585 #define PROCESSOR_PPC_620 620
586 #define PROCESSOR_HITACHI_SH3 10003
587 #define PROCESSOR_HITACHI_SH3E 10004
588 #define PROCESSOR_HITACHI_SH4 10005
589 #define PROCESSOR_MOTOROLA_821 821
590 #define PROCESSOR_SHx_SH3 103
591 #define PROCESSOR_SHx_SH4 104
592 #define PROCESSOR_STRONGARM 2577
593 #define PROCESSOR_ARM720 1824 /* 0x720 */
594 #define PROCESSOR_ARM820 2080 /* 0x820 */
595 #define PROCESSOR_ARM920 2336 /* 0x920 */
596 #define PROCESSOR_ARM_7TDMI 70001
598 #define MAXIMUM_PROCESSORS 32
599 typedef struct _MEMORY_BASIC_INFORMATION
601 LPVOID BaseAddress;
602 LPVOID AllocationBase;
603 DWORD AllocationProtect;
604 DWORD RegionSize;
605 DWORD State;
606 DWORD Protect;
607 DWORD Type;
608 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
610 #define PAGE_NOACCESS 0x01
611 #define PAGE_READONLY 0x02
612 #define PAGE_READWRITE 0x04
613 #define PAGE_WRITECOPY 0x08
614 #define PAGE_EXECUTE 0x10
615 #define PAGE_EXECUTE_READ 0x20
616 #define PAGE_EXECUTE_READWRITE 0x40
617 #define PAGE_EXECUTE_WRITECOPY 0x80
618 #define PAGE_GUARD 0x100
619 #define PAGE_NOCACHE 0x200
621 #define MEM_COMMIT 0x00001000
622 #define MEM_RESERVE 0x00002000
623 #define MEM_DECOMMIT 0x00004000
624 #define MEM_RELEASE 0x00008000
625 #define MEM_FREE 0x00010000
626 #define MEM_PRIVATE 0x00020000
627 #define MEM_MAPPED 0x00040000
628 #define MEM_RESET 0x00080000
629 #define MEM_TOP_DOWN 0x00100000
630 #ifdef __WINE__
631 #define MEM_SYSTEM 0x80000000
632 #endif
634 #define SEC_FILE 0x00800000
635 #define SEC_IMAGE 0x01000000
636 #define SEC_RESERVE 0x04000000
637 #define SEC_COMMIT 0x08000000
638 #define SEC_NOCACHE 0x10000000
639 #define MEM_IMAGE SEC_IMAGE
642 #define MINCHAR 0x80
643 #define MAXCHAR 0x7f
644 #define MINSHORT 0x8000
645 #define MAXSHORT 0x7fff
646 #define MINLONG 0x80000000
647 #define MAXLONG 0x7fffffff
648 #define MAXBYTE 0xff
649 #define MAXWORD 0xffff
650 #define MAXDWORD 0xffffffff
652 #define FIELD_OFFSET(type, field) \
653 ((LONG)(INT)&(((type *)0)->field))
655 #define CONTAINING_RECORD(address, type, field) \
656 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
658 /* Types */
660 typedef struct _LIST_ENTRY {
661 struct _LIST_ENTRY *Flink;
662 struct _LIST_ENTRY *Blink;
663 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
665 typedef struct _SINGLE_LIST_ENTRY {
666 struct _SINGLE_LIST_ENTRY *Next;
667 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
669 /* Heap flags */
671 #define HEAP_NO_SERIALIZE 0x00000001
672 #define HEAP_GROWABLE 0x00000002
673 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
674 #define HEAP_ZERO_MEMORY 0x00000008
675 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
676 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
677 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
678 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
679 #define HEAP_CREATE_ALIGN_16 0x00010000
680 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
682 /* This flag allows it to create heaps shared by all processes under win95,
683 FIXME: correct name */
684 #define HEAP_SHARED 0x04000000
686 /* Processor feature flags. */
687 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
688 #define PF_FLOATING_POINT_EMULATED 1
689 #define PF_COMPARE_EXCHANGE_DOUBLE 2
690 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
691 #define PF_PPC_MOVEMEM_64BIT_OK 4
692 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
693 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
694 #define PF_AMD3D_INSTRUCTIONS_AVAILABLE 7
695 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
698 /* Execution state flags */
699 #define ES_SYSTEM_REQUIRED 0x00000001
700 #define ES_DISPLAY_REQUIRED 0x00000002
701 #define ES_USER_PRESENT 0x00000004
702 #define ES_CONTINUOUS 0x80000000
704 /* The Win32 register context */
706 /* CONTEXT is the CPU-dependent context; it should be used */
707 /* wherever a platform-specific context is needed (e.g. exception */
708 /* handling, Win32 register functions). */
710 /* CONTEXT86 is the i386-specific context; it should be used */
711 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
712 /* Win16 register functions), so that this code can be compiled */
713 /* on all platforms. */
715 #define SIZE_OF_80387_REGISTERS 80
717 typedef struct _FLOATING_SAVE_AREA
719 DWORD ControlWord;
720 DWORD StatusWord;
721 DWORD TagWord;
722 DWORD ErrorOffset;
723 DWORD ErrorSelector;
724 DWORD DataOffset;
725 DWORD DataSelector;
726 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
727 DWORD Cr0NpxState;
728 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
730 #define MAXIMUM_SUPPORTED_EXTENSION 512
732 typedef struct _CONTEXT86
734 DWORD ContextFlags;
736 /* These are selected by CONTEXT_DEBUG_REGISTERS */
737 DWORD Dr0;
738 DWORD Dr1;
739 DWORD Dr2;
740 DWORD Dr3;
741 DWORD Dr6;
742 DWORD Dr7;
744 /* These are selected by CONTEXT_FLOATING_POINT */
745 FLOATING_SAVE_AREA FloatSave;
747 /* These are selected by CONTEXT_SEGMENTS */
748 DWORD SegGs;
749 DWORD SegFs;
750 DWORD SegEs;
751 DWORD SegDs;
753 /* These are selected by CONTEXT_INTEGER */
754 DWORD Edi;
755 DWORD Esi;
756 DWORD Ebx;
757 DWORD Edx;
758 DWORD Ecx;
759 DWORD Eax;
761 /* These are selected by CONTEXT_CONTROL */
762 DWORD Ebp;
763 DWORD Eip;
764 DWORD SegCs;
765 DWORD EFlags;
766 DWORD Esp;
767 DWORD SegSs;
769 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
770 } CONTEXT86;
772 #define CONTEXT_X86 0x00010000
773 #define CONTEXT_i386 CONTEXT_X86
774 #define CONTEXT_i486 CONTEXT_X86
776 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
777 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
778 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
779 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
780 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
781 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
783 /* i386 context definitions */
784 #ifdef __i386__
786 #define CONTEXT_CONTROL CONTEXT86_CONTROL
787 #define CONTEXT_INTEGER CONTEXT86_INTEGER
788 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
789 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
790 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
791 #define CONTEXT_FULL CONTEXT86_FULL
793 typedef CONTEXT86 CONTEXT;
795 #endif /* __i386__ */
797 /* Alpha context definitions */
798 #ifdef _ALPHA_
800 #define CONTEXT_ALPHA 0x00020000
802 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
803 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
804 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
805 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
807 typedef struct _CONTEXT
809 /* selected by CONTEXT_FLOATING_POINT */
810 ULONGLONG FltF0;
811 ULONGLONG FltF1;
812 ULONGLONG FltF2;
813 ULONGLONG FltF3;
814 ULONGLONG FltF4;
815 ULONGLONG FltF5;
816 ULONGLONG FltF6;
817 ULONGLONG FltF7;
818 ULONGLONG FltF8;
819 ULONGLONG FltF9;
820 ULONGLONG FltF10;
821 ULONGLONG FltF11;
822 ULONGLONG FltF12;
823 ULONGLONG FltF13;
824 ULONGLONG FltF14;
825 ULONGLONG FltF15;
826 ULONGLONG FltF16;
827 ULONGLONG FltF17;
828 ULONGLONG FltF18;
829 ULONGLONG FltF19;
830 ULONGLONG FltF20;
831 ULONGLONG FltF21;
832 ULONGLONG FltF22;
833 ULONGLONG FltF23;
834 ULONGLONG FltF24;
835 ULONGLONG FltF25;
836 ULONGLONG FltF26;
837 ULONGLONG FltF27;
838 ULONGLONG FltF28;
839 ULONGLONG FltF29;
840 ULONGLONG FltF30;
841 ULONGLONG FltF31;
843 /* selected by CONTEXT_INTEGER */
844 ULONGLONG IntV0;
845 ULONGLONG IntT0;
846 ULONGLONG IntT1;
847 ULONGLONG IntT2;
848 ULONGLONG IntT3;
849 ULONGLONG IntT4;
850 ULONGLONG IntT5;
851 ULONGLONG IntT6;
852 ULONGLONG IntT7;
853 ULONGLONG IntS0;
854 ULONGLONG IntS1;
855 ULONGLONG IntS2;
856 ULONGLONG IntS3;
857 ULONGLONG IntS4;
858 ULONGLONG IntS5;
859 ULONGLONG IntFp;
860 ULONGLONG IntA0;
861 ULONGLONG IntA1;
862 ULONGLONG IntA2;
863 ULONGLONG IntA3;
864 ULONGLONG IntA4;
865 ULONGLONG IntA5;
866 ULONGLONG IntT8;
867 ULONGLONG IntT9;
868 ULONGLONG IntT10;
869 ULONGLONG IntT11;
870 ULONGLONG IntRa;
871 ULONGLONG IntT12;
872 ULONGLONG IntAt;
873 ULONGLONG IntGp;
874 ULONGLONG IntSp;
875 ULONGLONG IntZero;
877 /* selected by CONTEXT_FLOATING_POINT */
878 ULONGLONG Fpcr;
879 ULONGLONG SoftFpcr;
881 /* selected by CONTEXT_CONTROL */
882 ULONGLONG Fir;
883 DWORD Psr;
884 DWORD ContextFlags;
885 DWORD Fill[4];
886 } CONTEXT;
888 #define _QUAD_PSR_OFFSET HighSoftFpcr
889 #define _QUAD_FLAGS_OFFSET HighFir
891 #endif /* _ALPHA_ */
893 /* Mips context definitions */
894 #ifdef _MIPS_
896 #define CONTEXT_R4000 0x00010000
898 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
899 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
900 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
902 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
904 typedef struct _CONTEXT
906 DWORD Argument[4];
907 /* These are selected by CONTEXT_FLOATING_POINT */
908 DWORD FltF0;
909 DWORD FltF1;
910 DWORD FltF2;
911 DWORD FltF3;
912 DWORD FltF4;
913 DWORD FltF5;
914 DWORD FltF6;
915 DWORD FltF7;
916 DWORD FltF8;
917 DWORD FltF9;
918 DWORD FltF10;
919 DWORD FltF11;
920 DWORD FltF12;
921 DWORD FltF13;
922 DWORD FltF14;
923 DWORD FltF15;
924 DWORD FltF16;
925 DWORD FltF17;
926 DWORD FltF18;
927 DWORD FltF19;
928 DWORD FltF20;
929 DWORD FltF21;
930 DWORD FltF22;
931 DWORD FltF23;
932 DWORD FltF24;
933 DWORD FltF25;
934 DWORD FltF26;
935 DWORD FltF27;
936 DWORD FltF28;
937 DWORD FltF29;
938 DWORD FltF30;
939 DWORD FltF31;
941 /* These are selected by CONTEXT_INTEGER */
942 DWORD IntZero;
943 DWORD IntAt;
944 DWORD IntV0;
945 DWORD IntV1;
946 DWORD IntA0;
947 DWORD IntA1;
948 DWORD IntA2;
949 DWORD IntA3;
950 DWORD IntT0;
951 DWORD IntT1;
952 DWORD IntT2;
953 DWORD IntT3;
954 DWORD IntT4;
955 DWORD IntT5;
956 DWORD IntT6;
957 DWORD IntT7;
958 DWORD IntS0;
959 DWORD IntS1;
960 DWORD IntS2;
961 DWORD IntS3;
962 DWORD IntS4;
963 DWORD IntS5;
964 DWORD IntS6;
965 DWORD IntS7;
966 DWORD IntT8;
967 DWORD IntT9;
968 DWORD IntK0;
969 DWORD IntK1;
970 DWORD IntGp;
971 DWORD IntSp;
972 DWORD IntS8;
973 DWORD IntRa;
974 DWORD IntLo;
975 DWORD IntHi;
977 /* These are selected by CONTEXT_FLOATING_POINT */
978 DWORD Fsr;
980 /* These are selected by CONTEXT_CONTROL */
981 DWORD Fir;
982 DWORD Psr;
984 DWORD ContextFlags;
985 DWORD Fill[2];
986 } CONTEXT;
988 #endif /* _MIPS_ */
990 /* PowerPC context definitions */
991 #ifdef __PPC__
993 #define CONTEXT_CONTROL 0x0001
994 #define CONTEXT_FLOATING_POINT 0x0002
995 #define CONTEXT_INTEGER 0x0004
996 #define CONTEXT_DEBUG_REGISTERS 0x0008
997 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
999 typedef struct
1001 /* These are selected by CONTEXT_FLOATING_POINT */
1002 double Fpr0;
1003 double Fpr1;
1004 double Fpr2;
1005 double Fpr3;
1006 double Fpr4;
1007 double Fpr5;
1008 double Fpr6;
1009 double Fpr7;
1010 double Fpr8;
1011 double Fpr9;
1012 double Fpr10;
1013 double Fpr11;
1014 double Fpr12;
1015 double Fpr13;
1016 double Fpr14;
1017 double Fpr15;
1018 double Fpr16;
1019 double Fpr17;
1020 double Fpr18;
1021 double Fpr19;
1022 double Fpr20;
1023 double Fpr21;
1024 double Fpr22;
1025 double Fpr23;
1026 double Fpr24;
1027 double Fpr25;
1028 double Fpr26;
1029 double Fpr27;
1030 double Fpr28;
1031 double Fpr29;
1032 double Fpr30;
1033 double Fpr31;
1034 double Fpscr;
1036 /* These are selected by CONTEXT_INTEGER */
1037 DWORD Gpr0;
1038 DWORD Gpr1;
1039 DWORD Gpr2;
1040 DWORD Gpr3;
1041 DWORD Gpr4;
1042 DWORD Gpr5;
1043 DWORD Gpr6;
1044 DWORD Gpr7;
1045 DWORD Gpr8;
1046 DWORD Gpr9;
1047 DWORD Gpr10;
1048 DWORD Gpr11;
1049 DWORD Gpr12;
1050 DWORD Gpr13;
1051 DWORD Gpr14;
1052 DWORD Gpr15;
1053 DWORD Gpr16;
1054 DWORD Gpr17;
1055 DWORD Gpr18;
1056 DWORD Gpr19;
1057 DWORD Gpr20;
1058 DWORD Gpr21;
1059 DWORD Gpr22;
1060 DWORD Gpr23;
1061 DWORD Gpr24;
1062 DWORD Gpr25;
1063 DWORD Gpr26;
1064 DWORD Gpr27;
1065 DWORD Gpr28;
1066 DWORD Gpr29;
1067 DWORD Gpr30;
1068 DWORD Gpr31;
1070 DWORD Cr;
1071 DWORD Xer;
1073 /* These are selected by CONTEXT_CONTROL */
1074 DWORD Msr;
1075 DWORD Iar; /* Instruction Address Register , aka PC ... */
1076 DWORD Lr;
1077 DWORD Ctr;
1079 DWORD ContextFlags;
1080 DWORD Fill[3];
1082 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1083 DWORD Dr0;
1084 DWORD Dr1;
1085 DWORD Dr2;
1086 DWORD Dr3;
1087 DWORD Dr4;
1088 DWORD Dr5;
1089 DWORD Dr6;
1090 DWORD Dr7;
1091 } CONTEXT;
1093 typedef struct _STACK_FRAME_HEADER
1095 DWORD BackChain;
1096 DWORD GlueSaved1;
1097 DWORD GlueSaved2;
1098 DWORD Reserved1;
1099 DWORD Spare1;
1100 DWORD Spare2;
1102 DWORD Parameter0;
1103 DWORD Parameter1;
1104 DWORD Parameter2;
1105 DWORD Parameter3;
1106 DWORD Parameter4;
1107 DWORD Parameter5;
1108 DWORD Parameter6;
1109 DWORD Parameter7;
1110 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
1112 #endif /* __PPC__ */
1114 #ifdef __ALPHA__
1117 * FIXME:
1119 * I have no idea if any of this is right as I just ripped
1120 * it from mingw-win32api.
1124 #define CONTEXT_ALPHA 0x20000
1125 #define CONTEXT_CONTROL (CONTEXT_ALPHA|1L)
1126 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA|2L)
1127 #define CONTEXT_INTEGER (CONTEXT_ALPHA|4L)
1128 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_FLOATING_POINT|CONTEXT_INTEGER)
1129 typedef struct _CONTEXT {
1130 ULONGLONG FltF0;
1131 ULONGLONG FltF1;
1132 ULONGLONG FltF2;
1133 ULONGLONG FltF3;
1134 ULONGLONG FltF4;
1135 ULONGLONG FltF5;
1136 ULONGLONG FltF6;
1137 ULONGLONG FltF7;
1138 ULONGLONG FltF8;
1139 ULONGLONG FltF9;
1140 ULONGLONG FltF10;
1141 ULONGLONG FltF11;
1142 ULONGLONG FltF12;
1143 ULONGLONG FltF13;
1144 ULONGLONG FltF14;
1145 ULONGLONG FltF15;
1146 ULONGLONG FltF16;
1147 ULONGLONG FltF17;
1148 ULONGLONG FltF18;
1149 ULONGLONG FltF19;
1150 ULONGLONG FltF20;
1151 ULONGLONG FltF21;
1152 ULONGLONG FltF22;
1153 ULONGLONG FltF23;
1154 ULONGLONG FltF24;
1155 ULONGLONG FltF25;
1156 ULONGLONG FltF26;
1157 ULONGLONG FltF27;
1158 ULONGLONG FltF28;
1159 ULONGLONG FltF29;
1160 ULONGLONG FltF30;
1161 ULONGLONG FltF31;
1162 ULONGLONG IntV0;
1163 ULONGLONG IntT0;
1164 ULONGLONG IntT1;
1165 ULONGLONG IntT2;
1166 ULONGLONG IntT3;
1167 ULONGLONG IntT4;
1168 ULONGLONG IntT5;
1169 ULONGLONG IntT6;
1170 ULONGLONG IntT7;
1171 ULONGLONG IntS0;
1172 ULONGLONG IntS1;
1173 ULONGLONG IntS2;
1174 ULONGLONG IntS3;
1175 ULONGLONG IntS4;
1176 ULONGLONG IntS5;
1177 ULONGLONG IntFp;
1178 ULONGLONG IntA0;
1179 ULONGLONG IntA1;
1180 ULONGLONG IntA2;
1181 ULONGLONG IntA3;
1182 ULONGLONG IntA4;
1183 ULONGLONG IntA5;
1184 ULONGLONG IntT8;
1185 ULONGLONG IntT9;
1186 ULONGLONG IntT10;
1187 ULONGLONG IntT11;
1188 ULONGLONG IntRa;
1189 ULONGLONG IntT12;
1190 ULONGLONG IntAt;
1191 ULONGLONG IntGp;
1192 ULONGLONG IntSp;
1193 ULONGLONG IntZero;
1194 ULONGLONG Fpcr;
1195 ULONGLONG SoftFpcr;
1196 ULONGLONG Fir;
1197 DWORD Psr;
1198 DWORD ContextFlags;
1199 DWORD Fill[4];
1200 } CONTEXT;
1202 #endif /* __ALPHA__ */
1204 #ifdef __sparc__
1207 * FIXME:
1209 * There is no official CONTEXT structure defined for the SPARC
1210 * architecture, so I just made one up.
1212 * This structure is valid only for 32-bit SPARC architectures,
1213 * not for 64-bit SPARC.
1215 * Note that this structure contains only the 'top-level' registers;
1216 * the rest of the register window chain is not visible.
1218 * The layout follows the Solaris 'prgregset_t' structure.
1222 #define CONTEXT_SPARC 0x10000000
1224 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
1225 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
1226 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
1228 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1230 typedef struct _CONTEXT
1232 DWORD ContextFlags;
1234 /* These are selected by CONTEXT_INTEGER */
1235 DWORD g0;
1236 DWORD g1;
1237 DWORD g2;
1238 DWORD g3;
1239 DWORD g4;
1240 DWORD g5;
1241 DWORD g6;
1242 DWORD g7;
1243 DWORD o0;
1244 DWORD o1;
1245 DWORD o2;
1246 DWORD o3;
1247 DWORD o4;
1248 DWORD o5;
1249 DWORD o6;
1250 DWORD o7;
1251 DWORD l0;
1252 DWORD l1;
1253 DWORD l2;
1254 DWORD l3;
1255 DWORD l4;
1256 DWORD l5;
1257 DWORD l6;
1258 DWORD l7;
1259 DWORD i0;
1260 DWORD i1;
1261 DWORD i2;
1262 DWORD i3;
1263 DWORD i4;
1264 DWORD i5;
1265 DWORD i6;
1266 DWORD i7;
1268 /* These are selected by CONTEXT_CONTROL */
1269 DWORD psr;
1270 DWORD pc;
1271 DWORD npc;
1272 DWORD y;
1273 DWORD wim;
1274 DWORD tbr;
1276 /* FIXME: floating point registers missing */
1278 } CONTEXT;
1280 #endif /* __sparc__ */
1282 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1283 #error You need to define a CONTEXT for your CPU
1284 #endif
1286 typedef CONTEXT *PCONTEXT;
1288 #ifdef __WINE__
1290 /* Macros to retrieve the current context */
1292 #ifdef __i386__
1294 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
1295 __ASM_GLOBAL_FUNC( name, \
1296 "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \
1297 ".long " __ASM_NAME(#fn) "\n\t" \
1298 ".byte " #args ", " #args )
1299 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1300 extern void WINAPI name(void); \
1301 _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
1302 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1303 extern void WINAPI name( t1 a1 ); \
1304 _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
1305 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1306 extern void WINAPI name( t1 a1, t2 a2 ); \
1307 _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
1308 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1309 extern void WINAPI name( t1 a1, t2 a2, t3 a3 ); \
1310 _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
1311 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1312 extern void WINAPI name( t1 a1, t2 a2, t3 a3, t4 a4 ); \
1313 _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
1315 #endif /* __i386__ */
1317 #ifdef __sparc__
1319 #ifdef __SUNPRO_C
1320 static DWORD __builtin_return_address(int p_iDepth)
1322 asm("ta 3");
1323 asm("tst %i0");
1324 asm("be End");
1325 asm("mov %fp, %l0");
1326 asm("Start:");
1327 asm("sub %i0, 1, %i0");
1328 asm("tst %i0");
1329 asm("bne Start");
1330 asm("ld [%l0+56], %l0");
1331 asm("End:");
1332 asm("ld [%l0+60], %i0");
1334 #endif
1336 /* FIXME: use getcontext() to retrieve full context */
1337 #define _GET_CONTEXT \
1338 CONTEXT context; \
1339 do { memset(&context, 0, sizeof(CONTEXT)); \
1340 context.ContextFlags = CONTEXT_CONTROL; \
1341 context.pc = (DWORD)__builtin_return_address(0); \
1342 } while (0)
1344 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1345 void WINAPI name ( void ) \
1346 { _GET_CONTEXT; fn( &context ); }
1347 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1348 void WINAPI name ( t1 a1 ) \
1349 { _GET_CONTEXT; fn( a1, &context ); }
1350 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1351 void WINAPI name ( t1 a1, t2 a2 ) \
1352 { _GET_CONTEXT; fn( a1, a2, &context ); }
1353 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1354 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1355 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1356 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1357 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1358 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1360 #endif /* __sparc__ */
1362 #ifdef __PPC__
1364 /* FIXME: use getcontext() to retrieve full context */
1365 #define _GET_CONTEXT \
1366 CONTEXT context; \
1367 do { memset(&context, 0, sizeof(CONTEXT)); \
1368 context.ContextFlags = CONTEXT_CONTROL; \
1369 } while (0)
1371 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1372 void WINAPI name ( void ) \
1373 { _GET_CONTEXT; fn( &context ); }
1374 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1375 void WINAPI name ( t1 a1 ) \
1376 { _GET_CONTEXT; fn( a1, &context ); }
1377 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1378 void WINAPI name ( t1 a1, t2 a2 ) \
1379 { _GET_CONTEXT; fn( a1, a2, &context ); }
1380 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1381 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1382 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1383 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1384 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1385 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1387 #endif /* __PPC__ */
1389 #ifdef __ALPHA__
1391 /* FIXME:
1392 * use getcontext() to retrieve full context
1393 * I dont know if this is correct for alpha as was ripped from
1394 * PPC support.
1397 #define _GET_CONTEXT \
1398 CONTEXT context; \
1399 do { memset(&context, 0, sizeof(CONTEXT)); \
1400 context.ContextFlags = CONTEXT_CONTROL; \
1401 } while (0)
1403 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
1404 void WINAPI name ( void ) \
1405 { _GET_CONTEXT; fn( &context ); }
1406 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
1407 void WINAPI name ( t1 a1 ) \
1408 { _GET_CONTEXT; fn( a1, &context ); }
1409 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
1410 void WINAPI name ( t1 a1, t2 a2 ) \
1411 { _GET_CONTEXT; fn( a1, a2, &context ); }
1412 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
1413 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
1414 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
1415 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
1416 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
1417 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
1419 #endif /* __ALPHA__ */
1421 #ifndef DEFINE_REGS_ENTRYPOINT_0
1422 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
1423 #endif
1425 #endif /* __WINE__ */
1430 * Language IDs
1433 #define MAKELCID(l, s) (MAKELONG(l, s))
1435 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1436 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1437 #define SUBLANGID(l) ((WORD)(l) >> 10)
1439 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1440 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1442 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1443 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1444 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1445 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1446 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1448 #define UNREFERENCED_PARAMETER(u) (u)
1449 #define DBG_UNREFERENCED_PARAMETER(u) (u)
1450 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (u)
1452 /* FIXME: are the symbolic names correct for LIDs: 0x17, 0x28,
1453 * 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x3a, 0x3b, 0x3c
1455 #define LANG_NEUTRAL 0x00
1456 #define LANG_INVARIANT 0x7f
1458 #define LANG_AFRIKAANS 0x36
1459 #define LANG_ALBANIAN 0x1c
1460 #define LANG_ARABIC 0x01
1461 #define LANG_ARMENIAN 0x2b
1462 #define LANG_ASSAMESE 0x4d
1463 #define LANG_AZERI 0x2c
1464 #define LANG_BASQUE 0x2d
1465 #define LANG_BELARUSIAN 0x23
1466 #define LANG_BENGALI 0x45
1467 #define LANG_BULGARIAN 0x02
1468 #define LANG_CATALAN 0x03
1469 #define LANG_CHINESE 0x04
1470 #define LANG_CROATIAN 0x1a
1471 #define LANG_CZECH 0x05
1472 #define LANG_DANISH 0x06
1473 #define LANG_DIVEHI 0x65
1474 #define LANG_DUTCH 0x13
1475 #define LANG_ENGLISH 0x09
1476 #define LANG_ESTONIAN 0x25
1477 #define LANG_FAEROESE 0x38
1478 #define LANG_FARSI 0x29
1479 #define LANG_FINNISH 0x0b
1480 #define LANG_FRENCH 0x0c
1481 #define LANG_GALICIAN 0x56
1482 #define LANG_GEORGIAN 0x37
1483 #define LANG_GERMAN 0x07
1484 #define LANG_GREEK 0x08
1485 #define LANG_GUJARATI 0x47
1486 #define LANG_HEBREW 0x0d
1487 #define LANG_HINDI 0x39
1488 #define LANG_HUNGARIAN 0x0e
1489 #define LANG_ICELANDIC 0x0f
1490 #define LANG_INDONESIAN 0x21
1491 #define LANG_ITALIAN 0x10
1492 #define LANG_JAPANESE 0x11
1493 #define LANG_KANNADA 0x4b
1494 #define LANG_KASHMIRI 0x60
1495 #define LANG_KAZAK 0x3f
1496 #define LANG_KONKANI 0x57
1497 #define LANG_KOREAN 0x12
1498 #define LANG_KYRGYZ 0x40
1499 #define LANG_LATVIAN 0x26
1500 #define LANG_LITHUANIAN 0x27
1501 #define LANG_MACEDONIAN 0x2f
1502 #define LANG_MALAY 0x3e
1503 #define LANG_MALAYALAM 0x4c
1504 #define LANG_MANIPURI 0x58
1505 #define LANG_MARATHI 0x4e
1506 #define LANG_MONGOLIAN 0x50
1507 #define LANG_NEPALI 0x61
1508 #define LANG_NORWEGIAN 0x14
1509 #define LANG_ORIYA 0x48
1510 #define LANG_POLISH 0x15
1511 #define LANG_PORTUGUESE 0x16
1512 #define LANG_PUNJABI 0x46
1513 #define LANG_ROMANIAN 0x18
1514 #define LANG_RUSSIAN 0x19
1515 #define LANG_SANSKRIT 0x4f
1516 #define LANG_SERBIAN 0x1a
1517 #define LANG_SINDHI 0x59
1518 #define LANG_SLOVAK 0x1b
1519 #define LANG_SLOVENIAN 0x24
1520 #define LANG_SPANISH 0x0a
1521 #define LANG_SWAHILI 0x41
1522 #define LANG_SWEDISH 0x1d
1523 #define LANG_SYRIAC 0x5a
1524 #define LANG_TAMIL 0x49
1525 #define LANG_TATAR 0x44
1526 #define LANG_TELUGU 0x4a
1527 #define LANG_THAI 0x1e
1528 #define LANG_TURKISH 0x1f
1529 #define LANG_UKRAINIAN 0x22
1530 #define LANG_URDU 0x20
1531 #define LANG_UZBEK 0x43
1532 #define LANG_VIETNAMESE 0x2a
1534 /* FIXME: these are not in the Windows header */
1535 #define LANG_GAELIC 0x3c
1536 #define LANG_MALTESE 0x3a
1537 #define LANG_MAORI 0x28
1538 #define LANG_RHAETO_ROMANCE 0x17
1539 #define LANG_SAAMI 0x3b
1540 #define LANG_SORBIAN 0x2e
1541 #define LANG_SUTU 0x30
1542 #define LANG_TSONGA 0x31
1543 #define LANG_TSWANA 0x32
1544 #define LANG_VENDA 0x33
1545 #define LANG_XHOSA 0x34
1546 #define LANG_ZULU 0x35
1548 /* non standard; keep the number high enough (but < 0xff) */
1549 #define LANG_ESPERANTO 0x8f
1550 #define LANG_WALON 0x90
1551 #define LANG_CORNISH 0x91
1552 #define LANG_WELSH 0x92
1553 #define LANG_BRETON 0x93
1555 /* Sublanguage definitions */
1556 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
1557 #define SUBLANG_DEFAULT 0x01 /* user default */
1558 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
1560 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
1561 #define SUBLANG_ARABIC_IRAQ 0x02
1562 #define SUBLANG_ARABIC_EGYPT 0x03
1563 #define SUBLANG_ARABIC_LIBYA 0x04
1564 #define SUBLANG_ARABIC_ALGERIA 0x05
1565 #define SUBLANG_ARABIC_MOROCCO 0x06
1566 #define SUBLANG_ARABIC_TUNISIA 0x07
1567 #define SUBLANG_ARABIC_OMAN 0x08
1568 #define SUBLANG_ARABIC_YEMEN 0x09
1569 #define SUBLANG_ARABIC_SYRIA 0x0a
1570 #define SUBLANG_ARABIC_JORDAN 0x0b
1571 #define SUBLANG_ARABIC_LEBANON 0x0c
1572 #define SUBLANG_ARABIC_KUWAIT 0x0d
1573 #define SUBLANG_ARABIC_UAE 0x0e
1574 #define SUBLANG_ARABIC_BAHRAIN 0x0f
1575 #define SUBLANG_ARABIC_QATAR 0x10
1576 #define SUBLANG_AZERI_LATIN 0x01
1577 #define SUBLANG_AZERI_CYRILLIC 0x02
1578 #define SUBLANG_CHINESE_TRADITIONAL 0x01
1579 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
1580 #define SUBLANG_CHINESE_HONGKONG 0x03
1581 #define SUBLANG_CHINESE_SINGAPORE 0x04
1582 #define SUBLANG_CHINESE_MACAU 0x05
1583 #define SUBLANG_DUTCH 0x01
1584 #define SUBLANG_DUTCH_BELGIAN 0x02
1585 #define SUBLANG_ENGLISH_US 0x01
1586 #define SUBLANG_ENGLISH_UK 0x02
1587 #define SUBLANG_ENGLISH_AUS 0x03
1588 #define SUBLANG_ENGLISH_CAN 0x04
1589 #define SUBLANG_ENGLISH_NZ 0x05
1590 #define SUBLANG_ENGLISH_EIRE 0x06
1591 #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
1592 #define SUBLANG_ENGLISH_JAMAICA 0x08
1593 #define SUBLANG_ENGLISH_CARIBBEAN 0x09
1594 #define SUBLANG_ENGLISH_BELIZE 0x0a
1595 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
1596 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
1597 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
1598 #define SUBLANG_FRENCH 0x01
1599 #define SUBLANG_FRENCH_BELGIAN 0x02
1600 #define SUBLANG_FRENCH_CANADIAN 0x03
1601 #define SUBLANG_FRENCH_SWISS 0x04
1602 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
1603 #define SUBLANG_FRENCH_MONACO 0x06
1604 #define SUBLANG_GERMAN 0x01
1605 #define SUBLANG_GERMAN_SWISS 0x02
1606 #define SUBLANG_GERMAN_AUSTRIAN 0x03
1607 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
1608 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
1609 #define SUBLANG_ITALIAN 0x01
1610 #define SUBLANG_ITALIAN_SWISS 0x02
1611 #define SUBLANG_KASHMIRI_SASIA 0x02
1612 #define SUBLANG_KASHMIRI_INDIA 0x02
1613 #define SUBLANG_KOREAN 0x01
1614 #define SUBLANG_LITHUANIAN 0x01
1615 #define SUBLANG_MALAY_MALAYSIA 0x01
1616 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
1617 #define SUBLANG_NEPALI_INDIA 0x02
1618 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
1619 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
1620 #define SUBLANG_PORTUGUESE 0x02
1621 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
1622 #define SUBLANG_SERBIAN_LATIN 0x02
1623 #define SUBLANG_SERBIAN_CYRILLIC 0x03
1624 #define SUBLANG_SPANISH 0x01
1625 #define SUBLANG_SPANISH_MEXICAN 0x02
1626 #define SUBLANG_SPANISH_MODERN 0x03
1627 #define SUBLANG_SPANISH_GUATEMALA 0x04
1628 #define SUBLANG_SPANISH_COSTA_RICA 0x05
1629 #define SUBLANG_SPANISH_PANAMA 0x06
1630 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
1631 #define SUBLANG_SPANISH_VENEZUELA 0x08
1632 #define SUBLANG_SPANISH_COLOMBIA 0x09
1633 #define SUBLANG_SPANISH_PERU 0x0a
1634 #define SUBLANG_SPANISH_ARGENTINA 0x0b
1635 #define SUBLANG_SPANISH_ECUADOR 0x0c
1636 #define SUBLANG_SPANISH_CHILE 0x0d
1637 #define SUBLANG_SPANISH_URUGUAY 0x0e
1638 #define SUBLANG_SPANISH_PARAGUAY 0x0f
1639 #define SUBLANG_SPANISH_BOLIVIA 0x10
1640 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
1641 #define SUBLANG_SPANISH_HONDURAS 0x12
1642 #define SUBLANG_SPANISH_NICARAGUA 0x13
1643 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
1644 #define SUBLANG_SWEDISH 0x01
1645 #define SUBLANG_SWEDISH_FINLAND 0x02
1646 #define SUBLANG_URDU_PAKISTAN 0x01
1647 #define SUBLANG_URDU_INDIA 0x02
1648 #define SUBLANG_UZBEK_LATIN 0x01
1649 #define SUBLANG_UZBEK_CYRILLIC 0x02
1651 /* FIXME: these are not in the Windows header */
1652 #define SUBLANG_DUTCH_SURINAM 0x03
1653 #define SUBLANG_ROMANIAN 0x01
1654 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
1655 #define SUBLANG_RUSSIAN 0x01
1656 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
1657 #define SUBLANG_CROATIAN 0x01
1658 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
1659 #define SUBLANG_GAELIC 0x01
1660 #define SUBLANG_GAELIC_SCOTTISH 0x02
1661 #define SUBLANG_GAELIC_MANX 0x03
1665 * Sort definitions
1668 #define SORT_DEFAULT 0x0
1669 #define SORT_JAPANESE_XJIS 0x0
1670 #define SORT_JAPANESE_UNICODE 0x1
1671 #define SORT_CHINESE_BIG5 0x0
1672 #define SORT_CHINESE_UNICODE 0x1
1673 #define SORT_KOREAN_KSC 0x0
1674 #define SORT_KOREAN_UNICODE 0x1
1679 * Definitions for IsTextUnicode()
1682 #define IS_TEXT_UNICODE_ASCII16 0x0001
1683 #define IS_TEXT_UNICODE_STATISTICS 0x0002
1684 #define IS_TEXT_UNICODE_CONTROLS 0x0004
1685 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
1686 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
1687 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
1688 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1689 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
1690 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
1691 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
1692 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
1693 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
1694 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
1695 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
1696 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
1697 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
1699 #include "ntstatus.h"
1701 #define MAXIMUM_WAIT_OBJECTS 64
1702 #define MAXIMUM_SUSPEND_COUNT 127
1706 * From OS/2 2.0 exception handling
1707 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1710 #define EH_NONCONTINUABLE 0x01
1711 #define EH_UNWINDING 0x02
1712 #define EH_EXIT_UNWIND 0x04
1713 #define EH_STACK_INVALID 0x08
1714 #define EH_NESTED_CALL 0x10
1716 #define EXCEPTION_CONTINUABLE 0
1717 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
1720 * The exception record used by Win32 to give additional information
1721 * about exception to exception handlers.
1724 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1726 typedef struct __EXCEPTION_RECORD
1728 DWORD ExceptionCode;
1729 DWORD ExceptionFlags;
1730 struct __EXCEPTION_RECORD *ExceptionRecord;
1732 LPVOID ExceptionAddress;
1733 DWORD NumberParameters;
1734 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1735 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1738 * The exception pointers structure passed to exception filters
1739 * in except() and the UnhandledExceptionFilter().
1742 typedef struct _EXCEPTION_POINTERS
1744 PEXCEPTION_RECORD ExceptionRecord;
1745 PCONTEXT ContextRecord;
1746 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1750 * The exception frame, used for registering exception handlers
1751 * Win32 cares only about this, but compilers generally emit
1752 * larger exception frames for their own use.
1755 struct __EXCEPTION_FRAME;
1757 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
1758 PCONTEXT,struct __EXCEPTION_FRAME **);
1760 typedef struct __EXCEPTION_FRAME
1762 struct __EXCEPTION_FRAME *Prev;
1763 PEXCEPTION_HANDLER Handler;
1764 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
1767 * function pointer to a exception filter
1770 typedef LONG (CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1771 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1773 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1774 LPTOP_LEVEL_EXCEPTION_FILTER
1775 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1777 /* status values for ContinueDebugEvent */
1778 #define DBG_CONTINUE 0x00010002
1779 #define DBG_TERMINATE_THREAD 0x40010003
1780 #define DBG_TERMINATE_PROCESS 0x40010004
1781 #define DBG_CONTROL_C 0x40010005
1782 #define DBG_CONTROL_BREAK 0x40010008
1783 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
1785 typedef struct _NT_TIB
1787 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1788 PVOID StackBase;
1789 PVOID StackLimit;
1790 PVOID SubSystemTib;
1791 union {
1792 PVOID FiberData;
1793 DWORD Version;
1794 } DUMMYUNIONNAME;
1795 PVOID ArbitraryUserPointer;
1796 struct _NT_TIB *Self;
1797 } NT_TIB, *PNT_TIB;
1799 struct _TEB;
1801 #if defined(__i386__) && defined(__GNUC__)
1802 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1803 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1805 struct _TEB *teb;
1806 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1807 return teb;
1809 #elif defined(__i386__) && defined(_MSC_VER)
1810 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1812 struct _TEB *teb;
1813 __asm mov eax, fs:[0x18];
1814 __asm mov teb, eax;
1815 return teb;
1817 #elif defined(__powerpc__)
1818 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1819 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1821 struct _TEB *teb;
1822 __asm__("\tmr %0, 2" : "=r" (teb));
1823 return teb;
1825 #else
1826 extern struct _TEB * WINAPI NtCurrentTeb(void);
1827 #endif
1831 * File formats definitions
1834 #include "pshpack2.h"
1835 typedef struct _IMAGE_DOS_HEADER {
1836 WORD e_magic; /* 00: MZ Header signature */
1837 WORD e_cblp; /* 02: Bytes on last page of file */
1838 WORD e_cp; /* 04: Pages in file */
1839 WORD e_crlc; /* 06: Relocations */
1840 WORD e_cparhdr; /* 08: Size of header in paragraphs */
1841 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
1842 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
1843 WORD e_ss; /* 0e: Initial (relative) SS value */
1844 WORD e_sp; /* 10: Initial SP value */
1845 WORD e_csum; /* 12: Checksum */
1846 WORD e_ip; /* 14: Initial IP value */
1847 WORD e_cs; /* 16: Initial (relative) CS value */
1848 WORD e_lfarlc; /* 18: File address of relocation table */
1849 WORD e_ovno; /* 1a: Overlay number */
1850 WORD e_res[4]; /* 1c: Reserved words */
1851 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
1852 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
1853 WORD e_res2[10]; /* 28: Reserved words */
1854 DWORD e_lfanew; /* 3c: Offset to extended header */
1855 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1856 #include "poppack.h"
1858 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
1859 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
1860 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
1861 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
1862 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
1863 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
1866 * This is the Windows executable (NE) header.
1867 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
1869 #include "pshpack2.h"
1870 typedef struct
1872 WORD ne_magic; /* 00 NE signature 'NE' */
1873 BYTE ne_ver; /* 02 Linker version number */
1874 BYTE ne_rev; /* 03 Linker revision number */
1875 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
1876 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
1877 LONG ne_crc; /* 08 Checksum */
1878 WORD ne_flags; /* 0c Flags about segments in this file */
1879 WORD ne_autodata; /* 0e Automatic data segment number */
1880 WORD ne_heap; /* 10 Initial size of local heap */
1881 WORD ne_stack; /* 12 Initial size of stack */
1882 DWORD ne_csip; /* 14 Initial CS:IP */
1883 DWORD ne_sssp; /* 18 Initial SS:SP */
1884 WORD ne_cseg; /* 1c # of entries in segment table */
1885 WORD ne_cmod; /* 1e # of entries in module reference tab. */
1886 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
1887 WORD ne_segtab; /* 22 Offset to segment table */
1888 WORD ne_rsrctab; /* 24 Offset to resource table */
1889 WORD ne_restab; /* 26 Offset to resident-name table */
1890 WORD ne_modtab; /* 28 Offset to module reference table */
1891 WORD ne_imptab; /* 2a Offset to imported name table */
1892 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
1893 WORD ne_cmovent; /* 30 # of movable entry points */
1894 WORD ne_align; /* 32 Logical sector alignment shift count */
1895 WORD ne_cres; /* 34 # of resource segments */
1896 BYTE ne_exetyp; /* 36 Flags indicating target OS */
1897 BYTE ne_flagsothers; /* 37 Additional information flags */
1898 WORD ne_pretthunks; /* 38 Offset to return thunks */
1899 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
1900 WORD ne_swaparea; /* 3c Reserved by Microsoft */
1901 WORD ne_expver; /* 3e Expected Windows version number */
1902 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
1903 #include "poppack.h"
1905 #include "pshpack2.h"
1906 typedef struct _IMAGE_VXD_HEADER {
1907 WORD e32_magic;
1908 BYTE e32_border;
1909 BYTE e32_worder;
1910 DWORD e32_level;
1911 WORD e32_cpu;
1912 WORD e32_os;
1913 DWORD e32_ver;
1914 DWORD e32_mflags;
1915 DWORD e32_mpages;
1916 DWORD e32_startobj;
1917 DWORD e32_eip;
1918 DWORD e32_stackobj;
1919 DWORD e32_esp;
1920 DWORD e32_pagesize;
1921 DWORD e32_lastpagesize;
1922 DWORD e32_fixupsize;
1923 DWORD e32_fixupsum;
1924 DWORD e32_ldrsize;
1925 DWORD e32_ldrsum;
1926 DWORD e32_objtab;
1927 DWORD e32_objcnt;
1928 DWORD e32_objmap;
1929 DWORD e32_itermap;
1930 DWORD e32_rsrctab;
1931 DWORD e32_rsrccnt;
1932 DWORD e32_restab;
1933 DWORD e32_enttab;
1934 DWORD e32_dirtab;
1935 DWORD e32_dircnt;
1936 DWORD e32_fpagetab;
1937 DWORD e32_frectab;
1938 DWORD e32_impmod;
1939 DWORD e32_impmodcnt;
1940 DWORD e32_impproc;
1941 DWORD e32_pagesum;
1942 DWORD e32_datapage;
1943 DWORD e32_preload;
1944 DWORD e32_nrestab;
1945 DWORD e32_cbnrestab;
1946 DWORD e32_nressum;
1947 DWORD e32_autodata;
1948 DWORD e32_debuginfo;
1949 DWORD e32_debuglen;
1950 DWORD e32_instpreload;
1951 DWORD e32_instdemand;
1952 DWORD e32_heapsize;
1953 BYTE e32_res3[12];
1954 DWORD e32_winresoff;
1955 DWORD e32_winreslen;
1956 WORD e32_devid;
1957 WORD e32_ddkver;
1958 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1959 #include "poppack.h"
1961 /* These defines describe the meanings of the bits in the Characteristics
1962 field */
1964 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
1965 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
1966 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
1967 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
1968 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
1969 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
1970 #define IMAGE_FILE_16BIT_MACHINE 0x0040
1971 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
1972 #define IMAGE_FILE_32BIT_MACHINE 0x0100
1973 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
1974 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
1975 #define IMAGE_FILE_SYSTEM 0x1000
1976 #define IMAGE_FILE_DLL 0x2000
1977 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
1978 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
1980 /* These are the settings of the Machine field. */
1981 #define IMAGE_FILE_MACHINE_UNKNOWN 0
1982 #define IMAGE_FILE_MACHINE_I860 0x14d
1983 #define IMAGE_FILE_MACHINE_I386 0x14c
1984 #define IMAGE_FILE_MACHINE_R3000 0x162
1985 #define IMAGE_FILE_MACHINE_R4000 0x166
1986 #define IMAGE_FILE_MACHINE_R10000 0x168
1987 #define IMAGE_FILE_MACHINE_ALPHA 0x184
1988 #define IMAGE_FILE_MACHINE_POWERPC 0x1F0
1990 #define IMAGE_SIZEOF_FILE_HEADER 20
1992 /* Possible Magic values */
1993 #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
1994 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
1996 /* These are indexes into the DataDirectory array */
1997 #define IMAGE_FILE_EXPORT_DIRECTORY 0
1998 #define IMAGE_FILE_IMPORT_DIRECTORY 1
1999 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2000 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2001 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2002 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2003 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2004 #define IMAGE_FILE_DESCRIPTION_STRING 7
2005 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2006 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2007 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2009 /* Directory Entries, indices into the DataDirectory array */
2011 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2012 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2013 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2014 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2015 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2016 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2017 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2018 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2019 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2020 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2021 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2022 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2023 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2024 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2025 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2027 /* Subsystem Values */
2029 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2030 #define IMAGE_SUBSYSTEM_NATIVE 1
2031 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2032 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem*/
2033 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2034 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2036 typedef struct _IMAGE_FILE_HEADER {
2037 WORD Machine;
2038 WORD NumberOfSections;
2039 DWORD TimeDateStamp;
2040 DWORD PointerToSymbolTable;
2041 DWORD NumberOfSymbols;
2042 WORD SizeOfOptionalHeader;
2043 WORD Characteristics;
2044 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2046 typedef struct _IMAGE_DATA_DIRECTORY {
2047 DWORD VirtualAddress;
2048 DWORD Size;
2049 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2051 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2053 typedef struct _IMAGE_OPTIONAL_HEADER {
2055 /* Standard fields */
2057 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2058 BYTE MajorLinkerVersion;
2059 BYTE MinorLinkerVersion;
2060 DWORD SizeOfCode;
2061 DWORD SizeOfInitializedData;
2062 DWORD SizeOfUninitializedData;
2063 DWORD AddressOfEntryPoint; /* 0x10 */
2064 DWORD BaseOfCode;
2065 DWORD BaseOfData;
2067 /* NT additional fields */
2069 DWORD ImageBase;
2070 DWORD SectionAlignment; /* 0x20 */
2071 DWORD FileAlignment;
2072 WORD MajorOperatingSystemVersion;
2073 WORD MinorOperatingSystemVersion;
2074 WORD MajorImageVersion;
2075 WORD MinorImageVersion;
2076 WORD MajorSubsystemVersion; /* 0x30 */
2077 WORD MinorSubsystemVersion;
2078 DWORD Win32VersionValue;
2079 DWORD SizeOfImage;
2080 DWORD SizeOfHeaders;
2081 DWORD CheckSum; /* 0x40 */
2082 WORD Subsystem;
2083 WORD DllCharacteristics;
2084 DWORD SizeOfStackReserve;
2085 DWORD SizeOfStackCommit;
2086 DWORD SizeOfHeapReserve; /* 0x50 */
2087 DWORD SizeOfHeapCommit;
2088 DWORD LoaderFlags;
2089 DWORD NumberOfRvaAndSizes;
2090 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2091 /* 0xE0 */
2092 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
2094 typedef struct _IMAGE_NT_HEADERS {
2095 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2096 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2097 IMAGE_OPTIONAL_HEADER OptionalHeader; /* 0x18 */
2098 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
2100 #define IMAGE_SIZEOF_SHORT_NAME 8
2102 typedef struct _IMAGE_SECTION_HEADER {
2103 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2104 union {
2105 DWORD PhysicalAddress;
2106 DWORD VirtualSize;
2107 } Misc;
2108 DWORD VirtualAddress;
2109 DWORD SizeOfRawData;
2110 DWORD PointerToRawData;
2111 DWORD PointerToRelocations;
2112 DWORD PointerToLinenumbers;
2113 WORD NumberOfRelocations;
2114 WORD NumberOfLinenumbers;
2115 DWORD Characteristics;
2116 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2118 #define IMAGE_SIZEOF_SECTION_HEADER 40
2120 #define IMAGE_FIRST_SECTION(ntheader) \
2121 ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2122 ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2124 /* These defines are for the Characteristics bitfield. */
2125 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2126 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2127 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2128 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2129 /* #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 - Reserved */
2130 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2132 #define IMAGE_SCN_CNT_CODE 0x00000020
2133 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2134 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2136 #define IMAGE_SCN_LNK_OTHER 0x00000100
2137 #define IMAGE_SCN_LNK_INFO 0x00000200
2138 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2139 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2140 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2142 /* 0x00002000 - Reserved */
2143 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2144 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2146 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2147 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2148 #define IMAGE_SCN_MEM_16BIT 0x00020000
2149 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2150 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2152 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2153 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2154 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2155 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2156 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2157 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2158 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2159 /* 0x00800000 - Unused */
2161 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2164 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2165 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2166 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2167 #define IMAGE_SCN_MEM_SHARED 0x10000000
2168 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2169 #define IMAGE_SCN_MEM_READ 0x40000000
2170 #define IMAGE_SCN_MEM_WRITE 0x80000000
2172 #include "pshpack2.h"
2174 typedef struct _IMAGE_SYMBOL {
2175 union {
2176 BYTE ShortName[8];
2177 struct {
2178 DWORD Short;
2179 DWORD Long;
2180 } Name;
2181 DWORD LongName[2];
2182 } N;
2183 DWORD Value;
2184 SHORT SectionNumber;
2185 WORD Type;
2186 BYTE StorageClass;
2187 BYTE NumberOfAuxSymbols;
2188 } IMAGE_SYMBOL;
2189 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2191 #define IMAGE_SIZEOF_SYMBOL 18
2193 typedef struct _IMAGE_LINENUMBER {
2194 union {
2195 DWORD SymbolTableIndex;
2196 DWORD VirtualAddress;
2197 } Type;
2198 WORD Linenumber;
2199 } IMAGE_LINENUMBER;
2200 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2202 #define IMAGE_SIZEOF_LINENUMBER 6
2204 typedef union _IMAGE_AUX_SYMBOL {
2205 struct {
2206 DWORD TagIndex;
2207 union {
2208 struct {
2209 WORD Linenumber;
2210 WORD Size;
2211 } LnSz;
2212 DWORD TotalSize;
2213 } Misc;
2214 union {
2215 struct {
2216 DWORD PointerToLinenumber;
2217 DWORD PointerToNextFunction;
2218 } Function;
2219 struct {
2220 WORD Dimension[4];
2221 } Array;
2222 } FcnAry;
2223 WORD TvIndex;
2224 } Sym;
2225 struct {
2226 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2227 } File;
2228 struct {
2229 DWORD Length;
2230 WORD NumberOfRelocations;
2231 WORD NumberOfLinenumbers;
2232 DWORD CheckSum;
2233 SHORT Number;
2234 BYTE Selection;
2235 } Section;
2236 } IMAGE_AUX_SYMBOL;
2237 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2239 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2241 #include "poppack.h"
2243 #define IMAGE_SYM_UNDEFINED (SHORT)0
2244 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2245 #define IMAGE_SYM_DEBUG (SHORT)-2
2247 #define IMAGE_SYM_TYPE_NULL 0x0000
2248 #define IMAGE_SYM_TYPE_VOID 0x0001
2249 #define IMAGE_SYM_TYPE_CHAR 0x0002
2250 #define IMAGE_SYM_TYPE_SHORT 0x0003
2251 #define IMAGE_SYM_TYPE_INT 0x0004
2252 #define IMAGE_SYM_TYPE_LONG 0x0005
2253 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2254 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2255 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2256 #define IMAGE_SYM_TYPE_UNION 0x0009
2257 #define IMAGE_SYM_TYPE_ENUM 0x000A
2258 #define IMAGE_SYM_TYPE_MOE 0x000B
2259 #define IMAGE_SYM_TYPE_BYTE 0x000C
2260 #define IMAGE_SYM_TYPE_WORD 0x000D
2261 #define IMAGE_SYM_TYPE_UINT 0x000E
2262 #define IMAGE_SYM_TYPE_DWORD 0x000F
2263 #define IMAGE_SYM_TYPE_PCODE 0x8000
2265 #define IMAGE_SYM_DTYPE_NULL 0
2266 #define IMAGE_SYM_DTYPE_POINTER 1
2267 #define IMAGE_SYM_DTYPE_FUNCTION 2
2268 #define IMAGE_SYM_DTYPE_ARRAY 3
2270 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2271 #define IMAGE_SYM_CLASS_NULL 0x0000
2272 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2273 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2274 #define IMAGE_SYM_CLASS_STATIC 0x0003
2275 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2276 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2277 #define IMAGE_SYM_CLASS_LABEL 0x0006
2278 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2279 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2280 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2281 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2282 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2283 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2284 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2285 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2286 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2287 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2288 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2289 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2291 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2292 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2293 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2294 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2295 #define IMAGE_SYM_CLASS_FILE 0x0067
2296 #define IMAGE_SYM_CLASS_SECTION 0x0068
2297 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2299 #define N_BTMASK 0x000F
2300 #define N_TMASK 0x0030
2301 #define N_TMASK1 0x00C0
2302 #define N_TMASK2 0x00F0
2303 #define N_BTSHFT 4
2304 #define N_TSHIFT 2
2306 #define BTYPE(x) ((x) & N_BTMASK)
2308 #ifndef ISPTR
2309 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2310 #endif
2312 #ifndef ISFCN
2313 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2314 #endif
2316 #ifndef ISARY
2317 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2318 #endif
2320 #ifndef ISTAG
2321 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2322 #endif
2324 #ifndef INCREF
2325 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2326 #endif
2327 #ifndef DECREF
2328 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2329 #endif
2331 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2332 #define IMAGE_COMDAT_SELECT_ANY 2
2333 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2334 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2335 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2336 #define IMAGE_COMDAT_SELECT_LARGEST 6
2337 #define IMAGE_COMDAT_SELECT_NEWEST 7
2339 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2340 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2341 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2343 /* Export module directory */
2345 typedef struct _IMAGE_EXPORT_DIRECTORY {
2346 DWORD Characteristics;
2347 DWORD TimeDateStamp;
2348 WORD MajorVersion;
2349 WORD MinorVersion;
2350 DWORD Name;
2351 DWORD Base;
2352 DWORD NumberOfFunctions;
2353 DWORD NumberOfNames;
2354 DWORD AddressOfFunctions;
2355 DWORD AddressOfNames;
2356 DWORD AddressOfNameOrdinals;
2357 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2359 /* Import name entry */
2360 typedef struct _IMAGE_IMPORT_BY_NAME {
2361 WORD Hint;
2362 BYTE Name[1];
2363 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2365 /* Import thunk */
2366 typedef struct _IMAGE_THUNK_DATA {
2367 union {
2368 LPBYTE ForwarderString;
2369 PDWORD Function;
2370 DWORD Ordinal;
2371 PIMAGE_IMPORT_BY_NAME AddressOfData;
2372 } u1;
2373 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2375 /* Import module directory */
2377 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2378 union {
2379 DWORD Characteristics; /* 0 for terminating null import descriptor */
2380 PIMAGE_THUNK_DATA OriginalFirstThunk; /* RVA to original unbound IAT */
2381 } u;
2382 DWORD TimeDateStamp; /* 0 if not bound,
2383 * -1 if bound, and real date\time stamp
2384 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2385 * (new BIND)
2386 * otherwise date/time stamp of DLL bound to
2387 * (Old BIND)
2389 DWORD ForwarderChain; /* -1 if no forwarders */
2390 DWORD Name;
2391 /* RVA to IAT (if bound this IAT has actual addresses) */
2392 PIMAGE_THUNK_DATA FirstThunk;
2393 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2395 #define IMAGE_ORDINAL_FLAG 0x80000000
2396 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2397 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
2399 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2401 DWORD TimeDateStamp;
2402 WORD OffsetModuleName;
2403 WORD NumberOfModuleForwarderRefs;
2404 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2405 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2407 typedef struct _IMAGE_BOUND_FORWARDER_REF
2409 DWORD TimeDateStamp;
2410 WORD OffsetModuleName;
2411 WORD Reserved;
2412 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2414 typedef struct _IMAGE_BASE_RELOCATION
2416 DWORD VirtualAddress;
2417 DWORD SizeOfBlock;
2418 /* WORD TypeOffset[1]; */
2419 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2421 #include "pshpack2.h"
2423 typedef struct _IMAGE_RELOCATION
2425 union {
2426 DWORD VirtualAddress;
2427 DWORD RelocCount;
2428 } DUMMYUNIONNAME;
2429 DWORD SymbolTableIndex;
2430 WORD Type;
2431 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
2433 #include "poppack.h"
2435 #define IMAGE_SIZEOF_RELOCATION 10
2437 /* generic relocation types */
2438 #define IMAGE_REL_BASED_ABSOLUTE 0
2439 #define IMAGE_REL_BASED_HIGH 1
2440 #define IMAGE_REL_BASED_LOW 2
2441 #define IMAGE_REL_BASED_HIGHLOW 3
2442 #define IMAGE_REL_BASED_HIGHADJ 4
2443 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
2444 #define IMAGE_REL_BASED_SECTION 6
2445 #define IMAGE_REL_BASED_REL 7
2446 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
2447 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
2448 #define IMAGE_REL_BASED_DIR64 10
2449 #define IMAGE_REL_BASED_HIGH3ADJ 11
2451 /* I386 relocation types */
2452 #define IMAGE_REL_I386_ABSOLUTE 0
2453 #define IMAGE_REL_I386_DIR16 1
2454 #define IMAGE_REL_I386_REL16 2
2455 #define IMAGE_REL_I386_DIR32 6
2456 #define IMAGE_REL_I386_DIR32NB 7
2457 #define IMAGE_REL_I386_SEG12 9
2458 #define IMAGE_REL_I386_SECTION 10
2459 #define IMAGE_REL_I386_SECREL 11
2460 #define IMAGE_REL_I386_REL32 20
2462 /* MIPS relocation types */
2463 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
2464 #define IMAGE_REL_MIPS_REFHALF 0x0001
2465 #define IMAGE_REL_MIPS_REFWORD 0x0002
2466 #define IMAGE_REL_MIPS_JMPADDR 0x0003
2467 #define IMAGE_REL_MIPS_REFHI 0x0004
2468 #define IMAGE_REL_MIPS_REFLO 0x0005
2469 #define IMAGE_REL_MIPS_GPREL 0x0006
2470 #define IMAGE_REL_MIPS_LITERAL 0x0007
2471 #define IMAGE_REL_MIPS_SECTION 0x000A
2472 #define IMAGE_REL_MIPS_SECREL 0x000B
2473 #define IMAGE_REL_MIPS_SECRELLO 0x000C
2474 #define IMAGE_REL_MIPS_SECRELHI 0x000D
2475 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
2476 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
2477 #define IMAGE_REL_MIPS_PAIR 0x0025
2479 /* ALPHA relocation types */
2480 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
2481 #define IMAGE_REL_ALPHA_REFLONG 0x0001
2482 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
2483 #define IMAGE_REL_ALPHA_GPREL 0x0003
2484 #define IMAGE_REL_ALPHA_LITERAL 0x0004
2485 #define IMAGE_REL_ALPHA_LITUSE 0x0005
2486 #define IMAGE_REL_ALPHA_GPDISP 0x0006
2487 #define IMAGE_REL_ALPHA_BRADDR 0x0007
2488 #define IMAGE_REL_ALPHA_HINT 0x0008
2489 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
2490 #define IMAGE_REL_ALPHA_REFHI 0x000A
2491 #define IMAGE_REL_ALPHA_REFLO 0x000B
2492 #define IMAGE_REL_ALPHA_PAIR 0x000C
2493 #define IMAGE_REL_ALPHA_MATCH 0x000D
2494 #define IMAGE_REL_ALPHA_SECTION 0x000E
2495 #define IMAGE_REL_ALPHA_SECREL 0x000F
2496 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
2497 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
2498 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
2499 #define IMAGE_REL_ALPHA_REFQ3 0x0013
2500 #define IMAGE_REL_ALPHA_REFQ2 0x0014
2501 #define IMAGE_REL_ALPHA_REFQ1 0x0015
2502 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
2503 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
2505 /* PowerPC relocation types */
2506 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
2507 #define IMAGE_REL_PPC_ADDR64 0x0001
2508 #define IMAGE_REL_PPC_ADDR 0x0002
2509 #define IMAGE_REL_PPC_ADDR24 0x0003
2510 #define IMAGE_REL_PPC_ADDR16 0x0004
2511 #define IMAGE_REL_PPC_ADDR14 0x0005
2512 #define IMAGE_REL_PPC_REL24 0x0006
2513 #define IMAGE_REL_PPC_REL14 0x0007
2514 #define IMAGE_REL_PPC_TOCREL16 0x0008
2515 #define IMAGE_REL_PPC_TOCREL14 0x0009
2516 #define IMAGE_REL_PPC_ADDR32NB 0x000A
2517 #define IMAGE_REL_PPC_SECREL 0x000B
2518 #define IMAGE_REL_PPC_SECTION 0x000C
2519 #define IMAGE_REL_PPC_IFGLUE 0x000D
2520 #define IMAGE_REL_PPC_IMGLUE 0x000E
2521 #define IMAGE_REL_PPC_SECREL16 0x000F
2522 #define IMAGE_REL_PPC_REFHI 0x0010
2523 #define IMAGE_REL_PPC_REFLO 0x0011
2524 #define IMAGE_REL_PPC_PAIR 0x0012
2525 #define IMAGE_REL_PPC_SECRELLO 0x0013
2526 #define IMAGE_REL_PPC_SECRELHI 0x0014
2527 #define IMAGE_REL_PPC_GPREL 0x0015
2528 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
2529 /* modifier bits */
2530 #define IMAGE_REL_PPC_NEG 0x0100
2531 #define IMAGE_REL_PPC_BRTAKEN 0x0200
2532 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
2533 #define IMAGE_REL_PPC_TOCDEFN 0x0800
2535 /* SH3 ? relocation type */
2536 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
2537 #define IMAGE_REL_SH3_DIRECT16 0x0001
2538 #define IMAGE_REL_SH3_DIRECT 0x0002
2539 #define IMAGE_REL_SH3_DIRECT8 0x0003
2540 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
2541 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
2542 #define IMAGE_REL_SH3_DIRECT4 0x0006
2543 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
2544 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
2545 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
2546 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
2547 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
2548 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
2549 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
2550 #define IMAGE_REL_SH3_SECTION 0x000E
2551 #define IMAGE_REL_SH3_SECREL 0x000F
2552 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
2554 /* ARM (Archimedes?) relocation types */
2555 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
2556 #define IMAGE_REL_ARM_ADDR 0x0001
2557 #define IMAGE_REL_ARM_ADDR32NB 0x0002
2558 #define IMAGE_REL_ARM_BRANCH24 0x0003
2559 #define IMAGE_REL_ARM_BRANCH11 0x0004
2560 #define IMAGE_REL_ARM_SECTION 0x000E
2561 #define IMAGE_REL_ARM_SECREL 0x000F
2563 /* IA64 relocation types */
2564 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
2565 #define IMAGE_REL_IA64_IMM14 0x0001
2566 #define IMAGE_REL_IA64_IMM22 0x0002
2567 #define IMAGE_REL_IA64_IMM64 0x0003
2568 #define IMAGE_REL_IA64_DIR 0x0004
2569 #define IMAGE_REL_IA64_DIR64 0x0005
2570 #define IMAGE_REL_IA64_PCREL21B 0x0006
2571 #define IMAGE_REL_IA64_PCREL21M 0x0007
2572 #define IMAGE_REL_IA64_PCREL21F 0x0008
2573 #define IMAGE_REL_IA64_GPREL22 0x0009
2574 #define IMAGE_REL_IA64_LTOFF22 0x000A
2575 #define IMAGE_REL_IA64_SECTION 0x000B
2576 #define IMAGE_REL_IA64_SECREL22 0x000C
2577 #define IMAGE_REL_IA64_SECREL64I 0x000D
2578 #define IMAGE_REL_IA64_SECREL 0x000E
2579 #define IMAGE_REL_IA64_LTOFF64 0x000F
2580 #define IMAGE_REL_IA64_DIR32NB 0x0010
2581 #define IMAGE_REL_IA64_RESERVED_11 0x0011
2582 #define IMAGE_REL_IA64_RESERVED_12 0x0012
2583 #define IMAGE_REL_IA64_RESERVED_13 0x0013
2584 #define IMAGE_REL_IA64_RESERVED_14 0x0014
2585 #define IMAGE_REL_IA64_RESERVED_15 0x0015
2586 #define IMAGE_REL_IA64_RESERVED_16 0x0016
2587 #define IMAGE_REL_IA64_ADDEND 0x001F
2589 /* archive format */
2591 #define IMAGE_ARCHIVE_START_SIZE 8
2592 #define IMAGE_ARCHIVE_START "!<arch>\n"
2593 #define IMAGE_ARCHIVE_END "`\n"
2594 #define IMAGE_ARCHIVE_PAD "\n"
2595 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
2596 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
2598 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2600 BYTE Name[16];
2601 BYTE Date[12];
2602 BYTE UserID[6];
2603 BYTE GroupID[6];
2604 BYTE Mode[8];
2605 BYTE Size[10];
2606 BYTE EndHeader[2];
2607 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2609 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2612 * Resource directory stuff
2614 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2615 DWORD Characteristics;
2616 DWORD TimeDateStamp;
2617 WORD MajorVersion;
2618 WORD MinorVersion;
2619 WORD NumberOfNamedEntries;
2620 WORD NumberOfIdEntries;
2621 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2622 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2624 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
2625 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
2627 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2628 union {
2629 struct {
2630 #ifdef BITFIELDS_BIGENDIAN
2631 unsigned NameIsString:1;
2632 unsigned NameOffset:31;
2633 #else
2634 unsigned NameOffset:31;
2635 unsigned NameIsString:1;
2636 #endif
2637 } DUMMYSTRUCTNAME1;
2638 DWORD Name;
2639 struct {
2640 #ifdef WORDS_BIGENDIAN
2641 WORD __pad;
2642 WORD Id;
2643 #else
2644 WORD Id;
2645 WORD __pad;
2646 #endif
2647 } DUMMYSTRUCTNAME2;
2648 } DUMMYUNIONNAME1;
2649 union {
2650 DWORD OffsetToData;
2651 struct {
2652 #ifdef BITFIELDS_BIGENDIAN
2653 unsigned DataIsDirectory:1;
2654 unsigned OffsetToDirectory:31;
2655 #else
2656 unsigned OffsetToDirectory:31;
2657 unsigned DataIsDirectory:1;
2658 #endif
2659 } DUMMYSTRUCTNAME3;
2660 } DUMMYUNIONNAME2;
2661 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2664 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2665 WORD Length;
2666 CHAR NameString[ 1 ];
2667 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2669 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2670 WORD Length;
2671 WCHAR NameString[ 1 ];
2672 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2674 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2675 DWORD OffsetToData;
2676 DWORD Size;
2677 DWORD CodePage;
2678 DWORD ResourceHandle;
2679 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2682 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
2683 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2686 typedef struct _IMAGE_TLS_DIRECTORY {
2687 DWORD StartAddressOfRawData;
2688 DWORD EndAddressOfRawData;
2689 LPDWORD AddressOfIndex;
2690 PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
2691 DWORD SizeOfZeroFill;
2692 DWORD Characteristics;
2693 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
2695 typedef struct _IMAGE_DEBUG_DIRECTORY {
2696 DWORD Characteristics;
2697 DWORD TimeDateStamp;
2698 WORD MajorVersion;
2699 WORD MinorVersion;
2700 DWORD Type;
2701 DWORD SizeOfData;
2702 DWORD AddressOfRawData;
2703 DWORD PointerToRawData;
2704 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2706 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
2707 #define IMAGE_DEBUG_TYPE_COFF 1
2708 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
2709 #define IMAGE_DEBUG_TYPE_FPO 3
2710 #define IMAGE_DEBUG_TYPE_MISC 4
2711 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
2712 #define IMAGE_DEBUG_TYPE_FIXUP 6
2713 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
2714 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
2715 #define IMAGE_DEBUG_TYPE_BORLAND 9
2716 #define IMAGE_DEBUG_TYPE_RESERVED10 10
2718 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2719 DWORD NumberOfSymbols;
2720 DWORD LvaToFirstSymbol;
2721 DWORD NumberOfLinenumbers;
2722 DWORD LvaToFirstLinenumber;
2723 DWORD RvaToFirstByteOfCode;
2724 DWORD RvaToLastByteOfCode;
2725 DWORD RvaToFirstByteOfData;
2726 DWORD RvaToLastByteOfData;
2727 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2729 #define FRAME_FPO 0
2730 #define FRAME_TRAP 1
2731 #define FRAME_TSS 2
2732 #define FRAME_NONFPO 3
2734 typedef struct _FPO_DATA {
2735 DWORD ulOffStart;
2736 DWORD cbProcSize;
2737 DWORD cdwLocals;
2738 WORD cdwParams;
2739 unsigned cbProlog : 8;
2740 unsigned cbRegs : 3;
2741 unsigned fHasSEH : 1;
2742 unsigned fUseBP : 1;
2743 unsigned reserved : 1;
2744 unsigned cbFrame : 2;
2745 } FPO_DATA, *PFPO_DATA;
2747 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2748 DWORD Characteristics;
2749 DWORD TimeDateStamp;
2750 WORD MajorVersion;
2751 WORD MinorVersion;
2752 DWORD GlobalFlagsClear;
2753 DWORD GlobalFlagsSet;
2754 DWORD CriticalSectionDefaultTimeout;
2755 DWORD DeCommitFreeBlockThreshold;
2756 DWORD DeCommitTotalFreeThreshold;
2757 PVOID LockPrefixTable;
2758 DWORD MaximumAllocationSize;
2759 DWORD VirtualMemoryThreshold;
2760 DWORD ProcessHeapFlags;
2761 DWORD ProcessAffinityMask;
2762 WORD CSDVersion;
2763 WORD Reserved1;
2764 PVOID EditList;
2765 DWORD Reserved[1];
2766 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2768 typedef struct _IMAGE_FUNCTION_ENTRY {
2769 DWORD StartingAddress;
2770 DWORD EndingAddress;
2771 DWORD EndOfPrologue;
2772 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2774 #define IMAGE_DEBUG_MISC_EXENAME 1
2776 typedef struct _IMAGE_DEBUG_MISC {
2777 DWORD DataType;
2778 DWORD Length;
2779 BYTE Unicode;
2780 BYTE Reserved[ 3 ];
2781 BYTE Data[ 1 ];
2782 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2784 /* This is the structure that appears at the very start of a .DBG file. */
2786 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2787 WORD Signature;
2788 WORD Flags;
2789 WORD Machine;
2790 WORD Characteristics;
2791 DWORD TimeDateStamp;
2792 DWORD CheckSum;
2793 DWORD ImageBase;
2794 DWORD SizeOfImage;
2795 DWORD NumberOfSections;
2796 DWORD ExportedNamesSize;
2797 DWORD DebugDirectorySize;
2798 DWORD SectionAlignment;
2799 DWORD Reserved[ 2 ];
2800 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2802 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2805 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2806 WORD Length;
2807 WORD Flags;
2808 BYTE Text[1];
2809 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2810 #define MESSAGE_RESOURCE_UNICODE 0x0001
2812 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2813 DWORD LowId;
2814 DWORD HighId;
2815 DWORD OffsetToEntries;
2816 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2818 typedef struct tagMESSAGE_RESOURCE_DATA {
2819 DWORD NumberOfBlocks;
2820 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
2821 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2824 * Here follows typedefs for security and tokens.
2828 * First a constant for the following typdefs.
2831 #define ANYSIZE_ARRAY 1
2833 /* FIXME: Orphan. What does it point to? */
2834 typedef PVOID PACCESS_TOKEN;
2837 * TOKEN_INFORMATION_CLASS
2840 typedef enum _TOKEN_INFORMATION_CLASS {
2841 TokenUser = 1,
2842 TokenGroups,
2843 TokenPrivileges,
2844 TokenOwner,
2845 TokenPrimaryGroup,
2846 TokenDefaultDacl,
2847 TokenSource,
2848 TokenType,
2849 TokenImpersonationLevel,
2850 TokenStatistics,
2851 TokenRestrictedSids,
2852 TokenSessionId,
2853 TokenGroupsAndPrivileges,
2854 TokenSessionReference,
2855 TokenSandBoxInert
2856 } TOKEN_INFORMATION_CLASS;
2858 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
2859 #define TOKEN_ADJUST_GROUPS 0x0040
2860 #define TOKEN_ADJUST_PRIVILEGES 0x0020
2861 #define TOKEN_ADJUST_SESSIONID 0x0100
2862 #define TOKEN_ASSIGN_PRIMARY 0x0001
2863 #define TOKEN_DUPLICATE 0x0002
2864 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
2865 #define TOKEN_IMPERSONATE 0x0004
2866 #define TOKEN_QUERY 0x0008
2867 #define TOKEN_QUERY_SOURCE 0x0010
2868 #define TOKEN_ADJUST_DEFAULT 0x0080
2869 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
2870 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
2871 TOKEN_ADJUST_PRIVILEGES | \
2872 TOKEN_ADJUST_GROUPS | \
2873 TOKEN_ADJUST_DEFAULT )
2874 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
2875 TOKEN_ASSIGN_PRIMARY | \
2876 TOKEN_DUPLICATE | \
2877 TOKEN_IMPERSONATE | \
2878 TOKEN_QUERY | \
2879 TOKEN_QUERY_SOURCE | \
2880 TOKEN_ADJUST_PRIVILEGES | \
2881 TOKEN_ADJUST_GROUPS | \
2882 TOKEN_ADJUST_SESSIONID | \
2883 TOKEN_ADJUST_DEFAULT )
2885 #ifndef _SECURITY_DEFINED
2886 #define _SECURITY_DEFINED
2889 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2891 typedef struct _GENERIC_MAPPING {
2892 ACCESS_MASK GenericRead;
2893 ACCESS_MASK GenericWrite;
2894 ACCESS_MASK GenericExecute;
2895 ACCESS_MASK GenericAll;
2896 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2898 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2899 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2900 typedef struct {
2901 BYTE Value[6];
2902 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
2903 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2905 #ifndef SID_DEFINED
2906 #define SID_DEFINED
2907 typedef struct _SID {
2908 BYTE Revision;
2909 BYTE SubAuthorityCount;
2910 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2911 DWORD SubAuthority[1];
2912 } SID,*PSID;
2913 #endif /* !defined(SID_DEFINED) */
2915 #define SID_REVISION (1) /* Current revision */
2916 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
2917 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
2921 * ACL
2924 #define ACL_REVISION1 1
2925 #define ACL_REVISION2 2
2926 #define ACL_REVISION3 3
2927 #define ACL_REVISION4 4
2929 #define MIN_ACL_REVISION ACL_REVISION2
2930 #define MAX_ACL_REVISION ACL_REVISION4
2932 typedef struct _ACL {
2933 BYTE AclRevision;
2934 BYTE Sbz1;
2935 WORD AclSize;
2936 WORD AceCount;
2937 WORD Sbz2;
2938 } ACL, *PACL;
2940 /* SECURITY_DESCRIPTOR */
2941 #define SECURITY_DESCRIPTOR_REVISION 1
2942 #define SECURITY_DESCRIPTOR_REVISION1 1
2945 #define SE_OWNER_DEFAULTED 0x0001
2946 #define SE_GROUP_DEFAULTED 0x0002
2947 #define SE_DACL_PRESENT 0x0004
2948 #define SE_DACL_DEFAULTED 0x0008
2949 #define SE_SACL_PRESENT 0x0010
2950 #define SE_SACL_DEFAULTED 0x0020
2951 #define SE_SELF_RELATIVE 0x8000
2953 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2954 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
2956 /* The security descriptor structure */
2957 typedef struct {
2958 BYTE Revision;
2959 BYTE Sbz1;
2960 SECURITY_DESCRIPTOR_CONTROL Control;
2961 DWORD Owner;
2962 DWORD Group;
2963 DWORD Sacl;
2964 DWORD Dacl;
2965 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
2967 typedef struct {
2968 BYTE Revision;
2969 BYTE Sbz1;
2970 SECURITY_DESCRIPTOR_CONTROL Control;
2971 PSID Owner;
2972 PSID Group;
2973 PACL Sacl;
2974 PACL Dacl;
2975 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
2977 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
2979 #endif /* _SECURITY_DEFINED */
2982 * SID_AND_ATTRIBUTES
2985 typedef struct _SID_AND_ATTRIBUTES {
2986 PSID Sid;
2987 DWORD Attributes;
2988 } SID_AND_ATTRIBUTES ;
2990 /* security entities */
2991 #define SECURITY_NULL_RID (0x00000000L)
2992 #define SECURITY_WORLD_RID (0x00000000L)
2993 #define SECURITY_LOCAL_RID (0X00000000L)
2995 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
2997 /* S-1-1 */
2998 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
3000 /* S-1-2 */
3001 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
3003 /* S-1-3 */
3004 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
3005 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
3006 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
3007 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
3008 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
3010 /* S-1-4 */
3011 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
3013 /* S-1-5 */
3014 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
3015 #define SECURITY_DIALUP_RID 0x00000001L
3016 #define SECURITY_NETWORK_RID 0x00000002L
3017 #define SECURITY_BATCH_RID 0x00000003L
3018 #define SECURITY_INTERACTIVE_RID 0x00000004L
3019 #define SECURITY_LOGON_IDS_RID 0x00000005L
3020 #define SECURITY_SERVICE_RID 0x00000006L
3021 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
3022 #define SECURITY_PROXY_RID 0x00000008L
3023 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
3024 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
3025 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
3026 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
3027 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
3028 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
3029 #define SECURITY_NT_NON_UNIQUE 0x00000015L
3030 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
3032 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
3033 #define DOMAIN_GROUP_RID_USERS 0x00000201L
3034 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
3036 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
3037 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
3038 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
3040 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
3042 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
3045 * TOKEN_USER
3048 typedef struct _TOKEN_USER {
3049 SID_AND_ATTRIBUTES User;
3050 } TOKEN_USER;
3053 * TOKEN_GROUPS
3056 typedef struct _TOKEN_GROUPS {
3057 DWORD GroupCount;
3058 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
3059 } TOKEN_GROUPS;
3062 * LUID_AND_ATTRIBUTES
3065 typedef union _LARGE_INTEGER {
3066 struct {
3067 #ifdef WORDS_BIGENDIAN
3068 LONG HighPart;
3069 DWORD LowPart;
3070 #else
3071 DWORD LowPart;
3072 LONG HighPart;
3073 #endif
3074 } DUMMYSTRUCTNAME;
3075 LONGLONG QuadPart;
3076 } LARGE_INTEGER, *PLARGE_INTEGER;
3078 typedef union _ULARGE_INTEGER {
3079 struct {
3080 #ifdef WORDS_BIGENDIAN
3081 DWORD HighPart;
3082 DWORD LowPart;
3083 #else
3084 DWORD LowPart;
3085 DWORD HighPart;
3086 #endif
3087 } DUMMYSTRUCTNAME;
3088 ULONGLONG QuadPart;
3089 } ULARGE_INTEGER, *PULARGE_INTEGER;
3092 * Locally Unique Identifier
3095 typedef struct _LUID {
3096 DWORD LowPart;
3097 LONG HighPart;
3098 } LUID, *PLUID;
3100 #include "pshpack4.h"
3101 typedef struct _LUID_AND_ATTRIBUTES {
3102 LUID Luid;
3103 DWORD Attributes;
3104 } LUID_AND_ATTRIBUTES;
3105 #include "poppack.h"
3108 * PRIVILEGE_SET
3111 typedef struct _PRIVILEGE_SET {
3112 DWORD PrivilegeCount;
3113 DWORD Control;
3114 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
3115 } PRIVILEGE_SET, *PPRIVILEGE_SET;
3118 * TOKEN_PRIVILEGES
3121 typedef struct _TOKEN_PRIVILEGES {
3122 DWORD PrivilegeCount;
3123 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
3124 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
3127 * TOKEN_OWNER
3130 typedef struct _TOKEN_OWNER {
3131 PSID Owner;
3132 } TOKEN_OWNER;
3135 * TOKEN_PRIMARY_GROUP
3138 typedef struct _TOKEN_PRIMARY_GROUP {
3139 PSID PrimaryGroup;
3140 } TOKEN_PRIMARY_GROUP;
3144 * TOKEN_DEFAULT_DACL
3147 typedef struct _TOKEN_DEFAULT_DACL {
3148 PACL DefaultDacl;
3149 } TOKEN_DEFAULT_DACL;
3152 * TOKEN_SOURCEL
3155 #define TOKEN_SOURCE_LENGTH 8
3157 typedef struct _TOKEN_SOURCE {
3158 char SourceName[TOKEN_SOURCE_LENGTH];
3159 LUID SourceIdentifier;
3160 } TOKEN_SOURCE;
3163 * TOKEN_TYPE
3166 typedef enum tagTOKEN_TYPE {
3167 TokenPrimary = 1,
3168 TokenImpersonation
3169 } TOKEN_TYPE;
3172 * SECURITY_IMPERSONATION_LEVEL
3175 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3176 SecurityAnonymous,
3177 SecurityIdentification,
3178 SecurityImpersonation,
3179 SecurityDelegation
3180 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
3183 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3184 * PSECURITY_CONTEXT_TRACKING_MODE;
3186 * Quality of Service
3189 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3190 DWORD Length;
3191 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3192 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3193 BOOLEAN EffectiveOnly;
3194 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3197 * TOKEN_STATISTICS
3200 typedef struct _TOKEN_STATISTICS {
3201 LUID TokenId;
3202 LUID AuthenticationId;
3203 LARGE_INTEGER ExpirationTime;
3204 TOKEN_TYPE TokenType;
3205 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3206 DWORD DynamicCharged;
3207 DWORD DynamicAvailable;
3208 DWORD GroupCount;
3209 DWORD PrivilegeCount;
3210 LUID ModifiedId;
3211 } TOKEN_STATISTICS;
3214 * ACLs of NT
3217 #define ACL_REVISION 2
3219 #define ACL_REVISION1 1
3220 #define ACL_REVISION2 2
3222 /* ACEs, directly starting after an ACL */
3223 typedef struct _ACE_HEADER {
3224 BYTE AceType;
3225 BYTE AceFlags;
3226 WORD AceSize;
3227 } ACE_HEADER,*PACE_HEADER;
3229 /* AceType */
3230 #define ACCESS_ALLOWED_ACE_TYPE 0
3231 #define ACCESS_DENIED_ACE_TYPE 1
3232 #define SYSTEM_AUDIT_ACE_TYPE 2
3233 #define SYSTEM_ALARM_ACE_TYPE 3
3235 /* inherit AceFlags */
3236 #define OBJECT_INHERIT_ACE 0x01
3237 #define CONTAINER_INHERIT_ACE 0x02
3238 #define NO_PROPAGATE_INHERIT_ACE 0x04
3239 #define INHERIT_ONLY_ACE 0x08
3240 #define VALID_INHERIT_FLAGS 0x0F
3242 /* AceFlags mask for what events we (should) audit */
3243 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
3244 #define FAILED_ACCESS_ACE_FLAG 0x80
3246 /* different ACEs depending on AceType
3247 * SidStart marks the begin of a SID
3248 * so the thing finally looks like this:
3249 * 0: ACE_HEADER
3250 * 4: ACCESS_MASK
3251 * 8... : SID
3253 typedef struct _ACCESS_ALLOWED_ACE {
3254 ACE_HEADER Header;
3255 DWORD Mask;
3256 DWORD SidStart;
3257 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3259 typedef struct _ACCESS_DENIED_ACE {
3260 ACE_HEADER Header;
3261 DWORD Mask;
3262 DWORD SidStart;
3263 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3265 typedef struct _SYSTEM_AUDIT_ACE {
3266 ACE_HEADER Header;
3267 DWORD Mask;
3268 DWORD SidStart;
3269 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3271 typedef struct _SYSTEM_ALARM_ACE {
3272 ACE_HEADER Header;
3273 DWORD Mask;
3274 DWORD SidStart;
3275 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3277 typedef enum tagSID_NAME_USE {
3278 SidTypeUser = 1,
3279 SidTypeGroup,
3280 SidTypeDomain,
3281 SidTypeAlias,
3282 SidTypeWellKnownGroup,
3283 SidTypeDeletedAccount,
3284 SidTypeInvalid,
3285 SidTypeUnknown
3286 } SID_NAME_USE,*PSID_NAME_USE;
3288 /* Access rights */
3290 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3291 #undef DELETE
3292 #define DELETE 0x00010000
3293 #define READ_CONTROL 0x00020000
3294 #define WRITE_DAC 0x00040000
3295 #define WRITE_OWNER 0x00080000
3296 #define SYNCHRONIZE 0x00100000
3297 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
3299 #define STANDARD_RIGHTS_READ READ_CONTROL
3300 #define STANDARD_RIGHTS_WRITE READ_CONTROL
3301 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
3303 #define STANDARD_RIGHTS_ALL 0x001f0000
3305 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
3307 #define GENERIC_READ 0x80000000
3308 #define GENERIC_WRITE 0x40000000
3309 #define GENERIC_EXECUTE 0x20000000
3310 #define GENERIC_ALL 0x10000000
3312 #define MAXIMUM_ALLOWED 0x02000000
3313 #define ACCESS_SYSTEM_SECURITY 0x01000000
3315 #define EVENT_MODIFY_STATE 0x0002
3316 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3318 #define SEMAPHORE_MODIFY_STATE 0x0002
3319 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3321 #define MUTEX_MODIFY_STATE 0x0001
3322 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3324 #define TIMER_QUERY_STATE 0x0001
3325 #define TIMER_MODIFY_STATE 0x0002
3326 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3328 #define PROCESS_TERMINATE 0x0001
3329 #define PROCESS_CREATE_THREAD 0x0002
3330 #define PROCESS_VM_OPERATION 0x0008
3331 #define PROCESS_VM_READ 0x0010
3332 #define PROCESS_VM_WRITE 0x0020
3333 #define PROCESS_DUP_HANDLE 0x0040
3334 #define PROCESS_CREATE_PROCESS 0x0080
3335 #define PROCESS_SET_QUOTA 0x0100
3336 #define PROCESS_SET_INFORMATION 0x0200
3337 #define PROCESS_QUERY_INFORMATION 0x0400
3338 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3340 #define THREAD_TERMINATE 0x0001
3341 #define THREAD_SUSPEND_RESUME 0x0002
3342 #define THREAD_GET_CONTEXT 0x0008
3343 #define THREAD_SET_CONTEXT 0x0010
3344 #define THREAD_SET_INFORMATION 0x0020
3345 #define THREAD_QUERY_INFORMATION 0x0040
3346 #define THREAD_SET_THREAD_TOKEN 0x0080
3347 #define THREAD_IMPERSONATE 0x0100
3348 #define THREAD_DIRECT_IMPERSONATION 0x0200
3349 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3351 #define THREAD_BASE_PRIORITY_LOWRT 15
3352 #define THREAD_BASE_PRIORITY_MAX 2
3353 #define THREAD_BASE_PRIORITY_MIN -2
3354 #define THREAD_BASE_PRIORITY_IDLE -15
3356 #define SECTION_QUERY 0x0001
3357 #define SECTION_MAP_WRITE 0x0002
3358 #define SECTION_MAP_READ 0x0004
3359 #define SECTION_MAP_EXECUTE 0x0008
3360 #define SECTION_EXTEND_SIZE 0x0010
3361 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
3363 #define FILE_READ_DATA 0x0001 /* file & pipe */
3364 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
3365 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
3366 #define FILE_ADD_FILE 0x0002 /* directory */
3367 #define FILE_APPEND_DATA 0x0004 /* file */
3368 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
3369 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
3370 #define FILE_READ_EA 0x0008 /* file & directory */
3371 #define FILE_READ_PROPERTIES FILE_READ_EA
3372 #define FILE_WRITE_EA 0x0010 /* file & directory */
3373 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
3374 #define FILE_EXECUTE 0x0020 /* file */
3375 #define FILE_TRAVERSE 0x0020 /* directory */
3376 #define FILE_DELETE_CHILD 0x0040 /* directory */
3377 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
3378 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
3379 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3381 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3382 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3383 SYNCHRONIZE)
3384 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3385 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3386 FILE_APPEND_DATA | SYNCHRONIZE)
3387 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3388 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3391 /* File attribute flags */
3392 #define FILE_SHARE_READ 0x00000001L
3393 #define FILE_SHARE_WRITE 0x00000002L
3394 #define FILE_SHARE_DELETE 0x00000004L
3395 #define FILE_ATTRIBUTE_READONLY 0x00000001L
3396 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
3397 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
3398 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
3399 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
3400 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
3401 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
3402 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
3403 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
3404 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
3405 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
3406 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
3408 /* File notification flags */
3409 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
3410 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
3411 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
3412 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
3413 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
3414 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
3415 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
3416 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
3418 #define FILE_ACTION_ADDED 0x00000001
3419 #define FILE_ACTION_REMOVED 0x00000002
3420 #define FILE_ACTION_MODIFIED 0x00000003
3421 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
3422 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
3425 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
3426 #define FILE_CASE_PRESERVED_NAMES 0x00000002
3427 #define FILE_UNICODE_ON_DISK 0x00000004
3428 #define FILE_PERSISTENT_ACLS 0x00000008
3429 #define FILE_FILE_COMPRESSION 0x00000010
3430 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
3432 /* File alignments (NT) */
3433 #define FILE_BYTE_ALIGNMENT 0x00000000
3434 #define FILE_WORD_ALIGNMENT 0x00000001
3435 #define FILE_LONG_ALIGNMENT 0x00000003
3436 #define FILE_QUAD_ALIGNMENT 0x00000007
3437 #define FILE_OCTA_ALIGNMENT 0x0000000f
3438 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
3439 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
3440 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
3441 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
3442 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
3444 #define REG_NONE 0 /* no type */
3445 #define REG_SZ 1 /* string type (ASCII) */
3446 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3447 #define REG_BINARY 3 /* binary format, callerspecific */
3448 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3449 #define REG_DWORD 4 /* DWORD in little endian format */
3450 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
3451 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
3452 #define REG_LINK 6 /* symbolic link (UNICODE) */
3453 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3454 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
3455 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
3456 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3458 /* ----------------------------- begin registry ----------------------------- */
3460 /* Registry security values */
3461 #define OWNER_SECURITY_INFORMATION 0x00000001
3462 #define GROUP_SECURITY_INFORMATION 0x00000002
3463 #define DACL_SECURITY_INFORMATION 0x00000004
3464 #define SACL_SECURITY_INFORMATION 0x00000008
3466 #define REG_OPTION_RESERVED 0x00000000
3467 #define REG_OPTION_NON_VOLATILE 0x00000000
3468 #define REG_OPTION_VOLATILE 0x00000001
3469 #define REG_OPTION_CREATE_LINK 0x00000002
3470 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
3471 #define REG_OPTION_OPEN_LINK 0x00000008
3472 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
3473 REG_OPTION_NON_VOLATILE| \
3474 REG_OPTION_VOLATILE| \
3475 REG_OPTION_CREATE_LINK| \
3476 REG_OPTION_BACKUP_RESTORE| \
3477 REG_OPTION_OPEN_LINK)
3480 #define REG_CREATED_NEW_KEY 0x00000001
3481 #define REG_OPENED_EXISTING_KEY 0x00000002
3483 /* For RegNotifyChangeKeyValue */
3484 #define REG_NOTIFY_CHANGE_NAME 0x01
3485 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
3486 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
3487 #define REG_NOTIFY_CHANGE_SECURITY 0x08
3489 #define KEY_QUERY_VALUE 0x00000001
3490 #define KEY_SET_VALUE 0x00000002
3491 #define KEY_CREATE_SUB_KEY 0x00000004
3492 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
3493 #define KEY_NOTIFY 0x00000010
3494 #define KEY_CREATE_LINK 0x00000020
3496 #define KEY_READ ((STANDARD_RIGHTS_READ| \
3497 KEY_QUERY_VALUE| \
3498 KEY_ENUMERATE_SUB_KEYS| \
3499 KEY_NOTIFY) \
3500 & (~SYNCHRONIZE) \
3502 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
3503 KEY_SET_VALUE| \
3504 KEY_CREATE_SUB_KEY) \
3505 & (~SYNCHRONIZE) \
3507 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
3508 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
3509 KEY_QUERY_VALUE| \
3510 KEY_SET_VALUE| \
3511 KEY_CREATE_SUB_KEY| \
3512 KEY_ENUMERATE_SUB_KEYS| \
3513 KEY_NOTIFY| \
3514 KEY_CREATE_LINK) \
3515 & (~SYNCHRONIZE) \
3517 /* ------------------------------ end registry ------------------------------ */
3520 #define EVENTLOG_SUCCESS 0x0000
3521 #define EVENTLOG_ERROR_TYPE 0x0001
3522 #define EVENTLOG_WARNING_TYPE 0x0002
3523 #define EVENTLOG_INFORMATION_TYPE 0x0004
3524 #define EVENTLOG_AUDIT_SUCCESS 0x0008
3525 #define EVENTLOG_AUDIT_FAILURE 0x0010
3527 #define SERVICE_BOOT_START 0x00000000
3528 #define SERVICE_SYSTEM_START 0x00000001
3529 #define SERVICE_AUTO_START 0x00000002
3530 #define SERVICE_DEMAND_START 0x00000003
3531 #define SERVICE_DISABLED 0x00000004
3533 #define SERVICE_ERROR_IGNORE 0x00000000
3534 #define SERVICE_ERROR_NORMAL 0x00000001
3535 #define SERVICE_ERROR_SEVERE 0x00000002
3536 #define SERVICE_ERROR_CRITICAL 0x00000003
3538 /* Service types */
3539 #define SERVICE_KERNEL_DRIVER 0x00000001
3540 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
3541 #define SERVICE_ADAPTER 0x00000004
3542 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
3544 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
3545 SERVICE_RECOGNIZER_DRIVER )
3547 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
3548 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
3549 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
3551 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
3553 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
3554 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
3557 typedef enum _CM_SERVICE_NODE_TYPE
3559 DriverType = SERVICE_KERNEL_DRIVER,
3560 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
3561 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
3562 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3563 AdapterType = SERVICE_ADAPTER,
3564 RecognizerType = SERVICE_RECOGNIZER_DRIVER
3565 } SERVICE_NODE_TYPE;
3567 typedef enum _CM_SERVICE_LOAD_TYPE
3569 BootLoad = SERVICE_BOOT_START,
3570 SystemLoad = SERVICE_SYSTEM_START,
3571 AutoLoad = SERVICE_AUTO_START,
3572 DemandLoad = SERVICE_DEMAND_START,
3573 DisableLoad = SERVICE_DISABLED
3574 } SERVICE_LOAD_TYPE;
3576 typedef enum _CM_ERROR_CONTROL_TYPE
3578 IgnoreError = SERVICE_ERROR_IGNORE,
3579 NormalError = SERVICE_ERROR_NORMAL,
3580 SevereError = SERVICE_ERROR_SEVERE,
3581 CriticalError = SERVICE_ERROR_CRITICAL
3582 } SERVICE_ERROR_TYPE;
3586 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
3587 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
3588 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
3589 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
3590 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
3592 #include "guiddef.h"
3594 typedef struct _RTL_CRITICAL_SECTION_DEBUG
3596 WORD Type;
3597 WORD CreatorBackTraceIndex;
3598 struct _RTL_CRITICAL_SECTION *CriticalSection;
3599 LIST_ENTRY ProcessLocksList;
3600 DWORD EntryCount;
3601 DWORD ContentionCount;
3602 DWORD Spare[ 2 ];
3603 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
3605 typedef struct _RTL_CRITICAL_SECTION {
3606 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
3607 LONG LockCount;
3608 LONG RecursionCount;
3609 HANDLE OwningThread;
3610 HANDLE LockSemaphore;
3611 ULONG_PTR SpinCount;
3612 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
3614 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
3616 #endif /* __WINE_WINNT_H */