Archived

This topic is now archived and is closed to further replies.

_walrus

problem with UnDecorateSymbolName

Recommended Posts

I''m trying to unmangle a name using UnDecorateSymbolName but it seems to fail each time, and i''m not sure why. I get an error code 126 each time and it returns 0. Any ideas would be a great help. Thanks

char resultingName[1024];
int retValue = UnDecorateSymbolName(mangledName, resultingName, 1024, UNDNAME_COMPLETE |  UNDNAME_32_BIT_DECODE  | UNDNAME_NO_LEADING_UNDERSCORES);

if (retValue)
{
   printf("%s Name is %s", mangledName, resultingName);
}
else
{
   HRESULT result = GetLastError();
   printf("Error %d", result);
}

 

Share this post


Link to post
Share on other sites
If I had to guess, I''d say that the decorated name you''re passing as an argument doesn''t have an associated module with debug information loaded by SymInitialize() or SymLoadModule64(). Are you sure the decorated name is listed by a SymEnumSymbols() call?

Share this post


Link to post
Share on other sites
its weird, but when i specify "UNDNAME_NO_LEADING_UNDERSCORES"
as an option the undecorateSymbolName doesnt work, but if i
dont have that parameter then it works fine




#include "stdafx.h"
#include <windows.h>
#include <imagehlp.h>
//#pragma hdrstop

// include the right library in the linker stage
#pragma comment( lib, "imagehlp.lib" )


__declspec( dllexport ) void hello()
{
printf("hello");
}


int main(int argc, char* argv[])
{
printf("Hello World!\n");

char undecorated_name[ 513 ];

memset( undecorated_name, 0, sizeof( undecorated_name ) );

//char * decorated_name = "?DT_GetCur@@YAJXZ";
char * decorated_name = "?hello@@YAXXZ";

//doesnt work with "UNDNAME_NO_LEADING_UNDERSCORES"
//
// if ( UnDecorateSymbolName( decorated_name,
// undecorated_name,
// sizeof( undecorated_name ),
// UNDNAME_COMPLETE //|UNDNAME_NO_LEADING_UNDERSCORES) > 0 )

//this one works fine:
if ( UnDecorateSymbolName( decorated_name,
undecorated_name,
sizeof( undecorated_name ),
UNDNAME_COMPLETE) > 0 )
{
printf("Undecorated name %s\n", undecorated_name );
}
else
{
printf( "This doesn't demangle %s\n", decorated_name );
}
return 0;
}



[edited by - _walrus on January 4, 2004 1:47:01 PM]

Share this post


Link to post
Share on other sites
Again, I''m going to have to say the problem is probably the module containing the decorated name isn''t being loaded. In your source code you seem to be trying to undecorate a function called GetCur() but there''s no GetCur() function in your code, and a quick scan of MSDN doesn''t show a GetCur() function in the windows API, so it wouldn''t be in any of the modules loaded automatically.

In any case, calling SymInitialize() might be a good idea.

Share this post


Link to post
Share on other sites