Log in

View Full Version : IDA function naming


scknight
October 16th, 2007, 19:27
This seems like a dumb question but I cant seem to figure it out. I've tried looking through IDA help and searching on the web. I looking at an app written in C++. I've identified certain classes based on RTTI information and now I want to start naming methods of the classes. My problem is if I name a function 'AClass::Somemethod' IDA then displays it as AClass__Somemethod. However the standard MFC classes show up named with the colons in the name. Am I doing something wrong when naming these methods?

TiGa
October 16th, 2007, 22:57
Have you tried setting the option Demangled names to names rather than commentary?

It will change this:
Code:
call ?GetDlgItemTextA@CWnd@@QBEHHPADH@Z ; CWnd::GetDlgItemTextA(int,char *,int)

into this:
Code:
call CWnd::GetDlgItemTextA(int,char *,int)


From the IDA 5.1 help file:
Quote:
You can set how demangled C++ names must be represented:

- as comments. this representation allows you to obtain
recompilable source text
- instead of mangled names. this representation makes the output
more readable. the disadvantage is that you can't recompile the
output
- don't display demangled names.


TiGa

Polaris
October 17th, 2007, 00:13
Quote:
[Originally Posted by scknight]This seems like a dumb question but I cant seem to figure it out. I've tried looking through IDA help and searching on the web. I looking at an app written in C++. I've identified certain classes based on RTTI information and now I want to start naming methods of the classes. My problem is if I name a function 'AClass::Somemethod' IDA then displays it as AClass__Somemethod. However the standard MFC classes show up named with the colons in the name. Am I doing something wrong when naming these methods?



Not a dumb question at all Basically IDA handles each item in its DB in its own way. This applies also to names you write, of course. By default, IDA prevents you to use some chars in some items probably to avoid confusion: if one of this characters is encountered, IDA replaces it with an underscore, like in your example.

In order to fix this (just for user-names) open your ida.cfg file, and look for the declaration of NameChars: this string contains all the characters that will be displayed in the user defined names. Just add there what you need. To add the ':':

Quote:
NameChars =
"$?@" // asm specific character
"_0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz:";


Good luck!

Sirmabus
December 24th, 2008, 21:19
This is an old thread, but it has useful information.

I think the ideal way is to create a mangled name your self, then let IDA display it as it wants to do.
This is what igorsk does in his RTTI scripts.
Code:
MakeName(a,"??_7"+name+"@@6B@";


Then no need for messing with "NameChars", etc. :-)