📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  IDA Pro  >>  Argsize of Functions Always Zero?

Topic created on: May 10, 2007 15:01 CDT by stahl .

Hi Everyone,

i have written a small and dirty idapython script to print out the argsize of a called function. sadly it doesn't work as expected. i want to find the actual arguments passed to a function call. so i thought the argsize might be useful. (other ideas?)

here is the script: it always prints zero:

ea = get_screen_ea()
called_ea = CodeRefsFrom(ea,False).pop()
calledfunc = get_func(called_ea)
print calledfunc.argsize

how can i get this information right? will it work for calls like:

call _read

a library function that is?

  pedram     May 11, 2007 10:40.25 CDT
Does the code in PaiMei.PIDA.function.py help you at all? Here are some of the relevant portions:


    self.saved_reg_size = func_struct.frregs
    self.frame_size     = get_frame_size(func_struct)
    self.ret_size       = get_frame_retsize(func_struct)
    self.local_var_size = func_struct.frsize

    def __init_args_and_local_vars__ (self):
        '''
        Calculate the total size of arguments, # of arguments and # of local variables.
        Update the internal class member variables appropriately.
        '''

        # grab the ida function and frame structures.
        func_struct  = get_func(self.ea_start)
        frame_struct = get_frame(func_struct)

        if not frame_struct:
            return

        argument_boundary = self.local_var_size + self.saved_reg_size + self.ret_size
        frame_offset      = 0

        for i in xrange(0, frame_struct.memqty):
            end_offset = frame_struct.get_member(i).soff

            if i == frame_struct.memqty - 1:
                begin_offset = frame_struct.get_member(i).eoff
            else:
                begin_offset = frame_struct.get_member(i+1).soff

            frame_offset += (begin_offset - end_offset)

            # grab the name of the current local variable or argument.
            name = get_member_name(frame_struct.get_member(i).id)

            if frame_offset > argument_boundary:
                self.args[end_offset] = name
            else:
                # if the name starts with a space, then ignore it as it
                # is either the stack saved ebp or eip.
                # XXX - this is a pretty ghetto check.
                if not name.startswith(" "):
                    self.local_vars[end_offset] = name

        self.arg_size       = frame_offset - argument_boundary
        self.num_args       = len(self.args)
        self.num_local_vars = len(self.local_vars)

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit