ntdll: Pass a server context to server_select().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f04c2bd4f1
commit
8eda3fcc68
|
@ -620,24 +620,18 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
|
|||
* server_select
|
||||
*/
|
||||
unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
|
||||
timeout_t abs_timeout, CONTEXT *context, pthread_mutex_t *mutex,
|
||||
timeout_t abs_timeout, context_t *context, pthread_mutex_t *mutex,
|
||||
user_apc_t *user_apc )
|
||||
{
|
||||
unsigned int ret;
|
||||
int cookie;
|
||||
obj_handle_t apc_handle = 0;
|
||||
context_t server_context;
|
||||
BOOL suspend_context = FALSE;
|
||||
BOOL suspend_context = !!context;
|
||||
apc_call_t call;
|
||||
apc_result_t result;
|
||||
sigset_t old_set;
|
||||
|
||||
memset( &result, 0, sizeof(result) );
|
||||
if (context)
|
||||
{
|
||||
suspend_context = TRUE;
|
||||
context_to_server( &server_context, context, current_machine );
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -655,26 +649,13 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
|
|||
wine_server_add_data( req, select_op, size );
|
||||
if (suspend_context)
|
||||
{
|
||||
wine_server_add_data( req, &server_context, sizeof(server_context) );
|
||||
wine_server_add_data( req, context, sizeof(*context) );
|
||||
suspend_context = FALSE; /* server owns the context now */
|
||||
}
|
||||
if (context) wine_server_set_reply( req, &server_context, sizeof(server_context) );
|
||||
if (context) wine_server_set_reply( req, context, sizeof(*context) );
|
||||
ret = server_call_unlocked( req );
|
||||
apc_handle = reply->apc_handle;
|
||||
call = reply->call;
|
||||
if (wine_server_reply_size( reply ))
|
||||
{
|
||||
DWORD context_flags = context->ContextFlags; /* unchanged registers are still available */
|
||||
XSTATE *xs = xstate_from_context( context );
|
||||
ULONG64 mask;
|
||||
|
||||
if (xs)
|
||||
mask = xs->Mask;
|
||||
context_from_server( context, &server_context, current_machine );
|
||||
context->ContextFlags |= context_flags;
|
||||
if (xs)
|
||||
xs->Mask |= mask;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ static unsigned int get_server_context_flags( const void *context, USHORT machin
|
|||
*
|
||||
* Convert a register context to the server format.
|
||||
*/
|
||||
NTSTATUS context_to_server( context_t *to, const void *src, USHORT machine )
|
||||
static NTSTATUS context_to_server( context_t *to, const void *src, USHORT machine )
|
||||
{
|
||||
DWORD i, flags;
|
||||
|
||||
|
@ -388,7 +388,7 @@ NTSTATUS context_to_server( context_t *to, const void *src, USHORT machine )
|
|||
*
|
||||
* Convert a register context from the server format.
|
||||
*/
|
||||
NTSTATUS context_from_server( void *dst, const context_t *from, USHORT machine )
|
||||
static NTSTATUS context_from_server( void *dst, const context_t *from, USHORT machine )
|
||||
{
|
||||
DWORD i;
|
||||
|
||||
|
@ -1052,9 +1052,12 @@ void exit_process( int status )
|
|||
void wait_suspend( CONTEXT *context )
|
||||
{
|
||||
int saved_errno = errno;
|
||||
context_t server_context;
|
||||
|
||||
context_to_server( &server_context, context, current_machine );
|
||||
/* wait with 0 timeout, will only return once the thread is no longer suspended */
|
||||
server_select( NULL, 0, SELECT_INTERRUPTIBLE, 0, context, NULL, NULL );
|
||||
server_select( NULL, 0, SELECT_INTERRUPTIBLE, 0, &server_context, NULL, NULL );
|
||||
context_from_server( context, &server_context, current_machine );
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
|
@ -1095,22 +1098,15 @@ NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_c
|
|||
|
||||
if (handle)
|
||||
{
|
||||
struct xcontext exception_context;
|
||||
DECLSPEC_ALIGN(64) XSTATE xs;
|
||||
XSTATE *src_xs;
|
||||
context_t server_context;
|
||||
|
||||
select_op.wait.op = SELECT_WAIT;
|
||||
select_op.wait.handles[0] = handle;
|
||||
|
||||
exception_context.c = *context;
|
||||
if ((src_xs = xstate_from_context( context )))
|
||||
{
|
||||
context_init_xstate( &exception_context.c, &xs );
|
||||
memcpy( &xs, src_xs, sizeof(xs) );
|
||||
}
|
||||
context_to_server( &server_context, context, current_machine );
|
||||
|
||||
server_select( &select_op, offsetof( select_op_t, wait.handles[1] ), SELECT_INTERRUPTIBLE,
|
||||
TIMEOUT_INFINITE, &exception_context.c, NULL, NULL );
|
||||
TIMEOUT_INFINITE, &server_context, NULL, NULL );
|
||||
|
||||
SERVER_START_REQ( get_exception_status )
|
||||
{
|
||||
|
@ -1118,12 +1114,7 @@ NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_c
|
|||
ret = wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
if (ret >= 0)
|
||||
{
|
||||
*context = exception_context.c;
|
||||
if (src_xs)
|
||||
memcpy( src_xs, &xs, sizeof(xs) );
|
||||
}
|
||||
if (ret >= 0) context_from_server( context, &server_context, current_machine );
|
||||
}
|
||||
|
||||
pthread_sigmask( SIG_SETMASK, &old_set, NULL );
|
||||
|
|
|
@ -159,7 +159,7 @@ extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN;
|
|||
extern void server_enter_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
||||
extern void server_leave_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
||||
extern unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
|
||||
timeout_t abs_timeout, CONTEXT *context, pthread_mutex_t *mutex,
|
||||
timeout_t abs_timeout, context_t *context, pthread_mutex_t *mutex,
|
||||
user_apc_t *user_apc ) DECLSPEC_HIDDEN;
|
||||
extern unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT flags,
|
||||
const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
|
||||
|
@ -177,8 +177,6 @@ extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN;
|
|||
extern void set_thread_id( TEB *teb, DWORD pid, DWORD tid ) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR zero_bits, SIZE_T reserve_size,
|
||||
SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS context_to_server( context_t *to, const void *src, USHORT machine ) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS context_from_server( void *dst, const context_t *from, USHORT machine ) 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;
|
||||
|
|
Loading…
Reference in New Issue