From 111398c364c2639432981c32e7af4e39888f2090 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 1 Dec 2021 11:47:03 +0100 Subject: [PATCH] wow64: Add handler for exceptions happening in 32-bit mode. Signed-off-by: Alexandre Julliard --- dlls/wow64/syscall.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 74fc8d9905e..bee186456cc 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -670,6 +670,39 @@ NTSTATUS WINAPI Wow64SystemServiceEx( UINT num, UINT *args ) } +static void cpu_simulate(void); + +/********************************************************************** + * simulate_filter + */ +static LONG CALLBACK simulate_filter( EXCEPTION_POINTERS *ptrs ) +{ + Wow64PassExceptionToGuest( ptrs ); + cpu_simulate(); /* re-enter simulation to run the exception dispatcher */ + return EXCEPTION_EXECUTE_HANDLER; +} + + +/********************************************************************** + * cpu_simulate + */ +static void cpu_simulate(void) +{ + for (;;) + { + __TRY + { + pBTCpuSimulate(); + } + __EXCEPT( simulate_filter ) + { + /* restart simulation loop */ + } + __ENDTRY + } +} + + /********************************************************************** * Wow64AllocateTemp (wow64.@) * @@ -769,7 +802,7 @@ void WINAPI Wow64LdrpInitialize( CONTEXT *context ) RtlRunOnceExecuteOnce( &init_done, process_init, NULL, NULL ); thread_init(); - pBTCpuSimulate(); + cpu_simulate(); }