- Fix one more leak when converting from non-gui to GUI thread stack.
Modified: trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S
Modified: trunk/reactos/ntoskrnl/ps/kill.c
Modified: trunk/reactos/ntoskrnl/ps/win32.c

Modified: trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S
--- trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S	2006-01-13 21:56:51 UTC (rev 20838)
+++ trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S	2006-01-13 22:23:31 UTC (rev 20839)
@@ -358,6 +358,26 @@
 
 .endfunc
 
+/*++
+ * @name KeSwitchKernelStack 
+ *
+ *     The KeSwitchKernelStack routine switches from the current thread's stack
+ *     to the new specified base and limit.
+ *
+ * @param StackBase
+ *        Pointer to the new Stack Base of the thread.
+ *
+ * @param StackLimit
+ *        Pointer to the new Stack Limit of the thread.
+ *
+ * @return The previous Stack Limit of the thread.
+ *
+ * @remark This routine should typically only be used when converting from a 
+ *         non-GUI to a GUI Thread. The caller is responsible for freeing the
+ *         previous stack. The new stack values MUST be valid before calling
+ *         this routine.
+ *
+ *--*/
 .globl _KeSwitchKernelStack@8
 .func KeSwitchKernelStack@8
 _KeSwitchKernelStack@8:
@@ -400,7 +420,7 @@
     pop edi
 
     /* Save old stack base and get new limit/base */
-    mov eax, [edx+KTHREAD_STACK_BASE]
+    mov eax, [edx+KTHREAD_STACK_LIMIT]
     mov ecx, [esp+12]
     mov esi, [esp+16]
 

Modified: trunk/reactos/ntoskrnl/ps/kill.c
--- trunk/reactos/ntoskrnl/ps/kill.c	2006-01-13 21:56:51 UTC (rev 20838)
+++ trunk/reactos/ntoskrnl/ps/kill.c	2006-01-13 22:23:31 UTC (rev 20839)
@@ -194,7 +194,7 @@
     if(Thread->Tcb.Win32Thread != NULL) ExFreePool (Thread->Tcb.Win32Thread);
 
     /* Release the Kernel Stack */
-    MmDeleteKernelStack((PVOID)Thread->Tcb.StackLimit, Thread->Tcb.StackLimit);
+    MmDeleteKernelStack((PVOID)Thread->Tcb.StackLimit, Thread->Tcb.LargeStack);
 
     /* Dereference the Process */
     ObDereferenceObject(Process);

Modified: trunk/reactos/ntoskrnl/ps/win32.c
--- trunk/reactos/ntoskrnl/ps/win32.c	2006-01-13 21:56:51 UTC (rev 20838)
+++ trunk/reactos/ntoskrnl/ps/win32.c	2006-01-13 22:23:31 UTC (rev 20839)
@@ -122,7 +122,7 @@
         KeLeaveCriticalRegion();
 
         /* Delete the old stack */
-        //MmDeleteKernelStack(OldStack, FALSE);
+        MmDeleteKernelStack(OldStack, FALSE);
     }
 
     /* This check is bizare. Check out win32k later */