📚 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  >>  How to use idasdk to generate comment?

Topic created on: May 19, 2008 10:07 CDT by thuanghai .

Hello folks!
  I am making a IDA's plugin, and I want to get the some comment in the view form, just like below:
  ;_onexit_t __cdecl _onexit(_onexit_t Func)
  __onexit proc near
  var_24    = dword ptr -20h
  var_20    = dword ptr -1Ch
  ms_exc    = CPPEH_RECORD ptr -18h
  Func      = dword ptr 8
  ......
This one often appeared with the function comment. And now how can I get it using idasdk, please give me some advice or some important reference sdk function.

Sorry!I want some other things, and edit again (2007.05.21)

  nezumi     May 20, 2008 11:38.14 CDT
get_func_cmt(func_t *fn ,bool repeatable) returns function comments, but local variables aren't comments, see frame.hpp and funcs.hpp, they describe how to deal with local variables, the key word is: frame.

  thuanghai     May 21, 2008 06:16.13 CDT
> nezumi: get_func_cmt(func_t *fn ,bool repeatable) returns function comments, but local variables aren\'t comments, see frame.hpp and funcs.hpp, they describe how to deal with local variables, the key word is: frame.

thank you for your reply!
   I have used get_func_cmt(),but got nothing.

  nezumi     May 21, 2008 10:47.54 CDT
use get_frame(func_t *pfn) or get_frame(ea_t ea) to get pointer to struc_t, use get_struc_first_offset()/get_struc_next_offset() to enumerate the members, in essence, struc_t*, returned by get_frame(), is a normal structure (see struct.hpp).
just remember: stack variables have negative offset, meanwhile normal structure members is always positive and say thanks to Iouri Kharon, who knows IDA-Pro better than anyone :=)

  thuanghai     June 3, 2008 10:12.55 CDT
> nezumi: use get_frame(func_t *pfn) or get_frame(ea_t ea) to get pointer to struc_t, use get_struc_first_offset()/get_struc_next_offset() to enumerate the members, in essence, struc_t*, returned by get_frame(), is a normal structure (see struct.hpp).
> just remember: stack variables have negative offset, meanwhile normal structure members is always positive and say thanks to Iouri Kharon, who knows IDA-Pro better than anyone :=)

  Just as you said, I try to use the functions you said, but only get the offset. Would you please give me some adivces more particularly.
  And in this days, I find some arg_?? and var_?? which IDA identified in the stack, but there are more holes which do not use to store anythings. So how can I get the arg?? and var_??
  :)

  cseagle     June 3, 2008 21:55.17 CDT
> thuanghai:
>   Just as you said, I try to use the functions you said, but only get the offset. Would you please give me some adivces more particularly.
>   And in this days, I find some arg_?? and var_?? which IDA identified in the stack, but there are more holes which do not use to store anythings. So how can I get the arg?? and var_??
>   :)

Shameless plug for my forthcmoing book which contains the following example that may help

func_t *func = get_func(get_screen_ea());  //get function at cursor location
msg("Local variable size is %d\n", func->frsize);
msg("Saved regs size is %d\n", func->frregs);
struc_t *frame = get_frame(func);          //get pointer to stack frame
if (frame) {
   size_t ret_addr = func->frsize + func->frregs;  //offset to return address
   for (size_t m = 0; m < frame->memqty; m++) {    //loop through members
      char fname[1024];
      get_member_name(frame->members[m].id, fname, sizeof(fname));
      if (frame->members[m].soff < func->frsize) {
         msg("Local variable ");
      }
      else if (frame->members[m].soff > ret_addr) {
         msg("Parameter ");
      }
      msg("%s is at frame offset %x\n", fname, frame->members[m].soff);
      if (frame->members[m].soff == ret_addr) {
         msg("%s is the saved return address\n", fname);
      }
   }
}


Regards,

Chris

  thuanghai     June 4, 2008 10:19.46 CDT
Oh, thanks cseagle, I got the answer by using your example. Thanks a lot.

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