Ejemplo n.º 1
0
def make_superfunc_t_from_matches(matches, func_name=None):
    warnings.warn("make_superfunc_t_from_matches() is deprecated.",
                  DeprecationWarning)
    decode_funcs = set()
    for ea, identifier in matches:
        if ea == idc.BADADDR:
            continue
        func = functions.Function(ea, identifier)
        if func_name is not None:
            func.rename(func_name)
        decode_funcs.add(func)
    return list(decode_funcs)
Ejemplo n.º 2
0
def iter_callers(func_ea) -> Iterable[functions.Function]:
    """
    Iterates Function objects that call the given address.

    :param func_ea: Address of a function call.
    :return:
    """
    cache = set()
    for ea in iter_calls_to(func_ea):
        try:
            func = functions.Function(ea)
        except AttributeError:
            continue
        if func.name not in cache:
            yield func
            cache.add(func.name)
Ejemplo n.º 3
0
def find_destination(start, instruction_limit=None) -> Optional[int]:
    """
    Finds the destination address for returned eax register.

    :param int start: Starting address to start looking
    :param int instruction_limit: Limit the number of instructions to traverse before giving up.
        Defaults to searching until the end of the function.

    :return: destination address or None if address couldn't be found or is not a loaded address.
    """
    count = 0
    func = functions.Function(start)
    for ea in func.heads(start):
        count += 1
        if instruction_limit is not None and count > instruction_limit:
            return None

        if idc.print_insn_mnem(ea) == "mov" and idc.print_operand(
                ea, 1) in RAX_FAM:
            if idc.get_operand_type(ea, 0) == idc.o_mem:
                return idc.get_operand_value(ea, 0)
            else:
                return None
    return None