public void Setup() { program = new Program(); program.Architecture = new IntelArchitecture(ProcessorMode.Protected32); program.Platform = new DefaultPlatform(null, program.Architecture); gcr = new GlobalCallRewriter(program, null); proc = new Procedure("foo", program.Architecture.CreateFrame()); flow = new ProcedureFlow(proc, program.Architecture); }
public void GcrStackArguments() { Frame f = program.Architecture.CreateFrame(); f.ReturnAddressKnown = true; f.ReturnAddressSize = PrimitiveType.Word16.Size; f.EnsureStackVariable(Constant.Word16( 8), 2, PrimitiveType.Word16); f.EnsureStackVariable(Constant.Word16( 6), 2, PrimitiveType.Word16); f.EnsureStackVariable(Constant.Word16( 0x0E), 2, PrimitiveType.Word32); GlobalCallRewriter gcr = new GlobalCallRewriter(null, null); using (FileUnitTester fut = new FileUnitTester("Analysis/GcrStackParameters.txt")) { foreach (KeyValuePair<int,Identifier> de in gcr.GetSortedStackArguments(f)) { fut.TextWriter.Write("{0:X4} ", de.Key); de.Value.Write(true, fut.TextWriter); fut.TextWriter.WriteLine(); } fut.AssertFilesEqual(); } }
public static void Rewrite(Program prog, ProgramDataFlow summaries) { GlobalCallRewriter crw = new GlobalCallRewriter(prog, summaries); foreach (Procedure proc in prog.Procedures.Values) { ProcedureFlow flow = (ProcedureFlow) crw.mpprocflow[proc]; flow.Dump(prog.Architecture); crw.AdjustLiveOut(flow); crw.EnsureSignature(proc, flow); crw.AddUseInstructionsForOutArguments(proc); } foreach (Procedure proc in prog.Procedures.Values) { crw.RewriteCalls(proc, prog.Architecture); crw.RewriteReturns(proc); } }