Commit a82f4dd9 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

Don't use GetExceptionCode and GetExceptionInformation in exception filter functions.

When using native compiler exceptions, it isn't valid to use GetExceptionCode and GetExceptionInformation anywhere other than in the filter or handler blocks since it would be very hard for the compiler to work out where to retrieve the exception information from on the stack. Therefore, remove the WINE_EXCEPTION_FILTER and WINE_FINALLY_FUNC macros which enabled GetExceptionCode, GetExceptionInformation and AbnormalTermination to be used inside of the functions they declared and fix up all callers to access the information directly.
parent 1d0bcb3b
......@@ -1642,9 +1642,9 @@ BOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE func, BOOL add)
return ret;
}
static WINE_EXCEPTION_FILTER(CONSOLE_CtrlEventHandler)
static LONG WINAPI CONSOLE_CtrlEventHandler(EXCEPTION_POINTERS *eptr)
{
TRACE("(%x)\n", GetExceptionCode());
TRACE("(%x)\n", eptr->ExceptionRecord->ExceptionCode);
return EXCEPTION_EXECUTE_HANDLER;
}
......
......@@ -53,9 +53,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
* constant is (http://msdn2.microsoft.com/en-us/library/ms693773.aspx) */
#define MAX_COMPARISON_DATA 2048
static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr)
static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *eptr)
{
switch (GetExceptionCode())
switch (eptr->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
case EXCEPTION_ILLEGAL_INSTRUCTION:
......
......@@ -39,9 +39,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
#define STUB_HEADER(This) (((const CInterfaceStubHeader*)((This)->lpVtbl))[-1])
static WINE_EXCEPTION_FILTER(stub_filter)
static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr)
{
if (GetExceptionInformation()->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
if (eptr->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
return EXCEPTION_CONTINUE_SEARCH;
return EXCEPTION_EXECUTE_HANDLER;
}
......
......@@ -153,14 +153,6 @@ static void RPCRT4_release_server_interface(RpcServerInterface *sif)
}
}
static WINE_EXCEPTION_FILTER(rpc_filter)
{
WARN("exception caught with code 0x%08x = %d\n", GetExceptionCode(), GetExceptionCode());
TRACE("returning failure packet\n");
/* catch every exception */
return EXCEPTION_EXECUTE_HANDLER;
}
static RPC_STATUS process_bind_packet(RpcConnection *conn, RpcPktBindHdr *hdr, RPC_MESSAGE *msg)
{
RPC_STATUS status;
......@@ -294,7 +286,8 @@ static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr *
RPCRT4_SetThreadCurrentCallHandle(msg->Handle);
__TRY {
if (func) func(msg);
} __EXCEPT(rpc_filter) {
} __EXCEPT(NULL) {
WARN("exception caught with code 0x%08x = %d\n", GetExceptionCode(), GetExceptionCode());
exception = TRUE;
if (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
status = ERROR_NOACCESS;
......
......@@ -521,10 +521,10 @@ DWORD WINAPI DOSVM_Loop( HANDLE hThread )
}
}
static WINE_EXCEPTION_FILTER(exception_handler)
static LONG WINAPI exception_handler(EXCEPTION_POINTERS *eptr)
{
EXCEPTION_RECORD *rec = GetExceptionInformation()->ExceptionRecord;
CONTEXT *context = GetExceptionInformation()->ContextRecord;
EXCEPTION_RECORD *rec = eptr->ExceptionRecord;
CONTEXT *context = eptr->ContextRecord;
int arg = rec->ExceptionInformation[0];
BOOL ret;
......
......@@ -108,11 +108,11 @@ static WORD alloc_pm_selector( WORD seg, unsigned char flags )
* Handle EXCEPTION_VM86_STI exceptions generated
* when there are pending asynchronous events.
*/
static WINE_EXCEPTION_FILTER(dpmi_exception_handler)
static LONG WINAPI dpmi_exception_handler(EXCEPTION_POINTERS *eptr)
{
#ifdef __i386__
EXCEPTION_RECORD *rec = GetExceptionInformation()->ExceptionRecord;
CONTEXT *context = GetExceptionInformation()->ContextRecord;
EXCEPTION_RECORD *rec = eptr->ExceptionRecord;
CONTEXT *context = eptr->ContextRecord;
if (rec->ExceptionCode == EXCEPTION_VM86_STI)
{
......
......@@ -126,9 +126,6 @@ typedef void (CALLBACK *__WINE_FINALLY)(BOOL);
/* convenience handler for page fault exceptions */
#define __EXCEPT_PAGE_FAULT __EXCEPT( (__WINE_FILTER)1 )
#define WINE_EXCEPTION_FILTER(func) LONG WINAPI func( EXCEPTION_POINTERS *__eptr )
#define WINE_FINALLY_FUNC(func) void WINAPI func( BOOL __normal )
#define GetExceptionInformation() (__eptr)
#define GetExceptionCode() (__eptr->ExceptionRecord->ExceptionCode)
#define AbnormalTermination() (!__normal)
......
......@@ -102,9 +102,10 @@ failed:
return FALSE;
}
static WINE_EXCEPTION_FILTER(assert_fault)
static LONG WINAPI assert_fault(EXCEPTION_POINTERS *eptr)
{
if (GetExceptionCode() == EXCEPTION_WINE_ASSERTION) return EXCEPTION_EXECUTE_HANDLER;
if (eptr->ExceptionRecord->ExceptionCode == EXCEPTION_WINE_ASSERTION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
......
......@@ -401,9 +401,9 @@ lvalue:
%%
static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
static LONG WINAPI wine_dbg_cmd(EXCEPTION_POINTERS *eptr)
{
switch (GetExceptionCode())
switch (eptr->ExceptionRecord->ExceptionCode)
{
case DEBUG_STATUS_INTERNAL_ERROR:
dbg_printf("\nWineDbg internal error\n");
......@@ -436,7 +436,7 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
dbg_interrupt_debuggee();
return EXCEPTION_CONTINUE_EXECUTION;
default:
dbg_printf("\nException %x\n", GetExceptionCode());
dbg_printf("\nException %x\n", eptr->ExceptionRecord->ExceptionCode);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment