ntdll: Avoid private Unix functions in RtlExitUserThread().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-07-22 13:04:54 +02:00
parent a511c0937c
commit d41b1c28c3
6 changed files with 14 additions and 28 deletions

View file

@ -81,26 +81,11 @@ void WINAPI RtlExitUserThread( ULONG status )
{
ULONG last;
if (status) /* send the exit code to the server (0 is already the default) */
{
SERVER_START_REQ( terminate_thread )
{
req->handle = wine_server_obj_handle( GetCurrentThread() );
req->exit_code = status;
wine_server_call( req );
}
SERVER_END_REQ;
}
NtQueryInformationThread( GetCurrentThread(), ThreadAmILastThread, &last, sizeof(last), NULL );
if (last)
{
LdrShutdownProcess();
unix_funcs->exit_process( status );
}
if (last) RtlExitUserProcess( status );
LdrShutdownThread();
RtlFreeThreadActivationContextStack();
for (;;) unix_funcs->exit_thread( status );
for (;;) NtTerminateThread( GetCurrentThread(), status );
}

View file

@ -1404,8 +1404,6 @@ static struct unix_funcs unix_funcs =
virtual_locked_recvmsg,
virtual_release_address_space,
virtual_set_large_address_space,
exit_thread,
exit_process,
exec_process,
wine_server_call,
server_send_fd,

View file

@ -1002,6 +1002,7 @@ done:
*/
NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
{
static BOOL clean_exit;
NTSTATUS ret;
BOOL self;
@ -1013,7 +1014,12 @@ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
self = reply->self;
}
SERVER_END_REQ;
if (self && handle) abort_process( exit_code );
if (self)
{
if (!handle) clean_exit = TRUE;
else if (clean_exit) exit_process( exit_code );
else abort_process( exit_code );
}
return ret;
}

View file

@ -298,7 +298,7 @@ void abort_process( int status )
/***********************************************************************
* exit_thread
*/
void CDECL exit_thread( int status )
static void exit_thread( int status )
{
static void *prev_teb;
TEB *teb;
@ -322,7 +322,7 @@ void CDECL exit_thread( int status )
/***********************************************************************
* exit_process
*/
void CDECL exit_process( int status )
void exit_process( int status )
{
pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
signal_exit_thread( get_unix_exit_code( status ), exit );
@ -525,7 +525,7 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
}
SERVER_END_REQ;
}
if (self) abort_thread( exit_code );
if (self) exit_thread( exit_code );
return ret;
}

View file

@ -120,8 +120,6 @@ extern NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, i
unsigned int *options ) DECLSPEC_HIDDEN;
extern void CDECL server_release_fd( HANDLE handle, int unix_fd ) DECLSPEC_HIDDEN;
extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN;
extern void CDECL DECLSPEC_NORETURN exit_thread( int status ) DECLSPEC_HIDDEN;
extern void CDECL DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch,
CONTEXT *context ) DECLSPEC_HIDDEN;
@ -181,6 +179,7 @@ extern NTSTATUS context_to_server( context_t *to, const CONTEXT *from ) DECLSPEC
extern NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN abort_process( int status ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN;
extern void wait_suspend( CONTEXT *context ) DECLSPEC_HIDDEN;
extern NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ) DECLSPEC_HIDDEN;
extern NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOOL *self ) DECLSPEC_HIDDEN;

View file

@ -28,7 +28,7 @@ struct msghdr;
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 90
#define NTDLL_UNIXLIB_VERSION 91
struct unix_funcs
{
@ -97,8 +97,6 @@ struct unix_funcs
void (CDECL *virtual_set_large_address_space)(void);
/* thread/process functions */
void (CDECL *exit_thread)( int status );
void (CDECL *exit_process)( int status );
NTSTATUS (CDECL *exec_process)( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status );
/* server functions */