mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:13:06 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
32
sdk/lib/crt/except/amd64/chkstk_asm.s
Normal file
32
sdk/lib/crt/except/amd64/chkstk_asm.s
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* PURPOSE: Implementation of _chkstk and _alloca_probe
|
||||
* FILE: lib/sdk/crt/except/amd64/chkstk_asm.s
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
.code64
|
||||
|
||||
MsgUnimplemented:
|
||||
.ascii "Unimplemented", CR, LF, NUL
|
||||
|
||||
FUNC __chkstk
|
||||
.endprolog
|
||||
UNIMPLEMENTED chkstk
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC __alloca_probe
|
||||
.endprolog
|
||||
UNIMPLEMENTED alloca_probe
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
END
|
||||
/* EOF */
|
51
sdk/lib/crt/except/amd64/chkstk_ms.s
Normal file
51
sdk/lib/crt/except/amd64/chkstk_ms.s
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* PURPOSE: Implementation of _chkstk and _alloca_probe
|
||||
* PROGRAMMERS Richard Henderson <rth@redhat.com>
|
||||
* Kai Tietz <kai.tietz@onevision.com>
|
||||
* Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
.code64
|
||||
|
||||
PUBLIC ___chkstk_ms
|
||||
|
||||
//cfi_startproc()
|
||||
___chkstk_ms:
|
||||
push rcx /* save temps */
|
||||
//cfi_push(%rcx)
|
||||
push rax
|
||||
//cfi_push(%rax)
|
||||
|
||||
cmp rax, PAGE_SIZE /* > 4k ?*/
|
||||
lea rcx, [rsp + 24] /* point past return addr */
|
||||
jb l_LessThanAPage
|
||||
|
||||
l_MoreThanAPage:
|
||||
sub rcx, PAGE_SIZE /* yes, move pointer down 4k */
|
||||
or byte ptr [rcx], 0 /* probe there */
|
||||
sub rax, PAGE_SIZE /* decrement count */
|
||||
|
||||
cmp rax, PAGE_SIZE
|
||||
ja l_MoreThanAPage /* and do it again */
|
||||
|
||||
l_LessThanAPage:
|
||||
sub rcx, rax
|
||||
or byte ptr [rcx], 0 /* less than 4k, just peek here */
|
||||
|
||||
pop rax
|
||||
//cfi_pop(%rax)
|
||||
pop rcx
|
||||
//cfi_pop(%rcx)
|
||||
ret
|
||||
//cfi_endproc()
|
||||
|
||||
END
|
||||
/* EOF */
|
85
sdk/lib/crt/except/amd64/cpp.s
Normal file
85
sdk/lib/crt/except/amd64/cpp.s
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
.code64
|
||||
.align 4
|
||||
|
||||
MACRO(START_VTABLE, shortname, cxxname)
|
||||
EXTERN shortname&_rtti:PROC
|
||||
EXTERN MSVCRT_&shortname&_vector_dtor:PROC
|
||||
.double shortname&_rtti
|
||||
PUBLIC MSVCRT_&shortname&_vtable
|
||||
MSVCRT_&shortname&_vtable:
|
||||
PUBLIC &cxxname
|
||||
&cxxname:
|
||||
.double MSVCRT_&shortname&_vector_dtor
|
||||
ENDM
|
||||
|
||||
MACRO(DEFINE_EXCEPTION_VTABLE, shortname, cxxname)
|
||||
START_VTABLE shortname, cxxname
|
||||
EXTERN MSVCRT_what_exception:ABS
|
||||
.double MSVCRT_what_exception
|
||||
ENDM
|
||||
|
||||
START_VTABLE type_info, __dummyname_type_info
|
||||
DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
|
||||
|
||||
|
||||
MACRO(DEFINE_ALIAS, alias, orig)
|
||||
EXTERN &orig:ABS
|
||||
ALIAS <&alias> = <&orig>
|
||||
ENDM
|
||||
|
||||
DEFINE_ALIAS ??3@YAXPEAX@Z, MSVCRT_operator_delete
|
||||
DEFINE_ALIAS ??_U@YAPEAX_K@Z, MSVCRT_operator_new
|
||||
DEFINE_ALIAS ??_V@YAXPEAX@Z, MSVCRT_operator_delete
|
||||
DEFINE_ALIAS ??2@YAPEAX_K@Z, MSVCRT_operator_new
|
||||
DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, MSVCRT__query_new_handler
|
||||
DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, MSVCRT__set_new_handler
|
||||
DEFINE_ALIAS ?set_new_handler@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_new_handler
|
||||
DEFINE_ALIAS ?_query_new_mode@@YAHXZ, MSVCRT__query_new_mode
|
||||
DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, MSVCRT__set_new_mode
|
||||
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator
|
||||
DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_terminate
|
||||
DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_unexpected
|
||||
DEFINE_ALIAS ?terminate@@YAXXZ, MSVCRT_terminate
|
||||
DEFINE_ALIAS ?unexpected@@YAXXZ, MSVCRT_unexpected
|
||||
DEFINE_ALIAS ?what@exception@@UEBAPEBDXZ, MSVCRT_what_exception
|
||||
DEFINE_ALIAS ??0exception@@QEAA@AEBQEBDH@Z, MSVCRT_exception_ctor_noalloc
|
||||
DEFINE_ALIAS ??0exception@@QEAA@AEBV0@@Z, MSVCRT_exception_copy_ctor
|
||||
DEFINE_ALIAS ??0exception@@QEAA@XZ, MSVCRT_exception_default_ctor
|
||||
DEFINE_ALIAS ??1exception@@UEAA@XZ, MSVCRT_exception_dtor
|
||||
DEFINE_ALIAS ??4exception@@QEAAAEAV0@AEBV0@@Z, MSVCRT_exception_opequals
|
||||
DEFINE_ALIAS ??1type_info@@UEAA@XZ, MSVCRT_type_info_dtor
|
||||
DEFINE_ALIAS ??0__non_rtti_object@@QEAA@AEBV0@@Z, MSVCRT___non_rtti_object_copy_ctor
|
||||
DEFINE_ALIAS ??0__non_rtti_object@@QEAA@PEBD@Z, MSVCRT___non_rtti_object_ctor
|
||||
DEFINE_ALIAS ??0bad_cast@@AEAA@PEBQEBD@Z, MSVCRT_bad_cast_ctor
|
||||
DEFINE_ALIAS ??0bad_cast@@QEAA@AEBQEBD@Z, MSVCRT_bad_cast_ctor
|
||||
DEFINE_ALIAS ??0bad_cast@@QEAA@AEBV0@@Z, MSVCRT_bad_cast_copy_ctor
|
||||
DEFINE_ALIAS ??0bad_cast@@QEAA@PEBD@Z, MSVCRT_bad_cast_ctor_charptr
|
||||
DEFINE_ALIAS ??0bad_typeid@@QEAA@AEBV0@@Z, MSVCRT_bad_typeid_copy_ctor
|
||||
DEFINE_ALIAS ??0bad_typeid@@QEAA@PEBD@Z, MSVCRT_bad_typeid_ctor
|
||||
DEFINE_ALIAS ??0exception@@QEAA@AEBQEBD@Z, MSVCRT_exception_ctor
|
||||
DEFINE_ALIAS ??1__non_rtti_object@@UEAA@XZ, MSVCRT___non_rtti_object_dtor
|
||||
DEFINE_ALIAS ??1bad_cast@@UEAA@XZ, MSVCRT_bad_cast_dtor
|
||||
DEFINE_ALIAS ??1bad_typeid@@UEAA@XZ, MSVCRT_bad_typeid_dtor
|
||||
DEFINE_ALIAS ??4bad_cast@@QEAAAEAV0@AEBV0@@Z, MSVCRT_bad_cast_opequals
|
||||
DEFINE_ALIAS ??4bad_typeid@@QEAAAEAV0@AEBV0@@Z, MSVCRT_bad_typeid_opequals
|
||||
DEFINE_ALIAS ??8type_info@@QEBAHAEBV0@@Z, MSVCRT_type_info_opequals_equals
|
||||
DEFINE_ALIAS ??9type_info@@QEBAHAEBV0@@Z, MSVCRT_type_info_opnot_equals
|
||||
DEFINE_ALIAS ??_Fbad_cast@@QEAAXXZ, MSVCRT_bad_cast_default_ctor
|
||||
DEFINE_ALIAS ??_Fbad_typeid@@QEAAXXZ, MSVCRT_bad_typeid_default_ctor
|
||||
DEFINE_ALIAS ?_query_new_handler@@YAP6AH_K@ZXZ, MSVCRT__query_new_handler
|
||||
DEFINE_ALIAS ?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z, MSVCRT__set_new_handler
|
||||
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPEAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator
|
||||
DEFINE_ALIAS ?before@type_info@@QEBAHAEBV1@@Z, MSVCRT_type_info_before
|
||||
DEFINE_ALIAS ?name@type_info@@QEBAPEBDXZ, MSVCRT_type_info_name
|
||||
DEFINE_ALIAS ?raw_name@type_info@@QEBAPEBDXZ, MSVCRT_type_info_raw_name
|
||||
DEFINE_ALIAS ??4__non_rtti_object@@QEAAAEAV0@AEBV0@@Z, MSVCRT___non_rtti_object_opequals
|
||||
|
||||
END
|
||||
|
30
sdk/lib/crt/except/amd64/ehandler.c
Normal file
30
sdk/lib/crt/except/amd64/ehandler.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
#include <precomp.h>
|
||||
|
||||
|
||||
_CRTIMP
|
||||
EXCEPTION_DISPOSITION
|
||||
__cdecl
|
||||
__C_specific_handler(
|
||||
struct _EXCEPTION_RECORD *_ExceptionRecord,
|
||||
void *_EstablisherFrame,
|
||||
struct _CONTEXT *_ContextRecord,
|
||||
struct _DISPATCHER_CONTEXT *_DispatcherContext)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
__debugbreak();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
__CxxFrameHandler(
|
||||
PEXCEPTION_RECORD rec,
|
||||
EXCEPTION_REGISTRATION_RECORD* ExceptionRegistrationFrame,
|
||||
PCONTEXT context,
|
||||
EXCEPTION_REGISTRATION_RECORD** _ExceptionRecord)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
__debugbreak();
|
||||
return 0;
|
||||
}
|
||||
|
65
sdk/lib/crt/except/amd64/seh.s
Normal file
65
sdk/lib/crt/except/amd64/seh.s
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CRT
|
||||
* FILE: lib/sdk/crt/except/amd64/seh.s
|
||||
* PURPOSE: SEH Support for the CRT
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
#define DISPOSITION_DISMISS 0
|
||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||
#define DISPOSITION_COLLIDED_UNWIND 3
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
PUBLIC _global_unwind2
|
||||
PUBLIC _local_unwind
|
||||
PUBLIC _local_unwind2
|
||||
PUBLIC _abnormal_termination
|
||||
PUBLIC _except_handler2
|
||||
PUBLIC _except_handler3
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
.code64
|
||||
|
||||
FUNC _unwind_handler
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC _global_unwind2
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC _abnormal_termination
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC _local_unwind
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC _local_unwind2
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC _except_handler2
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
FUNC _except_handler3
|
||||
.endprolog
|
||||
ret
|
||||
ENDFUNC
|
||||
|
||||
END
|
21
sdk/lib/crt/except/arm/__jump_unwind.s
Normal file
21
sdk/lib/crt/except/arm/__jump_unwind.s
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT library
|
||||
* PURPOSE: Implementation of __jump_unwind
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY __jump_unwind
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END __jump_unwind
|
||||
|
||||
END
|
||||
/* EOF */
|
21
sdk/lib/crt/except/arm/_abnormal_termination.s
Normal file
21
sdk/lib/crt/except/arm/_abnormal_termination.s
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _abnormal_termination
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY _abnormal_termination
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END _abnormal_termination
|
||||
|
||||
END
|
||||
/* EOF */
|
21
sdk/lib/crt/except/arm/_except_handler2.s
Normal file
21
sdk/lib/crt/except/arm/_except_handler2.s
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _except_handler2
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY _except_handler2
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END _except_handler2
|
||||
|
||||
END
|
||||
/* EOF */
|
21
sdk/lib/crt/except/arm/_except_handler3.s
Normal file
21
sdk/lib/crt/except/arm/_except_handler3.s
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _except_handler3
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY _except_handler3
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END _except_handler3
|
||||
|
||||
END
|
||||
/* EOF */
|
21
sdk/lib/crt/except/arm/_global_unwind2.s
Normal file
21
sdk/lib/crt/except/arm/_global_unwind2.s
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _global_unwind2
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY _global_unwind2
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END _global_unwind2
|
||||
|
||||
END
|
||||
/* EOF */
|
21
sdk/lib/crt/except/arm/_local_unwind2.s
Normal file
21
sdk/lib/crt/except/arm/_local_unwind2.s
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _local_unwind2
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY _local_unwind2
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END _local_unwind2
|
||||
|
||||
END
|
||||
/* EOF */
|
27
sdk/lib/crt/except/arm/chkstk_asm.s
Normal file
27
sdk/lib/crt/except/arm/chkstk_asm.s
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _chkstk and _alloca_probe
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
* Yuntian Zhang (yuntian.zh@gmail.com)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY __chkstk
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END __chkstk
|
||||
|
||||
LEAF_ENTRY __alloca_probe
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END __alloca_probe
|
||||
|
||||
END
|
||||
/* EOF */
|
27
sdk/lib/crt/except/arm/chkstk_ms.s
Normal file
27
sdk/lib/crt/except/arm/chkstk_ms.s
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT librariy
|
||||
* PURPOSE: Implementation of _chkstk and _alloca_probe
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
* Yuntian Zhang (yuntian.zh@gmail.com)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
TEXTAREA
|
||||
|
||||
LEAF_ENTRY ___chkstk_ms
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END __chkstk_ms
|
||||
|
||||
LEAF_ENTRY __alloca_probe
|
||||
__assertfail
|
||||
bx lr
|
||||
LEAF_END __alloca_probe
|
||||
|
||||
END
|
||||
/* EOF */
|
113
sdk/lib/crt/except/arm/cpp.s
Normal file
113
sdk/lib/crt/except/arm/cpp.s
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
||||
* PROJECT: ReactOS CRT library
|
||||
* PURPOSE: MSVC wrappers for C++ functions
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <kxarm.h>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
|
||||
TEXTAREA
|
||||
|
||||
MACRO
|
||||
DEFINE_ALIAS $FuncName, $Target
|
||||
LCLS _FuncName
|
||||
LCLS _Target
|
||||
_FuncName SETS "|$FuncName|"
|
||||
_Target SETS "|$Target|"
|
||||
IMPORT $_FuncName, WEAK $_Target
|
||||
MEND
|
||||
|
||||
DEFINE_ALIAS ??0__non_rtti_object@@QAA@ABV0@@Z, MSVCRT___non_rtti_object_copy_ctor
|
||||
DEFINE_ALIAS ??0__non_rtti_object@@QAA@PBD@Z, MSVCRT___non_rtti_object_ctor
|
||||
DEFINE_ALIAS ??0bad_cast@@AAA@PBQBD@Z, MSVCRT_bad_cast_ctor // private: __cdecl bad_cast::bad_cast(char const * const *)
|
||||
DEFINE_ALIAS ??0bad_cast@@QAA@ABV0@@Z, MSVCRT_bad_cast_copy_ctor // public: __cdecl bad_cast::bad_cast(class bad_cast const &)
|
||||
DEFINE_ALIAS ??0bad_cast@@QAA@PBD@Z, MSVCRT_bad_cast_ctor // public: __cdecl bad_cast::bad_cast(char const *)
|
||||
DEFINE_ALIAS ??0bad_typeid@@QAA@ABV0@@Z, MSVCRT_bad_typeid_copy_ctor // public: __cdecl bad_typeid::bad_typeid(class bad_typeid const &)
|
||||
DEFINE_ALIAS ??0bad_typeid@@QAA@PBD@Z, MSVCRT_bad_typeid_ctor // public: __cdecl bad_typeid::bad_typeid(char const *)
|
||||
DEFINE_ALIAS ??0exception@@QAA@ABQBD@Z, MSVCRT_exception_ctor // public: __cdecl exception::exception(char const * const &)
|
||||
DEFINE_ALIAS ??0exception@@QAA@ABQBDH@Z, MSVCRT_exception_ctor_noalloc // public: __cdecl exception::exception(char const * const &,int)
|
||||
DEFINE_ALIAS ??0exception@@QAA@ABV0@@Z, MSVCRT_exception_copy_ctor // public: __cdecl exception::exception(class exception const &)
|
||||
DEFINE_ALIAS ??0exception@@QAA@XZ, MSVCRT_exception_default_ctor // public: __cdecl exception::exception(void)
|
||||
DEFINE_ALIAS ??1__non_rtti_object@@UAA@XZ, MSVCRT___non_rtti_object_dtor // public: virtual __cdecl __non_rtti_object::~__non_rtti_object(void)
|
||||
DEFINE_ALIAS ??1bad_cast@@UAA@XZ, MSVCRT_bad_cast_dtor // public: virtual __cdecl bad_cast::~bad_cast(void)
|
||||
DEFINE_ALIAS ??1bad_typeid@@UAA@XZ, MSVCRT_bad_typeid_dtor // public: virtual __cdecl bad_typeid::~bad_typeid(void)
|
||||
DEFINE_ALIAS ??1exception@@UAA@XZ, MSVCRT_exception_dtor // public: virtual __cdecl exception::~exception(void)
|
||||
DEFINE_ALIAS ??1type_info@@UAA@XZ, MSVCRT_type_info_dtor // public: virtual __cdecl type_info::~type_info(void)
|
||||
DEFINE_ALIAS ??2@YAPAXI@Z, MSVCRT_operator_new // void * __cdecl operator new(unsigned int)
|
||||
DEFINE_ALIAS ??2@YAPAXIHPBDH@Z, MSVCRT_operator_new_dbg // void * __cdecl operator new(unsigned int,int,char const *,int)
|
||||
DEFINE_ALIAS ??3@YAXPAX@Z, MSVCRT_operator_delete // void __cdecl operator delete(void *)
|
||||
DEFINE_ALIAS ??4__non_rtti_object@@QAAAAV0@ABV0@@Z, MSVCRT___non_rtti_object_opequals // public: class __non_rtti_object & __cdecl __non_rtti_object::operator=(class __non_rtti_object const &)
|
||||
DEFINE_ALIAS ??4bad_cast@@QAAAAV0@ABV0@@Z, MSVCRT_bad_cast_opequals // public: class bad_cast & __cdecl bad_cast::operator=(class bad_cast const &)
|
||||
DEFINE_ALIAS ??4bad_typeid@@QAAAAV0@ABV0@@Z, MSVCRT_bad_typeid_opequals // public: class bad_typeid & __cdecl bad_typeid::operator=(class bad_typeid const &)
|
||||
DEFINE_ALIAS ??4exception@@QAAAAV0@ABV0@@Z, MSVCRT_exception_opequals // public: class exception & __cdecl exception::operator=(class exception const &)
|
||||
DEFINE_ALIAS ??8type_info@@QBAHABV0@@Z, MSVCRT_type_info_opequals_equals // public: int __cdecl type_info::operator==(class type_info const &)const
|
||||
DEFINE_ALIAS ??9type_info@@QBAHABV0@@Z, MSVCRT_type_info_opnot_equals // public: int __cdecl type_info::operator!=(class type_info const &)const
|
||||
DEFINE_ALIAS ??_Fbad_cast@@QAAXXZ, MSVCRT_bad_cast_default_ctor // public: void __cdecl bad_cast::`default constructor closure'(void)
|
||||
DEFINE_ALIAS ??_Fbad_typeid@@QAAXXZ, MSVCRT_bad_typeid_default_ctor // public: void __cdecl bad_typeid::`default constructor closure'(void)
|
||||
DEFINE_ALIAS ??_U@YAPAXI@Z, MSVCRT_operator_new // void * __cdecl operator new[](unsigned int)
|
||||
DEFINE_ALIAS ??_U@YAPAXIHPBDH@Z, MSVCRT_operator_new_dbg // void * __cdecl operator new[](unsigned int,int,char const *,int)
|
||||
DEFINE_ALIAS ??_V@YAXPAX@Z, MSVCRT_operator_delete // void __cdecl operator delete[](void *)
|
||||
DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, MSVCRT__query_new_handler // int (__cdecl*__cdecl _query_new_handler(void))(unsigned int)
|
||||
DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, MSVCRT__set_new_handler // int (__cdecl*__cdecl _set_new_handler(int (__cdecl*)(unsigned int)))(unsigned int)
|
||||
DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, MSVCRT__set_new_mode // int __cdecl _set_new_mode(int)
|
||||
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator // void (__cdecl*__cdecl _set_se_translator(void (__cdecl*)(unsigned int,struct _EXCEPTION_POINTERS *)))(unsigned int,struct _EXCEPTION_POINTERS *)
|
||||
DEFINE_ALIAS ?before@type_info@@QBAHABV1@@Z, MSVCRT_type_info_before // public: int __cdecl type_info::before(class type_info const &)const
|
||||
DEFINE_ALIAS ?name@type_info@@QBAPBDXZ, MSVCRT_type_info_name // public: char const * __cdecl type_info::name(void)const
|
||||
DEFINE_ALIAS ?raw_name@type_info@@QBAPBDXZ, MSVCRT_type_info_raw_name // public: char const * __cdecl type_info::raw_name(void)const
|
||||
DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_terminate // void (__cdecl*__cdecl set_terminate(void (__cdecl*)(void)))(void)
|
||||
DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_unexpected // void (__cdecl*__cdecl set_unexpected(void (__cdecl*)(void)))(void)
|
||||
DEFINE_ALIAS ?terminate@@YAXXZ, MSVCRT_terminate // void __cdecl terminate(void)
|
||||
DEFINE_ALIAS ?unexpected@@YAXXZ, MSVCRT_unexpected // void __cdecl unexpected(void)
|
||||
DEFINE_ALIAS ?what@exception@@UBAPBDXZ, MSVCRT_what_exception // public: virtual char const * __cdecl exception::what(void)const
|
||||
|
||||
#undef _MSVCRT_
|
||||
MACRO
|
||||
START_VTABLE $ShortName, $CxxName
|
||||
LCLS RttiName
|
||||
LCLS VtblName
|
||||
LCLS DtorName
|
||||
LCLS CxxLabel
|
||||
CxxLabel SETS "|$CxxName|"
|
||||
RttiName SETS "|$ShortName._rtti|"
|
||||
VtblName SETS "|MSVCRT_":CC:"$ShortName._vtable|"
|
||||
DtorName SETS "|MSVCRT_":CC:"$ShortName._vector_dtor|"
|
||||
EXTERN $RttiName
|
||||
DCD $RttiName
|
||||
EXPORT $VtblName
|
||||
$VtblName
|
||||
EXPORT $CxxLabel
|
||||
$CxxLabel
|
||||
EXTERN $DtorName
|
||||
DCD $DtorName
|
||||
MEND
|
||||
|
||||
MACRO
|
||||
DEFINE_EXCEPTION_VTABLE $ShortName, $CxxName
|
||||
START_VTABLE $ShortName, $CxxName
|
||||
EXTERN MSVCRT_what_exception
|
||||
DCD MSVCRT_what_exception
|
||||
MEND
|
||||
|
||||
START_VTABLE type_info, __dummyname_type_info
|
||||
DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
|
||||
|
||||
GBLS FuncName
|
||||
|
||||
//EXTERN MSVCRT_operator_delete
|
||||
//__ExportName ??3@YAXPAX@Z
|
||||
//b MSVCRT_operator_delete
|
||||
|
||||
//EXTERN MSVCRT_operator_new
|
||||
//__ExportName ??_U@YAPAXI@Z
|
||||
//b MSVCRT_operator_new
|
||||
|
||||
END
|
||||
/* EOF */
|
38
sdk/lib/crt/except/arm/ehandler.c
Normal file
38
sdk/lib/crt/except/arm/ehandler.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: lib/sdk/crt/except/arm/ehandler.c
|
||||
* PURPOSE: Low level exception handler functions
|
||||
* PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
_CRTIMP
|
||||
EXCEPTION_DISPOSITION
|
||||
__cdecl
|
||||
__C_specific_handler(
|
||||
struct _EXCEPTION_RECORD *_ExceptionRecord,
|
||||
void *_EstablisherFrame,
|
||||
struct _CONTEXT *_ContextRecord,
|
||||
struct _DISPATCHER_CONTEXT *_DispatcherContext)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
__debugbreak();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
__CxxFrameHandler3(
|
||||
PEXCEPTION_RECORD rec,
|
||||
EXCEPTION_REGISTRATION_RECORD* ExceptionRegistrationFrame,
|
||||
PCONTEXT context,
|
||||
EXCEPTION_REGISTRATION_RECORD** _ExceptionRecord)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
__debugbreak();
|
||||
return 0;
|
||||
}
|
||||
|
1266
sdk/lib/crt/except/cpp.c
Normal file
1266
sdk/lib/crt/except/cpp.c
Normal file
File diff suppressed because it is too large
Load diff
596
sdk/lib/crt/except/cppexcept.c
Normal file
596
sdk/lib/crt/except/cppexcept.c
Normal file
|
@ -0,0 +1,596 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
302
sdk/lib/crt/except/except.c
Normal file
302
sdk/lib/crt/except/except.c
Normal file
|
@ -0,0 +1,302 @@
|
|||
/*
|
||||
* 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 <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(®);
|
||||
|
||||
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(®);
|
||||
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;
|
||||
}
|
36
sdk/lib/crt/except/i386/chkesp.s
Normal file
36
sdk/lib/crt/except/i386/chkesp.s
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS C run time library
|
||||
* PURPOSE: Stack checker
|
||||
* PROGRAMMERS: Jérôme Gardou
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
/* Code is taken from wine 1.3.33,
|
||||
* Copyright Jon Griffiths and Alexandre Julliard
|
||||
*/
|
||||
EXTERN __chkesp_failed:PROC
|
||||
|
||||
PUBLIC __chkesp
|
||||
.code
|
||||
__chkesp:
|
||||
jnz .test_failed
|
||||
ret
|
||||
|
||||
.test_failed:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
sub esp, 12
|
||||
push eax
|
||||
push ecx
|
||||
push edx
|
||||
call __chkesp_failed
|
||||
pop edx
|
||||
pop ecx
|
||||
pop eax
|
||||
leave
|
||||
ret
|
||||
|
||||
END
|
100
sdk/lib/crt/except/i386/chkstk_asm.s
Normal file
100
sdk/lib/crt/except/i386/chkstk_asm.s
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Stack checker
|
||||
* FILE: lib/sdk/crt/except/i386/chkstk_asm.s
|
||||
* PROGRAMER: KJK::Hyperion <noog@libero.it>
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
PUBLIC __chkstk
|
||||
PUBLIC __alloca_probe
|
||||
PUBLIC __alloca_probe_16
|
||||
.code
|
||||
|
||||
/* 16 byte aligned alloca probe
|
||||
* EAX = size to be allocated */
|
||||
__alloca_probe_16:
|
||||
/* save the ECX register */
|
||||
push ecx
|
||||
|
||||
/* ecx = top of the previous stack frame */
|
||||
lea ecx, [esp + 8]
|
||||
|
||||
/* Calculate end of allocation */
|
||||
sub ecx, eax
|
||||
|
||||
/* Get the misalignment */
|
||||
and ecx, 15
|
||||
|
||||
/* Add the misalignment to the original alloc size */
|
||||
add eax, ecx
|
||||
|
||||
/* Check for overflow */
|
||||
jnc l1
|
||||
|
||||
/* Set maximum value */
|
||||
mov eax, HEX(0ffffffff)
|
||||
l1:
|
||||
/* Restore ecx */
|
||||
pop ecx
|
||||
/* Fall through to __chkstk */
|
||||
|
||||
/*
|
||||
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
|
||||
stack in areas of 4 KB each, trying to access each area. This ensures that the
|
||||
guard page for the stack is hit, and the stack growing triggered
|
||||
*/
|
||||
__chkstk:
|
||||
__alloca_probe:
|
||||
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX register */
|
||||
push ecx
|
||||
|
||||
/* ECX = top of the previous stack frame */
|
||||
lea ecx, [esp + 8]
|
||||
|
||||
/* probe the desired memory, page by page */
|
||||
cmp eax, PAGE_SIZE
|
||||
jl .l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
|
||||
/* raise the top of the stack by a page and probe */
|
||||
sub ecx, PAGE_SIZE
|
||||
test [ecx], eax
|
||||
|
||||
/* loop if still more than a page must be probed */
|
||||
sub eax, PAGE_SIZE
|
||||
cmp eax, PAGE_SIZE
|
||||
jge .l_MoreThanAPage
|
||||
|
||||
.l_LessThanAPage:
|
||||
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
sub ecx, eax
|
||||
test [ecx], eax
|
||||
|
||||
/* EAX = top of the stack */
|
||||
mov eax, esp
|
||||
|
||||
/* allocate the memory */
|
||||
mov esp, ecx
|
||||
|
||||
/* restore ECX */
|
||||
mov ecx, [eax]
|
||||
|
||||
/* restore the return address */
|
||||
mov eax, [eax + 4]
|
||||
push eax
|
||||
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
||||
END
|
59
sdk/lib/crt/except/i386/chkstk_ms.s
Normal file
59
sdk/lib/crt/except/i386/chkstk_ms.s
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Stack checker
|
||||
* PROGRAMERS: KJK::Hyperion <noog@libero.it>
|
||||
* Richard Henderson <rth@redhat.com>
|
||||
* Kai Tietz <kai.tietz@onevision.com>
|
||||
* Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
PUBLIC ___chkstk_ms
|
||||
.code
|
||||
|
||||
/* Special version, that does only probe and not allocate */
|
||||
___chkstk_ms:
|
||||
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX and EAX register */
|
||||
push ecx
|
||||
push eax
|
||||
|
||||
/* ECX = top of the previous stack frame */
|
||||
lea ecx, [esp + 12]
|
||||
|
||||
/* probe the desired memory, page by page */
|
||||
cmp eax, PAGE_SIZE
|
||||
jl .l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
|
||||
/* raise the top of the stack by a page and probe */
|
||||
sub ecx, PAGE_SIZE
|
||||
test [ecx], eax
|
||||
|
||||
/* loop if still more than a page must be probed */
|
||||
sub eax, PAGE_SIZE
|
||||
cmp eax, PAGE_SIZE
|
||||
jge .l_MoreThanAPage
|
||||
|
||||
.l_LessThanAPage:
|
||||
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
sub ecx, eax
|
||||
test [ecx], eax
|
||||
|
||||
/* restore ECX and EAX */
|
||||
pop eax
|
||||
pop ecx
|
||||
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
||||
END
|
112
sdk/lib/crt/except/i386/cpp.s
Normal file
112
sdk/lib/crt/except/i386/cpp.s
Normal file
|
@ -0,0 +1,112 @@
|
|||
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
.code
|
||||
.align 4
|
||||
|
||||
MACRO(DEFINE_THISCALL_WRAPPER, cxxname, stdcallname)
|
||||
EXTERN &stdcallname:PROC
|
||||
PUBLIC &cxxname
|
||||
&cxxname:
|
||||
pop eax
|
||||
push ecx
|
||||
push eax
|
||||
jmp &stdcallname
|
||||
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
|
||||
|
||||
|
||||
#undef _MSVCRT_
|
||||
MACRO(START_VTABLE, shortname, cxxname)
|
||||
EXTERN _&shortname&_rtti:PROC
|
||||
EXTERN ___thiscall_MSVCRT_&shortname&_vector_dtor:PROC
|
||||
.long _&shortname&_rtti
|
||||
PUBLIC _MSVCRT_&shortname&_vtable
|
||||
_MSVCRT_&shortname&_vtable:
|
||||
PUBLIC &cxxname
|
||||
&cxxname:
|
||||
.long ___thiscall_MSVCRT_&shortname&_vector_dtor
|
||||
ENDM
|
||||
|
||||
MACRO(DEFINE_EXCEPTION_VTABLE, shortname, cxxname)
|
||||
START_VTABLE shortname, cxxname
|
||||
EXTERN ___thiscall_MSVCRT_what_exception:PROC
|
||||
.long ___thiscall_MSVCRT_what_exception
|
||||
ENDM
|
||||
|
||||
START_VTABLE type_info, __dummyname_type_info
|
||||
DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
|
||||
DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
|
||||
|
||||
EXTERN _MSVCRT_operator_delete:PROC
|
||||
PUBLIC ??3@YAXPAX@Z
|
||||
??3@YAXPAX@Z:
|
||||
jmp _MSVCRT_operator_delete
|
||||
|
||||
EXTERN _MSVCRT_operator_new:PROC
|
||||
PUBLIC ??_U@YAPAXI@Z
|
||||
??_U@YAPAXI@Z:
|
||||
jmp _MSVCRT_operator_new
|
||||
|
||||
|
||||
MACRO(DEFINE_ALIAS, alias, orig, type)
|
||||
EXTERN &orig:&type
|
||||
ALIAS <&alias> = <&orig>
|
||||
ENDM
|
||||
|
||||
DEFINE_ALIAS ??_V@YAXPAX@Z, _MSVCRT_operator_delete, PROC
|
||||
DEFINE_ALIAS ??2@YAPAXI@Z, _MSVCRT_operator_new, PROC
|
||||
DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, _MSVCRT__query_new_handler, PROC
|
||||
DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, _MSVCRT__set_new_handler, PROC
|
||||
DEFINE_ALIAS ?set_new_handler@@YAP6AXXZP6AXXZ@Z, _MSVCRT_set_new_handler, PROC
|
||||
DEFINE_ALIAS ?_query_new_mode@@YAHXZ, _MSVCRT__query_new_mode, PROC
|
||||
DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, _MSVCRT__set_new_mode, PROC
|
||||
DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, _MSVCRT__set_se_translator, PROC
|
||||
DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, _MSVCRT_set_terminate, PROC
|
||||
DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, _MSVCRT_set_unexpected, PROC
|
||||
DEFINE_ALIAS ?terminate@@YAXXZ, _MSVCRT_terminate, PROC
|
||||
DEFINE_ALIAS ?unexpected@@YAXXZ, _MSVCRT_unexpected, PROC
|
||||
|
||||
|
||||
END
|
||||
|
30
sdk/lib/crt/except/i386/prolog.s
Normal file
30
sdk/lib/crt/except/i386/prolog.s
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CRT
|
||||
* FILE: lib/sdk/crt/except/i386/prolog.s
|
||||
* PURPOSE: SEH Support for the CRT
|
||||
* PROGRAMMERS: Wine Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
.code
|
||||
|
||||
PUBLIC __EH_prolog
|
||||
// Copied from Wine.
|
||||
__EH_prolog:
|
||||
push -1
|
||||
push eax
|
||||
push fs:0
|
||||
mov fs:0, esp
|
||||
mov eax, [esp + 12]
|
||||
mov [esp + 12], ebp
|
||||
lea ebp, [esp + 12]
|
||||
push eax
|
||||
ret
|
||||
|
||||
END
|
39
sdk/lib/crt/except/i386/unwind.c
Normal file
39
sdk/lib/crt/except/i386/unwind.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#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);
|
||||
}
|
65
sdk/lib/crt/except/matherr.c
Normal file
65
sdk/lib/crt/except/matherr.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include <precomp.h>
|
||||
|
||||
#define __USE_ISOC9X 1
|
||||
#define __USE_ISOC99 1
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FINITE
|
||||
#ifndef finite /* Could be a macro */
|
||||
#ifdef isfinite
|
||||
#define finite(x) isfinite(x)
|
||||
#else
|
||||
#define finite(x) (!isnan(x)) /* At least catch some cases */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef signbit
|
||||
#define signbit(x) 0
|
||||
#endif
|
||||
|
||||
typedef int (*MSVCRT_matherr_func)(struct _exception *);
|
||||
|
||||
static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
|
||||
|
||||
int CDECL _matherr(struct _exception *e)
|
||||
{
|
||||
if (e)
|
||||
TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
|
||||
e->retval);
|
||||
else
|
||||
TRACE("(null)\n");
|
||||
if (MSVCRT_default_matherr_func)
|
||||
return MSVCRT_default_matherr_func(e);
|
||||
ERR(":Unhandled math error!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* __setusermatherr (MSVCRT.@)
|
||||
*/
|
||||
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;
|
||||
}
|
22
sdk/lib/crt/except/powerpc/chkstk_asm.s
Normal file
22
sdk/lib/crt/except/powerpc/chkstk_asm.s
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Stack checker
|
||||
* FILE: lib/sdk/crt/except/powerpc/chkstk_asm.s
|
||||
* PROGRAMER: arty
|
||||
*/
|
||||
|
||||
.globl _chkstk
|
||||
.globl _alloca_probe
|
||||
|
||||
/*
|
||||
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
|
||||
stack in areas of 4 KB each, trying to access each area. This ensures that the
|
||||
guard page for the stack is hit, and the stack growing triggered
|
||||
*/
|
||||
_chkstk:
|
||||
_alloca_probe:
|
||||
/* return */
|
||||
blr
|
||||
|
||||
/* EOF */
|
75
sdk/lib/crt/except/powerpc/seh.s
Normal file
75
sdk/lib/crt/except/powerpc/seh.s
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CRT
|
||||
* FILE: lib/sdk/crt/except/powerpc/seh.s
|
||||
* PURPOSE: SEH Support for the CRT
|
||||
* PROGRAMMERS: arty
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ndk/asm.h>
|
||||
|
||||
#define DISPOSITION_DISMISS 0
|
||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||
#define DISPOSITION_COLLIDED_UNWIND 3
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
.globl _global_unwind2
|
||||
.globl _local_unwind2
|
||||
.globl _abnormal_termination
|
||||
.globl _except_handler2
|
||||
.globl _except_handler3
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
unwind_handler:
|
||||
blr
|
||||
|
||||
_global_unwind2:
|
||||
blr
|
||||
|
||||
_local_unwind2:
|
||||
blr
|
||||
|
||||
_except_handler2:
|
||||
blr
|
||||
|
||||
_except_handler3:
|
||||
blr
|
||||
|
||||
//
|
||||
//
|
||||
// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME
|
||||
// sorry
|
||||
//
|
||||
//
|
||||
.globl RtlpGetStackLimits
|
||||
RtlpGetStackLimits:
|
||||
stwu 1,16(1)
|
||||
mflr 0
|
||||
|
||||
stw 0,4(1)
|
||||
stw 3,8(1)
|
||||
stw 4,12(1)
|
||||
|
||||
/* Get the current thread */
|
||||
lwz 3,KPCR_CURRENT_THREAD(13)
|
||||
|
||||
/* Get the stack limits */
|
||||
lwz 4,KTHREAD_STACK_LIMIT(3)
|
||||
lwz 5,KTHREAD_INITIAL_STACK(3)
|
||||
subi 5,5,SIZEOF_FX_SAVE_AREA
|
||||
|
||||
/* Return them */
|
||||
lwz 3,8(1)
|
||||
stw 4,0(3)
|
||||
|
||||
lwz 3,12(1)
|
||||
stw 5,0(3)
|
||||
|
||||
addi 1,1,16
|
||||
|
||||
/* return */
|
||||
blr
|
45
sdk/lib/crt/except/stack.c
Normal file
45
sdk/lib/crt/except/stack.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <precomp.h>
|
||||
|
||||
/*********************************************************************
|
||||
* _chkesp (MSVCRT.@)
|
||||
*
|
||||
* Trap to a debugger if the value of the stack pointer has changed.
|
||||
*
|
||||
* PARAMS
|
||||
* None.
|
||||
*
|
||||
* RETURNS
|
||||
* Does not return.
|
||||
*
|
||||
* NOTES
|
||||
* This function is available for iX86 only.
|
||||
*
|
||||
* When VC++ generates debug code, it stores the value of the stack pointer
|
||||
* before calling any external function, and checks the value following
|
||||
* the call. It then calls this function, which will trap if the values are
|
||||
* not the same. Usually this means that the prototype used to call
|
||||
* the function is incorrect. It can also mean that the .spec entry has
|
||||
* the wrong calling convention or parameters.
|
||||
*/
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
void _chkesp_failed(void)
|
||||
{
|
||||
ERR("stack got corrupted!\n");
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
/*********************************************************************
|
||||
* _resetstkoflw (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _resetstkoflw(void)
|
||||
{
|
||||
int stack_addr;
|
||||
DWORD oldprot;
|
||||
|
||||
/* causes stack fault that updates NtCurrentTeb()->Tib.StackLimit */
|
||||
return VirtualProtect(&stack_addr, 1, PAGE_GUARD|PAGE_READWRITE, &oldprot);
|
||||
}
|
98
sdk/lib/crt/except/xcptfil.c
Normal file
98
sdk/lib/crt/except/xcptfil.c
Normal file
|
@ -0,0 +1,98 @@
|
|||
#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;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue