FunctionMatrix.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:IDAPython-Scripts 作者: razygon 项目源码 文件源码
def get_callers(ea,maxlen=None):
    '''
    Walk through the callers recursively starting at address ea.
    maxlen is the maximum number of node the graph can contain.
    Return a dictionary of list of caller addresses.
    Return empty dictionary when number of node > maxlen.
    '''
    xtree = {}
    visited = []
    towalk = [ea]
    while towalk:
        curr = towalk.pop()
        if curr not in xtree: # the start point also will record in the tree
            xtree[curr] = []
        if curr not in visited:
            visited.append(curr)
        for x in idautils.XrefsTo(curr):
            caller = idaapi.get_func(x.frm)
            if caller:
                caller = caller.startEA
                if caller not in visited:
                    towalk.append(caller)
#             else:    #not very clear, if this is not a function, still record it??
#                 caller = x.frm
#                 xtree[caller] = []
            xtree[curr].append(caller)
        if maxlen and len(tree) > maxlen:
            return {}                    
    return xtree
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号