Module: wine Branch: master Commit: 8f2d3e8396cd45267c387387087bb0ffa22d5b05 URL: https://gitlab.winehq.org/wine/wine/-/commit/8f2d3e8396cd45267c387387087bb0f...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jun 4 11:00:16 2024 +0200
msvcrt: Share the __CxxExceptionFilter implementation between platforms.
---
dlls/msvcrt/except.c | 34 ++++++++++++++++++++++++++++++++++ dlls/msvcrt/except_arm.c | 11 ----------- dlls/msvcrt/except_arm64.c | 11 ----------- dlls/msvcrt/except_arm64ec.c | 11 ----------- dlls/msvcrt/except_i386.c | 33 --------------------------------- dlls/msvcrt/except_x86_64.c | 10 ---------- 6 files changed, 34 insertions(+), 76 deletions(-)
diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c index dd45defbbeb..4bdfefd49ef 100644 --- a/dlls/msvcrt/except.c +++ b/dlls/msvcrt/except.c @@ -389,6 +389,40 @@ BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs) return (msvcrt_get_thread_data()->exc_record == rec); }
+/********************************************************************* + * __CxxExceptionFilter (MSVCRT.@) + */ +int CDECL __CxxExceptionFilter( EXCEPTION_POINTERS *ptrs, const type_info *ti, UINT flags, void **copy) +{ + const cxx_type_info *type; + EXCEPTION_RECORD *rec; + uintptr_t exc_base; + + TRACE( "%p %p %x %p\n", ptrs, ti, flags, copy ); + + if (!ptrs) return EXCEPTION_CONTINUE_SEARCH; + + /* handle catch(...) */ + if (!ti) return EXCEPTION_EXECUTE_HANDLER; + + rec = ptrs->ExceptionRecord; + if (!is_cxx_exception( rec )) return EXCEPTION_CONTINUE_SEARCH; + + if (rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0) + { + rec = msvcrt_get_thread_data()->exc_record; + if (!rec) return EXCEPTION_CONTINUE_SEARCH; + } + + exc_base = rec->ExceptionInformation[3]; + type = find_caught_type( (cxx_exception_type *)rec->ExceptionInformation[2], exc_base, ti, flags ); + if (!type) return EXCEPTION_CONTINUE_SEARCH; + + if (copy) copy_exception( (void *)rec->ExceptionInformation[1], copy, flags, type, exc_base ); + + return EXCEPTION_EXECUTE_HANDLER; +} + /********************************************************************* * __CxxQueryExceptionSize (MSVCRT.@) */ diff --git a/dlls/msvcrt/except_arm.c b/dlls/msvcrt/except_arm.c index 47194b4e8ae..93511728138 100644 --- a/dlls/msvcrt/except_arm.c +++ b/dlls/msvcrt/except_arm.c @@ -31,7 +31,6 @@ #include "winbase.h" #include "winternl.h" #include "msvcrt.h" -#include "wine/exception.h" #include "excpt.h" #include "wine/debug.h"
@@ -40,16 +39,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(seh);
-/********************************************************************* - * __CxxExceptionFilter (MSVCRT.@) - */ -int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, - const type_info *ti, int flags, void **copy ) -{ - FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy ); - return EXCEPTION_CONTINUE_SEARCH; -} - /********************************************************************* * __CxxFrameHandler (MSVCRT.@) */ diff --git a/dlls/msvcrt/except_arm64.c b/dlls/msvcrt/except_arm64.c index bbff0f618cc..2a5a67ef7c8 100644 --- a/dlls/msvcrt/except_arm64.c +++ b/dlls/msvcrt/except_arm64.c @@ -32,7 +32,6 @@ #include "winbase.h" #include "winternl.h" #include "msvcrt.h" -#include "wine/exception.h" #include "excpt.h" #include "wine/debug.h"
@@ -41,16 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(seh);
-/********************************************************************* - * __CxxExceptionFilter (MSVCRT.@) - */ -int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, - const type_info *ti, int flags, void **copy ) -{ - FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy ); - return EXCEPTION_CONTINUE_SEARCH; -} - /********************************************************************* * __CxxFrameHandler (MSVCRT.@) */ diff --git a/dlls/msvcrt/except_arm64ec.c b/dlls/msvcrt/except_arm64ec.c index 5ef9dae809b..779cf077bbe 100644 --- a/dlls/msvcrt/except_arm64ec.c +++ b/dlls/msvcrt/except_arm64ec.c @@ -32,7 +32,6 @@ #include "winbase.h" #include "winternl.h" #include "msvcrt.h" -#include "wine/exception.h" #include "excpt.h" #include "wine/debug.h"
@@ -40,16 +39,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(seh);
-/********************************************************************* - * __CxxExceptionFilter (MSVCRT.@) - */ -int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, - const type_info *ti, int flags, void **copy ) -{ - FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy ); - return EXCEPTION_CONTINUE_SEARCH; -} - /********************************************************************* * __CxxFrameHandler (MSVCRT.@) */ diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c index 0c5d805721d..abea9b28fd1 100644 --- a/dlls/msvcrt/except_i386.c +++ b/dlls/msvcrt/except_i386.c @@ -285,39 +285,6 @@ static inline void call_catch_block( PEXCEPTION_RECORD rec, CONTEXT *context, data->processing_throw--; }
-/********************************************************************* - * __CxxExceptionFilter (MSVCRT.@) - */ -int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, - const type_info *ti, int flags, void **copy) -{ - const cxx_type_info *type; - PEXCEPTION_RECORD rec; - - TRACE( "%p %p %x %p\n", ptrs, ti, flags, copy ); - - if (!ptrs) return EXCEPTION_CONTINUE_SEARCH; - - /* handle catch(...) */ - if (!ti) return EXCEPTION_EXECUTE_HANDLER; - - rec = ptrs->ExceptionRecord; - if (!is_cxx_exception( rec )) return EXCEPTION_CONTINUE_SEARCH; - - if (rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0) - { - rec = msvcrt_get_thread_data()->exc_record; - if (!rec) return EXCEPTION_CONTINUE_SEARCH; - } - - type = find_caught_type( (cxx_exception_type*)rec->ExceptionInformation[2], 0, ti, flags ); - if (!type) return EXCEPTION_CONTINUE_SEARCH; - - if (copy) copy_exception( (void *)rec->ExceptionInformation[1], copy, flags, type, 0 ); - - return EXCEPTION_EXECUTE_HANDLER; -} - static LONG CALLBACK se_translation_filter( EXCEPTION_POINTERS *ep, void *c ) { se_translator_ctx *ctx = (se_translator_ctx *)c; diff --git a/dlls/msvcrt/except_x86_64.c b/dlls/msvcrt/except_x86_64.c index 13bb0fa6fbd..23369599e61 100644 --- a/dlls/msvcrt/except_x86_64.c +++ b/dlls/msvcrt/except_x86_64.c @@ -410,16 +410,6 @@ static DWORD cxx_frame_handler(EXCEPTION_RECORD *rec, ULONG64 frame, return ExceptionContinueSearch; }
-/********************************************************************* - * __CxxExceptionFilter (MSVCRT.@) - */ -int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, - const type_info *ti, int flags, void **copy ) -{ - FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy ); - return EXCEPTION_CONTINUE_SEARCH; -} - /********************************************************************* * __CxxFrameHandler (MSVCRT.@) */