Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_all_xrefs_to(vw, va):
'''
get all xrefs, including fallthrough instructions, to this address.
vivisect doesn't consider fallthroughs as xrefs.
see: https://github.com/fireeye/flare-ida/blob/7207a46c18a81ad801720ce0595a151b777ef5d8/python/flare/jayutils.py#L311
'''
for xref in vw.getXrefsTo(va):
yield xref
op = get_prev_opcode(vw, va)
for tova, bflags in op.getBranches():
if tova == va:
yield (op.va, va, vivisect.const.REF_CODE, bflags)
init = vw.getXrefsTo(va)[:]
prev = vw.getPrevLocation(va)
if prev is None:
return init
lva, lsize, ltype, linfo = prev
if ltype != vivisect.const.LOC_OP:
return init
try:
op = vw.parseOpcode(lva)
except Exception:
print ('Weird error while doing getAllXrefsTo: %s' % str(err))
return init
brlist = op.getBranches()
for tova,bflags in brlist:
if tova == va:
init.append( (lva, tova, vivisect.const.REF_CODE, bflags) )
return init