Commit 81b9ca5d authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Pass the error code to VIRTUAL_HandleFault, and allow it to ignore the exception.

Also rename it to virtual_handle_fault for consistency.
parent aece8e07
...@@ -141,7 +141,7 @@ extern SIZE_T virtual_free_system_view( PVOID *addr_ptr ); ...@@ -141,7 +141,7 @@ extern SIZE_T virtual_free_system_view( PVOID *addr_ptr );
extern NTSTATUS virtual_alloc_thread_stack( void *base, SIZE_T stack_size ); extern NTSTATUS virtual_alloc_thread_stack( void *base, SIZE_T stack_size );
extern void virtual_clear_thread_stack(void); extern void virtual_clear_thread_stack(void);
extern BOOL virtual_handle_stack_fault( void *addr ); extern BOOL virtual_handle_stack_fault( void *addr );
extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr); extern NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err );
extern void VIRTUAL_SetForceExec( BOOL enable ); extern void VIRTUAL_SetForceExec( BOOL enable );
extern void VIRTUAL_UseLargeAddressSpace(void); extern void VIRTUAL_UseLargeAddressSpace(void);
extern struct _KUSER_SHARED_DATA *user_shared_data; extern struct _KUSER_SHARED_DATA *user_shared_data;
......
...@@ -1209,7 +1209,9 @@ static void WINAPI raise_segv_exception( EXCEPTION_RECORD *rec, CONTEXT *context ...@@ -1209,7 +1209,9 @@ static void WINAPI raise_segv_exception( EXCEPTION_RECORD *rec, CONTEXT *context
{ {
if (rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT && check_atl_thunk( rec, context )) if (rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT && check_atl_thunk( rec, context ))
goto done; goto done;
rec->ExceptionCode = VIRTUAL_HandleFault( (void *)rec->ExceptionInformation[1] ); if (!(rec->ExceptionCode = virtual_handle_fault( (void *)rec->ExceptionInformation[1],
rec->ExceptionInformation[0] )))
goto done;
} }
break; break;
case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_DATATYPE_MISALIGNMENT:
......
...@@ -321,7 +321,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context ) ...@@ -321,7 +321,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context )
static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr ) static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr )
{ {
EXCEPTION_RECORD rec; EXCEPTION_RECORD rec;
DWORD page_fault_code = EXCEPTION_ACCESS_VIOLATION;
rec.ExceptionRecord = NULL; rec.ExceptionRecord = NULL;
rec.ExceptionFlags = EXCEPTION_CONTINUABLE; rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
...@@ -336,9 +335,8 @@ static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr ...@@ -336,9 +335,8 @@ static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr
rec.NumberParameters = 2; rec.NumberParameters = 2;
rec.ExceptionInformation[0] = 0; /* FIXME ? */ rec.ExceptionInformation[0] = 0; /* FIXME ? */
rec.ExceptionInformation[1] = (ULONG_PTR)addr; rec.ExceptionInformation[1] = (ULONG_PTR)addr;
if (!(page_fault_code=VIRTUAL_HandleFault(addr))) if (!(rec.ExceptionCode = virtual_handle_fault(addr, rec.ExceptionInformation[0])))
return; return;
rec.ExceptionCode = page_fault_code;
break; break;
default:FIXME("Unhandled SIGSEGV/%x\n",code); default:FIXME("Unhandled SIGSEGV/%x\n",code);
break; break;
...@@ -358,9 +356,8 @@ static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr ...@@ -358,9 +356,8 @@ static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr
rec.NumberParameters = 2; rec.NumberParameters = 2;
rec.ExceptionInformation[0] = 0; /* FIXME ? */ rec.ExceptionInformation[0] = 0; /* FIXME ? */
rec.ExceptionInformation[1] = (ULONG_PTR)addr; rec.ExceptionInformation[1] = (ULONG_PTR)addr;
if (!(page_fault_code=VIRTUAL_HandleFault(addr))) if (!(rec.ExceptionCode = virtual_handle_fault(addr, rec.ExceptionInformation[0])))
return; return;
rec.ExceptionCode = page_fault_code;
break; break;
#endif #endif
default:FIXME("Unhandled SIGBUS/%x\n",code); default:FIXME("Unhandled SIGBUS/%x\n",code);
......
...@@ -180,12 +180,13 @@ static void segv_handler( int signal, siginfo_t *info, ucontext_t *ucontext ) ...@@ -180,12 +180,13 @@ static void segv_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
EXCEPTION_RECORD rec; EXCEPTION_RECORD rec;
CONTEXT context; CONTEXT context;
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
/* we want the page-fault case to be fast */ /* we want the page-fault case to be fast */
if ( info->si_code == SEGV_ACCERR ) if ( info->si_code == SEGV_ACCERR )
if (VIRTUAL_HandleFault( (LPVOID)info->si_addr )) return; if (!(rec.ExceptionCode = virtual_handle_fault( info->si_addr, 0 ))) return;
save_context( &context, ucontext ); save_context( &context, ucontext );
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
rec.ExceptionRecord = NULL; rec.ExceptionRecord = NULL;
rec.ExceptionFlags = EXCEPTION_CONTINUABLE; rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
rec.ExceptionAddress = (LPVOID)context.pc; rec.ExceptionAddress = (LPVOID)context.pc;
......
...@@ -263,6 +263,8 @@ static HANDLER_DEF(segv_handler) ...@@ -263,6 +263,8 @@ static HANDLER_DEF(segv_handler)
rec.NumberParameters = 2; rec.NumberParameters = 2;
rec.ExceptionInformation[0] = (ERROR_sig(HANDLER_CONTEXT) & 2) != 0; rec.ExceptionInformation[0] = (ERROR_sig(HANDLER_CONTEXT) & 2) != 0;
rec.ExceptionInformation[1] = (ULONG_PTR)FAULT_ADDRESS; rec.ExceptionInformation[1] = (ULONG_PTR)FAULT_ADDRESS;
if (!(rec.ExceptionCode = virtual_handle_fault( FAULT_ADDRESS, rec.ExceptionInformation[0] )))
goto done;
#endif #endif
break; break;
case TRAP_x86_ALIGNFLT: /* Alignment check exception */ case TRAP_x86_ALIGNFLT: /* Alignment check exception */
...@@ -282,6 +284,7 @@ static HANDLER_DEF(segv_handler) ...@@ -282,6 +284,7 @@ static HANDLER_DEF(segv_handler)
} }
__regs_RtlRaiseException( &rec, &context ); __regs_RtlRaiseException( &rec, &context );
done:
restore_context( &context, HANDLER_CONTEXT ); restore_context( &context, HANDLER_CONTEXT );
} }
......
...@@ -1399,9 +1399,9 @@ void virtual_clear_thread_stack(void) ...@@ -1399,9 +1399,9 @@ void virtual_clear_thread_stack(void)
/*********************************************************************** /***********************************************************************
* VIRTUAL_HandleFault * virtual_handle_fault
*/ */
NTSTATUS VIRTUAL_HandleFault( LPCVOID addr ) NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err )
{ {
FILE_VIEW *view; FILE_VIEW *view;
NTSTATUS ret = STATUS_ACCESS_VIOLATION; NTSTATUS ret = STATUS_ACCESS_VIOLATION;
......
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