Home > Windows API > How to undecorate symbol names?

How to undecorate symbol names?

So what does decoration of symbols mean? Decoration of symbols take place to provide c++ polymorphism support.

For e.g. if you have two functions

void Add( int num1, int num2 )
void Add( float num1, float num2 )

How does the compiler differentiate between the two? It creates a unique name for above functions based on the types passed, hence the function that takes two ints will have a different name from the one which takes two floats. This process is called “name mangling”.

So when we invoke either of these functions the compiler recreates the unique name based on the types that we pass in, so if we pass two floats it recreates the function’s mangled name and invokes that function.

So to undecorate symbol names call UnDecorateSymbolName.

A sample from MSDN…

if( UnDecorateSymbolName( szName,
                          szUndName,
                          sizeof( szUndName ),
                          UNDNAME_COMPLETE ))
{
	// UnDecorateSymbolName returned success
	printf ("Symbol : %sn", szUndName); }
else
{
	// UnDecorateSymbolName failed
	error = GetLastError();
	printf( "UnDecorateSymbolName returned error %dn", error );
}// End if
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: