Dependency Walker PE模块依赖性分析工具

摘要

本文主要讲解利用Dependency Walker为Qt的exe程序添加dll,以使得其可以在客户的机器上运行。

Dependency Walker 程序的目录

这里写图片描述

PE模块依赖性分析

打开depends.exe,有3种方式引入待分析的文件:

  • File -> Open
  • 菜单栏 -> 文件夹图标
  • 将待分析的程序拖入depends程序界面

它可以分析exe或dll文件。

我这里拖入一个exe文件,弹窗报错。这是因为该exe文件所需的相应dll不在exe的当前目录下,也不再系统环境变量的目录下。

这里写图片描述

模块依赖性分析结果如下。对于Qt程序来说,左侧目录树一般展开3级就足够了。

这里写图片描述

依赖树的5种不同图标的含义

  • 链接的非系统库
    这里写图片描述
  • 链接的64位系统库
    这里写图片描述
  • 链接到的系统库的软链接(意思就是该库在父节点或者前面的子节点已经出现过了)
    这里写图片描述
  • 链接到的非系统库的软链接(意思就是该库在父节点或者前面的子节点已经出现过了)
    这里写图片描述
  • 链接到的库,但是找不到该库文件
    这里写图片描述

在打包程序的时候一般只需要复制非系统库到当前exe的目录下即可,也就是说找出图标为“非系统库”的DLL就好了(这里写图片描述)。

该可执行文件需要引用的DLL在Module面板的滑动条拉到最底处

这里写图片描述

  • libgcc_s_dw2-1.dll
  • libstdc++-6.dll
  • libwinpthread-1.dll
  • Qt5Core.dll
  • Qt5SerialPort.dll

查看该库的位置

在该库上右击 -> properties…(Alt + Enter) -> “xxx 属性”对话框 -> “安全”选项卡 -> 对象名称(即为该文件的目录了。

这里写图片描述

这里写图片描述

后来,在试验中发现,比如 Qt 的桌面程序,需要拷贝 plugins/platforms文件夹到该可执行目录下。platforms里面包含一些dll,但是在Dependency Walker PE中并不会显示出这些dll。如果不拷贝该目录的话会报错

这里写图片描述

plugins/platforms目录结构

  • qminimal.dll
  • qminimald.dll
  • qoffscreen.dll
  • qoffscreend.dll
  • qwindows.dll
  • qwindowsd.dll
Dependency Walker 可以自由查看任何32位 或 64位 Windows 程序模块的内部层次依赖关系与结构关系 (包括exe, dll, ocx, sys, 等文件),并通过树状图示的方式显示。 本资源为32位系统支持,其他位宽程序请查看下面官网下载 http://www.dependencywalker.com/ (以下不做翻译) For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules. Another view displays the minimum set of required files, along with detailed information about each file including a full path to the file, base address, version numbers, machine type, debug information, and more. Dependency Walker is also very useful for troubleshooting system errors related to loading and executing modules. Dependency Walker detects many common application problems such as missing modules, invalid modules, import/export mismatches, circular dependency errors, mismatched machine types of modules, and module initialization failures. Dependency Walker runs on Windows 95, 98, Me, NT, 2000, XP, 2003, Vista, 7, and 8. It can process any 32-bit or 64-bit Windows module, including ones designed for Windows CE. It can be run as graphical application or as a console application. Dependency Walker handles all types of module dependencies, including implicit, explicit (dynamic / runtime), forwarded, delay-loaded, and injected. A detailed help is included. Dependency Walker is completely free to use. However, you may not profit from the distribution of it, nor may you bundle it with another product.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值