ntdll: Check for existing modref for the main exe before creating it
[wine/multimedia.git] / include / winnt.h
blobb79597227a6ab8143ac686f2534565bb37ffd5b7
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 _WINNT_
22 #define _WINNT_
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 #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64) || defined(__MINGW32__)) && !defined(MIDL_PASS)
35 # if defined(_MSC_VER)
36 # define DECLSPEC_IMPORT __declspec(dllimport)
37 # elif defined(__MINGW32__)
38 # define DECLSPEC_IMPORT __attribute__((dllimport))
39 # else
40 # define DECLSPEC_IMPORT
41 # endif
42 #else
43 # define DECLSPEC_IMPORT
44 #endif
46 #ifndef DECLSPEC_NORETURN
47 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
48 # define DECLSPEC_NORETURN __declspec(noreturn)
49 # elif defined(__GNUC__)
50 # define DECLSPEC_NORETURN __attribute__((noreturn))
51 # else
52 # define DECLSPEC_NORETURN
53 # endif
54 #endif
56 #ifndef DECLSPEC_ALIGN
57 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
58 # define DECLSPEC_ALIGN(x) __declspec(align(x))
59 # elif defined(__GNUC__)
60 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
61 # else
62 # define DECLSPEC_ALIGN(x)
63 # endif
64 #endif
66 #ifndef DECLSPEC_CACHEALIGN
67 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
68 #endif
70 #ifndef DECLSPEC_UUID
71 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
72 # define DECLSPEC_UUID(x) __declspec(uuid(x))
73 # else
74 # define DECLSPEC_UUID(x)
75 # endif
76 #endif
78 #ifndef DECLSPEC_NOVTABLE
79 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
80 # define DECLSPEC_NOVTABLE __declspec(novtable)
81 # else
82 # define DECLSPEC_NOVTABLE
83 # endif
84 #endif
86 #ifndef DECLSPEC_SELECTANY
87 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
88 #define DECLSPEC_SELECTANY __declspec(selectany)
89 #else
90 #define DECLSPEC_SELECTANY
91 #endif
92 #endif
94 #ifndef NOP_FUNCTION
95 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
96 # define NOP_FUNCTION __noop
97 # else
98 # define NOP_FUNCTION (void)0
99 # endif
100 #endif
102 #ifndef DECLSPEC_ADDRSAFE
103 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
104 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
105 # else
106 # define DECLSPEC_ADDRSAFE
107 # endif
108 #endif
110 #ifndef FORCEINLINE
111 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
112 # define FORCEINLINE __forceinline
113 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
114 # define FORCEINLINE __attribute__((always_inline))
115 # else
116 # define FORCEINLINE inline
117 # endif
118 #endif
120 #ifndef DECLSPEC_DEPRECATED
121 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
122 # define DECLSPEC_DEPRECATED __declspec(deprecated)
123 # define DEPRECATE_SUPPORTED
124 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
125 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
126 # define DEPRECATE_SUPPORTED
127 # else
128 # define DECLSPEC_DEPRECATED
129 # undef DEPRECATE_SUPPORTED
130 # endif
131 #endif
133 /* a couple of useful Wine extensions */
135 #ifdef _MSC_VER
136 # define DECLSPEC_EXPORT __declspec(dllexport)
137 #elif defined(__MINGW32__)
138 # define DECLSPEC_EXPORT __attribute__((dllexport))
139 #elif defined(__GNUC__) && (__GNUC__ > 2)
140 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
141 #else
142 # define DECLSPEC_EXPORT
143 #endif
145 #if defined(__GNUC__) && (__GNUC__ > 2)
146 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
147 #else
148 # define DECLSPEC_HIDDEN
149 #endif
151 /* Anonymous union/struct handling */
153 #ifndef NONAMELESSSTRUCT
154 # ifdef __GNUC__
155 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
156 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
157 # define NONAMELESSSTRUCT
158 # endif
159 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
160 # define NONAMELESSSTRUCT
161 # endif
162 #endif /* NONAMELESSSTRUCT */
164 #ifndef NONAMELESSUNION
165 # ifdef __GNUC__
166 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
167 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
168 # define NONAMELESSUNION
169 # endif
170 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
171 # define NONAMELESSUNION
172 # endif
173 #endif /* NONAMELESSUNION */
175 #ifndef NONAMELESSSTRUCT
176 #define DUMMYSTRUCTNAME
177 #define DUMMYSTRUCTNAME1
178 #define DUMMYSTRUCTNAME2
179 #define DUMMYSTRUCTNAME3
180 #define DUMMYSTRUCTNAME4
181 #define DUMMYSTRUCTNAME5
182 #else /* !defined(NONAMELESSSTRUCT) */
183 #define DUMMYSTRUCTNAME s
184 #define DUMMYSTRUCTNAME1 s1
185 #define DUMMYSTRUCTNAME2 s2
186 #define DUMMYSTRUCTNAME3 s3
187 #define DUMMYSTRUCTNAME4 s4
188 #define DUMMYSTRUCTNAME5 s5
189 #endif /* !defined(NONAMELESSSTRUCT) */
191 #ifndef NONAMELESSUNION
192 #define DUMMYUNIONNAME
193 #define DUMMYUNIONNAME1
194 #define DUMMYUNIONNAME2
195 #define DUMMYUNIONNAME3
196 #define DUMMYUNIONNAME4
197 #define DUMMYUNIONNAME5
198 #define DUMMYUNIONNAME6
199 #define DUMMYUNIONNAME7
200 #define DUMMYUNIONNAME8
201 #else /* !defined(NONAMELESSUNION) */
202 #define DUMMYUNIONNAME u
203 #define DUMMYUNIONNAME1 u1
204 #define DUMMYUNIONNAME2 u2
205 #define DUMMYUNIONNAME3 u3
206 #define DUMMYUNIONNAME4 u4
207 #define DUMMYUNIONNAME5 u5
208 #define DUMMYUNIONNAME6 u6
209 #define DUMMYUNIONNAME7 u7
210 #define DUMMYUNIONNAME8 u8
211 #endif /* !defined(NONAMELESSUNION) */
213 /* C99 restrict support */
215 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
216 # if defined(_MSC_VER) && defined(_M_MRX000)
217 # define RESTRICTED_POINTER __restrict
218 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
219 # define RESTRICTED_POINTER __restrict
220 # else
221 # define RESTRICTED_POINTER
222 # endif
223 #else
224 # define RESTRICTED_POINTER
225 #endif
227 /* C99 unaligned support */
229 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
230 # define UNALIGNED __unaligned
231 # ifdef _WIN64
232 # define UNALIGNED64 __unaligned
233 # else
234 # define UNALIGNED64
235 # endif
236 #else
237 # define UNALIGNED
238 # define UNALIGNED64
239 #endif
241 /* Alignment macros */
243 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
244 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
245 #define MEMORY_ALLOCATION_ALIGNMENT 16
246 #else
247 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
248 #define MEMORY_ALLOCATION_ALIGNMENT 8
249 #endif
251 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
252 # define TYPE_ALIGNMENT(t) __alignof(t)
253 #elif defined(__GNUC__)
254 # define TYPE_ALIGNMENT(t) __alignof__(t)
255 #else
256 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
257 #endif
259 #ifdef _WIN64
260 # define PROBE_ALIGNMENT(_s) \
261 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
262 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
263 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
264 #else
265 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
266 #endif
268 /* Compile time assertion */
270 #if defined(_MSC_VER)
271 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
272 #elif defined(__GNUC__)
273 # define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1]
274 #endif
276 /* Eliminate Microsoft C/C++ compiler warning 4715 */
277 #if (_MSC_VER > 1200)
278 # define DEFAULT_UNREACHABLE default: __assume(0)
279 #else
280 # define DEFAULT_UNREACHABLE
281 #endif
283 /* Error Masks */
284 #define APPLICATION_ERROR_MASK 0x20000000
285 #define ERROR_SEVERITY_SUCCESS 0x00000000
286 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
287 #define ERROR_SEVERITY_WARNING 0x80000000
288 #define ERROR_SEVERITY_ERROR 0xC0000000
290 /* Microsoft's macros for declaring functions */
292 #ifdef __cplusplus
293 # define EXTERN_C extern "C"
294 #else
295 # define EXTERN_C extern
296 #endif
298 #define STDMETHODCALLTYPE __stdcall
299 #define STDMETHODVCALLTYPE __cdecl
300 #define STDAPICALLTYPE __stdcall
301 #define STDAPIVCALLTYPE __cdecl
303 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
304 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
305 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
306 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
307 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
308 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
309 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
310 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
312 /* Define the basic types */
313 #ifndef VOID
314 #define VOID void
315 #endif
316 typedef VOID *PVOID;
317 typedef VOID *PVOID64;
318 typedef BYTE BOOLEAN, *PBOOLEAN;
319 typedef char CHAR, *PCHAR;
320 typedef short SHORT, *PSHORT;
321 #if defined(_WIN64) && !defined(_MSC_VER)
322 typedef int LONG, *PLONG;
323 #else
324 typedef long LONG, *PLONG;
325 #endif
327 /* Some systems might have wchar_t, but we really need 16 bit characters */
328 #ifdef WINE_UNICODE_NATIVE
329 typedef wchar_t WCHAR, *PWCHAR;
330 #else
331 typedef unsigned short WCHAR, *PWCHAR;
332 #endif
334 /* 'Extended/Wide' numerical types */
335 #ifndef _ULONGLONG_
336 # define _ULONGLONG_
337 # ifdef _MSC_VER
338 typedef signed __int64 LONGLONG, *PLONGLONG;
339 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
340 # else
341 typedef signed __int64 DECLSPEC_ALIGN(8) LONGLONG, *PLONGLONG;
342 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONGLONG, *PULONGLONG;
343 # endif
344 #endif
346 #ifndef _DWORDLONG_
347 # define _DWORDLONG_
348 # ifdef _MSC_VER
349 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
350 # else
351 typedef ULONGLONG DECLSPEC_ALIGN(8) DWORDLONG, *PDWORDLONG;
352 # endif
353 #endif
355 /* ANSI string types */
356 typedef CHAR *PCH, *LPCH;
357 typedef const CHAR *PCCH, *LPCCH;
358 typedef CHAR *PSTR, *LPSTR, *NPSTR;
359 typedef const CHAR *PCSTR, *LPCSTR;
361 /* Unicode string types */
362 typedef WCHAR *PWCH, *LPWCH;
363 typedef const WCHAR *PCWCH, *LPCWCH;
364 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
365 typedef const WCHAR *PCWSTR, *LPCWSTR;
367 /* Neutral character and string types */
368 /* These are only defined for Winelib, i.e. _not_ defined for
369 * the emulator. The reason is they depend on the UNICODE
370 * macro which only exists in the user's code.
372 #ifndef __WINESRC__
373 # ifdef UNICODE
374 # ifndef _TCHAR_DEFINED
375 typedef WCHAR TCHAR, *PTCHAR;
376 # define _TCHAR_DEFINED
377 #endif
378 typedef LPWSTR PTSTR, LPTSTR;
379 typedef LPCWSTR PCTSTR, LPCTSTR;
380 # define __TEXT(string) L##string
381 # else /* UNICODE */
382 # ifndef _TCHAR_DEFINED
383 typedef CHAR TCHAR, *PTCHAR;
384 # define _TCHAR_DEFINED
385 # endif
386 typedef LPSTR PTSTR, LPTSTR;
387 typedef LPCSTR PCTSTR, LPCTSTR;
388 # define __TEXT(string) string
389 # endif /* UNICODE */
390 # define TEXT(quote) __TEXT(quote)
391 #endif /* __WINESRC__ */
393 /* Misc common WIN32 types */
394 typedef char CCHAR;
395 typedef LONG HRESULT;
396 typedef DWORD LCID, *PLCID;
397 typedef WORD LANGID;
398 typedef DWORD EXECUTION_STATE;
400 /* Handle type */
402 typedef void *HANDLE;
403 typedef HANDLE *PHANDLE, *LPHANDLE;
405 #ifdef STRICT
406 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
407 #else /*STRICT*/
408 #define DECLARE_HANDLE(a) typedef HANDLE a
409 #endif /*STRICT*/
411 typedef BYTE FCHAR;
412 typedef WORD FSHORT;
413 typedef DWORD FLONG;
415 /* Defines */
417 #ifndef WIN32_NO_STATUS
419 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
420 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
421 #define STATUS_USER_APC ((DWORD) 0x000000C0)
422 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
423 #define STATUS_PENDING ((DWORD) 0x00000103)
424 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
425 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
426 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
427 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
428 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
429 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
430 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
431 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
432 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
433 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
434 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
435 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
436 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
437 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
438 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
439 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
440 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
441 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
442 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
443 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
444 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
445 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
446 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
447 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
448 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
449 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
450 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
451 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
452 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
453 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
455 /* status values for ContinueDebugEvent */
456 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
457 #define DBG_CONTINUE ((DWORD) 0x00010002)
458 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
459 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
460 #define DBG_CONTROL_C ((DWORD) 0x40010005)
461 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
462 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
463 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
465 #endif /* WIN32_NO_STATUS */
467 /* Argument 1 passed to the DllEntryProc. */
468 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
469 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
470 #define DLL_THREAD_ATTACH 2 /* attach new thread */
471 #define DLL_THREAD_DETACH 3 /* detach thread */
474 /* u.x.wProcessorArchitecture (NT) */
475 #define PROCESSOR_ARCHITECTURE_INTEL 0
476 #define PROCESSOR_ARCHITECTURE_MIPS 1
477 #define PROCESSOR_ARCHITECTURE_ALPHA 2
478 #define PROCESSOR_ARCHITECTURE_PPC 3
479 #define PROCESSOR_ARCHITECTURE_SHX 4
480 #define PROCESSOR_ARCHITECTURE_ARM 5
481 #define PROCESSOR_ARCHITECTURE_IA64 6
482 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
483 #define PROCESSOR_ARCHITECTURE_MSIL 8
484 #define PROCESSOR_ARCHITECTURE_AMD64 9
485 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
487 /* dwProcessorType */
488 #define PROCESSOR_INTEL_386 386
489 #define PROCESSOR_INTEL_486 486
490 #define PROCESSOR_INTEL_PENTIUM 586
491 #define PROCESSOR_INTEL_860 860
492 #define PROCESSOR_INTEL_IA64 2200
493 #define PROCESSOR_AMD_X8664 8664
494 #define PROCESSOR_MIPS_R2000 2000
495 #define PROCESSOR_MIPS_R3000 3000
496 #define PROCESSOR_MIPS_R4000 4000
497 #define PROCESSOR_ALPHA_21064 21064
498 #define PROCESSOR_PPC_601 601
499 #define PROCESSOR_PPC_603 603
500 #define PROCESSOR_PPC_604 604
501 #define PROCESSOR_PPC_620 620
502 #define PROCESSOR_HITACHI_SH3 10003
503 #define PROCESSOR_HITACHI_SH3E 10004
504 #define PROCESSOR_HITACHI_SH4 10005
505 #define PROCESSOR_MOTOROLA_821 821
506 #define PROCESSOR_SHx_SH3 103
507 #define PROCESSOR_SHx_SH4 104
508 #define PROCESSOR_STRONGARM 2577
509 #define PROCESSOR_ARM720 1824 /* 0x720 */
510 #define PROCESSOR_ARM820 2080 /* 0x820 */
511 #define PROCESSOR_ARM920 2336 /* 0x920 */
512 #define PROCESSOR_ARM_7TDMI 70001
514 #define MAXIMUM_PROCESSORS 32
515 typedef struct _MEMORY_BASIC_INFORMATION
517 LPVOID BaseAddress;
518 LPVOID AllocationBase;
519 DWORD AllocationProtect;
520 SIZE_T RegionSize;
521 DWORD State;
522 DWORD Protect;
523 DWORD Type;
524 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
526 #define PAGE_NOACCESS 0x01
527 #define PAGE_READONLY 0x02
528 #define PAGE_READWRITE 0x04
529 #define PAGE_WRITECOPY 0x08
530 #define PAGE_EXECUTE 0x10
531 #define PAGE_EXECUTE_READ 0x20
532 #define PAGE_EXECUTE_READWRITE 0x40
533 #define PAGE_EXECUTE_WRITECOPY 0x80
534 #define PAGE_GUARD 0x100
535 #define PAGE_NOCACHE 0x200
537 #define MEM_COMMIT 0x00001000
538 #define MEM_RESERVE 0x00002000
539 #define MEM_DECOMMIT 0x00004000
540 #define MEM_RELEASE 0x00008000
541 #define MEM_FREE 0x00010000
542 #define MEM_PRIVATE 0x00020000
543 #define MEM_MAPPED 0x00040000
544 #define MEM_RESET 0x00080000
545 #define MEM_TOP_DOWN 0x00100000
546 #define MEM_PHYSICAL 0x00400000
547 #ifdef __WINESRC__
548 #define MEM_SYSTEM 0x80000000
549 #endif
551 #define SEC_FILE 0x00800000
552 #define SEC_IMAGE 0x01000000
553 #define SEC_RESERVE 0x04000000
554 #define SEC_COMMIT 0x08000000
555 #define SEC_NOCACHE 0x10000000
556 #define MEM_IMAGE SEC_IMAGE
559 #define MINCHAR 0x80
560 #define MAXCHAR 0x7f
561 #define MINSHORT 0x8000
562 #define MAXSHORT 0x7fff
563 #define MINLONG 0x80000000
564 #define MAXLONG 0x7fffffff
565 #define MAXBYTE 0xff
566 #define MAXWORD 0xffff
567 #define MAXDWORD 0xffffffff
569 #define FIELD_OFFSET(type, field) \
570 ((LONG)(INT_PTR)&(((type *)0)->field))
572 #define CONTAINING_RECORD(address, type, field) \
573 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
575 /* Types */
577 typedef struct _LIST_ENTRY {
578 struct _LIST_ENTRY *Flink;
579 struct _LIST_ENTRY *Blink;
580 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
582 typedef struct _SINGLE_LIST_ENTRY {
583 struct _SINGLE_LIST_ENTRY *Next;
584 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
586 /* Heap flags */
588 #define HEAP_NO_SERIALIZE 0x00000001
589 #define HEAP_GROWABLE 0x00000002
590 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
591 #define HEAP_ZERO_MEMORY 0x00000008
592 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
593 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
594 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
595 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
596 #define HEAP_CREATE_ALIGN_16 0x00010000
597 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
599 /* This flag allows it to create heaps shared by all processes under win95,
600 FIXME: correct name */
601 #define HEAP_SHARED 0x04000000
603 /* Processor feature flags. */
604 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
605 #define PF_FLOATING_POINT_EMULATED 1
606 #define PF_COMPARE_EXCHANGE_DOUBLE 2
607 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
608 #define PF_PPC_MOVEMEM_64BIT_OK 4
609 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
610 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
611 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
612 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
613 #define PF_PAE_ENABLED 9
614 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
615 #define PF_NX_ENABLED 12
618 /* Execution state flags */
619 #define ES_SYSTEM_REQUIRED 0x00000001
620 #define ES_DISPLAY_REQUIRED 0x00000002
621 #define ES_USER_PRESENT 0x00000004
622 #define ES_CONTINUOUS 0x80000000
624 /* The Win32 register context */
626 /* CONTEXT is the CPU-dependent context; it should be used */
627 /* wherever a platform-specific context is needed (e.g. exception */
628 /* handling, Win32 register functions). */
630 /* CONTEXT86 is the i386-specific context; it should be used */
631 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
632 /* Win16 register functions), so that this code can be compiled */
633 /* on all platforms. */
635 #define SIZE_OF_80387_REGISTERS 80
637 typedef struct _FLOATING_SAVE_AREA
639 DWORD ControlWord;
640 DWORD StatusWord;
641 DWORD TagWord;
642 DWORD ErrorOffset;
643 DWORD ErrorSelector;
644 DWORD DataOffset;
645 DWORD DataSelector;
646 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
647 DWORD Cr0NpxState;
648 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
650 #define MAXIMUM_SUPPORTED_EXTENSION 512
652 typedef struct _CONTEXT86
654 DWORD ContextFlags;
656 /* These are selected by CONTEXT_DEBUG_REGISTERS */
657 DWORD Dr0;
658 DWORD Dr1;
659 DWORD Dr2;
660 DWORD Dr3;
661 DWORD Dr6;
662 DWORD Dr7;
664 /* These are selected by CONTEXT_FLOATING_POINT */
665 FLOATING_SAVE_AREA FloatSave;
667 /* These are selected by CONTEXT_SEGMENTS */
668 DWORD SegGs;
669 DWORD SegFs;
670 DWORD SegEs;
671 DWORD SegDs;
673 /* These are selected by CONTEXT_INTEGER */
674 DWORD Edi;
675 DWORD Esi;
676 DWORD Ebx;
677 DWORD Edx;
678 DWORD Ecx;
679 DWORD Eax;
681 /* These are selected by CONTEXT_CONTROL */
682 DWORD Ebp;
683 DWORD Eip;
684 DWORD SegCs;
685 DWORD EFlags;
686 DWORD Esp;
687 DWORD SegSs;
689 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
690 } CONTEXT86;
692 #define CONTEXT_X86 0x00010000
693 #define CONTEXT_i386 CONTEXT_X86
694 #define CONTEXT_i486 CONTEXT_X86
696 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
697 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
698 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
699 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
700 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
701 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
703 /* i386 context definitions */
704 #ifdef __i386__
706 #define CONTEXT_CONTROL CONTEXT86_CONTROL
707 #define CONTEXT_INTEGER CONTEXT86_INTEGER
708 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
709 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
710 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
711 #define CONTEXT_FULL CONTEXT86_FULL
713 typedef CONTEXT86 CONTEXT;
715 #endif /* __i386__ */
717 typedef struct _LDT_ENTRY {
718 WORD LimitLow;
719 WORD BaseLow;
720 union {
721 struct {
722 BYTE BaseMid;
723 BYTE Flags1;
724 BYTE Flags2;
725 BYTE BaseHi;
726 } Bytes;
727 struct {
728 unsigned BaseMid: 8;
729 unsigned Type : 5;
730 unsigned Dpl : 2;
731 unsigned Pres : 1;
732 unsigned LimitHi : 4;
733 unsigned Sys : 1;
734 unsigned Reserved_0 : 1;
735 unsigned Default_Big : 1;
736 unsigned Granularity : 1;
737 unsigned BaseHi : 8;
738 } Bits;
739 } HighWord;
740 } LDT_ENTRY, *PLDT_ENTRY;
742 /* x86-64 context definitions */
743 #if defined(__x86_64__)
745 #define CONTEXT_AMD64 0x00100000
747 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
748 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
749 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
750 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008L)
751 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010L)
752 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
753 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
755 typedef struct DECLSPEC_ALIGN(16) _M128A {
756 ULONGLONG Low;
757 LONGLONG High;
758 } M128A, *PM128A;
760 typedef struct _XMM_SAVE_AREA32 {
761 WORD ControlWord;
762 WORD StatusWord;
763 BYTE TagWord;
764 BYTE Reserved1;
765 WORD ErrorOpcode;
766 DWORD ErrorOffset;
767 WORD ErrorSelector;
768 WORD Reserved2;
769 DWORD DataOffset;
770 WORD DataSelector;
771 WORD Reserved3;
772 DWORD MxCsr;
773 DWORD MxCsr_Mask;
774 M128A FloatRegisters[8];
775 M128A XmmRegisters[16];
776 BYTE Reserved4[96];
777 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
779 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
780 DWORD64 P1Home;
781 DWORD64 P2Home;
782 DWORD64 P3Home;
783 DWORD64 P4Home;
784 DWORD64 P5Home;
785 DWORD64 P6Home;
787 /* Control flags */
788 DWORD ContextFlags;
789 DWORD MxCsr;
791 /* Segment */
792 WORD SegCs;
793 WORD SegDs;
794 WORD SegEs;
795 WORD SegFs;
796 WORD SegGs;
797 WORD SegSs;
798 DWORD EFlags;
800 /* Debug */
801 DWORD64 Dr0;
802 DWORD64 Dr1;
803 DWORD64 Dr2;
804 DWORD64 Dr3;
805 DWORD64 Dr6;
806 DWORD64 Dr7;
808 /* Integer */
809 DWORD64 Rax;
810 DWORD64 Rcx;
811 DWORD64 Rdx;
812 DWORD64 Rbx;
813 DWORD64 Rsp;
814 DWORD64 Rbp;
815 DWORD64 Rsi;
816 DWORD64 Rdi;
817 DWORD64 R8;
818 DWORD64 R9;
819 DWORD64 R10;
820 DWORD64 R11;
821 DWORD64 R12;
822 DWORD64 R13;
823 DWORD64 R14;
824 DWORD64 R15;
826 /* Counter */
827 DWORD64 Rip;
829 /* Floating point */
830 union {
831 XMM_SAVE_AREA32 FltSave;
832 struct {
833 M128A Header[2];
834 M128A Legacy[8];
835 M128A Xmm0;
836 M128A Xmm1;
837 M128A Xmm2;
838 M128A Xmm3;
839 M128A Xmm4;
840 M128A Xmm5;
841 M128A Xmm6;
842 M128A Xmm7;
843 M128A Xmm8;
844 M128A Xmm9;
845 M128A Xmm10;
846 M128A Xmm11;
847 M128A Xmm12;
848 M128A Xmm13;
849 M128A Xmm14;
850 M128A Xmm15;
851 } DUMMYSTRUCTNAME;
852 } DUMMYUNIONNAME;
854 /* Vector */
855 M128A VectorRegister[26];
856 DWORD64 VectorControl;
858 /* Debug control */
859 DWORD64 DebugControl;
860 DWORD64 LastBranchToRip;
861 DWORD64 LastBranchFromRip;
862 DWORD64 LastExceptionToRip;
863 DWORD64 LastExceptionFromRip;
864 } CONTEXT;
866 #endif /* __x86_64__ */
868 /* Alpha context definitions */
869 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
871 #define CONTEXT_ALPHA 0x00020000
873 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
874 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
875 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
876 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
878 typedef struct _CONTEXT
880 /* selected by CONTEXT_FLOATING_POINT */
881 ULONGLONG FltF0;
882 ULONGLONG FltF1;
883 ULONGLONG FltF2;
884 ULONGLONG FltF3;
885 ULONGLONG FltF4;
886 ULONGLONG FltF5;
887 ULONGLONG FltF6;
888 ULONGLONG FltF7;
889 ULONGLONG FltF8;
890 ULONGLONG FltF9;
891 ULONGLONG FltF10;
892 ULONGLONG FltF11;
893 ULONGLONG FltF12;
894 ULONGLONG FltF13;
895 ULONGLONG FltF14;
896 ULONGLONG FltF15;
897 ULONGLONG FltF16;
898 ULONGLONG FltF17;
899 ULONGLONG FltF18;
900 ULONGLONG FltF19;
901 ULONGLONG FltF20;
902 ULONGLONG FltF21;
903 ULONGLONG FltF22;
904 ULONGLONG FltF23;
905 ULONGLONG FltF24;
906 ULONGLONG FltF25;
907 ULONGLONG FltF26;
908 ULONGLONG FltF27;
909 ULONGLONG FltF28;
910 ULONGLONG FltF29;
911 ULONGLONG FltF30;
912 ULONGLONG FltF31;
914 /* selected by CONTEXT_INTEGER */
915 ULONGLONG IntV0;
916 ULONGLONG IntT0;
917 ULONGLONG IntT1;
918 ULONGLONG IntT2;
919 ULONGLONG IntT3;
920 ULONGLONG IntT4;
921 ULONGLONG IntT5;
922 ULONGLONG IntT6;
923 ULONGLONG IntT7;
924 ULONGLONG IntS0;
925 ULONGLONG IntS1;
926 ULONGLONG IntS2;
927 ULONGLONG IntS3;
928 ULONGLONG IntS4;
929 ULONGLONG IntS5;
930 ULONGLONG IntFp;
931 ULONGLONG IntA0;
932 ULONGLONG IntA1;
933 ULONGLONG IntA2;
934 ULONGLONG IntA3;
935 ULONGLONG IntA4;
936 ULONGLONG IntA5;
937 ULONGLONG IntT8;
938 ULONGLONG IntT9;
939 ULONGLONG IntT10;
940 ULONGLONG IntT11;
941 ULONGLONG IntRa;
942 ULONGLONG IntT12;
943 ULONGLONG IntAt;
944 ULONGLONG IntGp;
945 ULONGLONG IntSp;
946 ULONGLONG IntZero;
948 /* selected by CONTEXT_FLOATING_POINT */
949 ULONGLONG Fpcr;
950 ULONGLONG SoftFpcr;
952 /* selected by CONTEXT_CONTROL */
953 ULONGLONG Fir;
954 DWORD Psr;
955 DWORD ContextFlags;
956 DWORD Fill[4];
957 } CONTEXT;
959 #define _QUAD_PSR_OFFSET HighSoftFpcr
960 #define _QUAD_FLAGS_OFFSET HighFir
962 #endif /* _ALPHA_ */
964 #ifdef __arm__
966 /* The following flags control the contents of the CONTEXT structure. */
968 #define CONTEXT_ARM 0x0000040
969 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
970 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
972 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
974 typedef struct _CONTEXT {
975 /* The flags values within this flag control the contents of
976 a CONTEXT record.
978 If the context record is used as an input parameter, then
979 for each portion of the context record controlled by a flag
980 whose value is set, it is assumed that that portion of the
981 context record contains valid context. If the context record
982 is being used to modify a thread's context, then only that
983 portion of the threads context will be modified.
985 If the context record is used as an IN OUT parameter to capture
986 the context of a thread, then only those portions of the thread's
987 context corresponding to set flags will be returned.
989 The context record is never used as an OUT only parameter. */
991 ULONG ContextFlags;
993 /* This section is specified/returned if the ContextFlags word contains
994 the flag CONTEXT_INTEGER. */
995 ULONG R0;
996 ULONG R1;
997 ULONG R2;
998 ULONG R3;
999 ULONG R4;
1000 ULONG R5;
1001 ULONG R6;
1002 ULONG R7;
1003 ULONG R8;
1004 ULONG R9;
1005 ULONG R10;
1006 ULONG R11;
1007 ULONG R12;
1009 ULONG Sp;
1010 ULONG Lr;
1011 ULONG Pc;
1012 ULONG Psr;
1013 } CONTEXT;
1015 #endif /* __arm__ */
1018 /* Mips context definitions */
1019 #ifdef _MIPS_
1021 #define CONTEXT_R4000 0x00010000
1023 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
1024 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
1025 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
1027 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1029 typedef struct _CONTEXT
1031 DWORD Argument[4];
1032 /* These are selected by CONTEXT_FLOATING_POINT */
1033 DWORD FltF0;
1034 DWORD FltF1;
1035 DWORD FltF2;
1036 DWORD FltF3;
1037 DWORD FltF4;
1038 DWORD FltF5;
1039 DWORD FltF6;
1040 DWORD FltF7;
1041 DWORD FltF8;
1042 DWORD FltF9;
1043 DWORD FltF10;
1044 DWORD FltF11;
1045 DWORD FltF12;
1046 DWORD FltF13;
1047 DWORD FltF14;
1048 DWORD FltF15;
1049 DWORD FltF16;
1050 DWORD FltF17;
1051 DWORD FltF18;
1052 DWORD FltF19;
1053 DWORD FltF20;
1054 DWORD FltF21;
1055 DWORD FltF22;
1056 DWORD FltF23;
1057 DWORD FltF24;
1058 DWORD FltF25;
1059 DWORD FltF26;
1060 DWORD FltF27;
1061 DWORD FltF28;
1062 DWORD FltF29;
1063 DWORD FltF30;
1064 DWORD FltF31;
1066 /* These are selected by CONTEXT_INTEGER */
1067 DWORD IntZero;
1068 DWORD IntAt;
1069 DWORD IntV0;
1070 DWORD IntV1;
1071 DWORD IntA0;
1072 DWORD IntA1;
1073 DWORD IntA2;
1074 DWORD IntA3;
1075 DWORD IntT0;
1076 DWORD IntT1;
1077 DWORD IntT2;
1078 DWORD IntT3;
1079 DWORD IntT4;
1080 DWORD IntT5;
1081 DWORD IntT6;
1082 DWORD IntT7;
1083 DWORD IntS0;
1084 DWORD IntS1;
1085 DWORD IntS2;
1086 DWORD IntS3;
1087 DWORD IntS4;
1088 DWORD IntS5;
1089 DWORD IntS6;
1090 DWORD IntS7;
1091 DWORD IntT8;
1092 DWORD IntT9;
1093 DWORD IntK0;
1094 DWORD IntK1;
1095 DWORD IntGp;
1096 DWORD IntSp;
1097 DWORD IntS8;
1098 DWORD IntRa;
1099 DWORD IntLo;
1100 DWORD IntHi;
1102 /* These are selected by CONTEXT_FLOATING_POINT */
1103 DWORD Fsr;
1105 /* These are selected by CONTEXT_CONTROL */
1106 DWORD Fir;
1107 DWORD Psr;
1109 DWORD ContextFlags;
1110 DWORD Fill[2];
1111 } CONTEXT;
1113 #endif /* _MIPS_ */
1115 /* PowerPC context definitions */
1116 #ifdef __powerpc__
1118 #define CONTEXT_CONTROL 0x0001
1119 #define CONTEXT_FLOATING_POINT 0x0002
1120 #define CONTEXT_INTEGER 0x0004
1121 #define CONTEXT_DEBUG_REGISTERS 0x0008
1122 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1124 typedef struct
1126 /* These are selected by CONTEXT_FLOATING_POINT */
1127 double Fpr0;
1128 double Fpr1;
1129 double Fpr2;
1130 double Fpr3;
1131 double Fpr4;
1132 double Fpr5;
1133 double Fpr6;
1134 double Fpr7;
1135 double Fpr8;
1136 double Fpr9;
1137 double Fpr10;
1138 double Fpr11;
1139 double Fpr12;
1140 double Fpr13;
1141 double Fpr14;
1142 double Fpr15;
1143 double Fpr16;
1144 double Fpr17;
1145 double Fpr18;
1146 double Fpr19;
1147 double Fpr20;
1148 double Fpr21;
1149 double Fpr22;
1150 double Fpr23;
1151 double Fpr24;
1152 double Fpr25;
1153 double Fpr26;
1154 double Fpr27;
1155 double Fpr28;
1156 double Fpr29;
1157 double Fpr30;
1158 double Fpr31;
1159 double Fpscr;
1161 /* These are selected by CONTEXT_INTEGER */
1162 DWORD Gpr0;
1163 DWORD Gpr1;
1164 DWORD Gpr2;
1165 DWORD Gpr3;
1166 DWORD Gpr4;
1167 DWORD Gpr5;
1168 DWORD Gpr6;
1169 DWORD Gpr7;
1170 DWORD Gpr8;
1171 DWORD Gpr9;
1172 DWORD Gpr10;
1173 DWORD Gpr11;
1174 DWORD Gpr12;
1175 DWORD Gpr13;
1176 DWORD Gpr14;
1177 DWORD Gpr15;
1178 DWORD Gpr16;
1179 DWORD Gpr17;
1180 DWORD Gpr18;
1181 DWORD Gpr19;
1182 DWORD Gpr20;
1183 DWORD Gpr21;
1184 DWORD Gpr22;
1185 DWORD Gpr23;
1186 DWORD Gpr24;
1187 DWORD Gpr25;
1188 DWORD Gpr26;
1189 DWORD Gpr27;
1190 DWORD Gpr28;
1191 DWORD Gpr29;
1192 DWORD Gpr30;
1193 DWORD Gpr31;
1195 DWORD Cr;
1196 DWORD Xer;
1198 /* These are selected by CONTEXT_CONTROL */
1199 DWORD Msr;
1200 DWORD Iar; /* Instruction Address Register , aka PC ... */
1201 DWORD Lr;
1202 DWORD Ctr;
1204 DWORD ContextFlags;
1206 DWORD Dar; /* Fault registers for coredump */
1207 DWORD Dsisr;
1208 DWORD Trap; /* number of powerpc exception taken */
1210 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1211 DWORD Dr0;
1212 DWORD Dr1;
1213 DWORD Dr2;
1214 DWORD Dr3;
1215 DWORD Dr4;
1216 DWORD Dr5;
1217 DWORD Dr6;
1218 DWORD Dr7;
1219 } CONTEXT;
1221 typedef struct _STACK_FRAME_HEADER
1223 DWORD BackChain;
1224 DWORD GlueSaved1;
1225 DWORD GlueSaved2;
1226 DWORD Reserved1;
1227 DWORD Spare1;
1228 DWORD Spare2;
1230 DWORD Parameter0;
1231 DWORD Parameter1;
1232 DWORD Parameter2;
1233 DWORD Parameter3;
1234 DWORD Parameter4;
1235 DWORD Parameter5;
1236 DWORD Parameter6;
1237 DWORD Parameter7;
1238 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
1240 #endif /* __powerpc__ */
1242 #ifdef __sparc__
1245 * FIXME:
1247 * There is no official CONTEXT structure defined for the SPARC
1248 * architecture, so I just made one up.
1250 * This structure is valid only for 32-bit SPARC architectures,
1251 * not for 64-bit SPARC.
1253 * Note that this structure contains only the 'top-level' registers;
1254 * the rest of the register window chain is not visible.
1256 * The layout follows the Solaris 'prgregset_t' structure.
1260 #define CONTEXT_SPARC 0x10000000
1262 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
1263 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
1264 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
1266 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1268 typedef struct _CONTEXT
1270 DWORD ContextFlags;
1272 /* These are selected by CONTEXT_INTEGER */
1273 DWORD g0;
1274 DWORD g1;
1275 DWORD g2;
1276 DWORD g3;
1277 DWORD g4;
1278 DWORD g5;
1279 DWORD g6;
1280 DWORD g7;
1281 DWORD o0;
1282 DWORD o1;
1283 DWORD o2;
1284 DWORD o3;
1285 DWORD o4;
1286 DWORD o5;
1287 DWORD o6;
1288 DWORD o7;
1289 DWORD l0;
1290 DWORD l1;
1291 DWORD l2;
1292 DWORD l3;
1293 DWORD l4;
1294 DWORD l5;
1295 DWORD l6;
1296 DWORD l7;
1297 DWORD i0;
1298 DWORD i1;
1299 DWORD i2;
1300 DWORD i3;
1301 DWORD i4;
1302 DWORD i5;
1303 DWORD i6;
1304 DWORD i7;
1306 /* These are selected by CONTEXT_CONTROL */
1307 DWORD psr;
1308 DWORD pc;
1309 DWORD npc;
1310 DWORD y;
1311 DWORD wim;
1312 DWORD tbr;
1314 /* FIXME: floating point registers missing */
1316 } CONTEXT;
1318 #endif /* __sparc__ */
1320 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1321 #error You need to define a CONTEXT for your CPU
1322 #endif
1324 typedef CONTEXT *PCONTEXT;
1327 * Language IDs
1330 #define MAKELCID(l, s) (MAKELONG(l, s))
1332 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1333 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1334 #define SUBLANGID(l) ((WORD)(l) >> 10)
1336 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1337 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1339 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1340 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1341 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1342 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1343 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1345 #define UNREFERENCED_PARAMETER(u) (u)
1346 #define DBG_UNREFERENCED_PARAMETER(u) (u)
1347 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (u)
1349 /* FIXME: are the symbolic names correct for LIDs: 0x17, 0x28,
1350 * 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x3a, 0x3b, 0x3c
1352 #define LANG_NEUTRAL 0x00
1353 #define LANG_INVARIANT 0x7f
1355 #define LANG_AFRIKAANS 0x36
1356 #define LANG_ALBANIAN 0x1c
1357 #define LANG_ARABIC 0x01
1358 #define LANG_ARMENIAN 0x2b
1359 #define LANG_ASSAMESE 0x4d
1360 #define LANG_AZERI 0x2c
1361 #define LANG_BASQUE 0x2d
1362 #define LANG_BELARUSIAN 0x23
1363 #define LANG_BENGALI 0x45
1364 #define LANG_BULGARIAN 0x02
1365 #define LANG_CATALAN 0x03
1366 #define LANG_CHINESE 0x04
1367 #define LANG_CROATIAN 0x1a
1368 #define LANG_CZECH 0x05
1369 #define LANG_DANISH 0x06
1370 #define LANG_DIVEHI 0x65
1371 #define LANG_DUTCH 0x13
1372 #define LANG_ENGLISH 0x09
1373 #define LANG_ESTONIAN 0x25
1374 #define LANG_FAEROESE 0x38
1375 #define LANG_FARSI 0x29
1376 #define LANG_FINNISH 0x0b
1377 #define LANG_FRENCH 0x0c
1378 #define LANG_GALICIAN 0x56
1379 #define LANG_GEORGIAN 0x37
1380 #define LANG_GERMAN 0x07
1381 #define LANG_GREEK 0x08
1382 #define LANG_GUJARATI 0x47
1383 #define LANG_HEBREW 0x0d
1384 #define LANG_HINDI 0x39
1385 #define LANG_HUNGARIAN 0x0e
1386 #define LANG_ICELANDIC 0x0f
1387 #define LANG_INDONESIAN 0x21
1388 #define LANG_ITALIAN 0x10
1389 #define LANG_JAPANESE 0x11
1390 #define LANG_KANNADA 0x4b
1391 #define LANG_KASHMIRI 0x60
1392 #define LANG_KAZAK 0x3f
1393 #define LANG_KONKANI 0x57
1394 #define LANG_KOREAN 0x12
1395 #define LANG_KYRGYZ 0x40
1396 #define LANG_LATVIAN 0x26
1397 #define LANG_LITHUANIAN 0x27
1398 #define LANG_MACEDONIAN 0x2f
1399 #define LANG_MALAY 0x3e
1400 #define LANG_MALAYALAM 0x4c
1401 #define LANG_MANIPURI 0x58
1402 #define LANG_MARATHI 0x4e
1403 #define LANG_MONGOLIAN 0x50
1404 #define LANG_NEPALI 0x61
1405 #define LANG_NORWEGIAN 0x14
1406 #define LANG_ORIYA 0x48
1407 #define LANG_POLISH 0x15
1408 #define LANG_PORTUGUESE 0x16
1409 #define LANG_PUNJABI 0x46
1410 #define LANG_ROMANIAN 0x18
1411 #define LANG_RUSSIAN 0x19
1412 #define LANG_SANSKRIT 0x4f
1413 #define LANG_SERBIAN 0x1a
1414 #define LANG_SINDHI 0x59
1415 #define LANG_SLOVAK 0x1b
1416 #define LANG_SLOVENIAN 0x24
1417 #define LANG_SPANISH 0x0a
1418 #define LANG_SWAHILI 0x41
1419 #define LANG_SWEDISH 0x1d
1420 #define LANG_SYRIAC 0x5a
1421 #define LANG_TAMIL 0x49
1422 #define LANG_TATAR 0x44
1423 #define LANG_TELUGU 0x4a
1424 #define LANG_THAI 0x1e
1425 #define LANG_TURKISH 0x1f
1426 #define LANG_UKRAINIAN 0x22
1427 #define LANG_URDU 0x20
1428 #define LANG_UZBEK 0x43
1429 #define LANG_VIETNAMESE 0x2a
1431 /* FIXME: these are not in the Windows header */
1432 #define LANG_GAELIC 0x3c
1433 #define LANG_MALTESE 0x3a
1434 #define LANG_MAORI 0x28
1435 #define LANG_RHAETO_ROMANCE 0x17
1436 #define LANG_SAAMI 0x3b
1437 #define LANG_SORBIAN 0x2e
1438 #define LANG_SUTU 0x30
1439 #define LANG_TSONGA 0x31
1440 #define LANG_TSWANA 0x32
1441 #define LANG_VENDA 0x33
1442 #define LANG_XHOSA 0x34
1443 #define LANG_ZULU 0x35
1445 /* non standard; keep the number high enough (but < 0xff) */
1446 #define LANG_ESPERANTO 0x8f
1447 #define LANG_WALON 0x90
1448 #define LANG_CORNISH 0x91
1449 #define LANG_WELSH 0x92
1450 #define LANG_BRETON 0x93
1452 /* Sublanguage definitions */
1453 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
1454 #define SUBLANG_DEFAULT 0x01 /* user default */
1455 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
1457 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
1458 #define SUBLANG_ARABIC_IRAQ 0x02
1459 #define SUBLANG_ARABIC_EGYPT 0x03
1460 #define SUBLANG_ARABIC_LIBYA 0x04
1461 #define SUBLANG_ARABIC_ALGERIA 0x05
1462 #define SUBLANG_ARABIC_MOROCCO 0x06
1463 #define SUBLANG_ARABIC_TUNISIA 0x07
1464 #define SUBLANG_ARABIC_OMAN 0x08
1465 #define SUBLANG_ARABIC_YEMEN 0x09
1466 #define SUBLANG_ARABIC_SYRIA 0x0a
1467 #define SUBLANG_ARABIC_JORDAN 0x0b
1468 #define SUBLANG_ARABIC_LEBANON 0x0c
1469 #define SUBLANG_ARABIC_KUWAIT 0x0d
1470 #define SUBLANG_ARABIC_UAE 0x0e
1471 #define SUBLANG_ARABIC_BAHRAIN 0x0f
1472 #define SUBLANG_ARABIC_QATAR 0x10
1473 #define SUBLANG_AZERI_LATIN 0x01
1474 #define SUBLANG_AZERI_CYRILLIC 0x02
1475 #define SUBLANG_CHINESE_TRADITIONAL 0x01
1476 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
1477 #define SUBLANG_CHINESE_HONGKONG 0x03
1478 #define SUBLANG_CHINESE_SINGAPORE 0x04
1479 #define SUBLANG_CHINESE_MACAU 0x05
1480 #define SUBLANG_DUTCH 0x01
1481 #define SUBLANG_DUTCH_BELGIAN 0x02
1482 #define SUBLANG_ENGLISH_US 0x01
1483 #define SUBLANG_ENGLISH_UK 0x02
1484 #define SUBLANG_ENGLISH_AUS 0x03
1485 #define SUBLANG_ENGLISH_CAN 0x04
1486 #define SUBLANG_ENGLISH_NZ 0x05
1487 #define SUBLANG_ENGLISH_EIRE 0x06
1488 #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
1489 #define SUBLANG_ENGLISH_JAMAICA 0x08
1490 #define SUBLANG_ENGLISH_CARIBBEAN 0x09
1491 #define SUBLANG_ENGLISH_BELIZE 0x0a
1492 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
1493 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
1494 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
1495 #define SUBLANG_FRENCH 0x01
1496 #define SUBLANG_FRENCH_BELGIAN 0x02
1497 #define SUBLANG_FRENCH_CANADIAN 0x03
1498 #define SUBLANG_FRENCH_SWISS 0x04
1499 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
1500 #define SUBLANG_FRENCH_MONACO 0x06
1501 #define SUBLANG_GERMAN 0x01
1502 #define SUBLANG_GERMAN_SWISS 0x02
1503 #define SUBLANG_GERMAN_AUSTRIAN 0x03
1504 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
1505 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
1506 #define SUBLANG_ITALIAN 0x01
1507 #define SUBLANG_ITALIAN_SWISS 0x02
1508 #define SUBLANG_KASHMIRI_SASIA 0x02
1509 #define SUBLANG_KASHMIRI_INDIA 0x02
1510 #define SUBLANG_KOREAN 0x01
1511 #define SUBLANG_LITHUANIAN 0x01
1512 #define SUBLANG_MALAY_MALAYSIA 0x01
1513 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
1514 #define SUBLANG_NEPALI_INDIA 0x02
1515 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
1516 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
1517 #define SUBLANG_PORTUGUESE 0x02
1518 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
1519 #define SUBLANG_SERBIAN_LATIN 0x02
1520 #define SUBLANG_SERBIAN_CYRILLIC 0x03
1521 #define SUBLANG_SPANISH 0x01
1522 #define SUBLANG_SPANISH_MEXICAN 0x02
1523 #define SUBLANG_SPANISH_MODERN 0x03
1524 #define SUBLANG_SPANISH_GUATEMALA 0x04
1525 #define SUBLANG_SPANISH_COSTA_RICA 0x05
1526 #define SUBLANG_SPANISH_PANAMA 0x06
1527 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
1528 #define SUBLANG_SPANISH_VENEZUELA 0x08
1529 #define SUBLANG_SPANISH_COLOMBIA 0x09
1530 #define SUBLANG_SPANISH_PERU 0x0a
1531 #define SUBLANG_SPANISH_ARGENTINA 0x0b
1532 #define SUBLANG_SPANISH_ECUADOR 0x0c
1533 #define SUBLANG_SPANISH_CHILE 0x0d
1534 #define SUBLANG_SPANISH_URUGUAY 0x0e
1535 #define SUBLANG_SPANISH_PARAGUAY 0x0f
1536 #define SUBLANG_SPANISH_BOLIVIA 0x10
1537 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
1538 #define SUBLANG_SPANISH_HONDURAS 0x12
1539 #define SUBLANG_SPANISH_NICARAGUA 0x13
1540 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
1541 #define SUBLANG_SWEDISH 0x01
1542 #define SUBLANG_SWEDISH_FINLAND 0x02
1543 #define SUBLANG_URDU_PAKISTAN 0x01
1544 #define SUBLANG_URDU_INDIA 0x02
1545 #define SUBLANG_UZBEK_LATIN 0x01
1546 #define SUBLANG_UZBEK_CYRILLIC 0x02
1548 /* FIXME: these are not in the Windows header */
1549 #define SUBLANG_DUTCH_SURINAM 0x03
1550 #define SUBLANG_ROMANIAN 0x01
1551 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
1552 #define SUBLANG_RUSSIAN 0x01
1553 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
1554 #define SUBLANG_CROATIAN 0x01
1555 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
1556 #define SUBLANG_GAELIC 0x01
1557 #define SUBLANG_GAELIC_SCOTTISH 0x02
1558 #define SUBLANG_GAELIC_MANX 0x03
1562 * Sort definitions
1565 #define SORT_DEFAULT 0x0
1566 #define SORT_JAPANESE_XJIS 0x0
1567 #define SORT_JAPANESE_UNICODE 0x1
1568 #define SORT_CHINESE_BIG5 0x0
1569 #define SORT_CHINESE_UNICODE 0x1
1570 #define SORT_KOREAN_KSC 0x0
1571 #define SORT_KOREAN_UNICODE 0x1
1576 * Definitions for IsTextUnicode()
1579 #define IS_TEXT_UNICODE_ASCII16 0x0001
1580 #define IS_TEXT_UNICODE_STATISTICS 0x0002
1581 #define IS_TEXT_UNICODE_CONTROLS 0x0004
1582 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
1583 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
1584 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
1585 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
1586 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
1587 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
1588 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
1589 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
1590 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
1591 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
1592 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
1593 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
1594 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
1596 #define MAXIMUM_WAIT_OBJECTS 64
1597 #define MAXIMUM_SUSPEND_COUNT 127
1601 * From OS/2 2.0 exception handling
1602 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
1605 #define EH_NONCONTINUABLE 0x01
1606 #define EH_UNWINDING 0x02
1607 #define EH_EXIT_UNWIND 0x04
1608 #define EH_STACK_INVALID 0x08
1609 #define EH_NESTED_CALL 0x10
1611 #define EXCEPTION_CONTINUABLE 0
1612 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
1615 * The exception record used by Win32 to give additional information
1616 * about exception to exception handlers.
1619 #define EXCEPTION_MAXIMUM_PARAMETERS 15
1621 typedef struct _EXCEPTION_RECORD
1623 DWORD ExceptionCode;
1624 DWORD ExceptionFlags;
1625 struct _EXCEPTION_RECORD *ExceptionRecord;
1627 PVOID ExceptionAddress;
1628 DWORD NumberParameters;
1629 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1630 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1633 * The exception pointers structure passed to exception filters
1634 * in except() and the UnhandledExceptionFilter().
1637 typedef struct _EXCEPTION_POINTERS
1639 PEXCEPTION_RECORD ExceptionRecord;
1640 PCONTEXT ContextRecord;
1641 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1645 * The exception frame, used for registering exception handlers
1646 * Win32 cares only about this, but compilers generally emit
1647 * larger exception frames for their own use.
1650 struct _EXCEPTION_REGISTRATION_RECORD;
1652 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
1653 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
1655 typedef struct _EXCEPTION_REGISTRATION_RECORD
1657 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
1658 PEXCEPTION_HANDLER Handler;
1659 } EXCEPTION_REGISTRATION_RECORD;
1662 * function pointer to an exception filter
1665 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
1666 typedef LONG (CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1667 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1669 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1670 LPTOP_LEVEL_EXCEPTION_FILTER
1671 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1673 typedef struct _NT_TIB
1675 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1676 PVOID StackBase;
1677 PVOID StackLimit;
1678 PVOID SubSystemTib;
1679 union {
1680 PVOID FiberData;
1681 DWORD Version;
1682 } DUMMYUNIONNAME;
1683 PVOID ArbitraryUserPointer;
1684 struct _NT_TIB *Self;
1685 } NT_TIB, *PNT_TIB;
1687 struct _TEB;
1689 #if defined(__i386__) && defined(__GNUC__)
1690 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
1691 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1693 struct _TEB *teb;
1694 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1695 return teb;
1697 #elif defined(__i386__) && defined(_MSC_VER)
1698 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1700 struct _TEB *teb;
1701 __asm mov eax, fs:[0x18];
1702 __asm mov teb, eax;
1703 return teb;
1705 #else
1706 extern struct _TEB * WINAPI NtCurrentTeb(void);
1707 #endif
1709 #ifdef NONAMELESSUNION
1710 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
1711 #else
1712 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
1713 #endif
1714 #define GetFiberData() (*(void **)GetCurrentFiber())
1716 #define TLS_MINIMUM_AVAILABLE 64
1719 * File formats definitions
1722 #include <pshpack2.h>
1723 typedef struct _IMAGE_DOS_HEADER {
1724 WORD e_magic; /* 00: MZ Header signature */
1725 WORD e_cblp; /* 02: Bytes on last page of file */
1726 WORD e_cp; /* 04: Pages in file */
1727 WORD e_crlc; /* 06: Relocations */
1728 WORD e_cparhdr; /* 08: Size of header in paragraphs */
1729 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
1730 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
1731 WORD e_ss; /* 0e: Initial (relative) SS value */
1732 WORD e_sp; /* 10: Initial SP value */
1733 WORD e_csum; /* 12: Checksum */
1734 WORD e_ip; /* 14: Initial IP value */
1735 WORD e_cs; /* 16: Initial (relative) CS value */
1736 WORD e_lfarlc; /* 18: File address of relocation table */
1737 WORD e_ovno; /* 1a: Overlay number */
1738 WORD e_res[4]; /* 1c: Reserved words */
1739 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
1740 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
1741 WORD e_res2[10]; /* 28: Reserved words */
1742 DWORD e_lfanew; /* 3c: Offset to extended header */
1743 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1744 #include <poppack.h>
1746 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
1747 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
1748 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
1749 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
1750 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
1751 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
1754 * This is the Windows executable (NE) header.
1755 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
1757 #include <pshpack2.h>
1758 typedef struct
1760 WORD ne_magic; /* 00 NE signature 'NE' */
1761 BYTE ne_ver; /* 02 Linker version number */
1762 BYTE ne_rev; /* 03 Linker revision number */
1763 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
1764 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
1765 LONG ne_crc; /* 08 Checksum */
1766 WORD ne_flags; /* 0c Flags about segments in this file */
1767 WORD ne_autodata; /* 0e Automatic data segment number */
1768 WORD ne_heap; /* 10 Initial size of local heap */
1769 WORD ne_stack; /* 12 Initial size of stack */
1770 DWORD ne_csip; /* 14 Initial CS:IP */
1771 DWORD ne_sssp; /* 18 Initial SS:SP */
1772 WORD ne_cseg; /* 1c # of entries in segment table */
1773 WORD ne_cmod; /* 1e # of entries in module reference tab. */
1774 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
1775 WORD ne_segtab; /* 22 Offset to segment table */
1776 WORD ne_rsrctab; /* 24 Offset to resource table */
1777 WORD ne_restab; /* 26 Offset to resident-name table */
1778 WORD ne_modtab; /* 28 Offset to module reference table */
1779 WORD ne_imptab; /* 2a Offset to imported name table */
1780 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
1781 WORD ne_cmovent; /* 30 # of movable entry points */
1782 WORD ne_align; /* 32 Logical sector alignment shift count */
1783 WORD ne_cres; /* 34 # of resource segments */
1784 BYTE ne_exetyp; /* 36 Flags indicating target OS */
1785 BYTE ne_flagsothers; /* 37 Additional information flags */
1786 WORD ne_pretthunks; /* 38 Offset to return thunks */
1787 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
1788 WORD ne_swaparea; /* 3c Reserved by Microsoft */
1789 WORD ne_expver; /* 3e Expected Windows version number */
1790 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
1791 #include <poppack.h>
1793 #include <pshpack2.h>
1794 typedef struct _IMAGE_VXD_HEADER {
1795 WORD e32_magic;
1796 BYTE e32_border;
1797 BYTE e32_worder;
1798 DWORD e32_level;
1799 WORD e32_cpu;
1800 WORD e32_os;
1801 DWORD e32_ver;
1802 DWORD e32_mflags;
1803 DWORD e32_mpages;
1804 DWORD e32_startobj;
1805 DWORD e32_eip;
1806 DWORD e32_stackobj;
1807 DWORD e32_esp;
1808 DWORD e32_pagesize;
1809 DWORD e32_lastpagesize;
1810 DWORD e32_fixupsize;
1811 DWORD e32_fixupsum;
1812 DWORD e32_ldrsize;
1813 DWORD e32_ldrsum;
1814 DWORD e32_objtab;
1815 DWORD e32_objcnt;
1816 DWORD e32_objmap;
1817 DWORD e32_itermap;
1818 DWORD e32_rsrctab;
1819 DWORD e32_rsrccnt;
1820 DWORD e32_restab;
1821 DWORD e32_enttab;
1822 DWORD e32_dirtab;
1823 DWORD e32_dircnt;
1824 DWORD e32_fpagetab;
1825 DWORD e32_frectab;
1826 DWORD e32_impmod;
1827 DWORD e32_impmodcnt;
1828 DWORD e32_impproc;
1829 DWORD e32_pagesum;
1830 DWORD e32_datapage;
1831 DWORD e32_preload;
1832 DWORD e32_nrestab;
1833 DWORD e32_cbnrestab;
1834 DWORD e32_nressum;
1835 DWORD e32_autodata;
1836 DWORD e32_debuginfo;
1837 DWORD e32_debuglen;
1838 DWORD e32_instpreload;
1839 DWORD e32_instdemand;
1840 DWORD e32_heapsize;
1841 BYTE e32_res3[12];
1842 DWORD e32_winresoff;
1843 DWORD e32_winreslen;
1844 WORD e32_devid;
1845 WORD e32_ddkver;
1846 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
1847 #include <poppack.h>
1849 /* These defines describe the meanings of the bits in the Characteristics
1850 field */
1852 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
1853 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
1854 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
1855 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
1856 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
1857 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
1858 #define IMAGE_FILE_16BIT_MACHINE 0x0040
1859 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
1860 #define IMAGE_FILE_32BIT_MACHINE 0x0100
1861 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
1862 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
1863 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
1864 #define IMAGE_FILE_SYSTEM 0x1000
1865 #define IMAGE_FILE_DLL 0x2000
1866 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
1867 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
1869 /* These are the settings of the Machine field. */
1870 #define IMAGE_FILE_MACHINE_UNKNOWN 0
1871 #define IMAGE_FILE_MACHINE_I860 0x014d
1872 #define IMAGE_FILE_MACHINE_I386 0x014c
1873 #define IMAGE_FILE_MACHINE_R3000 0x0162
1874 #define IMAGE_FILE_MACHINE_R4000 0x0166
1875 #define IMAGE_FILE_MACHINE_R10000 0x0168
1876 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
1877 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
1878 #define IMAGE_FILE_MACHINE_SH3 0x01a2
1879 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
1880 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
1881 #define IMAGE_FILE_MACHINE_SH4 0x01a6
1882 #define IMAGE_FILE_MACHINE_SH5 0x01a8
1883 #define IMAGE_FILE_MACHINE_ARM 0x01c0
1884 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
1885 #define IMAGE_FILE_MACHINE_AM33 0x01d3
1886 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
1887 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
1888 #define IMAGE_FILE_MACHINE_IA64 0x0200
1889 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
1890 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
1891 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
1892 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
1893 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
1894 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
1895 #define IMAGE_FILE_MACHINE_CEF 0x0cef
1896 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
1897 #define IMAGE_FILE_MACHINE_AMD64 0x8664
1898 #define IMAGE_FILE_MACHINE_M32R 0x9041
1899 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
1901 #define IMAGE_SIZEOF_FILE_HEADER 20
1902 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
1903 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
1904 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
1905 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
1906 #define IMAGE_SIZEOF_SHORT_NAME 8
1907 #define IMAGE_SIZEOF_SECTION_HEADER 40
1908 #define IMAGE_SIZEOF_SYMBOL 18
1909 #define IMAGE_SIZEOF_AUX_SYMBOL 18
1910 #define IMAGE_SIZEOF_RELOCATION 10
1911 #define IMAGE_SIZEOF_BASE_RELOCATION 8
1912 #define IMAGE_SIZEOF_LINENUMBER 6
1913 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
1915 /* Possible Magic values */
1916 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
1917 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
1918 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
1920 #ifdef _WIN64
1921 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
1922 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
1923 #else
1924 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
1925 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
1926 #endif
1928 /* These are indexes into the DataDirectory array */
1929 #define IMAGE_FILE_EXPORT_DIRECTORY 0
1930 #define IMAGE_FILE_IMPORT_DIRECTORY 1
1931 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
1932 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
1933 #define IMAGE_FILE_SECURITY_DIRECTORY 4
1934 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
1935 #define IMAGE_FILE_DEBUG_DIRECTORY 6
1936 #define IMAGE_FILE_DESCRIPTION_STRING 7
1937 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
1938 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
1939 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
1941 /* Directory Entries, indices into the DataDirectory array */
1943 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
1944 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
1945 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
1946 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
1947 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
1948 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
1949 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
1950 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
1951 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
1952 #define IMAGE_DIRECTORY_ENTRY_TLS 9
1953 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
1954 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
1955 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
1956 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
1957 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
1959 /* Subsystem Values */
1961 #define IMAGE_SUBSYSTEM_UNKNOWN 0
1962 #define IMAGE_SUBSYSTEM_NATIVE 1
1963 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
1964 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
1965 #define IMAGE_SUBSYSTEM_OS2_CUI 5
1966 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
1967 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
1968 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
1969 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
1970 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
1971 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
1972 #define IMAGE_SUBSYSTEM_EFI_ROM 13
1973 #define IMAGE_SUBSYSTEM_XBOX 14
1975 /* DLL Characteristics */
1976 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
1977 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
1978 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
1979 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
1980 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
1982 typedef struct _IMAGE_FILE_HEADER {
1983 WORD Machine;
1984 WORD NumberOfSections;
1985 DWORD TimeDateStamp;
1986 DWORD PointerToSymbolTable;
1987 DWORD NumberOfSymbols;
1988 WORD SizeOfOptionalHeader;
1989 WORD Characteristics;
1990 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1992 typedef struct _IMAGE_DATA_DIRECTORY {
1993 DWORD VirtualAddress;
1994 DWORD Size;
1995 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1997 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
1999 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2000 WORD Magic; /* 0x20b */
2001 BYTE MajorLinkerVersion;
2002 BYTE MinorLinkerVersion;
2003 DWORD SizeOfCode;
2004 DWORD SizeOfInitializedData;
2005 DWORD SizeOfUninitializedData;
2006 DWORD AddressOfEntryPoint;
2007 DWORD BaseOfCode;
2008 ULONGLONG ImageBase;
2009 DWORD SectionAlignment;
2010 DWORD FileAlignment;
2011 WORD MajorOperatingSystemVersion;
2012 WORD MinorOperatingSystemVersion;
2013 WORD MajorImageVersion;
2014 WORD MinorImageVersion;
2015 WORD MajorSubsystemVersion;
2016 WORD MinorSubsystemVersion;
2017 DWORD Win32VersionValue;
2018 DWORD SizeOfImage;
2019 DWORD SizeOfHeaders;
2020 DWORD CheckSum;
2021 WORD Subsystem;
2022 WORD DllCharacteristics;
2023 ULONGLONG SizeOfStackReserve;
2024 ULONGLONG SizeOfStackCommit;
2025 ULONGLONG SizeOfHeapReserve;
2026 ULONGLONG SizeOfHeapCommit;
2027 DWORD LoaderFlags;
2028 DWORD NumberOfRvaAndSizes;
2029 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2030 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2032 typedef struct _IMAGE_NT_HEADERS64 {
2033 DWORD Signature;
2034 IMAGE_FILE_HEADER FileHeader;
2035 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2036 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2038 typedef struct _IMAGE_OPTIONAL_HEADER {
2040 /* Standard fields */
2042 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2043 BYTE MajorLinkerVersion;
2044 BYTE MinorLinkerVersion;
2045 DWORD SizeOfCode;
2046 DWORD SizeOfInitializedData;
2047 DWORD SizeOfUninitializedData;
2048 DWORD AddressOfEntryPoint; /* 0x10 */
2049 DWORD BaseOfCode;
2050 DWORD BaseOfData;
2052 /* NT additional fields */
2054 DWORD ImageBase;
2055 DWORD SectionAlignment; /* 0x20 */
2056 DWORD FileAlignment;
2057 WORD MajorOperatingSystemVersion;
2058 WORD MinorOperatingSystemVersion;
2059 WORD MajorImageVersion;
2060 WORD MinorImageVersion;
2061 WORD MajorSubsystemVersion; /* 0x30 */
2062 WORD MinorSubsystemVersion;
2063 DWORD Win32VersionValue;
2064 DWORD SizeOfImage;
2065 DWORD SizeOfHeaders;
2066 DWORD CheckSum; /* 0x40 */
2067 WORD Subsystem;
2068 WORD DllCharacteristics;
2069 DWORD SizeOfStackReserve;
2070 DWORD SizeOfStackCommit;
2071 DWORD SizeOfHeapReserve; /* 0x50 */
2072 DWORD SizeOfHeapCommit;
2073 DWORD LoaderFlags;
2074 DWORD NumberOfRvaAndSizes;
2075 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2076 /* 0xE0 */
2077 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2079 typedef struct _IMAGE_NT_HEADERS {
2080 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2081 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2082 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2083 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2085 #ifdef _WIN64
2086 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2087 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2088 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2089 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2090 #else
2091 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2092 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2093 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2094 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2095 #endif
2097 #define IMAGE_SIZEOF_SHORT_NAME 8
2099 typedef struct _IMAGE_SECTION_HEADER {
2100 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2101 union {
2102 DWORD PhysicalAddress;
2103 DWORD VirtualSize;
2104 } Misc;
2105 DWORD VirtualAddress;
2106 DWORD SizeOfRawData;
2107 DWORD PointerToRawData;
2108 DWORD PointerToRelocations;
2109 DWORD PointerToLinenumbers;
2110 WORD NumberOfRelocations;
2111 WORD NumberOfLinenumbers;
2112 DWORD Characteristics;
2113 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2115 #define IMAGE_SIZEOF_SECTION_HEADER 40
2117 #define IMAGE_FIRST_SECTION(ntheader) \
2118 ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
2119 ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
2121 /* These defines are for the Characteristics bitfield. */
2122 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2123 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2124 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2125 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2126 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2127 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2129 #define IMAGE_SCN_CNT_CODE 0x00000020
2130 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2131 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2133 #define IMAGE_SCN_LNK_OTHER 0x00000100
2134 #define IMAGE_SCN_LNK_INFO 0x00000200
2135 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2136 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2137 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2139 /* 0x00002000 - Reserved */
2140 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2141 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2143 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2144 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2145 #define IMAGE_SCN_MEM_16BIT 0x00020000
2146 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2147 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2149 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2150 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2151 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2152 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2153 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2154 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2155 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2156 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2157 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2158 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2159 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2160 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2161 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2162 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2163 /* 0x00F00000 - Unused */
2164 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2166 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2169 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2170 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2171 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2172 #define IMAGE_SCN_MEM_SHARED 0x10000000
2173 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2174 #define IMAGE_SCN_MEM_READ 0x40000000
2175 #define IMAGE_SCN_MEM_WRITE 0x80000000
2177 #include <pshpack2.h>
2179 typedef struct _IMAGE_SYMBOL {
2180 union {
2181 BYTE ShortName[8];
2182 struct {
2183 DWORD Short;
2184 DWORD Long;
2185 } Name;
2186 DWORD LongName[2];
2187 } N;
2188 DWORD Value;
2189 SHORT SectionNumber;
2190 WORD Type;
2191 BYTE StorageClass;
2192 BYTE NumberOfAuxSymbols;
2193 } IMAGE_SYMBOL;
2194 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2196 #define IMAGE_SIZEOF_SYMBOL 18
2198 typedef struct _IMAGE_LINENUMBER {
2199 union {
2200 DWORD SymbolTableIndex;
2201 DWORD VirtualAddress;
2202 } Type;
2203 WORD Linenumber;
2204 } IMAGE_LINENUMBER;
2205 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2207 #define IMAGE_SIZEOF_LINENUMBER 6
2209 typedef union _IMAGE_AUX_SYMBOL {
2210 struct {
2211 DWORD TagIndex;
2212 union {
2213 struct {
2214 WORD Linenumber;
2215 WORD Size;
2216 } LnSz;
2217 DWORD TotalSize;
2218 } Misc;
2219 union {
2220 struct {
2221 DWORD PointerToLinenumber;
2222 DWORD PointerToNextFunction;
2223 } Function;
2224 struct {
2225 WORD Dimension[4];
2226 } Array;
2227 } FcnAry;
2228 WORD TvIndex;
2229 } Sym;
2230 struct {
2231 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2232 } File;
2233 struct {
2234 DWORD Length;
2235 WORD NumberOfRelocations;
2236 WORD NumberOfLinenumbers;
2237 DWORD CheckSum;
2238 SHORT Number;
2239 BYTE Selection;
2240 } Section;
2241 } IMAGE_AUX_SYMBOL;
2242 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2244 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2246 #include <poppack.h>
2248 #define IMAGE_SYM_UNDEFINED (SHORT)0
2249 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2250 #define IMAGE_SYM_DEBUG (SHORT)-2
2252 #define IMAGE_SYM_TYPE_NULL 0x0000
2253 #define IMAGE_SYM_TYPE_VOID 0x0001
2254 #define IMAGE_SYM_TYPE_CHAR 0x0002
2255 #define IMAGE_SYM_TYPE_SHORT 0x0003
2256 #define IMAGE_SYM_TYPE_INT 0x0004
2257 #define IMAGE_SYM_TYPE_LONG 0x0005
2258 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2259 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2260 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2261 #define IMAGE_SYM_TYPE_UNION 0x0009
2262 #define IMAGE_SYM_TYPE_ENUM 0x000A
2263 #define IMAGE_SYM_TYPE_MOE 0x000B
2264 #define IMAGE_SYM_TYPE_BYTE 0x000C
2265 #define IMAGE_SYM_TYPE_WORD 0x000D
2266 #define IMAGE_SYM_TYPE_UINT 0x000E
2267 #define IMAGE_SYM_TYPE_DWORD 0x000F
2268 #define IMAGE_SYM_TYPE_PCODE 0x8000
2270 #define IMAGE_SYM_DTYPE_NULL 0
2271 #define IMAGE_SYM_DTYPE_POINTER 1
2272 #define IMAGE_SYM_DTYPE_FUNCTION 2
2273 #define IMAGE_SYM_DTYPE_ARRAY 3
2275 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2276 #define IMAGE_SYM_CLASS_NULL 0x0000
2277 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2278 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2279 #define IMAGE_SYM_CLASS_STATIC 0x0003
2280 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2281 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2282 #define IMAGE_SYM_CLASS_LABEL 0x0006
2283 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2284 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2285 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2286 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2287 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2288 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2289 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2290 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2291 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2292 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2293 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2294 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2296 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2297 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2298 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2299 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2300 #define IMAGE_SYM_CLASS_FILE 0x0067
2301 #define IMAGE_SYM_CLASS_SECTION 0x0068
2302 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2304 #define N_BTMASK 0x000F
2305 #define N_TMASK 0x0030
2306 #define N_TMASK1 0x00C0
2307 #define N_TMASK2 0x00F0
2308 #define N_BTSHFT 4
2309 #define N_TSHIFT 2
2311 #define BTYPE(x) ((x) & N_BTMASK)
2313 #ifndef ISPTR
2314 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2315 #endif
2317 #ifndef ISFCN
2318 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2319 #endif
2321 #ifndef ISARY
2322 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2323 #endif
2325 #ifndef ISTAG
2326 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2327 #endif
2329 #ifndef INCREF
2330 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2331 #endif
2332 #ifndef DECREF
2333 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2334 #endif
2336 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2337 #define IMAGE_COMDAT_SELECT_ANY 2
2338 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2339 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2340 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2341 #define IMAGE_COMDAT_SELECT_LARGEST 6
2342 #define IMAGE_COMDAT_SELECT_NEWEST 7
2344 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2345 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2346 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2348 /* Export module directory */
2350 typedef struct _IMAGE_EXPORT_DIRECTORY {
2351 DWORD Characteristics;
2352 DWORD TimeDateStamp;
2353 WORD MajorVersion;
2354 WORD MinorVersion;
2355 DWORD Name;
2356 DWORD Base;
2357 DWORD NumberOfFunctions;
2358 DWORD NumberOfNames;
2359 DWORD AddressOfFunctions;
2360 DWORD AddressOfNames;
2361 DWORD AddressOfNameOrdinals;
2362 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
2364 /* Import name entry */
2365 typedef struct _IMAGE_IMPORT_BY_NAME {
2366 WORD Hint;
2367 BYTE Name[1];
2368 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
2370 /* Import thunk */
2371 typedef struct _IMAGE_THUNK_DATA64 {
2372 union {
2373 ULONGLONG ForwarderString;
2374 ULONGLONG Function;
2375 ULONGLONG Ordinal;
2376 ULONGLONG AddressOfData;
2377 } u1;
2378 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
2380 typedef struct _IMAGE_THUNK_DATA32 {
2381 union {
2382 DWORD ForwarderString;
2383 DWORD Function;
2384 DWORD Ordinal;
2385 DWORD AddressOfData;
2386 } u1;
2387 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
2389 /* Import module directory */
2391 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
2392 union {
2393 DWORD Characteristics; /* 0 for terminating null import descriptor */
2394 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
2395 } DUMMYUNIONNAME;
2396 DWORD TimeDateStamp; /* 0 if not bound,
2397 * -1 if bound, and real date\time stamp
2398 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
2399 * (new BIND)
2400 * otherwise date/time stamp of DLL bound to
2401 * (Old BIND)
2403 DWORD ForwarderChain; /* -1 if no forwarders */
2404 DWORD Name;
2405 /* RVA to IAT (if bound this IAT has actual addresses) */
2406 DWORD FirstThunk;
2407 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
2409 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
2410 #define IMAGE_ORDINAL_FLAG32 0x80000000
2411 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
2412 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
2413 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
2414 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
2416 #ifdef _WIN64
2417 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
2418 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
2419 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
2420 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
2421 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
2422 #else
2423 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
2424 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
2425 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
2426 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
2427 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
2428 #endif
2430 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
2432 DWORD TimeDateStamp;
2433 WORD OffsetModuleName;
2434 WORD NumberOfModuleForwarderRefs;
2435 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
2436 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
2438 typedef struct _IMAGE_BOUND_FORWARDER_REF
2440 DWORD TimeDateStamp;
2441 WORD OffsetModuleName;
2442 WORD Reserved;
2443 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
2445 typedef struct _IMAGE_BASE_RELOCATION
2447 DWORD VirtualAddress;
2448 DWORD SizeOfBlock;
2449 /* WORD TypeOffset[1]; */
2450 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
2452 #include <pshpack2.h>
2454 typedef struct _IMAGE_RELOCATION
2456 union {
2457 DWORD VirtualAddress;
2458 DWORD RelocCount;
2459 } DUMMYUNIONNAME;
2460 DWORD SymbolTableIndex;
2461 WORD Type;
2462 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
2464 #include <poppack.h>
2466 #define IMAGE_SIZEOF_RELOCATION 10
2468 /* generic relocation types */
2469 #define IMAGE_REL_BASED_ABSOLUTE 0
2470 #define IMAGE_REL_BASED_HIGH 1
2471 #define IMAGE_REL_BASED_LOW 2
2472 #define IMAGE_REL_BASED_HIGHLOW 3
2473 #define IMAGE_REL_BASED_HIGHADJ 4
2474 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
2475 #define IMAGE_REL_BASED_SECTION 6
2476 #define IMAGE_REL_BASED_REL 7
2477 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
2478 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
2479 #define IMAGE_REL_BASED_DIR64 10
2480 #define IMAGE_REL_BASED_HIGH3ADJ 11
2482 /* I386 relocation types */
2483 #define IMAGE_REL_I386_ABSOLUTE 0
2484 #define IMAGE_REL_I386_DIR16 1
2485 #define IMAGE_REL_I386_REL16 2
2486 #define IMAGE_REL_I386_DIR32 6
2487 #define IMAGE_REL_I386_DIR32NB 7
2488 #define IMAGE_REL_I386_SEG12 9
2489 #define IMAGE_REL_I386_SECTION 10
2490 #define IMAGE_REL_I386_SECREL 11
2491 #define IMAGE_REL_I386_REL32 20
2493 /* MIPS relocation types */
2494 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
2495 #define IMAGE_REL_MIPS_REFHALF 0x0001
2496 #define IMAGE_REL_MIPS_REFWORD 0x0002
2497 #define IMAGE_REL_MIPS_JMPADDR 0x0003
2498 #define IMAGE_REL_MIPS_REFHI 0x0004
2499 #define IMAGE_REL_MIPS_REFLO 0x0005
2500 #define IMAGE_REL_MIPS_GPREL 0x0006
2501 #define IMAGE_REL_MIPS_LITERAL 0x0007
2502 #define IMAGE_REL_MIPS_SECTION 0x000A
2503 #define IMAGE_REL_MIPS_SECREL 0x000B
2504 #define IMAGE_REL_MIPS_SECRELLO 0x000C
2505 #define IMAGE_REL_MIPS_SECRELHI 0x000D
2506 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
2507 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
2508 #define IMAGE_REL_MIPS_PAIR 0x0025
2510 /* ALPHA relocation types */
2511 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
2512 #define IMAGE_REL_ALPHA_REFLONG 0x0001
2513 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
2514 #define IMAGE_REL_ALPHA_GPREL 0x0003
2515 #define IMAGE_REL_ALPHA_LITERAL 0x0004
2516 #define IMAGE_REL_ALPHA_LITUSE 0x0005
2517 #define IMAGE_REL_ALPHA_GPDISP 0x0006
2518 #define IMAGE_REL_ALPHA_BRADDR 0x0007
2519 #define IMAGE_REL_ALPHA_HINT 0x0008
2520 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
2521 #define IMAGE_REL_ALPHA_REFHI 0x000A
2522 #define IMAGE_REL_ALPHA_REFLO 0x000B
2523 #define IMAGE_REL_ALPHA_PAIR 0x000C
2524 #define IMAGE_REL_ALPHA_MATCH 0x000D
2525 #define IMAGE_REL_ALPHA_SECTION 0x000E
2526 #define IMAGE_REL_ALPHA_SECREL 0x000F
2527 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
2528 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
2529 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
2530 #define IMAGE_REL_ALPHA_REFQ3 0x0013
2531 #define IMAGE_REL_ALPHA_REFQ2 0x0014
2532 #define IMAGE_REL_ALPHA_REFQ1 0x0015
2533 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
2534 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
2536 /* PowerPC relocation types */
2537 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
2538 #define IMAGE_REL_PPC_ADDR64 0x0001
2539 #define IMAGE_REL_PPC_ADDR 0x0002
2540 #define IMAGE_REL_PPC_ADDR24 0x0003
2541 #define IMAGE_REL_PPC_ADDR16 0x0004
2542 #define IMAGE_REL_PPC_ADDR14 0x0005
2543 #define IMAGE_REL_PPC_REL24 0x0006
2544 #define IMAGE_REL_PPC_REL14 0x0007
2545 #define IMAGE_REL_PPC_TOCREL16 0x0008
2546 #define IMAGE_REL_PPC_TOCREL14 0x0009
2547 #define IMAGE_REL_PPC_ADDR32NB 0x000A
2548 #define IMAGE_REL_PPC_SECREL 0x000B
2549 #define IMAGE_REL_PPC_SECTION 0x000C
2550 #define IMAGE_REL_PPC_IFGLUE 0x000D
2551 #define IMAGE_REL_PPC_IMGLUE 0x000E
2552 #define IMAGE_REL_PPC_SECREL16 0x000F
2553 #define IMAGE_REL_PPC_REFHI 0x0010
2554 #define IMAGE_REL_PPC_REFLO 0x0011
2555 #define IMAGE_REL_PPC_PAIR 0x0012
2556 #define IMAGE_REL_PPC_SECRELLO 0x0013
2557 #define IMAGE_REL_PPC_SECRELHI 0x0014
2558 #define IMAGE_REL_PPC_GPREL 0x0015
2559 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
2560 /* modifier bits */
2561 #define IMAGE_REL_PPC_NEG 0x0100
2562 #define IMAGE_REL_PPC_BRTAKEN 0x0200
2563 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
2564 #define IMAGE_REL_PPC_TOCDEFN 0x0800
2566 /* SH3 ? relocation type */
2567 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
2568 #define IMAGE_REL_SH3_DIRECT16 0x0001
2569 #define IMAGE_REL_SH3_DIRECT 0x0002
2570 #define IMAGE_REL_SH3_DIRECT8 0x0003
2571 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
2572 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
2573 #define IMAGE_REL_SH3_DIRECT4 0x0006
2574 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
2575 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
2576 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
2577 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
2578 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
2579 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
2580 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
2581 #define IMAGE_REL_SH3_SECTION 0x000E
2582 #define IMAGE_REL_SH3_SECREL 0x000F
2583 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
2585 /* ARM (Archimedes?) relocation types */
2586 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
2587 #define IMAGE_REL_ARM_ADDR 0x0001
2588 #define IMAGE_REL_ARM_ADDR32NB 0x0002
2589 #define IMAGE_REL_ARM_BRANCH24 0x0003
2590 #define IMAGE_REL_ARM_BRANCH11 0x0004
2591 #define IMAGE_REL_ARM_SECTION 0x000E
2592 #define IMAGE_REL_ARM_SECREL 0x000F
2594 /* IA64 relocation types */
2595 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
2596 #define IMAGE_REL_IA64_IMM14 0x0001
2597 #define IMAGE_REL_IA64_IMM22 0x0002
2598 #define IMAGE_REL_IA64_IMM64 0x0003
2599 #define IMAGE_REL_IA64_DIR 0x0004
2600 #define IMAGE_REL_IA64_DIR64 0x0005
2601 #define IMAGE_REL_IA64_PCREL21B 0x0006
2602 #define IMAGE_REL_IA64_PCREL21M 0x0007
2603 #define IMAGE_REL_IA64_PCREL21F 0x0008
2604 #define IMAGE_REL_IA64_GPREL22 0x0009
2605 #define IMAGE_REL_IA64_LTOFF22 0x000A
2606 #define IMAGE_REL_IA64_SECTION 0x000B
2607 #define IMAGE_REL_IA64_SECREL22 0x000C
2608 #define IMAGE_REL_IA64_SECREL64I 0x000D
2609 #define IMAGE_REL_IA64_SECREL 0x000E
2610 #define IMAGE_REL_IA64_LTOFF64 0x000F
2611 #define IMAGE_REL_IA64_DIR32NB 0x0010
2612 #define IMAGE_REL_IA64_RESERVED_11 0x0011
2613 #define IMAGE_REL_IA64_RESERVED_12 0x0012
2614 #define IMAGE_REL_IA64_RESERVED_13 0x0013
2615 #define IMAGE_REL_IA64_RESERVED_14 0x0014
2616 #define IMAGE_REL_IA64_RESERVED_15 0x0015
2617 #define IMAGE_REL_IA64_RESERVED_16 0x0016
2618 #define IMAGE_REL_IA64_ADDEND 0x001F
2620 /* archive format */
2622 #define IMAGE_ARCHIVE_START_SIZE 8
2623 #define IMAGE_ARCHIVE_START "!<arch>\n"
2624 #define IMAGE_ARCHIVE_END "`\n"
2625 #define IMAGE_ARCHIVE_PAD "\n"
2626 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
2627 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
2629 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
2631 BYTE Name[16];
2632 BYTE Date[12];
2633 BYTE UserID[6];
2634 BYTE GroupID[6];
2635 BYTE Mode[8];
2636 BYTE Size[10];
2637 BYTE EndHeader[2];
2638 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
2640 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2643 * Resource directory stuff
2645 typedef struct _IMAGE_RESOURCE_DIRECTORY {
2646 DWORD Characteristics;
2647 DWORD TimeDateStamp;
2648 WORD MajorVersion;
2649 WORD MinorVersion;
2650 WORD NumberOfNamedEntries;
2651 WORD NumberOfIdEntries;
2652 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
2653 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
2655 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
2656 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
2658 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
2659 union {
2660 struct {
2661 #ifdef BITFIELDS_BIGENDIAN
2662 unsigned NameIsString:1;
2663 unsigned NameOffset:31;
2664 #else
2665 unsigned NameOffset:31;
2666 unsigned NameIsString:1;
2667 #endif
2668 } DUMMYSTRUCTNAME1;
2669 DWORD Name;
2670 struct {
2671 #ifdef WORDS_BIGENDIAN
2672 WORD __pad;
2673 WORD Id;
2674 #else
2675 WORD Id;
2676 WORD __pad;
2677 #endif
2678 } DUMMYSTRUCTNAME2;
2679 } DUMMYUNIONNAME1;
2680 union {
2681 DWORD OffsetToData;
2682 struct {
2683 #ifdef BITFIELDS_BIGENDIAN
2684 unsigned DataIsDirectory:1;
2685 unsigned OffsetToDirectory:31;
2686 #else
2687 unsigned OffsetToDirectory:31;
2688 unsigned DataIsDirectory:1;
2689 #endif
2690 } DUMMYSTRUCTNAME3;
2691 } DUMMYUNIONNAME2;
2692 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
2695 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
2696 WORD Length;
2697 CHAR NameString[ 1 ];
2698 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
2700 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
2701 WORD Length;
2702 WCHAR NameString[ 1 ];
2703 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
2705 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
2706 DWORD OffsetToData;
2707 DWORD Size;
2708 DWORD CodePage;
2709 DWORD Reserved;
2710 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
2713 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
2714 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
2717 typedef struct _IMAGE_TLS_DIRECTORY64 {
2718 ULONGLONG StartAddressOfRawData;
2719 ULONGLONG EndAddressOfRawData;
2720 ULONGLONG AddressOfIndex;
2721 ULONGLONG AddressOfCallBacks;
2722 DWORD SizeOfZeroFill;
2723 DWORD Characteristics;
2724 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
2726 typedef struct _IMAGE_TLS_DIRECTORY32 {
2727 DWORD StartAddressOfRawData;
2728 DWORD EndAddressOfRawData;
2729 DWORD AddressOfIndex;
2730 DWORD AddressOfCallBacks;
2731 DWORD SizeOfZeroFill;
2732 DWORD Characteristics;
2733 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
2735 #ifdef _WIN64
2736 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
2737 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
2738 #else
2739 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
2740 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
2741 #endif
2743 typedef struct _IMAGE_DEBUG_DIRECTORY {
2744 DWORD Characteristics;
2745 DWORD TimeDateStamp;
2746 WORD MajorVersion;
2747 WORD MinorVersion;
2748 DWORD Type;
2749 DWORD SizeOfData;
2750 DWORD AddressOfRawData;
2751 DWORD PointerToRawData;
2752 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
2754 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
2755 #define IMAGE_DEBUG_TYPE_COFF 1
2756 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
2757 #define IMAGE_DEBUG_TYPE_FPO 3
2758 #define IMAGE_DEBUG_TYPE_MISC 4
2759 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
2760 #define IMAGE_DEBUG_TYPE_FIXUP 6
2761 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
2762 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
2763 #define IMAGE_DEBUG_TYPE_BORLAND 9
2764 #define IMAGE_DEBUG_TYPE_RESERVED10 10
2766 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
2767 DWORD NumberOfSymbols;
2768 DWORD LvaToFirstSymbol;
2769 DWORD NumberOfLinenumbers;
2770 DWORD LvaToFirstLinenumber;
2771 DWORD RvaToFirstByteOfCode;
2772 DWORD RvaToLastByteOfCode;
2773 DWORD RvaToFirstByteOfData;
2774 DWORD RvaToLastByteOfData;
2775 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
2777 #define FRAME_FPO 0
2778 #define FRAME_TRAP 1
2779 #define FRAME_TSS 2
2780 #define FRAME_NONFPO 3
2782 typedef struct _FPO_DATA {
2783 DWORD ulOffStart;
2784 DWORD cbProcSize;
2785 DWORD cdwLocals;
2786 WORD cdwParams;
2787 WORD cbProlog : 8;
2788 WORD cbRegs : 3;
2789 WORD fHasSEH : 1;
2790 WORD fUseBP : 1;
2791 WORD reserved : 1;
2792 WORD cbFrame : 2;
2793 } FPO_DATA, *PFPO_DATA;
2795 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
2796 DWORD Size;
2797 DWORD TimeDateStamp;
2798 WORD MajorVersion;
2799 WORD MinorVersion;
2800 DWORD GlobalFlagsClear;
2801 DWORD GlobalFlagsSet;
2802 DWORD CriticalSectionDefaultTimeout;
2803 DWORD DeCommitFreeBlockThreshold;
2804 DWORD DeCommitTotalFreeThreshold;
2805 PVOID LockPrefixTable;
2806 DWORD MaximumAllocationSize;
2807 DWORD VirtualMemoryThreshold;
2808 DWORD ProcessHeapFlags;
2809 DWORD ProcessAffinityMask;
2810 WORD CSDVersion;
2811 WORD Reserved1;
2812 PVOID EditList;
2813 DWORD SecurityCookie;
2814 DWORD SEHandlerTable;
2815 DWORD SEHandlerCount;
2816 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
2818 typedef struct _IMAGE_FUNCTION_ENTRY {
2819 DWORD StartingAddress;
2820 DWORD EndingAddress;
2821 DWORD EndOfPrologue;
2822 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
2824 #define IMAGE_DEBUG_MISC_EXENAME 1
2826 typedef struct _IMAGE_DEBUG_MISC {
2827 DWORD DataType;
2828 DWORD Length;
2829 BYTE Unicode;
2830 BYTE Reserved[ 3 ];
2831 BYTE Data[ 1 ];
2832 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
2834 /* This is the structure that appears at the very start of a .DBG file. */
2836 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
2837 WORD Signature;
2838 WORD Flags;
2839 WORD Machine;
2840 WORD Characteristics;
2841 DWORD TimeDateStamp;
2842 DWORD CheckSum;
2843 DWORD ImageBase;
2844 DWORD SizeOfImage;
2845 DWORD NumberOfSections;
2846 DWORD ExportedNamesSize;
2847 DWORD DebugDirectorySize;
2848 DWORD SectionAlignment;
2849 DWORD Reserved[ 2 ];
2850 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
2852 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
2855 typedef struct tagMESSAGE_RESOURCE_ENTRY {
2856 WORD Length;
2857 WORD Flags;
2858 BYTE Text[1];
2859 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
2860 #define MESSAGE_RESOURCE_UNICODE 0x0001
2862 typedef struct tagMESSAGE_RESOURCE_BLOCK {
2863 DWORD LowId;
2864 DWORD HighId;
2865 DWORD OffsetToEntries;
2866 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
2868 typedef struct tagMESSAGE_RESOURCE_DATA {
2869 DWORD NumberOfBlocks;
2870 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
2871 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2874 * Here follows typedefs for security and tokens.
2878 * First a constant for the following typedefs.
2881 #define ANYSIZE_ARRAY 1
2883 /* FIXME: Orphan. What does it point to? */
2884 typedef PVOID PACCESS_TOKEN;
2885 typedef PVOID PSECURITY_DESCRIPTOR;
2886 typedef PVOID PSID;
2889 * TOKEN_INFORMATION_CLASS
2892 typedef enum _TOKEN_INFORMATION_CLASS {
2893 TokenUser = 1,
2894 TokenGroups,
2895 TokenPrivileges,
2896 TokenOwner,
2897 TokenPrimaryGroup,
2898 TokenDefaultDacl,
2899 TokenSource,
2900 TokenType,
2901 TokenImpersonationLevel,
2902 TokenStatistics,
2903 TokenRestrictedSids,
2904 TokenSessionId,
2905 TokenGroupsAndPrivileges,
2906 TokenSessionReference,
2907 TokenSandBoxInert
2908 } TOKEN_INFORMATION_CLASS;
2910 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
2911 #define TOKEN_ADJUST_GROUPS 0x0040
2912 #define TOKEN_ADJUST_PRIVILEGES 0x0020
2913 #define TOKEN_ADJUST_SESSIONID 0x0100
2914 #define TOKEN_ASSIGN_PRIMARY 0x0001
2915 #define TOKEN_DUPLICATE 0x0002
2916 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
2917 #define TOKEN_IMPERSONATE 0x0004
2918 #define TOKEN_QUERY 0x0008
2919 #define TOKEN_QUERY_SOURCE 0x0010
2920 #define TOKEN_ADJUST_DEFAULT 0x0080
2921 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
2922 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
2923 TOKEN_ADJUST_PRIVILEGES | \
2924 TOKEN_ADJUST_GROUPS | \
2925 TOKEN_ADJUST_DEFAULT )
2926 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
2927 TOKEN_ASSIGN_PRIMARY | \
2928 TOKEN_DUPLICATE | \
2929 TOKEN_IMPERSONATE | \
2930 TOKEN_QUERY | \
2931 TOKEN_QUERY_SOURCE | \
2932 TOKEN_ADJUST_PRIVILEGES | \
2933 TOKEN_ADJUST_GROUPS | \
2934 TOKEN_ADJUST_SESSIONID | \
2935 TOKEN_ADJUST_DEFAULT )
2937 #ifndef _SECURITY_DEFINED
2938 #define _SECURITY_DEFINED
2941 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
2943 typedef struct _GENERIC_MAPPING {
2944 ACCESS_MASK GenericRead;
2945 ACCESS_MASK GenericWrite;
2946 ACCESS_MASK GenericExecute;
2947 ACCESS_MASK GenericAll;
2948 } GENERIC_MAPPING, *PGENERIC_MAPPING;
2950 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
2951 #define SID_IDENTIFIER_AUTHORITY_DEFINED
2952 typedef struct {
2953 BYTE Value[6];
2954 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
2955 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
2957 #ifndef SID_DEFINED
2958 #define SID_DEFINED
2959 typedef struct _SID {
2960 BYTE Revision;
2961 BYTE SubAuthorityCount;
2962 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
2963 DWORD SubAuthority[1];
2964 } SID,*PISID;
2965 #endif /* !defined(SID_DEFINED) */
2967 #define SID_REVISION (1) /* Current revision */
2968 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
2969 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
2973 * ACL
2976 #define ACL_REVISION1 1
2977 #define ACL_REVISION2 2
2978 #define ACL_REVISION3 3
2979 #define ACL_REVISION4 4
2981 #define MIN_ACL_REVISION ACL_REVISION2
2982 #define MAX_ACL_REVISION ACL_REVISION4
2984 typedef struct _ACL {
2985 BYTE AclRevision;
2986 BYTE Sbz1;
2987 WORD AclSize;
2988 WORD AceCount;
2989 WORD Sbz2;
2990 } ACL, *PACL;
2992 typedef enum _ACL_INFORMATION_CLASS
2994 AclRevisionInformation = 1,
2995 AclSizeInformation
2996 } ACL_INFORMATION_CLASS;
2998 typedef struct _ACL_REVISION_INFORMATION
3000 DWORD AclRevision;
3001 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
3003 typedef struct _ACL_SIZE_INFORMATION
3005 DWORD AceCount;
3006 DWORD AclBytesInUse;
3007 DWORD AclBytesFree;
3008 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
3010 /* SECURITY_DESCRIPTOR */
3011 #define SECURITY_DESCRIPTOR_REVISION 1
3012 #define SECURITY_DESCRIPTOR_REVISION1 1
3016 * Privilege Names
3018 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
3019 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
3020 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
3021 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
3022 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
3023 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
3024 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
3025 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
3026 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
3027 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
3028 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
3029 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
3030 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
3031 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
3032 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
3033 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
3034 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
3035 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
3036 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
3037 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
3038 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
3039 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
3040 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
3041 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
3042 #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
3043 #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
3044 #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
3045 #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
3046 #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
3048 #define SE_GROUP_MANDATORY 0x00000001
3049 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
3050 #define SE_GROUP_ENABLED 0x00000004
3051 #define SE_GROUP_OWNER 0x00000008
3052 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
3053 #define SE_GROUP_LOGON_ID 0xC0000000
3054 #define SE_GROUP_RESOURCE 0x20000000
3056 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
3057 #define SE_PRIVILEGE_ENABLED 0x00000002
3058 #define SE_PRIVILEGE_REMOVE 0x00000004
3059 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
3061 #define PRIVILEGE_SET_ALL_NECESSARY 1
3063 #define SE_OWNER_DEFAULTED 0x00000001
3064 #define SE_GROUP_DEFAULTED 0x00000002
3065 #define SE_DACL_PRESENT 0x00000004
3066 #define SE_DACL_DEFAULTED 0x00000008
3067 #define SE_SACL_PRESENT 0x00000010
3068 #define SE_SACL_DEFAULTED 0x00000020
3069 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
3070 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
3071 #define SE_DACL_AUTO_INHERITED 0x00000400
3072 #define SE_SACL_AUTO_INHERITED 0x00000800
3073 #define SE_DACL_PROTECTED 0x00001000
3074 #define SE_SACL_PROTECTED 0x00002000
3075 #define SE_SELF_RELATIVE 0x00008000
3077 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
3078 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
3080 /* The security descriptor structure */
3081 typedef struct {
3082 BYTE Revision;
3083 BYTE Sbz1;
3084 SECURITY_DESCRIPTOR_CONTROL Control;
3085 DWORD Owner;
3086 DWORD Group;
3087 DWORD Sacl;
3088 DWORD Dacl;
3089 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
3091 typedef struct {
3092 BYTE Revision;
3093 BYTE Sbz1;
3094 SECURITY_DESCRIPTOR_CONTROL Control;
3095 PSID Owner;
3096 PSID Group;
3097 PACL Sacl;
3098 PACL Dacl;
3099 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
3101 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
3103 #endif /* _SECURITY_DEFINED */
3106 * SID_AND_ATTRIBUTES
3109 typedef struct _SID_AND_ATTRIBUTES {
3110 PSID Sid;
3111 DWORD Attributes;
3112 } SID_AND_ATTRIBUTES;
3114 /* security entities */
3115 #define SECURITY_NULL_RID (0x00000000L)
3116 #define SECURITY_WORLD_RID (0x00000000L)
3117 #define SECURITY_LOCAL_RID (0X00000000L)
3119 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
3121 /* S-1-1 */
3122 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
3124 /* S-1-2 */
3125 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
3127 /* S-1-3 */
3128 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
3129 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
3130 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
3131 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
3132 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
3134 /* S-1-4 */
3135 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
3137 /* S-1-5 */
3138 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
3139 #define SECURITY_DIALUP_RID 0x00000001L
3140 #define SECURITY_NETWORK_RID 0x00000002L
3141 #define SECURITY_BATCH_RID 0x00000003L
3142 #define SECURITY_INTERACTIVE_RID 0x00000004L
3143 #define SECURITY_LOGON_IDS_RID 0x00000005L
3144 #define SECURITY_SERVICE_RID 0x00000006L
3145 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
3146 #define SECURITY_PROXY_RID 0x00000008L
3147 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
3148 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
3149 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
3150 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
3151 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
3152 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
3153 #define SECURITY_NT_NON_UNIQUE 0x00000015L
3154 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
3156 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
3157 #define DOMAIN_GROUP_RID_USERS 0x00000201L
3158 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
3160 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
3161 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
3162 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
3164 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
3166 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
3169 * TOKEN_USER
3172 typedef struct _TOKEN_USER {
3173 SID_AND_ATTRIBUTES User;
3174 } TOKEN_USER, *PTOKEN_USER;
3177 * TOKEN_GROUPS
3180 typedef struct _TOKEN_GROUPS {
3181 DWORD GroupCount;
3182 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
3183 } TOKEN_GROUPS, *PTOKEN_GROUPS;
3186 * LUID_AND_ATTRIBUTES
3189 typedef union _LARGE_INTEGER {
3190 struct {
3191 #ifdef WORDS_BIGENDIAN
3192 LONG HighPart;
3193 DWORD LowPart;
3194 #else
3195 DWORD LowPart;
3196 LONG HighPart;
3197 #endif
3198 } u;
3199 #ifndef NONAMELESSSTRUCT
3200 struct {
3201 #ifdef WORDS_BIGENDIAN
3202 LONG HighPart;
3203 DWORD LowPart;
3204 #else
3205 DWORD LowPart;
3206 LONG HighPart;
3207 #endif
3209 #endif
3210 LONGLONG QuadPart;
3211 } LARGE_INTEGER, *PLARGE_INTEGER;
3213 typedef union _ULARGE_INTEGER {
3214 struct {
3215 #ifdef WORDS_BIGENDIAN
3216 DWORD HighPart;
3217 DWORD LowPart;
3218 #else
3219 DWORD LowPart;
3220 DWORD HighPart;
3221 #endif
3222 } u;
3223 #ifndef NONAMELESSSTRUCT
3224 struct {
3225 #ifdef WORDS_BIGENDIAN
3226 DWORD HighPart;
3227 DWORD LowPart;
3228 #else
3229 DWORD LowPart;
3230 DWORD HighPart;
3231 #endif
3233 #endif
3234 ULONGLONG QuadPart;
3235 } ULARGE_INTEGER, *PULARGE_INTEGER;
3238 * Locally Unique Identifier
3241 typedef struct _LUID {
3242 DWORD LowPart;
3243 LONG HighPart;
3244 } LUID, *PLUID;
3246 #include <pshpack4.h>
3247 typedef struct _LUID_AND_ATTRIBUTES {
3248 LUID Luid;
3249 DWORD Attributes;
3250 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
3251 #include <poppack.h>
3254 * PRIVILEGE_SET
3257 typedef struct _PRIVILEGE_SET {
3258 DWORD PrivilegeCount;
3259 DWORD Control;
3260 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
3261 } PRIVILEGE_SET, *PPRIVILEGE_SET;
3264 * TOKEN_PRIVILEGES
3267 typedef struct _TOKEN_PRIVILEGES {
3268 DWORD PrivilegeCount;
3269 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
3270 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
3273 * TOKEN_OWNER
3276 typedef struct _TOKEN_OWNER {
3277 PSID Owner;
3278 } TOKEN_OWNER, *PTOKEN_OWNER;
3281 * TOKEN_PRIMARY_GROUP
3284 typedef struct _TOKEN_PRIMARY_GROUP {
3285 PSID PrimaryGroup;
3286 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
3290 * TOKEN_DEFAULT_DACL
3293 typedef struct _TOKEN_DEFAULT_DACL {
3294 PACL DefaultDacl;
3295 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
3298 * TOKEN_SOURCEL
3301 #define TOKEN_SOURCE_LENGTH 8
3303 typedef struct _TOKEN_SOURCE {
3304 char SourceName[TOKEN_SOURCE_LENGTH];
3305 LUID SourceIdentifier;
3306 } TOKEN_SOURCE, *PTOKEN_SOURCE;
3309 * TOKEN_TYPE
3312 typedef enum tagTOKEN_TYPE {
3313 TokenPrimary = 1,
3314 TokenImpersonation
3315 } TOKEN_TYPE;
3318 * SECURITY_IMPERSONATION_LEVEL
3321 typedef enum _SECURITY_IMPERSONATION_LEVEL {
3322 SecurityAnonymous,
3323 SecurityIdentification,
3324 SecurityImpersonation,
3325 SecurityDelegation
3326 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
3329 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
3330 * PSECURITY_CONTEXT_TRACKING_MODE;
3332 * Quality of Service
3335 typedef struct _SECURITY_QUALITY_OF_SERVICE {
3336 DWORD Length;
3337 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3338 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
3339 BOOLEAN EffectiveOnly;
3340 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
3343 * TOKEN_STATISTICS
3346 #include <pshpack4.h>
3347 typedef struct _TOKEN_STATISTICS {
3348 LUID TokenId;
3349 LUID AuthenticationId;
3350 LARGE_INTEGER ExpirationTime;
3351 TOKEN_TYPE TokenType;
3352 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3353 DWORD DynamicCharged;
3354 DWORD DynamicAvailable;
3355 DWORD GroupCount;
3356 DWORD PrivilegeCount;
3357 LUID ModifiedId;
3358 } TOKEN_STATISTICS;
3359 #include <poppack.h>
3362 * ACLs of NT
3365 #define ACL_REVISION 2
3367 #define ACL_REVISION1 1
3368 #define ACL_REVISION2 2
3370 /* ACEs, directly starting after an ACL */
3371 typedef struct _ACE_HEADER {
3372 BYTE AceType;
3373 BYTE AceFlags;
3374 WORD AceSize;
3375 } ACE_HEADER,*PACE_HEADER;
3377 /* AceType */
3378 #define ACCESS_ALLOWED_ACE_TYPE 0
3379 #define ACCESS_DENIED_ACE_TYPE 1
3380 #define SYSTEM_AUDIT_ACE_TYPE 2
3381 #define SYSTEM_ALARM_ACE_TYPE 3
3383 /* inherit AceFlags */
3384 #define OBJECT_INHERIT_ACE 0x01
3385 #define CONTAINER_INHERIT_ACE 0x02
3386 #define NO_PROPAGATE_INHERIT_ACE 0x04
3387 #define INHERIT_ONLY_ACE 0x08
3388 #define INHERITED_ACE 0x10
3389 #define VALID_INHERIT_FLAGS 0x0F
3391 /* AceFlags mask for what events we (should) audit */
3392 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
3393 #define FAILED_ACCESS_ACE_FLAG 0x80
3395 /* different ACEs depending on AceType
3396 * SidStart marks the begin of a SID
3397 * so the thing finally looks like this:
3398 * 0: ACE_HEADER
3399 * 4: ACCESS_MASK
3400 * 8... : SID
3402 typedef struct _ACCESS_ALLOWED_ACE {
3403 ACE_HEADER Header;
3404 DWORD Mask;
3405 DWORD SidStart;
3406 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
3408 typedef struct _ACCESS_DENIED_ACE {
3409 ACE_HEADER Header;
3410 DWORD Mask;
3411 DWORD SidStart;
3412 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
3414 typedef struct _SYSTEM_AUDIT_ACE {
3415 ACE_HEADER Header;
3416 DWORD Mask;
3417 DWORD SidStart;
3418 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
3420 typedef struct _SYSTEM_ALARM_ACE {
3421 ACE_HEADER Header;
3422 DWORD Mask;
3423 DWORD SidStart;
3424 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
3426 typedef enum tagSID_NAME_USE {
3427 SidTypeUser = 1,
3428 SidTypeGroup,
3429 SidTypeDomain,
3430 SidTypeAlias,
3431 SidTypeWellKnownGroup,
3432 SidTypeDeletedAccount,
3433 SidTypeInvalid,
3434 SidTypeUnknown
3435 } SID_NAME_USE,*PSID_NAME_USE;
3437 /* Access rights */
3439 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
3440 #undef DELETE
3441 #define DELETE 0x00010000
3442 #define READ_CONTROL 0x00020000
3443 #define WRITE_DAC 0x00040000
3444 #define WRITE_OWNER 0x00080000
3445 #define SYNCHRONIZE 0x00100000
3446 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
3448 #define STANDARD_RIGHTS_READ READ_CONTROL
3449 #define STANDARD_RIGHTS_WRITE READ_CONTROL
3450 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
3452 #define STANDARD_RIGHTS_ALL 0x001f0000
3454 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
3456 #define GENERIC_READ 0x80000000
3457 #define GENERIC_WRITE 0x40000000
3458 #define GENERIC_EXECUTE 0x20000000
3459 #define GENERIC_ALL 0x10000000
3461 #define MAXIMUM_ALLOWED 0x02000000
3462 #define ACCESS_SYSTEM_SECURITY 0x01000000
3464 #define EVENT_QUERY_STATE 0x0001
3465 #define EVENT_MODIFY_STATE 0x0002
3466 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3468 #define SEMAPHORE_MODIFY_STATE 0x0002
3469 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3471 #define MUTEX_MODIFY_STATE 0x0001
3472 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
3474 #define TIMER_QUERY_STATE 0x0001
3475 #define TIMER_MODIFY_STATE 0x0002
3476 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
3478 #define PROCESS_TERMINATE 0x0001
3479 #define PROCESS_CREATE_THREAD 0x0002
3480 #define PROCESS_VM_OPERATION 0x0008
3481 #define PROCESS_VM_READ 0x0010
3482 #define PROCESS_VM_WRITE 0x0020
3483 #define PROCESS_DUP_HANDLE 0x0040
3484 #define PROCESS_CREATE_PROCESS 0x0080
3485 #define PROCESS_SET_QUOTA 0x0100
3486 #define PROCESS_SET_INFORMATION 0x0200
3487 #define PROCESS_QUERY_INFORMATION 0x0400
3488 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
3490 #define THREAD_TERMINATE 0x0001
3491 #define THREAD_SUSPEND_RESUME 0x0002
3492 #define THREAD_GET_CONTEXT 0x0008
3493 #define THREAD_SET_CONTEXT 0x0010
3494 #define THREAD_SET_INFORMATION 0x0020
3495 #define THREAD_QUERY_INFORMATION 0x0040
3496 #define THREAD_SET_THREAD_TOKEN 0x0080
3497 #define THREAD_IMPERSONATE 0x0100
3498 #define THREAD_DIRECT_IMPERSONATION 0x0200
3499 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
3501 #define THREAD_BASE_PRIORITY_LOWRT 15
3502 #define THREAD_BASE_PRIORITY_MAX 2
3503 #define THREAD_BASE_PRIORITY_MIN -2
3504 #define THREAD_BASE_PRIORITY_IDLE -15
3506 #define SECTION_QUERY 0x0001
3507 #define SECTION_MAP_WRITE 0x0002
3508 #define SECTION_MAP_READ 0x0004
3509 #define SECTION_MAP_EXECUTE 0x0008
3510 #define SECTION_EXTEND_SIZE 0x0010
3511 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
3512 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
3514 #define FILE_READ_DATA 0x0001 /* file & pipe */
3515 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
3516 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
3517 #define FILE_ADD_FILE 0x0002 /* directory */
3518 #define FILE_APPEND_DATA 0x0004 /* file */
3519 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
3520 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
3521 #define FILE_READ_EA 0x0008 /* file & directory */
3522 #define FILE_READ_PROPERTIES FILE_READ_EA
3523 #define FILE_WRITE_EA 0x0010 /* file & directory */
3524 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
3525 #define FILE_EXECUTE 0x0020 /* file */
3526 #define FILE_TRAVERSE 0x0020 /* directory */
3527 #define FILE_DELETE_CHILD 0x0040 /* directory */
3528 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
3529 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
3530 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
3532 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
3533 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
3534 SYNCHRONIZE)
3535 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
3536 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
3537 FILE_APPEND_DATA | SYNCHRONIZE)
3538 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
3539 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
3541 #define DUPLICATE_CLOSE_SOURCE 0x00000001
3542 #define DUPLICATE_SAME_ACCESS 0x00000002
3544 /* File attribute flags */
3545 #define FILE_SHARE_READ 0x00000001L
3546 #define FILE_SHARE_WRITE 0x00000002L
3547 #define FILE_SHARE_DELETE 0x00000004L
3549 #define FILE_ATTRIBUTE_READONLY 0x00000001
3550 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
3551 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
3552 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
3553 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
3554 #define FILE_ATTRIBUTE_NORMAL 0x00000080
3555 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
3556 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
3557 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
3558 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
3559 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
3560 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
3561 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
3563 /* File notification flags */
3564 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
3565 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
3566 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
3567 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
3568 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
3569 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
3570 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
3571 #define FILE_NOTIFY_CHANGE_EA 0x00000080
3572 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
3573 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
3574 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
3575 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
3577 #define FILE_ACTION_ADDED 0x00000001
3578 #define FILE_ACTION_REMOVED 0x00000002
3579 #define FILE_ACTION_MODIFIED 0x00000003
3580 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
3581 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
3582 #define FILE_ACTION_ADDED_STREAM 0x00000006
3583 #define FILE_ACTION_REMOVED_STREAM 0x00000007
3584 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
3586 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
3587 #define FILE_CASE_PRESERVED_NAMES 0x00000002
3588 #define FILE_UNICODE_ON_DISK 0x00000004
3589 #define FILE_PERSISTENT_ACLS 0x00000008
3590 #define FILE_FILE_COMPRESSION 0x00000010
3591 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
3592 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
3593 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
3594 #define FILE_NAMED_STREAMS 0x00040000
3595 #define FILE_READ_ONLY_VOLUME 0x00080000
3597 /* File alignments (NT) */
3598 #define FILE_BYTE_ALIGNMENT 0x00000000
3599 #define FILE_WORD_ALIGNMENT 0x00000001
3600 #define FILE_LONG_ALIGNMENT 0x00000003
3601 #define FILE_QUAD_ALIGNMENT 0x00000007
3602 #define FILE_OCTA_ALIGNMENT 0x0000000f
3603 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
3604 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
3605 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
3606 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
3607 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
3609 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
3610 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
3612 #define REG_NONE 0 /* no type */
3613 #define REG_SZ 1 /* string type (ASCII) */
3614 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
3615 #define REG_BINARY 3 /* binary format, callerspecific */
3616 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
3617 #define REG_DWORD 4 /* DWORD in little endian format */
3618 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
3619 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
3620 #define REG_LINK 6 /* symbolic link (UNICODE) */
3621 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
3622 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
3623 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
3624 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3625 #define REG_QWORD 11 /* QWORD in little endian format */
3626 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
3628 /* ----------------------------- begin power management --------------------- */
3630 typedef enum _LATENCY_TIME {
3631 LT_DONT_CARE,
3632 LT_LOWEST_LATENCY
3633 } LATENCY_TIME, *PLATENCY_TIME;
3635 #define DISCHARGE_POLICY_CRITICAL 0
3636 #define DISCHARGE_POLICY_LOW 1
3637 #define NUM_DISCHARGE_POLICIES 4
3639 #define PO_THROTTLE_NONE 0
3640 #define PO_THROTTLE_CONSTANT 1
3641 #define PO_THROTTLE_DEGRADE 2
3642 #define PO_THROTTLE_ADAPTIVE 3
3644 typedef enum _POWER_ACTION {
3645 PowerActionNone = 0,
3646 PowerActionReserved,
3647 PowerActionSleep,
3648 PowerActionHibernate,
3649 PowerActionShutdown,
3650 PowerActionShutdownReset,
3651 PowerActionShutdownOff,
3652 PowerActionWarmEject
3653 } POWER_ACTION,
3654 *PPOWER_ACTION;
3656 typedef enum _SYSTEM_POWER_STATE {
3657 PowerSystemUnspecified = 0,
3658 PowerSystemWorking = 1,
3659 PowerSystemSleeping1 = 2,
3660 PowerSystemSleeping2 = 3,
3661 PowerSystemSleeping3 = 4,
3662 PowerSystemHibernate = 5,
3663 PowerSystemShutdown = 6,
3664 PowerSystemMaximum = 7
3665 } SYSTEM_POWER_STATE,
3666 *PSYSTEM_POWER_STATE;
3668 typedef enum _DEVICE_POWER_STATE {
3669 PowerDeviceUnspecified,
3670 PowerDeviceD0,
3671 PowerDeviceD1,
3672 PowerDeviceD2,
3673 PowerDeviceD3,
3674 PowerDeviceMaximum
3675 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
3677 typedef enum _POWER_INFORMATION_LEVEL {
3678 SystemPowerPolicyAc,
3679 SystemPowerPolicyDc,
3680 VerifySystemPolicyAc,
3681 VerifySystemPolicyDc,
3682 SystemPowerCapabilities,
3683 SystemBatteryState,
3684 SystemPowerStateHandler,
3685 ProcessorStateHandler,
3686 SystemPowerPolicyCurrent,
3687 AdministratorPowerPolicy,
3688 SystemReserveHiberFile,
3689 ProcessorInformation,
3690 SystemPowerInformation,
3691 ProcessorStateHandler2,
3692 LastWakeTime,
3693 LastSleepTime,
3694 SystemExecutionState,
3695 SystemPowerStateNotifyHandler,
3696 ProcessorPowerPolicyAc,
3697 ProcessorPowerPolicyDc,
3698 VerifyProcessorPowerPolicyAc,
3699 VerifyProcessorPowerPolicyDc,
3700 ProcessorPowerPolicyCurrent
3701 } POWER_INFORMATION_LEVEL;
3703 typedef struct _ADMINISTRATOR_POWER_POLICY {
3704 SYSTEM_POWER_STATE MinSleep;
3705 SYSTEM_POWER_STATE MaxSleep;
3706 ULONG MinVideoTimeout;
3707 ULONG MaxVideoTimeout;
3708 ULONG MinSpindownTimeout;
3709 ULONG MaxSpindownTimeout;
3710 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
3712 typedef struct {
3713 ULONG Granularity;
3714 ULONG Capacity;
3715 } BATTERY_REPORTING_SCALE,
3716 *PBATTERY_REPORTING_SCALE;
3718 typedef struct {
3719 POWER_ACTION Action;
3720 ULONG Flags;
3721 ULONG EventCode;
3722 } POWER_ACTION_POLICY,
3723 *PPOWER_ACTION_POLICY;
3725 typedef struct _PROCESSOR_POWER_INFORMATION {
3726 ULONG Number;
3727 ULONG MaxMhz;
3728 ULONG CurrentMhz;
3729 ULONG MhzLimit;
3730 ULONG MaxIdleState;
3731 ULONG CurrentIdleState;
3732 } PROCESSOR_POWER_INFORMATION,
3733 *PPROCESSOR_POWER_INFORMATION;
3735 typedef struct _PROCESSOR_POWER_POLICY_INFO {
3736 ULONG TimeCheck;
3737 ULONG DemoteLimit;
3738 ULONG PromoteLimit;
3739 UCHAR DemotePercent;
3740 UCHAR PromotePercent;
3741 UCHAR Spare[2];
3742 ULONG AllowDemotion:1;
3743 ULONG AllowPromotion:1;
3744 ULONG Reserved:30;
3745 } PROCESSOR_POWER_POLICY_INFO,
3746 *PPROCESSOR_POWER_POLICY_INFO;
3748 typedef struct _PROCESSOR_POWER_POLICY {
3749 DWORD Revision;
3750 BYTE DynamicThrottle;
3751 BYTE Spare[3];
3752 DWORD DisableCStates:1;
3753 DWORD Reserved:31;
3754 DWORD PolicyCount;
3755 PROCESSOR_POWER_POLICY_INFO Policy[3];
3756 } PROCESSOR_POWER_POLICY,
3757 *PPROCESSOR_POWER_POLICY;
3759 typedef struct {
3760 BOOLEAN AcOnLine;
3761 BOOLEAN BatteryPresent;
3762 BOOLEAN Charging;
3763 BOOLEAN Discharging;
3764 BOOLEAN Spare1[4];
3765 ULONG MaxCapacity;
3766 ULONG RemainingCapacity;
3767 ULONG Rate;
3768 ULONG EstimatedTime;
3769 ULONG DefaultAlert1;
3770 ULONG DefaultAlert2;
3771 } SYSTEM_BATTERY_STATE,
3772 *PSYSTEM_BATTERY_STATE;
3774 typedef struct {
3775 BOOLEAN PowerButtonPresent;
3776 BOOLEAN SleepButtonPresent;
3777 BOOLEAN LidPresent;
3778 BOOLEAN SystemS1;
3779 BOOLEAN SystemS2;
3780 BOOLEAN SystemS3;
3781 BOOLEAN SystemS4;
3782 BOOLEAN SystemS5;
3783 BOOLEAN HiberFilePresent;
3784 BOOLEAN FullWake;
3785 BOOLEAN VideoDimPresent;
3786 BOOLEAN ApmPresent;
3787 BOOLEAN UpsPresent;
3788 BOOLEAN ThermalControl;
3789 BOOLEAN ProcessorThrottle;
3790 UCHAR ProcessorMinThrottle;
3791 UCHAR ProcessorMaxThrottle;
3792 UCHAR spare2[4];
3793 BOOLEAN DiskSpinDown;
3794 UCHAR spare3[8];
3795 BOOLEAN SystemBatteriesPresent;
3796 BOOLEAN BatteriesAreShortTerm;
3797 BATTERY_REPORTING_SCALE BatteryScale[3];
3798 SYSTEM_POWER_STATE AcOnLineWake;
3799 SYSTEM_POWER_STATE SoftLidWake;
3800 SYSTEM_POWER_STATE RtcWake;
3801 SYSTEM_POWER_STATE MinDeviceWakeState;
3802 SYSTEM_POWER_STATE DefaultLowLatencyWake;
3803 } SYSTEM_POWER_CAPABILITIES,
3804 *PSYSTEM_POWER_CAPABILITIES;
3806 typedef struct _SYSTEM_POWER_INFORMATION {
3807 ULONG MaxIdlenessAllowed;
3808 ULONG Idleness;
3809 ULONG TimeRemaining;
3810 UCHAR CoolingMode;
3811 } SYSTEM_POWER_INFORMATION,
3812 *PSYSTEM_POWER_INFORMATION;
3814 typedef struct _SYSTEM_POWER_LEVEL {
3815 BOOLEAN Enable;
3816 UCHAR Spare[3];
3817 ULONG BatteryLevel;
3818 POWER_ACTION_POLICY PowerPolicy;
3819 SYSTEM_POWER_STATE MinSystemState;
3820 } SYSTEM_POWER_LEVEL,
3821 *PSYSTEM_POWER_LEVEL;
3823 typedef struct _SYSTEM_POWER_POLICY {
3824 ULONG Revision;
3825 POWER_ACTION_POLICY PowerButton;
3826 POWER_ACTION_POLICY SleepButton;
3827 POWER_ACTION_POLICY LidClose;
3828 SYSTEM_POWER_STATE LidOpenWake;
3829 ULONG Reserved;
3830 POWER_ACTION_POLICY Idle;
3831 ULONG IdleTimeout;
3832 UCHAR IdleSensitivity;
3833 UCHAR DynamicThrottle;
3834 UCHAR Spare2[2];
3835 SYSTEM_POWER_STATE MinSleep;
3836 SYSTEM_POWER_STATE MaxSleep;
3837 SYSTEM_POWER_STATE ReducedLatencySleep;
3838 ULONG WinLogonFlags;
3839 ULONG Spare3;
3840 ULONG DozeS4Timeout;
3841 ULONG BroadcastCapacityResolution;
3842 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
3843 ULONG VideoTimeout;
3844 BOOLEAN VideoDimDisplay;
3845 ULONG VideoReserved[3];
3846 ULONG SpindownTimeout;
3847 BOOLEAN OptimizeForPower;
3848 UCHAR FanThrottleTolerance;
3849 UCHAR ForcedThrottle;
3850 UCHAR MinThrottle;
3851 POWER_ACTION_POLICY OverThrottled;
3852 } SYSTEM_POWER_POLICY,
3853 *PSYSTEM_POWER_POLICY;
3855 typedef union _FILE_SEGMENT_ELEMENT {
3856 PVOID64 Buffer;
3857 ULONGLONG Alignment;
3858 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
3860 typedef struct _FILE_NOTIFY_INFORMATION {
3861 DWORD NextEntryOffset;
3862 DWORD Action;
3863 DWORD FileNameLength;
3864 WCHAR FileName[1];
3865 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
3867 /* ----------------------------- begin tape storage --------------------- */
3869 #define TAPE_FIXED_PARTITIONS 0
3870 #define TAPE_SELECT_PARTITIONS 1
3871 #define TAPE_INITIATOR_PARTITIONS 2
3872 #define TAPE_ERASE_SHORT 0
3873 #define TAPE_ERASE_LONG 1
3874 #define TAPE_LOAD 0
3875 #define TAPE_UNLOAD 1
3876 #define TAPE_TENSION 2
3877 #define TAPE_LOCK 3
3878 #define TAPE_UNLOCK 4
3879 #define TAPE_FORMAT 5
3880 #define TAPE_SETMARKS 0
3881 #define TAPE_FILEMARKS 1
3882 #define TAPE_SHORT_FILEMARKS 2
3883 #define TAPE_LONG_FILEMARKS 3
3884 #define TAPE_REWIND 0
3885 #define TAPE_ABSOLUTE_BLOCK 1
3886 #define TAPE_LOGICAL_BLOCK 2
3887 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
3888 #define TAPE_SPACE_END_OF_DATA 4
3889 #define TAPE_SPACE_RELATIVE_BLOCKS 5
3890 #define TAPE_SPACE_FILEMARKS 6
3891 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
3892 #define TAPE_SPACE_SETMARKS 8
3893 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
3895 typedef struct _TAPE_CREATE_PARTITION {
3896 DWORD Method;
3897 DWORD Count;
3898 DWORD Size;
3899 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
3901 typedef struct _TAPE_ERASE {
3902 DWORD Type;
3903 BOOLEAN Immediate;
3904 } TAPE_ERASE, *PTAPE_ERASE;
3906 typedef struct _TAPE_PREPARE {
3907 DWORD Operation;
3908 BOOLEAN Immediate;
3909 } TAPE_PREPARE, *PTAPE_PREPARE;
3911 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
3912 BOOLEAN ECC;
3913 BOOLEAN Compression;
3914 BOOLEAN DataPadding;
3915 BOOLEAN ReportSetmarks;
3916 ULONG EOTWarningZoneSize;
3917 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
3919 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
3920 ULONG BlockSize;
3921 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
3923 typedef struct _TAPE_WRITE_MARKS {
3924 DWORD Type;
3925 DWORD Count;
3926 BOOLEAN Immediate;
3927 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
3929 typedef struct _TAPE_GET_POSITION {
3930 ULONG Type;
3931 ULONG Partition;
3932 ULONG OffsetLow;
3933 ULONG OffsetHigh;
3934 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
3936 typedef struct _TAPE_SET_POSITION {
3937 ULONG Method;
3938 ULONG Partition;
3939 LARGE_INTEGER Offset;
3940 BOOLEAN Immediate;
3941 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
3943 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
3944 BOOLEAN ECC;
3945 BOOLEAN Compression;
3946 BOOLEAN DataPadding;
3947 BOOLEAN ReportSetmarks;
3948 DWORD DefaultBlockSize;
3949 DWORD MaximumBlockSize;
3950 DWORD MinimumBlockSize;
3951 DWORD MaximumPartitionCount;
3952 DWORD FeaturesLow;
3953 DWORD FeaturesHigh;
3954 DWORD EOTWarningZoneSize;
3955 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
3957 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
3958 LARGE_INTEGER Capacity;
3959 LARGE_INTEGER Remaining;
3960 DWORD BlockSize;
3961 DWORD PartitionCount;
3962 BOOLEAN WriteProtected;
3963 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
3965 /* ----------------------------- begin registry ----------------------------- */
3967 /* Registry security values */
3968 #define OWNER_SECURITY_INFORMATION 0x00000001
3969 #define GROUP_SECURITY_INFORMATION 0x00000002
3970 #define DACL_SECURITY_INFORMATION 0x00000004
3971 #define SACL_SECURITY_INFORMATION 0x00000008
3973 #define REG_OPTION_RESERVED 0x00000000
3974 #define REG_OPTION_NON_VOLATILE 0x00000000
3975 #define REG_OPTION_VOLATILE 0x00000001
3976 #define REG_OPTION_CREATE_LINK 0x00000002
3977 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
3978 #define REG_OPTION_OPEN_LINK 0x00000008
3979 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
3980 REG_OPTION_NON_VOLATILE| \
3981 REG_OPTION_VOLATILE| \
3982 REG_OPTION_CREATE_LINK| \
3983 REG_OPTION_BACKUP_RESTORE| \
3984 REG_OPTION_OPEN_LINK)
3987 #define REG_CREATED_NEW_KEY 0x00000001
3988 #define REG_OPENED_EXISTING_KEY 0x00000002
3990 /* For RegNotifyChangeKeyValue */
3991 #define REG_NOTIFY_CHANGE_NAME 0x01
3992 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
3993 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
3994 #define REG_NOTIFY_CHANGE_SECURITY 0x08
3996 #define KEY_QUERY_VALUE 0x00000001
3997 #define KEY_SET_VALUE 0x00000002
3998 #define KEY_CREATE_SUB_KEY 0x00000004
3999 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
4000 #define KEY_NOTIFY 0x00000010
4001 #define KEY_CREATE_LINK 0x00000020
4003 /* for RegKeyRestore flags */
4004 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
4005 #define REG_REFRESH_HIVE 0x00000002
4006 #define REG_NO_LAZY_FLUSH 0x00000004
4007 #define REG_FORCE_RESTORE 0x00000008
4009 #define KEY_READ ((STANDARD_RIGHTS_READ| \
4010 KEY_QUERY_VALUE| \
4011 KEY_ENUMERATE_SUB_KEYS| \
4012 KEY_NOTIFY) \
4013 & (~SYNCHRONIZE) \
4015 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
4016 KEY_SET_VALUE| \
4017 KEY_CREATE_SUB_KEY) \
4018 & (~SYNCHRONIZE) \
4020 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
4021 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
4022 KEY_QUERY_VALUE| \
4023 KEY_SET_VALUE| \
4024 KEY_CREATE_SUB_KEY| \
4025 KEY_ENUMERATE_SUB_KEYS| \
4026 KEY_NOTIFY| \
4027 KEY_CREATE_LINK) \
4028 & (~SYNCHRONIZE) \
4030 /* ------------------------------ end registry ------------------------------ */
4033 #define EVENTLOG_SUCCESS 0x0000
4034 #define EVENTLOG_ERROR_TYPE 0x0001
4035 #define EVENTLOG_WARNING_TYPE 0x0002
4036 #define EVENTLOG_INFORMATION_TYPE 0x0004
4037 #define EVENTLOG_AUDIT_SUCCESS 0x0008
4038 #define EVENTLOG_AUDIT_FAILURE 0x0010
4040 #define SERVICE_BOOT_START 0x00000000
4041 #define SERVICE_SYSTEM_START 0x00000001
4042 #define SERVICE_AUTO_START 0x00000002
4043 #define SERVICE_DEMAND_START 0x00000003
4044 #define SERVICE_DISABLED 0x00000004
4046 #define SERVICE_ERROR_IGNORE 0x00000000
4047 #define SERVICE_ERROR_NORMAL 0x00000001
4048 #define SERVICE_ERROR_SEVERE 0x00000002
4049 #define SERVICE_ERROR_CRITICAL 0x00000003
4051 /* Service types */
4052 #define SERVICE_KERNEL_DRIVER 0x00000001
4053 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
4054 #define SERVICE_ADAPTER 0x00000004
4055 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
4057 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
4058 SERVICE_RECOGNIZER_DRIVER )
4060 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
4061 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
4062 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
4064 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
4066 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
4067 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
4070 typedef enum _CM_SERVICE_NODE_TYPE
4072 DriverType = SERVICE_KERNEL_DRIVER,
4073 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
4074 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
4075 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
4076 AdapterType = SERVICE_ADAPTER,
4077 RecognizerType = SERVICE_RECOGNIZER_DRIVER
4078 } SERVICE_NODE_TYPE;
4080 typedef enum _CM_SERVICE_LOAD_TYPE
4082 BootLoad = SERVICE_BOOT_START,
4083 SystemLoad = SERVICE_SYSTEM_START,
4084 AutoLoad = SERVICE_AUTO_START,
4085 DemandLoad = SERVICE_DEMAND_START,
4086 DisableLoad = SERVICE_DISABLED
4087 } SERVICE_LOAD_TYPE;
4089 typedef enum _CM_ERROR_CONTROL_TYPE
4091 IgnoreError = SERVICE_ERROR_IGNORE,
4092 NormalError = SERVICE_ERROR_NORMAL,
4093 SevereError = SERVICE_ERROR_SEVERE,
4094 CriticalError = SERVICE_ERROR_CRITICAL
4095 } SERVICE_ERROR_TYPE;
4099 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
4100 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
4101 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
4102 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
4103 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
4105 #include <guiddef.h>
4107 typedef struct _OBJECT_TYPE_LIST {
4108 WORD Level;
4109 WORD Sbz;
4110 GUID *ObjectType;
4111 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
4113 typedef struct _RTL_CRITICAL_SECTION_DEBUG
4115 WORD Type;
4116 WORD CreatorBackTraceIndex;
4117 struct _RTL_CRITICAL_SECTION *CriticalSection;
4118 LIST_ENTRY ProcessLocksList;
4119 DWORD EntryCount;
4120 DWORD ContentionCount;
4121 #ifdef __WINESRC__ /* in Wine we store the name here */
4122 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
4123 #else
4124 DWORD Spare[ 2 ];
4125 #endif
4126 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
4128 typedef struct _RTL_CRITICAL_SECTION {
4129 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
4130 LONG LockCount;
4131 LONG RecursionCount;
4132 HANDLE OwningThread;
4133 HANDLE LockSemaphore;
4134 ULONG_PTR SpinCount;
4135 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
4137 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
4139 #include <pshpack8.h>
4140 typedef struct _IO_COUNTERS {
4141 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
4142 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
4143 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
4144 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
4145 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
4146 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
4147 } IO_COUNTERS, *PIO_COUNTERS;
4148 #include <poppack.h>
4150 typedef struct {
4151 DWORD dwOSVersionInfoSize;
4152 DWORD dwMajorVersion;
4153 DWORD dwMinorVersion;
4154 DWORD dwBuildNumber;
4155 DWORD dwPlatformId;
4156 CHAR szCSDVersion[128];
4157 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
4159 typedef struct {
4160 DWORD dwOSVersionInfoSize;
4161 DWORD dwMajorVersion;
4162 DWORD dwMinorVersion;
4163 DWORD dwBuildNumber;
4164 DWORD dwPlatformId;
4165 WCHAR szCSDVersion[128];
4166 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
4168 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
4169 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
4170 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
4172 typedef struct {
4173 DWORD dwOSVersionInfoSize;
4174 DWORD dwMajorVersion;
4175 DWORD dwMinorVersion;
4176 DWORD dwBuildNumber;
4177 DWORD dwPlatformId;
4178 CHAR szCSDVersion[128];
4179 WORD wServicePackMajor;
4180 WORD wServicePackMinor;
4181 WORD wSuiteMask;
4182 BYTE wProductType;
4183 BYTE wReserved;
4184 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
4186 typedef struct {
4187 DWORD dwOSVersionInfoSize;
4188 DWORD dwMajorVersion;
4189 DWORD dwMinorVersion;
4190 DWORD dwBuildNumber;
4191 DWORD dwPlatformId;
4192 WCHAR szCSDVersion[128];
4193 WORD wServicePackMajor;
4194 WORD wServicePackMinor;
4195 WORD wSuiteMask;
4196 BYTE wProductType;
4197 BYTE wReserved;
4198 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
4200 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
4201 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
4202 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
4204 ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
4206 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
4208 #define VER_PLATFORM_WIN32s 0
4209 #define VER_PLATFORM_WIN32_WINDOWS 1
4210 #define VER_PLATFORM_WIN32_NT 2
4212 #define VER_MINORVERSION 0x00000001
4213 #define VER_MAJORVERSION 0x00000002
4214 #define VER_BUILDNUMBER 0x00000004
4215 #define VER_PLATFORMID 0x00000008
4216 #define VER_SERVICEPACKMINOR 0x00000010
4217 #define VER_SERVICEPACKMAJOR 0x00000020
4218 #define VER_SUITENAME 0x00000040
4219 #define VER_PRODUCT_TYPE 0x00000080
4221 #define VER_NT_WORKSTATION 1
4222 #define VER_NT_DOMAIN_CONTROLLER 2
4223 #define VER_NT_SERVER 3
4225 #define VER_SUITE_SMALLBUSINESS 0x00000001
4226 #define VER_SUITE_ENTERPRISE 0x00000002
4227 #define VER_SUITE_BACKOFFICE 0x00000004
4228 #define VER_SUITE_COMMUNICATIONS 0x00000008
4229 #define VER_SUITE_TERMINAL 0x00000010
4230 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
4231 #define VER_SUITE_EMBEDDEDNT 0x00000040
4232 #define VER_SUITE_DATACENTER 0x00000080
4233 #define VER_SUITE_SINGLEUSERTS 0x00000100
4234 #define VER_SUITE_PERSONAL 0x00000200
4235 #define VER_SUITE_BLADE 0x00000400
4237 #define VER_EQUAL 1
4238 #define VER_GREATER 2
4239 #define VER_GREATER_EQUAL 3
4240 #define VER_LESS 4
4241 #define VER_LESS_EQUAL 5
4242 #define VER_AND 6
4243 #define VER_OR 7
4245 #endif /* _WINNT_ */