[NTOS:Ke/x64] Improve KiDispatchExceptionToUser

Return back to the caller instead of exiting through KiServiceExit2, which is broken and needs to be changed to allow restoring of an exception frame.
This commit is contained in:
Timo Kreuzer 2022-12-15 20:58:32 +01:00
parent 24b4026ce8
commit 5b82ada2ed

View file

@ -93,7 +93,7 @@ KeInitExceptions(VOID)
} }
static static
VOID BOOLEAN
KiDispatchExceptionToUser( KiDispatchExceptionToUser(
IN PKTRAP_FRAME TrapFrame, IN PKTRAP_FRAME TrapFrame,
IN PCONTEXT Context, IN PCONTEXT Context,
@ -147,7 +147,7 @@ KiDispatchExceptionToUser(
/* Nothing we can do here */ /* Nothing we can do here */
_disable(); _disable();
_SEH2_YIELD(return); return FALSE;
} }
_SEH2_END; _SEH2_END;
@ -172,7 +172,7 @@ KiDispatchExceptionToUser(
_disable(); _disable();
/* Exit to usermode */ /* Exit to usermode */
KiServiceExit2(TrapFrame); return TRUE;
} }
static static
@ -361,8 +361,12 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
/* Forward exception to user mode debugger */ /* Forward exception to user mode debugger */
if (DbgkForwardException(ExceptionRecord, TRUE, FALSE)) return; if (DbgkForwardException(ExceptionRecord, TRUE, FALSE)) return;
/* Forward exception to user mode (does not return, if successful) */ /* Forward exception to user mode */
KiDispatchExceptionToUser(TrapFrame, &Context, ExceptionRecord); if (KiDispatchExceptionToUser(TrapFrame, &Context, ExceptionRecord))
{
/* Success, the exception will be handled by KiUserExceptionDispatcher */
return;
}
/* Failed to dispatch, fall through for second chance handling */ /* Failed to dispatch, fall through for second chance handling */
} }