前言
undname是vs自带的工具, 可以查看命名粉碎前的变量或函数名称.
用法 undname -f XXX
去undname中跟了一下, 找到了udname -f 的实现, 她调用了dbghelp.UnDecorateSymbolName 来干活.
验证:
UnDecorateSymbolName VC6SP6 + PSDK自带, 将DbgHelp.h, DbgHelp.Lib拷贝到工程中, 调用UnDecorateSymbolName, 可以看到效果一样.
代码片段
// hw.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdio.h>
#include "Dbghelp.h"
#pragma comment(lib, "Dbghelp.lib")
int main(int argc, char* argv[])
{
DWORD dwRc = 0;
const char* szDecoratedName = "?GetTypeString@@YAPBDK@Z";
char szUnDecoratedName[MAXBYTE] = {'\0'};
dwRc = UnDecorateSymbolName(szDecoratedName, szUnDecoratedName, sizeof(szUnDecoratedName), UNDNAME_COMPLETE);
if (dwRc > 0) {
printf("%s => \r\n%s\r\n", szDecoratedName, szUnDecoratedName);
} else {
printf("undname failed : %s\r\n", szDecoratedName);
}
/** run result
?GetTypeString@@YAPBDK@Z =>
char const * __cdecl GetTypeString(unsigned long)
*/
system("pause");
return 0;
}