kernel32/tests: Add a missing linebreak to an ok() message.
[wine.git] / include / winnt.h
blob72c399b410f4c5d46c7f1e083b98ea3cfb0f139e
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))) && !defined(__sun)
152 # define DECLSPEC_EXPORT __attribute__((visibility ("default")))
153 #else
154 # define DECLSPEC_EXPORT
155 #endif
157 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || defined(__sun)
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 #undef DUMMYSTRUCTNAME
196 #undef DUMMYSTRUCTNAME1
197 #undef DUMMYSTRUCTNAME2
198 #undef DUMMYSTRUCTNAME3
199 #undef DUMMYSTRUCTNAME4
200 #undef DUMMYSTRUCTNAME5
201 #ifndef NONAMELESSSTRUCT
202 #define DUMMYSTRUCTNAME
203 #define DUMMYSTRUCTNAME1
204 #define DUMMYSTRUCTNAME2
205 #define DUMMYSTRUCTNAME3
206 #define DUMMYSTRUCTNAME4
207 #define DUMMYSTRUCTNAME5
208 #else /* !defined(NONAMELESSSTRUCT) */
209 #define DUMMYSTRUCTNAME s
210 #define DUMMYSTRUCTNAME1 s1
211 #define DUMMYSTRUCTNAME2 s2
212 #define DUMMYSTRUCTNAME3 s3
213 #define DUMMYSTRUCTNAME4 s4
214 #define DUMMYSTRUCTNAME5 s5
215 #endif /* !defined(NONAMELESSSTRUCT) */
217 #undef DUMMYUNIONNAME
218 #undef DUMMYUNIONNAME1
219 #undef DUMMYUNIONNAME2
220 #undef DUMMYUNIONNAME3
221 #undef DUMMYUNIONNAME4
222 #undef DUMMYUNIONNAME5
223 #undef DUMMYUNIONNAME6
224 #undef DUMMYUNIONNAME7
225 #undef DUMMYUNIONNAME8
226 #ifndef NONAMELESSUNION
227 #define DUMMYUNIONNAME
228 #define DUMMYUNIONNAME1
229 #define DUMMYUNIONNAME2
230 #define DUMMYUNIONNAME3
231 #define DUMMYUNIONNAME4
232 #define DUMMYUNIONNAME5
233 #define DUMMYUNIONNAME6
234 #define DUMMYUNIONNAME7
235 #define DUMMYUNIONNAME8
236 #else /* !defined(NONAMELESSUNION) */
237 #define DUMMYUNIONNAME u
238 #define DUMMYUNIONNAME1 u1
239 #define DUMMYUNIONNAME2 u2
240 #define DUMMYUNIONNAME3 u3
241 #define DUMMYUNIONNAME4 u4
242 #define DUMMYUNIONNAME5 u5
243 #define DUMMYUNIONNAME6 u6
244 #define DUMMYUNIONNAME7 u7
245 #define DUMMYUNIONNAME8 u8
246 #endif /* !defined(NONAMELESSUNION) */
248 #undef __C89_NAMELESS
249 #undef __C89_NAMELESSSTRUCTNAME
250 #undef __C89_NAMELESSSTRUCTNAME1
251 #undef __C89_NAMELESSSTRUCTNAME2
252 #undef __C89_NAMELESSSTRUCTNAME3
253 #undef __C89_NAMELESSSTRUCTNAME4
254 #undef __C89_NAMELESSSTRUCTNAME5
255 #undef __C89_NAMELESSUNIONNAME
256 #undef __C89_NAMELESSUNIONNAME1
257 #undef __C89_NAMELESSUNIONNAME2
258 #undef __C89_NAMELESSUNIONNAME3
259 #undef __C89_NAMELESSUNIONNAME4
260 #undef __C89_NAMELESSUNIONNAME5
261 #undef __C89_NAMELESSUNIONNAME6
262 #undef __C89_NAMELESSUNIONNAME7
263 #undef __C89_NAMELESSUNIONNAME8
265 #if !defined(__WINESRC__) && !defined(WINE_NO_NAMELESS_EXTENSION)
266 # ifdef __GNUC__
267 /* Anonymous structs support starts with gcc 2.96/g++ 2.95 */
268 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ > 95) || ((__GNUC_MINOR__ == 95) && defined(__cplusplus))))
269 # define __C89_NAMELESS __extension__
270 # endif
271 # elif defined(_MSC_VER)
272 # define __C89_NAMELESS
273 # endif
274 #endif
276 #ifdef __C89_NAMELESS
277 # define __C89_NAMELESSSTRUCTNAME
278 # define __C89_NAMELESSSTRUCTNAME1
279 # define __C89_NAMELESSSTRUCTNAME2
280 # define __C89_NAMELESSSTRUCTNAME3
281 # define __C89_NAMELESSSTRUCTNAME4
282 # define __C89_NAMELESSSTRUCTNAME5
283 # define __C89_NAMELESSUNIONNAME
284 # define __C89_NAMELESSUNIONNAME1
285 # define __C89_NAMELESSUNIONNAME2
286 # define __C89_NAMELESSUNIONNAME3
287 # define __C89_NAMELESSUNIONNAME4
288 # define __C89_NAMELESSUNIONNAME5
289 # define __C89_NAMELESSUNIONNAME6
290 # define __C89_NAMELESSUNIONNAME7
291 # define __C89_NAMELESSUNIONNAME8
292 #else
293 # define __C89_NAMELESS
294 # define __C89_NAMELESSSTRUCTNAME DUMMYSTRUCTNAME
295 # define __C89_NAMELESSSTRUCTNAME1 DUMMYSTRUCTNAME1
296 # define __C89_NAMELESSSTRUCTNAME2 DUMMYSTRUCTNAME2
297 # define __C89_NAMELESSSTRUCTNAME3 DUMMYSTRUCTNAME3
298 # define __C89_NAMELESSSTRUCTNAME4 DUMMYSTRUCTNAME4
299 # define __C89_NAMELESSSTRUCTNAME5 DUMMYSTRUCTNAME5
300 # define __C89_NAMELESSUNIONNAME DUMMYUNIONNAME
301 # define __C89_NAMELESSUNIONNAME1 DUMMYUNIONNAME1
302 # define __C89_NAMELESSUNIONNAME2 DUMMYUNIONNAME2
303 # define __C89_NAMELESSUNIONNAME3 DUMMYUNIONNAME3
304 # define __C89_NAMELESSUNIONNAME4 DUMMYUNIONNAME4
305 # define __C89_NAMELESSUNIONNAME5 DUMMYUNIONNAME5
306 # define __C89_NAMELESSUNIONNAME6 DUMMYUNIONNAME6
307 # define __C89_NAMELESSUNIONNAME7 DUMMYUNIONNAME7
308 # define __C89_NAMELESSUNIONNAME8 DUMMYUNIONNAME8
309 #endif
311 /* C99 restrict support */
313 #if defined(ENABLE_RESTRICTED) && !defined(MIDL_PASS) && !defined(RC_INVOKED)
314 # if defined(_MSC_VER) && defined(_M_MRX000)
315 # define RESTRICTED_POINTER __restrict
316 # elif defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)))
317 # define RESTRICTED_POINTER __restrict
318 # else
319 # define RESTRICTED_POINTER
320 # endif
321 #else
322 # define RESTRICTED_POINTER
323 #endif
325 /* C99 unaligned support */
327 #ifndef UNALIGNED
328 #if defined(_MSC_VER) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64))
329 # define UNALIGNED __unaligned
330 # ifdef _WIN64
331 # define UNALIGNED64 __unaligned
332 # else
333 # define UNALIGNED64
334 # endif
335 #else
336 # define UNALIGNED
337 # define UNALIGNED64
338 #endif
339 #endif
341 /* Alignment macros */
343 #if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_ALPHA)) || defined(__alpha__)
344 #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
345 #define MEMORY_ALLOCATION_ALIGNMENT 16
346 #else
347 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
348 #define MEMORY_ALLOCATION_ALIGNMENT 8
349 #endif
351 #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)
352 # define TYPE_ALIGNMENT(t) __alignof(t)
353 #elif defined(__GNUC__)
354 # define TYPE_ALIGNMENT(t) __alignof__(t)
355 #else
356 # define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test)
357 #endif
359 #ifdef _WIN64
360 # define PROBE_ALIGNMENT(_s) \
361 (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? \
362 TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
363 # define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
364 #else
365 # define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
366 #endif
368 /* Compile time assertion */
370 #if defined(_MSC_VER)
371 # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
372 #else
373 # define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
374 #endif
376 /* Eliminate Microsoft C/C++ compiler warning 4715 */
377 #if defined(_MSC_VER) && (_MSC_VER > 1200)
378 # define DEFAULT_UNREACHABLE default: __assume(0)
379 #elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
380 # define DEFAULT_UNREACHABLE default: __builtin_unreachable()
381 #else
382 # define DEFAULT_UNREACHABLE default:
383 #endif
385 /* Error Masks */
386 #define APPLICATION_ERROR_MASK 0x20000000
387 #define ERROR_SEVERITY_SUCCESS 0x00000000
388 #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
389 #define ERROR_SEVERITY_WARNING 0x80000000
390 #define ERROR_SEVERITY_ERROR 0xC0000000
392 #ifdef __cplusplus
393 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
394 extern "C++" { \
395 inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)|((int)b)); } \
396 inline ENUMTYPE operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
397 inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)&((int)b)); } \
398 inline ENUMTYPE operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
399 inline ENUMTYPE operator ~ (ENUMTYPE a) { return (ENUMTYPE)(~((int)a)); } \
400 inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a)^((int)b)); } \
401 inline ENUMTYPE operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
403 #else
404 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
405 #endif
407 /* Microsoft's macros for declaring functions */
409 #ifdef __cplusplus
410 # define EXTERN_C extern "C"
411 #else
412 # define EXTERN_C extern
413 #endif
415 #define STDMETHODCALLTYPE __stdcall
416 #define STDMETHODVCALLTYPE __cdecl
417 #define STDAPICALLTYPE __stdcall
418 #define STDAPIVCALLTYPE __cdecl
420 #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
421 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
422 #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
423 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
424 #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
425 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
426 #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
427 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
429 /* Define the basic types */
430 #ifndef VOID
431 #define VOID void
432 #endif
433 typedef VOID *PVOID;
434 typedef VOID *PVOID64;
435 typedef BYTE BOOLEAN, *PBOOLEAN;
436 typedef char CHAR, *PCHAR;
437 typedef short SHORT, *PSHORT;
438 #ifdef _MSC_VER
439 typedef long LONG, *PLONG;
440 #else
441 typedef int LONG, *PLONG;
442 #endif
444 /* Some systems might have wchar_t, but we really need 16 bit characters */
445 #ifdef WINE_UNICODE_NATIVE
446 typedef wchar_t WCHAR, *PWCHAR;
447 #else
448 typedef unsigned short WCHAR, *PWCHAR;
449 #endif
451 typedef ULONG UCSCHAR;
452 #define MIN_UCSCHAR (0)
453 #define MAX_UCSCHAR (0x0010ffff)
454 #define UCSCHAR_INVALID_CHARACTER (0xffffffff)
456 /* 'Extended/Wide' numerical types */
457 #ifndef _ULONGLONG_
458 # define _ULONGLONG_
459 # ifdef _MSC_VER
460 typedef signed __int64 LONGLONG, *PLONGLONG;
461 typedef unsigned __int64 ULONGLONG, *PULONGLONG;
462 # else
463 typedef signed __int64 DECLSPEC_ALIGN(8) LONGLONG, *PLONGLONG;
464 typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONGLONG, *PULONGLONG;
465 # endif
466 #endif
468 #ifndef _DWORDLONG_
469 # define _DWORDLONG_
470 # ifdef _MSC_VER
471 typedef ULONGLONG DWORDLONG, *PDWORDLONG;
472 # else
473 typedef ULONGLONG DECLSPEC_ALIGN(8) DWORDLONG, *PDWORDLONG;
474 # endif
475 #endif
477 /* ANSI string types */
478 typedef CHAR *PCH, *LPCH, *PNZCH;
479 typedef const CHAR *PCCH, *LPCCH, *PCNZCH;
480 typedef CHAR *PSTR, *LPSTR, *NPSTR;
481 typedef const CHAR *PCSTR, *LPCSTR;
482 typedef CHAR *PZZSTR;
483 typedef const CHAR *PCZZSTR;
485 /* Unicode string types */
486 typedef const WCHAR *PCWCHAR, *LPCUWCHAR, *PCUWCHAR;
487 typedef WCHAR *PWCH, *LPWCH;
488 typedef const WCHAR *PCWCH, *LPCWCH;
489 typedef WCHAR *PNZWCH, *PUNZWCH;
490 typedef const WCHAR *PCNZWCH, *PCUNZWCH;
491 typedef WCHAR *PWSTR, *LPWSTR, *NWPSTR;
492 typedef const WCHAR *PCWSTR, *LPCWSTR;
493 typedef WCHAR *PZZWSTR, *PUZZWSTR;
494 typedef const WCHAR *PCZZWSTR, *PCUZZWSTR;
495 typedef PWSTR *PZPWSTR;
496 typedef PCWSTR *PZPCWSTR;
498 /* Neutral character and string types */
499 /* These are only defined for Winelib, i.e. _not_ defined for
500 * the emulator. The reason is they depend on the UNICODE
501 * macro which only exists in the user's code.
503 #ifndef WINE_NO_UNICODE_MACROS
504 # ifdef UNICODE
505 # ifndef _TCHAR_DEFINED
506 typedef WCHAR TCHAR, *PTCHAR;
507 # define _TCHAR_DEFINED
508 #endif
509 typedef LPWCH PTCH, LPTCH;
510 typedef LPCWCH PCTCH, LPCTCH;
511 typedef LPWSTR PTSTR, LPTSTR;
512 typedef LPCWSTR PCTSTR, LPCTSTR;
513 typedef LPWSTR PUTSTR, LPUTSTR;
514 typedef LPCWSTR PCUTSTR, LPCUTSTR;
515 typedef PNZWCH PNZTCH;
516 typedef PUNZWCH PUNZTCH;
517 typedef PCNZWCH PCNZTCH;
518 typedef PCUNZWCH PCUNZTCH;
519 typedef PZZWSTR PZZTSTR;
520 typedef PCZZWSTR PCZZTSTR;
521 typedef PUZZWSTR PUZZTSTR;
522 typedef PCUZZWSTR PCUZZTSTR;
523 # else /* UNICODE */
524 # ifndef _TCHAR_DEFINED
525 typedef CHAR TCHAR, *PTCHAR;
526 # define _TCHAR_DEFINED
527 # endif
528 typedef LPCH PTCH, LPTCH;
529 typedef LPCCH PCTCH, LPCTCH;
530 typedef LPSTR PTSTR, LPTSTR;
531 typedef LPCSTR PCTSTR, LPCTSTR;
532 typedef PNZCH PNZTCH, PUNZTCH;
533 typedef PCNZCH PCNZTCH, PCUNZTCH;
534 typedef PZZSTR PZZTSTR, PUZZTSTR;
535 typedef PCZZSTR PCZZTSTR, PCUZZTSTR;
536 # endif /* UNICODE */
537 #endif /* WINE_NO_UNICODE_MACROS */
539 /* UCS string types */
540 typedef UCSCHAR *PUCSCHAR, *PUUCSCHAR;
541 typedef const UCSCHAR *PCUCSCHAR, *PCUUCSCHAR;
542 typedef UCSCHAR *PUCSSTR, *PUUCSSTR;
543 typedef const UCSCHAR *PCUCSSTR, *PCUUCSSTR;
545 /* Misc common WIN32 types */
546 typedef char CCHAR;
547 typedef DWORD LCID, *PLCID;
548 typedef WORD LANGID;
549 typedef DWORD EXECUTION_STATE;
550 #ifndef _HRESULT_DEFINED
551 #define _HRESULT_DEFINED
552 typedef LONG HRESULT;
553 #endif
555 /* Handle type */
557 typedef void *HANDLE;
558 typedef HANDLE *PHANDLE, *LPHANDLE;
560 #ifdef STRICT
561 #define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
562 #else /*STRICT*/
563 #define DECLARE_HANDLE(a) typedef HANDLE a
564 #endif /*STRICT*/
566 typedef BYTE FCHAR;
567 typedef WORD FSHORT;
568 typedef DWORD FLONG;
570 /* Macro to deal with LP64 <=> LLP64 differences in numeric constants with 'l' modifier */
571 #ifndef __MSABI_LONG
572 # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
573 # define __MSABI_LONG(x) x ## l
574 # else
575 # define __MSABI_LONG(x) x
576 # endif
577 #endif
579 /* Defines */
581 #ifndef WIN32_NO_STATUS
583 #define STATUS_WAIT_0 ((DWORD) 0x00000000)
584 #define STATUS_ABANDONED_WAIT_0 ((DWORD) 0x00000080)
585 #define STATUS_USER_APC ((DWORD) 0x000000C0)
586 #define STATUS_TIMEOUT ((DWORD) 0x00000102)
587 #define STATUS_PENDING ((DWORD) 0x00000103)
588 #define STATUS_SEGMENT_NOTIFICATION ((DWORD) 0x40000005)
589 #define STATUS_GUARD_PAGE_VIOLATION ((DWORD) 0x80000001)
590 #define STATUS_DATATYPE_MISALIGNMENT ((DWORD) 0x80000002)
591 #define STATUS_BREAKPOINT ((DWORD) 0x80000003)
592 #define STATUS_SINGLE_STEP ((DWORD) 0x80000004)
593 #define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)
594 #define STATUS_IN_PAGE_ERROR ((DWORD) 0xC0000006)
595 #define STATUS_INVALID_HANDLE ((DWORD) 0xC0000008)
596 #define STATUS_NO_MEMORY ((DWORD) 0xC0000017)
597 #define STATUS_ILLEGAL_INSTRUCTION ((DWORD) 0xC000001D)
598 #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD) 0xC0000025)
599 #define STATUS_INVALID_DISPOSITION ((DWORD) 0xC0000026)
600 #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD) 0xC000008C)
601 #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD) 0xC000008D)
602 #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD) 0xC000008E)
603 #define STATUS_FLOAT_INEXACT_RESULT ((DWORD) 0xC000008F)
604 #define STATUS_FLOAT_INVALID_OPERATION ((DWORD) 0xC0000090)
605 #define STATUS_FLOAT_OVERFLOW ((DWORD) 0xC0000091)
606 #define STATUS_FLOAT_STACK_CHECK ((DWORD) 0xC0000092)
607 #define STATUS_FLOAT_UNDERFLOW ((DWORD) 0xC0000093)
608 #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD) 0xC0000094)
609 #define STATUS_INTEGER_OVERFLOW ((DWORD) 0xC0000095)
610 #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD) 0xC0000096)
611 #define STATUS_STACK_OVERFLOW ((DWORD) 0xC00000FD)
612 #define STATUS_CONTROL_C_EXIT ((DWORD) 0xC000013A)
613 #define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD) 0xC00002B4)
614 #define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD) 0xC00002B5)
615 #define STATUS_REG_NAT_CONSUMPTION ((DWORD) 0xC00002C9)
616 #define STATUS_SXS_EARLY_DEACTIVATION ((DWORD) 0xC015000F)
617 #define STATUS_SXS_INVALID_DEACTIVATION ((DWORD) 0xC0150010)
619 /* status values for ContinueDebugEvent */
620 #define DBG_EXCEPTION_HANDLED ((DWORD) 0x00010001)
621 #define DBG_CONTINUE ((DWORD) 0x00010002)
622 #define DBG_TERMINATE_THREAD ((DWORD) 0x40010003)
623 #define DBG_TERMINATE_PROCESS ((DWORD) 0x40010004)
624 #define DBG_CONTROL_C ((DWORD) 0x40010005)
625 #define DBG_PRINTEXCEPTION_C ((DWORD) 0x40010006)
626 #define DBG_RIPEXCEPTION ((DWORD) 0x40010007)
627 #define DBG_CONTROL_BREAK ((DWORD) 0x40010008)
628 #define DBG_COMMAND_EXCEPTION ((DWORD) 0x40010009)
629 #define DBG_EXCEPTION_NOT_HANDLED ((DWORD) 0x80010001)
631 #endif /* WIN32_NO_STATUS */
633 /* Argument 1 passed to the DllEntryProc. */
634 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
635 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
636 #define DLL_THREAD_ATTACH 2 /* attach new thread */
637 #define DLL_THREAD_DETACH 3 /* detach thread */
638 #ifdef __WINESRC__
639 #define DLL_WINE_PREATTACH 8 /* called before process attach for Wine builtins */
640 #endif
642 /* u.x.wProcessorArchitecture (NT) */
643 #define PROCESSOR_ARCHITECTURE_INTEL 0
644 #define PROCESSOR_ARCHITECTURE_MIPS 1
645 #define PROCESSOR_ARCHITECTURE_ALPHA 2
646 #define PROCESSOR_ARCHITECTURE_PPC 3
647 #define PROCESSOR_ARCHITECTURE_SHX 4
648 #define PROCESSOR_ARCHITECTURE_ARM 5
649 #define PROCESSOR_ARCHITECTURE_IA64 6
650 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
651 #define PROCESSOR_ARCHITECTURE_MSIL 8
652 #define PROCESSOR_ARCHITECTURE_AMD64 9
653 #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
654 #define PROCESSOR_ARCHITECTURE_NEUTRAL 11
655 #define PROCESSOR_ARCHITECTURE_ARM64 12
656 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
658 /* dwProcessorType */
659 #define PROCESSOR_INTEL_386 386
660 #define PROCESSOR_INTEL_486 486
661 #define PROCESSOR_INTEL_PENTIUM 586
662 #define PROCESSOR_INTEL_860 860
663 #define PROCESSOR_INTEL_IA64 2200
664 #define PROCESSOR_AMD_X8664 8664
665 #define PROCESSOR_MIPS_R2000 2000
666 #define PROCESSOR_MIPS_R3000 3000
667 #define PROCESSOR_MIPS_R4000 4000
668 #define PROCESSOR_ALPHA_21064 21064
669 #define PROCESSOR_PPC_601 601
670 #define PROCESSOR_PPC_603 603
671 #define PROCESSOR_PPC_604 604
672 #define PROCESSOR_PPC_620 620
673 #define PROCESSOR_HITACHI_SH3 10003
674 #define PROCESSOR_HITACHI_SH3E 10004
675 #define PROCESSOR_HITACHI_SH4 10005
676 #define PROCESSOR_MOTOROLA_821 821
677 #define PROCESSOR_SHx_SH3 103
678 #define PROCESSOR_SHx_SH4 104
679 #define PROCESSOR_STRONGARM 2577
680 #define PROCESSOR_ARM720 1824 /* 0x720 */
681 #define PROCESSOR_ARM820 2080 /* 0x820 */
682 #define PROCESSOR_ARM920 2336 /* 0x920 */
683 #define PROCESSOR_ARM_7TDMI 70001
684 #define PROCESSOR_OPTIL 18767
686 #ifdef _WIN64
687 #define MAXIMUM_PROCESSORS 64
688 #else
689 #define MAXIMUM_PROCESSORS 32
690 #endif
692 typedef struct _MEMORY_BASIC_INFORMATION
694 LPVOID BaseAddress;
695 LPVOID AllocationBase;
696 DWORD AllocationProtect;
697 SIZE_T RegionSize;
698 DWORD State;
699 DWORD Protect;
700 DWORD Type;
701 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
703 #define PAGE_NOACCESS 0x01
704 #define PAGE_READONLY 0x02
705 #define PAGE_READWRITE 0x04
706 #define PAGE_WRITECOPY 0x08
707 #define PAGE_EXECUTE 0x10
708 #define PAGE_EXECUTE_READ 0x20
709 #define PAGE_EXECUTE_READWRITE 0x40
710 #define PAGE_EXECUTE_WRITECOPY 0x80
711 #define PAGE_GUARD 0x100
712 #define PAGE_NOCACHE 0x200
713 #define PAGE_WRITECOMBINE 0x400
715 #define MEM_COMMIT 0x00001000
716 #define MEM_RESERVE 0x00002000
717 #define MEM_DECOMMIT 0x00004000
718 #define MEM_RELEASE 0x00008000
719 #define MEM_FREE 0x00010000
720 #define MEM_PRIVATE 0x00020000
721 #define MEM_MAPPED 0x00040000
722 #define MEM_RESET 0x00080000
723 #define MEM_TOP_DOWN 0x00100000
724 #define MEM_WRITE_WATCH 0x00200000
725 #define MEM_PHYSICAL 0x00400000
726 #define MEM_LARGE_PAGES 0x20000000
727 #define MEM_4MB_PAGES 0x80000000
729 #define SEC_FILE 0x00800000
730 #define SEC_IMAGE 0x01000000
731 #define SEC_PROTECTED_IMAGE 0x02000000
732 #define SEC_RESERVE 0x04000000
733 #define SEC_COMMIT 0x08000000
734 #define SEC_NOCACHE 0x10000000
735 #define SEC_WRITECOMBINE 0x40000000
736 #define SEC_LARGE_PAGES 0x80000000
737 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
738 #define MEM_IMAGE SEC_IMAGE
740 #define WRITE_WATCH_FLAG_RESET 0x00000001
742 #define AT_ROUND_TO_PAGE 0x40000000
744 #define MINCHAR 0x80
745 #define MAXCHAR 0x7f
746 #define MINSHORT 0x8000
747 #define MAXSHORT 0x7fff
748 #define MINLONG 0x80000000
749 #define MAXLONG 0x7fffffff
750 #define MAXBYTE 0xff
751 #define MAXWORD 0xffff
752 #define MAXDWORD 0xffffffff
753 #define MAXLONGLONG (((LONGLONG)0x7fffffff << 32) | 0xffffffff)
755 #define UNICODE_STRING_MAX_CHARS 32767
757 #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field))
759 #define CONTAINING_RECORD(address, type, field) \
760 ((type *)((PCHAR)(address) - offsetof(type, field)))
762 /* Types */
764 typedef struct _LIST_ENTRY {
765 struct _LIST_ENTRY *Flink;
766 struct _LIST_ENTRY *Blink;
767 } LIST_ENTRY, *PLIST_ENTRY, * RESTRICTED_POINTER PRLIST_ENTRY;
769 typedef struct _SINGLE_LIST_ENTRY {
770 struct _SINGLE_LIST_ENTRY *Next;
771 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
773 #ifdef _WIN64
775 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
776 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
777 PSLIST_ENTRY Next;
778 } SLIST_ENTRY;
780 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
781 struct {
782 ULONGLONG Alignment;
783 ULONGLONG Region;
784 } DUMMYSTRUCTNAME;
785 struct {
786 ULONGLONG Depth:16;
787 ULONGLONG Sequence:9;
788 ULONGLONG NextEntry:39;
789 ULONGLONG HeaderType:1;
790 ULONGLONG Init:1;
791 ULONGLONG Reserved:59;
792 ULONGLONG Region:3;
793 } Header8;
794 struct {
795 ULONGLONG Depth:16;
796 ULONGLONG Sequence:48;
797 ULONGLONG HeaderType:1;
798 ULONGLONG Init:1;
799 ULONGLONG Reserved:2;
800 ULONGLONG NextEntry:60;
801 } Header16;
802 } SLIST_HEADER, *PSLIST_HEADER;
804 #else
806 #undef SLIST_ENTRY /* for Mac OS */
807 #define SLIST_ENTRY SINGLE_LIST_ENTRY
808 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
809 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
811 typedef union _SLIST_HEADER {
812 ULONGLONG Alignment;
813 struct {
814 SLIST_ENTRY Next;
815 WORD Depth;
816 WORD Sequence;
817 } DUMMYSTRUCTNAME;
818 } SLIST_HEADER, *PSLIST_HEADER;
820 #endif
822 NTSYSAPI PSLIST_ENTRY WINAPI RtlFirstEntrySList(const SLIST_HEADER*);
823 NTSYSAPI VOID WINAPI RtlInitializeSListHead(PSLIST_HEADER);
824 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedFlushSList(PSLIST_HEADER);
825 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPopEntrySList(PSLIST_HEADER);
826 NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
827 NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER);
830 /* Heap flags */
832 #define HEAP_NO_SERIALIZE 0x00000001
833 #define HEAP_GROWABLE 0x00000002
834 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
835 #define HEAP_ZERO_MEMORY 0x00000008
836 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
837 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
838 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
839 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
840 #define HEAP_CREATE_ALIGN_16 0x00010000
841 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
842 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
844 /* This flag allows it to create heaps shared by all processes under win95,
845 FIXME: correct name */
846 #define HEAP_SHARED 0x04000000
848 typedef enum _HEAP_INFORMATION_CLASS {
849 HeapCompatibilityInformation,
850 } HEAP_INFORMATION_CLASS;
852 /* Processor feature flags. */
853 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
854 #define PF_FLOATING_POINT_EMULATED 1
855 #define PF_COMPARE_EXCHANGE_DOUBLE 2
856 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
857 #define PF_PPC_MOVEMEM_64BIT_OK 4
858 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
859 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
860 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
861 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
862 #define PF_PAE_ENABLED 9
863 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
864 #define PF_SSE_DAZ_MODE_AVAILABLE 11
865 #define PF_NX_ENABLED 12
866 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
867 #define PF_COMPARE_EXCHANGE128 14
868 #define PF_COMPARE64_EXCHANGE128 15
869 #define PF_CHANNELS_ENABLED 16
870 #define PF_XSAVE_ENABLED 17
871 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
872 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
873 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
874 #define PF_VIRT_FIRMWARE_ENABLED 21
875 #define PF_RDWRFSGSBASE_AVAILABLE 22
876 #define PF_FASTFAIL_AVAILABLE 23
877 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
878 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
879 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
880 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
881 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
882 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
883 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
884 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
887 /* Execution state flags */
888 #define ES_SYSTEM_REQUIRED 0x00000001
889 #define ES_DISPLAY_REQUIRED 0x00000002
890 #define ES_USER_PRESENT 0x00000004
891 #define ES_CONTINUOUS 0x80000000
893 /* The Win32 register context */
895 /* i386 context definitions */
896 #ifdef __i386__
898 #define SIZE_OF_80387_REGISTERS 80
900 typedef struct _FLOATING_SAVE_AREA
902 DWORD ControlWord;
903 DWORD StatusWord;
904 DWORD TagWord;
905 DWORD ErrorOffset;
906 DWORD ErrorSelector;
907 DWORD DataOffset;
908 DWORD DataSelector;
909 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
910 DWORD Cr0NpxState;
911 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
913 #define MAXIMUM_SUPPORTED_EXTENSION 512
915 typedef struct _CONTEXT
917 DWORD ContextFlags;
919 /* These are selected by CONTEXT_DEBUG_REGISTERS */
920 DWORD Dr0;
921 DWORD Dr1;
922 DWORD Dr2;
923 DWORD Dr3;
924 DWORD Dr6;
925 DWORD Dr7;
927 /* These are selected by CONTEXT_FLOATING_POINT */
928 FLOATING_SAVE_AREA FloatSave;
930 /* These are selected by CONTEXT_SEGMENTS */
931 DWORD SegGs;
932 DWORD SegFs;
933 DWORD SegEs;
934 DWORD SegDs;
936 /* These are selected by CONTEXT_INTEGER */
937 DWORD Edi;
938 DWORD Esi;
939 DWORD Ebx;
940 DWORD Edx;
941 DWORD Ecx;
942 DWORD Eax;
944 /* These are selected by CONTEXT_CONTROL */
945 DWORD Ebp;
946 DWORD Eip;
947 DWORD SegCs;
948 DWORD EFlags;
949 DWORD Esp;
950 DWORD SegSs;
952 BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
953 } CONTEXT;
955 #define CONTEXT_X86 0x00010000
956 #define CONTEXT_i386 CONTEXT_X86
957 #define CONTEXT_i486 CONTEXT_X86
959 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
960 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
961 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
962 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008) /* 387 state */
963 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010) /* DB 0-3,6,7 */
964 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x0020)
965 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
966 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
967 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
969 #define EXCEPTION_READ_FAULT 0
970 #define EXCEPTION_WRITE_FAULT 1
971 #define EXCEPTION_EXECUTE_FAULT 8
973 #endif /* __i386__ */
975 typedef struct _LDT_ENTRY {
976 WORD LimitLow;
977 WORD BaseLow;
978 union {
979 struct {
980 BYTE BaseMid;
981 BYTE Flags1;
982 BYTE Flags2;
983 BYTE BaseHi;
984 } Bytes;
985 struct {
986 unsigned BaseMid: 8;
987 unsigned Type : 5;
988 unsigned Dpl : 2;
989 unsigned Pres : 1;
990 unsigned LimitHi : 4;
991 unsigned Sys : 1;
992 unsigned Reserved_0 : 1;
993 unsigned Default_Big : 1;
994 unsigned Granularity : 1;
995 unsigned BaseHi : 8;
996 } Bits;
997 } HighWord;
998 } LDT_ENTRY, *PLDT_ENTRY;
1000 /* x86-64 context definitions */
1001 #if defined(__x86_64__)
1003 #define CONTEXT_AMD64 0x00100000
1005 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x0001)
1006 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x0002)
1007 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x0004)
1008 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x0008)
1009 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x0010)
1010 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1011 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1013 #define EXCEPTION_READ_FAULT 0
1014 #define EXCEPTION_WRITE_FAULT 1
1015 #define EXCEPTION_EXECUTE_FAULT 8
1017 typedef struct DECLSPEC_ALIGN(16) _M128A {
1018 ULONGLONG Low;
1019 LONGLONG High;
1020 } M128A, *PM128A;
1022 typedef struct _XMM_SAVE_AREA32 {
1023 WORD ControlWord; /* 000 */
1024 WORD StatusWord; /* 002 */
1025 BYTE TagWord; /* 004 */
1026 BYTE Reserved1; /* 005 */
1027 WORD ErrorOpcode; /* 006 */
1028 DWORD ErrorOffset; /* 008 */
1029 WORD ErrorSelector; /* 00c */
1030 WORD Reserved2; /* 00e */
1031 DWORD DataOffset; /* 010 */
1032 WORD DataSelector; /* 014 */
1033 WORD Reserved3; /* 016 */
1034 DWORD MxCsr; /* 018 */
1035 DWORD MxCsr_Mask; /* 01c */
1036 M128A FloatRegisters[8]; /* 020 */
1037 M128A XmmRegisters[16]; /* 0a0 */
1038 BYTE Reserved4[96]; /* 1a0 */
1039 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1041 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1042 DWORD64 P1Home; /* 000 */
1043 DWORD64 P2Home; /* 008 */
1044 DWORD64 P3Home; /* 010 */
1045 DWORD64 P4Home; /* 018 */
1046 DWORD64 P5Home; /* 020 */
1047 DWORD64 P6Home; /* 028 */
1049 /* Control flags */
1050 DWORD ContextFlags; /* 030 */
1051 DWORD MxCsr; /* 034 */
1053 /* Segment */
1054 WORD SegCs; /* 038 */
1055 WORD SegDs; /* 03a */
1056 WORD SegEs; /* 03c */
1057 WORD SegFs; /* 03e */
1058 WORD SegGs; /* 040 */
1059 WORD SegSs; /* 042 */
1060 DWORD EFlags; /* 044 */
1062 /* Debug */
1063 DWORD64 Dr0; /* 048 */
1064 DWORD64 Dr1; /* 050 */
1065 DWORD64 Dr2; /* 058 */
1066 DWORD64 Dr3; /* 060 */
1067 DWORD64 Dr6; /* 068 */
1068 DWORD64 Dr7; /* 070 */
1070 /* Integer */
1071 DWORD64 Rax; /* 078 */
1072 DWORD64 Rcx; /* 080 */
1073 DWORD64 Rdx; /* 088 */
1074 DWORD64 Rbx; /* 090 */
1075 DWORD64 Rsp; /* 098 */
1076 DWORD64 Rbp; /* 0a0 */
1077 DWORD64 Rsi; /* 0a8 */
1078 DWORD64 Rdi; /* 0b0 */
1079 DWORD64 R8; /* 0b8 */
1080 DWORD64 R9; /* 0c0 */
1081 DWORD64 R10; /* 0c8 */
1082 DWORD64 R11; /* 0d0 */
1083 DWORD64 R12; /* 0d8 */
1084 DWORD64 R13; /* 0e0 */
1085 DWORD64 R14; /* 0e8 */
1086 DWORD64 R15; /* 0f0 */
1088 /* Counter */
1089 DWORD64 Rip; /* 0f8 */
1091 /* Floating point */
1092 union {
1093 XMM_SAVE_AREA32 FltSave; /* 100 */
1094 struct {
1095 M128A Header[2]; /* 100 */
1096 M128A Legacy[8]; /* 120 */
1097 M128A Xmm0; /* 1a0 */
1098 M128A Xmm1; /* 1b0 */
1099 M128A Xmm2; /* 1c0 */
1100 M128A Xmm3; /* 1d0 */
1101 M128A Xmm4; /* 1e0 */
1102 M128A Xmm5; /* 1f0 */
1103 M128A Xmm6; /* 200 */
1104 M128A Xmm7; /* 210 */
1105 M128A Xmm8; /* 220 */
1106 M128A Xmm9; /* 230 */
1107 M128A Xmm10; /* 240 */
1108 M128A Xmm11; /* 250 */
1109 M128A Xmm12; /* 260 */
1110 M128A Xmm13; /* 270 */
1111 M128A Xmm14; /* 280 */
1112 M128A Xmm15; /* 290 */
1113 } DUMMYSTRUCTNAME;
1114 } DUMMYUNIONNAME;
1116 /* Vector */
1117 M128A VectorRegister[26]; /* 300 */
1118 DWORD64 VectorControl; /* 4a0 */
1120 /* Debug control */
1121 DWORD64 DebugControl; /* 4a8 */
1122 DWORD64 LastBranchToRip; /* 4b0 */
1123 DWORD64 LastBranchFromRip; /* 4b8 */
1124 DWORD64 LastExceptionToRip; /* 4c0 */
1125 DWORD64 LastExceptionFromRip; /* 4c8 */
1126 } CONTEXT;
1128 typedef struct _RUNTIME_FUNCTION
1130 DWORD BeginAddress;
1131 DWORD EndAddress;
1132 DWORD UnwindData;
1133 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1135 #define UNWIND_HISTORY_TABLE_SIZE 12
1137 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1139 ULONG64 ImageBase;
1140 PRUNTIME_FUNCTION FunctionEntry;
1141 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1143 #define UNWIND_HISTORY_TABLE_NONE 0
1144 #define UNWIND_HISTORY_TABLE_GLOBAL 1
1145 #define UNWIND_HISTORY_TABLE_LOCAL 2
1147 typedef struct _UNWIND_HISTORY_TABLE
1149 ULONG Count;
1150 UCHAR Search;
1151 ULONG64 LowAddress;
1152 ULONG64 HighAddress;
1153 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1154 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1156 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1158 union
1160 PM128A FloatingContext[16];
1161 struct
1163 PM128A Xmm0;
1164 PM128A Xmm1;
1165 PM128A Xmm2;
1166 PM128A Xmm3;
1167 PM128A Xmm4;
1168 PM128A Xmm5;
1169 PM128A Xmm6;
1170 PM128A Xmm7;
1171 PM128A Xmm8;
1172 PM128A Xmm9;
1173 PM128A Xmm10;
1174 PM128A Xmm11;
1175 PM128A Xmm12;
1176 PM128A Xmm13;
1177 PM128A Xmm14;
1178 PM128A Xmm15;
1179 } DUMMYSTRUCTNAME;
1180 } DUMMYUNIONNAME;
1182 union
1184 PULONG64 IntegerContext[16];
1185 struct
1187 PULONG64 Rax;
1188 PULONG64 Rcx;
1189 PULONG64 Rdx;
1190 PULONG64 Rbx;
1191 PULONG64 Rsp;
1192 PULONG64 Rbp;
1193 PULONG64 Rsi;
1194 PULONG64 Rdi;
1195 PULONG64 R8;
1196 PULONG64 R9;
1197 PULONG64 R10;
1198 PULONG64 R11;
1199 PULONG64 R12;
1200 PULONG64 R13;
1201 PULONG64 R14;
1202 PULONG64 R15;
1203 } DUMMYSTRUCTNAME;
1204 } DUMMYUNIONNAME2;
1205 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1207 typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64,PVOID);
1209 BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD64);
1210 BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1211 BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD64,DWORD64,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
1212 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD64,DWORD64*,UNWIND_HISTORY_TABLE*);
1213 PVOID WINAPI RtlVirtualUnwind(ULONG,ULONG64,ULONG64,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG64*,KNONVOLATILE_CONTEXT_POINTERS*);
1215 #define UNW_FLAG_NHANDLER 0
1216 #define UNW_FLAG_EHANDLER 1
1217 #define UNW_FLAG_UHANDLER 2
1218 #define UNW_FLAG_CHAININFO 4
1220 #endif /* __x86_64__ */
1222 /* IA64 context definitions */
1223 #ifdef __ia64__
1225 #define CONTEXT_IA64 0x00080000
1226 #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001)
1227 #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002)
1228 #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004)
1229 #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008)
1230 #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010)
1231 #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020)
1232 #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
1233 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
1234 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
1236 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1237 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1238 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1239 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1241 typedef struct _CONTEXT
1243 DWORD ContextFlags;
1244 DWORD Fill1[3];
1245 ULONGLONG DbI0;
1246 ULONGLONG DbI1;
1247 ULONGLONG DbI2;
1248 ULONGLONG DbI3;
1249 ULONGLONG DbI4;
1250 ULONGLONG DbI5;
1251 ULONGLONG DbI6;
1252 ULONGLONG DbI7;
1253 ULONGLONG DbD0;
1254 ULONGLONG DbD1;
1255 ULONGLONG DbD2;
1256 ULONGLONG DbD3;
1257 ULONGLONG DbD4;
1258 ULONGLONG DbD5;
1259 ULONGLONG DbD6;
1260 ULONGLONG DbD7;
1261 FLOAT128 FltS0;
1262 FLOAT128 FltS1;
1263 FLOAT128 FltS2;
1264 FLOAT128 FltS3;
1265 FLOAT128 FltT0;
1266 FLOAT128 FltT1;
1267 FLOAT128 FltT2;
1268 FLOAT128 FltT3;
1269 FLOAT128 FltT4;
1270 FLOAT128 FltT5;
1271 FLOAT128 FltT6;
1272 FLOAT128 FltT7;
1273 FLOAT128 FltT8;
1274 FLOAT128 FltT9;
1275 FLOAT128 FltS4;
1276 FLOAT128 FltS5;
1277 FLOAT128 FltS6;
1278 FLOAT128 FltS7;
1279 FLOAT128 FltS8;
1280 FLOAT128 FltS9;
1281 FLOAT128 FltS10;
1282 FLOAT128 FltS11;
1283 FLOAT128 FltS12;
1284 FLOAT128 FltS13;
1285 FLOAT128 FltS14;
1286 FLOAT128 FltS15;
1287 FLOAT128 FltS16;
1288 FLOAT128 FltS17;
1289 FLOAT128 FltS18;
1290 FLOAT128 FltS19;
1291 FLOAT128 FltF32;
1292 FLOAT128 FltF33;
1293 FLOAT128 FltF34;
1294 FLOAT128 FltF35;
1295 FLOAT128 FltF36;
1296 FLOAT128 FltF37;
1297 FLOAT128 FltF38;
1298 FLOAT128 FltF39;
1299 FLOAT128 FltF40;
1300 FLOAT128 FltF41;
1301 FLOAT128 FltF42;
1302 FLOAT128 FltF43;
1303 FLOAT128 FltF44;
1304 FLOAT128 FltF45;
1305 FLOAT128 FltF46;
1306 FLOAT128 FltF47;
1307 FLOAT128 FltF48;
1308 FLOAT128 FltF49;
1309 FLOAT128 FltF50;
1310 FLOAT128 FltF51;
1311 FLOAT128 FltF52;
1312 FLOAT128 FltF53;
1313 FLOAT128 FltF54;
1314 FLOAT128 FltF55;
1315 FLOAT128 FltF56;
1316 FLOAT128 FltF57;
1317 FLOAT128 FltF58;
1318 FLOAT128 FltF59;
1319 FLOAT128 FltF60;
1320 FLOAT128 FltF61;
1321 FLOAT128 FltF62;
1322 FLOAT128 FltF63;
1323 FLOAT128 FltF64;
1324 FLOAT128 FltF65;
1325 FLOAT128 FltF66;
1326 FLOAT128 FltF67;
1327 FLOAT128 FltF68;
1328 FLOAT128 FltF69;
1329 FLOAT128 FltF70;
1330 FLOAT128 FltF71;
1331 FLOAT128 FltF72;
1332 FLOAT128 FltF73;
1333 FLOAT128 FltF74;
1334 FLOAT128 FltF75;
1335 FLOAT128 FltF76;
1336 FLOAT128 FltF77;
1337 FLOAT128 FltF78;
1338 FLOAT128 FltF79;
1339 FLOAT128 FltF80;
1340 FLOAT128 FltF81;
1341 FLOAT128 FltF82;
1342 FLOAT128 FltF83;
1343 FLOAT128 FltF84;
1344 FLOAT128 FltF85;
1345 FLOAT128 FltF86;
1346 FLOAT128 FltF87;
1347 FLOAT128 FltF88;
1348 FLOAT128 FltF89;
1349 FLOAT128 FltF90;
1350 FLOAT128 FltF91;
1351 FLOAT128 FltF92;
1352 FLOAT128 FltF93;
1353 FLOAT128 FltF94;
1354 FLOAT128 FltF95;
1355 FLOAT128 FltF96;
1356 FLOAT128 FltF97;
1357 FLOAT128 FltF98;
1358 FLOAT128 FltF99;
1359 FLOAT128 FltF100;
1360 FLOAT128 FltF101;
1361 FLOAT128 FltF102;
1362 FLOAT128 FltF103;
1363 FLOAT128 FltF104;
1364 FLOAT128 FltF105;
1365 FLOAT128 FltF106;
1366 FLOAT128 FltF107;
1367 FLOAT128 FltF108;
1368 FLOAT128 FltF109;
1369 FLOAT128 FltF110;
1370 FLOAT128 FltF111;
1371 FLOAT128 FltF112;
1372 FLOAT128 FltF113;
1373 FLOAT128 FltF114;
1374 FLOAT128 FltF115;
1375 FLOAT128 FltF116;
1376 FLOAT128 FltF117;
1377 FLOAT128 FltF118;
1378 FLOAT128 FltF119;
1379 FLOAT128 FltF120;
1380 FLOAT128 FltF121;
1381 FLOAT128 FltF122;
1382 FLOAT128 FltF123;
1383 FLOAT128 FltF124;
1384 FLOAT128 FltF125;
1385 FLOAT128 FltF126;
1386 FLOAT128 FltF127;
1387 ULONGLONG StFPSR;
1388 ULONGLONG IntGp;
1389 ULONGLONG IntT0;
1390 ULONGLONG IntT1;
1391 ULONGLONG IntS0;
1392 ULONGLONG IntS1;
1393 ULONGLONG IntS2;
1394 ULONGLONG IntS3;
1395 ULONGLONG IntV0;
1396 ULONGLONG IntT2;
1397 ULONGLONG IntT3;
1398 ULONGLONG IntT4;
1399 ULONGLONG IntSp;
1400 ULONGLONG IntTeb;
1401 ULONGLONG IntT5;
1402 ULONGLONG IntT6;
1403 ULONGLONG IntT7;
1404 ULONGLONG IntT8;
1405 ULONGLONG IntT9;
1406 ULONGLONG IntT10;
1407 ULONGLONG IntT11;
1408 ULONGLONG IntT12;
1409 ULONGLONG IntT13;
1410 ULONGLONG IntT14;
1411 ULONGLONG IntT15;
1412 ULONGLONG IntT16;
1413 ULONGLONG IntT17;
1414 ULONGLONG IntT18;
1415 ULONGLONG IntT19;
1416 ULONGLONG IntT20;
1417 ULONGLONG IntT21;
1418 ULONGLONG IntT22;
1419 ULONGLONG IntNats;
1420 ULONGLONG Preds;
1421 ULONGLONG BrRp;
1422 ULONGLONG BrS0;
1423 ULONGLONG BrS1;
1424 ULONGLONG BrS2;
1425 ULONGLONG BrS3;
1426 ULONGLONG BrS4;
1427 ULONGLONG BrT0;
1428 ULONGLONG BrT1;
1429 ULONGLONG ApUNAT;
1430 ULONGLONG ApLC;
1431 ULONGLONG ApEC;
1432 ULONGLONG ApCCV;
1433 ULONGLONG ApDCR;
1434 ULONGLONG RsPFS;
1435 ULONGLONG RsBSP;
1436 ULONGLONG RsBSPSTORE;
1437 ULONGLONG RsRSC;
1438 ULONGLONG RsRNAT;
1439 ULONGLONG StIPSR;
1440 ULONGLONG StIIP;
1441 ULONGLONG StIFS;
1442 ULONGLONG StFCR;
1443 ULONGLONG Eflag;
1444 ULONGLONG SegCSD;
1445 ULONGLONG SegSSD;
1446 ULONGLONG Cflag;
1447 ULONGLONG StFSR;
1448 ULONGLONG StFIR;
1449 ULONGLONG StFDR;
1450 ULONGLONG UNUSEDPACK;
1451 } CONTEXT, *PCONTEXT;
1453 typedef struct _RUNTIME_FUNCTION
1455 ULONG BeginAddress;
1456 ULONG EndAddress;
1457 ULONG UnwindInfoAddress;
1458 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1460 typedef struct _FRAME_POINTERS {
1461 ULONGLONG MemoryStackFp;
1462 ULONGLONG BackingStoreFp;
1463 } FRAME_POINTERS, *PFRAME_POINTERS;
1465 #define UNWIND_HISTORY_TABLE_SIZE 12
1467 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
1468 ULONG64 ImageBase;
1469 ULONG64 Gp;
1470 PRUNTIME_FUNCTION FunctionEntry;
1471 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1473 typedef struct _UNWIND_HISTORY_TABLE {
1474 ULONG Count;
1475 UCHAR Search;
1476 ULONG64 LowAddress;
1477 ULONG64 HighAddress;
1478 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1479 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1481 typedef struct _KNONVOLATILE_CONTEXT_POINTERS
1483 PFLOAT128 FltS0;
1484 PFLOAT128 FltS1;
1485 PFLOAT128 FltS2;
1486 PFLOAT128 FltS3;
1487 PFLOAT128 HighFloatingContext[10];
1488 PFLOAT128 FltS4;
1489 PFLOAT128 FltS5;
1490 PFLOAT128 FltS6;
1491 PFLOAT128 FltS7;
1492 PFLOAT128 FltS8;
1493 PFLOAT128 FltS9;
1494 PFLOAT128 FltS10;
1495 PFLOAT128 FltS11;
1496 PFLOAT128 FltS12;
1497 PFLOAT128 FltS13;
1498 PFLOAT128 FltS14;
1499 PFLOAT128 FltS15;
1500 PFLOAT128 FltS16;
1501 PFLOAT128 FltS17;
1502 PFLOAT128 FltS18;
1503 PFLOAT128 FltS19;
1504 PULONGLONG IntS0;
1505 PULONGLONG IntS1;
1506 PULONGLONG IntS2;
1507 PULONGLONG IntS3;
1508 PULONGLONG IntSp;
1509 PULONGLONG IntS0Nat;
1510 PULONGLONG IntS1Nat;
1511 PULONGLONG IntS2Nat;
1512 PULONGLONG IntS3Nat;
1513 PULONGLONG IntSpNat;
1514 PULONGLONG Preds;
1515 PULONGLONG BrRp;
1516 PULONGLONG BrS0;
1517 PULONGLONG BrS1;
1518 PULONGLONG BrS2;
1519 PULONGLONG BrS3;
1520 PULONGLONG BrS4;
1521 PULONGLONG ApUNAT;
1522 PULONGLONG ApLC;
1523 PULONGLONG ApEC;
1524 PULONGLONG RsPFS;
1525 PULONGLONG StFSR;
1526 PULONGLONG StFIR;
1527 PULONGLONG StFDR;
1528 PULONGLONG Cflag;
1529 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1531 ULONGLONG WINAPI RtlVirtualUnwind(ULONGLONG,ULONGLONG,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,FRAME_POINTERS*,KNONVOLATILE_CONTEXT_POINTERS*);
1533 #endif /* __ia64__ */
1535 /* Alpha context definitions */
1536 #if defined(_ALPHA_) || defined(__ALPHA__) || defined(__alpha__)
1538 #define CONTEXT_ALPHA 0x00020000
1540 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001)
1541 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002)
1542 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004)
1543 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1545 #define EXCEPTION_READ_FAULT 0
1546 #define EXCEPTION_WRITE_FAULT 1
1547 #define EXCEPTION_EXECUTE_FAULT 8
1549 typedef struct _CONTEXT
1551 /* selected by CONTEXT_FLOATING_POINT */
1552 ULONGLONG FltF0;
1553 ULONGLONG FltF1;
1554 ULONGLONG FltF2;
1555 ULONGLONG FltF3;
1556 ULONGLONG FltF4;
1557 ULONGLONG FltF5;
1558 ULONGLONG FltF6;
1559 ULONGLONG FltF7;
1560 ULONGLONG FltF8;
1561 ULONGLONG FltF9;
1562 ULONGLONG FltF10;
1563 ULONGLONG FltF11;
1564 ULONGLONG FltF12;
1565 ULONGLONG FltF13;
1566 ULONGLONG FltF14;
1567 ULONGLONG FltF15;
1568 ULONGLONG FltF16;
1569 ULONGLONG FltF17;
1570 ULONGLONG FltF18;
1571 ULONGLONG FltF19;
1572 ULONGLONG FltF20;
1573 ULONGLONG FltF21;
1574 ULONGLONG FltF22;
1575 ULONGLONG FltF23;
1576 ULONGLONG FltF24;
1577 ULONGLONG FltF25;
1578 ULONGLONG FltF26;
1579 ULONGLONG FltF27;
1580 ULONGLONG FltF28;
1581 ULONGLONG FltF29;
1582 ULONGLONG FltF30;
1583 ULONGLONG FltF31;
1585 /* selected by CONTEXT_INTEGER */
1586 ULONGLONG IntV0;
1587 ULONGLONG IntT0;
1588 ULONGLONG IntT1;
1589 ULONGLONG IntT2;
1590 ULONGLONG IntT3;
1591 ULONGLONG IntT4;
1592 ULONGLONG IntT5;
1593 ULONGLONG IntT6;
1594 ULONGLONG IntT7;
1595 ULONGLONG IntS0;
1596 ULONGLONG IntS1;
1597 ULONGLONG IntS2;
1598 ULONGLONG IntS3;
1599 ULONGLONG IntS4;
1600 ULONGLONG IntS5;
1601 ULONGLONG IntFp;
1602 ULONGLONG IntA0;
1603 ULONGLONG IntA1;
1604 ULONGLONG IntA2;
1605 ULONGLONG IntA3;
1606 ULONGLONG IntA4;
1607 ULONGLONG IntA5;
1608 ULONGLONG IntT8;
1609 ULONGLONG IntT9;
1610 ULONGLONG IntT10;
1611 ULONGLONG IntT11;
1612 ULONGLONG IntRa;
1613 ULONGLONG IntT12;
1614 ULONGLONG IntAt;
1615 ULONGLONG IntGp;
1616 ULONGLONG IntSp;
1617 ULONGLONG IntZero;
1619 /* selected by CONTEXT_FLOATING_POINT */
1620 ULONGLONG Fpcr;
1621 ULONGLONG SoftFpcr;
1623 /* selected by CONTEXT_CONTROL */
1624 ULONGLONG Fir;
1625 DWORD Psr;
1626 DWORD ContextFlags;
1627 DWORD Fill[4];
1628 } CONTEXT;
1630 #define _QUAD_PSR_OFFSET HighSoftFpcr
1631 #define _QUAD_FLAGS_OFFSET HighFir
1633 #endif /* _ALPHA_ */
1635 #ifdef __arm__
1637 /* The following flags control the contents of the CONTEXT structure. */
1639 #define CONTEXT_ARM 0x0200000
1640 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001)
1641 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002)
1642 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004)
1643 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
1645 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1647 #define EXCEPTION_READ_FAULT 0
1648 #define EXCEPTION_WRITE_FAULT 1
1649 #define EXCEPTION_EXECUTE_FAULT 8
1651 typedef struct _RUNTIME_FUNCTION
1653 DWORD BeginAddress;
1654 union {
1655 DWORD UnwindData;
1656 struct {
1657 DWORD Flag : 2;
1658 DWORD FunctionLength : 11;
1659 DWORD Ret : 2;
1660 DWORD H : 1;
1661 DWORD Reg : 3;
1662 DWORD R : 1;
1663 DWORD L : 1;
1664 DWORD C : 1;
1665 DWORD StackAdjust : 10;
1666 } DUMMYSTRUCTNAME;
1667 } DUMMYUNIONNAME;
1668 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
1670 #define UNWIND_HISTORY_TABLE_SIZE 12
1672 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1674 DWORD ImageBase;
1675 PRUNTIME_FUNCTION FunctionEntry;
1676 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1678 typedef struct _UNWIND_HISTORY_TABLE
1680 DWORD Count;
1681 BYTE LocalHint;
1682 BYTE GlobalHint;
1683 BYTE Search;
1684 BYTE Once;
1685 DWORD LowAddress;
1686 DWORD HighAddress;
1687 UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1688 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1690 typedef struct _CONTEXT {
1691 /* The flags values within this flag control the contents of
1692 a CONTEXT record.
1694 If the context record is used as an input parameter, then
1695 for each portion of the context record controlled by a flag
1696 whose value is set, it is assumed that that portion of the
1697 context record contains valid context. If the context record
1698 is being used to modify a thread's context, then only that
1699 portion of the threads context will be modified.
1701 If the context record is used as an IN OUT parameter to capture
1702 the context of a thread, then only those portions of the thread's
1703 context corresponding to set flags will be returned.
1705 The context record is never used as an OUT only parameter. */
1707 ULONG ContextFlags;
1709 /* This section is specified/returned if the ContextFlags word contains
1710 the flag CONTEXT_INTEGER. */
1711 ULONG R0;
1712 ULONG R1;
1713 ULONG R2;
1714 ULONG R3;
1715 ULONG R4;
1716 ULONG R5;
1717 ULONG R6;
1718 ULONG R7;
1719 ULONG R8;
1720 ULONG R9;
1721 ULONG R10;
1722 ULONG Fp;
1723 ULONG Ip;
1725 /* These are selected by CONTEXT_CONTROL */
1726 ULONG Sp;
1727 ULONG Lr;
1728 ULONG Pc;
1729 ULONG Cpsr;
1730 } CONTEXT;
1732 BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD);
1733 BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
1734 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR,DWORD*,UNWIND_HISTORY_TABLE*);
1736 #endif /* __arm__ */
1738 #ifdef __aarch64__
1740 * FIXME:
1742 * There is not yet an official CONTEXT structure defined for the AArch64
1743 * architecture, so I just made one up.
1747 #define CONTEXT_ARM64 0x400000
1748 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x00000001)
1749 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x00000002)
1750 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x00000004)
1751 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x00000008)
1753 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
1755 #define EXCEPTION_READ_FAULT 0
1756 #define EXCEPTION_WRITE_FAULT 1
1757 #define EXCEPTION_EXECUTE_FAULT 8
1759 typedef struct _CONTEXT {
1760 ULONG ContextFlags;
1761 ULONG Cpsr;
1763 /* This section is specified/returned if the ContextFlags word contains
1764 the flag CONTEXT_INTEGER. */
1765 ULONGLONG X0;
1766 ULONGLONG X1;
1767 ULONGLONG X2;
1768 ULONGLONG X3;
1769 ULONGLONG X4;
1770 ULONGLONG X5;
1771 ULONGLONG X6;
1772 ULONGLONG X7;
1773 ULONGLONG X8;
1774 ULONGLONG X9;
1775 ULONGLONG X10;
1776 ULONGLONG X11;
1777 ULONGLONG X12;
1778 ULONGLONG X13;
1779 ULONGLONG X14;
1780 ULONGLONG X15;
1781 ULONGLONG X16;
1782 ULONGLONG X17;
1783 ULONGLONG X18;
1784 ULONGLONG X19;
1785 ULONGLONG X20;
1786 ULONGLONG X21;
1787 ULONGLONG X22;
1788 ULONGLONG X23;
1789 ULONGLONG X24;
1790 ULONGLONG X25;
1791 ULONGLONG X26;
1792 ULONGLONG X27;
1793 ULONGLONG X28;
1795 /* These are selected by CONTEXT_CONTROL */
1796 ULONGLONG Fp;
1797 ULONGLONG Lr;
1798 ULONGLONG Sp;
1799 ULONGLONG Pc;
1801 /* These are selected by CONTEXT_FLOATING_POINT */
1802 /* FIXME */
1803 } CONTEXT;
1805 #endif /* __aarch64__ */
1808 /* Mips context definitions */
1809 #if defined(_MIPS_) || defined(__MIPS__) || defined(__mips__)
1811 #define CONTEXT_R4000 0x00010000
1813 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
1814 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
1815 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
1817 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1819 #define EXCEPTION_READ_FAULT 0
1820 #define EXCEPTION_WRITE_FAULT 1
1821 #define EXCEPTION_EXECUTE_FAULT 8
1823 typedef struct _CONTEXT
1825 DWORD Argument[4];
1826 /* These are selected by CONTEXT_FLOATING_POINT */
1827 DWORD FltF0;
1828 DWORD FltF1;
1829 DWORD FltF2;
1830 DWORD FltF3;
1831 DWORD FltF4;
1832 DWORD FltF5;
1833 DWORD FltF6;
1834 DWORD FltF7;
1835 DWORD FltF8;
1836 DWORD FltF9;
1837 DWORD FltF10;
1838 DWORD FltF11;
1839 DWORD FltF12;
1840 DWORD FltF13;
1841 DWORD FltF14;
1842 DWORD FltF15;
1843 DWORD FltF16;
1844 DWORD FltF17;
1845 DWORD FltF18;
1846 DWORD FltF19;
1847 DWORD FltF20;
1848 DWORD FltF21;
1849 DWORD FltF22;
1850 DWORD FltF23;
1851 DWORD FltF24;
1852 DWORD FltF25;
1853 DWORD FltF26;
1854 DWORD FltF27;
1855 DWORD FltF28;
1856 DWORD FltF29;
1857 DWORD FltF30;
1858 DWORD FltF31;
1860 /* These are selected by CONTEXT_INTEGER */
1861 DWORD IntZero;
1862 DWORD IntAt;
1863 DWORD IntV0;
1864 DWORD IntV1;
1865 DWORD IntA0;
1866 DWORD IntA1;
1867 DWORD IntA2;
1868 DWORD IntA3;
1869 DWORD IntT0;
1870 DWORD IntT1;
1871 DWORD IntT2;
1872 DWORD IntT3;
1873 DWORD IntT4;
1874 DWORD IntT5;
1875 DWORD IntT6;
1876 DWORD IntT7;
1877 DWORD IntS0;
1878 DWORD IntS1;
1879 DWORD IntS2;
1880 DWORD IntS3;
1881 DWORD IntS4;
1882 DWORD IntS5;
1883 DWORD IntS6;
1884 DWORD IntS7;
1885 DWORD IntT8;
1886 DWORD IntT9;
1887 DWORD IntK0;
1888 DWORD IntK1;
1889 DWORD IntGp;
1890 DWORD IntSp;
1891 DWORD IntS8;
1892 DWORD IntRa;
1893 DWORD IntLo;
1894 DWORD IntHi;
1896 /* These are selected by CONTEXT_FLOATING_POINT */
1897 DWORD Fsr;
1899 /* These are selected by CONTEXT_CONTROL */
1900 DWORD Fir;
1901 DWORD Psr;
1903 DWORD ContextFlags;
1904 DWORD Fill[2];
1905 } CONTEXT;
1907 #endif /* _MIPS_ */
1909 /* PowerPC context definitions */
1910 #ifdef __powerpc__
1912 #define CONTEXT_CONTROL 0x0001
1913 #define CONTEXT_FLOATING_POINT 0x0002
1914 #define CONTEXT_INTEGER 0x0004
1915 #define CONTEXT_DEBUG_REGISTERS 0x0008
1916 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1918 #define EXCEPTION_READ_FAULT 0
1919 #define EXCEPTION_WRITE_FAULT 1
1920 #define EXCEPTION_EXECUTE_FAULT 8
1922 typedef struct
1924 /* These are selected by CONTEXT_FLOATING_POINT */
1925 double Fpr0;
1926 double Fpr1;
1927 double Fpr2;
1928 double Fpr3;
1929 double Fpr4;
1930 double Fpr5;
1931 double Fpr6;
1932 double Fpr7;
1933 double Fpr8;
1934 double Fpr9;
1935 double Fpr10;
1936 double Fpr11;
1937 double Fpr12;
1938 double Fpr13;
1939 double Fpr14;
1940 double Fpr15;
1941 double Fpr16;
1942 double Fpr17;
1943 double Fpr18;
1944 double Fpr19;
1945 double Fpr20;
1946 double Fpr21;
1947 double Fpr22;
1948 double Fpr23;
1949 double Fpr24;
1950 double Fpr25;
1951 double Fpr26;
1952 double Fpr27;
1953 double Fpr28;
1954 double Fpr29;
1955 double Fpr30;
1956 double Fpr31;
1957 double Fpscr;
1959 /* These are selected by CONTEXT_INTEGER */
1960 DWORD Gpr0;
1961 DWORD Gpr1;
1962 DWORD Gpr2;
1963 DWORD Gpr3;
1964 DWORD Gpr4;
1965 DWORD Gpr5;
1966 DWORD Gpr6;
1967 DWORD Gpr7;
1968 DWORD Gpr8;
1969 DWORD Gpr9;
1970 DWORD Gpr10;
1971 DWORD Gpr11;
1972 DWORD Gpr12;
1973 DWORD Gpr13;
1974 DWORD Gpr14;
1975 DWORD Gpr15;
1976 DWORD Gpr16;
1977 DWORD Gpr17;
1978 DWORD Gpr18;
1979 DWORD Gpr19;
1980 DWORD Gpr20;
1981 DWORD Gpr21;
1982 DWORD Gpr22;
1983 DWORD Gpr23;
1984 DWORD Gpr24;
1985 DWORD Gpr25;
1986 DWORD Gpr26;
1987 DWORD Gpr27;
1988 DWORD Gpr28;
1989 DWORD Gpr29;
1990 DWORD Gpr30;
1991 DWORD Gpr31;
1993 DWORD Cr;
1994 DWORD Xer;
1996 /* These are selected by CONTEXT_CONTROL */
1997 DWORD Msr;
1998 DWORD Iar; /* Instruction Address Register , aka PC ... */
1999 DWORD Lr;
2000 DWORD Ctr;
2002 DWORD ContextFlags;
2004 DWORD Dar; /* Fault registers for coredump */
2005 DWORD Dsisr;
2006 DWORD Trap; /* number of powerpc exception taken */
2008 /* These are selected by CONTEXT_DEBUG_REGISTERS */
2009 DWORD Dr0;
2010 DWORD Dr1;
2011 DWORD Dr2;
2012 DWORD Dr3;
2013 DWORD Dr4;
2014 DWORD Dr5;
2015 DWORD Dr6;
2016 DWORD Dr7;
2017 } CONTEXT;
2019 typedef struct _STACK_FRAME_HEADER
2021 DWORD BackChain;
2022 DWORD GlueSaved1;
2023 DWORD GlueSaved2;
2024 DWORD Reserved1;
2025 DWORD Spare1;
2026 DWORD Spare2;
2028 DWORD Parameter0;
2029 DWORD Parameter1;
2030 DWORD Parameter2;
2031 DWORD Parameter3;
2032 DWORD Parameter4;
2033 DWORD Parameter5;
2034 DWORD Parameter6;
2035 DWORD Parameter7;
2036 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
2038 #endif /* __powerpc__ */
2040 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
2041 #error You need to define a CONTEXT for your CPU
2042 #endif
2044 typedef CONTEXT *PCONTEXT;
2046 NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
2049 * Product types
2051 #define PRODUCT_UNDEFINED 0x00000000
2052 #define PRODUCT_ULTIMATE 0x00000001
2053 #define PRODUCT_HOME_BASIC 0x00000002
2054 #define PRODUCT_HOME_PREMIUM 0x00000003
2055 #define PRODUCT_ENTERPRISE 0x00000004
2056 #define PRODUCT_HOME_BASIC_N 0x00000005
2057 #define PRODUCT_BUSINESS 0x00000006
2058 #define PRODUCT_STANDARD_SERVER 0x00000007
2059 #define PRODUCT_DATACENTER_SERVER 0x00000008
2060 #define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
2061 #define PRODUCT_ENTERPRISE_SERVER 0x0000000A
2062 #define PRODUCT_STARTER 0x0000000B
2063 #define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
2064 #define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
2065 #define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
2066 #define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
2067 #define PRODUCT_BUSINESS_N 0x00000010
2068 #define PRODUCT_WEB_SERVER 0x00000011
2069 #define PRODUCT_CLUSTER_SERVER 0x00000012
2070 #define PRODUCT_HOME_SERVER 0x00000013
2071 #define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
2072 #define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
2073 #define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
2074 #define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
2075 #define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
2076 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
2077 #define PRODUCT_HOME_PREMIUM_N 0x0000001A
2078 #define PRODUCT_ENTERPRISE_N 0x0000001B
2079 #define PRODUCT_ULTIMATE_N 0x0000001C
2080 #define PRODUCT_WEB_SERVER_CORE 0x0000001D
2081 #define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
2082 #define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
2083 #define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
2084 #define PRODUCT_SERVER_FOUNDATION 0x00000021
2085 #define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
2086 #define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
2087 #define PRODUCT_STANDARD_SERVER_V 0x00000024
2088 #define PRODUCT_DATACENTER_SERVER_V 0x00000025
2089 #define PRODUCT_SERVER_V 0x00000025
2090 #define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
2091 #define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
2092 #define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
2093 #define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
2094 #define PRODUCT_HYPERV 0x0000002A
2095 #define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
2096 #define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
2097 #define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
2098 #define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
2099 #define PRODUCT_STARTER_N 0x0000002F
2100 #define PRODUCT_PROFESSIONAL 0x00000030
2101 #define PRODUCT_PROFESSIONAL_N 0x00000031
2102 #define PRODUCT_SB_SOLUTION_SERVER 0x00000032
2103 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
2104 #define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
2105 #define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
2106 #define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
2107 #define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
2108 #define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
2109 #define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
2110 #define PRODUCT_PROFESSIONAL_EMBEDDED 0x0000003A
2111 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
2112 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
2113 #define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
2114 #define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
2115 #define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
2116 #define PRODUCT_CLUSTER_SERVER_V 0x00000040
2117 #define PRODUCT_EMBEDDED 0x00000041
2118 #define PRODUCT_STARTER_E 0x00000042
2119 #define PRODUCT_HOME_BASIC_E 0x00000043
2120 #define PRODUCT_HOME_PREMIUM_E 0x00000044
2121 #define PRODUCT_PROFESSIONAL_E 0x00000045
2122 #define PRODUCT_ENTERPRISE_E 0x00000046
2123 #define PRODUCT_ULTIMATE_E 0x00000047
2124 #define PRODUCT_ENTERPRISE_EVALUATION 0x00000048
2125 #define PRODUCT_MULTIPOINT_STANDARD_SERVER 0x0000004C
2126 #define PRODUCT_MULTIPOINT_PREMIUM_SERVER 0x0000004D
2127 #define PRODUCT_STANDARD_EVALUATION_SERVER 0x0000004F
2128 #define PRODUCT_DATACENTER_EVALUATION_SERVER 0x00000050
2129 #define PRODUCT_ENTERPRISE_N_EVALUATION 0x00000054
2130 #define PRODUCT_EMBEDDED_AUTOMOTIVE 0x00000055
2131 #define PRODUCT_EMBEDDED_INDUSTRY_A 0x00000056
2132 #define PRODUCT_THINPC 0x00000057
2133 #define PRODUCT_EMBEDDED_A 0x00000058
2134 #define PRODUCT_EMBEDDED_INDUSTRY 0x00000059
2135 #define PRODUCT_EMBEDDED_E 0x0000005A
2136 #define PRODUCT_EMBEDDED_INDUSTRY_E 0x0000005B
2137 #define PRODUCT_EMBEDDED_INDUSTRY_A_E 0x0000005C
2138 #define PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER 0x0000005F
2139 #define PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER 0x00000060
2140 #define PRODUCT_CORE_ARM 0x00000061
2141 #define PRODUCT_CORE_N 0x00000062
2142 #define PRODUCT_CORE_COUNTRYSPECIFIC 0x00000063
2143 #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
2144 #define PRODUCT_CORE_LANGUAGESPECIFIC 0x00000064
2145 #define PRODUCT_CORE 0x00000065
2146 #define PRODUCT_PROFESSIONAL_WMC 0x00000067
2147 #define PRODUCT_MOBILE_CORE 0x00000068
2148 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069
2149 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A
2150 #define PRODUCT_EMBEDDED_EVAL 0x0000006B
2151 #define PRODUCT_EMBEDDED_E_EVAL 0x0000006C
2152 #define PRODUCT_NANO_SERVER 0x0000006D
2153 #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
2154 #define PRODUCT_CORE_CONNECTED 0x0000006F
2155 #define PRODUCT_PROFESSIONAL_STUDENT 0x00000070
2156 #define PRODUCT_CORE_CONNECTED_N 0x00000071
2157 #define PRODUCT_PROFESSIONAL_STUDENT_N 0x00000072
2158 #define PRODUCT_CORE_CONNECTED_SINGLELANGUAGE 0x00000073
2159 #define PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC 0x00000074
2160 #define PRODUCT_CONNECTED_CAR 0x00000075
2161 #define PRODUCT_INDUSTRY_HANDHELD 0x00000076
2162 #define PRODUCT_PPI_PRO 0x00000077
2163 #define PRODUCT_ARM64_SERVER 0x00000078
2164 #define PRODUCT_EDUCATION 0x00000079
2165 #define PRODUCT_EDUCATION_N 0x0000007A
2166 #define PRODUCT_IOTUAP 0x0000007B
2167 #define PRODUCT_CLOUD_HOST_INFRASTRUCTURE_SERVER 0x0000007C
2168 #define PRODUCT_ENTERPRISE_S 0x0000007D
2169 #define PRODUCT_ENTERPRISE_S_N 0x0000007E
2170 #define PRODUCT_PROFESSIONAL_S 0x0000007F
2171 #define PRODUCT_PROFESSIONAL_S_N 0x00000080
2172 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081
2173 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082
2174 #define PRODUCT_UNLICENSED 0xABCDABCD
2178 * Language IDs
2181 #define MAKELCID(l, s) (MAKELONG(l, s))
2183 #define MAKELANGID(p, s) ((((WORD)(s))<<10) | (WORD)(p))
2184 #define PRIMARYLANGID(l) ((WORD)(l) & 0x3ff)
2185 #define SUBLANGID(l) ((WORD)(l) >> 10)
2187 #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
2188 #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0x0f))
2190 #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
2191 #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
2192 #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
2193 #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
2194 #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
2195 #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL),SORT_DEFAULT))
2196 #define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
2197 #define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
2198 #define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
2199 #define LOCALE_NAME_MAX_LENGTH 85
2202 #define UNREFERENCED_PARAMETER(u) (void)(u)
2203 #define DBG_UNREFERENCED_PARAMETER(u) (void)(u)
2204 #define DBG_UNREFERENCED_LOCAL_VARIABLE(u) (void)(u)
2206 #include <winnt.rh>
2210 * Definitions for IsTextUnicode()
2213 #define IS_TEXT_UNICODE_ASCII16 0x0001
2214 #define IS_TEXT_UNICODE_STATISTICS 0x0002
2215 #define IS_TEXT_UNICODE_CONTROLS 0x0004
2216 #define IS_TEXT_UNICODE_SIGNATURE 0x0008
2217 #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F
2218 #define IS_TEXT_UNICODE_REVERSE_ASCII16 0x0010
2219 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 0x0020
2220 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 0x0040
2221 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 0x0080
2222 #define IS_TEXT_UNICODE_REVERSE_MASK 0x00F0
2223 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 0x0100
2224 #define IS_TEXT_UNICODE_ODD_LENGTH 0x0200
2225 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 0x0400
2226 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 0x0F00
2227 #define IS_TEXT_UNICODE_NULL_BYTES 0x1000
2228 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 0xF000
2230 #define MAXIMUM_WAIT_OBJECTS 64
2231 #define MAXIMUM_SUSPEND_COUNT 127
2233 #define WT_EXECUTEDEFAULT 0x00
2234 #define WT_EXECUTEINIOTHREAD 0x01
2235 #define WT_EXECUTEINUITHREAD 0x02
2236 #define WT_EXECUTEINWAITTHREAD 0x04
2237 #define WT_EXECUTEONLYONCE 0x08
2238 #define WT_EXECUTELONGFUNCTION 0x10
2239 #define WT_EXECUTEINTIMERTHREAD 0x20
2240 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x40
2241 #define WT_EXECUTEINPERSISTENTTHREAD 0x80
2242 #define WT_EXECUTEINLONGTHREAD 0x10
2243 #define WT_EXECUTEDELETEWAIT 0x08
2244 #define WT_TRANSFER_IMPERSONATION 0x0100
2247 #define EXCEPTION_CONTINUABLE 0
2248 #define EXCEPTION_NONCONTINUABLE 0x01
2251 * The exception record used by Win32 to give additional information
2252 * about exception to exception handlers.
2255 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2257 typedef struct _EXCEPTION_RECORD
2259 DWORD ExceptionCode;
2260 DWORD ExceptionFlags;
2261 struct _EXCEPTION_RECORD *ExceptionRecord;
2263 PVOID ExceptionAddress;
2264 DWORD NumberParameters;
2265 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2266 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2269 * The exception pointers structure passed to exception filters
2270 * in except() and the UnhandledExceptionFilter().
2273 typedef struct _EXCEPTION_POINTERS
2275 PEXCEPTION_RECORD ExceptionRecord;
2276 PCONTEXT ContextRecord;
2277 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2281 * The exception frame, used for registering exception handlers
2282 * Win32 cares only about this, but compilers generally emit
2283 * larger exception frames for their own use.
2286 struct _EXCEPTION_REGISTRATION_RECORD;
2288 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct _EXCEPTION_REGISTRATION_RECORD*,
2289 PCONTEXT,struct _EXCEPTION_REGISTRATION_RECORD **);
2291 typedef struct _EXCEPTION_REGISTRATION_RECORD
2293 struct _EXCEPTION_REGISTRATION_RECORD *Prev;
2294 PEXCEPTION_HANDLER Handler;
2295 } EXCEPTION_REGISTRATION_RECORD;
2298 * function pointer to an exception filter
2301 typedef LONG (CALLBACK *PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo);
2303 typedef struct _NT_TIB
2305 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2306 PVOID StackBase;
2307 PVOID StackLimit;
2308 PVOID SubSystemTib;
2309 union {
2310 PVOID FiberData;
2311 DWORD Version;
2312 } DUMMYUNIONNAME;
2313 PVOID ArbitraryUserPointer;
2314 struct _NT_TIB *Self;
2315 } NT_TIB, *PNT_TIB;
2317 struct _TEB;
2319 #if defined(__i386__) && defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
2320 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2322 struct _TEB *teb;
2323 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
2324 return teb;
2326 #elif defined(__i386__) && defined(_MSC_VER)
2327 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2329 struct _TEB *teb;
2330 __asm mov eax, fs:[0x18];
2331 __asm mov teb, eax;
2332 return teb;
2334 #elif defined(__x86_64__) && defined(__GNUC__)
2335 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2337 struct _TEB *teb;
2338 __asm__(".byte 0x65\n\tmovq (0x30),%0" : "=r" (teb));
2339 return teb;
2341 #elif defined(__x86_64__) && defined(_MSC_VER)
2342 #pragma intrinsic(__readgsqword)
2343 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
2345 return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
2347 #else
2348 extern struct _TEB * WINAPI NtCurrentTeb(void);
2349 #endif
2351 #ifdef NONAMELESSUNION
2352 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->u.FiberData)
2353 #else
2354 #define GetCurrentFiber() (((NT_TIB *)NtCurrentTeb())->FiberData)
2355 #endif
2356 #define GetFiberData() (*(void **)GetCurrentFiber())
2358 #define TLS_MINIMUM_AVAILABLE 64
2361 * File formats definitions
2364 #include <pshpack2.h>
2365 typedef struct _IMAGE_DOS_HEADER {
2366 WORD e_magic; /* 00: MZ Header signature */
2367 WORD e_cblp; /* 02: Bytes on last page of file */
2368 WORD e_cp; /* 04: Pages in file */
2369 WORD e_crlc; /* 06: Relocations */
2370 WORD e_cparhdr; /* 08: Size of header in paragraphs */
2371 WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
2372 WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
2373 WORD e_ss; /* 0e: Initial (relative) SS value */
2374 WORD e_sp; /* 10: Initial SP value */
2375 WORD e_csum; /* 12: Checksum */
2376 WORD e_ip; /* 14: Initial IP value */
2377 WORD e_cs; /* 16: Initial (relative) CS value */
2378 WORD e_lfarlc; /* 18: File address of relocation table */
2379 WORD e_ovno; /* 1a: Overlay number */
2380 WORD e_res[4]; /* 1c: Reserved words */
2381 WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
2382 WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
2383 WORD e_res2[10]; /* 28: Reserved words */
2384 DWORD e_lfanew; /* 3c: Offset to extended header */
2385 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2386 #include <poppack.h>
2388 #define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
2389 #define IMAGE_OS2_SIGNATURE 0x454E /* NE */
2390 #define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
2391 #define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
2392 #define IMAGE_VXD_SIGNATURE 0x454C /* LE */
2393 #define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
2396 * This is the Windows executable (NE) header.
2397 * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
2399 #include <pshpack2.h>
2400 typedef struct
2402 WORD ne_magic; /* 00 NE signature 'NE' */
2403 BYTE ne_ver; /* 02 Linker version number */
2404 BYTE ne_rev; /* 03 Linker revision number */
2405 WORD ne_enttab; /* 04 Offset to entry table relative to NE */
2406 WORD ne_cbenttab; /* 06 Length of entry table in bytes */
2407 LONG ne_crc; /* 08 Checksum */
2408 WORD ne_flags; /* 0c Flags about segments in this file */
2409 WORD ne_autodata; /* 0e Automatic data segment number */
2410 WORD ne_heap; /* 10 Initial size of local heap */
2411 WORD ne_stack; /* 12 Initial size of stack */
2412 DWORD ne_csip; /* 14 Initial CS:IP */
2413 DWORD ne_sssp; /* 18 Initial SS:SP */
2414 WORD ne_cseg; /* 1c # of entries in segment table */
2415 WORD ne_cmod; /* 1e # of entries in module reference tab. */
2416 WORD ne_cbnrestab; /* 20 Length of nonresident-name table */
2417 WORD ne_segtab; /* 22 Offset to segment table */
2418 WORD ne_rsrctab; /* 24 Offset to resource table */
2419 WORD ne_restab; /* 26 Offset to resident-name table */
2420 WORD ne_modtab; /* 28 Offset to module reference table */
2421 WORD ne_imptab; /* 2a Offset to imported name table */
2422 DWORD ne_nrestab; /* 2c Offset to nonresident-name table */
2423 WORD ne_cmovent; /* 30 # of movable entry points */
2424 WORD ne_align; /* 32 Logical sector alignment shift count */
2425 WORD ne_cres; /* 34 # of resource segments */
2426 BYTE ne_exetyp; /* 36 Flags indicating target OS */
2427 BYTE ne_flagsothers; /* 37 Additional information flags */
2428 WORD ne_pretthunks; /* 38 Offset to return thunks */
2429 WORD ne_psegrefbytes; /* 3a Offset to segment ref. bytes */
2430 WORD ne_swaparea; /* 3c Reserved by Microsoft */
2431 WORD ne_expver; /* 3e Expected Windows version number */
2432 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
2433 #include <poppack.h>
2435 #include <pshpack2.h>
2436 typedef struct _IMAGE_VXD_HEADER {
2437 WORD e32_magic;
2438 BYTE e32_border;
2439 BYTE e32_worder;
2440 DWORD e32_level;
2441 WORD e32_cpu;
2442 WORD e32_os;
2443 DWORD e32_ver;
2444 DWORD e32_mflags;
2445 DWORD e32_mpages;
2446 DWORD e32_startobj;
2447 DWORD e32_eip;
2448 DWORD e32_stackobj;
2449 DWORD e32_esp;
2450 DWORD e32_pagesize;
2451 DWORD e32_lastpagesize;
2452 DWORD e32_fixupsize;
2453 DWORD e32_fixupsum;
2454 DWORD e32_ldrsize;
2455 DWORD e32_ldrsum;
2456 DWORD e32_objtab;
2457 DWORD e32_objcnt;
2458 DWORD e32_objmap;
2459 DWORD e32_itermap;
2460 DWORD e32_rsrctab;
2461 DWORD e32_rsrccnt;
2462 DWORD e32_restab;
2463 DWORD e32_enttab;
2464 DWORD e32_dirtab;
2465 DWORD e32_dircnt;
2466 DWORD e32_fpagetab;
2467 DWORD e32_frectab;
2468 DWORD e32_impmod;
2469 DWORD e32_impmodcnt;
2470 DWORD e32_impproc;
2471 DWORD e32_pagesum;
2472 DWORD e32_datapage;
2473 DWORD e32_preload;
2474 DWORD e32_nrestab;
2475 DWORD e32_cbnrestab;
2476 DWORD e32_nressum;
2477 DWORD e32_autodata;
2478 DWORD e32_debuginfo;
2479 DWORD e32_debuglen;
2480 DWORD e32_instpreload;
2481 DWORD e32_instdemand;
2482 DWORD e32_heapsize;
2483 BYTE e32_res3[12];
2484 DWORD e32_winresoff;
2485 DWORD e32_winreslen;
2486 WORD e32_devid;
2487 WORD e32_ddkver;
2488 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2489 #include <poppack.h>
2491 /* These defines describe the meanings of the bits in the Characteristics
2492 field */
2494 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
2495 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
2496 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
2497 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
2498 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
2499 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
2500 #define IMAGE_FILE_16BIT_MACHINE 0x0040
2501 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
2502 #define IMAGE_FILE_32BIT_MACHINE 0x0100
2503 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
2504 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
2505 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
2506 #define IMAGE_FILE_SYSTEM 0x1000
2507 #define IMAGE_FILE_DLL 0x2000
2508 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
2509 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
2511 /* These are the settings of the Machine field. */
2512 #define IMAGE_FILE_MACHINE_UNKNOWN 0
2513 #define IMAGE_FILE_MACHINE_I860 0x014d
2514 #define IMAGE_FILE_MACHINE_I386 0x014c
2515 #define IMAGE_FILE_MACHINE_R3000 0x0162
2516 #define IMAGE_FILE_MACHINE_R4000 0x0166
2517 #define IMAGE_FILE_MACHINE_R10000 0x0168
2518 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
2519 #define IMAGE_FILE_MACHINE_ALPHA 0x0184
2520 #define IMAGE_FILE_MACHINE_SH3 0x01a2
2521 #define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
2522 #define IMAGE_FILE_MACHINE_SH3E 0x01a4
2523 #define IMAGE_FILE_MACHINE_SH4 0x01a6
2524 #define IMAGE_FILE_MACHINE_SH5 0x01a8
2525 #define IMAGE_FILE_MACHINE_ARM 0x01c0
2526 #define IMAGE_FILE_MACHINE_THUMB 0x01c2
2527 #define IMAGE_FILE_MACHINE_ARMNT 0x01c4
2528 #define IMAGE_FILE_MACHINE_ARM64 0xaa64
2529 #define IMAGE_FILE_MACHINE_AM33 0x01d3
2530 #define IMAGE_FILE_MACHINE_POWERPC 0x01f0
2531 #define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
2532 #define IMAGE_FILE_MACHINE_IA64 0x0200
2533 #define IMAGE_FILE_MACHINE_MIPS16 0x0266
2534 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284
2535 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
2536 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
2537 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
2538 #define IMAGE_FILE_MACHINE_TRICORE 0x0520
2539 #define IMAGE_FILE_MACHINE_CEF 0x0cef
2540 #define IMAGE_FILE_MACHINE_EBC 0x0ebc
2541 #define IMAGE_FILE_MACHINE_AMD64 0x8664
2542 #define IMAGE_FILE_MACHINE_M32R 0x9041
2543 #define IMAGE_FILE_MACHINE_CEE 0xc0ee
2545 #define IMAGE_SIZEOF_FILE_HEADER 20
2546 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
2547 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
2548 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
2549 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
2550 #define IMAGE_SIZEOF_SHORT_NAME 8
2551 #define IMAGE_SIZEOF_SECTION_HEADER 40
2552 #define IMAGE_SIZEOF_SYMBOL 18
2553 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2554 #define IMAGE_SIZEOF_RELOCATION 10
2555 #define IMAGE_SIZEOF_BASE_RELOCATION 8
2556 #define IMAGE_SIZEOF_LINENUMBER 6
2557 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
2559 /* Possible Magic values */
2560 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
2561 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
2562 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
2564 #ifdef _WIN64
2565 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
2566 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
2567 #else
2568 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
2569 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
2570 #endif
2572 /* These are indexes into the DataDirectory array */
2573 #define IMAGE_FILE_EXPORT_DIRECTORY 0
2574 #define IMAGE_FILE_IMPORT_DIRECTORY 1
2575 #define IMAGE_FILE_RESOURCE_DIRECTORY 2
2576 #define IMAGE_FILE_EXCEPTION_DIRECTORY 3
2577 #define IMAGE_FILE_SECURITY_DIRECTORY 4
2578 #define IMAGE_FILE_BASE_RELOCATION_TABLE 5
2579 #define IMAGE_FILE_DEBUG_DIRECTORY 6
2580 #define IMAGE_FILE_DESCRIPTION_STRING 7
2581 #define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
2582 #define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
2583 #define IMAGE_FILE_CALLBACK_DIRECTORY 10
2585 /* Directory Entries, indices into the DataDirectory array */
2587 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
2588 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
2589 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
2590 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
2591 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4
2592 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
2593 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6
2594 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
2595 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* (MIPS GP) */
2596 #define IMAGE_DIRECTORY_ENTRY_TLS 9
2597 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
2598 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
2599 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
2600 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
2601 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
2603 /* Subsystem Values */
2605 #define IMAGE_SUBSYSTEM_UNKNOWN 0
2606 #define IMAGE_SUBSYSTEM_NATIVE 1
2607 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI subsystem */
2608 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows character subsystem */
2609 #define IMAGE_SUBSYSTEM_OS2_CUI 5
2610 #define IMAGE_SUBSYSTEM_POSIX_CUI 7
2611 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 /* native Win9x driver */
2612 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE subsystem */
2613 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
2614 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
2615 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
2616 #define IMAGE_SUBSYSTEM_EFI_ROM 13
2617 #define IMAGE_SUBSYSTEM_XBOX 14
2618 #define IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION 16
2620 /* DLL Characteristics */
2621 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
2622 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
2623 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
2624 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
2625 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
2626 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
2627 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
2628 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
2630 typedef struct _IMAGE_FILE_HEADER {
2631 WORD Machine;
2632 WORD NumberOfSections;
2633 DWORD TimeDateStamp;
2634 DWORD PointerToSymbolTable;
2635 DWORD NumberOfSymbols;
2636 WORD SizeOfOptionalHeader;
2637 WORD Characteristics;
2638 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
2640 typedef struct _IMAGE_DATA_DIRECTORY {
2641 DWORD VirtualAddress;
2642 DWORD Size;
2643 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
2645 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
2647 typedef struct _IMAGE_OPTIONAL_HEADER64 {
2648 WORD Magic; /* 0x20b */
2649 BYTE MajorLinkerVersion;
2650 BYTE MinorLinkerVersion;
2651 DWORD SizeOfCode;
2652 DWORD SizeOfInitializedData;
2653 DWORD SizeOfUninitializedData;
2654 DWORD AddressOfEntryPoint;
2655 DWORD BaseOfCode;
2656 ULONGLONG ImageBase;
2657 DWORD SectionAlignment;
2658 DWORD FileAlignment;
2659 WORD MajorOperatingSystemVersion;
2660 WORD MinorOperatingSystemVersion;
2661 WORD MajorImageVersion;
2662 WORD MinorImageVersion;
2663 WORD MajorSubsystemVersion;
2664 WORD MinorSubsystemVersion;
2665 DWORD Win32VersionValue;
2666 DWORD SizeOfImage;
2667 DWORD SizeOfHeaders;
2668 DWORD CheckSum;
2669 WORD Subsystem;
2670 WORD DllCharacteristics;
2671 ULONGLONG SizeOfStackReserve;
2672 ULONGLONG SizeOfStackCommit;
2673 ULONGLONG SizeOfHeapReserve;
2674 ULONGLONG SizeOfHeapCommit;
2675 DWORD LoaderFlags;
2676 DWORD NumberOfRvaAndSizes;
2677 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2678 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
2680 typedef struct _IMAGE_NT_HEADERS64 {
2681 DWORD Signature;
2682 IMAGE_FILE_HEADER FileHeader;
2683 IMAGE_OPTIONAL_HEADER64 OptionalHeader;
2684 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
2686 typedef struct _IMAGE_OPTIONAL_HEADER {
2688 /* Standard fields */
2690 WORD Magic; /* 0x10b or 0x107 */ /* 0x00 */
2691 BYTE MajorLinkerVersion;
2692 BYTE MinorLinkerVersion;
2693 DWORD SizeOfCode;
2694 DWORD SizeOfInitializedData;
2695 DWORD SizeOfUninitializedData;
2696 DWORD AddressOfEntryPoint; /* 0x10 */
2697 DWORD BaseOfCode;
2698 DWORD BaseOfData;
2700 /* NT additional fields */
2702 DWORD ImageBase;
2703 DWORD SectionAlignment; /* 0x20 */
2704 DWORD FileAlignment;
2705 WORD MajorOperatingSystemVersion;
2706 WORD MinorOperatingSystemVersion;
2707 WORD MajorImageVersion;
2708 WORD MinorImageVersion;
2709 WORD MajorSubsystemVersion; /* 0x30 */
2710 WORD MinorSubsystemVersion;
2711 DWORD Win32VersionValue;
2712 DWORD SizeOfImage;
2713 DWORD SizeOfHeaders;
2714 DWORD CheckSum; /* 0x40 */
2715 WORD Subsystem;
2716 WORD DllCharacteristics;
2717 DWORD SizeOfStackReserve;
2718 DWORD SizeOfStackCommit;
2719 DWORD SizeOfHeapReserve; /* 0x50 */
2720 DWORD SizeOfHeapCommit;
2721 DWORD LoaderFlags;
2722 DWORD NumberOfRvaAndSizes;
2723 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /* 0x60 */
2724 /* 0xE0 */
2725 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
2727 typedef struct _IMAGE_NT_HEADERS {
2728 DWORD Signature; /* "PE"\0\0 */ /* 0x00 */
2729 IMAGE_FILE_HEADER FileHeader; /* 0x04 */
2730 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /* 0x18 */
2731 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
2733 #ifdef _WIN64
2734 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
2735 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
2736 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
2737 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
2738 #else
2739 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
2740 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
2741 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
2742 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
2743 #endif
2745 #define IMAGE_SIZEOF_SHORT_NAME 8
2747 typedef struct _IMAGE_SECTION_HEADER {
2748 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
2749 union {
2750 DWORD PhysicalAddress;
2751 DWORD VirtualSize;
2752 } Misc;
2753 DWORD VirtualAddress;
2754 DWORD SizeOfRawData;
2755 DWORD PointerToRawData;
2756 DWORD PointerToRelocations;
2757 DWORD PointerToLinenumbers;
2758 WORD NumberOfRelocations;
2759 WORD NumberOfLinenumbers;
2760 DWORD Characteristics;
2761 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
2763 #define IMAGE_SIZEOF_SECTION_HEADER 40
2765 #define IMAGE_FIRST_SECTION(ntheader) \
2766 ((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
2767 ((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
2769 /* These defines are for the Characteristics bitfield. */
2770 /* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
2771 /* #define IMAGE_SCN_TYPE_DSECT 0x00000001 - Reserved */
2772 /* #define IMAGE_SCN_TYPE_NOLOAD 0x00000002 - Reserved */
2773 /* #define IMAGE_SCN_TYPE_GROUP 0x00000004 - Reserved */
2774 #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 /* Reserved */
2775 /* #define IMAGE_SCN_TYPE_COPY 0x00000010 - Reserved */
2777 #define IMAGE_SCN_CNT_CODE 0x00000020
2778 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
2779 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
2781 #define IMAGE_SCN_LNK_OTHER 0x00000100
2782 #define IMAGE_SCN_LNK_INFO 0x00000200
2783 /* #define IMAGE_SCN_TYPE_OVER 0x00000400 - Reserved */
2784 #define IMAGE_SCN_LNK_REMOVE 0x00000800
2785 #define IMAGE_SCN_LNK_COMDAT 0x00001000
2787 /* 0x00002000 - Reserved */
2788 /* #define IMAGE_SCN_MEM_PROTECTED 0x00004000 - Obsolete */
2789 #define IMAGE_SCN_MEM_FARDATA 0x00008000
2791 /* #define IMAGE_SCN_MEM_SYSHEAP 0x00010000 - Obsolete */
2792 #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
2793 #define IMAGE_SCN_MEM_16BIT 0x00020000
2794 #define IMAGE_SCN_MEM_LOCKED 0x00040000
2795 #define IMAGE_SCN_MEM_PRELOAD 0x00080000
2797 #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
2798 #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
2799 #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
2800 #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
2801 #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 /* Default */
2802 #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
2803 #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
2804 #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
2805 #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
2806 #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
2807 #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
2808 #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
2809 #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
2810 #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
2811 /* 0x00F00000 - Unused */
2812 #define IMAGE_SCN_ALIGN_MASK 0x00F00000
2814 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
2817 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
2818 #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
2819 #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
2820 #define IMAGE_SCN_MEM_SHARED 0x10000000
2821 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
2822 #define IMAGE_SCN_MEM_READ 0x40000000
2823 #define IMAGE_SCN_MEM_WRITE 0x80000000
2825 #include <pshpack2.h>
2827 typedef struct _IMAGE_SYMBOL {
2828 union {
2829 BYTE ShortName[8];
2830 struct {
2831 DWORD Short;
2832 DWORD Long;
2833 } Name;
2834 DWORD LongName[2];
2835 } N;
2836 DWORD Value;
2837 SHORT SectionNumber;
2838 WORD Type;
2839 BYTE StorageClass;
2840 BYTE NumberOfAuxSymbols;
2841 } IMAGE_SYMBOL;
2842 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
2844 #define IMAGE_SIZEOF_SYMBOL 18
2846 typedef struct _IMAGE_LINENUMBER {
2847 union {
2848 DWORD SymbolTableIndex;
2849 DWORD VirtualAddress;
2850 } Type;
2851 WORD Linenumber;
2852 } IMAGE_LINENUMBER;
2853 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
2855 #define IMAGE_SIZEOF_LINENUMBER 6
2857 typedef union _IMAGE_AUX_SYMBOL {
2858 struct {
2859 DWORD TagIndex;
2860 union {
2861 struct {
2862 WORD Linenumber;
2863 WORD Size;
2864 } LnSz;
2865 DWORD TotalSize;
2866 } Misc;
2867 union {
2868 struct {
2869 DWORD PointerToLinenumber;
2870 DWORD PointerToNextFunction;
2871 } Function;
2872 struct {
2873 WORD Dimension[4];
2874 } Array;
2875 } FcnAry;
2876 WORD TvIndex;
2877 } Sym;
2878 struct {
2879 BYTE Name[IMAGE_SIZEOF_SYMBOL];
2880 } File;
2881 struct {
2882 DWORD Length;
2883 WORD NumberOfRelocations;
2884 WORD NumberOfLinenumbers;
2885 DWORD CheckSum;
2886 SHORT Number;
2887 BYTE Selection;
2888 } Section;
2889 } IMAGE_AUX_SYMBOL;
2890 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
2892 #define IMAGE_SIZEOF_AUX_SYMBOL 18
2894 #include <poppack.h>
2896 #define IMAGE_SYM_UNDEFINED (SHORT)0
2897 #define IMAGE_SYM_ABSOLUTE (SHORT)-1
2898 #define IMAGE_SYM_DEBUG (SHORT)-2
2900 #define IMAGE_SYM_TYPE_NULL 0x0000
2901 #define IMAGE_SYM_TYPE_VOID 0x0001
2902 #define IMAGE_SYM_TYPE_CHAR 0x0002
2903 #define IMAGE_SYM_TYPE_SHORT 0x0003
2904 #define IMAGE_SYM_TYPE_INT 0x0004
2905 #define IMAGE_SYM_TYPE_LONG 0x0005
2906 #define IMAGE_SYM_TYPE_FLOAT 0x0006
2907 #define IMAGE_SYM_TYPE_DOUBLE 0x0007
2908 #define IMAGE_SYM_TYPE_STRUCT 0x0008
2909 #define IMAGE_SYM_TYPE_UNION 0x0009
2910 #define IMAGE_SYM_TYPE_ENUM 0x000A
2911 #define IMAGE_SYM_TYPE_MOE 0x000B
2912 #define IMAGE_SYM_TYPE_BYTE 0x000C
2913 #define IMAGE_SYM_TYPE_WORD 0x000D
2914 #define IMAGE_SYM_TYPE_UINT 0x000E
2915 #define IMAGE_SYM_TYPE_DWORD 0x000F
2916 #define IMAGE_SYM_TYPE_PCODE 0x8000
2918 #define IMAGE_SYM_DTYPE_NULL 0
2919 #define IMAGE_SYM_DTYPE_POINTER 1
2920 #define IMAGE_SYM_DTYPE_FUNCTION 2
2921 #define IMAGE_SYM_DTYPE_ARRAY 3
2923 #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1
2924 #define IMAGE_SYM_CLASS_NULL 0x0000
2925 #define IMAGE_SYM_CLASS_AUTOMATIC 0x0001
2926 #define IMAGE_SYM_CLASS_EXTERNAL 0x0002
2927 #define IMAGE_SYM_CLASS_STATIC 0x0003
2928 #define IMAGE_SYM_CLASS_REGISTER 0x0004
2929 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 0x0005
2930 #define IMAGE_SYM_CLASS_LABEL 0x0006
2931 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 0x0007
2932 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 0x0008
2933 #define IMAGE_SYM_CLASS_ARGUMENT 0x0009
2934 #define IMAGE_SYM_CLASS_STRUCT_TAG 0x000A
2935 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 0x000B
2936 #define IMAGE_SYM_CLASS_UNION_TAG 0x000C
2937 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 0x000D
2938 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 0x000E
2939 #define IMAGE_SYM_CLASS_ENUM_TAG 0x000F
2940 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 0x0010
2941 #define IMAGE_SYM_CLASS_REGISTER_PARAM 0x0011
2942 #define IMAGE_SYM_CLASS_BIT_FIELD 0x0012
2944 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 0x0044
2945 #define IMAGE_SYM_CLASS_BLOCK 0x0064
2946 #define IMAGE_SYM_CLASS_FUNCTION 0x0065
2947 #define IMAGE_SYM_CLASS_END_OF_STRUCT 0x0066
2948 #define IMAGE_SYM_CLASS_FILE 0x0067
2949 #define IMAGE_SYM_CLASS_SECTION 0x0068
2950 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 0x0069
2952 #define N_BTMASK 0x000F
2953 #define N_TMASK 0x0030
2954 #define N_TMASK1 0x00C0
2955 #define N_TMASK2 0x00F0
2956 #define N_BTSHFT 4
2957 #define N_TSHIFT 2
2959 #define BTYPE(x) ((x) & N_BTMASK)
2961 #ifndef ISPTR
2962 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
2963 #endif
2965 #ifndef ISFCN
2966 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
2967 #endif
2969 #ifndef ISARY
2970 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
2971 #endif
2973 #ifndef ISTAG
2974 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
2975 #endif
2977 #ifndef INCREF
2978 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
2979 #endif
2980 #ifndef DECREF
2981 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
2982 #endif
2984 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
2985 #define IMAGE_COMDAT_SELECT_ANY 2
2986 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
2987 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
2988 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
2989 #define IMAGE_COMDAT_SELECT_LARGEST 6
2990 #define IMAGE_COMDAT_SELECT_NEWEST 7
2992 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
2993 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
2994 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
2996 /* Export module directory */
2998 typedef struct _IMAGE_EXPORT_DIRECTORY {
2999 DWORD Characteristics;
3000 DWORD TimeDateStamp;
3001 WORD MajorVersion;
3002 WORD MinorVersion;
3003 DWORD Name;
3004 DWORD Base;
3005 DWORD NumberOfFunctions;
3006 DWORD NumberOfNames;
3007 DWORD AddressOfFunctions;
3008 DWORD AddressOfNames;
3009 DWORD AddressOfNameOrdinals;
3010 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
3012 /* Import name entry */
3013 typedef struct _IMAGE_IMPORT_BY_NAME {
3014 WORD Hint;
3015 BYTE Name[1];
3016 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
3018 #include <pshpack8.h>
3019 /* Import thunk */
3020 typedef struct _IMAGE_THUNK_DATA64 {
3021 union {
3022 ULONGLONG ForwarderString;
3023 ULONGLONG Function;
3024 ULONGLONG Ordinal;
3025 ULONGLONG AddressOfData;
3026 } u1;
3027 } IMAGE_THUNK_DATA64,*PIMAGE_THUNK_DATA64;
3028 #include <poppack.h>
3030 typedef struct _IMAGE_THUNK_DATA32 {
3031 union {
3032 DWORD ForwarderString;
3033 DWORD Function;
3034 DWORD Ordinal;
3035 DWORD AddressOfData;
3036 } u1;
3037 } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
3039 /* Import module directory */
3041 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3042 union {
3043 DWORD Characteristics; /* 0 for terminating null import descriptor */
3044 DWORD OriginalFirstThunk; /* RVA to original unbound IAT */
3045 } DUMMYUNIONNAME;
3046 DWORD TimeDateStamp; /* 0 if not bound,
3047 * -1 if bound, and real date\time stamp
3048 * in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
3049 * (new BIND)
3050 * otherwise date/time stamp of DLL bound to
3051 * (Old BIND)
3053 DWORD ForwarderChain; /* -1 if no forwarders */
3054 DWORD Name;
3055 /* RVA to IAT (if bound this IAT has actual addresses) */
3056 DWORD FirstThunk;
3057 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
3059 #define IMAGE_ORDINAL_FLAG64 (((ULONGLONG)0x80000000 << 32) | 0x00000000)
3060 #define IMAGE_ORDINAL_FLAG32 0x80000000
3061 #define IMAGE_SNAP_BY_ORDINAL64(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG64) != 0)
3062 #define IMAGE_SNAP_BY_ORDINAL32(ordinal) (((ordinal) & IMAGE_ORDINAL_FLAG32) != 0)
3063 #define IMAGE_ORDINAL64(ordinal) ((ordinal) & 0xffff)
3064 #define IMAGE_ORDINAL32(ordinal) ((ordinal) & 0xffff)
3066 #ifdef _WIN64
3067 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3068 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3069 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3070 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3071 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3072 #else
3073 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3074 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3075 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3076 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3077 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3078 #endif
3080 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
3082 DWORD TimeDateStamp;
3083 WORD OffsetModuleName;
3084 WORD NumberOfModuleForwarderRefs;
3085 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
3086 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3088 typedef struct _IMAGE_BOUND_FORWARDER_REF
3090 DWORD TimeDateStamp;
3091 WORD OffsetModuleName;
3092 WORD Reserved;
3093 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3095 typedef struct _IMAGE_BASE_RELOCATION
3097 DWORD VirtualAddress;
3098 DWORD SizeOfBlock;
3099 /* WORD TypeOffset[1]; */
3100 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
3102 #include <pshpack2.h>
3104 typedef struct _IMAGE_RELOCATION
3106 union {
3107 DWORD VirtualAddress;
3108 DWORD RelocCount;
3109 } DUMMYUNIONNAME;
3110 DWORD SymbolTableIndex;
3111 WORD Type;
3112 } IMAGE_RELOCATION, *PIMAGE_RELOCATION;
3114 #include <poppack.h>
3116 #define IMAGE_SIZEOF_RELOCATION 10
3118 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR
3120 union
3122 DWORD AllAttributes;
3123 struct
3125 DWORD RvaBased:1;
3126 DWORD ReservedAttributes:31;
3127 } DUMMYSTRUCTNAME;
3128 } Attributes;
3130 DWORD DllNameRVA;
3131 DWORD ModuleHandleRVA;
3132 DWORD ImportAddressTableRVA;
3133 DWORD ImportNameTableRVA;
3134 DWORD BoundImportAddressTableRVA;
3135 DWORD UnloadInformationTableRVA;
3136 DWORD TimeDateStamp;
3137 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3138 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3140 /* generic relocation types */
3141 #define IMAGE_REL_BASED_ABSOLUTE 0
3142 #define IMAGE_REL_BASED_HIGH 1
3143 #define IMAGE_REL_BASED_LOW 2
3144 #define IMAGE_REL_BASED_HIGHLOW 3
3145 #define IMAGE_REL_BASED_HIGHADJ 4
3146 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
3147 #define IMAGE_REL_BASED_ARM_MOV32A 5 /* yes, 5 too */
3148 #define IMAGE_REL_BASED_ARM_MOV32 5 /* yes, 5 too */
3149 #define IMAGE_REL_BASED_SECTION 6
3150 #define IMAGE_REL_BASED_REL 7
3151 #define IMAGE_REL_BASED_ARM_MOV32T 7 /* yes, 7 too */
3152 #define IMAGE_REL_BASED_THUMB_MOV32 7 /* yes, 7 too */
3153 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
3154 #define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
3155 #define IMAGE_REL_BASED_DIR64 10
3156 #define IMAGE_REL_BASED_HIGH3ADJ 11
3158 /* I386 relocation types */
3159 #define IMAGE_REL_I386_ABSOLUTE 0
3160 #define IMAGE_REL_I386_DIR16 1
3161 #define IMAGE_REL_I386_REL16 2
3162 #define IMAGE_REL_I386_DIR32 6
3163 #define IMAGE_REL_I386_DIR32NB 7
3164 #define IMAGE_REL_I386_SEG12 9
3165 #define IMAGE_REL_I386_SECTION 10
3166 #define IMAGE_REL_I386_SECREL 11
3167 #define IMAGE_REL_I386_TOKEN 12
3168 #define IMAGE_REL_I386_SECREL7 13
3169 #define IMAGE_REL_I386_REL32 20
3171 /* MIPS relocation types */
3172 #define IMAGE_REL_MIPS_ABSOLUTE 0x0000
3173 #define IMAGE_REL_MIPS_REFHALF 0x0001
3174 #define IMAGE_REL_MIPS_REFWORD 0x0002
3175 #define IMAGE_REL_MIPS_JMPADDR 0x0003
3176 #define IMAGE_REL_MIPS_REFHI 0x0004
3177 #define IMAGE_REL_MIPS_REFLO 0x0005
3178 #define IMAGE_REL_MIPS_GPREL 0x0006
3179 #define IMAGE_REL_MIPS_LITERAL 0x0007
3180 #define IMAGE_REL_MIPS_SECTION 0x000A
3181 #define IMAGE_REL_MIPS_SECREL 0x000B
3182 #define IMAGE_REL_MIPS_SECRELLO 0x000C
3183 #define IMAGE_REL_MIPS_SECRELHI 0x000D
3184 #define IMAGE_REL_MIPS_TOKEN 0x000E
3185 #define IMAGE_REL_MIPS_JMPADDR16 0x0010
3186 #define IMAGE_REL_MIPS_REFWORDNB 0x0022
3187 #define IMAGE_REL_MIPS_PAIR 0x0025
3189 /* ALPHA relocation types */
3190 #define IMAGE_REL_ALPHA_ABSOLUTE 0x0000
3191 #define IMAGE_REL_ALPHA_REFLONG 0x0001
3192 #define IMAGE_REL_ALPHA_REFQUAD 0x0002
3193 #define IMAGE_REL_ALPHA_GPREL 0x0003
3194 #define IMAGE_REL_ALPHA_LITERAL 0x0004
3195 #define IMAGE_REL_ALPHA_LITUSE 0x0005
3196 #define IMAGE_REL_ALPHA_GPDISP 0x0006
3197 #define IMAGE_REL_ALPHA_BRADDR 0x0007
3198 #define IMAGE_REL_ALPHA_HINT 0x0008
3199 #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x0009
3200 #define IMAGE_REL_ALPHA_REFHI 0x000A
3201 #define IMAGE_REL_ALPHA_REFLO 0x000B
3202 #define IMAGE_REL_ALPHA_PAIR 0x000C
3203 #define IMAGE_REL_ALPHA_MATCH 0x000D
3204 #define IMAGE_REL_ALPHA_SECTION 0x000E
3205 #define IMAGE_REL_ALPHA_SECREL 0x000F
3206 #define IMAGE_REL_ALPHA_REFLONGNB 0x0010
3207 #define IMAGE_REL_ALPHA_SECRELLO 0x0011
3208 #define IMAGE_REL_ALPHA_SECRELHI 0x0012
3209 #define IMAGE_REL_ALPHA_REFQ3 0x0013
3210 #define IMAGE_REL_ALPHA_REFQ2 0x0014
3211 #define IMAGE_REL_ALPHA_REFQ1 0x0015
3212 #define IMAGE_REL_ALPHA_GPRELLO 0x0016
3213 #define IMAGE_REL_ALPHA_GPRELHI 0x0017
3215 /* PowerPC relocation types */
3216 #define IMAGE_REL_PPC_ABSOLUTE 0x0000
3217 #define IMAGE_REL_PPC_ADDR64 0x0001
3218 #define IMAGE_REL_PPC_ADDR 0x0002
3219 #define IMAGE_REL_PPC_ADDR24 0x0003
3220 #define IMAGE_REL_PPC_ADDR16 0x0004
3221 #define IMAGE_REL_PPC_ADDR14 0x0005
3222 #define IMAGE_REL_PPC_REL24 0x0006
3223 #define IMAGE_REL_PPC_REL14 0x0007
3224 #define IMAGE_REL_PPC_TOCREL16 0x0008
3225 #define IMAGE_REL_PPC_TOCREL14 0x0009
3226 #define IMAGE_REL_PPC_ADDR32NB 0x000A
3227 #define IMAGE_REL_PPC_SECREL 0x000B
3228 #define IMAGE_REL_PPC_SECTION 0x000C
3229 #define IMAGE_REL_PPC_IFGLUE 0x000D
3230 #define IMAGE_REL_PPC_IMGLUE 0x000E
3231 #define IMAGE_REL_PPC_SECREL16 0x000F
3232 #define IMAGE_REL_PPC_REFHI 0x0010
3233 #define IMAGE_REL_PPC_REFLO 0x0011
3234 #define IMAGE_REL_PPC_PAIR 0x0012
3235 #define IMAGE_REL_PPC_SECRELLO 0x0013
3236 #define IMAGE_REL_PPC_SECRELHI 0x0014
3237 #define IMAGE_REL_PPC_GPREL 0x0015
3238 #define IMAGE_REL_PPC_TOKEN 0x0016
3239 #define IMAGE_REL_PPC_TYPEMASK 0x00FF
3240 /* modifier bits */
3241 #define IMAGE_REL_PPC_NEG 0x0100
3242 #define IMAGE_REL_PPC_BRTAKEN 0x0200
3243 #define IMAGE_REL_PPC_BRNTAKEN 0x0400
3244 #define IMAGE_REL_PPC_TOCDEFN 0x0800
3246 /* SH3 relocation types */
3247 #define IMAGE_REL_SH3_ABSOLUTE 0x0000
3248 #define IMAGE_REL_SH3_DIRECT16 0x0001
3249 #define IMAGE_REL_SH3_DIRECT 0x0002
3250 #define IMAGE_REL_SH3_DIRECT8 0x0003
3251 #define IMAGE_REL_SH3_DIRECT8_WORD 0x0004
3252 #define IMAGE_REL_SH3_DIRECT8_LONG 0x0005
3253 #define IMAGE_REL_SH3_DIRECT4 0x0006
3254 #define IMAGE_REL_SH3_DIRECT4_WORD 0x0007
3255 #define IMAGE_REL_SH3_DIRECT4_LONG 0x0008
3256 #define IMAGE_REL_SH3_PCREL8_WORD 0x0009
3257 #define IMAGE_REL_SH3_PCREL8_LONG 0x000A
3258 #define IMAGE_REL_SH3_PCREL12_WORD 0x000B
3259 #define IMAGE_REL_SH3_STARTOF_SECTION 0x000C
3260 #define IMAGE_REL_SH3_SIZEOF_SECTION 0x000D
3261 #define IMAGE_REL_SH3_SECTION 0x000E
3262 #define IMAGE_REL_SH3_SECREL 0x000F
3263 #define IMAGE_REL_SH3_DIRECT32_NB 0x0010
3264 #define IMAGE_REL_SH3_GPREL4_LONG 0x0011
3265 #define IMAGE_REL_SH3_TOKEN 0x0012
3267 /* ARM relocation types */
3268 #define IMAGE_REL_ARM_ABSOLUTE 0x0000
3269 #define IMAGE_REL_ARM_ADDR 0x0001
3270 #define IMAGE_REL_ARM_ADDR32NB 0x0002
3271 #define IMAGE_REL_ARM_BRANCH24 0x0003
3272 #define IMAGE_REL_ARM_BRANCH11 0x0004
3273 #define IMAGE_REL_ARM_TOKEN 0x0005
3274 #define IMAGE_REL_ARM_GPREL12 0x0006
3275 #define IMAGE_REL_ARM_GPREL7 0x0007
3276 #define IMAGE_REL_ARM_BLX24 0x0008
3277 #define IMAGE_REL_ARM_BLX11 0x0009
3278 #define IMAGE_REL_ARM_SECTION 0x000E
3279 #define IMAGE_REL_ARM_SECREL 0x000F
3280 #define IMAGE_REL_ARM_MOV32A 0x0010
3281 #define IMAGE_REL_ARM_MOV32T 0x0011
3282 #define IMAGE_REL_ARM_BRANCH20T 0x0012
3283 #define IMAGE_REL_ARM_BRANCH24T 0x0014
3284 #define IMAGE_REL_ARM_BLX23T 0x0015
3286 /* ARM64 relocation types */
3287 #define IMAGE_REL_ARM64_ABSOLUTE 0x0000
3288 #define IMAGE_REL_ARM64_ADDR32 0x0001
3289 #define IMAGE_REL_ARM64_ADDR32NB 0x0002
3290 #define IMAGE_REL_ARM64_BRANCH26 0x0003
3291 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004
3292 #define IMAGE_REL_ARM64_REL21 0x0005
3293 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006
3294 #define IMAGE_REL_ARM64_PAGEOFFSET_12L 0x0007
3295 #define IMAGE_REL_ARM64_SECREL 0x0008
3296 #define IMAGE_REL_ARM64_SECREL_LOW12A 0x0009
3297 #define IMAGE_REL_ARM64_SECREL_HIGH12A 0x000A
3298 #define IMAGE_REL_ARM64_SECREL_LOW12L 0x000B
3299 #define IMAGE_REL_ARM64_TOKEN 0x000C
3300 #define IMAGE_REL_ARM64_SECTION 0x000D
3301 #define IMAGE_REL_ARM64_ADDR64 0x000E
3303 /* IA64 relocation types */
3304 #define IMAGE_REL_IA64_ABSOLUTE 0x0000
3305 #define IMAGE_REL_IA64_IMM14 0x0001
3306 #define IMAGE_REL_IA64_IMM22 0x0002
3307 #define IMAGE_REL_IA64_IMM64 0x0003
3308 #define IMAGE_REL_IA64_DIR 0x0004
3309 #define IMAGE_REL_IA64_DIR64 0x0005
3310 #define IMAGE_REL_IA64_PCREL21B 0x0006
3311 #define IMAGE_REL_IA64_PCREL21M 0x0007
3312 #define IMAGE_REL_IA64_PCREL21F 0x0008
3313 #define IMAGE_REL_IA64_GPREL22 0x0009
3314 #define IMAGE_REL_IA64_LTOFF22 0x000A
3315 #define IMAGE_REL_IA64_SECTION 0x000B
3316 #define IMAGE_REL_IA64_SECREL22 0x000C
3317 #define IMAGE_REL_IA64_SECREL64I 0x000D
3318 #define IMAGE_REL_IA64_SECREL 0x000E
3319 #define IMAGE_REL_IA64_LTOFF64 0x000F
3320 #define IMAGE_REL_IA64_DIR32NB 0x0010
3321 #define IMAGE_REL_IA64_SREL14 0x0011
3322 #define IMAGE_REL_IA64_SREL22 0x0012
3323 #define IMAGE_REL_IA64_SREL32 0x0013
3324 #define IMAGE_REL_IA64_UREL32 0x0014
3325 #define IMAGE_REL_IA64_PCREL60X 0x0015
3326 #define IMAGE_REL_IA64_PCREL60B 0x0016
3327 #define IMAGE_REL_IA64_PCREL60F 0x0017
3328 #define IMAGE_REL_IA64_PCREL60I 0x0018
3329 #define IMAGE_REL_IA64_PCREL60M 0x0019
3330 #define IMAGE_REL_IA64_IMMGPREL64 0x001A
3331 #define IMAGE_REL_IA64_TOKEN 0x001B
3332 #define IMAGE_REL_IA64_GPREL32 0x001C
3333 #define IMAGE_REL_IA64_ADDEND 0x001F
3335 /* AMD64 relocation types */
3336 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
3337 #define IMAGE_REL_AMD64_ADDR64 0x0001
3338 #define IMAGE_REL_AMD64_ADDR32 0x0002
3339 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
3340 #define IMAGE_REL_AMD64_REL32 0x0004
3341 #define IMAGE_REL_AMD64_REL32_1 0x0005
3342 #define IMAGE_REL_AMD64_REL32_2 0x0006
3343 #define IMAGE_REL_AMD64_REL32_3 0x0007
3344 #define IMAGE_REL_AMD64_REL32_4 0x0008
3345 #define IMAGE_REL_AMD64_REL32_5 0x0009
3346 #define IMAGE_REL_AMD64_SECTION 0x000A
3347 #define IMAGE_REL_AMD64_SECREL 0x000B
3348 #define IMAGE_REL_AMD64_SECREL7 0x000C
3349 #define IMAGE_REL_AMD64_TOKEN 0x000D
3350 #define IMAGE_REL_AMD64_SREL32 0x000E
3351 #define IMAGE_REL_AMD64_PAIR 0x000F
3352 #define IMAGE_REL_AMD64_SSPAN32 0x0010
3354 /* archive format */
3356 #define IMAGE_ARCHIVE_START_SIZE 8
3357 #define IMAGE_ARCHIVE_START "!<arch>\n"
3358 #define IMAGE_ARCHIVE_END "`\n"
3359 #define IMAGE_ARCHIVE_PAD "\n"
3360 #define IMAGE_ARCHIVE_LINKER_MEMBER "/ "
3361 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
3363 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
3365 BYTE Name[16];
3366 BYTE Date[12];
3367 BYTE UserID[6];
3368 BYTE GroupID[6];
3369 BYTE Mode[8];
3370 BYTE Size[10];
3371 BYTE EndHeader[2];
3372 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3374 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
3376 typedef struct _IMPORT_OBJECT_HEADER
3378 WORD Sig1;
3379 WORD Sig2;
3380 WORD Version;
3381 WORD Machine;
3382 DWORD TimeDateStamp;
3383 DWORD SizeOfData;
3384 union
3386 WORD Ordinal;
3387 WORD Hint;
3388 } DUMMYUNIONNAME;
3389 WORD Type : 2;
3390 WORD NameType : 3;
3391 WORD Reserved : 11;
3392 } IMPORT_OBJECT_HEADER;
3394 #define IMPORT_OBJECT_HDR_SIG2 0xffff
3396 typedef enum IMPORT_OBJECT_TYPE
3398 IMPORT_OBJECT_CODE = 0,
3399 IMPORT_OBJECT_DATA = 1,
3400 IMPORT_OBJECT_CONST = 2
3401 } IMPORT_OBJECT_TYPE;
3403 typedef enum IMPORT_OBJECT_NAME_TYPE
3405 IMPORT_OBJECT_ORDINAL = 0,
3406 IMPORT_OBJECT_NAME = 1,
3407 IMPORT_OBJECT_NAME_NO_PREFIX = 2,
3408 IMPORT_OBJECT_NAME_UNDECORATE = 3
3409 } IMPORT_OBJECT_NAME_TYPE;
3411 typedef struct _ANON_OBJECT_HEADER
3413 WORD Sig1;
3414 WORD Sig2;
3415 WORD Version;
3416 WORD Machine;
3417 DWORD TimeDateStamp;
3418 CLSID ClassID;
3419 DWORD SizeOfData;
3420 } ANON_OBJECT_HEADER;
3423 * Resource directory stuff
3425 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3426 DWORD Characteristics;
3427 DWORD TimeDateStamp;
3428 WORD MajorVersion;
3429 WORD MinorVersion;
3430 WORD NumberOfNamedEntries;
3431 WORD NumberOfIdEntries;
3432 /* IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
3433 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
3435 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
3436 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
3438 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3439 union {
3440 struct {
3441 #ifdef BITFIELDS_BIGENDIAN
3442 unsigned NameIsString:1;
3443 unsigned NameOffset:31;
3444 #else
3445 unsigned NameOffset:31;
3446 unsigned NameIsString:1;
3447 #endif
3448 } DUMMYSTRUCTNAME;
3449 DWORD Name;
3450 #ifdef WORDS_BIGENDIAN
3451 WORD __pad;
3452 WORD Id;
3453 #else
3454 WORD Id;
3455 WORD __pad;
3456 #endif
3457 } DUMMYUNIONNAME;
3458 union {
3459 DWORD OffsetToData;
3460 struct {
3461 #ifdef BITFIELDS_BIGENDIAN
3462 unsigned DataIsDirectory:1;
3463 unsigned OffsetToDirectory:31;
3464 #else
3465 unsigned OffsetToDirectory:31;
3466 unsigned DataIsDirectory:1;
3467 #endif
3468 } DUMMYSTRUCTNAME2;
3469 } DUMMYUNIONNAME2;
3470 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3473 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3474 WORD Length;
3475 CHAR NameString[ 1 ];
3476 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
3478 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3479 WORD Length;
3480 WCHAR NameString[ 1 ];
3481 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
3483 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3484 DWORD OffsetToData;
3485 DWORD Size;
3486 DWORD CodePage;
3487 DWORD Reserved;
3488 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
3491 typedef VOID (CALLBACK *PIMAGE_TLS_CALLBACK)(
3492 LPVOID DllHandle,DWORD Reason,LPVOID Reserved
3495 typedef struct _IMAGE_TLS_DIRECTORY64 {
3496 ULONGLONG StartAddressOfRawData;
3497 ULONGLONG EndAddressOfRawData;
3498 ULONGLONG AddressOfIndex;
3499 ULONGLONG AddressOfCallBacks;
3500 DWORD SizeOfZeroFill;
3501 DWORD Characteristics;
3502 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3504 typedef struct _IMAGE_TLS_DIRECTORY32 {
3505 DWORD StartAddressOfRawData;
3506 DWORD EndAddressOfRawData;
3507 DWORD AddressOfIndex;
3508 DWORD AddressOfCallBacks;
3509 DWORD SizeOfZeroFill;
3510 DWORD Characteristics;
3511 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3513 #ifdef _WIN64
3514 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3515 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3516 #else
3517 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3518 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3519 #endif
3521 typedef struct _IMAGE_DEBUG_DIRECTORY {
3522 DWORD Characteristics;
3523 DWORD TimeDateStamp;
3524 WORD MajorVersion;
3525 WORD MinorVersion;
3526 DWORD Type;
3527 DWORD SizeOfData;
3528 DWORD AddressOfRawData;
3529 DWORD PointerToRawData;
3530 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3532 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
3533 #define IMAGE_DEBUG_TYPE_COFF 1
3534 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
3535 #define IMAGE_DEBUG_TYPE_FPO 3
3536 #define IMAGE_DEBUG_TYPE_MISC 4
3537 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
3538 #define IMAGE_DEBUG_TYPE_FIXUP 6
3539 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
3540 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
3541 #define IMAGE_DEBUG_TYPE_BORLAND 9
3542 #define IMAGE_DEBUG_TYPE_RESERVED10 10
3543 #define IMAGE_DEBUG_TYPE_CLSID 11
3544 #define IMAGE_DEBUG_TYPE_VC_FEATURE 12
3545 #define IMAGE_DEBUG_TYPE_POGO 13
3546 #define IMAGE_DEBUG_TYPE_ILTCG 14
3547 #define IMAGE_DEBUG_TYPE_MPX 15
3549 typedef enum ReplacesCorHdrNumericDefines
3551 COMIMAGE_FLAGS_ILONLY = 0x00000001,
3552 COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3553 COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3554 COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3555 COMIMAGE_FLAGS_NATIVE_ENTRYPOINT= 0x00000010,
3556 COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3558 COR_VERSION_MAJOR_V2 = 2,
3559 COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3560 COR_VERSION_MINOR = 0,
3561 COR_DELETED_NAME_LENGTH = 8,
3562 COR_VTABLEGAP_NAME_LENGTH = 8,
3564 NATIVE_TYPE_MAX_CB = 1,
3565 COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xff,
3567 IMAGE_COR_MIH_METHODRVA = 0x01,
3568 IMAGE_COR_MIH_EHRVA = 0x02,
3569 IMAGE_COR_MIH_BASICBLOCK = 0x08,
3571 COR_VTABLE_32BIT = 0x01,
3572 COR_VTABLE_64BIT = 0x02,
3573 COR_VTABLE_FROM_UNMANAGED = 0x04,
3574 COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3576 IMAGE_COR_EATJ_THUNK_SIZE = 32,
3578 MAX_CLASS_NAME = 1024,
3579 MAX_PACKAGE_NAME = 1024,
3580 } ReplacesCorHdrNumericDefines;
3582 typedef struct IMAGE_COR20_HEADER
3584 DWORD cb;
3585 WORD MajorRuntimeVersion;
3586 WORD MinorRuntimeVersion;
3588 IMAGE_DATA_DIRECTORY MetaData;
3589 DWORD Flags;
3590 union {
3591 DWORD EntryPointToken;
3592 DWORD EntryPointRVA;
3593 } DUMMYUNIONNAME;
3595 IMAGE_DATA_DIRECTORY Resources;
3596 IMAGE_DATA_DIRECTORY StrongNameSignature;
3597 IMAGE_DATA_DIRECTORY CodeManagerTable;
3598 IMAGE_DATA_DIRECTORY VTableFixups;
3599 IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3600 IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3602 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3604 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3605 DWORD NumberOfSymbols;
3606 DWORD LvaToFirstSymbol;
3607 DWORD NumberOfLinenumbers;
3608 DWORD LvaToFirstLinenumber;
3609 DWORD RvaToFirstByteOfCode;
3610 DWORD RvaToLastByteOfCode;
3611 DWORD RvaToFirstByteOfData;
3612 DWORD RvaToLastByteOfData;
3613 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3615 #define FRAME_FPO 0
3616 #define FRAME_TRAP 1
3617 #define FRAME_TSS 2
3618 #define FRAME_NONFPO 3
3620 typedef struct _FPO_DATA {
3621 DWORD ulOffStart;
3622 DWORD cbProcSize;
3623 DWORD cdwLocals;
3624 WORD cdwParams;
3625 WORD cbProlog : 8;
3626 WORD cbRegs : 3;
3627 WORD fHasSEH : 1;
3628 WORD fUseBP : 1;
3629 WORD reserved : 1;
3630 WORD cbFrame : 2;
3631 } FPO_DATA, *PFPO_DATA;
3633 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
3634 DWORD Size;
3635 DWORD TimeDateStamp;
3636 WORD MajorVersion;
3637 WORD MinorVersion;
3638 DWORD GlobalFlagsClear;
3639 DWORD GlobalFlagsSet;
3640 DWORD CriticalSectionDefaultTimeout;
3641 ULONGLONG DeCommitFreeBlockThreshold;
3642 ULONGLONG DeCommitTotalFreeThreshold;
3643 ULONGLONG LockPrefixTable;
3644 ULONGLONG MaximumAllocationSize;
3645 ULONGLONG VirtualMemoryThreshold;
3646 ULONGLONG ProcessAffinityMask;
3647 DWORD ProcessHeapFlags;
3648 WORD CSDVersion;
3649 WORD Reserved1;
3650 ULONGLONG EditList;
3651 ULONGLONG SecurityCookie;
3652 ULONGLONG SEHandlerTable;
3653 ULONGLONG SEHandlerCount;
3654 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
3656 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
3657 DWORD Size;
3658 DWORD TimeDateStamp;
3659 WORD MajorVersion;
3660 WORD MinorVersion;
3661 DWORD GlobalFlagsClear;
3662 DWORD GlobalFlagsSet;
3663 DWORD CriticalSectionDefaultTimeout;
3664 DWORD DeCommitFreeBlockThreshold;
3665 DWORD DeCommitTotalFreeThreshold;
3666 PVOID LockPrefixTable;
3667 DWORD MaximumAllocationSize;
3668 DWORD VirtualMemoryThreshold;
3669 DWORD ProcessHeapFlags;
3670 DWORD ProcessAffinityMask;
3671 WORD CSDVersion;
3672 WORD Reserved1;
3673 PVOID EditList;
3674 DWORD SecurityCookie;
3675 DWORD SEHandlerTable;
3676 DWORD SEHandlerCount;
3677 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
3679 #ifdef _WIN64
3680 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
3681 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
3682 #else
3683 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
3684 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
3685 #endif
3687 typedef struct _IMAGE_FUNCTION_ENTRY {
3688 DWORD StartingAddress;
3689 DWORD EndingAddress;
3690 DWORD EndOfPrologue;
3691 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3693 #define IMAGE_DEBUG_MISC_EXENAME 1
3695 typedef struct _IMAGE_DEBUG_MISC {
3696 DWORD DataType;
3697 DWORD Length;
3698 BYTE Unicode;
3699 BYTE Reserved[ 3 ];
3700 BYTE Data[ 1 ];
3701 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3703 /* This is the structure that appears at the very start of a .DBG file. */
3705 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3706 WORD Signature;
3707 WORD Flags;
3708 WORD Machine;
3709 WORD Characteristics;
3710 DWORD TimeDateStamp;
3711 DWORD CheckSum;
3712 DWORD ImageBase;
3713 DWORD SizeOfImage;
3714 DWORD NumberOfSections;
3715 DWORD ExportedNamesSize;
3716 DWORD DebugDirectorySize;
3717 DWORD SectionAlignment;
3718 DWORD Reserved[ 2 ];
3719 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
3721 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
3724 typedef struct tagMESSAGE_RESOURCE_ENTRY {
3725 WORD Length;
3726 WORD Flags;
3727 BYTE Text[1];
3728 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
3729 #define MESSAGE_RESOURCE_UNICODE 0x0001
3731 typedef struct tagMESSAGE_RESOURCE_BLOCK {
3732 DWORD LowId;
3733 DWORD HighId;
3734 DWORD OffsetToEntries;
3735 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
3737 typedef struct tagMESSAGE_RESOURCE_DATA {
3738 DWORD NumberOfBlocks;
3739 MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
3740 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
3743 * Here follows typedefs for security and tokens.
3747 * First a constant for the following typedefs.
3750 #define ANYSIZE_ARRAY 1
3752 /* FIXME: Orphan. What does it point to? */
3753 typedef PVOID PACCESS_TOKEN;
3754 typedef PVOID PSECURITY_DESCRIPTOR;
3755 typedef PVOID PSID;
3757 typedef enum _TOKEN_ELEVATION_TYPE {
3758 TokenElevationTypeDefault = 1,
3759 TokenElevationTypeFull,
3760 TokenElevationTypeLimited
3761 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
3764 * TOKEN_INFORMATION_CLASS
3767 typedef enum _TOKEN_INFORMATION_CLASS {
3768 TokenUser = 1,
3769 TokenGroups,
3770 TokenPrivileges,
3771 TokenOwner,
3772 TokenPrimaryGroup,
3773 TokenDefaultDacl,
3774 TokenSource,
3775 TokenType,
3776 TokenImpersonationLevel,
3777 TokenStatistics,
3778 TokenRestrictedSids,
3779 TokenSessionId,
3780 TokenGroupsAndPrivileges,
3781 TokenSessionReference,
3782 TokenSandBoxInert,
3783 TokenAuditPolicy,
3784 TokenOrigin,
3785 TokenElevationType,
3786 TokenLinkedToken,
3787 TokenElevation,
3788 TokenHasRestrictions,
3789 TokenAccessInformation,
3790 TokenVirtualizationAllowed,
3791 TokenVirtualizationEnabled,
3792 TokenIntegrityLevel,
3793 TokenUIAccess,
3794 TokenMandatoryPolicy,
3795 TokenLogonSid,
3796 TokenIsAppContainer,
3797 TokenCapabilities,
3798 TokenAppContainerSid,
3799 TokenAppContainerNumber,
3800 TokenUserClaimAttributes,
3801 TokenDeviceClaimAttributes,
3802 TokenRestrictedUserClaimAttributes,
3803 TokenRestrictedDeviceClaimAttributes,
3804 TokenDeviceGroups,
3805 TokenRestrictedDeviceGroups,
3806 TokenSecurityAttributes,
3807 TokenIsRestricted,
3808 TokenProcessTrustLevel,
3809 MaxTokenInfoClass
3810 } TOKEN_INFORMATION_CLASS;
3812 #define TOKEN_TOKEN_ADJUST_DEFAULT 0x0080
3813 #define TOKEN_ADJUST_GROUPS 0x0040
3814 #define TOKEN_ADJUST_PRIVILEGES 0x0020
3815 #define TOKEN_ADJUST_SESSIONID 0x0100
3816 #define TOKEN_ASSIGN_PRIMARY 0x0001
3817 #define TOKEN_DUPLICATE 0x0002
3818 #define TOKEN_EXECUTE STANDARD_RIGHTS_EXECUTE
3819 #define TOKEN_IMPERSONATE 0x0004
3820 #define TOKEN_QUERY 0x0008
3821 #define TOKEN_QUERY_SOURCE 0x0010
3822 #define TOKEN_ADJUST_DEFAULT 0x0080
3823 #define TOKEN_READ (STANDARD_RIGHTS_READ|TOKEN_QUERY)
3824 #define TOKEN_WRITE (STANDARD_RIGHTS_WRITE | \
3825 TOKEN_ADJUST_PRIVILEGES | \
3826 TOKEN_ADJUST_GROUPS | \
3827 TOKEN_ADJUST_DEFAULT )
3828 #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
3829 TOKEN_ASSIGN_PRIMARY | \
3830 TOKEN_DUPLICATE | \
3831 TOKEN_IMPERSONATE | \
3832 TOKEN_QUERY | \
3833 TOKEN_QUERY_SOURCE | \
3834 TOKEN_ADJUST_PRIVILEGES | \
3835 TOKEN_ADJUST_GROUPS | \
3836 TOKEN_ADJUST_SESSIONID | \
3837 TOKEN_ADJUST_DEFAULT )
3839 #ifndef _SECURITY_DEFINED
3840 #define _SECURITY_DEFINED
3843 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
3845 typedef struct _GENERIC_MAPPING {
3846 ACCESS_MASK GenericRead;
3847 ACCESS_MASK GenericWrite;
3848 ACCESS_MASK GenericExecute;
3849 ACCESS_MASK GenericAll;
3850 } GENERIC_MAPPING, *PGENERIC_MAPPING;
3852 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
3853 #define SID_IDENTIFIER_AUTHORITY_DEFINED
3854 typedef struct {
3855 BYTE Value[6];
3856 } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
3857 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
3859 #ifndef SID_DEFINED
3860 #define SID_DEFINED
3861 typedef struct _SID {
3862 BYTE Revision;
3863 BYTE SubAuthorityCount;
3864 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
3865 DWORD SubAuthority[1];
3866 } SID,*PISID;
3867 #endif /* !defined(SID_DEFINED) */
3869 #define SID_REVISION (1) /* Current revision */
3870 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
3871 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
3873 #define SECURITY_MAX_SID_SIZE (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD)))
3876 * ACL
3879 #define ACL_REVISION1 1
3880 #define ACL_REVISION2 2
3881 #define ACL_REVISION3 3
3882 #define ACL_REVISION4 4
3884 #define MIN_ACL_REVISION ACL_REVISION2
3885 #define MAX_ACL_REVISION ACL_REVISION4
3887 #define ACL_REVISION 2
3889 typedef struct _ACL {
3890 BYTE AclRevision;
3891 BYTE Sbz1;
3892 WORD AclSize;
3893 WORD AceCount;
3894 WORD Sbz2;
3895 } ACL, *PACL;
3897 typedef enum _ACL_INFORMATION_CLASS
3899 AclRevisionInformation = 1,
3900 AclSizeInformation
3901 } ACL_INFORMATION_CLASS;
3903 typedef struct _ACL_REVISION_INFORMATION
3905 DWORD AclRevision;
3906 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
3908 typedef struct _ACL_SIZE_INFORMATION
3910 DWORD AceCount;
3911 DWORD AclBytesInUse;
3912 DWORD AclBytesFree;
3913 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
3915 /* SECURITY_DESCRIPTOR */
3916 #define SECURITY_DESCRIPTOR_REVISION 1
3917 #define SECURITY_DESCRIPTOR_REVISION1 1
3921 * Privilege Names
3923 #ifdef UNICODE
3924 #if defined(_MSC_VER)
3925 #define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege"
3926 #define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege"
3927 #define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege"
3928 #define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege"
3929 #define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege"
3930 #define SE_MACHINE_ACCOUNT_NAME L"SeMachineAccountPrivilege"
3931 #define SE_TCB_NAME L"SeTcbPrivilege"
3932 #define SE_SECURITY_NAME L"SeSecurityPrivilege"
3933 #define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege"
3934 #define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege"
3935 #define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege"
3936 #define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege"
3937 #define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege"
3938 #define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege"
3939 #define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege"
3940 #define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege"
3941 #define SE_BACKUP_NAME L"SeBackupPrivilege"
3942 #define SE_RESTORE_NAME L"SeRestorePrivilege"
3943 #define SE_SHUTDOWN_NAME L"SeShutdownPrivilege"
3944 #define SE_DEBUG_NAME L"SeDebugPrivilege"
3945 #define SE_AUDIT_NAME L"SeAuditPrivilege"
3946 #define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege"
3947 #define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege"
3948 #define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege"
3949 #define SE_UNDOCK_NAME L"SeUndockPrivilege"
3950 #define SE_ENABLE_DELEGATION_NAME L"SeEnableDelegationPrivilege"
3951 #define SE_MANAGE_VOLUME_NAME L"SeManageVolumePrivilege"
3952 #define SE_IMPERSONATE_NAME L"SeImpersonatePrivilege"
3953 #define SE_CREATE_GLOBAL_NAME L"SeCreateGlobalPrivilege"
3954 #elif defined(__GNUC__)
3955 #define SE_CREATE_TOKEN_NAME (const WCHAR []){ 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 }
3956 #define SE_ASSIGNPRIMARYTOKEN_NAME (const WCHAR []){ 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 }
3957 #define SE_LOCK_MEMORY_NAME (const WCHAR []){ 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 }
3958 #define SE_INCREASE_QUOTA_NAME (const WCHAR []){ 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 }
3959 #define SE_UNSOLICITED_INPUT_NAME (const WCHAR []){ 'S','e','U','n','s','o','l','i','c','i','t','e','d','I','n','p','u','t','P','r','i','v','i','l','e','g','e',0 }
3960 #define SE_MACHINE_ACCOUNT_NAME (const WCHAR []){ 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 }
3961 #define SE_TCB_NAME (const WCHAR []){ 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 }
3962 #define SE_SECURITY_NAME (const WCHAR []){ 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 }
3963 #define SE_TAKE_OWNERSHIP_NAME (const WCHAR []){ 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 }
3964 #define SE_LOAD_DRIVER_NAME (const WCHAR []){ 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 }
3965 #define SE_SYSTEM_PROFILE_NAME (const WCHAR []){ 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 }
3966 #define SE_SYSTEMTIME_NAME (const WCHAR []){ 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 }
3967 #define SE_PROF_SINGLE_PROCESS_NAME (const WCHAR []){ 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 }
3968 #define SE_INC_BASE_PRIORITY_NAME (const WCHAR []){ 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 }
3969 #define SE_CREATE_PAGEFILE_NAME (const WCHAR []){ 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 }
3970 #define SE_CREATE_PERMANENT_NAME (const WCHAR []){ 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 }
3971 #define SE_BACKUP_NAME (const WCHAR []){ 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 }
3972 #define SE_RESTORE_NAME (const WCHAR []){ 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 }
3973 #define SE_SHUTDOWN_NAME (const WCHAR []){ 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 }
3974 #define SE_DEBUG_NAME (const WCHAR []){ 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 }
3975 #define SE_AUDIT_NAME (const WCHAR []){ 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 }
3976 #define SE_SYSTEM_ENVIRONMENT_NAME (const WCHAR []){ 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 }
3977 #define SE_CHANGE_NOTIFY_NAME (const WCHAR []){ 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 }
3978 #define SE_REMOTE_SHUTDOWN_NAME (const WCHAR []){ 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 }
3979 #define SE_UNDOCK_NAME (const WCHAR []){ 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 }
3980 #define SE_ENABLE_DELEGATION_NAME (const WCHAR []){ 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 }
3981 #define SE_MANAGE_VOLUME_NAME (const WCHAR []){ 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 }
3982 #define SE_IMPERSONATE_NAME (const WCHAR []){ 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 }
3983 #define SE_CREATE_GLOBAL_NAME (const WCHAR []){ 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 }
3984 #else /* _MSC_VER/__GNUC__ */
3985 static const WCHAR SE_CREATE_TOKEN_NAME[] = { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
3986 static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME[] = { 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
3987 static const WCHAR SE_LOCK_MEMORY_NAME[] = { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
3988 static const WCHAR SE_INCREASE_QUOTA_NAME[] = { 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
3989 static const WCHAR SE_UNSOLICITED_INPUT_NAME[] = { 'S','e','U','n','s','o','l','i','c','i','t','e','d','I','n','p','u','t','P','r','i','v','i','l','e','g','e',0 };
3990 static const WCHAR SE_MACHINE_ACCOUNT_NAME[] = { 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
3991 static const WCHAR SE_TCB_NAME[] = { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
3992 static const WCHAR SE_SECURITY_NAME[] = { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
3993 static const WCHAR SE_TAKE_OWNERSHIP_NAME[] = { 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
3994 static const WCHAR SE_LOAD_DRIVER_NAME[] = { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
3995 static const WCHAR SE_SYSTEM_PROFILE_NAME[] = { 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
3996 static const WCHAR SE_SYSTEMTIME_NAME[] = { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
3997 static const WCHAR SE_PROF_SINGLE_PROCESS_NAME[] = { 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
3998 static const WCHAR SE_INC_BASE_PRIORITY_NAME[] = { 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
3999 static const WCHAR SE_CREATE_PAGEFILE_NAME[] = { 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
4000 static const WCHAR SE_CREATE_PERMANENT_NAME[] = { 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
4001 static const WCHAR SE_BACKUP_NAME[] = { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
4002 static const WCHAR SE_RESTORE_NAME[] = { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
4003 static const WCHAR SE_SHUTDOWN_NAME[] = { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
4004 static const WCHAR SE_DEBUG_NAME[] = { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
4005 static const WCHAR SE_AUDIT_NAME[] = { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
4006 static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME[] = { 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
4007 static const WCHAR SE_CHANGE_NOTIFY_NAME[] = { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
4008 static const WCHAR SE_REMOTE_SHUTDOWN_NAME[] = { 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
4009 static const WCHAR SE_UNDOCK_NAME[] = { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
4010 static const WCHAR SE_ENABLE_DELEGATION_NAME[] = { 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
4011 static const WCHAR SE_MANAGE_VOLUME_NAME[] = { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
4012 static const WCHAR SE_IMPERSONATE_NAME[] = { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
4013 static const WCHAR SE_CREATE_GLOBAL_NAME[] = { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
4014 #endif
4015 #else /* UNICODE */
4016 #define SE_CREATE_TOKEN_NAME "SeCreateTokenPrivilege"
4017 #define SE_ASSIGNPRIMARYTOKEN_NAME "SeAssignPrimaryTokenPrivilege"
4018 #define SE_LOCK_MEMORY_NAME "SeLockMemoryPrivilege"
4019 #define SE_INCREASE_QUOTA_NAME "SeIncreaseQuotaPrivilege"
4020 #define SE_UNSOLICITED_INPUT_NAME "SeUnsolicitedInputPrivilege"
4021 #define SE_MACHINE_ACCOUNT_NAME "SeMachineAccountPrivilege"
4022 #define SE_TCB_NAME "SeTcbPrivilege"
4023 #define SE_SECURITY_NAME "SeSecurityPrivilege"
4024 #define SE_TAKE_OWNERSHIP_NAME "SeTakeOwnershipPrivilege"
4025 #define SE_LOAD_DRIVER_NAME "SeLoadDriverPrivilege"
4026 #define SE_SYSTEM_PROFILE_NAME "SeSystemProfilePrivilege"
4027 #define SE_SYSTEMTIME_NAME "SeSystemtimePrivilege"
4028 #define SE_PROF_SINGLE_PROCESS_NAME "SeProfileSingleProcessPrivilege"
4029 #define SE_INC_BASE_PRIORITY_NAME "SeIncreaseBasePriorityPrivilege"
4030 #define SE_CREATE_PAGEFILE_NAME "SeCreatePagefilePrivilege"
4031 #define SE_CREATE_PERMANENT_NAME "SeCreatePermanentPrivilege"
4032 #define SE_BACKUP_NAME "SeBackupPrivilege"
4033 #define SE_RESTORE_NAME "SeRestorePrivilege"
4034 #define SE_SHUTDOWN_NAME "SeShutdownPrivilege"
4035 #define SE_DEBUG_NAME "SeDebugPrivilege"
4036 #define SE_AUDIT_NAME "SeAuditPrivilege"
4037 #define SE_SYSTEM_ENVIRONMENT_NAME "SeSystemEnvironmentPrivilege"
4038 #define SE_CHANGE_NOTIFY_NAME "SeChangeNotifyPrivilege"
4039 #define SE_REMOTE_SHUTDOWN_NAME "SeRemoteShutdownPrivilege"
4040 #define SE_UNDOCK_NAME "SeUndockPrivilege"
4041 #define SE_ENABLE_DELEGATION_NAME "SeEnableDelegationPrivilege"
4042 #define SE_MANAGE_VOLUME_NAME "SeManageVolumePrivilege"
4043 #define SE_IMPERSONATE_NAME "SeImpersonatePrivilege"
4044 #define SE_CREATE_GLOBAL_NAME "SeCreateGlobalPrivilege"
4045 #endif
4047 #define SE_GROUP_MANDATORY 0x00000001
4048 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
4049 #define SE_GROUP_ENABLED 0x00000004
4050 #define SE_GROUP_OWNER 0x00000008
4051 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
4052 #define SE_GROUP_INTEGRITY 0x00000020
4053 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
4054 #define SE_GROUP_LOGON_ID 0xC0000000
4055 #define SE_GROUP_RESOURCE 0x20000000
4056 #define SE_GROUP_VALID_ATTRIBUTES 0xE000007F
4058 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT 0x00000001
4059 #define SE_PRIVILEGE_ENABLED 0x00000002
4060 #define SE_PRIVILEGE_REMOVED 0x00000004
4061 #define SE_PRIVILEGE_USED_FOR_ACCESS 0x80000000
4063 #define PRIVILEGE_SET_ALL_NECESSARY 1
4065 #define SE_OWNER_DEFAULTED 0x00000001
4066 #define SE_GROUP_DEFAULTED 0x00000002
4067 #define SE_DACL_PRESENT 0x00000004
4068 #define SE_DACL_DEFAULTED 0x00000008
4069 #define SE_SACL_PRESENT 0x00000010
4070 #define SE_SACL_DEFAULTED 0x00000020
4071 #define SE_DACL_AUTO_INHERIT_REQ 0x00000100
4072 #define SE_SACL_AUTO_INHERIT_REQ 0x00000200
4073 #define SE_DACL_AUTO_INHERITED 0x00000400
4074 #define SE_SACL_AUTO_INHERITED 0x00000800
4075 #define SE_DACL_PROTECTED 0x00001000
4076 #define SE_SACL_PROTECTED 0x00002000
4077 #define SE_RM_CONTROL_VALID 0x00004000
4078 #define SE_SELF_RELATIVE 0x00008000
4080 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
4081 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
4083 /* The security descriptor structure */
4084 typedef struct {
4085 BYTE Revision;
4086 BYTE Sbz1;
4087 SECURITY_DESCRIPTOR_CONTROL Control;
4088 DWORD Owner;
4089 DWORD Group;
4090 DWORD Sacl;
4091 DWORD Dacl;
4092 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
4094 typedef struct {
4095 BYTE Revision;
4096 BYTE Sbz1;
4097 SECURITY_DESCRIPTOR_CONTROL Control;
4098 PSID Owner;
4099 PSID Group;
4100 PACL Sacl;
4101 PACL Dacl;
4102 } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
4104 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
4106 #endif /* _SECURITY_DEFINED */
4109 * SID_AND_ATTRIBUTES
4112 typedef struct _SID_AND_ATTRIBUTES {
4113 PSID Sid;
4114 DWORD Attributes;
4115 } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
4117 /* security entities */
4118 #define SECURITY_NULL_RID __MSABI_LONG(0x00000000)
4119 #define SECURITY_WORLD_RID __MSABI_LONG(0x00000000)
4120 #define SECURITY_LOCAL_RID __MSABI_LONG(0X00000000)
4122 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
4124 /* S-1-1 */
4125 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
4127 /* S-1-2 */
4128 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
4130 /* S-1-3 */
4131 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
4132 #define SECURITY_CREATOR_OWNER_RID __MSABI_LONG(0x00000000)
4133 #define SECURITY_CREATOR_GROUP_RID __MSABI_LONG(0x00000001)
4134 #define SECURITY_CREATOR_OWNER_SERVER_RID __MSABI_LONG(0x00000002)
4135 #define SECURITY_CREATOR_GROUP_SERVER_RID __MSABI_LONG(0x00000003)
4137 /* S-1-4 */
4138 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
4140 /* S-1-5 */
4141 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
4142 #define SECURITY_DIALUP_RID __MSABI_LONG(0x00000001)
4143 #define SECURITY_NETWORK_RID __MSABI_LONG(0x00000002)
4144 #define SECURITY_BATCH_RID __MSABI_LONG(0x00000003)
4145 #define SECURITY_INTERACTIVE_RID __MSABI_LONG(0x00000004)
4146 #define SECURITY_LOGON_IDS_RID __MSABI_LONG(0x00000005)
4147 #define SECURITY_SERVICE_RID __MSABI_LONG(0x00000006)
4148 #define SECURITY_ANONYMOUS_LOGON_RID __MSABI_LONG(0x00000007)
4149 #define SECURITY_PROXY_RID __MSABI_LONG(0x00000008)
4150 #define SECURITY_ENTERPRISE_CONTROLLERS_RID __MSABI_LONG(0x00000009)
4151 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4152 #define SECURITY_PRINCIPAL_SELF_RID __MSABI_LONG(0x0000000A)
4153 #define SECURITY_AUTHENTICATED_USER_RID __MSABI_LONG(0x0000000B)
4154 #define SECURITY_RESTRICTED_CODE_RID __MSABI_LONG(0x0000000C)
4155 #define SECURITY_TERMINAL_SERVER_RID __MSABI_LONG(0x0000000D)
4156 #define SECURITY_REMOTE_LOGON_RID __MSABI_LONG(0x0000000E)
4157 #define SECURITY_THIS_ORGANIZATION_RID __MSABI_LONG(0x0000000F)
4158 #define SECURITY_LOCAL_SYSTEM_RID __MSABI_LONG(0x00000012)
4159 #define SECURITY_LOCAL_SERVICE_RID __MSABI_LONG(0x00000013)
4160 #define SECURITY_NETWORK_SERVICE_RID __MSABI_LONG(0x00000014)
4161 #define SECURITY_NT_NON_UNIQUE __MSABI_LONG(0x00000015)
4162 #define SECURITY_BUILTIN_DOMAIN_RID __MSABI_LONG(0x00000020)
4164 #define SECURITY_PACKAGE_BASE_RID __MSABI_LONG(0x00000040)
4165 #define SECURITY_PACKAGE_NTLM_RID __MSABI_LONG(0x0000000A)
4166 #define SECURITY_PACKAGE_SCHANNEL_RID __MSABI_LONG(0x0000000E)
4167 #define SECURITY_PACKAGE_DIGEST_RID __MSABI_LONG(0x00000015)
4168 #define SECURITY_MAX_ALWAYS_FILTERED __MSABI_LONG(0x000003E7)
4169 #define SECURITY_MIN_NEVER_FILTERED __MSABI_LONG(0x000003E8)
4170 #define SECURITY_OTHER_ORGANIZATION_RID __MSABI_LONG(0x000003E8)
4172 #define FOREST_USER_RID_MAX __MSABI_LONG(0x000001F3)
4173 #define DOMAIN_USER_RID_ADMIN __MSABI_LONG(0x000001F4)
4174 #define DOMAIN_USER_RID_GUEST __MSABI_LONG(0x000001F5)
4175 #define DOMAIN_USER_RID_KRBTGT __MSABI_LONG(0x000001F6)
4176 #define DOMAIN_USER_RID_MAX __MSABI_LONG(0x000003E7)
4178 #define DOMAIN_GROUP_RID_ADMINS __MSABI_LONG(0x00000200)
4179 #define DOMAIN_GROUP_RID_USERS __MSABI_LONG(0x00000201)
4180 #define DOMAIN_GROUP_RID_GUESTS __MSABI_LONG(0x00000202)
4181 #define DOMAIN_GROUP_RID_COMPUTERS __MSABI_LONG(0x00000203)
4182 #define DOMAIN_GROUP_RID_CONTROLLERS __MSABI_LONG(0x00000204)
4183 #define DOMAIN_GROUP_RID_CERT_ADMINS __MSABI_LONG(0x00000205)
4184 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS __MSABI_LONG(0x00000206)
4185 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS __MSABI_LONG(0x00000207)
4186 #define DOMAIN_GROUP_RID_POLICY_ADMINS __MSABI_LONG(0x00000208)
4188 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
4189 #define SECURITY_APP_PACKAGE_BASE_RID __MSABI_LONG(0x000000002)
4190 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000002)
4191 #define SECURITY_APP_PACKAGE_RID_COUNT __MSABI_LONG(0x000000008)
4192 #define SECURITY_CAPABILITY_BASE_RID __MSABI_LONG(0x000000003)
4193 #define SECURITY_CAPABILITY_APP_RID __MSABI_LONG(0x000000400)
4194 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000002)
4195 #define SECURITY_CAPABILITY_RID_COUNT __MSABI_LONG(0x000000005)
4196 #define SECURITY_PARENT_PACKAGE_RID_COUNT SECURITY_APP_PACKAGE_RID_COUNT
4197 #define SECURITY_CHILD_PACKAGE_RID_COUNT __MSABI_LONG(0x00000000c)
4198 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE __MSABI_LONG(0x000000001)
4200 #define SECURITY_MANDATORY_LABEL_AUTHORITY {0,0,0,0,0,16}
4201 #define SECURITY_MANDATORY_UNTRUSTED_RID __MSABI_LONG(0x00000000)
4202 #define SECURITY_MANDATORY_LOW_RID __MSABI_LONG(0x00001000)
4203 #define SECURITY_MANDATORY_MEDIUM_RID __MSABI_LONG(0x00002000)
4204 #define SECURITY_MANDATORY_HIGH_RID __MSABI_LONG(0x00003000)
4205 #define SECURITY_MANDATORY_SYSTEM_RID __MSABI_LONG(0x00004000)
4206 #define SECURITY_MANDATORY_PROTECTED_PROCESS_RID __MSABI_LONG(0x00005000)
4208 #define DOMAIN_ALIAS_RID_ADMINS __MSABI_LONG(0x00000220)
4209 #define DOMAIN_ALIAS_RID_USERS __MSABI_LONG(0x00000221)
4210 #define DOMAIN_ALIAS_RID_GUESTS __MSABI_LONG(0x00000222)
4211 #define DOMAIN_ALIAS_RID_POWER_USERS __MSABI_LONG(0x00000223)
4213 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS __MSABI_LONG(0x00000224)
4214 #define DOMAIN_ALIAS_RID_SYSTEM_OPS __MSABI_LONG(0x00000225)
4215 #define DOMAIN_ALIAS_RID_PRINT_OPS __MSABI_LONG(0x00000226)
4216 #define DOMAIN_ALIAS_RID_BACKUP_OPS __MSABI_LONG(0x00000227)
4218 #define DOMAIN_ALIAS_RID_REPLICATOR __MSABI_LONG(0x00000228)
4219 #define DOMAIN_ALIAS_RID_RAS_SERVERS __MSABI_LONG(0x00000229)
4220 #define DOMAIN_ALIAS_RID_PREW2KCOMPACCESS __MSABI_LONG(0x0000022A)
4221 #define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS __MSABI_LONG(0x0000022B)
4222 #define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS __MSABI_LONG(0x0000022C)
4223 #define DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS __MSABI_LONG(0x0000022D)
4225 #define DOMAIN_ALIAS_RID_MONITORING_USERS __MSABI_LONG(0x0000022E)
4226 #define DOMAIN_ALIAS_RID_LOGGING_USERS __MSABI_LONG(0x0000022F)
4227 #define DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS __MSABI_LONG(0x00000230)
4228 #define DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS __MSABI_LONG(0x00000231)
4229 #define DOMAIN_ALIAS_RID_DCOM_USERS __MSABI_LONG(0x00000232)
4231 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
4233 #define SECURITY_PACKAGE_RID_COUNT __MSABI_LONG(2)
4234 #define SECURITY_LOGON_IDS_RID_COUNT __MSABI_LONG(3)
4236 typedef enum {
4237 WinNullSid = 0,
4238 WinWorldSid = 1,
4239 WinLocalSid = 2,
4240 WinCreatorOwnerSid = 3,
4241 WinCreatorGroupSid = 4,
4242 WinCreatorOwnerServerSid = 5,
4243 WinCreatorGroupServerSid = 6,
4244 WinNtAuthoritySid = 7,
4245 WinDialupSid = 8,
4246 WinNetworkSid = 9,
4247 WinBatchSid = 10,
4248 WinInteractiveSid = 11,
4249 WinServiceSid = 12,
4250 WinAnonymousSid = 13,
4251 WinProxySid = 14,
4252 WinEnterpriseControllersSid = 15,
4253 WinSelfSid = 16,
4254 WinAuthenticatedUserSid = 17,
4255 WinRestrictedCodeSid = 18,
4256 WinTerminalServerSid = 19,
4257 WinRemoteLogonIdSid = 20,
4258 WinLogonIdsSid = 21,
4259 WinLocalSystemSid = 22,
4260 WinLocalServiceSid = 23,
4261 WinNetworkServiceSid = 24,
4262 WinBuiltinDomainSid = 25,
4263 WinBuiltinAdministratorsSid = 26,
4264 WinBuiltinUsersSid = 27,
4265 WinBuiltinGuestsSid = 28,
4266 WinBuiltinPowerUsersSid = 29,
4267 WinBuiltinAccountOperatorsSid = 30,
4268 WinBuiltinSystemOperatorsSid = 31,
4269 WinBuiltinPrintOperatorsSid = 32,
4270 WinBuiltinBackupOperatorsSid = 33,
4271 WinBuiltinReplicatorSid = 34,
4272 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
4273 WinBuiltinRemoteDesktopUsersSid = 36,
4274 WinBuiltinNetworkConfigurationOperatorsSid = 37,
4275 WinAccountAdministratorSid = 38,
4276 WinAccountGuestSid = 39,
4277 WinAccountKrbtgtSid = 40,
4278 WinAccountDomainAdminsSid = 41,
4279 WinAccountDomainUsersSid = 42,
4280 WinAccountDomainGuestsSid = 43,
4281 WinAccountComputersSid = 44,
4282 WinAccountControllersSid = 45,
4283 WinAccountCertAdminsSid = 46,
4284 WinAccountSchemaAdminsSid = 47,
4285 WinAccountEnterpriseAdminsSid = 48,
4286 WinAccountPolicyAdminsSid = 49,
4287 WinAccountRasAndIasServersSid = 50,
4288 WinNTLMAuthenticationSid = 51,
4289 WinDigestAuthenticationSid = 52,
4290 WinSChannelAuthenticationSid = 53,
4291 WinThisOrganizationSid = 54,
4292 WinOtherOrganizationSid = 55,
4293 WinBuiltinIncomingForestTrustBuildersSid = 56,
4294 WinBuiltinPerfMonitoringUsersSid = 57,
4295 WinBuiltinPerfLoggingUsersSid = 58,
4296 WinBuiltinAuthorizationAccessSid = 59,
4297 WinBuiltinTerminalServerLicenseServersSid = 60,
4298 WinBuiltinDCOMUsersSid = 61,
4299 WinBuiltinIUsersSid = 62,
4300 WinIUserSid = 63,
4301 WinBuiltinCryptoOperatorsSid = 64,
4302 WinUntrustedLabelSid = 65,
4303 WinLowLabelSid = 66,
4304 WinMediumLabelSid = 67,
4305 WinHighLabelSid = 68,
4306 WinSystemLabelSid = 69,
4307 WinWriteRestrictedCodeSid = 70,
4308 WinCreatorOwnerRightsSid = 71,
4309 WinCacheablePrincipalsGroupSid = 72,
4310 WinNonCacheablePrincipalsGroupSid = 73,
4311 WinEnterpriseReadonlyControllersSid = 74,
4312 WinAccountReadonlyControllersSid = 75,
4313 WinBuiltinEventLogReadersGroup = 76,
4314 WinNewEnterpriseReadonlyControllersSid = 77,
4315 WinBuiltinCertSvcDComAccessGroup = 78,
4316 WinMediumPlusLabelSid = 79,
4317 WinLocalLogonSid = 80,
4318 WinConsoleLogonSid = 81,
4319 WinThisOrganizationCertificateSid = 82,
4320 WinApplicationPackageAuthoritySid = 83,
4321 WinBuiltinAnyPackageSid = 84,
4322 WinCapabilityInternetClientSid = 85,
4323 WinCapabilityInternetClientServerSid = 86,
4324 WinCapabilityPrivateNetworkClientServerSid = 87,
4325 WinCapabilityPicturesLibrarySid = 88,
4326 WinCapabilityVideosLibrarySid = 89,
4327 WinCapabilityMusicLibrarySid = 90,
4328 WinCapabilityDocumentsLibrarySid = 91,
4329 WinCapabilitySharedUserCertificatesSid = 92,
4330 WinCapabilityEnterpriseAuthenticationSid = 93,
4331 WinCapabilityRemovableStorageSid = 94,
4332 WinBuiltinRDSRemoteAccessServersSid = 95,
4333 WinBuiltinRDSEndpointServersSid = 96,
4334 WinBuiltinRDSManagementServersSid = 97,
4335 WinUserModeDriversSid = 98,
4336 WinBuiltinHyperVAdminsSid = 99,
4337 WinAccountCloneableControllersSid = 100,
4338 WinBuiltinAccessControlAssistanceOperatorsSid = 101,
4339 WinBuiltinRemoteManagementUsersSid = 102,
4340 WinAuthenticationAuthorityAssertedSid = 103,
4341 WinAuthenticationServiceAssertedSid = 104,
4342 WinLocalAccountSid = 105,
4343 WinLocalAccountAndAdministratorSid = 106,
4344 WinAccountProtectedUsersSid = 107,
4345 } WELL_KNOWN_SID_TYPE;
4348 * TOKEN_USER
4351 typedef struct _TOKEN_USER {
4352 SID_AND_ATTRIBUTES User;
4353 } TOKEN_USER, *PTOKEN_USER;
4356 * TOKEN_GROUPS
4359 typedef struct _TOKEN_GROUPS {
4360 DWORD GroupCount;
4361 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
4362 } TOKEN_GROUPS, *PTOKEN_GROUPS;
4365 * LUID_AND_ATTRIBUTES
4368 typedef union _LARGE_INTEGER {
4369 struct {
4370 #ifdef WORDS_BIGENDIAN
4371 LONG HighPart;
4372 DWORD LowPart;
4373 #else
4374 DWORD LowPart;
4375 LONG HighPart;
4376 #endif
4377 } u;
4378 #ifndef NONAMELESSSTRUCT
4379 struct {
4380 #ifdef WORDS_BIGENDIAN
4381 LONG HighPart;
4382 DWORD LowPart;
4383 #else
4384 DWORD LowPart;
4385 LONG HighPart;
4386 #endif
4388 #endif
4389 LONGLONG QuadPart;
4390 } LARGE_INTEGER, *PLARGE_INTEGER;
4392 typedef union _ULARGE_INTEGER {
4393 struct {
4394 #ifdef WORDS_BIGENDIAN
4395 DWORD HighPart;
4396 DWORD LowPart;
4397 #else
4398 DWORD LowPart;
4399 DWORD HighPart;
4400 #endif
4401 } u;
4402 #ifndef NONAMELESSSTRUCT
4403 struct {
4404 #ifdef WORDS_BIGENDIAN
4405 DWORD HighPart;
4406 DWORD LowPart;
4407 #else
4408 DWORD LowPart;
4409 DWORD HighPart;
4410 #endif
4412 #endif
4413 ULONGLONG QuadPart;
4414 } ULARGE_INTEGER, *PULARGE_INTEGER;
4417 * Locally Unique Identifier
4420 typedef struct _LUID {
4421 DWORD LowPart;
4422 LONG HighPart;
4423 } LUID, *PLUID;
4425 #include <pshpack4.h>
4426 typedef struct _LUID_AND_ATTRIBUTES {
4427 LUID Luid;
4428 DWORD Attributes;
4429 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
4430 #include <poppack.h>
4433 * PRIVILEGE_SET
4436 typedef struct _PRIVILEGE_SET {
4437 DWORD PrivilegeCount;
4438 DWORD Control;
4439 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
4440 } PRIVILEGE_SET, *PPRIVILEGE_SET;
4443 * TOKEN_PRIVILEGES
4446 typedef struct _TOKEN_PRIVILEGES {
4447 DWORD PrivilegeCount;
4448 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
4449 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
4452 * TOKEN_OWNER
4455 typedef struct _TOKEN_OWNER {
4456 PSID Owner;
4457 } TOKEN_OWNER, *PTOKEN_OWNER;
4460 * TOKEN_PRIMARY_GROUP
4463 typedef struct _TOKEN_PRIMARY_GROUP {
4464 PSID PrimaryGroup;
4465 } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
4469 * TOKEN_DEFAULT_DACL
4472 typedef struct _TOKEN_DEFAULT_DACL {
4473 PACL DefaultDacl;
4474 } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
4477 * TOKEN_SOURCE
4480 #define TOKEN_SOURCE_LENGTH 8
4482 typedef struct _TOKEN_SOURCE {
4483 char SourceName[TOKEN_SOURCE_LENGTH];
4484 LUID SourceIdentifier;
4485 } TOKEN_SOURCE, *PTOKEN_SOURCE;
4488 * TOKEN_TYPE
4491 typedef enum tagTOKEN_TYPE {
4492 TokenPrimary = 1,
4493 TokenImpersonation
4494 } TOKEN_TYPE;
4497 * SECURITY_IMPERSONATION_LEVEL
4500 typedef enum _SECURITY_IMPERSONATION_LEVEL {
4501 SecurityAnonymous,
4502 SecurityIdentification,
4503 SecurityImpersonation,
4504 SecurityDelegation
4505 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
4507 #define SECURITY_DYNAMIC_TRACKING (TRUE)
4508 #define SECURITY_STATIC_TRACKING (FALSE)
4510 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
4511 * PSECURITY_CONTEXT_TRACKING_MODE;
4513 * Quality of Service
4516 typedef struct _SECURITY_QUALITY_OF_SERVICE {
4517 DWORD Length;
4518 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4519 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
4520 BOOLEAN EffectiveOnly;
4521 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
4524 * TOKEN_STATISTICS
4527 #include <pshpack4.h>
4528 typedef struct _TOKEN_STATISTICS {
4529 LUID TokenId;
4530 LUID AuthenticationId;
4531 LARGE_INTEGER ExpirationTime;
4532 TOKEN_TYPE TokenType;
4533 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
4534 DWORD DynamicCharged;
4535 DWORD DynamicAvailable;
4536 DWORD GroupCount;
4537 DWORD PrivilegeCount;
4538 LUID ModifiedId;
4539 } TOKEN_STATISTICS;
4540 #include <poppack.h>
4542 typedef struct _TOKEN_GROUPS_AND_PRIVILEGES {
4543 DWORD SidCount;
4544 DWORD SidLength;
4545 PSID_AND_ATTRIBUTES Sids;
4546 DWORD RestrictedSidCount;
4547 DWORD RestrictedSidLength;
4548 PSID_AND_ATTRIBUTES RestrictedSids;
4549 DWORD PrivilegeCount;
4550 DWORD PrivilegeLength;
4551 PLUID_AND_ATTRIBUTES Privileges;
4552 LUID AuthenticationId;
4553 } TOKEN_GROUPS_AND_PRIVILEGES, * PTOKEN_GROUPS_AND_PRIVILEGES;
4555 typedef struct _TOKEN_ORIGIN {
4556 LUID OriginatingLogonSession;
4557 } TOKEN_ORIGIN, * PTOKEN_ORIGIN;
4559 typedef struct _TOKEN_LINKED_TOKEN {
4560 HANDLE LinkedToken;
4561 } TOKEN_LINKED_TOKEN, * PTOKEN_LINKED_TOKEN;
4563 typedef struct _TOKEN_ELEVATION {
4564 DWORD TokenIsElevated;
4565 } TOKEN_ELEVATION, * PTOKEN_ELEVATION;
4567 typedef struct _TOKEN_MANDATORY_LABEL {
4568 SID_AND_ATTRIBUTES Label;
4569 } TOKEN_MANDATORY_LABEL, * PTOKEN_MANDATORY_LABEL;
4571 typedef struct _TOKEN_APPCONTAINER_INFORMATION {
4572 PSID TokenAppContainer;
4573 } TOKEN_APPCONTAINER_INFORMATION, * PTOKEN_APPCONTAINER_INFORMATION;
4576 * ACLs of NT
4579 /* ACEs, directly starting after an ACL */
4580 typedef struct _ACE_HEADER {
4581 BYTE AceType;
4582 BYTE AceFlags;
4583 WORD AceSize;
4584 } ACE_HEADER,*PACE_HEADER;
4586 /* AceType */
4587 #define ACCESS_ALLOWED_ACE_TYPE 0
4588 #define ACCESS_DENIED_ACE_TYPE 1
4589 #define SYSTEM_AUDIT_ACE_TYPE 2
4590 #define SYSTEM_ALARM_ACE_TYPE 3
4591 #define SYSTEM_MANDATORY_LABEL_ACE_TYPE 0x11
4593 /* inherit AceFlags */
4594 #define OBJECT_INHERIT_ACE 0x01
4595 #define CONTAINER_INHERIT_ACE 0x02
4596 #define NO_PROPAGATE_INHERIT_ACE 0x04
4597 #define INHERIT_ONLY_ACE 0x08
4598 #define INHERITED_ACE 0x10
4599 #define VALID_INHERIT_FLAGS 0x1F
4601 /* AceFlags mask for what events we (should) audit */
4602 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
4603 #define FAILED_ACCESS_ACE_FLAG 0x80
4605 /* different ACEs depending on AceType
4606 * SidStart marks the begin of a SID
4607 * so the thing finally looks like this:
4608 * 0: ACE_HEADER
4609 * 4: ACCESS_MASK
4610 * 8... : SID
4612 typedef struct _ACCESS_ALLOWED_ACE {
4613 ACE_HEADER Header;
4614 DWORD Mask;
4615 DWORD SidStart;
4616 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
4618 typedef struct _ACCESS_DENIED_ACE {
4619 ACE_HEADER Header;
4620 DWORD Mask;
4621 DWORD SidStart;
4622 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
4624 typedef struct _SYSTEM_AUDIT_ACE {
4625 ACE_HEADER Header;
4626 DWORD Mask;
4627 DWORD SidStart;
4628 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
4630 typedef struct _SYSTEM_ALARM_ACE {
4631 ACE_HEADER Header;
4632 DWORD Mask;
4633 DWORD SidStart;
4634 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
4636 typedef struct _SYSTEM_MANDATORY_LABEL_ACE {
4637 ACE_HEADER Header;
4638 ACCESS_MASK Mask;
4639 DWORD SidStart;
4640 } SYSTEM_MANDATORY_LABEL_ACE,*PSYSTEM_MANDATORY_LABEL_ACE;
4642 #define SYSTEM_MANDATORY_LABEL_NO_WRITE_UP 0x1
4643 #define SYSTEM_MANDATORY_LABEL_NO_READ_UP 0x2
4644 #define SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP 0x4
4646 typedef enum tagSID_NAME_USE {
4647 SidTypeUser = 1,
4648 SidTypeGroup,
4649 SidTypeDomain,
4650 SidTypeAlias,
4651 SidTypeWellKnownGroup,
4652 SidTypeDeletedAccount,
4653 SidTypeInvalid,
4654 SidTypeUnknown
4655 } SID_NAME_USE,*PSID_NAME_USE;
4657 #define ACE_OBJECT_TYPE_PRESENT 0x1
4658 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x2
4660 /* Access rights */
4662 /* DELETE may be already defined via /usr/include/arpa/nameser_compat.h */
4663 #undef DELETE
4664 #define DELETE 0x00010000
4665 #define READ_CONTROL 0x00020000
4666 #define WRITE_DAC 0x00040000
4667 #define WRITE_OWNER 0x00080000
4668 #define SYNCHRONIZE 0x00100000
4669 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
4671 #define STANDARD_RIGHTS_READ READ_CONTROL
4672 #define STANDARD_RIGHTS_WRITE READ_CONTROL
4673 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
4675 #define STANDARD_RIGHTS_ALL 0x001f0000
4677 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
4679 #define GENERIC_READ 0x80000000
4680 #define GENERIC_WRITE 0x40000000
4681 #define GENERIC_EXECUTE 0x20000000
4682 #define GENERIC_ALL 0x10000000
4684 #define MAXIMUM_ALLOWED 0x02000000
4685 #define ACCESS_SYSTEM_SECURITY 0x01000000
4687 #define EVENT_QUERY_STATE 0x0001
4688 #define EVENT_MODIFY_STATE 0x0002
4689 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4691 #define SEMAPHORE_QUERY_STATE 0x0001
4692 #define SEMAPHORE_MODIFY_STATE 0x0002
4693 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4695 #define MUTANT_QUERY_STATE 0x0001
4696 #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
4698 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
4699 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
4700 #define JOB_OBJECT_QUERY 0x0004
4701 #define JOB_OBJECT_TERMINATE 0x0008
4702 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
4703 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1f)
4705 #define TIMER_QUERY_STATE 0x0001
4706 #define TIMER_MODIFY_STATE 0x0002
4707 #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
4709 #define PROCESS_TERMINATE 0x0001
4710 #define PROCESS_CREATE_THREAD 0x0002
4711 #define PROCESS_VM_OPERATION 0x0008
4712 #define PROCESS_VM_READ 0x0010
4713 #define PROCESS_VM_WRITE 0x0020
4714 #define PROCESS_DUP_HANDLE 0x0040
4715 #define PROCESS_CREATE_PROCESS 0x0080
4716 #define PROCESS_SET_QUOTA 0x0100
4717 #define PROCESS_SET_INFORMATION 0x0200
4718 #define PROCESS_QUERY_INFORMATION 0x0400
4719 #define PROCESS_SUSPEND_RESUME 0x0800
4720 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
4721 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
4722 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
4724 #define THREAD_TERMINATE 0x0001
4725 #define THREAD_SUSPEND_RESUME 0x0002
4726 #define THREAD_GET_CONTEXT 0x0008
4727 #define THREAD_SET_CONTEXT 0x0010
4728 #define THREAD_SET_INFORMATION 0x0020
4729 #define THREAD_QUERY_INFORMATION 0x0040
4730 #define THREAD_SET_THREAD_TOKEN 0x0080
4731 #define THREAD_IMPERSONATE 0x0100
4732 #define THREAD_DIRECT_IMPERSONATION 0x0200
4733 #define THREAD_SET_LIMITED_INFORMATION 0x0400
4734 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
4735 #define THREAD_RESUME 0x1000
4736 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xffff)
4738 #define THREAD_BASE_PRIORITY_LOWRT 15
4739 #define THREAD_BASE_PRIORITY_MAX 2
4740 #define THREAD_BASE_PRIORITY_MIN -2
4741 #define THREAD_BASE_PRIORITY_IDLE -15
4743 typedef struct _QUOTA_LIMITS {
4744 SIZE_T PagedPoolLimit;
4745 SIZE_T NonPagedPoolLimit;
4746 SIZE_T MinimumWorkingSetSize;
4747 SIZE_T MaximumWorkingSetSize;
4748 SIZE_T PagefileLimit;
4749 LARGE_INTEGER TimeLimit;
4750 } QUOTA_LIMITS, *PQUOTA_LIMITS;
4752 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
4753 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
4754 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
4755 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
4757 typedef struct _QUOTA_LIMITS_EX {
4758 SIZE_T PagedPoolLimit;
4759 SIZE_T NonPagedPoolLimit;
4760 SIZE_T MinimumWorkingSetSize;
4761 SIZE_T MaximumWorkingSetSize;
4762 SIZE_T PagefileLimit;
4763 LARGE_INTEGER TimeLimit;
4764 SIZE_T Reserved1;
4765 SIZE_T Reserved2;
4766 SIZE_T Reserved3;
4767 SIZE_T Reserved4;
4768 DWORD Flags;
4769 DWORD Reserved5;
4770 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
4772 #define SECTION_QUERY 0x0001
4773 #define SECTION_MAP_WRITE 0x0002
4774 #define SECTION_MAP_READ 0x0004
4775 #define SECTION_MAP_EXECUTE 0x0008
4776 #define SECTION_EXTEND_SIZE 0x0010
4777 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
4778 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|0x01f)
4780 #define FILE_READ_DATA 0x0001 /* file & pipe */
4781 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
4782 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
4783 #define FILE_ADD_FILE 0x0002 /* directory */
4784 #define FILE_APPEND_DATA 0x0004 /* file */
4785 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
4786 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
4787 #define FILE_READ_EA 0x0008 /* file & directory */
4788 #define FILE_READ_PROPERTIES FILE_READ_EA
4789 #define FILE_WRITE_EA 0x0010 /* file & directory */
4790 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
4791 #define FILE_EXECUTE 0x0020 /* file */
4792 #define FILE_TRAVERSE 0x0020 /* directory */
4793 #define FILE_DELETE_CHILD 0x0040 /* directory */
4794 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
4795 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
4796 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
4798 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
4799 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
4800 SYNCHRONIZE)
4801 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
4802 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
4803 FILE_APPEND_DATA | SYNCHRONIZE)
4804 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
4805 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
4807 #define DUPLICATE_CLOSE_SOURCE 0x00000001
4808 #define DUPLICATE_SAME_ACCESS 0x00000002
4810 /* File attribute flags */
4811 #define FILE_SHARE_READ 0x00000001
4812 #define FILE_SHARE_WRITE 0x00000002
4813 #define FILE_SHARE_DELETE 0x00000004
4815 #define FILE_ATTRIBUTE_READONLY 0x00000001
4816 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
4817 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
4818 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
4819 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
4820 #define FILE_ATTRIBUTE_DEVICE 0x00000040
4821 #define FILE_ATTRIBUTE_NORMAL 0x00000080
4822 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
4823 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
4824 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
4825 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
4826 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
4827 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
4828 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
4829 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
4830 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
4831 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
4832 #define FILE_ATTRIBUTE_EA 0x00040000
4834 /* File notification flags */
4835 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
4836 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
4837 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
4838 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
4839 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
4840 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
4841 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
4842 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
4843 #define FILE_NOTIFY_CHANGE_EA 0x00000080
4844 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
4845 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
4846 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
4847 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
4849 #define FILE_ACTION_ADDED 0x00000001
4850 #define FILE_ACTION_REMOVED 0x00000002
4851 #define FILE_ACTION_MODIFIED 0x00000003
4852 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
4853 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
4854 #define FILE_ACTION_ADDED_STREAM 0x00000006
4855 #define FILE_ACTION_REMOVED_STREAM 0x00000007
4856 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
4857 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
4858 #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000a
4859 #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000b
4861 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
4862 #define FILE_CASE_PRESERVED_NAMES 0x00000002
4863 #define FILE_UNICODE_ON_DISK 0x00000004
4864 #define FILE_PERSISTENT_ACLS 0x00000008
4865 #define FILE_FILE_COMPRESSION 0x00000010
4866 #define FILE_VOLUME_QUOTAS 0x00000020
4867 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
4868 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
4869 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
4870 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
4871 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
4872 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
4873 #define FILE_NAMED_STREAMS 0x00040000
4874 #define FILE_READ_ONLY_VOLUME 0x00080000
4875 #define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
4876 #define FILE_SUPPORTS_TRANSACTIONS 0x00200000
4877 #define FILE_SUPPORTS_HARD_LINKS 0x00400000
4878 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
4879 #define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000
4880 #define FILE_SUPPORTS_USN_JOURNAL 0x02000000
4881 #define FILE_SUPPORTS_INTEGRITY_STREAMS 0x04000000
4882 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
4883 #define FILE_SUPPORTS_SPARSE_VDL 0x10000000
4885 /* File alignments (NT) */
4886 #define FILE_BYTE_ALIGNMENT 0x00000000
4887 #define FILE_WORD_ALIGNMENT 0x00000001
4888 #define FILE_LONG_ALIGNMENT 0x00000003
4889 #define FILE_QUAD_ALIGNMENT 0x00000007
4890 #define FILE_OCTA_ALIGNMENT 0x0000000f
4891 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
4892 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
4893 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
4894 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
4895 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
4897 #define COMPRESSION_FORMAT_NONE 0
4898 #define COMPRESSION_FORMAT_DEFAULT 1
4899 #define COMPRESSION_FORMAT_LZNT1 2
4900 #define COMPRESSION_ENGINE_STANDARD 0
4901 #define COMPRESSION_ENGINE_MAXIMUM 256
4903 #define MAILSLOT_NO_MESSAGE ((DWORD)-1)
4904 #define MAILSLOT_WAIT_FOREVER ((DWORD)-1)
4906 #define REG_NONE 0 /* no type */
4907 #define REG_SZ 1 /* string type (ASCII) */
4908 #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
4909 #define REG_BINARY 3 /* binary format, callerspecific */
4910 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
4911 #define REG_DWORD 4 /* DWORD in little endian format */
4912 #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */
4913 #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */
4914 #define REG_LINK 6 /* symbolic link (UNICODE) */
4915 #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
4916 #define REG_RESOURCE_LIST 8 /* resource list? huh? */
4917 #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
4918 #define REG_RESOURCE_REQUIREMENTS_LIST 10
4919 #define REG_QWORD 11 /* QWORD in little endian format */
4920 #define REG_QWORD_LITTLE_ENDIAN 11 /* QWORD in little endian format */
4922 /* ----------------------------- begin power management --------------------- */
4924 typedef enum _LATENCY_TIME {
4925 LT_DONT_CARE,
4926 LT_LOWEST_LATENCY
4927 } LATENCY_TIME, *PLATENCY_TIME;
4929 #define DISCHARGE_POLICY_CRITICAL 0
4930 #define DISCHARGE_POLICY_LOW 1
4931 #define NUM_DISCHARGE_POLICIES 4
4933 #define PO_THROTTLE_NONE 0
4934 #define PO_THROTTLE_CONSTANT 1
4935 #define PO_THROTTLE_DEGRADE 2
4936 #define PO_THROTTLE_ADAPTIVE 3
4938 typedef enum _POWER_ACTION {
4939 PowerActionNone = 0,
4940 PowerActionReserved,
4941 PowerActionSleep,
4942 PowerActionHibernate,
4943 PowerActionShutdown,
4944 PowerActionShutdownReset,
4945 PowerActionShutdownOff,
4946 PowerActionWarmEject
4947 } POWER_ACTION,
4948 *PPOWER_ACTION;
4950 typedef enum _POWER_PLATFORM_ROLE {
4951 PlatformRoleUnspecified,
4952 PlatformRoleDesktop,
4953 PlatformRoleMobile,
4954 PlatformRoleWorkstation,
4955 PlatformRoleEnterpriseServer,
4956 PlatformRoleSOHOServer,
4957 PlatformRoleAppliancePC,
4958 PlatformRolePerformanceServer,
4959 PlatformRoleSlate,
4960 PlatformRoleMaximum
4961 } POWER_PLATFORM_ROLE, *PPOWER_PLATFORM_ROLE;
4963 typedef enum _SYSTEM_POWER_STATE {
4964 PowerSystemUnspecified = 0,
4965 PowerSystemWorking = 1,
4966 PowerSystemSleeping1 = 2,
4967 PowerSystemSleeping2 = 3,
4968 PowerSystemSleeping3 = 4,
4969 PowerSystemHibernate = 5,
4970 PowerSystemShutdown = 6,
4971 PowerSystemMaximum = 7
4972 } SYSTEM_POWER_STATE,
4973 *PSYSTEM_POWER_STATE;
4975 typedef enum _DEVICE_POWER_STATE {
4976 PowerDeviceUnspecified,
4977 PowerDeviceD0,
4978 PowerDeviceD1,
4979 PowerDeviceD2,
4980 PowerDeviceD3,
4981 PowerDeviceMaximum
4982 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
4984 typedef enum _POWER_INFORMATION_LEVEL {
4985 SystemPowerPolicyAc,
4986 SystemPowerPolicyDc,
4987 VerifySystemPolicyAc,
4988 VerifySystemPolicyDc,
4989 SystemPowerCapabilities,
4990 SystemBatteryState,
4991 SystemPowerStateHandler,
4992 ProcessorStateHandler,
4993 SystemPowerPolicyCurrent,
4994 AdministratorPowerPolicy,
4995 SystemReserveHiberFile,
4996 ProcessorInformation,
4997 SystemPowerInformation,
4998 ProcessorStateHandler2,
4999 LastWakeTime,
5000 LastSleepTime,
5001 SystemExecutionState,
5002 SystemPowerStateNotifyHandler,
5003 ProcessorPowerPolicyAc,
5004 ProcessorPowerPolicyDc,
5005 VerifyProcessorPowerPolicyAc,
5006 VerifyProcessorPowerPolicyDc,
5007 ProcessorPowerPolicyCurrent
5008 } POWER_INFORMATION_LEVEL;
5010 typedef struct _ADMINISTRATOR_POWER_POLICY {
5011 SYSTEM_POWER_STATE MinSleep;
5012 SYSTEM_POWER_STATE MaxSleep;
5013 ULONG MinVideoTimeout;
5014 ULONG MaxVideoTimeout;
5015 ULONG MinSpindownTimeout;
5016 ULONG MaxSpindownTimeout;
5017 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
5019 typedef struct {
5020 ULONG Granularity;
5021 ULONG Capacity;
5022 } BATTERY_REPORTING_SCALE,
5023 *PBATTERY_REPORTING_SCALE;
5025 typedef struct {
5026 POWER_ACTION Action;
5027 ULONG Flags;
5028 ULONG EventCode;
5029 } POWER_ACTION_POLICY,
5030 *PPOWER_ACTION_POLICY;
5032 typedef struct _PROCESSOR_POWER_INFORMATION {
5033 ULONG Number;
5034 ULONG MaxMhz;
5035 ULONG CurrentMhz;
5036 ULONG MhzLimit;
5037 ULONG MaxIdleState;
5038 ULONG CurrentIdleState;
5039 } PROCESSOR_POWER_INFORMATION,
5040 *PPROCESSOR_POWER_INFORMATION;
5042 typedef struct _PROCESSOR_POWER_POLICY_INFO {
5043 ULONG TimeCheck;
5044 ULONG DemoteLimit;
5045 ULONG PromoteLimit;
5046 UCHAR DemotePercent;
5047 UCHAR PromotePercent;
5048 UCHAR Spare[2];
5049 ULONG AllowDemotion:1;
5050 ULONG AllowPromotion:1;
5051 ULONG Reserved:30;
5052 } PROCESSOR_POWER_POLICY_INFO,
5053 *PPROCESSOR_POWER_POLICY_INFO;
5055 typedef struct _PROCESSOR_POWER_POLICY {
5056 DWORD Revision;
5057 BYTE DynamicThrottle;
5058 BYTE Spare[3];
5059 DWORD DisableCStates:1;
5060 DWORD Reserved:31;
5061 DWORD PolicyCount;
5062 PROCESSOR_POWER_POLICY_INFO Policy[3];
5063 } PROCESSOR_POWER_POLICY,
5064 *PPROCESSOR_POWER_POLICY;
5066 typedef struct {
5067 BOOLEAN AcOnLine;
5068 BOOLEAN BatteryPresent;
5069 BOOLEAN Charging;
5070 BOOLEAN Discharging;
5071 BOOLEAN Spare1[4];
5072 ULONG MaxCapacity;
5073 ULONG RemainingCapacity;
5074 ULONG Rate;
5075 ULONG EstimatedTime;
5076 ULONG DefaultAlert1;
5077 ULONG DefaultAlert2;
5078 } SYSTEM_BATTERY_STATE,
5079 *PSYSTEM_BATTERY_STATE;
5081 typedef struct {
5082 BOOLEAN PowerButtonPresent;
5083 BOOLEAN SleepButtonPresent;
5084 BOOLEAN LidPresent;
5085 BOOLEAN SystemS1;
5086 BOOLEAN SystemS2;
5087 BOOLEAN SystemS3;
5088 BOOLEAN SystemS4;
5089 BOOLEAN SystemS5;
5090 BOOLEAN HiberFilePresent;
5091 BOOLEAN FullWake;
5092 BOOLEAN VideoDimPresent;
5093 BOOLEAN ApmPresent;
5094 BOOLEAN UpsPresent;
5095 BOOLEAN ThermalControl;
5096 BOOLEAN ProcessorThrottle;
5097 UCHAR ProcessorMinThrottle;
5098 UCHAR ProcessorMaxThrottle;
5099 UCHAR spare2[4];
5100 BOOLEAN DiskSpinDown;
5101 UCHAR spare3[8];
5102 BOOLEAN SystemBatteriesPresent;
5103 BOOLEAN BatteriesAreShortTerm;
5104 BATTERY_REPORTING_SCALE BatteryScale[3];
5105 SYSTEM_POWER_STATE AcOnLineWake;
5106 SYSTEM_POWER_STATE SoftLidWake;
5107 SYSTEM_POWER_STATE RtcWake;
5108 SYSTEM_POWER_STATE MinDeviceWakeState;
5109 SYSTEM_POWER_STATE DefaultLowLatencyWake;
5110 } SYSTEM_POWER_CAPABILITIES,
5111 *PSYSTEM_POWER_CAPABILITIES;
5113 typedef struct _SYSTEM_POWER_INFORMATION {
5114 ULONG MaxIdlenessAllowed;
5115 ULONG Idleness;
5116 ULONG TimeRemaining;
5117 UCHAR CoolingMode;
5118 } SYSTEM_POWER_INFORMATION,
5119 *PSYSTEM_POWER_INFORMATION;
5121 typedef struct _SYSTEM_POWER_LEVEL {
5122 BOOLEAN Enable;
5123 UCHAR Spare[3];
5124 ULONG BatteryLevel;
5125 POWER_ACTION_POLICY PowerPolicy;
5126 SYSTEM_POWER_STATE MinSystemState;
5127 } SYSTEM_POWER_LEVEL,
5128 *PSYSTEM_POWER_LEVEL;
5130 typedef struct _SYSTEM_POWER_POLICY {
5131 ULONG Revision;
5132 POWER_ACTION_POLICY PowerButton;
5133 POWER_ACTION_POLICY SleepButton;
5134 POWER_ACTION_POLICY LidClose;
5135 SYSTEM_POWER_STATE LidOpenWake;
5136 ULONG Reserved;
5137 POWER_ACTION_POLICY Idle;
5138 ULONG IdleTimeout;
5139 UCHAR IdleSensitivity;
5140 UCHAR DynamicThrottle;
5141 UCHAR Spare2[2];
5142 SYSTEM_POWER_STATE MinSleep;
5143 SYSTEM_POWER_STATE MaxSleep;
5144 SYSTEM_POWER_STATE ReducedLatencySleep;
5145 ULONG WinLogonFlags;
5146 ULONG Spare3;
5147 ULONG DozeS4Timeout;
5148 ULONG BroadcastCapacityResolution;
5149 SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
5150 ULONG VideoTimeout;
5151 BOOLEAN VideoDimDisplay;
5152 ULONG VideoReserved[3];
5153 ULONG SpindownTimeout;
5154 BOOLEAN OptimizeForPower;
5155 UCHAR FanThrottleTolerance;
5156 UCHAR ForcedThrottle;
5157 UCHAR MinThrottle;
5158 POWER_ACTION_POLICY OverThrottled;
5159 } SYSTEM_POWER_POLICY,
5160 *PSYSTEM_POWER_POLICY;
5162 typedef union _FILE_SEGMENT_ELEMENT {
5163 PVOID64 Buffer;
5164 ULONGLONG Alignment;
5165 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
5167 typedef struct _FILE_NOTIFY_INFORMATION {
5168 DWORD NextEntryOffset;
5169 DWORD Action;
5170 DWORD FileNameLength;
5171 WCHAR FileName[1];
5172 } FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
5174 /* ----------------------------- begin tape storage --------------------- */
5176 #define TAPE_FIXED_PARTITIONS 0
5177 #define TAPE_SELECT_PARTITIONS 1
5178 #define TAPE_INITIATOR_PARTITIONS 2
5179 #define TAPE_ERASE_SHORT 0
5180 #define TAPE_ERASE_LONG 1
5181 #define TAPE_LOAD 0
5182 #define TAPE_UNLOAD 1
5183 #define TAPE_TENSION 2
5184 #define TAPE_LOCK 3
5185 #define TAPE_UNLOCK 4
5186 #define TAPE_FORMAT 5
5187 #define TAPE_SETMARKS 0
5188 #define TAPE_FILEMARKS 1
5189 #define TAPE_SHORT_FILEMARKS 2
5190 #define TAPE_LONG_FILEMARKS 3
5191 #define TAPE_REWIND 0
5192 #define TAPE_ABSOLUTE_BLOCK 1
5193 #define TAPE_LOGICAL_BLOCK 2
5194 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
5195 #define TAPE_SPACE_END_OF_DATA 4
5196 #define TAPE_SPACE_RELATIVE_BLOCKS 5
5197 #define TAPE_SPACE_FILEMARKS 6
5198 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
5199 #define TAPE_SPACE_SETMARKS 8
5200 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
5202 typedef struct _TAPE_CREATE_PARTITION {
5203 DWORD Method;
5204 DWORD Count;
5205 DWORD Size;
5206 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
5208 typedef struct _TAPE_ERASE {
5209 DWORD Type;
5210 BOOLEAN Immediate;
5211 } TAPE_ERASE, *PTAPE_ERASE;
5213 typedef struct _TAPE_PREPARE {
5214 DWORD Operation;
5215 BOOLEAN Immediate;
5216 } TAPE_PREPARE, *PTAPE_PREPARE;
5218 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
5219 BOOLEAN ECC;
5220 BOOLEAN Compression;
5221 BOOLEAN DataPadding;
5222 BOOLEAN ReportSetmarks;
5223 ULONG EOTWarningZoneSize;
5224 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
5226 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
5227 ULONG BlockSize;
5228 } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
5230 typedef struct _TAPE_WRITE_MARKS {
5231 DWORD Type;
5232 DWORD Count;
5233 BOOLEAN Immediate;
5234 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
5236 typedef struct _TAPE_GET_POSITION {
5237 ULONG Type;
5238 ULONG Partition;
5239 ULONG OffsetLow;
5240 ULONG OffsetHigh;
5241 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
5243 typedef struct _TAPE_SET_POSITION {
5244 ULONG Method;
5245 ULONG Partition;
5246 LARGE_INTEGER Offset;
5247 BOOLEAN Immediate;
5248 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
5250 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
5251 BOOLEAN ECC;
5252 BOOLEAN Compression;
5253 BOOLEAN DataPadding;
5254 BOOLEAN ReportSetmarks;
5255 DWORD DefaultBlockSize;
5256 DWORD MaximumBlockSize;
5257 DWORD MinimumBlockSize;
5258 DWORD MaximumPartitionCount;
5259 DWORD FeaturesLow;
5260 DWORD FeaturesHigh;
5261 DWORD EOTWarningZoneSize;
5262 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
5264 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
5265 LARGE_INTEGER Capacity;
5266 LARGE_INTEGER Remaining;
5267 DWORD BlockSize;
5268 DWORD PartitionCount;
5269 BOOLEAN WriteProtected;
5270 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
5272 /* ----------------------------- begin registry ----------------------------- */
5274 /* Registry security values */
5275 #define OWNER_SECURITY_INFORMATION 0x00000001
5276 #define GROUP_SECURITY_INFORMATION 0x00000002
5277 #define DACL_SECURITY_INFORMATION 0x00000004
5278 #define SACL_SECURITY_INFORMATION 0x00000008
5280 #define REG_OPTION_RESERVED 0x00000000
5281 #define REG_OPTION_NON_VOLATILE 0x00000000
5282 #define REG_OPTION_VOLATILE 0x00000001
5283 #define REG_OPTION_CREATE_LINK 0x00000002
5284 #define REG_OPTION_BACKUP_RESTORE 0x00000004 /* FIXME */
5285 #define REG_OPTION_OPEN_LINK 0x00000008
5286 #define REG_LEGAL_OPTION (REG_OPTION_RESERVED| \
5287 REG_OPTION_NON_VOLATILE| \
5288 REG_OPTION_VOLATILE| \
5289 REG_OPTION_CREATE_LINK| \
5290 REG_OPTION_BACKUP_RESTORE| \
5291 REG_OPTION_OPEN_LINK)
5294 #define REG_CREATED_NEW_KEY 0x00000001
5295 #define REG_OPENED_EXISTING_KEY 0x00000002
5297 /* For RegNotifyChangeKeyValue */
5298 #define REG_NOTIFY_CHANGE_NAME 0x01
5299 #define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02
5300 #define REG_NOTIFY_CHANGE_LAST_SET 0x04
5301 #define REG_NOTIFY_CHANGE_SECURITY 0x08
5303 #define KEY_QUERY_VALUE 0x00000001
5304 #define KEY_SET_VALUE 0x00000002
5305 #define KEY_CREATE_SUB_KEY 0x00000004
5306 #define KEY_ENUMERATE_SUB_KEYS 0x00000008
5307 #define KEY_NOTIFY 0x00000010
5308 #define KEY_CREATE_LINK 0x00000020
5309 #define KEY_WOW64_64KEY 0x00000100
5310 #define KEY_WOW64_32KEY 0x00000200
5311 #define KEY_WOW64_RES 0x00000300
5313 /* for RegKeyRestore flags */
5314 #define REG_WHOLE_HIVE_VOLATILE 0x00000001
5315 #define REG_REFRESH_HIVE 0x00000002
5316 #define REG_NO_LAZY_FLUSH 0x00000004
5317 #define REG_FORCE_RESTORE 0x00000008
5319 #define KEY_READ ((STANDARD_RIGHTS_READ| \
5320 KEY_QUERY_VALUE| \
5321 KEY_ENUMERATE_SUB_KEYS| \
5322 KEY_NOTIFY) \
5323 & (~SYNCHRONIZE) \
5325 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE| \
5326 KEY_SET_VALUE| \
5327 KEY_CREATE_SUB_KEY) \
5328 & (~SYNCHRONIZE) \
5330 #define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE))
5331 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL| \
5332 KEY_QUERY_VALUE| \
5333 KEY_SET_VALUE| \
5334 KEY_CREATE_SUB_KEY| \
5335 KEY_ENUMERATE_SUB_KEYS| \
5336 KEY_NOTIFY| \
5337 KEY_CREATE_LINK) \
5338 & (~SYNCHRONIZE) \
5340 /* ------------------------------ end registry ------------------------------ */
5343 #define EVENTLOG_SUCCESS 0x0000
5344 #define EVENTLOG_ERROR_TYPE 0x0001
5345 #define EVENTLOG_WARNING_TYPE 0x0002
5346 #define EVENTLOG_INFORMATION_TYPE 0x0004
5347 #define EVENTLOG_AUDIT_SUCCESS 0x0008
5348 #define EVENTLOG_AUDIT_FAILURE 0x0010
5350 #define EVENTLOG_SEQUENTIAL_READ 0x0001
5351 #define EVENTLOG_SEEK_READ 0x0002
5352 #define EVENTLOG_FORWARDS_READ 0x0004
5353 #define EVENTLOG_BACKWARDS_READ 0x0008
5355 typedef struct _EVENTLOGRECORD {
5356 DWORD Length;
5357 DWORD Reserved;
5358 DWORD RecordNumber;
5359 DWORD TimeGenerated;
5360 DWORD TimeWritten;
5361 DWORD EventID;
5362 WORD EventType;
5363 WORD NumStrings;
5364 WORD EventCategory;
5365 WORD ReservedFlags;
5366 DWORD ClosingRecordNumber;
5367 DWORD StringOffset;
5368 DWORD UserSidLength;
5369 DWORD UserSidOffset;
5370 DWORD DataLength;
5371 DWORD DataOffset;
5372 } EVENTLOGRECORD, *PEVENTLOGRECORD;
5374 #define SERVICE_BOOT_START 0x00000000
5375 #define SERVICE_SYSTEM_START 0x00000001
5376 #define SERVICE_AUTO_START 0x00000002
5377 #define SERVICE_DEMAND_START 0x00000003
5378 #define SERVICE_DISABLED 0x00000004
5380 #define SERVICE_ERROR_IGNORE 0x00000000
5381 #define SERVICE_ERROR_NORMAL 0x00000001
5382 #define SERVICE_ERROR_SEVERE 0x00000002
5383 #define SERVICE_ERROR_CRITICAL 0x00000003
5385 /* Service types */
5386 #define SERVICE_KERNEL_DRIVER 0x00000001
5387 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002
5388 #define SERVICE_ADAPTER 0x00000004
5389 #define SERVICE_RECOGNIZER_DRIVER 0x00000008
5391 #define SERVICE_DRIVER ( SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | \
5392 SERVICE_RECOGNIZER_DRIVER )
5394 #define SERVICE_WIN32_OWN_PROCESS 0x00000010
5395 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020
5396 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS)
5398 #define SERVICE_INTERACTIVE_PROCESS 0x00000100
5400 #define SERVICE_TYPE_ALL ( SERVICE_WIN32 | SERVICE_ADAPTER | \
5401 SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS )
5404 typedef enum _CM_SERVICE_NODE_TYPE
5406 DriverType = SERVICE_KERNEL_DRIVER,
5407 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
5408 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
5409 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
5410 AdapterType = SERVICE_ADAPTER,
5411 RecognizerType = SERVICE_RECOGNIZER_DRIVER
5412 } SERVICE_NODE_TYPE;
5414 typedef enum _CM_SERVICE_LOAD_TYPE
5416 BootLoad = SERVICE_BOOT_START,
5417 SystemLoad = SERVICE_SYSTEM_START,
5418 AutoLoad = SERVICE_AUTO_START,
5419 DemandLoad = SERVICE_DEMAND_START,
5420 DisableLoad = SERVICE_DISABLED
5421 } SERVICE_LOAD_TYPE;
5423 typedef enum _CM_ERROR_CONTROL_TYPE
5425 IgnoreError = SERVICE_ERROR_IGNORE,
5426 NormalError = SERVICE_ERROR_NORMAL,
5427 SevereError = SERVICE_ERROR_SEVERE,
5428 CriticalError = SERVICE_ERROR_CRITICAL
5429 } SERVICE_ERROR_TYPE;
5433 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
5434 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
5435 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
5436 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
5437 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
5439 #include <guiddef.h>
5441 typedef struct _OBJECT_TYPE_LIST {
5442 WORD Level;
5443 WORD Sbz;
5444 GUID *ObjectType;
5445 } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST;
5447 typedef struct _RTL_CRITICAL_SECTION_DEBUG
5449 WORD Type;
5450 WORD CreatorBackTraceIndex;
5451 struct _RTL_CRITICAL_SECTION *CriticalSection;
5452 LIST_ENTRY ProcessLocksList;
5453 DWORD EntryCount;
5454 DWORD ContentionCount;
5455 #ifdef __WINESRC__ /* in Wine we store the name here */
5456 DWORD_PTR Spare[8/sizeof(DWORD_PTR)];
5457 #else
5458 DWORD Spare[ 2 ];
5459 #endif
5460 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
5462 typedef struct _RTL_CRITICAL_SECTION {
5463 PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
5464 LONG LockCount;
5465 LONG RecursionCount;
5466 HANDLE OwningThread;
5467 HANDLE LockSemaphore;
5468 ULONG_PTR SpinCount;
5469 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
5471 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
5472 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
5473 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
5474 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
5475 #define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
5477 typedef struct _RTL_SRWLOCK {
5478 PVOID Ptr;
5479 } RTL_SRWLOCK, *PRTL_SRWLOCK;
5481 #define RTL_SRWLOCK_INIT {0}
5483 typedef struct _RTL_CONDITION_VARIABLE {
5484 PVOID Ptr;
5485 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
5486 #define RTL_CONDITION_VARIABLE_INIT {0}
5487 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
5489 typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
5490 typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
5492 #define RTL_RUN_ONCE_INIT {0}
5493 typedef union _RTL_RUN_ONCE {
5494 PVOID Ptr;
5495 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
5497 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001
5498 #define RTL_RUN_ONCE_ASYNC 0x00000002
5499 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004
5501 typedef DWORD WINAPI RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE, PVOID, PVOID*);
5502 typedef RTL_RUN_ONCE_INIT_FN *PRTL_RUN_ONCE_INIT_FN;
5503 NTSYSAPI VOID WINAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
5504 NTSYSAPI DWORD WINAPI RtlRunOnceExecuteOnce(PRTL_RUN_ONCE,PRTL_RUN_ONCE_INIT_FN,PVOID,PVOID*);
5505 NTSYSAPI DWORD WINAPI RtlRunOnceBeginInitialize(PRTL_RUN_ONCE, DWORD, PVOID*);
5506 NTSYSAPI DWORD WINAPI RtlRunOnceComplete(PRTL_RUN_ONCE, DWORD, PVOID);
5508 #include <pshpack8.h>
5509 typedef struct _IO_COUNTERS {
5510 ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
5511 ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
5512 ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
5513 ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
5514 ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
5515 ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
5516 } IO_COUNTERS, *PIO_COUNTERS;
5517 #include <poppack.h>
5519 typedef struct {
5520 DWORD dwOSVersionInfoSize;
5521 DWORD dwMajorVersion;
5522 DWORD dwMinorVersion;
5523 DWORD dwBuildNumber;
5524 DWORD dwPlatformId;
5525 CHAR szCSDVersion[128];
5526 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
5528 typedef struct {
5529 DWORD dwOSVersionInfoSize;
5530 DWORD dwMajorVersion;
5531 DWORD dwMinorVersion;
5532 DWORD dwBuildNumber;
5533 DWORD dwPlatformId;
5534 WCHAR szCSDVersion[128];
5535 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
5537 DECL_WINELIB_TYPE_AW(OSVERSIONINFO)
5538 DECL_WINELIB_TYPE_AW(POSVERSIONINFO)
5539 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFO)
5541 typedef struct {
5542 DWORD dwOSVersionInfoSize;
5543 DWORD dwMajorVersion;
5544 DWORD dwMinorVersion;
5545 DWORD dwBuildNumber;
5546 DWORD dwPlatformId;
5547 CHAR szCSDVersion[128];
5548 WORD wServicePackMajor;
5549 WORD wServicePackMinor;
5550 WORD wSuiteMask;
5551 BYTE wProductType;
5552 BYTE wReserved;
5553 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
5555 typedef struct {
5556 DWORD dwOSVersionInfoSize;
5557 DWORD dwMajorVersion;
5558 DWORD dwMinorVersion;
5559 DWORD dwBuildNumber;
5560 DWORD dwPlatformId;
5561 WCHAR szCSDVersion[128];
5562 WORD wServicePackMajor;
5563 WORD wServicePackMinor;
5564 WORD wSuiteMask;
5565 BYTE wProductType;
5566 BYTE wReserved;
5567 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
5569 DECL_WINELIB_TYPE_AW(OSVERSIONINFOEX)
5570 DECL_WINELIB_TYPE_AW(POSVERSIONINFOEX)
5571 DECL_WINELIB_TYPE_AW(LPOSVERSIONINFOEX)
5573 NTSYSAPI ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
5575 #define VER_SET_CONDITION(_m_,_t_,_c_) ((_m_)=VerSetConditionMask((_m_),(_t_),(_c_)))
5577 #define VER_PLATFORM_WIN32s 0
5578 #define VER_PLATFORM_WIN32_WINDOWS 1
5579 #define VER_PLATFORM_WIN32_NT 2
5581 #define VER_MINORVERSION 0x00000001
5582 #define VER_MAJORVERSION 0x00000002
5583 #define VER_BUILDNUMBER 0x00000004
5584 #define VER_PLATFORMID 0x00000008
5585 #define VER_SERVICEPACKMINOR 0x00000010
5586 #define VER_SERVICEPACKMAJOR 0x00000020
5587 #define VER_SUITENAME 0x00000040
5588 #define VER_PRODUCT_TYPE 0x00000080
5590 #define VER_NT_WORKSTATION 1
5591 #define VER_NT_DOMAIN_CONTROLLER 2
5592 #define VER_NT_SERVER 3
5594 #define VER_SUITE_SMALLBUSINESS 0x00000001
5595 #define VER_SUITE_ENTERPRISE 0x00000002
5596 #define VER_SUITE_BACKOFFICE 0x00000004
5597 #define VER_SUITE_COMMUNICATIONS 0x00000008
5598 #define VER_SUITE_TERMINAL 0x00000010
5599 #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
5600 #define VER_SUITE_EMBEDDEDNT 0x00000040
5601 #define VER_SUITE_DATACENTER 0x00000080
5602 #define VER_SUITE_SINGLEUSERTS 0x00000100
5603 #define VER_SUITE_PERSONAL 0x00000200
5604 #define VER_SUITE_BLADE 0x00000400
5605 #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
5606 #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
5607 #define VER_SUITE_STORAGE_SERVER 0x00002000
5608 #define VER_SUITE_COMPUTE_SERVER 0x00004000
5609 #define VER_SUITE_WH_SERVER 0x00008000
5611 #define VER_EQUAL 1
5612 #define VER_GREATER 2
5613 #define VER_GREATER_EQUAL 3
5614 #define VER_LESS 4
5615 #define VER_LESS_EQUAL 5
5616 #define VER_AND 6
5617 #define VER_OR 7
5619 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
5620 DWORD dwFlags;
5621 DWORD ulFormatVersion;
5622 DWORD ulAssemblyCount;
5623 DWORD ulRootManifestPathType;
5624 DWORD ulRootManifestPathChars;
5625 DWORD ulRootConfigurationPathType;
5626 DWORD ulRootConfigurationPathChars;
5627 DWORD ulAppDirPathType;
5628 DWORD ulAppDirPathChars;
5629 PCWSTR lpRootManifestPath;
5630 PCWSTR lpRootConfigurationPath;
5631 PCWSTR lpAppDirPath;
5632 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
5634 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
5635 DWORD ulFlags;
5636 DWORD ulEncodedAssemblyIdentityLength;
5637 DWORD ulManifestPathType;
5638 DWORD ulManifestPathLength;
5639 LARGE_INTEGER liManifestLastWriteTime;
5640 DWORD ulPolicyPathType;
5641 DWORD ulPolicyPathLength;
5642 LARGE_INTEGER liPolicyLastWriteTime;
5643 DWORD ulMetadataSatelliteRosterIndex;
5644 DWORD ulManifestVersionMajor;
5645 DWORD ulManifestVersionMinor;
5646 DWORD ulPolicyVersionMajor;
5647 DWORD ulPolicyVersionMinor;
5648 DWORD ulAssemblyDirectoryNameLength;
5649 PCWSTR lpAssemblyEncodedAssemblyIdentity;
5650 PCWSTR lpAssemblyManifestPath;
5651 PCWSTR lpAssemblyPolicyPath;
5652 PCWSTR lpAssemblyDirectoryName;
5653 DWORD ulFileCount;
5654 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
5656 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
5657 DWORD ulAssemblyIndex;
5658 DWORD ulFileIndexInAssembly;
5659 } ACTIVATION_CONTEXT_QUERY_INDEX, *PACTIVATION_CONTEXT_QUERY_INDEX;
5661 typedef const struct _ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
5663 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
5664 DWORD ulFlags;
5665 DWORD ulFilenameLength;
5666 DWORD ulPathLength;
5667 PCWSTR lpFileName;
5668 PCWSTR lpFilePath;
5669 } ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;
5671 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
5673 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
5674 ActivationContextBasicInformation = 1,
5675 ActivationContextDetailedInformation = 2,
5676 AssemblyDetailedInformationInActivationContext = 3,
5677 FileInformationInAssemblyOfAssemblyInActivationContext = 4,
5678 MaxActivationContextInfoClass,
5680 AssemblyDetailedInformationInActivationContxt = 3,
5681 FileInformationInAssemblyOfAssemblyInActivationContxt = 4
5682 } ACTIVATION_CONTEXT_INFO_CLASS;
5684 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE 1
5685 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2
5686 #define ACTIVATION_CONTEXT_PATH_TYPE_URL 3
5687 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF 4
5689 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
5690 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
5691 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
5692 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
5693 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
5694 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
5695 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
5696 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE 8
5697 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
5699 typedef enum _JOBOBJECTINFOCLASS
5701 JobObjectBasicAccountingInformation = 1,
5702 JobObjectBasicLimitInformation,
5703 JobObjectBasicProcessIdList,
5704 JobObjectBasicUIRestrictions,
5705 JobObjectSecurityLimitInformation,
5706 JobObjectEndOfJobTimeInformation,
5707 JobObjectAssociateCompletionPortInformation,
5708 JobObjectBasicAndIoAccountingInformation,
5709 JobObjectExtendedLimitInformation,
5710 JobObjectJobSetInformation,
5711 MaxJobObjectInfoClass
5712 } JOBOBJECTINFOCLASS;
5714 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
5715 LARGE_INTEGER TotalUserTime;
5716 LARGE_INTEGER TotalKernelTime;
5717 LARGE_INTEGER ThisPeriodTotalUserTime;
5718 LARGE_INTEGER ThisPeriodTotalKernelTime;
5719 DWORD TotalPageFaultCount;
5720 DWORD TotalProcesses;
5721 DWORD ActiveProcesses;
5722 DWORD TotalTerminatedProcesses;
5723 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
5725 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
5726 LARGE_INTEGER PerProcessUserTimeLimit;
5727 LARGE_INTEGER PerJobUserTimeLimit;
5728 DWORD LimitFlags;
5729 SIZE_T MinimumWorkingSetSize;
5730 SIZE_T MaximumWorkingSetSize;
5731 DWORD ActiveProcessLimit;
5732 ULONG_PTR Affinity;
5733 DWORD PriorityClass;
5734 DWORD SchedulingClass;
5735 } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
5737 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
5738 DWORD NumberOfAssignedProcesses;
5739 DWORD NumberOfProcessIdsInList;
5740 ULONG_PTR ProcessIdList[1];
5741 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
5743 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
5744 DWORD UIRestrictionsClass;
5745 } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
5747 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
5748 DWORD SecurityLimitFlags;
5749 HANDLE JobToken;
5750 PTOKEN_GROUPS SidsToDisable;
5751 PTOKEN_PRIVILEGES PrivilegesToDelete;
5752 PTOKEN_GROUPS RestrictedSids;
5753 } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
5755 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
5756 DWORD EndOfJobTimeAction;
5757 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
5759 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
5760 PVOID CompletionKey;
5761 HANDLE CompletionPort;
5762 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
5764 #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
5765 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
5766 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
5767 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
5768 #define JOB_OBJECT_MSG_NEW_PROCESS 6
5769 #define JOB_OBJECT_MSG_EXIT_PROCESS 7
5770 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
5771 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
5772 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
5774 typedef struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
5775 JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
5776 IO_COUNTERS IoInfo;
5777 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
5779 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
5780 JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
5781 IO_COUNTERS IoInfo;
5782 SIZE_T ProcessMemoryLimit;
5783 SIZE_T JobMemoryLimit;
5784 SIZE_T PeakProcessMemoryUsed;
5785 SIZE_T PeakJobMemoryUsed;
5786 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
5788 #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
5789 #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
5790 #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
5791 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
5792 #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
5793 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
5794 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
5795 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
5796 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
5797 #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
5798 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
5799 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
5800 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
5801 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
5802 #define JOB_OBJECT_LIMIT_SUBSET_AFFINITY 0x00004000
5804 #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
5805 #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
5806 #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00007fff
5808 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
5810 RelationProcessorCore = 0,
5811 RelationNumaNode = 1,
5812 RelationCache = 2,
5813 RelationProcessorPackage = 3,
5814 RelationGroup = 4,
5815 RelationAll = 0xffff
5816 } LOGICAL_PROCESSOR_RELATIONSHIP;
5818 typedef enum _PROCESSOR_CACHE_TYPE
5820 CacheUnified,
5821 CacheInstruction,
5822 CacheData,
5823 CacheTrace
5824 } PROCESSOR_CACHE_TYPE;
5826 typedef struct _PROCESSOR_GROUP_INFO
5828 BYTE MaximumProcessorCount;
5829 BYTE ActiveProcessorCount;
5830 BYTE Reserved[38];
5831 KAFFINITY ActiveProcessorMask;
5832 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
5834 typedef struct _CACHE_DESCRIPTOR
5836 BYTE Level;
5837 BYTE Associativity;
5838 WORD LineSize;
5839 DWORD Size;
5840 PROCESSOR_CACHE_TYPE Type;
5841 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
5843 typedef struct _GROUP_AFFINITY
5845 KAFFINITY Mask;
5846 WORD Group;
5847 WORD Reserved[3];
5848 } GROUP_AFFINITY, *PGROUP_AFFINITY;
5850 typedef struct _PROCESSOR_NUMBER
5852 WORD Group;
5853 BYTE Number;
5854 BYTE Reserved;
5855 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
5857 typedef struct _PROCESSOR_RELATIONSHIP
5859 BYTE Flags;
5860 BYTE EfficiencyClass;
5861 BYTE Reserved[20];
5862 WORD GroupCount;
5863 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
5864 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
5866 typedef struct _NUMA_NODE_RELATIONSHIP
5868 DWORD NodeNumber;
5869 BYTE Reserved[20];
5870 GROUP_AFFINITY GroupMask;
5871 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
5873 typedef struct _CACHE_RELATIONSHIP
5875 BYTE Level;
5876 BYTE Associativity;
5877 WORD LineSize;
5878 DWORD CacheSize;
5879 PROCESSOR_CACHE_TYPE Type;
5880 BYTE Reserved[20];
5881 GROUP_AFFINITY GroupMask;
5882 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
5884 typedef struct _GROUP_RELATIONSHIP
5886 WORD MaximumGroupCount;
5887 WORD ActiveGroupCount;
5888 BYTE Reserved[20];
5889 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
5890 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
5892 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
5894 ULONG_PTR ProcessorMask;
5895 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
5896 union
5898 struct
5900 BYTE Flags;
5901 } ProcessorCore;
5902 struct
5904 DWORD NodeNumber;
5905 } NumaNode;
5906 CACHE_DESCRIPTOR Cache;
5907 ULONGLONG Reserved[2];
5908 } DUMMYUNIONNAME;
5909 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
5911 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
5913 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
5914 DWORD Size;
5915 union
5917 PROCESSOR_RELATIONSHIP Processor;
5918 NUMA_NODE_RELATIONSHIP NumaNode;
5919 CACHE_RELATIONSHIP Cache;
5920 GROUP_RELATIONSHIP Group;
5921 } DUMMYUNIONNAME;
5922 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
5924 /* Threadpool things */
5925 typedef DWORD TP_VERSION,*PTP_VERSION;
5927 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE,*PTP_CALLBACK_INSTANCE;
5929 typedef VOID (CALLBACK *PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID);
5931 typedef struct _TP_POOL TP_POOL,*PTP_POOL;
5933 typedef enum _TP_CALLBACK_PRIORITY
5935 TP_CALLBACK_PRIORITY_HIGH,
5936 TP_CALLBACK_PRIORITY_NORMAL,
5937 TP_CALLBACK_PRIORITY_LOW,
5938 TP_CALLBACK_PRIORITY_INVALID,
5939 TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
5940 } TP_CALLBACK_PRIORITY;
5942 typedef struct _TP_POOL_STACK_INFORMATION
5944 SIZE_T StackReserve;
5945 SIZE_T StackCommit;
5946 } TP_POOL_STACK_INFORMATION,*PTP_POOL_STACK_INFORMATION;
5948 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP,*PTP_CLEANUP_GROUP;
5950 typedef VOID (CALLBACK *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID,PVOID);
5952 typedef struct _TP_CALLBACK_ENVIRON_V1
5954 TP_VERSION Version;
5955 PTP_POOL Pool;
5956 PTP_CLEANUP_GROUP CleanupGroup;
5957 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
5958 PVOID RaceDll;
5959 struct _ACTIVATION_CONTEXT* ActivationContext;
5960 PTP_SIMPLE_CALLBACK FinalizationCallback;
5961 union
5963 DWORD Flags;
5964 struct
5966 DWORD LongFunction:1;
5967 DWORD Persistent:1;
5968 DWORD Private:30;
5969 } s;
5970 } u;
5971 } TP_CALLBACK_ENVIRON_V1;
5973 typedef struct _TP_CALLBACK_ENVIRON_V3
5975 TP_VERSION Version;
5976 PTP_POOL Pool;
5977 PTP_CLEANUP_GROUP CleanupGroup;
5978 PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
5979 PVOID RaceDll;
5980 struct _ACTIVATION_CONTEXT *ActivationContext;
5981 PTP_SIMPLE_CALLBACK FinalizationCallback;
5982 union
5984 DWORD Flags;
5985 struct
5987 DWORD LongFunction:1;
5988 DWORD Persistent:1;
5989 DWORD Private:30;
5990 } s;
5991 } u;
5992 TP_CALLBACK_PRIORITY CallbackPriority;
5993 DWORD Size;
5994 } TP_CALLBACK_ENVIRON_V3;
5996 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
5997 typedef struct _TP_TIMER TP_TIMER, *PTP_TIMER;
5999 typedef DWORD TP_WAIT_RESULT;
6000 typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
6002 typedef struct _TP_IO TP_IO, *PTP_IO;
6004 typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
6006 typedef VOID (CALLBACK *PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WORK);
6007 typedef VOID (CALLBACK *PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_TIMER);
6008 typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,TP_WAIT_RESULT);
6009 typedef VOID (CALLBACK *PTP_WIN32_IO_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PVOID,ULONG,ULONG_PTR,PTP_IO);
6012 NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
6014 #ifdef __cplusplus
6016 #endif
6018 #endif /* _WINNT_ */