From 6159b12330666eb35fc18f1b709342ee5d2ef5d8 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 29 Jul 2021 11:04:20 +0200 Subject: [PATCH] wow64: Add thunks for the process/thread control syscalls. Signed-off-by: Alexandre Julliard --- dlls/wow64/process.c | 207 +++++++++++++++++++++++++++++++++++++++++++ dlls/wow64/syscall.h | 16 ++++ 2 files changed, 223 insertions(+) diff --git a/dlls/wow64/process.c b/dlls/wow64/process.c index 8f9ac3e6648..92ef5108658 100644 --- a/dlls/wow64/process.c +++ b/dlls/wow64/process.c @@ -32,6 +32,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(wow); +static SIZE_T get_machine_context_size( USHORT machine ) +{ + switch (machine) + { + case IMAGE_FILE_MACHINE_I386: return sizeof(I386_CONTEXT); + case IMAGE_FILE_MACHINE_ARMNT: return sizeof(ARM_CONTEXT); + case IMAGE_FILE_MACHINE_AMD64: return sizeof(AMD64_CONTEXT); + case IMAGE_FILE_MACHINE_ARM64: return sizeof(ARM64_NT_CONTEXT); + default: return 0; + } +} + + static BOOL is_process_wow64( HANDLE handle ) { ULONG_PTR info; @@ -229,6 +242,41 @@ static void put_ps_attributes( PS_ATTRIBUTE_LIST32 *attr32, const PS_ATTRIBUTE_L } +/********************************************************************** + * wow64_NtAlertResumeThread + */ +NTSTATUS WINAPI wow64_NtAlertResumeThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ULONG *count = get_ptr( &args ); + + return NtAlertResumeThread( handle, count ); +} + + +/********************************************************************** + * wow64_NtAlertThread + */ +NTSTATUS WINAPI wow64_NtAlertThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + + return NtAlertThread( handle ); +} + + +/********************************************************************** + * wow64_NtAssignProcessToJobObject + */ +NTSTATUS WINAPI wow64_NtAssignProcessToJobObject( UINT *args ) +{ + HANDLE job = get_handle( &args ); + HANDLE process = get_handle( &args ); + + return NtAssignProcessToJobObject( job, process ); +} + + /********************************************************************** * wow64_NtCreateThread */ @@ -328,6 +376,66 @@ NTSTATUS WINAPI wow64_NtCreateUserProcess( UINT *args ) } +/********************************************************************** + * wow64_NtDebugActiveProcess + */ +NTSTATUS WINAPI wow64_NtDebugActiveProcess( UINT *args ) +{ + HANDLE process = get_handle( &args ); + HANDLE debug = get_handle( &args ); + + return NtDebugActiveProcess( process, debug ); +} + + +/********************************************************************** + * wow64_NtFlushInstructionCache + */ +NTSTATUS WINAPI wow64_NtFlushInstructionCache( UINT *args ) +{ + HANDLE process = get_handle( &args ); + const void *addr = get_ptr( &args ); + SIZE_T size = get_ulong( &args ); + + return NtFlushInstructionCache( process, addr, size ); +} + + +/********************************************************************** + * wow64_NtFlushProcessWriteBuffers + */ +NTSTATUS WINAPI wow64_NtFlushProcessWriteBuffers( UINT *args ) +{ + NtFlushProcessWriteBuffers(); + return STATUS_SUCCESS; +} + + +/********************************************************************** + * wow64_NtGetContextThread + */ +NTSTATUS WINAPI wow64_NtGetContextThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + WOW64_CONTEXT *context = get_ptr( &args ); + + return NtQueryInformationThread( handle, ThreadWow64Context, context, + get_machine_context_size( current_machine ), NULL ); +} + + +/********************************************************************** + * wow64_NtIsProcessInJob + */ +NTSTATUS WINAPI wow64_NtIsProcessInJob( UINT *args ) +{ + HANDLE process = get_handle( &args ); + HANDLE job = get_handle( &args ); + + return NtIsProcessInJob( process, job ); +} + + /********************************************************************** * wow64_NtOpenProcess */ @@ -372,6 +480,105 @@ NTSTATUS WINAPI wow64_NtOpenThread( UINT *args ) } +/********************************************************************** + * wow64_NtQueueApcThread + */ +NTSTATUS WINAPI wow64_NtQueueApcThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ULONG func = get_ulong( &args ); + ULONG arg1 = get_ulong( &args ); + ULONG arg2 = get_ulong( &args ); + ULONG arg3 = get_ulong( &args ); + + return NtQueueApcThread( handle, apc_32to64( func ), + (ULONG_PTR)apc_param_32to64( func, arg1 ), arg2, arg3 ); +} + + +/********************************************************************** + * wow64_NtRemoveProcessDebug + */ +NTSTATUS WINAPI wow64_NtRemoveProcessDebug( UINT *args ) +{ + HANDLE process = get_handle( &args ); + HANDLE debug = get_handle( &args ); + + return NtRemoveProcessDebug( process, debug ); +} + + +/********************************************************************** + * wow64_NtResumeProcess + */ +NTSTATUS WINAPI wow64_NtResumeProcess( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + + return NtResumeProcess( handle ); +} + + +/********************************************************************** + * wow64_NtResumeThread + */ +NTSTATUS WINAPI wow64_NtResumeThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ULONG *count = get_ptr( &args ); + + return NtResumeThread( handle, count ); +} + + +/********************************************************************** + * wow64_NtSetContextThread + */ +NTSTATUS WINAPI wow64_NtSetContextThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + WOW64_CONTEXT *context = get_ptr( &args ); + + return NtSetInformationThread( handle, ThreadWow64Context, + context, get_machine_context_size( current_machine )); +} + + +/********************************************************************** + * wow64_NtSetThreadExecutionState + */ +NTSTATUS WINAPI wow64_NtSetThreadExecutionState( UINT *args ) +{ + EXECUTION_STATE new_state = get_ulong( &args ); + EXECUTION_STATE *old_state = get_ptr( &args ); + + return NtSetThreadExecutionState( new_state, old_state ); +} + + +/********************************************************************** + * wow64_NtSuspendProcess + */ +NTSTATUS WINAPI wow64_NtSuspendProcess( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + + return NtSuspendProcess( handle ); +} + + +/********************************************************************** + * wow64_NtSuspendThread + */ +NTSTATUS WINAPI wow64_NtSuspendThread( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + ULONG *count = get_ptr( &args ); + + return NtSuspendThread( handle, count ); +} + + /********************************************************************** * wow64_NtTerminateProcess */ diff --git a/dlls/wow64/syscall.h b/dlls/wow64/syscall.h index e2238e34186..98f87f395a7 100644 --- a/dlls/wow64/syscall.h +++ b/dlls/wow64/syscall.h @@ -24,11 +24,14 @@ #define ALL_SYSCALLS \ SYSCALL_ENTRY( NtAcceptConnectPort ) \ SYSCALL_ENTRY( NtAddAtom ) \ + SYSCALL_ENTRY( NtAlertResumeThread ) \ + SYSCALL_ENTRY( NtAlertThread ) \ SYSCALL_ENTRY( NtAllocateLocallyUniqueId ) \ SYSCALL_ENTRY( NtAllocateUuids ) \ SYSCALL_ENTRY( NtAllocateVirtualMemory ) \ SYSCALL_ENTRY( NtAllocateVirtualMemoryEx ) \ SYSCALL_ENTRY( NtAreMappedFilesTheSame ) \ + SYSCALL_ENTRY( NtAssignProcessToJobObject ) \ SYSCALL_ENTRY( NtCancelIoFile ) \ SYSCALL_ENTRY( NtCancelIoFileEx ) \ SYSCALL_ENTRY( NtCancelTimer ) \ @@ -59,6 +62,7 @@ SYSCALL_ENTRY( NtCreateThreadEx ) \ SYSCALL_ENTRY( NtCreateTimer ) \ SYSCALL_ENTRY( NtCreateUserProcess ) \ + SYSCALL_ENTRY( NtDebugActiveProcess ) \ SYSCALL_ENTRY( NtDebugContinue ) \ SYSCALL_ENTRY( NtDelayExecution ) \ SYSCALL_ENTRY( NtDeleteAtom ) \ @@ -70,12 +74,16 @@ SYSCALL_ENTRY( NtEnumerateValueKey ) \ SYSCALL_ENTRY( NtFindAtom ) \ SYSCALL_ENTRY( NtFlushBuffersFile ) \ + SYSCALL_ENTRY( NtFlushInstructionCache ) \ SYSCALL_ENTRY( NtFlushKey ) \ + SYSCALL_ENTRY( NtFlushProcessWriteBuffers ) \ SYSCALL_ENTRY( NtFlushVirtualMemory ) \ SYSCALL_ENTRY( NtFreeVirtualMemory ) \ + SYSCALL_ENTRY( NtGetContextThread ) \ SYSCALL_ENTRY( NtGetCurrentProcessorNumber ) \ SYSCALL_ENTRY( NtGetNlsSectionPtr ) \ SYSCALL_ENTRY( NtGetWriteWatch ) \ + SYSCALL_ENTRY( NtIsProcessInJob ) \ SYSCALL_ENTRY( NtListenPort ) \ SYSCALL_ENTRY( NtLoadKey ) \ SYSCALL_ENTRY( NtLoadKey2 ) \ @@ -128,6 +136,7 @@ SYSCALL_ENTRY( NtQueryValueKey ) \ SYSCALL_ENTRY( NtQueryVirtualMemory ) \ SYSCALL_ENTRY( NtQueryVolumeInformationFile ) \ + SYSCALL_ENTRY( NtQueueApcThread ) \ SYSCALL_ENTRY( NtReadFile ) \ SYSCALL_ENTRY( NtReadFileScatter ) \ SYSCALL_ENTRY( NtReadVirtualMemory ) \ @@ -136,6 +145,7 @@ SYSCALL_ENTRY( NtReleaseSemaphore ) \ SYSCALL_ENTRY( NtRemoveIoCompletion ) \ SYSCALL_ENTRY( NtRemoveIoCompletionEx ) \ + SYSCALL_ENTRY( NtRemoveProcessDebug ) \ SYSCALL_ENTRY( NtRenameKey ) \ SYSCALL_ENTRY( NtReplaceKey ) \ SYSCALL_ENTRY( NtReplyWaitReceivePort ) \ @@ -143,8 +153,11 @@ SYSCALL_ENTRY( NtResetEvent ) \ SYSCALL_ENTRY( NtResetWriteWatch ) \ SYSCALL_ENTRY( NtRestoreKey ) \ + SYSCALL_ENTRY( NtResumeProcess ) \ + SYSCALL_ENTRY( NtResumeThread ) \ SYSCALL_ENTRY( NtSaveKey ) \ SYSCALL_ENTRY( NtSecureConnectPort ) \ + SYSCALL_ENTRY( NtSetContextThread ) \ SYSCALL_ENTRY( NtSetDefaultLocale ) \ SYSCALL_ENTRY( NtSetDefaultUILanguage ) \ SYSCALL_ENTRY( NtSetEaFile ) \ @@ -155,11 +168,14 @@ SYSCALL_ENTRY( NtSetInformationObject ) \ SYSCALL_ENTRY( NtSetIoCompletion ) \ SYSCALL_ENTRY( NtSetPowerRequest ) \ + SYSCALL_ENTRY( NtSetThreadExecutionState ) \ SYSCALL_ENTRY( NtSetTimer ) \ SYSCALL_ENTRY( NtSetTimerResolution ) \ SYSCALL_ENTRY( NtSetValueKey ) \ SYSCALL_ENTRY( NtSetVolumeInformationFile ) \ SYSCALL_ENTRY( NtSignalAndWaitForSingleObject ) \ + SYSCALL_ENTRY( NtSuspendProcess ) \ + SYSCALL_ENTRY( NtSuspendThread ) \ SYSCALL_ENTRY( NtTerminateJobObject ) \ SYSCALL_ENTRY( NtTerminateProcess ) \ SYSCALL_ENTRY( NtTerminateThread ) \