wow64: Forward 64-bit invalid handle exceptions to the 32-bit guest.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-08-20 15:07:06 +02:00
parent e30b56b1a3
commit 2308120334
4 changed files with 41 additions and 4 deletions

View File

@ -1251,3 +1251,24 @@ NTSTATUS WINAPI wow64_NtTerminateThread( UINT *args )
return NtTerminateThread( handle, exit_code ); return NtTerminateThread( handle, exit_code );
} }
/**********************************************************************
* Wow64PassExceptionToGuest (wow64.@)
*/
void WINAPI Wow64PassExceptionToGuest( EXCEPTION_POINTERS *ptrs )
{
EXCEPTION_RECORD *rec = ptrs->ExceptionRecord;
EXCEPTION_RECORD32 rec32;
ULONG i;
rec32.ExceptionCode = rec->ExceptionCode;
rec32.ExceptionFlags = rec->ExceptionFlags;
rec32.ExceptionRecord = PtrToUlong( rec->ExceptionRecord );
rec32.ExceptionAddress = PtrToUlong( rec->ExceptionAddress );
rec32.NumberParameters = rec->NumberParameters;
for (i = 0; i < rec->NumberParameters; i++)
rec32.ExceptionInformation[i] = rec->ExceptionInformation[i];
call_user_exception_dispatcher( &rec32, NULL, ptrs->ContextRecord );
}

View File

@ -519,6 +519,21 @@ static void free_temp_data(void)
} }
/**********************************************************************
* syscall_filter
*/
static LONG CALLBACK syscall_filter( EXCEPTION_POINTERS *ptrs )
{
switch (ptrs->ExceptionRecord->ExceptionCode)
{
case STATUS_INVALID_HANDLE:
Wow64PassExceptionToGuest( ptrs );
break;
}
return EXCEPTION_EXECUTE_HANDLER;
}
/********************************************************************** /**********************************************************************
* Wow64SystemServiceEx (NTDLL.@) * Wow64SystemServiceEx (NTDLL.@)
*/ */
@ -536,7 +551,7 @@ NTSTATUS WINAPI Wow64SystemServiceEx( UINT num, UINT *args )
syscall_thunk thunk = syscall_thunks[syscall_map[num]]; syscall_thunk thunk = syscall_thunks[syscall_map[num]];
status = thunk( args ); status = thunk( args );
} }
__EXCEPT_ALL __EXCEPT( syscall_filter )
{ {
status = GetExceptionCode(); status = GetExceptionCode();
} }

View File

@ -13,7 +13,7 @@
@ stdcall Wow64LdrpInitialize(ptr) @ stdcall Wow64LdrpInitialize(ptr)
@ stub Wow64LogPrint @ stub Wow64LogPrint
@ stub Wow64NotifyUnsimulateComplete @ stub Wow64NotifyUnsimulateComplete
@ stub Wow64PassExceptionToGuest @ stdcall Wow64PassExceptionToGuest(ptr)
@ stub Wow64PrepareForDebuggerAttach @ stub Wow64PrepareForDebuggerAttach
@ stub Wow64PrepareForException @ stub Wow64PrepareForException
@ stub Wow64RaiseException @ stub Wow64RaiseException

View File

@ -28,8 +28,9 @@
ALL_SYSCALLS ALL_SYSCALLS
#undef SYSCALL_ENTRY #undef SYSCALL_ENTRY
void * WINAPI Wow64AllocateTemp( SIZE_T size ) DECLSPEC_HIDDEN; void * WINAPI Wow64AllocateTemp( SIZE_T size );
void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CONTEXT *context ) DECLSPEC_HIDDEN; void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CONTEXT *context );
void WINAPI Wow64PassExceptionToGuest( EXCEPTION_POINTERS *ptrs );
extern void init_file_redirects(void) DECLSPEC_HIDDEN; extern void init_file_redirects(void) DECLSPEC_HIDDEN;
extern BOOL get_file_redirect( OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN; extern BOOL get_file_redirect( OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN;