Make sure sed uses the right locale.
[wine.git] / include / winnt.h
blob2c8596ed038b3c173a7ef4321d04050811092cdc
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
32 #define NTAPI __stdcall
34 /* Macro for structure packing and more. */
36 #ifdef __GNUC__
37 #define WINE_PACKED __attribute__((packed))
38 #define WINE_UNUSED __attribute__((unused))
39 #else
40 #define WINE_PACKED /* nothing */
41 #define WINE_UNUSED /* nothing */
42 #endif
44 #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64) || defined(__MINGW32__)) && !defined(MIDL_PASS)
45 # if defined(_MSC_VER)
46 # define DECLSPEC_IMPORT __declspec(dllimport)
47 # elif defined(__MINGW32__)
48 # define DECLSPEC_IMPORT __attribute__((dllimport))
49 # else
50 # define DECLSPEC_IMPORT
51 # endif
52 #else
53 # define DECLSPEC_IMPORT
54 #endif
56 #ifndef DECLSPEC_NORETURN
57 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
58 # define DECLSPEC_NORETURN __declspec(noreturn)
59 # elif defined(__GNUC__)
60 # define DECLSPEC_NORETURN __attribute__((noreturn))
61 # else
62 # define DECLSPEC_NORETURN
63 # endif
64 #endif
66 #ifndef DECLSPEC_ALIGN
67 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
68 # define DECLSPEC_ALIGN(x) __declspec(align(x))
69 # elif defined(__GNUC__)
70 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
71 # else
72 # define DECLSPEC_ALIGN(x)
73 # endif
74 #endif
76 #ifndef DECLSPEC_CACHEALIGN
77 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
78 #endif
80 #ifndef DECLSPEC_UUID
81 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
82 # define DECLSPEC_UUID(x) __declspec(uuid(x))
83 # else
84 # define DECLSPEC_UUID(x)
85 # endif
86 #endif
88 #ifndef DECLSPEC_NOVTABLE
89 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
90 # define DECLSPEC_NOVTABLE __declspec(novtable)
91 # else
92 # define DECLSPEC_NOVTABLE
93 # endif
94 #endif
96 #ifndef DECLSPEC_SELECTANY
97 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
98 #define DECLSPEC_SELECTANY __declspec(selectany)
99 #else
100 #define DECLSPEC_SELECTANY
101 #endif
102 #endif
104 #ifndef NOP_FUNCTION
105 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
106 # define NOP_FUNCTION __noop
107 # else
108 # define NOP_FUNCTION (void)0
109 # endif
110 #endif
112 #ifndef DECLSPEC_ADDRSAFE
113 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
114 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
115 # else
116 # define DECLSPEC_ADDRSAFE
117 # endif
118 #endif
120 #ifndef FORCEINLINE
121 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
122 # define FORCEINLINE __forceinline
123 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
124 # define FORCEINLINE __attribute__((always_inline))
125 # else
126 # define FORCEINLINE inline
127 # endif
128 #endif
130 #ifndef DECLSPEC_DEPRECATED
131 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
132 # define DECLSPEC_DEPRECATED __declspec(deprecated)
133 # define DEPRECATE_SUPPORTED
134 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
135 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
136 # define DEPRECATE_SUPPORTED
137 # else
138 # define DECLSPEC_DEPRECATED
139 # undef DEPRECATE_SUPPORTED
140 # endif
141 #endif
143 /* Anonymous union/struct handling */
145 #ifndef NONAMELESSSTRUCT
146 # ifdef __GNUC__
147 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
148 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
149 # define NONAMELESSSTRUCT
150 # endif
151 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
152 # define NONAMELESSSTRUCT
153 # endif
154 #endif /* NONAMELESSSTRUCT */
156 #ifndef NONAMELESSUNION
157 # ifdef __GNUC__
158 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
159 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
160 # define NONAMELESSUNION
161 # endif
162 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
163 # define NONAMELESSUNION
164 # endif
165 #endif /* NONAMELESSUNION */
167 #ifndef NONAMELESSSTRUCT
168 #define DUMMYSTRUCTNAME
169 #define DUMMYSTRUCTNAME1
170 #define DUMMYSTRUCTNAME2
171 #define DUMMYSTRUCTNAME3
172 #define DUMMYSTRUCTNAME4
173 #define DUMMYSTRUCTNAME5
174 #else /* !defined(NONAMELESSSTRUCT) */
175 #define DUMMYSTRUCTNAME s
176 #define DUMMYSTRUCTNAME1 s1
177 #define DUMMYSTRUCTNAME2 s2
178 #define DUMMYSTRUCTNAME3 s3
179 #define DUMMYSTRUCTNAME4 s4
180 #define DUMMYSTRUCTNAME5 s5
181 #endif /* !defined(NONAMELESSSTRUCT) */
183 #ifndef NONAMELESSUNION
184 #define DUMMYUNIONNAME
185 #define DUMMYUNIONNAME1
186 #define DUMMYUNIONNAME2
187 #define DUMMYUNIONNAME3
188 #define DUMMYUNIONNAME4
189 #define DUMMYUNIONNAME5
190 #define DUMMYUNIONNAME6
191 #define DUMMYUNIONNAME7
192 #define DUMMYUNIONNAME8
193 #else /* !defined(NONAMELESSUNION) */
194 #define DUMMYUNIONNAME u
195 #define DUMMYUNIONNAME1 u1
196 #define DUMMYUNIONNAME2 u2
197 #define DUMMYUNIONNAME3 u3
198 #define DUMMYUNIONNAME4 u4
199 #define DUMMYUNIONNAME5 u5
200 #define DUMMYUNIONNAME6 u6
201 #define DUMMYUNIONNAME7 u7
202 #define DUMMYUNIONNAME8 u8
203 #endif /* !defined(NONAMELESSUNION) */
205 /* C99 restrict support */
207 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
208 # if defined(_MSC_VER) && defined(_M_MRX000)
209 # define RESTRICTED_POINTER __restrict
210 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
211 # define RESTRICTED_POINTER __restrict
212 # else
213 # define RESTRICTED_POINTER
214 # endif
215 #else
216 # define RESTRICTED_POINTER
217 #endif
219 /* C99 unaligned support */
221 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
222 # define UNALIGNED __unaligned
223 # ifdef _WIN64
224 # define UNALIGNED64 __unaligned
225 # else
226 # define UNALIGNED64
227 # endif
228 #else
229 # define UNALIGNED
230 # define UNALIGNED64
231 #endif
233 /* Alignment macros */
235 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
236 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
237 #define MEMORY_ALLOCATION_ALIGNMENT 16
238 #else
239 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
240 #define MEMORY_ALLOCATION_ALIGNMENT 8
241 #endif
243 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
244 # define TYPE_ALIGNMENT(t) __alignof(t)
245 #elif defined(__GNUC__)
246 # define TYPE_ALIGNMENT(t) __alignof__(t)
247 #else
248 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
249 #endif
251 #ifdef _WIN64
252 # define PROBE_ALIGNMENT(_s) \
253 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
254 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
255 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
256 #else
257 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
258 #endif
260 /* Compile time assertion */
262 #if defined(_MSC_VER)
263 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
264 #elif defined(__GNUC__)
265 # define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1]
266 #endif
268 /* Error Masks */
269 #define APPLICATION_ERROR_MASK 0x20000000
270 #define ERROR_SEVERITY_SUCCESS 0x00000000
271 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
272 #define ERROR_SEVERITY_WARNING 0x80000000
273 #define ERROR_SEVERITY_ERROR 0xC0000000
275 /* Microsoft's macros for declaring functions */
277 #ifdef __cplusplus
278 # define EXTERN_C extern "C"
279 #else
280 # define EXTERN_C extern
281 #endif
283 #define STDMETHODCALLTYPE __stdcall
284 #define STDMETHODVCALLTYPE __cdecl
285 #define STDAPICALLTYPE __stdcall
286 #define STDAPIVCALLTYPE __cdecl
288 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
289 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
290 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
291 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
292 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
293 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
294 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
295 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
297 /* Define the basic types */
298 #ifndef VOID
299 #define VOID void
300 #endif
301 typedef VOID *PVOID;
302 typedef BYTE BOOLEAN, *PBOOLEAN;
303 typedef char CHAR, *PCHAR;
304 typedef short SHORT, *PSHORT;
305 typedef long LONG, *PLONG;
307 /* Some systems might have wchar_t, but we really need 16 bit characters */
308 #ifdef WINE_UNICODE_NATIVE
309 typedef wchar_t WCHAR, *PWCHAR;
310 #else
311 typedef unsigned short WCHAR, *PWCHAR;
312 #endif
314 /* 'Extended/Wide' numerical types */
315 #ifndef _ULONGLONG_
316 #define _ULONGLONG_
317 typedef signed __int64 LONGLONG, *PLONGLONG;
318 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
319 #endif
321 #ifndef _DWORDLONG_
322 #define _DWORDLONG_
323 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
324 #endif
326 /* ANSI string types */
327 typedef CHAR *PCH, *LPCH;
328 typedef const CHAR *PCCH, *LPCCH;
329 typedef CHAR *PSTR, *LPSTR, *NPSTR;
330 typedef const CHAR *PCSTR, *LPCSTR;
332 /* Unicode string types */
333 typedef WCHAR *PWCH, *LPWCH;
334 typedef const WCHAR *PCWCH, *LPCWCH;
335 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
336 typedef const WCHAR *PCWSTR, *LPCWSTR;
338 /* Neutral character and string types */
339 /* These are only defined for Winelib, i.e. _not_ defined for
340 * the emulator. The reason is they depend on the UNICODE
341 * macro which only exists in the user's code.
343 #ifndef __WINESRC__
344 # ifdef UNICODE
345 typedef WCHAR TCHAR, *PTCHAR;
346 typedef LPWSTR PTSTR, LPTSTR;
347 typedef LPCWSTR PCTSTR, LPCTSTR;
348 # define __TEXT(string) L##string
349 # else /* UNICODE */
350 typedef CHAR TCHAR, *PTCHAR;
351 typedef LPSTR PTSTR, LPTSTR;
352 typedef LPCSTR PCTSTR, LPCTSTR;
353 # define __TEXT(string) string
354 # endif /* UNICODE */
355 # define TEXT(quote) __TEXT(quote)
356 #endif /* __WINESRC__ */
358 /* Misc common WIN32 types */
359 typedef char CCHAR;
360 typedef LONG HRESULT;
361 typedef DWORD LCID, *PLCID;
362 typedef WORD LANGID;
363 typedef DWORD EXECUTION_STATE;
365 /* Handle type */
367 typedef void *HANDLE;
368 typedef HANDLE *PHANDLE, *LPHANDLE;
370 #ifdef STRICT
371 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
372 #else /*STRICT*/
373 #define DECLARE_HANDLE(a) typedef HANDLE a
374 #endif /*STRICT*/
376 /* Defines */
378 #ifndef WIN32_NO_STATUS
380 #define STATUS_WAIT_0 0x00000000
381 #define STATUS_ABANDONED_WAIT_0 0x00000080
382 #define STATUS_USER_APC 0x000000C0
383 #define STATUS_TIMEOUT 0x00000102
384 #define STATUS_PENDING 0x00000103
385 #define STATUS_SEGMENT_NOTIFICATION 0x40000005
386 #define STATUS_GUARD_PAGE_VIOLATION 0x80000001
387 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
388 #define STATUS_BREAKPOINT 0x80000003
389 #define STATUS_SINGLE_STEP 0x80000004
390 #define STATUS_ACCESS_VIOLATION 0xC0000005
391 #define STATUS_IN_PAGE_ERROR 0xC0000006
392 #define STATUS_INVALID_HANDLE 0xC0000008
393 #define STATUS_NO_MEMORY 0xC0000017
394 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
395 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
396 #define STATUS_INVALID_DISPOSITION 0xC0000026
397 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
398 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
399 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
400 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
401 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
402 #define STATUS_FLOAT_OVERFLOW 0xC0000091
403 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
404 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
405 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
406 #define STATUS_INTEGER_OVERFLOW 0xC0000095
407 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
408 #define STATUS_STACK_OVERFLOW 0xC00000FD
409 #define STATUS_CONTROL_C_EXIT 0xC000013A
410 #define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
411 #define STATUS_FLOAT_MULTIPLE_TRAPS 0xC00002B5
412 #define STATUS_REG_NAT_CONSUMPTION 0xC00002C9
413 #define STATUS_SXS_EARLY_DEACTIVATION 0xC015000F
414 #define STATUS_SXS_INVALID_DEACTIVATION 0xC0150010
416 /* status values for ContinueDebugEvent */
417 #define DBG_EXCEPTION_HANDLED 0x00010001
418 #define DBG_CONTINUE 0x00010002
419 #define DBG_TERMINATE_THREAD 0x40010003
420 #define DBG_TERMINATE_PROCESS 0x40010004
421 #define DBG_CONTROL_C 0x40010005
422 #define DBG_CONTROL_BREAK 0x40010008
423 #define DBG_COMMAND_EXCEPTION 0x40010009
424 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
426 #endif /* WIN32_NO_STATUS */
428 /* Argument 1 passed to the DllEntryProc. */
429 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
430 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
431 #define DLL_THREAD_ATTACH 2 /* attach new thread */
432 #define DLL_THREAD_DETACH 3 /* detach thread */
435 /* u.x.wProcessorArchitecture (NT) */
436 #define PROCESSOR_ARCHITECTURE_INTEL 0
437 #define PROCESSOR_ARCHITECTURE_MIPS 1
438 #define PROCESSOR_ARCHITECTURE_ALPHA 2
439 #define PROCESSOR_ARCHITECTURE_PPC 3
440 #define PROCESSOR_ARCHITECTURE_SHX 4
441 #define PROCESSOR_ARCHITECTURE_ARM 5
442 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
444 /* dwProcessorType */
445 #define PROCESSOR_INTEL_386 386
446 #define PROCESSOR_INTEL_486 486
447 #define PROCESSOR_INTEL_PENTIUM 586
448 #define PROCESSOR_INTEL_860 860
449 #define PROCESSOR_MIPS_R2000 2000
450 #define PROCESSOR_MIPS_R3000 3000
451 #define PROCESSOR_MIPS_R4000 4000
452 #define PROCESSOR_ALPHA_21064 21064
453 #define PROCESSOR_PPC_601 601
454 #define PROCESSOR_PPC_603 603
455 #define PROCESSOR_PPC_604 604
456 #define PROCESSOR_PPC_620 620
457 #define PROCESSOR_HITACHI_SH3 10003
458 #define PROCESSOR_HITACHI_SH3E 10004
459 #define PROCESSOR_HITACHI_SH4 10005
460 #define PROCESSOR_MOTOROLA_821 821
461 #define PROCESSOR_SHx_SH3 103
462 #define PROCESSOR_SHx_SH4 104
463 #define PROCESSOR_STRONGARM 2577
464 #define PROCESSOR_ARM720 1824 /* 0x720 */
465 #define PROCESSOR_ARM820 2080 /* 0x820 */
466 #define PROCESSOR_ARM920 2336 /* 0x920 */
467 #define PROCESSOR_ARM_7TDMI 70001
469 #define MAXIMUM_PROCESSORS 32
470 typedef struct _MEMORY_BASIC_INFORMATION
472 LPVOID BaseAddress;
473 LPVOID AllocationBase;
474 DWORD AllocationProtect;
475 DWORD RegionSize;
476 DWORD State;
477 DWORD Protect;
478 DWORD Type;
479 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
481 #define PAGE_NOACCESS 0x01
482 #define PAGE_READONLY 0x02
483 #define PAGE_READWRITE 0x04
484 #define PAGE_WRITECOPY 0x08
485 #define PAGE_EXECUTE 0x10
486 #define PAGE_EXECUTE_READ 0x20
487 #define PAGE_EXECUTE_READWRITE 0x40
488 #define PAGE_EXECUTE_WRITECOPY 0x80
489 #define PAGE_GUARD 0x100
490 #define PAGE_NOCACHE 0x200
492 #define MEM_COMMIT 0x00001000
493 #define MEM_RESERVE 0x00002000
494 #define MEM_DECOMMIT 0x00004000
495 #define MEM_RELEASE 0x00008000
496 #define MEM_FREE 0x00010000
497 #define MEM_PRIVATE 0x00020000
498 #define MEM_MAPPED 0x00040000
499 #define MEM_RESET 0x00080000
500 #define MEM_TOP_DOWN 0x00100000
501 #ifdef __WINESRC__
502 #define MEM_SYSTEM 0x80000000
503 #endif
505 #define SEC_FILE 0x00800000
506 #define SEC_IMAGE 0x01000000
507 #define SEC_RESERVE 0x04000000
508 #define SEC_COMMIT 0x08000000
509 #define SEC_NOCACHE 0x10000000
510 #define MEM_IMAGE SEC_IMAGE
513 #define MINCHAR 0x80
514 #define MAXCHAR 0x7f
515 #define MINSHORT 0x8000
516 #define MAXSHORT 0x7fff
517 #define MINLONG 0x80000000
518 #define MAXLONG 0x7fffffff
519 #define MAXBYTE 0xff
520 #define MAXWORD 0xffff
521 #define MAXDWORD 0xffffffff
523 #define FIELD_OFFSET(type, field) \
524 ((LONG)(INT)&(((type *)0)->field))
526 #define CONTAINING_RECORD(address, type, field) \
527 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
529 /* Types */
531 typedef struct _LIST_ENTRY {
532 struct _LIST_ENTRY *Flink;
533 struct _LIST_ENTRY *Blink;
534 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
536 typedef struct _SINGLE_LIST_ENTRY {
537 struct _SINGLE_LIST_ENTRY *Next;
538 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
540 /* Heap flags */
542 #define HEAP_NO_SERIALIZE 0x00000001
543 #define HEAP_GROWABLE 0x00000002
544 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
545 #define HEAP_ZERO_MEMORY 0x00000008
546 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
547 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
548 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
549 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
550 #define HEAP_CREATE_ALIGN_16 0x00010000
551 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
553 /* This flag allows it to create heaps shared by all processes under win95,
554 FIXME: correct name */
555 #define HEAP_SHARED 0x04000000
557 /* Processor feature flags. */
558 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
559 #define PF_FLOATING_POINT_EMULATED 1
560 #define PF_COMPARE_EXCHANGE_DOUBLE 2
561 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
562 #define PF_PPC_MOVEMEM_64BIT_OK 4
563 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
564 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
565 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
566 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
567 #define PF_PAE_ENABLED 9
568 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
571 /* Execution state flags */
572 #define ES_SYSTEM_REQUIRED 0x00000001
573 #define ES_DISPLAY_REQUIRED 0x00000002
574 #define ES_USER_PRESENT 0x00000004
575 #define ES_CONTINUOUS 0x80000000
577 /* The Win32 register context */
579 /* CONTEXT is the CPU-dependent context; it should be used */
580 /* wherever a platform-specific context is needed (e.g. exception */
581 /* handling, Win32 register functions). */
583 /* CONTEXT86 is the i386-specific context; it should be used */
584 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
585 /* Win16 register functions), so that this code can be compiled */
586 /* on all platforms. */
588 #define SIZE_OF_80387_REGISTERS 80
590 typedef struct _FLOATING_SAVE_AREA
592 DWORD ControlWord;
593 DWORD StatusWord;
594 DWORD TagWord;
595 DWORD ErrorOffset;
596 DWORD ErrorSelector;
597 DWORD DataOffset;
598 DWORD DataSelector;
599 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
600 DWORD Cr0NpxState;
601 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
603 #define MAXIMUM_SUPPORTED_EXTENSION 512
605 typedef struct _CONTEXT86
607 DWORD ContextFlags;
609 /* These are selected by CONTEXT_DEBUG_REGISTERS */
610 DWORD Dr0;
611 DWORD Dr1;
612 DWORD Dr2;
613 DWORD Dr3;
614 DWORD Dr6;
615 DWORD Dr7;
617 /* These are selected by CONTEXT_FLOATING_POINT */
618 FLOATING_SAVE_AREA FloatSave;
620 /* These are selected by CONTEXT_SEGMENTS */
621 DWORD SegGs;
622 DWORD SegFs;
623 DWORD SegEs;
624 DWORD SegDs;
626 /* These are selected by CONTEXT_INTEGER */
627 DWORD Edi;
628 DWORD Esi;
629 DWORD Ebx;
630 DWORD Edx;
631 DWORD Ecx;
632 DWORD Eax;
634 /* These are selected by CONTEXT_CONTROL */
635 DWORD Ebp;
636 DWORD Eip;
637 DWORD SegCs;
638 DWORD EFlags;
639 DWORD Esp;
640 DWORD SegSs;
642 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
643 } CONTEXT86;
645 #define CONTEXT_X86 0x00010000
646 #define CONTEXT_i386 CONTEXT_X86
647 #define CONTEXT_i486 CONTEXT_X86
649 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
650 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
651 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
652 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
653 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
654 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
656 /* i386 context definitions */
657 #ifdef __i386__
659 #define CONTEXT_CONTROL CONTEXT86_CONTROL
660 #define CONTEXT_INTEGER CONTEXT86_INTEGER
661 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
662 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
663 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
664 #define CONTEXT_FULL CONTEXT86_FULL
666 typedef CONTEXT86 CONTEXT;
668 #endif /* __i386__ */
670 /* Alpha context definitions */
671 #ifdef _ALPHA_
673 #define CONTEXT_ALPHA 0x00020000
675 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
676 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
677 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
678 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
680 typedef struct _CONTEXT
682 /* selected by CONTEXT_FLOATING_POINT */
683 ULONGLONG FltF0;
684 ULONGLONG FltF1;
685 ULONGLONG FltF2;
686 ULONGLONG FltF3;
687 ULONGLONG FltF4;
688 ULONGLONG FltF5;
689 ULONGLONG FltF6;
690 ULONGLONG FltF7;
691 ULONGLONG FltF8;
692 ULONGLONG FltF9;
693 ULONGLONG FltF10;
694 ULONGLONG FltF11;
695 ULONGLONG FltF12;
696 ULONGLONG FltF13;
697 ULONGLONG FltF14;
698 ULONGLONG FltF15;
699 ULONGLONG FltF16;
700 ULONGLONG FltF17;
701 ULONGLONG FltF18;
702 ULONGLONG FltF19;
703 ULONGLONG FltF20;
704 ULONGLONG FltF21;
705 ULONGLONG FltF22;
706 ULONGLONG FltF23;
707 ULONGLONG FltF24;
708 ULONGLONG FltF25;
709 ULONGLONG FltF26;
710 ULONGLONG FltF27;
711 ULONGLONG FltF28;
712 ULONGLONG FltF29;
713 ULONGLONG FltF30;
714 ULONGLONG FltF31;
716 /* selected by CONTEXT_INTEGER */
717 ULONGLONG IntV0;
718 ULONGLONG IntT0;
719 ULONGLONG IntT1;
720 ULONGLONG IntT2;
721 ULONGLONG IntT3;
722 ULONGLONG IntT4;
723 ULONGLONG IntT5;
724 ULONGLONG IntT6;
725 ULONGLONG IntT7;
726 ULONGLONG IntS0;
727 ULONGLONG IntS1;
728 ULONGLONG IntS2;
729 ULONGLONG IntS3;
730 ULONGLONG IntS4;
731 ULONGLONG IntS5;
732 ULONGLONG IntFp;
733 ULONGLONG IntA0;
734 ULONGLONG IntA1;
735 ULONGLONG IntA2;
736 ULONGLONG IntA3;
737 ULONGLONG IntA4;
738 ULONGLONG IntA5;
739 ULONGLONG IntT8;
740 ULONGLONG IntT9;
741 ULONGLONG IntT10;
742 ULONGLONG IntT11;
743 ULONGLONG IntRa;
744 ULONGLONG IntT12;
745 ULONGLONG IntAt;
746 ULONGLONG IntGp;
747 ULONGLONG IntSp;
748 ULONGLONG IntZero;
750 /* selected by CONTEXT_FLOATING_POINT */
751 ULONGLONG Fpcr;
752 ULONGLONG SoftFpcr;
754 /* selected by CONTEXT_CONTROL */
755 ULONGLONG Fir;
756 DWORD Psr;
757 DWORD ContextFlags;
758 DWORD Fill[4];
759 } CONTEXT;
761 #define _QUAD_PSR_OFFSET HighSoftFpcr
762 #define _QUAD_FLAGS_OFFSET HighFir
764 #endif /* _ALPHA_ */
766 /* Mips context definitions */
767 #ifdef _MIPS_
769 #define CONTEXT_R4000 0x00010000
771 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
772 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
773 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
775 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
777 typedef struct _CONTEXT
779 DWORD Argument[4];
780 /* These are selected by CONTEXT_FLOATING_POINT */
781 DWORD FltF0;
782 DWORD FltF1;
783 DWORD FltF2;
784 DWORD FltF3;
785 DWORD FltF4;
786 DWORD FltF5;
787 DWORD FltF6;
788 DWORD FltF7;
789 DWORD FltF8;
790 DWORD FltF9;
791 DWORD FltF10;
792 DWORD FltF11;
793 DWORD FltF12;
794 DWORD FltF13;
795 DWORD FltF14;
796 DWORD FltF15;
797 DWORD FltF16;
798 DWORD FltF17;
799 DWORD FltF18;
800 DWORD FltF19;
801 DWORD FltF20;
802 DWORD FltF21;
803 DWORD FltF22;
804 DWORD FltF23;
805 DWORD FltF24;
806 DWORD FltF25;
807 DWORD FltF26;
808 DWORD FltF27;
809 DWORD FltF28;
810 DWORD FltF29;
811 DWORD FltF30;
812 DWORD FltF31;
814 /* These are selected by CONTEXT_INTEGER */
815 DWORD IntZero;
816 DWORD IntAt;
817 DWORD IntV0;
818 DWORD IntV1;
819 DWORD IntA0;
820 DWORD IntA1;
821 DWORD IntA2;
822 DWORD IntA3;
823 DWORD IntT0;
824 DWORD IntT1;
825 DWORD IntT2;
826 DWORD IntT3;
827 DWORD IntT4;
828 DWORD IntT5;
829 DWORD IntT6;
830 DWORD IntT7;
831 DWORD IntS0;
832 DWORD IntS1;
833 DWORD IntS2;
834 DWORD IntS3;
835 DWORD IntS4;
836 DWORD IntS5;
837 DWORD IntS6;
838 DWORD IntS7;
839 DWORD IntT8;
840 DWORD IntT9;
841 DWORD IntK0;
842 DWORD IntK1;
843 DWORD IntGp;
844 DWORD IntSp;
845 DWORD IntS8;
846 DWORD IntRa;
847 DWORD IntLo;
848 DWORD IntHi;
850 /* These are selected by CONTEXT_FLOATING_POINT */
851 DWORD Fsr;
853 /* These are selected by CONTEXT_CONTROL */
854 DWORD Fir;
855 DWORD Psr;
857 DWORD ContextFlags;
858 DWORD Fill[2];
859 } CONTEXT;
861 #endif /* _MIPS_ */
863 /* PowerPC context definitions */
864 #ifdef __powerpc__
866 #define CONTEXT_CONTROL 0x0001
867 #define CONTEXT_FLOATING_POINT 0x0002
868 #define CONTEXT_INTEGER 0x0004
869 #define CONTEXT_DEBUG_REGISTERS 0x0008
870 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
872 typedef struct
874 /* These are selected by CONTEXT_FLOATING_POINT */
875 double Fpr0;
876 double Fpr1;
877 double Fpr2;
878 double Fpr3;
879 double Fpr4;
880 double Fpr5;
881 double Fpr6;
882 double Fpr7;
883 double Fpr8;
884 double Fpr9;
885 double Fpr10;
886 double Fpr11;
887 double Fpr12;
888 double Fpr13;
889 double Fpr14;
890 double Fpr15;
891 double Fpr16;
892 double Fpr17;
893 double Fpr18;
894 double Fpr19;
895 double Fpr20;
896 double Fpr21;
897 double Fpr22;
898 double Fpr23;
899 double Fpr24;
900 double Fpr25;
901 double Fpr26;
902 double Fpr27;
903 double Fpr28;
904 double Fpr29;
905 double Fpr30;
906 double Fpr31;
907 double Fpscr;
909 /* These are selected by CONTEXT_INTEGER */
910 DWORD Gpr0;
911 DWORD Gpr1;
912 DWORD Gpr2;
913 DWORD Gpr3;
914 DWORD Gpr4;
915 DWORD Gpr5;
916 DWORD Gpr6;
917 DWORD Gpr7;
918 DWORD Gpr8;
919 DWORD Gpr9;
920 DWORD Gpr10;
921 DWORD Gpr11;
922 DWORD Gpr12;
923 DWORD Gpr13;
924 DWORD Gpr14;
925 DWORD Gpr15;
926 DWORD Gpr16;
927 DWORD Gpr17;
928 DWORD Gpr18;
929 DWORD Gpr19;
930 DWORD Gpr20;
931 DWORD Gpr21;
932 DWORD Gpr22;
933 DWORD Gpr23;
934 DWORD Gpr24;
935 DWORD Gpr25;
936 DWORD Gpr26;
937 DWORD Gpr27;
938 DWORD Gpr28;
939 DWORD Gpr29;
940 DWORD Gpr30;
941 DWORD Gpr31;
943 DWORD Cr;
944 DWORD Xer;
946 /* These are selected by CONTEXT_CONTROL */
947 DWORD Msr;
948 DWORD Iar; /* Instruction Address Register , aka PC ... */
949 DWORD Lr;
950 DWORD Ctr;
952 DWORD ContextFlags;
954 DWORD Dar; /* Fault registers for coredump */
955 DWORD Dsisr;
956 DWORD Trap; /* number of powerpc exception taken */
958 /* These are selected by CONTEXT_DEBUG_REGISTERS */
959 DWORD Dr0;
960 DWORD Dr1;
961 DWORD Dr2;
962 DWORD Dr3;
963 DWORD Dr4;
964 DWORD Dr5;
965 DWORD Dr6;
966 DWORD Dr7;
967 } CONTEXT;
969 typedef struct _STACK_FRAME_HEADER
971 DWORD BackChain;
972 DWORD GlueSaved1;
973 DWORD GlueSaved2;
974 DWORD Reserved1;
975 DWORD Spare1;
976 DWORD Spare2;
978 DWORD Parameter0;
979 DWORD Parameter1;
980 DWORD Parameter2;
981 DWORD Parameter3;
982 DWORD Parameter4;
983 DWORD Parameter5;
984 DWORD Parameter6;
985 DWORD Parameter7;
986 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
988 #endif /* __powerpc__ */
990 #ifdef __ALPHA__
993 * FIXME:
995 * I have no idea if any of this is right as I just ripped
996 * it from mingw-win32api.
1000 #define CONTEXT_ALPHA 0x20000
1001 #define CONTEXT_CONTROL (CONTEXT_ALPHA|1L)
1002 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA|2L)
1003 #define CONTEXT_INTEGER (CONTEXT_ALPHA|4L)
1004 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_FLOATING_POINT|CONTEXT_INTEGER)
1005 typedef struct _CONTEXT {
1006 ULONGLONG FltF0;
1007 ULONGLONG FltF1;
1008 ULONGLONG FltF2;
1009 ULONGLONG FltF3;
1010 ULONGLONG FltF4;
1011 ULONGLONG FltF5;
1012 ULONGLONG FltF6;
1013 ULONGLONG FltF7;
1014 ULONGLONG FltF8;
1015 ULONGLONG FltF9;
1016 ULONGLONG FltF10;
1017 ULONGLONG FltF11;
1018 ULONGLONG FltF12;
1019 ULONGLONG FltF13;
1020 ULONGLONG FltF14;
1021 ULONGLONG FltF15;
1022 ULONGLONG FltF16;
1023 ULONGLONG FltF17;
1024 ULONGLONG FltF18;
1025 ULONGLONG FltF19;
1026 ULONGLONG FltF20;
1027 ULONGLONG FltF21;
1028 ULONGLONG FltF22;
1029 ULONGLONG FltF23;
1030 ULONGLONG FltF24;
1031 ULONGLONG FltF25;
1032 ULONGLONG FltF26;
1033 ULONGLONG FltF27;
1034 ULONGLONG FltF28;
1035 ULONGLONG FltF29;
1036 ULONGLONG FltF30;
1037 ULONGLONG FltF31;
1038 ULONGLONG IntV0;
1039 ULONGLONG IntT0;
1040 ULONGLONG IntT1;
1041 ULONGLONG IntT2;
1042 ULONGLONG IntT3;
1043 ULONGLONG IntT4;
1044 ULONGLONG IntT5;
1045 ULONGLONG IntT6;
1046 ULONGLONG IntT7;
1047 ULONGLONG IntS0;
1048 ULONGLONG IntS1;
1049 ULONGLONG IntS2;
1050 ULONGLONG IntS3;
1051 ULONGLONG IntS4;
1052 ULONGLONG IntS5;
1053 ULONGLONG IntFp;
1054 ULONGLONG IntA0;
1055 ULONGLONG IntA1;
1056 ULONGLONG IntA2;
1057 ULONGLONG IntA3;
1058 ULONGLONG IntA4;
1059 ULONGLONG IntA5;
1060 ULONGLONG IntT8;
1061 ULONGLONG IntT9;
1062 ULONGLONG IntT10;
1063 ULONGLONG IntT11;
1064 ULONGLONG IntRa;
1065 ULONGLONG IntT12;
1066 ULONGLONG IntAt;
1067 ULONGLONG IntGp;
1068 ULONGLONG IntSp;
1069 ULONGLONG IntZero;
1070 ULONGLONG Fpcr;
1071 ULONGLONG SoftFpcr;
1072 ULONGLONG Fir;
1073 DWORD Psr;
1074 DWORD ContextFlags;
1075 DWORD Fill[4];
1076 } CONTEXT;
1078 #endif /* __ALPHA__ */
1080 #ifdef __sparc__
1083 * FIXME:
1085 * There is no official CONTEXT structure defined for the SPARC
1086 * architecture, so I just made one up.
1088 * This structure is valid only for 32-bit SPARC architectures,
1089 * not for 64-bit SPARC.
1091 * Note that this structure contains only the 'top-level' registers;
1092 * the rest of the register window chain is not visible.
1094 * The layout follows the Solaris 'prgregset_t' structure.
1098 #define CONTEXT_SPARC 0x10000000
1100 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
1101 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
1102 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
1104 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1106 typedef struct _CONTEXT
1108 DWORD ContextFlags;
1110 /* These are selected by CONTEXT_INTEGER */
1111 DWORD g0;
1112 DWORD g1;
1113 DWORD g2;
1114 DWORD g3;
1115 DWORD g4;
1116 DWORD g5;
1117 DWORD g6;
1118 DWORD g7;
1119 DWORD o0;
1120 DWORD o1;
1121 DWORD o2;
1122 DWORD o3;
1123 DWORD o4;
1124 DWORD o5;
1125 DWORD o6;
1126 DWORD o7;
1127 DWORD l0;
1128 DWORD l1;
1129 DWORD l2;
1130 DWORD l3;
1131 DWORD l4;
1132 DWORD l5;
1133 DWORD l6;
1134 DWORD l7;
1135 DWORD i0;
1136 DWORD i1;
1137 DWORD i2;
1138 DWORD i3;
1139 DWORD i4;
1140 DWORD i5;
1141 DWORD i6;
1142 DWORD i7;
1144 /* These are selected by CONTEXT_CONTROL */
1145 DWORD psr;
1146 DWORD pc;
1147 DWORD npc;
1148 DWORD y;
1149 DWORD wim;
1150 DWORD tbr;
1152 /* FIXME: floating point registers missing */
1154 } CONTEXT;
1156 #endif /* __sparc__ */
1158 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1159 #error You need to define a CONTEXT for your CPU
1160 #endif
1162 typedef CONTEXT *PCONTEXT;
1165 * Language IDs
1168 #define MAKELCID(l, s) (MAKELONG(l, s))
1170 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1171 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1172 #define SUBLANGID(l) ((WORD)(l) >> 10)
1174 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1175 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1177 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1178 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1179 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1180 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1181 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1183 #define UNREFERENCED_PARAMETER(u) (u)
1184 #define DBG_UNREFERENCED_PARAMETER(u) (u)
1185 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (u)
1187 /* FIXME: are the symbolic names correct for LIDs: 0x17, 0x28,
1188 * 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x3a, 0x3b, 0x3c
1190 #define LANG_NEUTRAL 0x00
1191 #define LANG_INVARIANT 0x7f
1193 #define LANG_AFRIKAANS 0x36
1194 #define LANG_ALBANIAN 0x1c
1195 #define LANG_ARABIC 0x01
1196 #define LANG_ARMENIAN 0x2b
1197 #define LANG_ASSAMESE 0x4d
1198 #define LANG_AZERI 0x2c
1199 #define LANG_BASQUE 0x2d
1200 #define LANG_BELARUSIAN 0x23
1201 #define LANG_BENGALI 0x45
1202 #define LANG_BULGARIAN 0x02
1203 #define LANG_CATALAN 0x03
1204 #define LANG_CHINESE 0x04
1205 #define LANG_CROATIAN 0x1a
1206 #define LANG_CZECH 0x05
1207 #define LANG_DANISH 0x06
1208 #define LANG_DIVEHI 0x65
1209 #define LANG_DUTCH 0x13
1210 #define LANG_ENGLISH 0x09
1211 #define LANG_ESTONIAN 0x25
1212 #define LANG_FAEROESE 0x38
1213 #define LANG_FARSI 0x29
1214 #define LANG_FINNISH 0x0b
1215 #define LANG_FRENCH 0x0c
1216 #define LANG_GALICIAN 0x56
1217 #define LANG_GEORGIAN 0x37
1218 #define LANG_GERMAN 0x07
1219 #define LANG_GREEK 0x08
1220 #define LANG_GUJARATI 0x47
1221 #define LANG_HEBREW 0x0d
1222 #define LANG_HINDI 0x39
1223 #define LANG_HUNGARIAN 0x0e
1224 #define LANG_ICELANDIC 0x0f
1225 #define LANG_INDONESIAN 0x21
1226 #define LANG_ITALIAN 0x10
1227 #define LANG_JAPANESE 0x11
1228 #define LANG_KANNADA 0x4b
1229 #define LANG_KASHMIRI 0x60
1230 #define LANG_KAZAK 0x3f
1231 #define LANG_KONKANI 0x57
1232 #define LANG_KOREAN 0x12
1233 #define LANG_KYRGYZ 0x40
1234 #define LANG_LATVIAN 0x26
1235 #define LANG_LITHUANIAN 0x27
1236 #define LANG_MACEDONIAN 0x2f
1237 #define LANG_MALAY 0x3e
1238 #define LANG_MALAYALAM 0x4c
1239 #define LANG_MANIPURI 0x58
1240 #define LANG_MARATHI 0x4e
1241 #define LANG_MONGOLIAN 0x50
1242 #define LANG_NEPALI 0x61
1243 #define LANG_NORWEGIAN 0x14
1244 #define LANG_ORIYA 0x48
1245 #define LANG_POLISH 0x15
1246 #define LANG_PORTUGUESE 0x16
1247 #define LANG_PUNJABI 0x46
1248 #define LANG_ROMANIAN 0x18
1249 #define LANG_RUSSIAN 0x19
1250 #define LANG_SANSKRIT 0x4f
1251 #define LANG_SERBIAN 0x1a
1252 #define LANG_SINDHI 0x59
1253 #define LANG_SLOVAK 0x1b
1254 #define LANG_SLOVENIAN 0x24
1255 #define LANG_SPANISH 0x0a
1256 #define LANG_SWAHILI 0x41
1257 #define LANG_SWEDISH 0x1d
1258 #define LANG_SYRIAC 0x5a
1259 #define LANG_TAMIL 0x49
1260 #define LANG_TATAR 0x44
1261 #define LANG_TELUGU 0x4a
1262 #define LANG_THAI 0x1e
1263 #define LANG_TURKISH 0x1f
1264 #define LANG_UKRAINIAN 0x22
1265 #define LANG_URDU 0x20
1266 #define LANG_UZBEK 0x43
1267 #define LANG_VIETNAMESE 0x2a
1269 /* FIXME: these are not in the Windows header */
1270 #define LANG_GAELIC 0x3c
1271 #define LANG_MALTESE 0x3a
1272 #define LANG_MAORI 0x28
1273 #define LANG_RHAETO_ROMANCE 0x17
1274 #define LANG_SAAMI 0x3b
1275 #define LANG_SORBIAN 0x2e
1276 #define LANG_SUTU 0x30
1277 #define LANG_TSONGA 0x31
1278 #define LANG_TSWANA 0x32
1279 #define LANG_VENDA 0x33
1280 #define LANG_XHOSA 0x34
1281 #define LANG_ZULU 0x35
1283 /* non standard; keep the number high enough (but < 0xff) */
1284 #define LANG_ESPERANTO 0x8f
1285 #define LANG_WALON 0x90
1286 #define LANG_CORNISH 0x91
1287 #define LANG_WELSH 0x92
1288 #define LANG_BRETON 0x93
1290 /* Sublanguage definitions */
1291 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
1292 #define SUBLANG_DEFAULT 0x01 /* user default */
1293 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
1295 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
1296 #define SUBLANG_ARABIC_IRAQ 0x02
1297 #define SUBLANG_ARABIC_EGYPT 0x03
1298 #define SUBLANG_ARABIC_LIBYA 0x04
1299 #define SUBLANG_ARABIC_ALGERIA 0x05
1300 #define SUBLANG_ARABIC_MOROCCO 0x06
1301 #define SUBLANG_ARABIC_TUNISIA 0x07
1302 #define SUBLANG_ARABIC_OMAN 0x08
1303 #define SUBLANG_ARABIC_YEMEN 0x09
1304 #define SUBLANG_ARABIC_SYRIA 0x0a
1305 #define SUBLANG_ARABIC_JORDAN 0x0b
1306 #define SUBLANG_ARABIC_LEBANON 0x0c
1307 #define SUBLANG_ARABIC_KUWAIT 0x0d
1308 #define SUBLANG_ARABIC_UAE 0x0e
1309 #define SUBLANG_ARABIC_BAHRAIN 0x0f
1310 #define SUBLANG_ARABIC_QATAR 0x10
1311 #define SUBLANG_AZERI_LATIN 0x01
1312 #define SUBLANG_AZERI_CYRILLIC 0x02
1313 #define SUBLANG_CHINESE_TRADITIONAL 0x01
1314 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
1315 #define SUBLANG_CHINESE_HONGKONG 0x03
1316 #define SUBLANG_CHINESE_SINGAPORE 0x04
1317 #define SUBLANG_CHINESE_MACAU 0x05
1318 #define SUBLANG_DUTCH 0x01
1319 #define SUBLANG_DUTCH_BELGIAN 0x02
1320 #define SUBLANG_ENGLISH_US 0x01
1321 #define SUBLANG_ENGLISH_UK 0x02
1322 #define SUBLANG_ENGLISH_AUS 0x03
1323 #define SUBLANG_ENGLISH_CAN 0x04
1324 #define SUBLANG_ENGLISH_NZ 0x05
1325 #define SUBLANG_ENGLISH_EIRE 0x06
1326 #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
1327 #define SUBLANG_ENGLISH_JAMAICA 0x08
1328 #define SUBLANG_ENGLISH_CARIBBEAN 0x09
1329 #define SUBLANG_ENGLISH_BELIZE 0x0a
1330 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
1331 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
1332 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
1333 #define SUBLANG_FRENCH 0x01
1334 #define SUBLANG_FRENCH_BELGIAN 0x02
1335 #define SUBLANG_FRENCH_CANADIAN 0x03
1336 #define SUBLANG_FRENCH_SWISS 0x04
1337 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
1338 #define SUBLANG_FRENCH_MONACO 0x06
1339 #define SUBLANG_GERMAN 0x01
1340 #define SUBLANG_GERMAN_SWISS 0x02
1341 #define SUBLANG_GERMAN_AUSTRIAN 0x03
1342 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
1343 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
1344 #define SUBLANG_ITALIAN 0x01
1345 #define SUBLANG_ITALIAN_SWISS 0x02
1346 #define SUBLANG_KASHMIRI_SASIA 0x02
1347 #define SUBLANG_KASHMIRI_INDIA 0x02
1348 #define SUBLANG_KOREAN 0x01
1349 #define SUBLANG_LITHUANIAN 0x01
1350 #define SUBLANG_MALAY_MALAYSIA 0x01
1351 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
1352 #define SUBLANG_NEPALI_INDIA 0x02
1353 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
1354 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
1355 #define SUBLANG_PORTUGUESE 0x02
1356 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
1357 #define SUBLANG_SERBIAN_LATIN 0x02
1358 #define SUBLANG_SERBIAN_CYRILLIC 0x03
1359 #define SUBLANG_SPANISH 0x01
1360 #define SUBLANG_SPANISH_MEXICAN 0x02
1361 #define SUBLANG_SPANISH_MODERN 0x03
1362 #define SUBLANG_SPANISH_GUATEMALA 0x04
1363 #define SUBLANG_SPANISH_COSTA_RICA 0x05
1364 #define SUBLANG_SPANISH_PANAMA 0x06
1365 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
1366 #define SUBLANG_SPANISH_VENEZUELA 0x08
1367 #define SUBLANG_SPANISH_COLOMBIA 0x09
1368 #define SUBLANG_SPANISH_PERU 0x0a
1369 #define SUBLANG_SPANISH_ARGENTINA 0x0b
1370 #define SUBLANG_SPANISH_ECUADOR 0x0c
1371 #define SUBLANG_SPANISH_CHILE 0x0d
1372 #define SUBLANG_SPANISH_URUGUAY 0x0e
1373 #define SUBLANG_SPANISH_PARAGUAY 0x0f
1374 #define SUBLANG_SPANISH_BOLIVIA 0x10
1375 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
1376 #define SUBLANG_SPANISH_HONDURAS 0x12
1377 #define SUBLANG_SPANISH_NICARAGUA 0x13
1378 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
1379 #define SUBLANG_SWEDISH 0x01
1380 #define SUBLANG_SWEDISH_FINLAND 0x02
1381 #define SUBLANG_URDU_PAKISTAN 0x01
1382 #define SUBLANG_URDU_INDIA 0x02
1383 #define SUBLANG_UZBEK_LATIN 0x01
1384 #define SUBLANG_UZBEK_CYRILLIC 0x02
1386 /* FIXME: these are not in the Windows header */
1387 #define SUBLANG_DUTCH_SURINAM 0x03
1388 #define SUBLANG_ROMANIAN 0x01
1389 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
1390 #define SUBLANG_RUSSIAN 0x01
1391 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
1392 #define SUBLANG_CROATIAN 0x01
1393 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
1394 #define SUBLANG_GAELIC 0x01
1395 #define SUBLANG_GAELIC_SCOTTISH 0x02
1396 #define SUBLANG_GAELIC_MANX 0x03
1400 * Sort definitions
1403 #define SORT_DEFAULT 0x0
1404 #define SORT_JAPANESE_XJIS 0x0
1405 #define SORT_JAPANESE_UNICODE 0x1
1406 #define SORT_CHINESE_BIG5 0x0
1407 #define SORT_CHINESE_UNICODE 0x1
1408 #define SORT_KOREAN_KSC 0x0
1409 #define SORT_KOREAN_UNICODE 0x1
1414 * Definitions for IsTextUnicode()
1417 #define IS_TEXT_UNICODE_ASCII16 0x0001
1418 #define IS_TEXT_UNICODE_STATISTICS 0x0002
1419 #define IS_TEXT_UNICODE_CONTROLS 0x0004
1420 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
1421 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
1422 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
1423 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1424 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
1425 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
1426 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
1427 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
1428 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
1429 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
1430 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
1431 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
1432 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
1434 #define MAXIMUM_WAIT_OBJECTS 64
1435 #define MAXIMUM_SUSPEND_COUNT 127
1439 * From OS/2 2.0 exception handling
1440 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1443 #define EH_NONCONTINUABLE 0x01
1444 #define EH_UNWINDING 0x02
1445 #define EH_EXIT_UNWIND 0x04
1446 #define EH_STACK_INVALID 0x08
1447 #define EH_NESTED_CALL 0x10
1449 #define EXCEPTION_CONTINUABLE 0
1450 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
1453 * The exception record used by Win32 to give additional information
1454 * about exception to exception handlers.
1457 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1459 typedef struct __EXCEPTION_RECORD
1461 DWORD ExceptionCode;
1462 DWORD ExceptionFlags;
1463 struct __EXCEPTION_RECORD *ExceptionRecord;
1465 LPVOID ExceptionAddress;
1466 DWORD NumberParameters;
1467 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1468 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1471 * The exception pointers structure passed to exception filters
1472 * in except() and the UnhandledExceptionFilter().
1475 typedef struct _EXCEPTION_POINTERS
1477 PEXCEPTION_RECORD ExceptionRecord;
1478 PCONTEXT ContextRecord;
1479 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1483 * The exception frame, used for registering exception handlers
1484 * Win32 cares only about this, but compilers generally emit
1485 * larger exception frames for their own use.
1488 struct _EXCEPTION_REGISTRATION_RECORD;
1490 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
1491 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
1493 typedef struct _EXCEPTION_REGISTRATION_RECORD
1495 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
1496 PEXCEPTION_HANDLER Handler;
1497 } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
1500 * function pointer to a exception filter
1503 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
1504 typedef LONG (CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1505 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1507 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1508 LPTOP_LEVEL_EXCEPTION_FILTER
1509 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1511 typedef struct _NT_TIB
1513 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1514 PVOID StackBase;
1515 PVOID StackLimit;
1516 PVOID SubSystemTib;
1517 union {
1518 PVOID FiberData;
1519 DWORD Version;
1520 } DUMMYUNIONNAME;
1521 PVOID ArbitraryUserPointer;
1522 struct _NT_TIB *Self;
1523 } NT_TIB, *PNT_TIB;
1525 struct _TEB;
1527 #if defined(__i386__) && defined(__GNUC__)
1528 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1529 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1531 struct _TEB *teb;
1532 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1533 return teb;
1535 #elif defined(__i386__) && defined(_MSC_VER)
1536 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1538 struct _TEB *teb;
1539 __asm mov eax, fs:[0x18];
1540 __asm mov teb, eax;
1541 return teb;
1543 #elif defined(__powerpc__)
1544 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1545 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1547 struct _TEB *teb;
1548 # ifdef __APPLE__
1549 __asm__("\tmr %0, r13" : "=r" (teb));
1550 # else
1551 __asm__("\tmr %0, 2" : "=r" (teb));
1552 # endif
1553 return teb;
1555 #else
1556 extern struct _TEB * WINAPI NtCurrentTeb(void);
1557 #endif
1559 #ifdef NONAMELESSUNION
1560 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
1561 #else
1562 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
1563 #endif
1564 #define GetFiberData() (*(void **)GetCurrentFiber())
1567 * File formats definitions
1570 #include <pshpack2.h>
1571 typedef struct _IMAGE_DOS_HEADER {
1572 WORD e_magic; /* 00: MZ Header signature */
1573 WORD e_cblp; /* 02: Bytes on last page of file */
1574 WORD e_cp; /* 04: Pages in file */
1575 WORD e_crlc; /* 06: Relocations */
1576 WORD e_cparhdr; /* 08: Size of header in paragraphs */
1577 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
1578 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
1579 WORD e_ss; /* 0e: Initial (relative) SS value */
1580 WORD e_sp; /* 10: Initial SP value */
1581 WORD e_csum; /* 12: Checksum */
1582 WORD e_ip; /* 14: Initial IP value */
1583 WORD e_cs; /* 16: Initial (relative) CS value */
1584 WORD e_lfarlc; /* 18: File address of relocation table */
1585 WORD e_ovno; /* 1a: Overlay number */
1586 WORD e_res[4]; /* 1c: Reserved words */
1587 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
1588 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
1589 WORD e_res2[10]; /* 28: Reserved words */
1590 DWORD e_lfanew; /* 3c: Offset to extended header */
1591 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1592 #include <poppack.h>
1594 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
1595 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
1596 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
1597 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
1598 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
1599 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
1602 * This is the Windows executable (NE) header.
1603 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
1605 #include <pshpack2.h>
1606 typedef struct
1608 WORD ne_magic; /* 00 NE signature 'NE' */
1609 BYTE ne_ver; /* 02 Linker version number */
1610 BYTE ne_rev; /* 03 Linker revision number */
1611 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
1612 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
1613 LONG ne_crc; /* 08 Checksum */
1614 WORD ne_flags; /* 0c Flags about segments in this file */
1615 WORD ne_autodata; /* 0e Automatic data segment number */
1616 WORD ne_heap; /* 10 Initial size of local heap */
1617 WORD ne_stack; /* 12 Initial size of stack */
1618 DWORD ne_csip; /* 14 Initial CS:IP */
1619 DWORD ne_sssp; /* 18 Initial SS:SP */
1620 WORD ne_cseg; /* 1c # of entries in segment table */
1621 WORD ne_cmod; /* 1e # of entries in module reference tab. */
1622 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
1623 WORD ne_segtab; /* 22 Offset to segment table */
1624 WORD ne_rsrctab; /* 24 Offset to resource table */
1625 WORD ne_restab; /* 26 Offset to resident-name table */
1626 WORD ne_modtab; /* 28 Offset to module reference table */
1627 WORD ne_imptab; /* 2a Offset to imported name table */
1628 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
1629 WORD ne_cmovent; /* 30 # of movable entry points */
1630 WORD ne_align; /* 32 Logical sector alignment shift count */
1631 WORD ne_cres; /* 34 # of resource segments */
1632 BYTE ne_exetyp; /* 36 Flags indicating target OS */
1633 BYTE ne_flagsothers; /* 37 Additional information flags */
1634 WORD ne_pretthunks; /* 38 Offset to return thunks */
1635 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
1636 WORD ne_swaparea; /* 3c Reserved by Microsoft */
1637 WORD ne_expver; /* 3e Expected Windows version number */
1638 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
1639 #include <poppack.h>
1641 #include <pshpack2.h>
1642 typedef struct _IMAGE_VXD_HEADER {
1643 WORD e32_magic;
1644 BYTE e32_border;
1645 BYTE e32_worder;
1646 DWORD e32_level;
1647 WORD e32_cpu;
1648 WORD e32_os;
1649 DWORD e32_ver;
1650 DWORD e32_mflags;
1651 DWORD e32_mpages;
1652 DWORD e32_startobj;
1653 DWORD e32_eip;
1654 DWORD e32_stackobj;
1655 DWORD e32_esp;
1656 DWORD e32_pagesize;
1657 DWORD e32_lastpagesize;
1658 DWORD e32_fixupsize;
1659 DWORD e32_fixupsum;
1660 DWORD e32_ldrsize;
1661 DWORD e32_ldrsum;
1662 DWORD e32_objtab;
1663 DWORD e32_objcnt;
1664 DWORD e32_objmap;
1665 DWORD e32_itermap;
1666 DWORD e32_rsrctab;
1667 DWORD e32_rsrccnt;
1668 DWORD e32_restab;
1669 DWORD e32_enttab;
1670 DWORD e32_dirtab;
1671 DWORD e32_dircnt;
1672 DWORD e32_fpagetab;
1673 DWORD e32_frectab;
1674 DWORD e32_impmod;
1675 DWORD e32_impmodcnt;
1676 DWORD e32_impproc;
1677 DWORD e32_pagesum;
1678 DWORD e32_datapage;
1679 DWORD e32_preload;
1680 DWORD e32_nrestab;
1681 DWORD e32_cbnrestab;
1682 DWORD e32_nressum;
1683 DWORD e32_autodata;
1684 DWORD e32_debuginfo;
1685 DWORD e32_debuglen;
1686 DWORD e32_instpreload;
1687 DWORD e32_instdemand;
1688 DWORD e32_heapsize;
1689 BYTE e32_res3[12];
1690 DWORD e32_winresoff;
1691 DWORD e32_winreslen;
1692 WORD e32_devid;
1693 WORD e32_ddkver;
1694 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1695 #include <poppack.h>
1697 /* These defines describe the meanings of the bits in the Characteristics
1698 field */
1700 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
1701 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
1702 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
1703 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
1704 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
1705 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
1706 #define IMAGE_FILE_16BIT_MACHINE 0x0040
1707 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
1708 #define IMAGE_FILE_32BIT_MACHINE 0x0100
1709 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
1710 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
1711 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
1712 #define IMAGE_FILE_SYSTEM 0x1000
1713 #define IMAGE_FILE_DLL 0x2000
1714 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
1715 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
1717 /* These are the settings of the Machine field. */
1718 #define IMAGE_FILE_MACHINE_UNKNOWN 0
1719 #define IMAGE_FILE_MACHINE_I860 0x014d
1720 #define IMAGE_FILE_MACHINE_I386 0x014c
1721 #define IMAGE_FILE_MACHINE_R3000 0x0162
1722 #define IMAGE_FILE_MACHINE_R4000 0x0166
1723 #define IMAGE_FILE_MACHINE_R10000 0x0168
1724 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
1725 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
1726 #define IMAGE_FILE_MACHINE_SH3 0x01a2
1727 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
1728 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
1729 #define IMAGE_FILE_MACHINE_SH4 0x01a6
1730 #define IMAGE_FILE_MACHINE_SH5 0x01a8
1731 #define IMAGE_FILE_MACHINE_ARM 0x01c0
1732 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
1733 #define IMAGE_FILE_MACHINE_AM33 0x01d3
1734 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
1735 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
1736 #define IMAGE_FILE_MACHINE_IA64 0x0200
1737 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
1738 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
1739 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
1740 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
1741 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
1742 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
1743 #define IMAGE_FILE_MACHINE_CEF 0x0cef
1744 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
1745 #define IMAGE_FILE_MACHINE_AMD64 0x8664
1746 #define IMAGE_FILE_MACHINE_M32R 0x9041
1747 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
1749 #define IMAGE_SIZEOF_FILE_HEADER 20
1750 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
1751 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
1752 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224
1753 #define IMAGE_SIZEOF_SHORT_NAME 8
1754 #define IMAGE_SIZEOF_SECTION_HEADER 40
1755 #define IMAGE_SIZEOF_SYMBOL 18
1756 #define IMAGE_SIZEOF_AUX_SYMBOL 18
1757 #define IMAGE_SIZEOF_RELOCATION 10
1758 #define IMAGE_SIZEOF_BASE_RELOCATION 8
1759 #define IMAGE_SIZEOF_LINENUMBER 6
1760 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
1762 /* Possible Magic values */
1763 #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
1764 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
1766 /* These are indexes into the DataDirectory array */
1767 #define IMAGE_FILE_EXPORT_DIRECTORY 0
1768 #define IMAGE_FILE_IMPORT_DIRECTORY 1
1769 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
1770 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
1771 #define IMAGE_FILE_SECURITY_DIRECTORY 4
1772 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
1773 #define IMAGE_FILE_DEBUG_DIRECTORY 6
1774 #define IMAGE_FILE_DESCRIPTION_STRING 7
1775 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
1776 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
1777 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
1779 /* Directory Entries, indices into the DataDirectory array */
1781 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
1782 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
1783 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
1784 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
1785 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
1786 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
1787 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
1788 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
1789 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
1790 #define IMAGE_DIRECTORY_ENTRY_TLS 9
1791 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
1792 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
1793 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
1794 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
1795 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
1797 /* Subsystem Values */
1799 #define IMAGE_SUBSYSTEM_UNKNOWN 0
1800 #define IMAGE_SUBSYSTEM_NATIVE 1
1801 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
1802 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
1803 #define IMAGE_SUBSYSTEM_OS2_CUI 5
1804 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
1805 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
1806 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
1807 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
1808 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
1809 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
1810 #define IMAGE_SUBSYSTEM_EFI_ROM 13
1811 #define IMAGE_SUBSYSTEM_XBOX 14
1813 typedef struct _IMAGE_FILE_HEADER {
1814 WORD Machine;
1815 WORD NumberOfSections;
1816 DWORD TimeDateStamp;
1817 DWORD PointerToSymbolTable;
1818 DWORD NumberOfSymbols;
1819 WORD SizeOfOptionalHeader;
1820 WORD Characteristics;
1821 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1823 typedef struct _IMAGE_DATA_DIRECTORY {
1824 DWORD VirtualAddress;
1825 DWORD Size;
1826 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1828 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
1830 typedef struct _IMAGE_OPTIONAL_HEADER {
1832 /* Standard fields */
1834 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
1835 BYTE MajorLinkerVersion;
1836 BYTE MinorLinkerVersion;
1837 DWORD SizeOfCode;
1838 DWORD SizeOfInitializedData;
1839 DWORD SizeOfUninitializedData;
1840 DWORD AddressOfEntryPoint; /* 0x10 */
1841 DWORD BaseOfCode;
1842 DWORD BaseOfData;
1844 /* NT additional fields */
1846 DWORD ImageBase;
1847 DWORD SectionAlignment; /* 0x20 */
1848 DWORD FileAlignment;
1849 WORD MajorOperatingSystemVersion;
1850 WORD MinorOperatingSystemVersion;
1851 WORD MajorImageVersion;
1852 WORD MinorImageVersion;
1853 WORD MajorSubsystemVersion; /* 0x30 */
1854 WORD MinorSubsystemVersion;
1855 DWORD Win32VersionValue;
1856 DWORD SizeOfImage;
1857 DWORD SizeOfHeaders;
1858 DWORD CheckSum; /* 0x40 */
1859 WORD Subsystem;
1860 WORD DllCharacteristics;
1861 DWORD SizeOfStackReserve;
1862 DWORD SizeOfStackCommit;
1863 DWORD SizeOfHeapReserve; /* 0x50 */
1864 DWORD SizeOfHeapCommit;
1865 DWORD LoaderFlags;
1866 DWORD NumberOfRvaAndSizes;
1867 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
1868 /* 0xE0 */
1869 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
1871 typedef struct _IMAGE_NT_HEADERS {
1872 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
1873 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
1874 IMAGE_OPTIONAL_HEADER OptionalHeader; /* 0x18 */
1875 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
1877 #define IMAGE_SIZEOF_SHORT_NAME 8
1879 typedef struct _IMAGE_SECTION_HEADER {
1880 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
1881 union {
1882 DWORD PhysicalAddress;
1883 DWORD VirtualSize;
1884 } Misc;
1885 DWORD VirtualAddress;
1886 DWORD SizeOfRawData;
1887 DWORD PointerToRawData;
1888 DWORD PointerToRelocations;
1889 DWORD PointerToLinenumbers;
1890 WORD NumberOfRelocations;
1891 WORD NumberOfLinenumbers;
1892 DWORD Characteristics;
1893 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
1895 #define IMAGE_SIZEOF_SECTION_HEADER 40
1897 #define IMAGE_FIRST_SECTION(ntheader) \
1898 ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
1899 ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
1901 /* These defines are for the Characteristics bitfield. */
1902 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
1903 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
1904 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
1905 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
1906 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
1907 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
1909 #define IMAGE_SCN_CNT_CODE 0x00000020
1910 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
1911 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
1913 #define IMAGE_SCN_LNK_OTHER 0x00000100
1914 #define IMAGE_SCN_LNK_INFO 0x00000200
1915 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
1916 #define IMAGE_SCN_LNK_REMOVE 0x00000800
1917 #define IMAGE_SCN_LNK_COMDAT 0x00001000
1919 /* 0x00002000 - Reserved */
1920 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
1921 #define IMAGE_SCN_MEM_FARDATA 0x00008000
1923 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
1924 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
1925 #define IMAGE_SCN_MEM_16BIT 0x00020000
1926 #define IMAGE_SCN_MEM_LOCKED 0x00040000
1927 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
1929 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
1930 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
1931 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
1932 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
1933 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
1934 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
1935 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
1936 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
1937 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
1938 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
1939 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
1940 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
1941 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
1942 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
1943 /* 0x00F00000 - Unused */
1944 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
1946 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
1949 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
1950 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
1951 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
1952 #define IMAGE_SCN_MEM_SHARED 0x10000000
1953 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
1954 #define IMAGE_SCN_MEM_READ 0x40000000
1955 #define IMAGE_SCN_MEM_WRITE 0x80000000
1957 #include <pshpack2.h>
1959 typedef struct _IMAGE_SYMBOL {
1960 union {
1961 BYTE ShortName[8];
1962 struct {
1963 DWORD Short;
1964 DWORD Long;
1965 } Name;
1966 DWORD LongName[2];
1967 } N;
1968 DWORD Value;
1969 SHORT SectionNumber;
1970 WORD Type;
1971 BYTE StorageClass;
1972 BYTE NumberOfAuxSymbols;
1973 } IMAGE_SYMBOL;
1974 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
1976 #define IMAGE_SIZEOF_SYMBOL 18
1978 typedef struct _IMAGE_LINENUMBER {
1979 union {
1980 DWORD SymbolTableIndex;
1981 DWORD VirtualAddress;
1982 } Type;
1983 WORD Linenumber;
1984 } IMAGE_LINENUMBER;
1985 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
1987 #define IMAGE_SIZEOF_LINENUMBER 6
1989 typedef union _IMAGE_AUX_SYMBOL {
1990 struct {
1991 DWORD TagIndex;
1992 union {
1993 struct {
1994 WORD Linenumber;
1995 WORD Size;
1996 } LnSz;
1997 DWORD TotalSize;
1998 } Misc;
1999 union {
2000 struct {
2001 DWORD PointerToLinenumber;
2002 DWORD PointerToNextFunction;
2003 } Function;
2004 struct {
2005 WORD Dimension[4];
2006 } Array;
2007 } FcnAry;
2008 WORD TvIndex;
2009 } Sym;
2010 struct {
2011 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2012 } File;
2013 struct {
2014 DWORD Length;
2015 WORD NumberOfRelocations;
2016 WORD NumberOfLinenumbers;
2017 DWORD CheckSum;
2018 SHORT Number;
2019 BYTE Selection;
2020 } Section;
2021 } IMAGE_AUX_SYMBOL;
2022 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2024 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2026 #include <poppack.h>
2028 #define IMAGE_SYM_UNDEFINED (SHORT)0
2029 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2030 #define IMAGE_SYM_DEBUG (SHORT)-2
2032 #define IMAGE_SYM_TYPE_NULL 0x0000
2033 #define IMAGE_SYM_TYPE_VOID 0x0001
2034 #define IMAGE_SYM_TYPE_CHAR 0x0002
2035 #define IMAGE_SYM_TYPE_SHORT 0x0003
2036 #define IMAGE_SYM_TYPE_INT 0x0004
2037 #define IMAGE_SYM_TYPE_LONG 0x0005
2038 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2039 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2040 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2041 #define IMAGE_SYM_TYPE_UNION 0x0009
2042 #define IMAGE_SYM_TYPE_ENUM 0x000A
2043 #define IMAGE_SYM_TYPE_MOE 0x000B
2044 #define IMAGE_SYM_TYPE_BYTE 0x000C
2045 #define IMAGE_SYM_TYPE_WORD 0x000D
2046 #define IMAGE_SYM_TYPE_UINT 0x000E
2047 #define IMAGE_SYM_TYPE_DWORD 0x000F
2048 #define IMAGE_SYM_TYPE_PCODE 0x8000
2050 #define IMAGE_SYM_DTYPE_NULL 0
2051 #define IMAGE_SYM_DTYPE_POINTER 1
2052 #define IMAGE_SYM_DTYPE_FUNCTION 2
2053 #define IMAGE_SYM_DTYPE_ARRAY 3
2055 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2056 #define IMAGE_SYM_CLASS_NULL 0x0000
2057 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2058 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2059 #define IMAGE_SYM_CLASS_STATIC 0x0003
2060 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2061 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2062 #define IMAGE_SYM_CLASS_LABEL 0x0006
2063 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2064 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2065 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2066 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2067 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2068 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2069 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2070 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2071 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2072 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2073 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2074 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2076 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2077 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2078 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2079 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2080 #define IMAGE_SYM_CLASS_FILE 0x0067
2081 #define IMAGE_SYM_CLASS_SECTION 0x0068
2082 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2084 #define N_BTMASK 0x000F
2085 #define N_TMASK 0x0030
2086 #define N_TMASK1 0x00C0
2087 #define N_TMASK2 0x00F0
2088 #define N_BTSHFT 4
2089 #define N_TSHIFT 2
2091 #define BTYPE(x) ((x) & N_BTMASK)
2093 #ifndef ISPTR
2094 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2095 #endif
2097 #ifndef ISFCN
2098 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2099 #endif
2101 #ifndef ISARY
2102 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2103 #endif
2105 #ifndef ISTAG
2106 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2107 #endif
2109 #ifndef INCREF
2110 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2111 #endif
2112 #ifndef DECREF
2113 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2114 #endif
2116 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2117 #define IMAGE_COMDAT_SELECT_ANY 2
2118 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2119 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2120 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2121 #define IMAGE_COMDAT_SELECT_LARGEST 6
2122 #define IMAGE_COMDAT_SELECT_NEWEST 7
2124 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2125 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2126 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2128 /* Export module directory */
2130 typedef struct _IMAGE_EXPORT_DIRECTORY {
2131 DWORD Characteristics;
2132 DWORD TimeDateStamp;
2133 WORD MajorVersion;
2134 WORD MinorVersion;
2135 DWORD Name;
2136 DWORD Base;
2137 DWORD NumberOfFunctions;
2138 DWORD NumberOfNames;
2139 DWORD AddressOfFunctions;
2140 DWORD AddressOfNames;
2141 DWORD AddressOfNameOrdinals;
2142 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2144 /* Import name entry */
2145 typedef struct _IMAGE_IMPORT_BY_NAME {
2146 WORD Hint;
2147 BYTE Name[1];
2148 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2150 /* Import thunk */
2151 typedef struct _IMAGE_THUNK_DATA {
2152 union {
2153 LPBYTE ForwarderString;
2154 PDWORD Function;
2155 DWORD Ordinal;
2156 PIMAGE_IMPORT_BY_NAME AddressOfData;
2157 } u1;
2158 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
2160 /* Import module directory */
2162 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2163 union {
2164 DWORD Characteristics; /* 0 for terminating null import descriptor */
2165 PIMAGE_THUNK_DATA OriginalFirstThunk; /* RVA to original unbound IAT */
2166 } u;
2167 DWORD TimeDateStamp; /* 0 if not bound,
2168 * -1 if bound, and real date\time stamp
2169 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2170 * (new BIND)
2171 * otherwise date/time stamp of DLL bound to
2172 * (Old BIND)
2174 DWORD ForwarderChain; /* -1 if no forwarders */
2175 DWORD Name;
2176 /* RVA to IAT (if bound this IAT has actual addresses) */
2177 PIMAGE_THUNK_DATA FirstThunk;
2178 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2180 #define IMAGE_ORDINAL_FLAG 0x80000000
2181 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
2182 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
2184 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2186 DWORD TimeDateStamp;
2187 WORD OffsetModuleName;
2188 WORD NumberOfModuleForwarderRefs;
2189 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2190 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2192 typedef struct _IMAGE_BOUND_FORWARDER_REF
2194 DWORD TimeDateStamp;
2195 WORD OffsetModuleName;
2196 WORD Reserved;
2197 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2199 typedef struct _IMAGE_BASE_RELOCATION
2201 DWORD VirtualAddress;
2202 DWORD SizeOfBlock;
2203 /* WORD TypeOffset[1]; */
2204 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2206 #include <pshpack2.h>
2208 typedef struct _IMAGE_RELOCATION
2210 union {
2211 DWORD VirtualAddress;
2212 DWORD RelocCount;
2213 } DUMMYUNIONNAME;
2214 DWORD SymbolTableIndex;
2215 WORD Type;
2216 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
2218 #include <poppack.h>
2220 #define IMAGE_SIZEOF_RELOCATION 10
2222 /* generic relocation types */
2223 #define IMAGE_REL_BASED_ABSOLUTE 0
2224 #define IMAGE_REL_BASED_HIGH 1
2225 #define IMAGE_REL_BASED_LOW 2
2226 #define IMAGE_REL_BASED_HIGHLOW 3
2227 #define IMAGE_REL_BASED_HIGHADJ 4
2228 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
2229 #define IMAGE_REL_BASED_SECTION 6
2230 #define IMAGE_REL_BASED_REL 7
2231 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
2232 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
2233 #define IMAGE_REL_BASED_DIR64 10
2234 #define IMAGE_REL_BASED_HIGH3ADJ 11
2236 /* I386 relocation types */
2237 #define IMAGE_REL_I386_ABSOLUTE 0
2238 #define IMAGE_REL_I386_DIR16 1
2239 #define IMAGE_REL_I386_REL16 2
2240 #define IMAGE_REL_I386_DIR32 6
2241 #define IMAGE_REL_I386_DIR32NB 7
2242 #define IMAGE_REL_I386_SEG12 9
2243 #define IMAGE_REL_I386_SECTION 10
2244 #define IMAGE_REL_I386_SECREL 11
2245 #define IMAGE_REL_I386_REL32 20
2247 /* MIPS relocation types */
2248 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
2249 #define IMAGE_REL_MIPS_REFHALF 0x0001
2250 #define IMAGE_REL_MIPS_REFWORD 0x0002
2251 #define IMAGE_REL_MIPS_JMPADDR 0x0003
2252 #define IMAGE_REL_MIPS_REFHI 0x0004
2253 #define IMAGE_REL_MIPS_REFLO 0x0005
2254 #define IMAGE_REL_MIPS_GPREL 0x0006
2255 #define IMAGE_REL_MIPS_LITERAL 0x0007
2256 #define IMAGE_REL_MIPS_SECTION 0x000A
2257 #define IMAGE_REL_MIPS_SECREL 0x000B
2258 #define IMAGE_REL_MIPS_SECRELLO 0x000C
2259 #define IMAGE_REL_MIPS_SECRELHI 0x000D
2260 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
2261 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
2262 #define IMAGE_REL_MIPS_PAIR 0x0025
2264 /* ALPHA relocation types */
2265 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
2266 #define IMAGE_REL_ALPHA_REFLONG 0x0001
2267 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
2268 #define IMAGE_REL_ALPHA_GPREL 0x0003
2269 #define IMAGE_REL_ALPHA_LITERAL 0x0004
2270 #define IMAGE_REL_ALPHA_LITUSE 0x0005
2271 #define IMAGE_REL_ALPHA_GPDISP 0x0006
2272 #define IMAGE_REL_ALPHA_BRADDR 0x0007
2273 #define IMAGE_REL_ALPHA_HINT 0x0008
2274 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
2275 #define IMAGE_REL_ALPHA_REFHI 0x000A
2276 #define IMAGE_REL_ALPHA_REFLO 0x000B
2277 #define IMAGE_REL_ALPHA_PAIR 0x000C
2278 #define IMAGE_REL_ALPHA_MATCH 0x000D
2279 #define IMAGE_REL_ALPHA_SECTION 0x000E
2280 #define IMAGE_REL_ALPHA_SECREL 0x000F
2281 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
2282 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
2283 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
2284 #define IMAGE_REL_ALPHA_REFQ3 0x0013
2285 #define IMAGE_REL_ALPHA_REFQ2 0x0014
2286 #define IMAGE_REL_ALPHA_REFQ1 0x0015
2287 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
2288 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
2290 /* PowerPC relocation types */
2291 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
2292 #define IMAGE_REL_PPC_ADDR64 0x0001
2293 #define IMAGE_REL_PPC_ADDR 0x0002
2294 #define IMAGE_REL_PPC_ADDR24 0x0003
2295 #define IMAGE_REL_PPC_ADDR16 0x0004
2296 #define IMAGE_REL_PPC_ADDR14 0x0005
2297 #define IMAGE_REL_PPC_REL24 0x0006
2298 #define IMAGE_REL_PPC_REL14 0x0007
2299 #define IMAGE_REL_PPC_TOCREL16 0x0008
2300 #define IMAGE_REL_PPC_TOCREL14 0x0009
2301 #define IMAGE_REL_PPC_ADDR32NB 0x000A
2302 #define IMAGE_REL_PPC_SECREL 0x000B
2303 #define IMAGE_REL_PPC_SECTION 0x000C
2304 #define IMAGE_REL_PPC_IFGLUE 0x000D
2305 #define IMAGE_REL_PPC_IMGLUE 0x000E
2306 #define IMAGE_REL_PPC_SECREL16 0x000F
2307 #define IMAGE_REL_PPC_REFHI 0x0010
2308 #define IMAGE_REL_PPC_REFLO 0x0011
2309 #define IMAGE_REL_PPC_PAIR 0x0012
2310 #define IMAGE_REL_PPC_SECRELLO 0x0013
2311 #define IMAGE_REL_PPC_SECRELHI 0x0014
2312 #define IMAGE_REL_PPC_GPREL 0x0015
2313 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
2314 /* modifier bits */
2315 #define IMAGE_REL_PPC_NEG 0x0100
2316 #define IMAGE_REL_PPC_BRTAKEN 0x0200
2317 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
2318 #define IMAGE_REL_PPC_TOCDEFN 0x0800
2320 /* SH3 ? relocation type */
2321 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
2322 #define IMAGE_REL_SH3_DIRECT16 0x0001
2323 #define IMAGE_REL_SH3_DIRECT 0x0002
2324 #define IMAGE_REL_SH3_DIRECT8 0x0003
2325 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
2326 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
2327 #define IMAGE_REL_SH3_DIRECT4 0x0006
2328 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
2329 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
2330 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
2331 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
2332 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
2333 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
2334 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
2335 #define IMAGE_REL_SH3_SECTION 0x000E
2336 #define IMAGE_REL_SH3_SECREL 0x000F
2337 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
2339 /* ARM (Archimedes?) relocation types */
2340 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
2341 #define IMAGE_REL_ARM_ADDR 0x0001
2342 #define IMAGE_REL_ARM_ADDR32NB 0x0002
2343 #define IMAGE_REL_ARM_BRANCH24 0x0003
2344 #define IMAGE_REL_ARM_BRANCH11 0x0004
2345 #define IMAGE_REL_ARM_SECTION 0x000E
2346 #define IMAGE_REL_ARM_SECREL 0x000F
2348 /* IA64 relocation types */
2349 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
2350 #define IMAGE_REL_IA64_IMM14 0x0001
2351 #define IMAGE_REL_IA64_IMM22 0x0002
2352 #define IMAGE_REL_IA64_IMM64 0x0003
2353 #define IMAGE_REL_IA64_DIR 0x0004
2354 #define IMAGE_REL_IA64_DIR64 0x0005
2355 #define IMAGE_REL_IA64_PCREL21B 0x0006
2356 #define IMAGE_REL_IA64_PCREL21M 0x0007
2357 #define IMAGE_REL_IA64_PCREL21F 0x0008
2358 #define IMAGE_REL_IA64_GPREL22 0x0009
2359 #define IMAGE_REL_IA64_LTOFF22 0x000A
2360 #define IMAGE_REL_IA64_SECTION 0x000B
2361 #define IMAGE_REL_IA64_SECREL22 0x000C
2362 #define IMAGE_REL_IA64_SECREL64I 0x000D
2363 #define IMAGE_REL_IA64_SECREL 0x000E
2364 #define IMAGE_REL_IA64_LTOFF64 0x000F
2365 #define IMAGE_REL_IA64_DIR32NB 0x0010
2366 #define IMAGE_REL_IA64_RESERVED_11 0x0011
2367 #define IMAGE_REL_IA64_RESERVED_12 0x0012
2368 #define IMAGE_REL_IA64_RESERVED_13 0x0013
2369 #define IMAGE_REL_IA64_RESERVED_14 0x0014
2370 #define IMAGE_REL_IA64_RESERVED_15 0x0015
2371 #define IMAGE_REL_IA64_RESERVED_16 0x0016
2372 #define IMAGE_REL_IA64_ADDEND 0x001F
2374 /* archive format */
2376 #define IMAGE_ARCHIVE_START_SIZE 8
2377 #define IMAGE_ARCHIVE_START "!<arch>\n"
2378 #define IMAGE_ARCHIVE_END "`\n"
2379 #define IMAGE_ARCHIVE_PAD "\n"
2380 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
2381 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
2383 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2385 BYTE Name[16];
2386 BYTE Date[12];
2387 BYTE UserID[6];
2388 BYTE GroupID[6];
2389 BYTE Mode[8];
2390 BYTE Size[10];
2391 BYTE EndHeader[2];
2392 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2394 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2397 * Resource directory stuff
2399 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2400 DWORD Characteristics;
2401 DWORD TimeDateStamp;
2402 WORD MajorVersion;
2403 WORD MinorVersion;
2404 WORD NumberOfNamedEntries;
2405 WORD NumberOfIdEntries;
2406 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2407 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2409 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
2410 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
2412 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2413 union {
2414 struct {
2415 #ifdef BITFIELDS_BIGENDIAN
2416 unsigned NameIsString:1;
2417 unsigned NameOffset:31;
2418 #else
2419 unsigned NameOffset:31;
2420 unsigned NameIsString:1;
2421 #endif
2422 } DUMMYSTRUCTNAME1;
2423 DWORD Name;
2424 struct {
2425 #ifdef WORDS_BIGENDIAN
2426 WORD __pad;
2427 WORD Id;
2428 #else
2429 WORD Id;
2430 WORD __pad;
2431 #endif
2432 } DUMMYSTRUCTNAME2;
2433 } DUMMYUNIONNAME1;
2434 union {
2435 DWORD OffsetToData;
2436 struct {
2437 #ifdef BITFIELDS_BIGENDIAN
2438 unsigned DataIsDirectory:1;
2439 unsigned OffsetToDirectory:31;
2440 #else
2441 unsigned OffsetToDirectory:31;
2442 unsigned DataIsDirectory:1;
2443 #endif
2444 } DUMMYSTRUCTNAME3;
2445 } DUMMYUNIONNAME2;
2446 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2449 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2450 WORD Length;
2451 CHAR NameString[ 1 ];
2452 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2454 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2455 WORD Length;
2456 WCHAR NameString[ 1 ];
2457 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2459 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2460 DWORD OffsetToData;
2461 DWORD Size;
2462 DWORD CodePage;
2463 DWORD ResourceHandle;
2464 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2467 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
2468 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2471 typedef struct _IMAGE_TLS_DIRECTORY {
2472 DWORD StartAddressOfRawData;
2473 DWORD EndAddressOfRawData;
2474 LPDWORD AddressOfIndex;
2475 PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
2476 DWORD SizeOfZeroFill;
2477 DWORD Characteristics;
2478 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
2480 typedef struct _IMAGE_DEBUG_DIRECTORY {
2481 DWORD Characteristics;
2482 DWORD TimeDateStamp;
2483 WORD MajorVersion;
2484 WORD MinorVersion;
2485 DWORD Type;
2486 DWORD SizeOfData;
2487 DWORD AddressOfRawData;
2488 DWORD PointerToRawData;
2489 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2491 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
2492 #define IMAGE_DEBUG_TYPE_COFF 1
2493 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
2494 #define IMAGE_DEBUG_TYPE_FPO 3
2495 #define IMAGE_DEBUG_TYPE_MISC 4
2496 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
2497 #define IMAGE_DEBUG_TYPE_FIXUP 6
2498 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
2499 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
2500 #define IMAGE_DEBUG_TYPE_BORLAND 9
2501 #define IMAGE_DEBUG_TYPE_RESERVED10 10
2503 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2504 DWORD NumberOfSymbols;
2505 DWORD LvaToFirstSymbol;
2506 DWORD NumberOfLinenumbers;
2507 DWORD LvaToFirstLinenumber;
2508 DWORD RvaToFirstByteOfCode;
2509 DWORD RvaToLastByteOfCode;
2510 DWORD RvaToFirstByteOfData;
2511 DWORD RvaToLastByteOfData;
2512 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2514 #define FRAME_FPO 0
2515 #define FRAME_TRAP 1
2516 #define FRAME_TSS 2
2517 #define FRAME_NONFPO 3
2519 typedef struct _FPO_DATA {
2520 DWORD ulOffStart;
2521 DWORD cbProcSize;
2522 DWORD cdwLocals;
2523 WORD cdwParams;
2524 unsigned cbProlog : 8;
2525 unsigned cbRegs : 3;
2526 unsigned fHasSEH : 1;
2527 unsigned fUseBP : 1;
2528 unsigned reserved : 1;
2529 unsigned cbFrame : 2;
2530 } FPO_DATA, *PFPO_DATA;
2532 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2533 DWORD Characteristics;
2534 DWORD TimeDateStamp;
2535 WORD MajorVersion;
2536 WORD MinorVersion;
2537 DWORD GlobalFlagsClear;
2538 DWORD GlobalFlagsSet;
2539 DWORD CriticalSectionDefaultTimeout;
2540 DWORD DeCommitFreeBlockThreshold;
2541 DWORD DeCommitTotalFreeThreshold;
2542 PVOID LockPrefixTable;
2543 DWORD MaximumAllocationSize;
2544 DWORD VirtualMemoryThreshold;
2545 DWORD ProcessHeapFlags;
2546 DWORD ProcessAffinityMask;
2547 WORD CSDVersion;
2548 WORD Reserved1;
2549 PVOID EditList;
2550 DWORD Reserved[1];
2551 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2553 typedef struct _IMAGE_FUNCTION_ENTRY {
2554 DWORD StartingAddress;
2555 DWORD EndingAddress;
2556 DWORD EndOfPrologue;
2557 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2559 #define IMAGE_DEBUG_MISC_EXENAME 1
2561 typedef struct _IMAGE_DEBUG_MISC {
2562 DWORD DataType;
2563 DWORD Length;
2564 BYTE Unicode;
2565 BYTE Reserved[ 3 ];
2566 BYTE Data[ 1 ];
2567 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2569 /* This is the structure that appears at the very start of a .DBG file. */
2571 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2572 WORD Signature;
2573 WORD Flags;
2574 WORD Machine;
2575 WORD Characteristics;
2576 DWORD TimeDateStamp;
2577 DWORD CheckSum;
2578 DWORD ImageBase;
2579 DWORD SizeOfImage;
2580 DWORD NumberOfSections;
2581 DWORD ExportedNamesSize;
2582 DWORD DebugDirectorySize;
2583 DWORD SectionAlignment;
2584 DWORD Reserved[ 2 ];
2585 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2587 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2590 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2591 WORD Length;
2592 WORD Flags;
2593 BYTE Text[1];
2594 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2595 #define MESSAGE_RESOURCE_UNICODE 0x0001
2597 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2598 DWORD LowId;
2599 DWORD HighId;
2600 DWORD OffsetToEntries;
2601 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2603 typedef struct tagMESSAGE_RESOURCE_DATA {
2604 DWORD NumberOfBlocks;
2605 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
2606 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2609 * Here follows typedefs for security and tokens.
2613 * First a constant for the following typdefs.
2616 #define ANYSIZE_ARRAY 1
2618 /* FIXME: Orphan. What does it point to? */
2619 typedef PVOID PACCESS_TOKEN;
2622 * TOKEN_INFORMATION_CLASS
2625 typedef enum _TOKEN_INFORMATION_CLASS {
2626 TokenUser = 1,
2627 TokenGroups,
2628 TokenPrivileges,
2629 TokenOwner,
2630 TokenPrimaryGroup,
2631 TokenDefaultDacl,
2632 TokenSource,
2633 TokenType,
2634 TokenImpersonationLevel,
2635 TokenStatistics,
2636 TokenRestrictedSids,
2637 TokenSessionId,
2638 TokenGroupsAndPrivileges,
2639 TokenSessionReference,
2640 TokenSandBoxInert
2641 } TOKEN_INFORMATION_CLASS;
2643 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
2644 #define TOKEN_ADJUST_GROUPS 0x0040
2645 #define TOKEN_ADJUST_PRIVILEGES 0x0020
2646 #define TOKEN_ADJUST_SESSIONID 0x0100
2647 #define TOKEN_ASSIGN_PRIMARY 0x0001
2648 #define TOKEN_DUPLICATE 0x0002
2649 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
2650 #define TOKEN_IMPERSONATE 0x0004
2651 #define TOKEN_QUERY 0x0008
2652 #define TOKEN_QUERY_SOURCE 0x0010
2653 #define TOKEN_ADJUST_DEFAULT 0x0080
2654 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
2655 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
2656 TOKEN_ADJUST_PRIVILEGES | \
2657 TOKEN_ADJUST_GROUPS | \
2658 TOKEN_ADJUST_DEFAULT )
2659 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
2660 TOKEN_ASSIGN_PRIMARY | \
2661 TOKEN_DUPLICATE | \
2662 TOKEN_IMPERSONATE | \
2663 TOKEN_QUERY | \
2664 TOKEN_QUERY_SOURCE | \
2665 TOKEN_ADJUST_PRIVILEGES | \
2666 TOKEN_ADJUST_GROUPS | \
2667 TOKEN_ADJUST_SESSIONID | \
2668 TOKEN_ADJUST_DEFAULT )
2670 #ifndef _SECURITY_DEFINED
2671 #define _SECURITY_DEFINED
2674 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2676 typedef struct _GENERIC_MAPPING {
2677 ACCESS_MASK GenericRead;
2678 ACCESS_MASK GenericWrite;
2679 ACCESS_MASK GenericExecute;
2680 ACCESS_MASK GenericAll;
2681 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2683 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2684 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2685 typedef struct {
2686 BYTE Value[6];
2687 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
2688 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2690 #ifndef SID_DEFINED
2691 #define SID_DEFINED
2692 typedef struct _SID {
2693 BYTE Revision;
2694 BYTE SubAuthorityCount;
2695 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2696 DWORD SubAuthority[1];
2697 } SID,*PSID;
2698 #endif /* !defined(SID_DEFINED) */
2700 #define SID_REVISION (1) /* Current revision */
2701 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
2702 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
2706 * ACL
2709 #define ACL_REVISION1 1
2710 #define ACL_REVISION2 2
2711 #define ACL_REVISION3 3
2712 #define ACL_REVISION4 4
2714 #define MIN_ACL_REVISION ACL_REVISION2
2715 #define MAX_ACL_REVISION ACL_REVISION4
2717 typedef struct _ACL {
2718 BYTE AclRevision;
2719 BYTE Sbz1;
2720 WORD AclSize;
2721 WORD AceCount;
2722 WORD Sbz2;
2723 } ACL, *PACL;
2725 typedef enum _ACL_INFORMATION_CLASS
2727 AclRevisionInformation = 1,
2728 AclSizeInformation
2729 } ACL_INFORMATION_CLASS;
2731 typedef struct _ACL_REVISION_INFORMATION
2733 DWORD AclRevision;
2734 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
2736 typedef struct _ACL_SIZE_INFORMATION
2738 DWORD AceCount;
2739 DWORD AclBytesInUse;
2740 DWORD AclBytesFree;
2741 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
2743 /* SECURITY_DESCRIPTOR */
2744 #define SECURITY_DESCRIPTOR_REVISION 1
2745 #define SECURITY_DESCRIPTOR_REVISION1 1
2749 * Privilege Names
2751 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
2752 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
2753 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
2754 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
2755 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
2756 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
2757 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
2758 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
2759 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
2760 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
2761 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
2762 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
2763 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
2764 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
2765 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
2766 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
2767 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
2768 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
2769 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
2770 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
2771 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
2772 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
2773 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
2774 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
2776 #define SE_GROUP_MANDATORY 0x00000001
2777 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
2778 #define SE_GROUP_ENABLED 0x00000004
2779 #define SE_GROUP_OWNER 0x00000008
2780 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
2781 #define SE_GROUP_LOGON_ID 0xC0000000
2782 #define SE_GROUP_RESOURCE 0x20000000
2784 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
2785 #define SE_PRIVILEGE_ENABLED 0x00000002
2786 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
2788 #define SE_OWNER_DEFAULTED 0x00000001
2789 #define SE_GROUP_DEFAULTED 0x00000002
2790 #define SE_DACL_PRESENT 0x00000004
2791 #define SE_DACL_DEFAULTED 0x00000008
2792 #define SE_SACL_PRESENT 0x00000010
2793 #define SE_SACL_DEFAULTED 0x00000020
2794 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
2795 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
2796 #define SE_DACL_AUTO_INHERITED 0x00000400
2797 #define SE_SACL_AUTO_INHERITED 0x00000800
2798 #define SE_DACL_PROTECTED 0x00001000
2799 #define SE_SACL_PROTECTED 0x00002000
2800 #define SE_SELF_RELATIVE 0x00008000
2802 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
2803 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
2805 /* The security descriptor structure */
2806 typedef struct {
2807 BYTE Revision;
2808 BYTE Sbz1;
2809 SECURITY_DESCRIPTOR_CONTROL Control;
2810 DWORD Owner;
2811 DWORD Group;
2812 DWORD Sacl;
2813 DWORD Dacl;
2814 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
2816 typedef struct {
2817 BYTE Revision;
2818 BYTE Sbz1;
2819 SECURITY_DESCRIPTOR_CONTROL Control;
2820 PSID Owner;
2821 PSID Group;
2822 PACL Sacl;
2823 PACL Dacl;
2824 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
2826 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
2828 #endif /* _SECURITY_DEFINED */
2831 * SID_AND_ATTRIBUTES
2834 typedef struct _SID_AND_ATTRIBUTES {
2835 PSID Sid;
2836 DWORD Attributes;
2837 } SID_AND_ATTRIBUTES;
2839 /* security entities */
2840 #define SECURITY_NULL_RID (0x00000000L)
2841 #define SECURITY_WORLD_RID (0x00000000L)
2842 #define SECURITY_LOCAL_RID (0X00000000L)
2844 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
2846 /* S-1-1 */
2847 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
2849 /* S-1-2 */
2850 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
2852 /* S-1-3 */
2853 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
2854 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
2855 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
2856 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
2857 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
2859 /* S-1-4 */
2860 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
2862 /* S-1-5 */
2863 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
2864 #define SECURITY_DIALUP_RID 0x00000001L
2865 #define SECURITY_NETWORK_RID 0x00000002L
2866 #define SECURITY_BATCH_RID 0x00000003L
2867 #define SECURITY_INTERACTIVE_RID 0x00000004L
2868 #define SECURITY_LOGON_IDS_RID 0x00000005L
2869 #define SECURITY_SERVICE_RID 0x00000006L
2870 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
2871 #define SECURITY_PROXY_RID 0x00000008L
2872 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
2873 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
2874 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
2875 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
2876 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
2877 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
2878 #define SECURITY_NT_NON_UNIQUE 0x00000015L
2879 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
2881 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
2882 #define DOMAIN_GROUP_RID_USERS 0x00000201L
2883 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
2885 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
2886 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
2887 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
2889 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
2891 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
2894 * TOKEN_USER
2897 typedef struct _TOKEN_USER {
2898 SID_AND_ATTRIBUTES User;
2899 } TOKEN_USER;
2902 * TOKEN_GROUPS
2905 typedef struct _TOKEN_GROUPS {
2906 DWORD GroupCount;
2907 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
2908 } TOKEN_GROUPS;
2911 * LUID_AND_ATTRIBUTES
2914 typedef union _LARGE_INTEGER {
2915 struct {
2916 #ifdef WORDS_BIGENDIAN
2917 LONG HighPart;
2918 DWORD LowPart;
2919 #else
2920 DWORD LowPart;
2921 LONG HighPart;
2922 #endif
2923 } DUMMYSTRUCTNAME;
2924 LONGLONG QuadPart;
2925 } LARGE_INTEGER, *PLARGE_INTEGER;
2927 typedef union _ULARGE_INTEGER {
2928 struct {
2929 #ifdef WORDS_BIGENDIAN
2930 DWORD HighPart;
2931 DWORD LowPart;
2932 #else
2933 DWORD LowPart;
2934 DWORD HighPart;
2935 #endif
2936 } DUMMYSTRUCTNAME;
2937 ULONGLONG QuadPart;
2938 } ULARGE_INTEGER, *PULARGE_INTEGER;
2941 * Locally Unique Identifier
2944 typedef struct _LUID {
2945 DWORD LowPart;
2946 LONG HighPart;
2947 } LUID, *PLUID;
2949 #include <pshpack4.h>
2950 typedef struct _LUID_AND_ATTRIBUTES {
2951 LUID Luid;
2952 DWORD Attributes;
2953 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
2954 #include <poppack.h>
2957 * PRIVILEGE_SET
2960 typedef struct _PRIVILEGE_SET {
2961 DWORD PrivilegeCount;
2962 DWORD Control;
2963 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
2964 } PRIVILEGE_SET, *PPRIVILEGE_SET;
2967 * TOKEN_PRIVILEGES
2970 typedef struct _TOKEN_PRIVILEGES {
2971 DWORD PrivilegeCount;
2972 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
2973 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
2976 * TOKEN_OWNER
2979 typedef struct _TOKEN_OWNER {
2980 PSID Owner;
2981 } TOKEN_OWNER;
2984 * TOKEN_PRIMARY_GROUP
2987 typedef struct _TOKEN_PRIMARY_GROUP {
2988 PSID PrimaryGroup;
2989 } TOKEN_PRIMARY_GROUP;
2993 * TOKEN_DEFAULT_DACL
2996 typedef struct _TOKEN_DEFAULT_DACL {
2997 PACL DefaultDacl;
2998 } TOKEN_DEFAULT_DACL;
3001 * TOKEN_SOURCEL
3004 #define TOKEN_SOURCE_LENGTH 8
3006 typedef struct _TOKEN_SOURCE {
3007 char SourceName[TOKEN_SOURCE_LENGTH];
3008 LUID SourceIdentifier;
3009 } TOKEN_SOURCE;
3012 * TOKEN_TYPE
3015 typedef enum tagTOKEN_TYPE {
3016 TokenPrimary = 1,
3017 TokenImpersonation
3018 } TOKEN_TYPE;
3021 * SECURITY_IMPERSONATION_LEVEL
3024 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3025 SecurityAnonymous,
3026 SecurityIdentification,
3027 SecurityImpersonation,
3028 SecurityDelegation
3029 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
3032 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3033 * PSECURITY_CONTEXT_TRACKING_MODE;
3035 * Quality of Service
3038 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3039 DWORD Length;
3040 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3041 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3042 BOOLEAN EffectiveOnly;
3043 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3046 * TOKEN_STATISTICS
3049 typedef struct _TOKEN_STATISTICS {
3050 LUID TokenId;
3051 LUID AuthenticationId;
3052 LARGE_INTEGER ExpirationTime;
3053 TOKEN_TYPE TokenType;
3054 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3055 DWORD DynamicCharged;
3056 DWORD DynamicAvailable;
3057 DWORD GroupCount;
3058 DWORD PrivilegeCount;
3059 LUID ModifiedId;
3060 } TOKEN_STATISTICS;
3063 * ACLs of NT
3066 #define ACL_REVISION 2
3068 #define ACL_REVISION1 1
3069 #define ACL_REVISION2 2
3071 /* ACEs, directly starting after an ACL */
3072 typedef struct _ACE_HEADER {
3073 BYTE AceType;
3074 BYTE AceFlags;
3075 WORD AceSize;
3076 } ACE_HEADER,*PACE_HEADER;
3078 /* AceType */
3079 #define ACCESS_ALLOWED_ACE_TYPE 0
3080 #define ACCESS_DENIED_ACE_TYPE 1
3081 #define SYSTEM_AUDIT_ACE_TYPE 2
3082 #define SYSTEM_ALARM_ACE_TYPE 3
3084 /* inherit AceFlags */
3085 #define OBJECT_INHERIT_ACE 0x01
3086 #define CONTAINER_INHERIT_ACE 0x02
3087 #define NO_PROPAGATE_INHERIT_ACE 0x04
3088 #define INHERIT_ONLY_ACE 0x08
3089 #define INHERITED_ACE 0x10
3090 #define VALID_INHERIT_FLAGS 0x0F
3092 /* AceFlags mask for what events we (should) audit */
3093 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
3094 #define FAILED_ACCESS_ACE_FLAG 0x80
3096 /* different ACEs depending on AceType
3097 * SidStart marks the begin of a SID
3098 * so the thing finally looks like this:
3099 * 0: ACE_HEADER
3100 * 4: ACCESS_MASK
3101 * 8... : SID
3103 typedef struct _ACCESS_ALLOWED_ACE {
3104 ACE_HEADER Header;
3105 DWORD Mask;
3106 DWORD SidStart;
3107 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3109 typedef struct _ACCESS_DENIED_ACE {
3110 ACE_HEADER Header;
3111 DWORD Mask;
3112 DWORD SidStart;
3113 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3115 typedef struct _SYSTEM_AUDIT_ACE {
3116 ACE_HEADER Header;
3117 DWORD Mask;
3118 DWORD SidStart;
3119 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3121 typedef struct _SYSTEM_ALARM_ACE {
3122 ACE_HEADER Header;
3123 DWORD Mask;
3124 DWORD SidStart;
3125 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3127 typedef enum tagSID_NAME_USE {
3128 SidTypeUser = 1,
3129 SidTypeGroup,
3130 SidTypeDomain,
3131 SidTypeAlias,
3132 SidTypeWellKnownGroup,
3133 SidTypeDeletedAccount,
3134 SidTypeInvalid,
3135 SidTypeUnknown
3136 } SID_NAME_USE,*PSID_NAME_USE;
3138 /* Access rights */
3140 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3141 #undef DELETE
3142 #define DELETE 0x00010000
3143 #define READ_CONTROL 0x00020000
3144 #define WRITE_DAC 0x00040000
3145 #define WRITE_OWNER 0x00080000
3146 #define SYNCHRONIZE 0x00100000
3147 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
3149 #define STANDARD_RIGHTS_READ READ_CONTROL
3150 #define STANDARD_RIGHTS_WRITE READ_CONTROL
3151 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
3153 #define STANDARD_RIGHTS_ALL 0x001f0000
3155 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
3157 #define GENERIC_READ 0x80000000
3158 #define GENERIC_WRITE 0x40000000
3159 #define GENERIC_EXECUTE 0x20000000
3160 #define GENERIC_ALL 0x10000000
3162 #define MAXIMUM_ALLOWED 0x02000000
3163 #define ACCESS_SYSTEM_SECURITY 0x01000000
3165 #define EVENT_MODIFY_STATE 0x0002
3166 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3168 #define SEMAPHORE_MODIFY_STATE 0x0002
3169 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3171 #define MUTEX_MODIFY_STATE 0x0001
3172 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3174 #define TIMER_QUERY_STATE 0x0001
3175 #define TIMER_MODIFY_STATE 0x0002
3176 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3178 #define PROCESS_TERMINATE 0x0001
3179 #define PROCESS_CREATE_THREAD 0x0002
3180 #define PROCESS_VM_OPERATION 0x0008
3181 #define PROCESS_VM_READ 0x0010
3182 #define PROCESS_VM_WRITE 0x0020
3183 #define PROCESS_DUP_HANDLE 0x0040
3184 #define PROCESS_CREATE_PROCESS 0x0080
3185 #define PROCESS_SET_QUOTA 0x0100
3186 #define PROCESS_SET_INFORMATION 0x0200
3187 #define PROCESS_QUERY_INFORMATION 0x0400
3188 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3190 #define THREAD_TERMINATE 0x0001
3191 #define THREAD_SUSPEND_RESUME 0x0002
3192 #define THREAD_GET_CONTEXT 0x0008
3193 #define THREAD_SET_CONTEXT 0x0010
3194 #define THREAD_SET_INFORMATION 0x0020
3195 #define THREAD_QUERY_INFORMATION 0x0040
3196 #define THREAD_SET_THREAD_TOKEN 0x0080
3197 #define THREAD_IMPERSONATE 0x0100
3198 #define THREAD_DIRECT_IMPERSONATION 0x0200
3199 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3201 #define THREAD_BASE_PRIORITY_LOWRT 15
3202 #define THREAD_BASE_PRIORITY_MAX 2
3203 #define THREAD_BASE_PRIORITY_MIN -2
3204 #define THREAD_BASE_PRIORITY_IDLE -15
3206 #define SECTION_QUERY 0x0001
3207 #define SECTION_MAP_WRITE 0x0002
3208 #define SECTION_MAP_READ 0x0004
3209 #define SECTION_MAP_EXECUTE 0x0008
3210 #define SECTION_EXTEND_SIZE 0x0010
3211 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
3213 #define FILE_READ_DATA 0x0001 /* file & pipe */
3214 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
3215 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
3216 #define FILE_ADD_FILE 0x0002 /* directory */
3217 #define FILE_APPEND_DATA 0x0004 /* file */
3218 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
3219 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
3220 #define FILE_READ_EA 0x0008 /* file & directory */
3221 #define FILE_READ_PROPERTIES FILE_READ_EA
3222 #define FILE_WRITE_EA 0x0010 /* file & directory */
3223 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
3224 #define FILE_EXECUTE 0x0020 /* file */
3225 #define FILE_TRAVERSE 0x0020 /* directory */
3226 #define FILE_DELETE_CHILD 0x0040 /* directory */
3227 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
3228 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
3229 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3231 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3232 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3233 SYNCHRONIZE)
3234 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3235 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3236 FILE_APPEND_DATA | SYNCHRONIZE)
3237 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3238 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3241 /* File attribute flags */
3242 #define FILE_SHARE_READ 0x00000001L
3243 #define FILE_SHARE_WRITE 0x00000002L
3244 #define FILE_SHARE_DELETE 0x00000004L
3245 #define FILE_ATTRIBUTE_READONLY 0x00000001L
3246 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
3247 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
3248 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
3249 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
3250 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
3251 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
3252 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
3253 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
3254 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
3255 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
3256 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
3258 /* File notification flags */
3259 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
3260 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
3261 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
3262 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
3263 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
3264 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
3265 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
3266 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
3268 #define FILE_ACTION_ADDED 0x00000001
3269 #define FILE_ACTION_REMOVED 0x00000002
3270 #define FILE_ACTION_MODIFIED 0x00000003
3271 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
3272 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
3275 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
3276 #define FILE_CASE_PRESERVED_NAMES 0x00000002
3277 #define FILE_UNICODE_ON_DISK 0x00000004
3278 #define FILE_PERSISTENT_ACLS 0x00000008
3279 #define FILE_FILE_COMPRESSION 0x00000010
3280 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
3282 /* File alignments (NT) */
3283 #define FILE_BYTE_ALIGNMENT 0x00000000
3284 #define FILE_WORD_ALIGNMENT 0x00000001
3285 #define FILE_LONG_ALIGNMENT 0x00000003
3286 #define FILE_QUAD_ALIGNMENT 0x00000007
3287 #define FILE_OCTA_ALIGNMENT 0x0000000f
3288 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
3289 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
3290 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
3291 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
3292 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
3294 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
3295 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
3297 #define REG_NONE 0 /* no type */
3298 #define REG_SZ 1 /* string type (ASCII) */
3299 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3300 #define REG_BINARY 3 /* binary format, callerspecific */
3301 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3302 #define REG_DWORD 4 /* DWORD in little endian format */
3303 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
3304 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
3305 #define REG_LINK 6 /* symbolic link (UNICODE) */
3306 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3307 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
3308 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
3309 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3310 #define REG_QWORD 11 /* QWORD in little endian format */
3311 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
3313 /* ----------------------------- begin power management --------------------- */
3315 typedef enum _LATENCY_TIME {
3316 LT_DONT_CARE,
3317 LT_LOWEST_LATENCY
3318 } LATENCY_TIME, *PLATENCY_TIME;
3320 /* ----------------------------- begin registry ----------------------------- */
3322 /* Registry security values */
3323 #define OWNER_SECURITY_INFORMATION 0x00000001
3324 #define GROUP_SECURITY_INFORMATION 0x00000002
3325 #define DACL_SECURITY_INFORMATION 0x00000004
3326 #define SACL_SECURITY_INFORMATION 0x00000008
3328 #define REG_OPTION_RESERVED 0x00000000
3329 #define REG_OPTION_NON_VOLATILE 0x00000000
3330 #define REG_OPTION_VOLATILE 0x00000001
3331 #define REG_OPTION_CREATE_LINK 0x00000002
3332 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
3333 #define REG_OPTION_OPEN_LINK 0x00000008
3334 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
3335 REG_OPTION_NON_VOLATILE| \
3336 REG_OPTION_VOLATILE| \
3337 REG_OPTION_CREATE_LINK| \
3338 REG_OPTION_BACKUP_RESTORE| \
3339 REG_OPTION_OPEN_LINK)
3342 #define REG_CREATED_NEW_KEY 0x00000001
3343 #define REG_OPENED_EXISTING_KEY 0x00000002
3345 /* For RegNotifyChangeKeyValue */
3346 #define REG_NOTIFY_CHANGE_NAME 0x01
3347 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
3348 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
3349 #define REG_NOTIFY_CHANGE_SECURITY 0x08
3351 #define KEY_QUERY_VALUE 0x00000001
3352 #define KEY_SET_VALUE 0x00000002
3353 #define KEY_CREATE_SUB_KEY 0x00000004
3354 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
3355 #define KEY_NOTIFY 0x00000010
3356 #define KEY_CREATE_LINK 0x00000020
3358 /* for RegKeyRestore flags */
3359 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
3360 #define REG_REFRESH_HIVE 0x00000002
3361 #define REG_NO_LAZY_FLUSH 0x00000004
3362 #define REG_FORCE_RESTORE 0x00000008
3364 #define KEY_READ ((STANDARD_RIGHTS_READ| \
3365 KEY_QUERY_VALUE| \
3366 KEY_ENUMERATE_SUB_KEYS| \
3367 KEY_NOTIFY) \
3368 & (~SYNCHRONIZE) \
3370 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
3371 KEY_SET_VALUE| \
3372 KEY_CREATE_SUB_KEY) \
3373 & (~SYNCHRONIZE) \
3375 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
3376 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
3377 KEY_QUERY_VALUE| \
3378 KEY_SET_VALUE| \
3379 KEY_CREATE_SUB_KEY| \
3380 KEY_ENUMERATE_SUB_KEYS| \
3381 KEY_NOTIFY| \
3382 KEY_CREATE_LINK) \
3383 & (~SYNCHRONIZE) \
3385 /* ------------------------------ end registry ------------------------------ */
3388 #define EVENTLOG_SUCCESS 0x0000
3389 #define EVENTLOG_ERROR_TYPE 0x0001
3390 #define EVENTLOG_WARNING_TYPE 0x0002
3391 #define EVENTLOG_INFORMATION_TYPE 0x0004
3392 #define EVENTLOG_AUDIT_SUCCESS 0x0008
3393 #define EVENTLOG_AUDIT_FAILURE 0x0010
3395 #define SERVICE_BOOT_START 0x00000000
3396 #define SERVICE_SYSTEM_START 0x00000001
3397 #define SERVICE_AUTO_START 0x00000002
3398 #define SERVICE_DEMAND_START 0x00000003
3399 #define SERVICE_DISABLED 0x00000004
3401 #define SERVICE_ERROR_IGNORE 0x00000000
3402 #define SERVICE_ERROR_NORMAL 0x00000001
3403 #define SERVICE_ERROR_SEVERE 0x00000002
3404 #define SERVICE_ERROR_CRITICAL 0x00000003
3406 /* Service types */
3407 #define SERVICE_KERNEL_DRIVER 0x00000001
3408 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
3409 #define SERVICE_ADAPTER 0x00000004
3410 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
3412 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
3413 SERVICE_RECOGNIZER_DRIVER )
3415 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
3416 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
3417 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
3419 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
3421 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
3422 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
3425 typedef enum _CM_SERVICE_NODE_TYPE
3427 DriverType = SERVICE_KERNEL_DRIVER,
3428 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
3429 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
3430 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3431 AdapterType = SERVICE_ADAPTER,
3432 RecognizerType = SERVICE_RECOGNIZER_DRIVER
3433 } SERVICE_NODE_TYPE;
3435 typedef enum _CM_SERVICE_LOAD_TYPE
3437 BootLoad = SERVICE_BOOT_START,
3438 SystemLoad = SERVICE_SYSTEM_START,
3439 AutoLoad = SERVICE_AUTO_START,
3440 DemandLoad = SERVICE_DEMAND_START,
3441 DisableLoad = SERVICE_DISABLED
3442 } SERVICE_LOAD_TYPE;
3444 typedef enum _CM_ERROR_CONTROL_TYPE
3446 IgnoreError = SERVICE_ERROR_IGNORE,
3447 NormalError = SERVICE_ERROR_NORMAL,
3448 SevereError = SERVICE_ERROR_SEVERE,
3449 CriticalError = SERVICE_ERROR_CRITICAL
3450 } SERVICE_ERROR_TYPE;
3454 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
3455 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
3456 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
3457 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
3458 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
3460 #include <guiddef.h>
3462 typedef struct _OBJECT_TYPE_LIST {
3463 WORD Level;
3464 WORD Sbz;
3465 GUID *ObjectType;
3466 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
3468 typedef struct _RTL_CRITICAL_SECTION_DEBUG
3470 WORD Type;
3471 WORD CreatorBackTraceIndex;
3472 struct _RTL_CRITICAL_SECTION *CriticalSection;
3473 LIST_ENTRY ProcessLocksList;
3474 DWORD EntryCount;
3475 DWORD ContentionCount;
3476 DWORD Spare[ 2 ];
3477 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
3479 typedef struct _RTL_CRITICAL_SECTION {
3480 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
3481 LONG LockCount;
3482 LONG RecursionCount;
3483 HANDLE OwningThread;
3484 HANDLE LockSemaphore;
3485 ULONG_PTR SpinCount;
3486 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
3488 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
3490 typedef struct _IO_COUNTERS {
3491 ULONGLONG ReadOperationCount;
3492 ULONGLONG WriteOperationCount;
3493 ULONGLONG OtherOperationCount;
3494 ULONGLONG ReadTransferCount;
3495 ULONGLONG WriteTransferCount;
3496 ULONGLONG OtherTransferCount;
3497 } IO_COUNTERS;
3498 typedef IO_COUNTERS *PIO_COUNTERS;
3500 typedef struct {
3501 DWORD dwOSVersionInfoSize;
3502 DWORD dwMajorVersion;
3503 DWORD dwMinorVersion;
3504 DWORD dwBuildNumber;
3505 DWORD dwPlatformId;
3506 CHAR szCSDVersion[128];
3507 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
3509 typedef struct {
3510 DWORD dwOSVersionInfoSize;
3511 DWORD dwMajorVersion;
3512 DWORD dwMinorVersion;
3513 DWORD dwBuildNumber;
3514 DWORD dwPlatformId;
3515 WCHAR szCSDVersion[128];
3516 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
3518 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
3519 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
3520 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
3522 typedef struct {
3523 DWORD dwOSVersionInfoSize;
3524 DWORD dwMajorVersion;
3525 DWORD dwMinorVersion;
3526 DWORD dwBuildNumber;
3527 DWORD dwPlatformId;
3528 CHAR szCSDVersion[128];
3529 WORD wServicePackMajor;
3530 WORD wServicePackMinor;
3531 WORD wSuiteMask;
3532 BYTE wProductType;
3533 BYTE wReserved;
3534 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
3536 typedef struct {
3537 DWORD dwOSVersionInfoSize;
3538 DWORD dwMajorVersion;
3539 DWORD dwMinorVersion;
3540 DWORD dwBuildNumber;
3541 DWORD dwPlatformId;
3542 WCHAR szCSDVersion[128];
3543 WORD wServicePackMajor;
3544 WORD wServicePackMinor;
3545 WORD wSuiteMask;
3546 BYTE wProductType;
3547 BYTE wReserved;
3548 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
3550 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
3551 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
3552 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
3554 ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
3556 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
3558 #define VER_PLATFORM_WIN32s 0
3559 #define VER_PLATFORM_WIN32_WINDOWS 1
3560 #define VER_PLATFORM_WIN32_NT 2
3562 #define VER_MINORVERSION 0x00000001
3563 #define VER_MAJORVERSION 0x00000002
3564 #define VER_BUILDNUMBER 0x00000004
3565 #define VER_PLATFORMID 0x00000008
3566 #define VER_SERVICEPACKMINOR 0x00000010
3567 #define VER_SERVICEPACKMAJOR 0x00000020
3568 #define VER_SUITENAME 0x00000040
3569 #define VER_PRODUCT_TYPE 0x00000080
3571 #define VER_NT_WORKSTATION 1
3572 #define VER_NT_DOMAIN_CONTROLLER 2
3573 #define VER_NT_SERVER 3
3575 #define VER_SUITE_SMALLBUSINESS 0x00000001
3576 #define VER_SUITE_ENTERPRISE 0x00000002
3577 #define VER_SUITE_BACKOFFICE 0x00000004
3578 #define VER_SUITE_COMMUNICATIONS 0x00000008
3579 #define VER_SUITE_TERMINAL 0x00000010
3580 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
3581 #define VER_SUITE_EMBEDDEDNT 0x00000040
3582 #define VER_SUITE_DATACENTER 0x00000080
3583 #define VER_SUITE_SINGLEUSERTS 0x00000100
3584 #define VER_SUITE_PERSONAL 0x00000200
3586 #define VER_EQUAL 1
3587 #define VER_GREATER 2
3588 #define VER_GREATER_EQUAL 3
3589 #define VER_LESS 4
3590 #define VER_LESS_EQUAL 5
3591 #define VER_AND 6
3592 #define VER_OR 7
3594 #endif /* __WINE_WINNT_H */