def function(ea):
    '''Returns the C function declaration at the address `ea`.'''
    res = idaapi.idc_get_type(ea)
    if res is None:
        raise internal.exceptions.MissingTypeOrAttribute(
            u"The function {:x} does not have a declaration.".format(ea))
    return res
Beispiel #2
0
def function(ea):
    '''returns the C function declaration at given address'''
    result = idaapi.idc_get_type(ea)
    if result is None:
        raise ValueError(
            "function {:x} does not have a declaration".format(ea))
    return result
Beispiel #3
0
def unmangle_arguments(ea):
    info = fn.type(ea)
    if not info.present():
        raise ValueError(info)

    # Grab the parameters from the idc type as it includes more information
    parameters = extract.arguments("{!s}".format(
        idaapi.idc_get_type(ea))) or extract.arguments("{!s}".format(info))
    param_s = parameters.lstrip('(').rstrip(')')

    index, indices, iterable = 0, [], ((idx, item)
                                       for idx, item in enumerate(param_s))
    for argi in range(info.get_nargs()):
        arg = info.get_nth_arg(argi)
        arg_s = "{!s}".format(arg)

        index, ch = next(iterable, (1 + index, ','))
        while ch in ' ':
            index, ch = next(iterable)

        while ch != ',':
            for item in arg_s:
                index, ch = next(iterable)
                if ch != item: break

            count = 0
            while ch != ',' or count > 0:
                index, ch = next(iterable, (1 + index, ','))
                if ch in '()':
                    count += -1 if ch in ')' else +1
                continue

            indices.append(index)

    pos, res = 0, []
    for argi, index in enumerate(indices):
        arg = info.get_nth_arg(argi)
        arg_s = "{!s}".format(arg)

        item = param_s[pos:index].strip()
        pos = 1 + index

        t, name = item[:len(arg_s)], item[len(arg_s):]
        res.append((t.strip(), name.strip()))
    return res
Beispiel #4
0
def function(ea):
    '''Returns the C function declaration at the address `ea`.'''
    res = idaapi.idc_get_type(ea)
    if res is None:
        raise internal.exceptions.MissingTypeOrAttribute(u"The function {:x} does not have a declaration.".format(ea))
    return res
Beispiel #5
0
def function(ea):
    '''returns the C function declaration at given address'''
    result = idaapi.idc_get_type(ea)
    if result is None:
        raise ValueError, 'function %x does not have a declaration' % ea
    return result