// DumpWriteLoc.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
#include <DbgHelp.h>
#pragma comment(lib, "Dbghelp.lib")
#pragma auto_inline (off) //取消内联效果
void FuncTest();
void FunctionTest2();
LONG __stdcall UnhandledExceptionFilterCall( __in struct _EXCEPTION_POINTERS *ExceptionInfo );
int main(int argc, char* argv[])
{
SetUnhandledExceptionFilter(UnhandledExceptionFilterCall);
FuncTest();
return 0;
}
LONG __stdcall UnhandledExceptionFilterCall( __in struct _EXCEPTION_POINTERS *ExceptionInfo )
{
HANDLE hDumpFile = CreateFile("D://DumpWriteLoc.dmp", GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDumpFile != INVALID_HANDLE_VALUE)
{
_MINIDUMP_EXCEPTION_INFORMATION MinExcInfo;
MinExcInfo.ClientPointers = TRUE;
MinExcInfo.ExceptionPointers = ExceptionInfo;
MinExcInfo.ThreadId = GetCurrentThreadId();
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile,
MiniDumpNormal, &MinExcInfo, NULL, NULL );
CloseHandle(hDumpFile);
}
return EXCEPTION_EXECUTE_HANDLER;
}
void FuncTest()
{
FunctionTest2();
}
void FunctionTest2()
{
int* p = NULL;
*p = 0;
char* pp = NULL;
*pp = '2';
}