diff --git a/dlls/kernel32/except.c b/dlls/kernel32/except.c index ed31ab97fba..1d2690efd1d 100644 --- a/dlls/kernel32/except.c +++ b/dlls/kernel32/except.c @@ -117,8 +117,9 @@ static int format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer, in case EXCEPTION_ACCESS_VIOLATION: if (rec->NumberParameters == 2) len = snprintf( buffer, size, "Unhandled page fault on %s access to 0x%08lx", - rec->ExceptionInformation[0] ? "write" : "read", - rec->ExceptionInformation[1]); + rec->ExceptionInformation[0] == EXCEPTION_WRITE_FAULT ? "write" : + rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT ? "execute" : "read", + rec->ExceptionInformation[1]); else len = snprintf( buffer, size, "Unhandled page fault"); break; @@ -448,11 +449,11 @@ LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers) { switch(rec->ExceptionInformation[0]) { - case 1: /* write access */ + case EXCEPTION_WRITE_FAULT: if (check_resource_write( (void *)rec->ExceptionInformation[1] )) return EXCEPTION_CONTINUE_EXECUTION; break; - case 8: /* execute access */ + case EXCEPTION_EXECUTE_FAULT: if (check_no_exec( (void *)rec->ExceptionInformation[1] )) return EXCEPTION_CONTINUE_EXECUTION; break; diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 72144bdaeb1..6ff7e39ba89 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -970,7 +970,8 @@ static void WINAPI raise_segv_exception( EXCEPTION_RECORD *rec, CONTEXT *context case EXCEPTION_ACCESS_VIOLATION: if (rec->NumberParameters == 2) { - if ((rec->ExceptionInformation[0] == 8) && check_atl_thunk( rec, context )) goto done; + if (rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT && check_atl_thunk( rec, context )) + goto done; rec->ExceptionCode = VIRTUAL_HandleFault( (void *)rec->ExceptionInformation[1] ); } break; diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c index 51f57c8139a..9a615d9d6ac 100644 --- a/dlls/winex11.drv/dib.c +++ b/dlls/winex11.drv/dib.c @@ -4359,7 +4359,7 @@ static LONG CALLBACK X11DRV_DIB_FaultHandler( PEXCEPTION_POINTERS ep ) if (!found) return EXCEPTION_CONTINUE_SEARCH; X11DRV_DIB_Lock( physBitmap, DIB_Status_None, FALSE ); - if (ep->ExceptionRecord->ExceptionInformation[0]) { + if (ep->ExceptionRecord->ExceptionInformation[0] == EXCEPTION_WRITE_FAULT) { /* the app tried to write the DIB bits */ X11DRV_DIB_Coerce( physBitmap, DIB_Status_AppMod, FALSE ); } else { diff --git a/include/winnt.h b/include/winnt.h index 3bbbcac2a0a..7ae686a6653 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -714,6 +714,10 @@ typedef struct _CONTEXT86 typedef CONTEXT86 CONTEXT; +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + #endif /* __i386__ */ typedef struct _LDT_ENTRY { @@ -754,6 +758,10 @@ typedef struct _LDT_ENTRY { #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + typedef struct DECLSPEC_ALIGN(16) _M128A { ULONGLONG Low; LONGLONG High; @@ -877,6 +885,10 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT { #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L) #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER) +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + typedef struct _CONTEXT { /* selected by CONTEXT_FLOATING_POINT */ @@ -973,6 +985,10 @@ typedef struct _CONTEXT #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER) +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + typedef struct _CONTEXT { /* The flags values within this flag control the contents of a CONTEXT record. @@ -1028,6 +1044,10 @@ typedef struct _CONTEXT { #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER) +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + typedef struct _CONTEXT { DWORD Argument[4]; @@ -1123,6 +1143,10 @@ typedef struct _CONTEXT #define CONTEXT_DEBUG_REGISTERS 0x0008 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER) +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + typedef struct { /* These are selected by CONTEXT_FLOATING_POINT */ @@ -1267,6 +1291,10 @@ typedef struct _STACK_FRAME_HEADER #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER) +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + typedef struct _CONTEXT { DWORD ContextFlags; diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 3a1fb4f7c76..7636b1625bd 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -307,7 +307,8 @@ static DWORD dbg_handle_exception(const EXCEPTION_RECORD* rec, BOOL first_chance case EXCEPTION_ACCESS_VIOLATION: if (rec->NumberParameters == 2) dbg_printf("page fault on %s access to 0x%08lx", - rec->ExceptionInformation[0] ? "write" : "read", + rec->ExceptionInformation[0] == EXCEPTION_WRITE_FAULT ? "write" : + rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT ? "execute" : "read", rec->ExceptionInformation[1]); else dbg_printf("page fault");