Name Mangling – How to Undecorate a decorated C++ function name.

14 04 2008


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.

Advertisements




Do you know who named C++?

14 04 2008


Do you know who named C++? Its Stroustrup who designed and created C++. But the earlier name was “C with Classes”. The name “C++” is suggested by another guy – Rick Mascitti. Read more at Stroustrup’s home page – http://www.research.att.com/~bs/bs_faq.html#name


Targeted Audiance – Everyone who wish to hear stories.