20#ifndef _AMD64_KETYPES_H
21#define _AMD64_KETYPES_H
31#define KF_SMEP 0x00000001
32#define KF_RDTSC 0x00000002
33#define KF_CR4 0x00000004
34#define KF_CMOV 0x00000008
35#define KF_GLOBAL_PAGE 0x00000010
36#define KF_LARGE_PAGE 0x00000020
37#define KF_MTRR 0x00000040
38#define KF_CMPXCHG8B 0x00000080
39#define KF_MMX 0x00000100
40#define KF_DTS 0x00000200
41#define KF_PAT 0x00000400
42#define KF_FXSR 0x00000800
43#define KF_FAST_SYSCALL 0x00001000
44#define KF_XMMI 0x00002000
45#define KF_3DNOW 0x00004000
46#define KF_AMDK6MTRR 0x00008000
47#define KF_XSAVEOPT 0x00008000
48#define KF_XMMI64 0x00010000
49#define KF_BRANCH 0x00020000
50#define KF_00040000 0x00040000
51#define KF_SSE3 0x00080000
52#define KF_CMPXCHG16B 0x00100000
53#define KF_AUTHENTICAMD 0x00200000
54#define KF_ACNT2 0x00400000
55#define KF_XSTATE 0x00800000
56#define KF_GENUINE_INTEL 0x01000000
57#define KF_02000000 0x02000000
58#define KF_SLAT 0x04000000
59#define KF_VIRT_FIRMWARE_ENABLED 0x08000000
60#define KF_RDWRFSGSBASE 0x10000000
61#define KF_NX_BIT 0x20000000
62#define KF_NX_DISABLED 0x40000000
63#define KF_NX_ENABLED 0x80000000
64#define KF_RDRAND 0x0000000100000000ULL
65#define KF_SMAP 0x0000000200000000ULL
66#define KF_RDTSCP 0x0000000400000000ULL
67#define KF_HUGEPAGE 0x0000002000000000ULL
68#define KF_XSAVES 0x0000004000000000ULL
69#define KF_FPU_LEAKAGE 0x0000020000000000ULL
70#define KF_CAT 0x0000100000000000ULL
71#define KF_CET_SS 0x0000400000000000ULL
72#define KF_SSSE3 0x0000800000000000ULL
73#define KF_SSE4_1 0x0001000000000000ULL
74#define KF_SSE4_2 0x0002000000000000ULL
76#define KF_XSAVEOPT_BIT 15
77#define KF_XSTATE_BIT 23
78#define KF_RDWRFSGSBASE_BIT 28
79#define KF_XSAVES_BIT 38
80#define KF_FPU_LEAKAGE_BIT 41
88#define PCR ((volatile KPCR * const)__readgsqword(FIELD_OFFSET(KPCR, Self)))
97#define DOUBLE_FAULT_STACK_SIZE 0x2000
113#define MACHINE_TYPE_ISA 0x0000
114#define MACHINE_TYPE_EISA 0x0001
115#define MACHINE_TYPE_MCA 0x0002
120#define I386_TASK_GATE 0x5
122#define I386_ACTIVE_TSS 0xB
123#define I386_CALL_GATE 0xC
124#define I386_INTERRUPT_GATE 0xE
125#define I386_TRAP_GATE 0xF
130#define RPL_MASK 0x0003
131#define MODE_MASK 0x0001
132#define KGDT64_NULL 0x0000
133#define KGDT64_R0_CODE 0x0010
134#define KGDT64_R0_DATA 0x0018
135#define KGDT64_R3_CMCODE 0x0020
136#define KGDT64_R3_DATA 0x0028
137#define KGDT64_R3_CODE 0x0030
138#define KGDT64_SYS_TSS 0x0040
139#define KGDT64_R3_CMTEB 0x0050
140#define KGDT64_R0_LDT 0x0060
153#define CR4_FXSR 0x200
154#define CR4_XMMEXCPT 0x400
155#define CR4_CHANNELS 0x800
156#define CR4_XSAVE 0x40000
161#define DR7_LEGAL 0xFFFF0355
162#define DR7_ACTIVE 0x00000355
163#define DR7_TRACE_BRANCH 0x00000200
164#define DR7_LAST_BRANCH 0x00000100
169#define DEBUG_ACTIVE_DR7 0x0001
170#define DEBUG_ACTIVE_INSTRUMENTED 0x0002
171#define DEBUG_ACTIVE_DBG_INSTRUMENTED 0x0003
172#define DEBUG_ACTIVE_MINIMAL_THREAD 0x0004
173#define DEBUG_ACTIVE_PRIMARY_THREAD 0x0080
174#define DEBUG_ACTIVE_PRIMARY_THREAD_BIT 0x0007
175#define DEBUG_ACTIVE_PRIMARY_THREAD_LOCK_BIT 0x001F
176#define DEBUG_ACTIVE_SCHEDULED_THREAD 0x0040
177#define DEBUG_ACTIVE_SCHEDULED_THREAD_BIT 0x0006
178#define DEBUG_ACTIVE_SCHEDULED_THREAD_LOCK_BIT 0x001E
179#define DEBUG_ACTIVE_SCHEDULED_THREAD_LOCK 0x40000000
184#define EFLAGS_CF 0x01L
185#define EFLAGS_ZF 0x40L
186#define EFLAGS_TF 0x100L
187#define EFLAGS_INTERRUPT_MASK 0x200L
188#define EFLAGS_DF 0x400L
189#define EFLAGS_IOPL 0x3000L
190#define EFLAGS_NESTED_TASK 0x4000L
192#define EFLAGS_RF 0x10000
193#define EFLAGS_V86_MASK 0x20000
194#define EFLAGS_ALIGN_CHECK 0x40000
195#define EFLAGS_VIF 0x80000
196#define EFLAGS_VIP 0x100000
197#define EFLAGS_ID 0x200000
198#define EFLAGS_USER_SANITIZE 0x3F4DD7
199#define EFLAG_SIGN 0x8000
200#define EFLAG_ZERO 0x4000
201#define EFLAGS_TF_MASK 0x0100
202#define EFLAGS_TF_SHIFT 0x0008
203#define EFLAGS_ID_MASK 0x200000
204#define EFLAGS_IF_MASK 0x0200
205#define EFLAGS_IF_SHIFT 0x0009
210#define XSW_INVALID_OPERATION 0x0001
211#define XSW_DENORMAL 0x0002
212#define XSW_ZERO_DIVIDE 0x0004
213#define XSW_OVERFLOW 0x0008
214#define XSW_UNDERFLOW 0x0010
215#define XSW_PRECISION 0x0020
216#define XCW_INVALID_OPERATION 0x0080
217#define XCW_DENORMAL 0x0100
218#define XCW_ZERO_DIVIDE 0x0200
219#define XCW_OVERFLOW 0x0400
220#define XCW_UNDERFLOW 0x0800
221#define XCW_PRECISION 0x1000
222#define XCW_ROUND_CONTROL 0x6000
223#define XCW_FLUSH_ZERO 0x8000
224#define XSW_ERROR_MASK 0x003F
225#define XSW_ERROR_SHIFT 7
230#define FSW_INVALID_OPERATION 0x0001
231#define FSW_DENORMAL 0x0002
232#define FSW_ZERO_DIVIDE 0x0004
233#define FSW_OVERFLOW 0x0008
234#define FSW_UNDERFLOW 0x0010
235#define FSW_PRECISION 0x0020
236#define FSW_STACK_FAULT 0x0040
237#define FSW_ERROR_SUMMARY 0x0080
238#define FSW_CONDITION_CODE_0 0x0100
239#define FSW_CONDITION_CODE_1 0x0200
240#define FSW_CONDITION_CODE_2 0x0400
241#define FSW_CONDITION_CODE_3 0x4000
242#define FSW_ERROR_MASK 0x003F
247#define MSR_EFER 0xC0000080
248#define MSR_STAR 0xC0000081
249#define MSR_LSTAR 0xC0000082
250#define MSR_CSTAR 0xC0000083
251#define MSR_SYSCALL_MASK 0xC0000084
252#define MSR_FS_BASE 0xC0000100
253#define MSR_GS_BASE 0xC0000101
254#define MSR_GS_SWAP 0xC0000102
255#define MSR_MCG_STATUS 0x017A
256#define MSR_AMD_ACCESS 0x9C5A203A
257#define MSR_IA32_MISC_ENABLE 0x000001A0
258#define MSR_LAST_BRANCH_FROM 0x01DB
259#define MSR_LAST_BRANCH_TO 0x01DC
260#define MSR_LAST_EXCEPTION_FROM 0x01DD
261#define MSR_LAST_EXCEPTION_TO 0x01DE
276#define MSR_SCE 0x0001
277#define MSR_LME 0x0100
278#define MSR_LMA 0x0400
279#define MSR_NXE 0x0800
280#define MSR_PAT 0x0277
281#define MSR_DEBUG_CTL 0x01D9
286#define MSR_XD_ENABLE_MASK 0xFFFFFFFB
291#define MSR_DEBUG_CTL_LBR 0x0001
292#define MSR_DEBUG_CTL_BTF 0x0002
300#define IPI_PACKET_READY 8
301#define IPI_SYNCH_REQUEST 16
311#define IPI_FROZEN_STATE_RUNNING 0
312#define IPI_FROZEN_STATE_FROZEN 2
313#define IPI_FROZEN_STATE_THAW 3
314#define IPI_FROZEN_STATE_OWNER 4
315#define IPI_FROZEN_STATE_TARGET_FREEZE 5
316#define IPI_FROZEN_FLAG_ACTIVE 0x20
321#define PRCB_MINOR_VERSION 1
322#define PRCB_MAJOR_VERSION 1
323#define PRCB_BUILD_DEBUG 1
324#define PRCB_BUILD_UNIPROCESSOR 2
329#define KEXCEPTION_ACTIVE_INTERRUPT_FRAME 0x0000
330#define KEXCEPTION_ACTIVE_EXCEPTION_FRAME 0x0001
331#define KEXCEPTION_ACTIVE_SERVICE_FRAME 0x0002
336#define INITIAL_STALL_COUNT 100
337#define MM_HAL_VA_START 0xFFFFFFFFFFC00000ULL
338#define MM_HAL_VA_END 0xFFFFFFFFFFFFFFFFULL
339#define APIC_BASE 0xFFFFFFFFFFFE0000ULL
344#define IO_ACCESS_MAP_NONE 0
345#define IOPM_OFFSET FIELD_OFFSET(KTSS, IoMaps[0].IoMap)
346#define KiComputeIopmOffset(MapNumber) \
347 (MapNumber == IO_ACCESS_MAP_NONE) ? \
348 (USHORT)(sizeof(KTSS)) : \
349 (USHORT)(FIELD_OFFSET(KTSS, IoMaps[MapNumber-1].IoMap))
354#define KSEG0_BASE 0xfffff80000000000ULL
356#define NMI_STACK_SIZE 0x2000
357#define ISR_STACK_SIZE 0x6000
363#define SYNCH_LEVEL DISPATCH_LEVEL
365#define SYNCH_LEVEL (IPI_LEVEL - 2)
371#define NUMBER_POOL_LOOKASIDE_LISTS 32
480#ifndef _LDT_ENTRY_DEFINED
481#define _LDT_ENTRY_DEFINED
522#define KGDTENTRY KGDTENTRY64
523#define PKGDTENTRY PKGDTENTRY64
564#define KIDTENTRY KIDTENTRY64
565#define PKIDTENTRY PKIDTENTRY64
574#ifndef NTOS_MODE_USER
619#if (NTDDI_VERSION < NTDDI_LONGHORN)
620#define GENERAL_LOOKASIDE_POOL PP_LOOKASIDE_LIST
642#if (NTDDI_VERSION >= NTDDI_LONGHORN)
653#if (NTDDI_VERSION >= NTDDI_LONGHORN)
666#if (NTDDI_VERSION >= NTDDI_LONGHORN)
685#if (NTDDI_VERSION >= NTDDI_LONGHORN)
693#if (NTDDI_VERSION >= NTDDI_LONGHORN)
700#if (NTDDI_VERSION >= NTDDI_LONGHORN)
716#if (NTDDI_VERSION < NTDDI_LONGHORN)
722#if (NTDDI_VERSION < NTDDI_LONGHORN)
730#if (NTDDI_VERSION >= NTDDI_LONGHORN)
750#if (NTDDI_VERSION < NTDDI_LONGHORN)
762#if (NTDDI_VERSION >= NTDDI_LONGHORN)
784#if (NTDDI_VERSION >= NTDDI_LONGHORN)
791#if (NTDDI_VERSION >= NTDDI_LONGHORN)
795#if (NTDDI_VERSION >= NTDDI_LONGHORN)
807#if (NTDDI_VERSION >= NTDDI_LONGHORN)
812#if (NTDDI_VERSION >= NTDDI_LONGHORN)
825#if (NTDDI_VERSION >= NTDDI_LONGHORN)
838#if (NTDDI_VERSION >= NTDDI_LONGHORN)
847#if (NTDDI_VERSION >= NTDDI_LONGHORN)
920 ULONG KeFirstLevelTbFills;
921 ULONG KeFloatingEmulationCount;
923 ULONG KeSecondLevelTbFills;
933 ULONG FeatureBitsHigh;
1007#define PKTSS PKTSS64
1019#if (NTDDI_VERSION >= NTDDI_WIN8)
1035#if (NTDDI_VERSION < NTDDI_WIN8)
1040#if (NTDDI_VERSION >= NTDDI_WIN8)
1137#define PROCESSOR_START_FLAG_FORCE_ENABLE_NX 0x0001
unsigned long long UINT64
EXCEPTION_ROUTINE * PEXCEPTION_ROUTINE
struct _KSPECIAL_REGISTERS * PKSPECIAL_REGISTERS
struct _KIDT_ACCESS KIDT_ACCESS
struct _KTRAP_FRAME KTRAP_FRAME
struct _KREQUEST_PACKET * PKREQUEST_PACKET
struct _KDESCRIPTOR * PKDESCRIPTOR
struct _KPROCESSOR_STATE * PKPROCESSOR_STATE
union _KGDTENTRY64 * PKGDTENTRY64
struct _KREQUEST_PACKET KREQUEST_PACKET
struct _KUSER_EXCEPTION_STACK * PKUSER_EXCEPTION_STACK
struct _KSTART_FRAME KSTART_FRAME
struct _REQUEST_MAILBOX * PREQUEST_MAILBOX
struct _KPROCESSOR_START_BLOCK * PKPROCESSOR_START_BLOCK
struct _KSWITCH_FRAME KSWITCH_FRAME
struct _DISPATCHER_CONTEXT * PDISPATCHER_CONTEXT
struct _REQUEST_MAILBOX REQUEST_MAILBOX
KEXCEPTION_FRAME KCALLOUT_FRAME
struct _KUSER_EXCEPTION_STACK KUSER_EXCEPTION_STACK
struct _KEXCEPTION_FRAME * PKEXCEPTION_FRAME
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
struct _DISPATCHER_CONTEXT DISPATCHER_CONTEXT
struct _KiIoAccessMap KIIO_ACCESS_MAP
struct _KDESCRIPTOR KDESCRIPTOR
struct _MACHINE_FRAME MACHINE_FRAME
struct _KSWITCH_FRAME * PKSWITCH_FRAME
struct _UCALLOUT_FRAME * PUCALLOUT_FRAME
KEXCEPTION_FRAME * PKCALLOUT_FRAME
union _KIDTENTRY64 * PKIDTENTRY64
union _KGDTENTRY64 KGDTENTRY64
union _KIDTENTRY64 KIDTENTRY64
struct _MACHINE_FRAME * PMACHINE_FRAME
struct _KSTART_FRAME * PKSTART_FRAME
struct _KEXCEPTION_FRAME KEXCEPTION_FRAME
struct _KTRAP_FRAME * PKTRAP_FRAME
struct _KPROCESSOR_START_BLOCK KPROCESSOR_START_BLOCK
struct _KSPECIAL_REGISTERS KSPECIAL_REGISTERS
union _CPU_INFO * PCPU_INFO
struct _KIDT_ACCESS * PKIDT_ACCESS
struct _KPROCESSOR_STATE KPROCESSOR_STATE
struct _UCALLOUT_FRAME UCALLOUT_FRAME
#define NUMBER_POOL_LOOKASIDE_LISTS
struct _RUNTIME_FUNCTION * FunctionEntry
struct _UNWIND_HISTORY_TABLE * HistoryTable
PEXCEPTION_ROUTINE LanguageHandler
ULONG SecondLevelCacheSize
UCHAR SecondLevelCacheAssociativity
struct _KPRCB * CurrentPrcb
union _KGDTENTRY64 * GdtBase
PKSPIN_LOCK_QUEUE LockArray
union _KIDTENTRY64 * IdtBase
UCHAR CoresPerPhysicalProcessor
ULONG CcCopyReadNoWaitMiss
ULONG CcLostDelayedWrites
KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock]
PROCESSOR_POWER_STATE PowerState
struct _KTHREAD * IdleThread
GENERAL_LOOKASIDE_POOL PPPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
struct _KPRCB * MultiThreadSetMaster
LONG MaximumDpcQueueDepth
ULONG CcPinReadNoWaitMiss
ULONG CachedResidentAvailable
ULONG CcPinMappedDataCount
ULONG CcMdlReadNoWaitMiss
UCHAR LogicalProcessorsPerPhysicalProcessor
GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
PP_LOOKASIDE_LIST PPLookasideList[16]
ULONG CcMapDataNoWaitMiss
LONG MmMappedWriteIoCount
ULONG KeExceptionDispatchCount
ULONG CcFastMdlReadNoWait
struct _KTHREAD * CurrentThread
LARGE_INTEGER IoReadTransferCount
struct _KTHREAD * NextThread
REQUEST_MAILBOX RequestMailbox[64]
LONG MmMappedPagesWriteCount
LONG MmCacheTransitionCount
ULONG CcFastReadResourceMiss
LARGE_INTEGER IoOtherTransferCount
LONG IoReadOperationCount
SLIST_HEADER HypercallPageList
UINT64 PackageProcessorSet
UINT64 CacheProcessorMask[5]
LONG IoWriteOperationCount
LONG IoOtherOperationCount
PVOID HypercallPageVirtual
struct _KNODE * ParentNode
UCHAR DpcInterruptRequested
UCHAR LogicalProcessorsPerCore
LARGE_INTEGER UpdateSignature
UINT64 MultiThreadProcessorSet
KPROCESSOR_STATE ProcessorState
LONG MmDirtyPagesWriteCount
LIST_ENTRY DispatcherReadyListHead[32]
ULONG CcFastMdlReadNotPossible
LARGE_INTEGER IoWriteTransferCount
ULONG CcLazyWriteHotSpots
ULONG KeAlignmentFixupCount
ULONG CcFastReadNotPossible
SINGLE_LIST_ENTRY DeferredReadyListHead
ULONG CcFastMdlReadResourceMiss
SLIST_HEADER InterruptObjectPool
KPROCESSOR_STATE ProcessorState
UCHAR LmIdentityTarget[6]
struct _KPROCESSOR_START_BLOCK * SelfMap
KSPECIAL_REGISTERS SpecialRegisters
ULONG64 LastExceptionToRip
ULONG64 LastBranchFromRip
ULONG64 LastExceptionFromRip
UINT64 LastExceptionFromRip
UINT64 LastExceptionToRip
MACHINE_FRAME MachineFrame
EXCEPTION_RECORD ExceptionRecord
KREQUEST_PACKET RequestPacket
MACHINE_FRAME MachineFrame
#define FIELD_OFFSET(t, f)
struct _KGDTENTRY64::@2314::@2316::@2319 Bits
struct _KGDTENTRY64::@2314::@2316::@2318 Bytes