Move final user stack cleanup to kernelmode

svn path=/trunk/; revision=11169
This commit is contained in:
Gé van Geldorp 2004-10-03 18:53:05 +00:00
parent 9584768301
commit 81e60d8ded
2 changed files with 10 additions and 19 deletions

View file

@ -1,4 +1,4 @@
/* $Id: exit.c,v 1.1 2003/12/30 05:10:32 hyperion Exp $
/* $Id: exit.c,v 1.2 2004/10/03 18:53:05 gvg Exp $
*/
/*
*/
@ -11,27 +11,12 @@
#include <rosrtl/thread.h>
static VOID NTAPI RtlRosExitUserThread_Stage2
(
IN ULONG_PTR Status
)
{
RtlRosFreeUserThreadStack(NtCurrentProcess(), NtCurrentThread());
NtTerminateThread(NtCurrentThread(), Status);
}
__declspec(noreturn) VOID NTAPI RtlRosExitUserThread
(
IN NTSTATUS Status
)
{
RtlRosSwitchStackForExit
(
NtCurrentTeb()->StaticUnicodeBuffer,
sizeof(NtCurrentTeb()->StaticUnicodeBuffer),
RtlRosExitUserThread_Stage2,
Status
);
NtTerminateThread(NtCurrentThread(), Status);
for(;;);
}

View file

@ -1,4 +1,4 @@
/* $Id: kill.c,v 1.77 2004/10/01 20:29:58 gvg Exp $
/* $Id: kill.c,v 1.78 2004/10/03 18:53:05 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -114,6 +114,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
PEPROCESS CurrentProcess;
SIZE_T Length = PAGE_SIZE;
PVOID TebBlock;
ULONG StackSize;
KeLowerIrql(PASSIVE_LEVEL);
@ -147,9 +148,14 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
PspRunCreateThreadNotifyRoutines(CurrentThread, FALSE);
PsTerminateWin32Thread(CurrentThread);
/* Free the TEB */
/* Free the usermode stack and the TEB */
if(CurrentThread->Tcb.Teb)
{
StackSize = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
&CurrentThread->Tcb.Teb->DeallocationStack,
&StackSize,
MEM_RELEASE);
DPRINT("Decommit teb at %p\n", CurrentThread->Tcb.Teb);
ExAcquireFastMutex(&CurrentProcess->TebLock);
TebBlock = MM_ROUND_DOWN(CurrentThread->Tcb.Teb, MM_VIRTMEM_GRANULARITY);