Commit 7404ef3e authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Don't rely on get_thread_context() updating the context flags.

parent 19f19d0e
......@@ -405,19 +405,16 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
*/
NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
{
NTSTATUS ret;
struct syscall_frame *frame = arm_thread_data()->syscall_frame;
DWORD needed_flags = context->ContextFlags & ~CONTEXT_ARM;
BOOL self = (handle == GetCurrentThread());
if (!self)
{
if ((ret = get_thread_context( handle, &context, &self, IMAGE_FILE_MACHINE_ARMNT ))) return ret;
needed_flags &= ~context->ContextFlags;
NTSTATUS ret = get_thread_context( handle, &context, &self, IMAGE_FILE_MACHINE_ARMNT );
if (ret || !self) return ret;
}
if (self)
{
if (needed_flags & CONTEXT_INTEGER)
{
context->R0 = frame->r0;
......@@ -449,7 +446,6 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
memcpy( context->u.D, frame->d, sizeof(frame->d) );
context->ContextFlags |= CONTEXT_FLOATING_POINT;
}
}
return STATUS_SUCCESS;
}
......
......@@ -493,19 +493,16 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
*/
NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
{
NTSTATUS ret;
struct syscall_frame *frame = arm64_thread_data()->syscall_frame;
DWORD needed_flags = context->ContextFlags & ~CONTEXT_ARM64;
BOOL self = (handle == GetCurrentThread());
if (!self)
{
if ((ret = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_ARM64 ))) return ret;
needed_flags &= ~context->ContextFlags;
NTSTATUS ret = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_ARM64 );
if (ret || !self) return ret;
}
if (self)
{
if (needed_flags & CONTEXT_INTEGER)
{
memcpy( context->u.X, frame->x, sizeof(context->u.X[0]) * 29 );
......@@ -528,7 +525,6 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
context->ContextFlags |= CONTEXT_FLOATING_POINT;
}
if (needed_flags & CONTEXT_DEBUG_REGISTERS) FIXME( "debug registers not supported\n" );
}
return STATUS_SUCCESS;
}
......
......@@ -1024,7 +1024,6 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
if (!self)
{
if ((ret = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 ))) return ret;
needed_flags &= ~context->ContextFlags;
}
if (self)
......@@ -1129,7 +1128,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
}
}
/* update the cached version of the debug registers */
if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386))
if (needed_flags & CONTEXT_DEBUG_REGISTERS)
{
x86_thread_data()->dr0 = context->Dr0;
x86_thread_data()->dr1 = context->Dr1;
......
......@@ -1725,26 +1725,19 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
*/
NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
{
NTSTATUS ret;
DWORD needed_flags;
struct syscall_frame *frame = amd64_thread_data()->syscall_frame;
DWORD needed_flags = context->ContextFlags & ~CONTEXT_AMD64;
BOOL self = (handle == GetCurrentThread());
if (!context) return STATUS_INVALID_PARAMETER;
needed_flags = context->ContextFlags & ~CONTEXT_AMD64;
/* debug registers require a server call */
if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64)) self = FALSE;
if (needed_flags & CONTEXT_DEBUG_REGISTERS) self = FALSE;
if (!self)
{
if ((ret = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_AMD64 ))) return ret;
needed_flags &= ~context->ContextFlags;
NTSTATUS ret = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_AMD64 );
if (ret || !self) return ret;
}
if (self)
{
if (needed_flags & CONTEXT_INTEGER)
{
context->Rax = frame->rax;
......@@ -1837,7 +1830,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
}
}
/* update the cached version of the debug registers */
if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64))
if (needed_flags & CONTEXT_DEBUG_REGISTERS)
{
amd64_thread_data()->dr0 = context->Dr0;
amd64_thread_data()->dr1 = context->Dr1;
......@@ -1846,8 +1839,6 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
amd64_thread_data()->dr6 = context->Dr6;
amd64_thread_data()->dr7 = context->Dr7;
}
}
return STATUS_SUCCESS;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment