Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 中使用 WinDbg 分析 .dmp 文件 #66

Open
xiaoxiaojx opened this issue Oct 6, 2023 · 0 comments
Open

Windows 中使用 WinDbg 分析 .dmp 文件 #66

xiaoxiaojx opened this issue Oct 6, 2023 · 0 comments

Comments

@xiaoxiaojx
Copy link
Owner

image

之前我们在 Docker 中使用 WineHQ 运行了微信, 奇怪的是隔几天会出现一次程序崩溃, 于是准备使用 WinDbg 分析微信的错误报告中的 .dmp 文件来找到崩溃的原因

image

WinDbg 提供了一组命令行和图形界面工具,用于分析内存转储文件(通常是由操作系统或应用程序崩溃时生成的 .DMP文件),跟踪程序执行、检查变量和数据结构、分析堆栈跟踪、监视系统性能等。它通常被开发人员和系统管理员用于解决复杂的软件问题,特别是在开发或维护大型、复杂的 Windows 应用程序时。

准备 .dmp 文件

作为示例我们可以写个会崩溃的程序并且退出时会生成 .dmp 文件, 使用 Visual Studio 时需要在链接器 > 输入 > 附加依赖性中增加 DbgHelp.lib
image

配置 WinDbg

首先可以通过 WinDbg 独立安装包下载,
然后把 .dmp 文件拖动到 WinDbg 中

此时我们必须配置 WinDbg 符号文件的目录, 再勾选 Reload 最后点击 OK 按钮。其中我们需要先新建 c:\symbols 目录作为符号文件的缓存目录, 符号文件是从 Microsoft 公共符号服务器 的地址下载而来

cache*c:\symbols;SRV*https://msdl.microsoft.com/download/symbols

image

符号文件包含大量的数据,这些数据在运行二进制文件时实际上并不需要,但在调试过程中很有用。可以认为相当于 JavaScript 中的 SourceMap 文件, 这是反解源码的必要条件

点击 OK 按钮后会发现目录会出现下载完成的符号文件
image

开始分析

当符合文件链接完成, 就可以输入如下命令开始分析

!analyze -v

image

分析结束 WinDbg 就可以回溯到程序崩溃的代码行列了

image

如果发现不好使就只能在 Docker 中运行 winedbg xxx.dmp 命令来使用 WineDbg 分析了
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant