mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Okay so we've got a basic KiDispatchException, we now need KiTrapFrameToContext and KiContextToTrapFrame.
- We aren't really sure where the hell we are since we can't printf anything otherwise we'll trap again and end up in an infinite loop. - So we're debugging with while (TRUE). svn path=/trunk/; revision=34481
This commit is contained in:
parent
784b0af4cd
commit
673e2fd5fd
2 changed files with 144 additions and 2 deletions
|
@ -25,6 +25,149 @@ KeContextToTrapFrame(IN PCONTEXT Context,
|
|||
IN ULONG ContextFlags,
|
||||
IN KPROCESSOR_MODE PreviousMode)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
|
||||
IN PKEXCEPTION_FRAME ExceptionFrame,
|
||||
IN OUT PCONTEXT Context)
|
||||
{
|
||||
while (TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||
IN PKEXCEPTION_FRAME ExceptionFrame,
|
||||
IN PKTRAP_FRAME TrapFrame,
|
||||
IN KPROCESSOR_MODE PreviousMode,
|
||||
IN BOOLEAN FirstChance)
|
||||
{
|
||||
CONTEXT Context;
|
||||
|
||||
//
|
||||
// Increase number of Exception Dispatches
|
||||
//
|
||||
KeGetCurrentPrcb()->KeExceptionDispatchCount++;
|
||||
|
||||
//
|
||||
// Set the context flags
|
||||
//
|
||||
Context.ContextFlags = CONTEXT_FULL;
|
||||
|
||||
//
|
||||
// FIXME: Fuck floating point
|
||||
//
|
||||
|
||||
//
|
||||
// Get a Context
|
||||
//
|
||||
KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
|
||||
|
||||
//
|
||||
// Look at our exception code
|
||||
//
|
||||
switch (ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
//
|
||||
// Breakpoint
|
||||
//
|
||||
case STATUS_BREAKPOINT:
|
||||
|
||||
//
|
||||
// Decrement PC by one
|
||||
//
|
||||
Context.Pc--;
|
||||
break;
|
||||
|
||||
//
|
||||
// Internal exception
|
||||
//
|
||||
case KI_EXCEPTION_ACCESS_VIOLATION:
|
||||
|
||||
//
|
||||
// Set correct code
|
||||
//
|
||||
ExceptionRecord->ExceptionCode = STATUS_ACCESS_VIOLATION;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle kernel-mode first, it's simpler
|
||||
//
|
||||
if (PreviousMode == KernelMode)
|
||||
{
|
||||
//
|
||||
// Check if this is a first-chance exception
|
||||
//
|
||||
if (FirstChance == TRUE)
|
||||
{
|
||||
//
|
||||
// Break into the debugger for the first time
|
||||
//
|
||||
if (KiDebugRoutine(TrapFrame,
|
||||
ExceptionFrame,
|
||||
ExceptionRecord,
|
||||
&Context,
|
||||
PreviousMode,
|
||||
FALSE))
|
||||
{
|
||||
//
|
||||
// Exception was handled
|
||||
//
|
||||
goto Handled;
|
||||
}
|
||||
|
||||
//
|
||||
// If the Debugger couldn't handle it, dispatch the exception
|
||||
//
|
||||
if (RtlDispatchException(ExceptionRecord, &Context)) goto Handled;
|
||||
}
|
||||
|
||||
//
|
||||
// This is a second-chance exception, only for the debugger
|
||||
//
|
||||
if (KiDebugRoutine(TrapFrame,
|
||||
ExceptionFrame,
|
||||
ExceptionRecord,
|
||||
&Context,
|
||||
PreviousMode,
|
||||
TRUE))
|
||||
{
|
||||
//
|
||||
// Exception was handled
|
||||
//
|
||||
goto Handled;
|
||||
}
|
||||
|
||||
//
|
||||
// Third strike; you're out
|
||||
//
|
||||
KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
|
||||
ExceptionRecord->ExceptionCode,
|
||||
(ULONG_PTR)ExceptionRecord->ExceptionAddress,
|
||||
(ULONG_PTR)TrapFrame,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// FIXME: User mode
|
||||
//
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
|
||||
Handled:
|
||||
//
|
||||
// Convert the context back into Trap/Exception Frames
|
||||
//
|
||||
KeContextToTrapFrame(&Context,
|
||||
ExceptionFrame,
|
||||
TrapFrame,
|
||||
Context.ContextFlags,
|
||||
PreviousMode);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ GENERATE_ARM_STUB RtlInitializeContext
|
|||
//
|
||||
GENERATE_ARM_STUB KiInitializeUserApc
|
||||
GENERATE_ARM_STUB KeDisableInterrupts
|
||||
GENERATE_ARM_STUB KiDispatchException
|
||||
GENERATE_ARM_STUB KiSwapProcess
|
||||
GENERATE_ARM_STUB KeSwitchKernelStack
|
||||
|
||||
|
|
Loading…
Reference in a new issue