mirror of
https://github.com/reactos/reactos.git
synced 2024-07-12 07:35:10 +00:00
- include/rosrtl/thread.h, lib/rosrtl/makefile, lib/rosrtl/makefile.i386, lib/rosrtl/thread/stack.c, lib/rosrtl/thread/exit.c, lib/rosrtl/thread/i386/stackexit.c: three new RosRtl functions (RtlRosExitUserThread, RtlRosFreeUserThreadStack and RtlRosSwitchStackForExit)
- lib/kernel32/makefile, lib/kernel32/thread/thread.c, lib/kernel32/thread/thread/i386/exit.S: kernel32.dll now uses them - lib/ntdll/dbg/debug.c, lib/ntdll/rtl/thread.c: ntdll.dll too - subsys/csrss/api/wapi.c: CSRSS too (should fix regression) svn path=/trunk/; revision=7323
This commit is contained in:
parent
baea3fcd85
commit
f3fcc98b2d
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.h,v 1.3 2003/07/22 20:10:04 hyperion Exp $
|
/* $Id: thread.h,v 1.4 2003/12/30 05:10:31 hyperion Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -36,6 +36,11 @@ NTSTATUS CDECL RtlRosCreateUserThreadVa
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
__declspec(noreturn) VOID NTAPI RtlRosExitUserThread
|
||||||
|
(
|
||||||
|
IN NTSTATUS Status
|
||||||
|
);
|
||||||
|
|
||||||
NTSTATUS NTAPI RtlRosInitializeContext
|
NTSTATUS NTAPI RtlRosInitializeContext
|
||||||
(
|
(
|
||||||
IN HANDLE ProcessHandle,
|
IN HANDLE ProcessHandle,
|
||||||
|
@ -61,6 +66,20 @@ NTSTATUS NTAPI RtlRosDeleteStack
|
||||||
IN PUSER_STACK UserStack
|
IN PUSER_STACK UserStack
|
||||||
);
|
);
|
||||||
|
|
||||||
|
NTSTATUS NTAPI RtlRosFreeUserThreadStack
|
||||||
|
(
|
||||||
|
IN HANDLE ProcessHandle,
|
||||||
|
IN HANDLE ThreadHandle
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS NTAPI RtlRosSwitchStackForExit
|
||||||
|
(
|
||||||
|
IN PVOID StackBase,
|
||||||
|
IN SIZE_T StackSize,
|
||||||
|
IN VOID (NTAPI * ExitRoutine)(ULONG_PTR Parameter),
|
||||||
|
IN ULONG_PTR Parameter
|
||||||
|
);
|
||||||
|
|
||||||
/* Private functions - for ROSRTL internal use only */
|
/* Private functions - for ROSRTL internal use only */
|
||||||
NTSTATUS NTAPI RtlpRosGetStackLimits
|
NTSTATUS NTAPI RtlpRosGetStackLimits
|
||||||
(
|
(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.72 2003/12/30 00:12:47 hyperion Exp $
|
# $Id: makefile,v 1.73 2003/12/30 05:10:31 hyperion Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -51,8 +51,7 @@ THREAD_OBJECTS = \
|
||||||
thread/fls.o
|
thread/fls.o
|
||||||
|
|
||||||
THREAD_I386_OBJECTS = \
|
THREAD_I386_OBJECTS = \
|
||||||
thread/i386/fiber.o \
|
thread/i386/fiber.o
|
||||||
thread/i386/exit.o
|
|
||||||
|
|
||||||
PROCESS_OBJECTS = \
|
PROCESS_OBJECTS = \
|
||||||
process/proc.o \
|
process/proc.o \
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
.extern _K32ExitThread@4
|
|
||||||
|
|
||||||
.globl _K32SwitchStackAndExitThread@12
|
|
||||||
|
|
||||||
_K32SwitchStackAndExitThread@12:
|
|
||||||
movl 0xC(%esp), %edx /* nExitCode */
|
|
||||||
movl 0x8(%esp), %ecx /* nStackSize */
|
|
||||||
movl 0x4(%esp), %esp /* pStackBase */
|
|
||||||
addl %ecx, %esp
|
|
||||||
subl $0x4, %esp
|
|
||||||
pushl %edx
|
|
||||||
call _K32ExitThread@4
|
|
||||||
|
|
||||||
/* EOF */
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.47 2003/12/30 01:08:16 hyperion Exp $
|
/* $Id: thread.c,v 1.48 2003/12/30 05:10:32 hyperion Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -281,28 +281,6 @@ GetCurrentThreadId(VOID)
|
||||||
return((DWORD)(NtCurrentTeb()->Cid).UniqueThread);
|
return((DWORD)(NtCurrentTeb()->Cid).UniqueThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID FASTCALL K32FreeCurrentStack(VOID)
|
|
||||||
{
|
|
||||||
MEMORY_BASIC_INFORMATION mbiInfo;
|
|
||||||
|
|
||||||
if(VirtualQuery(NtCurrentTeb()->Tib.StackLimit, &mbiInfo, sizeof(mbiInfo)))
|
|
||||||
VirtualFree(mbiInfo.AllocationBase, 0, MEM_RELEASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
__declspec(noreturn) VOID STDCALL K32ExitThread(DWORD nExitCode)
|
|
||||||
{
|
|
||||||
K32FreeCurrentStack();
|
|
||||||
NtTerminateThread(NtCurrentThread(), nExitCode);
|
|
||||||
for(;;);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern __declspec(noreturn) VOID STDCALL K32SwitchStackAndExitThread
|
|
||||||
(
|
|
||||||
PVOID pStackBase,
|
|
||||||
SIZE_T uStackSize,
|
|
||||||
DWORD uExitCode
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -330,12 +308,7 @@ ExitThread(DWORD uExitCode)
|
||||||
|
|
||||||
LdrShutdownThread();
|
LdrShutdownThread();
|
||||||
|
|
||||||
K32SwitchStackAndExitThread
|
RtlRosExitUserThread(uExitCode);
|
||||||
(
|
|
||||||
NtCurrentTeb()->StaticUnicodeBuffer,
|
|
||||||
sizeof(NtCurrentTeb()->StaticUnicodeBuffer),
|
|
||||||
uExitCode
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: debug.c,v 1.12 2003/11/17 02:12:50 hyperion Exp $
|
/* $Id: debug.c,v 1.13 2003/12/30 05:10:32 hyperion Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <ntdll/rtl.h>
|
#include <ntdll/rtl.h>
|
||||||
#include <rosrtl/string.h>
|
#include <rosrtl/string.h>
|
||||||
|
#include <rosrtl/thread.h>
|
||||||
#include <ntdll/dbg.h>
|
#include <ntdll/dbg.h>
|
||||||
#include <napi/lpc.h>
|
#include <napi/lpc.h>
|
||||||
|
|
||||||
|
@ -189,7 +190,7 @@ NTSTATUS STDCALL DbgUiRemoteBreakin(VOID)
|
||||||
{
|
{
|
||||||
DbgBreakPoint();
|
DbgBreakPoint();
|
||||||
|
|
||||||
RtlExitUserThread(0);
|
RtlRosExitUserThread(0);
|
||||||
|
|
||||||
DbgBreakPoint();
|
DbgBreakPoint();
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
@implemented
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL RtlCreateUserThread
|
NTSTATUS STDCALL RtlCreateUserThread
|
||||||
(
|
(
|
||||||
HANDLE ProcessHandle,
|
HANDLE ProcessHandle,
|
||||||
|
@ -67,6 +70,9 @@ NTSTATUS STDCALL RtlCreateUserThread
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@implemented
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL RtlInitializeContext
|
NTSTATUS STDCALL RtlInitializeContext
|
||||||
(
|
(
|
||||||
HANDLE ProcessHandle,
|
HANDLE ProcessHandle,
|
||||||
|
@ -87,58 +93,24 @@ NTSTATUS STDCALL RtlInitializeContext
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@implemented
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL RtlFreeUserThreadStack
|
NTSTATUS STDCALL RtlFreeUserThreadStack
|
||||||
(
|
(
|
||||||
HANDLE ProcessHandle,
|
HANDLE ProcessHandle,
|
||||||
HANDLE ThreadHandle
|
HANDLE ThreadHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
THREAD_BASIC_INFORMATION tbiInfo;
|
return RtlRosFreeUserThreadStack(ProcessHandle, ThreadHandle);
|
||||||
NTSTATUS nErrCode;
|
|
||||||
ULONG nDummy;
|
|
||||||
ULONG nSize = 0;
|
|
||||||
PVOID pStackBase;
|
|
||||||
PTEB pTeb;
|
|
||||||
|
|
||||||
/* query basic information about the thread */
|
|
||||||
nErrCode = NtQueryInformationThread
|
|
||||||
(
|
|
||||||
ThreadHandle,
|
|
||||||
ThreadBasicInformation,
|
|
||||||
&tbiInfo,
|
|
||||||
sizeof(tbiInfo),
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
/* failure */
|
|
||||||
if(!NT_SUCCESS(nErrCode)) return nErrCode;
|
|
||||||
if(tbiInfo.TebBaseAddress == NULL) return STATUS_ACCESS_VIOLATION;
|
|
||||||
|
|
||||||
pTeb = (PTEB)tbiInfo.TebBaseAddress;
|
|
||||||
|
|
||||||
/* read the base address of the stack to be deallocated */
|
|
||||||
nErrCode = NtReadVirtualMemory
|
|
||||||
(
|
|
||||||
ProcessHandle,
|
|
||||||
&pTeb->DeallocationStack,
|
|
||||||
&pStackBase,
|
|
||||||
sizeof(pStackBase),
|
|
||||||
&nDummy
|
|
||||||
);
|
|
||||||
|
|
||||||
/* failure */
|
|
||||||
if(!NT_SUCCESS(nErrCode)) return nErrCode;
|
|
||||||
if(pStackBase == NULL) return STATUS_ACCESS_VIOLATION;
|
|
||||||
|
|
||||||
/* deallocate the stack */
|
|
||||||
nErrCode = NtFreeVirtualMemory(ProcessHandle, pStackBase, &nSize, MEM_RELEASE);
|
|
||||||
|
|
||||||
return nErrCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL RtlExitUserThread(NTSTATUS nErrCode)
|
/*
|
||||||
|
@implemented
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL RtlExitUserThread(NTSTATUS Status)
|
||||||
{
|
{
|
||||||
return NtTerminateThread(NtCurrentThread(), nErrCode);
|
RtlRosExitUserThread(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.9 2003/08/07 04:03:23 royce Exp $
|
# $Id: makefile,v 1.10 2003/12/30 05:10:32 hyperion Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
|
||||||
|
|
||||||
THREAD_OBJECTS = \
|
THREAD_OBJECTS = \
|
||||||
thread/create.o \
|
thread/create.o \
|
||||||
|
thread/exit.o \
|
||||||
thread/stack.o
|
thread/stack.o
|
||||||
|
|
||||||
MISC_OBJECTS = \
|
MISC_OBJECTS = \
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# $Id: makefile.i386,v 1.1 2003/07/22 20:10:04 hyperion Exp $
|
# $Id: makefile.i386,v 1.2 2003/12/30 05:10:32 hyperion Exp $
|
||||||
|
|
||||||
THREAD_OBJECTS := \
|
THREAD_OBJECTS := \
|
||||||
$(THREAD_OBJECTS) \
|
$(THREAD_OBJECTS) \
|
||||||
thread/linearstack.o \
|
thread/linearstack.o \
|
||||||
thread/$(ARCH)/context.o
|
thread/$(ARCH)/context.o \
|
||||||
|
thread/$(ARCH)/stackexit.o
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|
39
reactos/lib/rosrtl/thread/exit.c
Normal file
39
reactos/lib/rosrtl/thread/exit.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/* $Id: exit.c,v 1.1 2003/12/30 05:10:32 hyperion Exp $
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#include <ntos.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
|
#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
|
||||||
|
);
|
||||||
|
|
||||||
|
for(;;);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
13
reactos/lib/rosrtl/thread/i386/stackexit.S
Normal file
13
reactos/lib/rosrtl/thread/i386/stackexit.S
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
.globl _RtlRosSwitchStackForExit@16
|
||||||
|
|
||||||
|
_RtlRosSwitchStackForExit@16:
|
||||||
|
movl 0x10(%esp), %edx /* Parameter */
|
||||||
|
movl 0xC(%esp), %eax /* ExitRoutine */
|
||||||
|
movl 0x8(%esp), %ecx /* StackSize */
|
||||||
|
movl 0x4(%esp), %esp /* StackBase */
|
||||||
|
addl %ecx, %esp
|
||||||
|
subl $0x4, %esp
|
||||||
|
pushl %edx
|
||||||
|
call *%eax
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: stack.c,v 1.3 2003/07/22 20:10:04 hyperion Exp $
|
/* $Id: stack.c,v 1.4 2003/12/30 05:10:32 hyperion Exp $
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
@ -184,6 +184,57 @@ NTSTATUS NTAPI RtlRosDeleteStack
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS NTAPI RtlRosFreeUserThreadStack
|
||||||
|
(
|
||||||
|
IN HANDLE ProcessHandle,
|
||||||
|
IN HANDLE ThreadHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS nErrCode;
|
||||||
|
ULONG nSize = 0;
|
||||||
|
PVOID pStackBase;
|
||||||
|
|
||||||
|
if(ThreadHandle == NtCurrentThread())
|
||||||
|
pStackBase = NtCurrentTeb()->DeallocationStack;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
THREAD_BASIC_INFORMATION tbiInfo;
|
||||||
|
ULONG nDummy;
|
||||||
|
|
||||||
|
/* query basic information about the thread */
|
||||||
|
nErrCode = NtQueryInformationThread
|
||||||
|
(
|
||||||
|
ThreadHandle,
|
||||||
|
ThreadBasicInformation,
|
||||||
|
&tbiInfo,
|
||||||
|
sizeof(tbiInfo),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
/* failure */
|
||||||
|
if(!NT_SUCCESS(nErrCode)) return nErrCode;
|
||||||
|
if(tbiInfo.TebBaseAddress == NULL) return STATUS_ACCESS_VIOLATION;
|
||||||
|
|
||||||
|
/* read the base address of the stack to be deallocated */
|
||||||
|
nErrCode = NtReadVirtualMemory
|
||||||
|
(
|
||||||
|
ProcessHandle,
|
||||||
|
&((PTEB)tbiInfo.TebBaseAddress)->DeallocationStack,
|
||||||
|
&pStackBase,
|
||||||
|
sizeof(pStackBase),
|
||||||
|
&nDummy
|
||||||
|
);
|
||||||
|
|
||||||
|
/* failure */
|
||||||
|
if(!NT_SUCCESS(nErrCode)) return nErrCode;
|
||||||
|
if(pStackBase == NULL) return STATUS_ACCESS_VIOLATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* deallocate the stack */
|
||||||
|
nErrCode = NtFreeVirtualMemory(ProcessHandle, pStackBase, &nSize, MEM_RELEASE);
|
||||||
|
|
||||||
|
return nErrCode;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI RtlpRosGetStackLimits
|
NTSTATUS NTAPI RtlpRosGetStackLimits
|
||||||
(
|
(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: wapi.c,v 1.32 2003/12/05 08:43:16 gvg Exp $
|
/* $Id: wapi.c,v 1.33 2003/12/30 05:10:32 hyperion Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/wapi.c
|
* reactos/subsys/csrss/api/wapi.c
|
||||||
*
|
*
|
||||||
|
@ -120,7 +120,7 @@ Thread_Api2(HANDLE ServerPort)
|
||||||
{
|
{
|
||||||
DPRINT1("CSR: NtReplyWaitReceivePort failed\n");
|
DPRINT1("CSR: NtReplyWaitReceivePort failed\n");
|
||||||
NtClose(ServerPort);
|
NtClose(ServerPort);
|
||||||
NtTerminateThread(NtCurrentThread(), Status);
|
RtlRosExitUserThread(Status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ Thread_Api2(HANDLE ServerPort)
|
||||||
{
|
{
|
||||||
CsrFreeProcessData( (ULONG)LpcRequest.Header.ClientId.UniqueProcess );
|
CsrFreeProcessData( (ULONG)LpcRequest.Header.ClientId.UniqueProcess );
|
||||||
NtClose(ServerPort);
|
NtClose(ServerPort);
|
||||||
NtTerminateThread(NtCurrentThread(), STATUS_SUCCESS);
|
RtlRosExitUserThread(STATUS_SUCCESS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue