ReactOS 0.4.16-dev-822-gbcedb53
terminate.cpp
Go to the documentation of this file.
1//
2// terminate.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The terminate handler
7//
8#include <corecrt_internal.h>
9#include <corecrt_terminate.h>
10
11
12
14 __acrt_ptd const* const ptd
15 ) throw()
16{
17 return ptd->_terminate ? ptd->_terminate : &abort;
18}
19
21{
23}
24
26 terminate_handler const new_handler
27 ) throw()
28{
29 __acrt_ptd* const ptd = __acrt_getptd();
30
32
33 ptd->_terminate = new_handler;
34
35 return old_handler;
36}
37
38extern "C" void __cdecl terminate() throw()
39{
41 if (handler)
42 {
43 // Note: We cannot allow any exceptions to propagate from a user-
44 // registered terminate handler, so if any structured exception escapes
45 // the user handler we abort.
46 __try
47 {
48 handler();
49 }
51 {
52 ; // Deliberately do nothing
53 }
55 }
56
57 // If the terminate handler returned, faulted, or otherwise failed to end
58 // execution, we will do it:
59 abort();
60}
#define __cdecl
Definition: accygwin.h:79
__acrt_ptd *__cdecl __acrt_getptd(void)
result_buffer_count char *const _In_ int const _In_ bool const _In_ unsigned const _In_ STRFLT const _In_ bool const _Inout_ __crt_cached_ptd_host &ptd throw()
Definition: cvt.cpp:119
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
#define abort()
Definition: i386-dis.c:34
void(__cdecl * terminate_handler)(void)
Definition: eh.h:24
_CRTIMP terminate_function __cdecl set_terminate(terminate_function _NewPtFunc)
Definition: cpp.c:642
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
void MSVCRT() terminate()
Definition: cpp.c:716
#define __try
Definition: pseh2_64.h:172
#define __except
Definition: pseh2_64.h:173
#define __endtry
Definition: pseh2_64.h:175
static terminate_handler __cdecl get_terminate_or_default(__acrt_ptd const *const ptd)
Definition: terminate.cpp:13
terminate_handler __cdecl _get_terminate()
Definition: terminate.cpp:20
terminate_handler _terminate