MCPcopy Create free account
hub / github.com/GJDuck/e9patch / findInstr

Function findInstr

src/e9patch/e9optimize.cpp:194–212  ·  view source on GitHub ↗

* Find the instruction at the given address. */

Source from the content-addressed store, hash-verified

192 * Find the instruction at the given address.
193 */
194Instr *findInstr(const Binary *B, intptr_t addr)
195{
196 Instr *lb = B->Is.front(), *ub = B->Is.end();
197 if (lb == nullptr || ub == nullptr)
198 return nullptr;
199 Instr *Is = lb;
200 ssize_t lo = 0, hi = (ub - lb) - 1;
201 while (lo <= hi)
202 {
203 ssize_t mid = (lo + hi) / 2;
204 if (addr > Is[mid].addr)
205 lo = mid+1;
206 else if (addr < Is[mid].addr)
207 hi = mid-1;
208 else
209 return &Is[mid];
210 }
211 return nullptr;
212}
213
214/*
215 * Optimize a jump (or call) instruction.

Callers 8

optimizeJumpFunction · 0.85
parseTargetsFunction · 0.85
CFGCodeAnalysisFunction · 0.85
CFGSectionAnalysisFunction · 0.85
buildTargetsMethod · 0.85
buildBBsMethod · 0.85
buildFsMethod · 0.85
buildLinesMethod · 0.85

Calls 2

frontMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected