Module: wine Branch: master Commit: 897cc66fd8a58fd33bc161cf03b60045b1ed7043 URL: https://gitlab.winehq.org/wine/wine/-/commit/897cc66fd8a58fd33bc161cf03b6004...
Author: Alexandre Julliard julliard@winehq.org Date: Tue May 21 20:33:50 2024 +0200
msvcp: Unify __ExceptionPtrCurrentException implementation.
---
dlls/msvcp90/exception.c | 63 +++++------------------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-)
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index 50ddc045226..3abf776a508 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -1306,7 +1306,6 @@ void __cdecl __ExceptionPtrRethrow(const exception_ptr *ep) * ?__ExceptionPtrCurrentException@@YAXPAX@Z * ?__ExceptionPtrCurrentException@@YAXPEAX@Z */ -#ifndef __x86_64__ void __cdecl __ExceptionPtrCurrentException(exception_ptr *ep) { void **current_exception = __current_exception(); @@ -1329,14 +1328,13 @@ void __cdecl __ExceptionPtrCurrentException(exception_ptr *ep)
if (ep->rec->ExceptionCode == CXX_EXCEPTION) { + void *obj = (void*)ep->rec->ExceptionInformation[1]; const cxx_exception_type *et = (void*)ep->rec->ExceptionInformation[2]; - const cxx_type_info *ti; - void **data, *obj; + uintptr_t base = rtti_rva_base( et ); + const cxx_type_info_table *table = rtti_rva( et->type_info_table, base ); + const cxx_type_info *ti = rtti_rva( table->info[0], base ); + void **data = HeapAlloc(GetProcessHeap(), 0, ti->size);
- ti = et->type_info_table->info[0]; - data = HeapAlloc(GetProcessHeap(), 0, ti->size); - - obj = (void*)ep->rec->ExceptionInformation[1]; if (ti->flags & CLASS_IS_SIMPLE_TYPE) { memcpy(data, obj, ti->size); @@ -1344,7 +1342,7 @@ void __cdecl __ExceptionPtrCurrentException(exception_ptr *ep) } else if (ti->copy_ctor) { - call_copy_ctor(ti->copy_ctor, data, get_this_pointer(&ti->offsets, obj), + call_copy_ctor(rtti_rva(ti->copy_ctor, base), data, get_this_pointer(&ti->offsets, obj), ti->flags & CLASS_HAS_VIRTUAL_BASE_CLASS); } else @@ -1353,55 +1351,6 @@ void __cdecl __ExceptionPtrCurrentException(exception_ptr *ep) } return; } -#else -void __cdecl __ExceptionPtrCurrentException(exception_ptr *ep) -{ - void **current_exception = __current_exception(); - EXCEPTION_RECORD *rec = current_exception ? *current_exception : NULL; - - TRACE("(%p)\n", ep); - - if (!rec) - { - ep->rec = NULL; - ep->ref = NULL; - return; - } - - ep->rec = HeapAlloc(GetProcessHeap(), 0, sizeof(EXCEPTION_RECORD)); - ep->ref = HeapAlloc(GetProcessHeap(), 0, sizeof(int)); - - *ep->rec = *rec; - *ep->ref = 1; - - if (ep->rec->ExceptionCode == CXX_EXCEPTION) - { - const cxx_exception_type *et = (void*)ep->rec->ExceptionInformation[2]; - const cxx_type_info *ti; - void **data, *obj; - char *base = RtlPcToFileHeader((void*)et, (void**)&base); - - ti = (const cxx_type_info*)(base + ((const cxx_type_info_table*)(base + et->type_info_table))->info[0]); - data = HeapAlloc(GetProcessHeap(), 0, ti->size); - - obj = (void*)ep->rec->ExceptionInformation[1]; - if (ti->flags & CLASS_IS_SIMPLE_TYPE) - { - memcpy(data, obj, ti->size); - if (ti->size == sizeof(void *)) *data = get_this_pointer(&ti->offsets, *data); - } - else if (ti->copy_ctor) - { - call_copy_ctor(base + ti->copy_ctor, data, get_this_pointer(&ti->offsets, obj), - ti->flags & CLASS_HAS_VIRTUAL_BASE_CLASS); - } - else - memcpy(data, get_this_pointer(&ti->offsets, obj), ti->size); - ep->rec->ExceptionInformation[1] = (ULONG_PTR)data; - } - return; -} -#endif
/********************************************************************* * ?__ExceptionPtrToBool@@YA_NPBX@Z