2001-01-10 23:59:25 +00:00
|
|
|
/*
|
|
|
|
* msvcrt.dll exception handling
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2005-05-13 17:44:28 +00:00
|
|
|
* Copyright 2005 Juan Lang
|
2001-01-10 23:59:25 +00:00
|
|
|
*
|
2002-03-09 23:29:33 +00:00
|
|
|
* 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
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
2001-01-12 20:41:03 +00:00
|
|
|
* FIXME: Incomplete support for nested exceptions/try block cleanup.
|
2001-01-10 23:59:25 +00:00
|
|
|
*/
|
2002-04-25 21:40:56 +00:00
|
|
|
|
2001-06-29 19:19:53 +00:00
|
|
|
#include "config.h"
|
2002-04-25 21:40:56 +00:00
|
|
|
#include "wine/port.h"
|
2001-06-29 19:19:53 +00:00
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2011-02-01 15:40:31 +00:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2002-09-12 22:07:02 +00:00
|
|
|
#include "winternl.h"
|
2001-01-12 20:41:03 +00:00
|
|
|
#include "wine/exception.h"
|
2001-01-10 23:59:25 +00:00
|
|
|
#include "msvcrt.h"
|
2002-12-12 23:34:01 +00:00
|
|
|
#include "excpt.h"
|
2005-05-13 17:44:28 +00:00
|
|
|
#include "wincon.h"
|
2002-01-22 00:57:16 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2016-03-16 20:02:08 +00:00
|
|
|
#include "cppexcept.h"
|
|
|
|
|
2006-01-05 13:36:37 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(seh);
|
2001-01-10 23:59:25 +00:00
|
|
|
|
2011-03-16 08:22:24 +00:00
|
|
|
static MSVCRT_security_error_handler security_error_handler;
|
|
|
|
|
2005-12-01 11:48:44 +00:00
|
|
|
static MSVCRT___sighandler_t sighandlers[MSVCRT_NSIG] = { MSVCRT_SIG_DFL };
|
2005-05-13 17:44:28 +00:00
|
|
|
|
|
|
|
static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
switch (ctrlType)
|
|
|
|
{
|
|
|
|
case CTRL_C_EVENT:
|
2005-12-01 11:48:44 +00:00
|
|
|
if (sighandlers[MSVCRT_SIGINT])
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
2005-12-01 11:48:44 +00:00
|
|
|
if (sighandlers[MSVCRT_SIGINT] != MSVCRT_SIG_IGN)
|
|
|
|
sighandlers[MSVCRT_SIGINT](MSVCRT_SIGINT);
|
2005-05-13 17:44:28 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-05 10:05:42 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* __pxcptinfoptrs (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void** CDECL MSVCRT___pxcptinfoptrs(void)
|
|
|
|
{
|
|
|
|
return (void**)&msvcrt_get_thread_data()->xcptinfo;
|
|
|
|
}
|
|
|
|
|
2010-05-12 15:15:29 +00:00
|
|
|
typedef void (CDECL *float_handler)(int, int);
|
2005-05-13 17:44:28 +00:00
|
|
|
|
|
|
|
/* The exception codes are actually NTSTATUS values */
|
2007-01-13 20:31:01 +00:00
|
|
|
static const struct
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
int signal;
|
|
|
|
} float_exception_map[] = {
|
2008-12-11 21:28:26 +00:00
|
|
|
{ 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 },
|
2005-05-13 17:44:28 +00:00
|
|
|
};
|
|
|
|
|
2013-03-06 14:07:51 +00:00
|
|
|
static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
|
|
|
LONG ret = EXCEPTION_CONTINUE_SEARCH;
|
2007-02-08 20:33:33 +00:00
|
|
|
MSVCRT___sighandler_t handler;
|
2005-05-13 17:44:28 +00:00
|
|
|
|
2005-05-19 14:21:21 +00:00
|
|
|
if (!except || !except->ExceptionRecord)
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
|
2005-05-13 17:44:28 +00:00
|
|
|
switch (except->ExceptionRecord->ExceptionCode)
|
|
|
|
{
|
|
|
|
case EXCEPTION_ACCESS_VIOLATION:
|
2007-02-08 20:33:33 +00:00
|
|
|
if ((handler = sighandlers[MSVCRT_SIGSEGV]) != MSVCRT_SIG_DFL)
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
2007-02-08 20:33:33 +00:00
|
|
|
if (handler != MSVCRT_SIG_IGN)
|
|
|
|
{
|
2013-03-05 10:05:42 +00:00
|
|
|
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
|
|
|
|
|
|
|
|
old_ep = *ep;
|
|
|
|
*ep = except;
|
2007-02-08 20:33:33 +00:00
|
|
|
sighandlers[MSVCRT_SIGSEGV] = MSVCRT_SIG_DFL;
|
|
|
|
handler(MSVCRT_SIGSEGV);
|
2013-03-05 10:05:42 +00:00
|
|
|
*ep = old_ep;
|
2007-02-08 20:33:33 +00:00
|
|
|
}
|
2005-05-13 17:44:28 +00:00
|
|
|
ret = EXCEPTION_CONTINUE_EXECUTION;
|
|
|
|
}
|
|
|
|
break;
|
2008-03-01 04:29:54 +00:00
|
|
|
/* According to msdn,
|
2005-05-13 17:44:28 +00:00
|
|
|
* 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:
|
2007-02-08 20:33:33 +00:00
|
|
|
if ((handler = sighandlers[MSVCRT_SIGFPE]) != MSVCRT_SIG_DFL)
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
2007-02-08 20:33:33 +00:00
|
|
|
if (handler != MSVCRT_SIG_IGN)
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
2013-03-05 10:05:42 +00:00
|
|
|
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
|
2008-10-21 20:44:27 +00:00
|
|
|
unsigned int i;
|
2008-12-11 21:28:26 +00:00
|
|
|
int float_signal = MSVCRT__FPE_INVALID;
|
2005-05-13 17:44:28 +00:00
|
|
|
|
2007-02-08 20:33:33 +00:00
|
|
|
sighandlers[MSVCRT_SIGFPE] = MSVCRT_SIG_DFL;
|
2005-05-13 17:44:28 +00:00
|
|
|
for (i = 0; i < sizeof(float_exception_map) /
|
2007-02-08 20:33:33 +00:00
|
|
|
sizeof(float_exception_map[0]); i++)
|
|
|
|
{
|
2005-05-13 17:44:28 +00:00
|
|
|
if (float_exception_map[i].status ==
|
2007-02-08 20:33:33 +00:00
|
|
|
except->ExceptionRecord->ExceptionCode)
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
|
|
|
float_signal = float_exception_map[i].signal;
|
|
|
|
break;
|
|
|
|
}
|
2007-02-08 20:33:33 +00:00
|
|
|
}
|
2013-03-05 10:05:42 +00:00
|
|
|
|
|
|
|
old_ep = *ep;
|
|
|
|
*ep = except;
|
2007-02-08 20:33:33 +00:00
|
|
|
((float_handler)handler)(MSVCRT_SIGFPE, float_signal);
|
2013-03-05 10:05:42 +00:00
|
|
|
*ep = old_ep;
|
2005-05-13 17:44:28 +00:00
|
|
|
}
|
|
|
|
ret = EXCEPTION_CONTINUE_EXECUTION;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
2008-03-24 20:53:49 +00:00
|
|
|
case EXCEPTION_PRIV_INSTRUCTION:
|
2007-02-08 20:33:33 +00:00
|
|
|
if ((handler = sighandlers[MSVCRT_SIGILL]) != MSVCRT_SIG_DFL)
|
2005-05-13 17:44:28 +00:00
|
|
|
{
|
2007-02-08 20:33:33 +00:00
|
|
|
if (handler != MSVCRT_SIG_IGN)
|
|
|
|
{
|
2013-03-05 10:05:42 +00:00
|
|
|
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
|
|
|
|
|
|
|
|
old_ep = *ep;
|
|
|
|
*ep = except;
|
2007-02-08 20:33:33 +00:00
|
|
|
sighandlers[MSVCRT_SIGILL] = MSVCRT_SIG_DFL;
|
|
|
|
handler(MSVCRT_SIGILL);
|
2013-03-05 10:05:42 +00:00
|
|
|
*ep = old_ep;
|
2007-02-08 20:33:33 +00:00
|
|
|
}
|
2005-05-13 17:44:28 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2001-01-10 23:59:25 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* signal (MSVCRT.@)
|
2005-05-13 17:44:28 +00:00
|
|
|
* Some signals may never be generated except through an explicit call to
|
|
|
|
* raise.
|
2001-01-10 23:59:25 +00:00
|
|
|
*/
|
2006-06-13 09:21:19 +00:00
|
|
|
MSVCRT___sighandler_t CDECL MSVCRT_signal(int sig, MSVCRT___sighandler_t func)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2005-12-01 11:48:44 +00:00
|
|
|
MSVCRT___sighandler_t ret = MSVCRT_SIG_ERR;
|
2005-05-13 17:44:28 +00:00
|
|
|
|
|
|
|
TRACE("(%d, %p)\n", sig, func);
|
|
|
|
|
2005-12-01 11:48:44 +00:00
|
|
|
if (func == MSVCRT_SIG_ERR) return MSVCRT_SIG_ERR;
|
2005-05-13 17:44:28 +00:00
|
|
|
|
|
|
|
switch (sig)
|
|
|
|
{
|
|
|
|
/* Cases handled internally. Note SIGTERM is never generated by Windows,
|
|
|
|
* so we effectively mask it.
|
|
|
|
*/
|
2005-12-01 11:48:44 +00:00
|
|
|
case MSVCRT_SIGABRT:
|
|
|
|
case MSVCRT_SIGFPE:
|
|
|
|
case MSVCRT_SIGILL:
|
|
|
|
case MSVCRT_SIGSEGV:
|
|
|
|
case MSVCRT_SIGINT:
|
|
|
|
case MSVCRT_SIGTERM:
|
2009-12-02 19:21:21 +00:00
|
|
|
case MSVCRT_SIGBREAK:
|
2005-05-13 17:44:28 +00:00
|
|
|
ret = sighandlers[sig];
|
|
|
|
sighandlers[sig] = func;
|
|
|
|
break;
|
|
|
|
default:
|
2005-12-01 11:48:44 +00:00
|
|
|
ret = MSVCRT_SIG_ERR;
|
2005-05-13 17:44:28 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
2005-05-19 14:21:21 +00:00
|
|
|
|
2007-02-08 20:33:39 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* 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)
|
|
|
|
{
|
2013-03-05 10:05:42 +00:00
|
|
|
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
|
|
|
|
|
2007-02-08 20:33:39 +00:00
|
|
|
sighandlers[sig] = MSVCRT_SIG_DFL;
|
2013-03-05 10:05:42 +00:00
|
|
|
|
|
|
|
old_ep = *ep;
|
|
|
|
*ep = NULL;
|
2007-02-08 20:33:39 +00:00
|
|
|
if (sig == MSVCRT_SIGFPE)
|
2008-12-11 21:28:26 +00:00
|
|
|
((float_handler)handler)(sig, MSVCRT__FPE_EXPLICITGEN);
|
2007-02-08 20:33:39 +00:00
|
|
|
else
|
|
|
|
handler(sig);
|
2013-03-05 10:05:42 +00:00
|
|
|
*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);
|
2007-02-08 20:33:39 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-05-19 14:21:21 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _XcptFilter (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 09:21:19 +00:00
|
|
|
int CDECL _XcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
|
2005-05-19 14:21:21 +00:00
|
|
|
{
|
2006-10-03 18:39:05 +00:00
|
|
|
TRACE("(%08x,%p)\n", ex, ptr);
|
2005-05-19 14:21:21 +00:00
|
|
|
/* I assume ptr->ExceptionRecord->ExceptionCode is the same as ex */
|
|
|
|
return msvcrt_exception_filter(ptr);
|
|
|
|
}
|
2009-10-03 11:13:37 +00:00
|
|
|
|
2010-04-12 15:52:32 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _abnormal_termination (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _abnormal_termination(void)
|
|
|
|
{
|
|
|
|
FIXME("(void)stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-03 11:13:37 +00:00
|
|
|
/******************************************************************
|
2014-04-21 12:32:40 +00:00
|
|
|
* __uncaught_exception (MSVCRT.@)
|
2009-10-03 11:13:37 +00:00
|
|
|
*/
|
|
|
|
BOOL CDECL MSVCRT___uncaught_exception(void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-03-16 08:22:24 +00:00
|
|
|
|
2014-04-21 12:32:40 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _set_security_error_handler (MSVCR70.@)
|
|
|
|
*/
|
2011-03-16 08:22:24 +00:00
|
|
|
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;
|
|
|
|
}
|
2013-10-25 12:12:43 +00:00
|
|
|
|
2014-04-21 12:32:40 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* __security_error_handler (MSVCR70.@)
|
|
|
|
*/
|
2013-10-25 12:12:43 +00:00
|
|
|
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);
|
|
|
|
}
|
2014-04-17 11:07:21 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __crtSetUnhandledExceptionFilter (MSVCR110.@)
|
|
|
|
*/
|
|
|
|
LPTOP_LEVEL_EXCEPTION_FILTER CDECL MSVCR110__crtSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER filter)
|
|
|
|
{
|
|
|
|
return SetUnhandledExceptionFilter(filter);
|
|
|
|
}
|
2016-03-16 20:01:50 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _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;
|
|
|
|
}
|
2016-03-16 20:01:55 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _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");
|
|
|
|
}
|
2016-03-16 20:02:04 +00:00
|
|
|
|
2016-03-16 20:03:19 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _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;
|
|
|
|
}
|
|
|
|
|
2016-03-16 20:02:08 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* __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);
|
|
|
|
|
2016-03-18 11:40:25 +00:00
|
|
|
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;
|
|
|
|
|
2016-03-16 20:02:08 +00:00
|
|
|
if (!info || !info->destructor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#if defined(__i386__)
|
|
|
|
__asm__ __volatile__("call *%0" : : "r" (info->destructor), "c" (object) : "eax", "edx", "memory" );
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
((void (__cdecl*)(void*))(info->destructor+rec->ExceptionInformation[3]))(object);
|
|
|
|
#else
|
|
|
|
((void (__cdecl*)(void*))info->destructor)(object);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-16 20:02:04 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* __CxxRegisterExceptionObject (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
BOOL CDECL __CxxRegisterExceptionObject(EXCEPTION_RECORD **rec, cxx_frame_info *frame_info)
|
|
|
|
{
|
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", rec, frame_info);
|
|
|
|
|
|
|
|
if (!rec || !*rec)
|
|
|
|
{
|
|
|
|
frame_info->rec = (void*)-1;
|
|
|
|
frame_info->unk = (void*)-1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_info->rec = data->exc_record;
|
|
|
|
frame_info->unk = 0;
|
|
|
|
data->exc_record = *rec;
|
|
|
|
_CreateFrameInfo(&frame_info->frame_info, (void*)(*rec)->ExceptionInformation[1]);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2016-03-16 20:02:45 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __CxxUnregisterExceptionObject (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void CDECL __CxxUnregisterExceptionObject(cxx_frame_info *frame_info, BOOL in_use)
|
|
|
|
{
|
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
|
2016-03-16 20:03:19 +00:00
|
|
|
TRACE("(%p)\n", frame_info);
|
2016-03-16 20:02:45 +00:00
|
|
|
|
|
|
|
if(frame_info->rec == (void*)-1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_FindAndUnlinkFrame(&frame_info->frame_info);
|
2016-03-16 20:03:19 +00:00
|
|
|
if(data->exc_record->ExceptionCode == CXX_EXCEPTION && !in_use
|
|
|
|
&& _IsExceptionObjectToBeDestroyed((void*)data->exc_record->ExceptionInformation[1]))
|
2016-03-16 20:02:45 +00:00
|
|
|
__DestructExceptionObject(data->exc_record);
|
|
|
|
data->exc_record = frame_info->rec;
|
|
|
|
}
|