public static unsafe void Throw(FOS_System.Exception ex) { Kernel.FOS_System.GC.IncrementRefCount(ex); //BasicConsole.WriteLine("Exception thrown:"); //BasicConsole.WriteLine(ex.Message); if (State->CurrentHandlerPtr->Ex != null) { //GC ref count remains consistent because the Ex pointer below is going to be replaced but // same pointer stored in InnerException. // Result is ref count goes: +1 here, -1 below ex.InnerException = (Kernel.FOS_System.Exception)Utilities.ObjectUtilities.GetObject(State->CurrentHandlerPtr->Ex); } if (ex.InstructionAddress == 0) { ex.InstructionAddress = *((uint *)BasePointer + 1); } State->CurrentHandlerPtr->Ex = Utilities.ObjectUtilities.GetHandle(ex); State->CurrentHandlerPtr->ExPending = 1; HandleException(); // We never expect to get here... HaltReason = "HandleException returned!"; BasicConsole.WriteLine(HaltReason); // Try to cause fault *((byte *)0x800000000) = 0; }
protected void OutputExceptionInfo(FOS_System.Exception Ex) { if (Ex != null) { console.WarningColour(); console.WriteLine(Ex.Message); if (Ex is FOS_System.Exceptions.PageFaultException) { console.WriteLine(((FOS_System.String) " - Address: ") + ((FOS_System.Exceptions.PageFaultException)Ex).address); console.WriteLine(((FOS_System.String) " - Error code: ") + ((FOS_System.Exceptions.PageFaultException)Ex).errorCode); } console.DefaultColour(); } else { console.WriteLine("No current exception."); } }
public static void ThrowFromPtr(UInt32 *exPtr) { FOS_System.Exception ex = (FOS_System.Exception)Utilities.ObjectUtilities.GetObject(exPtr); ex.InstructionAddress = *((uint *)BasePointer + 1); Throw(ex); }