Commit e8a1341f authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add platform-specific helpers for getting/setting the Wow64 context.

parent ee0b909f
......@@ -412,6 +412,24 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
/***********************************************************************
* set_thread_wow64_context
*/
NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size )
{
return STATUS_INVALID_INFO_CLASS;
}
/***********************************************************************
* get_thread_wow64_context
*/
NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size )
{
return STATUS_INVALID_INFO_CLASS;
}
/***********************************************************************
* setup_exception
*
* Modify the signal context to call the exception raise function.
......
......@@ -481,6 +481,42 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
}
/***********************************************************************
* set_thread_wow64_context
*/
NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size )
{
BOOL self;
USHORT machine;
switch (size)
{
case sizeof(I386_CONTEXT): machine = IMAGE_FILE_MACHINE_I386; break;
case sizeof(ARM_CONTEXT): machine = IMAGE_FILE_MACHINE_ARMNT; break;
default: return STATUS_INFO_LENGTH_MISMATCH;
}
return set_thread_context( handle, ctx, &self, machine );
}
/***********************************************************************
* get_thread_wow64_context
*/
NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size )
{
BOOL self;
USHORT machine;
switch (size)
{
case sizeof(I386_CONTEXT): machine = IMAGE_FILE_MACHINE_I386; break;
case sizeof(ARM_CONTEXT): machine = IMAGE_FILE_MACHINE_ARMNT; break;
default: return STATUS_INFO_LENGTH_MISMATCH;
}
return get_thread_context( handle, ctx, &self, machine );
}
/* Note, unwind_builtin_dll above has hardcoded assumptions on how this
* function stores things on the stack; if modified, modify that one in
* sync as well. */
......
......@@ -1256,6 +1256,24 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
/***********************************************************************
* set_thread_wow64_context
*/
NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size )
{
return STATUS_INVALID_INFO_CLASS;
}
/***********************************************************************
* get_thread_wow64_context
*/
NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size )
{
return STATUS_INVALID_INFO_CLASS;
}
/***********************************************************************
* is_privileged_instr
*
* Check if the fault location is a privileged instruction.
......
......@@ -1849,6 +1849,31 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
return STATUS_SUCCESS;
}
/***********************************************************************
* set_thread_wow64_context
*/
NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size )
{
BOOL self;
if (size != sizeof(I386_CONTEXT)) return STATUS_INFO_LENGTH_MISMATCH;
return set_thread_context( handle, ctx, &self, IMAGE_FILE_MACHINE_I386 );
}
/***********************************************************************
* get_thread_wow64_context
*/
NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size )
{
BOOL self;
if (size != sizeof(I386_CONTEXT)) return STATUS_INFO_LENGTH_MISMATCH;
return get_thread_context( handle, ctx, &self, IMAGE_FILE_MACHINE_I386 );
}
extern void CDECL raise_func_trampoline( void *dispatcher );
__ASM_GLOBAL_FUNC( raise_func_trampoline,
......
......@@ -1665,19 +1665,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
}
case ThreadWow64Context:
{
#ifdef _WIN64
BOOL self;
WOW64_CONTEXT *context = data;
if (length != sizeof(*context)) return STATUS_INFO_LENGTH_MISMATCH;
if ((status = get_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 ))) return status;
if (ret_len && !status) *ret_len = sizeof(*context);
return status;
#else
return STATUS_INVALID_INFO_CLASS;
#endif
}
return get_thread_wow64_context( handle, data, length );
case ThreadHideFromDebugger:
if (length != sizeof(BOOLEAN)) return STATUS_INFO_LENGTH_MISMATCH;
......@@ -1860,17 +1848,7 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
}
case ThreadWow64Context:
{
#ifdef _WIN64
BOOL self;
const WOW64_CONTEXT *context = data;
if (length != sizeof(*context)) return STATUS_INFO_LENGTH_MISMATCH;
return set_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 );
#else
return STATUS_INVALID_INFO_CLASS;
#endif
}
return set_thread_wow64_context( handle, data, length );
case ThreadEnableAlignmentFaultFixup:
if (length != sizeof(BOOLEAN)) return STATUS_INFO_LENGTH_MISMATCH;
......
......@@ -236,6 +236,8 @@ extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE ent
extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN;
extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN;
extern void signal_restore_full_cpu_context(void) DECLSPEC_HIDDEN;
extern NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size ) DECLSPEC_HIDDEN;
extern NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size ) DECLSPEC_HIDDEN;
extern void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid ) DECLSPEC_HIDDEN;
extern NTSTATUS open_hkcu_key( const char *path, HANDLE *key ) DECLSPEC_HIDDEN;
......
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