mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[RTL] Simplify RtlRaiseException
This commit is contained in:
parent
3ec1ca9b46
commit
e6af7d9dfe
1 changed files with 22 additions and 42 deletions
|
@ -19,57 +19,37 @@ RtlRaiseException(IN PEXCEPTION_RECORD ExceptionRecord)
|
|||
{
|
||||
CONTEXT Context;
|
||||
NTSTATUS Status = STATUS_INVALID_DISPOSITION;
|
||||
ULONG64 ImageBase;
|
||||
PRUNTIME_FUNCTION FunctionEntry;
|
||||
PVOID HandlerData;
|
||||
ULONG64 EstablisherFrame;
|
||||
|
||||
/* Capture the context */
|
||||
/* Capture the current context */
|
||||
RtlCaptureContext(&Context);
|
||||
|
||||
/* Get the function entry for this function */
|
||||
FunctionEntry = RtlLookupFunctionEntry(Context.Rip,
|
||||
&ImageBase,
|
||||
NULL);
|
||||
/* Fix up Context.Rip for the caller */
|
||||
Context.Rip = (ULONG64)_ReturnAddress();
|
||||
|
||||
/* Check if we found it */
|
||||
if (FunctionEntry)
|
||||
/* Fix up Context.Rsp for the caller */
|
||||
Context.Rsp = (ULONG64)_AddressOfReturnAddress() + 8;
|
||||
|
||||
/* Save the exception address */
|
||||
ExceptionRecord->ExceptionAddress = (PVOID)Context.Rip;
|
||||
|
||||
/* Check if user mode debugger is active */
|
||||
if (RtlpCheckForActiveDebugger())
|
||||
{
|
||||
/* Unwind to the caller of this function */
|
||||
RtlVirtualUnwind(UNW_FLAG_NHANDLER,
|
||||
ImageBase,
|
||||
Context.Rip,
|
||||
FunctionEntry,
|
||||
&Context,
|
||||
&HandlerData,
|
||||
&EstablisherFrame,
|
||||
NULL);
|
||||
|
||||
/* Save the exception address */
|
||||
ExceptionRecord->ExceptionAddress = (PVOID)Context.Rip;
|
||||
|
||||
/* Write the context flag */
|
||||
Context.ContextFlags = CONTEXT_FULL;
|
||||
|
||||
/* Check if user mode debugger is active */
|
||||
if (RtlpCheckForActiveDebugger())
|
||||
/* Raise an exception immediately */
|
||||
Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Dispatch the exception and check if we should continue */
|
||||
if (!RtlDispatchException(ExceptionRecord, &Context))
|
||||
{
|
||||
/* Raise an exception immediately */
|
||||
Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
|
||||
/* Raise the exception */
|
||||
Status = ZwRaiseException(ExceptionRecord, &Context, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Dispatch the exception and check if we should continue */
|
||||
if (!RtlDispatchException(ExceptionRecord, &Context))
|
||||
{
|
||||
/* Raise the exception */
|
||||
Status = ZwRaiseException(ExceptionRecord, &Context, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Continue, go back to previous context */
|
||||
Status = ZwContinue(&Context, FALSE);
|
||||
}
|
||||
/* Continue, go back to previous context */
|
||||
Status = ZwContinue(&Context, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue