Reputation: 11190
I am trying to get a list of parameters and the return type from a mangled function compiled in visual studio.
I know that I can use
UnDecorateSymbolName(function.c_str(), undecoratedName, 200, UNDNAME_COMPLETE))
but this just gives me another string, and I have to figure out if the string starts with a return type, or a specifier.
Is there a function to return SymbolNameInfo? Something along the lines:
struct SymbolInfo
{
char[255] symbolName
char[255] returnType
char[255] parameters
};
Upvotes: 8
Views: 822
Reputation: 11190
I managed to find an answer. It's not perfect, maybe someone else will have some better idea.
What I did was use
UnDecorateSymbolName(function.c_str(), undecoratedName, 200, UNDNAME_COMPLETE))
with different flags.
The flags I used with explanation:
UNDNAME_COMPLETE // this returns the whole undecorated name.
UNDNAME_NAME_ONLY // this return just the name of the symbol
UNDNAME_NO_FUNCTION_RETURNS // this return a string like UNDNAME_COMPLETE
// but without the return type
I used these 3 flags to do the following:
How this looks after test:
function : ?encrypt@@YAPADPAD@Z
fullName : char * __cdecl encrypt(char*)
SymbolInfo.name : encrypt
SymbolInfo.returnType : char *
SymbolInfo.parameters : (char *)
Upvotes: 1
Reputation: 145419
The easiest way to get unmangled name is probably to use Microsoft's undname.exe
, installed with Visual Studio.
For doing it programmatically, look at e.g. (http://code.google.com/p/pdbparse/source/browse/trunk/src/undname.c)*.
The above two references the result of a minute or so of googling. ;-)
*: jus’ hoping that some helpful bear won't come along to swat that perceived fly on my nose, but they always do
Upvotes: 0