diff --git a/dlls/msvcrt/cpp.c b/dlls/msvcrt/cpp.c index b98a3cea6d4..3060ac0d570 100644 --- a/dlls/msvcrt/cpp.c +++ b/dlls/msvcrt/cpp.c @@ -5,6 +5,7 @@ */ #include "msvcrt.h" +#include "msvcrt/eh.h" #include "msvcrt/malloc.h" @@ -133,6 +134,48 @@ const char * __stdcall MSVCRT_exception_what(exception * _this) } +static terminate_function func_terminate=NULL; +static unexpected_function func_unexpected=NULL; + +/****************************************************************** + * set_terminate (MSVCRT.@) + */ +terminate_function MSVCRT_set_terminate(terminate_function func) +{ + terminate_function previous=func_terminate; + TRACE("(%p) returning %p\n",func,previous); + func_terminate=func; + return previous; +} + +/****************************************************************** + * set_unexpected (MSVCRT.@) + */ +unexpected_function MSVCRT_set_unexpected(unexpected_function func) +{ + unexpected_function previous=func_unexpected; + TRACE("(%p) returning %p\n",func,previous); + func_unexpected=func; + return previous; +} + +/****************************************************************** + * terminate (MSVCRT.@) + */ +void MSVCRT_terminate() +{ + (*func_terminate)(); +} + +/****************************************************************** + * unexpected (MSVCRT.@) + */ +void MSVCRT_unexpected() +{ + (*func_unexpected)(); +} + + /****************************************************************** * bad_typeid_copy_ctor (MSVCRT.@) */ diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 0b084c8c5ec..ce6f427bd63 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -52,10 +52,10 @@ debug_channels (msvcrt) @ stdcall ?name@type_info@@QBEPBDXZ(ptr) MSVCRT_type_info_name @ stdcall ?raw_name@type_info@@QBEPBDXZ(ptr) MSVCRT_type_info_raw_name @ stub ?set_new_handler@@YAP6AXXZP6AXXZ@Z -@ stub ?set_terminate@@YAP6AXXZP6AXXZ@Z -@ stub ?set_unexpected@@YAP6AXXZP6AXXZ@Z -@ stub ?terminate@@YAXXZ #() -@ stub ?unexpected@@YAXXZ #() +@ cdecl ?set_terminate@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_terminate +@ cdecl ?set_unexpected@@YAP6AXXZP6AXXZ@Z(ptr) MSVCRT_set_unexpected +@ cdecl ?terminate@@YAXXZ() MSVCRT_terminate +@ cdecl ?unexpected@@YAXXZ() MSVCRT_unexpected @ stdcall ?what@exception@@UBEPBDXZ(ptr) MSVCRT_exception_what @ cdecl -noimport _CIacos() _CIacos @ cdecl -noimport _CIasin() _CIasin diff --git a/include/msvcrt/eh.h b/include/msvcrt/eh.h new file mode 100644 index 00000000000..664d2308b0a --- /dev/null +++ b/include/msvcrt/eh.h @@ -0,0 +1,31 @@ +/* + * C++ exception handling facility + * + * Copyright 2000 Francois Gouget. + */ +#ifndef __WINE_EH_H +#define __WINE_EH_H + +#if !defined(__cplusplus) && !defined(__WINE__) +#error "eh.h is meant only for C++ applications" +#endif + +#ifdef USE_MSVCRT_PREFIX +#define MSVCRT(x) MSVCRT_##x +#else +#define MSVCRT(x) x +#endif + + +typedef void (*terminate_handler)(); +typedef void (*terminate_function)(); +typedef void (*unexpected_handler)(); +typedef void (*unexpected_function)(); + + +terminate_function MSVCRT(set_terminate)(terminate_function func); +unexpected_function MSVCRT(set_unexpected)(unexpected_function func); +void MSVCRT(terminate)(); +void MSVCRT(unexpected)(); + +#endif /* __WINE_EH_H */