[CRT] Import wine exception handling code

The code is mostly unchanged. This includes the following changes:
* Move all wine code to crt/wine to keep it separated from our own code
* Add a minimal winternl.h
* Remove the asm macros from wine/config.h
* Include wine/asm.h where required
* Fix the names of the exported functions (GCC uses thiscall now and no wrappers are used anymore)
This commit is contained in:
Timo Kreuzer 2020-01-13 13:41:24 +01:00
parent a22ab61a87
commit 9efafd640f
29 changed files with 7504 additions and 2610 deletions

View file

@ -17,6 +17,7 @@
*/
#include "mshtml_private.h"
#include <wine/asm.h>
/*
* This object wraps any unrecognized interface overriding its IUnknown methods, allowing

View file

@ -20,6 +20,7 @@
#include "config.h"
#include "wine/port.h"
#include "wine/asm.h"
#define COBJMACROS

View file

@ -1,64 +1,64 @@
# msvcrt.dll - MS VC++ Run Time Library
# **************** x86 C++ functions ****************
@ cdecl -i386 -norelay ??0__non_rtti_object@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT___non_rtti_object_copy_ctor # public: __thiscall __non_rtti_object::__non_rtti_object(class __non_rtti_object const &)
@ cdecl -i386 -norelay ??0__non_rtti_object@@QAE@PBD@Z(ptr) __thiscall_MSVCRT___non_rtti_object_ctor # public: __thiscall __non_rtti_object::__non_rtti_object(char const *)
@ cdecl -i386 -norelay ??0bad_cast@@AAE@PBQBD@Z(ptr) __thiscall_MSVCRT_bad_cast_ctor # private: __thiscall bad_cast::bad_cast(char const * const *)
@ cdecl -i386 -norelay ??0bad_cast@@QAE@ABQBD@Z(ptr) __thiscall_MSVCRT_bad_cast_ctor # public: __thiscall bad_cast::bad_cast(char const * const &)
@ cdecl -i386 -norelay ??0bad_cast@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_cast_copy_ctor # public: __thiscall bad_cast::bad_cast(class bad_cast const &)
@ cdecl -i386 -norelay ??0bad_cast@@QAE@PBD@Z(ptr) __thiscall_MSVCRT_bad_cast_ctor_charptr # public: __thiscall bad_cast::bad_cast(char const *)
@ cdecl -i386 -norelay ??0bad_typeid@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_typeid_copy_ctor # public: __thiscall bad_typeid::bad_typeid(class bad_typeid const &)
@ cdecl -i386 -norelay ??0bad_typeid@@QAE@PBD@Z(ptr) __thiscall_MSVCRT_bad_typeid_ctor # public: __thiscall bad_typeid::bad_typeid(char const *)
@ cdecl -i386 -norelay ??0exception@@QAE@ABQBD@Z(ptr) __thiscall_MSVCRT_exception_ctor # public: __thiscall exception::exception(char const * const &)
@ cdecl -i386 -norelay ??0exception@@QAE@ABQBDH@Z(ptr long) __thiscall_MSVCRT_exception_ctor_noalloc # public: __thiscall exception::exception(char const * const &,int)
@ cdecl -i386 -norelay ??0exception@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT_exception_copy_ctor # public: __thiscall exception::exception(class exception const &)
@ cdecl -i386 -norelay ??0exception@@QAE@XZ() __thiscall_MSVCRT_exception_default_ctor # public: __thiscall exception::exception(void)
@ cdecl -i386 -norelay ??1__non_rtti_object@@UAE@XZ() __thiscall_MSVCRT___non_rtti_object_dtor # public: virtual __thiscall __non_rtti_object::~__non_rtti_object(void)
@ cdecl -i386 -norelay ??1bad_cast@@UAE@XZ() __thiscall_MSVCRT_bad_cast_dtor # public: virtual __thiscall bad_cast::~bad_cast(void)
@ cdecl -i386 -norelay ??1bad_typeid@@UAE@XZ() __thiscall_MSVCRT_bad_typeid_dtor # public: virtual __thiscall bad_typeid::~bad_typeid(void)
@ cdecl -i386 -norelay ??1exception@@UAE@XZ() __thiscall_MSVCRT_exception_dtor # public: virtual __thiscall exception::~exception(void)
@ cdecl -i386 -norelay ??1type_info@@UAE@XZ() __thiscall_MSVCRT_type_info_dtor # public: virtual __thiscall type_info::~type_info(void)
@ cdecl -i386 -norelay ??0__non_rtti_object@@QAE@ABV0@@Z(ptr) MSVCRT___non_rtti_object_copy_ctor # public: __thiscall __non_rtti_object::__non_rtti_object(class __non_rtti_object const &)
@ cdecl -i386 -norelay ??0__non_rtti_object@@QAE@PBD@Z(ptr) MSVCRT___non_rtti_object_ctor # public: __thiscall __non_rtti_object::__non_rtti_object(char const *)
@ cdecl -i386 -norelay ??0bad_cast@@AAE@PBQBD@Z(ptr) MSVCRT_bad_cast_ctor # private: __thiscall bad_cast::bad_cast(char const * const *)
@ cdecl -i386 -norelay ??0bad_cast@@QAE@ABQBD@Z(ptr) MSVCRT_bad_cast_ctor # public: __thiscall bad_cast::bad_cast(char const * const &)
@ cdecl -i386 -norelay ??0bad_cast@@QAE@ABV0@@Z(ptr) MSVCRT_bad_cast_copy_ctor # public: __thiscall bad_cast::bad_cast(class bad_cast const &)
@ cdecl -i386 -norelay ??0bad_cast@@QAE@PBD@Z(ptr) MSVCRT_bad_cast_ctor_charptr # public: __thiscall bad_cast::bad_cast(char const *)
@ cdecl -i386 -norelay ??0bad_typeid@@QAE@ABV0@@Z(ptr) MSVCRT_bad_typeid_copy_ctor # public: __thiscall bad_typeid::bad_typeid(class bad_typeid const &)
@ cdecl -i386 -norelay ??0bad_typeid@@QAE@PBD@Z(ptr) MSVCRT_bad_typeid_ctor # public: __thiscall bad_typeid::bad_typeid(char const *)
@ cdecl -i386 -norelay ??0exception@@QAE@ABQBD@Z(ptr) MSVCRT_exception_ctor # public: __thiscall exception::exception(char const * const &)
@ cdecl -i386 -norelay ??0exception@@QAE@ABQBDH@Z(ptr long) MSVCRT_exception_ctor_noalloc # public: __thiscall exception::exception(char const * const &,int)
@ cdecl -i386 -norelay ??0exception@@QAE@ABV0@@Z(ptr) MSVCRT_exception_copy_ctor # public: __thiscall exception::exception(class exception const &)
@ cdecl -i386 -norelay ??0exception@@QAE@XZ() MSVCRT_exception_default_ctor # public: __thiscall exception::exception(void)
@ cdecl -i386 -norelay ??1__non_rtti_object@@UAE@XZ() MSVCRT___non_rtti_object_dtor # public: virtual __thiscall __non_rtti_object::~__non_rtti_object(void)
@ cdecl -i386 -norelay ??1bad_cast@@UAE@XZ() MSVCRT_bad_cast_dtor # public: virtual __thiscall bad_cast::~bad_cast(void)
@ cdecl -i386 -norelay ??1bad_typeid@@UAE@XZ() MSVCRT_bad_typeid_dtor # public: virtual __thiscall bad_typeid::~bad_typeid(void)
@ cdecl -i386 -norelay ??1exception@@UAE@XZ() MSVCRT_exception_dtor # public: virtual __thiscall exception::~exception(void)
@ cdecl -i386 -norelay ??1type_info@@UAE@XZ() MSVCRT_type_info_dtor # public: virtual __thiscall type_info::~type_info(void)
@ cdecl -i386 ??2@YAPAXI@Z(long) MSVCRT_operator_new # void * __cdecl operator new(unsigned int)
;@ cdecl -i386 ??2@YAPAXIHPBDH@Z(long long str long) MSVCRT_operator_new_dbg # void * __cdecl operator new(unsigned int,int,char const *,int)
@ cdecl -i386 ??3@YAXPAX@Z(ptr) MSVCRT_operator_delete # void __cdecl operator delete(void *)
@ cdecl -i386 -norelay ??4__non_rtti_object@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT___non_rtti_object_opequals # public: class __non_rtti_object & __thiscall __non_rtti_object::operator=(class __non_rtti_object const &)
@ cdecl -i386 -norelay ??4bad_cast@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_cast_opequals # public: class bad_cast & __thiscall bad_cast::operator=(class bad_cast const &)
@ cdecl -i386 -norelay ??4bad_typeid@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_typeid_opequals # public: class bad_typeid & __thiscall bad_typeid::operator=(class bad_typeid const &)
@ cdecl -i386 -norelay ??4exception@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT_exception_opequals # public: class exception & __thiscall exception::operator=(class exception const &)
@ cdecl -i386 -norelay ??8type_info@@QBEHABV0@@Z(ptr) __thiscall_MSVCRT_type_info_opequals_equals # public: int __thiscall type_info::operator==(class type_info const &)const
@ cdecl -i386 -norelay ??9type_info@@QBEHABV0@@Z(ptr) __thiscall_MSVCRT_type_info_opnot_equals # public: int __thiscall type_info::operator!=(class type_info const &)const
@ cdecl -i386 -norelay ??4__non_rtti_object@@QAEAAV0@ABV0@@Z(ptr) MSVCRT___non_rtti_object_opequals # public: class __non_rtti_object & __thiscall __non_rtti_object::operator=(class __non_rtti_object const &)
@ cdecl -i386 -norelay ??4bad_cast@@QAEAAV0@ABV0@@Z(ptr) MSVCRT_bad_cast_opequals # public: class bad_cast & __thiscall bad_cast::operator=(class bad_cast const &)
@ cdecl -i386 -norelay ??4bad_typeid@@QAEAAV0@ABV0@@Z(ptr) MSVCRT_bad_typeid_opequals # public: class bad_typeid & __thiscall bad_typeid::operator=(class bad_typeid const &)
@ cdecl -i386 -norelay ??4exception@@QAEAAV0@ABV0@@Z(ptr) MSVCRT_exception_opequals # public: class exception & __thiscall exception::operator=(class exception const &)
@ cdecl -i386 -norelay ??8type_info@@QBEHABV0@@Z(ptr) MSVCRT_type_info_opequals_equals # public: int __thiscall type_info::operator==(class type_info const &)const
@ cdecl -i386 -norelay ??9type_info@@QBEHABV0@@Z(ptr) MSVCRT_type_info_opnot_equals # public: int __thiscall type_info::operator!=(class type_info const &)const
@ extern -i386 ??_7__non_rtti_object@@6B@ MSVCRT___non_rtti_object_vtable # const __non_rtti_object::`vftable'
@ extern -i386 ??_7bad_cast@@6B@ MSVCRT_bad_cast_vtable # const bad_cast::`vftable'
@ extern -i386 ??_7bad_typeid@@6B@ MSVCRT_bad_typeid_vtable # const bad_typeid::`vftable'
@ extern -i386 ??_7exception@@6B@ MSVCRT_exception_vtable # const exception::`vftable'
@ cdecl -i386 -norelay ??_E__non_rtti_object@@UAEPAXI@Z(long) __thiscall_MSVCRT___non_rtti_object_vector_dtor # public: virtual void * __thiscall __non_rtti_object::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Ebad_cast@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_cast_vector_dtor # public: virtual void * __thiscall bad_cast::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Ebad_typeid@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_typeid_vector_dtor # public: virtual void * __thiscall bad_typeid::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Eexception@@UAEPAXI@Z(long) __thiscall_MSVCRT_exception_vector_dtor # public: virtual void * __thiscall exception::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Fbad_cast@@QAEXXZ() __thiscall_MSVCRT_bad_cast_default_ctor # public: void __thiscall bad_cast::`default constructor closure'(void)
@ cdecl -i386 -norelay ??_Fbad_typeid@@QAEXXZ() __thiscall_MSVCRT_bad_typeid_default_ctor # public: void __thiscall bad_typeid::`default constructor closure'(void)
@ cdecl -i386 -norelay ??_G__non_rtti_object@@UAEPAXI@Z(long) __thiscall_MSVCRT___non_rtti_object_scalar_dtor # public: virtual void * __thiscall __non_rtti_object::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Gbad_cast@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_cast_scalar_dtor # public: virtual void * __thiscall bad_cast::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Gbad_typeid@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_typeid_scalar_dtor # public: virtual void * __thiscall bad_typeid::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Gexception@@UAEPAXI@Z(long) __thiscall_MSVCRT_exception_scalar_dtor # public: virtual void * __thiscall exception::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_E__non_rtti_object@@UAEPAXI@Z(long) MSVCRT___non_rtti_object_vector_dtor # public: virtual void * __thiscall __non_rtti_object::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Ebad_cast@@UAEPAXI@Z(long) MSVCRT_bad_cast_vector_dtor # public: virtual void * __thiscall bad_cast::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Ebad_typeid@@UAEPAXI@Z(long) MSVCRT_bad_typeid_vector_dtor # public: virtual void * __thiscall bad_typeid::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Eexception@@UAEPAXI@Z(long) MSVCRT_exception_vector_dtor # public: virtual void * __thiscall exception::`vector deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Fbad_cast@@QAEXXZ() MSVCRT_bad_cast_default_ctor # public: void __thiscall bad_cast::`default constructor closure'(void)
@ cdecl -i386 -norelay ??_Fbad_typeid@@QAEXXZ() MSVCRT_bad_typeid_default_ctor # public: void __thiscall bad_typeid::`default constructor closure'(void)
@ cdecl -i386 -norelay ??_G__non_rtti_object@@UAEPAXI@Z(long) MSVCRT___non_rtti_object_scalar_dtor # public: virtual void * __thiscall __non_rtti_object::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Gbad_cast@@UAEPAXI@Z(long) MSVCRT_bad_cast_scalar_dtor # public: virtual void * __thiscall bad_cast::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Gbad_typeid@@UAEPAXI@Z(long) MSVCRT_bad_typeid_scalar_dtor # public: virtual void * __thiscall bad_typeid::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 -norelay ??_Gexception@@UAEPAXI@Z(long) MSVCRT_exception_scalar_dtor # public: virtual void * __thiscall exception::`scalar deleting destructor'(unsigned int)
@ cdecl -i386 ??_U@YAPAXI@Z(long) MSVCRT_operator_new # void * __cdecl operator new[](unsigned int)
;@ cdecl -i386 ??_U@YAPAXIHPBDH@Z(long long str long) MSVCRT_operator_new_dbg # void * __cdecl operator new[](unsigned int,int,char const *,int)
@ cdecl -i386 ??_V@YAXPAX@Z(ptr) MSVCRT_operator_delete # void __cdecl operator delete[](void *)
@ cdecl -i386 -norelay __uncaught_exception(ptr)
@ cdecl -i386 -norelay __uncaught_exception(ptr) MSVCRT___uncaught_exception
@ cdecl -i386 -norelay ?_query_new_handler@@YAP6AHI@ZXZ() MSVCRT__query_new_handler # int (__cdecl*__cdecl _query_new_handler(void))(unsigned int)
@ cdecl -i386 ?_query_new_mode@@YAHXZ() MSVCRT__query_new_mode # int __cdecl _query_new_mode(void)
@ cdecl -i386 -norelay ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z(ptr) MSVCRT__set_new_handler # int (__cdecl*__cdecl _set_new_handler(int (__cdecl*)(unsigned int)))(unsigned int)
@ cdecl -i386 ?_set_new_mode@@YAHH@Z(long) MSVCRT__set_new_mode # int __cdecl _set_new_mode(int)
@ cdecl -i386 -norelay ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z(ptr) MSVCRT__set_se_translator # void (__cdecl*__cdecl _set_se_translator(void (__cdecl*)(unsigned int,struct _EXCEPTION_POINTERS *)))(unsigned int,struct _EXCEPTION_POINTERS *)
@ cdecl -i386 -norelay ?before@type_info@@QBEHABV1@@Z(ptr) __thiscall_MSVCRT_type_info_before # public: int __thiscall type_info::before(class type_info const &)const
@ cdecl -i386 -norelay ?name@type_info@@QBEPBDXZ() __thiscall_MSVCRT_type_info_name # public: char const * __thiscall type_info::name(void)const
@ cdecl -i386 -norelay ?raw_name@type_info@@QBEPBDXZ() __thiscall_MSVCRT_type_info_raw_name # public: char const * __thiscall type_info::raw_name(void)const
@ cdecl -i386 -norelay ?before@type_info@@QBEHABV1@@Z(ptr) MSVCRT_type_info_before # public: int __thiscall type_info::before(class type_info const &)const
@ cdecl -i386 -norelay ?name@type_info@@QBEPBDXZ() MSVCRT_type_info_name # public: char const * __thiscall type_info::name(void)const
@ cdecl -i386 -norelay ?raw_name@type_info@@QBEPBDXZ() MSVCRT_type_info_raw_name # public: char const * __thiscall type_info::raw_name(void)const
@ cdecl -i386 ?set_new_handler@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_new_handler # void (__cdecl*__cdecl set_new_handler(void (__cdecl*)(void)))(void)
@ cdecl -i386 ?set_terminate@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_terminate # void (__cdecl*__cdecl set_terminate(void (__cdecl*)(void)))(void)
@ cdecl -i386 ?set_unexpected@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_unexpected # void (__cdecl*__cdecl set_unexpected(void (__cdecl*)(void)))(void)
@ cdecl -i386 ?terminate@@YAXXZ() MSVCRT_terminate # void __cdecl terminate(void)
@ cdecl -i386 ?unexpected@@YAXXZ() MSVCRT_unexpected # void __cdecl unexpected(void)
@ cdecl -i386 -norelay ?what@exception@@UBEPBDXZ() __thiscall_MSVCRT_what_exception # public: virtual char const * __thiscall exception::what(void)const
@ cdecl -i386 -norelay ?what@exception@@UBEPBDXZ() MSVCRT_what_exception # public: virtual char const * __thiscall exception::what(void)const
# **************** win64 C++ functions ****************
@ cdecl -arch=win64 ??0__non_rtti_object@@QEAA@AEBV0@@Z(ptr) MSVCRT___non_rtti_object_copy_ctor # public: __cdecl __non_rtti_object::__non_rtti_object(class __non_rtti_object const & __ptr64) __ptr64
@ -94,7 +94,7 @@
@ cdecl -arch=win64 ??_Fbad_typeid@@QEAAXXZ() MSVCRT_bad_typeid_default_ctor # public: void __cdecl bad_typeid::`default constructor closure'(void) __ptr64
@ cdecl -arch=win64 ??_U@YAPEAX_K@Z(long) MSVCRT_operator_new # void * __ptr64 __cdecl operator new[](unsigned __int64)
@ cdecl -arch=win64 ??_V@YAXPEAX@Z(ptr) MSVCRT_operator_delete # void __cdecl operator delete[](void * __ptr64)
@ cdecl -arch=win64 __uncaught_exception(ptr)
@ cdecl -arch=win64 __uncaught_exception(ptr) MSVCRT___uncaught_exception
@ cdecl -arch=win64 ?_query_new_handler@@YAP6AH_K@ZXZ() MSVCRT__query_new_handler # int (__cdecl*__cdecl _query_new_handler(void))(unsigned __int64)
@ cdecl -arch=win64 ?_query_new_mode@@YAHXZ() MSVCRT__query_new_mode # int __cdecl _query_new_mode(void)
@ cdecl -arch=win64 ?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z(ptr) MSVCRT__set_new_handler # int (__cdecl*__cdecl _set_new_handler(int (__cdecl*)(unsigned __int64)))(unsigned __int64)
@ -108,7 +108,7 @@
@ cdecl -arch=win64 ?set_unexpected@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_unexpected # void (__cdecl*__cdecl set_unexpected(void (__cdecl*)(void)))(void)
@ cdecl -arch=win64 ?terminate@@YAXXZ() MSVCRT_terminate # void __cdecl terminate(void)
@ cdecl -arch=win64 ?unexpected@@YAXXZ() MSVCRT_unexpected # void __cdecl unexpected(void)
@ cdecl -arch=win64 -stub ?what@exception@@UEBAPEBDXZ() MSVCRT_what_exception # public: virtual char const * __ptr64 __cdecl exception::what(void)const __ptr64
@ cdecl -arch=win64 ?what@exception@@UEBAPEBDXZ() MSVCRT_what_exception # public: virtual char const * __ptr64 __cdecl exception::what(void)const __ptr64
# **************** ARM C++ functions ****************
@ cdecl -arch=arm ??0__non_rtti_object@@QAA@ABV0@@Z() MSVCRT___non_rtti_object_copy_ctor # public: __cdecl __non_rtti_object::__non_rtti_object(class __non_rtti_object const &)
@ -204,14 +204,14 @@
# stub __CxxCallUnwindDtor
# stub __CxxCallUnwindVecDtor
@ cdecl __CxxDetectRethrow(ptr)
# stub __CxxExceptionFilter
@ cdecl __CxxExceptionFilter()
@ cdecl -arch=i386,x86_64 -norelay __CxxFrameHandler(ptr ptr ptr ptr)
@ cdecl -arch=i386 -norelay __CxxFrameHandler2(ptr ptr ptr ptr) __CxxFrameHandler
@ cdecl -arch=arm -norelay __CxxFrameHandler3(ptr ptr ptr ptr)
@ stdcall -i386 __CxxLongjmpUnwind(ptr)
@ cdecl -i386 __CxxQueryExceptionSize()
# stub -i386 __CxxRegisterExceptionObject
# stub -i386 __CxxUnregisterExceptionObject
@ cdecl -i386 __CxxRegisterExceptionObject()
@ cdecl -i386 __CxxUnregisterExceptionObject()
@ cdecl -version=0x600+ __DestructExceptionObject(ptr)
@ cdecl __RTCastToVoid(ptr) MSVCRT___RTCastToVoid
@ cdecl __RTDynamicCast(ptr long ptr ptr long) MSVCRT___RTDynamicCast
@ -329,7 +329,7 @@
@ cdecl _callnewh(long)
@ cdecl _cexit()
@ cdecl _cgets(str)
# stub _cgetws
@ cdecl -stub _cgetws(wstr)
@ cdecl _chdir(str)
@ cdecl _chdrive(long)
@ cdecl _chgsign(double)
@ -347,14 +347,14 @@
@ cdecl -arch=x86_64,arm _copysignf(long long)
@ varargs _cprintf(str)
@ cdecl _cputs(str)
# stub _cputws
@ cdecl -stub _cputws(wstr)
@ cdecl _creat(str long)
@ varargs _cscanf(str)
@ cdecl _ctime64(ptr)
@ extern _ctype
@ cdecl _cwait(ptr long long)
@ varargs _cwprintf(wstr)
# @ varargs _cwscanf(wstr)
@ varargs -stub _cwscanf(wstr)
@ extern _daylight
@ extern _dstbias
@ cdecl _dup(long)
@ -431,8 +431,8 @@
@ cdecl _getpid() kernel32.GetCurrentProcessId
@ cdecl _getsystime(ptr)
@ cdecl _getw(ptr)
# stub _getwch
# stub _getwche
@ cdecl -stub _getwch()
@ cdecl -stub _getwche()
@ cdecl _getws(ptr)
@ cdecl -i386 _global_unwind2(ptr)
@ cdecl _gmtime64(ptr)

View file

@ -1,14 +1,14 @@
@ stub ??0Iostream_init@@QAE@AAVios@@H@Z
@ stub ??0Iostream_init@@QAE@XZ
@ cdecl -i386 ??0__non_rtti_object@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT___non_rtti_object_copy_ctor
@ cdecl -i386 ??0__non_rtti_object@@QAE@PBD@Z(ptr) __thiscall_MSVCRT___non_rtti_object_ctor
@ cdecl -i386 ??0bad_cast@@QAE@ABQBD@Z(ptr) __thiscall_MSVCRT_bad_cast_ctor
@ cdecl -i386 ??0bad_cast@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_cast_copy_ctor
@ cdecl -i386 ??0bad_typeid@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_typeid_copy_ctor
@ cdecl -i386 ??0bad_typeid@@QAE@PBD@Z(ptr) __thiscall_MSVCRT_bad_typeid_ctor
@ cdecl -i386 ??0exception@@QAE@ABQBD@Z(ptr) __thiscall_MSVCRT_exception_ctor
@ cdecl -i386 ??0exception@@QAE@ABV0@@Z(ptr) __thiscall_MSVCRT_exception_copy_ctor
@ cdecl -i386 ??0exception@@QAE@XZ() __thiscall_MSVCRT_exception_default_ctor
@ cdecl -i386 ??0__non_rtti_object@@QAE@ABV0@@Z(ptr) MSVCRT___non_rtti_object_copy_ctor
@ cdecl -i386 ??0__non_rtti_object@@QAE@PBD@Z(ptr) MSVCRT___non_rtti_object_ctor
@ cdecl -i386 ??0bad_cast@@QAE@ABQBD@Z(ptr) MSVCRT_bad_cast_ctor
@ cdecl -i386 ??0bad_cast@@QAE@ABV0@@Z(ptr) MSVCRT_bad_cast_copy_ctor
@ cdecl -i386 ??0bad_typeid@@QAE@ABV0@@Z(ptr) MSVCRT_bad_typeid_copy_ctor
@ cdecl -i386 ??0bad_typeid@@QAE@PBD@Z(ptr) MSVCRT_bad_typeid_ctor
@ cdecl -i386 ??0exception@@QAE@ABQBD@Z(ptr) MSVCRT_exception_ctor
@ cdecl -i386 ??0exception@@QAE@ABV0@@Z(ptr) MSVCRT_exception_copy_ctor
@ cdecl -i386 ??0exception@@QAE@XZ() MSVCRT_exception_default_ctor
@ stub ??0filebuf@@QAE@ABV0@@Z
@ stub ??0filebuf@@QAE@H@Z
@ stub ??0filebuf@@QAE@HPADH@Z
@ -70,10 +70,10 @@
@ stub ??0strstreambuf@@QAE@PADH0@Z
@ stub ??0strstreambuf@@QAE@XZ
@ stub ??1Iostream_init@@QAE@XZ
@ cdecl -i386 ??1__non_rtti_object@@UAE@XZ() __thiscall_MSVCRT___non_rtti_object_dtor
@ cdecl -i386 ??1bad_cast@@UAE@XZ() __thiscall_MSVCRT_bad_cast_dtor
@ cdecl -i386 ??1bad_typeid@@UAE@XZ() __thiscall_MSVCRT_bad_typeid_dtor
@ cdecl -i386 ??1exception@@UAE@XZ() __thiscall_MSVCRT_exception_dtor
@ cdecl -i386 ??1__non_rtti_object@@UAE@XZ() MSVCRT___non_rtti_object_dtor
@ cdecl -i386 ??1bad_cast@@UAE@XZ() MSVCRT_bad_cast_dtor
@ cdecl -i386 ??1bad_typeid@@UAE@XZ() MSVCRT_bad_typeid_dtor
@ cdecl -i386 ??1exception@@UAE@XZ() MSVCRT_exception_dtor
@ stub ??1filebuf@@UAE@XZ
@ stub ??1fstream@@UAE@XZ
@ stub ??1ifstream@@UAE@XZ
@ -92,16 +92,16 @@
@ stub ??1streambuf@@UAE@XZ
@ stub ??1strstream@@UAE@XZ
@ stub ??1strstreambuf@@UAE@XZ
@ cdecl -i386 ??1type_info@@UAE@XZ() __thiscall_MSVCRT_type_info_dtor
@ cdecl -i386 ??1type_info@@UAE@XZ() MSVCRT_type_info_dtor
@ cdecl -arch=win32 ??2@YAPAXI@Z(long) MSVCRT_operator_new
@ cdecl -arch=win64 ??2@YAPEAX_K@Z(double) MSVCRT_operator_new
@ cdecl -arch=win32 ??3@YAXPAX@Z(ptr) MSVCRT_operator_delete
@ cdecl -arch=win64 ??3@YAXPEAX@Z(ptr) MSVCRT_operator_delete
@ stub ??4Iostream_init@@QAEAAV0@ABV0@@Z
@ cdecl -i386 ??4__non_rtti_object@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT___non_rtti_object_opequals
@ cdecl -i386 ??4bad_cast@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_cast_opequals
@ cdecl -i386 ??4bad_typeid@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT_bad_typeid_opequals
@ cdecl -i386 ??4exception@@QAEAAV0@ABV0@@Z(ptr) __thiscall_MSVCRT_exception_opequals
@ cdecl -i386 ??4__non_rtti_object@@QAEAAV0@ABV0@@Z(ptr) MSVCRT___non_rtti_object_opequals
@ cdecl -i386 ??4bad_cast@@QAEAAV0@ABV0@@Z(ptr) MSVCRT_bad_cast_opequals
@ cdecl -i386 ??4bad_typeid@@QAEAAV0@ABV0@@Z(ptr) MSVCRT_bad_typeid_opequals
@ cdecl -i386 ??4exception@@QAEAAV0@ABV0@@Z(ptr) MSVCRT_exception_opequals
@ stub ??4filebuf@@QAEAAV0@ABV0@@Z
@ stub ??4fstream@@QAEAAV0@AAV0@@Z
@ stub ??4ifstream@@QAEAAV0@ABV0@@Z
@ -165,8 +165,8 @@
@ stub ??6ostream@@QAEAAV0@PBE@Z
@ stub ??6ostream@@QAEAAV0@PBX@Z
@ stub ??7ios@@QBEHXZ
@ cdecl -i386 ??8type_info@@QBEHABV0@@Z(ptr) __thiscall_MSVCRT_type_info_opequals_equals
@ cdecl -i386 ??9type_info@@QBEHABV0@@Z(ptr) __thiscall_MSVCRT_type_info_opnot_equals
@ cdecl -i386 ??8type_info@@QBEHABV0@@Z(ptr) MSVCRT_type_info_opequals_equals
@ cdecl -i386 ??9type_info@@QBEHABV0@@Z(ptr) MSVCRT_type_info_opnot_equals
@ stub ??Bios@@QBEPAXXZ
@ extern -i386 ??_7__non_rtti_object@@6B@ MSVCRT___non_rtti_object_vtable
@ extern -i386 ??_7bad_cast@@6B@ MSVCRT_bad_cast_vtable
@ -219,10 +219,10 @@
@ stub ??_Dstdiostream@@QAEXXZ
@ stub ??_Dstrstream@@QAEXXZ
@ stub ??_EIostream_init@@QAEPAXI@Z
@ cdecl -i386 ??_E__non_rtti_object@@UAEPAXI@Z(long) __thiscall_MSVCRT___non_rtti_object_vector_dtor
@ cdecl -i386 ??_Ebad_cast@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_cast_vector_dtor
@ cdecl -i386 ??_Ebad_typeid@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_typeid_vector_dtor
@ cdecl -i386 ??_Eexception@@UAEPAXI@Z(long) __thiscall_MSVCRT_exception_vector_dtor
@ cdecl -i386 ??_E__non_rtti_object@@UAEPAXI@Z(long) MSVCRT___non_rtti_object_vector_dtor
@ cdecl -i386 ??_Ebad_cast@@UAEPAXI@Z(long) MSVCRT_bad_cast_vector_dtor
@ cdecl -i386 ??_Ebad_typeid@@UAEPAXI@Z(long) MSVCRT_bad_typeid_vector_dtor
@ cdecl -i386 ??_Eexception@@UAEPAXI@Z(long) MSVCRT_exception_vector_dtor
@ stub ??_Efilebuf@@UAEPAXI@Z
@ stub ??_Efstream@@UAEPAXI@Z
@ stub ??_Eifstream@@UAEPAXI@Z
@ -242,10 +242,10 @@
@ stub ??_Estrstream@@UAEPAXI@Z
@ stub ??_Estrstreambuf@@UAEPAXI@Z
@ stub ??_GIostream_init@@QAEPAXI@Z
@ cdecl -i386 ??_G__non_rtti_object@@UAEPAXI@Z(long) __thiscall_MSVCRT___non_rtti_object_scalar_dtor
@ cdecl -i386 ??_Gbad_cast@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_cast_scalar_dtor
@ cdecl -i386 ??_Gbad_typeid@@UAEPAXI@Z(long) __thiscall_MSVCRT_bad_typeid_scalar_dtor
@ cdecl -i386 ??_Gexception@@UAEPAXI@Z(long) __thiscall_MSVCRT_exception_scalar_dtor
@ cdecl -i386 ??_G__non_rtti_object@@UAEPAXI@Z(long) MSVCRT___non_rtti_object_scalar_dtor
@ cdecl -i386 ??_Gbad_cast@@UAEPAXI@Z(long) MSVCRT_bad_cast_scalar_dtor
@ cdecl -i386 ??_Gbad_typeid@@UAEPAXI@Z(long) MSVCRT_bad_typeid_scalar_dtor
@ cdecl -i386 ??_Gexception@@UAEPAXI@Z(long) MSVCRT_exception_scalar_dtor
@ stub ??_Gfilebuf@@UAEPAXI@Z
@ stub ??_Gfstream@@UAEPAXI@Z
@ stub ??_Gifstream@@UAEPAXI@Z
@ -278,7 +278,7 @@
@ stub ?bad@ios@@QBEHXZ
@ stub ?base@streambuf@@IBEPADXZ
@ stub ?basefield@ios@@2JB
@ cdecl -i386 ?before@type_info@@QBEHABV1@@Z(ptr) __thiscall_MSVCRT_type_info_before
@ cdecl -i386 ?before@type_info@@QBEHABV1@@Z(ptr) MSVCRT_type_info_before
@ stub ?binary@filebuf@@2HB
@ stub ?bitalloc@ios@@SAJXZ
@ stub ?blen@streambuf@@IBEHXZ
@ -356,7 +356,7 @@
@ stub ?lockc@ios@@KAXXZ
@ stub ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
@ stub ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
@ cdecl -i386 ?name@type_info@@QBEPBDXZ() __thiscall_MSVCRT_type_info_name
@ cdecl -i386 ?name@type_info@@QBEPBDXZ() MSVCRT_type_info_name
@ stub ?oct@@YAAAVios@@AAV1@@Z
@ stub ?open@filebuf@@QAEPAV1@PBDHH@Z
@ stub ?open@fstream@@QAEXPBDHH@Z
@ -384,7 +384,7 @@
@ stub ?put@ostream@@QAEAAV1@E@Z
@ stub ?putback@istream@@QAEAAV1@D@Z
@ stub ?pword@ios@@QBEAAPAXH@Z
@ cdecl -i386 ?raw_name@type_info@@QBEPBDXZ() __thiscall_MSVCRT_type_info_raw_name
@ cdecl -i386 ?raw_name@type_info@@QBEPBDXZ() MSVCRT_type_info_raw_name
@ stub ?rdbuf@fstream@@QBEPAVfilebuf@@XZ
@ stub ?rdbuf@ifstream@@QBEPAVfilebuf@@XZ
@ stub ?rdbuf@ios@@QBEPAVstreambuf@@XZ
@ -467,7 +467,7 @@
@ stub ?unlockbuf@ios@@QAAXXZ
@ stub ?unlockc@ios@@KAXXZ
@ stub ?unsetf@ios@@QAEJJ@Z
@ cdecl -i386 ?what@exception@@UBEPBDXZ() __thiscall_MSVCRT_what_exception
@ cdecl -i386 ?what@exception@@UBEPBDXZ() MSVCRT_what_exception
@ stub ?width@ios@@QAEHH@Z
@ stub ?width@ios@@QBEHXZ
@ stub ?write@ostream@@QAEAAV1@PBCH@Z

View file

@ -99,6 +99,10 @@
/* thiscall support */
#ifdef _MSC_VER
#define __thiscall __stdcall
#endif
#if defined(__i386__) && !defined(__MINGW32__)
# ifdef _MSC_VER

View file

@ -1316,43 +1316,6 @@
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define to a macro to output a .cfi assembly pseudo-op */
#define __ASM_CFI(str) str
/* Define to a macro to define an assembly function */
#ifndef _MSC_VER
#ifndef NO_UNDERSCORE_PREFIX
#define __ASM_DEFINE_FUNC(name,suffix,code) asm(".text\n\t.align 4\n\t.globl _" #name suffix "\n\t.def _" #name suffix "; .scl 2; .type 32; .endef\n_" #name suffix ":\n\t.cfi_startproc\n\t" code "\n\t.cfi_endproc");
#else
#define __ASM_DEFINE_FUNC(name,suffix,code) asm(".text\n\t.align 4\n\t.globl " #name suffix "\n\t.def " #name suffix "; .scl 2; .type 32; .endef\n" #name suffix ":\n\t.cfi_startproc\n\t" code "\n\t.cfi_endproc");
#endif
#else
#define __ASM_DEFINE_FUNC(name,suffix,code)
#endif
/* Define to a macro to generate an assembly function directive */
#define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
/* Define to a macro to generate an assembly function with C calling
convention */
#define __ASM_GLOBAL_FUNC(name,code) __ASM_DEFINE_FUNC(name,"",code)
/* Define to a macro to generate an assembly name from a C symbol */
#ifndef NO_UNDERSCORE_PREFIX
#define __ASM_NAME(name) "_" name
#else
#define __ASM_NAME(name) name
#endif
/* Define to a macro to generate an stdcall suffix */
#define __ASM_STDCALL(args) "@" #args
/* Define to a macro to generate an assembly function with stdcall calling
convention */
#ifndef _MSC_VER
#define __ASM_STDCALL_FUNC(name,args,code) __ASM_DEFINE_FUNC(name,__ASM_STDCALL(args),code)
#endif
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */

View file

@ -16,6 +16,8 @@ extern "C" {
#define EH_EXIT_UNWIND 0x04
#define EH_STACK_INVALID 0x08
#define EH_NESTED_CALL 0x10
#define EH_TARGET_UNWIND 0x20
#define EH_COLLIDED_UNWIND 0x40
#define EXCEPTION_WINE_STUB 0x80000100
#define EXCEPTION_WINE_ASSERTION 0x80000101
@ -56,6 +58,7 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD
#define __TRY _SEH2_TRY
#define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation()))
#define __EXCEPT_CTX(func, ctx) _SEH2_EXCEPT((func)(GetExceptionInformation(), ctx))
#define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
#define __EXCEPT_ALL _SEH2_EXCEPT(_SEH_EXECUTE_HANDLER)
#define __ENDTRY _SEH2_END

View file

@ -20,12 +20,8 @@ list(APPEND CRT_SOURCE
direct/wgetdcwd.c
direct/wmkdir.c
direct/wrmdir.c
except/cpp.c
except/cppexcept.c
except/except.c
except/matherr.c
except/stack.c
except/xcptfil.c
float/chgsign.c
float/copysign.c
float/fpclass.c
@ -360,7 +356,11 @@ list(APPEND CRT_SOURCE
wstring/wcsstr.c
wstring/wcstok.c
wstring/wcsupr.c
wstring/wcsxfrm.c
wstring/wcsxfrm.c)
list(APPEND CRT_WINE_SOURCE
wine/cpp.c
wine/except.c
wine/heap.c
wine/undname.c)
@ -424,7 +424,6 @@ if(ARCH STREQUAL "i386")
string/i386/wcsrchr_asm.s)
list(APPEND CRT_SOURCE
except/i386/unwind.c
float/i386/clearfp.c
float/i386/cntrlfp.c
float/i386/fpreset.c
@ -437,6 +436,8 @@ if(ARCH STREQUAL "i386")
math/i386/cisin.c
math/i386/cisqrt.c
math/i386/ldexp.c)
list(APPEND CRT_WINE_SOURCE
wine/except_i386.c)
if(MSVC)
list(APPEND CRT_ASM_SOURCE
except/i386/cpp.s)
@ -477,6 +478,8 @@ elseif(ARCH STREQUAL "amd64")
except/amd64/ehandler.c
float/i386/cntrlfp.c
float/i386/statfp.c)
list(APPEND CRT_WINE_SOURCE
wine/except_x86_64.c)
if(MSVC)
list(APPEND CRT_ASM_SOURCE
except/amd64/cpp.s)
@ -491,6 +494,9 @@ elseif(ARCH STREQUAL "arm")
math/arm/__rt_udiv.c
math/arm/__rt_udiv64_worker.c
)
list(APPEND CRT_WINE_SOURCE
wine/except_arm.c
)
list(APPEND CRT_ASM_SOURCE
except/arm/_abnormal_termination.s
except/arm/_except_handler2.s
@ -584,6 +590,9 @@ if(NOT ARCH STREQUAL "i386")
string/wcsrchr.c)
endif()
# includes for wine code
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
set_source_files_properties(${CRT_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "__MINGW_IMPORT=extern;USE_MSVCRT_PREFIX;_MSVCRT_LIB_;_MSVCRT_;_MT;CRTDLL")
add_asm_files(crt_asm ${CRT_ASM_SOURCE})
@ -593,7 +602,7 @@ if(USE_CLANG_CL)
set_property(SOURCE stdlib/rot.c APPEND_STRING PROPERTY COMPILE_FLAGS " /fallback")
endif()
add_library(crt ${CRT_SOURCE} ${crt_asm})
add_library(crt ${CRT_SOURCE} ${CRT_WINE_SOURCE} ${crt_asm})
target_link_libraries(crt chkstk)
add_target_compile_definitions(crt
__MINGW_IMPORT=extern

View file

@ -16,15 +16,7 @@ __C_specific_handler(
return 0;
}
DWORD
__CxxFrameHandler(
PEXCEPTION_RECORD rec,
EXCEPTION_REGISTRATION_RECORD* ExceptionRegistrationFrame,
PCONTEXT context,
EXCEPTION_REGISTRATION_RECORD** _ExceptionRecord)
void __cdecl _local_unwind(void* frame, void* target)
{
UNIMPLEMENTED;
__debugbreak();
return 0;
RtlUnwind(frame, target, NULL, 0);
}

View file

@ -18,7 +18,6 @@
/* GLOBALS *******************************************************************/
PUBLIC _global_unwind2
PUBLIC _local_unwind
PUBLIC _local_unwind2
PUBLIC _abnormal_termination
PUBLIC _except_handler2
@ -42,11 +41,6 @@ FUNC _abnormal_termination
ret
ENDFUNC
FUNC _local_unwind
.endprolog
ret
ENDFUNC
FUNC _local_unwind2
.endprolog
ret

File diff suppressed because it is too large Load diff

View file

@ -1,596 +0,0 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2002 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* NOTES
* A good reference is the article "How a C++ compiler implements
* exception handling" by Vishal Kochhar, available on
* www.thecodeproject.com.
*/
#define __WINE_DEBUG_CHANNEL__
#include <precomp.h>
#include <stdarg.h>
#include <wine/exception.h>
#include <internal/wine/msvcrt.h>
#include <internal/wine/cppexcept.h>
#ifdef __i386__ /* CxxFrameHandler is not supported on non-i386 */
WINE_DEFAULT_DEBUG_CHANNEL(seh);
DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch,
const cxx_function_descr *descr,
EXCEPTION_REGISTRATION_RECORD* nested_frame, int nested_trylevel );
/* call a function with a given ebp */
#ifdef _MSC_VER
#pragma warning(disable:4731) // don't warn about modification of ebp
#endif
static inline void *call_ebp_func( void *func, void *_ebp )
{
void *result;
#ifdef _MSC_VER
__asm
{
mov eax, func
push ebx
push ebp
mov ebp, _ebp
call eax
pop ebp
pop ebx
mov result, eax
}
#else
int dummy;
__asm__ __volatile__ ("pushl %%ebx\n\t"
"pushl %%ebp\n\t"
"movl %4,%%ebp\n\t"
"call *%%eax\n\t"
"popl %%ebp\n\t"
"popl %%ebx"
: "=a" (result), "=S" (dummy), "=D" (dummy)
: "0" (func), "1" (_ebp) : "ecx", "edx", "memory" );
#endif
return result;
}
#ifdef _MSC_VER
#pragma warning(default:4731)
#endif
/* call a copy constructor */
static inline void call_copy_ctor( void *func, void *this, void *src, int has_vbase )
{
TRACE( "calling copy ctor %p object %p src %p\n", func, this, src );
#ifdef _MSC_VER
if (has_vbase)
{
__asm
{
mov ecx, this
push 1
push src
call func
}
}
else
{
__asm
{
mov ecx, this
push src
call func
}
}
#else
if (has_vbase)
/* in that case copy ctor takes an extra bool indicating whether to copy the base class */
__asm__ __volatile__("pushl $1; pushl %2; call *%0"
: : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" );
else
__asm__ __volatile__("pushl %2; call *%0"
: : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" );
#endif
}
/* call the destructor of the exception object */
static inline void call_dtor( void *func, void *object )
{
#ifdef _MSC_VER
__asm
{
mov ecx, object
call func
}
#else
__asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" );
#endif
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4731)
/* continue execution to the specified address after exception is caught */
__forceinline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{
__asm
{
mov eax, addr
mov edx, frame
mov esp, [edx-4]
lea ebp, [edx+12]
jmp eax
}
for (;;) ; /* unreached */
}
#pragma warning(pop)
#else
/* continue execution to the specified address after exception is caught */
static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{
__asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1"
: : "r" (frame), "a" (addr) );
for (;;) ; /* unreached */
}
#endif
static inline void dump_type( const cxx_type_info *type )
{
TRACE( "flags %x type %p %s offsets %d,%d,%d size %d copy ctor %p\n",
type->flags, type->type_info, dbgstr_type_info(type->type_info),
type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset,
type->size, type->copy_ctor );
}
static void dump_exception_type( const cxx_exception_type *type )
{
UINT i;
TRACE( "flags %x destr %p handler %p type info %p\n",
type->flags, type->destructor, type->custom_handler, type->type_info_table );
for (i = 0; i < type->type_info_table->count; i++)
{
TRACE( " %d: ", i );
dump_type( type->type_info_table->info[i] );
}
}
static void dump_function_descr( const cxx_function_descr *descr )
{
#ifndef WINE_NO_TRACE_MSGS
UINT i;
int j;
TRACE( "magic %x\n", descr->magic );
TRACE( "unwind table: %p %d\n", descr->unwind_table, descr->unwind_count );
for (i = 0; i < descr->unwind_count; i++)
{
TRACE( " %d: prev %d func %p\n", i,
descr->unwind_table[i].prev, descr->unwind_table[i].handler );
}
TRACE( "try table: %p %d\n", descr->tryblock, descr->tryblock_count );
for (i = 0; i < descr->tryblock_count; i++)
{
TRACE( " %d: start %d end %d catchlevel %d catch %p %d\n", i,
descr->tryblock[i].start_level, descr->tryblock[i].end_level,
descr->tryblock[i].catch_level, descr->tryblock[i].catchblock,
descr->tryblock[i].catchblock_count );
for (j = 0; j < descr->tryblock[i].catchblock_count; j++)
{
const catchblock_info *ptr = &descr->tryblock[i].catchblock[j];
TRACE( " %d: flags %x offset %d handler %p type %p %s\n",
j, ptr->flags, ptr->offset, ptr->handler,
ptr->type_info, dbgstr_type_info( ptr->type_info ) );
}
}
#endif
if (descr->magic <= CXX_FRAME_MAGIC_VC6) return;
TRACE( "expect list: %p\n", descr->expect_list );
if (descr->magic <= CXX_FRAME_MAGIC_VC7) return;
TRACE( "flags: %08x\n", descr->flags );
}
/* check if the exception type is caught by a given catch block, and return the type that matched */
static const cxx_type_info *find_caught_type( cxx_exception_type *exc_type,
const catchblock_info *catchblock )
{
UINT i;
for (i = 0; i < exc_type->type_info_table->count; i++)
{
const cxx_type_info *type = exc_type->type_info_table->info[i];
if (!catchblock->type_info) return type; /* catch(...) matches any type */
if (catchblock->type_info != type->type_info)
{
if (strcmp( catchblock->type_info->mangled, type->type_info->mangled )) continue;
}
/* type is the same, now check the flags */
if ((exc_type->flags & TYPE_FLAG_CONST) &&
!(catchblock->flags & TYPE_FLAG_CONST)) continue;
if ((exc_type->flags & TYPE_FLAG_VOLATILE) &&
!(catchblock->flags & TYPE_FLAG_VOLATILE)) continue;
return type; /* it matched */
}
return NULL;
}
/* copy the exception object where the catch block wants it */
static void copy_exception( void *object, cxx_exception_frame *frame,
const catchblock_info *catchblock, const cxx_type_info *type )
{
void **dest_ptr;
if (!catchblock->type_info || !catchblock->type_info->mangled[0]) return;
if (!catchblock->offset) return;
dest_ptr = (void **)((char *)&frame->ebp + catchblock->offset);
if (catchblock->flags & TYPE_FLAG_REFERENCE)
{
*dest_ptr = get_this_pointer( &type->offsets, object );
}
else if (type->flags & CLASS_IS_SIMPLE_TYPE)
{
memmove( dest_ptr, object, type->size );
/* if it is a pointer, adjust it */
if (type->size == sizeof(void *)) *dest_ptr = get_this_pointer( &type->offsets, *dest_ptr );
}
else /* copy the object */
{
if (type->copy_ctor)
call_copy_ctor( type->copy_ctor, dest_ptr, get_this_pointer(&type->offsets,object),
(type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS) );
else
memmove( dest_ptr, get_this_pointer(&type->offsets,object), type->size );
}
}
/* unwind the local function up to a given trylevel */
static void cxx_local_unwind( cxx_exception_frame* frame, const cxx_function_descr *descr, int last_level)
{
void (*handler)(void);
int trylevel = frame->trylevel;
while (trylevel != last_level)
{
if (trylevel < 0 || (unsigned)trylevel >= descr->unwind_count)
{
ERR( "invalid trylevel %d\n", trylevel );
MSVCRT_terminate();
}
handler = descr->unwind_table[trylevel].handler;
if (handler)
{
TRACE( "calling unwind handler %p trylevel %d last %d ebp %p\n",
handler, trylevel, last_level, &frame->ebp );
call_ebp_func( handler, &frame->ebp );
}
trylevel = descr->unwind_table[trylevel].prev;
}
frame->trylevel = last_level;
}
/* exception frame for nested exceptions in catch block */
struct catch_func_nested_frame
{
EXCEPTION_REGISTRATION_RECORD frame; /* standard exception frame */
EXCEPTION_RECORD *prev_rec; /* previous record to restore in thread data */
cxx_exception_frame *cxx_frame; /* frame of parent exception */
const cxx_function_descr *descr; /* descriptor of parent exception */
int trylevel; /* current try level */
EXCEPTION_RECORD *rec; /* rec associated with frame */
};
/* handler for exceptions happening while calling a catch function */
static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
{
struct catch_func_nested_frame *nested_frame = (struct catch_func_nested_frame *)frame;
if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
{
msvcrt_get_thread_data()->exc_record = nested_frame->prev_rec;
return ExceptionContinueSearch;
}
TRACE( "got nested exception in catch function\n" );
if(rec->ExceptionCode == CXX_EXCEPTION)
{
PEXCEPTION_RECORD prev_rec = nested_frame->rec;
if(rec->ExceptionInformation[1] == 0 && rec->ExceptionInformation[2] == 0)
{
/* exception was rethrown */
rec->ExceptionInformation[1] = prev_rec->ExceptionInformation[1];
rec->ExceptionInformation[2] = prev_rec->ExceptionInformation[2];
TRACE("detect rethrow: re-propagate: obj: %lx, type: %lx\n",
rec->ExceptionInformation[1], rec->ExceptionInformation[2]);
}
else {
/* new exception in exception handler, destroy old */
void *object = (void*)prev_rec->ExceptionInformation[1];
cxx_exception_type *info = (cxx_exception_type*) prev_rec->ExceptionInformation[2];
TRACE("detect threw new exception in catch block - destroy old(obj: %p type: %p)\n",
object, info);
if(info && info->destructor)
call_dtor( info->destructor, object );
}
}
return cxx_frame_handler( rec, nested_frame->cxx_frame, context,
NULL, nested_frame->descr, &nested_frame->frame,
nested_frame->trylevel );
}
/* find and call the appropriate catch block for an exception */
/* returns the address to continue execution to after the catch block was called */
static inline void call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame *frame,
const cxx_function_descr *descr, int nested_trylevel,
cxx_exception_type *info )
{
UINT i;
int j;
void *addr, *object = (void *)rec->ExceptionInformation[1];
struct catch_func_nested_frame nested_frame;
int trylevel = frame->trylevel;
thread_data_t *thread_data = msvcrt_get_thread_data();
DWORD save_esp = ((DWORD*)frame)[-1];
for (i = 0; i < descr->tryblock_count; i++)
{
const tryblock_info *tryblock = &descr->tryblock[i];
if (trylevel < tryblock->start_level) continue;
if (trylevel > tryblock->end_level) continue;
/* got a try block */
for (j = 0; j < tryblock->catchblock_count; j++)
{
const catchblock_info *catchblock = &tryblock->catchblock[j];
if(info)
{
const cxx_type_info *type = find_caught_type( info, catchblock );
if (!type) continue;
TRACE( "matched type %p in tryblock %d catchblock %d\n", type, i, j );
/* copy the exception to its destination on the stack */
copy_exception( object, frame, catchblock, type );
}
else
{
/* no CXX_EXCEPTION only proceed with a catch(...) block*/
if(catchblock->type_info)
continue;
TRACE("found catch(...) block\n");
}
/* unwind the stack */
RtlUnwind( frame, 0, rec, 0 );
cxx_local_unwind( frame, descr, tryblock->start_level );
frame->trylevel = tryblock->end_level + 1;
/* call the catch block */
TRACE( "calling catch block %p addr %p ebp %p\n",
catchblock, catchblock->handler, &frame->ebp );
/* setup an exception block for nested exceptions */
nested_frame.frame.Handler = (PEXCEPTION_ROUTINE)catch_function_nested_handler;
nested_frame.prev_rec = thread_data->exc_record;
nested_frame.cxx_frame = frame;
nested_frame.descr = descr;
nested_frame.trylevel = nested_trylevel + 1;
nested_frame.rec = rec;
__wine_push_frame( &nested_frame.frame );
thread_data->exc_record = rec;
addr = call_ebp_func( catchblock->handler, &frame->ebp );
thread_data->exc_record = nested_frame.prev_rec;
__wine_pop_frame( &nested_frame.frame );
((DWORD*)frame)[-1] = save_esp;
if (info && info->destructor) call_dtor( info->destructor, object );
TRACE( "done, continuing at %p\n", addr );
continue_after_catch( frame, addr );
}
}
}
/*********************************************************************
* cxx_frame_handler
*
* Implementation of __CxxFrameHandler.
*/
DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch,
const cxx_function_descr *descr,
EXCEPTION_REGISTRATION_RECORD* nested_frame,
int nested_trylevel )
{
cxx_exception_type *exc_type;
if (descr->magic < CXX_FRAME_MAGIC_VC6 || descr->magic > CXX_FRAME_MAGIC_VC8)
{
ERR( "invalid frame magic %x\n", descr->magic );
return ExceptionContinueSearch;
}
if (descr->magic >= CXX_FRAME_MAGIC_VC8 &&
(descr->flags & FUNC_DESCR_SYNCHRONOUS) &&
(rec->ExceptionCode != CXX_EXCEPTION))
return ExceptionContinueSearch; /* handle only c++ exceptions */
if (rec->ExceptionFlags & (EH_UNWINDING|EH_EXIT_UNWIND))
{
if (descr->unwind_count && !nested_trylevel) cxx_local_unwind( frame, descr, -1 );
return ExceptionContinueSearch;
}
if (!descr->tryblock_count) return ExceptionContinueSearch;
if(rec->ExceptionCode == CXX_EXCEPTION)
{
exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
if (rec->ExceptionInformation[0] > CXX_FRAME_MAGIC_VC8 &&
exc_type->custom_handler)
{
return exc_type->custom_handler( rec, frame, context, dispatch,
descr, nested_trylevel, nested_frame, 0 );
}
if (TRACE_ON(seh))
{
TRACE("handling C++ exception rec %p frame %p trylevel %d descr %p nested_frame %p\n",
rec, frame, frame->trylevel, descr, nested_frame );
dump_exception_type( exc_type );
dump_function_descr( descr );
}
}
else
{
exc_type = NULL;
TRACE("handling C exception code %x rec %p frame %p trylevel %d descr %p nested_frame %p\n",
rec->ExceptionCode, rec, frame, frame->trylevel, descr, nested_frame );
}
call_catch_block( rec, frame, descr, frame->trylevel, exc_type );
return ExceptionContinueSearch;
}
/*********************************************************************
* __CxxFrameHandler (MSVCRT.@)
*/
extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch );
#ifdef _MSC_VER
DWORD _declspec(naked) __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch )
{
__asm
{
push 0
push 0
push eax
push [esp + 28]
push [esp + 28]
push [esp + 28]
push [esp + 28]
call cxx_frame_handler
add esp, 28
ret
}
}
#else
__ASM_GLOBAL_FUNC( __CxxFrameHandler,
"pushl $0\n\t" /* nested_trylevel */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl $0\n\t" /* nested_frame */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl %eax\n\t" /* descr */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* dispatch */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* context */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* frame */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"pushl 28(%esp)\n\t" /* rec */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
"call " __ASM_NAME("cxx_frame_handler") "\n\t"
"add $28,%esp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset -28\n\t")
"ret" )
#endif
/*********************************************************************
* __CxxLongjmpUnwind (MSVCRT.@)
*
* Callback meant to be used as UnwindFunc for setjmp/longjmp.
*/
void __stdcall __CxxLongjmpUnwind( const struct __JUMP_BUFFER *buf )
{
cxx_exception_frame *frame = (cxx_exception_frame *)buf->Registration;
const cxx_function_descr *descr = (const cxx_function_descr *)buf->UnwindData[0];
TRACE( "unwinding frame %p descr %p trylevel %ld\n", frame, descr, buf->TryLevel );
cxx_local_unwind( frame, descr, buf->TryLevel );
}
#endif /* __i386__ */
/*********************************************************************
* __CppXcptFilter (MSVCRT.@)
*/
int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
return _XcptFilter( ex, ptr );
}
/*********************************************************************
* _CxxThrowException (MSVCRT.@)
*/
void WINAPI _CxxThrowException( exception *object, const cxx_exception_type *type )
{
ULONG_PTR args[3];
args[0] = CXX_FRAME_MAGIC_VC6;
args[1] = (ULONG_PTR)object;
args[2] = (ULONG_PTR)type;
RaiseException( CXX_EXCEPTION, EH_NONCONTINUABLE, 3, args );
}
/*********************************************************************
* __CxxDetectRethrow (MSVCRT.@)
*/
BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
{
PEXCEPTION_RECORD rec;
if (!ptrs)
return FALSE;
rec = ptrs->ExceptionRecord;
if (rec->ExceptionCode == CXX_EXCEPTION &&
rec->NumberParameters == 3 &&
rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
rec->ExceptionInformation[2])
{
ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
return TRUE;
}
return (msvcrt_get_thread_data()->exc_record == rec);
}
/*********************************************************************
* __CxxQueryExceptionSize (MSVCRT.@)
*/
unsigned int CDECL __CxxQueryExceptionSize(void)
{
return sizeof(cxx_exception_type);
}

View file

@ -1,338 +0,0 @@
/*
* msvcrt.dll exception handling
*
* Copyright 2000 Jon Griffiths
* Copyright 2005 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* FIXME: Incomplete support for nested exceptions/try block cleanup.
*/
#include <precomp.h>
#include "excpt.h"
#include "cppexcept.h"
#include <wine/exception.h>
void CDECL _global_unwind2(EXCEPTION_REGISTRATION_RECORD* frame);
typedef void (__cdecl *MSVCRT_security_error_handler)(int, void *);
static MSVCRT_security_error_handler security_error_handler;
/* VC++ extensions to Win32 SEH */
typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
int (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
{
EXCEPTION_REGISTRATION_RECORD *prev;
void (*handler)(PEXCEPTION_RECORD, EXCEPTION_REGISTRATION_RECORD*,
PCONTEXT, PEXCEPTION_RECORD);
PSCOPETABLE scopetable;
int trylevel;
int _ebp;
PEXCEPTION_POINTERS xpointers;
} MSVCRT_EXCEPTION_FRAME;
typedef struct
{
int gs_cookie_offset;
ULONG gs_cookie_xor;
int eh_cookie_offset;
ULONG eh_cookie_xor;
SCOPETABLE entries[1];
} SCOPETABLE_V4;
#ifdef __i386__
static const SCOPETABLE_V4 *get_scopetable_v4( MSVCRT_EXCEPTION_FRAME *frame, ULONG_PTR cookie )
{
return (const SCOPETABLE_V4 *)((ULONG_PTR)frame->scopetable ^ cookie);
}
#if defined(__GNUC__)
static inline void call_finally_block( void *code_block, void *base_ptr )
{
__asm__ __volatile__ ("movl %1,%%ebp; call *%%eax"
: : "a" (code_block), "g" (base_ptr));
}
static inline int call_filter( int (*func)(PEXCEPTION_POINTERS), void *arg, void *ebp )
{
int ret;
__asm__ __volatile__ ("pushl %%ebp; pushl %3; movl %2,%%ebp; call *%%eax; popl %%ebp; popl %%ebp"
: "=a" (ret)
: "0" (func), "r" (ebp), "r" (arg)
: "ecx", "edx", "memory" );
return ret;
}
static inline int call_unwind_func( int (*func)(void), void *ebp )
{
int ret;
__asm__ __volatile__ ("pushl %%ebp\n\t"
"pushl %%ebx\n\t"
"pushl %%esi\n\t"
"pushl %%edi\n\t"
"movl %2,%%ebp\n\t"
"call *%0\n\t"
"popl %%edi\n\t"
"popl %%esi\n\t"
"popl %%ebx\n\t"
"popl %%ebp"
: "=a" (ret)
: "0" (func), "r" (ebp)
: "ecx", "edx", "memory" );
return ret;
}
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4731) // Don't complain about changing ebp
void __inline call_finally_block( void *code_block, void *base_ptr )
{
__asm
{
mov eax, code_block
mov ebp, base_ptr
call [eax]
}
}
int __inline call_filter( int (*func)(PEXCEPTION_POINTERS), void *arg, void *_ebp )
{
int _ret;
__asm
{
push ebp
mov eax, arg
push eax
mov ebp, _ebp
mov eax, func
call [eax]
mov _ret, eax
pop ebp
pop ebp
}
return _ret;
}
int __inline call_unwind_func( int (*func)(void), void *_ebp )
{
int _ret;
__asm
{
push ebp
push ebx
push esi
push edi
mov ebp, _ebp
call dword ptr [func]
mov _ret, eax
pop edi
pop esi
pop ebx
pop ebp
}
return _ret;
}
#pragma warning(pop)
#endif
static DWORD MSVCRT_nested_handler(PEXCEPTION_RECORD rec,
EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context,
EXCEPTION_REGISTRATION_RECORD** dispatch)
{
if (!(rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
return ExceptionContinueSearch;
*dispatch = frame;
return ExceptionCollidedUnwind;
}
void msvcrt_local_unwind4( ULONG *cookie, MSVCRT_EXCEPTION_FRAME* frame, int trylevel, void *ebp )
{
EXCEPTION_REGISTRATION_RECORD reg;
const SCOPETABLE_V4 *scopetable = get_scopetable_v4( frame, *cookie );
TRACE("(%p,%d,%d)\n",frame, frame->trylevel, trylevel);
/* Register a handler in case of a nested exception */
reg.Handler = (PEXCEPTION_ROUTINE)MSVCRT_nested_handler;
reg.Prev = NtCurrentTeb()->NtTib.ExceptionList;
__wine_push_frame(&reg);
while (frame->trylevel != -2 && frame->trylevel != trylevel)
{
int level = frame->trylevel;
frame->trylevel = scopetable->entries[level].previousTryLevel;
if (!scopetable->entries[level].lpfnFilter)
{
TRACE( "__try block cleanup level %d handler %p ebp %p\n",
level, scopetable->entries[level].lpfnHandler, ebp );
call_unwind_func( scopetable->entries[level].lpfnHandler, ebp );
}
}
__wine_pop_frame(&reg);
TRACE("unwound OK\n");
}
/*********************************************************************
* _except_handler4_common (MSVCRT.@)
*/
int CDECL _except_handler4_common( ULONG *cookie, void (*check_cookie)(void),
EXCEPTION_RECORD *rec, MSVCRT_EXCEPTION_FRAME *frame,
CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
{
int retval, trylevel;
EXCEPTION_POINTERS exceptPtrs;
const SCOPETABLE_V4 *scope_table = get_scopetable_v4( frame, *cookie );
TRACE( "exception %x flags=%x at %p handler=%p %p %p cookie=%x scope table=%p cookies=%d/%x,%d/%x\n",
rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
frame->handler, context, dispatcher, *cookie, scope_table,
scope_table->gs_cookie_offset, scope_table->gs_cookie_xor,
scope_table->eh_cookie_offset, scope_table->eh_cookie_xor );
/* FIXME: no cookie validation yet */
if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
{
/* Unwinding the current frame */
msvcrt_local_unwind4( cookie, frame, -2, &frame->_ebp );
TRACE("unwound current frame, returning ExceptionContinueSearch\n");
return ExceptionContinueSearch;
}
else
{
/* Hunting for handler */
exceptPtrs.ExceptionRecord = rec;
exceptPtrs.ContextRecord = context;
*((DWORD *)frame-1) = (DWORD)&exceptPtrs;
trylevel = frame->trylevel;
while (trylevel != -2)
{
TRACE( "level %d prev %d filter %p\n", trylevel,
scope_table->entries[trylevel].previousTryLevel,
scope_table->entries[trylevel].lpfnFilter );
if (scope_table->entries[trylevel].lpfnFilter)
{
retval = call_filter( scope_table->entries[trylevel].lpfnFilter, &exceptPtrs, &frame->_ebp );
TRACE("filter returned %s\n", retval == EXCEPTION_CONTINUE_EXECUTION ?
"CONTINUE_EXECUTION" : retval == EXCEPTION_EXECUTE_HANDLER ?
"EXECUTE_HANDLER" : "CONTINUE_SEARCH");
if (retval == EXCEPTION_CONTINUE_EXECUTION)
return ExceptionContinueExecution;
if (retval == EXCEPTION_EXECUTE_HANDLER)
{
/* Unwind all higher frames, this one will handle the exception */
_global_unwind2((EXCEPTION_REGISTRATION_RECORD*)frame);
msvcrt_local_unwind4( cookie, frame, trylevel, &frame->_ebp );
/* Set our trylevel to the enclosing block, and call the __finally
* code, which won't return
*/
frame->trylevel = scope_table->entries[trylevel].previousTryLevel;
TRACE("__finally block %p\n",scope_table->entries[trylevel].lpfnHandler);
call_finally_block(scope_table->entries[trylevel].lpfnHandler, &frame->_ebp);
ERR("Returned from __finally block - expect crash!\n");
}
}
trylevel = scope_table->entries[trylevel].previousTryLevel;
}
}
TRACE("reached -2, returning ExceptionContinueSearch\n");
return ExceptionContinueSearch;
}
/*******************************************************************
* _local_unwind4 (MSVCRT.@)
*/
void CDECL _local_unwind4( ULONG *cookie, MSVCRT_EXCEPTION_FRAME* frame, int trylevel )
{
msvcrt_local_unwind4( cookie, frame, trylevel, &frame->_ebp );
}
/*********************************************************************
* _seh_longjmp_unwind4 (MSVCRT.@)
*/
void __stdcall _seh_longjmp_unwind4(struct __JUMP_BUFFER *jmp)
{
msvcrt_local_unwind4( (void *)jmp->Cookie, (MSVCRT_EXCEPTION_FRAME *)jmp->Registration,
jmp->TryLevel, (void *)jmp->Ebp );
}
#endif
/******************************************************************
* __uncaught_exception
*/
BOOL CDECL __uncaught_exception(void)
{
return FALSE;
}
/* _set_security_error_handler - not exported in native msvcrt, added in msvcr70 */
MSVCRT_security_error_handler CDECL _set_security_error_handler(
MSVCRT_security_error_handler handler )
{
MSVCRT_security_error_handler old = security_error_handler;
TRACE("(%p)\n", handler);
security_error_handler = handler;
return old;
}
/*********************************************************************
* __DestructExceptionObject (MSVCRT.@)
*/
void CDECL __DestructExceptionObject(EXCEPTION_RECORD* rec)
{
cxx_exception_type* info = (cxx_exception_type*)rec->ExceptionInformation[2];
void* object = (void*)rec->ExceptionInformation[1];
TRACE("(%p)\n", rec);
if (rec->ExceptionCode != CXX_EXCEPTION) return;
#ifndef __x86_64__
if (rec->NumberParameters != 3) return;
#else
if (rec->NumberParameters != 4) return;
#endif
if (rec->ExceptionInformation[0] < CXX_FRAME_MAGIC_VC6 ||
rec->ExceptionInformation[0] > CXX_FRAME_MAGIC_VC8) return;
if (!info || !info->destructor)
return;
#if defined(__i386__)
#ifdef _MSC_VER
((void(__fastcall*)(void*))info->destructor)(object);
#else
__asm__ __volatile__("call *%0" : : "r" (info->destructor), "c" (object) : "eax", "edx", "memory");
#endif
#elif defined(__x86_64__)
((void(__cdecl*)(void*))(info->destructor + rec->ExceptionInformation[3]))(object);
#else
((void(__cdecl*)(void*))info->destructor)(object);
#endif
}

View file

@ -5,53 +5,53 @@
.code
.align 4
MACRO(DEFINE_THISCALL_WRAPPER, cxxname, stdcallname)
EXTERN &stdcallname:PROC
PUBLIC &cxxname
&cxxname:
pop eax
push ecx
push eax
jmp &stdcallname
MACRO(DEFINE_THISCALL_ALIAS, cxxname, target)
#ifdef _USE_ML
EXTERN ___thiscall&target:PROC
ALIAS <&cxxname> = <___thiscall&target>
#else
PUBLIC cxxname
.weakref &cxxname, &target
#endif
ENDM
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@ABQBD@Z, _MSVCRT_exception_ctor@8
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@ABQBDH@Z, _MSVCRT_exception_ctor_noalloc@12
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@ABV0@@Z, _MSVCRT_exception_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0exception@@QAE@XZ, _MSVCRT_exception_default_ctor@4
DEFINE_THISCALL_WRAPPER ??1exception@@UAE@XZ, _MSVCRT_exception_dtor@4
DEFINE_THISCALL_WRAPPER ??4exception@@QAEAAV0@ABV0@@Z, _MSVCRT_exception_opequals@8
DEFINE_THISCALL_WRAPPER ??_Eexception@@UAEPAXI@Z, _MSVCRT_exception_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_Gexception@@UAEPAXI@Z, _MSVCRT_exception_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ?what@exception@@UBEPBDXZ, _MSVCRT_what_exception@4
DEFINE_THISCALL_WRAPPER ??0bad_typeid@@QAE@ABV0@@Z, _MSVCRT_bad_typeid_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_typeid@@QAE@PBD@Z, _MSVCRT_bad_typeid_ctor@8
DEFINE_THISCALL_WRAPPER ??_Fbad_typeid@@QAEXXZ, _MSVCRT_bad_typeid_default_ctor@4
DEFINE_THISCALL_WRAPPER ??1bad_typeid@@UAE@XZ, _MSVCRT_bad_typeid_dtor@4
DEFINE_THISCALL_WRAPPER ??4bad_typeid@@QAEAAV0@ABV0@@Z, _MSVCRT_bad_typeid_opequals@8
DEFINE_THISCALL_WRAPPER ??_Ebad_typeid@@UAEPAXI@Z, _MSVCRT_bad_typeid_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_Gbad_typeid@@UAEPAXI@Z, _MSVCRT_bad_typeid_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ??0__non_rtti_object@@QAE@ABV0@@Z, _MSVCRT___non_rtti_object_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0__non_rtti_object@@QAE@PBD@Z, _MSVCRT___non_rtti_object_ctor@8
DEFINE_THISCALL_WRAPPER ??1__non_rtti_object@@UAE@XZ, _MSVCRT___non_rtti_object_dtor@4
DEFINE_THISCALL_WRAPPER ??4__non_rtti_object@@QAEAAV0@ABV0@@Z, _MSVCRT___non_rtti_object_opequals@8
DEFINE_THISCALL_WRAPPER ??_E__non_rtti_object@@UAEPAXI@Z, _MSVCRT___non_rtti_object_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_G__non_rtti_object@@UAEPAXI@Z, _MSVCRT___non_rtti_object_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@AAE@PBQBD@Z, _MSVCRT_bad_cast_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@QAE@ABQBD@Z, _MSVCRT_bad_cast_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@QAE@ABV0@@Z, _MSVCRT_bad_cast_copy_ctor@8
DEFINE_THISCALL_WRAPPER ??0bad_cast@@QAE@PBD@Z, _MSVCRT_bad_cast_ctor_charptr@8
DEFINE_THISCALL_WRAPPER ??_Fbad_cast@@QAEXXZ, _MSVCRT_bad_cast_default_ctor@4
DEFINE_THISCALL_WRAPPER ??1bad_cast@@UAE@XZ, _MSVCRT_bad_cast_dtor@4
DEFINE_THISCALL_WRAPPER ??4bad_cast@@QAEAAV0@ABV0@@Z, _MSVCRT_bad_cast_opequals@8
DEFINE_THISCALL_WRAPPER ??_Ebad_cast@@UAEPAXI@Z, _MSVCRT_bad_cast_vector_dtor@8
DEFINE_THISCALL_WRAPPER ??_Gbad_cast@@UAEPAXI@Z, _MSVCRT_bad_cast_scalar_dtor@8
DEFINE_THISCALL_WRAPPER ??8type_info@@QBEHABV0@@Z, _MSVCRT_type_info_opequals_equals@8
DEFINE_THISCALL_WRAPPER ??9type_info@@QBEHABV0@@Z, _MSVCRT_type_info_opnot_equals@8
DEFINE_THISCALL_WRAPPER ?before@type_info@@QBEHABV1@@Z, _MSVCRT_type_info_before@8
DEFINE_THISCALL_WRAPPER ??1type_info@@UAE@XZ, _MSVCRT_type_info_dtor@4
DEFINE_THISCALL_WRAPPER ?name@type_info@@QBEPBDXZ, _MSVCRT_type_info_name@4
DEFINE_THISCALL_WRAPPER ?raw_name@type_info@@QBEPBDXZ, _MSVCRT_type_info_raw_name@4
DEFINE_THISCALL_ALIAS ??0exception@@QAE@ABQBD@Z, _MSVCRT_exception_ctor
DEFINE_THISCALL_ALIAS ??0exception@@QAE@ABQBDH@Z, _MSVCRT_exception_ctor_noalloc
DEFINE_THISCALL_ALIAS ??0exception@@QAE@ABV0@@Z, _MSVCRT_exception_copy_ctor
DEFINE_THISCALL_ALIAS ??0exception@@QAE@XZ, _MSVCRT_exception_default_ctor
DEFINE_THISCALL_ALIAS ??1exception@@UAE@XZ, _MSVCRT_exception_dtor
DEFINE_THISCALL_ALIAS ??4exception@@QAEAAV0@ABV0@@Z, _MSVCRT_exception_opequals
DEFINE_THISCALL_ALIAS ??_Eexception@@UAEPAXI@Z, _MSVCRT_exception_vector_dtor
DEFINE_THISCALL_ALIAS ??_Gexception@@UAEPAXI@Z, _MSVCRT_exception_scalar_dtor
DEFINE_THISCALL_ALIAS ?what@exception@@UBEPBDXZ, _MSVCRT_what_exception
DEFINE_THISCALL_ALIAS ??0bad_typeid@@QAE@ABV0@@Z, _MSVCRT_bad_typeid_copy_ctor
DEFINE_THISCALL_ALIAS ??0bad_typeid@@QAE@PBD@Z, _MSVCRT_bad_typeid_ctor
DEFINE_THISCALL_ALIAS ??_Fbad_typeid@@QAEXXZ, _MSVCRT_bad_typeid_default_ctor
DEFINE_THISCALL_ALIAS ??1bad_typeid@@UAE@XZ, _MSVCRT_bad_typeid_dtor
DEFINE_THISCALL_ALIAS ??4bad_typeid@@QAEAAV0@ABV0@@Z, _MSVCRT_bad_typeid_opequals
DEFINE_THISCALL_ALIAS ??_Ebad_typeid@@UAEPAXI@Z, _MSVCRT_bad_typeid_vector_dtor
DEFINE_THISCALL_ALIAS ??_Gbad_typeid@@UAEPAXI@Z, _MSVCRT_bad_typeid_scalar_dtor
DEFINE_THISCALL_ALIAS ??0__non_rtti_object@@QAE@ABV0@@Z, _MSVCRT___non_rtti_object_copy_ctor
DEFINE_THISCALL_ALIAS ??0__non_rtti_object@@QAE@PBD@Z, _MSVCRT___non_rtti_object_ctor
DEFINE_THISCALL_ALIAS ??1__non_rtti_object@@UAE@XZ, _MSVCRT___non_rtti_object_dtor
DEFINE_THISCALL_ALIAS ??4__non_rtti_object@@QAEAAV0@ABV0@@Z, _MSVCRT___non_rtti_object_opequals
DEFINE_THISCALL_ALIAS ??_E__non_rtti_object@@UAEPAXI@Z, _MSVCRT___non_rtti_object_vector_dtor
DEFINE_THISCALL_ALIAS ??_G__non_rtti_object@@UAEPAXI@Z, _MSVCRT___non_rtti_object_scalar_dtor
DEFINE_THISCALL_ALIAS ??0bad_cast@@AAE@PBQBD@Z, _MSVCRT_bad_cast_ctor
DEFINE_THISCALL_ALIAS ??0bad_cast@@QAE@ABQBD@Z, _MSVCRT_bad_cast_ctor
DEFINE_THISCALL_ALIAS ??0bad_cast@@QAE@ABV0@@Z, _MSVCRT_bad_cast_copy_ctor
DEFINE_THISCALL_ALIAS ??0bad_cast@@QAE@PBD@Z, _MSVCRT_bad_cast_ctor_charptr
DEFINE_THISCALL_ALIAS ??_Fbad_cast@@QAEXXZ, _MSVCRT_bad_cast_default_ctor
DEFINE_THISCALL_ALIAS ??1bad_cast@@UAE@XZ, _MSVCRT_bad_cast_dtor
DEFINE_THISCALL_ALIAS ??4bad_cast@@QAEAAV0@ABV0@@Z, _MSVCRT_bad_cast_opequals
DEFINE_THISCALL_ALIAS ??_Ebad_cast@@UAEPAXI@Z, _MSVCRT_bad_cast_vector_dtor
DEFINE_THISCALL_ALIAS ??_Gbad_cast@@UAEPAXI@Z, _MSVCRT_bad_cast_scalar_dtor
DEFINE_THISCALL_ALIAS ??8type_info@@QBEHABV0@@Z, _MSVCRT_type_info_opequals_equals
DEFINE_THISCALL_ALIAS ??9type_info@@QBEHABV0@@Z, _MSVCRT_type_info_opnot_equals
DEFINE_THISCALL_ALIAS ?before@type_info@@QBEHABV1@@Z, _MSVCRT_type_info_before
DEFINE_THISCALL_ALIAS ??1type_info@@UAE@XZ, _MSVCRT_type_info_dtor
DEFINE_THISCALL_ALIAS ?name@type_info@@QBEPBDXZ, _MSVCRT_type_info_name
DEFINE_THISCALL_ALIAS ?raw_name@type_info@@QBEPBDXZ, _MSVCRT_type_info_raw_name
#undef _MSVCRT_
@ -108,5 +108,63 @@ DEFINE_ALIAS ?terminate@@YAXXZ, _MSVCRT_terminate, PROC
DEFINE_ALIAS ?unexpected@@YAXXZ, _MSVCRT_unexpected, PROC
// void call_copy_ctor( void *func, void *this, void *src, int has_vbase );
PUBLIC _call_copy_ctor
_call_copy_ctor:
push ebp
CFI_ADJUST_CFA_OFFSET 4
CFI_REL_OFFSET ebp, 0
mov ebp, esp
CFI_DEF_CFA_REGISTER ebp
push 1
mov ecx, [ebp + 12]
push dword ptr [ebp + 16]
call dword ptr [ebp + 8]
leave
CFI_DEF_CFA esp, 4
CFI_SAME_VALUE ebp
ret
// void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr );
PUBLIC _continue_after_catch
_continue_after_catch:
mov edx, [esp + 4]
mov eax, [esp + 8]
mov esp, [edx - 4]
lea ebp, [edx + 12]
jmp eax
// void DECLSPEC_NORETURN call_finally_block( void *code_block, void *base_ptr );
PUBLIC _call_finally_block
_call_finally_block:
mov ebp, [esp +8]
jmp dword ptr [esp + 4]
// int call_filter( int (*func)(PEXCEPTION_POINTERS), void *arg, void *ebp );
PUBLIC _call_filter
_call_filter:
push ebp
push [esp + 12]
mov ebp, [esp + 20]
call dword ptr [esp + 12]
pop ebp
pop ebp
ret
// void *call_handler( void * (*func)(void), void *ebp );
PUBLIC _call_handler
_call_handler:
push ebp
push ebx
push esi
push edi
mov ebp, [esp + 24]
call dword ptr [esp + 29]
pop edi
pop esi
pop ebx
pop ebp
ret
END

View file

@ -1,39 +0,0 @@
#define WIN32_NO_STATUS
#include <precomp.h>
#define NTOS_MODE_USER
#include <setjmp.h>
#include <ndk/umtypes.h>
#include <ndk/extypes.h>
#include <ndk/rtlfuncs.h>
/* VC++ extensions to Win32 SEH */
typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
int (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
{
PEXCEPTION_REGISTRATION_RECORD *prev;
void (*handler)(PEXCEPTION_RECORD, PEXCEPTION_REGISTRATION_RECORD,
PCONTEXT, PEXCEPTION_RECORD);
PSCOPETABLE scopetable;
int trylevel;
int _ebp;
PEXCEPTION_POINTERS xpointers;
} MSVCRT_EXCEPTION_FRAME;
void
_local_unwind2(MSVCRT_EXCEPTION_FRAME *RegistrationFrame,
LONG TryLevel);
/*
* @implemented
*/
void __stdcall _seh_longjmp_unwind(_JUMP_BUFFER *jmp)
{
_local_unwind2((MSVCRT_EXCEPTION_FRAME*) jmp->Registration, jmp->TryLevel);
}

View file

@ -47,19 +47,3 @@ void CDECL __setusermatherr(MSVCRT_matherr_func func)
MSVCRT_default_matherr_func = func;
TRACE(":new matherr handler %p\n", func);
}
#define _FPIEEE_RECORD void
/*
* @unimplemented
*/
int _fpieee_flt(
unsigned long exception_code,
struct _EXCEPTION_POINTERS* ExceptionPointer,
int (*handler)(_FPIEEE_RECORD*)
)
{
FIXME("Unimplemented!\n");
return 0;
}

View file

@ -1,98 +0,0 @@
#include <precomp.h>
#include "internal/wine/msvcrt.h"
#include "internal/wine/cppexcept.h"
typedef void (*sighandler_t)(int);
static sighandler_t sighandlers[NSIG] = { SIG_DFL };
/* The exception codes are actually NTSTATUS values */
static const struct
{
NTSTATUS status;
int signal;
} float_exception_map[] = {
{ EXCEPTION_FLT_DENORMAL_OPERAND, _FPE_DENORMAL },
{ EXCEPTION_FLT_DIVIDE_BY_ZERO, _FPE_ZERODIVIDE },
{ EXCEPTION_FLT_INEXACT_RESULT, _FPE_INEXACT },
{ EXCEPTION_FLT_INVALID_OPERATION, _FPE_INVALID },
{ EXCEPTION_FLT_OVERFLOW, _FPE_OVERFLOW },
{ EXCEPTION_FLT_STACK_CHECK, _FPE_STACKOVERFLOW },
{ EXCEPTION_FLT_UNDERFLOW, _FPE_UNDERFLOW },
};
/*
* @implemented
*/
int CDECL
_XcptFilter(NTSTATUS ExceptionCode,
struct _EXCEPTION_POINTERS * except)
{
LONG ret = EXCEPTION_CONTINUE_SEARCH;
sighandler_t handler;
if (!except || !except->ExceptionRecord)
return EXCEPTION_CONTINUE_SEARCH;
switch (except->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
if ((handler = sighandlers[SIGSEGV]) != SIG_DFL)
{
if (handler != SIG_IGN)
{
sighandlers[SIGSEGV] = SIG_DFL;
handler(SIGSEGV);
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
/* According to msdn,
* the FPE signal handler takes as a second argument the type of
* floating point exception.
*/
case EXCEPTION_FLT_DENORMAL_OPERAND:
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_FLT_INEXACT_RESULT:
case EXCEPTION_FLT_INVALID_OPERATION:
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_FLT_UNDERFLOW:
if ((handler = sighandlers[SIGFPE]) != SIG_DFL)
{
if (handler != SIG_IGN)
{
unsigned int i;
int float_signal = _FPE_INVALID;
sighandlers[SIGFPE] = SIG_DFL;
for (i = 0; i < sizeof(float_exception_map) /
sizeof(float_exception_map[0]); i++)
{
if (float_exception_map[i].status ==
except->ExceptionRecord->ExceptionCode)
{
float_signal = float_exception_map[i].signal;
break;
}
}
((float_handler)handler)(SIGFPE, float_signal);
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_PRIV_INSTRUCTION:
if ((handler = sighandlers[SIGILL]) != SIG_DFL)
{
if (handler != SIG_IGN)
{
sighandlers[SIGILL] = SIG_DFL;
handler(SIGILL);
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
}
return ret;
}

View file

@ -1,50 +1,100 @@
#define DEFINE_THISCALL_WRAPPER(func, args) \
void __declspec(naked) __thiscall_ ## func (void) \
{ \
__asm { pop eax } \
__asm { push ecx } \
__asm { push eax } \
__asm { jmp func } \
}
exception * __stdcall MSVCRT_exception_ctor(exception * _this, const char ** name);
exception * __stdcall MSVCRT_exception_ctor_noalloc(exception * _this, char ** name, int noalloc);
exception * __stdcall MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs);
exception * __stdcall MSVCRT_exception_default_ctor(exception * _this);
void __stdcall MSVCRT_exception_dtor(exception * _this);
exception * __stdcall MSVCRT_exception_opequals(exception * _this, const exception * rhs);
void * __stdcall MSVCRT_exception_vector_dtor(exception * _this, unsigned int flags);
void * __stdcall MSVCRT_exception_scalar_dtor(exception * _this, unsigned int flags);
const char * __stdcall MSVCRT_what_exception(exception * _this);
bad_typeid * __stdcall MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs);
bad_typeid * __stdcall MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name);
bad_typeid * __stdcall MSVCRT_bad_typeid_default_ctor(bad_typeid * _this);
void __stdcall MSVCRT_bad_typeid_dtor(bad_typeid * _this);
bad_typeid * __stdcall MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs);
void * __stdcall MSVCRT_bad_typeid_vector_dtor(bad_typeid * _this, unsigned int flags);
void * __stdcall MSVCRT_bad_typeid_scalar_dtor(bad_typeid * _this, unsigned int flags);
__non_rtti_object * __stdcall MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this, const __non_rtti_object * rhs);
__non_rtti_object * __stdcall MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this, const char * name);
void __stdcall MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this);
__non_rtti_object * __stdcall MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this, const __non_rtti_object *rhs);
void * __stdcall MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object * _this, unsigned int flags);
void * __stdcall MSVCRT___non_rtti_object_scalar_dtor(__non_rtti_object * _this, unsigned int flags);
bad_cast * __stdcall MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name);
bad_cast * __stdcall MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs);
bad_cast * __stdcall MSVCRT_bad_cast_ctor_charptr(bad_cast * _this, const char * name);
bad_cast * __stdcall MSVCRT_bad_cast_default_ctor(bad_cast * _this);
void __stdcall MSVCRT_bad_cast_dtor(bad_cast * _this);
bad_cast * __stdcall MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs);
void * __stdcall MSVCRT_bad_cast_vector_dtor(bad_cast * _this, unsigned int flags);
void * __stdcall MSVCRT_bad_cast_scalar_dtor(bad_cast * _this, unsigned int flags);
int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs);
int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs);
int __stdcall MSVCRT_type_info_before(type_info * _this, const type_info * rhs);
void __stdcall MSVCRT_type_info_dtor(type_info * _this);
const char * __stdcall MSVCRT_type_info_name(type_info * _this);
const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this);
void * __stdcall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int flags);
#define __ASM_VTABLE(name,funcs)
//void *MSVCRT_ ## name ##_vtable[] =
exception * __thiscall MSVCRT_exception_ctor(exception * _this, const char ** name);
exception * __thiscall MSVCRT_exception_ctor_noalloc(exception * _this, char ** name, int noalloc);
exception * __thiscall MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs);
exception * __thiscall MSVCRT_exception_default_ctor(exception * _this);
void __thiscall MSVCRT_exception_dtor(exception * _this);
exception * __thiscall MSVCRT_exception_opequals(exception * _this, const exception * rhs);
void * __thiscall MSVCRT_exception_vector_dtor(exception * _this, unsigned int flags);
void * __thiscall MSVCRT_exception_scalar_dtor(exception * _this, unsigned int flags);
const char * __thiscall MSVCRT_what_exception(exception * _this);
bad_typeid * __thiscall MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs);
bad_typeid * __thiscall MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name);
bad_typeid * __thiscall MSVCRT_bad_typeid_default_ctor(bad_typeid * _this);
void __thiscall MSVCRT_bad_typeid_dtor(bad_typeid * _this);
bad_typeid * __thiscall MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs);
void * __thiscall MSVCRT_bad_typeid_vector_dtor(bad_typeid * _this, unsigned int flags);
void * __thiscall MSVCRT_bad_typeid_scalar_dtor(bad_typeid * _this, unsigned int flags);
__non_rtti_object * __thiscall MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this, const __non_rtti_object * rhs);
__non_rtti_object * __thiscall MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this, const char * name);
void __thiscall MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this);
__non_rtti_object * __thiscall MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this, const __non_rtti_object *rhs);
void * __thiscall MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object * _this, unsigned int flags);
void * __thiscall MSVCRT___non_rtti_object_scalar_dtor(__non_rtti_object * _this, unsigned int flags);
bad_cast * __thiscall MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name);
bad_cast * __thiscall MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs);
bad_cast * __thiscall MSVCRT_bad_cast_ctor_charptr(bad_cast * _this, const char * name);
bad_cast * __thiscall MSVCRT_bad_cast_default_ctor(bad_cast * _this);
void __thiscall MSVCRT_bad_cast_dtor(bad_cast * _this);
bad_cast * __thiscall MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs);
void * __thiscall MSVCRT_bad_cast_vector_dtor(bad_cast * _this, unsigned int flags);
void * __thiscall MSVCRT_bad_cast_scalar_dtor(bad_cast * _this, unsigned int flags);
int __thiscall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs);
int __thiscall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs);
int __thiscall MSVCRT_type_info_before(type_info * _this, const type_info * rhs);
void __thiscall MSVCRT_type_info_dtor(type_info * _this);
const char * __thiscall MSVCRT_type_info_name(type_info * _this);
const char * __thiscall MSVCRT_type_info_raw_name(type_info * _this);
void * __thiscall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int flags);
#if _MSVCR_VER >= 80
bad_alloc* __thiscall MSVCRT_bad_alloc_copy_ctor(bad_alloc* _this, const bad_alloc* rhs);
bad_alloc* __thiscall MSVCRT_bad_alloc_copy_ctor(bad_alloc* _this, const bad_alloc* rhs);
void __thiscall MSVCRT_bad_alloc_dtor(bad_alloc* _this);
#endif /* _MSVCR_VER >= 80 */
#if _MSVCR_VER >= 100
scheduler_resource_allocation_error* __thiscall scheduler_resource_allocation_error_ctor_name(
scheduler_resource_allocation_error* this, const char* name, HRESULT hr);
scheduler_resource_allocation_error* __thiscall scheduler_resource_allocation_error_ctor(
scheduler_resource_allocation_error* this, HRESULT hr);
scheduler_resource_allocation_error* __thiscall MSVCRT_scheduler_resource_allocation_error_copy_ctor(
scheduler_resource_allocation_error* this,
const scheduler_resource_allocation_error* rhs);
HRESULT __thiscall scheduler_resource_allocation_error_get_error_code(
const scheduler_resource_allocation_error* this);
void __thiscall MSVCRT_scheduler_resource_allocation_error_dtor(
scheduler_resource_allocation_error* this);
improper_lock* __thiscall improper_lock_ctor_str(improper_lock* this, const char* str);
improper_lock* __thiscall improper_lock_ctor(improper_lock* this);
improper_lock* __thiscall MSVCRT_improper_lock_copy_ctor(improper_lock* _this, const improper_lock* rhs);
void __thiscall MSVCRT_improper_lock_dtor(improper_lock* _this);
invalid_scheduler_policy_key* __thiscall invalid_scheduler_policy_key_ctor_str(
invalid_scheduler_policy_key* this, const char* str);
invalid_scheduler_policy_key* __thiscall invalid_scheduler_policy_key_ctor(
invalid_scheduler_policy_key* this);
invalid_scheduler_policy_key* __thiscall MSVCRT_invalid_scheduler_policy_key_copy_ctor(
invalid_scheduler_policy_key* _this, const invalid_scheduler_policy_key* rhs);
void __thiscall MSVCRT_invalid_scheduler_policy_key_dtor(
invalid_scheduler_policy_key* _this);
invalid_scheduler_policy_value* __thiscall invalid_scheduler_policy_value_ctor_str(
invalid_scheduler_policy_value* this, const char* str);
invalid_scheduler_policy_value* __thiscall invalid_scheduler_policy_value_ctor(
invalid_scheduler_policy_value* this);
invalid_scheduler_policy_value* __thiscall MSVCRT_invalid_scheduler_policy_value_copy_ctor(
invalid_scheduler_policy_value* _this, const invalid_scheduler_policy_value* rhs);
void __thiscall MSVCRT_invalid_scheduler_policy_value_dtor(
invalid_scheduler_policy_value* _this);
invalid_scheduler_policy_thread_specification* __thiscall invalid_scheduler_policy_thread_specification_ctor_str(
invalid_scheduler_policy_thread_specification* this, const char* str);
invalid_scheduler_policy_thread_specification* __thiscall invalid_scheduler_policy_thread_specification_ctor(
invalid_scheduler_policy_thread_specification* this);
invalid_scheduler_policy_thread_specification* __thiscall MSVCRT_invalid_scheduler_policy_thread_specification_copy_ctor(
invalid_scheduler_policy_thread_specification* _this, const invalid_scheduler_policy_thread_specification* rhs);
void __thiscall MSVCRT_invalid_scheduler_policy_thread_specification_dtor(
invalid_scheduler_policy_thread_specification* _this);
improper_scheduler_attach* __thiscall improper_scheduler_attach_ctor_str(
improper_scheduler_attach* this, const char* str);
improper_scheduler_attach* __thiscall improper_scheduler_attach_ctor(
improper_scheduler_attach* this);
improper_scheduler_attach* __thiscall MSVCRT_improper_scheduler_attach_copy_ctor(
improper_scheduler_attach* _this, const improper_scheduler_attach* rhs);
void __thiscall MSVCRT_improper_scheduler_attach_dtor(
improper_scheduler_attach* _this);
improper_scheduler_detach* __thiscall improper_scheduler_detach_ctor_str(
improper_scheduler_detach* this, const char* str);
improper_scheduler_detach* __thiscall improper_scheduler_detach_ctor(
improper_scheduler_detach* this);
improper_scheduler_detach* __thiscall MSVCRT_improper_scheduler_detach_copy_ctor(
improper_scheduler_detach* _this, const improper_scheduler_detach* rhs);
void __thiscall MSVCRT_improper_scheduler_detach_dtor(
improper_scheduler_detach* _this);
#endif

2189
sdk/lib/crt/wine/cpp.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -21,6 +21,8 @@
#ifndef __MSVCRT_CPPEXCEPT_H
#define __MSVCRT_CPPEXCEPT_H
#include "wine/asm.h"
#define CXX_FRAME_MAGIC_VC6 0x19930520
#define CXX_FRAME_MAGIC_VC7 0x19930521
#define CXX_FRAME_MAGIC_VC8 0x19930522
@ -33,16 +35,16 @@ typedef void (*vtable_ptr)(void);
/* type_info object, see cpp.c for implementation */
typedef struct __type_info
{
const vtable_ptr* vtable;
char* name; /* Unmangled name, allocated lazily */
const vtable_ptr *vtable;
char *name; /* Unmangled name, allocated lazily */
char mangled[64]; /* Variable length, but we declare it large enough for static RTTI */
} type_info;
/* exception object */
typedef struct __exception
{
const vtable_ptr* vtable;
char* name; /* Name of this exception, always a new copy for each object */
const vtable_ptr *vtable;
char *name; /* Name of this exception, always a new copy for each object */
BOOL do_free; /* Whether to free 'name' in our dtor */
} exception;
@ -61,7 +63,7 @@ typedef struct
typedef struct __cxx_type_info
{
UINT flags; /* flags (see CLASS_* flags below) */
const type_info* type_info; /* C++ type info */
const type_info *type_info; /* C++ type info */
this_ptr_offsets offsets; /* offsets for computing the this pointer */
unsigned int size; /* object size */
cxx_copy_ctor copy_ctor; /* copy constructor */
@ -85,7 +87,7 @@ typedef struct __cxx_type_info
typedef struct __cxx_type_info_table
{
UINT count; /* number of types */
const cxx_type_info* info[3]; /* variable length, we declare it large enough for static RTTI */
const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */
} cxx_type_info_table;
#else
typedef struct __cxx_type_info_table
@ -98,10 +100,10 @@ typedef struct __cxx_type_info_table
struct __cxx_exception_frame;
struct __cxx_function_descr;
typedef DWORD(*cxx_exc_custom_handler)(PEXCEPTION_RECORD, struct __cxx_exception_frame*,
typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, struct __cxx_exception_frame*,
PCONTEXT, EXCEPTION_REGISTRATION_RECORD**,
const struct __cxx_function_descr*, int nested_trylevel,
EXCEPTION_REGISTRATION_RECORD* nested_frame, DWORD unknown3);
EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 );
/* type information for an exception object */
#ifndef __x86_64__
@ -110,7 +112,7 @@ typedef struct __cxx_exception_type
UINT flags; /* TYPE_FLAG flags */
void (*destructor)(void);/* exception object destructor */
cxx_exc_custom_handler custom_handler; /* custom handler for this exception */
const cxx_type_info_table* type_info_table; /* list of types for this exception object */
const cxx_type_info_table *type_info_table; /* list of types for this exception object */
} cxx_exception_type;
#else
typedef struct
@ -122,33 +124,33 @@ typedef struct
} cxx_exception_type;
#endif
void WINAPI _CxxThrowException(exception*, const cxx_exception_type*);
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
int CDECL _XcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
static inline const char* dbgstr_type_info(const type_info* info)
static inline const char *dbgstr_type_info( const type_info *info )
{
if (!info) return "{}";
return wine_dbg_sprintf("{vtable=%p name=%s (%s)}",
info->vtable, info->mangled, info->name ? info->name : "");
return wine_dbg_sprintf( "{vtable=%p name=%s (%s)}",
info->vtable, info->mangled, info->name ? info->name : "" );
}
/* compute the this pointer for a base class of a given type */
static inline void* get_this_pointer(const this_ptr_offsets* off, void* object)
static inline void *get_this_pointer( const this_ptr_offsets *off, void *object )
{
if (!object) return NULL;
if (off->vbase_descr >= 0)
{
int* offset_ptr;
int *offset_ptr;
/* move this ptr to vbase descriptor */
object = (char*)object + off->vbase_descr;
object = (char *)object + off->vbase_descr;
/* and fetch additional offset from vbase descriptor */
offset_ptr = (int*)(*(char**)object + off->vbase_offset);
object = (char*)object + *offset_ptr;
offset_ptr = (int *)(*(char **)object + off->vbase_offset);
object = (char *)object + *offset_ptr;
}
object = (char*)object + off->this_offset;
object = (char *)object + off->this_offset;
return object;
}

267
sdk/lib/crt/wine/cxx.h Normal file
View file

@ -0,0 +1,267 @@
/*
* Copyright 2012 Piotr Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/asm.h"
#ifdef _WIN64
#define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
#define __ASM_VTABLE(name,funcs) \
__asm__(".data\n" \
"\t.balign 8\n" \
"\t.quad " __ASM_NAME(#name "_rtti") "\n" \
"\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
__ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
funcs "\n\t.text")
#else
#define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
#define __ASM_VTABLE(name,funcs) \
__asm__(".data\n" \
"\t.balign 4\n" \
"\t.long " __ASM_NAME(#name "_rtti") "\n" \
"\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
__ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
funcs "\n\t.text")
#endif /* _WIN64 */
#ifndef __x86_64__
#define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
static type_info name ## _type_info = { \
&MSVCRT_type_info_vtable, \
NULL, \
mangled_name \
}; \
\
static const rtti_base_descriptor name ## _rtti_base_descriptor = { \
&name ##_type_info, \
base_classes_no, \
{ 0, -1, 0}, \
64 \
}; \
\
static const rtti_base_array name ## _rtti_base_array = { \
{ \
&name ## _rtti_base_descriptor, \
cl1, \
cl2, \
cl3, \
cl4, \
cl5, \
cl6, \
cl7, \
cl8, \
cl9, \
} \
}; \
\
static const rtti_object_hierarchy name ## _hierarchy = { \
0, \
0, \
base_classes_no+1, \
&name ## _rtti_base_array \
}; \
\
const rtti_object_locator name ## _rtti = { \
0, \
off, \
0, \
&name ## _type_info, \
&name ## _hierarchy \
};
#else
#define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
static type_info name ## _type_info = { \
&MSVCRT_type_info_vtable, \
NULL, \
mangled_name \
}; \
\
static rtti_base_descriptor name ## _rtti_base_descriptor = { \
0xdeadbeef, \
base_classes_no, \
{ 0, -1, 0}, \
64 \
}; \
\
static rtti_base_array name ## _rtti_base_array = { \
{ \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
} \
}; \
\
static rtti_object_hierarchy name ## _hierarchy = { \
0, \
0, \
base_classes_no+1, \
0xdeadbeef \
}; \
\
rtti_object_locator name ## _rtti = { \
1, \
off, \
0, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef \
};\
\
static void init_ ## name ## _rtti(char *base) \
{ \
name ## _rtti_base_descriptor.type_descriptor = (char*)&name ## _type_info - base; \
name ## _rtti_base_array.bases[0] = (char*)&name ## _rtti_base_descriptor - base; \
name ## _rtti_base_array.bases[1] = (char*)cl1 - base; \
name ## _rtti_base_array.bases[2] = (char*)cl2 - base; \
name ## _rtti_base_array.bases[3] = (char*)cl3 - base; \
name ## _rtti_base_array.bases[4] = (char*)cl4 - base; \
name ## _rtti_base_array.bases[5] = (char*)cl5 - base; \
name ## _rtti_base_array.bases[6] = (char*)cl6 - base; \
name ## _rtti_base_array.bases[7] = (char*)cl7 - base; \
name ## _rtti_base_array.bases[8] = (char*)cl8 - base; \
name ## _rtti_base_array.bases[9] = (char*)cl9 - base; \
name ## _hierarchy.base_classes = (char*)&name ## _rtti_base_array - base; \
name ## _rtti.type_descriptor = (char*)&name ## _type_info - base; \
name ## _rtti.type_hierarchy = (char*)&name ## _hierarchy - base; \
name ## _rtti.object_locator = (char*)&name ## _rtti - base; \
}
#endif
#define DEFINE_RTTI_DATA0(name, off, mangled_name) \
DEFINE_RTTI_DATA(name, off, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA1(name, off, cl1, mangled_name) \
DEFINE_RTTI_DATA(name, off, 1, cl1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA2(name, off, cl1, cl2, mangled_name) \
DEFINE_RTTI_DATA(name, off, 2, cl1, cl2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA3(name, off, cl1, cl2, cl3, mangled_name) \
DEFINE_RTTI_DATA(name, off, 3, cl1, cl2, cl3, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA4(name, off, cl1, cl2, cl3, cl4, mangled_name) \
DEFINE_RTTI_DATA(name, off, 4, cl1, cl2, cl3, cl4, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA8(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, mangled_name) \
DEFINE_RTTI_DATA(name, off, 8, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, NULL, mangled_name)
#define DEFINE_RTTI_DATA9(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
DEFINE_RTTI_DATA(name, off, 9, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name)
#ifndef __x86_64__
typedef struct _rtti_base_descriptor
{
const type_info *type_descriptor;
int num_base_classes;
this_ptr_offsets offsets; /* offsets for computing the this pointer */
unsigned int attributes;
} rtti_base_descriptor;
typedef struct _rtti_base_array
{
const rtti_base_descriptor *bases[10]; /* First element is the class itself */
} rtti_base_array;
typedef struct _rtti_object_hierarchy
{
unsigned int signature;
unsigned int attributes;
int array_len; /* Size of the array pointed to by 'base_classes' */
const rtti_base_array *base_classes;
} rtti_object_hierarchy;
typedef struct _rtti_object_locator
{
unsigned int signature;
int base_class_offset;
unsigned int flags;
const type_info *type_descriptor;
const rtti_object_hierarchy *type_hierarchy;
} rtti_object_locator;
#else
typedef struct
{
unsigned int type_descriptor;
int num_base_classes;
this_ptr_offsets offsets; /* offsets for computing the this pointer */
unsigned int attributes;
} rtti_base_descriptor;
typedef struct
{
unsigned int bases[10]; /* First element is the class itself */
} rtti_base_array;
typedef struct
{
unsigned int signature;
unsigned int attributes;
int array_len; /* Size of the array pointed to by 'base_classes' */
unsigned int base_classes;
} rtti_object_hierarchy;
typedef struct
{
unsigned int signature;
int base_class_offset;
unsigned int flags;
unsigned int type_descriptor;
unsigned int type_hierarchy;
unsigned int object_locator;
} rtti_object_locator;
#endif
#if defined(__i386__) && !defined(__MINGW32__)
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
extern void *vtbl_wrapper_0;
extern void *vtbl_wrapper_4;
extern void *vtbl_wrapper_8;
extern void *vtbl_wrapper_12;
extern void *vtbl_wrapper_16;
extern void *vtbl_wrapper_20;
extern void *vtbl_wrapper_24;
extern void *vtbl_wrapper_28;
extern void *vtbl_wrapper_32;
extern void *vtbl_wrapper_36;
extern void *vtbl_wrapper_40;
extern void *vtbl_wrapper_44;
extern void *vtbl_wrapper_48;
#else
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__thiscall***)type)this)[0][off/4]args
#endif
//exception* __thiscall MSVCRT_exception_ctor(exception*, const char**);

545
sdk/lib/crt/wine/except.c Normal file
View file

@ -0,0 +1,545 @@
/*
* msvcrt.dll exception handling
*
* Copyright 2000 Jon Griffiths
* Copyright 2005 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* FIXME: Incomplete support for nested exceptions/try block cleanup.
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "wine/exception.h"
#include "msvcrt.h"
#include "excpt.h"
#include "wincon.h"
#include "wine/debug.h"
#include "cppexcept.h"
WINE_DEFAULT_DEBUG_CHANNEL(seh);
#if _MSVCR_VER>=70 && _MSVCR_VER<=71
static MSVCRT_security_error_handler security_error_handler;
#endif
static MSVCRT___sighandler_t sighandlers[MSVCRT_NSIG] = { MSVCRT_SIG_DFL };
static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType)
{
BOOL ret = FALSE;
switch (ctrlType)
{
case CTRL_C_EVENT:
if (sighandlers[MSVCRT_SIGINT])
{
if (sighandlers[MSVCRT_SIGINT] != MSVCRT_SIG_IGN)
sighandlers[MSVCRT_SIGINT](MSVCRT_SIGINT);
ret = TRUE;
}
break;
}
return ret;
}
/*********************************************************************
* __pxcptinfoptrs (MSVCRT.@)
*/
void** CDECL MSVCRT___pxcptinfoptrs(void)
{
return (void**)&msvcrt_get_thread_data()->xcptinfo;
}
typedef void (CDECL *float_handler)(int, int);
/* The exception codes are actually NTSTATUS values */
static const struct
{
NTSTATUS status;
int signal;
} float_exception_map[] = {
{ EXCEPTION_FLT_DENORMAL_OPERAND, MSVCRT__FPE_DENORMAL },
{ EXCEPTION_FLT_DIVIDE_BY_ZERO, MSVCRT__FPE_ZERODIVIDE },
{ EXCEPTION_FLT_INEXACT_RESULT, MSVCRT__FPE_INEXACT },
{ EXCEPTION_FLT_INVALID_OPERATION, MSVCRT__FPE_INVALID },
{ EXCEPTION_FLT_OVERFLOW, MSVCRT__FPE_OVERFLOW },
{ EXCEPTION_FLT_STACK_CHECK, MSVCRT__FPE_STACKOVERFLOW },
{ EXCEPTION_FLT_UNDERFLOW, MSVCRT__FPE_UNDERFLOW },
};
static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
{
LONG ret = EXCEPTION_CONTINUE_SEARCH;
MSVCRT___sighandler_t handler;
if (!except || !except->ExceptionRecord)
return EXCEPTION_CONTINUE_SEARCH;
switch (except->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
if ((handler = sighandlers[MSVCRT_SIGSEGV]) != MSVCRT_SIG_DFL)
{
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
old_ep = *ep;
*ep = except;
sighandlers[MSVCRT_SIGSEGV] = MSVCRT_SIG_DFL;
handler(MSVCRT_SIGSEGV);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
/* According to msdn,
* the FPE signal handler takes as a second argument the type of
* floating point exception.
*/
case EXCEPTION_FLT_DENORMAL_OPERAND:
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_FLT_INEXACT_RESULT:
case EXCEPTION_FLT_INVALID_OPERATION:
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_FLT_UNDERFLOW:
if ((handler = sighandlers[MSVCRT_SIGFPE]) != MSVCRT_SIG_DFL)
{
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
unsigned int i;
int float_signal = MSVCRT__FPE_INVALID;
sighandlers[MSVCRT_SIGFPE] = MSVCRT_SIG_DFL;
for (i = 0; i < ARRAY_SIZE(float_exception_map); i++)
{
if (float_exception_map[i].status ==
except->ExceptionRecord->ExceptionCode)
{
float_signal = float_exception_map[i].signal;
break;
}
}
old_ep = *ep;
*ep = except;
((float_handler)handler)(MSVCRT_SIGFPE, float_signal);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_PRIV_INSTRUCTION:
if ((handler = sighandlers[MSVCRT_SIGILL]) != MSVCRT_SIG_DFL)
{
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
old_ep = *ep;
*ep = except;
sighandlers[MSVCRT_SIGILL] = MSVCRT_SIG_DFL;
handler(MSVCRT_SIGILL);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
}
break;
}
return ret;
}
void msvcrt_init_signals(void)
{
SetConsoleCtrlHandler(msvcrt_console_handler, TRUE);
}
void msvcrt_free_signals(void)
{
SetConsoleCtrlHandler(msvcrt_console_handler, FALSE);
}
/*********************************************************************
* signal (MSVCRT.@)
* Some signals may never be generated except through an explicit call to
* raise.
*/
MSVCRT___sighandler_t CDECL MSVCRT_signal(int sig, MSVCRT___sighandler_t func)
{
MSVCRT___sighandler_t ret = MSVCRT_SIG_ERR;
TRACE("(%d, %p)\n", sig, func);
if (func == MSVCRT_SIG_ERR) return MSVCRT_SIG_ERR;
switch (sig)
{
/* Cases handled internally. Note SIGTERM is never generated by Windows,
* so we effectively mask it.
*/
case MSVCRT_SIGABRT:
case MSVCRT_SIGFPE:
case MSVCRT_SIGILL:
case MSVCRT_SIGSEGV:
case MSVCRT_SIGINT:
case MSVCRT_SIGTERM:
case MSVCRT_SIGBREAK:
ret = sighandlers[sig];
sighandlers[sig] = func;
break;
default:
ret = MSVCRT_SIG_ERR;
}
return ret;
}
/*********************************************************************
* raise (MSVCRT.@)
*/
int CDECL MSVCRT_raise(int sig)
{
MSVCRT___sighandler_t handler;
TRACE("(%d)\n", sig);
switch (sig)
{
case MSVCRT_SIGFPE:
case MSVCRT_SIGILL:
case MSVCRT_SIGSEGV:
handler = sighandlers[sig];
if (handler == MSVCRT_SIG_DFL) MSVCRT__exit(3);
if (handler != MSVCRT_SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
sighandlers[sig] = MSVCRT_SIG_DFL;
old_ep = *ep;
*ep = NULL;
if (sig == MSVCRT_SIGFPE)
((float_handler)handler)(sig, MSVCRT__FPE_EXPLICITGEN);
else
handler(sig);
*ep = old_ep;
}
break;
case MSVCRT_SIGABRT:
case MSVCRT_SIGINT:
case MSVCRT_SIGTERM:
case MSVCRT_SIGBREAK:
handler = sighandlers[sig];
if (handler == MSVCRT_SIG_DFL) MSVCRT__exit(3);
if (handler != MSVCRT_SIG_IGN)
{
sighandlers[sig] = MSVCRT_SIG_DFL;
handler(sig);
}
break;
default:
return -1;
}
return 0;
}
/*********************************************************************
* _XcptFilter (MSVCRT.@)
*/
int CDECL _XcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
{
TRACE("(%08x,%p)\n", ex, ptr);
/* I assume ptr->ExceptionRecord->ExceptionCode is the same as ex */
return msvcrt_exception_filter(ptr);
}
#ifndef __REACTOS__
/*********************************************************************
* _abnormal_termination (MSVCRT.@)
*/
int CDECL _abnormal_termination(void)
{
FIXME("(void)stub\n");
return 0;
}
#endif /* __REACTOS__ */
/******************************************************************
* __uncaught_exception (MSVCRT.@)
*/
BOOL CDECL MSVCRT___uncaught_exception(void)
{
return msvcrt_get_thread_data()->processing_throw != 0;
}
#if _MSVCR_VER>=70 && _MSVCR_VER<=71
/*********************************************************************
* _set_security_error_handler (MSVCR70.@)
*/
MSVCRT_security_error_handler CDECL _set_security_error_handler(
MSVCRT_security_error_handler handler )
{
MSVCRT_security_error_handler old = security_error_handler;
TRACE("(%p)\n", handler);
security_error_handler = handler;
return old;
}
/*********************************************************************
* __security_error_handler (MSVCR70.@)
*/
void CDECL __security_error_handler(int code, void *data)
{
if(security_error_handler)
security_error_handler(code, data);
else
FIXME("(%d, %p) stub\n", code, data);
MSVCRT__exit(3);
}
#endif /* _MSVCR_VER>=70 && _MSVCR_VER<=71 */
#if _MSVCR_VER>=110
/*********************************************************************
* __crtSetUnhandledExceptionFilter (MSVCR110.@)
*/
LPTOP_LEVEL_EXCEPTION_FILTER CDECL MSVCR110__crtSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER filter)
{
return SetUnhandledExceptionFilter(filter);
}
#endif
/*********************************************************************
* _CreateFrameInfo (MSVCR80.@)
*/
frame_info* CDECL _CreateFrameInfo(frame_info *fi, void *obj)
{
thread_data_t *data = msvcrt_get_thread_data();
TRACE("(%p, %p)\n", fi, obj);
fi->next = data->frame_info_head;
data->frame_info_head = fi;
fi->object = obj;
return fi;
}
/*********************************************************************
* _FindAndUnlinkFrame (MSVCR80.@)
*/
void CDECL _FindAndUnlinkFrame(frame_info *fi)
{
thread_data_t *data = msvcrt_get_thread_data();
frame_info *cur = data->frame_info_head;
TRACE("(%p)\n", fi);
if (cur == fi)
{
data->frame_info_head = cur->next;
return;
}
for (; cur->next; cur = cur->next)
{
if (cur->next == fi)
{
cur->next = fi->next;
return;
}
}
ERR("frame not found, native crashes in this case\n");
}
/*********************************************************************
* _IsExceptionObjectToBeDestroyed (MSVCR80.@)
*/
BOOL __cdecl _IsExceptionObjectToBeDestroyed(const void *obj)
{
frame_info *cur;
TRACE( "%p\n", obj );
for (cur = msvcrt_get_thread_data()->frame_info_head; cur; cur = cur->next)
{
if (cur->object == obj)
return FALSE;
}
return TRUE;
}
/*********************************************************************
* __DestructExceptionObject (MSVCRT.@)
*/
void CDECL __DestructExceptionObject(EXCEPTION_RECORD *rec)
{
cxx_exception_type *info = (cxx_exception_type*) rec->ExceptionInformation[2];
void *object = (void*)rec->ExceptionInformation[1];
TRACE("(%p)\n", rec);
if (rec->ExceptionCode != CXX_EXCEPTION) return;
#ifndef __x86_64__
if (rec->NumberParameters != 3) return;
#else
if (rec->NumberParameters != 4) return;
#endif
if (rec->ExceptionInformation[0] < CXX_FRAME_MAGIC_VC6 ||
rec->ExceptionInformation[0] > CXX_FRAME_MAGIC_VC8) return;
if (!info || !info->destructor)
return;
#if defined(__i386__)
#ifdef _MSC_VER
((void(__fastcall*)(void*))info->destructor)(object);
#else
__asm__ __volatile__("call *%0" : : "r" (info->destructor), "c" (object) : "eax", "edx", "memory");
#endif
#elif defined(__x86_64__)
((void (__cdecl*)(void*))(info->destructor+rec->ExceptionInformation[3]))(object);
#else
((void (__cdecl*)(void*))info->destructor)(object);
#endif
}
/*********************************************************************
* __CxxRegisterExceptionObject (MSVCRT.@)
*/
BOOL CDECL __CxxRegisterExceptionObject(EXCEPTION_POINTERS *ep, cxx_frame_info *frame_info)
{
thread_data_t *data = msvcrt_get_thread_data();
TRACE("(%p, %p)\n", ep, frame_info);
if (!ep || !ep->ExceptionRecord)
{
frame_info->rec = (void*)-1;
frame_info->context = (void*)-1;
return TRUE;
}
frame_info->rec = data->exc_record;
frame_info->context = data->ctx_record;
data->exc_record = ep->ExceptionRecord;
data->ctx_record = ep->ContextRecord;
_CreateFrameInfo(&frame_info->frame_info, (void*)ep->ExceptionRecord->ExceptionInformation[1]);
return TRUE;
}
/*********************************************************************
* __CxxUnregisterExceptionObject (MSVCRT.@)
*/
void CDECL __CxxUnregisterExceptionObject(cxx_frame_info *frame_info, BOOL in_use)
{
thread_data_t *data = msvcrt_get_thread_data();
TRACE("(%p)\n", frame_info);
if(frame_info->rec == (void*)-1)
return;
_FindAndUnlinkFrame(&frame_info->frame_info);
if(data->exc_record->ExceptionCode == CXX_EXCEPTION && !in_use
&& _IsExceptionObjectToBeDestroyed((void*)data->exc_record->ExceptionInformation[1]))
__DestructExceptionObject(data->exc_record);
data->exc_record = frame_info->rec;
data->ctx_record = frame_info->context;
}
struct __std_exception_data {
char *what;
MSVCRT_bool dofree;
};
#if _MSVCR_VER>=140
/*********************************************************************
* __std_exception_copy (UCRTBASE.@)
*/
void CDECL MSVCRT___std_exception_copy(const struct __std_exception_data *src,
struct __std_exception_data *dst)
{
TRACE("(%p %p)\n", src, dst);
if(src->dofree && src->what) {
dst->what = MSVCRT__strdup(src->what);
dst->dofree = 1;
} else {
dst->what = src->what;
dst->dofree = 0;
}
}
/*********************************************************************
* __std_exception_destroy (UCRTBASE.@)
*/
void CDECL MSVCRT___std_exception_destroy(struct __std_exception_data *data)
{
TRACE("(%p)\n", data);
if(data->dofree)
MSVCRT_free(data->what);
data->what = NULL;
data->dofree = 0;
}
/*********************************************************************
* __current_exception (UCRTBASE.@)
*/
void** CDECL __current_exception(void)
{
TRACE("()\n");
return (void**)&msvcrt_get_thread_data()->exc_record;
}
/*********************************************************************
* __current_exception_context (UCRTBASE.@)
*/
void** CDECL __current_exception_context(void)
{
TRACE("()\n");
return (void**)&msvcrt_get_thread_data()->ctx_record;
}
/*********************************************************************
* __processing_throw (UCRTBASE.@)
*/
int* CDECL __processing_throw(void)
{
TRACE("()\n");
return &msvcrt_get_thread_data()->processing_throw;
}
#endif /* _MSVCR_VER>=140 */

View file

@ -0,0 +1,147 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2011 Alexandre Julliard
* Copyright 2013 André Hentschel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#ifdef __arm__
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "msvcrt.h"
#include "wine/exception.h"
#include "excpt.h"
#include "wine/debug.h"
#include "cppexcept.h"
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.@)
*/
EXCEPTION_DISPOSITION CDECL __CxxFrameHandler(EXCEPTION_RECORD *rec, DWORD frame, CONTEXT *context,
DISPATCHER_CONTEXT *dispatch)
{
FIXME("%p %x %p %p: not implemented\n", rec, frame, context, dispatch);
return ExceptionContinueSearch;
}
/*********************************************************************
* __CppXcptFilter (MSVCRT.@)
*/
int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
return _XcptFilter(ex, ptr);
}
/*********************************************************************
* __CxxDetectRethrow (MSVCRT.@)
*/
BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
{
PEXCEPTION_RECORD rec;
if (!ptrs)
return FALSE;
rec = ptrs->ExceptionRecord;
if (rec->ExceptionCode == CXX_EXCEPTION &&
rec->NumberParameters == 3 &&
rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
rec->ExceptionInformation[2])
{
ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
return TRUE;
}
return (msvcrt_get_thread_data()->exc_record == rec);
}
/*********************************************************************
* __CxxQueryExceptionSize (MSVCRT.@)
*/
unsigned int CDECL __CxxQueryExceptionSize(void)
{
return sizeof(cxx_exception_type);
}
/*******************************************************************
* _setjmp (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC(MSVCRT__setjmp,
"mov r1, #0\n\t" /* frame */
"b " __ASM_NAME("__wine_setjmpex"));
/*******************************************************************
* longjmp (MSVCRT.@)
*/
void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
{
EXCEPTION_RECORD rec;
if (!retval) retval = 1;
if (jmp->Frame)
{
rec.ExceptionCode = STATUS_LONGJUMP;
rec.ExceptionFlags = 0;
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = NULL;
rec.NumberParameters = 1;
rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
RtlUnwind((void *)jmp->Frame, (void *)jmp->Pc, &rec, IntToPtr(retval));
}
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
*/
int __cdecl _fpieee_flt(ULONG exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
{
FIXME("(%x %p %p)\n", exception_code, ep, handler);
return EXCEPTION_CONTINUE_SEARCH;
}
#endif /* __arm__ */

View file

@ -0,0 +1,148 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2011 Alexandre Julliard
* Copyright 2013 André Hentschel
* Copyright 2017 Martin Storsjo
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#ifdef __aarch64__
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "msvcrt.h"
#include "wine/exception.h"
#include "excpt.h"
#include "wine/debug.h"
#include "cppexcept.h"
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.@)
*/
EXCEPTION_DISPOSITION CDECL __CxxFrameHandler(EXCEPTION_RECORD *rec, DWORD frame, CONTEXT *context,
DISPATCHER_CONTEXT *dispatch)
{
FIXME("%p %x %p %p: not implemented\n", rec, frame, context, dispatch);
return ExceptionContinueSearch;
}
/*********************************************************************
* __CppXcptFilter (MSVCRT.@)
*/
int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
return _XcptFilter(ex, ptr);
}
/*********************************************************************
* __CxxDetectRethrow (MSVCRT.@)
*/
BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
{
PEXCEPTION_RECORD rec;
if (!ptrs)
return FALSE;
rec = ptrs->ExceptionRecord;
if (rec->ExceptionCode == CXX_EXCEPTION &&
rec->NumberParameters == 3 &&
rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
rec->ExceptionInformation[2])
{
ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
return TRUE;
}
return (msvcrt_get_thread_data()->exc_record == rec);
}
/*********************************************************************
* __CxxQueryExceptionSize (MSVCRT.@)
*/
unsigned int CDECL __CxxQueryExceptionSize(void)
{
return sizeof(cxx_exception_type);
}
/*******************************************************************
* _setjmp (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC(MSVCRT__setjmp,
"mov x1, #0\n\t" /* frame */
"b " __ASM_NAME("__wine_setjmpex"));
/*******************************************************************
* longjmp (MSVCRT.@)
*/
void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
{
EXCEPTION_RECORD rec;
if (!retval) retval = 1;
if (jmp->Frame)
{
rec.ExceptionCode = STATUS_LONGJUMP;
rec.ExceptionFlags = 0;
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = NULL;
rec.NumberParameters = 1;
rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
RtlUnwind((void *)jmp->Frame, (void *)jmp->Lr, &rec, IntToPtr(retval));
}
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
*/
int __cdecl _fpieee_flt(ULONG exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
{
FIXME("(%x %p %p)\n", exception_code, ep, handler);
return EXCEPTION_CONTINUE_SEARCH;
}
#endif /* __aarch64__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,758 @@
/*
* msvcrt C++ exception handling
*
* Copyright 2011 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#ifdef __x86_64__
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "msvcrt.h"
#include "wine/exception.h"
#include "excpt.h"
#include "wine/debug.h"
#include "cppexcept.h"
WINE_DEFAULT_DEBUG_CHANNEL(seh);
typedef struct
{
int prev;
UINT handler;
} unwind_info;
typedef struct
{
UINT flags;
UINT type_info;
int offset;
UINT handler;
UINT frame;
} catchblock_info;
#define TYPE_FLAG_CONST 1
#define TYPE_FLAG_VOLATILE 2
#define TYPE_FLAG_REFERENCE 8
typedef struct
{
int start_level;
int end_level;
int catch_level;
int catchblock_count;
UINT catchblock;
} tryblock_info;
typedef struct
{
int ip;
int state;
} ipmap_info;
typedef struct __cxx_function_descr
{
UINT magic;
UINT unwind_count;
UINT unwind_table;
UINT tryblock_count;
UINT tryblock;
UINT ipmap_count;
UINT ipmap;
UINT unwind_help;
UINT expect_list;
UINT flags;
} cxx_function_descr;
typedef struct
{
cxx_frame_info frame_info;
BOOL rethrow;
} cxx_catch_ctx;
typedef struct
{
ULONG64 dest_frame;
ULONG64 orig_frame;
EXCEPTION_RECORD *seh_rec;
DISPATCHER_CONTEXT *dispatch;
const cxx_function_descr *descr;
} se_translator_ctx;
static inline void* rva_to_ptr(UINT rva, ULONG64 base)
{
return rva ? (void*)(base+rva) : NULL;
}
static inline void dump_type(UINT type_rva, ULONG64 base)
{
const cxx_type_info *type = rva_to_ptr(type_rva, base);
TRACE("flags %x type %x %s offsets %d,%d,%d size %d copy ctor %x(%p)\n",
type->flags, type->type_info, dbgstr_type_info(rva_to_ptr(type->type_info, base)),
type->offsets.this_offset, type->offsets.vbase_descr, type->offsets.vbase_offset,
type->size, type->copy_ctor, rva_to_ptr(type->copy_ctor, base));
}
static void dump_exception_type(const cxx_exception_type *type, ULONG64 base)
{
const cxx_type_info_table *type_info_table = rva_to_ptr(type->type_info_table, base);
UINT i;
TRACE("flags %x destr %x(%p) handler %x(%p) type info %x(%p)\n",
type->flags, type->destructor, rva_to_ptr(type->destructor, base),
type->custom_handler, rva_to_ptr(type->custom_handler, base),
type->type_info_table, type_info_table);
for (i = 0; i < type_info_table->count; i++)
{
TRACE(" %d: ", i);
dump_type(type_info_table->info[i], base);
}
}
static void dump_function_descr(const cxx_function_descr *descr, ULONG64 image_base)
{
unwind_info *unwind_table = rva_to_ptr(descr->unwind_table, image_base);
tryblock_info *tryblock = rva_to_ptr(descr->tryblock, image_base);
ipmap_info *ipmap = rva_to_ptr(descr->ipmap, image_base);
UINT i, j;
TRACE("magic %x\n", descr->magic);
TRACE("unwind table: %x(%p) %d\n", descr->unwind_table, unwind_table, descr->unwind_count);
for (i=0; i<descr->unwind_count; i++)
{
TRACE(" %d: prev %d func %x(%p)\n", i, unwind_table[i].prev,
unwind_table[i].handler, rva_to_ptr(unwind_table[i].handler, image_base));
}
TRACE("try table: %x(%p) %d\n", descr->tryblock, tryblock, descr->tryblock_count);
for (i=0; i<descr->tryblock_count; i++)
{
catchblock_info *catchblock = rva_to_ptr(tryblock[i].catchblock, image_base);
TRACE(" %d: start %d end %d catchlevel %d catch %x(%p) %d\n", i,
tryblock[i].start_level, tryblock[i].end_level,
tryblock[i].catch_level, tryblock[i].catchblock,
catchblock, tryblock[i].catchblock_count);
for (j=0; j<tryblock[i].catchblock_count; j++)
{
TRACE(" %d: flags %x offset %d handler %x(%p) frame %x type %x %s\n",
j, catchblock[j].flags, catchblock[j].offset, catchblock[j].handler,
rva_to_ptr(catchblock[j].handler, image_base), catchblock[j].frame,
catchblock[j].type_info,
dbgstr_type_info(rva_to_ptr(catchblock[j].type_info, image_base)));
}
}
TRACE("ipmap: %x(%p) %d\n", descr->ipmap, ipmap, descr->ipmap_count);
for (i=0; i<descr->ipmap_count; i++)
{
TRACE(" %d: ip %x state %d\n", i, ipmap[i].ip, ipmap[i].state);
}
TRACE("unwind_help %d\n", descr->unwind_help);
if (descr->magic <= CXX_FRAME_MAGIC_VC6) return;
TRACE("expect list: %x\n", descr->expect_list);
if (descr->magic <= CXX_FRAME_MAGIC_VC7) return;
TRACE("flags: %08x\n", descr->flags);
}
static inline int ip_to_state(ipmap_info *ipmap, UINT count, int ip)
{
UINT low = 0, high = count-1, med;
while (low < high) {
med = low + (high-low)/2;
if (ipmap[med].ip <= ip && ipmap[med+1].ip > ip)
{
low = med;
break;
}
if (ipmap[med].ip < ip) low = med+1;
else high = med-1;
}
TRACE("%x -> %d\n", ip, ipmap[low].state);
return ipmap[low].state;
}
/* check if the exception type is caught by a given catch block, and return the type that matched */
static const cxx_type_info *find_caught_type(cxx_exception_type *exc_type, ULONG64 exc_base,
const type_info *catch_ti, UINT catch_flags)
{
const cxx_type_info_table *type_info_table = rva_to_ptr(exc_type->type_info_table, exc_base);
UINT i;
for (i = 0; i < type_info_table->count; i++)
{
const cxx_type_info *type = rva_to_ptr(type_info_table->info[i], exc_base);
const type_info *ti = rva_to_ptr(type->type_info, exc_base);
if (!catch_ti) return type; /* catch(...) matches any type */
if (catch_ti != ti)
{
if (strcmp( catch_ti->mangled, ti->mangled )) continue;
}
/* type is the same, now check the flags */
if ((exc_type->flags & TYPE_FLAG_CONST) &&
!(catch_flags & TYPE_FLAG_CONST)) continue;
if ((exc_type->flags & TYPE_FLAG_VOLATILE) &&
!(catch_flags & TYPE_FLAG_VOLATILE)) continue;
return type; /* it matched */
}
return NULL;
}
static inline void copy_exception(void *object, ULONG64 frame,
DISPATCHER_CONTEXT *dispatch,
const catchblock_info *catchblock,
const cxx_type_info *type, ULONG64 exc_base)
{
const type_info *catch_ti = rva_to_ptr(catchblock->type_info, dispatch->ImageBase);
void **dest = rva_to_ptr(catchblock->offset, frame);
if (!catch_ti || !catch_ti->mangled[0]) return;
if (!catchblock->offset) return;
if (catchblock->flags & TYPE_FLAG_REFERENCE)
{
*dest = get_this_pointer(&type->offsets, object);
}
else if (type->flags & CLASS_IS_SIMPLE_TYPE)
{
memmove(dest, object, type->size);
/* if it is a pointer, adjust it */
if (type->size == sizeof(void*)) *dest = get_this_pointer(&type->offsets, *dest);
}
else /* copy the object */
{
if (type->copy_ctor)
{
if (type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS)
{
void (__cdecl *copy_ctor)(void*, void*, int) =
rva_to_ptr(type->copy_ctor, exc_base);
copy_ctor(dest, get_this_pointer(&type->offsets, object), 1);
}
else
{
void (__cdecl *copy_ctor)(void*, void*) =
rva_to_ptr(type->copy_ctor, exc_base);
copy_ctor(dest, get_this_pointer(&type->offsets, object));
}
}
else
memmove(dest, get_this_pointer(&type->offsets,object), type->size);
}
}
static void cxx_local_unwind(ULONG64 frame, DISPATCHER_CONTEXT *dispatch,
const cxx_function_descr *descr, int last_level)
{
const unwind_info *unwind_table = rva_to_ptr(descr->unwind_table, dispatch->ImageBase);
void (__cdecl *handler)(ULONG64 unk, ULONG64 rbp);
int *unwind_help = rva_to_ptr(descr->unwind_help, frame);
int trylevel;
if (unwind_help[0] == -2)
{
trylevel = ip_to_state(rva_to_ptr(descr->ipmap, dispatch->ImageBase),
descr->ipmap_count, dispatch->ControlPc-dispatch->ImageBase);
}
else
{
trylevel = unwind_help[0];
}
TRACE("current level: %d, last level: %d\n", trylevel, last_level);
while (trylevel > last_level)
{
if (trylevel<0 || trylevel>=descr->unwind_count)
{
ERR("invalid trylevel %d\n", trylevel);
MSVCRT_terminate();
}
handler = rva_to_ptr(unwind_table[trylevel].handler, dispatch->ImageBase);
if (handler)
{
TRACE("handler: %p\n", handler);
handler(0, frame);
}
trylevel = unwind_table[trylevel].prev;
}
unwind_help[0] = trylevel;
}
static LONG CALLBACK cxx_rethrow_filter(PEXCEPTION_POINTERS eptrs, void *c)
{
EXCEPTION_RECORD *rec = eptrs->ExceptionRecord;
thread_data_t *data = msvcrt_get_thread_data();
cxx_catch_ctx *ctx = c;
if (rec->ExceptionCode != CXX_EXCEPTION)
return EXCEPTION_CONTINUE_SEARCH;
if (!rec->ExceptionInformation[1] && !rec->ExceptionInformation[2])
return EXCEPTION_EXECUTE_HANDLER;
if (rec->ExceptionInformation[1] == data->exc_record->ExceptionInformation[1])
ctx->rethrow = TRUE;
return EXCEPTION_CONTINUE_SEARCH;
}
static void CALLBACK cxx_catch_cleanup(BOOL normal, void *c)
{
cxx_catch_ctx *ctx = c;
__CxxUnregisterExceptionObject(&ctx->frame_info, ctx->rethrow);
}
static void* WINAPI call_catch_block(EXCEPTION_RECORD *rec)
{
ULONG64 frame = rec->ExceptionInformation[1];
const cxx_function_descr *descr = (void*)rec->ExceptionInformation[2];
EXCEPTION_RECORD *prev_rec = (void*)rec->ExceptionInformation[4];
EXCEPTION_RECORD *untrans_rec = (void*)rec->ExceptionInformation[6];
CONTEXT *context = (void*)rec->ExceptionInformation[7];
void* (__cdecl *handler)(ULONG64 unk, ULONG64 rbp) = (void*)rec->ExceptionInformation[5];
int *unwind_help = rva_to_ptr(descr->unwind_help, frame);
EXCEPTION_POINTERS ep = { prev_rec, context };
cxx_catch_ctx ctx;
void *ret_addr = NULL;
TRACE("calling handler %p\n", handler);
ctx.rethrow = FALSE;
__CxxRegisterExceptionObject(&ep, &ctx.frame_info);
msvcrt_get_thread_data()->processing_throw--;
__TRY
{
__TRY
{
ret_addr = handler(0, frame);
}
__EXCEPT_CTX(cxx_rethrow_filter, &ctx)
{
TRACE("detect rethrow: exception code: %x\n", prev_rec->ExceptionCode);
ctx.rethrow = TRUE;
if (untrans_rec)
{
__DestructExceptionObject(prev_rec);
RaiseException(untrans_rec->ExceptionCode, untrans_rec->ExceptionFlags,
untrans_rec->NumberParameters, untrans_rec->ExceptionInformation);
}
else
{
RaiseException(prev_rec->ExceptionCode, prev_rec->ExceptionFlags,
prev_rec->NumberParameters, prev_rec->ExceptionInformation);
}
}
__ENDTRY
}
__FINALLY_CTX(cxx_catch_cleanup, &ctx)
unwind_help[0] = -2;
unwind_help[1] = -1;
return ret_addr;
}
static inline BOOL cxx_is_consolidate(const EXCEPTION_RECORD *rec)
{
return rec->ExceptionCode==STATUS_UNWIND_CONSOLIDATE && rec->NumberParameters==8 &&
rec->ExceptionInformation[0]==(ULONG_PTR)call_catch_block;
}
static inline void find_catch_block(EXCEPTION_RECORD *rec, CONTEXT *context,
EXCEPTION_RECORD *untrans_rec,
ULONG64 frame, DISPATCHER_CONTEXT *dispatch,
const cxx_function_descr *descr,
cxx_exception_type *info, ULONG64 orig_frame)
{
ULONG64 exc_base = (rec->NumberParameters == 4 ? rec->ExceptionInformation[3] : 0);
int trylevel = ip_to_state(rva_to_ptr(descr->ipmap, dispatch->ImageBase),
descr->ipmap_count, dispatch->ControlPc-dispatch->ImageBase);
thread_data_t *data = msvcrt_get_thread_data();
const tryblock_info *in_catch;
EXCEPTION_RECORD catch_record;
CONTEXT ctx;
UINT i, j;
INT *unwind_help;
data->processing_throw++;
for (i=descr->tryblock_count; i>0; i--)
{
in_catch = rva_to_ptr(descr->tryblock, dispatch->ImageBase);
in_catch = &in_catch[i-1];
if (trylevel>in_catch->end_level && trylevel<=in_catch->catch_level)
break;
}
if (!i)
in_catch = NULL;
unwind_help = rva_to_ptr(descr->unwind_help, orig_frame);
if (trylevel > unwind_help[1])
unwind_help[0] = unwind_help[1] = trylevel;
else
trylevel = unwind_help[1];
TRACE("current trylevel: %d\n", trylevel);
for (i=0; i<descr->tryblock_count; i++)
{
const tryblock_info *tryblock = rva_to_ptr(descr->tryblock, dispatch->ImageBase);
tryblock = &tryblock[i];
if (trylevel < tryblock->start_level) continue;
if (trylevel > tryblock->end_level) continue;
if (in_catch)
{
if(tryblock->start_level <= in_catch->end_level) continue;
if(tryblock->end_level > in_catch->catch_level) continue;
}
/* got a try block */
for (j=0; j<tryblock->catchblock_count; j++)
{
const catchblock_info *catchblock = rva_to_ptr(tryblock->catchblock, dispatch->ImageBase);
catchblock = &catchblock[j];
if (info)
{
const cxx_type_info *type = find_caught_type(info, exc_base,
rva_to_ptr(catchblock->type_info, dispatch->ImageBase),
catchblock->flags);
if (!type) continue;
TRACE("matched type %p in tryblock %d catchblock %d\n", type, i, j);
/* copy the exception to its destination on the stack */
copy_exception((void*)rec->ExceptionInformation[1],
orig_frame, dispatch, catchblock, type, exc_base);
}
else
{
/* no CXX_EXCEPTION only proceed with a catch(...) block*/
if (catchblock->type_info)
continue;
TRACE("found catch(...) block\n");
}
/* unwind stack and call catch */
memset(&catch_record, 0, sizeof(catch_record));
catch_record.ExceptionCode = STATUS_UNWIND_CONSOLIDATE;
catch_record.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
catch_record.NumberParameters = 8;
catch_record.ExceptionInformation[0] = (ULONG_PTR)call_catch_block;
catch_record.ExceptionInformation[1] = orig_frame;
catch_record.ExceptionInformation[2] = (ULONG_PTR)descr;
catch_record.ExceptionInformation[3] = tryblock->start_level;
catch_record.ExceptionInformation[4] = (ULONG_PTR)rec;
catch_record.ExceptionInformation[5] =
(ULONG_PTR)rva_to_ptr(catchblock->handler, dispatch->ImageBase);
catch_record.ExceptionInformation[6] = (ULONG_PTR)untrans_rec;
catch_record.ExceptionInformation[7] = (ULONG_PTR)context;
RtlUnwindEx((void*)frame, (void*)dispatch->ControlPc, &catch_record, NULL, &ctx, NULL);
}
}
TRACE("no matching catch block found\n");
data->processing_throw--;
}
static LONG CALLBACK se_translation_filter(EXCEPTION_POINTERS *ep, void *c)
{
se_translator_ctx *ctx = (se_translator_ctx *)c;
EXCEPTION_RECORD *rec = ep->ExceptionRecord;
cxx_exception_type *exc_type;
if (rec->ExceptionCode != CXX_EXCEPTION)
{
TRACE("non-c++ exception thrown in SEH handler: %x\n", rec->ExceptionCode);
MSVCRT_terminate();
}
exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
find_catch_block(rec, ep->ContextRecord, ctx->seh_rec, ctx->dest_frame, ctx->dispatch,
ctx->descr, exc_type, ctx->orig_frame);
__DestructExceptionObject(rec);
return ExceptionContinueSearch;
}
static DWORD cxx_frame_handler(EXCEPTION_RECORD *rec, ULONG64 frame,
CONTEXT *context, DISPATCHER_CONTEXT *dispatch,
const cxx_function_descr *descr)
{
int trylevel = ip_to_state(rva_to_ptr(descr->ipmap, dispatch->ImageBase),
descr->ipmap_count, dispatch->ControlPc-dispatch->ImageBase);
cxx_exception_type *exc_type;
ULONG64 orig_frame = frame;
ULONG64 throw_base;
DWORD throw_func_off;
void *throw_func;
UINT i, j;
int unwindlevel = -1;
if (descr->magic<CXX_FRAME_MAGIC_VC6 || descr->magic>CXX_FRAME_MAGIC_VC8)
{
FIXME("unhandled frame magic %x\n", descr->magic);
return ExceptionContinueSearch;
}
if (descr->magic >= CXX_FRAME_MAGIC_VC8 &&
(descr->flags & FUNC_DESCR_SYNCHRONOUS) &&
(rec->ExceptionCode != CXX_EXCEPTION &&
!cxx_is_consolidate(rec) &&
rec->ExceptionCode != STATUS_LONGJUMP))
return ExceptionContinueSearch; /* handle only c++ exceptions */
/* update orig_frame if it's a nested exception */
throw_func_off = RtlLookupFunctionEntry(dispatch->ControlPc, &throw_base, NULL)->BeginAddress;
throw_func = rva_to_ptr(throw_func_off, throw_base);
TRACE("reconstructed handler pointer: %p\n", throw_func);
for (i=descr->tryblock_count; i>0; i--)
{
const tryblock_info *tryblock = rva_to_ptr(descr->tryblock, dispatch->ImageBase);
tryblock = &tryblock[i-1];
if (trylevel>tryblock->end_level && trylevel<=tryblock->catch_level)
{
for (j=0; j<tryblock->catchblock_count; j++)
{
const catchblock_info *catchblock = rva_to_ptr(tryblock->catchblock, dispatch->ImageBase);
catchblock = &catchblock[j];
if (rva_to_ptr(catchblock->handler, dispatch->ImageBase) == throw_func)
{
TRACE("nested exception detected\n");
unwindlevel = tryblock->end_level;
orig_frame = *(ULONG64*)rva_to_ptr(catchblock->frame, frame);
TRACE("setting orig_frame to %lx\n", orig_frame);
}
}
}
}
if (rec->ExceptionFlags & (EH_UNWINDING|EH_EXIT_UNWIND))
{
if (rec->ExceptionFlags & EH_TARGET_UNWIND)
cxx_local_unwind(orig_frame, dispatch, descr,
cxx_is_consolidate(rec) ? rec->ExceptionInformation[3] : trylevel);
else
cxx_local_unwind(orig_frame, dispatch, descr, unwindlevel);
return ExceptionContinueSearch;
}
if (!descr->tryblock_count) return ExceptionContinueSearch;
if (rec->ExceptionCode == CXX_EXCEPTION)
{
exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
if (TRACE_ON(seh))
{
TRACE("handling C++ exception rec %p frame %lx descr %p\n", rec, frame, descr);
dump_exception_type(exc_type, rec->ExceptionInformation[3]);
dump_function_descr(descr, dispatch->ImageBase);
}
}
else
{
thread_data_t *data = msvcrt_get_thread_data();
exc_type = NULL;
TRACE("handling C exception code %x rec %p frame %lx descr %p\n",
rec->ExceptionCode, rec, frame, descr);
if (data->se_translator) {
EXCEPTION_POINTERS except_ptrs;
se_translator_ctx ctx;
ctx.dest_frame = frame;
ctx.orig_frame = orig_frame;
ctx.seh_rec = rec;
ctx.dispatch = dispatch;
ctx.descr = descr;
__TRY
{
except_ptrs.ExceptionRecord = rec;
except_ptrs.ContextRecord = context;
data->se_translator(rec->ExceptionCode, &except_ptrs);
}
__EXCEPT_CTX(se_translation_filter, &ctx)
{
}
__ENDTRY
}
}
find_catch_block(rec, context, NULL, frame, dispatch, descr, exc_type, orig_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.@)
*/
EXCEPTION_DISPOSITION CDECL __CxxFrameHandler( EXCEPTION_RECORD *rec, ULONG64 frame,
CONTEXT *context, DISPATCHER_CONTEXT *dispatch )
{
TRACE( "%p %lx %p %p\n", rec, frame, context, dispatch );
return cxx_frame_handler( rec, frame, context, dispatch,
rva_to_ptr(*(UINT*)dispatch->HandlerData, dispatch->ImageBase) );
}
/*********************************************************************
* __CppXcptFilter (MSVCRT.@)
*/
int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
return _XcptFilter( ex, ptr );
}
/*********************************************************************
* __CxxDetectRethrow (MSVCRT.@)
*/
BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
{
PEXCEPTION_RECORD rec;
if (!ptrs)
return FALSE;
rec = ptrs->ExceptionRecord;
if (rec->ExceptionCode == CXX_EXCEPTION &&
rec->NumberParameters == 4 &&
rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
rec->ExceptionInformation[2])
{
ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
return TRUE;
}
return (msvcrt_get_thread_data()->exc_record == rec);
}
/*********************************************************************
* __CxxQueryExceptionSize (MSVCRT.@)
*/
unsigned int CDECL __CxxQueryExceptionSize(void)
{
return sizeof(cxx_exception_type);
}
/*******************************************************************
* _setjmp (MSVCRT.@)
*/
__ASM_GLOBAL_FUNC( MSVCRT__setjmp,
"jmp " __ASM_NAME("__wine_setjmpex") );
/*******************************************************************
* longjmp (MSVCRT.@)
*/
void __cdecl MSVCRT_longjmp( struct MSVCRT___JUMP_BUFFER *jmp, int retval )
{
EXCEPTION_RECORD rec;
if (!retval) retval = 1;
if (jmp->Frame)
{
rec.ExceptionCode = STATUS_LONGJUMP;
rec.ExceptionFlags = 0;
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = NULL;
rec.NumberParameters = 1;
rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
RtlUnwind( (void *)jmp->Frame, (void *)jmp->Rip, &rec, IntToPtr(retval) );
}
__wine_longjmp( (__wine_jmp_buf *)jmp, retval );
}
#ifndef __REACTOS__ // different file for ntdll
/*******************************************************************
* _local_unwind (MSVCRT.@)
*/
void __cdecl _local_unwind( void *frame, void *target )
{
RtlUnwind( frame, target, NULL, 0 );
}
#endif /* __REACTOS__ */
/*********************************************************************
* _fpieee_flt (MSVCRT.@)
*/
int __cdecl _fpieee_flt(ULONG exception_code, EXCEPTION_POINTERS *ep,
int (__cdecl *handler)(_FPIEEE_RECORD*))
{
FIXME("(%x %p %p) opcode: %s\n", exception_code, ep, handler,
wine_dbgstr_longlong(*(ULONG64*)ep->ContextRecord->Rip));
return EXCEPTION_CONTINUE_SEARCH;
}
#if _MSVCR_VER>=110 && _MSVCR_VER<=120
/*********************************************************************
* __crtCapturePreviousContext (MSVCR110.@)
*/
void __cdecl get_prev_context(CONTEXT *ctx, DWORD64 rip)
{
ULONG64 frame, image_base;
RUNTIME_FUNCTION *rf;
void *data;
TRACE("(%p)\n", ctx);
rf = RtlLookupFunctionEntry(ctx->Rip, &image_base, NULL);
if(!rf) {
FIXME("RtlLookupFunctionEntry failed\n");
return;
}
RtlVirtualUnwind(UNW_FLAG_NHANDLER, image_base, ctx->Rip,
rf, ctx, &data, &frame, NULL);
}
__ASM_GLOBAL_FUNC( __crtCapturePreviousContext,
"movq %rcx,8(%rsp)\n\t"
"call " __ASM_NAME("RtlCaptureContext") "\n\t"
"movq 8(%rsp),%rcx\n\t" /* context */
"leaq 8(%rsp),%rax\n\t"
"movq %rax,0x98(%rcx)\n\t" /* context->Rsp */
"movq (%rsp),%rax\n\t"
"movq %rax,0xf8(%rcx)\n\t" /* context->Rip */
"jmp " __ASM_NAME("get_prev_context") )
#endif
#endif /* __x86_64__ */

1494
sdk/lib/crt/wine/msvcrt.h Normal file

File diff suppressed because it is too large Load diff

74
sdk/lib/crt/wine/mtdll.h Normal file
View file

@ -0,0 +1,74 @@
/*
* Copyright (c) 2002, TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef WINE_MTDLL_H
#define WINE_MTDLL_H
#if defined(_MT)
#define _mlock(locknum) _lock(locknum)
#define _munlock(locknum) _unlock(locknum)
void __cdecl _unlock( int locknum );
void __cdecl _lock( int locknum );
#else
#define _mlock(locknum) do {} while(0)
#define _munlock(locknum) do {} while(0)
#endif
#define _SIGNAL_LOCK 1
#define _IOB_SCAN_LOCK 2
#define _TMPNAM_LOCK 3
#define _INPUT_LOCK 4
#define _OUTPUT_LOCK 5
#define _CSCANF_LOCK 6
#define _CPRINTF_LOCK 7
#define _CONIO_LOCK 8
#define _HEAP_LOCK 9
#define _BHEAP_LOCK 10 /* No longer used? */
#define _TIME_LOCK 11
#define _ENV_LOCK 12
#define _EXIT_LOCK1 13
#define _EXIT_LOCK2 14
#define _THREADDATA_LOCK 15 /* No longer used? */
#define _POPEN_LOCK 16
#define _LOCKTAB_LOCK 17
#define _OSFHND_LOCK 18
#define _SETLOCALE_LOCK 19
#define _LC_COLLATE_LOCK 20 /* No longer used? */
#define _LC_CTYPE_LOCK 21 /* No longer used? */
#define _LC_MONETARY_LOCK 22 /* No longer used? */
#define _LC_NUMERIC_LOCK 23 /* No longer used? */
#define _LC_TIME_LOCK 24 /* No longer used? */
#define _MB_CP_LOCK 25
#define _NLG_LOCK 26
#define _TYPEINFO_LOCK 27
#define _STREAM_LOCKS 28
/* Must match definition in msvcrt/stdio.h */
#define _IOB_ENTRIES 20
#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_IOB_ENTRIES-1)
#define _TOTAL_LOCKS (_LAST_STREAM_LOCK+1)
#endif /* WINE_MTDLL_H */

313
sdk/lib/crt/wine/winternl.h Normal file
View file

@ -0,0 +1,313 @@
/*
* Internal NT APIs and data structures
*
* Copyright (C) the Wine project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_WINTERNL_H
#define __WINE_WINTERNL_H
#ifndef __REACTOS__
#include <ntdef.h>
#endif /* __REACTOS__ */
#include <windef.h>
#include <windef.h>
#ifdef __cplusplus
extern "C" {
#endif /* defined(__cplusplus) */
#ifndef WINE_NTSTATUS_DECLARED
#define WINE_NTSTATUS_DECLARED
typedef LONG NTSTATUS;
#endif
#ifndef __UNICODE_STRING_DEFINED__
#define __UNICODE_STRING_DEFINED__
typedef struct _UNICODE_STRING {
USHORT Length; /* bytes */
USHORT MaximumLength; /* bytes */
PWSTR Buffer;
} UNICODE_STRING, * PUNICODE_STRING;
#endif
typedef struct _CLIENT_ID
{
HANDLE UniqueProcess;
HANDLE UniqueThread;
} CLIENT_ID, * PCLIENT_ID;
typedef struct _CURDIR
{
UNICODE_STRING DosPath;
PVOID Handle;
} CURDIR, * PCURDIR;
typedef struct RTL_DRIVE_LETTER_CURDIR
{
USHORT Flags;
USHORT Length;
ULONG TimeStamp;
UNICODE_STRING DosPath;
} RTL_DRIVE_LETTER_CURDIR, * PRTL_DRIVE_LETTER_CURDIR;
typedef struct tagRTL_BITMAP {
ULONG SizeOfBitMap; /* Number of bits in the bitmap */
PULONG Buffer; /* Bitmap data, assumed sized to a DWORD boundary */
} RTL_BITMAP, * PRTL_BITMAP;
typedef const RTL_BITMAP* PCRTL_BITMAP;
typedef struct _RTL_USER_PROCESS_PARAMETERS
{
ULONG AllocationSize;
ULONG Size;
ULONG Flags;
ULONG DebugFlags;
HANDLE ConsoleHandle;
ULONG ConsoleFlags;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
CURDIR CurrentDirectory;
UNICODE_STRING DllPath;
UNICODE_STRING ImagePathName;
UNICODE_STRING CommandLine;
PWSTR Environment;
ULONG dwX;
ULONG dwY;
ULONG dwXSize;
ULONG dwYSize;
ULONG dwXCountChars;
ULONG dwYCountChars;
ULONG dwFillAttribute;
ULONG dwFlags;
ULONG wShowWindow;
UNICODE_STRING WindowTitle;
UNICODE_STRING Desktop;
UNICODE_STRING ShellInfo;
UNICODE_STRING RuntimeInfo;
RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
} RTL_USER_PROCESS_PARAMETERS, * PRTL_USER_PROCESS_PARAMETERS;
typedef struct _PEB_LDR_DATA
{
ULONG Length;
BOOLEAN Initialized;
PVOID SsHandle;
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;
LIST_ENTRY InInitializationOrderModuleList;
PVOID EntryInProgress;
} PEB_LDR_DATA, * PPEB_LDR_DATA;
typedef struct _GDI_TEB_BATCH
{
ULONG Offset;
HANDLE HDC;
ULONG Buffer[0x136];
} GDI_TEB_BATCH;
typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME
{
struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME* Previous;
struct _ACTIVATION_CONTEXT* ActivationContext;
ULONG Flags;
} RTL_ACTIVATION_CONTEXT_STACK_FRAME, * PRTL_ACTIVATION_CONTEXT_STACK_FRAME;
typedef struct _ACTIVATION_CONTEXT_STACK
{
ULONG Flags;
ULONG NextCookieSequenceNumber;
RTL_ACTIVATION_CONTEXT_STACK_FRAME* ActiveFrame;
LIST_ENTRY FrameListCache;
} ACTIVATION_CONTEXT_STACK, * PACTIVATION_CONTEXT_STACK;
typedef struct _TEB_ACTIVE_FRAME_CONTEXT
{
ULONG Flags;
const char* FrameName;
} TEB_ACTIVE_FRAME_CONTEXT, * PTEB_ACTIVE_FRAME_CONTEXT;
typedef struct _TEB_ACTIVE_FRAME
{
ULONG Flags;
struct _TEB_ACTIVE_FRAME* Previous;
TEB_ACTIVE_FRAME_CONTEXT* Context;
} TEB_ACTIVE_FRAME, * PTEB_ACTIVE_FRAME;
typedef struct _PEB
{ /* win32/win64 */
BOOLEAN InheritedAddressSpace; /* 000/000 */
BOOLEAN ReadImageFileExecOptions; /* 001/001 */
BOOLEAN BeingDebugged; /* 002/002 */
BOOLEAN SpareBool; /* 003/003 */
HANDLE Mutant; /* 004/008 */
HMODULE ImageBaseAddress; /* 008/010 */
PPEB_LDR_DATA LdrData; /* 00c/018 */
RTL_USER_PROCESS_PARAMETERS* ProcessParameters; /* 010/020 */
PVOID SubSystemData; /* 014/028 */
HANDLE ProcessHeap; /* 018/030 */
PRTL_CRITICAL_SECTION FastPebLock; /* 01c/038 */
PVOID /*PPEBLOCKROUTINE*/ FastPebLockRoutine; /* 020/040 */
PVOID /*PPEBLOCKROUTINE*/ FastPebUnlockRoutine; /* 024/048 */
ULONG EnvironmentUpdateCount; /* 028/050 */
PVOID KernelCallbackTable; /* 02c/058 */
ULONG Reserved[2]; /* 030/060 */
PVOID /*PPEB_FREE_BLOCK*/ FreeList; /* 038/068 */
ULONG TlsExpansionCounter; /* 03c/070 */
PRTL_BITMAP TlsBitmap; /* 040/078 */
ULONG TlsBitmapBits[2]; /* 044/080 */
PVOID ReadOnlySharedMemoryBase; /* 04c/088 */
PVOID ReadOnlySharedMemoryHeap; /* 050/090 */
PVOID* ReadOnlyStaticServerData; /* 054/098 */
PVOID AnsiCodePageData; /* 058/0a0 */
PVOID OemCodePageData; /* 05c/0a8 */
PVOID UnicodeCaseTableData; /* 060/0b0 */
ULONG NumberOfProcessors; /* 064/0b8 */
ULONG NtGlobalFlag; /* 068/0bc */
LARGE_INTEGER CriticalSectionTimeout; /* 070/0c0 */
SIZE_T HeapSegmentReserve; /* 078/0c8 */
SIZE_T HeapSegmentCommit; /* 07c/0d0 */
SIZE_T HeapDeCommitTotalFreeThreshold; /* 080/0d8 */
SIZE_T HeapDeCommitFreeBlockThreshold; /* 084/0e0 */
ULONG NumberOfHeaps; /* 088/0e8 */
ULONG MaximumNumberOfHeaps; /* 08c/0ec */
PVOID* ProcessHeaps; /* 090/0f0 */
PVOID GdiSharedHandleTable; /* 094/0f8 */
PVOID ProcessStarterHelper; /* 098/100 */
PVOID GdiDCAttributeList; /* 09c/108 */
PVOID LoaderLock; /* 0a0/110 */
ULONG OSMajorVersion; /* 0a4/118 */
ULONG OSMinorVersion; /* 0a8/11c */
ULONG OSBuildNumber; /* 0ac/120 */
ULONG OSPlatformId; /* 0b0/124 */
ULONG ImageSubSystem; /* 0b4/128 */
ULONG ImageSubSystemMajorVersion; /* 0b8/12c */
ULONG ImageSubSystemMinorVersion; /* 0bc/130 */
ULONG ImageProcessAffinityMask; /* 0c0/134 */
HANDLE GdiHandleBuffer[28]; /* 0c4/138 */
ULONG unknown[6]; /* 134/218 */
PVOID PostProcessInitRoutine; /* 14c/230 */
PRTL_BITMAP TlsExpansionBitmap; /* 150/238 */
ULONG TlsExpansionBitmapBits[32]; /* 154/240 */
ULONG SessionId; /* 1d4/2c0 */
ULARGE_INTEGER AppCompatFlags; /* 1d8/2c8 */
ULARGE_INTEGER AppCompatFlagsUser; /* 1e0/2d0 */
PVOID ShimData; /* 1e8/2d8 */
PVOID AppCompatInfo; /* 1ec/2e0 */
UNICODE_STRING CSDVersion; /* 1f0/2e8 */
PVOID ActivationContextData; /* 1f8/2f8 */
PVOID ProcessAssemblyStorageMap; /* 1fc/300 */
PVOID SystemDefaultActivationData; /* 200/308 */
PVOID SystemAssemblyStorageMap; /* 204/310 */
SIZE_T MinimumStackCommit; /* 208/318 */
PVOID* FlsCallback; /* 20c/320 */
LIST_ENTRY FlsListHead; /* 210/328 */
PRTL_BITMAP FlsBitmap; /* 218/338 */
ULONG FlsBitmapBits[4]; /* 21c/340 */
} PEB, * PPEB;
typedef struct _TEB
{ /* win32/win64 */
NT_TIB Tib; /* 000/0000 */
PVOID EnvironmentPointer; /* 01c/0038 */
CLIENT_ID ClientId; /* 020/0040 */
PVOID ActiveRpcHandle; /* 028/0050 */
PVOID ThreadLocalStoragePointer; /* 02c/0058 */
PPEB Peb; /* 030/0060 */
ULONG LastErrorValue; /* 034/0068 */
ULONG CountOfOwnedCriticalSections; /* 038/006c */
PVOID CsrClientThread; /* 03c/0070 */
PVOID Win32ThreadInfo; /* 040/0078 */
ULONG Win32ClientInfo[31]; /* 044/0080 used for user32 private data in Wine */
PVOID WOW32Reserved; /* 0c0/0100 */
ULONG CurrentLocale; /* 0c4/0108 */
ULONG FpSoftwareStatusRegister; /* 0c8/010c */
PVOID SystemReserved1[54]; /* 0cc/0110 used for kernel32 private data in Wine */
LONG ExceptionCode; /* 1a4/02c0 */
ACTIVATION_CONTEXT_STACK ActivationContextStack; /* 1a8/02c8 */
BYTE SpareBytes1[24]; /* 1bc/02e8 */
PVOID SystemReserved2[10]; /* 1d4/0300 used for ntdll platform-specific private data in Wine */
GDI_TEB_BATCH GdiTebBatch; /* 1fc/0350 used for ntdll private data in Wine */
HANDLE gdiRgn; /* 6dc/0838 */
HANDLE gdiPen; /* 6e0/0840 */
HANDLE gdiBrush; /* 6e4/0848 */
CLIENT_ID RealClientId; /* 6e8/0850 */
HANDLE GdiCachedProcessHandle; /* 6f0/0860 */
ULONG GdiClientPID; /* 6f4/0868 */
ULONG GdiClientTID; /* 6f8/086c */
PVOID GdiThreadLocaleInfo; /* 6fc/0870 */
ULONG UserReserved[5]; /* 700/0878 */
PVOID glDispatchTable[280]; /* 714/0890 */
PVOID glReserved1[26]; /* b74/1150 */
PVOID glReserved2; /* bdc/1220 */
PVOID glSectionInfo; /* be0/1228 */
PVOID glSection; /* be4/1230 */
PVOID glTable; /* be8/1238 */
PVOID glCurrentRC; /* bec/1240 */
PVOID glContext; /* bf0/1248 */
ULONG LastStatusValue; /* bf4/1250 */
UNICODE_STRING StaticUnicodeString; /* bf8/1258 used by advapi32 */
WCHAR StaticUnicodeBuffer[261]; /* c00/1268 used by advapi32 */
PVOID DeallocationStack; /* e0c/1478 */
PVOID TlsSlots[64]; /* e10/1480 */
LIST_ENTRY TlsLinks; /* f10/1680 */
PVOID Vdm; /* f18/1690 */
PVOID ReservedForNtRpc; /* f1c/1698 */
PVOID DbgSsReserved[2]; /* f20/16a0 */
ULONG HardErrorDisabled; /* f28/16b0 */
PVOID Instrumentation[16]; /* f2c/16b8 */
PVOID WinSockData; /* f6c/1738 */
ULONG GdiBatchCount; /* f70/1740 */
ULONG Spare2; /* f74/1744 */
ULONG GuaranteedStackBytes; /* f78/1748 */
PVOID ReservedForPerf; /* f7c/1750 */
PVOID ReservedForOle; /* f80/1758 */
ULONG WaitingOnLoaderLock; /* f84/1760 */
PVOID Reserved5[3]; /* f88/1768 */
PVOID* TlsExpansionSlots; /* f94/1780 */
#ifdef _WIN64
PVOID DeallocationBStore; /* /1788 */
PVOID BStoreLimit; /* /1790 */
#endif
ULONG ImpersonationLocale; /* f98/1798 */
ULONG IsImpersonating; /* f9c/179c */
PVOID NlsCache; /* fa0/17a0 */
PVOID ShimData; /* fa4/17a8 */
ULONG HeapVirtualAffinity; /* fa8/17b0 */
PVOID CurrentTransactionHandle; /* fac/17b8 */
TEB_ACTIVE_FRAME* ActiveFrame; /* fb0/17c0 */
PVOID* FlsSlots; /* fb4/17c8 */
} TEB, * PTEB;
NTSYSAPI PVOID WINAPI RtlAllocateHeap(HANDLE, ULONG, SIZE_T) __WINE_ALLOC_SIZE(3);
NTSYSAPI BOOLEAN WINAPI RtlAreBitsSet(PCRTL_BITMAP, ULONG, ULONG);
NTSYSAPI BOOLEAN WINAPI RtlAreBitsClear(PCRTL_BITMAP, ULONG, ULONG);
NTSYSAPI BOOLEAN WINAPI RtlFreeHeap(HANDLE, ULONG, PVOID);
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG);
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG);
#define ARRAY_SIZE ARRAYSIZE
#define MSVCRT_free free
#define MSVCRT_malloc malloc
//#define MSVCRT_terminate terminate
#define MSVCRT__exit exit
#define MSVCRT_abort abort
#endif /* __WINE_WINTERNL_H */