def refs(self):
'''Return the (address, opnum, type) of all the references to this member within the database.'''
mid = self.id
# calculate the high-byte which is used to determine an address from a structure
bits = int(math.ceil(math.log(idaapi.BADADDR)/math.log(2.0)))
highbyte = 0xff << (bits-8)
# if structure is a frame..
if internal.netnode.name.get(self.__owner.id).startswith('$ '):
name, mptr = self.fullname, self.ptr
sptr = idaapi.get_sptr(mptr)
# get frame, func_t
frname, _ = name.split('.', 2)
frid = internal.netnode.get(frname)
ea = idaapi.get_func_by_frame(frid)
f = idaapi.get_func(ea)
# now find all xrefs to member within function
xl = idaapi.xreflist_t()
idaapi.build_stkvar_xrefs(xl, f, mptr)
# now we can add it
res = []
for xr in xl:
ea, opnum = xr.ea, int(xr.opnum)
res.append( interface.OREF(ea, opnum, interface.ref_t(xr.type, instruction.op_state(ea, opnum))) ) # FIXME
return res
# otherwise, it's a structure..which means we need to specify the member to get refs for
x = idaapi.xrefblk_t()
ok = x.first_to(mid, 0)
if not ok:
return []
# collect all references available
refs = [(x.frm,x.iscode,x.type)]
while x.next_to():
refs.append((x.frm,x.iscode,x.type))
# now figure out which operand has the structure member applied to it
res = []
for ea,_,t in refs:
ops = ((idx, internal.netnode.sup.get(ea, 0xf+idx)) for idx in range(idaapi.UA_MAXOP) if internal.netnode.sup.get(ea, 0xf+idx) is not None)
ops = ((idx, interface.node.sup_opstruct(val, idaapi.get_inf_structure().is_64bit())) for idx, val in ops)
ops = (idx for idx, ids in ops if self.__owner.id in ids) # sanity
res.extend( interface.OREF(ea, int(op), interface.ref_t.of(t)) for op in ops)
return res
#strpath_t
#op_stroff(ea, n, tid_t* path, int path_len, adiff_t delta)
#get_stroff_path(ea, n, tid_t* path, adiff_t delta)
评论列表
文章目录