3 Copyright (c) Alex Ionescu. All rights reserved.
11 Type definitions for the Loader.
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
26 #ifndef NTOS_MODE_USER
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 // \----------------------------------------------------------------/
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
45 // There are 2 tables (kernel and shadow, used by Win32K)
47 #define NUMBER_SERVICE_TABLES 2
48 #define NTOS_SERVICE_INDEX 0
49 #define WIN32K_SERVICE_INDEX 1
52 // NB. From assembly code, the table number must be computed as an offset into
53 // the service descriptor table.
55 // Each entry into the table is 16 bytes long on 32-bit architectures, and
56 // 32 bytes long on 64-bit architectures.
58 // Thus, Table Number 1 is offset 16 (0x10) on x86, and offset 32 (0x20) on
62 #define BITS_PER_ENTRY 5 // (1 << 5) = 32 bytes
64 #define BITS_PER_ENTRY 4 // (1 << 4) = 16 bytes
68 // We want the table number, but leave some extra bits to we can have the offset
69 // into the descriptor table.
71 #define SERVICE_TABLE_SHIFT (12 - BITS_PER_ENTRY)
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.
78 #define SERVICE_TABLE_MASK (((1 << TABLE_NUMBER_BITS) - 1) << BITS_PER_ENTRY)
81 // To get the table offset (ie: the service call number), just keep the 12 bits
83 #define SERVICE_NUMBER_MASK ((1 << TABLE_OFFSET_BITS) - 1)
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)
90 #define SERVICE_TABLE_TEST (WIN32K_SERVICE_INDEX << BITS_PER_ENTRY)
93 // Context Record Flags
95 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
98 // Maximum System Descriptor Table Entries
100 #define SSDT_MAX_ENTRIES 2
103 // Processor Architectures
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
118 // Object Type Mask for Kernel Dispatcher Objects
120 #define KOBJECT_TYPE_MASK 0x7F
121 #define KOBJECT_LOCK_BIT 0x80
124 // Dispatcher Priority increments
126 #define THREAD_ALERT_INCREMENT 2
129 // Physical memory offset of KUSER_SHARED_DATA
131 #define KI_USER_SHARED_DATA_PHYSICAL 0x41000
134 // Quantum values and decrements
136 #define MAX_QUANTUM 0x7F
137 #define WAIT_QUANTUM_DECREMENT 1
138 #define CLOCK_QUANTUM_DECREMENT 3
141 // Kernel Feature Bits
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
169 #define KF_XSAVEOPT_BIT 15
170 #define KF_XSTATE_BIT 23
171 #define KF_RDWRFSGSBASE_BIT 28
174 // Internal Exception Codes
176 #define KI_EXCEPTION_INTERNAL 0x10000000
177 #define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
179 typedef struct _FIBER
/* Field offsets: */
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 */
194 ULONG GuaranteedStackBytes
; /* 0x2E0 */
195 PVOID FlsData
; /* 0x2E4 */
196 struct _ACTIVATION_CONTEXT_STACK
*ActivationContextStackPointer
;
200 #ifndef NTOS_MODE_USER
202 // Number of dispatch codes supported by KINTERRUPT
205 #define DISPATCH_LENGTH 4
206 #elif (NTDDI_VERSION >= NTDDI_LONGHORN)
207 #define DISPATCH_LENGTH 135
209 #define DISPATCH_LENGTH 106
215 // KPROCESSOR_MODE Type
217 typedef CCHAR KPROCESSOR_MODE
;
220 // Dereferencable pointer to KUSER_SHARED_DATA in User-Mode
222 #define SharedUserData ((KUSER_SHARED_DATA *)USER_SHARED_DATA)
225 // Maximum WOW64 Entries in KUSER_SHARED_DATA
227 #define MAX_WOW64_SHARED_ENTRIES 16
230 // Maximum Processor Features supported in KUSER_SHARED_DATA
232 #define PROCESSOR_FEATURE_MAX 64
237 typedef enum _EVENT_TYPE
246 typedef enum _TIMER_TYPE
255 typedef enum _WAIT_TYPE
262 // Processor Execution Modes
274 typedef enum _KWAIT_REASON
316 typedef enum _KPROFILE_SOURCE
319 ProfileAlignmentFixup
,
322 ProfileLoadInstructions
,
323 ProfilePipelineFrozen
,
324 ProfileBranchInstructions
,
325 ProfileTotalNonissues
,
329 ProfileBranchMispredictions
,
330 ProfileStoreInstructions
,
331 ProfileFpInstructions
,
332 ProfileIntegerInstructions
,
336 ProfileSpecialInstructions
,
339 ProfileDcacheAccesses
,
340 ProfileMemoryBarrierCycles
,
341 ProfileLoadLinkedIssues
,
346 // NT Product and Architecture Types
348 typedef enum _NT_PRODUCT_TYPE
353 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
355 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
360 } ALTERNATIVE_ARCHITECTURE_TYPE
;
367 typedef enum _KTHREAD_STATE
377 #if (NTDDI_VERSION >= NTDDI_WS03)
380 } KTHREAD_STATE
, *PKTHREAD_STATE
;
383 // Kernel Object Types
385 typedef enum _KOBJECTS
387 EventNotificationObject
= 0,
388 EventSynchronizationObject
= 1,
395 TimerNotificationObject
= 8,
396 TimerSynchronizationObject
= 9,
407 DeviceQueueObject
= 20,
408 EventPairObject
= 21,
409 InterruptObject
= 22,
411 ThreadedDpcObject
= 24,
412 MaximumKernelObject
= 25
418 typedef enum _ADJUST_REASON
428 typedef enum _KCONTINUE_STATUS
432 ContinueProcessorReselected
,
433 ContinueNextProcessor
439 typedef enum _KPROCESS_STATE
446 } KPROCESS_STATE
, *PKPROCESS_STATE
;
449 // NtVdmControl Classes
451 typedef enum _VDMSERVICECLASS
453 VdmStartExecution
= 0,
454 VdmQueueInterrupt
= 1,
455 VdmDelayInterrupt
= 2,
458 VdmSetInt21Handler
= 5,
460 VdmPrinterDirectIoOpen
= 7,
461 VdmPrinterDirectIoClose
= 8,
462 VdmPrinterInitialize
= 9,
463 VdmSetLdtEntries
= 10,
464 VdmSetProcessLdtInfo
= 11,
465 VdmAdlibEmulation
= 12,
466 VdmPMCliControl
= 13,
467 VdmQueryVdmProcess
= 14,
470 #ifdef NTOS_MODE_USER
473 // APC Normal Routine
476 (NTAPI
*PKNORMAL_ROUTINE
)(
477 _In_ PVOID NormalContext
,
478 _In_ PVOID SystemArgument1
,
479 _In_ PVOID SystemArgument2
486 (NTAPI
*PTIMER_APC_ROUTINE
)(
487 _In_ PVOID TimerContext
,
488 _In_ ULONG TimerLowValue
,
489 _In_ LONG TimerHighValue
493 // System Time Structure
495 typedef struct _KSYSTEM_TIME
500 } KSYSTEM_TIME
, *PKSYSTEM_TIME
;
503 // Shared Kernel User Data
505 typedef struct _KUSER_SHARED_DATA
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
;
518 ULONG LargePageMinimum
;
520 NT_PRODUCT_TYPE NtProductType
;
521 BOOLEAN ProductTypeIsValid
;
522 ULONG NtMajorVersion
;
523 ULONG NtMinorVersion
;
524 BOOLEAN ProcessorFeatures
[PROCESSOR_FEATURE_MAX
];
527 volatile ULONG TimeSlip
;
528 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture
;
529 LARGE_INTEGER SystemExpirationDate
;
531 BOOLEAN KdDebuggerEnabled
;
532 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
533 UCHAR NXSupportPolicy
;
535 volatile ULONG ActiveConsoleId
;
536 volatile ULONG DismountCount
;
537 ULONG ComPlusPackage
;
538 ULONG LastSystemRITEventTickCount
;
539 ULONG NumberOfPhysicalPages
;
540 BOOLEAN SafeBootMode
;
543 ULONGLONG TestRetInstruction
;
545 ULONG SystemCallReturn
;
546 ULONGLONG SystemCallPad
[3];
548 volatile KSYSTEM_TIME TickCount
;
549 volatile ULONG64 TickCountQuad
;
552 #if (NTDDI_VERSION >= NTDDI_WS03)
553 LONGLONG ConsoleSessionForegroundProcessId
;
554 ULONG Wow64SharedInformation
[MAX_WOW64_SHARED_ENTRIES
];
556 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
557 USHORT UserModeGlobalLogger
[8];
558 ULONG HeapTracingPid
[2];
559 ULONG CritSecTracingPid
[2];
562 ULONG SharedDataFlags
;
565 ULONG DbgErrorPortPresent
:1;
566 ULONG DbgElevationEnabled
:1;
567 ULONG DbgVirtEnabled
:1;
568 ULONG DbgInstallerDetectEnabled
:1;
572 ULONG ImageFileExecutionOptions
;
573 KAFFINITY ActiveProcessorAffinity
;
575 } KUSER_SHARED_DATA
, *PKUSER_SHARED_DATA
;
580 #include "pshpack1.h"
581 typedef struct _VdmVirtualIca
594 } VDMVIRTUALICA
, *PVDMVIRTUALICA
;
597 typedef struct _VdmIcaUserData
600 PVDMVIRTUALICA pIcaMaster
;
601 PVDMVIRTUALICA pIcaSlave
;
606 PULONG pAddrIretBopTable
;
607 PHANDLE phWowIdleEvent
;
608 PLARGE_INTEGER pIcaTimeout
;
609 PHANDLE phMainThreadSuspended
;
610 } VDMICAUSERDATA
, *PVDMICAUSERDATA
;
612 typedef struct _VDM_INITIALIZE_DATA
615 PVDMICAUSERDATA IcaUserData
;
616 } VDM_INITIALIZE_DATA
, *PVDM_INITIALIZE_DATA
;
621 // System Thread Start Routine
625 (NTAPI
*PKSYSTEM_ROUTINE
)(
626 PKSTART_ROUTINE StartRoutine
,
632 (NTAPI
*PKNORMAL_ROUTINE
)(
633 IN PVOID NormalContext OPTIONAL
,
634 IN PVOID SystemArgument1 OPTIONAL
,
635 IN PVOID SystemArgument2 OPTIONAL
);
638 (NTAPI
*PKRUNDOWN_ROUTINE
)(
639 IN
struct _KAPC
*Apc
);
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
);
651 // APC Environment Types
653 typedef enum _KAPC_ENVIRONMENT
655 OriginalApcEnvironment
,
656 AttachedApcEnvironment
,
657 CurrentApcEnvironment
,
661 typedef struct _KTIMER_TABLE_ENTRY
663 #if (NTDDI_VERSION >= NTDDI_LONGHORN) || defined(_M_ARM) || defined(_M_AMD64)
668 } KTIMER_TABLE_ENTRY
, *PKTIMER_TABLE_ENTRY
;
670 typedef struct _KTIMER_TABLE
672 PKTIMER TimerExpiry
[64];
673 KTIMER_TABLE_ENTRY TimerEntries
[256];
674 } KTIMER_TABLE
, *PKTIMER_TABLE
;
676 typedef struct _KDPC_LIST
678 SINGLE_LIST_ENTRY ListHead
;
679 SINGLE_LIST_ENTRY
* LastEntry
;
680 } KDPC_LIST
, *PKDPC_LIST
;
682 typedef struct _SYNCH_COUNTERS
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
;
735 typedef struct _KDPC_DATA
737 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
740 LIST_ENTRY DpcListHead
;
743 #if defined(_M_AMD64) || defined(_M_ARM)
744 volatile LONG DpcQueueDepth
;
746 volatile ULONG DpcQueueDepth
;
749 #if (NTDDI_VERSION >= NTDDI_LONGHORN) || defined(_M_ARM)
752 } KDPC_DATA
, *PKDPC_DATA
;
755 // Per-Processor Lookaside List
757 typedef struct _PP_LOOKASIDE_LIST
759 struct _GENERAL_LOOKASIDE
*P
;
760 struct _GENERAL_LOOKASIDE
*L
;
761 } PP_LOOKASIDE_LIST
, *PPP_LOOKASIDE_LIST
;
764 // Architectural Types
766 #include <arch/ketypes.h>
769 // Kernel Memory Node
771 #include <pshpack1.h>
772 typedef struct _KNODE
774 SLIST_HEADER DeadStackList
;
775 SLIST_HEADER PfnDereferenceSListHead
;
776 KAFFINITY ProcessorMask
;
784 ULONG MmShiftedColor
;
786 struct _SINGLE_LIST_ENTRY
*PfnDeferredList
;
791 // Structure for Get/SetContext APC
793 typedef struct _GETSETCONTEXT
797 KPROCESSOR_MODE Mode
;
799 } GETSETCONTEXT
, *PGETSETCONTEXT
;
802 // Kernel Profile Object
804 typedef struct _KPROFILE
808 LIST_ENTRY ProfileListEntry
;
809 struct _KPROCESS
*Process
;
816 KPROFILE_SOURCE Source
;
818 } KPROFILE
, *PKPROFILE
;
821 // Kernel Interrupt Object
823 typedef struct _KINTERRUPT
827 LIST_ENTRY InterruptListEntry
;
828 PKSERVICE_ROUTINE ServiceRoutine
;
829 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
830 PKSERVICE_ROUTINE MessageServiceRoutine
;
833 PVOID ServiceContext
;
836 PKSPIN_LOCK ActualLock
;
837 PKINTERRUPT_ROUTINE DispatchAddress
;
840 KIRQL SynchronizeIrql
;
841 BOOLEAN FloatingSave
;
845 KINTERRUPT_MODE Mode
;
846 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
847 KINTERRUPT_POLARITY Polarity
;
851 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
855 PKTRAP_FRAME TrapFrame
;
858 ULONG DispatchCode
[DISPATCH_LENGTH
];
862 // Kernel Event Pair Object
864 typedef struct _KEVENT_PAIR
870 } KEVENT_PAIR
, *PKEVENT_PAIR
;
873 // Kernel No Execute Options
875 typedef struct _KEXECUTE_OPTIONS
877 UCHAR ExecuteDisable
:1;
878 UCHAR ExecuteEnable
:1;
879 UCHAR DisableThunkEmulation
:1;
881 UCHAR ExecuteDispatchEnable
:1;
882 UCHAR ImageDispatchEnable
:1;
884 } KEXECUTE_OPTIONS
, *PKEXECUTE_OPTIONS
;
886 #if (NTDDI_VERSION >= NTDDI_WIN7)
887 typedef union _KWAIT_STATUS_REGISTER
900 } KWAIT_STATUS_REGISTER
, *PKWAIT_STATUS_REGISTER
;
902 typedef struct _COUNTER_READING
904 enum _HARDWARE_COUNTER_TYPE Type
;
908 }COUNTER_READING
, *PCOUNTER_READING
;
910 typedef struct _KTHREAD_COUNTERS
912 ULONG64 WaitReasonBitMap
;
913 struct _THREAD_PERFORMANCE_DATA
* UserData
;
915 ULONG ContextSwitches
;
916 ULONG64 CycleTimeBias
;
917 ULONG64 HardwareCounters
;
918 COUNTER_READING HwCounter
[16];
919 }KTHREAD_COUNTERS
, *PKTHREAD_COUNTERS
;
923 // Kernel Thread (KTHREAD)
925 typedef struct _KTHREAD
927 DISPATCHER_HEADER Header
;
928 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
933 ULONGLONG QuantumTarget
;
935 LIST_ENTRY MutantListHead
;
938 ULONG_PTR StackLimit
; // FIXME: PVOID
940 KSPIN_LOCK ThreadLock
;
941 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
942 KWAIT_STATUS_REGISTER WaitRegister
;
949 ULONG KernelStackResident
:1;
950 ULONG ReadyTransition
:1;
951 ULONG ProcessReadyQueue
:1;
953 ULONG SystemAffinityActive
:1;
955 ULONG GdiFlushActive
:1;
956 ULONG UserStackWalkActive
:1;
957 ULONG ApcInterruptRequest
:1;
958 ULONG ForceDeferSchedule
:1;
959 ULONG QuantumEndMigrate
:1;
960 ULONG UmsDirectedSwitchEnable
:1;
972 UCHAR ApcStateFill
[FIELD_OFFSET(KAPC_STATE
, UserApcPending
) + 1];
973 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
975 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
976 /* On x86, the following members "fall out" of the union */
977 volatile ULONG NextProcessor
;
978 volatile ULONG DeferredProcessor
;
980 /* On x86, the following members "fall out" of the union */
981 volatile USHORT NextProcessor
;
982 volatile USHORT DeferredProcessor
;
986 /* On x86, the following members "fall out" of the union */
987 volatile UCHAR NextProcessor
;
988 volatile UCHAR DeferredProcessor
;
990 SCHAR AdjustIncrement
;
994 KSPIN_LOCK ApcQueueLock
;
995 #ifndef _M_AMD64 // [
996 ULONG ContextSwitches
;
997 volatile UCHAR State
;
1000 KPROCESSOR_MODE WaitMode
;
1002 LONG_PTR WaitStatus
;
1003 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1004 PKWAIT_BLOCK WaitBlockList
;
1008 PKWAIT_BLOCK WaitBlockList
;
1011 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1016 ULONG KernelStackResident
:1;
1017 ULONG ReadyTransition
:1;
1018 ULONG ProcessReadyQueue
:1;
1020 ULONG SystemAffinityActive
:1;
1022 ULONG GdiFlushActive
:1;
1032 #if (NTDDI_VERSION < NTDDI_LONGHORN)
1034 BOOLEAN EnableStackSwap
;
1036 volatile UCHAR SwapBusy
;
1037 BOOLEAN Alerted
[MaximumMode
];
1041 LIST_ENTRY WaitListEntry
;
1042 SINGLE_LIST_ENTRY SwapListEntry
;
1045 #ifndef _M_AMD64 // [
1051 SHORT KernelApcDisable
;
1052 SHORT SpecialApcDisable
;
1054 ULONG CombinedApcDisable
;
1059 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1067 UCHAR TimerFill
[FIELD_OFFSET(KTIMER
, Period
) + sizeof(LONG
)];
1068 #if !defined(_WIN64) // [
1077 ULONG AutoAlignment
:1;
1078 ULONG DisableBoost
:1;
1079 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1080 ULONG EtwStackTraceApc1Inserted
:1;
1081 ULONG EtwStackTraceApc2Inserted
:1;
1082 ULONG CycleChargePending
:1;
1083 ULONG CalloutActive
:1;
1084 ULONG ApcQueueable
:1;
1085 ULONG EnableStackSwap
:1;
1087 ULONG ReservedFlags
:23;
1089 LONG ReservedFlags
:30;
1094 #if defined(_WIN64) && (NTDDI_VERSION < NTDDI_WIN7) // [
1098 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1099 #if defined(_WIN64) // [
1107 DECLSPEC_ALIGN(8) KWAIT_BLOCK WaitBlock
[THREAD_WAIT_OBJECTS
+ 1];
1108 #if (NTDDI_VERSION < NTDDI_WIN7) // [
1111 UCHAR WaitBlockFill0
[FIELD_OFFSET(KWAIT_BLOCK
, SpareByte
)]; // 32bit = 23, 64bit = 43
1112 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1113 UCHAR IdealProcessor
;
1115 BOOLEAN SystemAffinityActive
;
1120 UCHAR WaitBlockFill1
[1 * sizeof(KWAIT_BLOCK
) + FIELD_OFFSET(KWAIT_BLOCK
, SpareByte
)]; // 47 / 91
1125 UCHAR WaitBlockFill2
[2 * sizeof(KWAIT_BLOCK
) + FIELD_OFFSET(KWAIT_BLOCK
, SpareByte
)]; // 71 / 139
1126 UCHAR ResourceIndex
;
1130 UCHAR WaitBlockFill3
[3 * sizeof(KWAIT_BLOCK
) + FIELD_OFFSET(KWAIT_BLOCK
, SpareByte
)]; // 95 / 187
1134 #ifdef _M_AMD64 // [
1137 UCHAR WaitBlockFill4
[FIELD_OFFSET(KWAIT_BLOCK
, SpareLong
)];
1138 ULONG ContextSwitches
;
1142 UCHAR WaitBlockFill5
[1 * sizeof(KWAIT_BLOCK
) + FIELD_OFFSET(KWAIT_BLOCK
, SpareLong
)];
1150 UCHAR WaitBlockFill6
[2 * sizeof(KWAIT_BLOCK
) + FIELD_OFFSET(KWAIT_BLOCK
, SpareLong
)];
1153 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1156 UCHAR WaitBlockFill7
[168];
1157 PVOID TebMappedLowVa
;
1158 struct _UMS_CONTROL_BLOCK
* Ucb
;
1163 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1164 UCHAR WaitBlockFill8
[188];
1166 UCHAR WaitBlockFill7
[3 * sizeof(KWAIT_BLOCK
) + FIELD_OFFSET(KWAIT_BLOCK
, SpareLong
)];
1172 SHORT KernelApcDisable
;
1173 SHORT SpecialApcDisable
;
1175 ULONG CombinedApcDisable
;
1180 LIST_ENTRY QueueListEntry
;
1181 PKTRAP_FRAME TrapFrame
;
1182 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1183 PVOID FirstArgument
;
1184 union // 2 elements, 0x8 bytes (sizeof)
1186 PVOID CallbackStack
;
1187 ULONG_PTR CallbackDepth
;
1190 PVOID CallbackStack
;
1192 #if (NTDDI_VERSION < NTDDI_LONGHORN) || ((NTDDI_VERSION < NTDDI_WIN7) && !defined(_WIN64)) // [
1195 #if (NTDDI_VERSION < NTDDI_LONGHORN) && defined(_WIN64) // [
1198 UCHAR ApcStateIndex
;
1199 #if (NTDDI_VERSION < NTDDI_LONGHORN) // [
1200 UCHAR IdealProcessor
;
1202 BOOLEAN ProcessReadyQueue
;
1207 BOOLEAN KernelStackResident
;
1210 SCHAR PriorityDecrement
;
1211 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1214 CHAR AdjustIncrement
;
1215 #if (NTDDI_VERSION >= NTDDI_WIN7)
1222 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1223 ULONG SystemCallNumber
;
1224 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1230 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1231 GROUP_AFFINITY UserAffinity
;
1232 struct _KPROCESS
*Process
;
1233 GROUP_AFFINITY Affinity
;
1234 ULONG IdealProcessor
;
1235 ULONG UserIdealProcessor
;
1237 KAFFINITY UserAffinity
;
1238 struct _KPROCESS
*Process
;
1241 PKAPC_STATE ApcStatePointer
[2];
1244 KAPC_STATE SavedApcState
;
1247 UCHAR SavedApcStateFill
[FIELD_OFFSET(KAPC_STATE
, UserApcPending
) + 1];
1248 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1258 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1261 UCHAR UserIdealProcessor
;
1263 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1264 #elif (NTDDI_VERSION >= NTDDI_LONGHORN) // ][
1267 UCHAR CalloutActive
;
1270 UCHAR CodePatchInProgress
;
1274 #if defined(_M_IX86) // [
1275 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1276 UCHAR OtherPlatformFill
;
1288 UCHAR SuspendApcFill0
[1];
1289 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1290 UCHAR ResourceIndex
;
1291 #elif (NTDDI_VERSION >= NTDDI_LONGHORN) // ][
1299 UCHAR SuspendApcFill1
[3];
1304 UCHAR SuspendApcFill2
[4];
1309 UCHAR SuspendApcFill3
[FIELD_OFFSET(KAPC
, SystemArgument1
)];
1310 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1318 UCHAR SuspendApcFill4
[FIELD_OFFSET(KAPC
, SystemArgument2
)]; // 40 / 72
1323 UCHAR SuspendApcFill5
[FIELD_OFFSET(KAPC
, Inserted
) + 1]; // 47 / 83
1324 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1339 KSEMAPHORE SuspendSemaphore
;
1342 UCHAR SuspendSemaphorefill
[FIELD_OFFSET(KSEMAPHORE
, Limit
) + 4]; // 20 / 28
1344 ULONG SListFaultCount
;
1349 ULONG SListFaultCount
;
1351 LIST_ENTRY ThreadListEntry
;
1352 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1353 LIST_ENTRY MutantListHead
;
1355 PVOID SListFaultAddress
;
1356 #ifdef _M_AMD64 // [
1357 LONG64 ReadOperationCount
;
1358 LONG64 WriteOperationCount
;
1359 LONG64 OtherOperationCount
;
1360 LONG64 ReadTransferCount
;
1361 LONG64 WriteTransferCount
;
1362 LONG64 OtherTransferCount
;
1364 #if (NTDDI_VERSION >= NTDDI_WIN7) // [
1365 PKTHREAD_COUNTERS ThreadCounters
;
1366 PXSTATE_SAVE XStateSave
;
1367 #elif (NTDDI_VERSION >= NTDDI_LONGHORN) // ][
1368 PVOID MdlForLockedTeb
;
1372 #define ASSERT_THREAD(object) \
1373 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ThreadObject))
1376 // Kernel Process (KPROCESS)
1378 typedef struct _KPROCESS
1380 DISPATCHER_HEADER Header
;
1381 LIST_ENTRY ProfileListHead
;
1382 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1383 ULONG_PTR DirectoryTableBase
;
1386 ULONG_PTR DirectoryTableBase
[2];
1388 #if defined(_M_IX86)
1389 KGDTENTRY LdtDescriptor
;
1390 KIDTENTRY Int21Descriptor
;
1393 #if defined(_M_IX86)
1397 volatile ULONG ActiveProcessors
;
1400 LIST_ENTRY ReadyListHead
;
1401 SINGLE_LIST_ENTRY SwapListEntry
;
1402 PVOID VdmTrapcHandler
;
1403 LIST_ENTRY ThreadListHead
;
1404 KSPIN_LOCK ProcessLock
;
1410 LONG AutoAlignment
:1;
1411 LONG DisableBoost
:1;
1412 LONG DisableQuantum
:1;
1413 LONG ReservedFlags
:29;
1426 KEXECUTE_OPTIONS Flags
;
1427 UCHAR ExecuteOptions
;
1430 LIST_ENTRY ProcessListEntry
;
1431 #if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
1432 ULONGLONG CycleTime
;
1436 #define ASSERT_PROCESS(object) \
1437 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))
1440 // System Service Table Descriptor
1442 typedef struct _KSERVICE_TABLE_DESCRIPTOR
1448 LONG TableBaseGpOffset
;
1451 } KSERVICE_TABLE_DESCRIPTOR
, *PKSERVICE_TABLE_DESCRIPTOR
;
1453 #if (NTDDI_VERSION >= NTDDI_WIN8)
1455 // Entropy Timing State
1457 typedef struct _KENTROPY_TIMING_STATE
1462 ULONG LastDeliveredBuffer
;
1463 PULONG RawDataBuffer
;
1464 } KENTROPY_TIMING_STATE
, *PKENTROPY_TIMING_STATE
;
1467 // Constants from ks386.inc, ksamd64.inc and ksarm.h
1469 #define KENTROPY_TIMING_INTERRUPTS_PER_BUFFER 0x400
1470 #define KENTROPY_TIMING_BUFFER_MASK 0x7ff
1471 #define KENTROPY_TIMING_ANALYSIS 0x0
1473 #endif /* (NTDDI_VERSION >= NTDDI_WIN8) */
1476 // Exported Loader Parameter Block
1478 extern struct _LOADER_PARAMETER_BLOCK NTSYSAPI
*KeLoaderBlock
;
1481 // Exported Hardware Data
1483 extern ULONG NTSYSAPI KiDmaIoCoherency
;
1484 extern ULONG NTSYSAPI KeMaximumIncrement
;
1485 extern ULONG NTSYSAPI KeMinimumIncrement
;
1486 extern ULONG NTSYSAPI KeDcacheFlushCount
;
1487 extern ULONG NTSYSAPI KeIcacheFlushCount
;
1488 extern ULONG_PTR NTSYSAPI KiBugCheckData
[];
1489 extern BOOLEAN NTSYSAPI KiEnableTimerWatchdog
;
1492 // Exported System Service Descriptor Tables
1494 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable
[SSDT_MAX_ENTRIES
];
1495 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow
[SSDT_MAX_ENTRIES
];
1497 #endif // !NTOS_MODE_USER
1499 #endif // _KETYPES_H