1999-05-09 18:12:19 +02:00
|
|
|
/*
|
|
|
|
* NT exception handling routines
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-05-09 18:12:19 +02:00
|
|
|
* Copyright 1999 Turchanov Sergey
|
|
|
|
* Copyright 1999 Alexandre Julliard
|
2002-03-10 00:29:33 +01: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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-05-09 18:12:19 +02:00
|
|
|
*/
|
|
|
|
|
2001-10-14 18:18:52 +02:00
|
|
|
#include "config.h"
|
2002-04-25 23:40:56 +02:00
|
|
|
#include "wine/port.h"
|
2001-10-14 18:18:52 +02:00
|
|
|
|
2000-08-06 04:42:46 +02:00
|
|
|
#include <assert.h>
|
1999-06-18 20:21:24 +02:00
|
|
|
#include <signal.h>
|
2000-11-25 02:31:17 +01:00
|
|
|
|
2002-12-10 23:56:43 +01:00
|
|
|
#include "windef.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
1999-06-18 20:21:24 +02:00
|
|
|
#include "global.h"
|
1999-05-12 15:10:39 +02:00
|
|
|
#include "wine/exception.h"
|
1999-05-09 18:12:19 +02:00
|
|
|
#include "stackframe.h"
|
1999-06-18 20:21:24 +02:00
|
|
|
#include "miscemu.h"
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-12-13 00:34:01 +01:00
|
|
|
#include "excpt.h"
|
1999-05-09 18:12:19 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(seh);
|
1999-05-09 18:12:19 +02:00
|
|
|
|
|
|
|
/* Exception record for handling exceptions happening inside exception handlers */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EXCEPTION_FRAME frame;
|
|
|
|
EXCEPTION_FRAME *prevFrame;
|
|
|
|
} EXC_NESTED_FRAME;
|
|
|
|
|
2000-11-26 00:56:20 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
# define GET_IP(context) ((LPVOID)(context)->Eip)
|
2002-08-17 03:19:06 +02:00
|
|
|
#elif defined(__sparc__)
|
2000-11-26 00:56:20 +01:00
|
|
|
# define GET_IP(context) ((LPVOID)(context)->pc)
|
2002-08-17 03:19:06 +02:00
|
|
|
#elif defined(__powerpc__)
|
2002-08-30 02:00:57 +02:00
|
|
|
# define GET_IP(context) ((LPVOID)(context)->Iar)
|
2002-08-17 03:19:06 +02:00
|
|
|
#else
|
2000-11-26 00:56:20 +01:00
|
|
|
# error You must define GET_IP for this CPU
|
|
|
|
#endif
|
|
|
|
|
2001-06-15 21:43:15 +02:00
|
|
|
extern void SIGNAL_Unblock(void);
|
|
|
|
|
2001-01-11 01:53:25 +01:00
|
|
|
void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
|
2002-06-01 01:06:46 +02:00
|
|
|
void WINAPI EXC_RtlUnwind( PEXCEPTION_FRAME, LPVOID,
|
2001-01-11 01:53:25 +01:00
|
|
|
PEXCEPTION_RECORD, DWORD, PCONTEXT );
|
|
|
|
void WINAPI EXC_NtRaiseException( PEXCEPTION_RECORD, PCONTEXT,
|
|
|
|
BOOL, PCONTEXT );
|
|
|
|
|
1999-05-09 18:12:19 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* EXC_RaiseHandler
|
|
|
|
*
|
|
|
|
* Handler for exceptions happening inside a handler.
|
|
|
|
*/
|
1999-11-10 20:42:13 +01:00
|
|
|
static DWORD EXC_RaiseHandler( EXCEPTION_RECORD *rec, EXCEPTION_FRAME *frame,
|
|
|
|
CONTEXT *context, EXCEPTION_FRAME **dispatcher )
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
|
|
|
if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
|
|
|
|
return ExceptionContinueSearch;
|
|
|
|
/* We shouldn't get here so we store faulty frame in dispatcher */
|
|
|
|
*dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
|
|
|
|
return ExceptionNestedException;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* EXC_UnwindHandler
|
|
|
|
*
|
|
|
|
* Handler for exceptions happening inside an unwind handler.
|
|
|
|
*/
|
1999-11-10 20:42:13 +01:00
|
|
|
static DWORD EXC_UnwindHandler( EXCEPTION_RECORD *rec, EXCEPTION_FRAME *frame,
|
|
|
|
CONTEXT *context, EXCEPTION_FRAME **dispatcher )
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
|
|
|
if (!(rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
|
|
|
|
return ExceptionContinueSearch;
|
|
|
|
/* We shouldn't get here so we store faulty frame in dispatcher */
|
|
|
|
*dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
|
|
|
|
return ExceptionCollidedUnwind;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* EXC_CallHandler
|
|
|
|
*
|
|
|
|
* Call an exception handler, setting up an exception frame to catch exceptions
|
|
|
|
* happening during the handler execution.
|
1999-10-24 01:55:50 +02:00
|
|
|
* Please do not change the first 4 parameters order in any way - some exceptions handlers
|
|
|
|
* rely on Base Pointer (EBP) to have a fixed position related to the exception frame
|
1999-05-09 18:12:19 +02:00
|
|
|
*/
|
1999-10-24 01:55:50 +02:00
|
|
|
static DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame,
|
2002-06-01 01:06:46 +02:00
|
|
|
CONTEXT *context, EXCEPTION_FRAME **dispatcher,
|
1999-10-24 01:55:50 +02:00
|
|
|
PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler)
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
|
|
|
EXC_NESTED_FRAME newframe;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
newframe.frame.Handler = nested_handler;
|
|
|
|
newframe.prevFrame = frame;
|
2000-08-06 04:42:46 +02:00
|
|
|
__wine_push_frame( &newframe.frame );
|
1999-05-23 22:02:04 +02:00
|
|
|
TRACE( "calling handler at %p code=%lx flags=%lx\n",
|
|
|
|
handler, record->ExceptionCode, record->ExceptionFlags );
|
1999-05-09 18:12:19 +02:00
|
|
|
ret = handler( record, frame, context, dispatcher );
|
|
|
|
TRACE( "handler returned %lx\n", ret );
|
2000-08-06 04:42:46 +02:00
|
|
|
__wine_pop_frame( &newframe.frame );
|
1999-05-09 18:12:19 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-10 23:16:10 +01:00
|
|
|
/**********************************************************************
|
2000-08-30 02:00:48 +02:00
|
|
|
* send_debug_event
|
2000-03-10 23:16:10 +01:00
|
|
|
*
|
|
|
|
* Send an EXCEPTION_DEBUG_EVENT event to the debugger.
|
|
|
|
*/
|
2001-01-26 21:45:41 +01:00
|
|
|
static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context )
|
2000-03-10 23:16:10 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
int ret;
|
2001-01-26 21:45:41 +01:00
|
|
|
HANDLE handle = 0;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( queue_exception_event )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->first = first_chance;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, context, sizeof(*context) );
|
|
|
|
wine_server_add_data( req, rec, sizeof(*rec) );
|
|
|
|
if (!wine_server_call( req )) handle = reply->handle;
|
2001-01-26 21:45:41 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-01-26 21:45:41 +01:00
|
|
|
if (!handle) return 0; /* no debugger present or other error */
|
|
|
|
|
|
|
|
/* No need to wait on the handle since the process gets suspended
|
|
|
|
* once the event is passed to the debugger, so when we get back
|
|
|
|
* here the event has been continued already.
|
|
|
|
*/
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( get_exception_status )
|
2001-01-26 21:45:41 +01:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_set_reply( req, context, sizeof(*context) );
|
|
|
|
wine_server_call( req );
|
|
|
|
ret = reply->status;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-01-26 21:45:41 +01:00
|
|
|
NtClose( handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
return ret;
|
2000-03-10 23:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-09 18:12:19 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* EXC_DefaultHandling
|
|
|
|
*
|
|
|
|
* Default handling for exceptions. Called when we didn't find a suitable handler.
|
|
|
|
*/
|
|
|
|
static void EXC_DefaultHandling( EXCEPTION_RECORD *rec, CONTEXT *context )
|
|
|
|
{
|
2000-03-10 23:16:10 +01:00
|
|
|
if (send_debug_event( rec, FALSE, context ) == DBG_CONTINUE) return; /* continue execution */
|
1999-06-18 20:21:24 +02:00
|
|
|
|
1999-05-09 18:12:19 +02:00
|
|
|
if (rec->ExceptionFlags & EH_STACK_INVALID)
|
|
|
|
ERR("Exception frame is not in stack limits => unable to dispatch exception.\n");
|
|
|
|
else if (rec->ExceptionCode == EXCEPTION_NONCONTINUABLE_EXCEPTION)
|
|
|
|
ERR("Process attempted to continue execution after noncontinuable exception.\n");
|
|
|
|
else
|
|
|
|
ERR("Unhandled exception code %lx flags %lx addr %p\n",
|
|
|
|
rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
|
2000-07-29 23:56:59 +02:00
|
|
|
NtTerminateProcess( NtCurrentProcess(), 1 );
|
1999-05-09 18:12:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-13 18:21:37 +02:00
|
|
|
/***********************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* RtlRaiseException (NTDLL.@)
|
1999-05-09 18:12:19 +02:00
|
|
|
*/
|
2001-09-11 02:32:32 +02:00
|
|
|
DEFINE_REGS_ENTRYPOINT_1( RtlRaiseException, EXC_RtlRaiseException, EXCEPTION_RECORD * );
|
1999-11-14 00:54:04 +01:00
|
|
|
void WINAPI EXC_RtlRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context )
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
|
|
|
PEXCEPTION_FRAME frame, dispatch, nested_frame;
|
|
|
|
EXCEPTION_RECORD newrec;
|
2002-01-02 22:44:05 +01:00
|
|
|
DWORD res, c;
|
1999-05-09 18:12:19 +02:00
|
|
|
|
2002-01-02 22:44:05 +01:00
|
|
|
TRACE( "code=%lx flags=%lx addr=%p\n", rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
|
|
|
|
for (c=0; c<rec->NumberParameters; c++) TRACE(" info[%ld]=%08lx\n", c, rec->ExceptionInformation[c]);
|
2003-02-11 22:56:59 +01:00
|
|
|
if (rec->ExceptionCode == EXCEPTION_WINE_STUB)
|
|
|
|
FIXME( "call to unimplemented function %s\n", (char*)rec->ExceptionInformation[1] );
|
1999-05-23 22:02:04 +02:00
|
|
|
|
2000-03-10 23:16:10 +01:00
|
|
|
if (send_debug_event( rec, TRUE, context ) == DBG_CONTINUE) return; /* continue execution */
|
1999-06-18 20:21:24 +02:00
|
|
|
|
2001-06-15 21:43:15 +02:00
|
|
|
SIGNAL_Unblock(); /* we may be in a signal handler, and exception handlers may jump out */
|
|
|
|
|
1999-06-22 13:43:42 +02:00
|
|
|
frame = NtCurrentTeb()->except;
|
1999-05-09 18:12:19 +02:00
|
|
|
nested_frame = NULL;
|
|
|
|
while (frame != (PEXCEPTION_FRAME)0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
/* Check frame address */
|
1999-06-22 13:43:42 +02:00
|
|
|
if (((void*)frame < NtCurrentTeb()->stack_low) ||
|
|
|
|
((void*)(frame+1) > NtCurrentTeb()->stack_top) ||
|
1999-05-09 18:12:19 +02:00
|
|
|
(int)frame & 3)
|
|
|
|
{
|
|
|
|
rec->ExceptionFlags |= EH_STACK_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call handler */
|
1999-10-24 01:55:50 +02:00
|
|
|
res = EXC_CallHandler( rec, frame, context, &dispatch, frame->Handler, EXC_RaiseHandler );
|
1999-05-09 18:12:19 +02:00
|
|
|
if (frame == nested_frame)
|
|
|
|
{
|
|
|
|
/* no longer nested */
|
|
|
|
nested_frame = NULL;
|
|
|
|
rec->ExceptionFlags &= ~EH_NESTED_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(res)
|
|
|
|
{
|
|
|
|
case ExceptionContinueExecution:
|
|
|
|
if (!(rec->ExceptionFlags & EH_NONCONTINUABLE)) return;
|
|
|
|
newrec.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
|
|
|
|
newrec.ExceptionFlags = EH_NONCONTINUABLE;
|
|
|
|
newrec.ExceptionRecord = rec;
|
|
|
|
newrec.NumberParameters = 0;
|
|
|
|
RtlRaiseException( &newrec ); /* never returns */
|
|
|
|
break;
|
|
|
|
case ExceptionContinueSearch:
|
|
|
|
break;
|
|
|
|
case ExceptionNestedException:
|
|
|
|
if (nested_frame < dispatch) nested_frame = dispatch;
|
|
|
|
rec->ExceptionFlags |= EH_NESTED_CALL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newrec.ExceptionCode = STATUS_INVALID_DISPOSITION;
|
|
|
|
newrec.ExceptionFlags = EH_NONCONTINUABLE;
|
|
|
|
newrec.ExceptionRecord = rec;
|
|
|
|
newrec.NumberParameters = 0;
|
|
|
|
RtlRaiseException( &newrec ); /* never returns */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
frame = frame->Prev;
|
|
|
|
}
|
|
|
|
EXC_DefaultHandling( rec, context );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* RtlUnwind (NTDLL.@)
|
1999-05-09 18:12:19 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
DEFINE_REGS_ENTRYPOINT_4( RtlUnwind, EXC_RtlUnwind,
|
2002-09-13 00:07:02 +02:00
|
|
|
PVOID, PVOID, PEXCEPTION_RECORD, PVOID );
|
2002-06-01 01:06:46 +02:00
|
|
|
void WINAPI EXC_RtlUnwind( PEXCEPTION_FRAME pEndFrame, LPVOID unusedEip,
|
1999-11-14 00:54:04 +01:00
|
|
|
PEXCEPTION_RECORD pRecord, DWORD returnEax,
|
|
|
|
CONTEXT *context )
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
|
|
|
EXCEPTION_RECORD record, newrec;
|
|
|
|
PEXCEPTION_FRAME frame, dispatch;
|
|
|
|
|
1999-06-26 20:40:24 +02:00
|
|
|
#ifdef __i386__
|
1999-09-27 12:58:45 +02:00
|
|
|
context->Eax = returnEax;
|
1999-06-26 20:40:24 +02:00
|
|
|
#endif
|
1999-05-13 18:21:37 +02:00
|
|
|
|
1999-05-09 18:12:19 +02:00
|
|
|
/* build an exception record, if we do not have one */
|
|
|
|
if (!pRecord)
|
|
|
|
{
|
|
|
|
record.ExceptionCode = STATUS_UNWIND;
|
|
|
|
record.ExceptionFlags = 0;
|
|
|
|
record.ExceptionRecord = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
record.ExceptionAddress = GET_IP(context);
|
1999-05-09 18:12:19 +02:00
|
|
|
record.NumberParameters = 0;
|
|
|
|
pRecord = &record;
|
|
|
|
}
|
|
|
|
|
|
|
|
pRecord->ExceptionFlags |= EH_UNWINDING | (pEndFrame ? 0 : EH_EXIT_UNWIND);
|
1999-05-23 22:02:04 +02:00
|
|
|
|
|
|
|
TRACE( "code=%lx flags=%lx\n", pRecord->ExceptionCode, pRecord->ExceptionFlags );
|
|
|
|
|
1999-05-09 18:12:19 +02:00
|
|
|
/* get chain of exception frames */
|
1999-06-22 13:43:42 +02:00
|
|
|
frame = NtCurrentTeb()->except;
|
1999-05-09 18:12:19 +02:00
|
|
|
while ((frame != (PEXCEPTION_FRAME)0xffffffff) && (frame != pEndFrame))
|
|
|
|
{
|
|
|
|
/* Check frame address */
|
|
|
|
if (pEndFrame && (frame > pEndFrame))
|
|
|
|
{
|
|
|
|
newrec.ExceptionCode = STATUS_INVALID_UNWIND_TARGET;
|
|
|
|
newrec.ExceptionFlags = EH_NONCONTINUABLE;
|
|
|
|
newrec.ExceptionRecord = pRecord;
|
|
|
|
newrec.NumberParameters = 0;
|
|
|
|
RtlRaiseException( &newrec ); /* never returns */
|
|
|
|
}
|
1999-06-22 13:43:42 +02:00
|
|
|
if (((void*)frame < NtCurrentTeb()->stack_low) ||
|
|
|
|
((void*)(frame+1) > NtCurrentTeb()->stack_top) ||
|
1999-05-09 18:12:19 +02:00
|
|
|
(int)frame & 3)
|
|
|
|
{
|
|
|
|
newrec.ExceptionCode = STATUS_BAD_STACK;
|
|
|
|
newrec.ExceptionFlags = EH_NONCONTINUABLE;
|
|
|
|
newrec.ExceptionRecord = pRecord;
|
|
|
|
newrec.NumberParameters = 0;
|
|
|
|
RtlRaiseException( &newrec ); /* never returns */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call handler */
|
1999-10-24 01:55:50 +02:00
|
|
|
switch(EXC_CallHandler( pRecord, frame, context, &dispatch,
|
|
|
|
frame->Handler, EXC_UnwindHandler ))
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
|
|
|
case ExceptionContinueSearch:
|
|
|
|
break;
|
|
|
|
case ExceptionCollidedUnwind:
|
|
|
|
frame = dispatch;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newrec.ExceptionCode = STATUS_INVALID_DISPOSITION;
|
|
|
|
newrec.ExceptionFlags = EH_NONCONTINUABLE;
|
|
|
|
newrec.ExceptionRecord = pRecord;
|
|
|
|
newrec.NumberParameters = 0;
|
|
|
|
RtlRaiseException( &newrec ); /* never returns */
|
|
|
|
break;
|
|
|
|
}
|
2000-08-06 04:42:46 +02:00
|
|
|
frame = __wine_pop_frame( frame );
|
1999-05-09 18:12:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* NtRaiseException (NTDLL.@)
|
1999-05-09 18:12:19 +02:00
|
|
|
*/
|
1999-11-14 00:54:04 +01:00
|
|
|
DEFINE_REGS_ENTRYPOINT_3( NtRaiseException, EXC_NtRaiseException,
|
2001-09-11 02:32:32 +02:00
|
|
|
EXCEPTION_RECORD *, CONTEXT *, BOOL );
|
1999-11-14 00:54:04 +01:00
|
|
|
void WINAPI EXC_NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *ctx,
|
|
|
|
BOOL first, CONTEXT *context )
|
1999-05-09 18:12:19 +02:00
|
|
|
{
|
1999-11-14 00:54:04 +01:00
|
|
|
EXC_RtlRaiseException( rec, ctx );
|
1999-05-09 18:12:19 +02:00
|
|
|
*context = *ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RtlRaiseStatus (NTDLL.@)
|
1999-05-09 18:12:19 +02:00
|
|
|
*
|
|
|
|
* Raise an exception with ExceptionCode = status
|
|
|
|
*/
|
|
|
|
void WINAPI RtlRaiseStatus( NTSTATUS status )
|
|
|
|
{
|
|
|
|
EXCEPTION_RECORD ExceptionRec;
|
|
|
|
|
|
|
|
ExceptionRec.ExceptionCode = status;
|
|
|
|
ExceptionRec.ExceptionFlags = EH_NONCONTINUABLE;
|
|
|
|
ExceptionRec.ExceptionRecord = NULL;
|
|
|
|
ExceptionRec.NumberParameters = 0;
|
|
|
|
RtlRaiseException( &ExceptionRec );
|
|
|
|
}
|
2000-08-06 04:42:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* __wine_exception_handler (NTDLL.@)
|
2000-08-06 04:42:46 +02:00
|
|
|
*
|
|
|
|
* Exception handler for exception blocks declared in Wine code.
|
|
|
|
*/
|
|
|
|
DWORD __wine_exception_handler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame,
|
|
|
|
CONTEXT *context, LPVOID pdispatcher )
|
|
|
|
{
|
|
|
|
__WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
|
|
|
|
|
|
|
|
if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))
|
|
|
|
return ExceptionContinueSearch;
|
|
|
|
if (wine_frame->u.filter)
|
|
|
|
{
|
|
|
|
EXCEPTION_POINTERS ptrs;
|
|
|
|
ptrs.ExceptionRecord = record;
|
|
|
|
ptrs.ContextRecord = context;
|
|
|
|
switch(wine_frame->u.filter( &ptrs ))
|
|
|
|
{
|
|
|
|
case EXCEPTION_CONTINUE_SEARCH:
|
|
|
|
return ExceptionContinueSearch;
|
|
|
|
case EXCEPTION_CONTINUE_EXECUTION:
|
|
|
|
return ExceptionContinueExecution;
|
|
|
|
case EXCEPTION_EXECUTE_HANDLER:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MESSAGE( "Invalid return value from exception filter\n" );
|
|
|
|
assert( FALSE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* hack to make GetExceptionCode() work in handler */
|
|
|
|
wine_frame->ExceptionCode = record->ExceptionCode;
|
|
|
|
wine_frame->ExceptionRecord = wine_frame;
|
|
|
|
|
|
|
|
RtlUnwind( frame, 0, record, 0 );
|
|
|
|
__wine_pop_frame( frame );
|
|
|
|
longjmp( wine_frame->jmp, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* __wine_finally_handler (NTDLL.@)
|
2000-08-06 04:42:46 +02:00
|
|
|
*
|
|
|
|
* Exception handler for try/finally blocks declared in Wine code.
|
|
|
|
*/
|
|
|
|
DWORD __wine_finally_handler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame,
|
|
|
|
CONTEXT *context, LPVOID pdispatcher )
|
|
|
|
{
|
2002-08-13 05:29:17 +02:00
|
|
|
if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
|
|
|
|
{
|
|
|
|
__WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
|
|
|
|
wine_frame->u.finally_func( FALSE );
|
|
|
|
}
|
|
|
|
return ExceptionContinueSearch;
|
|
|
|
}
|
2000-08-06 04:42:46 +02:00
|
|
|
|
2002-08-13 05:29:17 +02:00
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* __wine_callto16_handler
|
|
|
|
*
|
|
|
|
* Handler for exceptions occuring in 16-bit code.
|
|
|
|
*/
|
|
|
|
DWORD __wine_callto16_handler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame,
|
|
|
|
CONTEXT *context, LPVOID pdispatcher )
|
|
|
|
{
|
|
|
|
if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
|
|
|
|
{
|
|
|
|
/* unwinding: restore the stack pointer in the TEB, and leave the Win16 mutex */
|
|
|
|
STACK32FRAME *frame32 = (STACK32FRAME *)((char *)frame - offsetof(STACK32FRAME,frame));
|
|
|
|
NtCurrentTeb()->cur_stack = frame32->frame16;
|
|
|
|
_LeaveWin16Lock();
|
|
|
|
}
|
2000-08-06 04:42:46 +02:00
|
|
|
return ExceptionContinueSearch;
|
|
|
|
}
|