Commit 1591e01e authored by Alexandre Julliard's avatar Alexandre Julliard

wow64: Implement backend notification functions.

Co-authored-by: 's avatarBilly Laws <blaws05@gmail.com>
parent 04ffca6e
......@@ -435,6 +435,9 @@ NTSTATUS WINAPI wow64_NtFlushInstructionCache( UINT *args )
const void *addr = get_ptr( &args );
SIZE_T size = get_ulong( &args );
if (pBTCpuNotifyFlushInstructionCache2 && RtlIsCurrentProcess( process ))
pBTCpuNotifyFlushInstructionCache2( addr, size );
return NtFlushInstructionCache( process, addr, size );
}
......
......@@ -100,6 +100,7 @@ static HMODULE win32u_module;
static WOW64INFO *wow64info;
/* cpu backend dll functions */
/* the function prototypes most likely differ from Windows */
static void * (WINAPI *pBTCpuGetBopCode)(void);
static NTSTATUS (WINAPI *pBTCpuGetContext)(HANDLE,HANDLE,void *,void *);
static BOOLEAN (WINAPI *pBTCpuIsProcessorFeaturePresent)(UINT);
......@@ -110,6 +111,13 @@ static void (WINAPI *pBTCpuSimulate)(void);
static NTSTATUS (WINAPI *pBTCpuResetToConsistentState)( EXCEPTION_POINTERS * );
static void * (WINAPI *p__wine_get_unix_opcode)(void);
static void * (WINAPI *pKiRaiseUserExceptionDispatcher)(void);
void (WINAPI *pBTCpuNotifyFlushInstructionCache2)( const void *, SIZE_T ) = NULL;
void (WINAPI *pBTCpuNotifyMapViewOfSection)( void * ) = NULL;
void (WINAPI *pBTCpuNotifyMemoryAlloc)( void *, SIZE_T, ULONG, ULONG ) = NULL;
void (WINAPI *pBTCpuNotifyMemoryDirty)( void *, SIZE_T ) = NULL;
void (WINAPI *pBTCpuNotifyMemoryFree)( void *, SIZE_T ) = NULL;
void (WINAPI *pBTCpuNotifyMemoryProtect)( void *, SIZE_T, ULONG ) = NULL;
void (WINAPI *pBTCpuNotifyUnmapViewOfSection)( void * ) = NULL;
void (WINAPI *pBTCpuUpdateProcessorInformation)( SYSTEM_CPU_INFORMATION * ) = NULL;
void *dummy = RtlUnwind;
......@@ -896,6 +904,13 @@ static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **contex
GET_PTR( BTCpuResetToConsistentState );
GET_PTR( BTCpuSetContext );
GET_PTR( BTCpuSimulate );
GET_PTR( BTCpuNotifyFlushInstructionCache2 );
GET_PTR( BTCpuNotifyMapViewOfSection );
GET_PTR( BTCpuNotifyMemoryAlloc );
GET_PTR( BTCpuNotifyMemoryDirty );
GET_PTR( BTCpuNotifyMemoryFree );
GET_PTR( BTCpuNotifyMemoryProtect );
GET_PTR( BTCpuNotifyUnmapViewOfSection );
GET_PTR( BTCpuUpdateProcessorInformation );
GET_PTR( __wine_get_unix_opcode );
......
......@@ -126,6 +126,8 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemory( UINT *args )
size_32to64( &size, size32 ), type, protect );
if (!status)
{
if (pBTCpuNotifyMemoryAlloc && RtlIsCurrentProcess(process))
pBTCpuNotifyMemoryAlloc( addr, size, type, protect );
put_addr( addr32, addr );
put_size( size32, size );
}
......@@ -150,7 +152,8 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemoryEx( UINT *args )
SIZE_T size;
NTSTATUS status;
MEM_EXTENDED_PARAMETER *params64;
BOOL set_limit = (!*addr32 && process == GetCurrentProcess());
BOOL is_current = RtlIsCurrentProcess( process );
BOOL set_limit = (!*addr32 && is_current);
if ((status = mem_extended_parameters_32to64( &params64, params32, &count, set_limit ))) return status;
......@@ -158,6 +161,7 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemoryEx( UINT *args )
type, protect, params64, count );
if (!status)
{
if (pBTCpuNotifyMemoryAlloc && is_current) pBTCpuNotifyMemoryAlloc( addr, size, type, protect );
put_addr( addr32, addr );
put_size( size32, size );
}
......@@ -212,12 +216,14 @@ NTSTATUS WINAPI wow64_NtFreeVirtualMemory( UINT *args )
ULONG *size32 = get_ptr( &args );
ULONG type = get_ulong( &args );
void *addr;
SIZE_T size;
void *addr = ULongToPtr( *addr32 );
SIZE_T size = *size32;
NTSTATUS status;
status = NtFreeVirtualMemory( process, addr_32to64( &addr, addr32 ),
size_32to64( &size, size32 ), type );
if (pBTCpuNotifyMemoryFree && RtlIsCurrentProcess( process ))
pBTCpuNotifyMemoryFree( addr, size );
status = NtFreeVirtualMemory( process, &addr, &size, type );
if (!status)
{
put_addr( addr32, addr );
......@@ -353,9 +359,12 @@ NTSTATUS WINAPI wow64_NtMapViewOfSection( UINT *args )
{
SECTION_IMAGE_INFORMATION info;
if (!NtQuerySection( handle, SectionImageInformation, &info, sizeof(info), NULL ))
if (RtlIsCurrentProcess( process ) &&
!NtQuerySection( handle, SectionImageInformation, &info, sizeof(info), NULL ) &&
info.Machine == current_machine)
{
if (info.Machine == current_machine) init_image_mapping( addr );
if (pBTCpuNotifyMapViewOfSection) pBTCpuNotifyMapViewOfSection( addr );
init_image_mapping( addr );
}
put_addr( addr32, addr );
put_size( size32, size );
......@@ -382,7 +391,8 @@ NTSTATUS WINAPI wow64_NtMapViewOfSectionEx( UINT *args )
SIZE_T size;
NTSTATUS status;
MEM_EXTENDED_PARAMETER *params64;
BOOL set_limit = (!*addr32 && process == GetCurrentProcess());
BOOL is_current = RtlIsCurrentProcess( process );
BOOL set_limit = (!*addr32 && is_current);
if ((status = mem_extended_parameters_32to64( &params64, params32, &count, set_limit ))) return status;
......@@ -392,9 +402,12 @@ NTSTATUS WINAPI wow64_NtMapViewOfSectionEx( UINT *args )
{
SECTION_IMAGE_INFORMATION info;
if (!NtQuerySection( handle, SectionImageInformation, &info, sizeof(info), NULL ))
if (is_current &&
!NtQuerySection( handle, SectionImageInformation, &info, sizeof(info), NULL ) &&
info.Machine == current_machine)
{
if (info.Machine == current_machine) init_image_mapping( addr );
if (pBTCpuNotifyMapViewOfSection) pBTCpuNotifyMapViewOfSection( addr );
init_image_mapping( addr );
}
put_addr( addr32, addr );
put_size( size32, size );
......@@ -413,12 +426,14 @@ NTSTATUS WINAPI wow64_NtProtectVirtualMemory( UINT *args )
ULONG new_prot = get_ulong( &args );
ULONG *old_prot = get_ptr( &args );
void *addr;
SIZE_T size;
void *addr = ULongToPtr( *addr32 );
SIZE_T size = *size32;
NTSTATUS status;
status = NtProtectVirtualMemory( process, addr_32to64( &addr, addr32 ),
size_32to64( &size, size32 ), new_prot, old_prot );
if (pBTCpuNotifyMemoryProtect && RtlIsCurrentProcess(process))
pBTCpuNotifyMemoryProtect( addr, size, new_prot );
status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot );
if (!status)
{
put_addr( addr32, addr );
......@@ -686,6 +701,9 @@ NTSTATUS WINAPI wow64_NtUnmapViewOfSection( UINT *args )
HANDLE process = get_handle( &args );
void *addr = get_ptr( &args );
if (pBTCpuNotifyUnmapViewOfSection && RtlIsCurrentProcess( process ))
pBTCpuNotifyUnmapViewOfSection( addr );
return NtUnmapViewOfSection( process, addr );
}
......@@ -699,6 +717,9 @@ NTSTATUS WINAPI wow64_NtUnmapViewOfSectionEx( UINT *args )
void *addr = get_ptr( &args );
ULONG flags = get_ulong( &args );
if (pBTCpuNotifyUnmapViewOfSection && RtlIsCurrentProcess( process ))
pBTCpuNotifyUnmapViewOfSection( addr );
return NtUnmapViewOfSectionEx( process, addr, flags );
}
......
......@@ -38,7 +38,15 @@ extern ULONG_PTR args_alignment DECLSPEC_HIDDEN;
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 *pBTCpuNotifyFlushInstructionCache2)( const void *, SIZE_T );
extern void (WINAPI *pBTCpuNotifyMapViewOfSection)( void * );
extern void (WINAPI *pBTCpuNotifyMemoryAlloc)( void *, SIZE_T, ULONG, ULONG );
extern void (WINAPI *pBTCpuNotifyMemoryDirty)( void *, SIZE_T );
extern void (WINAPI *pBTCpuNotifyMemoryFree)( void *, SIZE_T );
extern void (WINAPI *pBTCpuNotifyMemoryProtect)( void *, SIZE_T, ULONG );
extern void (WINAPI *pBTCpuNotifyUnmapViewOfSection)( void * );
extern void (WINAPI *pBTCpuUpdateProcessorInformation)( SYSTEM_CPU_INFORMATION * );
struct object_attr64
{
......
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