[XDK][DDK] Take the gcc path for __assert_annotation{A,W} and __CREATE_NTOS_DATA_IMPO...
[reactos.git] / sdk / include / xdk / ketypes.h
1 /******************************************************************************
2 * Kernel Types *
3 ******************************************************************************/
4 $if (_WDMDDK_)
5
6 typedef UCHAR KIRQL, *PKIRQL;
7 typedef CCHAR KPROCESSOR_MODE;
8 typedef LONG KPRIORITY;
9
10 typedef enum _MODE {
11 KernelMode,
12 UserMode,
13 MaximumMode
14 } MODE;
15
16 #define CACHE_FULLY_ASSOCIATIVE 0xFF
17 #define MAXIMUM_SUSPEND_COUNT MAXCHAR
18
19 #define EVENT_QUERY_STATE (0x0001)
20 #define EVENT_MODIFY_STATE (0x0002)
21 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
22
23 #define LTP_PC_SMT 0x1
24
25 #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS)
26 #define SINGLE_GROUP_LEGACY_API 1
27 #endif
28
29 #define SEMAPHORE_QUERY_STATE (0x0001)
30 #define SEMAPHORE_MODIFY_STATE (0x0002)
31 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
32
33 $endif(_WDMDDK_)
34 $if(_WDMDDK_ || _WINNT_)
35
36 typedef struct _PROCESSOR_GROUP_INFO {
37 UCHAR MaximumProcessorCount;
38 UCHAR ActiveProcessorCount;
39 UCHAR Reserved[38];
40 KAFFINITY ActiveProcessorMask;
41 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
42
43 typedef enum _PROCESSOR_CACHE_TYPE {
44 CacheUnified,
45 CacheInstruction,
46 CacheData,
47 CacheTrace
48 } PROCESSOR_CACHE_TYPE;
49
50 typedef struct _CACHE_DESCRIPTOR {
51 UCHAR Level;
52 UCHAR Associativity;
53 USHORT LineSize;
54 ULONG Size;
55 PROCESSOR_CACHE_TYPE Type;
56 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
57
58 typedef struct _NUMA_NODE_RELATIONSHIP {
59 ULONG NodeNumber;
60 UCHAR Reserved[20];
61 GROUP_AFFINITY GroupMask;
62 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
63
64 typedef struct _CACHE_RELATIONSHIP {
65 UCHAR Level;
66 UCHAR Associativity;
67 USHORT LineSize;
68 ULONG CacheSize;
69 PROCESSOR_CACHE_TYPE Type;
70 UCHAR Reserved[20];
71 GROUP_AFFINITY GroupMask;
72 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
73
74 typedef struct _GROUP_RELATIONSHIP {
75 USHORT MaximumGroupCount;
76 USHORT ActiveGroupCount;
77 UCHAR Reserved[20];
78 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
79 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
80
81 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
82 RelationProcessorCore,
83 RelationNumaNode,
84 RelationCache,
85 RelationProcessorPackage,
86 RelationGroup,
87 RelationAll = 0xffff
88 } LOGICAL_PROCESSOR_RELATIONSHIP;
89
90 typedef struct _PROCESSOR_RELATIONSHIP {
91 UCHAR Flags;
92 UCHAR Reserved[21];
93 USHORT GroupCount;
94 _Field_size_(GroupCount) GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
95 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
96
97 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION {
98 ULONG_PTR ProcessorMask;
99 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
100 _ANONYMOUS_UNION union {
101 struct {
102 UCHAR Flags;
103 } ProcessorCore;
104 struct {
105 ULONG NodeNumber;
106 } NumaNode;
107 CACHE_DESCRIPTOR Cache;
108 ULONGLONG Reserved[2];
109 } DUMMYUNIONNAME;
110 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
111
112 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
113 LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
114 ULONG Size;
115 _ANONYMOUS_UNION union {
116 PROCESSOR_RELATIONSHIP Processor;
117 NUMA_NODE_RELATIONSHIP NumaNode;
118 CACHE_RELATIONSHIP Cache;
119 GROUP_RELATIONSHIP Group;
120 } DUMMYUNIONNAME;
121 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
122
123 $endif(_WDMDDK_ || _WINNT_)
124 $if(_WDMDDK_)
125
126 /* Processor features */
127 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
128 #define PF_FLOATING_POINT_EMULATED 1
129 #define PF_COMPARE_EXCHANGE_DOUBLE 2
130 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
131 #define PF_PPC_MOVEMEM_64BIT_OK 4
132 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
133 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
134 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
135 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
136 #define PF_PAE_ENABLED 9
137 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
138 #define PF_SSE_DAZ_MODE_AVAILABLE 11
139 #define PF_NX_ENABLED 12
140 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
141 #define PF_COMPARE_EXCHANGE128 14
142 #define PF_COMPARE64_EXCHANGE128 15
143 #define PF_CHANNELS_ENABLED 16
144 #define PF_XSAVE_ENABLED 17
145 #define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
146 #define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
147 #define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
148 #define PF_VIRT_FIRMWARE_ENABLED 21
149 #define PF_RDWRFSGSBASE_AVAILABLE 22
150 #define PF_FASTFAIL_AVAILABLE 23
151 #define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
152 #define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
153 #define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
154 #define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
155 #define PF_RDRAND_INSTRUCTION_AVAILABLE 28
156 #define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
157 #define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
158 #define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
159
160 #define MAXIMUM_WAIT_OBJECTS 64
161
162 #define ASSERT_APC(Object) \
163 NT_ASSERT((Object)->Type == ApcObject)
164
165 #define ASSERT_DPC(Object) \
166 NT_ASSERT(((Object)->Type == 0) || \
167 ((Object)->Type == DpcObject) || \
168 ((Object)->Type == ThreadedDpcObject))
169
170 #define ASSERT_GATE(Object) \
171 NT_ASSERT((((Object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
172 (((Object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
173
174 #define ASSERT_DEVICE_QUEUE(Object) \
175 NT_ASSERT((Object)->Type == DeviceQueueObject)
176
177 #define ASSERT_TIMER(Object) \
178 NT_ASSERT(((Object)->Header.Type == TimerNotificationObject) || \
179 ((Object)->Header.Type == TimerSynchronizationObject))
180
181 #define ASSERT_MUTANT(Object) \
182 NT_ASSERT((Object)->Header.Type == MutantObject)
183
184 #define ASSERT_SEMAPHORE(Object) \
185 NT_ASSERT((Object)->Header.Type == SemaphoreObject)
186
187 #define ASSERT_EVENT(Object) \
188 NT_ASSERT(((Object)->Header.Type == NotificationEvent) || \
189 ((Object)->Header.Type == SynchronizationEvent))
190
191 #define DPC_NORMAL 0
192 #define DPC_THREADED 1
193
194 #define GM_LOCK_BIT 0x1
195 #define GM_LOCK_BIT_V 0x0
196 #define GM_LOCK_WAITER_WOKEN 0x2
197 #define GM_LOCK_WAITER_INC 0x4
198
199 #define LOCK_QUEUE_WAIT_BIT 0
200 #define LOCK_QUEUE_OWNER_BIT 1
201
202 #define LOCK_QUEUE_WAIT 1
203 #define LOCK_QUEUE_OWNER 2
204 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4
205 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
206
207 #define PROCESSOR_FEATURE_MAX 64
208
209 #define DBG_STATUS_CONTROL_C 1
210 #define DBG_STATUS_SYSRQ 2
211 #define DBG_STATUS_BUGCHECK_FIRST 3
212 #define DBG_STATUS_BUGCHECK_SECOND 4
213 #define DBG_STATUS_FATAL 5
214 #define DBG_STATUS_DEBUG_CONTROL 6
215 #define DBG_STATUS_WORKER 7
216
217 #if defined(_WIN64)
218 #define MAXIMUM_PROC_PER_GROUP 64
219 #else
220 #define MAXIMUM_PROC_PER_GROUP 32
221 #endif
222 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP
223
224 #define EXCEPTION_DIVIDED_BY_ZERO 0
225 #define EXCEPTION_DEBUG 1
226 #define EXCEPTION_NMI 2
227 #define EXCEPTION_INT3 3
228 #define EXCEPTION_BOUND_CHECK 5
229 #define EXCEPTION_INVALID_OPCODE 6
230 #define EXCEPTION_NPX_NOT_AVAILABLE 7
231 #define EXCEPTION_DOUBLE_FAULT 8
232 #define EXCEPTION_NPX_OVERRUN 9
233 #define EXCEPTION_INVALID_TSS 0x0A
234 #define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B
235 #define EXCEPTION_STACK_FAULT 0x0C
236 #define EXCEPTION_GP_FAULT 0x0D
237 #define EXCEPTION_RESERVED_TRAP 0x0F
238 #define EXCEPTION_NPX_ERROR 0x010
239 #define EXCEPTION_ALIGNMENT_CHECK 0x011
240
241 typedef enum _KBUGCHECK_CALLBACK_REASON {
242 KbCallbackInvalid,
243 KbCallbackReserved1,
244 KbCallbackSecondaryDumpData,
245 KbCallbackDumpIo,
246 KbCallbackAddPages
247 } KBUGCHECK_CALLBACK_REASON;
248
249 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
250
251 _Function_class_(KBUGCHECK_REASON_CALLBACK_ROUTINE)
252 _IRQL_requires_same_
253 typedef VOID
254 (NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)(
255 _In_ KBUGCHECK_CALLBACK_REASON Reason,
256 _In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
257 _Inout_ PVOID ReasonSpecificData,
258 _In_ ULONG ReasonSpecificDataLength);
259 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE;
260
261 typedef struct _KBUGCHECK_ADD_PAGES {
262 _Inout_ PVOID Context;
263 _Inout_ ULONG Flags;
264 _In_ ULONG BugCheckCode;
265 _Out_ ULONG_PTR Address;
266 _Out_ ULONG_PTR Count;
267 } KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES;
268
269 typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA {
270 _In_ PVOID InBuffer;
271 _In_ ULONG InBufferLength;
272 _In_ ULONG MaximumAllowed;
273 _Out_ GUID Guid;
274 _Out_ PVOID OutBuffer;
275 _Out_ ULONG OutBufferLength;
276 } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA;
277
278 typedef enum _KBUGCHECK_DUMP_IO_TYPE {
279 KbDumpIoInvalid,
280 KbDumpIoHeader,
281 KbDumpIoBody,
282 KbDumpIoSecondaryData,
283 KbDumpIoComplete
284 } KBUGCHECK_DUMP_IO_TYPE;
285
286 typedef struct _KBUGCHECK_DUMP_IO {
287 _In_ ULONG64 Offset;
288 _In_ PVOID Buffer;
289 _In_ ULONG BufferLength;
290 _In_ KBUGCHECK_DUMP_IO_TYPE Type;
291 } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO;
292
293 #define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL
294 #define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL
295 #define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL
296
297 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
298 LIST_ENTRY Entry;
299 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
300 PUCHAR Component;
301 ULONG_PTR Checksum;
302 KBUGCHECK_CALLBACK_REASON Reason;
303 UCHAR State;
304 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
305
306 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
307 BufferEmpty,
308 BufferInserted,
309 BufferStarted,
310 BufferFinished,
311 BufferIncomplete
312 } KBUGCHECK_BUFFER_DUMP_STATE;
313
314 _Function_class_(KBUGCHECK_CALLBACK_ROUTINE)
315 _IRQL_requires_same_
316 typedef VOID
317 (NTAPI KBUGCHECK_CALLBACK_ROUTINE)(
318 IN PVOID Buffer,
319 IN ULONG Length);
320 typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE;
321
322 typedef struct _KBUGCHECK_CALLBACK_RECORD {
323 LIST_ENTRY Entry;
324 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
325 _Field_size_bytes_opt_(Length) PVOID Buffer;
326 ULONG Length;
327 PUCHAR Component;
328 ULONG_PTR Checksum;
329 UCHAR State;
330 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
331
332 _Function_class_(NMI_CALLBACK)
333 _IRQL_requires_same_
334 typedef BOOLEAN
335 (NTAPI NMI_CALLBACK)(
336 _In_opt_ PVOID Context,
337 _In_ BOOLEAN Handled);
338 typedef NMI_CALLBACK *PNMI_CALLBACK;
339
340 typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE {
341 KeProcessorAddStartNotify = 0,
342 KeProcessorAddCompleteNotify,
343 KeProcessorAddFailureNotify
344 } KE_PROCESSOR_CHANGE_NOTIFY_STATE;
345
346 typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT {
347 KE_PROCESSOR_CHANGE_NOTIFY_STATE State;
348 ULONG NtNumber;
349 NTSTATUS Status;
350 #if (NTDDI_VERSION >= NTDDI_WIN7)
351 PROCESSOR_NUMBER ProcNumber;
352 #endif
353 } KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT;
354
355 _IRQL_requires_same_
356 _Function_class_(PROCESSOR_CALLBACK_FUNCTION)
357 typedef VOID
358 (NTAPI PROCESSOR_CALLBACK_FUNCTION)(
359 _In_ PVOID CallbackContext,
360 _In_ PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext,
361 _Inout_ PNTSTATUS OperationStatus);
362 typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION;
363
364 #define KE_PROCESSOR_CHANGE_ADD_EXISTING 1
365
366 #define INVALID_PROCESSOR_INDEX 0xffffffff
367
368 typedef enum _KINTERRUPT_POLARITY {
369 InterruptPolarityUnknown,
370 InterruptActiveHigh,
371 InterruptActiveLow
372 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
373
374 typedef enum _KPROFILE_SOURCE {
375 ProfileTime,
376 ProfileAlignmentFixup,
377 ProfileTotalIssues,
378 ProfilePipelineDry,
379 ProfileLoadInstructions,
380 ProfilePipelineFrozen,
381 ProfileBranchInstructions,
382 ProfileTotalNonissues,
383 ProfileDcacheMisses,
384 ProfileIcacheMisses,
385 ProfileCacheMisses,
386 ProfileBranchMispredictions,
387 ProfileStoreInstructions,
388 ProfileFpInstructions,
389 ProfileIntegerInstructions,
390 Profile2Issue,
391 Profile3Issue,
392 Profile4Issue,
393 ProfileSpecialInstructions,
394 ProfileTotalCycles,
395 ProfileIcacheIssues,
396 ProfileDcacheAccesses,
397 ProfileMemoryBarrierCycles,
398 ProfileLoadLinkedIssues,
399 ProfileMaximum
400 } KPROFILE_SOURCE;
401
402 typedef enum _KWAIT_REASON {
403 Executive,
404 FreePage,
405 PageIn,
406 PoolAllocation,
407 DelayExecution,
408 Suspended,
409 UserRequest,
410 WrExecutive,
411 WrFreePage,
412 WrPageIn,
413 WrPoolAllocation,
414 WrDelayExecution,
415 WrSuspended,
416 WrUserRequest,
417 WrEventPair,
418 WrQueue,
419 WrLpcReceive,
420 WrLpcReply,
421 WrVirtualMemory,
422 WrPageOut,
423 WrRendezvous,
424 WrKeyedEvent,
425 WrTerminated,
426 WrProcessInSwap,
427 WrCpuRateControl,
428 WrCalloutStack,
429 WrKernel,
430 WrResource,
431 WrPushLock,
432 WrMutex,
433 WrQuantumEnd,
434 WrDispatchInt,
435 WrPreempted,
436 WrYieldExecution,
437 WrFastMutex,
438 WrGuardedMutex,
439 WrRundown,
440 MaximumWaitReason
441 } KWAIT_REASON;
442
443 typedef struct _KWAIT_BLOCK {
444 LIST_ENTRY WaitListEntry;
445 #if (NTDDI_VERSION >= NTDDI_WIN8)
446 UCHAR WaitType;
447 volatile UCHAR BlockState;
448 USHORT WaitKey;
449 #ifdef _WIN64
450 LONG SpareLong;
451 #endif
452 union {
453 struct _KTHREAD *Thread;
454 struct _KQUEUE *NotificationQueue;
455 };
456 PVOID Object;
457 PVOID SparePtr;
458 #else
459 struct _KTHREAD *Thread;
460 PVOID Object;
461 struct _KWAIT_BLOCK *NextWaitBlock;
462 USHORT WaitKey;
463 UCHAR WaitType;
464 #if (NTDDI_VERSION >= NTDDI_WIN7)
465 volatile UCHAR BlockState;
466 #else
467 UCHAR SpareByte;
468 #endif
469 #if defined(_WIN64)
470 LONG SpareLong;
471 #endif
472 #endif
473 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK;
474
475 typedef enum _KINTERRUPT_MODE {
476 LevelSensitive,
477 Latched
478 } KINTERRUPT_MODE;
479
480 #define THREAD_WAIT_OBJECTS 3
481
482 _IRQL_requires_same_
483 _Function_class_(KSTART_ROUTINE)
484 typedef VOID
485 (NTAPI KSTART_ROUTINE)(
486 _In_ PVOID StartContext);
487 typedef KSTART_ROUTINE *PKSTART_ROUTINE;
488
489 typedef VOID
490 (NTAPI *PKINTERRUPT_ROUTINE)(
491 VOID);
492
493 _Function_class_(KSERVICE_ROUTINE)
494 _IRQL_requires_(HIGH_LEVEL)
495 _IRQL_requires_same_
496 typedef BOOLEAN
497 (NTAPI KSERVICE_ROUTINE)(
498 _In_ struct _KINTERRUPT *Interrupt,
499 _In_ PVOID ServiceContext);
500 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
501
502 _Function_class_(KMESSAGE_SERVICE_ROUTINE)
503 _IRQL_requires_same_
504 typedef BOOLEAN
505 (NTAPI KMESSAGE_SERVICE_ROUTINE)(
506 _In_ struct _KINTERRUPT *Interrupt,
507 _In_ PVOID ServiceContext,
508 _In_ ULONG MessageID);
509 typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE;
510
511 typedef enum _KD_OPTION {
512 KD_OPTION_SET_BLOCK_ENABLE,
513 } KD_OPTION;
514
515 #ifdef _NTSYSTEM_
516 typedef VOID
517 (NTAPI *PKNORMAL_ROUTINE)(
518 IN PVOID NormalContext OPTIONAL,
519 IN PVOID SystemArgument1 OPTIONAL,
520 IN PVOID SystemArgument2 OPTIONAL);
521
522 typedef VOID
523 (NTAPI *PKRUNDOWN_ROUTINE)(
524 IN struct _KAPC *Apc);
525
526 typedef VOID
527 (NTAPI *PKKERNEL_ROUTINE)(
528 IN struct _KAPC *Apc,
529 IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
530 IN OUT PVOID *NormalContext OPTIONAL,
531 IN OUT PVOID *SystemArgument1 OPTIONAL,
532 IN OUT PVOID *SystemArgument2 OPTIONAL);
533 #endif
534
535 typedef struct _KAPC {
536 UCHAR Type;
537 UCHAR SpareByte0;
538 UCHAR Size;
539 UCHAR SpareByte1;
540 ULONG SpareLong0;
541 struct _KTHREAD *Thread;
542 LIST_ENTRY ApcListEntry;
543 #ifdef _NTSYSTEM_
544 PKKERNEL_ROUTINE KernelRoutine;
545 PKRUNDOWN_ROUTINE RundownRoutine;
546 PKNORMAL_ROUTINE NormalRoutine;
547 #else
548 PVOID Reserved[3];
549 #endif
550 PVOID NormalContext;
551 PVOID SystemArgument1;
552 PVOID SystemArgument2;
553 CCHAR ApcStateIndex;
554 KPROCESSOR_MODE ApcMode;
555 BOOLEAN Inserted;
556 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
557
558 #define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0)
559 #define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1)
560 #define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0)
561 #define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1)
562 #define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2)
563 #define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex)
564 #define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN))
565
566 typedef struct _KDEVICE_QUEUE_ENTRY {
567 LIST_ENTRY DeviceListEntry;
568 ULONG SortKey;
569 BOOLEAN Inserted;
570 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
571 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
572
573 typedef PVOID PKIPI_CONTEXT;
574
575 typedef VOID
576 (NTAPI *PKIPI_WORKER)(
577 IN OUT PKIPI_CONTEXT PacketContext,
578 IN PVOID Parameter1 OPTIONAL,
579 IN PVOID Parameter2 OPTIONAL,
580 IN PVOID Parameter3 OPTIONAL);
581
582 typedef struct _KIPI_COUNTS {
583 ULONG Freeze;
584 ULONG Packet;
585 ULONG DPC;
586 ULONG APC;
587 ULONG FlushSingleTb;
588 ULONG FlushMultipleTb;
589 ULONG FlushEntireTb;
590 ULONG GenericCall;
591 ULONG ChangeColor;
592 ULONG SweepDcache;
593 ULONG SweepIcache;
594 ULONG SweepIcacheRange;
595 ULONG FlushIoBuffers;
596 ULONG GratuitousDPC;
597 } KIPI_COUNTS, *PKIPI_COUNTS;
598
599 _IRQL_requires_same_
600 _Function_class_(KIPI_BROADCAST_WORKER)
601 _IRQL_requires_(IPI_LEVEL)
602 typedef ULONG_PTR
603 (NTAPI KIPI_BROADCAST_WORKER)(
604 _In_ ULONG_PTR Argument);
605 typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER;
606
607 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
608
609 typedef struct _KSPIN_LOCK_QUEUE {
610 struct _KSPIN_LOCK_QUEUE *volatile Next;
611 PKSPIN_LOCK volatile Lock;
612 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
613
614 typedef struct _KLOCK_QUEUE_HANDLE {
615 KSPIN_LOCK_QUEUE LockQueue;
616 KIRQL OldIrql;
617 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
618
619 #if defined(_AMD64_)
620
621 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER;
622
623 #define LockQueueDispatcherLock 0
624 #define LockQueueExpansionLock 1
625 #define LockQueuePfnLock 2
626 #define LockQueueSystemSpaceLock 3
627 #define LockQueueVacbLock 4
628 #define LockQueueMasterLock 5
629 #define LockQueueNonPagedPoolLock 6
630 #define LockQueueIoCancelLock 7
631 #define LockQueueWorkQueueLock 8
632 #define LockQueueIoVpbLock 9
633 #define LockQueueIoDatabaseLock 10
634 #define LockQueueIoCompletionLock 11
635 #define LockQueueNtfsStructLock 12
636 #define LockQueueAfdWorkQueueLock 13
637 #define LockQueueBcbLock 14
638 #define LockQueueMmNonPagedPoolLock 15
639 #define LockQueueUnusedSpare16 16
640 #define LockQueueTimerTableLock 17
641 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS)
642
643 #else
644
645 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
646 LockQueueDispatcherLock,
647 LockQueueExpansionLock,
648 LockQueuePfnLock,
649 LockQueueSystemSpaceLock,
650 LockQueueVacbLock,
651 LockQueueMasterLock,
652 LockQueueNonPagedPoolLock,
653 LockQueueIoCancelLock,
654 LockQueueWorkQueueLock,
655 LockQueueIoVpbLock,
656 LockQueueIoDatabaseLock,
657 LockQueueIoCompletionLock,
658 LockQueueNtfsStructLock,
659 LockQueueAfdWorkQueueLock,
660 LockQueueBcbLock,
661 LockQueueMmNonPagedPoolLock,
662 LockQueueUnusedSpare16,
663 LockQueueTimerTableLock,
664 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
665 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
666
667 #endif /* defined(_AMD64_) */
668
669 _Function_class_(KDEFERRED_ROUTINE)
670 _IRQL_requires_(DISPATCH_LEVEL)
671 _IRQL_requires_same_
672 typedef VOID
673 (NTAPI KDEFERRED_ROUTINE)(
674 _In_ struct _KDPC *Dpc,
675 _In_opt_ PVOID DeferredContext,
676 _In_opt_ PVOID SystemArgument1,
677 _In_opt_ PVOID SystemArgument2);
678 typedef KDEFERRED_ROUTINE *PKDEFERRED_ROUTINE;
679
680 typedef enum _KDPC_IMPORTANCE {
681 LowImportance,
682 MediumImportance,
683 HighImportance,
684 MediumHighImportance
685 } KDPC_IMPORTANCE;
686
687 typedef struct _KDPC {
688 UCHAR Type;
689 UCHAR Importance;
690 volatile USHORT Number;
691 LIST_ENTRY DpcListEntry;
692 PKDEFERRED_ROUTINE DeferredRoutine;
693 PVOID DeferredContext;
694 PVOID SystemArgument1;
695 PVOID SystemArgument2;
696 volatile PVOID DpcData;
697 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
698
699 typedef struct _KDPC_WATCHDOG_INFORMATION {
700 ULONG DpcTimeLimit;
701 ULONG DpcTimeCount;
702 ULONG DpcWatchdogLimit;
703 ULONG DpcWatchdogCount;
704 ULONG Reserved;
705 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION;
706
707 typedef struct _KDEVICE_QUEUE {
708 CSHORT Type;
709 CSHORT Size;
710 LIST_ENTRY DeviceListHead;
711 KSPIN_LOCK Lock;
712 # if defined(_AMD64_)
713 _ANONYMOUS_UNION union {
714 BOOLEAN Busy;
715 _ANONYMOUS_STRUCT struct {
716 LONG64 Reserved:8;
717 LONG64 Hint:56;
718 } DUMMYSTRUCTNAME;
719 } DUMMYUNIONNAME;
720 # else
721 BOOLEAN Busy;
722 # endif
723 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
724
725 #define TIMER_EXPIRED_INDEX_BITS 6
726 #define TIMER_PROCESSOR_INDEX_BITS 5
727
728 typedef struct _DISPATCHER_HEADER {
729 _ANONYMOUS_UNION union {
730 _ANONYMOUS_STRUCT struct {
731 UCHAR Type;
732 _ANONYMOUS_UNION union {
733 _ANONYMOUS_UNION union {
734 UCHAR TimerControlFlags;
735 _ANONYMOUS_STRUCT struct {
736 UCHAR Absolute:1;
737 UCHAR Coalescable:1;
738 UCHAR KeepShifting:1;
739 UCHAR EncodedTolerableDelay:5;
740 } DUMMYSTRUCTNAME;
741 } DUMMYUNIONNAME;
742 UCHAR Abandoned;
743 #if (NTDDI_VERSION < NTDDI_WIN7)
744 UCHAR NpxIrql;
745 #endif
746 BOOLEAN Signalling;
747 } DUMMYUNIONNAME;
748 _ANONYMOUS_UNION union {
749 _ANONYMOUS_UNION union {
750 UCHAR ThreadControlFlags;
751 _ANONYMOUS_STRUCT struct {
752 UCHAR CpuThrottled:1;
753 UCHAR CycleProfiling:1;
754 UCHAR CounterProfiling:1;
755 UCHAR Reserved:5;
756 } DUMMYSTRUCTNAME;
757 } DUMMYUNIONNAME;
758 UCHAR Size;
759 UCHAR Hand;
760 } DUMMYUNIONNAME2;
761 _ANONYMOUS_UNION union {
762 #if (NTDDI_VERSION >= NTDDI_WIN7)
763 _ANONYMOUS_UNION union {
764 UCHAR TimerMiscFlags;
765 _ANONYMOUS_STRUCT struct {
766 #if !defined(_X86_)
767 UCHAR Index:TIMER_EXPIRED_INDEX_BITS;
768 #else
769 UCHAR Index:1;
770 UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS;
771 #endif
772 UCHAR Inserted:1;
773 volatile UCHAR Expired:1;
774 } DUMMYSTRUCTNAME;
775 } DUMMYUNIONNAME;
776 #else
777 /* Pre Win7 compatibility fix to latest WDK */
778 UCHAR Inserted;
779 #endif
780 _ANONYMOUS_UNION union {
781 BOOLEAN DebugActive;
782 _ANONYMOUS_STRUCT struct {
783 BOOLEAN ActiveDR7:1;
784 BOOLEAN Instrumented:1;
785 BOOLEAN Reserved2:4;
786 BOOLEAN UmsScheduled:1;
787 BOOLEAN UmsPrimary:1;
788 } DUMMYSTRUCTNAME;
789 } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */
790 BOOLEAN DpcActive;
791 } DUMMYUNIONNAME3;
792 } DUMMYSTRUCTNAME;
793 volatile LONG Lock;
794 } DUMMYUNIONNAME;
795 LONG SignalState;
796 LIST_ENTRY WaitListHead;
797 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
798
799 typedef struct _KEVENT {
800 DISPATCHER_HEADER Header;
801 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
802
803 typedef struct _KSEMAPHORE {
804 DISPATCHER_HEADER Header;
805 LONG Limit;
806 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
807
808 #define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG))
809
810 typedef struct _KGATE {
811 DISPATCHER_HEADER Header;
812 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
813
814 typedef struct _KGUARDED_MUTEX {
815 volatile LONG Count;
816 PKTHREAD Owner;
817 ULONG Contention;
818 KGATE Gate;
819 _ANONYMOUS_UNION union {
820 _ANONYMOUS_STRUCT struct {
821 SHORT KernelApcDisable;
822 SHORT SpecialApcDisable;
823 } DUMMYSTRUCTNAME;
824 ULONG CombinedApcDisable;
825 } DUMMYUNIONNAME;
826 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
827
828 typedef struct _KMUTANT {
829 DISPATCHER_HEADER Header;
830 LIST_ENTRY MutantListEntry;
831 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
832 BOOLEAN Abandoned;
833 UCHAR ApcDisable;
834 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
835
836 #define TIMER_TABLE_SIZE 512
837 #define TIMER_TABLE_SHIFT 9
838
839 typedef struct _KTIMER {
840 DISPATCHER_HEADER Header;
841 ULARGE_INTEGER DueTime;
842 LIST_ENTRY TimerListEntry;
843 struct _KDPC *Dpc;
844 #if (NTDDI_VERSION >= NTDDI_WIN7) && !defined(_X86_)
845 ULONG Processor;
846 #endif
847 ULONG Period;
848 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
849
850 typedef enum _LOCK_OPERATION {
851 IoReadAccess,
852 IoWriteAccess,
853 IoModifyAccess
854 } LOCK_OPERATION;
855
856 #define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG))
857
858 _Function_class_(KSYNCHRONIZE_ROUTINE)
859 _IRQL_requires_same_
860 typedef BOOLEAN
861 (NTAPI KSYNCHRONIZE_ROUTINE)(
862 _In_ PVOID SynchronizeContext);
863 typedef KSYNCHRONIZE_ROUTINE *PKSYNCHRONIZE_ROUTINE;
864
865 typedef enum _POOL_TYPE {
866 NonPagedPool,
867 PagedPool,
868 NonPagedPoolMustSucceed,
869 DontUseThisType,
870 NonPagedPoolCacheAligned,
871 PagedPoolCacheAligned,
872 NonPagedPoolCacheAlignedMustS,
873 MaxPoolType,
874 NonPagedPoolSession = 32,
875 PagedPoolSession,
876 NonPagedPoolMustSucceedSession,
877 DontUseThisTypeSession,
878 NonPagedPoolCacheAlignedSession,
879 PagedPoolCacheAlignedSession,
880 NonPagedPoolCacheAlignedMustSSession
881 } POOL_TYPE;
882
883 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
884 StandardDesign,
885 NEC98x86,
886 EndAlternatives
887 } ALTERNATIVE_ARCHITECTURE_TYPE;
888
889 #ifndef _X86_
890
891 #ifndef IsNEC_98
892 #define IsNEC_98 (FALSE)
893 #endif
894
895 #ifndef IsNotNEC_98
896 #define IsNotNEC_98 (TRUE)
897 #endif
898
899 #ifndef SetNEC_98
900 #define SetNEC_98
901 #endif
902
903 #ifndef SetNotNEC_98
904 #define SetNotNEC_98
905 #endif
906
907 #endif
908
909 typedef struct _KSYSTEM_TIME {
910 ULONG LowPart;
911 LONG High1Time;
912 LONG High2Time;
913 } KSYSTEM_TIME, *PKSYSTEM_TIME;
914
915 typedef struct DECLSPEC_ALIGN(16) _M128A {
916 ULONGLONG Low;
917 LONGLONG High;
918 } M128A, *PM128A;
919
920 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT {
921 USHORT ControlWord;
922 USHORT StatusWord;
923 UCHAR TagWord;
924 UCHAR Reserved1;
925 USHORT ErrorOpcode;
926 ULONG ErrorOffset;
927 USHORT ErrorSelector;
928 USHORT Reserved2;
929 ULONG DataOffset;
930 USHORT DataSelector;
931 USHORT Reserved3;
932 ULONG MxCsr;
933 ULONG MxCsr_Mask;
934 M128A FloatRegisters[8];
935 #if defined(_WIN64)
936 M128A XmmRegisters[16];
937 UCHAR Reserved4[96];
938 #else
939 M128A XmmRegisters[8];
940 UCHAR Reserved4[192];
941 ULONG StackControl[7];
942 ULONG Cr0NpxState;
943 #endif
944 } XSAVE_FORMAT, *PXSAVE_FORMAT;
945
946 typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER {
947 ULONG64 Mask;
948 ULONG64 Reserved[7];
949 } XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER;
950
951 typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA {
952 XSAVE_FORMAT LegacyState;
953 XSAVE_AREA_HEADER Header;
954 } XSAVE_AREA, *PXSAVE_AREA;
955
956 typedef struct _XSTATE_CONTEXT {
957 ULONG64 Mask;
958 ULONG Length;
959 ULONG Reserved1;
960 _Field_size_bytes_opt_(Length) PXSAVE_AREA Area;
961 #if defined(_X86_)
962 ULONG Reserved2;
963 #endif
964 PVOID Buffer;
965 #if defined(_X86_)
966 ULONG Reserved3;
967 #endif
968 } XSTATE_CONTEXT, *PXSTATE_CONTEXT;
969
970 typedef struct _XSTATE_SAVE {
971 #if defined(_AMD64_)
972 struct _XSTATE_SAVE* Prev;
973 struct _KTHREAD* Thread;
974 UCHAR Level;
975 XSTATE_CONTEXT XStateContext;
976 #elif defined(_IA64_) || defined(_ARM_)
977 ULONG Dummy;
978 #elif defined(_X86_)
979 _ANONYMOUS_UNION union {
980 _ANONYMOUS_STRUCT struct {
981 LONG64 Reserved1;
982 ULONG Reserved2;
983 struct _XSTATE_SAVE* Prev;
984 PXSAVE_AREA Reserved3;
985 struct _KTHREAD* Thread;
986 PVOID Reserved4;
987 UCHAR Level;
988 } DUMMYSTRUCTNAME;
989 XSTATE_CONTEXT XStateContext;
990 } DUMMYUNIONNAME;
991 #endif
992 } XSTATE_SAVE, *PXSTATE_SAVE;
993
994 #ifdef _X86_
995
996 #define MAXIMUM_SUPPORTED_EXTENSION 512
997
998 #if !defined(__midl) && !defined(MIDL_PASS)
999 C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION);
1000 #endif
1001
1002 #endif /* _X86_ */
1003
1004 #define XSAVE_ALIGN 64
1005 #define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA)
1006
1007 #if !defined(__midl) && !defined(MIDL_PASS)
1008 C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0);
1009 C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0);
1010 C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64);
1011 #endif
1012
1013 typedef struct _CONTEXT_CHUNK {
1014 LONG Offset;
1015 ULONG Length;
1016 } CONTEXT_CHUNK, *PCONTEXT_CHUNK;
1017
1018 typedef struct _CONTEXT_EX {
1019 CONTEXT_CHUNK All;
1020 CONTEXT_CHUNK Legacy;
1021 CONTEXT_CHUNK XState;
1022 } CONTEXT_EX, *PCONTEXT_EX;
1023
1024 #define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN)
1025
1026 #if (NTDDI_VERSION >= NTDDI_VISTA)
1027 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
1028 #elif (NTDDI_VERSION >= NTDDI_WINXP)
1029 extern NTSYSAPI CCHAR KeNumberProcessors;
1030 #else
1031 __CREATE_NTOS_DATA_IMPORT_ALIAS(KeNumberProcessors)
1032 extern PCCHAR KeNumberProcessors;
1033 #endif
1034
1035 $endif (_WDMDDK_)
1036 $if (_NTDDK_)
1037
1038 typedef struct _EXCEPTION_REGISTRATION_RECORD
1039 {
1040 struct _EXCEPTION_REGISTRATION_RECORD *Next;
1041 PEXCEPTION_ROUTINE Handler;
1042 } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
1043
1044 typedef struct _NT_TIB {
1045 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1046 PVOID StackBase;
1047 PVOID StackLimit;
1048 PVOID SubSystemTib;
1049 _ANONYMOUS_UNION union {
1050 PVOID FiberData;
1051 ULONG Version;
1052 } DUMMYUNIONNAME;
1053 PVOID ArbitraryUserPointer;
1054 struct _NT_TIB *Self;
1055 } NT_TIB, *PNT_TIB;
1056
1057 typedef struct _NT_TIB32 {
1058 ULONG ExceptionList;
1059 ULONG StackBase;
1060 ULONG StackLimit;
1061 ULONG SubSystemTib;
1062 _ANONYMOUS_UNION union {
1063 ULONG FiberData;
1064 ULONG Version;
1065 } DUMMYUNIONNAME;
1066 ULONG ArbitraryUserPointer;
1067 ULONG Self;
1068 } NT_TIB32,*PNT_TIB32;
1069
1070 typedef struct _NT_TIB64 {
1071 ULONG64 ExceptionList;
1072 ULONG64 StackBase;
1073 ULONG64 StackLimit;
1074 ULONG64 SubSystemTib;
1075 _ANONYMOUS_UNION union {
1076 ULONG64 FiberData;
1077 ULONG Version;
1078 } DUMMYUNIONNAME;
1079 ULONG64 ArbitraryUserPointer;
1080 ULONG64 Self;
1081 } NT_TIB64,*PNT_TIB64;
1082
1083 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1084 #define NX_SUPPORT_POLICY_ALWAYSON 1
1085 #define NX_SUPPORT_POLICY_OPTIN 2
1086 #define NX_SUPPORT_POLICY_OPTOUT 3
1087
1088 _IRQL_requires_same_
1089 _Function_class_(EXPAND_STACK_CALLOUT)
1090 typedef VOID
1091 (NTAPI EXPAND_STACK_CALLOUT)(
1092 _In_opt_ PVOID Parameter);
1093 typedef EXPAND_STACK_CALLOUT *PEXPAND_STACK_CALLOUT;
1094
1095 typedef VOID
1096 (NTAPI *PTIMER_APC_ROUTINE)(
1097 _In_ PVOID TimerContext,
1098 _In_ ULONG TimerLowValue,
1099 _In_ LONG TimerHighValue);
1100
1101 typedef enum _TIMER_SET_INFORMATION_CLASS {
1102 TimerSetCoalescableTimer,
1103 MaxTimerInfoClass
1104 } TIMER_SET_INFORMATION_CLASS;
1105
1106 #if (NTDDI_VERSION >= NTDDI_WIN7)
1107 typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO {
1108 _In_ LARGE_INTEGER DueTime;
1109 _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine;
1110 _In_opt_ PVOID TimerContext;
1111 _In_opt_ struct _COUNTED_REASON_CONTEXT *WakeContext;
1112 _In_opt_ ULONG Period;
1113 _In_ ULONG TolerableDelay;
1114 _Out_opt_ PBOOLEAN PreviousState;
1115 } TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO;
1116 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1117
1118 #define XSTATE_LEGACY_FLOATING_POINT 0
1119 #define XSTATE_LEGACY_SSE 1
1120 #define XSTATE_GSSE 2
1121
1122 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1LL << (XSTATE_LEGACY_FLOATING_POINT))
1123 #define XSTATE_MASK_LEGACY_SSE (1LL << (XSTATE_LEGACY_SSE))
1124 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1125 #define XSTATE_MASK_GSSE (1LL << (XSTATE_GSSE))
1126
1127 #define MAXIMUM_XSTATE_FEATURES 64
1128
1129 typedef struct _XSTATE_FEATURE {
1130 ULONG Offset;
1131 ULONG Size;
1132 } XSTATE_FEATURE, *PXSTATE_FEATURE;
1133
1134 typedef struct _XSTATE_CONFIGURATION {
1135 ULONG64 EnabledFeatures;
1136 ULONG Size;
1137 ULONG OptimizedSave:1;
1138 XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
1139 } XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION;
1140
1141 #define MAX_WOW64_SHARED_ENTRIES 16
1142
1143 typedef struct _KUSER_SHARED_DATA {
1144 ULONG TickCountLowDeprecated;
1145 ULONG TickCountMultiplier;
1146 volatile KSYSTEM_TIME InterruptTime;
1147 volatile KSYSTEM_TIME SystemTime;
1148 volatile KSYSTEM_TIME TimeZoneBias;
1149 USHORT ImageNumberLow;
1150 USHORT ImageNumberHigh;
1151 WCHAR NtSystemRoot[260];
1152 ULONG MaxStackTraceDepth;
1153 ULONG CryptoExponent;
1154 ULONG TimeZoneId;
1155 ULONG LargePageMinimum;
1156 ULONG Reserved2[7];
1157 NT_PRODUCT_TYPE NtProductType;
1158 BOOLEAN ProductTypeIsValid;
1159 ULONG NtMajorVersion;
1160 ULONG NtMinorVersion;
1161 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1162 ULONG Reserved1;
1163 ULONG Reserved3;
1164 volatile ULONG TimeSlip;
1165 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1166 ULONG AltArchitecturePad[1];
1167 LARGE_INTEGER SystemExpirationDate;
1168 ULONG SuiteMask;
1169 BOOLEAN KdDebuggerEnabled;
1170 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1171 UCHAR NXSupportPolicy;
1172 #endif
1173 volatile ULONG ActiveConsoleId;
1174 volatile ULONG DismountCount;
1175 ULONG ComPlusPackage;
1176 ULONG LastSystemRITEventTickCount;
1177 ULONG NumberOfPhysicalPages;
1178 BOOLEAN SafeBootMode;
1179 #if (NTDDI_VERSION >= NTDDI_WIN7)
1180 _ANONYMOUS_UNION union {
1181 UCHAR TscQpcData;
1182 _ANONYMOUS_STRUCT struct {
1183 UCHAR TscQpcEnabled:1;
1184 UCHAR TscQpcSpareFlag:1;
1185 UCHAR TscQpcShift:6;
1186 } DUMMYSTRUCTNAME;
1187 } DUMMYUNIONNAME;
1188 UCHAR TscQpcPad[2];
1189 #endif
1190 #if (NTDDI_VERSION >= NTDDI_VISTA)
1191 _ANONYMOUS_UNION union {
1192 ULONG SharedDataFlags;
1193 _ANONYMOUS_STRUCT struct {
1194 ULONG DbgErrorPortPresent:1;
1195 ULONG DbgElevationEnabled:1;
1196 ULONG DbgVirtEnabled:1;
1197 ULONG DbgInstallerDetectEnabled:1;
1198 ULONG DbgSystemDllRelocated:1;
1199 ULONG DbgDynProcessorEnabled:1;
1200 ULONG DbgSEHValidationEnabled:1;
1201 ULONG SpareBits:25;
1202 } DUMMYSTRUCTNAME2;
1203 } DUMMYUNIONNAME2;
1204 #else
1205 ULONG TraceLogging;
1206 #endif
1207 ULONG DataFlagsPad[1];
1208 ULONGLONG TestRetInstruction;
1209 ULONG SystemCall;
1210 ULONG SystemCallReturn;
1211 ULONGLONG SystemCallPad[3];
1212 _ANONYMOUS_UNION union {
1213 volatile KSYSTEM_TIME TickCount;
1214 volatile ULONG64 TickCountQuad;
1215 _ANONYMOUS_STRUCT struct {
1216 ULONG ReservedTickCountOverlay[3];
1217 ULONG TickCountPad[1];
1218 } DUMMYSTRUCTNAME;
1219 } DUMMYUNIONNAME3;
1220 ULONG Cookie;
1221 ULONG CookiePad[1];
1222 #if (NTDDI_VERSION >= NTDDI_WS03)
1223 LONGLONG ConsoleSessionForegroundProcessId;
1224 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
1225 #endif
1226 #if (NTDDI_VERSION >= NTDDI_VISTA)
1227 #if (NTDDI_VERSION >= NTDDI_WIN7)
1228 USHORT UserModeGlobalLogger[16];
1229 #else
1230 USHORT UserModeGlobalLogger[8];
1231 ULONG HeapTracingPid[2];
1232 ULONG CritSecTracingPid[2];
1233 #endif
1234 ULONG ImageFileExecutionOptions;
1235 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1236 ULONG LangGenerationCount;
1237 #else
1238 /* 4 bytes padding */
1239 #endif
1240 ULONGLONG Reserved5;
1241 volatile ULONG64 InterruptTimeBias;
1242 #endif
1243 #if (NTDDI_VERSION >= NTDDI_WIN7)
1244 volatile ULONG64 TscQpcBias;
1245 volatile ULONG ActiveProcessorCount;
1246 volatile USHORT ActiveGroupCount;
1247 USHORT Reserved4;
1248 volatile ULONG AitSamplingValue;
1249 volatile ULONG AppCompatFlag;
1250 ULONGLONG SystemDllNativeRelocation;
1251 ULONG SystemDllWowRelocation;
1252 ULONG XStatePad[1];
1253 XSTATE_CONFIGURATION XState;
1254 #endif
1255 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
1256
1257 #if (NTDDI_VERSION >= NTDDI_VISTA)
1258 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
1259 #elif (NTDDI_VERSION >= NTDDI_WINXP)
1260 extern NTSYSAPI CCHAR KeNumberProcessors;
1261 #else
1262 extern PCCHAR KeNumberProcessors;
1263 #endif
1264
1265 $endif (_NTDDK_)
1266 $if (_NTIFS_)
1267 typedef struct _KAPC_STATE {
1268 LIST_ENTRY ApcListHead[MaximumMode];
1269 PKPROCESS Process;
1270 BOOLEAN KernelApcInProgress;
1271 BOOLEAN KernelApcPending;
1272 BOOLEAN UserApcPending;
1273 } KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
1274
1275 #define KAPC_STATE_ACTUAL_LENGTH (FIELD_OFFSET(KAPC_STATE, UserApcPending) + sizeof(BOOLEAN))
1276
1277 #define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject);
1278
1279 typedef struct _KQUEUE {
1280 DISPATCHER_HEADER Header;
1281 LIST_ENTRY EntryListHead;
1282 volatile ULONG CurrentCount;
1283 ULONG MaximumCount;
1284 LIST_ENTRY ThreadListHead;
1285 } KQUEUE, *PKQUEUE, *RESTRICTED_POINTER PRKQUEUE;
1286
1287 $endif (_NTIFS_)
1288