#include "login.h" #include #include #include #include "logproc.h" #include #include #include "CLogTrack.h" #include "client/windows/handler/exception_handler.h" long __stdcall CrashInfocallback(_EXCEPTION_POINTERS *pexcp) { //创建 Dump 文件 HANDLE hDumpFile = ::CreateFile( L"client.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if (hDumpFile != INVALID_HANDLE_VALUE) { //Dump信息 MINIDUMP_EXCEPTION_INFORMATION dumpInfo; dumpInfo.ExceptionPointers = pexcp; dumpInfo.ThreadId = GetCurrentThreadId(); dumpInfo.ClientPointers = TRUE; //写入Dump文件内容 ::MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL ); } EXCEPTION_RECORD* record = pexcp->ExceptionRecord; QString errCode(QString::number(record->ExceptionCode,16)), errAdr(QString::number((uint)record->ExceptionAddress,16)); HWND task = nullptr; task=FindWindow(L"Shell_TrayWnd",nullptr); if(task) { ShowWindow(task,SW_SHOW);//隐藏任务栏 } QMessageBox::critical(NULL,QString::fromLocal8Bit("程序崩溃"), QString::fromLocal8Bit("
对于发生的错误,表示诚挚的歉意
")+ QString::fromLocal8Bit("
错误代码:%1
错误地址:%2
").arg(errCode).arg(errAdr), QMessageBox::Ok); myServerLog()<ExceptionRecord; QString errCode(QString::number(record->ExceptionCode, 16)), errAdr(QString::number((uint)record->ExceptionAddress, 16)); HWND task = nullptr; task = FindWindow(L"Shell_TrayWnd", nullptr); if (task) { ShowWindow(task, SW_SHOW);//隐藏任务栏 } QMessageBox::critical(NULL, QString::fromLocal8Bit("程序崩溃"), QString::fromLocal8Bit("
对于发生的错误,表示诚挚的歉意
") + QString::fromLocal8Bit("
错误代码:%1
错误地址:%2
").arg(errCode).arg(errAdr), QMessageBox::Ok); myDebug() << QString::fromLocal8Bit("程序崩溃,错误代码:%1,错误地址:%2").arg(errCode).arg(errAdr); return succeeded; } int main(int argc, char *argv[]) { QApplication a(argc, argv); ::SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)CrashInfocallback); g_appInfoPtr = std::make_shared(); QFileInfo file("coe.cfgi"); QString sFilePath = file.absoluteFilePath(); QSettings set(sFilePath, QSettings::IniFormat); g_appInfoPtr->m_bShowDebugInfo = set.value("config/debug", false).toBool(); qInstallMessageHandler(CustomOutputMessage); // google_breakpad::ExceptionHandler eh( // L".", NULL, callback, NULL, // google_breakpad::ExceptionHandler::HANDLER_ALL); login w; w.show(); if (argc > 1) { QString sParam = argv[1]; if (sParam == "updateLauncher") { QString sSourceFile = g_appInfoPtr->m_sCacheFileDir + "uptemp/launcher.exe"; QString sDestFileName = "launcher.exe"; QFile file(sSourceFile); if (file.exists()) { QFile::remove(sDestFileName); bool bcopy = file.copy(sDestFileName); myDebug() << bcopy; } return a.exec(); } else if (sParam == "runClient") { return a.exec(); } else { return 0; } } else { #ifdef _DEBUG return a.exec(); #else return 0; #endif } }