You can customize this to meet your needs. For example, you could add some logic to make it only write out dumps under certain conditions. You could write out a dump with heap by replacing dbgMinidumpNormal with dbgMinidumpFull. Or you could have this
routine run OnExceptionThrown instead of OnExceptionNotHandled (again, adding some conditions on when to write the dump).
I hope that helps. It's always better to create a dump file from out of process. While a call to dbghelp.dll!MiniDumpWriteDump on your own process won't fail, you may end up with a bad dump. There are a few reasons for this. The first is that the faulting
process if often not in such a good state to begin with and any complicated call might fail. If you're only worried about minor issues, then this may not apply here. The second is that it will have a hard time getting the stack information correct for the
calling thread. For this reason, it is suggested that you spin off a seperate worker thread that will make the call to write out the dump.