(instruction)
return result
Returns an array containing the arguments to the current function,
    if $pc is a 'call' or 'bl' type instruction.

    Otherwise, returns None.
Returns an array containing the arguments to the current function,
    if $pc is a 'call' or 'bl' type instruction.
Returns an array containing the arguments to the current function if $pc is a call or bl type instruction .
def get(instruction):
    """
    Returns an array containing the arguments to the current function,
    if $pc is a 'call' or 'bl' type instruction.

    Otherwise, returns None.
    """
    n_args_default = 4

    if instruction.address != pwndbg.regs.pc:
        return []

    try:
        abi = pwndbg.abi.ABI.default()
    except KeyError:
        return []

    if CS_GRP_CALL in instruction.groups:
        # Not sure of any OS which allows multiple operands on
        # a call instruction.
        assert len(instruction.operands) == 1

        target = instruction.operands[0].int

        if not target:
            return []

        name = pwndbg.symbol.get(target)
        if not name:
            return []
    elif CS_GRP_INT in instruction.groups:
        # Get the syscall number and name
        abi = pwndbg.abi.ABI.syscall()

        target  = None
        syscall = getattr(pwndbg.regs, abi.syscall_register)
        name    = pwndbg.constants.syscall(syscall)
    else:
        return []

    result = []
    name = name or ''

    sym   = gdb.lookup_symbol(name)
    name  = name.replace('isoc99_', '') # __isoc99_sscanf
    name  = name.replace('@plt', '')    # getpwiod@plt

    # If we have particular `XXX_chk` function in our database, we use it.
    # Otherwise, we show args for its unchecked version.
    # We also lstrip `_` in here, as e.g. `__printf_chk` needs the underscores.
    if name not in pwndbg.functions.functions:
        name  = name.replace('_chk', '')
        name  = name.strip().lstrip('_')    # _malloc

    func = pwndbg.functions.functions.get(name, None)

    # Try to extract the data from GDB.
    # Note that this is currently broken, pending acceptance of
    # my patch: https://sourceware.org/ml/gdb-patches/2015-06/msg00268.html
    if sym and sym[0]:
        try:
            n_args_default = len(sym[0].type.fields())
        except TypeError:
            pass

    # Try to grab the data out of IDA
    if not func and target:
        typename = pwndbg.ida.GetType(target)

        if typename:
            typename += ';'

            # GetType() does not include the name.
            typename = typename.replace('(', ' function_name(', 1)

            for k, v in ida_replacements.items():
                typename = typename.replace(k, v)

            func = pwndbg.funcparser.ExtractFuncDeclFromSource(typename + ';')

    if func:
        args = func.args
    else:
        args = [pwndbg.functions.Argument('int', 0, argname(i, abi)) for i in range(n_args_default)]

    for i, arg in enumerate(args):
        result.append((arg, argument(i, abi)))

    return result
def get ( instruction ) : n_args_default = 4 if instruction . address != pwndbg . regs . pc : return [ ] try : abi = pwndbg . abi . ABI . default ( ) except KeyError : return [ ] if CS_GRP_CALL in instruction . groups : # Not sure of any OS which allows multiple operands on # a call instruction. assert len ( instruction . operands ) == 1 target = instruction . operands [ 0 ] . int if not target : return [ ] name = pwndbg . symbol . get ( target ) if not name : return [ ] elif CS_GRP_INT in instruction . groups : # Get the syscall number and name abi = pwndbg . abi . ABI . syscall ( ) target = None syscall = getattr ( pwndbg . regs , abi . syscall_register ) name = pwndbg . constants . syscall ( syscall ) else : return [ ] result = [ ] name = name or '' sym = gdb . lookup_symbol ( name ) name = name . replace ( 'isoc99_' , '' ) # __isoc99_sscanf name = name . replace ( '@plt' , '' ) # getpwiod@plt # If we have particular `XXX_chk` function in our database, we use it. # Otherwise, we show args for its unchecked version. # We also lstrip `_` in here, as e.g. `__printf_chk` needs the underscores. if name not in pwndbg . functions . functions : name = name . replace ( '_chk' , '' ) name = name . strip ( ) . lstrip ( '_' ) # _malloc func = pwndbg . functions . functions . get ( name , None ) # Try to extract the data from GDB. # Note that this is currently broken, pending acceptance of # my patch: https://sourceware.org/ml/gdb-patches/2015-06/msg00268.html if sym and sym [ 0 ] : try : n_args_default = len ( sym [ 0 ] . type . fields ( ) ) except TypeError : pass # Try to grab the data out of IDA if not func and target : typename = pwndbg . ida . GetType ( target ) if typename : typename += ';' # GetType() does not include the name. typename = typename . replace ( '(' , ' function_name(' , 1 ) for k , v in ida_replacements . items ( ) : typename = typename . replace ( k , v ) func = pwndbg . funcparser . ExtractFuncDeclFromSource ( typename + ';' ) if func : args = func . args else : args = [ pwndbg . functions . Argument ( 'int' , 0 , argname ( i , abi ) ) for i in range ( n_args_default ) ] for i , arg in enumerate ( args ) : result . append ( ( arg , argument ( i , abi ) ) ) return result