Update ETHREAD to latest version.
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
Modified: trunk/reactos/ntoskrnl/io/irp.c
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
Modified: trunk/reactos/ntoskrnl/ps/kill.c
Modified: trunk/reactos/ntoskrnl/ps/thread.c

Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
--- trunk/reactos/ntoskrnl/include/internal/ps.h	2005-05-07 00:21:06 UTC (rev 15067)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h	2005-05-07 00:37:48 UTC (rev 15068)
@@ -65,58 +65,101 @@
 } PS_IMPERSONATION_INFORMATION, *PPS_IMPERSONATION_INFORMATION;
 #endif
 
-#include <pshpack1.h>
-
-/* This needs to be fixed ASAP! */
+#include <pshpack4.h>
+/*
+ * NAME:           ETHREAD
+ * DESCRIPTION:    Internal Executive Thread Structure.
+ * PORTABILITY:    Architecture Independent.
+ * KERNEL VERSION: 5.2
+ * DOCUMENTATION:  http://reactos.com/wiki/index.php/ETHREAD
+ */
 typedef struct _ETHREAD
 {
-  KTHREAD Tcb;
-  union {
-  	LARGE_INTEGER CreateTime;
-  	UCHAR NestedFaultCount:2;
-  	UCHAR ApcNeeded:1;
-  };
-  LARGE_INTEGER ExitTime;
-  LIST_ENTRY LpcReplyChain;
-  NTSTATUS ExitStatus;
-  PVOID OfsChain;
-  LIST_ENTRY PostBlockList;
-  union {
-    struct _TERMINATION_PORT *TerminationPort;
-    struct _ETHREAD* ReaperLink;  
-  };
-  KSPIN_LOCK ActiveTimerListLock;
-  LIST_ENTRY ActiveTimerListHead;
-  CLIENT_ID Cid;
-  KSEMAPHORE LpcReplySemaphore;
-  PVOID LpcReplyMessage;
-  ULONG LpcReplyMessageId;
-  ULONG PerformanceCountLow;
-  PPS_IMPERSONATION_INFORMATION ImpersonationInfo;
-  LIST_ENTRY IrpList;
-  PIRP TopLevelIrp;
-  PDEVICE_OBJECT DeviceToVerify;
-  ULONG ReadClusterSize;
-  UCHAR ForwardClusterOnly;
-  UCHAR DisablePageFaultClustering;
-  UCHAR DeadThread;
-  UCHAR HideFromDebugger;
-  ULONG HasTerminated;
-#ifdef _ENABLE_THRDEVTPAIR
-  PVOID EventPair;
-#endif /* _ENABLE_THRDEVTPAIR */
-  ACCESS_MASK GrantedAccess;
-  struct _EPROCESS *ThreadsProcess;
-  PKSTART_ROUTINE StartAddress;
-  LPTHREAD_START_ROUTINE Win32StartAddress;
-  ULONG LpcReceivedMessageId;
-  UCHAR LpcExitThreadCalled;
-  UCHAR HardErrorsAreDisabled;
-  UCHAR LpcReceivedMsgIdValid;
-  UCHAR ActiveImpersonationInfo;
-  ULONG PerformanceCountHigh;
-  LIST_ENTRY ThreadListEntry;
-  BOOLEAN SystemThread;
+    KTHREAD                        Tcb;                         /* 1C0 */
+    LARGE_INTEGER                  CreateTime;                  /* 1C0 */
+    LARGE_INTEGER                  ExitTime;                    /* 1C0 */
+    union {
+        LIST_ENTRY                 LpcReplyChain;               /* 1C0 */
+        LIST_ENTRY                 KeyedWaitChain;              /* 1C0 */
+    };
+    union {
+        NTSTATUS                   ExitStatus;                  /* 1C8 */
+        PVOID                      OfsChain;                    /* 1C8 */
+    };
+    LIST_ENTRY                     PostBlockList;               /* 1CC */
+    union {
+        struct _TERMINATION_PORT   *TerminationPort;            /* 1D4 */
+        struct _ETHREAD            *ReaperLink;                 /* 1D4 */
+        PVOID                      KeyedWaitValue;              /* 1D4 */
+    };
+    KSPIN_LOCK                     ActiveTimerListLock;         /* 1D8 */
+    LIST_ENTRY                     ActiveTimerListHead;         /* 1D8 */
+    CLIENT_ID                      Cid;                         /* 1E0 */
+    union {
+        KSEMAPHORE                 LpcReplySemaphore;           /* 1E4 */
+        KSEMAPHORE                 KeyedReplySemaphore;         /* 1E4 */
+    };
+    union {
+        PVOID                      LpcReplyMessage;             /* 200 */
+        PVOID                      LpcWaitingOnPort;            /* 200 */
+    };
+    PPS_IMPERSONATION_INFORMATION  ImpersonationInfo;           /* 204 */
+    LIST_ENTRY                     IrpList;                     /* 208 */
+    ULONG                          TopLevelIrp;                 /* 210 */
+    PDEVICE_OBJECT                 DeviceToVerify;              /* 214 */
+    struct _EPROCESS               *ThreadsProcess;             /* 218 */
+    PKSTART_ROUTINE                StartAddress;                /* 21C */
+    union {
+        LPTHREAD_START_ROUTINE     Win32StartAddress;           /* 220 */
+        ULONG                      LpcReceivedMessageId;        /* 220 */
+    };
+    LIST_ENTRY                     ThreadListEntry;             /* 224 */
+    EX_RUNDOWN_REF                 RundownProtect;              /* 22C */
+    EX_PUSH_LOCK                   ThreadLock;                  /* 230 */
+    ULONG                          LpcReplyMessageId;           /* 234 */
+    ULONG                          ReadClusterSize;             /* 238 */
+    ACCESS_MASK                    GrantedAccess;               /* 23C */
+    union {
+        struct {
+           ULONG                   Terminated:1;
+           ULONG                   DeadThread:1;
+           ULONG                   HideFromDebugger:1;
+           ULONG                   ActiveImpersonationInfo:1;
+           ULONG                   SystemThread:1;
+           ULONG                   HardErrorsAreDisabled:1;
+           ULONG                   BreakOnTermination:1;
+           ULONG                   SkipCreationMsg:1;
+           ULONG                   SkipTerminationMsg:1;
+        };
+        ULONG                      CrossThreadFlags;            /* 240 */
+    };
+    union {
+        struct {
+           ULONG                   ActiveExWorker:1;
+           ULONG                   ExWorkerCanWaitUser:1;
+           ULONG                   MemoryMaker:1;
+           ULONG                   KeyedEventInUse:1;
+        };
+        ULONG                      SameThreadPassiveFlags;      /* 244 */
+    };
+    union {
+        struct {
+           ULONG                   LpcReceivedMsgIdValid:1;
+           ULONG                   LpcExitThreadCalled:1;
+           ULONG                   AddressSpaceOwner:1;
+           ULONG                   OwnsProcessWorkingSetExclusive:1;
+           ULONG                   OwnsProcessWorkingSetShared:1;
+           ULONG                   OwnsSystemWorkingSetExclusive:1;
+           ULONG                   OwnsSystemWorkingSetShared:1;
+           ULONG                   OwnsSessionWorkingSetExclusive:1;
+           ULONG                   OwnsSessionWorkingSetShared:1;
+           ULONG                   ApcNeeded:1;
+        };
+        ULONG                      SameThreadPassiveFlags;      /* 248 */
+    };   
+    UCHAR                          ForwardClusterOnly;          /* 24C */
+    UCHAR                          DisablePageFaultClustering;  /* 24D */
+    UCHAR                          ActiveFaultCount;            /* 24E */
 } ETHREAD;
 
 #include <poppack.h>
@@ -128,6 +171,13 @@
 #endif /* __USE_W32API */
   
 #include <pshpack4.h>
+/*
+ * NAME:           EPROCESS
+ * DESCRIPTION:    Internal Executive Process Structure.
+ * PORTABILITY:    Architecture Independent.
+ * KERNEL VERSION: 5.2
+ * DOCUMENTATION:  http://reactos.com/wiki/index.php/EPROCESS
+ */
 struct _EPROCESS
 {
     KPROCESS              Pcb;                          /* 000 */

Modified: trunk/reactos/ntoskrnl/io/irp.c
--- trunk/reactos/ntoskrnl/io/irp.c	2005-05-07 00:21:06 UTC (rev 15067)
+++ trunk/reactos/ntoskrnl/io/irp.c	2005-05-07 00:37:48 UTC (rev 15068)
@@ -913,7 +913,7 @@
 STDCALL
 IoGetTopLevelIrp(VOID)
 {
-    return(PsGetCurrentThread()->TopLevelIrp);
+    return (PIRP)PsGetCurrentThread()->TopLevelIrp;
 }
 
 /*
@@ -1131,7 +1131,7 @@
 STDCALL
 IoSetTopLevelIrp(IN PIRP Irp)
 {
-    PsGetCurrentThread()->TopLevelIrp = Irp;
+    PsGetCurrentThread()->TopLevelIrp = (ULONG)Irp;
 }
 
 /*

Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
--- trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S	2005-05-07 00:21:06 UTC (rev 15067)
+++ trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S	2005-05-07 00:37:48 UTC (rev 15068)
@@ -125,13 +125,13 @@
     
     /* Set the Thread to running */
     mov byte ptr [esi+KTHREAD_STATE], Running
-    
+
     /* Save the Exception list */
     push [ebx+KPCR_EXCEPTION_LIST]
     
     /* Switching, disable interrupts now */
     cli
-    
+
 #ifdef CONFIG_SMP
     /* Save FPU state if the thread has used it. */
     mov dword ptr [ebx+KPCR_NPX_THREAD], 0
@@ -157,9 +157,14 @@
     mov [edi+KTHREAD_KERNEL_STACK], esp
     mov esp, [esi+KTHREAD_KERNEL_STACK]
    
+    /* Change the address space */
+    mov eax, [esi+KTHREAD_APCSTATE_PROCESS]
+    mov eax, [eax+KPROCESS_DIRECTORY_TABLE_BASE]
+    mov cr3, eax
+    
     /* Stack is OK, safe to enable interrupts now */
     sti 
-    
+
     /* Check if address space switch is needed */
     mov eax, [edi+KTHREAD_APCSTATE_PROCESS]
     cmp eax, [esi+KTHREAD_APCSTATE_PROCESS]

Modified: trunk/reactos/ntoskrnl/ps/kill.c
--- trunk/reactos/ntoskrnl/ps/kill.c	2005-05-07 00:21:06 UTC (rev 15067)
+++ trunk/reactos/ntoskrnl/ps/kill.c	2005-05-07 00:37:48 UTC (rev 15068)
@@ -129,9 +129,9 @@
         if (Thread != CurrentThread) {
         
             /* Make sure it didn't already terminate */
-            if (!Thread->HasTerminated) {
+            if (!Thread->Terminated) {
 
-                Thread->HasTerminated = TRUE;
+                Thread->Terminated = TRUE;
                 
                 /* Terminate it by APC */
                 PspTerminateThreadByPointer(Thread, ExitStatus);
@@ -485,7 +485,7 @@
 
             /* mark our thread as terminating so attempts to terminate it, when
                unlocking the process, fail */
-            CurrentThread->HasTerminated = TRUE;
+            CurrentThread->Terminated = TRUE;
 
             PsUnlockProcess(Process);
 
@@ -549,9 +549,9 @@
         PsLockProcess(Thread->ThreadsProcess, FALSE);
         
         /* This isn't our thread, terminate it if not already done */
-        if (!Thread->HasTerminated) {
+        if (!Thread->Terminated) {
          
-             Thread->HasTerminated = TRUE;
+             Thread->Terminated = TRUE;
              
              /* Terminate it */
              PspTerminateThreadByPointer(Thread, ExitStatus);
@@ -564,7 +564,7 @@
         
     } else {
 
-        Thread->HasTerminated = TRUE;
+        Thread->Terminated = TRUE;
         
         /* it's safe to dereference thread, there's at least the keep-alive
            reference which will be removed by the thread reaper causing the

Modified: trunk/reactos/ntoskrnl/ps/thread.c
--- trunk/reactos/ntoskrnl/ps/thread.c	2005-05-07 00:21:06 UTC (rev 15067)
+++ trunk/reactos/ntoskrnl/ps/thread.c	2005-05-07 00:37:48 UTC (rev 15068)
@@ -46,7 +46,7 @@
            "This is my IRQL: %d. This is my Thread Pointer: %x.\n", StartRoutine,
             StartContext, KeGetCurrentIrql(), Thread);
     
-    if (!Thread->HasTerminated) {
+    if (!Thread->Terminated) {
     
         /* Allocate the APC */
         ThreadApc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG('T', 'h', 'r','d'));
@@ -82,7 +82,7 @@
     KeLowerIrql(PASSIVE_LEVEL);
     
     /* Make sure it's not terminated by now */
-    if (!Thread->HasTerminated) {
+    if (!Thread->Terminated) {
     
         /* Call it */
         (StartRoutine)(StartContext);
@@ -483,7 +483,7 @@
 STDCALL
 PsIsThreadTerminating(IN PETHREAD Thread)
 {
-    return (Thread->HasTerminated ? TRUE : FALSE);
+    return (Thread->Terminated ? TRUE : FALSE);
 }
 
 /*