dbghelp.dll 定位异常奔溃信息
时间:2021-07-01 10:21:17
帮助过:21人阅读
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 }
定位异常需要以下三个文件:
xxx.dmp
xxx.exe
xxx.pdb
用visual stdio 打开.dmp文件,可以观察到异常的位置
用visual stdio 打开.dmp文件
dbghelp.dll 定位异常奔溃信息
标签:creat ace windows 出现 att argv handle exce cli