动态加载一个dll,使用到的GetProcAddress如何取到dll中类的方法格式是怎么样的,麻烦举例说明下,单独的不在类中的方法我是可以取到的。

mlinlin 2013-07-08 01:51:24
动态加载一个dll,使用到的GetProcAddress如何取到dll中类的方法格式是怎么样的,麻烦举例说明下,单独的不在类中的方法我是可以取到的。
...全文
308 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2013-07-08
  • 打赏
  • 举报
回复
引用 3 楼 mlinlin 的回复:
引用 2 楼 zhao4zhong1 的回复:
dumpbin /EXPORTS xxx.dll
嗯,张老师,我有这么来用然后生成一个lib,但是发现导出的函数带有好多问号,所以怀疑是不是会有问题,我测试看看,谢谢
#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
mlinlin 2013-07-08
  • 打赏
  • 举报
回复
引用 5 楼 lianshaohua 的回复:
使用的是显示加载; 但你提到的lib库中很多符号不是给你显示加载用的,如果有dll、lib、.h等三 个文件,最好使用隐式加载;
嗯,我现在通过dll对应生成了一个lib来使用了,刚才测试了一下是可以的,谢谢,结贴给分
mlinlin 2013-07-08
  • 打赏
  • 举报
回复
引用 4 楼 akirya 的回复:
就算你或得到正确的函数地址,也不能正常使用的
哦,这样啊,我现在通过dll对应生成了一个lib来使用了,刚才测试了一下是可以的,谢谢,结贴给分
ztenv 版主 2013-07-08
  • 打赏
  • 举报
回复
使用的是显示加载; 但你提到的lib库中很多符号不是给你显示加载用的,如果有dll、lib、.h等三 个文件,最好使用隐式加载;
  • 打赏
  • 举报
回复
就算你或得到正确的函数地址,也不能正常使用的
mlinlin 2013-07-08
  • 打赏
  • 举报
回复
引用 2 楼 zhao4zhong1 的回复:
dumpbin /EXPORTS xxx.dll
嗯,张老师,我有这么来用然后生成一个lib,但是发现导出的函数带有好多问号,所以怀疑是不是会有问题,我测试看看,谢谢
赵4老师 2013-07-08
  • 打赏
  • 举报
回复
dumpbin /EXPORTS xxx.dll
mlinlin 2013-07-08
  • 打赏
  • 举报
回复
没人用过吗,不是吧,求帮忙啊,感激不尽、、、、、、、、、

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧