64,646
社区成员
发帖
与我相关
我的任务
分享
#pragma comment(lib,"imagehlp")
#include <stdio.h>
#include <windows.h>
#include <ImageHlp.h>
char dsn[1024];
void main(int argc,char **argv) {
if (argc<2) {
printf("Usage: %s DecorateSymbolName\n to UnDecorateSymbolName.\n",argv[0]);
printf("For example: %s ??4COleDateTime@@QAEABV0@N@Z\n",argv[0]);
printf("public: class COleDateTime const & __thiscall COleDateTime::operator=(double)\n");
return;
}
if (0==UnDecorateSymbolName(argv[1],dsn,1024,UNDNAME_COMPLETE)) {
printf("UnDecorateSymbolName %s ERROR %08lx!",argv[1],GetLastError());
} else {
printf("%s\n",dsn);
}
}
UnDecorateSymbolName
The UnDecorateSymbolName function undecorates decorated C++ symbol names.
DWORD UnDecorateSymbolName(
IN LPSTR DecoratedName,
OUT LPSTR UnDecoratedName,
IN DWORD UndecoratedLength,
IN DWORD Flags
);
Parameters
DecoratedName
Pointer to a null-terminated string that specifies a decorated C++ symbol name. This name can be identified by the first character of the name, which is always a question mark (?).
UnDecoratedName
Pointer to a null-terminated string that specifies the buffer that receives the undecorated name.
UndecoratedLength
Specifies the length of the UnDecoratedName buffer.
Flags
Specifies how the decorated name is undecorated. This parameter can be zero or any combination of the following values: Value Description
UNDNAME_COMPLETE Enable full undecoration.
UNDNAME_NO_LEADING_UNDERSCORES Remove leading underscores from Microsoft keywords.
UNDNAME_NO_MS_KEYWORDS Disable expansion of Microsoft keywords.
UNDNAME_NO_FUNCTION_RETURNS Disable expansion of return types for primary declarations.
UNDNAME_NO_ALLOCATION_MODEL Disable expansion of the declaration model.
UNDNAME_NO_ALLOCATION_LANGUAGE Disable expansion of the declaration language specifier.
UNDNAME_NO_MS_THISTYPE Disable expansion of Microsoft keywords on the this type for primary declaration.
UNDNAME_NO_CV_THISTYPE Disable expansion of CodeView modifiers on the this type for primary declaration.
UNDNAME_NO_THISTYPE Disable all modifiers on the this type.
UNDNAME_NO_ACCESS_SPECIFIERS Disable expansion of access specifiers for members.
UNDNAME_NO_THROW_SIGNATURES Disable expansion of throw-signatures for functions and pointers to functions.
UNDNAME_NO_MEMBER_TYPE Disable expansion of the static or virtual attribute of members.
UNDNAME_NO_RETURN_UDT_MODEL Disable expansion of Microsoft model for UDT returns.
UNDNAME_32_BIT_DECODE Undecorate 32-bit decorated names.
UNDNAME_NAME_ONLY Crack only the name for primary declaration. Returns [scope::]name. Does expand template parameters.
UNDNAME_NO_ARGUMENTS Do not undecorate function arguments.
UNDNAME_NO_SPECIAL_SYMS Do not undecorate special names, such as vtable, vcall, vector, metatype, and so on.
Return Values
If the function succeeds, the return value is the number of characters in the UnDecoratedName buffer, not including the NULL terminator.
If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
Remarks
If the function fails and returns zero, the content of the UnDecoratedName buffer is undetermined.
QuickInfo
Windows NT: Requires version 4.0 or later.
Windows: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Windows CE: Unsupported.
Header: Declared in imagehlp.h.
Import Library: Use imagehlp.lib.
See Also
PE Image Helper (ImageHlp) Overview, ImageHlp Debugger Functions
使用的是显示加载; 但你提到的lib库中很多符号不是给你显示加载用的,如果有dll、lib、.h等三 个文件,最好使用隐式加载;
就算你或得到正确的函数地址,也不能正常使用的
dumpbin /EXPORTS xxx.dll