- Fix KiDispatchException to unmask KI_EXCEPTION_INTERNAL when setting the exception...
[reactos.git] / reactos / include / ndk / ketypes.h
index 0d797df..83354dd 100644 (file)
-/*
- * PROJECT:         ReactOS Native Headers
- * FILE:            include/ndk/ketypes.h
- * PURPOSE:         Definitions for Kernel Types not defined in DDK/IFS
- * PROGRAMMER:      Alex Ionescu (alex@relsoft.net)
- * UPDATE HISTORY:
- *                  Created 06/10/04
- */
+/*++ NDK Version: 0098
+
+Copyright (c) Alex Ionescu.  All rights reserved.
+
+Header Name:
+
+    lpctypes.h
+
+Abstract:
+
+    Type definitions for the Loader.
+
+Author:
+
+    Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
+
+--*/
+
 #ifndef _KETYPES_H
 #define _KETYPES_H
 
-/* DEPENDENCIES **************************************************************/
-#include "haltypes.h"
-#include "potypes.h"
-#include "mmtypes.h"
-#include <arc/arc.h>
+//
+// Dependencies
+//
+#include <umtypes.h>
+#ifndef NTOS_MODE_USER
+#include <haltypes.h>
+#include <potypes.h>
+#include <ifssupp.h>
+#endif
+
+//
+// Context Record Flags
+//
+#define CONTEXT_DEBUGGER                (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
+
+//
+// Maximum System Descriptor Table Entries
+//
+#define SSDT_MAX_ENTRIES                2
+
+//
+// Processor Architectures
+//
+#define PROCESSOR_ARCHITECTURE_INTEL    0
+
+//
+// Object Type Mask for Kernel Dispatcher Objects
+//
+#define KOBJECT_TYPE_MASK               0x7F
+#define KOBJECT_LOCK_BIT                0x80
 
-/* CONSTANTS *****************************************************************/
-#define SSDT_MAX_ENTRIES 4
-#define PROCESSOR_FEATURE_MAX 64
+//
+// Dispatcher Priority increments
+//
+#define THREAD_ALERT_INCREMENT          2
 
-#define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
+//
+// User Shared Data in Kernel-Mode
+//
+#define KI_USER_SHARED_DATA             0xffdf0000
 
-#define THREAD_WAIT_OBJECTS 4
+//
+// Physical memory offset of KUSER_SHARED_DATA
+//
+#define KI_USER_SHARED_DATA_PHYSICAL    0x41000
 
-/* EXPORTED DATA *************************************************************/
-extern CHAR NTOSAPI KeNumberProcessors;
-extern LOADER_PARAMETER_BLOCK NTOSAPI KeLoaderBlock;
-extern ULONG NTOSAPI KeDcacheFlushCount;
-extern ULONG NTOSAPI KeIcacheFlushCount;
-extern KAFFINITY NTOSAPI KeActiveProcessors;
-extern ULONG NTOSAPI KiDmaIoCoherency; /* RISC Architectures only */
-extern ULONG NTOSAPI KeMaximumIncrement;
-extern ULONG NTOSAPI KeMinimumIncrement;
-extern ULONG NTOSAPI NtBuildNumber;
-extern SSDT_ENTRY NTOSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
-extern SSDT_ENTRY NTOSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
+//
+// Quantum values and decrements
+//
+#define MAX_QUANTUM                     0x7F
+#define WAIT_QUANTUM_DECREMENT          1
+#define CLOCK_QUANTUM_DECREMENT         3
 
-/* ENUMERATIONS **************************************************************/
+//
+// Kernel Feature Bits
+//
+#define KF_V86_VIS                      0x00000001
+#define KF_RDTSC                        0x00000002
+#define KF_CR4                          0x00000004
+#define KF_CMOV                         0x00000008
+#define KF_GLOBAL_PAGE                  0x00000010
+#define KF_LARGE_PAGE                   0x00000020
+#define KF_MTRR                         0x00000040
+#define KF_CMPXCHG8B                    0x00000080
+#define KF_MMX                          0x00000100
+#define KF_WORKING_PTE                  0x00000200
+#define KF_PAT                          0x00000400
+#define KF_FXSR                         0x00000800
+#define KF_FAST_SYSCALL                 0x00001000
+#define KF_XMMI                         0x00002000
+#define KF_3DNOW                        0x00004000
+#define KF_AMDK6MTRR                    0x00008000
+#define KF_XMMI64                       0x00010000
+#define KF_DTS                          0x00020000
+#define KF_NX_BIT                       0x20000000
+#define KF_NX_DISABLED                  0x40000000
+#define KF_NX_ENABLED                   0x80000000
 
-/* TYPES *********************************************************************/
+//
+// Internal Exception Codes
+//
+#define KI_EXCEPTION_INTERNAL           0x10000000
+#define KI_EXCEPTION_ACCESS_VIOLATION   (KI_EXCEPTION_INTERNAL | 0x04)
 
-typedef struct _CONFIGURATION_COMPONENT_DATA
+//
+// KPCR Access for non-IA64 builds
+//
+#define K0IPCR                          ((ULONG_PTR)(KIP0PCRADDRESS))
+#define PCR                             ((volatile KPCR * const)K0IPCR)
+#if !defined(CONFIG_SMP) && !defined(NT_BUILD)
+#define KeGetPcr()                      PCR
+#else
+#define KeGetPcr()                      ((volatile KPCR * const)__readfsdword(0x1C))
+#endif
+
+//
+// Number of dispatch codes supported by KINTERRUPT
+//
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+#define KINTERRUPT_DISPATCH_CODES       135
+#else
+#define KINTERRUPT_DISPATCH_CODES       106
+#endif
+
+#ifdef NTOS_MODE_USER
+
+//
+// KPROCESSOR_MODE Type
+//
+typedef CCHAR KPROCESSOR_MODE;
+
+//
+// Dereferencable pointer to KUSER_SHARED_DATA in User-Mode
+//
+#define SharedUserData                  ((KUSER_SHARED_DATA *CONST)USER_SHARED_DATA)
+
+//
+// Maximum WOW64 Entries in KUSER_SHARED_DATA
+//
+#define MAX_WOW64_SHARED_ENTRIES        16
+
+//
+// Maximum Processor Features supported in KUSER_SHARED_DATA
+//
+#define PROCESSOR_FEATURE_MAX           64
+
+//
+// Event Types
+//
+typedef enum _EVENT_TYPE
 {
-    struct _CONFIGURATION_COMPONENT_DATA *Parent;
-    struct _CONFIGURATION_COMPONENT_DATA *Child;
-    struct _CONFIGURATION_COMPONENT_DATA *Sibling;
-    CONFIGURATION_COMPONENT Component;
-} CONFIGURATION_COMPONENT_DATA, *PCONFIGURATION_COMPONENT_DATA;
+    NotificationEvent,
+    SynchronizationEvent
+} EVENT_TYPE;
 
-typedef enum _KAPC_ENVIRONMENT
+//
+// Timer Types
+//
+typedef enum _TIMER_TYPE
 {
-    OriginalApcEnvironment,
-    AttachedApcEnvironment,
-    CurrentApcEnvironment
-} KAPC_ENVIRONMENT;
+    NotificationTimer,
+    SynchronizationTimer
+} TIMER_TYPE;
 
-typedef struct _KDPC_DATA
+//
+// Wait Types
+//
+typedef enum _WAIT_TYPE
 {
-    LIST_ENTRY  DpcListHead;
-    ULONG  DpcLock;
-    ULONG  DpcQueueDepth;
-    ULONG  DpcCount;
-} KDPC_DATA, *PKDPC_DATA;
+    WaitAll,
+    WaitAny
+} WAIT_TYPE;
+
+//
+// Processor Execution Modes
+//
+typedef enum _MODE
+{
+    KernelMode,
+    UserMode,
+    MaximumMode
+} MODE;
+
+//
+// Wait Reasons
+//
+typedef enum _KWAIT_REASON
+{
+    Executive,
+    FreePage,
+    PageIn,
+    PoolAllocation,
+    DelayExecution,
+    Suspended,
+    UserRequest,
+    WrExecutive,
+    WrFreePage,
+    WrPageIn,
+    WrPoolAllocation,
+    WrDelayExecution,
+    WrSuspended,
+    WrUserRequest,
+    WrEventPair,
+    WrQueue,
+    WrLpcReceive,
+    WrLpcReply,
+    WrVirtualMemory,
+    WrPageOut,
+    WrRendezvous,
+    Spare2,
+    WrGuardedMutex,
+    Spare4,
+    Spare5,
+    Spare6,
+    WrKernel,
+    WrResource,
+    WrPushLock,
+    WrMutex,
+    WrQuantumEnd,
+    WrDispatchInt,
+    WrPreempted,
+    WrYieldExecution,
+    MaximumWaitReason
+} KWAIT_REASON;
+
+//
+// Profiling Sources
+//
+typedef enum _KPROFILE_SOURCE
+{
+    ProfileTime,
+    ProfileAlignmentFixup,
+    ProfileTotalIssues,
+    ProfilePipelineDry,
+    ProfileLoadInstructions,
+    ProfilePipelineFrozen,
+    ProfileBranchInstructions,
+    ProfileTotalNonissues,
+    ProfileDcacheMisses,
+    ProfileIcacheMisses,
+    ProfileCacheMisses,
+    ProfileBranchMispredictions,
+    ProfileStoreInstructions,
+    ProfileFpInstructions,
+    ProfileIntegerInstructions,
+    Profile2Issue,
+    Profile3Issue,
+    Profile4Issue,
+    ProfileSpecialInstructions,
+    ProfileTotalCycles,
+    ProfileIcacheIssues,
+    ProfileDcacheAccesses,
+    ProfileMemoryBarrierCycles,
+    ProfileLoadLinkedIssues,
+    ProfileMaximum
+} KPROFILE_SOURCE;
 
-/* We don't want to force NTIFS usage only for a single structure */
-#ifndef _NTIFS_
-typedef struct _KAPC_STATE
+//
+// NT Product and Architecture Types
+//
+typedef enum _NT_PRODUCT_TYPE
 {
-    LIST_ENTRY  ApcListHead[2];
-    PKPROCESS   Process;
-    BOOLEAN     KernelApcInProgress;
-    BOOLEAN     KernelApcPending;
-    BOOLEAN     UserApcPending;
-} KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
+    NtProductWinNt = 1,
+    NtProductLanManNt,
+    NtProductServer
+} NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
+
+typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
+{
+    StandardDesign,
+    NEC98x86,
+    EndAlternatives
+} ALTERNATIVE_ARCHITECTURE_TYPE;
+
 #endif
 
-/* FIXME: Most of these should go to i386 directory */
-typedef struct _FNSAVE_FORMAT
-{
-    ULONG ControlWord;
-    ULONG StatusWord;
-    ULONG TagWord;
-    ULONG ErrorOffset;
-    ULONG ErrorSelector;
-    ULONG DataOffset;
-    ULONG DataSelector;
-    UCHAR RegisterArea[80];
-} FNSAVE_FORMAT, *PFNSAVE_FORMAT;
-
-typedef struct _FXSAVE_FORMAT
-{
-    USHORT ControlWord;
-    USHORT StatusWord;
-    USHORT TagWord;
-    USHORT ErrorOpcode;
-    ULONG ErrorOffset;
-    ULONG ErrorSelector;
-    ULONG DataOffset;
-    ULONG DataSelector;
-    ULONG MXCsr;
-    ULONG MXCsrMask;
-    UCHAR RegisterArea[128];
-    UCHAR Reserved3[128];
-    UCHAR Reserved4[224];
-    UCHAR Align16Byte[8];
-} FXSAVE_FORMAT, *PFXSAVE_FORMAT;
-
-typedef struct _FX_SAVE_AREA
+//
+// Thread States
+//
+typedef enum _KTHREAD_STATE
 {
-    union
-    {
-        FNSAVE_FORMAT FnArea;
-        FXSAVE_FORMAT FxArea;
-    } U;
-    ULONG NpxSavedCpu;
-    ULONG Cr0NpxState;
-} FX_SAVE_AREA, *PFX_SAVE_AREA;
-
-typedef struct _KTRAP_FRAME
-{
-    PVOID DebugEbp;
-    PVOID DebugEip;
-    PVOID DebugArgMark;
-    PVOID DebugPointer;
-    PVOID TempCs;
-    PVOID TempEip;
-    ULONG Dr0;
-    ULONG Dr1;
-    ULONG Dr2;
-    ULONG Dr3;
-    ULONG Dr6;
-    ULONG Dr7;
-    USHORT Gs;
-    USHORT Reserved1;
-    USHORT Es;
-    USHORT Reserved2;
-    USHORT Ds;
-    USHORT Reserved3;
-    ULONG Edx;
-    ULONG Ecx;
-    ULONG Eax;
-    ULONG PreviousMode;
-    PVOID ExceptionList;
-    USHORT Fs;
-    USHORT Reserved4;
-    ULONG Edi;
-    ULONG Esi;
-    ULONG Ebx;
-    ULONG Ebp;
-    ULONG ErrorCode;
-    ULONG Eip;
-    ULONG Cs;
-    ULONG Eflags;
-    ULONG Esp;
-    USHORT Ss;
-    USHORT Reserved5;
-    USHORT V86_Es;
-    USHORT Reserved6;
-    USHORT V86_Ds;
-    USHORT Reserved7;
-    USHORT V86_Fs;
-    USHORT Reserved8;
-    USHORT V86_Gs;
-    USHORT Reserved9;
-} KTRAP_FRAME, *PKTRAP_FRAME;
-
-/* FIXME: Win32k uses windows.h! */
-#ifndef __WIN32K__
-typedef struct _LDT_ENTRY
-{
-    WORD LimitLow;
-    WORD BaseLow;
-    union
-    {
-        struct
-        {
-            BYTE BaseMid;
-            BYTE Flags1;
-            BYTE Flags2;
-            BYTE BaseHi;
-        } Bytes;
-        struct
-        {
-            DWORD BaseMid : 8;
-            DWORD Type : 5;
-            DWORD Dpl : 2;
-            DWORD Pres : 1;
-            DWORD LimitHi : 4;
-            DWORD Sys : 1;
-            DWORD Reserved_0 : 1;
-            DWORD Default_Big : 1;
-            DWORD Granularity : 1;
-            DWORD BaseHi : 8;
-        } Bits;
-    } HighWord;
-} LDT_ENTRY, *PLDT_ENTRY, *LPLDT_ENTRY;
+    Initialized,
+    Ready,
+    Running,
+    Standby,
+    Terminated,
+    Waiting,
+    Transition,
+    DeferredReady,
+#if (NTDDI_VERSION >= NTDDI_WS03)
+    GateWait,
 #endif
+} KTHREAD_STATE, *PKTHREAD_STATE;
+
+//
+// Adjust reasons
+//
+typedef enum _ADJUST_REASON
+{
+    AdjustNone = 0,
+    AdjustUnwait = 1,
+    AdjustBoost = 2
+} ADJUST_REASON;
+
+//
+// Continue Status
+//
+typedef enum _KCONTINUE_STATUS
+{
+    ContinueError = 0,
+    ContinueSuccess,
+    ContinueProcessorReselected,
+    ContinueNextProcessor
+} KCONTINUE_STATUS;
+
+//
+// Process States
+//
+typedef enum _KPROCESS_STATE
+{
+    ProcessInMemory,
+    ProcessOutOfMemory,
+    ProcessInTransition,
+    ProcessInSwap,
+    ProcessOutSwap,
+} KPROCESS_STATE, *PKPROCESS_STATE;
+
+//
+// NtVdmControl Classes
+//
+typedef enum _VDMSERVICECLASS
+{
+   VdmStartExecution = 0,
+   VdmQueueInterrupt = 1,
+   VdmDelayInterrupt = 2,
+   VdmInitialize = 3,
+   VdmFeatures = 4,
+   VdmSetInt21Handler = 5,
+   VdmQueryDir = 6,
+   VdmPrinterDirectIoOpen = 7,
+   VdmPrinterDirectIoClose = 8,
+   VdmPrinterInitialize = 9,
+   VdmSetLdtEntries = 10,
+   VdmSetProcessLdtInfo = 11,
+   VdmAdlibEmulation = 12,
+   VdmPMCliControl = 13,
+   VdmQueryVdmProcess = 14,
+} VDMSERVICECLASS;
+
+#ifdef NTOS_MODE_USER
+
+//
+// APC Normal Routine
+//
+typedef VOID
+(NTAPI *PKNORMAL_ROUTINE)(
+    IN PVOID NormalContext,
+    IN PVOID SystemArgument1,
+    IN PVOID SystemArgument2
+);
+
+//
+// Timer Routine
+//
+typedef VOID
+(NTAPI *PTIMER_APC_ROUTINE)(
+    IN PVOID TimerContext,
+    IN ULONG TimerLowValue,
+    IN LONG TimerHighValue
+);
+
+//
+// System Time Structure
+//
+typedef struct _KSYSTEM_TIME
+{
+    ULONG LowPart;
+    LONG High1Time;
+    LONG High2Time;
+} KSYSTEM_TIME, *PKSYSTEM_TIME;
 
-typedef struct _KGDTENTRY
+//
+// Shared Kernel User Data
+//
+typedef struct _KUSER_SHARED_DATA
 {
-    USHORT LimitLow;
-    USHORT BaseLow;
+    ULONG TickCountLowDeprecated;
+    ULONG TickCountMultiplier;
+    volatile KSYSTEM_TIME InterruptTime;
+    volatile KSYSTEM_TIME SystemTime;
+    volatile KSYSTEM_TIME TimeZoneBias;
+    USHORT ImageNumberLow;
+    USHORT ImageNumberHigh;
+    WCHAR NtSystemRoot[260];
+    ULONG MaxStackTraceDepth;
+    ULONG CryptoExponent;
+    ULONG TimeZoneId;
+    ULONG LargePageMinimum;
+    ULONG Reserved2[7];
+    NT_PRODUCT_TYPE NtProductType;
+    BOOLEAN ProductTypeIsValid;
+    ULONG NtMajorVersion;
+    ULONG NtMinorVersion;
+    BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
+    ULONG Reserved1;
+    ULONG Reserved3;
+    volatile ULONG TimeSlip;
+    ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
+    LARGE_INTEGER SystemExpirationDate;
+    ULONG SuiteMask;
+    BOOLEAN KdDebuggerEnabled;
+#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
+    UCHAR NXSupportPolicy;
+#endif
+    volatile ULONG ActiveConsoleId;
+    volatile ULONG DismountCount;
+    ULONG ComPlusPackage;
+    ULONG LastSystemRITEventTickCount;
+    ULONG NumberOfPhysicalPages;
+    BOOLEAN SafeBootMode;
+    ULONG TraceLogging;
+    ULONG Fill0;
+    ULONGLONG TestRetInstruction;
+    ULONG SystemCall;
+    ULONG SystemCallReturn;
+    ULONGLONG SystemCallPad[3];
+    union {
+        volatile KSYSTEM_TIME TickCount;
+        volatile ULONG64 TickCountQuad;
+    };
+    ULONG Cookie;
+#if (NTDDI_VERSION >= NTDDI_WS03)
+    LONGLONG ConsoleSessionForegroundProcessId;
+    ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
+#endif
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    USHORT UserModeGlobalLogger[8];
+    ULONG HeapTracingPid[2];
+    ULONG CritSecTracingPid[2];
     union
     {
+        ULONG SharedDataFlags;
         struct
         {
-            UCHAR BaseMid;
-            UCHAR Flags1;
-            UCHAR Flags2;
-            UCHAR BaseHi;
-        } Bytes;
-        struct
-        {
-            ULONG BaseMid       : 8;
-            ULONG Type          : 5;
-            ULONG Dpl           : 2;
-            ULONG Pres          : 1;
-            ULONG LimitHi       : 4;
-            ULONG Sys           : 1;
-            ULONG Reserved_0    : 1;
-            ULONG Default_Big   : 1;
-            ULONG Granularity   : 1;
-            ULONG BaseHi        : 8;
-        } Bits;
-    } HighWord;
-} KGDTENTRY, *PKGDTENTRY;
-
-typedef struct _KIDTENTRY
-{
-    USHORT Offset;
-    USHORT Selector;
-    USHORT Access;
-    USHORT ExtendedOffset;
-} KIDTENTRY, *PKIDTENTRY;
-
-typedef struct _HARDWARE_PTE_X86
-{
-    ULONG Valid             : 1;
-    ULONG Write             : 1;
-    ULONG Owner             : 1;
-    ULONG WriteThrough      : 1;
-    ULONG CacheDisable      : 1;
-    ULONG Accessed          : 1;
-    ULONG Dirty             : 1;
-    ULONG LargePage         : 1;
-    ULONG Global            : 1;
-    ULONG CopyOnWrite       : 1;
-    ULONG Prototype         : 1;
-    ULONG reserved          : 1;
-    ULONG PageFrameNumber   : 20;
-} HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
-
-#pragma pack(push,4)
-
-/* Fixme: Use correct types? */
-typedef struct _KPROCESSOR_STATE
-{
-    PCONTEXT ContextFrame;
-    PVOID SpecialRegisters;
-} KPROCESSOR_STATE;
-
-/* Processor Control Block */
-typedef struct _KPRCB
-{
-    USHORT MinorVersion;
-    USHORT MajorVersion;
-    struct _KTHREAD *CurrentThread;
-    struct _KTHREAD *NextThread;
-    struct _KTHREAD *IdleThread;
-    UCHAR Number;
-    UCHAR Reserved;
-    USHORT BuildType;
-    ULONG SetMember;
-    UCHAR CpuType;
-    UCHAR CpuID;
-    USHORT CpuStep;
-    KPROCESSOR_STATE ProcessorState;
-    ULONG KernelReserved[16];
-    ULONG HalReserved[16];
-    UCHAR PrcbPad0[92];
-    PVOID LockQueue[33]; // Used for Queued Spinlocks
-    struct _KTHREAD *NpxThread;
-    ULONG InterruptCount;
-    ULONG KernelTime;
-    ULONG UserTime;
-    ULONG DpcTime;
-    ULONG DebugDpcTime;
-    ULONG InterruptTime;
-    ULONG AdjustDpcThreshold;
-    ULONG PageColor;
-    UCHAR SkipTick;
-    UCHAR DebuggerSavedIRQL;
-    UCHAR Spare1[6];
-    struct _KNODE *ParentNode;
-    ULONG MultiThreadProcessorSet;
-    struct _KPRCB *MultiThreadSetMaster;
-    ULONG ThreadStartCount[2];
-    ULONG CcFastReadNoWait;
-    ULONG CcFastReadWait;
-    ULONG CcFastReadNotPossible;
-    ULONG CcCopyReadNoWait;
-    ULONG CcCopyReadWait;
-    ULONG CcCopyReadNoWaitMiss;
-    ULONG KeAlignmentFixupCount;
-    ULONG KeContextSwitches;
-    ULONG KeDcacheFlushCount;
-    ULONG KeExceptionDispatchCount;
-    ULONG KeFirstLevelTbFills;
-    ULONG KeFloatingEmulationCount;
-    ULONG KeIcacheFlushCount;
-    ULONG KeSecondLevelTbFills;
-    ULONG KeSystemCalls;
-    ULONG IoReadOperationCount;
-    ULONG IoWriteOperationCount;
-    ULONG IoOtherOperationCount;
-    LARGE_INTEGER IoReadTransferCount;
-    LARGE_INTEGER IoWriteTransferCount;
-    LARGE_INTEGER IoOtherTransferCount;
-    ULONG SpareCounter1[8];
-    PP_LOOKASIDE_LIST PPLookasideList[16];
-    PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
-    PP_LOOKASIDE_LIST PPPagedLookasideList[32];
-    ULONG PacketBarrier;
-    ULONG ReverseStall;
-    PVOID IpiFrame;
-    UCHAR PrcbPad2[52];
-    PVOID CurrentPacket[3];
-    ULONG TargetSet;
-    ULONG_PTR WorkerRoutine;
-    ULONG IpiFrozen;
-    UCHAR PrcbPad3[40];
-    ULONG RequestSummary;
-    struct _KPRCB *SignalDone;
-    UCHAR PrcbPad4[56];
-    struct _KDPC_DATA DpcData[2];
-    PVOID DpcStack;
-    ULONG MaximumDpcQueueDepth;
-    ULONG DpcRequestRate;
-    ULONG MinimumDpcRate;
-    UCHAR DpcInterruptRequested;
-    UCHAR DpcThreadRequested;
-    UCHAR DpcRoutineActive;
-    UCHAR DpcThreadActive;
-    ULONG PrcbLock;
-    ULONG DpcLastCount;
-    ULONG TimerHand;
-    ULONG TimerRequest;
-    PVOID DpcThread;
-    struct _KEVENT *DpcEvent;
-    UCHAR ThreadDpcEnable;
-    BOOLEAN QuantumEnd;
-    UCHAR PrcbPad50;
-    UCHAR IdleSchedule;
-    ULONG DpcSetEventRequest;
-    UCHAR PrcbPad5[18];
-    LONG TickOffset;
-    struct _KDPC* CallDpc;
-    ULONG PrcbPad7[8];
-    LIST_ENTRY WaitListHead;
-    ULONG ReadySummary;
-    ULONG SelectNextLast;
-    LIST_ENTRY DispatcherReadyListHead[32];
-    SINGLE_LIST_ENTRY DeferredReadyListHead;
-    ULONG PrcbPad72[11];
-    PVOID ChainedInterruptList;
-    LONG LookasideIrpFloat;
-    LONG MmPageFaultCount;
-    LONG MmCopyOnWriteCount;
-    LONG MmTransitionCount;
-    LONG MmCacheTransitionCount;
-    LONG MmDemandZeroCount;
-    LONG MmPageReadCount;
-    LONG MmPageReadIoCount;
-    LONG MmCacheReadCount;
-    LONG MmCacheIoCount;
-    LONG MmDirtyPagesWriteCount;
-    LONG MmDirtyWriteIoCount;
-    LONG MmMappedPagesWriteCount;
-    LONG MmMappedWriteIoCount;
-    ULONG SpareFields0[1];
-    CHAR VendorString[13];
-    UCHAR InitialApicId;
-    UCHAR LogicalProcessorsPerPhysicalProcessor;
-    ULONG MHz;
-    ULONG FeatureBits;
-    LARGE_INTEGER UpdateSignature;
-    LARGE_INTEGER IsrTime;
-    LARGE_INTEGER SpareField1;
-    FX_SAVE_AREA NpxSaveArea;
-    PROCESSOR_POWER_STATE PowerState;
-} KPRCB, *PKPRCB;
-
-/*
- * This is the complete, internal KPCR structure
- */
-typedef struct _KIPCR
-{
-    KPCR_TIB  Tib;                /* 00 */
-    struct _KPCR  *Self;          /* 1C */
-    struct _KPRCB  *Prcb;         /* 20 */
-    KIRQL  Irql;                  /* 24 */
-    ULONG  IRR;                   /* 28 */
-    ULONG  IrrActive;             /* 2C */
-    ULONG  IDR;                   /* 30 */
-    PVOID  KdVersionBlock;        /* 34 */
-    PUSHORT  IDT;                 /* 38 */
-    PUSHORT  GDT;                 /* 3C */
-    struct _KTSS  *TSS;           /* 40 */
-    USHORT  MajorVersion;         /* 44 */
-    USHORT  MinorVersion;         /* 46 */
-    KAFFINITY  SetMember;         /* 48 */
-    ULONG  StallScaleFactor;      /* 4C */
-    UCHAR  SparedUnused;          /* 50 */
-    UCHAR  Number;                /* 51 */
-    UCHAR  Reserved;              /* 52 */
-    UCHAR  L2CacheAssociativity;  /* 53 */
-    ULONG  VdmAlert;              /* 54 */
-    ULONG  KernelReserved[14];    /* 58 */
-    ULONG  L2CacheSize;           /* 90 */
-    ULONG  HalReserved[16];       /* 94 */
-    ULONG  InterruptMode;         /* D4 */
-    UCHAR  KernelReserved2[0x48]; /* D8 */
-    KPRCB  PrcbData;              /* 120 */
-} KIPCR, *PKIPCR;
-
-#pragma pack(pop)
+            ULONG DbgErrorPortPresent:1;
+            ULONG DbgElevationEnabled:1;
+            ULONG DbgVirtEnabled:1;
+            ULONG DbgInstallerDetectEnabled:1;
+            ULONG SpareBits:28;
+        };
+    };
+    ULONG ImageFileExecutionOptions;
+    KAFFINITY ActiveProcessorAffinity;
+#endif
+} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
 
-#include <pshpack1.h>
+//
+// VDM Structures
+//
+#include "pshpack1.h"
+typedef struct _VdmVirtualIca
+{
+    LONG ica_count[8];
+    LONG ica_int_line;
+    LONG ica_cpu_int;
+    USHORT ica_base;
+    USHORT ica_hipiri;
+    USHORT ica_mode;
+    UCHAR ica_master;
+    UCHAR ica_irr;
+    UCHAR ica_isr;
+    UCHAR ica_imr;
+    UCHAR ica_ssr;
+} VDMVIRTUALICA, *PVDMVIRTUALICA;
+#include "poppack.h"
+
+typedef struct _VdmIcaUserData
+{
+    PVOID pIcaLock;
+    PVDMVIRTUALICA pIcaMaster;
+    PVDMVIRTUALICA pIcaSlave;
+    PULONG pDelayIrq;
+    PULONG pUndelayIrq;
+    PULONG pDelayIret;
+    PULONG pIretHooked;
+    PULONG pAddrIretBopTable;
+    PHANDLE phWowIdleEvent;
+    PLARGE_INTEGER pIcaTimeout;
+    PHANDLE phMainThreadSuspended;
+} VDMICAUSERDATA, *PVDMICAUSERDATA;
+
+typedef struct _VDM_INITIALIZE_DATA
+{
+    PVOID TrapcHandler;
+    PVDMICAUSERDATA IcaUserData;
+} VDM_INITIALIZE_DATA, *PVDM_INITIALIZE_DATA;
 
-typedef struct _KTSSNOIOPM
-{
-    USHORT PreviousTask;
-    USHORT Reserved1;
-    ULONG  Esp0;
-    USHORT Ss0;
-    USHORT Reserved2;
-    ULONG  Esp1;
-    USHORT Ss1;
-    USHORT Reserved3;
-    ULONG  Esp2;
-    USHORT Ss2;
-    USHORT Reserved4;
-    ULONG  Cr3;
-    ULONG  Eip;
-    ULONG  Eflags;
-    ULONG  Eax;
-    ULONG  Ecx;
-    ULONG  Edx;
-    ULONG  Ebx;
-    ULONG  Esp;
-    ULONG  Ebp;
-    ULONG  Esi;
-    ULONG  Edi;
-    USHORT Es;
-    USHORT Reserved5;
-    USHORT Cs;
-    USHORT Reserved6;
-    USHORT Ss;
-    USHORT Reserved7;
-    USHORT Ds;
-    USHORT Reserved8;
-    USHORT Fs;
-    USHORT Reserved9;
-    USHORT Gs;
-    USHORT Reserved10;
-    USHORT Ldt;
-    USHORT Reserved11;
-    USHORT Trap;
-    USHORT IoMapBase;
-    /* no interrupt redirection map */
-    UCHAR IoBitmap[1];
-} KTSSNOIOPM;
-
-typedef struct _KTSS
-{
-    USHORT PreviousTask;
-    USHORT Reserved1;
-    ULONG  Esp0;
-    USHORT Ss0;
-    USHORT Reserved2;
-    ULONG  Esp1;
-    USHORT Ss1;
-    USHORT Reserved3;
-    ULONG  Esp2;
-    USHORT Ss2;
-    USHORT Reserved4;
-    ULONG  Cr3;
-    ULONG  Eip;
-    ULONG  Eflags;
-    ULONG  Eax;
-    ULONG  Ecx;
-    ULONG  Edx;
-    ULONG  Ebx;
-    ULONG  Esp;
-    ULONG  Ebp;
-    ULONG  Esi;
-    ULONG  Edi;
-    USHORT Es;
-    USHORT Reserved5;
-    USHORT Cs;
-    USHORT Reserved6;
-    USHORT Ss;
-    USHORT Reserved7;
-    USHORT Ds;
-    USHORT Reserved8;
-    USHORT Fs;
-    USHORT Reserved9;
-    USHORT Gs;
-    USHORT Reserved10;
-    USHORT Ldt;
-    USHORT Reserved11;
-    USHORT Trap;
-    USHORT IoMapBase;
-    /* no interrupt redirection map */
-    UCHAR  IoBitmap[8193];
-} KTSS;
+#else
 
-#include <poppack.h>
+//
+// System Thread Start Routine
+//
+typedef
+VOID
+(NTAPI *PKSYSTEM_ROUTINE)(
+    PKSTART_ROUTINE StartRoutine,
+    PVOID StartContext
+);
+
+//
+// APC Environment Types
+//
+typedef enum _KAPC_ENVIRONMENT
+{
+    OriginalApcEnvironment,
+    AttachedApcEnvironment,
+    CurrentApcEnvironment,
+    InsertApcEnvironment
+} KAPC_ENVIRONMENT;
 
-/* i386 Doesn't have Exception Frames */
-typedef struct _KEXCEPTION_FRAME
+//
+// CPU Cache Types
+//
+typedef enum _PROCESSOR_CACHE_TYPE
 {
+    CacheUnified,
+    CacheInstruction,
+    CacheData,
+    CacheTrace,
+} PROCESSOR_CACHE_TYPE;
 
-} KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
+//
+// PRCB DPC Data
+//
+typedef struct _KDPC_DATA
+{
+    LIST_ENTRY DpcListHead;
+    ULONG DpcLock;
+    volatile ULONG DpcQueueDepth;
+    ULONG DpcCount;
+} KDPC_DATA, *PKDPC_DATA;
 
+//
+// Per-Processor Lookaside List
+//
+typedef struct _PP_LOOKASIDE_LIST
+{
+    struct _GENERAL_LOOKASIDE *P;
+    struct _GENERAL_LOOKASIDE *L;
+} PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST;
+
+//
+// CPU Cache Descriptor
+//
+typedef struct _CACHE_DESCRIPTOR
+{
+    UCHAR Level;
+    UCHAR Associativity;
+    USHORT LineSize;
+    ULONG Size;
+    PROCESSOR_CACHE_TYPE Type;
+} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
+
+//
+// Architectural Types
+//
+#include <arch/ketypes.h>
+
+//
+// Kernel Memory Node
+//
+#include <pshpack1.h>
 typedef struct _KNODE
 {
-   SLIST_HEADER DeadStackList;
-   SLIST_HEADER PfnDereferenceSListHead;
-   ULONG ProcessorMask;
-   ULONG Color;
-   UCHAR Seed;
-   UCHAR NodeNumber;
-   ULONG Flags;
-   ULONG MmShiftedColor;
-   ULONG FreeCount[2];
-   struct _SINGLE_LIST_ENTRY *PfnDeferredList;
+    SLIST_HEADER DeadStackList;
+    SLIST_HEADER PfnDereferenceSListHead;
+    KAFFINITY ProcessorMask;
+    ULONG Color;
+    UCHAR Seed;
+    UCHAR NodeNumber;
+    ULONG Flags;
+    ULONG MmShiftedColor;
+    ULONG FreeCount[2];
+    struct _SINGLE_LIST_ENTRY *PfnDeferredList;
 } KNODE, *PKNODE;
+#include <poppack.h>
 
+//
+// Kernel Profile Object
+//
 typedef struct _KPROFILE
 {
     CSHORT Type;
     CSHORT Size;
-    LIST_ENTRY ListEntry;
-    PVOID RegionStart;
-    PVOID RegionEnd;
+    LIST_ENTRY ProfileListEntry;
+    struct _KPROCESS *Process;
+    PVOID RangeBase;
+    PVOID RangeLimit;
     ULONG BucketShift;
     PVOID Buffer;
-    CSHORT Source;
-    ULONG Affinity;
-    BOOLEAN Active;
-    struct _KPROCESS *Process;
+    ULONG Segment;
+    KAFFINITY Affinity;
+    KPROFILE_SOURCE Source;
+    BOOLEAN Started;
 } KPROFILE, *PKPROFILE;
 
+//
+// Kernel Interrupt Object
+//
 typedef struct _KINTERRUPT
 {
-    CSHORT              Type;
-    CSHORT              Size;
-    LIST_ENTRY          InterruptListEntry;
-    PKSERVICE_ROUTINE   ServiceRoutine;
-    PVOID               ServiceContext;
-    KSPIN_LOCK          SpinLock;
-    ULONG               TickCount;
-    PKSPIN_LOCK         ActualLock;
-    PVOID               DispatchAddress;
-    ULONG               Vector;
-    KIRQL               Irql;
-    KIRQL               SynchronizeIrql;
-    BOOLEAN             FloatingSave;
-    BOOLEAN             Connected;
-    CHAR                Number;
-    UCHAR               ShareVector;
-    KINTERRUPT_MODE     Mode;
-    ULONG               ServiceCount;
-    ULONG               DispatchCount;
-    ULONG               DispatchCode[106];
+    CSHORT Type;
+    CSHORT Size;
+    LIST_ENTRY InterruptListEntry;
+    PKSERVICE_ROUTINE ServiceRoutine;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    PKSERVICE_ROUTINE MessageServiceRoutine;
+    ULONG MessageIndex;
+#endif
+    PVOID ServiceContext;
+    KSPIN_LOCK SpinLock;
+    ULONG TickCount;
+    PKSPIN_LOCK ActualLock;
+    PVOID DispatchAddress;
+    ULONG Vector;
+    KIRQL Irql;
+    KIRQL SynchronizeIrql;
+    BOOLEAN FloatingSave;
+    BOOLEAN Connected;
+    CHAR Number;
+    UCHAR ShareVector;
+    KINTERRUPT_MODE Mode;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    KINTERRUPT_POLARITY Polarity;
+#endif
+    ULONG ServiceCount;
+    ULONG DispatchCount;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    ULONGLONG Rsvd1;
+#endif
+    ULONG DispatchCode[KINTERRUPT_DISPATCH_CODES];
 } KINTERRUPT, *PKINTERRUPT;
 
+//
+// Kernel Event Pair Object
+//
 typedef struct _KEVENT_PAIR
 {
     CSHORT Type;
@@ -585,6 +653,9 @@ typedef struct _KEVENT_PAIR
     KEVENT HighEvent;
 } KEVENT_PAIR, *PKEVENT_PAIR;
 
+//
+// Kernel No Execute Options
+//
 typedef struct _KEXECUTE_OPTIONS
 {
     UCHAR ExecuteDisable:1;
@@ -596,6 +667,9 @@ typedef struct _KEXECUTE_OPTIONS
     UCHAR Spare:2;
 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
 
+//
+// Kernel Object Types
+//
 typedef enum _KOBJECTS
 {
     EventNotificationObject = 0,
@@ -626,164 +700,349 @@ typedef enum _KOBJECTS
     MaximumKernelObject = 25
 } KOBJECTS;
 
-#include <pshpack1.h>
-
+//
+// Kernel Thread (KTHREAD)
+//
 typedef struct _KTHREAD
 {
-    /* For waiting on thread exit */
-    DISPATCHER_HEADER DispatcherHeader;    /* 00 */
-
-    /* List of mutants owned by the thread */
-    LIST_ENTRY        MutantListHead;      /* 10 */
-    PVOID             InitialStack;        /* 18 */
-    ULONG_PTR         StackLimit;          /* 1C */
-
-    /* Pointer to the thread's environment block in user memory */
-    struct _TEB       *Teb;                /* 20 */
-
-    /* Pointer to the thread's TLS array */
-    PVOID             TlsArray;            /* 24 */
-    PVOID             KernelStack;         /* 28 */
-    UCHAR             DebugActive;         /* 2C */
-
-    /* Thread state (one of THREAD_STATE_xxx constants below) */
-    UCHAR             State;               /* 2D */
-    BOOLEAN           Alerted[2];          /* 2E */
-    UCHAR             Iopl;                /* 30 */
-    UCHAR             NpxState;            /* 31 */
-    CHAR              Saturation;          /* 32 */
-    CHAR              Priority;            /* 33 */
-    KAPC_STATE        ApcState;            /* 34 */
-    ULONG             ContextSwitches;     /* 4C */
-    LONG              WaitStatus;          /* 50 */
-    KIRQL             WaitIrql;            /* 54 */
-    CHAR              WaitMode;            /* 55 */
-    UCHAR             WaitNext;            /* 56 */
-    UCHAR             WaitReason;          /* 57 */
-    union                                  /* 58 */
+    DISPATCHER_HEADER DispatcherHeader;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    ULONGLONG CycleTime;
+    ULONG HighCycleTime;
+#else
+    LIST_ENTRY MutantListHead;
+#endif
+    PVOID InitialStack;
+    ULONG_PTR StackLimit;
+    PVOID KernelStack;
+    KSPIN_LOCK ThreadLock;
+    union
+    {
+        KAPC_STATE ApcState;
+        struct
+        {
+            UCHAR ApcStateFill[23];
+            UCHAR ApcQueueable;
+            volatile UCHAR NextProcessor;
+            volatile UCHAR DeferredProcessor;
+            UCHAR AdjustReason;
+            SCHAR AdjustIncrement;
+        };
+    };
+    KSPIN_LOCK ApcQueueLock;
+    ULONG ContextSwitches;
+    volatile UCHAR State;
+    UCHAR NpxState;
+    KIRQL WaitIrql;
+    KPROCESSOR_MODE WaitMode;
+    LONG_PTR WaitStatus;
+    union
+    {
+        PKWAIT_BLOCK WaitBlockList;
+        PKGATE GateObject;
+    };
+    BOOLEAN Alertable;
+    BOOLEAN WaitNext;
+    UCHAR WaitReason;
+    SCHAR Priority;
+    BOOLEAN EnableStackSwap;
+    volatile UCHAR SwapBusy;
+    BOOLEAN Alerted[MaximumMode];
+    union
+    {
+        LIST_ENTRY WaitListEntry;
+        SINGLE_LIST_ENTRY SwapListEntry;
+    };
+    PKQUEUE Queue;
+    ULONG WaitTime;
+    union
+    {
+        struct
+        {
+            SHORT KernelApcDisable;
+            SHORT SpecialApcDisable;
+        };
+        ULONG CombinedApcDisable;
+    };
+    struct _TEB *Teb;
+    union
+    {
+        KTIMER Timer;
+        struct
+        {
+            UCHAR TimerFill[40];
+            union
+            {
+                struct
+                {
+                    LONG AutoAlignment:1;
+                    LONG DisableBoost:1;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+                    LONG EtwStackTrace1ApcInserted:1;
+                    LONG EtwStackTrace2ApcInserted:1;
+                    LONG CycleChargePending:1;
+                    LONG ReservedFlags:27;
+#else
+                    LONG ReservedFlags:30;
+#endif
+                };
+                LONG ThreadFlags;
+            };
+        };
+    };
+    union
+    {
+        KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
+        struct
+        {
+            UCHAR WaitBlockFill0[23];
+            BOOLEAN SystemAffinityActive;
+        };
+        struct
+        {
+            UCHAR WaitBlockFill1[47];
+            CCHAR PreviousMode;
+        };
+        struct
+        {
+            UCHAR WaitBlockFill2[71];
+            UCHAR ResourceIndex;
+        };
+        struct
+        {
+            UCHAR WaitBlockFill3[95];
+            UCHAR LargeStack;
+        };
+    };
+    LIST_ENTRY QueueListEntry;
+    PKTRAP_FRAME TrapFrame;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    PVOID FirstArgument;
+#endif
+    PVOID CallbackStack;
+    PVOID ServiceTable;
+    UCHAR ApcStateIndex;
+    UCHAR IdealProcessor;
+    BOOLEAN Preempted;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    BOOLEAN CalloutActive;
+#else
+    BOOLEAN ProcessReadyQueue;
+#endif
+    BOOLEAN KernelStackResident;
+    SCHAR BasePriority;
+    SCHAR PriorityDecrement;
+    CHAR Saturation;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    ULONG SystemCallNumber;
+    union
+    {
+        struct
+        {
+            ULONG Reserved0:1;
+            ULONG ReadyTransition:1;
+            ULONG ProcessReadyQueue:1;
+            ULONG Reserved2:1;
+            ULONG Reserved3:28;
+        };
+        LONG MiscFlags;
+    };
+#endif
+    KAFFINITY UserAffinity;
+    struct _KPROCESS *Process;
+    KAFFINITY Affinity;
+    PKAPC_STATE ApcStatePointer[2];
+    union
     {
-        PKWAIT_BLOCK  WaitBlockList;      /* 58 */
-        PKGATE        GateObject;         /* 58 */
-    };                                     /* 58 */
-    LIST_ENTRY        WaitListEntry;       /* 5C */
-    ULONG             WaitTime;            /* 64 */
-    CHAR              BasePriority;        /* 68 */
-    UCHAR             DecrementCount;      /* 69 */
-    UCHAR             PriorityDecrement;   /* 6A */
-    CHAR              Quantum;             /* 6B */
-    KWAIT_BLOCK       WaitBlock[4];        /* 6C */
-    PVOID             LegoData;            /* CC */
+        KAPC_STATE SavedApcState;
+        struct
+        {
+            UCHAR SavedApcStateFill[23];
+            CCHAR FreezeCount;
+            CCHAR SuspendCount;
+            UCHAR UserIdealProcessor;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+            union
+            {
+                struct
+                {
+                    UCHAR ReservedBits0:1;
+                    UCHAR SegmentsPresent:1;
+                    UCHAR Reservedbits1:1;
+                };
+                UCHAR NestedStateFlags;
+            };
+#else
+            UCHAR CalloutActive;
+#endif
+            UCHAR Iopl;
+        };
+    };
+    PVOID Win32Thread;
+    PVOID StackBase;
+    union
+    {
+        KAPC SuspendApc;
+        struct
+        {
+            UCHAR SuspendApcFill0[1];
+            SCHAR Quantum;
+        };
+        struct
+        {
+            UCHAR SuspendApcFill1[3];
+            UCHAR QuantumReset;
+        };
+        struct
+        {
+            UCHAR SuspendApcFill2[4];
+            ULONG KernelTime;
+        };
+        struct
+        {
+            UCHAR SuspendApcFill3[36];
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+            PKPRCB WaitPrcb;
+#else
+            PVOID TlsArray;
+#endif
+        };
+        struct
+        {
+            UCHAR SuspendApcFill4[40];
+            PVOID LegoData;
+        };
+        struct
+        {
+            UCHAR SuspendApcFill5[47];
+            UCHAR PowerState;
+            ULONG UserTime;
+        };
+    };
     union
     {
+        KSEMAPHORE SuspendSemaphore;
         struct
         {
-            USHORT KernelApcDisable;
-            USHORT SpecialApcDisable;
+            UCHAR SuspendSemaphorefill[20];
+            ULONG SListFaultCount;
         };
-        ULONG      CombinedApcDisable;     /* D0 */
     };
-    KAFFINITY         UserAffinity;        /* D4 */
-    UCHAR             SystemAffinityActive;/* D8 */
-    UCHAR             PowerState;          /* D9 */
-    UCHAR             NpxIrql;             /* DA */
-    UCHAR             Pad[1];              /* DB */
-    PVOID             ServiceTable;        /* DC */
-    struct _KQUEUE    *Queue;              /* E0 */
-    KSPIN_LOCK        ApcQueueLock;        /* E4 */
-    KTIMER            Timer;               /* E8 */
-    LIST_ENTRY        QueueListEntry;      /* 110 */
-    KAFFINITY         Affinity;            /* 118 */
-    UCHAR             Preempted;           /* 11C */
-    UCHAR             ProcessReadyQueue;   /* 11D */
-    UCHAR             KernelStackResident; /* 11E */
-    UCHAR             NextProcessor;       /* 11F */
-    PVOID             CallbackStack;       /* 120 */
-    struct _W32THREAD *Win32Thread;        /* 124 */
-    struct _KTRAP_FRAME *TrapFrame;        /* 128 */
-    PKAPC_STATE       ApcStatePointer[2];  /* 12C */
-    UCHAR             EnableStackSwap;     /* 134 */
-    UCHAR             LargeStack;          /* 135 */
-    UCHAR             ResourceIndex;       /* 136 */
-    UCHAR             PreviousMode;        /* 137 */
-    ULONG             KernelTime;          /* 138 */
-    ULONG             UserTime;            /* 13C */
-    KAPC_STATE        SavedApcState;       /* 140 */
-    UCHAR             Alertable;           /* 158 */
-    UCHAR             ApcStateIndex;       /* 159 */
-    UCHAR             ApcQueueable;        /* 15A */
-    UCHAR             AutoAlignment;       /* 15B */
-    PVOID             StackBase;           /* 15C */
-    KAPC              SuspendApc;          /* 160 */
-    KSEMAPHORE        SuspendSemaphore;    /* 190 */
-    LIST_ENTRY        ThreadListEntry;     /* 1A4 */
-    CHAR              FreezeCount;         /* 1AC */
-    UCHAR             SuspendCount;        /* 1AD */
-    UCHAR             IdealProcessor;      /* 1AE */
-    UCHAR             DisableBoost;        /* 1AF */
-    UCHAR             QuantumReset;        /* 1B0 */
+    LIST_ENTRY ThreadListEntry;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    LIST_ENTRY MutantListHead;
+#endif
+    PVOID SListFaultAddress;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    PVOID MdlForLockedteb;
+#endif
 } KTHREAD;
 
-#include <poppack.h>
+#define ASSERT_THREAD(object) \
+    ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))
 
-/*
- * NAME:           KPROCESS
- * DESCRIPTION:    Internal Kernel Process Structure.
- * PORTABILITY:    Architecture Dependent.
- * KERNEL VERSION: 5.2
- * DOCUMENTATION:  http://reactos.com/wiki/index.php/KPROCESS
- */
+//
+// Kernel Process (KPROCESS)
+//
 typedef struct _KPROCESS
 {
-    DISPATCHER_HEADER     Header;                    /* 000 */
-    LIST_ENTRY            ProfileListHead;           /* 010 */
-    PHYSICAL_ADDRESS      DirectoryTableBase;        /* 018 */
-    KGDTENTRY             LdtDescriptor;             /* 020 */
-    KIDTENTRY             Int21Descriptor;           /* 028 */
-    USHORT                IopmOffset;                /* 030 */
-    UCHAR                 Iopl;                      /* 032 */
-    UCHAR                 Unused;                    /* 033 */
-    ULONG                 ActiveProcessors;          /* 034 */
-    ULONG                 KernelTime;                /* 038 */
-    ULONG                 UserTime;                  /* 03C */
-    LIST_ENTRY            ReadyListHead;             /* 040 */
-    LIST_ENTRY            SwapListEntry;             /* 048 */
-    PVOID                 VdmTrapcHandler;           /* 04C */
-    LIST_ENTRY            ThreadListHead;            /* 050 */
-    KSPIN_LOCK            ProcessLock;               /* 058 */
-    KAFFINITY             Affinity;                  /* 05C */
+    DISPATCHER_HEADER Header;
+    LIST_ENTRY ProfileListHead;
+    LARGE_INTEGER DirectoryTableBase;
+#if defined(_M_IX86)
+    KGDTENTRY LdtDescriptor;
+    KIDTENTRY Int21Descriptor;
+    USHORT IopmOffset;
+    UCHAR Iopl;
+    UCHAR Unused;
+#endif
+    volatile ULONG ActiveProcessors;
+    ULONG KernelTime;
+    ULONG UserTime;
+    LIST_ENTRY ReadyListHead;
+    SINGLE_LIST_ENTRY SwapListEntry;
+    PVOID VdmTrapcHandler;
+    LIST_ENTRY ThreadListHead;
+    KSPIN_LOCK ProcessLock;
+    KAFFINITY Affinity;
     union
     {
         struct
         {
-            ULONG         AutoAlignment:1;           /* 060.0 */
-            ULONG         DisableBoost:1;            /* 060.1 */
-            ULONG         DisableQuantum:1;          /* 060.2 */
-            ULONG         ReservedFlags:29;          /* 060.3 */
+            LONG AutoAlignment:1;
+            LONG DisableBoost:1;
+            LONG DisableQuantum:1;
+            LONG ReservedFlags:29;
         };
-        ULONG             ProcessFlags;              /* 060 */
+        LONG ProcessFlags;
+    };
+    SCHAR BasePriority;
+    SCHAR QuantumReset;
+    UCHAR State;
+    UCHAR ThreadSeed;
+    UCHAR PowerState;
+    UCHAR IdealNode;
+    UCHAR Visited;
+    union
+    {
+        KEXECUTE_OPTIONS Flags;
+        UCHAR ExecuteOptions;
     };
-    CHAR                  BasePriority;              /* 064 */
-    CHAR                  QuantumReset;              /* 065 */
-    UCHAR                 State;                     /* 066 */
-    UCHAR                 ThreadSeed;                /* 067 */
-    UCHAR                 PowerState;                /* 068 */
-    UCHAR                 IdealNode;                 /* 069 */
-    UCHAR                 Visited;                   /* 06A */
-    KEXECUTE_OPTIONS      Flags;                     /* 06B */
-    ULONG                 StackCount;                /* 06C */
-    LIST_ENTRY            ProcessListEntry;          /* 070 */
-} KPROCESS;
+    ULONG StackCount;
+    LIST_ENTRY ProcessListEntry;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+    ULONGLONG CycleTime;
+#endif
+} KPROCESS, *PKPROCESS;
 
-typedef enum _KTHREAD_STATE
+#define ASSERT_PROCESS(object) \
+    ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))
+
+//
+// System Service Table Descriptor
+//
+typedef struct _KSERVICE_TABLE_DESCRIPTOR
 {
-    Initialized,
-    Ready,
-    Running,
-    Standby,
-    Terminated,
-    Waiting,
-    Transition,
-    DeferredReady,
-} KTHREAD_STATE, *PKTHREAD_STATE;
+    PULONG_PTR Base;
+    PULONG Count;
+    ULONG Limit;
+#if defined(_IA64_)
+    LONG TableBaseGpOffset;
+#endif
+    PUCHAR Number;
+} KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
+
+//
+// Exported Loader Parameter Block
+//
+extern struct _LOADER_PARAMETER_BLOCK NTSYSAPI *KeLoaderBlock;
 
+//
+// Exported Hardware Data
+//
+extern KAFFINITY NTSYSAPI KeActiveProcessors;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+extern volatile CCHAR NTSYSAPI KeNumberProcessors;
+#else
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+extern CCHAR NTSYSAPI KeNumberProcessors;
+#else
+//extern PCCHAR KeNumberProcessors;
+extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
+#endif
 #endif
+extern ULONG NTSYSAPI KiDmaIoCoherency;
+extern ULONG NTSYSAPI KeMaximumIncrement;
+extern ULONG NTSYSAPI KeMinimumIncrement;
+extern ULONG NTSYSAPI KeDcacheFlushCount;
+extern ULONG NTSYSAPI KeIcacheFlushCount;
+
+//
+// Exported System Service Descriptor Tables
+//
+extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
+extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
+
+#endif // !NTOS_MODE_USER
+
+#endif // _KETYPES_H