public IEnumerable <RtlInstructionCluster> GetTrace(IProcessorArchitecture arch, Address addrStart, ProcessorState state, IStorageBinder binder) { return(arch.CreateRewriter( Program.CreateImageReader(arch, addrStart), state, binder, this)); }
/// <summary> /// Tries to determine if the instruction at <paramref name="addr"/> is /// a trampoline instruction. If so, we return a call to the imported /// function directly. /// procedure. /// </summary> /// <remarks> /// A trampoline is a procedure whose only contents is an indirect /// JUMP to a location that contains the address of an imported /// function. Because these trampolines may take on different /// appearances depending on the processor architecture, we have to /// call out to the architecture to assist in matching them. /// </remarks> /// <param name="addr"></param> /// <returns>Null if there was no trampoline.</returns> public ProcedureBase?GetTrampoline(IProcessorArchitecture arch, Address addr) { if (!Program.SegmentMap.IsValidAddress(addr)) { return(null); } var rdr = Program.CreateImageReader(arch, addr); var rw = arch.CreateRewriter(rdr, arch.CreateProcessorState(), arch.CreateFrame(), this); var target = Program.Platform.GetTrampolineDestination(addr, rw.SelectMany(c => c.Instructions), this); return(target); }
private long PerformanceTest_A32Rewriter(IProcessorArchitecture arch, byte[] buf) { var mem = new MemoryArea(Address.Ptr32(0x00100000), buf); var rdr = arch.CreateImageReader(mem, mem.BaseAddress); var dasm = arch.CreateRewriter(rdr, arch.CreateProcessorState(), new StorageBinder(), new RewriterPerformanceDialog.RewriterHost(new Dictionary <Address, ImportReference>())); Stopwatch sw = new Stopwatch(); sw.Start(); foreach (var instr in dasm) { } sw.Stop(); var time = sw.ElapsedMilliseconds; return(time); }
/// <summary> /// Get a rewriter for the specified address. If a rewriter is already /// available from the rewriter pool, remove it from the pool and use it, /// otherwise create a new one. /// </summary> /// <param name="addr"></param> /// <returns></returns> private IEnumerator <RtlInstructionCluster> GetRewriter( IProcessorArchitecture arch, Address addr, IDictionary <Address, IEnumerator <RtlInstructionCluster> > pool) { if (!pool.Remove(addr, out var e)) { var rdr = program.CreateImageReader(arch, addr); var rw = arch.CreateRewriter( rdr, arch.CreateProcessorState(), storageBinder, this.host); return(rw.GetEnumerator()); } else { return(e); } }
protected override IEnumerable <RtlInstructionCluster> GetRtlStream(MemoryArea mem, IStorageBinder binder, IRewriterHost host) { var state = new CrayProcessorState(arch); return(arch.CreateRewriter(arch.CreateImageReader(mem, 0), state, binder, host)); }