kernel32: Add a CopyFile test.
[wine/multimedia.git] / include / winnt.h
blobeb3ab2ccf63699ecf018ce972b2e9a8da69a1bcf
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef _WINNT_
22 #define _WINNT_
24 #include <basetsd.h>
25 #include <guiddef.h>
27 #ifndef RC_INVOKED
28 #include <ctype.h>
29 #include <stddef.h>
30 #include <string.h>
31 #endif
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 #ifdef _NTSYSTEM_
39 #define NTSYSAPI
40 #else
41 #define NTSYSAPI DECLSPEC_IMPORT
42 #endif
44 #define NTAPI __stdcall
46 #ifndef MIDL_PASS
47 # if defined(_MSC_VER)
48 # define DECLSPEC_IMPORT __declspec(dllimport)
49 # elif defined(__MINGW32__) || defined(__CYGWIN__)
50 # define DECLSPEC_IMPORT __attribute__((dllimport))
51 # else
52 # define DECLSPEC_IMPORT DECLSPEC_HIDDEN
53 # endif
54 #else
55 # define DECLSPEC_IMPORT
56 #endif
58 #ifndef DECLSPEC_NORETURN
59 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
60 # define DECLSPEC_NORETURN __declspec(noreturn)
61 # elif defined(__GNUC__)
62 # define DECLSPEC_NORETURN __attribute__((noreturn))
63 # else
64 # define DECLSPEC_NORETURN
65 # endif
66 #endif
68 #ifndef DECLSPEC_ALIGN
69 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
70 # define DECLSPEC_ALIGN(x) __declspec(align(x))
71 # elif defined(__GNUC__)
72 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
73 # else
74 # define DECLSPEC_ALIGN(x)
75 # endif
76 #endif
78 #ifndef DECLSPEC_CACHEALIGN
79 # define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
80 #endif
82 #ifndef DECLSPEC_UUID
83 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined (__cplusplus)
84 # define DECLSPEC_UUID(x) __declspec(uuid(x))
85 # else
86 # define DECLSPEC_UUID(x)
87 # endif
88 #endif
90 #ifndef DECLSPEC_NOVTABLE
91 # if defined(_MSC_VER) && (_MSC_VER >= 1100) && defined(__cplusplus)
92 # define DECLSPEC_NOVTABLE __declspec(novtable)
93 # else
94 # define DECLSPEC_NOVTABLE
95 # endif
96 #endif
98 #ifndef DECLSPEC_SELECTANY
99 #if defined(_MSC_VER) && (_MSC_VER >= 1100)
100 #define DECLSPEC_SELECTANY __declspec(selectany)
101 #else
102 #define DECLSPEC_SELECTANY
103 #endif
104 #endif
106 #ifndef NOP_FUNCTION
107 # if defined(_MSC_VER) && (_MSC_VER >= 1210)
108 # define NOP_FUNCTION __noop
109 # else
110 # define NOP_FUNCTION (void)0
111 # endif
112 #endif
114 #ifndef DECLSPEC_ADDRSAFE
115 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
116 # define DECLSPEC_ADDRSAFE __declspec(address_safe)
117 # else
118 # define DECLSPEC_ADDRSAFE
119 # endif
120 #endif
122 #ifndef FORCEINLINE
123 # if defined(_MSC_VER) && (_MSC_VER >= 1200)
124 # define FORCEINLINE __forceinline
125 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
126 # define FORCEINLINE inline __attribute__((always_inline))
127 # else
128 # define FORCEINLINE inline
129 # endif
130 #endif
132 #ifndef DECLSPEC_DEPRECATED
133 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
134 # define DECLSPEC_DEPRECATED __declspec(deprecated)
135 # define DEPRECATE_SUPPORTED
136 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
137 # define DECLSPEC_DEPRECATED __attribute__((deprecated))
138 # define DEPRECATE_SUPPORTED
139 # else
140 # define DECLSPEC_DEPRECATED
141 # undef DEPRECATE_SUPPORTED
142 # endif
143 #endif
145 /* a couple of useful Wine extensions */
147 #ifdef _MSC_VER
148 # define DECLSPEC_EXPORT __declspec(dllexport)
149 #elif defined(__MINGW32__)
150 # define DECLSPEC_EXPORT __attribute__((dllexport))
151 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
152 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
153 #else
154 # define DECLSPEC_EXPORT
155 #endif
157 #if defined(__MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
158 # define DECLSPEC_HIDDEN
159 #elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
160 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
161 #else
162 # define DECLSPEC_HIDDEN
163 #endif
165 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
166 #define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
167 #else
168 #define __WINE_ALLOC_SIZE(x)
169 #endif
171 /* Anonymous union/struct handling */
173 #ifndef NONAMELESSSTRUCT
174 # ifdef __GNUC__
175 /* Anonymous struct support starts with gcc 2.96 or gcc/g++ 3.x */
176 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && (defined(__cplusplus) || (__GNUC_MINOR__ < 96)))
177 # define NONAMELESSSTRUCT
178 # endif
179 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
180 # define NONAMELESSSTRUCT
181 # endif
182 #endif /* NONAMELESSSTRUCT */
184 #ifndef NONAMELESSUNION
185 # ifdef __GNUC__
186 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
187 # if (__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus))))
188 # define NONAMELESSUNION
189 # endif
190 # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
191 # define NONAMELESSUNION
192 # endif
193 #endif /* NONAMELESSUNION */
195 #ifndef NONAMELESSSTRUCT
196 #define DUMMYSTRUCTNAME
197 #define DUMMYSTRUCTNAME1
198 #define DUMMYSTRUCTNAME2
199 #define DUMMYSTRUCTNAME3
200 #define DUMMYSTRUCTNAME4
201 #define DUMMYSTRUCTNAME5
202 #else /* !defined(NONAMELESSSTRUCT) */
203 #define DUMMYSTRUCTNAME s
204 #define DUMMYSTRUCTNAME1 s1
205 #define DUMMYSTRUCTNAME2 s2
206 #define DUMMYSTRUCTNAME3 s3
207 #define DUMMYSTRUCTNAME4 s4
208 #define DUMMYSTRUCTNAME5 s5
209 #endif /* !defined(NONAMELESSSTRUCT) */
211 #ifndef NONAMELESSUNION
212 #define DUMMYUNIONNAME
213 #define DUMMYUNIONNAME1
214 #define DUMMYUNIONNAME2
215 #define DUMMYUNIONNAME3
216 #define DUMMYUNIONNAME4
217 #define DUMMYUNIONNAME5
218 #define DUMMYUNIONNAME6
219 #define DUMMYUNIONNAME7
220 #define DUMMYUNIONNAME8
221 #else /* !defined(NONAMELESSUNION) */
222 #define DUMMYUNIONNAME u
223 #define DUMMYUNIONNAME1 u1
224 #define DUMMYUNIONNAME2 u2
225 #define DUMMYUNIONNAME3 u3
226 #define DUMMYUNIONNAME4 u4
227 #define DUMMYUNIONNAME5 u5
228 #define DUMMYUNIONNAME6 u6
229 #define DUMMYUNIONNAME7 u7
230 #define DUMMYUNIONNAME8 u8
231 #endif /* !defined(NONAMELESSUNION) */
233 /* C99 restrict support */
235 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
236 # if defined(_MSC_VER) && defined(_M_MRX000)
237 # define RESTRICTED_POINTER __restrict
238 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
239 # define RESTRICTED_POINTER __restrict
240 # else
241 # define RESTRICTED_POINTER
242 # endif
243 #else
244 # define RESTRICTED_POINTER
245 #endif
247 /* C99 unaligned support */
249 #ifndef UNALIGNED
250 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
251 # define UNALIGNED __unaligned
252 # ifdef _WIN64
253 # define UNALIGNED64 __unaligned
254 # else
255 # define UNALIGNED64
256 # endif
257 #else
258 # define UNALIGNED
259 # define UNALIGNED64
260 #endif
261 #endif
263 /* Alignment macros */
265 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
266 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
267 #define MEMORY_ALLOCATION_ALIGNMENT 16
268 #else
269 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
270 #define MEMORY_ALLOCATION_ALIGNMENT 8
271 #endif
273 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
274 # define TYPE_ALIGNMENT(t) __alignof(t)
275 #elif defined(__GNUC__)
276 # define TYPE_ALIGNMENT(t) __alignof__(t)
277 #else
278 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
279 #endif
281 #ifdef _WIN64
282 # define PROBE_ALIGNMENT(_s) \
283 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
284 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
285 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
286 #else
287 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
288 #endif
290 /* Compile time assertion */
292 #if defined(_MSC_VER)
293 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
294 #else
295 # define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
296 #endif
298 /* Eliminate Microsoft C/C++ compiler warning 4715 */
299 #if defined(_MSC_VER) && (_MSC_VER > 1200)
300 # define DEFAULT_UNREACHABLE default: __assume(0)
301 #else
302 # define DEFAULT_UNREACHABLE
303 #endif
305 /* Error Masks */
306 #define APPLICATION_ERROR_MASK 0x20000000
307 #define ERROR_SEVERITY_SUCCESS 0x00000000
308 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
309 #define ERROR_SEVERITY_WARNING 0x80000000
310 #define ERROR_SEVERITY_ERROR 0xC0000000
312 #ifdef __cplusplus
313 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
314 extern "C++" { \
315 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
316 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
317 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \
318 inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
319 inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \
320 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \
321 inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
323 #else
324 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
325 #endif
327 /* Microsoft's macros for declaring functions */
329 #ifdef __cplusplus
330 # define EXTERN_C extern "C"
331 #else
332 # define EXTERN_C extern
333 #endif
335 #define STDMETHODCALLTYPE __stdcall
336 #define STDMETHODVCALLTYPE __cdecl
337 #define STDAPICALLTYPE __stdcall
338 #define STDAPIVCALLTYPE __cdecl
340 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
341 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
342 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
343 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
344 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
345 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
346 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
347 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
349 /* Define the basic types */
350 #ifndef VOID
351 #define VOID void
352 #endif
353 typedef VOID *PVOID;
354 typedef VOID *PVOID64;
355 typedef BYTE BOOLEAN, *PBOOLEAN;
356 typedef char CHAR, *PCHAR;
357 typedef short SHORT, *PSHORT;
358 #ifdef _MSC_VER
359 typedef long LONG, *PLONG;
360 #else
361 typedef int LONG, *PLONG;
362 #endif
364 /* Some systems might have wchar_t, but we really need 16 bit characters */
365 #ifdef WINE_UNICODE_NATIVE
366 typedef wchar_t WCHAR, *PWCHAR;
367 #else
368 typedef unsigned short WCHAR, *PWCHAR;
369 #endif
371 /* 'Extended/Wide' numerical types */
372 #ifndef _ULONGLONG_
373 # define _ULONGLONG_
374 # ifdef _MSC_VER
375 typedef signed __int64 LONGLONG, *PLONGLONG;
376 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
377 # else
378 typedef signed __int64 DECLSPEC_ALIGN(8) LONGLONG, *PLONGLONG;
379 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONGLONG, *PULONGLONG;
380 # endif
381 #endif
383 #ifndef _DWORDLONG_
384 # define _DWORDLONG_
385 # ifdef _MSC_VER
386 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
387 # else
388 typedef ULONGLONG DECLSPEC_ALIGN(8) DWORDLONG, *PDWORDLONG;
389 # endif
390 #endif
392 /* ANSI string types */
393 typedef CHAR *PCH, *LPCH;
394 typedef const CHAR *PCCH, *LPCCH;
395 typedef CHAR *PSTR, *LPSTR, *NPSTR;
396 typedef const CHAR *PCSTR, *LPCSTR;
398 /* Unicode string types */
399 typedef WCHAR *PWCH, *LPWCH;
400 typedef const WCHAR *PCWCH, *LPCWCH;
401 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
402 typedef const WCHAR *PCWSTR, *LPCWSTR;
404 /* Neutral character and string types */
405 /* These are only defined for Winelib, i.e. _not_ defined for
406 * the emulator. The reason is they depend on the UNICODE
407 * macro which only exists in the user's code.
409 #ifndef WINE_NO_UNICODE_MACROS
410 # ifdef UNICODE
411 # ifndef _TCHAR_DEFINED
412 typedef WCHAR TCHAR, *PTCHAR;
413 # define _TCHAR_DEFINED
414 #endif
415 typedef LPWSTR PTSTR, LPTSTR;
416 typedef LPCWSTR PCTSTR, LPCTSTR;
417 # define __TEXT(string) L##string
418 # else /* UNICODE */
419 # ifndef _TCHAR_DEFINED
420 typedef CHAR TCHAR, *PTCHAR;
421 # define _TCHAR_DEFINED
422 # endif
423 typedef LPSTR PTSTR, LPTSTR;
424 typedef LPCSTR PCTSTR, LPCTSTR;
425 # define __TEXT(string) string
426 # endif /* UNICODE */
427 # define TEXT(quote) __TEXT(quote)
428 #endif /* WINE_NO_UNICODE_MACROS */
430 /* Misc common WIN32 types */
431 typedef char CCHAR;
432 typedef DWORD LCID, *PLCID;
433 typedef WORD LANGID;
434 typedef DWORD EXECUTION_STATE;
435 #ifndef _HRESULT_DEFINED
436 #define _HRESULT_DEFINED
437 typedef LONG HRESULT;
438 #endif
440 /* Handle type */
442 typedef void *HANDLE;
443 typedef HANDLE *PHANDLE, *LPHANDLE;
445 #ifdef STRICT
446 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
447 #else /*STRICT*/
448 #define DECLARE_HANDLE(a) typedef HANDLE a
449 #endif /*STRICT*/
451 typedef BYTE FCHAR;
452 typedef WORD FSHORT;
453 typedef DWORD FLONG;
455 /* Defines */
457 #ifndef WIN32_NO_STATUS
459 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
460 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
461 #define STATUS_USER_APC ((DWORD) 0x000000C0)
462 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
463 #define STATUS_PENDING ((DWORD) 0x00000103)
464 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
465 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
466 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
467 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
468 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
469 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
470 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
471 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
472 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
473 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
474 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
475 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
476 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
477 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
478 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
479 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
480 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
481 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
482 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
483 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
484 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
485 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
486 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
487 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
488 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
489 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
490 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
491 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
492 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
493 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
495 /* status values for ContinueDebugEvent */
496 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
497 #define DBG_CONTINUE ((DWORD) 0x00010002)
498 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
499 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
500 #define DBG_CONTROL_C ((DWORD) 0x40010005)
501 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
502 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
503 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
505 #endif /* WIN32_NO_STATUS */
507 /* Argument 1 passed to the DllEntryProc. */
508 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
509 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
510 #define DLL_THREAD_ATTACH 2 /* attach new thread */
511 #define DLL_THREAD_DETACH 3 /* detach thread */
512 #ifdef __WINESRC__
513 #define DLL_WINE_PREATTACH 8 /* called before process attach for Wine builtins */
514 #endif
516 /* u.x.wProcessorArchitecture (NT) */
517 #define PROCESSOR_ARCHITECTURE_INTEL 0
518 #define PROCESSOR_ARCHITECTURE_MIPS 1
519 #define PROCESSOR_ARCHITECTURE_ALPHA 2
520 #define PROCESSOR_ARCHITECTURE_PPC 3
521 #define PROCESSOR_ARCHITECTURE_SHX 4
522 #define PROCESSOR_ARCHITECTURE_ARM 5
523 #define PROCESSOR_ARCHITECTURE_IA64 6
524 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
525 #define PROCESSOR_ARCHITECTURE_MSIL 8
526 #define PROCESSOR_ARCHITECTURE_AMD64 9
527 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
529 /* dwProcessorType */
530 #define PROCESSOR_INTEL_386 386
531 #define PROCESSOR_INTEL_486 486
532 #define PROCESSOR_INTEL_PENTIUM 586
533 #define PROCESSOR_INTEL_860 860
534 #define PROCESSOR_INTEL_IA64 2200
535 #define PROCESSOR_AMD_X8664 8664
536 #define PROCESSOR_MIPS_R2000 2000
537 #define PROCESSOR_MIPS_R3000 3000
538 #define PROCESSOR_MIPS_R4000 4000
539 #define PROCESSOR_ALPHA_21064 21064
540 #define PROCESSOR_PPC_601 601
541 #define PROCESSOR_PPC_603 603
542 #define PROCESSOR_PPC_604 604
543 #define PROCESSOR_PPC_620 620
544 #define PROCESSOR_HITACHI_SH3 10003
545 #define PROCESSOR_HITACHI_SH3E 10004
546 #define PROCESSOR_HITACHI_SH4 10005
547 #define PROCESSOR_MOTOROLA_821 821
548 #define PROCESSOR_SHx_SH3 103
549 #define PROCESSOR_SHx_SH4 104
550 #define PROCESSOR_STRONGARM 2577
551 #define PROCESSOR_ARM720 1824 /* 0x720 */
552 #define PROCESSOR_ARM820 2080 /* 0x820 */
553 #define PROCESSOR_ARM920 2336 /* 0x920 */
554 #define PROCESSOR_ARM_7TDMI 70001
556 #ifdef _WIN64
557 #define MAXIMUM_PROCESSORS 64
558 #else
559 #define MAXIMUM_PROCESSORS 32
560 #endif
562 typedef struct _MEMORY_BASIC_INFORMATION
564 LPVOID BaseAddress;
565 LPVOID AllocationBase;
566 DWORD AllocationProtect;
567 SIZE_T RegionSize;
568 DWORD State;
569 DWORD Protect;
570 DWORD Type;
571 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
573 #define PAGE_NOACCESS 0x01
574 #define PAGE_READONLY 0x02
575 #define PAGE_READWRITE 0x04
576 #define PAGE_WRITECOPY 0x08
577 #define PAGE_EXECUTE 0x10
578 #define PAGE_EXECUTE_READ 0x20
579 #define PAGE_EXECUTE_READWRITE 0x40
580 #define PAGE_EXECUTE_WRITECOPY 0x80
581 #define PAGE_GUARD 0x100
582 #define PAGE_NOCACHE 0x200
583 #define PAGE_WRITECOMBINE 0x400
585 #define MEM_COMMIT 0x00001000
586 #define MEM_RESERVE 0x00002000
587 #define MEM_DECOMMIT 0x00004000
588 #define MEM_RELEASE 0x00008000
589 #define MEM_FREE 0x00010000
590 #define MEM_PRIVATE 0x00020000
591 #define MEM_MAPPED 0x00040000
592 #define MEM_RESET 0x00080000
593 #define MEM_TOP_DOWN 0x00100000
594 #define MEM_WRITE_WATCH 0x00200000
595 #define MEM_PHYSICAL 0x00400000
596 #define MEM_LARGE_PAGES 0x20000000
597 #define MEM_4MB_PAGES 0x80000000
599 #define SEC_FILE 0x00800000
600 #define SEC_IMAGE 0x01000000
601 #define SEC_RESERVE 0x04000000
602 #define SEC_COMMIT 0x08000000
603 #define SEC_NOCACHE 0x10000000
604 #define SEC_LARGE_PAGES 0x80000000
605 #define MEM_IMAGE SEC_IMAGE
607 #define WRITE_WATCH_FLAG_RESET 0x00000001
610 #define MINCHAR 0x80
611 #define MAXCHAR 0x7f
612 #define MINSHORT 0x8000
613 #define MAXSHORT 0x7fff
614 #define MINLONG 0x80000000
615 #define MAXLONG 0x7fffffff
616 #define MAXBYTE 0xff
617 #define MAXWORD 0xffff
618 #define MAXDWORD 0xffffffff
620 #define UNICODE_STRING_MAX_CHARS 32767
622 #define FIELD_OFFSET(type, field) \
623 ((LONG)(INT_PTR)&(((type *)0)->field))
625 #define CONTAINING_RECORD(address, type, field) \
626 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
628 /* Types */
630 typedef struct _LIST_ENTRY {
631 struct _LIST_ENTRY *Flink;
632 struct _LIST_ENTRY *Blink;
633 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
635 typedef struct _SINGLE_LIST_ENTRY {
636 struct _SINGLE_LIST_ENTRY *Next;
637 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
639 #ifdef _WIN64
641 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
642 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
643 PSLIST_ENTRY Next;
644 } SLIST_ENTRY;
646 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
647 struct {
648 ULONGLONG Alignment;
649 ULONGLONG Region;
650 } DUMMYSTRUCTNAME;
651 struct {
652 ULONGLONG Depth:16;
653 ULONGLONG Sequence:9;
654 ULONGLONG NextEntry:39;
655 ULONGLONG HeaderType:1;
656 ULONGLONG Init:1;
657 ULONGLONG Reserved:59;
658 ULONGLONG Region:3;
659 } Header8;
660 struct {
661 ULONGLONG Depth:16;
662 ULONGLONG Sequence:48;
663 ULONGLONG HeaderType:1;
664 ULONGLONG Init:1;
665 ULONGLONG Reserved:2;
666 ULONGLONG NextEntry:60;
667 } Header16;
668 } SLIST_HEADER, *PSLIST_HEADER;
670 #else
672 #undef SLIST_ENTRY /* for Mac OS */
673 #define SLIST_ENTRY SINGLE_LIST_ENTRY
674 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
675 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
677 typedef union _SLIST_HEADER {
678 ULONGLONG Alignment;
679 struct {
680 SLIST_ENTRY Next;
681 WORD Depth;
682 WORD Sequence;
683 } DUMMYSTRUCTNAME;
684 } SLIST_HEADER, *PSLIST_HEADER;
686 #endif
688 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
689 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
690 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
691 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
692 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
693 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
696 /* Heap flags */
698 #define HEAP_NO_SERIALIZE 0x00000001
699 #define HEAP_GROWABLE 0x00000002
700 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
701 #define HEAP_ZERO_MEMORY 0x00000008
702 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
703 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
704 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
705 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
706 #define HEAP_CREATE_ALIGN_16 0x00010000
707 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
708 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
710 /* This flag allows it to create heaps shared by all processes under win95,
711 FIXME: correct name */
712 #define HEAP_SHARED 0x04000000
714 typedef enum _HEAP_INFORMATION_CLASS {
715 HeapCompatibilityInformation,
716 } HEAP_INFORMATION_CLASS;
718 /* Processor feature flags. */
719 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
720 #define PF_FLOATING_POINT_EMULATED 1
721 #define PF_COMPARE_EXCHANGE_DOUBLE 2
722 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
723 #define PF_PPC_MOVEMEM_64BIT_OK 4
724 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
725 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
726 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
727 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
728 #define PF_PAE_ENABLED 9
729 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
730 #define PF_SSE_DAZ_MODE_AVAILABLE 11
731 #define PF_NX_ENABLED 12
732 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
733 #define PF_COMPARE_EXCHANGE128 14
734 #define PF_COMPARE64_EXCHANGE128 15
735 #define PF_CHANNELS_ENABLED 16
738 /* Execution state flags */
739 #define ES_SYSTEM_REQUIRED 0x00000001
740 #define ES_DISPLAY_REQUIRED 0x00000002
741 #define ES_USER_PRESENT 0x00000004
742 #define ES_CONTINUOUS 0x80000000
744 /* The Win32 register context */
746 /* CONTEXT is the CPU-dependent context; it should be used */
747 /* wherever a platform-specific context is needed (e.g. exception */
748 /* handling, Win32 register functions). */
750 /* CONTEXT86 is the i386-specific context; it should be used */
751 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
752 /* Win16 register functions), so that this code can be compiled */
753 /* on all platforms. */
755 #define SIZE_OF_80387_REGISTERS 80
757 typedef struct _FLOATING_SAVE_AREA
759 DWORD ControlWord;
760 DWORD StatusWord;
761 DWORD TagWord;
762 DWORD ErrorOffset;
763 DWORD ErrorSelector;
764 DWORD DataOffset;
765 DWORD DataSelector;
766 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
767 DWORD Cr0NpxState;
768 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
770 #define MAXIMUM_SUPPORTED_EXTENSION 512
772 typedef struct _CONTEXT86
774 DWORD ContextFlags;
776 /* These are selected by CONTEXT_DEBUG_REGISTERS */
777 DWORD Dr0;
778 DWORD Dr1;
779 DWORD Dr2;
780 DWORD Dr3;
781 DWORD Dr6;
782 DWORD Dr7;
784 /* These are selected by CONTEXT_FLOATING_POINT */
785 FLOATING_SAVE_AREA FloatSave;
787 /* These are selected by CONTEXT_SEGMENTS */
788 DWORD SegGs;
789 DWORD SegFs;
790 DWORD SegEs;
791 DWORD SegDs;
793 /* These are selected by CONTEXT_INTEGER */
794 DWORD Edi;
795 DWORD Esi;
796 DWORD Ebx;
797 DWORD Edx;
798 DWORD Ecx;
799 DWORD Eax;
801 /* These are selected by CONTEXT_CONTROL */
802 DWORD Ebp;
803 DWORD Eip;
804 DWORD SegCs;
805 DWORD EFlags;
806 DWORD Esp;
807 DWORD SegSs;
809 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
810 } CONTEXT86;
812 #define CONTEXT_X86 0x00010000
813 #define CONTEXT_i386 CONTEXT_X86
814 #define CONTEXT_i486 CONTEXT_X86
816 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
817 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
818 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
819 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
820 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
821 #define CONTEXT86_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020L)
822 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
823 #define CONTEXT86_ALL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS | \
824 CONTEXT86_FLOATING_POINT | CONTEXT86_DEBUG_REGISTERS | CONTEXT86_EXTENDED_REGISTERS)
826 /* i386 context definitions */
827 #ifdef __i386__
829 #define CONTEXT_CONTROL CONTEXT86_CONTROL
830 #define CONTEXT_INTEGER CONTEXT86_INTEGER
831 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
832 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
833 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
834 #define CONTEXT_EXTENDED_REGISTERS CONTEXT86_EXTENDED_REGISTERS
835 #define CONTEXT_FULL CONTEXT86_FULL
836 #define CONTEXT_ALL CONTEXT86_ALL
838 typedef CONTEXT86 CONTEXT;
840 #define EXCEPTION_READ_FAULT 0
841 #define EXCEPTION_WRITE_FAULT 1
842 #define EXCEPTION_EXECUTE_FAULT 8
844 #endif /* __i386__ */
846 typedef struct _LDT_ENTRY {
847 WORD LimitLow;
848 WORD BaseLow;
849 union {
850 struct {
851 BYTE BaseMid;
852 BYTE Flags1;
853 BYTE Flags2;
854 BYTE BaseHi;
855 } Bytes;
856 struct {
857 unsigned BaseMid: 8;
858 unsigned Type : 5;
859 unsigned Dpl : 2;
860 unsigned Pres : 1;
861 unsigned LimitHi : 4;
862 unsigned Sys : 1;
863 unsigned Reserved_0 : 1;
864 unsigned Default_Big : 1;
865 unsigned Granularity : 1;
866 unsigned BaseHi : 8;
867 } Bits;
868 } HighWord;
869 } LDT_ENTRY, *PLDT_ENTRY;
871 /* x86-64 context definitions */
872 #if defined(__x86_64__)
874 #define CONTEXT_AMD64 0x00100000
876 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
877 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
878 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
879 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008L)
880 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010L)
881 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
882 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
884 #define EXCEPTION_READ_FAULT 0
885 #define EXCEPTION_WRITE_FAULT 1
886 #define EXCEPTION_EXECUTE_FAULT 8
888 typedef struct DECLSPEC_ALIGN(16) _M128A {
889 ULONGLONG Low;
890 LONGLONG High;
891 } M128A, *PM128A;
893 typedef struct _XMM_SAVE_AREA32 {
894 WORD ControlWord; /* 000 */
895 WORD StatusWord; /* 002 */
896 BYTE TagWord; /* 004 */
897 BYTE Reserved1; /* 005 */
898 WORD ErrorOpcode; /* 006 */
899 DWORD ErrorOffset; /* 008 */
900 WORD ErrorSelector; /* 00c */
901 WORD Reserved2; /* 00e */
902 DWORD DataOffset; /* 010 */
903 WORD DataSelector; /* 014 */
904 WORD Reserved3; /* 016 */
905 DWORD MxCsr; /* 018 */
906 DWORD MxCsr_Mask; /* 01c */
907 M128A FloatRegisters[8]; /* 020 */
908 M128A XmmRegisters[16]; /* 0a0 */
909 BYTE Reserved4[96]; /* 1a0 */
910 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
912 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
913 DWORD64 P1Home; /* 000 */
914 DWORD64 P2Home; /* 008 */
915 DWORD64 P3Home; /* 010 */
916 DWORD64 P4Home; /* 018 */
917 DWORD64 P5Home; /* 020 */
918 DWORD64 P6Home; /* 028 */
920 /* Control flags */
921 DWORD ContextFlags; /* 030 */
922 DWORD MxCsr; /* 034 */
924 /* Segment */
925 WORD SegCs; /* 038 */
926 WORD SegDs; /* 03a */
927 WORD SegEs; /* 03c */
928 WORD SegFs; /* 03e */
929 WORD SegGs; /* 040 */
930 WORD SegSs; /* 042 */
931 DWORD EFlags; /* 044 */
933 /* Debug */
934 DWORD64 Dr0; /* 048 */
935 DWORD64 Dr1; /* 050 */
936 DWORD64 Dr2; /* 058 */
937 DWORD64 Dr3; /* 060 */
938 DWORD64 Dr6; /* 068 */
939 DWORD64 Dr7; /* 070 */
941 /* Integer */
942 DWORD64 Rax; /* 078 */
943 DWORD64 Rcx; /* 080 */
944 DWORD64 Rdx; /* 088 */
945 DWORD64 Rbx; /* 090 */
946 DWORD64 Rsp; /* 098 */
947 DWORD64 Rbp; /* 0a0 */
948 DWORD64 Rsi; /* 0a8 */
949 DWORD64 Rdi; /* 0b0 */
950 DWORD64 R8; /* 0b8 */
951 DWORD64 R9; /* 0c0 */
952 DWORD64 R10; /* 0c8 */
953 DWORD64 R11; /* 0d0 */
954 DWORD64 R12; /* 0d8 */
955 DWORD64 R13; /* 0e0 */
956 DWORD64 R14; /* 0e8 */
957 DWORD64 R15; /* 0f0 */
959 /* Counter */
960 DWORD64 Rip; /* 0f8 */
962 /* Floating point */
963 union {
964 XMM_SAVE_AREA32 FltSave; /* 100 */
965 struct {
966 M128A Header[2]; /* 100 */
967 M128A Legacy[8]; /* 120 */
968 M128A Xmm0; /* 1a0 */
969 M128A Xmm1; /* 1b0 */
970 M128A Xmm2; /* 1c0 */
971 M128A Xmm3; /* 1d0 */
972 M128A Xmm4; /* 1e0 */
973 M128A Xmm5; /* 1f0 */
974 M128A Xmm6; /* 200 */
975 M128A Xmm7; /* 210 */
976 M128A Xmm8; /* 220 */
977 M128A Xmm9; /* 230 */
978 M128A Xmm10; /* 240 */
979 M128A Xmm11; /* 250 */
980 M128A Xmm12; /* 260 */
981 M128A Xmm13; /* 270 */
982 M128A Xmm14; /* 280 */
983 M128A Xmm15; /* 290 */
984 } DUMMYSTRUCTNAME;
985 } DUMMYUNIONNAME;
987 /* Vector */
988 M128A VectorRegister[26]; /* 300 */
989 DWORD64 VectorControl; /* 4a0 */
991 /* Debug control */
992 DWORD64 DebugControl; /* 4a8 */
993 DWORD64 LastBranchToRip; /* 4b0 */
994 DWORD64 LastBranchFromRip; /* 4b8 */
995 DWORD64 LastExceptionToRip; /* 4c0 */
996 DWORD64 LastExceptionFromRip; /* 4c8 */
997 } CONTEXT;
999 typedef struct _RUNTIME_FUNCTION
1001 DWORD BeginAddress;
1002 DWORD EndAddress;
1003 DWORD UnwindData;
1004 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1006 #define UNWIND_HISTORY_TABLE_SIZE 12
1008 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1010 ULONG64 ImageBase;
1011 PRUNTIME_FUNCTION FunctionEntry;
1012 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1014 #define UNWIND_HISTORY_TABLE_NONE 0
1015 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1016 #define UNWIND_HISTORY_TABLE_LOCAL 2
1018 typedef struct _UNWIND_HISTORY_TABLE
1020 ULONG Count;
1021 UCHAR Search;
1022 ULONG64 LowAddress;
1023 ULONG64 HighAddress;
1024 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1025 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1027 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1029 union
1031 PM128A FloatingContext[16];
1032 struct
1034 PM128A Xmm0;
1035 PM128A Xmm1;
1036 PM128A Xmm2;
1037 PM128A Xmm3;
1038 PM128A Xmm4;
1039 PM128A Xmm5;
1040 PM128A Xmm6;
1041 PM128A Xmm7;
1042 PM128A Xmm8;
1043 PM128A Xmm9;
1044 PM128A Xmm10;
1045 PM128A Xmm11;
1046 PM128A Xmm12;
1047 PM128A Xmm13;
1048 PM128A Xmm14;
1049 PM128A Xmm15;
1050 } DUMMYSTRUCTNAME1;
1051 } DUMMYUNIONNAME1;
1053 union
1055 PULONG64 IntegerContext[16];
1056 struct
1058 PULONG64 Rax;
1059 PULONG64 Rcx;
1060 PULONG64 Rdx;
1061 PULONG64 Rbx;
1062 PULONG64 Rsp;
1063 PULONG64 Rbp;
1064 PULONG64 Rsi;
1065 PULONG64 Rdi;
1066 PULONG64 R8;
1067 PULONG64 R9;
1068 PULONG64 R10;
1069 PULONG64 R11;
1070 PULONG64 R12;
1071 PULONG64 R13;
1072 PULONG64 R14;
1073 PULONG64 R15;
1074 } DUMMYSTRUCTNAME2;
1075 } DUMMYUNIONNAME2;
1076 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1078 BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD64);
1079 BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1080 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD64,DWORD64*,UNWIND_HISTORY_TABLE*);
1081 PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1083 #define UNW_FLAG_NHANDLER 0
1084 #define UNW_FLAG_EHANDLER 1
1085 #define UNW_FLAG_UHANDLER 2
1086 #define UNW_FLAG_CHAININFO 4
1088 #endif /* __x86_64__ */
1090 /* IA64 context definitions */
1091 #ifdef __ia64__
1093 typedef struct _FRAME_POINTERS {
1094 ULONGLONG MemoryStackFp;
1095 ULONGLONG BackingStoreFp;
1096 } FRAME_POINTERS, *PFRAME_POINTERS;
1098 #define UNWIND_HISTORY_TABLE_SIZE 12
1100 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
1101 ULONG64 ImageBase;
1102 ULONG64 Gp;
1103 PRUNTIME_FUNCTION FunctionEntry;
1104 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1106 typedef struct _UNWIND_HISTORY_TABLE {
1107 ULONG Count;
1108 UCHAR Search;
1109 ULONG64 LowAddress;
1110 ULONG64 HighAddress;
1111 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1112 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1114 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1116 PFLOAT128 FltS0;
1117 PFLOAT128 FltS1;
1118 PFLOAT128 FltS2;
1119 PFLOAT128 FltS3;
1120 PFLOAT128 HighFloatingContext[10];
1121 PFLOAT128 FltS4;
1122 PFLOAT128 FltS5;
1123 PFLOAT128 FltS6;
1124 PFLOAT128 FltS7;
1125 PFLOAT128 FltS8;
1126 PFLOAT128 FltS9;
1127 PFLOAT128 FltS10;
1128 PFLOAT128 FltS11;
1129 PFLOAT128 FltS12;
1130 PFLOAT128 FltS13;
1131 PFLOAT128 FltS14;
1132 PFLOAT128 FltS15;
1133 PFLOAT128 FltS16;
1134 PFLOAT128 FltS17;
1135 PFLOAT128 FltS18;
1136 PFLOAT128 FltS19;
1137 PULONGLONG IntS0;
1138 PULONGLONG IntS1;
1139 PULONGLONG IntS2;
1140 PULONGLONG IntS3;
1141 PULONGLONG IntSp;
1142 PULONGLONG IntS0Nat;
1143 PULONGLONG IntS1Nat;
1144 PULONGLONG IntS2Nat;
1145 PULONGLONG IntS3Nat;
1146 PULONGLONG IntSpNat;
1147 PULONGLONG Preds;
1148 PULONGLONG BrRp;
1149 PULONGLONG BrS0;
1150 PULONGLONG BrS1;
1151 PULONGLONG BrS2;
1152 PULONGLONG BrS3;
1153 PULONGLONG BrS4;
1154 PULONGLONG ApUNAT;
1155 PULONGLONG ApLC;
1156 PULONGLONG ApEC;
1157 PULONGLONG RsPFS;
1158 PULONGLONG StFSR;
1159 PULONGLONG StFIR;
1160 PULONGLONG StFDR;
1161 PULONGLONG Cflag;
1162 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1164 ULONGLONG WINAPI RtlVirtualUnwind(ULONGLONG,ULONGLONG,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,FRAME_POINTERS*,KNONVOLATILE_CONTEXT_POINTERS*);
1166 #endif /* __ia64__ */
1168 /* Alpha context definitions */
1169 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1171 #define CONTEXT_ALPHA 0x00020000
1173 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
1174 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
1175 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
1176 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1178 #define EXCEPTION_READ_FAULT 0
1179 #define EXCEPTION_WRITE_FAULT 1
1180 #define EXCEPTION_EXECUTE_FAULT 8
1182 typedef struct _CONTEXT
1184 /* selected by CONTEXT_FLOATING_POINT */
1185 ULONGLONG FltF0;
1186 ULONGLONG FltF1;
1187 ULONGLONG FltF2;
1188 ULONGLONG FltF3;
1189 ULONGLONG FltF4;
1190 ULONGLONG FltF5;
1191 ULONGLONG FltF6;
1192 ULONGLONG FltF7;
1193 ULONGLONG FltF8;
1194 ULONGLONG FltF9;
1195 ULONGLONG FltF10;
1196 ULONGLONG FltF11;
1197 ULONGLONG FltF12;
1198 ULONGLONG FltF13;
1199 ULONGLONG FltF14;
1200 ULONGLONG FltF15;
1201 ULONGLONG FltF16;
1202 ULONGLONG FltF17;
1203 ULONGLONG FltF18;
1204 ULONGLONG FltF19;
1205 ULONGLONG FltF20;
1206 ULONGLONG FltF21;
1207 ULONGLONG FltF22;
1208 ULONGLONG FltF23;
1209 ULONGLONG FltF24;
1210 ULONGLONG FltF25;
1211 ULONGLONG FltF26;
1212 ULONGLONG FltF27;
1213 ULONGLONG FltF28;
1214 ULONGLONG FltF29;
1215 ULONGLONG FltF30;
1216 ULONGLONG FltF31;
1218 /* selected by CONTEXT_INTEGER */
1219 ULONGLONG IntV0;
1220 ULONGLONG IntT0;
1221 ULONGLONG IntT1;
1222 ULONGLONG IntT2;
1223 ULONGLONG IntT3;
1224 ULONGLONG IntT4;
1225 ULONGLONG IntT5;
1226 ULONGLONG IntT6;
1227 ULONGLONG IntT7;
1228 ULONGLONG IntS0;
1229 ULONGLONG IntS1;
1230 ULONGLONG IntS2;
1231 ULONGLONG IntS3;
1232 ULONGLONG IntS4;
1233 ULONGLONG IntS5;
1234 ULONGLONG IntFp;
1235 ULONGLONG IntA0;
1236 ULONGLONG IntA1;
1237 ULONGLONG IntA2;
1238 ULONGLONG IntA3;
1239 ULONGLONG IntA4;
1240 ULONGLONG IntA5;
1241 ULONGLONG IntT8;
1242 ULONGLONG IntT9;
1243 ULONGLONG IntT10;
1244 ULONGLONG IntT11;
1245 ULONGLONG IntRa;
1246 ULONGLONG IntT12;
1247 ULONGLONG IntAt;
1248 ULONGLONG IntGp;
1249 ULONGLONG IntSp;
1250 ULONGLONG IntZero;
1252 /* selected by CONTEXT_FLOATING_POINT */
1253 ULONGLONG Fpcr;
1254 ULONGLONG SoftFpcr;
1256 /* selected by CONTEXT_CONTROL */
1257 ULONGLONG Fir;
1258 DWORD Psr;
1259 DWORD ContextFlags;
1260 DWORD Fill[4];
1261 } CONTEXT;
1263 #define _QUAD_PSR_OFFSET HighSoftFpcr
1264 #define _QUAD_FLAGS_OFFSET HighFir
1266 #endif /* _ALPHA_ */
1268 #ifdef __arm__
1270 /* The following flags control the contents of the CONTEXT structure. */
1272 #define CONTEXT_ARM 0x0000040
1273 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
1274 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
1276 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1278 #define EXCEPTION_READ_FAULT 0
1279 #define EXCEPTION_WRITE_FAULT 1
1280 #define EXCEPTION_EXECUTE_FAULT 8
1282 typedef struct _CONTEXT {
1283 /* The flags values within this flag control the contents of
1284 a CONTEXT record.
1286 If the context record is used as an input parameter, then
1287 for each portion of the context record controlled by a flag
1288 whose value is set, it is assumed that that portion of the
1289 context record contains valid context. If the context record
1290 is being used to modify a thread's context, then only that
1291 portion of the threads context will be modified.
1293 If the context record is used as an IN OUT parameter to capture
1294 the context of a thread, then only those portions of the thread's
1295 context corresponding to set flags will be returned.
1297 The context record is never used as an OUT only parameter. */
1299 ULONG ContextFlags;
1301 /* This section is specified/returned if the ContextFlags word contains
1302 the flag CONTEXT_INTEGER. */
1303 ULONG R0;
1304 ULONG R1;
1305 ULONG R2;
1306 ULONG R3;
1307 ULONG R4;
1308 ULONG R5;
1309 ULONG R6;
1310 ULONG R7;
1311 ULONG R8;
1312 ULONG R9;
1313 ULONG R10;
1314 ULONG R11;
1315 ULONG R12;
1317 ULONG Sp;
1318 ULONG Lr;
1319 ULONG Pc;
1320 ULONG Psr;
1321 } CONTEXT;
1323 #endif /* __arm__ */
1326 /* Mips context definitions */
1327 #ifdef _MIPS_
1329 #define CONTEXT_R4000 0x00010000
1331 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
1332 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
1333 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
1335 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1337 #define EXCEPTION_READ_FAULT 0
1338 #define EXCEPTION_WRITE_FAULT 1
1339 #define EXCEPTION_EXECUTE_FAULT 8
1341 typedef struct _CONTEXT
1343 DWORD Argument[4];
1344 /* These are selected by CONTEXT_FLOATING_POINT */
1345 DWORD FltF0;
1346 DWORD FltF1;
1347 DWORD FltF2;
1348 DWORD FltF3;
1349 DWORD FltF4;
1350 DWORD FltF5;
1351 DWORD FltF6;
1352 DWORD FltF7;
1353 DWORD FltF8;
1354 DWORD FltF9;
1355 DWORD FltF10;
1356 DWORD FltF11;
1357 DWORD FltF12;
1358 DWORD FltF13;
1359 DWORD FltF14;
1360 DWORD FltF15;
1361 DWORD FltF16;
1362 DWORD FltF17;
1363 DWORD FltF18;
1364 DWORD FltF19;
1365 DWORD FltF20;
1366 DWORD FltF21;
1367 DWORD FltF22;
1368 DWORD FltF23;
1369 DWORD FltF24;
1370 DWORD FltF25;
1371 DWORD FltF26;
1372 DWORD FltF27;
1373 DWORD FltF28;
1374 DWORD FltF29;
1375 DWORD FltF30;
1376 DWORD FltF31;
1378 /* These are selected by CONTEXT_INTEGER */
1379 DWORD IntZero;
1380 DWORD IntAt;
1381 DWORD IntV0;
1382 DWORD IntV1;
1383 DWORD IntA0;
1384 DWORD IntA1;
1385 DWORD IntA2;
1386 DWORD IntA3;
1387 DWORD IntT0;
1388 DWORD IntT1;
1389 DWORD IntT2;
1390 DWORD IntT3;
1391 DWORD IntT4;
1392 DWORD IntT5;
1393 DWORD IntT6;
1394 DWORD IntT7;
1395 DWORD IntS0;
1396 DWORD IntS1;
1397 DWORD IntS2;
1398 DWORD IntS3;
1399 DWORD IntS4;
1400 DWORD IntS5;
1401 DWORD IntS6;
1402 DWORD IntS7;
1403 DWORD IntT8;
1404 DWORD IntT9;
1405 DWORD IntK0;
1406 DWORD IntK1;
1407 DWORD IntGp;
1408 DWORD IntSp;
1409 DWORD IntS8;
1410 DWORD IntRa;
1411 DWORD IntLo;
1412 DWORD IntHi;
1414 /* These are selected by CONTEXT_FLOATING_POINT */
1415 DWORD Fsr;
1417 /* These are selected by CONTEXT_CONTROL */
1418 DWORD Fir;
1419 DWORD Psr;
1421 DWORD ContextFlags;
1422 DWORD Fill[2];
1423 } CONTEXT;
1425 #endif /* _MIPS_ */
1427 /* PowerPC context definitions */
1428 #ifdef __powerpc__
1430 #define CONTEXT_CONTROL 0x0001
1431 #define CONTEXT_FLOATING_POINT 0x0002
1432 #define CONTEXT_INTEGER 0x0004
1433 #define CONTEXT_DEBUG_REGISTERS 0x0008
1434 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1436 #define EXCEPTION_READ_FAULT 0
1437 #define EXCEPTION_WRITE_FAULT 1
1438 #define EXCEPTION_EXECUTE_FAULT 8
1440 typedef struct
1442 /* These are selected by CONTEXT_FLOATING_POINT */
1443 double Fpr0;
1444 double Fpr1;
1445 double Fpr2;
1446 double Fpr3;
1447 double Fpr4;
1448 double Fpr5;
1449 double Fpr6;
1450 double Fpr7;
1451 double Fpr8;
1452 double Fpr9;
1453 double Fpr10;
1454 double Fpr11;
1455 double Fpr12;
1456 double Fpr13;
1457 double Fpr14;
1458 double Fpr15;
1459 double Fpr16;
1460 double Fpr17;
1461 double Fpr18;
1462 double Fpr19;
1463 double Fpr20;
1464 double Fpr21;
1465 double Fpr22;
1466 double Fpr23;
1467 double Fpr24;
1468 double Fpr25;
1469 double Fpr26;
1470 double Fpr27;
1471 double Fpr28;
1472 double Fpr29;
1473 double Fpr30;
1474 double Fpr31;
1475 double Fpscr;
1477 /* These are selected by CONTEXT_INTEGER */
1478 DWORD Gpr0;
1479 DWORD Gpr1;
1480 DWORD Gpr2;
1481 DWORD Gpr3;
1482 DWORD Gpr4;
1483 DWORD Gpr5;
1484 DWORD Gpr6;
1485 DWORD Gpr7;
1486 DWORD Gpr8;
1487 DWORD Gpr9;
1488 DWORD Gpr10;
1489 DWORD Gpr11;
1490 DWORD Gpr12;
1491 DWORD Gpr13;
1492 DWORD Gpr14;
1493 DWORD Gpr15;
1494 DWORD Gpr16;
1495 DWORD Gpr17;
1496 DWORD Gpr18;
1497 DWORD Gpr19;
1498 DWORD Gpr20;
1499 DWORD Gpr21;
1500 DWORD Gpr22;
1501 DWORD Gpr23;
1502 DWORD Gpr24;
1503 DWORD Gpr25;
1504 DWORD Gpr26;
1505 DWORD Gpr27;
1506 DWORD Gpr28;
1507 DWORD Gpr29;
1508 DWORD Gpr30;
1509 DWORD Gpr31;
1511 DWORD Cr;
1512 DWORD Xer;
1514 /* These are selected by CONTEXT_CONTROL */
1515 DWORD Msr;
1516 DWORD Iar; /* Instruction Address Register , aka PC ... */
1517 DWORD Lr;
1518 DWORD Ctr;
1520 DWORD ContextFlags;
1522 DWORD Dar; /* Fault registers for coredump */
1523 DWORD Dsisr;
1524 DWORD Trap; /* number of powerpc exception taken */
1526 /* These are selected by CONTEXT_DEBUG_REGISTERS */
1527 DWORD Dr0;
1528 DWORD Dr1;
1529 DWORD Dr2;
1530 DWORD Dr3;
1531 DWORD Dr4;
1532 DWORD Dr5;
1533 DWORD Dr6;
1534 DWORD Dr7;
1535 } CONTEXT;
1537 typedef struct _STACK_FRAME_HEADER
1539 DWORD BackChain;
1540 DWORD GlueSaved1;
1541 DWORD GlueSaved2;
1542 DWORD Reserved1;
1543 DWORD Spare1;
1544 DWORD Spare2;
1546 DWORD Parameter0;
1547 DWORD Parameter1;
1548 DWORD Parameter2;
1549 DWORD Parameter3;
1550 DWORD Parameter4;
1551 DWORD Parameter5;
1552 DWORD Parameter6;
1553 DWORD Parameter7;
1554 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
1556 #endif /* __powerpc__ */
1558 #ifdef __sparc__
1561 * FIXME:
1563 * There is no official CONTEXT structure defined for the SPARC
1564 * architecture, so I just made one up.
1566 * This structure is valid only for 32-bit SPARC architectures,
1567 * not for 64-bit SPARC.
1569 * Note that this structure contains only the 'top-level' registers;
1570 * the rest of the register window chain is not visible.
1572 * The layout follows the Solaris 'prgregset_t' structure.
1576 #define CONTEXT_SPARC 0x10000000
1578 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
1579 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
1580 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
1582 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1584 #define EXCEPTION_READ_FAULT 0
1585 #define EXCEPTION_WRITE_FAULT 1
1586 #define EXCEPTION_EXECUTE_FAULT 8
1588 typedef struct _CONTEXT
1590 DWORD ContextFlags;
1592 /* These are selected by CONTEXT_INTEGER */
1593 DWORD g0;
1594 DWORD g1;
1595 DWORD g2;
1596 DWORD g3;
1597 DWORD g4;
1598 DWORD g5;
1599 DWORD g6;
1600 DWORD g7;
1601 DWORD o0;
1602 DWORD o1;
1603 DWORD o2;
1604 DWORD o3;
1605 DWORD o4;
1606 DWORD o5;
1607 DWORD o6;
1608 DWORD o7;
1609 DWORD l0;
1610 DWORD l1;
1611 DWORD l2;
1612 DWORD l3;
1613 DWORD l4;
1614 DWORD l5;
1615 DWORD l6;
1616 DWORD l7;
1617 DWORD i0;
1618 DWORD i1;
1619 DWORD i2;
1620 DWORD i3;
1621 DWORD i4;
1622 DWORD i5;
1623 DWORD i6;
1624 DWORD i7;
1626 /* These are selected by CONTEXT_CONTROL */
1627 DWORD psr;
1628 DWORD pc;
1629 DWORD npc;
1630 DWORD y;
1631 DWORD wim;
1632 DWORD tbr;
1634 /* FIXME: floating point registers missing */
1636 } CONTEXT;
1638 #endif /* __sparc__ */
1640 #ifdef __ia64__
1642 #define CONTEXT_IA64 0x00080000
1643 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1644 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1645 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1646 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1647 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1648 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1649 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1650 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1651 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1653 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1654 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1655 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1656 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1658 typedef struct _CONTEXT
1660 DWORD ContextFlags;
1661 DWORD Fill1[3];
1662 ULONGLONG DbI0;
1663 ULONGLONG DbI1;
1664 ULONGLONG DbI2;
1665 ULONGLONG DbI3;
1666 ULONGLONG DbI4;
1667 ULONGLONG DbI5;
1668 ULONGLONG DbI6;
1669 ULONGLONG DbI7;
1670 ULONGLONG DbD0;
1671 ULONGLONG DbD1;
1672 ULONGLONG DbD2;
1673 ULONGLONG DbD3;
1674 ULONGLONG DbD4;
1675 ULONGLONG DbD5;
1676 ULONGLONG DbD6;
1677 ULONGLONG DbD7;
1678 FLOAT128 FltS0;
1679 FLOAT128 FltS1;
1680 FLOAT128 FltS2;
1681 FLOAT128 FltS3;
1682 FLOAT128 FltT0;
1683 FLOAT128 FltT1;
1684 FLOAT128 FltT2;
1685 FLOAT128 FltT3;
1686 FLOAT128 FltT4;
1687 FLOAT128 FltT5;
1688 FLOAT128 FltT6;
1689 FLOAT128 FltT7;
1690 FLOAT128 FltT8;
1691 FLOAT128 FltT9;
1692 FLOAT128 FltS4;
1693 FLOAT128 FltS5;
1694 FLOAT128 FltS6;
1695 FLOAT128 FltS7;
1696 FLOAT128 FltS8;
1697 FLOAT128 FltS9;
1698 FLOAT128 FltS10;
1699 FLOAT128 FltS11;
1700 FLOAT128 FltS12;
1701 FLOAT128 FltS13;
1702 FLOAT128 FltS14;
1703 FLOAT128 FltS15;
1704 FLOAT128 FltS16;
1705 FLOAT128 FltS17;
1706 FLOAT128 FltS18;
1707 FLOAT128 FltS19;
1708 FLOAT128 FltF32;
1709 FLOAT128 FltF33;
1710 FLOAT128 FltF34;
1711 FLOAT128 FltF35;
1712 FLOAT128 FltF36;
1713 FLOAT128 FltF37;
1714 FLOAT128 FltF38;
1715 FLOAT128 FltF39;
1716 FLOAT128 FltF40;
1717 FLOAT128 FltF41;
1718 FLOAT128 FltF42;
1719 FLOAT128 FltF43;
1720 FLOAT128 FltF44;
1721 FLOAT128 FltF45;
1722 FLOAT128 FltF46;
1723 FLOAT128 FltF47;
1724 FLOAT128 FltF48;
1725 FLOAT128 FltF49;
1726 FLOAT128 FltF50;
1727 FLOAT128 FltF51;
1728 FLOAT128 FltF52;
1729 FLOAT128 FltF53;
1730 FLOAT128 FltF54;
1731 FLOAT128 FltF55;
1732 FLOAT128 FltF56;
1733 FLOAT128 FltF57;
1734 FLOAT128 FltF58;
1735 FLOAT128 FltF59;
1736 FLOAT128 FltF60;
1737 FLOAT128 FltF61;
1738 FLOAT128 FltF62;
1739 FLOAT128 FltF63;
1740 FLOAT128 FltF64;
1741 FLOAT128 FltF65;
1742 FLOAT128 FltF66;
1743 FLOAT128 FltF67;
1744 FLOAT128 FltF68;
1745 FLOAT128 FltF69;
1746 FLOAT128 FltF70;
1747 FLOAT128 FltF71;
1748 FLOAT128 FltF72;
1749 FLOAT128 FltF73;
1750 FLOAT128 FltF74;
1751 FLOAT128 FltF75;
1752 FLOAT128 FltF76;
1753 FLOAT128 FltF77;
1754 FLOAT128 FltF78;
1755 FLOAT128 FltF79;
1756 FLOAT128 FltF80;
1757 FLOAT128 FltF81;
1758 FLOAT128 FltF82;
1759 FLOAT128 FltF83;
1760 FLOAT128 FltF84;
1761 FLOAT128 FltF85;
1762 FLOAT128 FltF86;
1763 FLOAT128 FltF87;
1764 FLOAT128 FltF88;
1765 FLOAT128 FltF89;
1766 FLOAT128 FltF90;
1767 FLOAT128 FltF91;
1768 FLOAT128 FltF92;
1769 FLOAT128 FltF93;
1770 FLOAT128 FltF94;
1771 FLOAT128 FltF95;
1772 FLOAT128 FltF96;
1773 FLOAT128 FltF97;
1774 FLOAT128 FltF98;
1775 FLOAT128 FltF99;
1776 FLOAT128 FltF100;
1777 FLOAT128 FltF101;
1778 FLOAT128 FltF102;
1779 FLOAT128 FltF103;
1780 FLOAT128 FltF104;
1781 FLOAT128 FltF105;
1782 FLOAT128 FltF106;
1783 FLOAT128 FltF107;
1784 FLOAT128 FltF108;
1785 FLOAT128 FltF109;
1786 FLOAT128 FltF110;
1787 FLOAT128 FltF111;
1788 FLOAT128 FltF112;
1789 FLOAT128 FltF113;
1790 FLOAT128 FltF114;
1791 FLOAT128 FltF115;
1792 FLOAT128 FltF116;
1793 FLOAT128 FltF117;
1794 FLOAT128 FltF118;
1795 FLOAT128 FltF119;
1796 FLOAT128 FltF120;
1797 FLOAT128 FltF121;
1798 FLOAT128 FltF122;
1799 FLOAT128 FltF123;
1800 FLOAT128 FltF124;
1801 FLOAT128 FltF125;
1802 FLOAT128 FltF126;
1803 FLOAT128 FltF127;
1804 ULONGLONG StFPSR;
1805 ULONGLONG IntGp;
1806 ULONGLONG IntT0;
1807 ULONGLONG IntT1;
1808 ULONGLONG IntS0;
1809 ULONGLONG IntS1;
1810 ULONGLONG IntS2;
1811 ULONGLONG IntS3;
1812 ULONGLONG IntV0;
1813 ULONGLONG IntT2;
1814 ULONGLONG IntT3;
1815 ULONGLONG IntT4;
1816 ULONGLONG IntSp;
1817 ULONGLONG IntTeb;
1818 ULONGLONG IntT5;
1819 ULONGLONG IntT6;
1820 ULONGLONG IntT7;
1821 ULONGLONG IntT8;
1822 ULONGLONG IntT9;
1823 ULONGLONG IntT10;
1824 ULONGLONG IntT11;
1825 ULONGLONG IntT12;
1826 ULONGLONG IntT13;
1827 ULONGLONG IntT14;
1828 ULONGLONG IntT15;
1829 ULONGLONG IntT16;
1830 ULONGLONG IntT17;
1831 ULONGLONG IntT18;
1832 ULONGLONG IntT19;
1833 ULONGLONG IntT20;
1834 ULONGLONG IntT21;
1835 ULONGLONG IntT22;
1836 ULONGLONG IntNats;
1837 ULONGLONG Preds;
1838 ULONGLONG BrRp;
1839 ULONGLONG BrS0;
1840 ULONGLONG BrS1;
1841 ULONGLONG BrS2;
1842 ULONGLONG BrS3;
1843 ULONGLONG BrS4;
1844 ULONGLONG BrT0;
1845 ULONGLONG BrT1;
1846 ULONGLONG ApUNAT;
1847 ULONGLONG ApLC;
1848 ULONGLONG ApEC;
1849 ULONGLONG ApCCV;
1850 ULONGLONG ApDCR;
1851 ULONGLONG RsPFS;
1852 ULONGLONG RsBSP;
1853 ULONGLONG RsBSPSTORE;
1854 ULONGLONG RsRSC;
1855 ULONGLONG RsRNAT;
1856 ULONGLONG StIPSR;
1857 ULONGLONG StIIP;
1858 ULONGLONG StIFS;
1859 ULONGLONG StFCR;
1860 ULONGLONG Eflag;
1861 ULONGLONG SegCSD;
1862 ULONGLONG SegSSD;
1863 ULONGLONG Cflag;
1864 ULONGLONG StFSR;
1865 ULONGLONG StFIR;
1866 ULONGLONG StFDR;
1867 ULONGLONG UNUSEDPACK;
1868 } CONTEXT, *PCONTEXT;
1870 typedef struct _RUNTIME_FUNCTION
1872 ULONG BeginAddress;
1873 ULONG EndAddress;
1874 ULONG UnwindInfoAddress;
1875 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1877 #endif /* __ia64__ */
1879 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
1880 #error You need to define a CONTEXT for your CPU
1881 #endif
1883 typedef CONTEXT *PCONTEXT;
1885 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
1888 * Product types
1890 #define PRODUCT_UNLICENSED 0xABCDABCD
1891 #define PRODUCT_BUSINESS 0x00000006
1892 #define PRODUCT_BUSINESS_N 0x00000010
1893 #define PRODUCT_CLUSTER_SERVER 0x00000012
1894 #define PRODUCT_DATACENTER_SERVER 0x00000008
1895 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
1896 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
1897 #define PRODUCT_SERVER_V 0x00000025
1898 #define PRODUCT_ENTERPRISE 0x00000004
1899 #define PRODUCT_ENTERPRISE_N 0x0000001B
1900 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
1901 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
1902 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
1903 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
1904 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
1905 #define PRODUCT_HOME_BASIC 0x00000002
1906 #define PRODUCT_HOME_BASIC_N 0x00000005
1907 #define PRODUCT_HOME_PREMIUM 0x00000003
1908 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
1909 #define PRODUCT_HYPERV 0x0000002A
1910 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
1911 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
1912 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
1913 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
1914 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
1915 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
1916 #define PRODUCT_STANDARD_SERVER 0x00000007
1917 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
1918 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
1919 #define PRODUCT_STANDARD_SERVER_V 0x00000024
1920 #define PRODUCT_STARTER 0x0000000B
1921 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
1922 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
1923 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
1924 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
1925 #define PRODUCT_UNDEFINED 0x00000000
1926 #define PRODUCT_ULTIMATE 0x00000001
1927 #define PRODUCT_ULTIMATE_N 0x0000001C
1928 #define PRODUCT_WEB_SERVER 0x00000011
1929 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
1933 * Language IDs
1936 #define MAKELCID(l, s) (MAKELONG(l, s))
1938 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
1939 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
1940 #define SUBLANGID(l) ((WORD)(l) >> 10)
1942 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
1943 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
1945 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
1946 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
1947 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
1948 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
1949 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
1951 #define UNREFERENCED_PARAMETER(u) (void)(u)
1952 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
1953 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
1955 #define LANG_NEUTRAL 0x00
1956 #define LANG_INVARIANT 0x7f
1958 #define LANG_AFRIKAANS 0x36
1959 #define LANG_ALBANIAN 0x1c
1960 #define LANG_ALSATIAN 0x84
1961 #define LANG_AMHARIC 0x5e
1962 #define LANG_ARABIC 0x01
1963 #define LANG_ARMENIAN 0x2b
1964 #define LANG_ASSAMESE 0x4d
1965 #define LANG_AZERI 0x2c
1966 #define LANG_BASHKIR 0x6d
1967 #define LANG_BASQUE 0x2d
1968 #define LANG_BELARUSIAN 0x23
1969 #define LANG_BENGALI 0x45
1970 #define LANG_BOSNIAN 0x1a
1971 #define LANG_BOSNIAN_NEUTRAL 0x781a
1972 #define LANG_BRETON 0x7e
1973 #define LANG_BULGARIAN 0x02
1974 #define LANG_CATALAN 0x03
1975 #define LANG_CHINESE 0x04
1976 #define LANG_CHINESE_SIMPLIFIED 0x0004
1977 #define LANG_CHINESE_TRADITIONAL 0x7c04
1978 #define LANG_CORSICAN 0x83
1979 #define LANG_CROATIAN 0x1a
1980 #define LANG_CZECH 0x05
1981 #define LANG_DANISH 0x06
1982 #define LANG_DARI 0x8c
1983 #define LANG_DIVEHI 0x65
1984 #define LANG_DUTCH 0x13
1985 #define LANG_ENGLISH 0x09
1986 #define LANG_ESTONIAN 0x25
1987 #define LANG_FAEROESE 0x38
1988 #define LANG_FARSI LANG_PERSIAN
1989 #define LANG_FILIPINO 0x64
1990 #define LANG_FINNISH 0x0b
1991 #define LANG_FRENCH 0x0c
1992 #define LANG_FRISIAN 0x62
1993 #define LANG_GALICIAN 0x56
1994 #define LANG_GEORGIAN 0x37
1995 #define LANG_GERMAN 0x07
1996 #define LANG_GREEK 0x08
1997 #define LANG_GREENLANDIC 0x6f
1998 #define LANG_GUJARATI 0x47
1999 #define LANG_HAUSA 0x68
2000 #define LANG_HEBREW 0x0d
2001 #define LANG_HINDI 0x39
2002 #define LANG_HUNGARIAN 0x0e
2003 #define LANG_ICELANDIC 0x0f
2004 #define LANG_IGBO 0x70
2005 #define LANG_INDONESIAN 0x21
2006 #define LANG_INUKTITUT 0x5d
2007 #define LANG_IRISH 0x3c
2008 #define LANG_ITALIAN 0x10
2009 #define LANG_JAPANESE 0x11
2010 #define LANG_KANNADA 0x4b
2011 #define LANG_KASHMIRI 0x60
2012 #define LANG_KAZAK 0x3f
2013 #define LANG_KHMER 0x53
2014 #define LANG_KICHE 0x86
2015 #define LANG_KINYARWANDA 0x87
2016 #define LANG_KONKANI 0x57
2017 #define LANG_KOREAN 0x12
2018 #define LANG_KYRGYZ 0x40
2019 #define LANG_LAO 0x54
2020 #define LANG_LATVIAN 0x26
2021 #define LANG_LITHUANIAN 0x27
2022 #define LANG_LOWER_SORBIAN 0x2e
2023 #define LANG_LUXEMBOURGISH 0x6e
2024 #define LANG_MACEDONIAN 0x2f
2025 #define LANG_MALAY 0x3e
2026 #define LANG_MALAYALAM 0x4c
2027 #define LANG_MALTESE 0x3a
2028 #define LANG_MANIPURI 0x58
2029 #define LANG_MAORI 0x81
2030 #define LANG_MAPUDUNGUN 0x7a
2031 #define LANG_MARATHI 0x4e
2032 #define LANG_MOHAWK 0x7c
2033 #define LANG_MONGOLIAN 0x50
2034 #define LANG_NEPALI 0x61
2035 #define LANG_NORWEGIAN 0x14
2036 #define LANG_OCCITAN 0x82
2037 #define LANG_ORIYA 0x48
2038 #define LANG_PASHTO 0x63
2039 #define LANG_PERSIAN 0x29
2040 #define LANG_POLISH 0x15
2041 #define LANG_PORTUGUESE 0x16
2042 #define LANG_PUNJABI 0x46
2043 #define LANG_QUECHUA 0x6b
2044 #define LANG_ROMANIAN 0x18
2045 #define LANG_ROMANSH 0x17
2046 #define LANG_RUSSIAN 0x19
2047 #define LANG_SAMI 0x3b
2048 #define LANG_SANSKRIT 0x4f
2049 #define LANG_SERBIAN 0x1a
2050 #define LANG_SERBIAN_NEUTRAL 0x7c1a
2051 #define LANG_SINDHI 0x59
2052 #define LANG_SINHALESE 0x5b
2053 #define LANG_SLOVAK 0x1b
2054 #define LANG_SLOVENIAN 0x24
2055 #define LANG_SOTHO 0x6c
2056 #define LANG_SPANISH 0x0a
2057 #define LANG_SWAHILI 0x41
2058 #define LANG_SWEDISH 0x1d
2059 #define LANG_SYRIAC 0x5a
2060 #define LANG_TAJIK 0x28
2061 #define LANG_TAMAZIGHT 0x5f
2062 #define LANG_TAMIL 0x49
2063 #define LANG_TATAR 0x44
2064 #define LANG_TELUGU 0x4a
2065 #define LANG_THAI 0x1e
2066 #define LANG_TIBETAN 0x51
2067 #define LANG_TIGRIGNA 0x73
2068 #define LANG_TSWANA 0x32
2069 #define LANG_TURKISH 0x1f
2070 #define LANG_TURKMEN 0x42
2071 #define LANG_UIGHUR 0x80
2072 #define LANG_UKRAINIAN 0x22
2073 #define LANG_UPPER_SORBIAN 0x2e
2074 #define LANG_URDU 0x20
2075 #define LANG_UZBEK 0x43
2076 #define LANG_VIETNAMESE 0x2a
2077 #define LANG_WELSH 0x52
2078 #define LANG_WOLOF 0x88
2079 #define LANG_XHOSA 0x34
2080 #define LANG_YAKUT 0x85
2081 #define LANG_YI 0x78
2082 #define LANG_YORUBA 0x6a
2083 #define LANG_ZULU 0x35
2085 /* These are documented by the MSDN but are missing from the Windows header */
2086 #define LANG_MALAGASY 0x8d
2088 /* FIXME: these are not defined anywhere */
2089 #define LANG_SUTU 0x30
2090 #define LANG_TSONGA 0x31
2091 #define LANG_VENDA 0x33
2093 /* non standard; keep the number high enough (but < 0xff) */
2094 #define LANG_ESPERANTO 0x8f
2095 #define LANG_WALON 0x90
2096 #define LANG_CORNISH 0x91
2097 #define LANG_GAELIC 0x94
2099 /* Sublanguage definitions */
2100 #define SUBLANG_NEUTRAL 0x00 /* language neutral */
2101 #define SUBLANG_DEFAULT 0x01 /* user default */
2102 #define SUBLANG_SYS_DEFAULT 0x02 /* system default */
2103 #define SUBLANG_CUSTOM_DEFAULT 0x03
2104 #define SUBLANG_CUSTOM_UNSPECIFIED 0x04
2105 #define SUBLANG_UI_CUSTOM_DEFAULT 0x05
2107 #define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01
2108 #define SUBLANG_ALBANIAN_ALBANIA 0x01
2109 #define SUBLANG_ALSATIAN_FRANCE 0x01
2110 #define SUBLANG_AMHARIC_ETHIOPIA 0x01
2111 #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
2112 #define SUBLANG_ARABIC_IRAQ 0x02
2113 #define SUBLANG_ARABIC_EGYPT 0x03
2114 #define SUBLANG_ARABIC_LIBYA 0x04
2115 #define SUBLANG_ARABIC_ALGERIA 0x05
2116 #define SUBLANG_ARABIC_MOROCCO 0x06
2117 #define SUBLANG_ARABIC_TUNISIA 0x07
2118 #define SUBLANG_ARABIC_OMAN 0x08
2119 #define SUBLANG_ARABIC_YEMEN 0x09
2120 #define SUBLANG_ARABIC_SYRIA 0x0a
2121 #define SUBLANG_ARABIC_JORDAN 0x0b
2122 #define SUBLANG_ARABIC_LEBANON 0x0c
2123 #define SUBLANG_ARABIC_KUWAIT 0x0d
2124 #define SUBLANG_ARABIC_UAE 0x0e
2125 #define SUBLANG_ARABIC_BAHRAIN 0x0f
2126 #define SUBLANG_ARABIC_QATAR 0x10
2127 #define SUBLANG_ARMENIAN_ARMENIA 0x01
2128 #define SUBLANG_ASSAMESE_INDIA 0x01
2129 #define SUBLANG_AZERI_LATIN 0x01
2130 #define SUBLANG_AZERI_CYRILLIC 0x02
2131 #define SUBLANG_BASHKIR_RUSSIA 0x01
2132 #define SUBLANG_BASQUE_BASQUE 0x01
2133 #define SUBLANG_BELARUSIAN_BELARUS 0x01
2134 #define SUBLANG_BENGALI_INDIA 0x01
2135 #define SUBLANG_BENGALI_BANGLADESH 0x02
2136 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
2137 #define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
2138 #define SUBLANG_BRETON_FRANCE 0x01
2139 #define SUBLANG_BULGARIAN_BULGARIA 0x01
2140 #define SUBLANG_CATALAN_CATALAN 0x01
2141 #define SUBLANG_CHINESE_TRADITIONAL 0x01
2142 #define SUBLANG_CHINESE_SIMPLIFIED 0x02
2143 #define SUBLANG_CHINESE_HONGKONG 0x03
2144 #define SUBLANG_CHINESE_SINGAPORE 0x04
2145 #define SUBLANG_CHINESE_MACAU 0x05
2146 #define SUBLANG_CORSICAN_FRANCE 0x01
2147 #define SUBLANG_CROATIAN_CROATIA 0x01
2148 #define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
2149 #define SUBLANG_CZECH_CZECH_REPUBLIC 0x01
2150 #define SUBLANG_DANISH_DENMARK 0x01
2151 #define SUBLANG_DARI_AFGHANISTAN 0x01
2152 #define SUBLANG_DIVEHI_MALDIVES 0x01
2153 #define SUBLANG_DUTCH 0x01
2154 #define SUBLANG_DUTCH_BELGIAN 0x02
2155 #define SUBLANG_ENGLISH_US 0x01
2156 #define SUBLANG_ENGLISH_UK 0x02
2157 #define SUBLANG_ENGLISH_AUS 0x03
2158 #define SUBLANG_ENGLISH_CAN 0x04
2159 #define SUBLANG_ENGLISH_NZ 0x05
2160 #define SUBLANG_ENGLISH_EIRE 0x06
2161 #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
2162 #define SUBLANG_ENGLISH_JAMAICA 0x08
2163 #define SUBLANG_ENGLISH_CARIBBEAN 0x09
2164 #define SUBLANG_ENGLISH_BELIZE 0x0a
2165 #define SUBLANG_ENGLISH_TRINIDAD 0x0b
2166 #define SUBLANG_ENGLISH_ZIMBABWE 0x0c
2167 #define SUBLANG_ENGLISH_PHILIPPINES 0x0d
2168 #define SUBLANG_ENGLISH_INDIA 0x10
2169 #define SUBLANG_ENGLISH_MALAYSIA 0x11
2170 #define SUBLANG_ENGLISH_SINGAPORE 0x12
2171 #define SUBLANG_ESTONIAN_ESTONIA 0x01
2172 #define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01
2173 #define SUBLANG_FILIPINO_PHILIPPINES 0x01
2174 #define SUBLANG_FINNISH_FINLAND 0x01
2175 #define SUBLANG_FRENCH 0x01
2176 #define SUBLANG_FRENCH_BELGIAN 0x02
2177 #define SUBLANG_FRENCH_CANADIAN 0x03
2178 #define SUBLANG_FRENCH_SWISS 0x04
2179 #define SUBLANG_FRENCH_LUXEMBOURG 0x05
2180 #define SUBLANG_FRENCH_MONACO 0x06
2181 #define SUBLANG_FRISIAN_NETHERLANDS 0x01
2182 #define SUBLANG_GALICIAN_GALICIAN 0x01
2183 #define SUBLANG_GEORGIAN_GEORGIA 0x01
2184 #define SUBLANG_GERMAN 0x01
2185 #define SUBLANG_GERMAN_SWISS 0x02
2186 #define SUBLANG_GERMAN_AUSTRIAN 0x03
2187 #define SUBLANG_GERMAN_LUXEMBOURG 0x04
2188 #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
2189 #define SUBLANG_GREEK_GREECE 0x01
2190 #define SUBLANG_GREENLANDIC_GREENLAND 0x01
2191 #define SUBLANG_GUJARATI_INDIA 0x01
2192 #define SUBLANG_HAUSA_NIGERIA_LATIN 0x01
2193 #define SUBLANG_HEBREW_ISRAEL 0x01
2194 #define SUBLANG_HINDI_INDIA 0x01
2195 #define SUBLANG_HUNGARIAN_HUNGARY 0x01
2196 #define SUBLANG_ICELANDIC_ICELAND 0x01
2197 #define SUBLANG_IGBO_NIGERIA 0x01
2198 #define SUBLANG_INDONESIAN_INDONESIA 0x01
2199 #define SUBLANG_INUKTITUT_CANADA 0x01
2200 #define SUBLANG_INUKTITUT_CANADA_LATIN 0x02
2201 #define SUBLANG_IRISH_IRELAND 0x02
2202 #define SUBLANG_ITALIAN 0x01
2203 #define SUBLANG_ITALIAN_SWISS 0x02
2204 #define SUBLANG_JAPANESE_JAPAN 0x01
2205 #define SUBLANG_KANNADA_INDIA 0x01
2206 #define SUBLANG_KASHMIRI_SASIA 0x02
2207 #define SUBLANG_KASHMIRI_INDIA 0x02
2208 #define SUBLANG_KAZAK_KAZAKHSTAN 0x01
2209 #define SUBLANG_KHMER_CAMBODIA 0x01
2210 #define SUBLANG_KICHE_GUATEMALA 0x01
2211 #define SUBLANG_KINYARWANDA_RWANDA 0X01
2212 #define SUBLANG_KONKANI_INDIA 0x01
2213 #define SUBLANG_KOREAN 0x01
2214 #define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01
2215 #define SUBLANG_LAO_LAO 0x01
2216 #define SUBLANG_LATVIAN_LATVIA 0x01
2217 #define SUBLANG_LITHUANIAN_LITHUANIA 0x01
2218 #define SUBLANG_LOWER_SORBIAN_GERMANY 0x02
2219 #define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01
2220 #define SUBLANG_MACEDONIAN_MACEDONIA 0x01
2221 #define SUBLANG_MALAY_MALAYSIA 0x01
2222 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
2223 #define SUBLANG_MALAYALAM_INDIA 0x01
2224 #define SUBLANG_MALTESE_MALTA 0x01
2225 #define SUBLANG_MAORI_NEW_ZEALAND 0x01
2226 #define SUBLANG_MAPUDUNGUN_CHILE 0x01
2227 #define SUBLANG_MARATHI_INDIA 0x01
2228 #define SUBLANG_MOHAWK_MOHAWK 0x01
2229 #define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01
2230 #define SUBLANG_MONGOLIAN_PRC 0x02
2231 #define SUBLANG_NEPALI_INDIA 0x02
2232 #define SUBLANG_NEPALI_NEPAL 0x01
2233 #define SUBLANG_NORWEGIAN_BOKMAL 0x01
2234 #define SUBLANG_NORWEGIAN_NYNORSK 0x02
2235 #define SUBLANG_OCCITAN_FRANCE 0x01
2236 #define SUBLANG_ORIYA_INDIA 0x01
2237 #define SUBLANG_PASHTO_AFGHANISTAN 0x01
2238 #define SUBLANG_PERSIAN_IRAN 0x01
2239 #define SUBLANG_POLISH_POLAND 0x01
2240 #define SUBLANG_PORTUGUESE 0x02
2241 #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
2242 #define SUBLANG_PUNJABI_INDIA 0x01
2243 #define SUBLANG_QUECHUA_BOLIVIA 0x01
2244 #define SUBLANG_QUECHUA_ECUADOR 0x02
2245 #define SUBLANG_QUECHUA_PERU 0x03
2246 #define SUBLANG_ROMANIAN_ROMANIA 0x01
2247 #define SUBLANG_ROMANSH_SWITZERLAND 0x01
2248 #define SUBLANG_RUSSIAN_RUSSIA 0x01
2249 #define SUBLANG_SAMI_NORTHERN_NORWAY 0x01
2250 #define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02
2251 #define SUBLANG_SAMI_NORTHERN_FINLAND 0x03
2252 #define SUBLANG_SAMI_LULE_NORWAY 0x04
2253 #define SUBLANG_SAMI_LULE_SWEDEN 0x05
2254 #define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06
2255 #define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07
2256 #define SUBLANG_SAMI_SKOLT_FINLAND 0x08
2257 #define SUBLANG_SAMI_INARI_FINLAND 0x09
2258 #define SUBLANG_SANSKRIT_INDIA 0x01
2259 #define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN 0x06
2260 #define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x07
2261 #define SUBLANG_SERBIAN_CROATIA 0x01
2262 #define SUBLANG_SERBIAN_LATIN 0x02
2263 #define SUBLANG_SERBIAN_CYRILLIC 0x03
2264 #define SUBLANG_SINDHI_AFGHANISTAN 0x02
2265 #define SUBLANG_SINHALESE_SRI_LANKA 0x01
2266 #define SUBLANG_SLOVAK_SLOVAKIA 0x01
2267 #define SUBLANG_SLOVENIAN_SLOVENIA 0x01
2268 #define SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA 0x01
2269 #define SUBLANG_SPANISH 0x01
2270 #define SUBLANG_SPANISH_MEXICAN 0x02
2271 #define SUBLANG_SPANISH_MODERN 0x03
2272 #define SUBLANG_SPANISH_GUATEMALA 0x04
2273 #define SUBLANG_SPANISH_COSTA_RICA 0x05
2274 #define SUBLANG_SPANISH_PANAMA 0x06
2275 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
2276 #define SUBLANG_SPANISH_VENEZUELA 0x08
2277 #define SUBLANG_SPANISH_COLOMBIA 0x09
2278 #define SUBLANG_SPANISH_PERU 0x0a
2279 #define SUBLANG_SPANISH_ARGENTINA 0x0b
2280 #define SUBLANG_SPANISH_ECUADOR 0x0c
2281 #define SUBLANG_SPANISH_CHILE 0x0d
2282 #define SUBLANG_SPANISH_URUGUAY 0x0e
2283 #define SUBLANG_SPANISH_PARAGUAY 0x0f
2284 #define SUBLANG_SPANISH_BOLIVIA 0x10
2285 #define SUBLANG_SPANISH_EL_SALVADOR 0x11
2286 #define SUBLANG_SPANISH_HONDURAS 0x12
2287 #define SUBLANG_SPANISH_NICARAGUA 0x13
2288 #define SUBLANG_SPANISH_PUERTO_RICO 0x14
2289 #define SUBLANG_SPANISH_US 0x15
2290 #define SUBLANG_SWAHILI_KENYA 0x01
2291 #define SUBLANG_SWEDISH 0x01
2292 #define SUBLANG_SWEDISH_FINLAND 0x02
2293 #define SUBLANG_SYRIAC_SYRIA 0x01
2294 #define SUBLANG_TAJIK_TAJIKISTAN 0x01
2295 #define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02
2296 #define SUBLANG_TAMIL_INDIA 0x01
2297 #define SUBLANG_TATAR_RUSSIA 0x01
2298 #define SUBLANG_TELUGU_INDIA 0x01
2299 #define SUBLANG_THAI_THAILAND 0x01
2300 #define SUBLANG_TIBETAN_PRC 0x01
2301 #define SUBLANG_TIBETAN_BHUTAN 0x02
2302 #define SUBLANG_TIGRIGNA_ERITREA 0x02
2303 #define SUBLANG_TSWANA_SOUTH_AFRICA 0x01
2304 #define SUBLANG_TURKISH_TURKEY 0x01
2305 #define SUBLANG_TURKMEN_TURKMENISTAN 0x01
2306 #define SUBLANG_UIGHUR_PRC 0x01
2307 #define SUBLANG_UKRAINIAN_UKRAINE 0x01
2308 #define SUBLANG_UPPER_SORBIAN_GERMANY 0x01
2309 #define SUBLANG_URDU_PAKISTAN 0x01
2310 #define SUBLANG_URDU_INDIA 0x02
2311 #define SUBLANG_UZBEK_LATIN 0x01
2312 #define SUBLANG_UZBEK_CYRILLIC 0x02
2313 #define SUBLANG_VIETNAMESE_VIETNAM 0x01
2314 #define SUBLANG_WELSH_UNITED_KINGDOM 0x01
2315 #define SUBLANG_WOLOF_SENEGAL 0x01
2316 #define SUBLANG_XHOSA_SOUTH_AFRICA 0x01
2317 #define SUBLANG_YAKUT_RUSSIA 0x01
2318 #define SUBLANG_YI_PRC 0x01
2319 #define SUBLANG_YORUBA_NIGERIA 0x01
2320 #define SUBLANG_ZULU_SOUTH_AFRICA 0x01
2322 /* These are documented by the MSDN but are missing from the Windows header */
2323 #define SUBLANG_ENGLISH_IRELAND SUBLANG_ENGLISH_EIRE
2324 #define SUBLANG_HAUSA_NIGERIA SUBLANG_HAUSA_NIGERIA_LATIN
2325 #define SUBLANG_LAO_LAO_PDR SUBLANG_LAO_LAO
2326 #define SUBLANG_LITHUANIAN SUBLANG_LITHUANIAN_LITHUANIA
2327 #define SUBLANG_PORTUGUESE_PORTUGAL SUBLANG_PORTUGUESE
2328 #define SUBLANG_SWAHILI SUBLANG_SWAHILI_KENYA
2329 #define SUBLANG_SWEDISH_SWEDEN SUBLANG_SWEDISH
2330 #define SUBLANG_SYRIAC SUBLANG_SYRIAC_SYRIA
2332 /* FIXME: these are not defined anywhere */
2333 #define SUBLANG_DUTCH_SURINAM 0x03
2334 #define SUBLANG_ROMANIAN SUBLANG_ROMANIAN_ROMANIA
2335 #define SUBLANG_ROMANIAN_MOLDAVIA 0x02
2336 #define SUBLANG_RUSSIAN SUBLANG_RUSSIAN_RUSSIA
2337 #define SUBLANG_RUSSIAN_MOLDAVIA 0x02
2338 #define SUBLANG_CROATIAN SUBLANG_CROATIAN_CROATIA
2339 #define SUBLANG_LITHUANIAN_CLASSIC 0x02
2340 #define SUBLANG_GAELIC 0x01
2341 #define SUBLANG_GAELIC_SCOTTISH 0x02
2342 #define SUBLANG_GAELIC_MANX 0x03
2346 * Sort definitions
2349 #define SORT_DEFAULT 0x0
2350 #define SORT_JAPANESE_XJIS 0x0
2351 #define SORT_JAPANESE_UNICODE 0x1
2352 #define SORT_CHINESE_BIG5 0x0
2353 #define SORT_CHINESE_UNICODE 0x1
2354 #define SORT_KOREAN_KSC 0x0
2355 #define SORT_KOREAN_UNICODE 0x1
2360 * Definitions for IsTextUnicode()
2363 #define IS_TEXT_UNICODE_ASCII16 0x0001
2364 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2365 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2366 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2367 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2368 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2369 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2370 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2371 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2372 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2373 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2374 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2375 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2376 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2377 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2378 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2380 #define MAXIMUM_WAIT_OBJECTS 64
2381 #define MAXIMUM_SUSPEND_COUNT 127
2383 #define WT_EXECUTEDEFAULT 0x00
2384 #define WT_EXECUTEINIOTHREAD 0x01
2385 #define WT_EXECUTEINUITHREAD 0x02
2386 #define WT_EXECUTEINWAITTHREAD 0x04
2387 #define WT_EXECUTEONLYONCE 0x08
2388 #define WT_EXECUTELONGFUNCTION 0x10
2389 #define WT_EXECUTEINTIMERTHREAD 0x20
2390 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2391 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2392 #define WT_EXECUTEINLONGTHREAD 0x10
2393 #define WT_EXECUTEDELETEWAIT 0x08
2394 #define WT_TRANSFER_IMPERSONATION 0x0100
2397 #define EXCEPTION_CONTINUABLE 0
2398 #define EXCEPTION_NONCONTINUABLE 0x01
2401 * The exception record used by Win32 to give additional information
2402 * about exception to exception handlers.
2405 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2407 typedef struct _EXCEPTION_RECORD
2409 DWORD ExceptionCode;
2410 DWORD ExceptionFlags;
2411 struct _EXCEPTION_RECORD *ExceptionRecord;
2413 PVOID ExceptionAddress;
2414 DWORD NumberParameters;
2415 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2416 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2419 * The exception pointers structure passed to exception filters
2420 * in except() and the UnhandledExceptionFilter().
2423 typedef struct _EXCEPTION_POINTERS
2425 PEXCEPTION_RECORD ExceptionRecord;
2426 PCONTEXT ContextRecord;
2427 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2431 * The exception frame, used for registering exception handlers
2432 * Win32 cares only about this, but compilers generally emit
2433 * larger exception frames for their own use.
2436 struct _EXCEPTION_REGISTRATION_RECORD;
2438 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2439 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2441 typedef struct _EXCEPTION_REGISTRATION_RECORD
2443 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2444 PEXCEPTION_HANDLER Handler;
2445 } EXCEPTION_REGISTRATION_RECORD;
2448 * function pointer to an exception filter
2451 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2453 typedef struct _NT_TIB
2455 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2456 PVOID StackBase;
2457 PVOID StackLimit;
2458 PVOID SubSystemTib;
2459 union {
2460 PVOID FiberData;
2461 DWORD Version;
2462 } DUMMYUNIONNAME;
2463 PVOID ArbitraryUserPointer;
2464 struct _NT_TIB *Self;
2465 } NT_TIB, *PNT_TIB;
2467 struct _TEB;
2469 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2470 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2472 struct _TEB *teb;
2473 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2474 return teb;
2476 #elif defined(__i386__) && defined(_MSC_VER)
2477 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2479 struct _TEB *teb;
2480 __asm mov eax, fs:[0x18];
2481 __asm mov teb, eax;
2482 return teb;
2484 #elif defined(__x86_64__) && defined(__GNUC__)
2485 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2487 struct _TEB *teb;
2488 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2489 return teb;
2491 #elif defined(__x86_64__) && defined (_MSC_VER)
2492 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2494 struct _TEB *teb;
2495 __asm mov rax, gs:[0x30];
2496 __asm mov teb, rax;
2497 return teb;
2499 #else
2500 extern struct _TEB * WINAPI NtCurrentTeb(void);
2501 #endif
2503 #ifdef NONAMELESSUNION
2504 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2505 #else
2506 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2507 #endif
2508 #define GetFiberData() (*(void **)GetCurrentFiber())
2510 #define TLS_MINIMUM_AVAILABLE 64
2513 * File formats definitions
2516 #include <pshpack2.h>
2517 typedef struct _IMAGE_DOS_HEADER {
2518 WORD e_magic; /* 00: MZ Header signature */
2519 WORD e_cblp; /* 02: Bytes on last page of file */
2520 WORD e_cp; /* 04: Pages in file */
2521 WORD e_crlc; /* 06: Relocations */
2522 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2523 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2524 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2525 WORD e_ss; /* 0e: Initial (relative) SS value */
2526 WORD e_sp; /* 10: Initial SP value */
2527 WORD e_csum; /* 12: Checksum */
2528 WORD e_ip; /* 14: Initial IP value */
2529 WORD e_cs; /* 16: Initial (relative) CS value */
2530 WORD e_lfarlc; /* 18: File address of relocation table */
2531 WORD e_ovno; /* 1a: Overlay number */
2532 WORD e_res[4]; /* 1c: Reserved words */
2533 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2534 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2535 WORD e_res2[10]; /* 28: Reserved words */
2536 DWORD e_lfanew; /* 3c: Offset to extended header */
2537 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2538 #include <poppack.h>
2540 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2541 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2542 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2543 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2544 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2545 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2548 * This is the Windows executable (NE) header.
2549 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2551 #include <pshpack2.h>
2552 typedef struct
2554 WORD ne_magic; /* 00 NE signature 'NE' */
2555 BYTE ne_ver; /* 02 Linker version number */
2556 BYTE ne_rev; /* 03 Linker revision number */
2557 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2558 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2559 LONG ne_crc; /* 08 Checksum */
2560 WORD ne_flags; /* 0c Flags about segments in this file */
2561 WORD ne_autodata; /* 0e Automatic data segment number */
2562 WORD ne_heap; /* 10 Initial size of local heap */
2563 WORD ne_stack; /* 12 Initial size of stack */
2564 DWORD ne_csip; /* 14 Initial CS:IP */
2565 DWORD ne_sssp; /* 18 Initial SS:SP */
2566 WORD ne_cseg; /* 1c # of entries in segment table */
2567 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2568 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2569 WORD ne_segtab; /* 22 Offset to segment table */
2570 WORD ne_rsrctab; /* 24 Offset to resource table */
2571 WORD ne_restab; /* 26 Offset to resident-name table */
2572 WORD ne_modtab; /* 28 Offset to module reference table */
2573 WORD ne_imptab; /* 2a Offset to imported name table */
2574 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2575 WORD ne_cmovent; /* 30 # of movable entry points */
2576 WORD ne_align; /* 32 Logical sector alignment shift count */
2577 WORD ne_cres; /* 34 # of resource segments */
2578 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2579 BYTE ne_flagsothers; /* 37 Additional information flags */
2580 WORD ne_pretthunks; /* 38 Offset to return thunks */
2581 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2582 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2583 WORD ne_expver; /* 3e Expected Windows version number */
2584 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2585 #include <poppack.h>
2587 #include <pshpack2.h>
2588 typedef struct _IMAGE_VXD_HEADER {
2589 WORD e32_magic;
2590 BYTE e32_border;
2591 BYTE e32_worder;
2592 DWORD e32_level;
2593 WORD e32_cpu;
2594 WORD e32_os;
2595 DWORD e32_ver;
2596 DWORD e32_mflags;
2597 DWORD e32_mpages;
2598 DWORD e32_startobj;
2599 DWORD e32_eip;
2600 DWORD e32_stackobj;
2601 DWORD e32_esp;
2602 DWORD e32_pagesize;
2603 DWORD e32_lastpagesize;
2604 DWORD e32_fixupsize;
2605 DWORD e32_fixupsum;
2606 DWORD e32_ldrsize;
2607 DWORD e32_ldrsum;
2608 DWORD e32_objtab;
2609 DWORD e32_objcnt;
2610 DWORD e32_objmap;
2611 DWORD e32_itermap;
2612 DWORD e32_rsrctab;
2613 DWORD e32_rsrccnt;
2614 DWORD e32_restab;
2615 DWORD e32_enttab;
2616 DWORD e32_dirtab;
2617 DWORD e32_dircnt;
2618 DWORD e32_fpagetab;
2619 DWORD e32_frectab;
2620 DWORD e32_impmod;
2621 DWORD e32_impmodcnt;
2622 DWORD e32_impproc;
2623 DWORD e32_pagesum;
2624 DWORD e32_datapage;
2625 DWORD e32_preload;
2626 DWORD e32_nrestab;
2627 DWORD e32_cbnrestab;
2628 DWORD e32_nressum;
2629 DWORD e32_autodata;
2630 DWORD e32_debuginfo;
2631 DWORD e32_debuglen;
2632 DWORD e32_instpreload;
2633 DWORD e32_instdemand;
2634 DWORD e32_heapsize;
2635 BYTE e32_res3[12];
2636 DWORD e32_winresoff;
2637 DWORD e32_winreslen;
2638 WORD e32_devid;
2639 WORD e32_ddkver;
2640 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2641 #include <poppack.h>
2643 /* These defines describe the meanings of the bits in the Characteristics
2644 field */
2646 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2647 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2648 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2649 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2650 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2651 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2652 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2653 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2654 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2655 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2656 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2657 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2658 #define IMAGE_FILE_SYSTEM 0x1000
2659 #define IMAGE_FILE_DLL 0x2000
2660 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2661 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2663 /* These are the settings of the Machine field. */
2664 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2665 #define IMAGE_FILE_MACHINE_I860 0x014d
2666 #define IMAGE_FILE_MACHINE_I386 0x014c
2667 #define IMAGE_FILE_MACHINE_R3000 0x0162
2668 #define IMAGE_FILE_MACHINE_R4000 0x0166
2669 #define IMAGE_FILE_MACHINE_R10000 0x0168
2670 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2671 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2672 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2673 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2674 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2675 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2676 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2677 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2678 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2679 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2680 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2681 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2682 #define IMAGE_FILE_MACHINE_IA64 0x0200
2683 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2684 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2685 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2686 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2687 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2688 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2689 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2690 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2691 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2692 #define IMAGE_FILE_MACHINE_M32R 0x9041
2693 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2695 #define IMAGE_SIZEOF_FILE_HEADER 20
2696 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2697 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2698 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2699 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2700 #define IMAGE_SIZEOF_SHORT_NAME 8
2701 #define IMAGE_SIZEOF_SECTION_HEADER 40
2702 #define IMAGE_SIZEOF_SYMBOL 18
2703 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2704 #define IMAGE_SIZEOF_RELOCATION 10
2705 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2706 #define IMAGE_SIZEOF_LINENUMBER 6
2707 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2709 /* Possible Magic values */
2710 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2711 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2712 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2714 #ifdef _WIN64
2715 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2716 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2717 #else
2718 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2719 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2720 #endif
2722 /* These are indexes into the DataDirectory array */
2723 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2724 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2725 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2726 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2727 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2728 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2729 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2730 #define IMAGE_FILE_DESCRIPTION_STRING 7
2731 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2732 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2733 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2735 /* Directory Entries, indices into the DataDirectory array */
2737 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2738 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2739 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2740 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2741 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2742 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2743 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2744 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2745 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2746 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2747 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2748 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2749 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2750 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2751 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2753 /* Subsystem Values */
2755 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2756 #define IMAGE_SUBSYSTEM_NATIVE 1
2757 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2758 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2759 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2760 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2761 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2762 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2763 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2764 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2765 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2766 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2767 #define IMAGE_SUBSYSTEM_XBOX 14
2769 /* DLL Characteristics */
2770 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2771 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2772 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2773 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2774 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2775 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2776 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2777 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2779 typedef struct _IMAGE_FILE_HEADER {
2780 WORD Machine;
2781 WORD NumberOfSections;
2782 DWORD TimeDateStamp;
2783 DWORD PointerToSymbolTable;
2784 DWORD NumberOfSymbols;
2785 WORD SizeOfOptionalHeader;
2786 WORD Characteristics;
2787 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2789 typedef struct _IMAGE_DATA_DIRECTORY {
2790 DWORD VirtualAddress;
2791 DWORD Size;
2792 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2794 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2796 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2797 WORD Magic; /* 0x20b */
2798 BYTE MajorLinkerVersion;
2799 BYTE MinorLinkerVersion;
2800 DWORD SizeOfCode;
2801 DWORD SizeOfInitializedData;
2802 DWORD SizeOfUninitializedData;
2803 DWORD AddressOfEntryPoint;
2804 DWORD BaseOfCode;
2805 ULONGLONG ImageBase;
2806 DWORD SectionAlignment;
2807 DWORD FileAlignment;
2808 WORD MajorOperatingSystemVersion;
2809 WORD MinorOperatingSystemVersion;
2810 WORD MajorImageVersion;
2811 WORD MinorImageVersion;
2812 WORD MajorSubsystemVersion;
2813 WORD MinorSubsystemVersion;
2814 DWORD Win32VersionValue;
2815 DWORD SizeOfImage;
2816 DWORD SizeOfHeaders;
2817 DWORD CheckSum;
2818 WORD Subsystem;
2819 WORD DllCharacteristics;
2820 ULONGLONG SizeOfStackReserve;
2821 ULONGLONG SizeOfStackCommit;
2822 ULONGLONG SizeOfHeapReserve;
2823 ULONGLONG SizeOfHeapCommit;
2824 DWORD LoaderFlags;
2825 DWORD NumberOfRvaAndSizes;
2826 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2827 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2829 typedef struct _IMAGE_NT_HEADERS64 {
2830 DWORD Signature;
2831 IMAGE_FILE_HEADER FileHeader;
2832 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2833 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2835 typedef struct _IMAGE_OPTIONAL_HEADER {
2837 /* Standard fields */
2839 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2840 BYTE MajorLinkerVersion;
2841 BYTE MinorLinkerVersion;
2842 DWORD SizeOfCode;
2843 DWORD SizeOfInitializedData;
2844 DWORD SizeOfUninitializedData;
2845 DWORD AddressOfEntryPoint; /* 0x10 */
2846 DWORD BaseOfCode;
2847 DWORD BaseOfData;
2849 /* NT additional fields */
2851 DWORD ImageBase;
2852 DWORD SectionAlignment; /* 0x20 */
2853 DWORD FileAlignment;
2854 WORD MajorOperatingSystemVersion;
2855 WORD MinorOperatingSystemVersion;
2856 WORD MajorImageVersion;
2857 WORD MinorImageVersion;
2858 WORD MajorSubsystemVersion; /* 0x30 */
2859 WORD MinorSubsystemVersion;
2860 DWORD Win32VersionValue;
2861 DWORD SizeOfImage;
2862 DWORD SizeOfHeaders;
2863 DWORD CheckSum; /* 0x40 */
2864 WORD Subsystem;
2865 WORD DllCharacteristics;
2866 DWORD SizeOfStackReserve;
2867 DWORD SizeOfStackCommit;
2868 DWORD SizeOfHeapReserve; /* 0x50 */
2869 DWORD SizeOfHeapCommit;
2870 DWORD LoaderFlags;
2871 DWORD NumberOfRvaAndSizes;
2872 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2873 /* 0xE0 */
2874 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2876 typedef struct _IMAGE_NT_HEADERS {
2877 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2878 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2879 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2880 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2882 #ifdef _WIN64
2883 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2884 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2885 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2886 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2887 #else
2888 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2889 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2890 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2891 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2892 #endif
2894 #define IMAGE_SIZEOF_SHORT_NAME 8
2896 typedef struct _IMAGE_SECTION_HEADER {
2897 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2898 union {
2899 DWORD PhysicalAddress;
2900 DWORD VirtualSize;
2901 } Misc;
2902 DWORD VirtualAddress;
2903 DWORD SizeOfRawData;
2904 DWORD PointerToRawData;
2905 DWORD PointerToRelocations;
2906 DWORD PointerToLinenumbers;
2907 WORD NumberOfRelocations;
2908 WORD NumberOfLinenumbers;
2909 DWORD Characteristics;
2910 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2912 #define IMAGE_SIZEOF_SECTION_HEADER 40
2914 #define IMAGE_FIRST_SECTION(ntheader) \
2915 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2916 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2918 /* These defines are for the Characteristics bitfield. */
2919 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2920 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2921 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2922 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2923 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2924 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2926 #define IMAGE_SCN_CNT_CODE 0x00000020
2927 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2928 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2930 #define IMAGE_SCN_LNK_OTHER 0x00000100
2931 #define IMAGE_SCN_LNK_INFO 0x00000200
2932 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2933 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2934 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2936 /* 0x00002000 - Reserved */
2937 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2938 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2940 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2941 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2942 #define IMAGE_SCN_MEM_16BIT 0x00020000
2943 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2944 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2946 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2947 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2948 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2949 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2950 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2951 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2952 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2953 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2954 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2955 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2956 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2957 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2958 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2959 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2960 /* 0x00F00000 - Unused */
2961 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2963 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2966 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2967 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2968 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2969 #define IMAGE_SCN_MEM_SHARED 0x10000000
2970 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2971 #define IMAGE_SCN_MEM_READ 0x40000000
2972 #define IMAGE_SCN_MEM_WRITE 0x80000000
2974 #include <pshpack2.h>
2976 typedef struct _IMAGE_SYMBOL {
2977 union {
2978 BYTE ShortName[8];
2979 struct {
2980 DWORD Short;
2981 DWORD Long;
2982 } Name;
2983 DWORD LongName[2];
2984 } N;
2985 DWORD Value;
2986 SHORT SectionNumber;
2987 WORD Type;
2988 BYTE StorageClass;
2989 BYTE NumberOfAuxSymbols;
2990 } IMAGE_SYMBOL;
2991 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2993 #define IMAGE_SIZEOF_SYMBOL 18
2995 typedef struct _IMAGE_LINENUMBER {
2996 union {
2997 DWORD SymbolTableIndex;
2998 DWORD VirtualAddress;
2999 } Type;
3000 WORD Linenumber;
3001 } IMAGE_LINENUMBER;
3002 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
3004 #define IMAGE_SIZEOF_LINENUMBER 6
3006 typedef union _IMAGE_AUX_SYMBOL {
3007 struct {
3008 DWORD TagIndex;
3009 union {
3010 struct {
3011 WORD Linenumber;
3012 WORD Size;
3013 } LnSz;
3014 DWORD TotalSize;
3015 } Misc;
3016 union {
3017 struct {
3018 DWORD PointerToLinenumber;
3019 DWORD PointerToNextFunction;
3020 } Function;
3021 struct {
3022 WORD Dimension[4];
3023 } Array;
3024 } FcnAry;
3025 WORD TvIndex;
3026 } Sym;
3027 struct {
3028 BYTE Name[IMAGE_SIZEOF_SYMBOL];
3029 } File;
3030 struct {
3031 DWORD Length;
3032 WORD NumberOfRelocations;
3033 WORD NumberOfLinenumbers;
3034 DWORD CheckSum;
3035 SHORT Number;
3036 BYTE Selection;
3037 } Section;
3038 } IMAGE_AUX_SYMBOL;
3039 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
3041 #define IMAGE_SIZEOF_AUX_SYMBOL 18
3043 #include <poppack.h>
3045 #define IMAGE_SYM_UNDEFINED (SHORT)0
3046 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
3047 #define IMAGE_SYM_DEBUG (SHORT)-2
3049 #define IMAGE_SYM_TYPE_NULL 0x0000
3050 #define IMAGE_SYM_TYPE_VOID 0x0001
3051 #define IMAGE_SYM_TYPE_CHAR 0x0002
3052 #define IMAGE_SYM_TYPE_SHORT 0x0003
3053 #define IMAGE_SYM_TYPE_INT 0x0004
3054 #define IMAGE_SYM_TYPE_LONG 0x0005
3055 #define IMAGE_SYM_TYPE_FLOAT 0x0006
3056 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
3057 #define IMAGE_SYM_TYPE_STRUCT 0x0008
3058 #define IMAGE_SYM_TYPE_UNION 0x0009
3059 #define IMAGE_SYM_TYPE_ENUM 0x000A
3060 #define IMAGE_SYM_TYPE_MOE 0x000B
3061 #define IMAGE_SYM_TYPE_BYTE 0x000C
3062 #define IMAGE_SYM_TYPE_WORD 0x000D
3063 #define IMAGE_SYM_TYPE_UINT 0x000E
3064 #define IMAGE_SYM_TYPE_DWORD 0x000F
3065 #define IMAGE_SYM_TYPE_PCODE 0x8000
3067 #define IMAGE_SYM_DTYPE_NULL 0
3068 #define IMAGE_SYM_DTYPE_POINTER 1
3069 #define IMAGE_SYM_DTYPE_FUNCTION 2
3070 #define IMAGE_SYM_DTYPE_ARRAY 3
3072 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
3073 #define IMAGE_SYM_CLASS_NULL 0x0000
3074 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
3075 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
3076 #define IMAGE_SYM_CLASS_STATIC 0x0003
3077 #define IMAGE_SYM_CLASS_REGISTER 0x0004
3078 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
3079 #define IMAGE_SYM_CLASS_LABEL 0x0006
3080 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
3081 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
3082 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
3083 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
3084 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
3085 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
3086 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
3087 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
3088 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
3089 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
3090 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
3091 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
3093 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
3094 #define IMAGE_SYM_CLASS_BLOCK 0x0064
3095 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
3096 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
3097 #define IMAGE_SYM_CLASS_FILE 0x0067
3098 #define IMAGE_SYM_CLASS_SECTION 0x0068
3099 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
3101 #define N_BTMASK 0x000F
3102 #define N_TMASK 0x0030
3103 #define N_TMASK1 0x00C0
3104 #define N_TMASK2 0x00F0
3105 #define N_BTSHFT 4
3106 #define N_TSHIFT 2
3108 #define BTYPE(x) ((x) & N_BTMASK)
3110 #ifndef ISPTR
3111 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
3112 #endif
3114 #ifndef ISFCN
3115 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
3116 #endif
3118 #ifndef ISARY
3119 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
3120 #endif
3122 #ifndef ISTAG
3123 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
3124 #endif
3126 #ifndef INCREF
3127 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
3128 #endif
3129 #ifndef DECREF
3130 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
3131 #endif
3133 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
3134 #define IMAGE_COMDAT_SELECT_ANY 2
3135 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
3136 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
3137 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
3138 #define IMAGE_COMDAT_SELECT_LARGEST 6
3139 #define IMAGE_COMDAT_SELECT_NEWEST 7
3141 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
3142 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
3143 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
3145 /* Export module directory */
3147 typedef struct _IMAGE_EXPORT_DIRECTORY {
3148 DWORD Characteristics;
3149 DWORD TimeDateStamp;
3150 WORD MajorVersion;
3151 WORD MinorVersion;
3152 DWORD Name;
3153 DWORD Base;
3154 DWORD NumberOfFunctions;
3155 DWORD NumberOfNames;
3156 DWORD AddressOfFunctions;
3157 DWORD AddressOfNames;
3158 DWORD AddressOfNameOrdinals;
3159 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
3161 /* Import name entry */
3162 typedef struct _IMAGE_IMPORT_BY_NAME {
3163 WORD Hint;
3164 BYTE Name[1];
3165 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
3167 #include <pshpack8.h>
3168 /* Import thunk */
3169 typedef struct _IMAGE_THUNK_DATA64 {
3170 union {
3171 ULONGLONG ForwarderString;
3172 ULONGLONG Function;
3173 ULONGLONG Ordinal;
3174 ULONGLONG AddressOfData;
3175 } u1;
3176 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3177 #include <poppack.h>
3179 typedef struct _IMAGE_THUNK_DATA32 {
3180 union {
3181 DWORD ForwarderString;
3182 DWORD Function;
3183 DWORD Ordinal;
3184 DWORD AddressOfData;
3185 } u1;
3186 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3188 /* Import module directory */
3190 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3191 union {
3192 DWORD Characteristics; /* 0 for terminating null import descriptor */
3193 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3194 } DUMMYUNIONNAME;
3195 DWORD TimeDateStamp; /* 0 if not bound,
3196 * -1 if bound, and real date\time stamp
3197 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3198 * (new BIND)
3199 * otherwise date/time stamp of DLL bound to
3200 * (Old BIND)
3202 DWORD ForwarderChain; /* -1 if no forwarders */
3203 DWORD Name;
3204 /* RVA to IAT (if bound this IAT has actual addresses) */
3205 DWORD FirstThunk;
3206 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3208 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3209 #define IMAGE_ORDINAL_FLAG32 0x80000000
3210 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3211 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3212 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3213 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3215 #ifdef _WIN64
3216 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3217 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3218 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3219 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3220 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3221 #else
3222 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3223 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3224 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3225 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3226 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3227 #endif
3229 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3231 DWORD TimeDateStamp;
3232 WORD OffsetModuleName;
3233 WORD NumberOfModuleForwarderRefs;
3234 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3235 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3237 typedef struct _IMAGE_BOUND_FORWARDER_REF
3239 DWORD TimeDateStamp;
3240 WORD OffsetModuleName;
3241 WORD Reserved;
3242 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3244 typedef struct _IMAGE_BASE_RELOCATION
3246 DWORD VirtualAddress;
3247 DWORD SizeOfBlock;
3248 /* WORD TypeOffset[1]; */
3249 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3251 #include <pshpack2.h>
3253 typedef struct _IMAGE_RELOCATION
3255 union {
3256 DWORD VirtualAddress;
3257 DWORD RelocCount;
3258 } DUMMYUNIONNAME;
3259 DWORD SymbolTableIndex;
3260 WORD Type;
3261 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3263 #include <poppack.h>
3265 #define IMAGE_SIZEOF_RELOCATION 10
3267 /* generic relocation types */
3268 #define IMAGE_REL_BASED_ABSOLUTE 0
3269 #define IMAGE_REL_BASED_HIGH 1
3270 #define IMAGE_REL_BASED_LOW 2
3271 #define IMAGE_REL_BASED_HIGHLOW 3
3272 #define IMAGE_REL_BASED_HIGHADJ 4
3273 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3274 #define IMAGE_REL_BASED_SECTION 6
3275 #define IMAGE_REL_BASED_REL 7
3276 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3277 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3278 #define IMAGE_REL_BASED_DIR64 10
3279 #define IMAGE_REL_BASED_HIGH3ADJ 11
3281 /* I386 relocation types */
3282 #define IMAGE_REL_I386_ABSOLUTE 0
3283 #define IMAGE_REL_I386_DIR16 1
3284 #define IMAGE_REL_I386_REL16 2
3285 #define IMAGE_REL_I386_DIR32 6
3286 #define IMAGE_REL_I386_DIR32NB 7
3287 #define IMAGE_REL_I386_SEG12 9
3288 #define IMAGE_REL_I386_SECTION 10
3289 #define IMAGE_REL_I386_SECREL 11
3290 #define IMAGE_REL_I386_REL32 20
3292 /* MIPS relocation types */
3293 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3294 #define IMAGE_REL_MIPS_REFHALF 0x0001
3295 #define IMAGE_REL_MIPS_REFWORD 0x0002
3296 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3297 #define IMAGE_REL_MIPS_REFHI 0x0004
3298 #define IMAGE_REL_MIPS_REFLO 0x0005
3299 #define IMAGE_REL_MIPS_GPREL 0x0006
3300 #define IMAGE_REL_MIPS_LITERAL 0x0007
3301 #define IMAGE_REL_MIPS_SECTION 0x000A
3302 #define IMAGE_REL_MIPS_SECREL 0x000B
3303 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3304 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3305 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3306 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3307 #define IMAGE_REL_MIPS_PAIR 0x0025
3309 /* ALPHA relocation types */
3310 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3311 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3312 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3313 #define IMAGE_REL_ALPHA_GPREL 0x0003
3314 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3315 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3316 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3317 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3318 #define IMAGE_REL_ALPHA_HINT 0x0008
3319 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3320 #define IMAGE_REL_ALPHA_REFHI 0x000A
3321 #define IMAGE_REL_ALPHA_REFLO 0x000B
3322 #define IMAGE_REL_ALPHA_PAIR 0x000C
3323 #define IMAGE_REL_ALPHA_MATCH 0x000D
3324 #define IMAGE_REL_ALPHA_SECTION 0x000E
3325 #define IMAGE_REL_ALPHA_SECREL 0x000F
3326 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3327 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3328 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3329 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3330 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3331 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3332 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3333 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3335 /* PowerPC relocation types */
3336 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3337 #define IMAGE_REL_PPC_ADDR64 0x0001
3338 #define IMAGE_REL_PPC_ADDR 0x0002
3339 #define IMAGE_REL_PPC_ADDR24 0x0003
3340 #define IMAGE_REL_PPC_ADDR16 0x0004
3341 #define IMAGE_REL_PPC_ADDR14 0x0005
3342 #define IMAGE_REL_PPC_REL24 0x0006
3343 #define IMAGE_REL_PPC_REL14 0x0007
3344 #define IMAGE_REL_PPC_TOCREL16 0x0008
3345 #define IMAGE_REL_PPC_TOCREL14 0x0009
3346 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3347 #define IMAGE_REL_PPC_SECREL 0x000B
3348 #define IMAGE_REL_PPC_SECTION 0x000C
3349 #define IMAGE_REL_PPC_IFGLUE 0x000D
3350 #define IMAGE_REL_PPC_IMGLUE 0x000E
3351 #define IMAGE_REL_PPC_SECREL16 0x000F
3352 #define IMAGE_REL_PPC_REFHI 0x0010
3353 #define IMAGE_REL_PPC_REFLO 0x0011
3354 #define IMAGE_REL_PPC_PAIR 0x0012
3355 #define IMAGE_REL_PPC_SECRELLO 0x0013
3356 #define IMAGE_REL_PPC_SECRELHI 0x0014
3357 #define IMAGE_REL_PPC_GPREL 0x0015
3358 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3359 /* modifier bits */
3360 #define IMAGE_REL_PPC_NEG 0x0100
3361 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3362 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3363 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3365 /* SH3 ? relocation type */
3366 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3367 #define IMAGE_REL_SH3_DIRECT16 0x0001
3368 #define IMAGE_REL_SH3_DIRECT 0x0002
3369 #define IMAGE_REL_SH3_DIRECT8 0x0003
3370 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3371 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3372 #define IMAGE_REL_SH3_DIRECT4 0x0006
3373 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3374 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3375 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3376 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3377 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3378 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3379 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3380 #define IMAGE_REL_SH3_SECTION 0x000E
3381 #define IMAGE_REL_SH3_SECREL 0x000F
3382 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3384 /* ARM (Archimedes?) relocation types */
3385 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3386 #define IMAGE_REL_ARM_ADDR 0x0001
3387 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3388 #define IMAGE_REL_ARM_BRANCH24 0x0003
3389 #define IMAGE_REL_ARM_BRANCH11 0x0004
3390 #define IMAGE_REL_ARM_SECTION 0x000E
3391 #define IMAGE_REL_ARM_SECREL 0x000F
3393 /* IA64 relocation types */
3394 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3395 #define IMAGE_REL_IA64_IMM14 0x0001
3396 #define IMAGE_REL_IA64_IMM22 0x0002
3397 #define IMAGE_REL_IA64_IMM64 0x0003
3398 #define IMAGE_REL_IA64_DIR 0x0004
3399 #define IMAGE_REL_IA64_DIR64 0x0005
3400 #define IMAGE_REL_IA64_PCREL21B 0x0006
3401 #define IMAGE_REL_IA64_PCREL21M 0x0007
3402 #define IMAGE_REL_IA64_PCREL21F 0x0008
3403 #define IMAGE_REL_IA64_GPREL22 0x0009
3404 #define IMAGE_REL_IA64_LTOFF22 0x000A
3405 #define IMAGE_REL_IA64_SECTION 0x000B
3406 #define IMAGE_REL_IA64_SECREL22 0x000C
3407 #define IMAGE_REL_IA64_SECREL64I 0x000D
3408 #define IMAGE_REL_IA64_SECREL 0x000E
3409 #define IMAGE_REL_IA64_LTOFF64 0x000F
3410 #define IMAGE_REL_IA64_DIR32NB 0x0010
3411 #define IMAGE_REL_IA64_RESERVED_11 0x0011
3412 #define IMAGE_REL_IA64_RESERVED_12 0x0012
3413 #define IMAGE_REL_IA64_RESERVED_13 0x0013
3414 #define IMAGE_REL_IA64_RESERVED_14 0x0014
3415 #define IMAGE_REL_IA64_RESERVED_15 0x0015
3416 #define IMAGE_REL_IA64_RESERVED_16 0x0016
3417 #define IMAGE_REL_IA64_ADDEND 0x001F
3419 /* AMD64 relocation types */
3420 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3421 #define IMAGE_REL_AMD64_ADDR64 0x0001
3422 #define IMAGE_REL_AMD64_ADDR32 0x0002
3423 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3424 #define IMAGE_REL_AMD64_REL32 0x0004
3425 #define IMAGE_REL_AMD64_REL32_1 0x0005
3426 #define IMAGE_REL_AMD64_REL32_2 0x0006
3427 #define IMAGE_REL_AMD64_REL32_3 0x0007
3428 #define IMAGE_REL_AMD64_REL32_4 0x0008
3429 #define IMAGE_REL_AMD64_REL32_5 0x0009
3430 #define IMAGE_REL_AMD64_SECTION 0x000A
3431 #define IMAGE_REL_AMD64_SECREL 0x000B
3432 #define IMAGE_REL_AMD64_SECREL7 0x000C
3433 #define IMAGE_REL_AMD64_TOKEN 0x000D
3434 #define IMAGE_REL_AMD64_SREL32 0x000E
3435 #define IMAGE_REL_AMD64_PAIR 0x000F
3436 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3438 /* archive format */
3440 #define IMAGE_ARCHIVE_START_SIZE 8
3441 #define IMAGE_ARCHIVE_START "!<arch>\n"
3442 #define IMAGE_ARCHIVE_END "`\n"
3443 #define IMAGE_ARCHIVE_PAD "\n"
3444 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3445 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3447 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3449 BYTE Name[16];
3450 BYTE Date[12];
3451 BYTE UserID[6];
3452 BYTE GroupID[6];
3453 BYTE Mode[8];
3454 BYTE Size[10];
3455 BYTE EndHeader[2];
3456 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3458 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3460 typedef struct _IMPORT_OBJECT_HEADER
3462 WORD Sig1;
3463 WORD Sig2;
3464 WORD Version;
3465 WORD Machine;
3466 DWORD TimeDateStamp;
3467 DWORD SizeOfData;
3468 union
3470 WORD Ordinal;
3471 WORD Hint;
3472 } DUMMYUNIONNAME;
3473 WORD Type : 2;
3474 WORD NameType : 3;
3475 WORD Reserved : 11;
3476 } IMPORT_OBJECT_HEADER;
3478 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3480 typedef enum IMPORT_OBJECT_TYPE
3482 IMPORT_OBJECT_CODE = 0,
3483 IMPORT_OBJECT_DATA = 1,
3484 IMPORT_OBJECT_CONST = 2
3485 } IMPORT_OBJECT_TYPE;
3487 typedef enum IMPORT_OBJECT_NAME_TYPE
3489 IMPORT_OBJECT_ORDINAL = 0,
3490 IMPORT_OBJECT_NAME = 1,
3491 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3492 IMPORT_OBJECT_NAME_UNDECORATE = 3
3493 } IMPORT_OBJECT_NAME_TYPE;
3495 typedef struct _ANON_OBJECT_HEADER
3497 WORD Sig1;
3498 WORD Sig2;
3499 WORD Version;
3500 WORD Machine;
3501 DWORD TimeDateStamp;
3502 CLSID ClassID;
3503 DWORD SizeOfData;
3504 } ANON_OBJECT_HEADER;
3507 * Resource directory stuff
3509 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3510 DWORD Characteristics;
3511 DWORD TimeDateStamp;
3512 WORD MajorVersion;
3513 WORD MinorVersion;
3514 WORD NumberOfNamedEntries;
3515 WORD NumberOfIdEntries;
3516 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3517 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3519 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3520 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3522 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3523 union {
3524 struct {
3525 #ifdef BITFIELDS_BIGENDIAN
3526 unsigned NameIsString:1;
3527 unsigned NameOffset:31;
3528 #else
3529 unsigned NameOffset:31;
3530 unsigned NameIsString:1;
3531 #endif
3532 } DUMMYSTRUCTNAME1;
3533 DWORD Name;
3534 struct {
3535 #ifdef WORDS_BIGENDIAN
3536 WORD __pad;
3537 WORD Id;
3538 #else
3539 WORD Id;
3540 WORD __pad;
3541 #endif
3542 } DUMMYSTRUCTNAME2;
3543 } DUMMYUNIONNAME1;
3544 union {
3545 DWORD OffsetToData;
3546 struct {
3547 #ifdef BITFIELDS_BIGENDIAN
3548 unsigned DataIsDirectory:1;
3549 unsigned OffsetToDirectory:31;
3550 #else
3551 unsigned OffsetToDirectory:31;
3552 unsigned DataIsDirectory:1;
3553 #endif
3554 } DUMMYSTRUCTNAME3;
3555 } DUMMYUNIONNAME2;
3556 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3559 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3560 WORD Length;
3561 CHAR NameString[ 1 ];
3562 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3564 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3565 WORD Length;
3566 WCHAR NameString[ 1 ];
3567 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3569 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3570 DWORD OffsetToData;
3571 DWORD Size;
3572 DWORD CodePage;
3573 DWORD Reserved;
3574 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3577 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3578 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3581 typedef struct _IMAGE_TLS_DIRECTORY64 {
3582 ULONGLONG StartAddressOfRawData;
3583 ULONGLONG EndAddressOfRawData;
3584 ULONGLONG AddressOfIndex;
3585 ULONGLONG AddressOfCallBacks;
3586 DWORD SizeOfZeroFill;
3587 DWORD Characteristics;
3588 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3590 typedef struct _IMAGE_TLS_DIRECTORY32 {
3591 DWORD StartAddressOfRawData;
3592 DWORD EndAddressOfRawData;
3593 DWORD AddressOfIndex;
3594 DWORD AddressOfCallBacks;
3595 DWORD SizeOfZeroFill;
3596 DWORD Characteristics;
3597 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3599 #ifdef _WIN64
3600 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3601 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3602 #else
3603 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3604 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3605 #endif
3607 typedef struct _IMAGE_DEBUG_DIRECTORY {
3608 DWORD Characteristics;
3609 DWORD TimeDateStamp;
3610 WORD MajorVersion;
3611 WORD MinorVersion;
3612 DWORD Type;
3613 DWORD SizeOfData;
3614 DWORD AddressOfRawData;
3615 DWORD PointerToRawData;
3616 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3618 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3619 #define IMAGE_DEBUG_TYPE_COFF 1
3620 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3621 #define IMAGE_DEBUG_TYPE_FPO 3
3622 #define IMAGE_DEBUG_TYPE_MISC 4
3623 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3624 #define IMAGE_DEBUG_TYPE_FIXUP 6
3625 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3626 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3627 #define IMAGE_DEBUG_TYPE_BORLAND 9
3628 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3630 typedef enum ReplacesCorHdrNumericDefines
3632 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3633 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3634 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3635 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3636 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3638 COR_VERSION_MAJOR_V2 = 2,
3639 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3640 COR_VERSION_MINOR = 0,
3641 COR_DELETED_NAME_LENGTH = 8,
3642 COR_VTABLEGAP_NAME_LENGTH = 8,
3644 NATIVE_TYPE_MAX_CB = 1,
3645 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3647 IMAGE_COR_MIH_METHODRVA = 0x01,
3648 IMAGE_COR_MIH_EHRVA = 0x02,
3649 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3651 COR_VTABLE_32BIT = 0x01,
3652 COR_VTABLE_64BIT = 0x02,
3653 COR_VTABLE_FROM_UNMANAGED = 0x04,
3654 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3656 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3658 MAX_CLASS_NAME = 1024,
3659 MAX_PACKAGE_NAME = 1024,
3660 } ReplacesCorHdrNumericDefines;
3662 typedef struct IMAGE_COR20_HEADER
3664 DWORD cb;
3665 WORD MajorRuntimeVersion;
3666 WORD MinorRuntimeVersion;
3668 IMAGE_DATA_DIRECTORY MetaData;
3669 DWORD Flags;
3670 DWORD EntryPointToken;
3672 IMAGE_DATA_DIRECTORY Resources;
3673 IMAGE_DATA_DIRECTORY StrongNameSignature;
3674 IMAGE_DATA_DIRECTORY CodeManagerTable;
3675 IMAGE_DATA_DIRECTORY VTableFixups;
3676 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3677 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3679 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3681 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3682 DWORD NumberOfSymbols;
3683 DWORD LvaToFirstSymbol;
3684 DWORD NumberOfLinenumbers;
3685 DWORD LvaToFirstLinenumber;
3686 DWORD RvaToFirstByteOfCode;
3687 DWORD RvaToLastByteOfCode;
3688 DWORD RvaToFirstByteOfData;
3689 DWORD RvaToLastByteOfData;
3690 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3692 #define FRAME_FPO 0
3693 #define FRAME_TRAP 1
3694 #define FRAME_TSS 2
3695 #define FRAME_NONFPO 3
3697 typedef struct _FPO_DATA {
3698 DWORD ulOffStart;
3699 DWORD cbProcSize;
3700 DWORD cdwLocals;
3701 WORD cdwParams;
3702 WORD cbProlog : 8;
3703 WORD cbRegs : 3;
3704 WORD fHasSEH : 1;
3705 WORD fUseBP : 1;
3706 WORD reserved : 1;
3707 WORD cbFrame : 2;
3708 } FPO_DATA, *PFPO_DATA;
3710 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
3711 DWORD Size;
3712 DWORD TimeDateStamp;
3713 WORD MajorVersion;
3714 WORD MinorVersion;
3715 DWORD GlobalFlagsClear;
3716 DWORD GlobalFlagsSet;
3717 DWORD CriticalSectionDefaultTimeout;
3718 DWORD DeCommitFreeBlockThreshold;
3719 DWORD DeCommitTotalFreeThreshold;
3720 PVOID LockPrefixTable;
3721 DWORD MaximumAllocationSize;
3722 DWORD VirtualMemoryThreshold;
3723 DWORD ProcessHeapFlags;
3724 DWORD ProcessAffinityMask;
3725 WORD CSDVersion;
3726 WORD Reserved1;
3727 PVOID EditList;
3728 DWORD SecurityCookie;
3729 DWORD SEHandlerTable;
3730 DWORD SEHandlerCount;
3731 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
3733 typedef struct _IMAGE_FUNCTION_ENTRY {
3734 DWORD StartingAddress;
3735 DWORD EndingAddress;
3736 DWORD EndOfPrologue;
3737 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3739 #define IMAGE_DEBUG_MISC_EXENAME 1
3741 typedef struct _IMAGE_DEBUG_MISC {
3742 DWORD DataType;
3743 DWORD Length;
3744 BYTE Unicode;
3745 BYTE Reserved[ 3 ];
3746 BYTE Data[ 1 ];
3747 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3749 /* This is the structure that appears at the very start of a .DBG file. */
3751 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3752 WORD Signature;
3753 WORD Flags;
3754 WORD Machine;
3755 WORD Characteristics;
3756 DWORD TimeDateStamp;
3757 DWORD CheckSum;
3758 DWORD ImageBase;
3759 DWORD SizeOfImage;
3760 DWORD NumberOfSections;
3761 DWORD ExportedNamesSize;
3762 DWORD DebugDirectorySize;
3763 DWORD SectionAlignment;
3764 DWORD Reserved[ 2 ];
3765 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3767 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3770 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3771 WORD Length;
3772 WORD Flags;
3773 BYTE Text[1];
3774 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3775 #define MESSAGE_RESOURCE_UNICODE 0x0001
3777 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3778 DWORD LowId;
3779 DWORD HighId;
3780 DWORD OffsetToEntries;
3781 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3783 typedef struct tagMESSAGE_RESOURCE_DATA {
3784 DWORD NumberOfBlocks;
3785 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
3786 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3789 * Here follows typedefs for security and tokens.
3793 * First a constant for the following typedefs.
3796 #define ANYSIZE_ARRAY 1
3798 /* FIXME: Orphan. What does it point to? */
3799 typedef PVOID PACCESS_TOKEN;
3800 typedef PVOID PSECURITY_DESCRIPTOR;
3801 typedef PVOID PSID;
3804 * TOKEN_INFORMATION_CLASS
3807 typedef enum _TOKEN_INFORMATION_CLASS {
3808 TokenUser = 1,
3809 TokenGroups,
3810 TokenPrivileges,
3811 TokenOwner,
3812 TokenPrimaryGroup,
3813 TokenDefaultDacl,
3814 TokenSource,
3815 TokenType,
3816 TokenImpersonationLevel,
3817 TokenStatistics,
3818 TokenRestrictedSids,
3819 TokenSessionId,
3820 TokenGroupsAndPrivileges,
3821 TokenSessionReference,
3822 TokenSandBoxInert,
3823 TokenAuditPolicy,
3824 TokenOrigin,
3825 TokenElevationType,
3826 TokenLinkedToken,
3827 TokenElevation,
3828 TokenHasRestrictions,
3829 TokenAccessInformation,
3830 TokenVirtualizationAllowed,
3831 TokenVirtualizationEnabled,
3832 TokenIntegrityLevel,
3833 TokenUIAccess,
3834 TokenMandatoryPolicy,
3835 TokenLogonSid,
3836 MaxTokenInfoClass
3837 } TOKEN_INFORMATION_CLASS;
3839 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
3840 #define TOKEN_ADJUST_GROUPS 0x0040
3841 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3842 #define TOKEN_ADJUST_SESSIONID 0x0100
3843 #define TOKEN_ASSIGN_PRIMARY 0x0001
3844 #define TOKEN_DUPLICATE 0x0002
3845 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3846 #define TOKEN_IMPERSONATE 0x0004
3847 #define TOKEN_QUERY 0x0008
3848 #define TOKEN_QUERY_SOURCE 0x0010
3849 #define TOKEN_ADJUST_DEFAULT 0x0080
3850 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3851 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3852 TOKEN_ADJUST_PRIVILEGES | \
3853 TOKEN_ADJUST_GROUPS | \
3854 TOKEN_ADJUST_DEFAULT )
3855 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3856 TOKEN_ASSIGN_PRIMARY | \
3857 TOKEN_DUPLICATE | \
3858 TOKEN_IMPERSONATE | \
3859 TOKEN_QUERY | \
3860 TOKEN_QUERY_SOURCE | \
3861 TOKEN_ADJUST_PRIVILEGES | \
3862 TOKEN_ADJUST_GROUPS | \
3863 TOKEN_ADJUST_SESSIONID | \
3864 TOKEN_ADJUST_DEFAULT )
3866 #ifndef _SECURITY_DEFINED
3867 #define _SECURITY_DEFINED
3870 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3872 typedef struct _GENERIC_MAPPING {
3873 ACCESS_MASK GenericRead;
3874 ACCESS_MASK GenericWrite;
3875 ACCESS_MASK GenericExecute;
3876 ACCESS_MASK GenericAll;
3877 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3879 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3880 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3881 typedef struct {
3882 BYTE Value[6];
3883 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
3884 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3886 #ifndef SID_DEFINED
3887 #define SID_DEFINED
3888 typedef struct _SID {
3889 BYTE Revision;
3890 BYTE SubAuthorityCount;
3891 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3892 DWORD SubAuthority[1];
3893 } SID,*PISID;
3894 #endif /* !defined(SID_DEFINED) */
3896 #define SID_REVISION (1) /* Current revision */
3897 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3898 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3900 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3903 * ACL
3906 #define ACL_REVISION1 1
3907 #define ACL_REVISION2 2
3908 #define ACL_REVISION3 3
3909 #define ACL_REVISION4 4
3911 #define MIN_ACL_REVISION ACL_REVISION2
3912 #define MAX_ACL_REVISION ACL_REVISION4
3914 #define ACL_REVISION 2
3916 typedef struct _ACL {
3917 BYTE AclRevision;
3918 BYTE Sbz1;
3919 WORD AclSize;
3920 WORD AceCount;
3921 WORD Sbz2;
3922 } ACL, *PACL;
3924 typedef enum _ACL_INFORMATION_CLASS
3926 AclRevisionInformation = 1,
3927 AclSizeInformation
3928 } ACL_INFORMATION_CLASS;
3930 typedef struct _ACL_REVISION_INFORMATION
3932 DWORD AclRevision;
3933 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
3935 typedef struct _ACL_SIZE_INFORMATION
3937 DWORD AceCount;
3938 DWORD AclBytesInUse;
3939 DWORD AclBytesFree;
3940 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
3942 /* SECURITY_DESCRIPTOR */
3943 #define SECURITY_DESCRIPTOR_REVISION 1
3944 #define SECURITY_DESCRIPTOR_REVISION1 1
3948 * Privilege Names
3950 #define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
3951 #define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
3952 #define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
3953 #define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
3954 #define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
3955 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
3956 #define SE_TCB_NAME TEXT("SeTcbPrivilege")
3957 #define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
3958 #define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
3959 #define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
3960 #define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
3961 #define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
3962 #define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
3963 #define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
3964 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
3965 #define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
3966 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
3967 #define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
3968 #define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
3969 #define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
3970 #define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
3971 #define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
3972 #define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
3973 #define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
3974 #define SE_UNDOCK_NAME TEXT("SeUndockPrivilege")
3975 #define SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege")
3976 #define SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege")
3977 #define SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege")
3978 #define SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege")
3980 #define SE_GROUP_MANDATORY 0x00000001
3981 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
3982 #define SE_GROUP_ENABLED 0x00000004
3983 #define SE_GROUP_OWNER 0x00000008
3984 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
3985 #define SE_GROUP_LOGON_ID 0xC0000000
3986 #define SE_GROUP_RESOURCE 0x20000000
3988 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
3989 #define SE_PRIVILEGE_ENABLED 0x00000002
3990 #define SE_PRIVILEGE_REMOVE 0x00000004
3991 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
3993 #define PRIVILEGE_SET_ALL_NECESSARY 1
3995 #define SE_OWNER_DEFAULTED 0x00000001
3996 #define SE_GROUP_DEFAULTED 0x00000002
3997 #define SE_DACL_PRESENT 0x00000004
3998 #define SE_DACL_DEFAULTED 0x00000008
3999 #define SE_SACL_PRESENT 0x00000010
4000 #define SE_SACL_DEFAULTED 0x00000020
4001 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4002 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4003 #define SE_DACL_AUTO_INHERITED 0x00000400
4004 #define SE_SACL_AUTO_INHERITED 0x00000800
4005 #define SE_DACL_PROTECTED 0x00001000
4006 #define SE_SACL_PROTECTED 0x00002000
4007 #define SE_RM_CONTROL_VALID 0x00004000
4008 #define SE_SELF_RELATIVE 0x00008000
4010 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4011 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4013 /* The security descriptor structure */
4014 typedef struct {
4015 BYTE Revision;
4016 BYTE Sbz1;
4017 SECURITY_DESCRIPTOR_CONTROL Control;
4018 DWORD Owner;
4019 DWORD Group;
4020 DWORD Sacl;
4021 DWORD Dacl;
4022 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4024 typedef struct {
4025 BYTE Revision;
4026 BYTE Sbz1;
4027 SECURITY_DESCRIPTOR_CONTROL Control;
4028 PSID Owner;
4029 PSID Group;
4030 PACL Sacl;
4031 PACL Dacl;
4032 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4034 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4036 #endif /* _SECURITY_DEFINED */
4039 * SID_AND_ATTRIBUTES
4042 typedef struct _SID_AND_ATTRIBUTES {
4043 PSID Sid;
4044 DWORD Attributes;
4045 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4047 /* security entities */
4048 #define SECURITY_NULL_RID (0x00000000L)
4049 #define SECURITY_WORLD_RID (0x00000000L)
4050 #define SECURITY_LOCAL_RID (0X00000000L)
4052 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4054 /* S-1-1 */
4055 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4057 /* S-1-2 */
4058 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4060 /* S-1-3 */
4061 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4062 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
4063 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
4064 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
4065 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
4067 /* S-1-4 */
4068 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4070 /* S-1-5 */
4071 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4072 #define SECURITY_DIALUP_RID 0x00000001L
4073 #define SECURITY_NETWORK_RID 0x00000002L
4074 #define SECURITY_BATCH_RID 0x00000003L
4075 #define SECURITY_INTERACTIVE_RID 0x00000004L
4076 #define SECURITY_LOGON_IDS_RID 0x00000005L
4077 #define SECURITY_SERVICE_RID 0x00000006L
4078 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
4079 #define SECURITY_PROXY_RID 0x00000008L
4080 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
4081 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4082 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
4083 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
4084 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
4085 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
4086 #define SECURITY_REMOTE_LOGON_RID 0x0000000EL
4087 #define SECURITY_THIS_ORGANIZATION_RID 0x0000000FL
4088 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
4089 #define SECURITY_LOCAL_SERVICE_RID 0x00000013L
4090 #define SECURITY_NETWORK_SERVICE_RID 0x00000014L
4091 #define SECURITY_NT_NON_UNIQUE 0x00000015L
4092 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
4094 #define SECURITY_PACKAGE_BASE_RID 0x00000040L
4095 #define SECURITY_PACKAGE_NTLM_RID 0x0000000AL
4096 #define SECURITY_PACKAGE_SCHANNEL_RID 0x0000000EL
4097 #define SECURITY_PACKAGE_DIGEST_RID 0x00000015L
4098 #define SECURITY_MAX_ALWAYS_FILTERED 0x000003E7L
4099 #define SECURITY_MIN_NEVER_FILTERED 0x000003E8L
4100 #define SECURITY_OTHER_ORGANIZATION_RID 0x000003E8L
4102 #define FOREST_USER_RID_MAX 0x000001F3L
4103 #define DOMAIN_USER_RID_ADMIN 0x000001F4L
4104 #define DOMAIN_USER_RID_GUEST 0x000001F5L
4105 #define DOMAIN_USER_RID_KRBTGT 0x000001F6L
4106 #define DOMAIN_USER_RID_MAX 0x000003E7L
4108 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
4109 #define DOMAIN_GROUP_RID_USERS 0x00000201L
4110 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
4111 #define DOMAIN_GROUP_RID_COMPUTERS 0x00000203L
4112 #define DOMAIN_GROUP_RID_CONTROLLERS 0x00000204L
4113 #define DOMAIN_GROUP_RID_CERT_ADMINS 0x00000205L
4114 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS 0x00000206L
4115 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS 0x00000207L
4116 #define DOMAIN_GROUP_RID_POLICY_ADMINS 0x00000208L
4118 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4119 #define SECURITY_MANDATORY_UNTRUSTED_RID 0x00000000L
4120 #define SECURITY_MANDATORY_LOW_RID 0x00001000L
4121 #define SECURITY_MANDATORY_MEDIUM_RID 0x00002000L
4122 #define SECURITY_MANDATORY_HIGH_RID 0x00003000L
4123 #define SECURITY_MANDATORY_SYSTEM_RID 0x00004000L
4124 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID 0x00005000L
4126 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
4127 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
4128 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
4129 #define DOMAIN_ALIAS_RID_POWER_USERS 0x00000223L
4131 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS 0x00000224L
4132 #define DOMAIN_ALIAS_RID_SYSTEM_OPS 0x00000225L
4133 #define DOMAIN_ALIAS_RID_PRINT_OPS 0x00000226L
4134 #define DOMAIN_ALIAS_RID_BACKUP_OPS 0x00000227L
4136 #define DOMAIN_ALIAS_RID_REPLICATOR 0x00000228L
4137 #define DOMAIN_ALIAS_RID_RAS_SERVERS 0x00000229L
4138 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS 0x0000022AL
4139 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS 0x0000022BL
4140 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS 0x0000022CL
4141 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS 0x0000022DL
4143 #define DOMAIN_ALIAS_RID_MONITORING_USERS 0x0000022EL
4144 #define DOMAIN_ALIAS_RID_LOGGING_USERS 0x0000022FL
4145 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS 0x00000230L
4146 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS 0x00000231L
4147 #define DOMAIN_ALIAS_RID_DCOM_USERS 0x00000232L
4149 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4151 #define SECURITY_PACKAGE_RID_COUNT 2L
4152 #define SECURITY_LOGON_IDS_RID_COUNT 3L
4154 typedef enum {
4155 WinNullSid = 0,
4156 WinWorldSid = 1,
4157 WinLocalSid = 2,
4158 WinCreatorOwnerSid = 3,
4159 WinCreatorGroupSid = 4,
4160 WinCreatorOwnerServerSid = 5,
4161 WinCreatorGroupServerSid = 6,
4162 WinNtAuthoritySid = 7,
4163 WinDialupSid = 8,
4164 WinNetworkSid = 9,
4165 WinBatchSid = 10,
4166 WinInteractiveSid = 11,
4167 WinServiceSid = 12,
4168 WinAnonymousSid = 13,
4169 WinProxySid = 14,
4170 WinEnterpriseControllersSid = 15,
4171 WinSelfSid = 16,
4172 WinAuthenticatedUserSid = 17,
4173 WinRestrictedCodeSid = 18,
4174 WinTerminalServerSid = 19,
4175 WinRemoteLogonIdSid = 20,
4176 WinLogonIdsSid = 21,
4177 WinLocalSystemSid = 22,
4178 WinLocalServiceSid = 23,
4179 WinNetworkServiceSid = 24,
4180 WinBuiltinDomainSid = 25,
4181 WinBuiltinAdministratorsSid = 26,
4182 WinBuiltinUsersSid = 27,
4183 WinBuiltinGuestsSid = 28,
4184 WinBuiltinPowerUsersSid = 29,
4185 WinBuiltinAccountOperatorsSid = 30,
4186 WinBuiltinSystemOperatorsSid = 31,
4187 WinBuiltinPrintOperatorsSid = 32,
4188 WinBuiltinBackupOperatorsSid = 33,
4189 WinBuiltinReplicatorSid = 34,
4190 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4191 WinBuiltinRemoteDesktopUsersSid = 36,
4192 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4193 WinAccountAdministratorSid = 38,
4194 WinAccountGuestSid = 39,
4195 WinAccountKrbtgtSid = 40,
4196 WinAccountDomainAdminsSid = 41,
4197 WinAccountDomainUsersSid = 42,
4198 WinAccountDomainGuestsSid = 43,
4199 WinAccountComputersSid = 44,
4200 WinAccountControllersSid = 45,
4201 WinAccountCertAdminsSid = 46,
4202 WinAccountSchemaAdminsSid = 47,
4203 WinAccountEnterpriseAdminsSid = 48,
4204 WinAccountPolicyAdminsSid = 49,
4205 WinAccountRasAndIasServersSid = 50,
4206 WinNTLMAuthenticationSid = 51,
4207 WinDigestAuthenticationSid = 52,
4208 WinSChannelAuthenticationSid = 53,
4209 WinThisOrganizationSid = 54,
4210 WinOtherOrganizationSid = 55,
4211 WinBuiltinIncomingForestTrustBuildersSid = 56,
4212 WinBuiltinPerfMonitoringUsersSid = 57,
4213 WinBuiltinPerfLoggingUsersSid = 58,
4214 WinBuiltinAuthorizationAccessSid = 59,
4215 WinBuiltinTerminalServerLicenseServersSid = 60,
4216 WinBuiltinDCOMUsersSid = 61,
4217 WinBuiltinIUsersSid = 62,
4218 WinIUserSid = 63,
4219 WinBuiltinCryptoOperatorsSid = 64,
4220 WinUntrustedLabelSid = 65,
4221 WinLowLabelSid = 66,
4222 WinMediumLabelSid = 67,
4223 WinHighLabelSid = 68,
4224 WinSystemLabelSid = 69,
4225 WinWriteRestrictedCodeSid = 70,
4226 WinCreatorOwnerRightsSid = 71,
4227 WinCacheablePrincipalsGroupSid = 72,
4228 WinNonCacheablePrincipalsGroupSid = 73,
4229 WinEnterpriseReadonlyControllersSid = 74,
4230 WinAccountReadonlyControllersSid = 75,
4231 WinBuiltinEventLogReadersGroup = 76,
4232 } WELL_KNOWN_SID_TYPE;
4235 * TOKEN_USER
4238 typedef struct _TOKEN_USER {
4239 SID_AND_ATTRIBUTES User;
4240 } TOKEN_USER, *PTOKEN_USER;
4243 * TOKEN_GROUPS
4246 typedef struct _TOKEN_GROUPS {
4247 DWORD GroupCount;
4248 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4249 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4252 * LUID_AND_ATTRIBUTES
4255 typedef union _LARGE_INTEGER {
4256 struct {
4257 #ifdef WORDS_BIGENDIAN
4258 LONG HighPart;
4259 DWORD LowPart;
4260 #else
4261 DWORD LowPart;
4262 LONG HighPart;
4263 #endif
4264 } u;
4265 #ifndef NONAMELESSSTRUCT
4266 struct {
4267 #ifdef WORDS_BIGENDIAN
4268 LONG HighPart;
4269 DWORD LowPart;
4270 #else
4271 DWORD LowPart;
4272 LONG HighPart;
4273 #endif
4275 #endif
4276 LONGLONG QuadPart;
4277 } LARGE_INTEGER, *PLARGE_INTEGER;
4279 typedef union _ULARGE_INTEGER {
4280 struct {
4281 #ifdef WORDS_BIGENDIAN
4282 DWORD HighPart;
4283 DWORD LowPart;
4284 #else
4285 DWORD LowPart;
4286 DWORD HighPart;
4287 #endif
4288 } u;
4289 #ifndef NONAMELESSSTRUCT
4290 struct {
4291 #ifdef WORDS_BIGENDIAN
4292 DWORD HighPart;
4293 DWORD LowPart;
4294 #else
4295 DWORD LowPart;
4296 DWORD HighPart;
4297 #endif
4299 #endif
4300 ULONGLONG QuadPart;
4301 } ULARGE_INTEGER, *PULARGE_INTEGER;
4304 * Locally Unique Identifier
4307 typedef struct _LUID {
4308 DWORD LowPart;
4309 LONG HighPart;
4310 } LUID, *PLUID;
4312 #include <pshpack4.h>
4313 typedef struct _LUID_AND_ATTRIBUTES {
4314 LUID Luid;
4315 DWORD Attributes;
4316 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4317 #include <poppack.h>
4320 * PRIVILEGE_SET
4323 typedef struct _PRIVILEGE_SET {
4324 DWORD PrivilegeCount;
4325 DWORD Control;
4326 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4327 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4330 * TOKEN_PRIVILEGES
4333 typedef struct _TOKEN_PRIVILEGES {
4334 DWORD PrivilegeCount;
4335 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4336 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4339 * TOKEN_OWNER
4342 typedef struct _TOKEN_OWNER {
4343 PSID Owner;
4344 } TOKEN_OWNER, *PTOKEN_OWNER;
4347 * TOKEN_PRIMARY_GROUP
4350 typedef struct _TOKEN_PRIMARY_GROUP {
4351 PSID PrimaryGroup;
4352 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4356 * TOKEN_DEFAULT_DACL
4359 typedef struct _TOKEN_DEFAULT_DACL {
4360 PACL DefaultDacl;
4361 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4364 * TOKEN_SOURCEL
4367 #define TOKEN_SOURCE_LENGTH 8
4369 typedef struct _TOKEN_SOURCE {
4370 char SourceName[TOKEN_SOURCE_LENGTH];
4371 LUID SourceIdentifier;
4372 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4375 * TOKEN_TYPE
4378 typedef enum tagTOKEN_TYPE {
4379 TokenPrimary = 1,
4380 TokenImpersonation
4381 } TOKEN_TYPE;
4384 * SECURITY_IMPERSONATION_LEVEL
4387 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4388 SecurityAnonymous,
4389 SecurityIdentification,
4390 SecurityImpersonation,
4391 SecurityDelegation
4392 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4394 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4395 #define SECURITY_STATIC_TRACKING (FALSE)
4397 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4398 * PSECURITY_CONTEXT_TRACKING_MODE;
4400 * Quality of Service
4403 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4404 DWORD Length;
4405 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4406 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4407 BOOLEAN EffectiveOnly;
4408 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4411 * TOKEN_STATISTICS
4414 #include <pshpack4.h>
4415 typedef struct _TOKEN_STATISTICS {
4416 LUID TokenId;
4417 LUID AuthenticationId;
4418 LARGE_INTEGER ExpirationTime;
4419 TOKEN_TYPE TokenType;
4420 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4421 DWORD DynamicCharged;
4422 DWORD DynamicAvailable;
4423 DWORD GroupCount;
4424 DWORD PrivilegeCount;
4425 LUID ModifiedId;
4426 } TOKEN_STATISTICS;
4427 #include <poppack.h>
4430 * ACLs of NT
4433 /* ACEs, directly starting after an ACL */
4434 typedef struct _ACE_HEADER {
4435 BYTE AceType;
4436 BYTE AceFlags;
4437 WORD AceSize;
4438 } ACE_HEADER,*PACE_HEADER;
4440 /* AceType */
4441 #define ACCESS_ALLOWED_ACE_TYPE 0
4442 #define ACCESS_DENIED_ACE_TYPE 1
4443 #define SYSTEM_AUDIT_ACE_TYPE 2
4444 #define SYSTEM_ALARM_ACE_TYPE 3
4446 /* inherit AceFlags */
4447 #define OBJECT_INHERIT_ACE 0x01
4448 #define CONTAINER_INHERIT_ACE 0x02
4449 #define NO_PROPAGATE_INHERIT_ACE 0x04
4450 #define INHERIT_ONLY_ACE 0x08
4451 #define INHERITED_ACE 0x10
4452 #define VALID_INHERIT_FLAGS 0x1F
4454 /* AceFlags mask for what events we (should) audit */
4455 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4456 #define FAILED_ACCESS_ACE_FLAG 0x80
4458 /* different ACEs depending on AceType
4459 * SidStart marks the begin of a SID
4460 * so the thing finally looks like this:
4461 * 0: ACE_HEADER
4462 * 4: ACCESS_MASK
4463 * 8... : SID
4465 typedef struct _ACCESS_ALLOWED_ACE {
4466 ACE_HEADER Header;
4467 DWORD Mask;
4468 DWORD SidStart;
4469 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
4471 typedef struct _ACCESS_DENIED_ACE {
4472 ACE_HEADER Header;
4473 DWORD Mask;
4474 DWORD SidStart;
4475 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
4477 typedef struct _SYSTEM_AUDIT_ACE {
4478 ACE_HEADER Header;
4479 DWORD Mask;
4480 DWORD SidStart;
4481 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
4483 typedef struct _SYSTEM_ALARM_ACE {
4484 ACE_HEADER Header;
4485 DWORD Mask;
4486 DWORD SidStart;
4487 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
4489 typedef enum tagSID_NAME_USE {
4490 SidTypeUser = 1,
4491 SidTypeGroup,
4492 SidTypeDomain,
4493 SidTypeAlias,
4494 SidTypeWellKnownGroup,
4495 SidTypeDeletedAccount,
4496 SidTypeInvalid,
4497 SidTypeUnknown
4498 } SID_NAME_USE,*PSID_NAME_USE;
4500 #define ACE_OBJECT_TYPE_PRESENT 0x1
4501 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4503 /* Access rights */
4505 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4506 #undef DELETE
4507 #define DELETE 0x00010000
4508 #define READ_CONTROL 0x00020000
4509 #define WRITE_DAC 0x00040000
4510 #define WRITE_OWNER 0x00080000
4511 #define SYNCHRONIZE 0x00100000
4512 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4514 #define STANDARD_RIGHTS_READ READ_CONTROL
4515 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4516 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4518 #define STANDARD_RIGHTS_ALL 0x001f0000
4520 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4522 #define GENERIC_READ 0x80000000
4523 #define GENERIC_WRITE 0x40000000
4524 #define GENERIC_EXECUTE 0x20000000
4525 #define GENERIC_ALL 0x10000000
4527 #define MAXIMUM_ALLOWED 0x02000000
4528 #define ACCESS_SYSTEM_SECURITY 0x01000000
4530 #define EVENT_QUERY_STATE 0x0001
4531 #define EVENT_MODIFY_STATE 0x0002
4532 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4534 #define SEMAPHORE_MODIFY_STATE 0x0002
4535 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4537 #define MUTEX_MODIFY_STATE 0x0001
4538 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
4540 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
4541 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
4542 #define JOB_OBJECT_QUERY 0x0004
4543 #define JOB_OBJECT_TERMINATE 0x0008
4544 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
4545 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
4547 #define TIMER_QUERY_STATE 0x0001
4548 #define TIMER_MODIFY_STATE 0x0002
4549 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4551 #define PROCESS_TERMINATE 0x0001
4552 #define PROCESS_CREATE_THREAD 0x0002
4553 #define PROCESS_VM_OPERATION 0x0008
4554 #define PROCESS_VM_READ 0x0010
4555 #define PROCESS_VM_WRITE 0x0020
4556 #define PROCESS_DUP_HANDLE 0x0040
4557 #define PROCESS_CREATE_PROCESS 0x0080
4558 #define PROCESS_SET_QUOTA 0x0100
4559 #define PROCESS_SET_INFORMATION 0x0200
4560 #define PROCESS_QUERY_INFORMATION 0x0400
4561 #define PROCESS_SUSPEND_RESUME 0x0800
4562 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
4563 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
4565 #define THREAD_TERMINATE 0x0001
4566 #define THREAD_SUSPEND_RESUME 0x0002
4567 #define THREAD_GET_CONTEXT 0x0008
4568 #define THREAD_SET_CONTEXT 0x0010
4569 #define THREAD_SET_INFORMATION 0x0020
4570 #define THREAD_QUERY_INFORMATION 0x0040
4571 #define THREAD_SET_THREAD_TOKEN 0x0080
4572 #define THREAD_IMPERSONATE 0x0100
4573 #define THREAD_DIRECT_IMPERSONATION 0x0200
4574 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
4576 #define THREAD_BASE_PRIORITY_LOWRT 15
4577 #define THREAD_BASE_PRIORITY_MAX 2
4578 #define THREAD_BASE_PRIORITY_MIN -2
4579 #define THREAD_BASE_PRIORITY_IDLE -15
4581 typedef struct _QUOTA_LIMITS {
4582 SIZE_T PagedPoolLimit;
4583 SIZE_T NonPagedPoolLimit;
4584 SIZE_T MinimumWorkingSetSize;
4585 SIZE_T MaximumWorkingSetSize;
4586 SIZE_T PagefileLimit;
4587 LARGE_INTEGER TimeLimit;
4588 } QUOTA_LIMITS, *PQUOTA_LIMITS;
4590 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
4591 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
4592 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
4593 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
4595 typedef struct _QUOTA_LIMITS_EX {
4596 SIZE_T PagedPoolLimit;
4597 SIZE_T NonPagedPoolLimit;
4598 SIZE_T MinimumWorkingSetSize;
4599 SIZE_T MaximumWorkingSetSize;
4600 SIZE_T PagefileLimit;
4601 LARGE_INTEGER TimeLimit;
4602 SIZE_T Reserved1;
4603 SIZE_T Reserved2;
4604 SIZE_T Reserved3;
4605 SIZE_T Reserved4;
4606 DWORD Flags;
4607 DWORD Reserved5;
4608 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
4610 #define SECTION_QUERY 0x0001
4611 #define SECTION_MAP_WRITE 0x0002
4612 #define SECTION_MAP_READ 0x0004
4613 #define SECTION_MAP_EXECUTE 0x0008
4614 #define SECTION_EXTEND_SIZE 0x0010
4615 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
4616 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
4618 #define FILE_READ_DATA 0x0001 /* file & pipe */
4619 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
4620 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
4621 #define FILE_ADD_FILE 0x0002 /* directory */
4622 #define FILE_APPEND_DATA 0x0004 /* file */
4623 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
4624 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
4625 #define FILE_READ_EA 0x0008 /* file & directory */
4626 #define FILE_READ_PROPERTIES FILE_READ_EA
4627 #define FILE_WRITE_EA 0x0010 /* file & directory */
4628 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
4629 #define FILE_EXECUTE 0x0020 /* file */
4630 #define FILE_TRAVERSE 0x0020 /* directory */
4631 #define FILE_DELETE_CHILD 0x0040 /* directory */
4632 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
4633 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
4634 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
4636 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
4637 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
4638 SYNCHRONIZE)
4639 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
4640 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
4641 FILE_APPEND_DATA | SYNCHRONIZE)
4642 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
4643 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
4645 #define DUPLICATE_CLOSE_SOURCE 0x00000001
4646 #define DUPLICATE_SAME_ACCESS 0x00000002
4648 /* File attribute flags */
4649 #define FILE_SHARE_READ 0x00000001L
4650 #define FILE_SHARE_WRITE 0x00000002L
4651 #define FILE_SHARE_DELETE 0x00000004L
4653 #define FILE_ATTRIBUTE_READONLY 0x00000001
4654 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
4655 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
4656 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
4657 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
4658 #define FILE_ATTRIBUTE_DEVICE 0x00000040
4659 #define FILE_ATTRIBUTE_NORMAL 0x00000080
4660 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
4661 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
4662 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
4663 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
4664 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
4665 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
4666 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
4668 /* File notification flags */
4669 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
4670 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
4671 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
4672 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
4673 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
4674 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
4675 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
4676 #define FILE_NOTIFY_CHANGE_EA 0x00000080
4677 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
4678 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
4679 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
4680 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
4682 #define FILE_ACTION_ADDED 0x00000001
4683 #define FILE_ACTION_REMOVED 0x00000002
4684 #define FILE_ACTION_MODIFIED 0x00000003
4685 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
4686 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
4687 #define FILE_ACTION_ADDED_STREAM 0x00000006
4688 #define FILE_ACTION_REMOVED_STREAM 0x00000007
4689 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
4691 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
4692 #define FILE_CASE_PRESERVED_NAMES 0x00000002
4693 #define FILE_UNICODE_ON_DISK 0x00000004
4694 #define FILE_PERSISTENT_ACLS 0x00000008
4695 #define FILE_FILE_COMPRESSION 0x00000010
4696 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
4697 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
4698 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
4699 #define FILE_NAMED_STREAMS 0x00040000
4700 #define FILE_READ_ONLY_VOLUME 0x00080000
4702 /* File alignments (NT) */
4703 #define FILE_BYTE_ALIGNMENT 0x00000000
4704 #define FILE_WORD_ALIGNMENT 0x00000001
4705 #define FILE_LONG_ALIGNMENT 0x00000003
4706 #define FILE_QUAD_ALIGNMENT 0x00000007
4707 #define FILE_OCTA_ALIGNMENT 0x0000000f
4708 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
4709 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
4710 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
4711 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
4712 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
4714 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
4715 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
4717 #define REG_NONE 0 /* no type */
4718 #define REG_SZ 1 /* string type (ASCII) */
4719 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
4720 #define REG_BINARY 3 /* binary format, callerspecific */
4721 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
4722 #define REG_DWORD 4 /* DWORD in little endian format */
4723 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
4724 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
4725 #define REG_LINK 6 /* symbolic link (UNICODE) */
4726 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
4727 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
4728 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
4729 #define REG_RESOURCE_REQUIREMENTS_LIST 10
4730 #define REG_QWORD 11 /* QWORD in little endian format */
4731 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
4733 /* ----------------------------- begin power management --------------------- */
4735 typedef enum _LATENCY_TIME {
4736 LT_DONT_CARE,
4737 LT_LOWEST_LATENCY
4738 } LATENCY_TIME, *PLATENCY_TIME;
4740 #define DISCHARGE_POLICY_CRITICAL 0
4741 #define DISCHARGE_POLICY_LOW 1
4742 #define NUM_DISCHARGE_POLICIES 4
4744 #define PO_THROTTLE_NONE 0
4745 #define PO_THROTTLE_CONSTANT 1
4746 #define PO_THROTTLE_DEGRADE 2
4747 #define PO_THROTTLE_ADAPTIVE 3
4749 typedef enum _POWER_ACTION {
4750 PowerActionNone = 0,
4751 PowerActionReserved,
4752 PowerActionSleep,
4753 PowerActionHibernate,
4754 PowerActionShutdown,
4755 PowerActionShutdownReset,
4756 PowerActionShutdownOff,
4757 PowerActionWarmEject
4758 } POWER_ACTION,
4759 *PPOWER_ACTION;
4761 typedef enum _SYSTEM_POWER_STATE {
4762 PowerSystemUnspecified = 0,
4763 PowerSystemWorking = 1,
4764 PowerSystemSleeping1 = 2,
4765 PowerSystemSleeping2 = 3,
4766 PowerSystemSleeping3 = 4,
4767 PowerSystemHibernate = 5,
4768 PowerSystemShutdown = 6,
4769 PowerSystemMaximum = 7
4770 } SYSTEM_POWER_STATE,
4771 *PSYSTEM_POWER_STATE;
4773 typedef enum _DEVICE_POWER_STATE {
4774 PowerDeviceUnspecified,
4775 PowerDeviceD0,
4776 PowerDeviceD1,
4777 PowerDeviceD2,
4778 PowerDeviceD3,
4779 PowerDeviceMaximum
4780 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
4782 typedef enum _POWER_INFORMATION_LEVEL {
4783 SystemPowerPolicyAc,
4784 SystemPowerPolicyDc,
4785 VerifySystemPolicyAc,
4786 VerifySystemPolicyDc,
4787 SystemPowerCapabilities,
4788 SystemBatteryState,
4789 SystemPowerStateHandler,
4790 ProcessorStateHandler,
4791 SystemPowerPolicyCurrent,
4792 AdministratorPowerPolicy,
4793 SystemReserveHiberFile,
4794 ProcessorInformation,
4795 SystemPowerInformation,
4796 ProcessorStateHandler2,
4797 LastWakeTime,
4798 LastSleepTime,
4799 SystemExecutionState,
4800 SystemPowerStateNotifyHandler,
4801 ProcessorPowerPolicyAc,
4802 ProcessorPowerPolicyDc,
4803 VerifyProcessorPowerPolicyAc,
4804 VerifyProcessorPowerPolicyDc,
4805 ProcessorPowerPolicyCurrent
4806 } POWER_INFORMATION_LEVEL;
4808 typedef struct _ADMINISTRATOR_POWER_POLICY {
4809 SYSTEM_POWER_STATE MinSleep;
4810 SYSTEM_POWER_STATE MaxSleep;
4811 ULONG MinVideoTimeout;
4812 ULONG MaxVideoTimeout;
4813 ULONG MinSpindownTimeout;
4814 ULONG MaxSpindownTimeout;
4815 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
4817 typedef struct {
4818 ULONG Granularity;
4819 ULONG Capacity;
4820 } BATTERY_REPORTING_SCALE,
4821 *PBATTERY_REPORTING_SCALE;
4823 typedef struct {
4824 POWER_ACTION Action;
4825 ULONG Flags;
4826 ULONG EventCode;
4827 } POWER_ACTION_POLICY,
4828 *PPOWER_ACTION_POLICY;
4830 typedef struct _PROCESSOR_POWER_INFORMATION {
4831 ULONG Number;
4832 ULONG MaxMhz;
4833 ULONG CurrentMhz;
4834 ULONG MhzLimit;
4835 ULONG MaxIdleState;
4836 ULONG CurrentIdleState;
4837 } PROCESSOR_POWER_INFORMATION,
4838 *PPROCESSOR_POWER_INFORMATION;
4840 typedef struct _PROCESSOR_POWER_POLICY_INFO {
4841 ULONG TimeCheck;
4842 ULONG DemoteLimit;
4843 ULONG PromoteLimit;
4844 UCHAR DemotePercent;
4845 UCHAR PromotePercent;
4846 UCHAR Spare[2];
4847 ULONG AllowDemotion:1;
4848 ULONG AllowPromotion:1;
4849 ULONG Reserved:30;
4850 } PROCESSOR_POWER_POLICY_INFO,
4851 *PPROCESSOR_POWER_POLICY_INFO;
4853 typedef struct _PROCESSOR_POWER_POLICY {
4854 DWORD Revision;
4855 BYTE DynamicThrottle;
4856 BYTE Spare[3];
4857 DWORD DisableCStates:1;
4858 DWORD Reserved:31;
4859 DWORD PolicyCount;
4860 PROCESSOR_POWER_POLICY_INFO Policy[3];
4861 } PROCESSOR_POWER_POLICY,
4862 *PPROCESSOR_POWER_POLICY;
4864 typedef struct {
4865 BOOLEAN AcOnLine;
4866 BOOLEAN BatteryPresent;
4867 BOOLEAN Charging;
4868 BOOLEAN Discharging;
4869 BOOLEAN Spare1[4];
4870 ULONG MaxCapacity;
4871 ULONG RemainingCapacity;
4872 ULONG Rate;
4873 ULONG EstimatedTime;
4874 ULONG DefaultAlert1;
4875 ULONG DefaultAlert2;
4876 } SYSTEM_BATTERY_STATE,
4877 *PSYSTEM_BATTERY_STATE;
4879 typedef struct {
4880 BOOLEAN PowerButtonPresent;
4881 BOOLEAN SleepButtonPresent;
4882 BOOLEAN LidPresent;
4883 BOOLEAN SystemS1;
4884 BOOLEAN SystemS2;
4885 BOOLEAN SystemS3;
4886 BOOLEAN SystemS4;
4887 BOOLEAN SystemS5;
4888 BOOLEAN HiberFilePresent;
4889 BOOLEAN FullWake;
4890 BOOLEAN VideoDimPresent;
4891 BOOLEAN ApmPresent;
4892 BOOLEAN UpsPresent;
4893 BOOLEAN ThermalControl;
4894 BOOLEAN ProcessorThrottle;
4895 UCHAR ProcessorMinThrottle;
4896 UCHAR ProcessorMaxThrottle;
4897 UCHAR spare2[4];
4898 BOOLEAN DiskSpinDown;
4899 UCHAR spare3[8];
4900 BOOLEAN SystemBatteriesPresent;
4901 BOOLEAN BatteriesAreShortTerm;
4902 BATTERY_REPORTING_SCALE BatteryScale[3];
4903 SYSTEM_POWER_STATE AcOnLineWake;
4904 SYSTEM_POWER_STATE SoftLidWake;
4905 SYSTEM_POWER_STATE RtcWake;
4906 SYSTEM_POWER_STATE MinDeviceWakeState;
4907 SYSTEM_POWER_STATE DefaultLowLatencyWake;
4908 } SYSTEM_POWER_CAPABILITIES,
4909 *PSYSTEM_POWER_CAPABILITIES;
4911 typedef struct _SYSTEM_POWER_INFORMATION {
4912 ULONG MaxIdlenessAllowed;
4913 ULONG Idleness;
4914 ULONG TimeRemaining;
4915 UCHAR CoolingMode;
4916 } SYSTEM_POWER_INFORMATION,
4917 *PSYSTEM_POWER_INFORMATION;
4919 typedef struct _SYSTEM_POWER_LEVEL {
4920 BOOLEAN Enable;
4921 UCHAR Spare[3];
4922 ULONG BatteryLevel;
4923 POWER_ACTION_POLICY PowerPolicy;
4924 SYSTEM_POWER_STATE MinSystemState;
4925 } SYSTEM_POWER_LEVEL,
4926 *PSYSTEM_POWER_LEVEL;
4928 typedef struct _SYSTEM_POWER_POLICY {
4929 ULONG Revision;
4930 POWER_ACTION_POLICY PowerButton;
4931 POWER_ACTION_POLICY SleepButton;
4932 POWER_ACTION_POLICY LidClose;
4933 SYSTEM_POWER_STATE LidOpenWake;
4934 ULONG Reserved;
4935 POWER_ACTION_POLICY Idle;
4936 ULONG IdleTimeout;
4937 UCHAR IdleSensitivity;
4938 UCHAR DynamicThrottle;
4939 UCHAR Spare2[2];
4940 SYSTEM_POWER_STATE MinSleep;
4941 SYSTEM_POWER_STATE MaxSleep;
4942 SYSTEM_POWER_STATE ReducedLatencySleep;
4943 ULONG WinLogonFlags;
4944 ULONG Spare3;
4945 ULONG DozeS4Timeout;
4946 ULONG BroadcastCapacityResolution;
4947 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
4948 ULONG VideoTimeout;
4949 BOOLEAN VideoDimDisplay;
4950 ULONG VideoReserved[3];
4951 ULONG SpindownTimeout;
4952 BOOLEAN OptimizeForPower;
4953 UCHAR FanThrottleTolerance;
4954 UCHAR ForcedThrottle;
4955 UCHAR MinThrottle;
4956 POWER_ACTION_POLICY OverThrottled;
4957 } SYSTEM_POWER_POLICY,
4958 *PSYSTEM_POWER_POLICY;
4960 typedef union _FILE_SEGMENT_ELEMENT {
4961 PVOID64 Buffer;
4962 ULONGLONG Alignment;
4963 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
4965 typedef struct _FILE_NOTIFY_INFORMATION {
4966 DWORD NextEntryOffset;
4967 DWORD Action;
4968 DWORD FileNameLength;
4969 WCHAR FileName[1];
4970 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
4972 /* ----------------------------- begin tape storage --------------------- */
4974 #define TAPE_FIXED_PARTITIONS 0
4975 #define TAPE_SELECT_PARTITIONS 1
4976 #define TAPE_INITIATOR_PARTITIONS 2
4977 #define TAPE_ERASE_SHORT 0
4978 #define TAPE_ERASE_LONG 1
4979 #define TAPE_LOAD 0
4980 #define TAPE_UNLOAD 1
4981 #define TAPE_TENSION 2
4982 #define TAPE_LOCK 3
4983 #define TAPE_UNLOCK 4
4984 #define TAPE_FORMAT 5
4985 #define TAPE_SETMARKS 0
4986 #define TAPE_FILEMARKS 1
4987 #define TAPE_SHORT_FILEMARKS 2
4988 #define TAPE_LONG_FILEMARKS 3
4989 #define TAPE_REWIND 0
4990 #define TAPE_ABSOLUTE_BLOCK 1
4991 #define TAPE_LOGICAL_BLOCK 2
4992 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
4993 #define TAPE_SPACE_END_OF_DATA 4
4994 #define TAPE_SPACE_RELATIVE_BLOCKS 5
4995 #define TAPE_SPACE_FILEMARKS 6
4996 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
4997 #define TAPE_SPACE_SETMARKS 8
4998 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5000 typedef struct _TAPE_CREATE_PARTITION {
5001 DWORD Method;
5002 DWORD Count;
5003 DWORD Size;
5004 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5006 typedef struct _TAPE_ERASE {
5007 DWORD Type;
5008 BOOLEAN Immediate;
5009 } TAPE_ERASE, *PTAPE_ERASE;
5011 typedef struct _TAPE_PREPARE {
5012 DWORD Operation;
5013 BOOLEAN Immediate;
5014 } TAPE_PREPARE, *PTAPE_PREPARE;
5016 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5017 BOOLEAN ECC;
5018 BOOLEAN Compression;
5019 BOOLEAN DataPadding;
5020 BOOLEAN ReportSetmarks;
5021 ULONG EOTWarningZoneSize;
5022 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5024 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5025 ULONG BlockSize;
5026 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5028 typedef struct _TAPE_WRITE_MARKS {
5029 DWORD Type;
5030 DWORD Count;
5031 BOOLEAN Immediate;
5032 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5034 typedef struct _TAPE_GET_POSITION {
5035 ULONG Type;
5036 ULONG Partition;
5037 ULONG OffsetLow;
5038 ULONG OffsetHigh;
5039 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5041 typedef struct _TAPE_SET_POSITION {
5042 ULONG Method;
5043 ULONG Partition;
5044 LARGE_INTEGER Offset;
5045 BOOLEAN Immediate;
5046 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5048 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5049 BOOLEAN ECC;
5050 BOOLEAN Compression;
5051 BOOLEAN DataPadding;
5052 BOOLEAN ReportSetmarks;
5053 DWORD DefaultBlockSize;
5054 DWORD MaximumBlockSize;
5055 DWORD MinimumBlockSize;
5056 DWORD MaximumPartitionCount;
5057 DWORD FeaturesLow;
5058 DWORD FeaturesHigh;
5059 DWORD EOTWarningZoneSize;
5060 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
5062 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
5063 LARGE_INTEGER Capacity;
5064 LARGE_INTEGER Remaining;
5065 DWORD BlockSize;
5066 DWORD PartitionCount;
5067 BOOLEAN WriteProtected;
5068 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
5070 /* ----------------------------- begin registry ----------------------------- */
5072 /* Registry security values */
5073 #define OWNER_SECURITY_INFORMATION 0x00000001
5074 #define GROUP_SECURITY_INFORMATION 0x00000002
5075 #define DACL_SECURITY_INFORMATION 0x00000004
5076 #define SACL_SECURITY_INFORMATION 0x00000008
5078 #define REG_OPTION_RESERVED 0x00000000
5079 #define REG_OPTION_NON_VOLATILE 0x00000000
5080 #define REG_OPTION_VOLATILE 0x00000001
5081 #define REG_OPTION_CREATE_LINK 0x00000002
5082 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5083 #define REG_OPTION_OPEN_LINK 0x00000008
5084 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
5085 REG_OPTION_NON_VOLATILE| \
5086 REG_OPTION_VOLATILE| \
5087 REG_OPTION_CREATE_LINK| \
5088 REG_OPTION_BACKUP_RESTORE| \
5089 REG_OPTION_OPEN_LINK)
5092 #define REG_CREATED_NEW_KEY 0x00000001
5093 #define REG_OPENED_EXISTING_KEY 0x00000002
5095 /* For RegNotifyChangeKeyValue */
5096 #define REG_NOTIFY_CHANGE_NAME 0x01
5097 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5098 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5099 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5101 #define KEY_QUERY_VALUE 0x00000001
5102 #define KEY_SET_VALUE 0x00000002
5103 #define KEY_CREATE_SUB_KEY 0x00000004
5104 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5105 #define KEY_NOTIFY 0x00000010
5106 #define KEY_CREATE_LINK 0x00000020
5107 #define KEY_WOW64_64KEY 0x00000100
5108 #define KEY_WOW64_32KEY 0x00000200
5109 #define KEY_WOW64_RES 0x00000300
5111 /* for RegKeyRestore flags */
5112 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5113 #define REG_REFRESH_HIVE 0x00000002
5114 #define REG_NO_LAZY_FLUSH 0x00000004
5115 #define REG_FORCE_RESTORE 0x00000008
5117 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5118 KEY_QUERY_VALUE| \
5119 KEY_ENUMERATE_SUB_KEYS| \
5120 KEY_NOTIFY) \
5121 & (~SYNCHRONIZE) \
5123 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5124 KEY_SET_VALUE| \
5125 KEY_CREATE_SUB_KEY) \
5126 & (~SYNCHRONIZE) \
5128 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5129 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5130 KEY_QUERY_VALUE| \
5131 KEY_SET_VALUE| \
5132 KEY_CREATE_SUB_KEY| \
5133 KEY_ENUMERATE_SUB_KEYS| \
5134 KEY_NOTIFY| \
5135 KEY_CREATE_LINK) \
5136 & (~SYNCHRONIZE) \
5138 /* ------------------------------ end registry ------------------------------ */
5141 #define EVENTLOG_SUCCESS 0x0000
5142 #define EVENTLOG_ERROR_TYPE 0x0001
5143 #define EVENTLOG_WARNING_TYPE 0x0002
5144 #define EVENTLOG_INFORMATION_TYPE 0x0004
5145 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5146 #define EVENTLOG_AUDIT_FAILURE 0x0010
5148 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5149 #define EVENTLOG_SEEK_READ 0x0002
5150 #define EVENTLOG_FORWARDS_READ 0x0004
5151 #define EVENTLOG_BACKWARDS_READ 0x0008
5153 typedef struct _EVENTLOGRECORD {
5154 DWORD Length;
5155 DWORD Reserved;
5156 DWORD RecordNumber;
5157 DWORD TimeGenerated;
5158 DWORD TimeWritten;
5159 DWORD EventID;
5160 WORD EventType;
5161 WORD NumStrings;
5162 WORD EventCategory;
5163 WORD ReservedFlags;
5164 DWORD ClosingRecordNumber;
5165 DWORD StringOffset;
5166 DWORD UserSidLength;
5167 DWORD UserSidOffset;
5168 DWORD DataLength;
5169 DWORD DataOffset;
5170 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5172 #define SERVICE_BOOT_START 0x00000000
5173 #define SERVICE_SYSTEM_START 0x00000001
5174 #define SERVICE_AUTO_START 0x00000002
5175 #define SERVICE_DEMAND_START 0x00000003
5176 #define SERVICE_DISABLED 0x00000004
5178 #define SERVICE_ERROR_IGNORE 0x00000000
5179 #define SERVICE_ERROR_NORMAL 0x00000001
5180 #define SERVICE_ERROR_SEVERE 0x00000002
5181 #define SERVICE_ERROR_CRITICAL 0x00000003
5183 /* Service types */
5184 #define SERVICE_KERNEL_DRIVER 0x00000001
5185 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5186 #define SERVICE_ADAPTER 0x00000004
5187 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5189 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5190 SERVICE_RECOGNIZER_DRIVER )
5192 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5193 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5194 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5196 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5198 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5199 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5202 typedef enum _CM_SERVICE_NODE_TYPE
5204 DriverType = SERVICE_KERNEL_DRIVER,
5205 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
5206 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
5207 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
5208 AdapterType = SERVICE_ADAPTER,
5209 RecognizerType = SERVICE_RECOGNIZER_DRIVER
5210 } SERVICE_NODE_TYPE;
5212 typedef enum _CM_SERVICE_LOAD_TYPE
5214 BootLoad = SERVICE_BOOT_START,
5215 SystemLoad = SERVICE_SYSTEM_START,
5216 AutoLoad = SERVICE_AUTO_START,
5217 DemandLoad = SERVICE_DEMAND_START,
5218 DisableLoad = SERVICE_DISABLED
5219 } SERVICE_LOAD_TYPE;
5221 typedef enum _CM_ERROR_CONTROL_TYPE
5223 IgnoreError = SERVICE_ERROR_IGNORE,
5224 NormalError = SERVICE_ERROR_NORMAL,
5225 SevereError = SERVICE_ERROR_SEVERE,
5226 CriticalError = SERVICE_ERROR_CRITICAL
5227 } SERVICE_ERROR_TYPE;
5231 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5232 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5233 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5234 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5235 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5237 #include <guiddef.h>
5239 typedef struct _OBJECT_TYPE_LIST {
5240 WORD Level;
5241 WORD Sbz;
5242 GUID *ObjectType;
5243 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
5245 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5247 WORD Type;
5248 WORD CreatorBackTraceIndex;
5249 struct _RTL_CRITICAL_SECTION *CriticalSection;
5250 LIST_ENTRY ProcessLocksList;
5251 DWORD EntryCount;
5252 DWORD ContentionCount;
5253 #ifdef __WINESRC__ /* in Wine we store the name here */
5254 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
5255 #else
5256 DWORD Spare[ 2 ];
5257 #endif
5258 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
5260 typedef struct _RTL_CRITICAL_SECTION {
5261 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
5262 LONG LockCount;
5263 LONG RecursionCount;
5264 HANDLE OwningThread;
5265 HANDLE LockSemaphore;
5266 ULONG_PTR SpinCount;
5267 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
5269 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5270 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5271 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5272 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5273 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5275 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
5276 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
5278 #include <pshpack8.h>
5279 typedef struct _IO_COUNTERS {
5280 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
5281 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
5282 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
5283 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
5284 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
5285 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
5286 } IO_COUNTERS, *PIO_COUNTERS;
5287 #include <poppack.h>
5289 typedef struct {
5290 DWORD dwOSVersionInfoSize;
5291 DWORD dwMajorVersion;
5292 DWORD dwMinorVersion;
5293 DWORD dwBuildNumber;
5294 DWORD dwPlatformId;
5295 CHAR szCSDVersion[128];
5296 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5298 typedef struct {
5299 DWORD dwOSVersionInfoSize;
5300 DWORD dwMajorVersion;
5301 DWORD dwMinorVersion;
5302 DWORD dwBuildNumber;
5303 DWORD dwPlatformId;
5304 WCHAR szCSDVersion[128];
5305 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
5307 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
5308 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
5309 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
5311 typedef struct {
5312 DWORD dwOSVersionInfoSize;
5313 DWORD dwMajorVersion;
5314 DWORD dwMinorVersion;
5315 DWORD dwBuildNumber;
5316 DWORD dwPlatformId;
5317 CHAR szCSDVersion[128];
5318 WORD wServicePackMajor;
5319 WORD wServicePackMinor;
5320 WORD wSuiteMask;
5321 BYTE wProductType;
5322 BYTE wReserved;
5323 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5325 typedef struct {
5326 DWORD dwOSVersionInfoSize;
5327 DWORD dwMajorVersion;
5328 DWORD dwMinorVersion;
5329 DWORD dwBuildNumber;
5330 DWORD dwPlatformId;
5331 WCHAR szCSDVersion[128];
5332 WORD wServicePackMajor;
5333 WORD wServicePackMinor;
5334 WORD wSuiteMask;
5335 BYTE wProductType;
5336 BYTE wReserved;
5337 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
5339 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
5340 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
5341 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
5343 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
5345 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5347 #define VER_PLATFORM_WIN32s 0
5348 #define VER_PLATFORM_WIN32_WINDOWS 1
5349 #define VER_PLATFORM_WIN32_NT 2
5351 #define VER_MINORVERSION 0x00000001
5352 #define VER_MAJORVERSION 0x00000002
5353 #define VER_BUILDNUMBER 0x00000004
5354 #define VER_PLATFORMID 0x00000008
5355 #define VER_SERVICEPACKMINOR 0x00000010
5356 #define VER_SERVICEPACKMAJOR 0x00000020
5357 #define VER_SUITENAME 0x00000040
5358 #define VER_PRODUCT_TYPE 0x00000080
5360 #define VER_NT_WORKSTATION 1
5361 #define VER_NT_DOMAIN_CONTROLLER 2
5362 #define VER_NT_SERVER 3
5364 #define VER_SUITE_SMALLBUSINESS 0x00000001
5365 #define VER_SUITE_ENTERPRISE 0x00000002
5366 #define VER_SUITE_BACKOFFICE 0x00000004
5367 #define VER_SUITE_COMMUNICATIONS 0x00000008
5368 #define VER_SUITE_TERMINAL 0x00000010
5369 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5370 #define VER_SUITE_EMBEDDEDNT 0x00000040
5371 #define VER_SUITE_DATACENTER 0x00000080
5372 #define VER_SUITE_SINGLEUSERTS 0x00000100
5373 #define VER_SUITE_PERSONAL 0x00000200
5374 #define VER_SUITE_BLADE 0x00000400
5376 #define VER_EQUAL 1
5377 #define VER_GREATER 2
5378 #define VER_GREATER_EQUAL 3
5379 #define VER_LESS 4
5380 #define VER_LESS_EQUAL 5
5381 #define VER_AND 6
5382 #define VER_OR 7
5384 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
5385 DWORD dwFlags;
5386 DWORD ulFormatVersion;
5387 DWORD ulAssemblyCount;
5388 DWORD ulRootManifestPathType;
5389 DWORD ulRootManifestPathChars;
5390 DWORD ulRootConfigurationPathType;
5391 DWORD ulRootConfigurationPathChars;
5392 DWORD ulAppDirPathType;
5393 DWORD ulAppDirPathChars;
5394 PCWSTR lpRootManifestPath;
5395 PCWSTR lpRootConfigurationPath;
5396 PCWSTR lpAppDirPath;
5397 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
5399 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
5400 DWORD ulFlags;
5401 DWORD ulEncodedAssemblyIdentityLength;
5402 DWORD ulManifestPathType;
5403 DWORD ulManifestPathLength;
5404 LARGE_INTEGER liManifestLastWriteTime;
5405 DWORD ulPolicyPathType;
5406 DWORD ulPolicyPathLength;
5407 LARGE_INTEGER liPolicyLastWriteTime;
5408 DWORD ulMetadataSatelliteRosterIndex;
5409 DWORD ulManifestVersionMajor;
5410 DWORD ulManifestVersionMinor;
5411 DWORD ulPolicyVersionMajor;
5412 DWORD ulPolicyVersionMinor;
5413 DWORD ulAssemblyDirectoryNameLength;
5414 PCWSTR lpAssemblyEncodedAssemblyIdentity;
5415 PCWSTR lpAssemblyManifestPath;
5416 PCWSTR lpAssemblyPolicyPath;
5417 PCWSTR lpAssemblyDirectoryName;
5418 DWORD ulFileCount;
5419 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
5421 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
5422 DWORD ulAssemblyIndex;
5423 DWORD ulFileIndexInAssembly;
5424 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
5426 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
5428 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
5429 DWORD ulFlags;
5430 DWORD ulFilenameLength;
5431 DWORD ulPathLength;
5432 PCWSTR lpFileName;
5433 PCWSTR lpFilePath;
5434 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
5436 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
5438 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
5439 ActivationContextBasicInformation = 1,
5440 ActivationContextDetailedInformation = 2,
5441 AssemblyDetailedInformationInActivationContext = 3,
5442 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
5443 MaxActivationContextInfoClass,
5445 AssemblyDetailedInformationInActivationContxt = 3,
5446 FileInformationInAssemblyOfAssemblyInActivationContxt = 4
5447 } ACTIVATION_CONTEXT_INFO_CLASS;
5449 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
5450 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
5451 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
5452 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
5454 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
5455 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
5456 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
5457 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
5458 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
5459 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
5460 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
5461 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
5462 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
5464 typedef enum _JOBOBJECTINFOCLASS
5466 JobObjectBasicAccountingInformation = 1,
5467 JobObjectBasicLimitInformation,
5468 JobObjectBasicProcessIdList,
5469 JobObjectBasicUIRestrictions,
5470 JobObjectSecurityLimitInformation,
5471 JobObjectEndOfJobTimeInformation,
5472 JobObjectAssociateCompletionPortInformation,
5473 JobObjectBasicAndIoAccountingInformation,
5474 JobObjectExtendedLimitInformation,
5475 JobObjectJobSetInformation,
5476 MaxJobObjectInfoClass
5477 } JOBOBJECTINFOCLASS;
5479 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
5481 #ifdef __cplusplus
5483 #endif
5485 #endif /* _WINNT_ */