Example #1
0
                                           str(get_item(ea, ti)))
        return node

    def get_tinfo_and_declstr(ea):
        ti = ida.get_or_guess_tinfo(ea)
        return (ti, ea, ida.print_tinfo(ida.name(ea), ti))

    def has_got_seg_in_data_refs(refs):
        # filter out data not referenced by GOT
        return '.got' in [ida.seg_name(x) for x in refs]

    def get_refs_and_ea((_, ea)):
        return (ida.data_refs_to(ea), ea)

    refs_eas = imap(get_refs_and_ea,
                    ida.ea_list_from_segs(segs))
    data = list(get_tinfo_and_declstr(ea)
                for (refs, ea) in refs_eas
                if has_got_seg_in_data_refs(refs))
    declstrs = '\n'.join([x[2] for x in data])
    decls = izip(data,
                 cdecl.get_decls(declstrs, cpp_in).decls[utils.cpp_decomp_tag])
    return map(gen, decls)

def get_fns_and_types(segs, wanted_fns, cpp_in):
    '''[str] -> [str] -> str -> ([c_ast], [c_ast])'''
    # NOTE mutates, because...
    #
    # IDA will always give us demangled names in type signatures, so we have to
    # replace the name in the returned decl with the mangled name
    def get_wanted(l, (name, decl)):
Example #2
0
def get_literals(segs, fn, pred):
    '''[str] -> fn -> fn -> {str : <dyn>}'''
    return {name : fn(ea)
            for (name, ea) in ida.ea_list_from_segs(segs)
            if pred(ea)}
Example #3
0
                typename = get_type_for_c_ast_constant(ti)
                node.init = ep_ct.constant(typename, str(get_item(ea, ti)))
        return node

    def get_tinfo_and_declstr(ea):
        ti = ida.get_or_guess_tinfo(ea)
        return (ti, ea, ida.print_tinfo(ida.name(ea), ti))

    def has_got_seg_in_data_refs(refs):
        # filter out data not referenced by GOT
        return '.got' in [ida.seg_name(x) for x in refs]

    def get_refs_and_ea((_, ea)):
        return (ida.data_refs_to(ea), ea)

    refs_eas = imap(get_refs_and_ea, ida.ea_list_from_segs(segs))
    data = list(get_tinfo_and_declstr(ea)
                for (refs, ea) in refs_eas
                if has_got_seg_in_data_refs(refs))
    declstrs = '\n'.join([x[2] for x in data])
    decls = izip(data, cdecl.get_decls(declstrs, cpp_in).decls[utils.cpp_decomp_tag])
    return map(gen, decls)


def get_fns_and_types(segs, wanted_fns, cpp_in):
    '''[str] -> [str] -> str -> ([c_ast], [c_ast])'''
    # NOTE mutates, because...
    #
    # IDA will always give us demangled names in type signatures, so we have to
    # replace the name in the returned decl with the mangled name
    def get_wanted(l, (name, decl)):