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