public static unsafe void Throw(FlingOops.Exception ex) { FlingOops.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 = (FlingOops.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 *)0xDEADBEEF) = 0; }
public static void ThrowFromPtr(UInt32 *exPtr) { FlingOops.Exception ex = (FlingOops.Exception)Utilities.ObjectUtilities.GetObject(exPtr); ex.InstructionAddress = *((uint *)BasePointer + 1); Throw(ex); }