[CPPRT][CRT][MSVCRT] Move __CxxFrameHandler3 to crt and export it on NT6

Previously it was in cpprt, which is a support library for C++, containing functions that are not exported by msvcrt. But since Vista __CxxFrameHandler3 is exported by msvcrt. Therefore move it to crt, and to satisfy pre-Vista configurations, also add it to msvcrtex.
This commit is contained in:
Timo Kreuzer 2020-09-24 07:49:16 +02:00
parent 310563aece
commit ce848e5c11
9 changed files with 58 additions and 22 deletions

View file

@ -0,0 +1,15 @@
#include <asm.inc>
.code64
.align 4
MACRO(DEFINE_ALIAS, alias, orig)
EXTERN &orig : PROC
ALIAS <&alias> = <&orig>
ENDM
; These are the same
DEFINE_ALIAS __CxxFrameHandler3, __CxxFrameHandler
END

View file

@ -4,9 +4,13 @@ if(ARCH STREQUAL "i386")
except/i386/chkstk_asm.s
)
list(APPEND CRT_EXCEPT_ASM_SOURCE
except/i386/__CxxFrameHandler3.s
except/i386/chkesp.s
except/i386/prolog.s
)
list(APPEND CRT_EXCEPT_SOURCE
except/i386/CxxHandleV8Frame.c
)
if(MSVC)
list(APPEND CRT_EXCEPT_ASM_SOURCE
except/i386/cpp.s)

View file

@ -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);
}

View file

@ -0,0 +1,26 @@
#include <asm.inc>
.code
.align 4
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
END

View file

@ -36,9 +36,20 @@ if(ARCH STREQUAL "i386")
list(APPEND MSVCRTEX_SOURCE
math/i386/sqrtf.c)
endif()
if(MSVC AND DLL_EXPORT_VERSION LESS 0x600)
list(APPEND MSVCRTEX_ASM_SOURCE
except/i386/__CxxFrameHandler3.s)
list(APPEND MSVCRTEX_SOURCE
except/i386/CxxHandleV8Frame.c)
endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND MSVCRTEX_ASM_SOURCE
except/amd64/chkstk_ms.s)
if(MSVC AND DLL_EXPORT_VERSION LESS 0x600)
list(APPEND MSVCRTEX_ASM_SOURCE
except/amd64/__CxxFrameHandler3.s
)
endif()
elseif(ARCH STREQUAL "arm")
list(APPEND MSVCRTEX_SOURCE
math/arm/__rt_sdiv.c