|
@@ -13,6 +13,7 @@
|
|
|
#endif
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
#include <Windows.h>
|
|
|
+#include <DbgHelp.h>
|
|
|
|
|
|
#define KSGStart __stdcall
|
|
|
|
|
@@ -37,10 +38,38 @@ namespace Framework
|
|
|
__declspec( dllexport ) void releaseFramework();
|
|
|
}
|
|
|
|
|
|
+typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
|
|
+
|
|
|
+void createMinidump(struct _EXCEPTION_POINTERS* apExceptionInfo)
|
|
|
+{
|
|
|
+ HMODULE mhLib = ::LoadLibrary("dbghelp.dll");
|
|
|
+ MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress(mhLib, "MiniDumpWriteDump");
|
|
|
+
|
|
|
+ HANDLE hFile = ::CreateFile("error_core_memory_dump.dmp", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
|
|
+ FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
+
|
|
|
+ _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
|
|
|
+ ExInfo.ThreadId = ::GetCurrentThreadId();
|
|
|
+ ExInfo.ExceptionPointers = apExceptionInfo;
|
|
|
+ ExInfo.ClientPointers = FALSE;
|
|
|
+
|
|
|
+ pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
|
|
|
+ ::CloseHandle(hFile);
|
|
|
+}
|
|
|
+
|
|
|
+LONG WINAPI unhandledHandler(struct _EXCEPTION_POINTERS* apExceptionInfo)
|
|
|
+{
|
|
|
+ createMinidump(apExceptionInfo);
|
|
|
+ return EXCEPTION_CONTINUE_SEARCH;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int WINAPI WinMain( _In_ HINSTANCE hinst, _In_opt_ HINSTANCE hpinst, _In_ LPSTR cmd, int _In_ show )
|
|
|
{
|
|
|
#ifdef _DEBUG
|
|
|
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
|
|
+#else
|
|
|
+ SetUnhandledExceptionFilter(unhandledHandler);
|
|
|
#endif
|
|
|
Framework::initFramework();
|
|
|
Framework::Startparam stp;
|