Esempio n. 1
0
        public override void InitSimulator(IPlatformEngine sim)
        {
            if (FaultAddress % 2 == 1)
            {
                throw new NotSupportedException();
            }

            uint hitCount = 0;

            sim.SetBreakPoint(FaultAddress, engine => {
                hitCount++;

                if (hitCount == BreakpointHitCount)   // We hit the glitched instruction
                {
                    engine.Write(FaultAddress, FaultedData);

                    engine.RequestRestart(FaultAddress);
                }
                else if (hitCount == BreakpointHitCount + 1)   // Execute glitched instruction
                {
                }
                else if (hitCount == BreakpointHitCount + 2)   // Write back original instruction
                {
                    engine.Write(FaultAddress, OriginalData);

                    engine.RequestRestart(FaultAddress);
                }
            });
        }