Commit 1942cc30 authored by Alexandre Julliard's avatar Alexandre Julliard

wow64: Also send notifications for failed memory management calls.

parent ef3e97db
......@@ -392,6 +392,21 @@ static void test_cross_process_notifications( HANDLE process, void *ptr )
}
ok( !entry, "not at end of list\n" );
addr = (void *)0x123;
size = 0x321;
status = NtAllocateVirtualMemory( process, &addr, 0, &size, MEM_COMMIT, PAGE_EXECUTE_READ );
ok( status == STATUS_CONFLICTING_ADDRESSES || status == STATUS_INVALID_PARAMETER,
"NtAllocateVirtualMemory failed %lx\n", status );
entry = pop_from_work_list( &list->work_list );
if (current_machine != IMAGE_FILE_MACHINE_ARM64)
{
entry = expect_cross_work_entry( list, entry, CrossProcessPreVirtualAlloc, addr, 0x321,
MEM_COMMIT, PAGE_EXECUTE_READ, 0, 0xcccccccc );
entry = expect_cross_work_entry( list, entry, CrossProcessPostVirtualAlloc, addr, 0x321,
MEM_COMMIT, PAGE_EXECUTE_READ, status, 0xcccccccc );
}
ok( !entry, "not at end of list\n" );
addr = NULL;
size = 0x4321;
status = NtAllocateVirtualMemory( process, &addr, 0, &size, MEM_RESERVE, PAGE_EXECUTE_READWRITE );
......@@ -433,6 +448,23 @@ static void test_cross_process_notifications( HANDLE process, void *ptr )
}
ok( !entry, "not at end of list\n" );
addr2 = (char *)addr + 0x222;
size = 34;
status = NtProtectVirtualMemory( process, &addr2, &size, PAGE_EXECUTE_WRITECOPY, &old_prot );
ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PAGE_PROTECTION,
"NtProtectVirtualMemory failed %lx\n", status );
entry = pop_from_work_list( &list->work_list );
if (current_machine != IMAGE_FILE_MACHINE_ARM64)
{
entry = expect_cross_work_entry( list, entry, CrossProcessPreVirtualProtect,
(char *)addr + 0x222, 34,
PAGE_EXECUTE_WRITECOPY, 0, 0xcccccccc, 0xcccccccc );
entry = expect_cross_work_entry( list, entry, CrossProcessPostVirtualProtect,
(char *)addr + 0x222, 34,
PAGE_EXECUTE_WRITECOPY, status, 0xcccccccc, 0xcccccccc );
}
ok( !entry, "not at end of list\n" );
status = NtWriteVirtualMemory( process, (char *)addr + 0x1111, data, sizeof(data), &size );
ok( !status, "NtWriteVirtualMemory failed %lx\n", status );
entry = pop_from_work_list( &list->work_list );
......@@ -465,6 +497,21 @@ static void test_cross_process_notifications( HANDLE process, void *ptr )
}
ok( !entry, "not at end of list\n" );
addr = (void *)0x123;
size = 0;
status = NtFreeVirtualMemory( process, &addr, &size, MEM_RELEASE );
ok( status == STATUS_MEMORY_NOT_ALLOCATED || status == STATUS_INVALID_PARAMETER,
"NtFreeVirtualMemory failed %lx\n", status );
entry = pop_from_work_list( &list->work_list );
if (current_machine != IMAGE_FILE_MACHINE_ARM64)
{
entry = expect_cross_work_entry( list, entry, CrossProcessPreVirtualFree, addr, 0,
MEM_RELEASE, 0, 0xcccccccc, 0xcccccccc );
entry = expect_cross_work_entry( list, entry, CrossProcessPostVirtualFree, addr, 0,
MEM_RELEASE, status, 0xcccccccc, 0xcccccccc );
}
ok( !entry, "not at end of list\n" );
file = CreateFileA( "c:\\windows\\syswow64\\version.dll", GENERIC_READ | GENERIC_EXECUTE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
ok( file != INVALID_HANDLE_VALUE, "Failed to open version.dll\n" );
mapping = CreateFileMappingA( file, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL );
......
......@@ -1296,6 +1296,7 @@ void WINAPI Wow64ProcessPendingCrossProcessItems(void)
break;
case CrossProcessPostVirtualAlloc:
if (!pBTCpuNotifyMemoryAlloc) break;
if (entry->args[2]) break;
pBTCpuNotifyMemoryAlloc( (void *)entry->addr, entry->size, entry->args[0], entry->args[1] );
break;
case CrossProcessPreVirtualFree:
......
......@@ -160,15 +160,14 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemory( UINT *args )
addr, size, 3, type, protect, 0 );
status = NtAllocateVirtualMemory( process, &addr, get_zero_bits( zero_bits ), &size, type, protect );
if (!is_current)
send_cross_process_notification( process, CrossProcessPostVirtualAlloc,
addr, size, 3, type, protect, status );
if (!status)
{
if (is_current)
{
if (pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect );
}
else send_cross_process_notification( process, CrossProcessPostVirtualAlloc,
addr, size, 3, type, protect, 0 );
if (is_current && pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect );
put_addr( addr32, addr );
put_size( size32, size );
}
......@@ -204,15 +203,13 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemoryEx( UINT *args )
addr, size, 3, type, protect, 0 );
status = NtAllocateVirtualMemoryEx( process, &addr, &size, type, protect, params64, count );
if (!is_current) send_cross_process_notification( process, CrossProcessPostVirtualAlloc,
addr, size, 3, type, protect, status );
if (!status)
{
if (is_current)
{
if (pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect );
}
else send_cross_process_notification( process, CrossProcessPostVirtualAlloc,
addr, size, 3, type, protect, 0 );
if (is_current && pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect );
put_addr( addr32, addr );
put_size( size32, size );
}
......@@ -299,11 +296,11 @@ NTSTATUS WINAPI wow64_NtFreeVirtualMemory( UINT *args )
addr, size, 2, type, 0 );
status = NtFreeVirtualMemory( process, &addr, &size, type );
if (!is_current) send_cross_process_notification( process, CrossProcessPostVirtualFree,
addr, size, 2, type, status );
if (!status)
{
if (!is_current)
send_cross_process_notification( process, CrossProcessPostVirtualFree,
addr, size, 2, type, 0 );
put_addr( addr32, addr );
put_size( size32, size );
}
......@@ -517,11 +514,12 @@ NTSTATUS WINAPI wow64_NtProtectVirtualMemory( UINT *args )
addr, size, 2, new_prot, 0 );
status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot );
if (!is_current) send_cross_process_notification( process, CrossProcessPostVirtualProtect,
addr, size, 2, new_prot, status );
if (!status)
{
if (!is_current)
send_cross_process_notification( process, CrossProcessPostVirtualProtect,
addr, size, 2, new_prot, 0 );
put_addr( addr32, addr );
put_size( size32, size );
}
......
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