def _feature_returnpoints(self, f_ea):
'''
Number of 'ret' within the function
rets = [addr1, addr2. ...]
prior feature: Null
'''
# rets = []
# for ea in idautils.FuncItems(f_ea):
# if idaapi.is_ret_insn(ea):
# rets.append(ea)
# self.ftable["returnpoints"] = rets
DEBUG_PRINT("in returnpoints")
fun = idaapi.get_func(f_ea)
visited = []
retVal = []
for ret in self.ftable["returnpoints"]:
towalk = [ret]
# print 'towalk',towalk
while towalk:
curr = towalk.pop()
# print 'curr',curr
if curr not in range(fun.startEA,fun.endEA+2): # the start point also will record int the tree
# print 'not in range'
continue
# print '1', hex(curr)
if curr not in visited:
visited.append(curr)
inst = GetInstruction(curr)
# print '2', inst
if inst is None:
continue
elif 'eax' in inst:
# print ret, curr, inst
retVal.append((ret,curr,inst))
continue
for xto in idautils.XrefsTo(curr, 0):
DEBUG_PRINT('xto')
if xto.frm not in visited:
DEBUG_PRINT(xto.frm)
towalk.append(xto.frm)
DEBUG_PRINT(retVal)
return len(self.ftable["returnpoints"]), retVal
评论列表
文章目录