f3bbf77caa67a09c631fa4d9ec3023ce46f98e13
[reactos.git] / reactos / include / ndk / ketypes.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 lpctypes.h
8
9 Abstract:
10
11 Type definitions for the Loader.
12
13 Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17 --*/
18
19 #ifndef _KETYPES_H
20 #define _KETYPES_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #ifndef NTOS_MODE_USER
27 #include <haltypes.h>
28 #include <potypes.h>
29 #include <ifssupp.h>
30 #endif
31
32 //
33 // A system call ID is formatted as such:
34 // .________________________________________________________________.
35 // | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
36 // |--------------|-------------------------------------------------|
37 // | TABLE NUMBER | TABLE OFFSET |
38 // \----------------------------------------------------------------/
39 //
40 // The table number is then used as an index into the service descriptor table.
41 #define TABLE_NUMBER_BITS 1
42 #define TABLE_OFFSET_BITS 12
43
44 //
45 // There are 2 tables (kernel and shadow, used by Win32K)
46 //
47 #define NUMBER_SERVICE_TABLES 2
48 #define NTOS_SERVICE_INDEX 0
49 #define WIN32K_SERVICE_INDEX 1
50
51 //
52 // NB. From assembly code, the table number must be computed as an offset into
53 // the service descriptor table.
54 //
55 // Each entry into the table is 16 bytes long on 32-bit architectures, and
56 // 32 bytes long on 64-bit architectures.
57 //
58 // Thus, Table Number 1 is offset 16 (0x10) on x86, and offset 32 (0x20) on
59 // x64.
60 //
61 #ifdef _WIN64
62 #define BITS_PER_ENTRY 5 // (1 << 5) = 32 bytes
63 #else
64 #define BITS_PER_ENTRY 4 // (1 << 4) = 16 bytes
65 #endif
66
67 //
68 // We want the table number, but leave some extra bits to we can have the offset
69 // into the descriptor table.
70 //
71 #define SERVICE_TABLE_SHIFT (12 - BITS_PER_ENTRY)
72
73 //
74 // Now the table number (as an offset) is corrupted with part of the table offset
75 // This mask will remove the extra unwanted bits, and give us the offset into the
76 // descriptor table proper.
77 //
78 #define SERVICE_TABLE_MASK (((1 << TABLE_NUMBER_BITS) - 1) << BITS_PER_ENTRY)
79
80 //
81 // To get the table offset (ie: the service call number), just keep the 12 bits
82 //
83 #define SERVICE_NUMBER_MASK ((1 << TABLE_OFFSET_BITS) - 1)
84
85 //
86 // We'll often need to check if this is a graphics call. This is done by comparing
87 // the table number offset with the known Win32K table number offset.
88 // This is usually index 1, so table number offset 0x10 (x86) or 0x20 (x64)
89 //
90 #define SERVICE_TABLE_TEST (WIN32K_SERVICE_INDEX << BITS_PER_ENTRY)
91
92 //
93 // Context Record Flags
94 //
95 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
96
97 //
98 // Maximum System Descriptor Table Entries
99 //
100 #define SSDT_MAX_ENTRIES 2
101
102 //
103 // Processor Architectures
104 //
105 #define PROCESSOR_ARCHITECTURE_INTEL 0
106 #define PROCESSOR_ARCHITECTURE_MIPS 1
107 #define PROCESSOR_ARCHITECTURE_ALPHA 2
108 #define PROCESSOR_ARCHITECTURE_PPC 3
109 #define PROCESSOR_ARCHITECTURE_SHX 4
110 #define PROCESSOR_ARCHITECTURE_ARM 5
111 #define PROCESSOR_ARCHITECTURE_IA64 6
112 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
113 #define PROCESSOR_ARCHITECTURE_MSIL 8
114 #define PROCESSOR_ARCHITECTURE_AMD64 9
115 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
116
117 //
118 // Object Type Mask for Kernel Dispatcher Objects
119 //
120 #define KOBJECT_TYPE_MASK 0x7F
121 #define KOBJECT_LOCK_BIT 0x80
122
123 //
124 // Dispatcher Priority increments
125 //
126 #define THREAD_ALERT_INCREMENT 2
127
128 //
129 // Physical memory offset of KUSER_SHARED_DATA
130 //
131 #define KI_USER_SHARED_DATA_PHYSICAL 0x41000
132
133 //
134 // Quantum values and decrements
135 //
136 #define MAX_QUANTUM 0x7F
137 #define WAIT_QUANTUM_DECREMENT 1
138 #define CLOCK_QUANTUM_DECREMENT 3
139
140 //
141 // Kernel Feature Bits
142 //
143 #define KF_V86_VIS 0x00000001
144 #define KF_RDTSC 0x00000002
145 #define KF_CR4 0x00000004
146 #define KF_CMOV 0x00000008
147 #define KF_GLOBAL_PAGE 0x00000010
148 #define KF_LARGE_PAGE 0x00000020
149 #define KF_MTRR 0x00000040
150 #define KF_CMPXCHG8B 0x00000080
151 #define KF_MMX 0x00000100
152 #define KF_WORKING_PTE 0x00000200
153 #define KF_PAT 0x00000400
154 #define KF_FXSR 0x00000800
155 #define KF_FAST_SYSCALL 0x00001000
156 #define KF_XMMI 0x00002000
157 #define KF_3DNOW 0x00004000
158 #define KF_AMDK6MTRR 0x00008000
159 #define KF_XMMI64 0x00010000
160 #define KF_DTS 0x00020000
161 #define KF_BRANCH 0x00020000 // from ksamd64.inc
162 #define KF_SSE3 0x00080000
163 #define KF_CMPXCHG16B 0x00100000
164 #define KF_XSTATE 0x00800000 // from ks386.inc, ksamd64.inc
165 #define KF_NX_BIT 0x20000000
166 #define KF_NX_DISABLED 0x40000000
167 #define KF_NX_ENABLED 0x80000000
168
169 #define KF_XSAVEOPT_BIT 15
170 #define KF_XSTATE_BIT 23
171 #define KF_RDWRFSGSBASE_BIT 28
172
173 //
174 // Internal Exception Codes
175 //
176 #define KI_EXCEPTION_INTERNAL 0x10000000
177 #define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
178
179 typedef struct _FIBER /* Field offsets: */
180 { /* i386 arm x64 */
181 PVOID FiberData; /* 0x000 0x000 0x000 */
182 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;/* 0x004 0x004 0x008 */
183 PVOID StackBase; /* 0x008 0x008 0x010 */
184 PVOID StackLimit; /* 0x00C 0x00C 0x018 */
185 PVOID DeallocationStack; /* 0x010 0x010 0x020 */
186 CONTEXT FiberContext; /* 0x014 0x018 0x030 */
187 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
188 PVOID Wx86Tib; /* 0x2E0 0x1b8 0x500 */
189 struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer; /* 0x2E4 0x1bc 0x508 */
190 PVOID FlsData; /* 0x2E8 0x1c0 0x510 */
191 ULONG GuaranteedStackBytes; /* 0x2EC 0x1c4 0x518 */
192 ULONG TebFlags; /* 0x2F0 0x1c8 0x51C */
193 #else
194 ULONG GuaranteedStackBytes; /* 0x2E0 */
195 PVOID FlsData; /* 0x2E4 */
196 struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer;
197 #endif
198 } FIBER, *PFIBER;
199
200 #ifndef NTOS_MODE_USER
201 //
202 // Number of dispatch codes supported by KINTERRUPT
203 //
204 #ifdef _M_AMD64
205 #define DISPATCH_LENGTH 4
206 #elif (NTDDI_VERSION >= NTDDI_LONGHORN)
207 #define DISPATCH_LENGTH 135
208 #else
209 #define DISPATCH_LENGTH 106
210 #endif
211
212 #else
213
214 //
215 // KPROCESSOR_MODE Type
216 //
217 typedef CCHAR KPROCESSOR_MODE;
218
219 //
220 // Dereferencable pointer to KUSER_SHARED_DATA in User-Mode
221 //
222 #define SharedUserData ((KUSER_SHARED_DATA *)USER_SHARED_DATA)
223
224 //
225 // Maximum WOW64 Entries in KUSER_SHARED_DATA
226 //
227 #define MAX_WOW64_SHARED_ENTRIES 16
228
229 //
230 // Maximum Processor Features supported in KUSER_SHARED_DATA
231 //
232 #define PROCESSOR_FEATURE_MAX 64
233
234 //
235 // Event Types
236 //
237 typedef enum _EVENT_TYPE
238 {
239 NotificationEvent,
240 SynchronizationEvent
241 } EVENT_TYPE;
242
243 //
244 // Timer Types
245 //
246 typedef enum _TIMER_TYPE
247 {
248 NotificationTimer,
249 SynchronizationTimer
250 } TIMER_TYPE;
251
252 //
253 // Wait Types
254 //
255 typedef enum _WAIT_TYPE
256 {
257 WaitAll,
258 WaitAny
259 } WAIT_TYPE;
260
261 //
262 // Processor Execution Modes
263 //
264 typedef enum _MODE
265 {
266 KernelMode,
267 UserMode,
268 MaximumMode
269 } MODE;
270
271 //
272 // Wait Reasons
273 //
274 typedef enum _KWAIT_REASON
275 {
276 Executive,
277 FreePage,
278 PageIn,
279 PoolAllocation,
280 DelayExecution,
281 Suspended,
282 UserRequest,
283 WrExecutive,
284 WrFreePage,
285 WrPageIn,
286 WrPoolAllocation,
287 WrDelayExecution,
288 WrSuspended,
289 WrUserRequest,
290 WrEventPair,
291 WrQueue,
292 WrLpcReceive,
293 WrLpcReply,
294 WrVirtualMemory,
295 WrPageOut,
296 WrRendezvous,
297 Spare2,
298 WrGuardedMutex,
299 Spare4,
300 Spare5,
301 Spare6,
302 WrKernel,
303 WrResource,
304 WrPushLock,
305 WrMutex,
306 WrQuantumEnd,
307 WrDispatchInt,
308 WrPreempted,
309 WrYieldExecution,
310 MaximumWaitReason
311 } KWAIT_REASON;
312
313 //
314 // Profiling Sources
315 //
316 typedef enum _KPROFILE_SOURCE
317 {
318 ProfileTime,
319 ProfileAlignmentFixup,
320 ProfileTotalIssues,
321 ProfilePipelineDry,
322 ProfileLoadInstructions,
323 ProfilePipelineFrozen,
324 ProfileBranchInstructions,
325 ProfileTotalNonissues,
326 ProfileDcacheMisses,
327 ProfileIcacheMisses,
328 ProfileCacheMisses,
329 ProfileBranchMispredictions,
330 ProfileStoreInstructions,
331 ProfileFpInstructions,
332 ProfileIntegerInstructions,
333 Profile2Issue,
334 Profile3Issue,
335 Profile4Issue,
336 ProfileSpecialInstructions,
337 ProfileTotalCycles,
338 ProfileIcacheIssues,
339 ProfileDcacheAccesses,
340 ProfileMemoryBarrierCycles,
341 ProfileLoadLinkedIssues,
342 ProfileMaximum
343 } KPROFILE_SOURCE;
344
345 //
346 // NT Product and Architecture Types
347 //
348 typedef enum _NT_PRODUCT_TYPE
349 {
350 NtProductWinNt = 1,
351 NtProductLanManNt,
352 NtProductServer
353 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
354
355 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
356 {
357 StandardDesign,
358 NEC98x86,
359 EndAlternatives
360 } ALTERNATIVE_ARCHITECTURE_TYPE;
361
362 #endif
363
364 //
365 // Thread States
366 //
367 typedef enum _KTHREAD_STATE
368 {
369 Initialized,
370 Ready,
371 Running,
372 Standby,
373 Terminated,
374 Waiting,
375 Transition,
376 DeferredReady,
377 #if (NTDDI_VERSION >= NTDDI_WS03)
378 GateWait
379 #endif
380 } KTHREAD_STATE, *PKTHREAD_STATE;
381
382 //
383 // Kernel Object Types
384 //
385 typedef enum _KOBJECTS
386 {
387 EventNotificationObject = 0,
388 EventSynchronizationObject = 1,
389 MutantObject = 2,
390 ProcessObject = 3,
391 QueueObject = 4,
392 SemaphoreObject = 5,
393 ThreadObject = 6,
394 GateObject = 7,
395 TimerNotificationObject = 8,
396 TimerSynchronizationObject = 9,
397 Spare2Object = 10,
398 Spare3Object = 11,
399 Spare4Object = 12,
400 Spare5Object = 13,
401 Spare6Object = 14,
402 Spare7Object = 15,
403 Spare8Object = 16,
404 Spare9Object = 17,
405 ApcObject = 18,
406 DpcObject = 19,
407 DeviceQueueObject = 20,
408 EventPairObject = 21,
409 InterruptObject = 22,
410 ProfileObject = 23,
411 ThreadedDpcObject = 24,
412 MaximumKernelObject = 25
413 } KOBJECTS;
414
415 //
416 // Adjust reasons
417 //
418 typedef enum _ADJUST_REASON
419 {
420 AdjustNone = 0,
421 AdjustUnwait = 1,
422 AdjustBoost = 2
423 } ADJUST_REASON;
424
425 //
426 // Continue Status
427 //
428 typedef enum _KCONTINUE_STATUS
429 {
430 ContinueError = 0,
431 ContinueSuccess,
432 ContinueProcessorReselected,
433 ContinueNextProcessor
434 } KCONTINUE_STATUS;
435
436 //
437 // Process States
438 //
439 typedef enum _KPROCESS_STATE
440 {
441 ProcessInMemory,
442 ProcessOutOfMemory,
443 ProcessInTransition,
444 ProcessInSwap,
445 ProcessOutSwap,
446 } KPROCESS_STATE, *PKPROCESS_STATE;
447
448 //
449 // NtVdmControl Classes
450 //
451 typedef enum _VDMSERVICECLASS
452 {
453 VdmStartExecution = 0,
454 VdmQueueInterrupt = 1,
455 VdmDelayInterrupt = 2,
456 VdmInitialize = 3,
457 VdmFeatures = 4,
458 VdmSetInt21Handler = 5,
459 VdmQueryDir = 6,
460 VdmPrinterDirectIoOpen = 7,
461 VdmPrinterDirectIoClose = 8,
462 VdmPrinterInitialize = 9,
463 VdmSetLdtEntries = 10,
464 VdmSetProcessLdtInfo = 11,
465 VdmAdlibEmulation = 12,
466 VdmPMCliControl = 13,
467 VdmQueryVdmProcess = 14,
468 } VDMSERVICECLASS;
469
470 #ifdef NTOS_MODE_USER
471
472 //
473 // APC Normal Routine
474 //
475 typedef VOID
476 (NTAPI *PKNORMAL_ROUTINE)(
477 _In_ PVOID NormalContext,
478 _In_ PVOID SystemArgument1,
479 _In_ PVOID SystemArgument2
480 );
481
482 //
483 // Timer Routine
484 //
485 typedef VOID
486 (NTAPI *PTIMER_APC_ROUTINE)(
487 _In_ PVOID TimerContext,
488 _In_ ULONG TimerLowValue,
489 _In_ LONG TimerHighValue
490 );
491
492 //
493 // System Time Structure
494 //
495 typedef struct _KSYSTEM_TIME
496 {
497 ULONG LowPart;
498 LONG High1Time;
499 LONG High2Time;
500 } KSYSTEM_TIME, *PKSYSTEM_TIME;
501
502 //
503 // Shared Kernel User Data
504 //
505 typedef struct _KUSER_SHARED_DATA
506 {
507 ULONG TickCountLowDeprecated;
508 ULONG TickCountMultiplier;
509 volatile KSYSTEM_TIME InterruptTime;
510 volatile KSYSTEM_TIME SystemTime;
511 volatile KSYSTEM_TIME TimeZoneBias;
512 USHORT ImageNumberLow;
513 USHORT ImageNumberHigh;
514 WCHAR NtSystemRoot[260];
515 ULONG MaxStackTraceDepth;
516 ULONG CryptoExponent;
517 ULONG TimeZoneId;
518 ULONG LargePageMinimum;
519 ULONG Reserved2[7];
520 NT_PRODUCT_TYPE NtProductType;
521 BOOLEAN ProductTypeIsValid;
522 ULONG NtMajorVersion;
523 ULONG NtMinorVersion;
524 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
525 ULONG Reserved1;
526 ULONG Reserved3;
527 volatile ULONG TimeSlip;
528 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
529 LARGE_INTEGER SystemExpirationDate;
530 ULONG SuiteMask;
531 BOOLEAN KdDebuggerEnabled;
532 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
533 UCHAR NXSupportPolicy;
534 #endif
535 volatile ULONG ActiveConsoleId;
536 volatile ULONG DismountCount;
537 ULONG ComPlusPackage;
538 ULONG LastSystemRITEventTickCount;
539 ULONG NumberOfPhysicalPages;
540 BOOLEAN SafeBootMode;
541 ULONG TraceLogging;
542 ULONG Fill0;
543 ULONGLONG TestRetInstruction;
544 ULONG SystemCall;
545 ULONG SystemCallReturn;
546 ULONGLONG SystemCallPad[3];
547 union {
548 volatile KSYSTEM_TIME TickCount;
549 volatile ULONG64 TickCountQuad;
550 };
551 ULONG Cookie;
552 #if (NTDDI_VERSION >= NTDDI_WS03)
553 LONGLONG ConsoleSessionForegroundProcessId;
554 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
555 #endif
556 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
557 USHORT UserModeGlobalLogger[8];
558 ULONG HeapTracingPid[2];
559 ULONG CritSecTracingPid[2];
560 union
561 {
562 ULONG SharedDataFlags;
563 struct
564 {
565 ULONG DbgErrorPortPresent:1;
566 ULONG DbgElevationEnabled:1;
567 ULONG DbgVirtEnabled:1;
568 ULONG DbgInstallerDetectEnabled:1;
569 ULONG SpareBits:28;
570 };
571 };
572 ULONG ImageFileExecutionOptions;
573 KAFFINITY ActiveProcessorAffinity;
574 #endif
575 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
576
577 //
578 // VDM Structures
579 //
580 #include "pshpack1.h"
581 typedef struct _VdmVirtualIca
582 {
583 LONG ica_count[8];
584 LONG ica_int_line;
585 LONG ica_cpu_int;
586 USHORT ica_base;
587 USHORT ica_hipiri;
588 USHORT ica_mode;
589 UCHAR ica_master;
590 UCHAR ica_irr;
591 UCHAR ica_isr;
592 UCHAR ica_imr;
593 UCHAR ica_ssr;
594 } VDMVIRTUALICA, *PVDMVIRTUALICA;
595 #include "poppack.h"
596
597 typedef struct _VdmIcaUserData
598 {
599 PVOID pIcaLock;
600 PVDMVIRTUALICA pIcaMaster;
601 PVDMVIRTUALICA pIcaSlave;
602 PULONG pDelayIrq;
603 PULONG pUndelayIrq;
604 PULONG pDelayIret;
605 PULONG pIretHooked;
606 PULONG pAddrIretBopTable;
607 PHANDLE phWowIdleEvent;
608 PLARGE_INTEGER pIcaTimeout;
609 PHANDLE phMainThreadSuspended;
610 } VDMICAUSERDATA, *PVDMICAUSERDATA;
611
612 typedef struct _VDM_INITIALIZE_DATA
613 {
614 PVOID TrapcHandler;
615 PVDMICAUSERDATA IcaUserData;
616 } VDM_INITIALIZE_DATA, *PVDM_INITIALIZE_DATA;
617
618 #else
619
620 //
621 // System Thread Start Routine
622 //
623 typedef
624 VOID
625 (NTAPI *PKSYSTEM_ROUTINE)(
626 PKSTART_ROUTINE StartRoutine,
627 PVOID StartContext
628 );
629
630 #ifndef _NTSYSTEM_
631 typedef VOID
632 (NTAPI *PKNORMAL_ROUTINE)(
633 IN PVOID NormalContext OPTIONAL,
634 IN PVOID SystemArgument1 OPTIONAL,
635 IN PVOID SystemArgument2 OPTIONAL);
636
637 typedef VOID
638 (NTAPI *PKRUNDOWN_ROUTINE)(
639 IN struct _KAPC *Apc);
640
641 typedef VOID
642 (NTAPI *PKKERNEL_ROUTINE)(
643 IN struct _KAPC *Apc,
644 IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
645 IN OUT PVOID *NormalContext OPTIONAL,
646 IN OUT PVOID *SystemArgument1 OPTIONAL,
647 IN OUT PVOID *SystemArgument2 OPTIONAL);
648 #endif
649
650 //
651 // APC Environment Types
652 //
653 typedef enum _KAPC_ENVIRONMENT
654 {
655 OriginalApcEnvironment,
656 AttachedApcEnvironment,
657 CurrentApcEnvironment,
658 InsertApcEnvironment
659 } KAPC_ENVIRONMENT;
660
661 typedef struct _KTIMER_TABLE_ENTRY
662 {
663 #if (NTDDI_VERSION >= NTDDI_LONGHORN) || defined(_M_ARM) || defined(_M_AMD64)
664 KSPIN_LOCK Lock;
665 #endif
666 LIST_ENTRY Entry;
667 ULARGE_INTEGER Time;
668 } KTIMER_TABLE_ENTRY, *PKTIMER_TABLE_ENTRY;
669
670 typedef struct _KTIMER_TABLE
671 {
672 PKTIMER TimerExpiry[64];
673 KTIMER_TABLE_ENTRY TimerEntries[256];
674 } KTIMER_TABLE, *PKTIMER_TABLE;
675
676 typedef struct _KDPC_LIST
677 {
678 SINGLE_LIST_ENTRY ListHead;
679 SINGLE_LIST_ENTRY* LastEntry;
680 } KDPC_LIST, *PKDPC_LIST;
681
682 typedef struct _SYNCH_COUNTERS
683 {
684 ULONG SpinLockAcquireCount;
685 ULONG SpinLockContentionCount;
686 ULONG SpinLockSpinCount;
687 ULONG IpiSendRequestBroadcastCount;
688 ULONG IpiSendRequestRoutineCount;
689 ULONG IpiSendSoftwareInterruptCount;
690 ULONG ExInitializeResourceCount;
691 ULONG ExReInitializeResourceCount;
692 ULONG ExDeleteResourceCount;
693 ULONG ExecutiveResourceAcquiresCount;
694 ULONG ExecutiveResourceContentionsCount;
695 ULONG ExecutiveResourceReleaseExclusiveCount;
696 ULONG ExecutiveResourceReleaseSharedCount;
697 ULONG ExecutiveResourceConvertsCount;
698 ULONG ExAcqResExclusiveAttempts;
699 ULONG ExAcqResExclusiveAcquiresExclusive;
700 ULONG ExAcqResExclusiveAcquiresExclusiveRecursive;
701 ULONG ExAcqResExclusiveWaits;
702 ULONG ExAcqResExclusiveNotAcquires;
703 ULONG ExAcqResSharedAttempts;
704 ULONG ExAcqResSharedAcquiresExclusive;
705 ULONG ExAcqResSharedAcquiresShared;
706 ULONG ExAcqResSharedAcquiresSharedRecursive;
707 ULONG ExAcqResSharedWaits;
708 ULONG ExAcqResSharedNotAcquires;
709 ULONG ExAcqResSharedStarveExclusiveAttempts;
710 ULONG ExAcqResSharedStarveExclusiveAcquiresExclusive;
711 ULONG ExAcqResSharedStarveExclusiveAcquiresShared;
712 ULONG ExAcqResSharedStarveExclusiveAcquiresSharedRecursive;
713 ULONG ExAcqResSharedStarveExclusiveWaits;
714 ULONG ExAcqResSharedStarveExclusiveNotAcquires;
715 ULONG ExAcqResSharedWaitForExclusiveAttempts;
716 ULONG ExAcqResSharedWaitForExclusiveAcquiresExclusive;
717 ULONG ExAcqResSharedWaitForExclusiveAcquiresShared;
718 ULONG ExAcqResSharedWaitForExclusiveAcquiresSharedRecursive;
719 ULONG ExAcqResSharedWaitForExclusiveWaits;
720 ULONG ExAcqResSharedWaitForExclusiveNotAcquires;
721 ULONG ExSetResOwnerPointerExclusive;
722 ULONG ExSetResOwnerPointerSharedNew;
723 ULONG ExSetResOwnerPointerSharedOld;
724 ULONG ExTryToAcqExclusiveAttempts;
725 ULONG ExTryToAcqExclusiveAcquires;
726 ULONG ExBoostExclusiveOwner;
727 ULONG ExBoostSharedOwners;
728 ULONG ExEtwSynchTrackingNotificationsCount;
729 ULONG ExEtwSynchTrackingNotificationsAccountedCount;
730 } SYNCH_COUNTERS, *PSYNCH_COUNTERS;
731
732 //
733 // PRCB DPC Data
734 //
735 typedef struct _KDPC_DATA
736 {
737 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
738 KDPC_LIST DpcList;
739 #else
740 LIST_ENTRY DpcListHead;
741 #endif
742 ULONG_PTR DpcLock;
743 #if defined(_M_AMD64) || defined(_M_ARM)
744 volatile LONG DpcQueueDepth;
745 #else
746 volatile ULONG DpcQueueDepth;
747 #endif
748 ULONG DpcCount;
749 #if (NTDDI_VERSION >= NTDDI_LONGHORN) || defined(_M_ARM)
750 PKDPC ActiveDpc;
751 #endif
752 } KDPC_DATA, *PKDPC_DATA;
753
754 //
755 // Per-Processor Lookaside List
756 //
757 typedef struct _PP_LOOKASIDE_LIST
758 {
759 struct _GENERAL_LOOKASIDE *P;
760 struct _GENERAL_LOOKASIDE *L;
761 } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST;
762
763 //
764 // Architectural Types
765 //
766 #include <arch/ketypes.h>
767
768 //
769 // Kernel Memory Node
770 //
771 #include <pshpack1.h>
772 typedef struct _KNODE
773 {
774 SLIST_HEADER DeadStackList;
775 SLIST_HEADER PfnDereferenceSListHead;
776 KAFFINITY ProcessorMask;
777 ULONG Color;
778 UCHAR Seed;
779 UCHAR NodeNumber;
780 ULONG Flags;
781 ULONG MmShiftedColor;
782 ULONG FreeCount[2];
783 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
784 } KNODE, *PKNODE;
785 #include <poppack.h>
786
787 //
788 // Structure for Get/SetContext APC
789 //
790 typedef struct _GETSETCONTEXT
791 {
792 KAPC Apc;
793 KEVENT Event;
794 KPROCESSOR_MODE Mode;
795 CONTEXT Context;
796 } GETSETCONTEXT, *PGETSETCONTEXT;
797
798 //
799 // Kernel Profile Object
800 //
801 typedef struct _KPROFILE
802 {
803 CSHORT Type;
804 CSHORT Size;
805 LIST_ENTRY ProfileListEntry;
806 struct _KPROCESS *Process;
807 PVOID RangeBase;
808 PVOID RangeLimit;
809 ULONG BucketShift;
810 PVOID Buffer;
811 ULONG_PTR Segment;
812 KAFFINITY Affinity;
813 KPROFILE_SOURCE Source;
814 BOOLEAN Started;
815 } KPROFILE, *PKPROFILE;
816
817 //
818 // Kernel Interrupt Object
819 //
820 typedef struct _KINTERRUPT
821 {
822 CSHORT Type;
823 CSHORT Size;
824 LIST_ENTRY InterruptListEntry;
825 PKSERVICE_ROUTINE ServiceRoutine;
826 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
827 PKSERVICE_ROUTINE MessageServiceRoutine;
828 ULONG MessageIndex;
829 #endif
830 PVOID ServiceContext;
831 KSPIN_LOCK SpinLock;
832 ULONG TickCount;
833 PKSPIN_LOCK ActualLock;
834 PKINTERRUPT_ROUTINE DispatchAddress;
835 ULONG Vector;
836 KIRQL Irql;
837 KIRQL SynchronizeIrql;
838 BOOLEAN FloatingSave;
839 BOOLEAN Connected;
840 CCHAR Number;
841 BOOLEAN ShareVector;
842 KINTERRUPT_MODE Mode;
843 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
844 KINTERRUPT_POLARITY Polarity;
845 #endif
846 ULONG ServiceCount;
847 ULONG DispatchCount;
848 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
849 ULONGLONG Rsvd1;
850 #endif
851 #ifdef _M_AMD64
852 PKTRAP_FRAME TrapFrame;
853 PVOID Reserved;
854 #endif
855 ULONG DispatchCode[DISPATCH_LENGTH];
856 } KINTERRUPT;
857
858 //
859 // Kernel Event Pair Object
860 //
861 typedef struct _KEVENT_PAIR
862 {
863 CSHORT Type;
864 CSHORT Size;
865 KEVENT LowEvent;
866 KEVENT HighEvent;
867 } KEVENT_PAIR, *PKEVENT_PAIR;
868
869 //
870 // Kernel No Execute Options
871 //
872 typedef struct _KEXECUTE_OPTIONS
873 {
874 UCHAR ExecuteDisable:1;
875 UCHAR ExecuteEnable:1;
876 UCHAR DisableThunkEmulation:1;
877 UCHAR Permanent:1;
878 UCHAR ExecuteDispatchEnable:1;
879 UCHAR ImageDispatchEnable:1;
880 UCHAR Spare:2;
881 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
882
883 #if (NTDDI_VERSION >= NTDDI_WIN7)
884 typedef union _KWAIT_STATUS_REGISTER
885 {
886 UCHAR Flags;
887 struct
888 {
889 UCHAR State:2;
890 UCHAR Affinity:1;
891 UCHAR Priority:1;
892 UCHAR Apc:1;
893 UCHAR UserApc:1;
894 UCHAR Alert:1;
895 UCHAR Unused:1;
896 };
897 } KWAIT_STATUS_REGISTER, *PKWAIT_STATUS_REGISTER;
898
899 typedef struct _COUNTER_READING
900 {
901 enum _HARDWARE_COUNTER_TYPE Type;
902 ULONG Index;
903 ULONG64 Start;
904 ULONG64 Total;
905 }COUNTER_READING, *PCOUNTER_READING;
906
907 typedef struct _KTHREAD_COUNTERS
908 {
909 ULONG64 WaitReasonBitMap;
910 struct _THREAD_PERFORMANCE_DATA* UserData;
911 ULONG Flags;
912 ULONG ContextSwitches;
913 ULONG64 CycleTimeBias;
914 ULONG64 HardwareCounters;
915 COUNTER_READING HwCounter[16];
916 }KTHREAD_COUNTERS, *PKTHREAD_COUNTERS;
917 #endif
918
919 //
920 // Kernel Thread (KTHREAD)
921 //
922 typedef struct _KTHREAD
923 {
924 DISPATCHER_HEADER Header;
925 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
926 ULONGLONG CycleTime;
927 #ifndef _WIN64 // [
928 ULONG HighCycleTime;
929 #endif // ]
930 ULONGLONG QuantumTarget;
931 #else // ][
932 LIST_ENTRY MutantListHead;
933 #endif // ]
934 PVOID InitialStack;
935 ULONG_PTR StackLimit; // FIXME: PVOID
936 PVOID KernelStack;
937 KSPIN_LOCK ThreadLock;
938 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
939 KWAIT_STATUS_REGISTER WaitRegister;
940 BOOLEAN Running;
941 BOOLEAN Alerted[2];
942 union
943 {
944 struct
945 {
946 ULONG KernelStackResident:1;
947 ULONG ReadyTransition:1;
948 ULONG ProcessReadyQueue:1;
949 ULONG WaitNext:1;
950 ULONG SystemAffinityActive:1;
951 ULONG Alertable:1;
952 ULONG GdiFlushActive:1;
953 ULONG UserStackWalkActive:1;
954 ULONG ApcInterruptRequest:1;
955 ULONG ForceDeferSchedule:1;
956 ULONG QuantumEndMigrate:1;
957 ULONG UmsDirectedSwitchEnable:1;
958 ULONG TimerActive:1;
959 ULONG Reserved:19;
960 };
961 LONG MiscFlags;
962 };
963 #endif // ]
964 union
965 {
966 KAPC_STATE ApcState;
967 struct
968 {
969 UCHAR ApcStateFill[FIELD_OFFSET(KAPC_STATE, UserApcPending) + 1];
970 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
971 SCHAR Priority;
972 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
973 /* On x86, the following members "fall out" of the union */
974 volatile ULONG NextProcessor;
975 volatile ULONG DeferredProcessor;
976 #else // ][
977 /* On x86, the following members "fall out" of the union */
978 volatile USHORT NextProcessor;
979 volatile USHORT DeferredProcessor;
980 #endif // ]
981 #else // ][
982 UCHAR ApcQueueable;
983 /* On x86, the following members "fall out" of the union */
984 volatile UCHAR NextProcessor;
985 volatile UCHAR DeferredProcessor;
986 UCHAR AdjustReason;
987 SCHAR AdjustIncrement;
988 #endif // ]
989 };
990 };
991 KSPIN_LOCK ApcQueueLock;
992 #ifndef _M_AMD64 // [
993 ULONG ContextSwitches;
994 volatile UCHAR State;
995 UCHAR NpxState;
996 KIRQL WaitIrql;
997 KPROCESSOR_MODE WaitMode;
998 #endif // ]
999 LONG_PTR WaitStatus;
1000 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1001 PKWAIT_BLOCK WaitBlockList;
1002 #else // ][
1003 union
1004 {
1005 PKWAIT_BLOCK WaitBlockList;
1006 PKGATE GateObject;
1007 };
1008 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1009 union
1010 {
1011 struct
1012 {
1013 ULONG KernelStackResident:1;
1014 ULONG ReadyTransition:1;
1015 ULONG ProcessReadyQueue:1;
1016 ULONG WaitNext:1;
1017 ULONG SystemAffinityActive:1;
1018 ULONG Alertable:1;
1019 ULONG GdiFlushActive:1;
1020 ULONG Reserved:25;
1021 };
1022 LONG MiscFlags;
1023 };
1024 #else // ][
1025 BOOLEAN Alertable;
1026 BOOLEAN WaitNext;
1027 #endif // ]
1028 UCHAR WaitReason;
1029 #if (NTDDI_VERSION < NTDDI_LONGHORN)
1030 SCHAR Priority;
1031 BOOLEAN EnableStackSwap;
1032 #endif // ]
1033 volatile UCHAR SwapBusy;
1034 BOOLEAN Alerted[MaximumMode];
1035 #endif // ]
1036 union
1037 {
1038 LIST_ENTRY WaitListEntry;
1039 SINGLE_LIST_ENTRY SwapListEntry;
1040 };
1041 PKQUEUE Queue;
1042 #ifndef _M_AMD64 // [
1043 ULONG WaitTime;
1044 union
1045 {
1046 struct
1047 {
1048 SHORT KernelApcDisable;
1049 SHORT SpecialApcDisable;
1050 };
1051 ULONG CombinedApcDisable;
1052 };
1053 #endif // ]
1054 struct _TEB *Teb;
1055
1056 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1057 KTIMER Timer;
1058 #else // ][
1059 union
1060 {
1061 KTIMER Timer;
1062 struct
1063 {
1064 UCHAR TimerFill[FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)];
1065 #if !defined(_WIN64) // [
1066 };
1067 };
1068 #endif // ]
1069 #endif // ]
1070 union
1071 {
1072 struct
1073 {
1074 ULONG AutoAlignment:1;
1075 ULONG DisableBoost:1;
1076 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1077 ULONG EtwStackTraceApc1Inserted:1;
1078 ULONG EtwStackTraceApc2Inserted:1;
1079 ULONG CycleChargePending:1;
1080 ULONG CalloutActive:1;
1081 ULONG ApcQueueable:1;
1082 ULONG EnableStackSwap:1;
1083 ULONG GuiThread:1;
1084 ULONG ReservedFlags:23;
1085 #else // ][
1086 LONG ReservedFlags:30;
1087 #endif // ]
1088 };
1089 LONG ThreadFlags;
1090 };
1091 #if defined(_WIN64) && (NTDDI_VERSION < NTDDI_WIN7) // [
1092 };
1093 };
1094 #endif // ]
1095 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1096 #if defined(_WIN64) // [
1097 ULONG Spare0;
1098 #else // ][
1099 PVOID ServiceTable;
1100 #endif // ]
1101 #endif // ]
1102 union
1103 {
1104 DECLSPEC_ALIGN(8) KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
1105 #if (NTDDI_VERSION < NTDDI_WIN7) // [
1106 struct
1107 {
1108 UCHAR WaitBlockFill0[FIELD_OFFSET(KWAIT_BLOCK, SpareByte)]; // 32bit = 23, 64bit = 43
1109 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1110 UCHAR IdealProcessor;
1111 #else // ][
1112 BOOLEAN SystemAffinityActive;
1113 #endif // ]
1114 };
1115 struct
1116 {
1117 UCHAR WaitBlockFill1[1 * sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareByte)]; // 47 / 91
1118 CCHAR PreviousMode;
1119 };
1120 struct
1121 {
1122 UCHAR WaitBlockFill2[2 * sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareByte)]; // 71 / 139
1123 UCHAR ResourceIndex;
1124 };
1125 struct
1126 {
1127 UCHAR WaitBlockFill3[3 * sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareByte)]; // 95 / 187
1128 UCHAR LargeStack;
1129 };
1130 #endif // ]
1131 #ifdef _M_AMD64 // [
1132 struct
1133 {
1134 UCHAR WaitBlockFill4[FIELD_OFFSET(KWAIT_BLOCK, SpareLong)];
1135 ULONG ContextSwitches;
1136 };
1137 struct
1138 {
1139 UCHAR WaitBlockFill5[1 * sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareLong)];
1140 UCHAR State;
1141 UCHAR NpxState;
1142 UCHAR WaitIrql;
1143 CHAR WaitMode;
1144 };
1145 struct
1146 {
1147 UCHAR WaitBlockFill6[2 * sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareLong)];
1148 ULONG WaitTime;
1149 };
1150 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1151 struct
1152 {
1153 UCHAR WaitBlockFill7[168];
1154 PVOID TebMappedLowVa;
1155 struct _UMS_CONTROL_BLOCK* Ucb;
1156 };
1157 #endif // ]
1158 struct
1159 {
1160 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1161 UCHAR WaitBlockFill8[188];
1162 #else // ][
1163 UCHAR WaitBlockFill7[3 * sizeof(KWAIT_BLOCK) + FIELD_OFFSET(KWAIT_BLOCK, SpareLong)];
1164 #endif // ]
1165 union
1166 {
1167 struct
1168 {
1169 SHORT KernelApcDisable;
1170 SHORT SpecialApcDisable;
1171 };
1172 ULONG CombinedApcDisable;
1173 };
1174 };
1175 #endif // ]
1176 };
1177 LIST_ENTRY QueueListEntry;
1178 PKTRAP_FRAME TrapFrame;
1179 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1180 PVOID FirstArgument;
1181 union // 2 elements, 0x8 bytes (sizeof)
1182 {
1183 PVOID CallbackStack;
1184 ULONG_PTR CallbackDepth;
1185 };
1186 #else // ][
1187 PVOID CallbackStack;
1188 #endif // ]
1189 #if (NTDDI_VERSION < NTDDI_LONGHORN) || ((NTDDI_VERSION < NTDDI_WIN7) && !defined(_WIN64)) // [
1190 PVOID ServiceTable;
1191 #endif // ]
1192 #if (NTDDI_VERSION < NTDDI_LONGHORN) && defined(_WIN64) // [
1193 ULONG KernelLimit;
1194 #endif // ]
1195 UCHAR ApcStateIndex;
1196 #if (NTDDI_VERSION < NTDDI_LONGHORN) // [
1197 UCHAR IdealProcessor;
1198 BOOLEAN Preempted;
1199 BOOLEAN ProcessReadyQueue;
1200 #ifdef _WIN64 // [
1201 PVOID Win32kTable;
1202 ULONG Win32kLimit;
1203 #endif // ]
1204 BOOLEAN KernelStackResident;
1205 #endif // ]
1206 SCHAR BasePriority;
1207 SCHAR PriorityDecrement;
1208 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1209 BOOLEAN Preempted;
1210 UCHAR AdjustReason;
1211 CHAR AdjustIncrement;
1212 #if (NTDDI_VERSION >= NTDDI_WIN7)
1213 UCHAR PreviousMode;
1214 #else
1215 UCHAR Spare01;
1216 #endif
1217 #endif // ]
1218 CHAR Saturation;
1219 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1220 ULONG SystemCallNumber;
1221 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1222 ULONG FreezeCount;
1223 #else // ][
1224 ULONG Spare02;
1225 #endif // ]
1226 #endif // ]
1227 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1228 GROUP_AFFINITY UserAffinity;
1229 struct _KPROCESS *Process;
1230 GROUP_AFFINITY Affinity;
1231 ULONG IdealProcessor;
1232 ULONG UserIdealProcessor;
1233 #else // ][
1234 KAFFINITY UserAffinity;
1235 struct _KPROCESS *Process;
1236 KAFFINITY Affinity;
1237 #endif // ]
1238 PKAPC_STATE ApcStatePointer[2];
1239 union
1240 {
1241 KAPC_STATE SavedApcState;
1242 struct
1243 {
1244 UCHAR SavedApcStateFill[FIELD_OFFSET(KAPC_STATE, UserApcPending) + 1];
1245 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1246 UCHAR WaitReason;
1247 #else // ][
1248 CCHAR FreezeCount;
1249 #endif // ]
1250 #ifndef _WIN64 // [
1251 };
1252 };
1253 #endif // ]
1254 CCHAR SuspendCount;
1255 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1256 CCHAR Spare1;
1257 #else // ][
1258 UCHAR UserIdealProcessor;
1259 #endif // ]
1260 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1261 #elif (NTDDI_VERSION >= NTDDI_LONGHORN) // ][
1262 UCHAR Spare03;
1263 #else // ][
1264 UCHAR CalloutActive;
1265 #endif // ]
1266 #ifdef _WIN64 // [
1267 UCHAR CodePatchInProgress;
1268 };
1269 };
1270 #endif // ]
1271 #if defined(_M_IX86) // [
1272 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1273 UCHAR OtherPlatformFill;
1274 #else // ][
1275 UCHAR Iopl;
1276 #endif // ]
1277 #endif // ]
1278 PVOID Win32Thread;
1279 PVOID StackBase;
1280 union
1281 {
1282 KAPC SuspendApc;
1283 struct
1284 {
1285 UCHAR SuspendApcFill0[1];
1286 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1287 UCHAR ResourceIndex;
1288 #elif (NTDDI_VERSION >= NTDDI_LONGHORN) // ][
1289 CHAR Spare04;
1290 #else // ][
1291 SCHAR Quantum;
1292 #endif // ]
1293 };
1294 struct
1295 {
1296 UCHAR SuspendApcFill1[3];
1297 UCHAR QuantumReset;
1298 };
1299 struct
1300 {
1301 UCHAR SuspendApcFill2[4];
1302 ULONG KernelTime;
1303 };
1304 struct
1305 {
1306 UCHAR SuspendApcFill3[FIELD_OFFSET(KAPC, SystemArgument1)];
1307 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1308 PKPRCB WaitPrcb;
1309 #else
1310 PVOID TlsArray;
1311 #endif
1312 };
1313 struct
1314 {
1315 UCHAR SuspendApcFill4[FIELD_OFFSET(KAPC, SystemArgument2)]; // 40 / 72
1316 PVOID LegoData;
1317 };
1318 struct
1319 {
1320 UCHAR SuspendApcFill5[FIELD_OFFSET(KAPC, Inserted) + 1]; // 47 / 83
1321 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1322 UCHAR LargeStack;
1323 #else // ][
1324 UCHAR PowerState;
1325 #endif // ]
1326 #ifdef _WIN64 // [
1327 ULONG UserTime;
1328 #endif // ]
1329 };
1330 };
1331 #ifndef _WIN64 // [
1332 ULONG UserTime;
1333 #endif // ]
1334 union
1335 {
1336 KSEMAPHORE SuspendSemaphore;
1337 struct
1338 {
1339 UCHAR SuspendSemaphorefill[FIELD_OFFSET(KSEMAPHORE, Limit) + 4]; // 20 / 28
1340 #ifdef _WIN64 // [
1341 ULONG SListFaultCount;
1342 #endif // ]
1343 };
1344 };
1345 #ifndef _WIN64 // [
1346 ULONG SListFaultCount;
1347 #endif // ]
1348 LIST_ENTRY ThreadListEntry;
1349 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1350 LIST_ENTRY MutantListHead;
1351 #endif // ]
1352 PVOID SListFaultAddress;
1353 #ifdef _M_AMD64 // [
1354 LONG64 ReadOperationCount;
1355 LONG64 WriteOperationCount;
1356 LONG64 OtherOperationCount;
1357 LONG64 ReadTransferCount;
1358 LONG64 WriteTransferCount;
1359 LONG64 OtherTransferCount;
1360 #endif // ]
1361 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1362 PKTHREAD_COUNTERS ThreadCounters;
1363 PXSTATE_SAVE XStateSave;
1364 #elif (NTDDI_VERSION >= NTDDI_LONGHORN) // ][
1365 PVOID MdlForLockedTeb;
1366 #endif // ]
1367 } KTHREAD;
1368
1369 #define ASSERT_THREAD(object) \
1370 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ThreadObject))
1371
1372 //
1373 // Kernel Process (KPROCESS)
1374 //
1375 typedef struct _KPROCESS
1376 {
1377 DISPATCHER_HEADER Header;
1378 LIST_ENTRY ProfileListHead;
1379 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1380 ULONG_PTR DirectoryTableBase;
1381 ULONG Unused0;
1382 #else
1383 ULONG_PTR DirectoryTableBase[2];
1384 #endif
1385 #if defined(_M_IX86)
1386 KGDTENTRY LdtDescriptor;
1387 KIDTENTRY Int21Descriptor;
1388 #endif
1389 USHORT IopmOffset;
1390 #if defined(_M_IX86)
1391 UCHAR Iopl;
1392 UCHAR Unused;
1393 #endif
1394 volatile ULONG ActiveProcessors;
1395 ULONG KernelTime;
1396 ULONG UserTime;
1397 LIST_ENTRY ReadyListHead;
1398 SINGLE_LIST_ENTRY SwapListEntry;
1399 PVOID VdmTrapcHandler;
1400 LIST_ENTRY ThreadListHead;
1401 KSPIN_LOCK ProcessLock;
1402 KAFFINITY Affinity;
1403 union
1404 {
1405 struct
1406 {
1407 LONG AutoAlignment:1;
1408 LONG DisableBoost:1;
1409 LONG DisableQuantum:1;
1410 LONG ReservedFlags:29;
1411 };
1412 LONG ProcessFlags;
1413 };
1414 SCHAR BasePriority;
1415 SCHAR QuantumReset;
1416 UCHAR State;
1417 UCHAR ThreadSeed;
1418 UCHAR PowerState;
1419 UCHAR IdealNode;
1420 UCHAR Visited;
1421 union
1422 {
1423 KEXECUTE_OPTIONS Flags;
1424 UCHAR ExecuteOptions;
1425 };
1426 ULONG StackCount;
1427 LIST_ENTRY ProcessListEntry;
1428 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1429 ULONGLONG CycleTime;
1430 #endif // ]
1431 } KPROCESS;
1432
1433 #define ASSERT_PROCESS(object) \
1434 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))
1435
1436 //
1437 // System Service Table Descriptor
1438 //
1439 typedef struct _KSERVICE_TABLE_DESCRIPTOR
1440 {
1441 PULONG_PTR Base;
1442 PULONG Count;
1443 ULONG Limit;
1444 #if defined(_IA64_)
1445 LONG TableBaseGpOffset;
1446 #endif
1447 PUCHAR Number;
1448 } KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
1449
1450 #if (NTDDI_VERSION >= NTDDI_WIN8)
1451 //
1452 // Entropy Timing State
1453 //
1454 typedef struct _KENTROPY_TIMING_STATE
1455 {
1456 ULONG EntropyCount;
1457 ULONG Buffer[64];
1458 KDPC Dpc;
1459 ULONG LastDeliveredBuffer;
1460 PULONG RawDataBuffer;
1461 } KENTROPY_TIMING_STATE, *PKENTROPY_TIMING_STATE;
1462
1463 //
1464 // Constants from ks386.inc, ksamd64.inc and ksarm.h
1465 //
1466 #define KENTROPY_TIMING_INTERRUPTS_PER_BUFFER 0x400
1467 #define KENTROPY_TIMING_BUFFER_MASK 0x7ff
1468 #define KENTROPY_TIMING_ANALYSIS 0x0
1469
1470 #endif /* (NTDDI_VERSION >= NTDDI_WIN8) */
1471
1472 //
1473 // Exported Loader Parameter Block
1474 //
1475 extern struct _LOADER_PARAMETER_BLOCK NTSYSAPI *KeLoaderBlock;
1476
1477 //
1478 // Exported Hardware Data
1479 //
1480 extern KAFFINITY NTSYSAPI KeActiveProcessors;
1481 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1482 extern volatile CCHAR NTSYSAPI KeNumberProcessors;
1483 #else
1484 #if (NTDDI_VERSION >= NTDDI_WINXP)
1485 extern CCHAR NTSYSAPI KeNumberProcessors;
1486 #else
1487 //extern PCCHAR KeNumberProcessors;
1488 extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
1489 #endif
1490 #endif
1491 extern ULONG NTSYSAPI KiDmaIoCoherency;
1492 extern ULONG NTSYSAPI KeMaximumIncrement;
1493 extern ULONG NTSYSAPI KeMinimumIncrement;
1494 extern ULONG NTSYSAPI KeDcacheFlushCount;
1495 extern ULONG NTSYSAPI KeIcacheFlushCount;
1496 extern ULONG_PTR NTSYSAPI KiBugCheckData[];
1497 extern BOOLEAN NTSYSAPI KiEnableTimerWatchdog;
1498
1499 //
1500 // Exported System Service Descriptor Tables
1501 //
1502 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
1503 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
1504
1505 #endif // !NTOS_MODE_USER
1506
1507 #endif // _KETYPES_H