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

Also rename it to virtual_handle_fault for consistency.
This commit is contained in:
Alexandre Julliard 2008-11-25 12:02:16 +01:00
parent aece8e0700
commit 81b9ca5dbd
6 changed files with 14 additions and 11 deletions

View File

@ -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 void virtual_clear_thread_stack(void);
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_UseLargeAddressSpace(void);
extern struct _KUSER_SHARED_DATA *user_shared_data;

View File

@ -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 ))
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;
case EXCEPTION_DATATYPE_MISALIGNMENT:

View File

@ -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 )
{
EXCEPTION_RECORD rec;
DWORD page_fault_code = EXCEPTION_ACCESS_VIOLATION;
rec.ExceptionRecord = NULL;
rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
@ -336,9 +335,8 @@ static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr
rec.NumberParameters = 2;
rec.ExceptionInformation[0] = 0; /* FIXME ? */
rec.ExceptionInformation[1] = (ULONG_PTR)addr;
if (!(page_fault_code=VIRTUAL_HandleFault(addr)))
if (!(rec.ExceptionCode = virtual_handle_fault(addr, rec.ExceptionInformation[0])))
return;
rec.ExceptionCode = page_fault_code;
break;
default:FIXME("Unhandled SIGSEGV/%x\n",code);
break;
@ -358,9 +356,8 @@ static void do_segv( CONTEXT *context, int trap, int err, int code, void * addr
rec.NumberParameters = 2;
rec.ExceptionInformation[0] = 0; /* FIXME ? */
rec.ExceptionInformation[1] = (ULONG_PTR)addr;
if (!(page_fault_code=VIRTUAL_HandleFault(addr)))
if (!(rec.ExceptionCode = virtual_handle_fault(addr, rec.ExceptionInformation[0])))
return;
rec.ExceptionCode = page_fault_code;
break;
#endif
default:FIXME("Unhandled SIGBUS/%x\n",code);

View File

@ -180,12 +180,13 @@ static void segv_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
EXCEPTION_RECORD rec;
CONTEXT context;
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
/* we want the page-fault case to be fast */
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 );
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
rec.ExceptionRecord = NULL;
rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
rec.ExceptionAddress = (LPVOID)context.pc;

View File

@ -263,6 +263,8 @@ static HANDLER_DEF(segv_handler)
rec.NumberParameters = 2;
rec.ExceptionInformation[0] = (ERROR_sig(HANDLER_CONTEXT) & 2) != 0;
rec.ExceptionInformation[1] = (ULONG_PTR)FAULT_ADDRESS;
if (!(rec.ExceptionCode = virtual_handle_fault( FAULT_ADDRESS, rec.ExceptionInformation[0] )))
goto done;
#endif
break;
case TRAP_x86_ALIGNFLT: /* Alignment check exception */
@ -282,6 +284,7 @@ static HANDLER_DEF(segv_handler)
}
__regs_RtlRaiseException( &rec, &context );
done:
restore_context( &context, HANDLER_CONTEXT );
}

View File

@ -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;
NTSTATUS ret = STATUS_ACCESS_VIOLATION;