我试图从visual studio中编译的一个错位函数中获取参数列表和返回类型.
我知道我可以用
UnDecorateSymbolName(function.c_str(), undecoratedName, 200, UNDNAME_COMPLETE))
Run Code Online (Sandbox Code Playgroud)
但这只是给了我另一个字符串,我必须弄清楚字符串是以返回类型还是说明符开头的.
是否有返回SymbolNameInfo的函数?一些事情:
struct SymbolInfo
{
char[255] symbolName
char[255] returnType
char[255] parameters
};
Run Code Online (Sandbox Code Playgroud)
我设法找到了答案。它并不完美,也许其他人会有更好的想法。
我所做的是使用
UnDecorateSymbolName(function.c_str(), undecoratedName, 200, UNDNAME_COMPLETE))
Run Code Online (Sandbox Code Playgroud)
具有不同的标志。
我使用的标志和解释:
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
Run Code Online (Sandbox Code Playgroud)
我使用这 3 个标志执行以下操作:
测试后的效果如何:
function : ?encrypt@@YAPADPAD@Z
fullName : char * __cdecl encrypt(char*)
SymbolInfo.name : encrypt
SymbolInfo.returnType : char *
SymbolInfo.parameters : (char *)
Run Code Online (Sandbox Code Playgroud)