Alexandre Julliard : wow64: Add thunks for the Wow64-specific virtual memory syscalls.
Alexandre Julliard
julliard at winehq.org
Tue Jul 27 15:51:00 CDT 2021
Module: wine
Branch: master
Commit: 1d457b14a162c10ae7dca54059fa933ab73695b2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=1d457b14a162c10ae7dca54059fa933ab73695b2
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Jul 27 12:15:07 2021 +0200
wow64: Add thunks for the Wow64-specific virtual memory syscalls.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wow64/syscall.c | 3 +++
dlls/wow64/syscall.h | 3 +++
dlls/wow64/virtual.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/wow64/wow64_private.h | 11 +++++++++++
4 files changed, 63 insertions(+)
diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c
index 6803efbd7e9..2f165879195 100644
--- a/dlls/wow64/syscall.c
+++ b/dlls/wow64/syscall.c
@@ -34,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wow);
USHORT native_machine = 0;
USHORT current_machine = 0;
+ULONG_PTR args_alignment = 0;
typedef NTSTATUS (WINAPI *syscall_thunk)( UINT *args );
@@ -271,6 +272,8 @@ static void init_syscall_table( HMODULE ntdll )
const USHORT *ordinals;
ULONG id, exp_size, exp_pos, wrap_pos;
+ args_alignment = (current_machine == IMAGE_FILE_MACHINE_I386) ? sizeof(ULONG) : sizeof(ULONG64);
+
exports = RtlImageDirectoryEntryToData( ntdll, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size );
ordinals = get_rva( ntdll, exports->AddressOfNameOrdinals );
functions = get_rva( ntdll, exports->AddressOfFunctions );
diff --git a/dlls/wow64/syscall.h b/dlls/wow64/syscall.h
index 2cdca8a3e8d..ab25bcb501d 100644
--- a/dlls/wow64/syscall.h
+++ b/dlls/wow64/syscall.h
@@ -139,6 +139,9 @@
SYSCALL_ENTRY( NtWaitForKeyedEvent ) \
SYSCALL_ENTRY( NtWaitForMultipleObjects ) \
SYSCALL_ENTRY( NtWaitForSingleObject ) \
+ SYSCALL_ENTRY( NtWow64AllocateVirtualMemory64 ) \
+ SYSCALL_ENTRY( NtWow64ReadVirtualMemory64 ) \
+ SYSCALL_ENTRY( NtWow64WriteVirtualMemory64 ) \
SYSCALL_ENTRY( NtWriteVirtualMemory ) \
SYSCALL_ENTRY( NtYieldExecution )
diff --git a/dlls/wow64/virtual.c b/dlls/wow64/virtual.c
index e1eaa053109..36bd91d9f8c 100644
--- a/dlls/wow64/virtual.c
+++ b/dlls/wow64/virtual.c
@@ -443,6 +443,52 @@ NTSTATUS WINAPI wow64_NtUnmapViewOfSection( UINT *args )
}
+/**********************************************************************
+ * wow64_NtWow64AllocateVirtualMemory64
+ */
+NTSTATUS WINAPI wow64_NtWow64AllocateVirtualMemory64( UINT *args )
+{
+ HANDLE process = get_handle( &args );
+ void **addr = get_ptr( &args );
+ ULONG_PTR zero_bits = get_ulong64( &args );
+ SIZE_T *size = get_ptr( &args );
+ ULONG type = get_ulong( &args );
+ ULONG protect = get_ulong( &args );
+
+ return NtAllocateVirtualMemory( process, addr, zero_bits, size, type, protect );
+}
+
+
+/**********************************************************************
+ * wow64_NtWow64ReadVirtualMemory64
+ */
+NTSTATUS WINAPI wow64_NtWow64ReadVirtualMemory64( UINT *args )
+{
+ HANDLE process = get_handle( &args );
+ void *addr = (void *)(ULONG_PTR)get_ulong64( &args );
+ void *buffer = get_ptr( &args );
+ SIZE_T size = get_ulong64( &args );
+ SIZE_T *ret_size = get_ptr( &args );
+
+ return NtReadVirtualMemory( process, addr, buffer, size, ret_size );
+}
+
+
+/**********************************************************************
+ * wow64_NtWow64WriteVirtualMemory64
+ */
+NTSTATUS WINAPI wow64_NtWow64WriteVirtualMemory64( UINT *args )
+{
+ HANDLE process = get_handle( &args );
+ void *addr = (void *)(ULONG_PTR)get_ulong64( &args );
+ const void *buffer = get_ptr( &args );
+ SIZE_T size = get_ulong64( &args );
+ SIZE_T *ret_size = get_ptr( &args );
+
+ return NtWriteVirtualMemory( process, addr, buffer, size, ret_size );
+}
+
+
/**********************************************************************
* wow64_NtWriteVirtualMemory
*/
diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h
index f4d195f06fb..6ba77720263 100644
--- a/dlls/wow64/wow64_private.h
+++ b/dlls/wow64/wow64_private.h
@@ -32,6 +32,7 @@ void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CON
extern USHORT native_machine DECLSPEC_HIDDEN;
extern USHORT current_machine DECLSPEC_HIDDEN;
+extern ULONG_PTR args_alignment DECLSPEC_HIDDEN;
struct object_attr64
{
@@ -63,6 +64,16 @@ 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 ULONG64 get_ulong64( UINT **args )
+{
+ ULONG64 ret;
+
+ *args = (UINT *)(((ULONG_PTR)*args + args_alignment - 1) & ~(args_alignment - 1));
+ ret = *(ULONG64 *)*args;
+ *args += 2;
+ return ret;
+}
+
static inline ULONG_PTR get_zero_bits( ULONG_PTR zero_bits )
{
return zero_bits ? zero_bits : 0x7fffffff;
More information about the wine-cvs
mailing list