/// <summary> /// Extracts structured program constructs out of snarled goto nests, if possible. /// Since procedures are now independent of each other, this analysis /// is done one procedure at a time. /// </summary> public void StructureProgram() { if (project is null) { return; } foreach (var program in project.Programs) { int i = 0; foreach (Procedure proc in program.Procedures.Values) { if (eventListener.IsCanceled()) { return; } try { eventListener.ShowProgress("Rewriting procedures to high-level language.", i, program.Procedures.Values.Count); ++i; IStructureAnalysis sa = new StructureAnalysis(eventListener, program, proc); sa.Structure(); } catch (Exception e) { eventListener.Error( eventListener.CreateProcedureNavigator(program, proc), e, "An error occurred while rewriting procedure to high-level language."); } } } project.FireScriptEvent(ScriptEvent.OnProgramDecompiled); WriteDecompilerProducts(); eventListener.ShowStatus("Rewriting complete."); }
/// <summary> /// Extracts structured program constructs out of snarled goto nests, if possible. /// Since procedures are now independent of each other, this analysis /// is done one procedure at a time. /// </summary> public void StructureProgram() { foreach (var program in project.Programs) { int i = 0; foreach (Procedure proc in program.Procedures.Values) { try { eventListener.ShowProgress("Rewriting procedures to high-level language.", i, program.Procedures.Values.Count); ++i; Console.WriteLine("rewriting: {0}", proc); IStructureAnalysis sa = new StructureAnalysis(proc); sa.Structure(); } catch (Exception e) { eventListener.Error( eventListener.CreateProcedureNavigator(program, proc), e, "An error occurred while rewriting procedure to high-level language."); } } WriteDecompilerProducts(); } eventListener.ShowStatus("Rewriting complete."); }
private void CompileTest(ProcedureBuilder mock) { proc = mock.Procedure; var sa = new StructureAnalysis(new FakeDecompilerEventListener(), new Program(), proc); sa.Structure(); }
private void CompileTest(ProcedureBuilder mock) { proc = mock.Procedure; var sa = new StructureAnalysis(proc); sa.Structure(); }
private void RunTest32(string expected, Program program) { var sw = new StringWriter(); foreach (var proc in program.Procedures.Values) { var cfgc = new ControlFlowGraphCleaner(proc); cfgc.Transform(); var sa = new StructureAnalysis(proc); sa.Structure(); var fmt = new CodeFormatter(new TextFormatter(sw)); fmt.Write(proc); sw.WriteLine("==="); } Console.WriteLine(sw); Assert.AreEqual(expected, sw.ToString()); }
private void RunTest(ProcedureBuilder mock, string outFilename) { Procedure proc = mock.Procedure; using (FileUnitTester fut = new FileUnitTester(outFilename)) { ControlFlowGraphCleaner cfgc = new ControlFlowGraphCleaner(proc); cfgc.Transform(); proc.Write(false, fut.TextWriter); fut.TextWriter.WriteLine(); StructureAnalysis sa = new StructureAnalysis(proc); sa.Structure(); CodeFormatter fmt = new CodeFormatter(new TextFormatter(fut.TextWriter)); fmt.Write(proc); fut.TextWriter.WriteLine("==========================="); fut.AssertFilesEqual(); } }
private void RunTest16(string sourceFilename, string outFilename, Address addrBase) { using (FileUnitTester fut = new FileUnitTester(outFilename)) { RewriteProgramMsdos(sourceFilename, addrBase); foreach (Procedure proc in program.Procedures.Values) { var cfgc = new ControlFlowGraphCleaner(program.Procedures.Values[0]); cfgc.Transform(); proc.Write(false, fut.TextWriter); fut.TextWriter.WriteLine(); var sa = new StructureAnalysis(proc); sa.Structure(); var fmt = new CodeFormatter(new TextFormatter(fut.TextWriter)); fmt.Write(proc); fut.TextWriter.WriteLine("==========================="); } fut.AssertFilesEqual(); } }
private void RunTest(string expected, Program program) { var sw = new StringWriter(); foreach (var proc in program.Procedures.Values) { var cfgc = new ControlFlowGraphCleaner(proc); cfgc.Transform(); var sa = new StructureAnalysis(new FakeDecompilerEventListener(), program, proc); sa.Structure(); var fmt = proc.CreateCodeFormatter(new TextFormatter(sw)); fmt.Write(proc); sw.WriteLine("==="); } try { Assert.AreEqual(expected, sw.ToString()); } catch { Console.WriteLine(sw); throw; } }