- Fix major bugs in the definition of _KTHREAD inside the NDK. I made some stupid assumptions when reading the .pdb dump data. _KTHREAD should now be the right size and structure as Win 2003. (the reason this bug wasn't more evident was because we were using 1-byte packing and a "padding" field. this has now been removed).

svn path=/trunk/; revision=25481
This commit is contained in:
Alex Ionescu 2007-01-16 02:40:41 +00:00
parent 73d8fac4c0
commit 532a28a03c

View file

@ -679,7 +679,6 @@ typedef enum _KOBJECTS
// //
// Kernel Thread (KTHREAD) // Kernel Thread (KTHREAD)
// //
#include <pshpack1.h>
typedef struct _KTHREAD typedef struct _KTHREAD
{ {
DISPATCHER_HEADER DispatcherHeader; DISPATCHER_HEADER DispatcherHeader;
@ -700,31 +699,31 @@ typedef struct _KTHREAD
{ {
UCHAR ApcStateFill[23]; UCHAR ApcStateFill[23];
UCHAR ApcQueueable; 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; KSPIN_LOCK ApcQueueLock;
ULONG ContextSwitches; ULONG ContextSwitches;
volatile UCHAR State; volatile UCHAR State;
UCHAR NpxState; UCHAR NpxState;
UCHAR WaitIrql; KIRQL WaitIrql;
SCHAR WaitMode; KPROCESSOR_MODE WaitMode;
LONG WaitStatus; LONG_PTR WaitStatus;
union union
{ {
PKWAIT_BLOCK WaitBlockList; PKWAIT_BLOCK WaitBlockList;
PKGATE GateObject; PKGATE GateObject;
}; };
UCHAR Alertable; BOOLEAN Alertable;
UCHAR WaitNext; BOOLEAN WaitNext;
UCHAR WaitReason; UCHAR WaitReason;
SCHAR Priority; SCHAR Priority;
UCHAR EnableStackSwap; BOOLEAN EnableStackSwap;
volatile UCHAR SwapBusy; volatile UCHAR SwapBusy;
UCHAR Alerted[2]; BOOLEAN Alerted[MaximumMode];
union union
{ {
LIST_ENTRY WaitListEntry; LIST_ENTRY WaitListEntry;
@ -745,51 +744,50 @@ typedef struct _KTHREAD
union union
{ {
KTIMER Timer; KTIMER Timer;
UCHAR TimerFill[40];
};
union
{
struct struct
{ {
LONG AutoAlignment:1; UCHAR TimerFill[40];
LONG DisableBoost:1; union
{
struct
{
LONG AutoAlignment:1;
LONG DisableBoost:1;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) #if (NTDDI_VERSION >= NTDDI_LONGHORN)
LONG EtwStackTrace1ApcInserted:1; LONG EtwStackTrace1ApcInserted:1;
LONG EtwStackTrace2ApcInserted:1; LONG EtwStackTrace2ApcInserted:1;
LONG CycleChargePending:1; LONG CycleChargePending:1;
LONG ReservedFlags:27; LONG ReservedFlags:27;
#else #else
LONG ReservedFlags:30; LONG ReservedFlags:30;
#endif #endif
};
LONG ThreadFlags;
};
}; };
LONG ThreadFlags;
}; };
PVOID Padding;
union union
{ {
KWAIT_BLOCK WaitBlock[4]; KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
union struct
{ {
struct UCHAR WaitBlockFill0[23];
{ BOOLEAN SystemAffinityActive;
UCHAR WaitBlockFill0[23]; };
UCHAR SystemAffinityActive; struct
}; {
struct UCHAR WaitBlockFill1[47];
{ CCHAR PreviousMode;
UCHAR WaitBlockFill1[47]; };
SCHAR PreviousMode; struct
}; {
struct UCHAR WaitBlockFill2[71];
{ UCHAR ResourceIndex;
UCHAR WaitBlockFill2[71]; };
UCHAR ResourceIndex; struct
}; {
struct UCHAR WaitBlockFill3[95];
{ UCHAR LargeStack;
UCHAR WaitBlockFill3[95];
UCHAR LargeStack;
};
}; };
}; };
LIST_ENTRY QueueListEntry; LIST_ENTRY QueueListEntry;
@ -801,15 +799,15 @@ typedef struct _KTHREAD
PVOID ServiceTable; PVOID ServiceTable;
UCHAR ApcStateIndex; UCHAR ApcStateIndex;
UCHAR IdealProcessor; UCHAR IdealProcessor;
UCHAR Preempted; BOOLEAN Preempted;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) #if (NTDDI_VERSION >= NTDDI_LONGHORN)
UCHAR CalloutActive; BOOLEAN CalloutActive;
#else #else
UCHAR ProcessReadyQueue; BOOLEAN ProcessReadyQueue;
#endif #endif
UCHAR KernelStackResident; BOOLEAN KernelStackResident;
CHAR BasePriority; SCHAR BasePriority;
CHAR PriorityDecrement; SCHAR PriorityDecrement;
CHAR Saturation; CHAR Saturation;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) #if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONG SystemCallNumber; ULONG SystemCallNumber;
@ -833,29 +831,29 @@ typedef struct _KTHREAD
union union
{ {
KAPC_STATE SavedApcState; KAPC_STATE SavedApcState;
union
{
UCHAR SavedApcStateFill[23];
SCHAR FreezeCount;
};
};
SCHAR SuspendCount;
UCHAR UserIdealProcessor;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
union
{
struct struct
{ {
UCHAR ReservedBits0:1; UCHAR SavedApcStateFill[23];
UCHAR SegmentsPresent:1; CCHAR FreezeCount;
UCHAR Reservedbits1:1; CCHAR SuspendCount;
}; UCHAR UserIdealProcessor;
UCHAR NestedStateFlags; #if (NTDDI_VERSION >= NTDDI_LONGHORN)
}; union
{
struct
{
UCHAR ReservedBits0:1;
UCHAR SegmentsPresent:1;
UCHAR Reservedbits1:1;
};
UCHAR NestedStateFlags;
};
#else #else
UCHAR CalloutActive; UCHAR CalloutActive;
#endif #endif
UCHAR Iopl; UCHAR Iopl;
};
};
PVOID Win32Thread; PVOID Win32Thread;
PVOID StackBase; PVOID StackBase;
union union
@ -894,15 +892,18 @@ typedef struct _KTHREAD
{ {
UCHAR SuspendApcFill5[47]; UCHAR SuspendApcFill5[47];
UCHAR PowerState; UCHAR PowerState;
ULONG UserTime;
}; };
}; };
ULONG UserTime;
union union
{ {
KSEMAPHORE SuspendSemaphore; KSEMAPHORE SuspendSemaphore;
UCHAR SuspendSemaphorefill[20]; struct
{
UCHAR SuspendSemaphorefill[20];
ULONG SListFaultCount;
};
}; };
ULONG SListFaultCount;
LIST_ENTRY ThreadListEntry; LIST_ENTRY ThreadListEntry;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) #if (NTDDI_VERSION >= NTDDI_LONGHORN)
LIST_ENTRY MutantListHead; LIST_ENTRY MutantListHead;
@ -912,7 +913,6 @@ typedef struct _KTHREAD
PVOID MdlForLockedteb; PVOID MdlForLockedteb;
#endif #endif
} KTHREAD; } KTHREAD;
#include <poppack.h>
#define ASSERT_THREAD(object) \ #define ASSERT_THREAD(object) \
ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject)) ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))