mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Fix exception handling/PSEH. Fixes bug 797.
svn path=/trunk/; revision=18000
This commit is contained in:
parent
3d31bdc1fc
commit
43fc149042
2 changed files with 19 additions and 19 deletions
|
@ -109,7 +109,7 @@ CaptureRest:
|
||||||
mov [ebx+CONTEXT_EBP], eax
|
mov [ebx+CONTEXT_EBP], eax
|
||||||
|
|
||||||
/* And get ESP */
|
/* And get ESP */
|
||||||
mov eax, [ebp+8]
|
lea eax, [ebp+8]
|
||||||
mov [ebx+CONTEXT_ESP], eax
|
mov [ebx+CONTEXT_ESP], eax
|
||||||
|
|
||||||
/* Return to the caller */
|
/* Return to the caller */
|
||||||
|
|
|
@ -56,12 +56,12 @@ RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
EXCEPTION_DISPOSITION ReturnValue;
|
EXCEPTION_DISPOSITION ReturnValue;
|
||||||
ULONG_PTR StackLow, StackHigh;
|
ULONG_PTR StackLow, StackHigh;
|
||||||
ULONG_PTR RegistrationFrameEnd;
|
ULONG_PTR RegistrationFrameEnd;
|
||||||
DPRINT1("RtlDispatchException(): %p, %p \n", ExceptionRecord, Context);
|
DPRINT("RtlDispatchException(): %p, %p \n", ExceptionRecord, Context);
|
||||||
|
|
||||||
/* Get the current stack limits and registration frame */
|
/* Get the current stack limits and registration frame */
|
||||||
RtlpGetStackLimits(&StackLow, &StackHigh);
|
RtlpGetStackLimits(&StackLow, &StackHigh);
|
||||||
RegistrationFrame = RtlpGetExceptionList();
|
RegistrationFrame = RtlpGetExceptionList();
|
||||||
DPRINT1("RegistrationFrame is 0x%X\n", RegistrationFrame);
|
DPRINT("RegistrationFrame is 0x%X\n", RegistrationFrame);
|
||||||
|
|
||||||
/* Now loop every frame */
|
/* Now loop every frame */
|
||||||
while (RegistrationFrame != EXCEPTION_CHAIN_END)
|
while (RegistrationFrame != EXCEPTION_CHAIN_END)
|
||||||
|
@ -92,20 +92,20 @@ RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if logging is enabled */
|
/* Check if logging is enabled */
|
||||||
DPRINT1("Checking for logging\n");
|
DPRINT("Checking for logging\n");
|
||||||
RtlpCheckLogException(ExceptionRecord,
|
RtlpCheckLogException(ExceptionRecord,
|
||||||
Context,
|
Context,
|
||||||
RegistrationFrame,
|
RegistrationFrame,
|
||||||
sizeof(*RegistrationFrame));
|
sizeof(*RegistrationFrame));
|
||||||
|
|
||||||
/* Call the handler */
|
/* Call the handler */
|
||||||
DPRINT1("Executing handler: %p\n", RegistrationFrame->Handler);
|
DPRINT("Executing handler: %p\n", RegistrationFrame->Handler);
|
||||||
ReturnValue = RtlpExecuteHandlerForException(ExceptionRecord,
|
ReturnValue = RtlpExecuteHandlerForException(ExceptionRecord,
|
||||||
RegistrationFrame,
|
RegistrationFrame,
|
||||||
Context,
|
Context,
|
||||||
&DispatcherContext,
|
&DispatcherContext,
|
||||||
RegistrationFrame->Handler);
|
RegistrationFrame->Handler);
|
||||||
DPRINT1("Handler returned: %lx\n", ReturnValue);
|
DPRINT("Handler returned: %lx\n", ReturnValue);
|
||||||
|
|
||||||
/* Check if this is a nested frame */
|
/* Check if this is a nested frame */
|
||||||
if (RegistrationFrame == NestedFrame)
|
if (RegistrationFrame == NestedFrame)
|
||||||
|
@ -128,7 +128,7 @@ RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
ExceptionRecord2.NumberParameters = 0;
|
ExceptionRecord2.NumberParameters = 0;
|
||||||
|
|
||||||
/* Raise the exception */
|
/* Raise the exception */
|
||||||
DPRINT1("Non-continuable\n");
|
DPRINT("Non-continuable\n");
|
||||||
RtlRaiseException(&ExceptionRecord2);
|
RtlRaiseException(&ExceptionRecord2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -147,6 +147,7 @@ RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
}
|
}
|
||||||
else if (ReturnValue == ExceptionContinueSearch)
|
else if (ReturnValue == ExceptionContinueSearch)
|
||||||
{
|
{
|
||||||
|
/* Do nothing */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -165,7 +166,7 @@ RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unhandled, return false */
|
/* Unhandled, return false */
|
||||||
DPRINT1("FALSE\n");
|
DPRINT("FALSE\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +188,7 @@ RtlUnwind(PVOID RegistrationFrame OPTIONAL,
|
||||||
ULONG_PTR RegistrationFrameEnd;
|
ULONG_PTR RegistrationFrameEnd;
|
||||||
CONTEXT LocalContext;
|
CONTEXT LocalContext;
|
||||||
PCONTEXT Context;
|
PCONTEXT Context;
|
||||||
DPRINT1("RtlUnwind(). RegistrationFrame 0x%X\n", RegistrationFrame);
|
DPRINT("RtlUnwind(). RegistrationFrame 0x%X\n", RegistrationFrame);
|
||||||
|
|
||||||
/* Get the current stack limits */
|
/* Get the current stack limits */
|
||||||
RtlpGetStackLimits(&StackLow, &StackHigh);
|
RtlpGetStackLimits(&StackLow, &StackHigh);
|
||||||
|
@ -227,13 +228,13 @@ RtlUnwind(PVOID RegistrationFrame OPTIONAL,
|
||||||
RtlpCaptureContext(Context);
|
RtlpCaptureContext(Context);
|
||||||
|
|
||||||
/* Pop the current arguments off */
|
/* Pop the current arguments off */
|
||||||
LocalContext.Esp += sizeof(RegistrationFrame) +
|
Context->Esp += sizeof(RegistrationFrame) +
|
||||||
sizeof(ReturnAddress) +
|
sizeof(ReturnAddress) +
|
||||||
sizeof(ExceptionRecord) +
|
sizeof(ExceptionRecord) +
|
||||||
sizeof(ReturnValue);
|
sizeof(ReturnValue);
|
||||||
|
|
||||||
/* Set the new value for EAX */
|
/* Set the new value for EAX */
|
||||||
LocalContext.Eax = (ULONG)EaxValue;
|
Context->Eax = (ULONG)EaxValue;
|
||||||
|
|
||||||
/* Get the current frame */
|
/* Get the current frame */
|
||||||
RegistrationFrame2 = RtlpGetExceptionList();
|
RegistrationFrame2 = RtlpGetExceptionList();
|
||||||
|
@ -241,7 +242,7 @@ RtlUnwind(PVOID RegistrationFrame OPTIONAL,
|
||||||
/* Now loop every frame */
|
/* Now loop every frame */
|
||||||
while (RegistrationFrame2 != EXCEPTION_CHAIN_END)
|
while (RegistrationFrame2 != EXCEPTION_CHAIN_END)
|
||||||
{
|
{
|
||||||
DPRINT1("RegistrationFrame is 0x%X\n", RegistrationFrame2);
|
DPRINT("RegistrationFrame is 0x%X\n", RegistrationFrame2);
|
||||||
|
|
||||||
/* If this is the target */
|
/* If this is the target */
|
||||||
if (RegistrationFrame2 == RegistrationFrame)
|
if (RegistrationFrame2 == RegistrationFrame)
|
||||||
|
@ -297,19 +298,18 @@ RtlUnwind(PVOID RegistrationFrame OPTIONAL,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Call the handler */
|
/* Call the handler */
|
||||||
DPRINT1("Executing unwind handler: %p\n", RegistrationFrame2->Handler);
|
DPRINT("Executing unwind handler: %p\n", RegistrationFrame2->Handler);
|
||||||
ReturnValue = RtlpExecuteHandlerForUnwind(ExceptionRecord,
|
ReturnValue = RtlpExecuteHandlerForUnwind(ExceptionRecord,
|
||||||
RegistrationFrame2,
|
RegistrationFrame2,
|
||||||
Context,
|
Context,
|
||||||
&DispatcherContext,
|
&DispatcherContext,
|
||||||
RegistrationFrame2->Handler);
|
RegistrationFrame2->Handler);
|
||||||
DPRINT1("Handler returned: %lx\n", ReturnValue);
|
DPRINT("Handler returned: %lx\n", ReturnValue);
|
||||||
|
|
||||||
/* Handle the dispositions */
|
/* Handle the dispositions */
|
||||||
if (ReturnValue == ExceptionContinueSearch)
|
if (ReturnValue == ExceptionContinueSearch)
|
||||||
{
|
{
|
||||||
/* Get out of here */
|
/* Do nothing */
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (ReturnValue == ExceptionCollidedUnwind)
|
else if (ReturnValue == ExceptionCollidedUnwind)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue