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