This is an automated email from the ASF dual-hosted git repository. damjan pushed a commit to branch windows-amd64 in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 91a82f51b994378b285296537635517faa325e04 Author: Damjan Jovanovic <dam...@apache.org> AuthorDate: Sat Jan 25 03:07:58 2025 +0200 Fix the __type_info layout. It should be the same on Win32 and Win64. Also add some documentation. Patch by: me --- .../source/cpp_uno/msvc_win64_x86-64/except.cxx | 69 ++++++++++++++++++++-- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/main/bridges/source/cpp_uno/msvc_win64_x86-64/except.cxx b/main/bridges/source/cpp_uno/msvc_win64_x86-64/except.cxx index 156af671e5..a61fb7f715 100644 --- a/main/bridges/source/cpp_uno/msvc_win64_x86-64/except.cxx +++ b/main/bridges/source/cpp_uno/msvc_win64_x86-64/except.cxx @@ -47,6 +47,67 @@ using namespace ::std; using namespace ::osl; using namespace ::rtl; +//############################################################################## +// Windows's C++ exception handling is built on top of SEH (Structured Exception Handling). +// +// SEH documentation: +// https://web.archive.org/web/20060114142024/https://www.microsoft.com/msj/0197/exception/exception.aspx +// +// See this excellent article, +// "Decoding the parameters of a thrown C++ exception (0xE06D7363)" +// by Raymond Chen: +// https://devblogs.microsoft.com/oldnewthing/20100730-00/?p=13273 +// +// Then this one with more details on ExceptionInformation: +// http://workblog.pilin.name/2014/03/decoding-parameters-of-thrown-c.html +// +// Others: +// https://github.com/icestudent/ontl/blob/master/ntl/nt/exception.hxx +// https://www.openrce.org/articles/full_view/21 +// https://www.openrce.org/articles/full_view/23 +// +// For a C++ exception in SEH, on AMD64: +// +// +-----------------------------------+ +-------------------------------------------------------------+ +// |EXCEPTION_POINTERS | |EXCEPTION_RECORD | +// +-----------------------------------+ +-------------------------------------------------------------+ +// |PEXCEPTION_RECORD ExceptionRecord;|----------->|DWORD ExceptionCode; // == 0xE06D7363 for C++ exception | +// |PCONTEXT ContextRecord; | |DWORD ExceptionFlags; | +// +-----------------------------------+ |struct _EXCEPTION_RECORD *ExceptionRecord; | +// |PVOID ExceptionAddress; | +// |DWORD NumberParameters; // == 4 on AMD64, 3 on i386 | +// |ULONG_PTR ExceptionInformation[0]; | +// C++ object being thrown <----------|ULONG_PTR ExceptionInformation[1]; | +// +----------------------------------------------|ULONG_PTR ExceptionInformation[2]; | +// | HINSTANCE of the EXE/DLL where <----------|ULONG_PTR ExceptionInformation[3]; | +// | where the exception was thrown |ULONG_PTR ExceptionInformation[...]; | +// | |ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];| +// | offset from HINSTANCE +-------------------------------------------------------------+ +// | to: +// | +------------------------------+ +// | |ThrowInfo | +// | +------------------------------+ +// +---->|unsigned int attributes; | +----------------------------------+ +// |PMFN pmfnUnwind; | |CatchableTypeArray | +// |__int32 pForwardCompat; | offset from HINSTANCE to: +----------------------------------+ +// |__int32 pCatchableTypeArray;|---------------------------->|int nCatchableTypes; | +// +------------------------------+ +--------|__int32 arrayOfCatchableTypes[];| +// | +----------------------------------+ +// +------------------------+ | +// |CatchableType | | +// +------------------------+ offsets from HINSTANCE to | +// |unsigned int properties;|<--------------------------+ +--------------------------------+ +// |__int32 pType; |---------+ |TypeDescriptor | +// |PMD thisDisplacement;| | offset from HINSTANCE to +--------------------------------+ +// |int sizeOrOffset; | +------------------------->|const void * _EH_PTR64 pVFTable;| +// |PMFN copyFunction; | |void * _EH_PTR64 spare; | +// +------------------------+ |char name[]; | +// +--------------------------------+ +// +// +// +// + namespace CPPU_CURRENT_NAMESPACE { @@ -117,9 +178,8 @@ class __type_info public: virtual ~__type_info() throw (); - inline __type_info( void * m_vtable, const char * m_d_name ) throw () - : _m_vtable( m_vtable ) - , _m_name( NULL ) + inline __type_info( void * m_data, const char * m_d_name ) throw () + : _m_data( m_data ) { ::strcpy( _m_d_name, m_d_name ); } // #100211# - checked size_t length() const @@ -128,8 +188,7 @@ public: } private: - void * _m_vtable; - char * _m_name; // cached copy of unmangled name, NULL initially + void * _m_data; char _m_d_name[1]; // mangled name }; //__________________________________________________________________________________________________