From 54901695dcbf97173bc22c0df4b916089d2eeb11 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 23 Jul 2021 17:00:52 +0200 Subject: [PATCH] wow64: Add thunks for the timer syscalls. Signed-off-by: Alexandre Julliard --- dlls/wow64/sync.c | 86 ++++++++++++++++++++++++++++++++++++++ dlls/wow64/syscall.h | 7 +++- dlls/wow64/wow64_private.h | 11 +++++ 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/dlls/wow64/sync.c b/dlls/wow64/sync.c index bd7e20ca02c..c6c5e1d374d 100644 --- a/dlls/wow64/sync.c +++ b/dlls/wow64/sync.c @@ -29,6 +29,18 @@ #include "wow64_private.h" +/********************************************************************** + * wow64_NtCancelTimer + */ +NTSTATUS WINAPI wow64_NtCancelTimer( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + BOOLEAN *state = get_ptr( &args ); + + return NtCancelTimer( handle, state ); +} + + /********************************************************************** * wow64_NtClearEvent */ @@ -105,6 +117,27 @@ NTSTATUS WINAPI wow64_NtCreateSemaphore( UINT *args ) } +/********************************************************************** + * wow64_NtCreateTimer + */ +NTSTATUS WINAPI wow64_NtCreateTimer( UINT *args ) +{ + ULONG *handle_ptr = get_ptr( &args ); + ACCESS_MASK access = get_ulong( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + TIMER_TYPE type = get_ulong( &args ); + + struct object_attr64 attr; + HANDLE handle = 0; + NTSTATUS status; + + *handle_ptr = 0; + status = NtCreateTimer( &handle, access, objattr_32to64( &attr, attr32 ), type ); + put_handle( handle_ptr, handle ); + return status; +} + + /********************************************************************** * wow64_NtOpenEvent */ @@ -165,6 +198,26 @@ NTSTATUS WINAPI wow64_NtOpenSemaphore( UINT *args ) } +/********************************************************************** + * wow64_NtOpenTimer + */ +NTSTATUS WINAPI wow64_NtOpenTimer( UINT *args ) +{ + ULONG *handle_ptr = get_ptr( &args ); + ACCESS_MASK access = get_ulong( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + + struct object_attr64 attr; + HANDLE handle = 0; + NTSTATUS status; + + *handle_ptr = 0; + status = NtOpenTimer( &handle, access, objattr_32to64( &attr, attr32 )); + put_handle( handle_ptr, handle ); + return status; +} + + /********************************************************************** * wow64_NtPulseEvent */ @@ -222,6 +275,21 @@ NTSTATUS WINAPI wow64_NtQuerySemaphore( UINT *args ) } +/********************************************************************** + * wow64_NtQueryTimer + */ +NTSTATUS WINAPI wow64_NtQueryTimer( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + TIMER_INFORMATION_CLASS class = get_ulong( &args ); + void *info = get_ptr( &args ); + ULONG len = get_ulong( &args ); + ULONG *retlen = get_ptr( &args ); + + return NtQueryTimer( handle, class, info, len, retlen ); +} + + /********************************************************************** * wow64_NtReleaseMutant */ @@ -269,3 +337,21 @@ NTSTATUS WINAPI wow64_NtSetEvent( UINT *args ) return NtSetEvent( handle, prev_state ); } + + +/********************************************************************** + * wow64_NtSetTimer + */ +NTSTATUS WINAPI wow64_NtSetTimer( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + LARGE_INTEGER *when = get_ptr( &args ); + ULONG apc = get_ulong( &args ); + ULONG apc_param = get_ulong( &args ); + BOOLEAN resume = get_ulong( &args ); + ULONG period = get_ulong( &args ); + BOOLEAN *state = get_ptr( &args ); + + return NtSetTimer( handle, when, apc_32to64( apc ), apc_param_32to64( apc, apc_param ), + resume, period, state ); +} diff --git a/dlls/wow64/syscall.h b/dlls/wow64/syscall.h index bb9f220332c..f348ecfe1d9 100644 --- a/dlls/wow64/syscall.h +++ b/dlls/wow64/syscall.h @@ -25,17 +25,20 @@ SYSCALL_ENTRY( NtAddAtom ) \ SYSCALL_ENTRY( NtAllocateLocallyUniqueId ) \ SYSCALL_ENTRY( NtAllocateUuids ) \ + SYSCALL_ENTRY( NtCancelTimer ) \ SYSCALL_ENTRY( NtClearEvent ) \ SYSCALL_ENTRY( NtClose ) \ SYSCALL_ENTRY( NtCreateEvent ) \ SYSCALL_ENTRY( NtCreateMutant ) \ SYSCALL_ENTRY( NtCreateSemaphore ) \ + SYSCALL_ENTRY( NtCreateTimer ) \ SYSCALL_ENTRY( NtDeleteAtom ) \ SYSCALL_ENTRY( NtFindAtom ) \ SYSCALL_ENTRY( NtGetCurrentProcessorNumber ) \ SYSCALL_ENTRY( NtOpenEvent ) \ SYSCALL_ENTRY( NtOpenMutant ) \ SYSCALL_ENTRY( NtOpenSemaphore ) \ + SYSCALL_ENTRY( NtOpenTimer ) \ SYSCALL_ENTRY( NtPulseEvent ) \ SYSCALL_ENTRY( NtQueryDefaultLocale ) \ SYSCALL_ENTRY( NtQueryDefaultUILanguage ) \ @@ -44,11 +47,13 @@ SYSCALL_ENTRY( NtQueryInstallUILanguage ) \ SYSCALL_ENTRY( NtQueryMutant ) \ SYSCALL_ENTRY( NtQuerySemaphore ) \ + SYSCALL_ENTRY( NtQueryTimer ) \ SYSCALL_ENTRY( NtReleaseMutant ) \ SYSCALL_ENTRY( NtReleaseSemaphore ) \ SYSCALL_ENTRY( NtResetEvent ) \ SYSCALL_ENTRY( NtSetDefaultLocale ) \ SYSCALL_ENTRY( NtSetDefaultUILanguage ) \ - SYSCALL_ENTRY( NtSetEvent ) + SYSCALL_ENTRY( NtSetEvent ) \ + SYSCALL_ENTRY( NtSetTimer ) #endif /* __WOW64_SYSCALL_H */ diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h index 5ec8ef9d847..f555f8db7bb 100644 --- a/dlls/wow64/wow64_private.h +++ b/dlls/wow64/wow64_private.h @@ -63,6 +63,17 @@ static inline ULONG get_ulong( UINT **args ) { return *(*args)++; } static inline HANDLE get_handle( UINT **args ) { return LongToHandle( *(*args)++ ); } static inline void *get_ptr( UINT **args ) { return ULongToPtr( *(*args)++ ); } +static inline void *apc_32to64( ULONG func ) +{ + return func ? Wow64ApcRoutine : NULL; +} + +static inline void *apc_param_32to64( ULONG func, ULONG context ) +{ + if (!func) return ULongToPtr( context ); + return (void *)(ULONG_PTR)(((ULONG64)func << 32) | context); +} + static inline UNICODE_STRING *unicode_str_32to64( UNICODE_STRING *str, const UNICODE_STRING32 *str32 ) { if (!str32) return NULL;