Author: tfaber Date: Sat Feb 28 21:03:04 2015 New Revision: 66503
URL: http://svn.reactos.org/svn/reactos?rev=66503&view=rev Log: [CPPRT] - Implement __CxxFrameHandler3 as a wrapper around __CxxFrameHandler that translates VC8-style function exception descriptions to VC7-style. This is necessary to make C++ exceptions work on Windows Server 2003, because msvcrt!__CxxFrameHandler does not support VC8 descriptors there. CORE-9290 #resolve
Added: trunk/reactos/lib/sdk/cpprt/i386/framehandler.c (with props) Modified: trunk/reactos/lib/sdk/cpprt/CMakeLists.txt trunk/reactos/lib/sdk/cpprt/i386/cpprt.s
Modified: trunk/reactos/lib/sdk/cpprt/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/CMakeLists.tx... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/cpprt/CMakeLists.txt [iso-8859-1] Sat Feb 28 21:03:04 2015 @@ -1,5 +1,7 @@
set_cpp(WITH_EXCEPTIONS) + +include_directories(${REACTOS_SOURCE_DIR}/lib/sdk/crt/include)
list(APPEND SOURCE ehvec.cpp @@ -7,6 +9,7 @@
if(ARCH STREQUAL "i386") add_asm_files(cpprt_asm i386/cpprt.s) + list(APPEND SOURCE i386/framehandler.c) elseif(ARCH STREQUAL "amd64") add_asm_files(cpprt_asm amd64/cpprt.s) endif()
Modified: trunk/reactos/lib/sdk/cpprt/i386/cpprt.s URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/i386/cpprt.s?... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/i386/cpprt.s [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/cpprt/i386/cpprt.s [iso-8859-1] Sat Feb 28 21:03:04 2015 @@ -7,13 +7,27 @@ ALIAS <&alias> = <&orig> ENDM
+EXTERN _CxxHandleV8Frame@20 : PROC +PUBLIC ___CxxFrameHandler3 +___CxxFrameHandler3: + push eax + push dword ptr [esp + 20] + push dword ptr [esp + 20] + push dword ptr [esp + 20] + push dword ptr [esp + 20] + call _CxxHandleV8Frame@20 + ret + +EXTERN ___CxxFrameHandler : PROC +PUBLIC _CallCxxFrameHandler +_CallCxxFrameHandler: + mov eax, dword ptr [esp + 20] + jmp ___CxxFrameHandler + ; void __stdcall `eh vector constructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *),void (__thiscall*)(void *)) DEFINE_ALIAS ??_L@YGXPAXIHP6EX0@Z1@Z, ?MSVCRTEX_eh_vector_constructor_iterator@@YGXPAXIHP6EX0@Z1@Z
; void __stdcall `eh vector destructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *)) DEFINE_ALIAS ??_M@YGXPAXIHP6EX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YGXPAXIHP6EX0@Z@Z
-; These are the same -DEFINE_ALIAS ___CxxFrameHandler3, ___CxxFrameHandler - END
Added: trunk/reactos/lib/sdk/cpprt/i386/framehandler.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/cpprt/i386/framehan... ============================================================================== --- trunk/reactos/lib/sdk/cpprt/i386/framehandler.c (added) +++ trunk/reactos/lib/sdk/cpprt/i386/framehandler.c [iso-8859-1] Sat Feb 28 21:03:04 2015 @@ -0,0 +1,46 @@ +/* + * PROJECT: ReactOS C++ runtime library + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: __CxxFrameHandler3 to __CxxFrameHandler wrapper + * PROGRAMMER: Thomas Faber (thomas.faber@reactos.org) + */ + +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> +#include <ndk/rtltypes.h> + +#define WINE_NO_TRACE_MSGS +#include <wine/debug.h> +#include <wine/exception.h> +#include <internal/wine/msvcrt.h> +#include <internal/wine/cppexcept.h> + +extern DWORD CDECL CallCxxFrameHandler(PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD *frame, + PCONTEXT context, EXCEPTION_REGISTRATION_RECORD **dispatch, + const cxx_function_descr *descr); + +DWORD +__stdcall +CxxHandleV8Frame( + _In_ PEXCEPTION_RECORD rec, + _In_ EXCEPTION_REGISTRATION_RECORD *frame, + _In_ PCONTEXT context, + _In_ EXCEPTION_REGISTRATION_RECORD **dispatch, + _In_ const cxx_function_descr *descr) +{ + cxx_function_descr stub_descr; + + if (descr->magic != CXX_FRAME_MAGIC_VC8) + return CallCxxFrameHandler(rec, frame, context, dispatch, descr); + + if ((descr->flags & FUNC_DESCR_SYNCHRONOUS) && + (rec->ExceptionCode != CXX_EXCEPTION)) + { + return ExceptionContinueSearch; /* handle only c++ exceptions */ + } + + stub_descr = *descr; + stub_descr.magic = CXX_FRAME_MAGIC_VC7; + return CallCxxFrameHandler(rec, frame, context, dispatch, &stub_descr); +}
Propchange: trunk/reactos/lib/sdk/cpprt/i386/framehandler.c ------------------------------------------------------------------------------ svn:eol-style = native