Commit 1d457b14 authored by Alexandre Julliard's avatar Alexandre Julliard

wow64: Add thunks for the Wow64-specific virtual memory syscalls.

parent ee2ee4d1
......@@ -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 );
......
......@@ -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 )
......
......@@ -444,6 +444,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
*/
NTSTATUS WINAPI wow64_NtWriteVirtualMemory( UINT *args )
......
......@@ -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;
......
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