From d03c6f0016f329fc8ef12ec18be9d5779e1d734f Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Fri, 13 Jan 2006 22:23:31 +0000 Subject: [PATCH] - Fix one more leak when converting from non-gui to GUI thread stack. svn path=/trunk/; revision=20839 --- reactos/ntoskrnl/ke/i386/usercall_asm.S | 22 +++++++++++++++++++++- reactos/ntoskrnl/ps/kill.c | 2 +- reactos/ntoskrnl/ps/win32.c | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/ke/i386/usercall_asm.S b/reactos/ntoskrnl/ke/i386/usercall_asm.S index c957af794be..03f5a2114ee 100644 --- a/reactos/ntoskrnl/ke/i386/usercall_asm.S +++ b/reactos/ntoskrnl/ke/i386/usercall_asm.S @@ -358,6 +358,26 @@ NoStack: .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 @@ _KeSwitchKernelStack@8: 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] diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 6b447e71115..5c04e38451e 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -194,7 +194,7 @@ PspDeleteThread(PVOID ObjectBody) 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); diff --git a/reactos/ntoskrnl/ps/win32.c b/reactos/ntoskrnl/ps/win32.c index c2e75e94421..5ce902dc3d0 100644 --- a/reactos/ntoskrnl/ps/win32.c +++ b/reactos/ntoskrnl/ps/win32.c @@ -122,7 +122,7 @@ PsConvertToGuiThread(VOID) KeLeaveCriticalRegion(); /* Delete the old stack */ - //MmDeleteKernelStack(OldStack, FALSE); + MmDeleteKernelStack(OldStack, FALSE); } /* This check is bizare. Check out win32k later */