Name Mangling – How to Undecorate a decorated C++ function name.
![]()
For generating unique function names C++ decorates the function names to wired form. This is best known as Name Mangling. You can see sample of decorated function names by using dependency walker. Open any DLL in dependency walker and in the exported section, most probably you can see a list of decorated function names.
![]()
So, if you want to see the real function prototype of that decorated function name, what to do? Just use, UnDecorateSymbolName() function. Please see the following code block.
// Buffer for undecorating Function Name.
TCHAR tchUnDecoratedName[ 512 ];
// The Decorated function Name.
TCHAR tchDecoratedName[] =
_T( "?classCDataPathProperty@CDataPathProperty@@2UCRuntimeClass@@B" );
if( UnDecorateSymbolName( tchDecoratedName, // Decorated Name.
tchUnDecoratedName, // UnDecorated Name.
512, // Buffer size.
UNDNAME_COMPLETE )) // Flags.
{
// Display the undecorated function name.
CString csUndecoratedName( tchUnDecoratedName );
AfxMessageBox( csUndecoratedName );
}
![]()
Don’t forget to include the header file – “Dbghelp.h” and library file – “Dbghelp.lib“.
![]()
Targeted Audience – Intermediate.
[...] If you want to get the function name from a mangled name, then have a look at my previous post – http://weseetips.com/2008/04/14/name-mangling-how-to-undecorate-a-c-decorated-function-name/ [...]
the code metioned above will only work for a specific compiler of a specific version, since currently, there’s no standard for this area.
Hi,
Its true that there is no standard for name mangling but the provided function – UnDecorateSymbolName() is part of SDK and will work for all Visual C++ compilers. Not only for a specific compiler version.
Regards,
Jijo.
??,?????????? ? ??????????? ?????????
)
Un-Decorating with google translate -
“??,?????????? ? ??????????? ?????????
”
”
“Yes, disagree with the previous speakers)
Hi Babyla,
Thanks for writing down your opinion. Keep watching!
Regards,
Jijo.
??,?????????? ? ??????????? ??????????????
^..^ Bye
need help. what is the header for a function named do_it() that takes three type char arguments and return a type float to the program???? pls help me……..
Hi rachelle,
there isn’t any standard api named do_it(). If you just want the signature its -
float do_it( char a, char b, char b);
I think your problem is something different. Could you please elabrate a bit more? Feel free to ping via my gtalk – jijoraj@gmail.com. I’ll be online from 9:00 AM to 4:00 PM IST.
Best Regards,
Jijo.
?????? ???????. ??? ???????!!!
? ??? ???? ??????????
Hi,I supply one code under VC++6.0, enjoy it.(qduwg@163.com,china)
//undec.cpp –file name
#include
#include
#include
int main(int argc,char* argv[])
{
char buff[256];
if(argc==2)
{ UnDecorateSymbolName(argv[1],buff,256,0);
printf(buff);
}
else
{printf(“usage: undec.exe decroatedname\n”); //command line for undec
}
return 0;
}