1 LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *pExceptionPointers) 2 { 3 //先创建dump文件 4 HANDLE lhDumpFile = CreateFileA("xxx.dmp", GENERIC_WRITE, 0, NULL, 5 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 6 MINIDUMP_EXCEPTION_INFORMATION loExceptionInfo; 7 loExceptionInfo.ExceptionPointers = pExceptionPointers; 8 loExceptionInfo.ThreadId = GetCurrentThreadId(); 9 loExceptionInfo.ClientPointers = TRUE; 10 int nDumpType = MiniDumpNormal | MiniDumpWithDataSegs | MiniDumpWithFullMemory | 11 MiniDumpWithThreadInfo | MiniDumpWithHandleData | MiniDumpWithUnloadedModules; 12 //写dump文件 13 MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), lhDumpFile, (MINIDUMP_TYPE)nDumpType, &loExceptionInfo, NULL, NULL); 14 CloseHandle(lhDumpFile); 15 return EXCEPTION_EXECUTE_HANDLER; 16 } 17 18 int main(int argc, char** argv) 19 { 20 SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); 21 ...... 22 ...... 23 return 0; 24 }
原文:https://www.cnblogs.com/briskzou/p/12154212.html