xref: /reactos/sdk/include/xdk/winnt_old.h (revision 2b7246fd)
1 
2 #if defined(__ROS_LONG64__)
3 #undef InterlockedExchange
4 #define InterlockedExchange(a,b) _InterlockedExchange((long*)a,b)
5 #undef InterlockedExchangeAdd
6 #define InterlockedExchangeAdd(a,b) _InterlockedExchangeAdd((long*)a,b)
7 #undef InterlockedCompareExchange
8 #define InterlockedCompareExchange(a,b,c) _InterlockedCompareExchange((long*)a,b,c)
9 #undef InterlockedIncrement
10 #define InterlockedIncrement(a) _InterlockedIncrement((long*)a)
11 #undef InterlockedDecrement
12 #define InterlockedDecrement(a) _InterlockedDecrement((long*)a)
13 #endif
14 
15 #undef __C89_NAMELESS
16 #undef __C89_NAMELESSSTRUCTNAME
17 #undef __C89_NAMELESSSTRUCTNAME1
18 #undef __C89_NAMELESSSTRUCTNAME2
19 #undef __C89_NAMELESSSTRUCTNAME3
20 #undef __C89_NAMELESSSTRUCTNAME4
21 #undef __C89_NAMELESSSTRUCTNAME5
22 #undef __C89_NAMELESSUNIONNAME
23 #undef __C89_NAMELESSUNIONNAME1
24 #undef __C89_NAMELESSUNIONNAME2
25 #undef __C89_NAMELESSUNIONNAME3
26 #undef __C89_NAMELESSUNIONNAME4
27 #undef __C89_NAMELESSUNIONNAME5
28 #undef __C89_NAMELESSUNIONNAME6
29 #undef __C89_NAMELESSUNIONNAME7
30 #undef __C89_NAMELESSUNIONNAME8
31 
32 #if !defined(__WINESRC__) && !defined(WINE_NO_NAMELESS_EXTENSION)
33 # ifdef __GNUC__
34    /* Anonymous structs support starts with gcc 2.96/g++ 2.95 */
35 #  if (__GNUC__ > 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ > 95) || ((__GNUC_MINOR__ == 95) && defined(__cplusplus))))
36 #   define __C89_NAMELESS __extension__
37 #  endif
38 # elif defined(_MSC_VER)
39 #  define __C89_NAMELESS
40 # endif
41 #endif
42 
43 #ifdef __C89_NAMELESS
44 # define __C89_NAMELESSSTRUCTNAME
45 # define __C89_NAMELESSSTRUCTNAME1
46 # define __C89_NAMELESSSTRUCTNAME2
47 # define __C89_NAMELESSSTRUCTNAME3
48 # define __C89_NAMELESSSTRUCTNAME4
49 # define __C89_NAMELESSSTRUCTNAME5
50 # define __C89_NAMELESSUNIONNAME
51 # define __C89_NAMELESSUNIONNAME1
52 # define __C89_NAMELESSUNIONNAME2
53 # define __C89_NAMELESSUNIONNAME3
54 # define __C89_NAMELESSUNIONNAME4
55 # define __C89_NAMELESSUNIONNAME5
56 # define __C89_NAMELESSUNIONNAME6
57 # define __C89_NAMELESSUNIONNAME7
58 # define __C89_NAMELESSUNIONNAME8
59 #else
60 # define __C89_NAMELESS
61 # define __C89_NAMELESSSTRUCTNAME DUMMYSTRUCTNAME
62 # define __C89_NAMELESSSTRUCTNAME1 DUMMYSTRUCTNAME1
63 # define __C89_NAMELESSSTRUCTNAME2 DUMMYSTRUCTNAME2
64 # define __C89_NAMELESSSTRUCTNAME3 DUMMYSTRUCTNAME3
65 # define __C89_NAMELESSSTRUCTNAME4 DUMMYSTRUCTNAME4
66 # define __C89_NAMELESSSTRUCTNAME5 DUMMYSTRUCTNAME5
67 # define __C89_NAMELESSUNIONNAME DUMMYUNIONNAME
68 # define __C89_NAMELESSUNIONNAME1 DUMMYUNIONNAME1
69 # define __C89_NAMELESSUNIONNAME2 DUMMYUNIONNAME2
70 # define __C89_NAMELESSUNIONNAME3 DUMMYUNIONNAME3
71 # define __C89_NAMELESSUNIONNAME4 DUMMYUNIONNAME4
72 # define __C89_NAMELESSUNIONNAME5 DUMMYUNIONNAME5
73 # define __C89_NAMELESSUNIONNAME6 DUMMYUNIONNAME6
74 # define __C89_NAMELESSUNIONNAME7 DUMMYUNIONNAME7
75 # define __C89_NAMELESSUNIONNAME8 DUMMYUNIONNAME8
76 #endif
77 
78 #define DECLSPEC_HIDDEN
79 
80 /*#ifdef _WINE*/
81 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
82 # define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
83 #else
84 # define __WINE_ALLOC_SIZE(x)
85 #endif
86 /*#endif*/
87 
88 #ifdef __GNUC__
89 # define _HAVE_INT64
90 # ifndef _INTEGRAL_MAX_BITS
91 #  define _INTEGRAL_MAX_BITS 64
92 # endif
93 # undef __int64
94 # define __int64 long long
95 #elif (defined(__WATCOMC__) || defined(_MSC_VER)) && (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64 )
96 # define _HAVE_INT64
97 #endif /* __GNUC__/__WATCOMC */
98 
99 #ifdef _MSC_VER
100 # pragma warning(push)
101 # pragma warning(disable:4201)
102 # pragma warning(disable:4214)
103 # pragma warning(disable:4820)
104 #endif
105 
106 #define ACE_OBJECT_TYPE_PRESENT           0x00000001
107 #define ACE_INHERITED_OBJECT_TYPE_PRESENT 0x00000002
108 
109 /* also in ddk/ntifs.h */
110 #define COMPRESSION_FORMAT_NONE         (0x0000)
111 #define COMPRESSION_FORMAT_DEFAULT      (0x0001)
112 #define COMPRESSION_FORMAT_LZNT1        (0x0002)
113 #define COMPRESSION_ENGINE_STANDARD     (0x0000)
114 #define COMPRESSION_ENGINE_MAXIMUM      (0x0100)
115 #define COMPRESSION_ENGINE_HIBER        (0x0200)
116 #define ACCESS_ALLOWED_ACE_TYPE         (0x0)
117 #define ACCESS_DENIED_ACE_TYPE          (0x1)
118 #define SYSTEM_AUDIT_ACE_TYPE           (0x2)
119 #define SYSTEM_ALARM_ACE_TYPE           (0x3)
120 /*end ntifs.h */
121 
122 #define REG_STANDARD_FORMAT 1
123 #define REG_LATEST_FORMAT   2
124 #define REG_NO_COMPRESSION  4
125 
126 #ifndef WIN32_NO_STATUS
127 
128 #define STATUS_WAIT_0                    ((DWORD)0x00000000)
129 #define STATUS_ABANDONED_WAIT_0          ((DWORD)0x00000080)
130 #define STATUS_USER_APC                  ((DWORD)0x000000C0)
131 #define STATUS_TIMEOUT                   ((DWORD)0x00000102)
132 #define STATUS_PENDING                   ((DWORD)0x00000103)
133 #define STATUS_SEGMENT_NOTIFICATION      ((DWORD)0x40000005)
134 #define STATUS_GUARD_PAGE_VIOLATION      ((DWORD)0x80000001)
135 #define STATUS_DATATYPE_MISALIGNMENT     ((DWORD)0x80000002)
136 #define STATUS_BREAKPOINT                ((DWORD)0x80000003)
137 #define STATUS_SINGLE_STEP               ((DWORD)0x80000004)
138 #define STATUS_ACCESS_VIOLATION          ((DWORD)0xC0000005)
139 #define STATUS_IN_PAGE_ERROR             ((DWORD)0xC0000006)
140 #define STATUS_INVALID_HANDLE            ((DWORD)0xC0000008)
141 #define STATUS_NO_MEMORY                 ((DWORD)0xC0000017)
142 #define STATUS_ILLEGAL_INSTRUCTION       ((DWORD)0xC000001D)
143 #define STATUS_NONCONTINUABLE_EXCEPTION  ((DWORD)0xC0000025)
144 #define STATUS_INVALID_DISPOSITION       ((DWORD)0xC0000026)
145 #define STATUS_ARRAY_BOUNDS_EXCEEDED     ((DWORD)0xC000008C)
146 #define STATUS_FLOAT_DENORMAL_OPERAND    ((DWORD)0xC000008D)
147 #define STATUS_FLOAT_DIVIDE_BY_ZERO      ((DWORD)0xC000008E)
148 #define STATUS_FLOAT_INEXACT_RESULT      ((DWORD)0xC000008F)
149 #define STATUS_FLOAT_INVALID_OPERATION   ((DWORD)0xC0000090)
150 #define STATUS_FLOAT_OVERFLOW            ((DWORD)0xC0000091)
151 #define STATUS_FLOAT_STACK_CHECK         ((DWORD)0xC0000092)
152 #define STATUS_FLOAT_UNDERFLOW           ((DWORD)0xC0000093)
153 #define STATUS_INTEGER_DIVIDE_BY_ZERO    ((DWORD)0xC0000094)
154 #define STATUS_INTEGER_OVERFLOW          ((DWORD)0xC0000095)
155 #define STATUS_PRIVILEGED_INSTRUCTION    ((DWORD)0xC0000096)
156 #define STATUS_STACK_OVERFLOW            ((DWORD)0xC00000FD)
157 #define STATUS_CONTROL_C_EXIT            ((DWORD)0xC000013A)
158 #define STATUS_FLOAT_MULTIPLE_FAULTS     ((DWORD)0xC00002B4)
159 #define STATUS_FLOAT_MULTIPLE_TRAPS      ((DWORD)0xC00002B5)
160 #define STATUS_REG_NAT_CONSUMPTION       ((DWORD)0xC00002C9)
161 #define STATUS_SXS_EARLY_DEACTIVATION    ((DWORD)0xC015000F)
162 #define STATUS_SXS_INVALID_DEACTIVATION  ((DWORD)0xC0150010)
163 
164 #define DBG_EXCEPTION_HANDLED       ((DWORD)0x00010001)
165 #define DBG_CONTINUE                ((DWORD)0x00010002)
166 #define DBG_TERMINATE_THREAD        ((DWORD)0x40010003)
167 #define DBG_TERMINATE_PROCESS       ((DWORD)0x40010004)
168 #define DBG_CONTROL_C               ((DWORD)0x40010005)
169 #define DBG_CONTROL_BREAK           ((DWORD)0x40010008)
170 #define DBG_COMMAND_EXCEPTION       ((DWORD)0x40010009)
171 #define DBG_EXCEPTION_NOT_HANDLED   ((DWORD)0x80010001)
172 
173 #endif /* WIN32_NO_STATUS */
174 
175 #define INVALID_FILE_ATTRIBUTES    ((DWORD)-1)
176 
177 /* Also in ddk/winddk.h */
178 #define FILE_LIST_DIRECTORY        0x00000001
179 #define FILE_READ_DATA            0x00000001
180 #define FILE_ADD_FILE            0x00000002
181 #define FILE_WRITE_DATA            0x00000002
182 #define FILE_ADD_SUBDIRECTORY        0x00000004
183 #define FILE_APPEND_DATA        0x00000004
184 #define FILE_CREATE_PIPE_INSTANCE    0x00000004
185 #define FILE_READ_EA            0x00000008
186 #define FILE_READ_PROPERTIES        0x00000008
187 #define FILE_WRITE_EA            0x00000010
188 #define FILE_WRITE_PROPERTIES        0x00000010
189 #define FILE_EXECUTE            0x00000020
190 #define FILE_TRAVERSE            0x00000020
191 #define FILE_DELETE_CHILD        0x00000040
192 #define FILE_READ_ATTRIBUTES        0x00000080
193 #define FILE_WRITE_ATTRIBUTES        0x00000100
194 
195 #define FILE_SHARE_READ            0x00000001
196 #define FILE_SHARE_WRITE        0x00000002
197 #define FILE_SHARE_DELETE        0x00000004
198 #define FILE_SHARE_VALID_FLAGS        0x00000007
199 
200 #define FILE_ATTRIBUTE_READONLY            0x00000001
201 #define FILE_ATTRIBUTE_HIDDEN            0x00000002
202 #define FILE_ATTRIBUTE_SYSTEM            0x00000004
203 #define FILE_ATTRIBUTE_DIRECTORY        0x00000010
204 #define FILE_ATTRIBUTE_ARCHIVE            0x00000020
205 #define FILE_ATTRIBUTE_DEVICE            0x00000040
206 #define FILE_ATTRIBUTE_NORMAL            0x00000080
207 #define FILE_ATTRIBUTE_TEMPORARY        0x00000100
208 #define FILE_ATTRIBUTE_SPARSE_FILE        0x00000200
209 #define FILE_ATTRIBUTE_REPARSE_POINT        0x00000400
210 #define FILE_ATTRIBUTE_COMPRESSED        0x00000800
211 #define FILE_ATTRIBUTE_OFFLINE            0x00001000
212 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED    0x00002000
213 #define FILE_ATTRIBUTE_ENCRYPTED        0x00004000
214 #define FILE_ATTRIBUTE_INTEGRITY_STREAM   0x00008000
215 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
216 #define FILE_ATTRIBUTE_VALID_FLAGS        0x00007fb7
217 #define FILE_ATTRIBUTE_VALID_SET_FLAGS        0x000031a7
218 
219 #define FILE_COPY_STRUCTURED_STORAGE        0x00000041
220 #define FILE_STRUCTURED_STORAGE            0x00000441
221 
222 #define FILE_VALID_OPTION_FLAGS            0x00ffffff
223 #define FILE_VALID_PIPE_OPTION_FLAGS        0x00000032
224 #define FILE_VALID_MAILSLOT_OPTION_FLAGS    0x00000032
225 #define FILE_VALID_SET_FLAGS            0x00000036
226 
227 #define FILE_DIRECTORY_FILE        0x00000001
228 #define FILE_WRITE_THROUGH        0x00000002
229 #define FILE_SEQUENTIAL_ONLY        0x00000004
230 #define FILE_NO_INTERMEDIATE_BUFFERING    0x00000008
231 #define FILE_SYNCHRONOUS_IO_ALERT    0x00000010
232 #define FILE_SYNCHRONOUS_IO_NONALERT    0x00000020
233 #define FILE_NON_DIRECTORY_FILE        0x00000040
234 #define FILE_CREATE_TREE_CONNECTION    0x00000080
235 #define FILE_COMPLETE_IF_OPLOCKED    0x00000100
236 #define FILE_NO_EA_KNOWLEDGE        0x00000200
237 #define FILE_OPEN_REMOTE_INSTANCE    0x00000400
238 #define FILE_RANDOM_ACCESS        0x00000800
239 #define FILE_DELETE_ON_CLOSE        0x00001000
240 #define FILE_OPEN_BY_FILE_ID        0x00002000
241 #define FILE_OPEN_FOR_BACKUP_INTENT    0x00004000
242 #define FILE_NO_COMPRESSION        0x00008000
243 #define FILE_RESERVE_OPFILTER        0x00100000
244 #define FILE_OPEN_REPARSE_POINT        0x00200000
245 #define FILE_OPEN_NO_RECALL        0x00400000
246 #define FILE_OPEN_FOR_FREE_SPACE_QUERY    0x00800000
247 
248 #define FILE_ALL_ACCESS \
249   (STANDARD_RIGHTS_REQUIRED | \
250    SYNCHRONIZE | \
251    0x1FF)
252 
253 #define FILE_GENERIC_EXECUTE \
254   (STANDARD_RIGHTS_EXECUTE | \
255    FILE_READ_ATTRIBUTES | \
256    FILE_EXECUTE | \
257    SYNCHRONIZE)
258 
259 #define FILE_GENERIC_READ \
260   (STANDARD_RIGHTS_READ | \
261    FILE_READ_DATA | \
262    FILE_READ_ATTRIBUTES | \
263    FILE_READ_EA | \
264    SYNCHRONIZE)
265 
266 #define FILE_GENERIC_WRITE \
267   (STANDARD_RIGHTS_WRITE | \
268    FILE_WRITE_DATA | \
269    FILE_WRITE_ATTRIBUTES | \
270    FILE_WRITE_EA | \
271    FILE_APPEND_DATA | \
272    SYNCHRONIZE)
273 /* end winddk.h */
274 /* also in ddk/ntifs.h */
275 #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
276 #define FILE_NOTIFY_CHANGE_DIR_NAME    0x00000002
277 #define FILE_NOTIFY_CHANGE_NAME        0x00000003
278 #define FILE_NOTIFY_CHANGE_ATTRIBUTES    0x00000004
279 #define FILE_NOTIFY_CHANGE_SIZE        0x00000008
280 #define FILE_NOTIFY_CHANGE_LAST_WRITE    0x00000010
281 #define FILE_NOTIFY_CHANGE_LAST_ACCESS    0x00000020
282 #define FILE_NOTIFY_CHANGE_CREATION    0x00000040
283 #define FILE_NOTIFY_CHANGE_EA        0x00000080
284 #define FILE_NOTIFY_CHANGE_SECURITY    0x00000100
285 #define FILE_NOTIFY_CHANGE_STREAM_NAME    0x00000200
286 #define FILE_NOTIFY_CHANGE_STREAM_SIZE    0x00000400
287 #define FILE_NOTIFY_CHANGE_STREAM_WRITE    0x00000800
288 #define FILE_NOTIFY_VALID_MASK        0x00000fff
289 
290 #define FILE_CASE_SENSITIVE_SEARCH        0x00000001
291 #define FILE_CASE_PRESERVED_NAMES         0x00000002
292 #define FILE_UNICODE_ON_DISK              0x00000004
293 #define FILE_PERSISTENT_ACLS              0x00000008
294 #define FILE_FILE_COMPRESSION             0x00000010
295 #define FILE_VOLUME_QUOTAS                0x00000020
296 #define FILE_SUPPORTS_SPARSE_FILES        0x00000040
297 #define FILE_SUPPORTS_REPARSE_POINTS      0x00000080
298 #define FILE_SUPPORTS_REMOTE_STORAGE      0x00000100
299 #define FS_LFN_APIS                       0x00004000
300 #define FILE_VOLUME_IS_COMPRESSED         0x00008000
301 #define FILE_SUPPORTS_OBJECT_IDS          0x00010000
302 #define FILE_SUPPORTS_ENCRYPTION          0x00020000
303 #define FILE_NAMED_STREAMS                0x00040000
304 #define FILE_READ_ONLY_VOLUME             0x00080000
305 #define FILE_SEQUENTIAL_WRITE_ONCE        0x00100000
306 #define FILE_SUPPORTS_TRANSACTIONS        0x00200000
307 #define FILE_SUPPORTS_HARD_LINKS          0x00400000
308 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
309 #define FILE_SUPPORTS_OPEN_BY_FILE_ID     0x01000000
310 #define FILE_SUPPORTS_USN_JOURNAL         0x02000000
311 #define FILE_SUPPORTS_INTEGRITY_STREAMS   0x04000000
312 #define FILE_SUPPORTS_BLOCK_REFCOUNTING   0x08000000
313 #define FILE_SUPPORTS_SPARSE_VDL          0x10000000
314 #define FILE_DAX_VOLUME                   0x20000000
315 
316 #define IO_COMPLETION_QUERY_STATE       0x0001
317 #define IO_COMPLETION_MODIFY_STATE      0x0002
318 #define IO_COMPLETION_ALL_ACCESS        (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
319 /* end ntifs.h */
320 
321 /* also in ddk/winddk.h */
322 #define DUPLICATE_CLOSE_SOURCE        0x00000001
323 #define DUPLICATE_SAME_ACCESS        0x00000002
324 /* end winddk.k */
325 
326 #define MAILSLOT_NO_MESSAGE    ((DWORD)-1)
327 #define MAILSLOT_WAIT_FOREVER    ((DWORD)-1)
328 #define PROCESS_TERMINATE    1
329 #define PROCESS_CREATE_THREAD    2
330 #define PROCESS_SET_SESSIONID    4
331 #define PROCESS_VM_OPERATION    8
332 #define PROCESS_VM_READ    16
333 #define PROCESS_VM_WRITE    32
334 #define PROCESS_CREATE_PROCESS    128
335 #define PROCESS_SET_QUOTA    256
336 #define PROCESS_SET_INFORMATION    512
337 #define PROCESS_QUERY_INFORMATION    1024
338 #define PROCESS_SUSPEND_RESUME    2048
339 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
340 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xFFF)
341 #define PROCESS_DUP_HANDLE    64
342 #define THREAD_TERMINATE    1
343 #define THREAD_SUSPEND_RESUME    2
344 #define THREAD_GET_CONTEXT    8
345 #define THREAD_SET_CONTEXT    16
346 #define THREAD_SET_INFORMATION    32
347 #define THREAD_QUERY_INFORMATION    64
348 #define THREAD_SET_THREAD_TOKEN    128
349 #define THREAD_IMPERSONATE    256
350 #define THREAD_DIRECT_IMPERSONATION    0x200
351 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800
352 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3FF)
353 #define MUTANT_QUERY_STATE    0x0001
354 #define MUTANT_ALL_ACCESS    (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|MUTANT_QUERY_STATE)
355 #define TIMER_QUERY_STATE    0x0001
356 #define TIMER_MODIFY_STATE    0x0002
357 #define TIMER_ALL_ACCESS    (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|TIMER_QUERY_STATE|TIMER_MODIFY_STATE)
358 #define THREAD_BASE_PRIORITY_LOWRT    15
359 #define THREAD_BASE_PRIORITY_MAX    2
360 #define THREAD_BASE_PRIORITY_MIN    (-2)
361 #define THREAD_BASE_PRIORITY_IDLE    (-15)
362 
363 #define PROCESS_SET_LIMITED_INFORMATION 0x2000
364 #define THREAD_RESUME 0x1000
365 
366 #define SE_CREATE_TOKEN_NAME    TEXT("SeCreateTokenPrivilege")
367 #define SE_ASSIGNPRIMARYTOKEN_NAME    TEXT("SeAssignPrimaryTokenPrivilege")
368 #define SE_LOCK_MEMORY_NAME    TEXT("SeLockMemoryPrivilege")
369 #define SE_INCREASE_QUOTA_NAME    TEXT("SeIncreaseQuotaPrivilege")
370 #define SE_UNSOLICITED_INPUT_NAME    TEXT("SeUnsolicitedInputPrivilege")
371 #define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
372 #define SE_TCB_NAME    TEXT("SeTcbPrivilege")
373 #define SE_SECURITY_NAME    TEXT("SeSecurityPrivilege")
374 #define SE_TAKE_OWNERSHIP_NAME    TEXT("SeTakeOwnershipPrivilege")
375 #define SE_LOAD_DRIVER_NAME    TEXT("SeLoadDriverPrivilege")
376 #define SE_SYSTEM_PROFILE_NAME    TEXT("SeSystemProfilePrivilege")
377 #define SE_SYSTEMTIME_NAME    TEXT("SeSystemtimePrivilege")
378 #define SE_PROF_SINGLE_PROCESS_NAME    TEXT("SeProfileSingleProcessPrivilege")
379 #define SE_INC_BASE_PRIORITY_NAME    TEXT("SeIncreaseBasePriorityPrivilege")
380 #define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
381 #define SE_CREATE_PERMANENT_NAME    TEXT("SeCreatePermanentPrivilege")
382 #define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
383 #define SE_RESTORE_NAME    TEXT("SeRestorePrivilege")
384 #define SE_SHUTDOWN_NAME    TEXT("SeShutdownPrivilege")
385 #define SE_DEBUG_NAME    TEXT("SeDebugPrivilege")
386 #define SE_AUDIT_NAME    TEXT("SeAuditPrivilege")
387 #define SE_SYSTEM_ENVIRONMENT_NAME    TEXT("SeSystemEnvironmentPrivilege")
388 #define SE_CHANGE_NOTIFY_NAME    TEXT("SeChangeNotifyPrivilege")
389 #define SE_REMOTE_SHUTDOWN_NAME    TEXT("SeRemoteShutdownPrivilege")
390 #define SE_UNDOCK_NAME    TEXT("SeUndockPrivilege")
391 #define SE_SYNC_AGENT_NAME    TEXT("SeSyncAgentPrivilege")
392 #define SE_ENABLE_DELEGATION_NAME    TEXT("SeEnableDelegationPrivilege")
393 #define SE_MANAGE_VOLUME_NAME    TEXT("SeManageVolumePrivilege")
394 #define SE_IMPERSONATE_NAME    TEXT("SeImpersonatePrivilege")
395 #define SE_CREATE_GLOBAL_NAME    TEXT("SeCreateGlobalPrivilege")
396 
397 #define SE_GROUP_MANDATORY          0x00000001
398 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
399 #define SE_GROUP_ENABLED            0x00000004
400 #define SE_GROUP_OWNER              0x00000008
401 #define SE_GROUP_USE_FOR_DENY_ONLY  0x00000010
402 #define SE_GROUP_INTEGRITY          0x00000020
403 #define SE_GROUP_INTEGRITY_ENABLED  0x00000040
404 #define SE_GROUP_LOGON_ID           0xC0000000
405 #define SE_GROUP_RESOURCE           0x20000000
406 #define SE_GROUP_VALID_ATTRIBUTES   0xE000007F
407 
408 /* FIXME: non-standard */
409 #define LANG_ESPERANTO      0x8f
410 #define LANG_WALON          0x90
411 #define LANG_CORNISH        0x92
412 
413 /* FIXME: not present in the official headers */
414 #define LANG_MALAGASY       0x8d
415 #define LANG_GAELIC         0x94
416 #define LANG_SAAMI          0x3b
417 #define LANG_SUTU           0x30
418 #define LANG_TSONGA         0x31
419 #define LANG_VENDA          0x33
420 #define LANG_MANX_GAELIC    0x94
421 #define SUBLANG_PORTUGUESE_PORTUGAL   0x02
422 
423 #define PROCESSOR_INTEL_386 386
424 #define PROCESSOR_INTEL_486 486
425 #define PROCESSOR_INTEL_PENTIUM 586
426 #define PROCESSOR_MIPS_R4000 4000
427 #define PROCESSOR_ALPHA_21064 21064
428 #define PROCESSOR_INTEL_IA64 2200
429 #define PROCESSOR_PPC_601 601
430 #define PROCESSOR_PPC_603 603
431 #define PROCESSOR_PPC_604 604
432 #define PROCESSOR_PPC_620 620
433 #define PROCESSOR_INTEL_860 860
434 #define PROCESSOR_AMD_X8664 8664
435 #define PROCESSOR_MIPS_R2000 2000
436 #define PROCESSOR_MIPS_R3000 3000
437 #define PROCESSOR_HITACHI_SH3 10003
438 #define PROCESSOR_HITACHI_SH3E 10004
439 #define PROCESSOR_HITACHI_SH4 10005
440 #define PROCESSOR_MOTOROLA_821 821
441 #define PROCESSOR_SHx_SH3 103
442 #define PROCESSOR_SHx_SH4 104
443 #define PROCESSOR_STRONGARM 2577
444 #define PROCESSOR_ARM720 1824
445 #define PROCESSOR_ARM820 2080
446 #define PROCESSOR_ARM920 2336
447 #define PROCESSOR_ARM_7TDMI 70001
448 #define PROCESSOR_ARCHITECTURE_INTEL 0
449 #define PROCESSOR_ARCHITECTURE_MIPS 1
450 #define PROCESSOR_ARCHITECTURE_ALPHA 2
451 #define PROCESSOR_ARCHITECTURE_PPC 3
452 #define PROCESSOR_ARCHITECTURE_SHX 4
453 #define PROCESSOR_ARCHITECTURE_ARM 5
454 #define PROCESSOR_ARCHITECTURE_IA64 6
455 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
456 #define PROCESSOR_ARCHITECTURE_MSIL 8
457 #define PROCESSOR_ARCHITECTURE_AMD64 9
458 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
459 
460 /* also in ddk/ntifs.h */
461 #define FILE_ACTION_ADDED                   0x00000001
462 #define FILE_ACTION_REMOVED                 0x00000002
463 #define FILE_ACTION_MODIFIED                0x00000003
464 #define FILE_ACTION_RENAMED_OLD_NAME        0x00000004
465 #define FILE_ACTION_RENAMED_NEW_NAME        0x00000005
466 #define FILE_ACTION_ADDED_STREAM            0x00000006
467 #define FILE_ACTION_REMOVED_STREAM          0x00000007
468 #define FILE_ACTION_MODIFIED_STREAM         0x00000008
469 #define FILE_ACTION_REMOVED_BY_DELETE       0x00000009
470 #define FILE_ACTION_ID_NOT_TUNNELLED        0x0000000A
471 #define FILE_ACTION_TUNNELLED_ID_COLLISION  0x0000000B
472 /* end ntifs.h */
473 #define HEAP_NO_SERIALIZE 1
474 #define HEAP_GROWABLE 2
475 #define HEAP_GENERATE_EXCEPTIONS 4
476 #define HEAP_ZERO_MEMORY 8
477 #define HEAP_REALLOC_IN_PLACE_ONLY 16
478 #define HEAP_TAIL_CHECKING_ENABLED 32
479 #define HEAP_FREE_CHECKING_ENABLED 64
480 #define HEAP_DISABLE_COALESCE_ON_FREE 128
481 #define HEAP_CREATE_ALIGN_16 0x10000
482 #define HEAP_CREATE_ENABLE_TRACING 0x20000
483 #define HEAP_CREATE_ENABLE_EXECUTE 0x00040000
484 #define HEAP_MAXIMUM_TAG 0xFFF
485 #define HEAP_PSEUDO_TAG_FLAG 0x8000
486 #define HEAP_TAG_SHIFT 16
487 #define HEAP_MAKE_TAG_FLAGS(b,o) ((DWORD)((b)+(o)<<16)))
488 
489 #define KEY_QUERY_VALUE 1
490 #define KEY_SET_VALUE 2
491 #define KEY_CREATE_SUB_KEY 4
492 #define KEY_ENUMERATE_SUB_KEYS 8
493 #define KEY_NOTIFY 16
494 #define KEY_CREATE_LINK 32
495 #define KEY_WOW64_64KEY         0x00000100
496 #define KEY_WOW64_32KEY         0x00000200
497 #define KEY_WOW64_RES           0x00000300
498 
499 #define KEY_WRITE 0x20006
500 #define KEY_EXECUTE 0x20019
501 #define KEY_READ 0x20019
502 #define KEY_ALL_ACCESS 0xf003f
503 #define REG_WHOLE_HIVE_VOLATILE    1
504 #define REG_REFRESH_HIVE    2
505 #define REG_NO_LAZY_FLUSH    4
506 #define REG_FORCE_RESTORE    8
507 #define REG_OPTION_RESERVED    0
508 #define REG_OPTION_NON_VOLATILE    0
509 #define REG_OPTION_VOLATILE    1
510 #define REG_OPTION_CREATE_LINK    2
511 #define REG_OPTION_BACKUP_RESTORE    4
512 #define REG_OPTION_OPEN_LINK    8
513 #define REG_LEGAL_OPTION    15
514 #define MAXIMUM_PROCESSORS 32
515 #define PAGE_NOACCESS    0x0001
516 #define PAGE_READONLY    0x0002
517 #define PAGE_READWRITE    0x0004
518 #define PAGE_WRITECOPY    0x0008
519 #define PAGE_EXECUTE    0x0010
520 #define PAGE_EXECUTE_READ    0x0020
521 #define PAGE_EXECUTE_READWRITE    0x0040
522 #define PAGE_EXECUTE_WRITECOPY    0x0080
523 #define PAGE_GUARD        0x0100
524 #define PAGE_NOCACHE        0x0200
525 #define PAGE_WRITECOMBINE    0x0400
526 #define MEM_COMMIT           0x1000
527 #define MEM_RESERVE          0x2000
528 #define MEM_DECOMMIT         0x4000
529 #define MEM_RELEASE          0x8000
530 #define MEM_FREE            0x10000
531 #define MEM_PRIVATE         0x20000
532 #define MEM_MAPPED          0x40000
533 #define MEM_RESET           0x80000
534 #define MEM_TOP_DOWN       0x100000
535 #define MEM_WRITE_WATCH       0x200000 /* 98/Me */
536 #define MEM_PHYSICAL       0x400000
537 #define MEM_4MB_PAGES    0x80000000
538 #define MEM_IMAGE        SEC_IMAGE
539 #define SEC_NO_CHANGE    0x00400000
540 #define SEC_FILE    0x00800000
541 #define SEC_IMAGE    0x01000000
542 #define SEC_VLM        0x02000000
543 #define SEC_RESERVE    0x04000000
544 #define SEC_COMMIT    0x08000000
545 #define SEC_NOCACHE    0x10000000
546 #define SEC_WRITECOMBINE 0x40000000
547 #define SEC_LARGE_PAGES  0x80000000
548 #define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
549 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
550 #define SECTION_EXTEND_SIZE 16
551 #define SECTION_MAP_READ 4
552 #define SECTION_MAP_WRITE 2
553 #define SECTION_QUERY 1
554 #define SECTION_MAP_EXECUTE 8
555 #define SECTION_ALL_ACCESS 0xf001f
556 #define WRITE_WATCH_FLAG_RESET 0x01
557 #define MESSAGE_RESOURCE_UNICODE 1
558 #define RTL_CRITSECT_TYPE 0
559 #define RTL_RESOURCE_TYPE 1
560 
561 #define AT_ROUND_TO_PAGE 0x40000000
562 
563 #define IMAGE_SIZEOF_FILE_HEADER    20
564 #define IMAGE_FILE_RELOCS_STRIPPED    1
565 #define IMAGE_FILE_EXECUTABLE_IMAGE    2
566 #define IMAGE_FILE_LINE_NUMS_STRIPPED    4
567 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED    8
568 #define IMAGE_FILE_AGGRESIVE_WS_TRIM     16
569 #define IMAGE_FILE_LARGE_ADDRESS_AWARE    32
570 #define IMAGE_FILE_BYTES_REVERSED_LO    128
571 #define IMAGE_FILE_32BIT_MACHINE    256
572 #define IMAGE_FILE_DEBUG_STRIPPED    512
573 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP    1024
574 #define IMAGE_FILE_NET_RUN_FROM_SWAP    2048
575 #define IMAGE_FILE_SYSTEM    4096
576 #define IMAGE_FILE_DLL    8192
577 #define IMAGE_FILE_UP_SYSTEM_ONLY    16384
578 #define IMAGE_FILE_BYTES_REVERSED_HI    32768
579 #define IMAGE_FILE_MACHINE_UNKNOWN    0
580 
581 #define IMAGE_FILE_MACHINE_AM33       0x1d3
582 #define IMAGE_FILE_MACHINE_AMD64      0x8664
583 #define IMAGE_FILE_MACHINE_ARM        0x1c0
584 #define IMAGE_FILE_MACHINE_ARMNT      0x1c4
585 #define IMAGE_FILE_MACHINE_EBC        0xebc
586 #define IMAGE_FILE_MACHINE_I386       0x14c
587 #define IMAGE_FILE_MACHINE_IA64       0x200
588 #define IMAGE_FILE_MACHINE_M32R       0x9041
589 #define IMAGE_FILE_MACHINE_MIPS16     0x266
590 #define IMAGE_FILE_MACHINE_MIPSFPU    0x366
591 #define IMAGE_FILE_MACHINE_MIPSFPU16  0x466
592 #define IMAGE_FILE_MACHINE_POWERPC    0x1f0
593 #define IMAGE_FILE_MACHINE_POWERPCFP  0x1f1
594 #define IMAGE_FILE_MACHINE_R4000      0x166
595 #define IMAGE_FILE_MACHINE_SH3        0x1a2
596 #define IMAGE_FILE_MACHINE_SH3E       0x01a4
597 #define IMAGE_FILE_MACHINE_SH3DSP     0x1a3
598 #define IMAGE_FILE_MACHINE_SH4        0x1a6
599 #define IMAGE_FILE_MACHINE_SH5        0x1a8
600 #define IMAGE_FILE_MACHINE_THUMB      0x1c2
601 #define IMAGE_FILE_MACHINE_WCEMIPSV2  0x169
602 #define IMAGE_FILE_MACHINE_R3000      0x162
603 #define IMAGE_FILE_MACHINE_R10000     0x168
604 #define IMAGE_FILE_MACHINE_ALPHA      0x184
605 #define IMAGE_FILE_MACHINE_ALPHA64    0x0284
606 #define IMAGE_FILE_MACHINE_AXP64      IMAGE_FILE_MACHINE_ALPHA64
607 #define IMAGE_FILE_MACHINE_CEE        0xC0EE
608 #define IMAGE_FILE_MACHINE_TRICORE    0x0520
609 #define IMAGE_FILE_MACHINE_CEF        0x0CEF
610 #define IMAGE_FILE_MACHINE_ARM64      0xAA64
611 
612 #define IMAGE_FILE_EXPORT_DIRECTORY        0
613 #define IMAGE_FILE_IMPORT_DIRECTORY        1
614 #define IMAGE_FILE_RESOURCE_DIRECTORY        2
615 #define IMAGE_FILE_EXCEPTION_DIRECTORY        3
616 #define IMAGE_FILE_SECURITY_DIRECTORY        4
617 #define IMAGE_FILE_BASE_RELOCATION_TABLE    5
618 #define IMAGE_FILE_DEBUG_DIRECTORY        6
619 #define IMAGE_FILE_DESCRIPTION_STRING        7
620 #define IMAGE_FILE_MACHINE_VALUE        8  /* Mips */
621 #define IMAGE_FILE_THREAD_LOCAL_STORAGE        9
622 #define IMAGE_FILE_CALLBACK_DIRECTORY        10
623 
624 #define IMAGE_DOS_SIGNATURE 0x5A4D
625 #define IMAGE_OS2_SIGNATURE 0x454E
626 #define IMAGE_OS2_SIGNATURE_LE 0x454C
627 #define IMAGE_VXD_SIGNATURE 0x454C
628 #define IMAGE_NT_SIGNATURE 0x00004550
629 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
630 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
631 #ifdef _WIN64
632 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
633 #else
634 #define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
635 #endif
636 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
637 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
638 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
639 #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56
640 #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
641 #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224
642 #define IMAGE_SIZEOF_SHORT_NAME 8
643 #define IMAGE_SIZEOF_SECTION_HEADER 40
644 #define IMAGE_SIZEOF_SYMBOL 18
645 #define IMAGE_SIZEOF_AUX_SYMBOL 18
646 #define IMAGE_SIZEOF_RELOCATION 10
647 #define IMAGE_SIZEOF_BASE_RELOCATION 8
648 #define IMAGE_SIZEOF_LINENUMBER 6
649 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
650 #define SIZEOF_RFPO_DATA 16
651 
652 #define IMAGE_SUBSYSTEM_UNKNOWN                      0
653 #define IMAGE_SUBSYSTEM_NATIVE                       1
654 #define IMAGE_SUBSYSTEM_WINDOWS_GUI                  2
655 #define IMAGE_SUBSYSTEM_WINDOWS_CUI                  3
656 #define IMAGE_SUBSYSTEM_OS2_CUI                      5
657 #define IMAGE_SUBSYSTEM_POSIX_CUI                    7
658 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS               8
659 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI               9
660 #define IMAGE_SUBSYSTEM_EFI_APPLICATION             10
661 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER     11
662 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER          12
663 #define IMAGE_SUBSYSTEM_EFI_ROM                     13
664 #define IMAGE_SUBSYSTEM_XBOX                        14
665 
666 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
667 #define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 0x0080
668 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
669 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
670 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
671 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
672 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
673 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
674 #define IMAGE_FIRST_SECTION(h) ((PIMAGE_SECTION_HEADER) ((ULONG_PTR)h+FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader)+((PIMAGE_NT_HEADERS)(h))->FileHeader.SizeOfOptionalHeader))
675 #define IMAGE_DIRECTORY_ENTRY_EXPORT    0
676 #define IMAGE_DIRECTORY_ENTRY_IMPORT    1
677 #define IMAGE_DIRECTORY_ENTRY_RESOURCE    2
678 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION    3
679 #define IMAGE_DIRECTORY_ENTRY_SECURITY    4
680 #define IMAGE_DIRECTORY_ENTRY_BASERELOC    5
681 #define IMAGE_DIRECTORY_ENTRY_DEBUG    6
682 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT    7
683 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR    8
684 #define IMAGE_DIRECTORY_ENTRY_TLS    9
685 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG    10
686 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT    11
687 #define IMAGE_DIRECTORY_ENTRY_IAT    12
688 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT    13
689 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR    14
690 #define IMAGE_SCN_TYPE_REG 0
691 #define IMAGE_SCN_TYPE_DSECT 1
692 //#define IMAGE_SCN_TYPE_NOLOAD 2
693 #define IMAGE_SCN_TYPE_GROUP 4
694 #define IMAGE_SCN_TYPE_NO_PAD 8
695 #define IMAGE_SCN_CNT_CODE 32
696 #define IMAGE_SCN_CNT_INITIALIZED_DATA 64
697 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 128
698 #define IMAGE_SCN_LNK_OTHER 256
699 #define IMAGE_SCN_LNK_INFO 512
700 #define IMAGE_SCN_LNK_REMOVE 2048
701 #define IMAGE_SCN_LNK_COMDAT 4096
702 #define IMAGE_SCN_MEM_FARDATA 0x8000
703 #define IMAGE_SCN_MEM_PURGEABLE 0x20000
704 #define IMAGE_SCN_MEM_16BIT 0x20000
705 #define IMAGE_SCN_MEM_LOCKED  0x40000
706 #define IMAGE_SCN_MEM_PRELOAD 0x80000
707 #define IMAGE_SCN_ALIGN_1BYTES 0x100000
708 #define IMAGE_SCN_ALIGN_2BYTES 0x200000
709 #define IMAGE_SCN_ALIGN_4BYTES 0x300000
710 #define IMAGE_SCN_ALIGN_8BYTES 0x400000
711 #define IMAGE_SCN_ALIGN_16BYTES 0x500000
712 #define IMAGE_SCN_ALIGN_32BYTES 0x600000
713 #define IMAGE_SCN_ALIGN_64BYTES 0x700000
714 #define IMAGE_SCN_LNK_NRELOC_OVFL 0x1000000
715 #define IMAGE_SCN_MEM_DISCARDABLE 0x2000000
716 #define IMAGE_SCN_MEM_NOT_CACHED 0x4000000
717 #define IMAGE_SCN_MEM_NOT_PAGED 0x8000000
718 #define IMAGE_SCN_MEM_SHARED 0x10000000
719 #define IMAGE_SCN_MEM_EXECUTE 0x20000000
720 #define IMAGE_SCN_MEM_READ 0x40000000
721 #define IMAGE_SCN_MEM_WRITE 0x80000000
722 #define IMAGE_SYM_UNDEFINED    0
723 #define IMAGE_SYM_ABSOLUTE (-1)
724 #define IMAGE_SYM_DEBUG    (-2)
725 #define IMAGE_SYM_TYPE_NULL 0
726 #define IMAGE_SYM_TYPE_VOID 1
727 #define IMAGE_SYM_TYPE_CHAR 2
728 #define IMAGE_SYM_TYPE_SHORT 3
729 #define IMAGE_SYM_TYPE_INT 4
730 #define IMAGE_SYM_TYPE_LONG 5
731 #define IMAGE_SYM_TYPE_FLOAT 6
732 #define IMAGE_SYM_TYPE_DOUBLE 7
733 #define IMAGE_SYM_TYPE_STRUCT 8
734 #define IMAGE_SYM_TYPE_UNION 9
735 #define IMAGE_SYM_TYPE_ENUM 10
736 #define IMAGE_SYM_TYPE_MOE 11
737 #define IMAGE_SYM_TYPE_BYTE 12
738 #define IMAGE_SYM_TYPE_WORD 13
739 #define IMAGE_SYM_TYPE_UINT 14
740 #define IMAGE_SYM_TYPE_DWORD 15
741 #define IMAGE_SYM_TYPE_PCODE 32768
742 #define IMAGE_SYM_DTYPE_NULL 0
743 #define IMAGE_SYM_DTYPE_POINTER 1
744 #define IMAGE_SYM_DTYPE_FUNCTION 2
745 #define IMAGE_SYM_DTYPE_ARRAY 3
746 #define IMAGE_SYM_CLASS_END_OF_FUNCTION    (-1)
747 #define IMAGE_SYM_CLASS_NULL 0
748 #define IMAGE_SYM_CLASS_AUTOMATIC 1
749 #define IMAGE_SYM_CLASS_EXTERNAL 2
750 #define IMAGE_SYM_CLASS_STATIC 3
751 #define IMAGE_SYM_CLASS_REGISTER 4
752 #define IMAGE_SYM_CLASS_EXTERNAL_DEF 5
753 #define IMAGE_SYM_CLASS_LABEL 6
754 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
755 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
756 #define IMAGE_SYM_CLASS_ARGUMENT 9
757 #define IMAGE_SYM_CLASS_STRUCT_TAG 10
758 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
759 #define IMAGE_SYM_CLASS_UNION_TAG 12
760 #define IMAGE_SYM_CLASS_TYPE_DEFINITION 13
761 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
762 #define IMAGE_SYM_CLASS_ENUM_TAG 15
763 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
764 #define IMAGE_SYM_CLASS_REGISTER_PARAM 17
765 #define IMAGE_SYM_CLASS_BIT_FIELD 18
766 #define IMAGE_SYM_CLASS_FAR_EXTERNAL 68
767 #define IMAGE_SYM_CLASS_BLOCK 100
768 #define IMAGE_SYM_CLASS_FUNCTION 101
769 #define IMAGE_SYM_CLASS_END_OF_STRUCT 102
770 #define IMAGE_SYM_CLASS_FILE 103
771 #define IMAGE_SYM_CLASS_SECTION 104
772 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
773 #define IMAGE_COMDAT_SELECT_NODUPLICATES 1
774 #define IMAGE_COMDAT_SELECT_ANY 2
775 #define IMAGE_COMDAT_SELECT_SAME_SIZE 3
776 #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
777 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
778 #define IMAGE_COMDAT_SELECT_LARGEST 6
779 #define IMAGE_COMDAT_SELECT_NEWEST 7
780 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
781 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
782 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
783 #define IMAGE_REL_I386_ABSOLUTE 0
784 #define IMAGE_REL_I386_DIR16 1
785 #define IMAGE_REL_I386_REL16 2
786 #define IMAGE_REL_I386_DIR32 6
787 #define IMAGE_REL_I386_DIR32NB 7
788 #define IMAGE_REL_I386_SEG12 9
789 #define IMAGE_REL_I386_SECTION 10
790 #define IMAGE_REL_I386_SECREL 11
791 #define IMAGE_REL_I386_REL32 20
792 #define IMAGE_REL_MIPS_ABSOLUTE 0
793 #define IMAGE_REL_MIPS_REFHALF 1
794 #define IMAGE_REL_MIPS_REFWORD 2
795 #define IMAGE_REL_MIPS_JMPADDR 3
796 #define IMAGE_REL_MIPS_REFHI 4
797 #define IMAGE_REL_MIPS_REFLO 5
798 #define IMAGE_REL_MIPS_GPREL 6
799 #define IMAGE_REL_MIPS_LITERAL 7
800 #define IMAGE_REL_MIPS_SECTION 10
801 #define IMAGE_REL_MIPS_SECREL 11
802 #define IMAGE_REL_MIPS_SECRELLO 12
803 #define IMAGE_REL_MIPS_SECRELHI 13
804 #define IMAGE_REL_MIPS_REFWORDNB 34
805 #define IMAGE_REL_MIPS_PAIR 35
806 #define IMAGE_REL_ALPHA_ABSOLUTE 0
807 #define IMAGE_REL_ALPHA_REFLONG 1
808 #define IMAGE_REL_ALPHA_REFQUAD 2
809 #define IMAGE_REL_ALPHA_GPREL32 3
810 #define IMAGE_REL_ALPHA_LITERAL 4
811 #define IMAGE_REL_ALPHA_LITUSE 5
812 #define IMAGE_REL_ALPHA_GPDISP 6
813 #define IMAGE_REL_ALPHA_BRADDR 7
814 #define IMAGE_REL_ALPHA_HINT 8
815 #define IMAGE_REL_ALPHA_INLINE_REFLONG 9
816 #define IMAGE_REL_ALPHA_REFHI 10
817 #define IMAGE_REL_ALPHA_REFLO 11
818 #define IMAGE_REL_ALPHA_PAIR 12
819 #define IMAGE_REL_ALPHA_MATCH 13
820 #define IMAGE_REL_ALPHA_SECTION 14
821 #define IMAGE_REL_ALPHA_SECREL 15
822 #define IMAGE_REL_ALPHA_REFLONGNB 16
823 #define IMAGE_REL_ALPHA_SECRELLO 17
824 #define IMAGE_REL_ALPHA_SECRELHI 18
825 #define IMAGE_REL_PPC_ABSOLUTE 0
826 #define IMAGE_REL_PPC_ADDR64 1
827 #define IMAGE_REL_PPC_ADDR32 2
828 #define IMAGE_REL_PPC_ADDR24 3
829 #define IMAGE_REL_PPC_ADDR16 4
830 #define IMAGE_REL_PPC_ADDR14 5
831 #define IMAGE_REL_PPC_REL24 6
832 #define IMAGE_REL_PPC_REL14 7
833 #define IMAGE_REL_PPC_TOCREL16 8
834 #define IMAGE_REL_PPC_TOCREL14 9
835 #define IMAGE_REL_PPC_ADDR32NB 10
836 #define IMAGE_REL_PPC_SECREL 11
837 #define IMAGE_REL_PPC_SECTION 12
838 #define IMAGE_REL_PPC_IFGLUE 13
839 #define IMAGE_REL_PPC_IMGLUE 14
840 #define IMAGE_REL_PPC_SECREL16 15
841 #define IMAGE_REL_PPC_REFHI 16
842 #define IMAGE_REL_PPC_REFLO 17
843 #define IMAGE_REL_PPC_PAIR 18
844 #define IMAGE_REL_PPC_TYPEMASK 255
845 #define IMAGE_REL_PPC_NEG 256
846 #define IMAGE_REL_PPC_BRTAKEN 512
847 #define IMAGE_REL_PPC_BRNTAKEN 1024
848 #define IMAGE_REL_PPC_TOCDEFN 2048
849 #define IMAGE_REL_BASED_ABSOLUTE 0
850 #define IMAGE_REL_BASED_HIGH 1
851 #define IMAGE_REL_BASED_LOW 2
852 #define IMAGE_REL_BASED_HIGHLOW 3
853 #define IMAGE_REL_BASED_HIGHADJ 4
854 #define IMAGE_REL_BASED_MIPS_JMPADDR 5
855 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9
856 #define IMAGE_REL_BASED_IA64_IMM64 9
857 #define IMAGE_REL_BASED_DIR64 10
858 #define IMAGE_ARCHIVE_START_SIZE 8
859 #define IMAGE_ARCHIVE_START "!<arch>\n"
860 #define IMAGE_ARCHIVE_END "`\n"
861 #define IMAGE_ARCHIVE_PAD "\n"
862 #define IMAGE_ARCHIVE_LINKER_MEMBER "/               "
863 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "//              "
864 #define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
865 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
866 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
867 #define IMAGE_DEBUG_TYPE_COFF 1
868 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
869 #define IMAGE_DEBUG_TYPE_FPO 3
870 #define IMAGE_DEBUG_TYPE_MISC 4
871 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
872 #define IMAGE_DEBUG_TYPE_FIXUP 6
873 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
874 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
875 #define FRAME_FPO 0
876 #define FRAME_TRAP 1
877 #define FRAME_TSS 2
878 #define FRAME_NONFPO 3
879 #define IMAGE_DEBUG_MISC_EXENAME 1
880 #define N_BTMASK 0x000F
881 #define N_TMASK 0x0030
882 #define N_TMASK1 0x00C0
883 #define N_TMASK2 0x00F0
884 #define N_BTSHFT 4
885 #define N_TSHIFT 2
886 #define IS_TEXT_UNICODE_ASCII16 1
887 #define IS_TEXT_UNICODE_REVERSE_ASCII16 16
888 #define IS_TEXT_UNICODE_STATISTICS 2
889 #define IS_TEXT_UNICODE_REVERSE_STATISTICS 32
890 #define IS_TEXT_UNICODE_CONTROLS 4
891 #define IS_TEXT_UNICODE_REVERSE_CONTROLS 64
892 #define IS_TEXT_UNICODE_SIGNATURE 8
893 #define IS_TEXT_UNICODE_REVERSE_SIGNATURE 128
894 #define IS_TEXT_UNICODE_ILLEGAL_CHARS 256
895 #define IS_TEXT_UNICODE_ODD_LENGTH 512
896 #define IS_TEXT_UNICODE_DBCS_LEADBYTE 1024
897 #define IS_TEXT_UNICODE_NULL_BYTES 4096
898 #define IS_TEXT_UNICODE_UNICODE_MASK 15
899 #define IS_TEXT_UNICODE_REVERSE_MASK 240
900 #define IS_TEXT_UNICODE_NOT_UNICODE_MASK 3840
901 #define IS_TEXT_UNICODE_NOT_ASCII_MASK 61440
902 #define SERVICE_KERNEL_DRIVER 1
903 #define SERVICE_FILE_SYSTEM_DRIVER 2
904 #define SERVICE_ADAPTER 4
905 #define SERVICE_RECOGNIZER_DRIVER 8
906 #define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER|SERVICE_FILE_SYSTEM_DRIVER|SERVICE_RECOGNIZER_DRIVER)
907 #define SERVICE_WIN32_OWN_PROCESS 16
908 #define SERVICE_WIN32_SHARE_PROCESS 32
909 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS|SERVICE_WIN32_SHARE_PROCESS)
910 #define SERVICE_INTERACTIVE_PROCESS 256
911 #define SERVICE_TYPE_ALL (SERVICE_WIN32|SERVICE_ADAPTER|SERVICE_DRIVER|SERVICE_INTERACTIVE_PROCESS)
912 #define SERVICE_BOOT_START 0
913 #define SERVICE_SYSTEM_START 1
914 #define SERVICE_AUTO_START 2
915 #define SERVICE_DEMAND_START 3
916 #define SERVICE_DISABLED 4
917 #define SERVICE_ERROR_IGNORE 0
918 #define SERVICE_ERROR_NORMAL 1
919 #define SERVICE_ERROR_SEVERE 2
920 #define SERVICE_ERROR_CRITICAL 3
921 
922 #define DLL_PROCESS_DETACH    0
923 #define DLL_PROCESS_ATTACH    1
924 #define DLL_THREAD_ATTACH    2
925 #define DLL_THREAD_DETACH    3
926 #ifdef __WINESRC__
927 #define DLL_WINE_PREATTACH    8 /* Never called, but defined for compatibility with Wine source */
928 #endif
929 #define TAPE_ABSOLUTE_POSITION 0
930 #define TAPE_LOGICAL_POSITION 1
931 #define TAPE_PSEUDO_LOGICAL_POSITION 2
932 #define TAPE_REWIND 0
933 #define TAPE_ABSOLUTE_BLOCK 1
934 #define TAPE_LOGICAL_BLOCK 2
935 #define TAPE_PSEUDO_LOGICAL_BLOCK 3
936 #define TAPE_SPACE_END_OF_DATA 4
937 #define TAPE_SPACE_RELATIVE_BLOCKS 5
938 #define TAPE_SPACE_FILEMARKS 6
939 #define TAPE_SPACE_SEQUENTIAL_FMKS 7
940 #define TAPE_SPACE_SETMARKS 8
941 #define TAPE_SPACE_SEQUENTIAL_SMKS 9
942 #define TAPE_DRIVE_FIXED 1
943 #define TAPE_DRIVE_SELECT 2
944 #define TAPE_DRIVE_INITIATOR 4
945 #define TAPE_DRIVE_ERASE_SHORT 16
946 #define TAPE_DRIVE_ERASE_LONG 32
947 #define TAPE_DRIVE_ERASE_BOP_ONLY 64
948 #define TAPE_DRIVE_ERASE_IMMEDIATE 128
949 #define TAPE_DRIVE_TAPE_CAPACITY 256
950 #define TAPE_DRIVE_TAPE_REMAINING 512
951 #define TAPE_DRIVE_FIXED_BLOCK 1024
952 #define TAPE_DRIVE_VARIABLE_BLOCK 2048
953 #define TAPE_DRIVE_WRITE_PROTECT 4096
954 #define TAPE_DRIVE_EOT_WZ_SIZE 8192
955 #define TAPE_DRIVE_ECC 0x10000
956 #define TAPE_DRIVE_COMPRESSION 0x20000
957 #define TAPE_DRIVE_PADDING 0x40000
958 #define TAPE_DRIVE_REPORT_SMKS 0x80000
959 #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x100000
960 #define TAPE_DRIVE_GET_LOGICAL_BLK 0x200000
961 #define TAPE_DRIVE_SET_EOT_WZ_SIZE 0x400000
962 #define TAPE_DRIVE_EJECT_MEDIA 0x1000000
963 #define TAPE_DRIVE_CLEAN_REQUESTS 0x2000000
964 #define TAPE_DRIVE_SET_CMP_BOP_ONLY 0x4000000
965 #define TAPE_DRIVE_RESERVED_BIT 0x80000000
966 #define TAPE_DRIVE_LOAD_UNLOAD 0x80000001
967 #define TAPE_DRIVE_TENSION 0x80000002
968 #define TAPE_DRIVE_LOCK_UNLOCK 0x80000004
969 #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
970 #define TAPE_DRIVE_SET_BLOCK_SIZE 0x80000010
971 #define TAPE_DRIVE_LOAD_UNLD_IMMED 0x80000020
972 #define TAPE_DRIVE_TENSION_IMMED 0x80000040
973 #define TAPE_DRIVE_LOCK_UNLK_IMMED 0x80000080
974 #define TAPE_DRIVE_SET_ECC 0x80000100
975 #define TAPE_DRIVE_SET_COMPRESSION 0x80000200
976 #define TAPE_DRIVE_SET_PADDING 0x80000400
977 #define TAPE_DRIVE_SET_REPORT_SMKS 0x80000800
978 #define TAPE_DRIVE_ABSOLUTE_BLK 0x80001000
979 #define TAPE_DRIVE_ABS_BLK_IMMED 0x80002000
980 #define TAPE_DRIVE_LOGICAL_BLK 0x80004000
981 #define TAPE_DRIVE_LOG_BLK_IMMED 0x80008000
982 #define TAPE_DRIVE_END_OF_DATA 0x80010000
983 #define TAPE_DRIVE_RELATIVE_BLKS 0x80020000
984 #define TAPE_DRIVE_FILEMARKS 0x80040000
985 #define TAPE_DRIVE_SEQUENTIAL_FMKS 0x80080000
986 #define TAPE_DRIVE_SETMARKS 0x80100000
987 #define TAPE_DRIVE_SEQUENTIAL_SMKS 0x80200000
988 #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
989 #define TAPE_DRIVE_SPACE_IMMEDIATE 0x80800000
990 #define TAPE_DRIVE_WRITE_SETMARKS 0x81000000
991 #define TAPE_DRIVE_WRITE_FILEMARKS 0x82000000
992 #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
993 #define TAPE_DRIVE_WRITE_LONG_FMKS 0x88000000
994 #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
995 #define TAPE_DRIVE_FORMAT 0xA0000000
996 #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
997 #define TAPE_DRIVE_HIGH_FEATURES 0x80000000
998 #define TAPE_FIXED_PARTITIONS    0
999 #define TAPE_INITIATOR_PARTITIONS    2
1000 #define TAPE_SELECT_PARTITIONS    1
1001 #define TAPE_FILEMARKS    1
1002 #define TAPE_LONG_FILEMARKS    3
1003 #define TAPE_SETMARKS    0
1004 #define TAPE_SHORT_FILEMARKS    2
1005 #define TAPE_ERASE_LONG 1
1006 #define TAPE_ERASE_SHORT 0
1007 #define TAPE_LOAD 0
1008 #define TAPE_UNLOAD 1
1009 #define TAPE_TENSION 2
1010 #define TAPE_LOCK 3
1011 #define TAPE_UNLOCK 4
1012 #define TAPE_FORMAT 5
1013 #if (_WIN32_WINNT >= 0x0500)
1014 #define VER_MINORVERSION 0x0000001
1015 #define VER_MAJORVERSION 0x0000002
1016 #define VER_BUILDNUMBER 0x0000004
1017 #define VER_PLATFORMID 0x0000008
1018 #define VER_SERVICEPACKMINOR 0x0000010
1019 #define VER_SERVICEPACKMAJOR 0x0000020
1020 #define VER_SUITENAME 0x0000040
1021 #define VER_PRODUCT_TYPE 0x0000080
1022 #define VER_EQUAL 1
1023 #define VER_GREATER 2
1024 #define VER_GREATER_EQUAL 3
1025 #define VER_LESS 4
1026 #define VER_LESS_EQUAL 5
1027 #define VER_AND 6
1028 #define VER_OR 7
1029 #endif
1030 
1031 #define VER_PLATFORM_WIN32s 0
1032 #define VER_PLATFORM_WIN32_WINDOWS 1
1033 #define VER_PLATFORM_WIN32_NT 2
1034 #define VER_NT_WORKSTATION 1
1035 #define VER_NT_DOMAIN_CONTROLLER 2
1036 #define VER_NT_SERVER 3
1037 
1038 #define WT_EXECUTEDEFAULT 0x00000000
1039 #define WT_EXECUTEINIOTHREAD 0x00000001
1040 #define WT_EXECUTEINUITHREAD 0x00000002
1041 #define WT_EXECUTEINWAITTHREAD 0x00000004
1042 #define WT_EXECUTEONLYONCE 0x00000008
1043 #define WT_EXECUTELONGFUNCTION 0x00000010
1044 #define WT_EXECUTEINTIMERTHREAD 0x00000020
1045 #define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040
1046 #define WT_EXECUTEINPERSISTENTTHREAD 0x00000080
1047 #define WT_TRANSFER_IMPERSONATION 0x00000100
1048 #define WT_SET_MAX_THREADPOOL_THREADS(flags,limit) ((flags)|=(limit)<<16)
1049 typedef VOID (NTAPI *WORKERCALLBACKFUNC)(PVOID);
1050 #if (_WIN32_WINNT >= 0x0501)
1051 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION 1
1052 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION 2
1053 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION 3
1054 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION 4
1055 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION 5
1056 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION 6
1057 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION 7
1058 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES 9
1059 #define ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS 10
1060 #define ACTIVATION_CONTEXT_SECTION_COMPATIBILITY_INFO 11
1061 #endif /* (_WIN32_WINNT >= 0x0501) */
1062 #define BTYPE(x) ((x)&N_BTMASK)
1063 #define ISPTR(x) (((x)&N_TMASK)==(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT))
1064 #define ISFCN(x) (((x)&N_TMASK)==(IMAGE_SYM_DTYPE_FUNCTION<<N_BTSHFT))
1065 #define ISARY(x) (((x)&N_TMASK)==(IMAGE_SYM_DTYPE_ARRAY<<N_BTSHFT))
1066 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG||(x)==IMAGE_SYM_CLASS_UNION_TAG||(x)==IMAGE_SYM_CLASS_ENUM_TAG)
1067 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
1068 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
1069 #define TLS_MINIMUM_AVAILABLE 64
1070 #define FLS_MAXIMUM_AVAILABLE 128
1071 #define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE   FIELD_OFFSET(REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer)
1072 #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
1073 #define IO_REPARSE_TAG_RESERVED_ZERO 0
1074 #define IO_REPARSE_TAG_RESERVED_ONE 1
1075 #define IO_REPARSE_TAG_RESERVED_RANGE IO_REPARSE_TAG_RESERVED_ONE
1076 #define IsReparseTagMicrosoft(x) ((x)&0x80000000)
1077 #define IsReparseTagHighLatency(x) ((x)&0x40000000)
1078 #define IsReparseTagNameSurrogate(x) ((x)&0x20000000)
1079 #define IO_REPARSE_TAG_VALID_VALUES 0xE000FFFF
1080 #define IsReparseTagValid(x) (!((x)&~IO_REPARSE_TAG_VALID_VALUES)&&((x)>IO_REPARSE_TAG_RESERVED_RANGE))
1081 #define IO_REPARSE_TAG_SYMBOLIC_LINK IO_REPARSE_TAG_RESERVED_ZERO
1082 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1083 #define IO_REPARSE_TAG_SYMLINK 0xA000000CL
1084 
1085 #define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO    0x01000000
1086 #define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN     0x02000000
1087 #define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT      0x04000000
1088 #define RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE    0x08000000
1089 #define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO 0x10000000
1090 #define RTL_CRITICAL_SECTION_ALL_FLAG_BITS         0xFF000000
1091 #define RTL_CRITICAL_SECTION_FLAG_RESERVED \
1092     (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & \
1093     (~(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO | \
1094        RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN | \
1095        RTL_CRITICAL_SECTION_FLAG_STATIC_INIT | \
1096        RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE | \
1097        RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO)))
1098 
1099 #ifndef RC_INVOKED
1100 
1101 #ifdef _GUID_DEFINED
1102 # warning _GUID_DEFINED is deprecated, use GUID_DEFINED instead
1103 #endif
1104 
1105 #if ! (defined _GUID_DEFINED || defined GUID_DEFINED) /* also defined in basetyps.h */
1106 #define GUID_DEFINED
1107 typedef struct _GUID {
1108     unsigned long  Data1;
1109     unsigned short Data2;
1110     unsigned short Data3;
1111     unsigned char  Data4[8];
1112 } GUID, *REFGUID, *LPGUID;
1113 #endif /* GUID_DEFINED */
1114 
1115 typedef enum _ACL_INFORMATION_CLASS {
1116   AclRevisionInformation = 1,
1117   AclSizeInformation
1118 } ACL_INFORMATION_CLASS;
1119 
1120 typedef struct _ACL_REVISION_INFORMATION {
1121   DWORD AclRevision;
1122 } ACL_REVISION_INFORMATION, *PACL_REVISION_INFORMATION;
1123 
1124 typedef struct _ACL_SIZE_INFORMATION {
1125   DWORD AceCount;
1126   DWORD AclBytesInUse;
1127   DWORD AclBytesFree;
1128 } ACL_SIZE_INFORMATION, *PACL_SIZE_INFORMATION;
1129 
1130 #ifndef _LDT_ENTRY_DEFINED
1131 #define _LDT_ENTRY_DEFINED
1132 
1133 typedef struct _LDT_ENTRY {
1134   WORD LimitLow;
1135   WORD BaseLow;
1136   union {
1137     struct {
1138       BYTE BaseMid;
1139       BYTE Flags1;
1140       BYTE Flags2;
1141       BYTE BaseHi;
1142     } Bytes;
1143     struct {
1144       DWORD BaseMid:8;
1145       DWORD Type:5;
1146       DWORD Dpl:2;
1147       DWORD Pres:1;
1148       DWORD LimitHi:4;
1149       DWORD Sys:1;
1150       DWORD Reserved_0:1;
1151       DWORD Default_Big:1;
1152       DWORD Granularity:1;
1153       DWORD BaseHi:8;
1154     } Bits;
1155   } HighWord;
1156 } LDT_ENTRY, *PLDT_ENTRY, *LPLDT_ENTRY;
1157 
1158 #endif /* _LDT_ENTRY_DEFINED */
1159 
1160 /* FIXME: add more machines */
1161 #if defined(_X86_)
1162 #define SIZE_OF_80387_REGISTERS    80
1163 #define CONTEXT_i386    0x10000
1164 #define CONTEXT_i486    0x10000
1165 #define CONTEXT_CONTROL    (CONTEXT_i386|0x00000001L)
1166 #define CONTEXT_INTEGER    (CONTEXT_i386|0x00000002L)
1167 #define CONTEXT_SEGMENTS    (CONTEXT_i386|0x00000004L)
1168 #define CONTEXT_FLOATING_POINT    (CONTEXT_i386|0x00000008L)
1169 #define CONTEXT_DEBUG_REGISTERS    (CONTEXT_i386|0x00000010L)
1170 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
1171 #define CONTEXT_FULL    (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
1172 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
1173                      CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
1174                      CONTEXT_EXTENDED_REGISTERS)
1175 #define MAXIMUM_SUPPORTED_EXTENSION  512
1176 
1177 #define EXCEPTION_READ_FAULT    0
1178 #define EXCEPTION_WRITE_FAULT   1
1179 #define EXCEPTION_EXECUTE_FAULT 8
1180 
1181 typedef struct _FLOATING_SAVE_AREA {
1182   DWORD ControlWord;
1183   DWORD StatusWord;
1184   DWORD TagWord;
1185   DWORD ErrorOffset;
1186   DWORD ErrorSelector;
1187   DWORD DataOffset;
1188   DWORD DataSelector;
1189   BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
1190   DWORD Cr0NpxState;
1191 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1192 
1193 typedef struct _CONTEXT {
1194   DWORD ContextFlags;
1195   DWORD Dr0;
1196   DWORD Dr1;
1197   DWORD Dr2;
1198   DWORD Dr3;
1199   DWORD Dr6;
1200   DWORD Dr7;
1201   FLOATING_SAVE_AREA FloatSave;
1202   DWORD SegGs;
1203   DWORD SegFs;
1204   DWORD SegEs;
1205   DWORD SegDs;
1206   DWORD Edi;
1207   DWORD Esi;
1208   DWORD Ebx;
1209   DWORD Edx;
1210   DWORD Ecx;
1211   DWORD Eax;
1212   DWORD Ebp;
1213   DWORD Eip;
1214   DWORD SegCs;
1215   DWORD EFlags;
1216   DWORD Esp;
1217   DWORD SegSs;
1218   BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
1219 } CONTEXT;
1220 #elif defined(_AMD64_)
1221 
1222 #define CONTEXT_AMD64 0x100000
1223 
1224 #if !defined(RC_INVOKED)
1225 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
1226 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
1227 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
1228 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
1229 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
1230 
1231 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1232 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1233 
1234 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1235 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1236 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1237 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1238 #endif
1239 
1240 #define INITIAL_MXCSR 0x1f80
1241 #define INITIAL_FPCSR 0x027f
1242 #define EXCEPTION_READ_FAULT    0
1243 #define EXCEPTION_WRITE_FAULT   1
1244 #define EXCEPTION_EXECUTE_FAULT 8
1245 
1246 typedef struct DECLSPEC_ALIGN(16) _M128A {
1247     ULONGLONG Low;
1248     LONGLONG High;
1249 } M128A, *PM128A;
1250 
1251 typedef struct _XMM_SAVE_AREA32 {
1252     WORD ControlWord;
1253     WORD StatusWord;
1254     BYTE TagWord;
1255     BYTE Reserved1;
1256     WORD ErrorOpcode;
1257     DWORD ErrorOffset;
1258     WORD ErrorSelector;
1259     WORD Reserved2;
1260     DWORD DataOffset;
1261     WORD DataSelector;
1262     WORD Reserved3;
1263     DWORD MxCsr;
1264     DWORD MxCsr_Mask;
1265     M128A FloatRegisters[8];
1266     M128A XmmRegisters[16];
1267     BYTE Reserved4[96];
1268 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
1269 
1270 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1271     DWORD64 P1Home;
1272     DWORD64 P2Home;
1273     DWORD64 P3Home;
1274     DWORD64 P4Home;
1275     DWORD64 P5Home;
1276     DWORD64 P6Home;
1277 
1278     /* Control flags */
1279     DWORD ContextFlags;
1280     DWORD MxCsr;
1281 
1282     /* Segment */
1283     WORD SegCs;
1284     WORD SegDs;
1285     WORD SegEs;
1286     WORD SegFs;
1287     WORD SegGs;
1288     WORD SegSs;
1289     DWORD EFlags;
1290 
1291     /* Debug */
1292     DWORD64 Dr0;
1293     DWORD64 Dr1;
1294     DWORD64 Dr2;
1295     DWORD64 Dr3;
1296     DWORD64 Dr6;
1297     DWORD64 Dr7;
1298 
1299     /* Integer */
1300     DWORD64 Rax;
1301     DWORD64 Rcx;
1302     DWORD64 Rdx;
1303     DWORD64 Rbx;
1304     DWORD64 Rsp;
1305     DWORD64 Rbp;
1306     DWORD64 Rsi;
1307     DWORD64 Rdi;
1308     DWORD64 R8;
1309     DWORD64 R9;
1310     DWORD64 R10;
1311     DWORD64 R11;
1312     DWORD64 R12;
1313     DWORD64 R13;
1314     DWORD64 R14;
1315     DWORD64 R15;
1316 
1317     /* Counter */
1318     DWORD64 Rip;
1319 
1320    /* Floating point */
1321    union {
1322        XMM_SAVE_AREA32 FltSave;
1323        struct {
1324            M128A Header[2];
1325            M128A Legacy[8];
1326            M128A Xmm0;
1327            M128A Xmm1;
1328            M128A Xmm2;
1329            M128A Xmm3;
1330            M128A Xmm4;
1331            M128A Xmm5;
1332            M128A Xmm6;
1333            M128A Xmm7;
1334            M128A Xmm8;
1335            M128A Xmm9;
1336            M128A Xmm10;
1337            M128A Xmm11;
1338            M128A Xmm12;
1339            M128A Xmm13;
1340            M128A Xmm14;
1341            M128A Xmm15;
1342       } DUMMYSTRUCTNAME;
1343     } DUMMYUNIONNAME;
1344 
1345      /* Vector */
1346     M128A VectorRegister[26];
1347     DWORD64 VectorControl;
1348 
1349     /* Debug control */
1350     DWORD64 DebugControl;
1351     DWORD64 LastBranchToRip;
1352     DWORD64 LastBranchFromRip;
1353     DWORD64 LastExceptionToRip;
1354     DWORD64 LastExceptionFromRip;
1355 } CONTEXT;
1356 
1357 
1358 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
1359     union {
1360         PM128A FloatingContext[16];
1361         struct {
1362             PM128A Xmm0;
1363             PM128A Xmm1;
1364             PM128A Xmm2;
1365             PM128A Xmm3;
1366             PM128A Xmm4;
1367             PM128A Xmm5;
1368             PM128A Xmm6;
1369             PM128A Xmm7;
1370             PM128A Xmm8;
1371             PM128A Xmm9;
1372             PM128A Xmm10;
1373             PM128A Xmm11;
1374             PM128A Xmm12;
1375             PM128A Xmm13;
1376             PM128A Xmm14;
1377             PM128A Xmm15;
1378         } DUMMYSTRUCTNAME;
1379     } DUMMYUNIONNAME;
1380 
1381     union {
1382         PULONG64 IntegerContext[16];
1383         struct {
1384             PULONG64 Rax;
1385             PULONG64 Rcx;
1386             PULONG64 Rdx;
1387             PULONG64 Rbx;
1388             PULONG64 Rsp;
1389             PULONG64 Rbp;
1390             PULONG64 Rsi;
1391             PULONG64 Rdi;
1392             PULONG64 R8;
1393             PULONG64 R9;
1394             PULONG64 R10;
1395             PULONG64 R11;
1396             PULONG64 R12;
1397             PULONG64 R13;
1398             PULONG64 R14;
1399             PULONG64 R15;
1400         } DUMMYSTRUCTNAME;
1401     } DUMMYUNIONNAME2;
1402 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
1403 
1404 #define UNW_FLAG_NHANDLER 0x0
1405 #define UNW_FLAG_EHANDLER 0x1
1406 #define UNW_FLAG_UHANDLER 0x2
1407 #define UNW_FLAG_CHAININFO 0x4
1408 #define UNW_FLAG_NO_EPILOGUE  0x80000000UL
1409 
1410 #define RUNTIME_FUNCTION_INDIRECT 0x1
1411 
1412 typedef struct _RUNTIME_FUNCTION {
1413     DWORD BeginAddress;
1414     DWORD EndAddress;
1415     DWORD UnwindData;
1416 } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
1417 
1418 #define UNWIND_HISTORY_TABLE_SIZE 12
1419 
1420 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
1421 {
1422     DWORD64 ImageBase;
1423     PRUNTIME_FUNCTION FunctionEntry;
1424 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
1425 
1426 typedef struct _UNWIND_HISTORY_TABLE
1427 {
1428     DWORD Count;
1429     BYTE  LocalHint;
1430     BYTE  GlobalHint;
1431     BYTE  Search;
1432     BYTE  Once;
1433     ULONG64 LowAddress;
1434     ULONG64 HighAddress;
1435     UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
1436 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
1437 
1438 typedef
1439 _Function_class_(GET_RUNTIME_FUNCTION_CALLBACK)
1440 PRUNTIME_FUNCTION
1441 GET_RUNTIME_FUNCTION_CALLBACK(
1442     _In_ DWORD64 ControlPc,
1443     _In_opt_ PVOID Context);
1444 typedef GET_RUNTIME_FUNCTION_CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK;
1445 
1446 typedef
1447 _Function_class_(OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)
1448 DWORD
1449 OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK(
1450     _In_ HANDLE Process,
1451     _In_ PVOID TableAddress,
1452     _Out_ PDWORD Entries,
1453     _Out_ PRUNTIME_FUNCTION* Functions);
1454 typedef OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK *POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK;
1455 
1456 struct _EXCEPTION_POINTERS;
1457 typedef
1458 LONG
1459 (*PEXCEPTION_FILTER) (
1460     struct _EXCEPTION_POINTERS *ExceptionPointers,
1461     PVOID EstablisherFrame);
1462 
1463 typedef
1464 VOID
1465 (*PTERMINATION_HANDLER) (
1466     BOOLEAN AbnormalTermination,
1467     PVOID EstablisherFrame);
1468 
1469 typedef struct _DISPATCHER_CONTEXT
1470 {
1471     ULONG64 ControlPc;
1472     ULONG64 ImageBase;
1473     PRUNTIME_FUNCTION FunctionEntry;
1474     ULONG64 EstablisherFrame;
1475     ULONG64 TargetIp;
1476     struct _CONTEXT *ContextRecord;
1477     PEXCEPTION_ROUTINE LanguageHandler;
1478     PVOID HandlerData;
1479     PUNWIND_HISTORY_TABLE HistoryTable;
1480     ULONG ScopeIndex;
1481     ULONG Fill0;
1482 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1483 
1484 typedef struct _SCOPE_TABLE_AMD64
1485 {
1486     DWORD Count;
1487     struct
1488     {
1489         DWORD BeginAddress;
1490         DWORD EndAddress;
1491         DWORD HandlerAddress;
1492         DWORD JumpTarget;
1493     } ScopeRecord[1];
1494 } SCOPE_TABLE_AMD64, *PSCOPE_TABLE_AMD64;
1495 typedef SCOPE_TABLE_AMD64 SCOPE_TABLE, *PSCOPE_TABLE;
1496 
1497 #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
1498 
1499 NTSYSAPI
1500 VOID
1501 __cdecl
1502 RtlRestoreContext(struct _CONTEXT *ContextRecord,
1503                   struct _EXCEPTION_RECORD *ExceptionRecord);
1504 
1505 NTSYSAPI
1506 BOOLEAN
1507 __cdecl
1508 RtlAddFunctionTable(PRUNTIME_FUNCTION FunctionTable,
1509                     DWORD EntryCount,
1510                     DWORD64 BaseAddress);
1511 
1512 NTSYSAPI
1513 BOOLEAN
1514 __cdecl
1515 RtlInstallFunctionTableCallback(DWORD64 TableIdentifier,
1516                                 DWORD64 BaseAddress,
1517                                 DWORD Length,
1518                                 PGET_RUNTIME_FUNCTION_CALLBACK Callback,
1519                                 PVOID Context,
1520                                 PCWSTR OutOfProcessCallbackDll);
1521 
1522 NTSYSAPI
1523 BOOLEAN
1524 __cdecl
1525 RtlDeleteFunctionTable(PRUNTIME_FUNCTION FunctionTable);
1526 
1527 NTSYSAPI
1528 PRUNTIME_FUNCTION
1529 NTAPI
1530 RtlLookupFunctionEntry(
1531     _In_ DWORD64 ControlPc,
1532     _Out_ PDWORD64 ImageBase,
1533     _Inout_opt_ PUNWIND_HISTORY_TABLE HistoryTable);
1534 
1535 NTSYSAPI
1536 PEXCEPTION_ROUTINE
1537 NTAPI
1538 RtlVirtualUnwind(
1539     _In_ DWORD HandlerType,
1540     _In_ DWORD64 ImageBase,
1541     _In_ DWORD64 ControlPc,
1542     _In_ PRUNTIME_FUNCTION FunctionEntry,
1543     _Inout_ struct _CONTEXT *ContextRecord,
1544     _Out_ PVOID *HandlerData,
1545     _Out_ PDWORD64 EstablisherFrame,
1546     _Inout_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers);
1547 
1548 NTSYSAPI
1549 VOID
1550 NTAPI
1551 RtlUnwindEx(
1552     _In_opt_ PVOID TargetFrame,
1553     _In_opt_ PVOID TargetIp,
1554     _In_opt_ struct _EXCEPTION_RECORD *ExceptionRecord,
1555     _In_ PVOID ReturnValue,
1556     _In_ struct _CONTEXT *ContextRecord,
1557     _In_opt_ PUNWIND_HISTORY_TABLE HistoryTable);
1558 
1559 #elif defined(_PPC_)
1560 #define CONTEXT_CONTROL    1L
1561 #define CONTEXT_FLOATING_POINT    2L
1562 #define CONTEXT_INTEGER    4L
1563 #define CONTEXT_DEBUG_REGISTERS    8L
1564 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_FLOATING_POINT|CONTEXT_INTEGER)
1565 typedef struct _FLOATING_SAVE_AREA
1566 {
1567     double Fpr0;
1568     double Fpr1;
1569     double Fpr2;
1570     double Fpr3;
1571     double Fpr4;
1572     double Fpr5;
1573     double Fpr6;
1574     double Fpr7;
1575     double Fpr8;
1576     double Fpr9;
1577     double Fpr10;
1578     double Fpr11;
1579     double Fpr12;
1580     double Fpr13;
1581     double Fpr14;
1582     double Fpr15;
1583     double Fpr16;
1584     double Fpr17;
1585     double Fpr18;
1586     double Fpr19;
1587     double Fpr20;
1588     double Fpr21;
1589     double Fpr22;
1590     double Fpr23;
1591     double Fpr24;
1592     double Fpr25;
1593     double Fpr26;
1594     double Fpr27;
1595     double Fpr28;
1596     double Fpr29;
1597     double Fpr30;
1598     double Fpr31;
1599     double Fpscr;
1600 } FLOATING_SAVE_AREA;
1601 
1602 typedef struct _CONTEXT {
1603         FLOATING_SAVE_AREA FloatSave;
1604     DWORD Gpr0;
1605     DWORD Gpr1;
1606     DWORD Gpr2;
1607     DWORD Gpr3;
1608     DWORD Gpr4;
1609     DWORD Gpr5;
1610     DWORD Gpr6;
1611     DWORD Gpr7;
1612     DWORD Gpr8;
1613     DWORD Gpr9;
1614     DWORD Gpr10;
1615     DWORD Gpr11;
1616     DWORD Gpr12;
1617     DWORD Gpr13;
1618     DWORD Gpr14;
1619     DWORD Gpr15;
1620     DWORD Gpr16;
1621     DWORD Gpr17;
1622     DWORD Gpr18;
1623     DWORD Gpr19;
1624     DWORD Gpr20;
1625     DWORD Gpr21;
1626     DWORD Gpr22;
1627     DWORD Gpr23;
1628     DWORD Gpr24;
1629     DWORD Gpr25;
1630     DWORD Gpr26;
1631     DWORD Gpr27;
1632     DWORD Gpr28;
1633     DWORD Gpr29;
1634     DWORD Gpr30;
1635     DWORD Gpr31;
1636     DWORD Cr;
1637     DWORD Xer;
1638     DWORD Msr;
1639     DWORD Iar;
1640     DWORD Lr;
1641     DWORD Ctr;
1642     DWORD ContextFlags;
1643     DWORD Fill[3];
1644     DWORD Dr0;
1645     DWORD Dr1;
1646     DWORD Dr2;
1647     DWORD Dr3;
1648     DWORD Dr4;
1649     DWORD Dr5;
1650     DWORD Dr6;
1651     DWORD Dr7;
1652 } CONTEXT;
1653 #elif defined(_ALPHA_)
1654 #define CONTEXT_ALPHA    0x20000
1655 #define CONTEXT_CONTROL    (CONTEXT_ALPHA|1L)
1656 #define CONTEXT_FLOATING_POINT    (CONTEXT_ALPHA|2L)
1657 #define CONTEXT_INTEGER    (CONTEXT_ALPHA|4L)
1658 #define CONTEXT_FULL    (CONTEXT_CONTROL|CONTEXT_FLOATING_POINT|CONTEXT_INTEGER)
1659 typedef struct _CONTEXT {
1660     ULONGLONG FltF0;
1661     ULONGLONG FltF1;
1662     ULONGLONG FltF2;
1663     ULONGLONG FltF3;
1664     ULONGLONG FltF4;
1665     ULONGLONG FltF5;
1666     ULONGLONG FltF6;
1667     ULONGLONG FltF7;
1668     ULONGLONG FltF8;
1669     ULONGLONG FltF9;
1670     ULONGLONG FltF10;
1671     ULONGLONG FltF11;
1672     ULONGLONG FltF12;
1673     ULONGLONG FltF13;
1674     ULONGLONG FltF14;
1675     ULONGLONG FltF15;
1676     ULONGLONG FltF16;
1677     ULONGLONG FltF17;
1678     ULONGLONG FltF18;
1679     ULONGLONG FltF19;
1680     ULONGLONG FltF20;
1681     ULONGLONG FltF21;
1682     ULONGLONG FltF22;
1683     ULONGLONG FltF23;
1684     ULONGLONG FltF24;
1685     ULONGLONG FltF25;
1686     ULONGLONG FltF26;
1687     ULONGLONG FltF27;
1688     ULONGLONG FltF28;
1689     ULONGLONG FltF29;
1690     ULONGLONG FltF30;
1691     ULONGLONG FltF31;
1692     ULONGLONG IntV0;
1693     ULONGLONG IntT0;
1694     ULONGLONG IntT1;
1695     ULONGLONG IntT2;
1696     ULONGLONG IntT3;
1697     ULONGLONG IntT4;
1698     ULONGLONG IntT5;
1699     ULONGLONG IntT6;
1700     ULONGLONG IntT7;
1701     ULONGLONG IntS0;
1702     ULONGLONG IntS1;
1703     ULONGLONG IntS2;
1704     ULONGLONG IntS3;
1705     ULONGLONG IntS4;
1706     ULONGLONG IntS5;
1707     ULONGLONG IntFp;
1708     ULONGLONG IntA0;
1709     ULONGLONG IntA1;
1710     ULONGLONG IntA2;
1711     ULONGLONG IntA3;
1712     ULONGLONG IntA4;
1713     ULONGLONG IntA5;
1714     ULONGLONG IntT8;
1715     ULONGLONG IntT9;
1716     ULONGLONG IntT10;
1717     ULONGLONG IntT11;
1718     ULONGLONG IntRa;
1719     ULONGLONG IntT12;
1720     ULONGLONG IntAt;
1721     ULONGLONG IntGp;
1722     ULONGLONG IntSp;
1723     ULONGLONG IntZero;
1724     ULONGLONG Fpcr;
1725     ULONGLONG SoftFpcr;
1726     ULONGLONG Fir;
1727     DWORD Psr;
1728     DWORD ContextFlags;
1729     DWORD Fill[4];
1730 } CONTEXT;
1731 #elif defined(_SH_)
1732 
1733 /* These are the debug or break registers on the SH3 */
1734 typedef struct _DEBUG_REGISTERS {
1735     DWORD  BarA;
1736     UCHAR  BasrA;
1737     UCHAR  BamrA;
1738     USHORT BbrA;
1739     DWORD  BarB;
1740     UCHAR  BasrB;
1741     UCHAR  BamrB;
1742     USHORT BbrB;
1743     DWORD  BdrB;
1744     DWORD  BdmrB;
1745     USHORT Brcr;
1746     USHORT Align;
1747 } DEBUG_REGISTERS, *PDEBUG_REGISTERS;
1748 
1749 /* The following flags control the contents of the CONTEXT structure. */
1750 
1751 #define CONTEXT_SH3        0x00000040
1752 #define CONTEXT_SH4        0x000000c0    /* CONTEXT_SH3 | 0x80 - must contain the SH3 bits */
1753 
1754 #ifdef SH3
1755 #define CONTEXT_CONTROL         (CONTEXT_SH3 | 0x00000001L)
1756 #define CONTEXT_INTEGER         (CONTEXT_SH3 | 0x00000002L)
1757 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_SH3 | 0x00000008L)
1758 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_DEBUG_REGISTERS)
1759 #else    /* SH4 */
1760 #define CONTEXT_CONTROL         (CONTEXT_SH4 | 0x00000001L)
1761 #define CONTEXT_INTEGER         (CONTEXT_SH4 | 0x00000002L)
1762 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_SH4 | 0x00000008L)
1763 #define CONTEXT_FLOATING_POINT  (CONTEXT_SH4 | 0x00000004L)
1764 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_DEBUG_REGISTERS | CONTEXT_FLOATING_POINT)
1765 #endif
1766 
1767 /* Context Frame */
1768 
1769 /*  This frame is used to store a limited processor context into the */
1770 /* Thread structure for CPUs which have no floating point support. */
1771 
1772 typedef struct _CONTEXT {
1773     /* The flags values within this flag control the contents of */
1774     /* a CONTEXT record. */
1775 
1776     /* If the context record is used as an input parameter, then */
1777     /* for each portion of the context record controlled by a flag */
1778     /* whose value is set, it is assumed that that portion of the */
1779     /* context record contains valid context. If the context record */
1780     /* is being used to modify a thread's context, then only that */
1781     /* portion of the threads context will be modified. */
1782 
1783     /* If the context record is used as an IN OUT parameter to capture */
1784     /* the context of a thread, then only those portions of the thread's */
1785     /* context corresponding to set flags will be returned. */
1786 
1787     /* The context record is never used as an OUT only parameter. */
1788 
1789 
1790     DWORD ContextFlags;
1791 
1792     /* This section is specified/returned if the ContextFlags word contains */
1793     /* the flag CONTEXT_INTEGER. */
1794 
1795     /* N.B. The registers RA and R15 are defined in this section, but are */
1796     /*  considered part of the control context rather than part of the integer */
1797     /*  context. */
1798 
1799     DWORD PR;
1800     DWORD MACH;
1801     DWORD MACL;
1802     DWORD GBR;
1803     DWORD R0;
1804     DWORD R1;
1805     DWORD R2;
1806     DWORD R3;
1807     DWORD R4;
1808     DWORD R5;
1809     DWORD R6;
1810     DWORD R7;
1811     DWORD R8;
1812     DWORD R9;
1813     DWORD R10;
1814     DWORD R11;
1815     DWORD R12;
1816     DWORD R13;
1817     DWORD R14;
1818     DWORD R15;
1819 
1820     /* This section is specified/returned if the ContextFlags word contains */
1821     /* the flag CONTEXT_CONTROL. */
1822 
1823     /* N.B. The registers r15 and ra are defined in the integer section, */
1824     /*   but are considered part of the control context rather than part of */
1825     /*   the integer context. */
1826 
1827     DWORD Fir;
1828     DWORD Psr;
1829 
1830 #if !defined(SH3e) && !defined(SH4)
1831     DWORD    OldStuff[2];
1832     DEBUG_REGISTERS DebugRegisters;
1833 #else
1834     DWORD    Fpscr;
1835     DWORD    Fpul;
1836     DWORD    FRegs[16];
1837 #if defined(SH4)
1838     DWORD    xFRegs[16];
1839 #endif
1840 #endif
1841 } CONTEXT;
1842 
1843 #elif defined(_MIPS_)
1844 
1845 /* The following flags control the contents of the CONTEXT structure. */
1846 
1847 #define CONTEXT_R4000   0x00010000    /* r4000 context */
1848 
1849 #define CONTEXT_CONTROL         (CONTEXT_R4000 | 0x00000001L)
1850 #define CONTEXT_FLOATING_POINT  (CONTEXT_R4000 | 0x00000002L)
1851 #define CONTEXT_INTEGER         (CONTEXT_R4000 | 0x00000004L)
1852 
1853 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
1854 
1855 /* Context Frame */
1856 
1857 /*  N.B. This frame must be exactly a multiple of 16 bytes in length. */
1858 
1859 /*  This frame has a several purposes: 1) it is used as an argument to */
1860 /*  NtContinue, 2) it is used to constuct a call frame for APC delivery, */
1861 /*  3) it is used to construct a call frame for exception dispatching */
1862 /*  in user mode, and 4) it is used in the user level thread creation */
1863 /*  routines. */
1864 
1865 /*  The layout of the record conforms to a standard call frame. */
1866 
1867 
1868 typedef struct _CONTEXT {
1869 
1870     /* This section is always present and is used as an argument build */
1871     /* area. */
1872 
1873     DWORD Argument[4];
1874 
1875     /* This section is specified/returned if the ContextFlags word contains */
1876     /* the flag CONTEXT_FLOATING_POINT. */
1877 
1878     DWORD FltF0;
1879     DWORD FltF1;
1880     DWORD FltF2;
1881     DWORD FltF3;
1882     DWORD FltF4;
1883     DWORD FltF5;
1884     DWORD FltF6;
1885     DWORD FltF7;
1886     DWORD FltF8;
1887     DWORD FltF9;
1888     DWORD FltF10;
1889     DWORD FltF11;
1890     DWORD FltF12;
1891     DWORD FltF13;
1892     DWORD FltF14;
1893     DWORD FltF15;
1894     DWORD FltF16;
1895     DWORD FltF17;
1896     DWORD FltF18;
1897     DWORD FltF19;
1898     DWORD FltF20;
1899     DWORD FltF21;
1900     DWORD FltF22;
1901     DWORD FltF23;
1902     DWORD FltF24;
1903     DWORD FltF25;
1904     DWORD FltF26;
1905     DWORD FltF27;
1906     DWORD FltF28;
1907     DWORD FltF29;
1908     DWORD FltF30;
1909     DWORD FltF31;
1910 
1911     /* This section is specified/returned if the ContextFlags word contains */
1912     /* the flag CONTEXT_INTEGER. */
1913 
1914     /* N.B. The registers gp, sp, and ra are defined in this section, but are */
1915     /*  considered part of the control context rather than part of the integer */
1916     /*  context. */
1917 
1918     /* N.B. Register zero is not stored in the frame. */
1919 
1920     DWORD IntZero;
1921     DWORD IntAt;
1922     DWORD IntV0;
1923     DWORD IntV1;
1924     DWORD IntA0;
1925     DWORD IntA1;
1926     DWORD IntA2;
1927     DWORD IntA3;
1928     DWORD IntT0;
1929     DWORD IntT1;
1930     DWORD IntT2;
1931     DWORD IntT3;
1932     DWORD IntT4;
1933     DWORD IntT5;
1934     DWORD IntT6;
1935     DWORD IntT7;
1936     DWORD IntS0;
1937     DWORD IntS1;
1938     DWORD IntS2;
1939     DWORD IntS3;
1940     DWORD IntS4;
1941     DWORD IntS5;
1942     DWORD IntS6;
1943     DWORD IntS7;
1944     DWORD IntT8;
1945     DWORD IntT9;
1946     DWORD IntK0;
1947     DWORD IntK1;
1948     DWORD IntGp;
1949     DWORD IntSp;
1950     DWORD IntS8;
1951     DWORD IntRa;
1952     DWORD IntLo;
1953     DWORD IntHi;
1954 
1955     /* This section is specified/returned if the ContextFlags word contains */
1956     /* the flag CONTEXT_FLOATING_POINT. */
1957 
1958     DWORD Fsr;
1959 
1960     /* This section is specified/returned if the ContextFlags word contains */
1961     /* the flag CONTEXT_CONTROL. */
1962 
1963     /* N.B. The registers gp, sp, and ra are defined in the integer section, */
1964     /*   but are considered part of the control context rather than part of */
1965     /*   the integer context. */
1966 
1967     DWORD Fir;
1968     DWORD Psr;
1969 
1970     /* The flags values within this flag control the contents of */
1971     /* a CONTEXT record. */
1972 
1973     /* If the context record is used as an input parameter, then */
1974     /* for each portion of the context record controlled by a flag */
1975     /* whose value is set, it is assumed that that portion of the */
1976     /* context record contains valid context. If the context record */
1977     /* is being used to modify a thread's context, then only that */
1978     /* portion of the threads context will be modified. */
1979 
1980     /* If the context record is used as an IN OUT parameter to capture */
1981     /* the context of a thread, then only those portions of the thread's */
1982     /* context corresponding to set flags will be returned. */
1983 
1984     /* The context record is never used as an OUT only parameter. */
1985 
1986     DWORD ContextFlags;
1987 
1988     DWORD Fill[2];
1989 
1990 } CONTEXT;
1991 #elif defined(_ARM_)
1992 
1993 #ifndef PAGE_SIZE
1994 #define PAGE_SIZE                         0x1000 // FIXME: This should probably go elsewhere
1995 #endif
1996 
1997 /* The following flags control the contents of the CONTEXT structure. */
1998 
1999 #define CONTEXT_ARM             0x200000L
2000 #define CONTEXT_CONTROL         (CONTEXT_ARM | 0x00000001L)
2001 #define CONTEXT_INTEGER         (CONTEXT_ARM | 0x00000002L)
2002 #define CONTEXT_FLOATING_POINT  (CONTEXT_ARM | 0x00000004L)
2003 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008L)
2004 #define CONTEXT_FULL            (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2005 
2006 #define EXCEPTION_READ_FAULT    0
2007 #define EXCEPTION_WRITE_FAULT   1
2008 #define EXCEPTION_EXECUTE_FAULT 8
2009 
2010 typedef struct _NEON128
2011 {
2012     ULONGLONG Low;
2013     LONGLONG High;
2014 } NEON128, *PNEON128;
2015 
2016 #define ARM_MAX_BREAKPOINTS 8
2017 #define ARM_MAX_WATCHPOINTS 1
2018 
2019 typedef struct _CONTEXT
2020 {
2021     /* The flags values within this flag control the contents of
2022        a CONTEXT record.
2023 
2024        If the context record is used as an input parameter, then
2025        for each portion of the context record controlled by a flag
2026        whose value is set, it is assumed that that portion of the
2027        context record contains valid context. If the context record
2028        is being used to modify a thread's context, then only that
2029        portion of the threads context will be modified.
2030 
2031        If the context record is used as an IN OUT parameter to capture
2032        the context of a thread, then only those portions of the thread's
2033        context corresponding to set flags will be returned.
2034 
2035        The context record is never used as an OUT only parameter. */
2036     DWORD ContextFlags;
2037 
2038     /* This section is specified/returned if the ContextFlags word contains
2039        the flag CONTEXT_INTEGER. */
2040     DWORD R0;
2041     DWORD R1;
2042     DWORD R2;
2043     DWORD R3;
2044     DWORD R4;
2045     DWORD R5;
2046     DWORD R6;
2047     DWORD R7;
2048     DWORD R8;
2049     DWORD R9;
2050     DWORD R10;
2051     DWORD R11;
2052     DWORD R12;
2053 
2054     DWORD Sp;
2055     DWORD Lr;
2056     DWORD Pc;
2057     DWORD Cpsr;
2058 
2059     /* Floating Point/NEON Registers */
2060     DWORD Fpscr;
2061     DWORD Padding;
2062     union
2063     {
2064         NEON128 Q[16];
2065         ULONGLONG D[32];
2066         DWORD S[32];
2067     } DUMMYUNIONNAME;
2068 
2069     /* Debug registers */
2070     DWORD Bvr[ARM_MAX_BREAKPOINTS];
2071     DWORD Bcr[ARM_MAX_BREAKPOINTS];
2072     DWORD Wvr[ARM_MAX_WATCHPOINTS];
2073     DWORD Wcr[ARM_MAX_WATCHPOINTS];
2074 
2075     DWORD Padding2[2];
2076 } CONTEXT, *PCONTEXT;
2077 
2078 typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY
2079 {
2080     DWORD BeginAddress;
2081     union
2082     {
2083         DWORD UnwindData;
2084         struct
2085         {
2086             DWORD Flag : 2;
2087             DWORD FunctionLength : 11;
2088             DWORD Ret : 2;
2089             DWORD H : 1;
2090             DWORD Reg : 3;
2091             DWORD R : 1;
2092             DWORD L : 1;
2093             DWORD C : 1;
2094             DWORD StackAdjust : 10;
2095         } DUMMYSTRUCTNAME;
2096     } DUMMYUNIONNAME;
2097 } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY, *PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY;
2098 typedef IMAGE_ARM_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
2099 
2100 typedef struct _SCOPE_TABLE_ARM
2101 {
2102     DWORD Count;
2103     struct
2104     {
2105         DWORD BeginAddress;
2106         DWORD EndAddress;
2107         DWORD HandlerAddress;
2108         DWORD JumpTarget;
2109     } ScopeRecord[1];
2110 } SCOPE_TABLE_ARM, *PSCOPE_TABLE_ARM;
2111 typedef SCOPE_TABLE_ARM SCOPE_TABLE, *PSCOPE_TABLE;
2112 
2113 typedef struct _DISPATCHER_CONTEXT
2114 {
2115     DWORD ControlPc;
2116     DWORD ImageBase;
2117     PRUNTIME_FUNCTION FunctionEntry;
2118     DWORD EstablisherFrame;
2119     DWORD TargetPc;
2120     PCONTEXT ContextRecord;
2121     PEXCEPTION_ROUTINE LanguageHandler;
2122     PVOID HandlerData;
2123     struct _UNWIND_HISTORY_TABLE *HistoryTable;
2124     DWORD ScopeIndex;
2125     BOOLEAN ControlPcIsUnwound;
2126     PBYTE  NonVolatileRegisters;
2127     DWORD Reserved;
2128 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
2129 
2130 #elif defined(_ARM64_)
2131 
2132 #define CONTEXT_ARM64   0x00400000L
2133 #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x1L)
2134 #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x2L)
2135 #define CONTEXT_FLOATING_POINT  (CONTEXT_ARM64 | 0x4L)
2136 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x8L)
2137 #define CONTEXT_X18 (CONTEXT_ARM64 | 0x10L)
2138 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2139 
2140 
2141 #define EXCEPTION_READ_FAULT    0
2142 #define EXCEPTION_WRITE_FAULT   1
2143 #define EXCEPTION_EXECUTE_FAULT 8
2144 
2145 typedef union NEON128 {
2146     struct {
2147         ULONGLONG Low;
2148         LONGLONG High;
2149     } DUMMYSTRUCTNAME;
2150     double D[2];
2151     float S[4];
2152     WORD   H[8];
2153     BYTE  B[16];
2154 } NEON128, *PNEON128;
2155 
2156 #define ARM64_MAX_BREAKPOINTS 8
2157 #define ARM64_MAX_WATCHPOINTS 2
2158 
2159 typedef struct _CONTEXT {
2160 
2161     //
2162     // Control flags.
2163     //
2164 
2165     DWORD ContextFlags;
2166 
2167     //
2168     // Integer registers
2169     //
2170 
2171     DWORD Cpsr;
2172     union {
2173         struct {
2174             DWORD64 X0;
2175             DWORD64 X1;
2176             DWORD64 X2;
2177             DWORD64 X3;
2178             DWORD64 X4;
2179             DWORD64 X5;
2180             DWORD64 X6;
2181             DWORD64 X7;
2182             DWORD64 X8;
2183             DWORD64 X9;
2184             DWORD64 X10;
2185             DWORD64 X11;
2186             DWORD64 X12;
2187             DWORD64 X13;
2188             DWORD64 X14;
2189             DWORD64 X15;
2190             DWORD64 X16;
2191             DWORD64 X17;
2192             DWORD64 X18;
2193             DWORD64 X19;
2194             DWORD64 X20;
2195             DWORD64 X21;
2196             DWORD64 X22;
2197             DWORD64 X23;
2198             DWORD64 X24;
2199             DWORD64 X25;
2200             DWORD64 X26;
2201             DWORD64 X27;
2202             DWORD64 X28;
2203             DWORD64 Fp;
2204             DWORD64 Lr;
2205         } DUMMYSTRUCTNAME;
2206         DWORD64 X[31];
2207     } DUMMYUNIONNAME;
2208 
2209     DWORD64 Sp;
2210     DWORD64 Pc;
2211 
2212     //
2213     // Floating Point/NEON Registers
2214     //
2215 
2216     NEON128 V[32];
2217     DWORD Fpcr;
2218     DWORD Fpsr;
2219 
2220     //
2221     // Debug registers
2222     //
2223 
2224     DWORD Bcr[ARM64_MAX_BREAKPOINTS];
2225     DWORD64 Bvr[ARM64_MAX_BREAKPOINTS];
2226     DWORD Wcr[ARM64_MAX_WATCHPOINTS];
2227     DWORD64 Wvr[ARM64_MAX_WATCHPOINTS];
2228 
2229 } _CONTEXT, *P_CONTEXT;
2230 typedef _CONTEXT CONTEXT, *PCONTEXT;
2231 
2232 typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY {
2233     DWORD BeginAddress;
2234     union {
2235         DWORD UnwindData;
2236         struct {
2237             DWORD Flag : 2;
2238             DWORD FunctionLength : 11;
2239             DWORD RegF : 3;
2240             DWORD RegI : 4;
2241             DWORD H : 1;
2242             DWORD CR : 2;
2243             DWORD FrameSize : 9;
2244         } DUMMYSTRUCTNAME;
2245     } DUMMYUNIONNAME;
2246 } IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;
2247 typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
2248 
2249 typedef struct _SCOPE_TABLE_ARM64 {
2250     DWORD Count;
2251     struct
2252     {
2253         DWORD BeginAddress;
2254         DWORD EndAddress;
2255         DWORD HandlerAddress;
2256         DWORD JumpTarget;
2257     } ScopeRecord[1];
2258 } SCOPE_TABLE_ARM64, *PSCOPE_TABLE_ARM64;
2259 typedef SCOPE_TABLE_ARM64 SCOPE_TABLE, *PSCOPE_TABLE;
2260 
2261 typedef struct _DISPATCHER_CONTEXT {
2262     ULONG_PTR ControlPc;
2263     ULONG_PTR ImageBase;
2264     PRUNTIME_FUNCTION FunctionEntry;
2265     ULONG_PTR EstablisherFrame;
2266     ULONG_PTR TargetPc;
2267     PCONTEXT ContextRecord;
2268     PEXCEPTION_ROUTINE LanguageHandler;
2269     PVOID HandlerData;
2270     struct _UNWIND_HISTORY_TABLE *HistoryTable;
2271     DWORD ScopeIndex;
2272     BOOLEAN ControlPcIsUnwound;
2273     PBYTE  NonVolatileRegisters;
2274 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
2275 #else
2276 #error "undefined processor type"
2277 #endif
2278 typedef CONTEXT *PCONTEXT;
2279 
2280 /* The WoW64 context */
2281 #define WOW64_CONTEXT_i386 0x00010000
2282 #define WOW64_CONTEXT_i486 0x00010000
2283 #define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
2284 #define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
2285 #define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
2286 #define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
2287 #define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
2288 #define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
2289 #define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
2290 #define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
2291                            WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
2292                            WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
2293 
2294 #define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
2295 
2296 #define WOW64_CONTEXT_EXCEPTION_ACTIVE      0x08000000
2297 #define WOW64_CONTEXT_SERVICE_ACTIVE        0x10000000
2298 #define WOW64_CONTEXT_EXCEPTION_REQUEST     0x40000000
2299 #define WOW64_CONTEXT_EXCEPTION_REPORTING   0x80000000
2300 
2301 #define WOW64_SIZE_OF_80387_REGISTERS 80
2302 #define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
2303 
2304 typedef struct _WOW64_FLOATING_SAVE_AREA
2305 {
2306     DWORD   ControlWord;
2307     DWORD   StatusWord;
2308     DWORD   TagWord;
2309     DWORD   ErrorOffset;
2310     DWORD   ErrorSelector;
2311     DWORD   DataOffset;
2312     DWORD   DataSelector;
2313     BYTE    RegisterArea[WOW64_SIZE_OF_80387_REGISTERS];
2314     DWORD   Cr0NpxState;
2315 } WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
2316 
2317 #include "pshpack4.h"
2318 typedef struct _WOW64_CONTEXT
2319 {
2320     DWORD ContextFlags;
2321     DWORD Dr0;
2322     DWORD Dr1;
2323     DWORD Dr2;
2324     DWORD Dr3;
2325     DWORD Dr6;
2326     DWORD Dr7;
2327     WOW64_FLOATING_SAVE_AREA FloatSave;
2328     DWORD SegGs;
2329     DWORD SegFs;
2330     DWORD SegEs;
2331     DWORD SegDs;
2332     DWORD Edi;
2333     DWORD Esi;
2334     DWORD Ebx;
2335     DWORD Edx;
2336     DWORD Ecx;
2337     DWORD Eax;
2338     DWORD Ebp;
2339     DWORD Eip;
2340     DWORD SegCs;
2341     DWORD EFlags;
2342     DWORD Esp;
2343     DWORD SegSs;
2344     BYTE ExtendedRegisters[WOW64_MAXIMUM_SUPPORTED_EXTENSION];
2345 } WOW64_CONTEXT, *PWOW64_CONTEXT;
2346 #include "poppack.h"
2347 
2348 
2349 #define EXCEPTION_MAXIMUM_PARAMETERS 15
2350 #define EXCEPTION_NONCONTINUABLE  0x01
2351 #define EXCEPTION_UNWINDING       0x02
2352 #define EXCEPTION_EXIT_UNWIND     0x04
2353 #define EXCEPTION_STACK_INVALID   0x08
2354 #define EXCEPTION_NESTED_CALL     0x10
2355 #define EXCEPTION_TARGET_UNWIND   0x20
2356 #define EXCEPTION_COLLIDED_UNWIND 0x40
2357 #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
2358                           EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
2359 
2360 #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
2361 #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
2362 #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
2363 
2364 typedef struct _EXCEPTION_RECORD {
2365   DWORD ExceptionCode;
2366   DWORD ExceptionFlags;
2367   struct _EXCEPTION_RECORD *ExceptionRecord;
2368   PVOID ExceptionAddress;
2369   DWORD NumberParameters;
2370   ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2371 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
2372 
2373 typedef struct _EXCEPTION_RECORD32 {
2374   DWORD ExceptionCode;
2375   DWORD ExceptionFlags;
2376   DWORD ExceptionRecord;
2377   DWORD ExceptionAddress;
2378   DWORD NumberParameters;
2379   DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2380 } EXCEPTION_RECORD32,*PEXCEPTION_RECORD32;
2381 
2382 typedef struct _EXCEPTION_RECORD64 {
2383   DWORD ExceptionCode;
2384   DWORD ExceptionFlags;
2385   DWORD64 ExceptionRecord;
2386   DWORD64 ExceptionAddress;
2387   DWORD NumberParameters;
2388   DWORD __unusedAlignment;
2389   DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
2390 } EXCEPTION_RECORD64,*PEXCEPTION_RECORD64;
2391 
2392 typedef struct _EXCEPTION_POINTERS {
2393   PEXCEPTION_RECORD ExceptionRecord;
2394   PCONTEXT ContextRecord;
2395 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
2396 
2397 typedef struct _SECURITY_ATTRIBUTES {
2398     DWORD nLength;
2399     LPVOID lpSecurityDescriptor;
2400     BOOL bInheritHandle;
2401 } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
2402 
2403 #define SECURITY_MIN_SID_SIZE (sizeof(SID))
2404 
2405 $include(setypes.h)
2406 
2407 typedef struct _SYSTEM_AUDIT_OBJECT_ACE {
2408   ACE_HEADER Header;
2409   ACCESS_MASK Mask;
2410   DWORD Flags;
2411   GUID ObjectType;
2412   GUID InheritedObjectType;
2413   DWORD SidStart;
2414 } SYSTEM_AUDIT_OBJECT_ACE,*PSYSTEM_AUDIT_OBJECT_ACE;
2415 
2416 typedef struct _SYSTEM_ALARM_OBJECT_ACE {
2417   ACE_HEADER Header;
2418   ACCESS_MASK Mask;
2419   DWORD Flags;
2420   GUID ObjectType;
2421   GUID InheritedObjectType;
2422   DWORD SidStart;
2423 } SYSTEM_ALARM_OBJECT_ACE,*PSYSTEM_ALARM_OBJECT_ACE;
2424 
2425 typedef struct _ACCESS_ALLOWED_CALLBACK_ACE {
2426   ACE_HEADER Header;
2427   ACCESS_MASK Mask;
2428   DWORD SidStart;
2429 } ACCESS_ALLOWED_CALLBACK_ACE, *PACCESS_ALLOWED_CALLBACK_ACE;
2430 
2431 typedef struct _ACCESS_DENIED_CALLBACK_ACE {
2432   ACE_HEADER Header;
2433   ACCESS_MASK Mask;
2434   DWORD SidStart;
2435 } ACCESS_DENIED_CALLBACK_ACE, *PACCESS_DENIED_CALLBACK_ACE;
2436 
2437 typedef struct _SYSTEM_AUDIT_CALLBACK_ACE {
2438   ACE_HEADER Header;
2439   ACCESS_MASK Mask;
2440   DWORD SidStart;
2441 } SYSTEM_AUDIT_CALLBACK_ACE, *PSYSTEM_AUDIT_CALLBACK_ACE;
2442 
2443 typedef struct _SYSTEM_ALARM_CALLBACK_ACE {
2444   ACE_HEADER Header;
2445   ACCESS_MASK Mask;
2446   DWORD SidStart;
2447 } SYSTEM_ALARM_CALLBACK_ACE, *PSYSTEM_ALARM_CALLBACK_ACE;
2448 
2449 typedef struct _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE {
2450   ACE_HEADER Header;
2451   ACCESS_MASK Mask;
2452   DWORD Flags;
2453   GUID ObjectType;
2454   GUID InheritedObjectType;
2455   DWORD SidStart;
2456 } ACCESS_ALLOWED_CALLBACK_OBJECT_ACE, *PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
2457 
2458 typedef struct _ACCESS_DENIED_CALLBACK_OBJECT_ACE {
2459   ACE_HEADER Header;
2460   ACCESS_MASK Mask;
2461   DWORD Flags;
2462   GUID ObjectType;
2463   GUID InheritedObjectType;
2464   DWORD SidStart;
2465 } ACCESS_DENIED_CALLBACK_OBJECT_ACE, *PACCESS_DENIED_CALLBACK_OBJECT_ACE;
2466 
2467 typedef struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE {
2468   ACE_HEADER Header;
2469   ACCESS_MASK Mask;
2470   DWORD Flags;
2471   GUID ObjectType;
2472   GUID InheritedObjectType;
2473   DWORD SidStart;
2474 } SYSTEM_AUDIT_CALLBACK_OBJECT_ACE, *PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
2475 
2476 typedef struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE {
2477   ACE_HEADER Header;
2478   ACCESS_MASK Mask;
2479   DWORD Flags;
2480   GUID ObjectType;
2481   GUID InheritedObjectType;
2482   DWORD SidStart;
2483 } SYSTEM_ALARM_CALLBACK_OBJECT_ACE, *PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
2484 
2485 typedef enum _TOKEN_ELEVATION_TYPE {
2486     TokenElevationTypeDefault = 1,
2487     TokenElevationTypeFull,
2488     TokenElevationTypeLimited,
2489 } TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;
2490 
2491 typedef struct _QUOTA_LIMITS {
2492   SIZE_T PagedPoolLimit;
2493   SIZE_T NonPagedPoolLimit;
2494   SIZE_T MinimumWorkingSetSize;
2495   SIZE_T MaximumWorkingSetSize;
2496   SIZE_T PagefileLimit;
2497   LARGE_INTEGER TimeLimit;
2498 } QUOTA_LIMITS,*PQUOTA_LIMITS;
2499 
2500 typedef union _RATE_QUOTA_LIMIT {
2501   DWORD RateData;
2502   struct {
2503     DWORD RatePercent : 7;
2504     DWORD Reserved0 : 25;
2505   } DUMMYSTRUCTNAME;
2506 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
2507 
2508 typedef struct _QUOTA_LIMITS_EX {
2509   SIZE_T PagedPoolLimit;
2510   SIZE_T NonPagedPoolLimit;
2511   SIZE_T MinimumWorkingSetSize;
2512   SIZE_T MaximumWorkingSetSize;
2513   SIZE_T PagefileLimit;
2514   LARGE_INTEGER TimeLimit;
2515   SIZE_T Reserved1;
2516   SIZE_T Reserved2;
2517   SIZE_T Reserved3;
2518   SIZE_T Reserved4;
2519   DWORD Flags;
2520   RATE_QUOTA_LIMIT CpuRateLimit;
2521 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
2522 
2523 typedef struct _IO_COUNTERS {
2524   ULONGLONG ReadOperationCount;
2525   ULONGLONG WriteOperationCount;
2526   ULONGLONG OtherOperationCount;
2527   ULONGLONG ReadTransferCount;
2528   ULONGLONG WriteTransferCount;
2529   ULONGLONG OtherTransferCount;
2530 } IO_COUNTERS, *PIO_COUNTERS;
2531 
2532 typedef struct _FILE_NOTIFY_INFORMATION {
2533   DWORD NextEntryOffset;
2534   DWORD Action;
2535   DWORD FileNameLength;
2536   WCHAR FileName[1];
2537 } FILE_NOTIFY_INFORMATION,*PFILE_NOTIFY_INFORMATION;
2538 
2539 typedef struct _TAPE_ERASE {
2540   DWORD Type;
2541   BOOLEAN Immediate;
2542 } TAPE_ERASE, *PTAPE_ERASE;
2543 
2544 typedef struct _TAPE_GET_DRIVE_PARAMETERS {
2545   BOOLEAN ECC;
2546   BOOLEAN Compression;
2547   BOOLEAN DataPadding;
2548   BOOLEAN ReportSetmarks;
2549   DWORD DefaultBlockSize;
2550   DWORD MaximumBlockSize;
2551   DWORD MinimumBlockSize;
2552   DWORD MaximumPartitionCount;
2553   DWORD FeaturesLow;
2554   DWORD FeaturesHigh;
2555   DWORD EOTWarningZoneSize;
2556 } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
2557 
2558 typedef struct _TAPE_GET_MEDIA_PARAMETERS {
2559   LARGE_INTEGER Capacity;
2560   LARGE_INTEGER Remaining;
2561   DWORD BlockSize;
2562   DWORD PartitionCount;
2563   BOOLEAN WriteProtected;
2564 } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
2565 
2566 typedef struct _TAPE_GET_POSITION {
2567   DWORD Type;
2568   DWORD Partition;
2569   LARGE_INTEGER Offset;
2570 } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
2571 
2572 typedef struct _TAPE_PREPARE {
2573   DWORD Operation;
2574   BOOLEAN Immediate;
2575 } TAPE_PREPARE, *PTAPE_PREPARE;
2576 
2577 typedef struct _TAPE_SET_DRIVE_PARAMETERS {
2578   BOOLEAN ECC;
2579   BOOLEAN Compression;
2580   BOOLEAN DataPadding;
2581   BOOLEAN ReportSetmarks;
2582   DWORD EOTWarningZoneSize;
2583 } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
2584 
2585 typedef struct _TAPE_SET_MEDIA_PARAMETERS {
2586   DWORD BlockSize;
2587 } TAPE_SET_MEDIA_PARAMETERS,*PTAPE_SET_MEDIA_PARAMETERS;
2588 
2589 typedef struct _TAPE_SET_POSITION {
2590   DWORD Method;
2591   DWORD Partition;
2592   LARGE_INTEGER Offset;
2593   BOOLEAN Immediate;
2594 } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
2595 
2596 typedef struct _TAPE_WRITE_MARKS {
2597   DWORD Type;
2598   DWORD Count;
2599   BOOLEAN Immediate;
2600 } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
2601 
2602 typedef struct _TAPE_CREATE_PARTITION {
2603   DWORD Method;
2604   DWORD Count;
2605   DWORD Size;
2606 } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
2607 
2608 typedef struct _MEMORY_BASIC_INFORMATION {
2609   PVOID BaseAddress;
2610   PVOID AllocationBase;
2611   DWORD AllocationProtect;
2612   SIZE_T RegionSize;
2613   DWORD State;
2614   DWORD Protect;
2615   DWORD Type;
2616 } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
2617 
2618 typedef struct _MESSAGE_RESOURCE_ENTRY {
2619   WORD Length;
2620   WORD Flags;
2621   BYTE Text[1];
2622 } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
2623 
2624 typedef struct _MESSAGE_RESOURCE_BLOCK {
2625   DWORD LowId;
2626   DWORD HighId;
2627   DWORD OffsetToEntries;
2628 } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
2629 
2630 typedef struct _MESSAGE_RESOURCE_DATA {
2631   DWORD NumberOfBlocks;
2632   MESSAGE_RESOURCE_BLOCK Blocks[1];
2633 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
2634 
2635 //
2636 // Slist Header
2637 //
2638 #ifndef _SLIST_HEADER_
2639 #define _SLIST_HEADER_
2640 
2641 #if defined(_WIN64)
2642 
2643 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
2644   struct _SLIST_ENTRY *Next;
2645 } SLIST_ENTRY, *PSLIST_ENTRY;
2646 
2647 typedef struct _SLIST_ENTRY32 {
2648   DWORD Next;
2649 } SLIST_ENTRY32, *PSLIST_ENTRY32;
2650 
2651 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
2652   _ANONYMOUS_STRUCT struct {
2653     ULONGLONG Alignment;
2654     ULONGLONG Region;
2655   } DUMMYSTRUCTNAME;
2656   struct {
2657     ULONGLONG Depth:16;
2658     ULONGLONG Sequence:9;
2659     ULONGLONG NextEntry:39;
2660     ULONGLONG HeaderType:1;
2661     ULONGLONG Init:1;
2662     ULONGLONG Reserved:59;
2663     ULONGLONG Region:3;
2664   } Header8;
2665   struct {
2666     ULONGLONG Depth:16;
2667     ULONGLONG Sequence:48;
2668     ULONGLONG HeaderType:1;
2669     ULONGLONG Init:1;
2670     ULONGLONG Reserved:2;
2671     ULONGLONG NextEntry:60;
2672   } Header16;
2673   struct {
2674     ULONGLONG Depth:16;
2675     ULONGLONG Sequence:48;
2676     ULONGLONG HeaderType:1;
2677     ULONGLONG Reserved:3;
2678     ULONGLONG NextEntry:60;
2679   } HeaderX64;
2680 } SLIST_HEADER, *PSLIST_HEADER;
2681 
2682 typedef union _SLIST_HEADER32{
2683   ULONGLONG Alignment;
2684   _ANONYMOUS_STRUCT struct {
2685     SLIST_ENTRY32 Next;
2686     WORD Depth;
2687     WORD Sequence;
2688   } DUMMYSTRUCTNAME;
2689 } SLIST_HEADER32, *PSLIST_HEADER32;
2690 
2691 #else
2692 
2693 #define SLIST_ENTRY SINGLE_LIST_ENTRY
2694 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
2695 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
2696 
2697 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32;
2698 
2699 typedef union _SLIST_HEADER {
2700   ULONGLONG Alignment;
2701   _ANONYMOUS_STRUCT struct {
2702     SLIST_ENTRY Next;
2703     WORD Depth;
2704     WORD Sequence;
2705   } DUMMYSTRUCTNAME;
2706 } SLIST_HEADER, *PSLIST_HEADER;
2707 
2708 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32;
2709 
2710 #endif /* defined(_WIN64) */
2711 
2712 #endif /* _SLIST_HEADER_ */
2713 
2714 NTSYSAPI
2715 VOID
2716 NTAPI
2717 RtlInitializeSListHead(
2718   _Out_ PSLIST_HEADER ListHead);
2719 
2720 _Must_inspect_result_
2721 NTSYSAPI
2722 PSLIST_ENTRY
2723 NTAPI
2724 RtlFirstEntrySList(
2725   _In_ const SLIST_HEADER *ListHead);
2726 
2727 NTSYSAPI
2728 PSLIST_ENTRY
2729 NTAPI
2730 RtlInterlockedPopEntrySList(
2731   _Inout_ PSLIST_HEADER ListHead);
2732 
2733 NTSYSAPI
2734 PSLIST_ENTRY
2735 NTAPI
2736 RtlInterlockedPushEntrySList(
2737   _Inout_ PSLIST_HEADER ListHead,
2738   _Inout_ __drv_aliasesMem PSLIST_ENTRY ListEntry);
2739 
2740 NTSYSAPI
2741 PSLIST_ENTRY
2742 NTAPI
2743 RtlInterlockedFlushSList(
2744   _Inout_ PSLIST_HEADER ListHead);
2745 
2746 NTSYSAPI
2747 WORD
2748 NTAPI
2749 RtlQueryDepthSList(
2750   _In_ PSLIST_HEADER ListHead);
2751 
2752 
2753 #define RTL_CONDITION_VARIABLE_INIT {0}
2754 #define RTL_CONDITION_VARIABLE_LOCKMODE_SHARED 0x1
2755 
2756 typedef struct _RTL_CONDITION_VARIABLE {
2757   PVOID Ptr;
2758 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE;
2759 
2760 typedef struct _RTL_CRITICAL_SECTION_DEBUG {
2761   WORD Type;
2762   WORD CreatorBackTraceIndex;
2763   struct _RTL_CRITICAL_SECTION *CriticalSection;
2764   LIST_ENTRY ProcessLocksList;
2765   DWORD EntryCount;
2766   DWORD ContentionCount;
2767   DWORD Flags;
2768   WORD CreatorBackTraceIndexHigh;
2769   WORD SpareWORD;
2770 } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG, RTL_RESOURCE_DEBUG, *PRTL_RESOURCE_DEBUG;
2771 
2772 #include "pshpack8.h"
2773 typedef struct _RTL_CRITICAL_SECTION {
2774   PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
2775   LONG LockCount;
2776   LONG RecursionCount;
2777   HANDLE OwningThread;
2778   HANDLE LockSemaphore;
2779   ULONG_PTR SpinCount;
2780 } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
2781 #include "poppack.h"
2782 
2783 NTSYSAPI
2784 WORD
2785 NTAPI
2786 RtlCaptureStackBackTrace(
2787     IN DWORD FramesToSkip,
2788     IN DWORD FramesToCapture,
2789     OUT PVOID *BackTrace,
2790     OUT PDWORD BackTraceHash OPTIONAL
2791 );
2792 
2793 NTSYSAPI
2794 VOID
2795 NTAPI
2796 RtlCaptureContext(
2797     _Out_ PCONTEXT ContextRecord
2798 );
2799 
2800 NTSYSAPI
2801 PVOID
2802 NTAPI
2803 RtlPcToFileHeader(
2804   _In_ PVOID PcValue,
2805   _Out_ PVOID* BaseOfImage);
2806 
2807 NTSYSAPI
2808 VOID
2809 NTAPI
2810 RtlUnwind(
2811     _In_opt_ PVOID TargetFrame,
2812     _In_opt_ PVOID TargetIp,
2813     _In_opt_ PEXCEPTION_RECORD ExceptionRecord,
2814     _In_ PVOID ReturnValue);
2815 
2816 #define RTL_SRWLOCK_INIT {0}
2817 
2818 typedef struct _RTL_SRWLOCK {
2819   PVOID Ptr;
2820 } RTL_SRWLOCK, *PRTL_SRWLOCK;
2821 
2822 typedef LONG
2823 (NTAPI *PVECTORED_EXCEPTION_HANDLER)(
2824     struct _EXCEPTION_POINTERS *ExceptionInfo
2825 );
2826 
2827 
2828 #define EVENTLOG_SEQUENTIAL_READ    1
2829 #define EVENTLOG_SEEK_READ          2
2830 #define EVENTLOG_FORWARDS_READ      4
2831 #define EVENTLOG_BACKWARDS_READ     8
2832 
2833 #define EVENTLOG_SUCCESS            0
2834 #define EVENTLOG_ERROR_TYPE         1
2835 #define EVENTLOG_WARNING_TYPE       2
2836 #define EVENTLOG_INFORMATION_TYPE   4
2837 #define EVENTLOG_AUDIT_SUCCESS      8
2838 #define EVENTLOG_AUDIT_FAILURE      16
2839 
2840 typedef struct _EVENTLOGRECORD {
2841   DWORD Length;             /* Length of full record, including the data portion */
2842   DWORD Reserved;
2843   DWORD RecordNumber;
2844   DWORD TimeGenerated;
2845   DWORD TimeWritten;
2846   DWORD EventID;
2847   WORD EventType;
2848   WORD NumStrings;          /* Number of strings in the 'Strings' array */
2849   WORD EventCategory;
2850   WORD ReservedFlags;
2851   DWORD ClosingRecordNumber;
2852   DWORD StringOffset;
2853   DWORD UserSidLength;
2854   DWORD UserSidOffset;
2855   DWORD DataLength;         /* Length of the data portion */
2856   DWORD DataOffset;         /* Offset from beginning of record */
2857 /*
2858  * Length-varying data:
2859  *
2860  * WCHAR SourceName[];
2861  * WCHAR ComputerName[];
2862  * SID   UserSid;           // Must be aligned on a DWORD boundary
2863  * WCHAR Strings[];
2864  * BYTE  Data[];
2865  * CHAR  Pad[];             // Padding for DWORD boundary
2866  * DWORD Length;            // Same as the first 'Length' member at the beginning
2867  */
2868 } EVENTLOGRECORD, *PEVENTLOGRECORD;
2869 
2870 
2871 typedef struct _OSVERSIONINFOA {
2872   DWORD dwOSVersionInfoSize;
2873   DWORD dwMajorVersion;
2874   DWORD dwMinorVersion;
2875   DWORD dwBuildNumber;
2876   DWORD dwPlatformId;
2877   CHAR szCSDVersion[128];
2878 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2879 
2880 typedef struct _OSVERSIONINFOW {
2881   DWORD dwOSVersionInfoSize;
2882   DWORD dwMajorVersion;
2883   DWORD dwMinorVersion;
2884   DWORD dwBuildNumber;
2885   DWORD dwPlatformId;
2886   WCHAR szCSDVersion[128];
2887 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2888 
2889 typedef struct _OSVERSIONINFOEXA {
2890   DWORD dwOSVersionInfoSize;
2891   DWORD dwMajorVersion;
2892   DWORD dwMinorVersion;
2893   DWORD dwBuildNumber;
2894   DWORD dwPlatformId;
2895   CHAR szCSDVersion[128];
2896   WORD wServicePackMajor;
2897   WORD wServicePackMinor;
2898   WORD wSuiteMask;
2899   BYTE wProductType;
2900   BYTE wReserved;
2901 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2902 
2903 typedef struct _OSVERSIONINFOEXW {
2904   DWORD dwOSVersionInfoSize;
2905   DWORD dwMajorVersion;
2906   DWORD dwMinorVersion;
2907   DWORD dwBuildNumber;
2908   DWORD dwPlatformId;
2909   WCHAR szCSDVersion[128];
2910   WORD wServicePackMajor;
2911   WORD wServicePackMinor;
2912   WORD wSuiteMask;
2913   BYTE wProductType;
2914   BYTE wReserved;
2915 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2916 
2917 #include <pshpack2.h>
2918 
2919 typedef struct _IMAGE_VXD_HEADER {
2920   WORD e32_magic;
2921   BYTE e32_border;
2922   BYTE e32_worder;
2923   DWORD e32_level;
2924   WORD e32_cpu;
2925   WORD e32_os;
2926   DWORD e32_ver;
2927   DWORD e32_mflags;
2928   DWORD e32_mpages;
2929   DWORD e32_startobj;
2930   DWORD e32_eip;
2931   DWORD e32_stackobj;
2932   DWORD e32_esp;
2933   DWORD e32_pagesize;
2934   DWORD e32_lastpagesize;
2935   DWORD e32_fixupsize;
2936   DWORD e32_fixupsum;
2937   DWORD e32_ldrsize;
2938   DWORD e32_ldrsum;
2939   DWORD e32_objtab;
2940   DWORD e32_objcnt;
2941   DWORD e32_objmap;
2942   DWORD e32_itermap;
2943   DWORD e32_rsrctab;
2944   DWORD e32_rsrccnt;
2945   DWORD e32_restab;
2946   DWORD e32_enttab;
2947   DWORD e32_dirtab;
2948   DWORD e32_dircnt;
2949   DWORD e32_fpagetab;
2950   DWORD e32_frectab;
2951   DWORD e32_impmod;
2952   DWORD e32_impmodcnt;
2953   DWORD e32_impproc;
2954   DWORD e32_pagesum;
2955   DWORD e32_datapage;
2956   DWORD e32_preload;
2957   DWORD e32_nrestab;
2958   DWORD e32_cbnrestab;
2959   DWORD e32_nressum;
2960   DWORD e32_autodata;
2961   DWORD e32_debuginfo;
2962   DWORD e32_debuglen;
2963   DWORD e32_instpreload;
2964   DWORD e32_instdemand;
2965   DWORD e32_heapsize;
2966   BYTE e32_res3[12];
2967   DWORD e32_winresoff;
2968   DWORD e32_winreslen;
2969   WORD e32_devid;
2970   WORD e32_ddkver;
2971 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
2972 
2973 typedef struct _IMAGE_DOS_HEADER {
2974   WORD e_magic;
2975   WORD e_cblp;
2976   WORD e_cp;
2977   WORD e_crlc;
2978   WORD e_cparhdr;
2979   WORD e_minalloc;
2980   WORD e_maxalloc;
2981   WORD e_ss;
2982   WORD e_sp;
2983   WORD e_csum;
2984   WORD e_ip;
2985   WORD e_cs;
2986   WORD e_lfarlc;
2987   WORD e_ovno;
2988   WORD e_res[4];
2989   WORD e_oemid;
2990   WORD e_oeminfo;
2991   WORD e_res2[10];
2992   LONG e_lfanew;
2993 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
2994 
2995 typedef struct _IMAGE_OS2_HEADER {
2996   WORD ne_magic;
2997   CHAR ne_ver;
2998   CHAR ne_rev;
2999   WORD ne_enttab;
3000   WORD ne_cbenttab;
3001   LONG ne_crc;
3002   WORD ne_flags;
3003   WORD ne_autodata;
3004   WORD ne_heap;
3005   WORD ne_stack;
3006   LONG ne_csip;
3007   LONG ne_sssp;
3008   WORD ne_cseg;
3009   WORD ne_cmod;
3010   WORD ne_cbnrestab;
3011   WORD ne_segtab;
3012   WORD ne_rsrctab;
3013   WORD ne_restab;
3014   WORD ne_modtab;
3015   WORD ne_imptab;
3016   LONG ne_nrestab;
3017   WORD ne_cmovent;
3018   WORD ne_align;
3019   WORD ne_cres;
3020   BYTE ne_exetyp;
3021   BYTE ne_flagsothers;
3022   WORD ne_pretthunks;
3023   WORD ne_psegrefbytes;
3024   WORD ne_swaparea;
3025   WORD ne_expver;
3026 } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
3027 
3028 #include <poppack.h>
3029 
3030 typedef struct _IMAGE_FILE_HEADER {
3031   WORD Machine;
3032   WORD NumberOfSections;
3033   DWORD TimeDateStamp;
3034   DWORD PointerToSymbolTable;
3035   DWORD NumberOfSymbols;
3036   WORD SizeOfOptionalHeader;
3037   WORD Characteristics;
3038 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
3039 
3040 typedef struct _IMAGE_DATA_DIRECTORY {
3041   DWORD VirtualAddress;
3042   DWORD Size;
3043 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
3044 
3045 typedef struct _IMAGE_OPTIONAL_HEADER32 {
3046   WORD Magic;
3047   BYTE MajorLinkerVersion;
3048   BYTE MinorLinkerVersion;
3049   DWORD SizeOfCode;
3050   DWORD SizeOfInitializedData;
3051   DWORD SizeOfUninitializedData;
3052   DWORD AddressOfEntryPoint;
3053   DWORD BaseOfCode;
3054   DWORD BaseOfData;
3055   DWORD ImageBase;
3056   DWORD SectionAlignment;
3057   DWORD FileAlignment;
3058   WORD MajorOperatingSystemVersion;
3059   WORD MinorOperatingSystemVersion;
3060   WORD MajorImageVersion;
3061   WORD MinorImageVersion;
3062   WORD MajorSubsystemVersion;
3063   WORD MinorSubsystemVersion;
3064   DWORD Win32VersionValue;
3065   DWORD SizeOfImage;
3066   DWORD SizeOfHeaders;
3067   DWORD CheckSum;
3068   WORD Subsystem;
3069   WORD DllCharacteristics;
3070   DWORD SizeOfStackReserve;
3071   DWORD SizeOfStackCommit;
3072   DWORD SizeOfHeapReserve;
3073   DWORD SizeOfHeapCommit;
3074   DWORD LoaderFlags;
3075   DWORD NumberOfRvaAndSizes;
3076   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
3077 } IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
3078 
3079 typedef struct _IMAGE_OPTIONAL_HEADER64 {
3080   WORD Magic;
3081   BYTE MajorLinkerVersion;
3082   BYTE MinorLinkerVersion;
3083   DWORD SizeOfCode;
3084   DWORD SizeOfInitializedData;
3085   DWORD SizeOfUninitializedData;
3086   DWORD AddressOfEntryPoint;
3087   DWORD BaseOfCode;
3088   ULONGLONG ImageBase;
3089   DWORD SectionAlignment;
3090   DWORD FileAlignment;
3091   WORD MajorOperatingSystemVersion;
3092   WORD MinorOperatingSystemVersion;
3093   WORD MajorImageVersion;
3094   WORD MinorImageVersion;
3095   WORD MajorSubsystemVersion;
3096   WORD MinorSubsystemVersion;
3097   DWORD Win32VersionValue;
3098   DWORD SizeOfImage;
3099   DWORD SizeOfHeaders;
3100   DWORD CheckSum;
3101   WORD Subsystem;
3102   WORD DllCharacteristics;
3103   ULONGLONG SizeOfStackReserve;
3104   ULONGLONG SizeOfStackCommit;
3105   ULONGLONG SizeOfHeapReserve;
3106   ULONGLONG SizeOfHeapCommit;
3107   DWORD LoaderFlags;
3108   DWORD NumberOfRvaAndSizes;
3109   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
3110 } IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
3111 
3112 typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
3113   WORD Magic;
3114   BYTE MajorLinkerVersion;
3115   BYTE MinorLinkerVersion;
3116   DWORD SizeOfCode;
3117   DWORD SizeOfInitializedData;
3118   DWORD SizeOfUninitializedData;
3119   DWORD AddressOfEntryPoint;
3120   DWORD BaseOfCode;
3121   DWORD BaseOfData;
3122   DWORD BaseOfBss;
3123   DWORD GprMask;
3124   DWORD CprMask[4];
3125   DWORD GpValue;
3126 } IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER;
3127 
3128 typedef struct _IMAGE_NT_HEADERS32 {
3129   DWORD Signature;
3130   IMAGE_FILE_HEADER FileHeader;
3131   IMAGE_OPTIONAL_HEADER32 OptionalHeader;
3132 } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
3133 
3134 typedef struct _IMAGE_NT_HEADERS64 {
3135   DWORD Signature;
3136   IMAGE_FILE_HEADER FileHeader;
3137   IMAGE_OPTIONAL_HEADER64 OptionalHeader;
3138 } IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
3139 
3140 #ifdef _WIN64
3141 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
3142 typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
3143 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
3144 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
3145 #else
3146 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
3147 typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
3148 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
3149 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
3150 #endif
3151 
3152 typedef struct _IMAGE_ROM_HEADERS {
3153   IMAGE_FILE_HEADER FileHeader;
3154   IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
3155 } IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS;
3156 
3157 typedef struct _IMAGE_SECTION_HEADER {
3158   BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
3159   union {
3160     DWORD PhysicalAddress;
3161     DWORD VirtualSize;
3162   } Misc;
3163   DWORD VirtualAddress;
3164   DWORD SizeOfRawData;
3165   DWORD PointerToRawData;
3166   DWORD PointerToRelocations;
3167   DWORD PointerToLinenumbers;
3168   WORD NumberOfRelocations;
3169   WORD NumberOfLinenumbers;
3170   DWORD Characteristics;
3171 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
3172 
3173 #include <pshpack2.h>
3174 
3175 typedef struct _IMAGE_SYMBOL {
3176   union {
3177     BYTE ShortName[8];
3178     struct {
3179       DWORD Short;
3180       DWORD Long;
3181     } Name;
3182     PBYTE LongName[2];
3183   } N;
3184   DWORD Value;
3185   SHORT SectionNumber;
3186   WORD Type;
3187   BYTE StorageClass;
3188   BYTE NumberOfAuxSymbols;
3189 } IMAGE_SYMBOL, *PIMAGE_SYMBOL;
3190 
3191 typedef struct _IMAGE_LINENUMBER {
3192   union {
3193     DWORD SymbolTableIndex;
3194     DWORD VirtualAddress;
3195   } Type;
3196   WORD Linenumber;
3197 } IMAGE_LINENUMBER, UNALIGNED *PIMAGE_LINENUMBER;
3198 
3199 typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF {
3200   BYTE bAuxType;
3201   BYTE bReserved;
3202   DWORD SymbolTableIndex;
3203   BYTE rgbReserved[12];
3204 } IMAGE_AUX_SYMBOL_TOKEN_DEF, UNALIGNED *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
3205 
3206 typedef union _IMAGE_AUX_SYMBOL {
3207   struct {
3208     DWORD TagIndex;
3209     union {
3210       struct {
3211         WORD Linenumber;
3212         WORD Size;
3213       } LnSz;
3214       DWORD TotalSize;
3215     } Misc;
3216     union {
3217       struct {
3218         DWORD PointerToLinenumber;
3219         DWORD PointerToNextFunction;
3220       } Function;
3221       struct {
3222         WORD Dimension[4];
3223       } Array;
3224     } FcnAry;
3225     WORD TvIndex;
3226   } Sym;
3227   struct {
3228     BYTE Name[IMAGE_SIZEOF_SYMBOL];
3229   } File;
3230   struct {
3231     DWORD Length;
3232     WORD NumberOfRelocations;
3233     WORD NumberOfLinenumbers;
3234     DWORD CheckSum;
3235     SHORT Number;
3236     BYTE Selection;
3237     BYTE bReserved;
3238     SHORT HighNumber;
3239   } Section;
3240   IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
3241   struct {
3242     DWORD crc;
3243     BYTE rgbReserved[14];
3244   } CRC;
3245 } IMAGE_AUX_SYMBOL, *PIMAGE_AUX_SYMBOL;
3246 
3247 typedef struct _IMAGE_RELOCATION {
3248   _ANONYMOUS_UNION union {
3249     DWORD VirtualAddress;
3250     DWORD RelocCount;
3251   } DUMMYUNIONNAME;
3252   DWORD SymbolTableIndex;
3253   WORD Type;
3254 } IMAGE_RELOCATION, UNALIGNED *PIMAGE_RELOCATION;
3255 
3256 #include <poppack.h>
3257 
3258 #ifndef __IMAGE_COR20_HEADER_DEFINED__
3259 #define __IMAGE_COR20_HEADER_DEFINED__
3260 
3261 typedef enum ReplacesCorHdrNumericDefines {
3262   COMIMAGE_FLAGS_ILONLY = 0x00000001,
3263   COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002,
3264   COMIMAGE_FLAGS_IL_LIBRARY = 0x00000004,
3265   COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008,
3266   COMIMAGE_FLAGS_NATIVE_ENTRYPOINT = 0x00000010,
3267   COMIMAGE_FLAGS_TRACKDEBUGDATA = 0x00010000,
3268   COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000,
3269   COR_VERSION_MAJOR_V2 = 2,
3270   COR_VERSION_MAJOR = COR_VERSION_MAJOR_V2,
3271   COR_VERSION_MINOR = 0,
3272   COR_DELETED_NAME_LENGTH = 8,
3273   COR_VTABLEGAP_NAME_LENGTH = 8,
3274   NATIVE_TYPE_MAX_CB = 1,
3275   COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 0xFF,
3276   IMAGE_COR_MIH_METHODRVA = 0x01,
3277   IMAGE_COR_MIH_EHRVA = 0x02,
3278   IMAGE_COR_MIH_BASICBLOCK = 0x08,
3279   COR_VTABLE_32BIT = 0x01,
3280   COR_VTABLE_64BIT = 0x02,
3281   COR_VTABLE_FROM_UNMANAGED = 0x04,
3282   COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN = 0x08,
3283   COR_VTABLE_CALL_MOST_DERIVED = 0x10,
3284   IMAGE_COR_EATJ_THUNK_SIZE = 32,
3285   MAX_CLASS_NAME = 1024,
3286   MAX_PACKAGE_NAME = 1024
3287 } ReplacesCorHdrNumericDefines;
3288 
3289 typedef struct IMAGE_COR20_HEADER {
3290   DWORD cb;
3291   WORD MajorRuntimeVersion;
3292   WORD MinorRuntimeVersion;
3293   IMAGE_DATA_DIRECTORY MetaData;
3294   DWORD Flags;
3295   _ANONYMOUS_UNION union {
3296     DWORD EntryPointToken;
3297     DWORD EntryPointRVA;
3298   } DUMMYUNIONNAME;
3299   IMAGE_DATA_DIRECTORY Resources;
3300   IMAGE_DATA_DIRECTORY StrongNameSignature;
3301   IMAGE_DATA_DIRECTORY CodeManagerTable;
3302   IMAGE_DATA_DIRECTORY VTableFixups;
3303   IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
3304   IMAGE_DATA_DIRECTORY ManagedNativeHeader;
3305 } IMAGE_COR20_HEADER, *PIMAGE_COR20_HEADER;
3306 
3307 #endif /* __IMAGE_COR20_HEADER_DEFINED__ */
3308 
3309 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
3310   DWORD NumberOfSymbols;
3311   DWORD LvaToFirstSymbol;
3312   DWORD NumberOfLinenumbers;
3313   DWORD LvaToFirstLinenumber;
3314   DWORD RvaToFirstByteOfCode;
3315   DWORD RvaToLastByteOfCode;
3316   DWORD RvaToFirstByteOfData;
3317   DWORD RvaToLastByteOfData;
3318 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
3319 
3320 typedef struct _IMAGE_BASE_RELOCATION {
3321   DWORD VirtualAddress;
3322   DWORD SizeOfBlock;
3323 } IMAGE_BASE_RELOCATION, UNALIGNED *PIMAGE_BASE_RELOCATION;
3324 
3325 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
3326   BYTE Name[16];
3327   BYTE Date[12];
3328   BYTE UserID[6];
3329   BYTE GroupID[6];
3330   BYTE Mode[8];
3331   BYTE Size[10];
3332   BYTE EndHeader[2];
3333 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
3334 
3335 typedef struct _IMAGE_EXPORT_DIRECTORY {
3336   DWORD Characteristics;
3337   DWORD TimeDateStamp;
3338   WORD MajorVersion;
3339   WORD MinorVersion;
3340   DWORD Name;
3341   DWORD Base;
3342   DWORD NumberOfFunctions;
3343   DWORD NumberOfNames;
3344   DWORD AddressOfFunctions;
3345   DWORD AddressOfNames;
3346   DWORD AddressOfNameOrdinals;
3347 } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
3348 
3349 typedef struct _IMAGE_IMPORT_BY_NAME {
3350   WORD Hint;
3351   BYTE Name[1];
3352 } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
3353 
3354 #include <pshpack8.h>
3355 typedef struct _IMAGE_THUNK_DATA64 {
3356   union {
3357     ULONGLONG ForwarderString;
3358     ULONGLONG Function;
3359     ULONGLONG Ordinal;
3360     ULONGLONG AddressOfData;
3361   } u1;
3362 } IMAGE_THUNK_DATA64, *PIMAGE_THUNK_DATA64;
3363 #include <poppack.h>
3364 
3365 typedef struct _IMAGE_THUNK_DATA32 {
3366   union {
3367     DWORD ForwarderString;
3368     DWORD Function;
3369     DWORD Ordinal;
3370     DWORD AddressOfData;
3371   } u1;
3372 } IMAGE_THUNK_DATA32, *PIMAGE_THUNK_DATA32;
3373 
3374 #define IMAGE_ORDINAL_FLAG64 0x8000000000000000ULL
3375 #define IMAGE_ORDINAL_FLAG32 0x80000000
3376 #define IMAGE_ORDINAL64(Ordinal) (Ordinal & 0xffff)
3377 #define IMAGE_ORDINAL32(Ordinal) (Ordinal & 0xffff)
3378 #define IMAGE_SNAP_BY_ORDINAL64(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG64)!=0)
3379 #define IMAGE_SNAP_BY_ORDINAL32(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG32)!=0)
3380 
3381 typedef VOID
3382 (NTAPI *PIMAGE_TLS_CALLBACK)(PVOID DllHandle,DWORD Reason,PVOID Reserved);
3383 
3384 typedef struct _IMAGE_TLS_DIRECTORY64 {
3385   ULONGLONG StartAddressOfRawData;
3386   ULONGLONG EndAddressOfRawData;
3387   ULONGLONG AddressOfIndex;
3388   ULONGLONG AddressOfCallBacks;
3389   DWORD SizeOfZeroFill;
3390   DWORD Characteristics;
3391 } IMAGE_TLS_DIRECTORY64, *PIMAGE_TLS_DIRECTORY64;
3392 
3393 typedef struct _IMAGE_TLS_DIRECTORY32 {
3394   DWORD StartAddressOfRawData;
3395   DWORD EndAddressOfRawData;
3396   DWORD AddressOfIndex;
3397   DWORD AddressOfCallBacks;
3398   DWORD SizeOfZeroFill;
3399   DWORD Characteristics;
3400 } IMAGE_TLS_DIRECTORY32, *PIMAGE_TLS_DIRECTORY32;
3401 
3402 #ifdef _WIN64
3403 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG64
3404 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL64(Ordinal)
3405 typedef IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
3406 typedef PIMAGE_THUNK_DATA64 PIMAGE_THUNK_DATA;
3407 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL64(Ordinal)
3408 typedef IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
3409 typedef PIMAGE_TLS_DIRECTORY64 PIMAGE_TLS_DIRECTORY;
3410 #else
3411 #define IMAGE_ORDINAL_FLAG IMAGE_ORDINAL_FLAG32
3412 #define IMAGE_ORDINAL(Ordinal) IMAGE_ORDINAL32(Ordinal)
3413 typedef IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
3414 typedef PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA;
3415 #define IMAGE_SNAP_BY_ORDINAL(Ordinal) IMAGE_SNAP_BY_ORDINAL32(Ordinal)
3416 typedef IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
3417 typedef PIMAGE_TLS_DIRECTORY32 PIMAGE_TLS_DIRECTORY;
3418 #endif
3419 
3420 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
3421   _ANONYMOUS_UNION union {
3422     DWORD Characteristics;
3423     DWORD OriginalFirstThunk;
3424   } DUMMYUNIONNAME;
3425   DWORD TimeDateStamp;
3426   DWORD ForwarderChain;
3427   DWORD Name;
3428   DWORD FirstThunk;
3429 } IMAGE_IMPORT_DESCRIPTOR, UNALIGNED *PIMAGE_IMPORT_DESCRIPTOR;
3430 
3431 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR {
3432   DWORD TimeDateStamp;
3433   WORD OffsetModuleName;
3434   WORD NumberOfModuleForwarderRefs;
3435 } IMAGE_BOUND_IMPORT_DESCRIPTOR, *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
3436 
3437 typedef struct _IMAGE_BOUND_FORWARDER_REF {
3438   DWORD TimeDateStamp;
3439   WORD OffsetModuleName;
3440   WORD Reserved;
3441 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
3442 
3443 typedef struct _IMAGE_DELAYLOAD_DESCRIPTOR {
3444   union {
3445     DWORD AllAttributes;
3446     struct {
3447       DWORD RvaBased:1;
3448       DWORD ReservedAttributes:31;
3449     };
3450   } Attributes;
3451   DWORD DllNameRVA;
3452   DWORD ModuleHandleRVA;
3453   DWORD ImportAddressTableRVA;
3454   DWORD ImportNameTableRVA;
3455   DWORD BoundImportAddressTableRVA;
3456   DWORD UnloadInformationTableRVA;
3457   DWORD TimeDateStamp;
3458 } IMAGE_DELAYLOAD_DESCRIPTOR, *PIMAGE_DELAYLOAD_DESCRIPTOR;
3459 
3460 typedef const IMAGE_DELAYLOAD_DESCRIPTOR *PCIMAGE_DELAYLOAD_DESCRIPTOR;
3461 
3462 typedef struct _IMAGE_RESOURCE_DIRECTORY {
3463   DWORD Characteristics;
3464   DWORD TimeDateStamp;
3465   WORD MajorVersion;
3466   WORD MinorVersion;
3467   WORD NumberOfNamedEntries;
3468   WORD NumberOfIdEntries;
3469 } IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
3470 
3471 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
3472   _ANONYMOUS_UNION union {
3473     _ANONYMOUS_STRUCT struct {
3474       DWORD NameOffset:31;
3475       DWORD NameIsString:1;
3476     } DUMMYSTRUCTNAME;
3477     DWORD Name;
3478     WORD Id;
3479   } DUMMYUNIONNAME;
3480   _ANONYMOUS_UNION union {
3481     DWORD OffsetToData;
3482     _ANONYMOUS_STRUCT struct {
3483       DWORD OffsetToDirectory:31;
3484       DWORD DataIsDirectory:1;
3485     } DUMMYSTRUCTNAME2;
3486   } DUMMYUNIONNAME2;
3487 } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
3488 
3489 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
3490   WORD Length;
3491   CHAR NameString[1];
3492 } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;
3493 
3494 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
3495   WORD Length;
3496   WCHAR NameString[1];
3497 } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;
3498 
3499 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
3500   DWORD OffsetToData;
3501   DWORD Size;
3502   DWORD CodePage;
3503   DWORD Reserved;
3504 } IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;
3505 
3506 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32 {
3507   DWORD Size;
3508   DWORD TimeDateStamp;
3509   WORD MajorVersion;
3510   WORD MinorVersion;
3511   DWORD GlobalFlagsClear;
3512   DWORD GlobalFlagsSet;
3513   DWORD CriticalSectionDefaultTimeout;
3514   DWORD DeCommitFreeBlockThreshold;
3515   DWORD DeCommitTotalFreeThreshold;
3516   DWORD LockPrefixTable;
3517   DWORD MaximumAllocationSize;
3518   DWORD VirtualMemoryThreshold;
3519   DWORD ProcessHeapFlags;
3520   DWORD ProcessAffinityMask;
3521   WORD CSDVersion;
3522   WORD Reserved1;
3523   DWORD EditList;
3524   DWORD SecurityCookie;
3525   DWORD SEHandlerTable;
3526   DWORD SEHandlerCount;
3527 } IMAGE_LOAD_CONFIG_DIRECTORY32, *PIMAGE_LOAD_CONFIG_DIRECTORY32;
3528 
3529 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64 {
3530   DWORD Size;
3531   DWORD TimeDateStamp;
3532   WORD MajorVersion;
3533   WORD MinorVersion;
3534   DWORD GlobalFlagsClear;
3535   DWORD GlobalFlagsSet;
3536   DWORD CriticalSectionDefaultTimeout;
3537   ULONGLONG DeCommitFreeBlockThreshold;
3538   ULONGLONG DeCommitTotalFreeThreshold;
3539   ULONGLONG LockPrefixTable;
3540   ULONGLONG MaximumAllocationSize;
3541   ULONGLONG VirtualMemoryThreshold;
3542   ULONGLONG ProcessAffinityMask;
3543   DWORD ProcessHeapFlags;
3544   WORD CSDVersion;
3545   WORD Reserved1;
3546   ULONGLONG EditList;
3547   ULONGLONG SecurityCookie;
3548   ULONGLONG SEHandlerTable;
3549   ULONGLONG SEHandlerCount;
3550 } IMAGE_LOAD_CONFIG_DIRECTORY64, *PIMAGE_LOAD_CONFIG_DIRECTORY64;
3551 
3552 #ifdef _WIN64
3553 typedef IMAGE_LOAD_CONFIG_DIRECTORY64 IMAGE_LOAD_CONFIG_DIRECTORY;
3554 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64 PIMAGE_LOAD_CONFIG_DIRECTORY;
3555 #else
3556 typedef IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY;
3557 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY;
3558 #endif
3559 
3560 typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY {
3561   DWORD BeginAddress;
3562   DWORD EndAddress;
3563   DWORD UnwindInfoAddress;
3564 } IMAGE_RUNTIME_FUNCTION_ENTRY, *PIMAGE_RUNTIME_FUNCTION_ENTRY;
3565 
3566 typedef struct _IMAGE_DEBUG_DIRECTORY {
3567   DWORD Characteristics;
3568   DWORD TimeDateStamp;
3569   WORD MajorVersion;
3570   WORD MinorVersion;
3571   DWORD Type;
3572   DWORD SizeOfData;
3573   DWORD AddressOfRawData;
3574   DWORD PointerToRawData;
3575 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
3576 
3577 typedef struct _FPO_DATA {
3578   DWORD ulOffStart;
3579   DWORD cbProcSize;
3580   DWORD cdwLocals;
3581   WORD cdwParams;
3582   WORD cbProlog:8;
3583   WORD cbRegs:3;
3584   WORD fHasSEH:1;
3585   WORD fUseBP:1;
3586   WORD reserved:1;
3587   WORD cbFrame:2;
3588 } FPO_DATA, *PFPO_DATA;
3589 
3590 typedef struct _IMAGE_DEBUG_MISC {
3591   DWORD DataType;
3592   DWORD Length;
3593   BOOLEAN Unicode;
3594   BYTE Reserved[3];
3595   BYTE Data[1];
3596 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
3597 
3598 typedef struct _IMAGE_FUNCTION_ENTRY {
3599   DWORD StartingAddress;
3600   DWORD EndingAddress;
3601   DWORD EndOfPrologue;
3602 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
3603 
3604 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
3605   WORD Signature;
3606   WORD Flags;
3607   WORD Machine;
3608   WORD Characteristics;
3609   DWORD TimeDateStamp;
3610   DWORD CheckSum;
3611   DWORD ImageBase;
3612   DWORD SizeOfImage;
3613   DWORD NumberOfSections;
3614   DWORD ExportedNamesSize;
3615   DWORD DebugDirectorySize;
3616   DWORD SectionAlignment;
3617   DWORD Reserved[2];
3618 } IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER;
3619 
3620 typedef enum _CM_SERVICE_NODE_TYPE {
3621   DriverType = SERVICE_KERNEL_DRIVER,
3622   FileSystemType = SERVICE_FILE_SYSTEM_DRIVER,
3623   Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS,
3624   Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
3625   AdapterType = SERVICE_ADAPTER,
3626   RecognizerType = SERVICE_RECOGNIZER_DRIVER
3627 } SERVICE_NODE_TYPE;
3628 
3629 typedef enum _CM_SERVICE_LOAD_TYPE {
3630   BootLoad = SERVICE_BOOT_START,
3631   SystemLoad = SERVICE_SYSTEM_START,
3632   AutoLoad = SERVICE_AUTO_START,
3633   DemandLoad = SERVICE_DEMAND_START,
3634   DisableLoad = SERVICE_DISABLED
3635 } SERVICE_LOAD_TYPE;
3636 
3637 typedef enum _CM_ERROR_CONTROL_TYPE {
3638   IgnoreError = SERVICE_ERROR_IGNORE,
3639   NormalError = SERVICE_ERROR_NORMAL,
3640   SevereError = SERVICE_ERROR_SEVERE,
3641   CriticalError = SERVICE_ERROR_CRITICAL
3642 } SERVICE_ERROR_TYPE;
3643 
3644 typedef struct _NT_TIB {
3645   struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
3646   PVOID StackBase;
3647   PVOID StackLimit;
3648   PVOID SubSystemTib;
3649   _ANONYMOUS_UNION union {
3650     PVOID FiberData;
3651     DWORD Version;
3652   } DUMMYUNIONNAME;
3653   PVOID ArbitraryUserPointer;
3654   struct _NT_TIB *Self;
3655 } NT_TIB,*PNT_TIB;
3656 
3657 typedef struct _NT_TIB32 {
3658   DWORD ExceptionList;
3659   DWORD StackBase;
3660   DWORD StackLimit;
3661   DWORD SubSystemTib;
3662   _ANONYMOUS_UNION union {
3663     DWORD FiberData;
3664     DWORD Version;
3665   } DUMMYUNIONNAME;
3666   DWORD ArbitraryUserPointer;
3667   DWORD Self;
3668 } NT_TIB32,*PNT_TIB32;
3669 
3670 typedef struct _NT_TIB64 {
3671   DWORD64 ExceptionList;
3672   DWORD64 StackBase;
3673   DWORD64 StackLimit;
3674   DWORD64 SubSystemTib;
3675   _ANONYMOUS_UNION union {
3676     DWORD64 FiberData;
3677     DWORD Version;
3678   } DUMMYUNIONNAME;
3679   DWORD64 ArbitraryUserPointer;
3680   DWORD64 Self;
3681 } NT_TIB64,*PNT_TIB64;
3682 
3683 typedef struct _REPARSE_GUID_DATA_BUFFER {
3684   DWORD ReparseTag;
3685   WORD ReparseDataLength;
3686   WORD Reserved;
3687   GUID ReparseGuid;
3688   struct {
3689     BYTE DataBuffer[1];
3690   } GenericReparseBuffer;
3691 } REPARSE_GUID_DATA_BUFFER, *PREPARSE_GUID_DATA_BUFFER;
3692 
3693 typedef struct _REPARSE_POINT_INFORMATION {
3694     WORD   ReparseDataLength;
3695     WORD   UnparsedNameLength;
3696 } REPARSE_POINT_INFORMATION, *PREPARSE_POINT_INFORMATION;
3697 
3698 typedef union _FILE_SEGMENT_ELEMENT {
3699   PVOID64 Buffer;
3700   ULONGLONG Alignment;
3701 } FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
3702 
3703 /* JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags constants */
3704 #define JOB_OBJECT_LIMIT_WORKINGSET                 0x0001
3705 #define JOB_OBJECT_LIMIT_PROCESS_TIME               0x0002
3706 #define JOB_OBJECT_LIMIT_JOB_TIME                   0x0004
3707 #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS             0x0008
3708 #define JOB_OBJECT_LIMIT_AFFINITY                   0x0010
3709 #define JOB_OBJECT_LIMIT_PRIORITY_CLASS             0x0020
3710 #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME          0x0040
3711 #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS           0x0080
3712 #define JOB_OBJECT_LIMIT_PROCESS_MEMORY             0x0100
3713 #define JOB_OBJECT_LIMIT_JOB_MEMORY                 0x0200
3714 #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x0400
3715 #define JOB_OBJECT_LIMIT_BREAKAWAY_OK               0x0800
3716 #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK        0x1000
3717 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE          0x2000
3718 
3719 /* JOBOBJECT_BASIC_UI_RESTRICTIONS.UIRestrictionsClass constants */
3720 #define JOB_OBJECT_UILIMIT_HANDLES          0x0001
3721 #define JOB_OBJECT_UILIMIT_READCLIPBOARD    0x0002
3722 #define JOB_OBJECT_UILIMIT_WRITECLIPBOARD   0x0004
3723 #define JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS 0x0008
3724 #define JOB_OBJECT_UILIMIT_DISPLAYSETTINGS  0x0010
3725 #define JOB_OBJECT_UILIMIT_GLOBALATOMS      0x0020
3726 #define JOB_OBJECT_UILIMIT_DESKTOP          0x0040
3727 #define JOB_OBJECT_UILIMIT_EXITWINDOWS      0x0080
3728 
3729 /* JOBOBJECT_SECURITY_LIMIT_INFORMATION.SecurityLimitFlags constants */
3730 #define JOB_OBJECT_SECURITY_NO_ADMIN          0x0001
3731 #define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN  0x0002
3732 #define JOB_OBJECT_SECURITY_ONLY_TOKEN        0x0004
3733 #define JOB_OBJECT_SECURITY_FILTER_TOKENS     0x0008
3734 
3735 /* JOBOBJECT_END_OF_JOB_TIME_INFORMATION.EndOfJobTimeAction constants */
3736 #define JOB_OBJECT_TERMINATE_AT_END_OF_JOB  0
3737 #define JOB_OBJECT_POST_AT_END_OF_JOB       1
3738 
3739 #define JOB_OBJECT_MSG_END_OF_JOB_TIME        1
3740 #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME    2
3741 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT   3
3742 #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO    4
3743 #define JOB_OBJECT_MSG_NEW_PROCESS            6
3744 #define JOB_OBJECT_MSG_EXIT_PROCESS           7
3745 #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS  8
3746 #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT   9
3747 #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT       10
3748 
3749 #define JOB_OBJECT_ASSIGN_PROCESS           1
3750 #define JOB_OBJECT_SET_ATTRIBUTES           2
3751 #define JOB_OBJECT_QUERY                    4
3752 #define JOB_OBJECT_TERMINATE                8
3753 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES  16
3754 #define JOB_OBJECT_ALL_ACCESS               (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|31)
3755 
3756 typedef enum _JOBOBJECTINFOCLASS {
3757   JobObjectBasicAccountingInformation = 1,
3758   JobObjectBasicLimitInformation,
3759   JobObjectBasicProcessIdList,
3760   JobObjectBasicUIRestrictions,
3761   JobObjectSecurityLimitInformation,
3762   JobObjectEndOfJobTimeInformation,
3763   JobObjectAssociateCompletionPortInformation,
3764   JobObjectBasicAndIoAccountingInformation,
3765   JobObjectExtendedLimitInformation,
3766   JobObjectJobSetInformation,
3767   JobObjectGroupInformation,
3768   MaxJobObjectInfoClass
3769 } JOBOBJECTINFOCLASS;
3770 
3771 typedef struct _JOB_SET_ARRAY {
3772   HANDLE JobHandle;
3773   DWORD MemberLevel;
3774   DWORD Flags;
3775 } JOB_SET_ARRAY, *PJOB_SET_ARRAY;
3776 
3777 typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
3778   LARGE_INTEGER TotalUserTime;
3779   LARGE_INTEGER TotalKernelTime;
3780   LARGE_INTEGER ThisPeriodTotalUserTime;
3781   LARGE_INTEGER ThisPeriodTotalKernelTime;
3782   DWORD TotalPageFaultCount;
3783   DWORD TotalProcesses;
3784   DWORD ActiveProcesses;
3785   DWORD TotalTerminatedProcesses;
3786 } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION,*PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
3787 
3788 typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
3789   LARGE_INTEGER PerProcessUserTimeLimit;
3790   LARGE_INTEGER PerJobUserTimeLimit;
3791   DWORD LimitFlags;
3792   SIZE_T MinimumWorkingSetSize;
3793   SIZE_T MaximumWorkingSetSize;
3794   DWORD ActiveProcessLimit;
3795   ULONG_PTR Affinity;
3796   DWORD PriorityClass;
3797   DWORD SchedulingClass;
3798 } JOBOBJECT_BASIC_LIMIT_INFORMATION,*PJOBOBJECT_BASIC_LIMIT_INFORMATION;
3799 
3800 typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
3801   DWORD NumberOfAssignedProcesses;
3802   DWORD NumberOfProcessIdsInList;
3803   ULONG_PTR ProcessIdList[1];
3804 } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
3805 
3806 typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
3807   DWORD UIRestrictionsClass;
3808 } JOBOBJECT_BASIC_UI_RESTRICTIONS,*PJOBOBJECT_BASIC_UI_RESTRICTIONS;
3809 
3810 typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
3811   DWORD SecurityLimitFlags;
3812   HANDLE JobToken;
3813   PTOKEN_GROUPS SidsToDisable;
3814   PTOKEN_PRIVILEGES PrivilegesToDelete;
3815   PTOKEN_GROUPS RestrictedSids;
3816 } JOBOBJECT_SECURITY_LIMIT_INFORMATION,*PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
3817 
3818 typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
3819   DWORD EndOfJobTimeAction;
3820 } JOBOBJECT_END_OF_JOB_TIME_INFORMATION,*PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
3821 
3822 typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
3823   PVOID CompletionKey;
3824   HANDLE CompletionPort;
3825 } JOBOBJECT_ASSOCIATE_COMPLETION_PORT,*PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
3826 
3827 typedef struct _JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
3828   JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
3829   IO_COUNTERS IoInfo;
3830 } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION,*PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
3831 
3832 typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
3833   JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
3834   IO_COUNTERS IoInfo;
3835   SIZE_T ProcessMemoryLimit;
3836   SIZE_T JobMemoryLimit;
3837   SIZE_T PeakProcessMemoryUsed;
3838   SIZE_T PeakJobMemoryUsed;
3839 } JOBOBJECT_EXTENDED_LIMIT_INFORMATION,*PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
3840 
3841 typedef struct _JOBOBJECT_JOBSET_INFORMATION {
3842   DWORD MemberLevel;
3843 } JOBOBJECT_JOBSET_INFORMATION,*PJOBOBJECT_JOBSET_INFORMATION;
3844 
3845 /* Fixme: Making these defines conditional on WINVER will break ddk includes */
3846 #if 1 /* (WINVER >= 0x0500) */
3847 
3848 #define ES_SYSTEM_REQUIRED                0x00000001
3849 #define ES_DISPLAY_REQUIRED               0x00000002
3850 #define ES_USER_PRESENT                   0x00000004
3851 #define ES_CONTINUOUS                     0x80000000
3852 
3853 typedef enum _LATENCY_TIME {
3854   LT_DONT_CARE,
3855   LT_LOWEST_LATENCY
3856 } LATENCY_TIME, *PLATENCY_TIME;
3857 
3858 typedef enum _SYSTEM_POWER_STATE {
3859   PowerSystemUnspecified = 0,
3860   PowerSystemWorking,
3861   PowerSystemSleeping1,
3862   PowerSystemSleeping2,
3863   PowerSystemSleeping3,
3864   PowerSystemHibernate,
3865   PowerSystemShutdown,
3866   PowerSystemMaximum
3867 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
3868 
3869 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
3870 
3871 typedef enum {
3872   PowerActionNone = 0,
3873   PowerActionReserved,
3874   PowerActionSleep,
3875   PowerActionHibernate,
3876   PowerActionShutdown,
3877   PowerActionShutdownReset,
3878   PowerActionShutdownOff,
3879   PowerActionWarmEject
3880 } POWER_ACTION, *PPOWER_ACTION;
3881 
3882 typedef enum _DEVICE_POWER_STATE {
3883   PowerDeviceUnspecified = 0,
3884   PowerDeviceD0,
3885   PowerDeviceD1,
3886   PowerDeviceD2,
3887   PowerDeviceD3,
3888   PowerDeviceMaximum
3889 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
3890 
3891 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
3892 typedef struct {
3893   DWORD Granularity;
3894   DWORD Capacity;
3895 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
3896 #endif
3897 
3898 typedef struct _POWER_ACTION_POLICY {
3899   POWER_ACTION Action;
3900   DWORD Flags;
3901   DWORD EventCode;
3902 } POWER_ACTION_POLICY, *PPOWER_ACTION_POLICY;
3903 
3904 /* POWER_ACTION_POLICY.Flags constants */
3905 #define POWER_ACTION_QUERY_ALLOWED        0x00000001
3906 #define POWER_ACTION_UI_ALLOWED           0x00000002
3907 #define POWER_ACTION_OVERRIDE_APPS        0x00000004
3908 #define POWER_ACTION_LIGHTEST_FIRST       0x10000000
3909 #define POWER_ACTION_LOCK_CONSOLE         0x20000000
3910 #define POWER_ACTION_DISABLE_WAKES        0x40000000
3911 #define POWER_ACTION_CRITICAL             0x80000000
3912 
3913 /* POWER_ACTION_POLICY.EventCode constants */
3914 #define POWER_LEVEL_USER_NOTIFY_TEXT      0x00000001
3915 #define POWER_LEVEL_USER_NOTIFY_SOUND     0x00000002
3916 #define POWER_LEVEL_USER_NOTIFY_EXEC      0x00000004
3917 #define POWER_USER_NOTIFY_BUTTON          0x00000008
3918 #define POWER_USER_NOTIFY_SHUTDOWN        0x00000010
3919 #define POWER_FORCE_TRIGGER_RESET         0x80000000
3920 
3921 #define DISCHARGE_POLICY_CRITICAL    0
3922 #define DISCHARGE_POLICY_LOW        1
3923 #define NUM_DISCHARGE_POLICIES        4
3924 
3925 #define PO_THROTTLE_NONE    0
3926 #define PO_THROTTLE_CONSTANT    1
3927 #define PO_THROTTLE_DEGRADE    2
3928 #define PO_THROTTLE_ADAPTIVE    3
3929 #define PO_THROTTLE_MAXIMUM    4
3930 
3931 typedef struct _SYSTEM_POWER_LEVEL {
3932   BOOLEAN Enable;
3933   BYTE Spare[3];
3934   DWORD BatteryLevel;
3935   POWER_ACTION_POLICY PowerPolicy;
3936   SYSTEM_POWER_STATE MinSystemState;
3937 } SYSTEM_POWER_LEVEL, *PSYSTEM_POWER_LEVEL;
3938 
3939 typedef struct _SYSTEM_POWER_POLICY {
3940   DWORD Revision;
3941   POWER_ACTION_POLICY PowerButton;
3942   POWER_ACTION_POLICY SleepButton;
3943   POWER_ACTION_POLICY LidClose;
3944   SYSTEM_POWER_STATE LidOpenWake;
3945   DWORD Reserved;
3946   POWER_ACTION_POLICY Idle;
3947   DWORD IdleTimeout;
3948   BYTE IdleSensitivity;
3949   BYTE DynamicThrottle;
3950   BYTE Spare2[2];
3951   SYSTEM_POWER_STATE MinSleep;
3952   SYSTEM_POWER_STATE MaxSleep;
3953   SYSTEM_POWER_STATE ReducedLatencySleep;
3954   DWORD WinLogonFlags;
3955   DWORD Spare3;
3956   DWORD DozeS4Timeout;
3957   DWORD BroadcastCapacityResolution;
3958   SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES];
3959   DWORD VideoTimeout;
3960   BOOLEAN VideoDimDisplay;
3961   DWORD VideoReserved[3];
3962   DWORD SpindownTimeout;
3963   BOOLEAN OptimizeForPower;
3964   BYTE FanThrottleTolerance;
3965   BYTE ForcedThrottle;
3966   BYTE MinThrottle;
3967   POWER_ACTION_POLICY OverThrottled;
3968 } SYSTEM_POWER_POLICY, *PSYSTEM_POWER_POLICY;
3969 
3970 typedef struct _SYSTEM_POWER_CAPABILITIES {
3971   BOOLEAN PowerButtonPresent;
3972   BOOLEAN SleepButtonPresent;
3973   BOOLEAN LidPresent;
3974   BOOLEAN SystemS1;
3975   BOOLEAN SystemS2;
3976   BOOLEAN SystemS3;
3977   BOOLEAN SystemS4;
3978   BOOLEAN SystemS5;
3979   BOOLEAN HiberFilePresent;
3980   BOOLEAN FullWake;
3981   BOOLEAN VideoDimPresent;
3982   BOOLEAN ApmPresent;
3983   BOOLEAN UpsPresent;
3984   BOOLEAN ThermalControl;
3985   BOOLEAN ProcessorThrottle;
3986   BYTE ProcessorMinThrottle;
3987 #if (NTDDI_VERSION < NTDDI_WINXP)
3988   BYTE ProcessorThrottleScale;
3989   BYTE spare2[4];
3990 #else
3991   BYTE ProcessorMaxThrottle;
3992   BOOLEAN FastSystemS4;
3993   BYTE spare2[3];
3994 #endif /* (NTDDI_VERSION < NTDDI_WINXP) */
3995   BOOLEAN DiskSpinDown;
3996   BYTE spare3[8];
3997   BOOLEAN SystemBatteriesPresent;
3998   BOOLEAN BatteriesAreShortTerm;
3999   BATTERY_REPORTING_SCALE BatteryScale[3];
4000   SYSTEM_POWER_STATE AcOnLineWake;
4001   SYSTEM_POWER_STATE SoftLidWake;
4002   SYSTEM_POWER_STATE RtcWake;
4003   SYSTEM_POWER_STATE MinDeviceWakeState;
4004   SYSTEM_POWER_STATE DefaultLowLatencyWake;
4005 } SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
4006 
4007 typedef struct _SYSTEM_BATTERY_STATE {
4008   BOOLEAN AcOnLine;
4009   BOOLEAN BatteryPresent;
4010   BOOLEAN Charging;
4011   BOOLEAN Discharging;
4012   BOOLEAN Spare1[4];
4013   DWORD MaxCapacity;
4014   DWORD RemainingCapacity;
4015   DWORD Rate;
4016   DWORD EstimatedTime;
4017   DWORD DefaultAlert1;
4018   DWORD DefaultAlert2;
4019 } SYSTEM_BATTERY_STATE, *PSYSTEM_BATTERY_STATE;
4020 
4021 // FIXME: This should not be here!
4022 typedef struct _PROCESSOR_POWER_INFORMATION {
4023   ULONG Number;
4024   ULONG MaxMhz;
4025   ULONG CurrentMhz;
4026   ULONG MhzLimit;
4027   ULONG MaxIdleState;
4028   ULONG CurrentIdleState;
4029 } PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
4030 
4031 typedef DWORD EXECUTION_STATE, *PEXECUTION_STATE;
4032 
4033 typedef enum _POWER_INFORMATION_LEVEL {
4034   SystemPowerPolicyAc,
4035   SystemPowerPolicyDc,
4036   VerifySystemPolicyAc,
4037   VerifySystemPolicyDc,
4038   SystemPowerCapabilities,
4039   SystemBatteryState,
4040   SystemPowerStateHandler,
4041   ProcessorStateHandler,
4042   SystemPowerPolicyCurrent,
4043   AdministratorPowerPolicy,
4044   SystemReserveHiberFile,
4045   ProcessorInformation,
4046   SystemPowerInformation,
4047   ProcessorStateHandler2,
4048   LastWakeTime,
4049   LastSleepTime,
4050   SystemExecutionState,
4051   SystemPowerStateNotifyHandler,
4052   ProcessorPowerPolicyAc,
4053   ProcessorPowerPolicyDc,
4054   VerifyProcessorPowerPolicyAc,
4055   VerifyProcessorPowerPolicyDc,
4056   ProcessorPowerPolicyCurrent,
4057   SystemPowerStateLogging,
4058   SystemPowerLoggingEntry,
4059   SetPowerSettingValue,
4060   NotifyUserPowerSetting,
4061   PowerInformationLevelUnused0,
4062   PowerInformationLevelUnused1,
4063   SystemVideoState,
4064   TraceApplicationPowerMessage,
4065   TraceApplicationPowerMessageEnd,
4066   ProcessorPerfStates,
4067   ProcessorIdleStates,
4068   ProcessorCap,
4069   SystemWakeSource,
4070   SystemHiberFileInformation,
4071   TraceServicePowerMessage,
4072   ProcessorLoad,
4073   PowerShutdownNotification,
4074   MonitorCapabilities,
4075   SessionPowerInit,
4076   SessionDisplayState,
4077   PowerRequestCreate,
4078   PowerRequestAction,
4079   GetPowerRequestList,
4080   ProcessorInformationEx,
4081   NotifyUserModeLegacyPowerEvent,
4082   GroupPark,
4083   ProcessorIdleDomains,
4084   WakeTimerList,
4085   SystemHiberFileSize,
4086   PowerInformationLevelMaximum
4087 } POWER_INFORMATION_LEVEL;
4088 
4089 #if (_WIN32_WINNT >= 0x0501)
4090 
4091 typedef enum _ACTIVATION_CONTEXT_INFO_CLASS {
4092   ActivationContextBasicInformation = 1,
4093   ActivationContextDetailedInformation = 2,
4094   AssemblyDetailedInformationInActivationContext = 3,
4095   FileInformationInAssemblyOfAssemblyInActivationContext = 4,
4096   RunlevelInformationInActivationContext = 5,
4097   CompatibilityInformationInActivationContext = 6,
4098   ActivationContextManifestResourceName = 7,
4099   MaxActivationContextInfoClass,
4100 /* For compatibility with the old names */
4101   AssemblyDetailedInformationInActivationContxt = 3,
4102   FileInformationInAssemblyOfAssemblyInActivationContxt = 4
4103 } ACTIVATION_CONTEXT_INFO_CLASS;
4104 
4105 typedef struct _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
4106   DWORD ulFlags;
4107   DWORD ulEncodedAssemblyIdentityLength;
4108   DWORD ulManifestPathType;
4109   DWORD ulManifestPathLength;
4110   LARGE_INTEGER liManifestLastWriteTime;
4111   DWORD ulPolicyPathType;
4112   DWORD ulPolicyPathLength;
4113   LARGE_INTEGER liPolicyLastWriteTime;
4114   DWORD ulMetadataSatelliteRosterIndex;
4115   DWORD ulManifestVersionMajor;
4116   DWORD ulManifestVersionMinor;
4117   DWORD ulPolicyVersionMajor;
4118   DWORD ulPolicyVersionMinor;
4119   DWORD ulAssemblyDirectoryNameLength;
4120   PCWSTR lpAssemblyEncodedAssemblyIdentity;
4121   PCWSTR lpAssemblyManifestPath;
4122   PCWSTR lpAssemblyPolicyPath;
4123   PCWSTR lpAssemblyDirectoryName;
4124   DWORD ulFileCount;
4125 } ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
4126 typedef const ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
4127 
4128 typedef struct _ACTIVATION_CONTEXT_DETAILED_INFORMATION {
4129   DWORD dwFlags;
4130   DWORD ulFormatVersion;
4131   DWORD ulAssemblyCount;
4132   DWORD ulRootManifestPathType;
4133   DWORD ulRootManifestPathChars;
4134   DWORD ulRootConfigurationPathType;
4135   DWORD ulRootConfigurationPathChars;
4136   DWORD ulAppDirPathType;
4137   DWORD ulAppDirPathChars;
4138   PCWSTR lpRootManifestPath;
4139   PCWSTR lpRootConfigurationPath;
4140   PCWSTR lpAppDirPath;
4141 } ACTIVATION_CONTEXT_DETAILED_INFORMATION, *PACTIVATION_CONTEXT_DETAILED_INFORMATION;
4142 typedef const ACTIVATION_CONTEXT_DETAILED_INFORMATION *PCACTIVATION_CONTEXT_DETAILED_INFORMATION;
4143 
4144 typedef struct _ACTIVATION_CONTEXT_QUERY_INDEX {
4145   DWORD ulAssemblyIndex;
4146   DWORD ulFileIndexInAssembly;
4147 } ACTIVATION_CONTEXT_QUERY_INDEX,*PACTIVATION_CONTEXT_QUERY_INDEX;
4148 typedef const ACTIVATION_CONTEXT_QUERY_INDEX *PCACTIVATION_CONTEXT_QUERY_INDEX;
4149 
4150 typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
4151   DWORD ulFlags;
4152   DWORD ulFilenameLength;
4153   DWORD ulPathLength;
4154   PCWSTR lpFileName;
4155   PCWSTR lpFilePath;
4156 } ASSEMBLY_FILE_DETAILED_INFORMATION,*PASSEMBLY_FILE_DETAILED_INFORMATION;
4157 typedef const ASSEMBLY_FILE_DETAILED_INFORMATION *PCASSEMBLY_FILE_DETAILED_INFORMATION;
4158 
4159 typedef enum {
4160   ACTCTX_RUN_LEVEL_UNSPECIFIED = 0,
4161   ACTCTX_RUN_LEVEL_AS_INVOKER,
4162   ACTCTX_RUN_LEVEL_HIGHEST_AVAILABLE,
4163   ACTCTX_RUN_LEVEL_REQUIRE_ADMIN,
4164   ACTCTX_RUN_LEVEL_NUMBERS
4165 } ACTCTX_REQUESTED_RUN_LEVEL;
4166 
4167 typedef struct _ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION {
4168   DWORD ulFlags;
4169   ACTCTX_REQUESTED_RUN_LEVEL RunLevel;
4170   DWORD UiAccess;
4171 } ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION, *PACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION;
4172 
4173 typedef enum {
4174   ACTCTX_COMPATIBILITY_ELEMENT_TYPE_UNKNOWN = 0,
4175   ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS
4176 } ACTCTX_COMPATIBILITY_ELEMENT_TYPE;
4177 
4178 typedef struct _COMPATIBILITY_CONTEXT_ELEMENT {
4179   GUID Id;
4180   ACTCTX_COMPATIBILITY_ELEMENT_TYPE Type;
4181 } COMPATIBILITY_CONTEXT_ELEMENT, *PCOMPATIBILITY_CONTEXT_ELEMENT;
4182 
4183 typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
4184   DWORD ElementCount;
4185   COMPATIBILITY_CONTEXT_ELEMENT Elements[];
4186 } ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;
4187 
4188 
4189 #define ACTIVATION_CONTEXT_PATH_TYPE_NONE         1
4190 #define ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE   2
4191 #define ACTIVATION_CONTEXT_PATH_TYPE_URL          3
4192 #define ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF  4
4193 
4194 #define ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION          1
4195 #define ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION               2
4196 #define ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION      3
4197 #define ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION        4
4198 #define ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION     5
4199 #define ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION  6
4200 #define ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION        7
4201 #define ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE    8
4202 #define ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES                9
4203 
4204 #endif /* (_WIN32_WINNT >= 0x0501) */
4205 
4206 typedef struct _PROCESSOR_POWER_POLICY_INFO {
4207   DWORD TimeCheck;
4208   DWORD DemoteLimit;
4209   DWORD PromoteLimit;
4210   BYTE DemotePercent;
4211   BYTE PromotePercent;
4212   BYTE Spare[2];
4213   DWORD AllowDemotion:1;
4214   DWORD AllowPromotion:1;
4215   DWORD Reserved:30;
4216 } PROCESSOR_POWER_POLICY_INFO, *PPROCESSOR_POWER_POLICY_INFO;
4217 
4218 typedef struct _PROCESSOR_POWER_POLICY {
4219   DWORD Revision;
4220   BYTE DynamicThrottle;
4221   BYTE Spare[3];
4222   DWORD DisableCStates:1;
4223   DWORD Reserved:31;
4224   DWORD PolicyCount;
4225   PROCESSOR_POWER_POLICY_INFO Policy[3];
4226 } PROCESSOR_POWER_POLICY, *PPROCESSOR_POWER_POLICY;
4227 
4228 typedef struct _ADMINISTRATOR_POWER_POLICY {
4229   SYSTEM_POWER_STATE MinSleep;
4230   SYSTEM_POWER_STATE MaxSleep;
4231   DWORD MinVideoTimeout;
4232   DWORD MaxVideoTimeout;
4233   DWORD MinSpindownTimeout;
4234   DWORD MaxSpindownTimeout;
4235 } ADMINISTRATOR_POWER_POLICY, *PADMINISTRATOR_POWER_POLICY;
4236 
4237 #endif /* WINVER >= 0x0500 */
4238 
4239 typedef VOID (NTAPI *WAITORTIMERCALLBACKFUNC)(PVOID,BOOLEAN);
4240 
4241 #ifdef UNICODE
4242 typedef OSVERSIONINFOW OSVERSIONINFO,*POSVERSIONINFO,*LPOSVERSIONINFO;
4243 typedef OSVERSIONINFOEXW OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX;
4244 #else
4245 typedef OSVERSIONINFOA OSVERSIONINFO,*POSVERSIONINFO,*LPOSVERSIONINFO;
4246 typedef OSVERSIONINFOEXA OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX;
4247 #endif
4248 
4249 #define VER_SET_CONDITION(lc,t,c) ((lc) = VerSetConditionMask((lc),(t),(c)))
4250 
4251 #if (_WIN32_WINNT >= 0x0500)
4252 ULONGLONG WINAPI VerSetConditionMask(_In_ ULONGLONG, _In_ DWORD, _In_ BYTE);
4253 #endif
4254 
4255 typedef enum _HEAP_INFORMATION_CLASS {
4256   HeapCompatibilityInformation,
4257   HeapEnableTerminationOnCorruption
4258 } HEAP_INFORMATION_CLASS;
4259 
4260 #define CACHE_FULLY_ASSOCIATIVE 0xFF
4261 
4262 _Check_return_
4263 NTSYSAPI
4264 SIZE_T
4265 NTAPI
4266 RtlCompareMemory (
4267   _In_ const VOID *Source1,
4268   _In_ const VOID *Source2,
4269   _In_ SIZE_T Length);
4270 
4271 #define RtlMoveMemory(Dest,Source,Length) memmove((Dest),(Source),(Length))
4272 #define RtlCopyMemory(Dest,Source,Length) memcpy((Dest),(Source),(Length))
4273 #define RtlFillMemory(Dest,Length,Fill) memset((Dest),(Fill),(Length))
4274 #define RtlZeroMemory(Dest,Length) RtlFillMemory((Dest),(Length),0)
4275 #define RtlEqualMemory(Dest,Source,Length) (!memcmp((Dest),(Source),(Length)))
4276 
4277 FORCEINLINE
4278 PVOID
4279 RtlSecureZeroMemory(_Out_writes_bytes_all_(Length) PVOID Buffer,
4280                     _In_ SIZE_T Length)
4281 {
4282     volatile char *VolatilePointer;
4283 
4284     /* Get a volatile pointer to prevent any compiler optimizations */
4285     VolatilePointer = (volatile char *)Buffer;
4286 
4287     /* Loop the whole buffer */
4288     while (Length)
4289     {
4290         /* Zero the current byte and move on */
4291         *VolatilePointer++ = 0;
4292         Length--;
4293     }
4294 
4295     /* Return the pointer to ensure the compiler won't optimize this away */
4296     return Buffer;
4297 }
4298 
4299 #if defined(_M_IX86)
4300 FORCEINLINE struct _TEB * NtCurrentTeb(void)
4301 {
4302     return (struct _TEB *)__readfsdword(0x18);
4303 }
4304 FORCEINLINE PVOID GetCurrentFiber(VOID)
4305 {
4306     return (PVOID)(ULONG_PTR)__readfsdword(0x10);
4307 }
4308 #elif defined (_M_AMD64)
4309 FORCEINLINE struct _TEB * NtCurrentTeb(void)
4310 {
4311     return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
4312 }
4313 FORCEINLINE PVOID GetCurrentFiber(VOID)
4314 {
4315   #ifdef NONAMELESSUNION
4316     return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, DUMMYUNIONNAME.FiberData));
4317   #else
4318     return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, FiberData));
4319   #endif
4320 }
4321 #elif defined (_M_ARM)
4322 #define CP15_PMSELR      15, 0,  9, 12, 5
4323 #define CP15_PMXEVCNTR   15, 0,  9, 13, 2
4324 #define CP15_TPIDRURW    15, 0, 13,  0, 2
4325 #define CP15_TPIDRURO    15, 0, 13,  0, 3
4326 #define CP15_TPIDRPRW    15, 0, 13,  0, 4
4327 FORCEINLINE struct _TEB * NtCurrentTeb(void)
4328 {
4329     return (struct _TEB *)(ULONG_PTR)_MoveFromCoprocessor(CP15_TPIDRURW);
4330 }
4331 FORCEINLINE PVOID GetCurrentFiber(VOID)
4332 {
4333   #ifdef NONAMELESSUNION
4334     return ((PNT_TIB )(ULONG_PTR)_MoveFromCoprocessor(CP15_TPIDRURW))->DUMMYUNIONNAME.FiberData;
4335   #else
4336     return ((PNT_TIB )(ULONG_PTR)_MoveFromCoprocessor(CP15_TPIDRURW))->FiberData;
4337   #endif
4338 }
4339 #elif defined (_M_ARM64)
4340 FORCEINLINE struct _TEB * NtCurrentTeb(void)
4341 {
4342     //UNIMPLEMENTED;
4343     return 0;
4344 }
4345 FORCEINLINE PVOID GetCurrentFiber(VOID)
4346 {
4347     //UNIMPLEMENTED;
4348     return 0;
4349 }
4350 #elif defined(_M_PPC)
4351 FORCEINLINE unsigned long _read_teb_dword(const unsigned long Offset)
4352 {
4353     unsigned long result;
4354     __asm__("\tadd 7,13,%1\n"
4355             "\tlwz %0,0(7)\n"
4356             : "=r" (result)
4357             : "r" (Offset)
4358             : "r7");
4359     return result;
4360 }
4361 FORCEINLINE struct _TEB * NtCurrentTeb(void)
4362 {
4363     return (struct _TEB *)_read_teb_dword(0x18);
4364 }
4365 FORCEINLINE PVOID GetCurrentFiber(void)
4366 {
4367     return _read_teb_dword(0x10);
4368 }
4369 #else
4370 #error Unknown architecture
4371 #endif
4372 
4373 FORCEINLINE PVOID GetFiberData(void)
4374 {
4375     return *((PVOID *)GetCurrentFiber());
4376 }
4377 
4378 /* TODO: Other architectures than X86 */
4379 #if defined(_M_IX86)
4380 #define PF_TEMPORAL_LEVEL_1
4381 #define PF_NON_TEMPORAL_LEVEL_ALL
4382 #define PreFetchCacheLine(l, a)
4383 #elif defined (_M_AMD64)
4384 #define PreFetchCacheLine(l, a)
4385 #elif defined(_M_PPC)
4386 #define PreFetchCacheLine(l, a)
4387 #elif defined(_M_ARM)
4388 #define PreFetchCacheLine(l, a)
4389 #elif defined(_M_ARM64)
4390 #define PreFetchCacheLine(l, a)
4391 #else
4392 #error Unknown architecture
4393 #endif
4394 
4395 /* TODO: Other architectures than X86 */
4396 #if defined(_M_IX86)
4397 #if defined(_MSC_VER)
4398 FORCEINLINE
4399 VOID
4400 MemoryBarrier (VOID)
4401 {
4402     LONG Barrier;
4403     __asm { xchg Barrier, eax }
4404 }
4405 #else
4406 FORCEINLINE
4407 VOID
4408 MemoryBarrier(VOID)
4409 {
4410     LONG Barrier, *Dummy = &Barrier;
4411     (VOID)Dummy;
4412     __asm__ __volatile__("xchgl %%eax, %[Barrier]" : : [Barrier] "m" (Barrier) : "memory");
4413 }
4414 #endif
4415 #elif defined (_M_AMD64)
4416 #define MemoryBarrier __faststorefence
4417 #elif defined(_M_PPC)
4418 #define MemoryBarrier()
4419 #elif defined(_M_ARM)
4420 #define MemoryBarrier()
4421 #elif defined(_M_ARM64)
4422 #define MemoryBarrier()
4423 #else
4424 #error Unknown architecture
4425 #endif
4426 
4427 #if defined(_M_IX86) || defined(_M_AMD64)
4428 
4429 #define YieldProcessor _mm_pause
4430 
4431 __analysis_noreturn
4432 FORCEINLINE
4433 VOID
4434 DbgRaiseAssertionFailure(VOID)
4435 {
4436     __int2c();
4437 }
4438 
4439 #elif defined(_M_PPC)
4440 #define YieldProcessor() __asm__ __volatile__("nop");
4441 #elif defined(_M_MIPS)
4442 #define YieldProcessor() __asm__ __volatile__("nop");
4443 #elif defined(_M_ARM)
4444 #define YieldProcessor __yield
4445 #elif defined(_M_ARM64)
4446 #define YieldProcessor __yield
4447 #else
4448 #error Unknown architecture
4449 #endif
4450 
4451 typedef struct _TP_POOL TP_POOL, *PTP_POOL;
4452 typedef struct _TP_WORK TP_WORK, *PTP_WORK;
4453 typedef struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE, *PTP_CALLBACK_INSTANCE;
4454 
4455 typedef DWORD TP_VERSION, *PTP_VERSION;
4456 
4457 typedef enum _TP_CALLBACK_PRIORITY {
4458   TP_CALLBACK_PRIORITY_HIGH,
4459   TP_CALLBACK_PRIORITY_NORMAL,
4460   TP_CALLBACK_PRIORITY_LOW,
4461   TP_CALLBACK_PRIORITY_INVALID,
4462   TP_CALLBACK_PRIORITY_COUNT = TP_CALLBACK_PRIORITY_INVALID
4463 } TP_CALLBACK_PRIORITY;
4464 
4465 typedef VOID
4466 (NTAPI *PTP_WORK_CALLBACK)(
4467   _Inout_ PTP_CALLBACK_INSTANCE Instance,
4468   _Inout_opt_ PVOID Context,
4469   _Inout_ PTP_WORK Work);
4470 
4471 typedef struct _TP_CLEANUP_GROUP TP_CLEANUP_GROUP, *PTP_CLEANUP_GROUP;
4472 
4473 typedef VOID
4474 (NTAPI *PTP_SIMPLE_CALLBACK)(
4475   _Inout_ PTP_CALLBACK_INSTANCE Instance,
4476   _Inout_opt_ PVOID Context);
4477 
4478 typedef VOID
4479 (NTAPI *PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(
4480   _Inout_opt_ PVOID ObjectContext,
4481   _Inout_opt_ PVOID CleanupContext);
4482 
4483 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
4484 typedef struct _TP_CALLBACK_ENVIRON_V3 {
4485   TP_VERSION Version;
4486   PTP_POOL Pool;
4487   PTP_CLEANUP_GROUP CleanupGroup;
4488   PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
4489   PVOID RaceDll;
4490   struct _ACTIVATION_CONTEXT *ActivationContext;
4491   PTP_SIMPLE_CALLBACK FinalizationCallback;
4492   union {
4493     DWORD Flags;
4494     struct {
4495       DWORD LongFunction:1;
4496       DWORD Persistent:1;
4497       DWORD Private:30;
4498     } s;
4499   } u;
4500   TP_CALLBACK_PRIORITY CallbackPriority;
4501   DWORD Size;
4502 } TP_CALLBACK_ENVIRON_V3, TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
4503 #else
4504 typedef struct _TP_CALLBACK_ENVIRON_V1 {
4505   TP_VERSION Version;
4506   PTP_POOL Pool;
4507   PTP_CLEANUP_GROUP CleanupGroup;
4508   PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
4509   PVOID RaceDll;
4510   struct _ACTIVATION_CONTEXT *ActivationContext;
4511   PTP_SIMPLE_CALLBACK FinalizationCallback;
4512   union {
4513     DWORD Flags;
4514     struct {
4515       DWORD LongFunction:1;
4516       DWORD Persistent:1;
4517       DWORD Private:30;
4518     } s;
4519   } u;
4520 } TP_CALLBACK_ENVIRON_V1, TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
4521 #endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN7) */
4522 
4523 #ifdef __WINESRC__
4524 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
4525 #endif
4526 
4527 #ifdef _MSC_VER
4528 #pragma warning(pop)
4529 #endif
4530 
4531 #endif /* RC_INVOKED */
4532