在 C++ 服务和用户模式应用程序崩溃后收集崩溃 .dmp 和 .hdmp 文件

2022-01-12 00:00:00 winapi crash c++ crash-dumps crash-reports

我正在使用 WinAPI 在 C++/MFC 中进行编码.我的软件由本地服务和为登录的 Windows 用户提供用户界面的用户模式应用程序组成.我正在寻找一种方法来收集 .dmp 和 .hdmp 文件,以防这些模块中的任何一个发生崩溃.我知道 WER 应该收集它们并提交他们给微软.有没有办法收集这些文件并将它们保存在硬盘上的某个位置?

I'm coding in C++/MFC using WinAPIs. My software consists of a local service and a user-mode app that provides user interface for a logged in Windows user. I'm looking for a way to collect .dmp and .hdmp files in case of crash in either of those modules. I know that WER supposedly collects them and submits them to Microsoft. Is there a way to collect those files and keep them somewhere on the hard drive?

PS.我需要它才能在 Windows XP SP3、Vista、7、8 下工作.

PS. I need this to work under Windows XP SP3, Vista, 7, 8.

推荐答案

Windows 2000 和 XP 已经使用 DrWatson 保存故障转储.运行 drwtsn32.exe 允许您获取/配置日志和转储文件的路径.

Windows 2000 and XP already save crash dumps using DrWatson. Running drwtsn32.exe allows you to get/configure the path to the log and the dump files.

Windows Vista+ 仅使用 WER,默认情况下不保存转储,但您可以 启用创建用户模式转储.
我将 HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsWindows Error ReportingLocalDumpsDumpType 值设置为 2 以保存完整转储,默认情况下存储在 %LOCALAPPDATA%CrashDumps (C:Usersdee.earleyAppDataLocalCrashDumps).

Windows Vista+ only uses WER, which doesn't save a dump by default, but you can enable creation of user mode dumps.
I set the HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsWindows Error ReportingLocalDumpsDumpType value to 2 to save full dumps which, by default are stored in %LOCALAPPDATA%CrashDumps (C:Usersdee.earleyAppDataLocalCrashDumps).

安装像 WinDebug 这样的调试器还可以让您在用户模式应用和服务发生异常时捕获它们.

Installing a debugger like WinDebug will also allow you to catch exceptions from user mode apps and the service as they occur.

相关文章