From: Billy Laws blaws05@gmail.com
Inter-process invalidation is left unimplemented, but this covers the majority of cases that a JIT needs to be aware of in order to flush any caches on code changes. --- dlls/wow64/process.c | 8 ++++++++ dlls/wow64/syscall.c | 8 ++++++++ dlls/wow64/virtual.c | 32 ++++++++++++++++++++++++++++++++ dlls/wow64/wow64_private.h | 4 ++++ 4 files changed, 52 insertions(+)
diff --git a/dlls/wow64/process.c b/dlls/wow64/process.c index 2182491bbfb..226dbd646a1 100644 --- a/dlls/wow64/process.c +++ b/dlls/wow64/process.c @@ -435,6 +435,14 @@ NTSTATUS WINAPI wow64_NtFlushInstructionCache( UINT *args ) const void *addr = get_ptr( &args ); SIZE_T size = get_ulong( &args );
+ if (pBTCpuNotifyFlushInstructionCache2) + { + if (GetCurrentProcess() == process) + pBTCpuNotifyFlushInstructionCache2( addr, size ); + else + FIXME( "Flushing instruction cache of non-current process\n" ); + } + return NtFlushInstructionCache( process, addr, size ); }
diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 85db80a53df..649305831ce 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -111,6 +111,10 @@ static NTSTATUS (WINAPI *pBTCpuResetToConsistentState)( EXCEPTION_POINTERS * ); static void * (WINAPI *p__wine_get_unix_opcode)(void); static void * (WINAPI *pKiRaiseUserExceptionDispatcher)(void); void (WINAPI *pBTCpuUpdateProcessorInformation)( SYSTEM_CPU_INFORMATION * ) = NULL; +void (WINAPI *pBTCpuNotifyUnmapViewOfSection)(PVOID,ULONG) = NULL; +void (WINAPI *pBTCpuNotifyMemoryFree)(PVOID,SIZE_T,ULONG) = NULL; +void (WINAPI *pBTCpuNotifyMemoryProtect)(PVOID,SIZE_T,DWORD) = NULL; +void (WINAPI *pBTCpuNotifyFlushInstructionCache2)(LPCVOID,SIZE_T) = NULL;
void *dummy = RtlUnwind;
@@ -897,6 +901,10 @@ static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **contex GET_PTR( BTCpuSetContext ); GET_PTR( BTCpuSimulate ); GET_PTR( BTCpuUpdateProcessorInformation ); + GET_PTR( BTCpuNotifyUnmapViewOfSection ); + GET_PTR( BTCpuNotifyMemoryFree ); + GET_PTR( BTCpuNotifyMemoryProtect ); + GET_PTR( BTCpuNotifyFlushInstructionCache2 ); GET_PTR( __wine_get_unix_opcode );
module = load_64bit_module( L"wow64win.dll" ); diff --git a/dlls/wow64/virtual.c b/dlls/wow64/virtual.c index c171fe39cb2..ef07e7a85db 100644 --- a/dlls/wow64/virtual.c +++ b/dlls/wow64/virtual.c @@ -216,6 +216,14 @@ NTSTATUS WINAPI wow64_NtFreeVirtualMemory( UINT *args ) SIZE_T size; NTSTATUS status;
+ if (pBTCpuNotifyMemoryFree) + { + if (GetCurrentProcess() == process) + pBTCpuNotifyMemoryFree( *addr_32to64( &addr, addr32 ), *size_32to64( &size, size32 ), type ); + else + FIXME( "Freeing memory of non-current process\n" ); + } + status = NtFreeVirtualMemory( process, addr_32to64( &addr, addr32 ), size_32to64( &size, size32 ), type ); if (!status) @@ -417,6 +425,14 @@ NTSTATUS WINAPI wow64_NtProtectVirtualMemory( UINT *args ) SIZE_T size; NTSTATUS status;
+ if (pBTCpuNotifyMemoryProtect) + { + if (GetCurrentProcess() == process) + pBTCpuNotifyMemoryProtect( *addr_32to64( &addr, addr32 ), *size_32to64( &size, size32 ), new_prot ); + else + FIXME( "Protecting the memory of non-current process\n" ); + } + status = NtProtectVirtualMemory( process, addr_32to64( &addr, addr32 ), size_32to64( &size, size32 ), new_prot, old_prot ); if (!status) @@ -686,6 +702,14 @@ NTSTATUS WINAPI wow64_NtUnmapViewOfSection( UINT *args ) HANDLE process = get_handle( &args ); void *addr = get_ptr( &args );
+ if (pBTCpuNotifyUnmapViewOfSection) + { + if (GetCurrentProcess() == process) + pBTCpuNotifyUnmapViewOfSection( addr, 0 ); + else + FIXME( "Unmapping memory of non-current process\n" ); + } + return NtUnmapViewOfSection( process, addr ); }
@@ -699,6 +723,14 @@ NTSTATUS WINAPI wow64_NtUnmapViewOfSectionEx( UINT *args ) void *addr = get_ptr( &args ); ULONG flags = get_ulong( &args );
+ if (pBTCpuNotifyUnmapViewOfSection) + { + if (GetCurrentProcess() == process) + pBTCpuNotifyUnmapViewOfSection( addr, flags ); + else + FIXME( "Unmapping memory of non-current process\n" ); + } + return NtUnmapViewOfSectionEx( process, addr, flags ); }
diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h index a840c1d01c0..690194d002f 100644 --- a/dlls/wow64/wow64_private.h +++ b/dlls/wow64/wow64_private.h @@ -39,6 +39,10 @@ extern ULONG_PTR highest_user_address DECLSPEC_HIDDEN; extern ULONG_PTR default_zero_bits DECLSPEC_HIDDEN; extern SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock DECLSPEC_HIDDEN; extern void (WINAPI *pBTCpuUpdateProcessorInformation)( SYSTEM_CPU_INFORMATION * ) DECLSPEC_HIDDEN; +extern void (WINAPI *pBTCpuNotifyUnmapViewOfSection)(PVOID,ULONG) DECLSPEC_HIDDEN; +extern void (WINAPI *pBTCpuNotifyMemoryFree)(PVOID,SIZE_T,ULONG) DECLSPEC_HIDDEN; +extern void (WINAPI *pBTCpuNotifyMemoryProtect)(PVOID,SIZE_T,DWORD) DECLSPEC_HIDDEN; +extern void (WINAPI *pBTCpuNotifyFlushInstructionCache2)(LPCVOID,SIZE_T) DECLSPEC_HIDDEN;
struct object_attr64 {