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. I need this to work under Windows XP SP3, Vista, 7, 8.
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+ 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_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\DumpType
value to 2 to save full dumps which, by default are stored in %LOCALAPPDATA%\CrashDumps
(C:\Users\dee.earley\AppData\Local\CrashDumps
).
Installing a debugger like WinDebug will also allow you to catch exceptions from user mode apps and the service as they occur.
Microsoft's DebugDiag tool is quite useful for monitoring processes and spitting out dump files on exceptions and crashes.
http://www.microsoft.com/en-us/download/details.aspx?id=26798
I've used this in multiple customer environments to track down problems that I could not reproduce in my own environment.
If you are looking a way for handling crash on customers side the best solution is using google-breakpad library. In your case exception handler will write dump files on the disk.