//
#define SSDT_MAX_ENTRIES 2
+//
+// Processor Architectures
+//
+#define PROCESSOR_ARCHITECTURE_INTEL 0
+
//
// Object Type Mask for Kernel Dispatcher Objects
//
#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
+
+//
+// Internal Exception Codes
+//
+#define KI_EXCEPTION_INTERNAL 0x10000000
+#define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
//
// KPCR Access for non-IA64 builds
//
#define K0IPCR ((ULONG_PTR)(KIP0PCRADDRESS))
#define PCR ((volatile KPCR * const)K0IPCR)
-#ifdef _WE_USE_THE_SAME_PCR_ADDRESS
+#if !defined(CONFIG_SMP) && !defined(NT_BUILD)
#define KeGetPcr() PCR
#else
#define KeGetPcr() ((volatile KPCR * const)__readfsdword(0x1C))
#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
//
//
// Kernel Thread (KTHREAD)
//
-#include <pshpack1.h>
typedef struct _KTHREAD
{
DISPATCHER_HEADER DispatcherHeader;
{
UCHAR ApcStateFill[23];
UCHAR ApcQueueable;
+ volatile UCHAR NextProcessor;
+ volatile UCHAR DeferredProcessor;
+ UCHAR AdjustReason;
+ SCHAR AdjustIncrement;
};
};
- volatile UCHAR NextProcessor;
- volatile UCHAR DeferredProcessor;
- UCHAR AdjustReason;
- SCHAR AdjustIncrement;
KSPIN_LOCK ApcQueueLock;
ULONG ContextSwitches;
volatile UCHAR State;
UCHAR NpxState;
- UCHAR WaitIrql;
- SCHAR WaitMode;
- LONG WaitStatus;
+ KIRQL WaitIrql;
+ KPROCESSOR_MODE WaitMode;
+ LONG_PTR WaitStatus;
union
{
PKWAIT_BLOCK WaitBlockList;
PKGATE GateObject;
};
- UCHAR Alertable;
- UCHAR WaitNext;
+ BOOLEAN Alertable;
+ BOOLEAN WaitNext;
UCHAR WaitReason;
SCHAR Priority;
- UCHAR EnableStackSwap;
+ BOOLEAN EnableStackSwap;
volatile UCHAR SwapBusy;
- UCHAR Alerted[2];
+ BOOLEAN Alerted[MaximumMode];
union
{
LIST_ENTRY WaitListEntry;
union
{
KTIMER Timer;
- UCHAR TimerFill[40];
- };
- union
- {
struct
{
- LONG AutoAlignment:1;
- LONG DisableBoost:1;
+ 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;
+ LONG EtwStackTrace1ApcInserted:1;
+ LONG EtwStackTrace2ApcInserted:1;
+ LONG CycleChargePending:1;
+ LONG ReservedFlags:27;
#else
- LONG ReservedFlags:30;
+ LONG ReservedFlags:30;
#endif
+ };
+ LONG ThreadFlags;
+ };
};
- LONG ThreadFlags;
};
- PVOID Padding;
union
{
- KWAIT_BLOCK WaitBlock[4];
- union
+ KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
+ struct
{
- struct
- {
- UCHAR WaitBlockFill0[23];
- UCHAR SystemAffinityActive;
- };
- struct
- {
- UCHAR WaitBlockFill1[47];
- SCHAR PreviousMode;
- };
- struct
- {
- UCHAR WaitBlockFill2[71];
- UCHAR ResourceIndex;
- };
- struct
- {
- UCHAR WaitBlockFill3[95];
- UCHAR LargeStack;
- };
+ 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;
PVOID ServiceTable;
UCHAR ApcStateIndex;
UCHAR IdealProcessor;
- UCHAR Preempted;
+ BOOLEAN Preempted;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- UCHAR CalloutActive;
+ BOOLEAN CalloutActive;
#else
- UCHAR ProcessReadyQueue;
+ BOOLEAN ProcessReadyQueue;
#endif
- UCHAR KernelStackResident;
- CHAR BasePriority;
- CHAR PriorityDecrement;
+ BOOLEAN KernelStackResident;
+ SCHAR BasePriority;
+ SCHAR PriorityDecrement;
CHAR Saturation;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONG SystemCallNumber;
union
{
KAPC_STATE SavedApcState;
- union
+ struct
{
UCHAR SavedApcStateFill[23];
- SCHAR FreezeCount;
- };
- };
- SCHAR SuspendCount;
- UCHAR UserIdealProcessor;
+ CCHAR FreezeCount;
+ CCHAR SuspendCount;
+ UCHAR UserIdealProcessor;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- union
- {
- struct
- {
- UCHAR ReservedBits0:1;
- UCHAR SegmentsPresent:1;
- UCHAR Reservedbits1:1;
- };
- UCHAR NestedStateFlags;
- };
+ union
+ {
+ struct
+ {
+ UCHAR ReservedBits0:1;
+ UCHAR SegmentsPresent:1;
+ UCHAR Reservedbits1:1;
+ };
+ UCHAR NestedStateFlags;
+ };
#else
- UCHAR CalloutActive;
+ UCHAR CalloutActive;
#endif
- UCHAR Iopl;
+ UCHAR Iopl;
+ };
+ };
PVOID Win32Thread;
PVOID StackBase;
union
{
UCHAR SuspendApcFill5[47];
UCHAR PowerState;
+ ULONG UserTime;
};
};
- ULONG UserTime;
union
{
KSEMAPHORE SuspendSemaphore;
- UCHAR SuspendSemaphorefill[20];
+ struct
+ {
+ UCHAR SuspendSemaphorefill[20];
+ ULONG SListFaultCount;
+ };
};
- ULONG SListFaultCount;
LIST_ENTRY ThreadListEntry;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
LIST_ENTRY MutantListHead;
PVOID MdlForLockedteb;
#endif
} KTHREAD;
-#include <poppack.h>
#define ASSERT_THREAD(object) \
ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))