如何打开在c++中创建的DLL文件来查看类、方法和源代码
How can I open DLL file created in C++ to view classes, methods and source code?
我发现了一个用c++创建的。dll文件。我想打开这个文件,看看类里面的函数。
如何打开这个文件并在我的c++项目中调用函数?
使用Microsoft的命令行实用程序 dumpbin
,您可以显示DLL导入或导出的内容:
dumpbin /exports Test0221-5.dll
显示公开的函数。但这取决于你来分析内容。例如:
Dump of file Test0221-5.dll
File Type: DLL
Section contains the following exports for Test0221-5.dll
00000000 characteristics
555E19D5 time date stamp Thu May 21 19:45:57 2015
0.00 version
1 ordinal base
4 number of functions
4 number of names
ordinal hint RVA name
1 0 000113E3 ??0Btest@@QAE@XZ = @ILT+990(??0Btest@@QAE@XZ)
2 1 000112CB ??1Btest@@QAE@XZ = @ILT+710(??1Btest@@QAE@XZ)
3 2 00011028 ?MemberFunc@A@@UAEXXZ = @ILT+35(?MemberFunc@A@@UAEXXZ)
4 3 00011244 createInstance = @ILT+575(_createInstance)
Summary
1000 .data
1000 .idata
3000 .rdata
1000 .reloc
1000 .rsrc
C000 .text
10000 .textbss
因此,在上面,您可以看到函数4。这个名字对应一个符号,所以它可能是一个叫做createInstance()
的extern "C"
函数。但是你不能找到任何关于它的参数或者它的返回类型的信息。
函数1到3更具表现力。它看起来像一个函数名,但名字中有?
@
等奇怪的字符。这些都是"乱糟糟"的c++名称。名称的混淆取决于编译器。
MSVC有一个工具undname
:
undname ??0Btest@@QAE@XZ
Undecoration of :- "??0Btest@@QAE@XZ"
is :- "public: __thiscall Btest::Btest(void)"
你称它为一个符号一个符号。幸运的是,有一个更方便的选择:http://demangler.com/。您可以复制损坏名称的完整列表(MSVC或GCC)并在浏览器中传递它,以查找,例如:
public: __thiscall Btest::Btest(void) = @ILT 990(public: __thiscall Btest::Btest(void)
public: __thiscall Btest::~Btest(void) = @ILT 710(public: __thiscall Btest::~Btest(void)
public: virtual void __thiscall A::MemberFunc(void) = @ILT 35(public: virtual void __thiscall A::MemberFunc(void)
你得到函数的类,它是虚的还是非虚的,它是静态的还是非静态的,返回类型,调用约定,以及每个参数的类型。
也许这可以帮助你,但正如你所看到的,这是相当手工的,不可能是完整的。例如,您不会看到类继承和非导出成员。
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 通过方法访问结构
- 最小硬币更换问题(自上而下方法)
- C++为构建时间获取QDateTime的可靠方法
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 处理多个异常集合的C++方法
- 更改命令行 qt5 源代码构建配置的正确/快速方法
- 使用 Git 处理 C++ Visual Studio 2019 解决方案的外部依赖项源代码管理的最佳方法是什么?
- 我最近正在阅读opencv源代码。有没有更好的方法来在opencv库中查找类定义?
- 将本机方法添加到 OpenJDK 源代码
- 使用继承的类模板避免公共成员不可见和源代码膨胀/重复的更好方法
- 如何在我的源代码中找到所有发生的情况,其中std :: string被传递给方法作为副本而不是恒定引用
- gdb 中的方法定义没有源代码
- CMake 从公共源代码树生成多个项目的方法
- 有没有一种方法可以将C++源代码编译成二进制文件,以便gdb可以看到它
- 用于解析C++源代码并将头内联方法移动到.cpp源文件的工具
- 将函数合并到源代码中的方法
- 方法,但从未在Geant4源代码中定义
- 获取源代码树中 boost:shared_ptr get 方法的所有用法的列表
- 如何打开在c++中创建的DLL文件来查看类、方法和源代码