private void RewriteCall(Statement stm, CallInstruction call) { var e = expander.Expand(call.Callee); var pt = e.Accept(asc).ResolveAs <Pointer>(); if (pt == null) { return; } var ft = pt.Pointee as FunctionType; if (ft == null) { return; } ssam.AdjustRegisterAfterCall( stm, call, ssa.Procedure.Architecture.StackRegister, ft.StackDelta - call.CallSite.SizeOfReturnAddressOnStack); var ab = new ApplicationBuilder( ssa.Procedure.Architecture, proc.Frame, call.CallSite, call.Callee, ft, false); stm.Instruction = ab.CreateInstruction(); ssaIdTransformer.Transform(stm, call); DefineUninitializedIdentifiers(stm, call); changed = true; }
public void RewriteCall(Statement stm, CallInstruction call, FunctionType ft) { ssam.AdjustRegisterAfterCall( stm, call, ssa.Procedure.Architecture.StackRegister, ft.StackDelta - call.CallSite.SizeOfReturnAddressOnStack); ssam.AdjustRegisterAfterCall( stm, call, program.Architecture.FpuStackRegister, -ft.FpuStackDelta); var ab = program.Architecture.CreateFrameApplicationBuilder( proc.Frame, call.CallSite, call.Callee); stm.Instruction = ab.CreateInstruction(ft, null); ssaIdTransformer.Transform(stm, call); ssam.DefineUninitializedIdentifiers(stm, call); }
private void RewriteCall( Statement stm, CallInstruction ci, FunctionType sig, ProcedureCharacteristics?chr) { ssam.AdjustRegisterAfterCall( stm, ci, this.arch.StackRegister, sig.StackDelta - ci.CallSite.SizeOfReturnAddressOnStack); ssam.AdjustRegisterAfterCall( stm, ci, this.arch.FpuStackRegister, -sig.FpuStackDelta); var ab = new CallApplicationBuilder(this.ssa, stm, ci, ci.Callee, true); stm.Instruction = ab.CreateInstruction(sig, chr); ssam.AdjustSsa(stm, ci); }
private void RewriteCall( Statement stm, CallInstruction ci, FunctionType sig, ProcedureCharacteristics chr) { ssam.AdjustRegisterAfterCall( stm, ci, this.arch.StackRegister, sig.StackDelta - ci.CallSite.SizeOfReturnAddressOnStack); var ab = new ApplicationBuilder( arch, ssa.Procedure.Frame, ci.CallSite, ci.Callee, sig, false); stm.Instruction = ab.CreateInstruction(); ssaIdTransformer.Transform(stm, ci); }
private void BypassRegisterOffsets(Dictionary <Procedure, int?> savedSps, RegisterStorage register) { foreach (var ssa in this.ssas.Values) { var callStms = ssa.Procedure.Statements .Where(stm => stm.Instruction is CallInstruction) .ToList(); var ssam = new SsaMutator(ssa); foreach (var stm in callStms) { var call = (CallInstruction)stm.Instruction; if (!((call.Callee as ProcedureConstant)?.Procedure is Procedure proc)) { continue; } if (savedSps.TryGetValue(proc, out var delta) && delta.HasValue) { ssam.AdjustRegisterAfterCall(stm, call, register, delta.Value); } } } }