From a82f4dd9b77d5d880b948ceef213fb36ece10461 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Fri, 15 Feb 2008 15:19:29 +0000 Subject: [PATCH] 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. --- dlls/kernel32/console.c | 4 ++-- dlls/ole32/moniker.c | 4 ++-- dlls/rpcrt4/cstub.c | 4 ++-- dlls/rpcrt4/rpc_server.c | 11 ++--------- dlls/winedos/dosvm.c | 6 +++--- dlls/winedos/int31.c | 6 +++--- include/wine/exception.h | 3 --- programs/explorer/hal.c | 5 +++-- programs/winedbg/dbg.y | 6 +++--- 9 files changed, 20 insertions(+), 29 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index b14b9c028df..1d86f8a1e67 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -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; } diff --git a/dlls/ole32/moniker.c b/dlls/ole32/moniker.c index cc83d95b59e..b1918213f9a 100644 --- a/dlls/ole32/moniker.c +++ b/dlls/ole32/moniker.c @@ -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: diff --git a/dlls/rpcrt4/cstub.c b/dlls/rpcrt4/cstub.c index cd07c297390..b416a10bd69 100644 --- a/dlls/rpcrt4/cstub.c +++ b/dlls/rpcrt4/cstub.c @@ -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; } diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c index 9ffec507226..5404259c2c7 100644 --- a/dlls/rpcrt4/rpc_server.c +++ b/dlls/rpcrt4/rpc_server.c @@ -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; diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c index 2d1b915210a..51e8e568e7e 100644 --- a/dlls/winedos/dosvm.c +++ b/dlls/winedos/dosvm.c @@ -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; diff --git a/dlls/winedos/int31.c b/dlls/winedos/int31.c index dc7351ce5a4..b1dfe4b3dba 100644 --- a/dlls/winedos/int31.c +++ b/dlls/winedos/int31.c @@ -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) { diff --git a/include/wine/exception.h b/include/wine/exception.h index adf892694c7..10b6c90fc87 100644 --- a/include/wine/exception.h +++ b/include/wine/exception.h @@ -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) diff --git a/programs/explorer/hal.c b/programs/explorer/hal.c index 38b0523a58f..df31c6b9a50 100644 --- a/programs/explorer/hal.c +++ b/programs/explorer/hal.c @@ -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; } diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 4679986966a..70bc66f0574 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -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; }