bool DolphinApp::OnInit() { InitLanguageSupport(); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; wxString videoBackendName; wxString audioEmulationName; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, wxS("h"), wxS("help"), _("Show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, wxS("d"), wxS("debugger"), _("Opens the debugger"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, wxS("l"), wxS("logger"), _("Opens the logger"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("e"), wxS("exec"), _("Loads the specified file (DOL,ELF,GCM,ISO,WAD)"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, wxS("b"), wxS("batch"), _("Exit Dolphin with emulator"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("V"), wxS("video_backend"), _("Specify a video backend"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("A"), wxS("audio_emulation"), _("Low level (LLE) or high level (HLE) audio"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found(wxT("debugger")); UseLogger = parser.Found(wxT("logger")); LoadFile = parser.Found(wxT("exec"), &FileToLoad); BatchMode = parser.Found(wxT("batch")); selectVideoBackend = parser.Found(wxT("video_backend"), &videoBackendName); // TODO: This currently has no effect. Implement or delete. selectAudioEmulation = parser.Found(wxT("audio_emulation"), &audioEmulationName); #endif // wxUSE_CMDLINE_PARSER #if defined _DEBUG && defined _WIN32 int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF; _CrtSetDbgFlag(tmpflag); #endif // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); // "ExtendedTrace" looks freakin dangerous!!! #ifdef _WIN32 EXTENDEDTRACEINITIALIZE("."); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); #elif wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif // TODO: if First Boot if (!cpu_info.bSSE2) { PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" "Sayonara!\n"); return false; } #ifdef _WIN32 if (!wxSetWorkingDirectory(wxString(File::GetExeDirectory().c_str(), *wxConvCurrent))) { INFO_LOG(CONSOLE, "set working directory failed"); } #else //create all necessary directories in user directory //TODO : detect the revision and upgrade where necessary File::CopyDir(std::string(SHARED_USER_DIR GAMECONFIG_DIR DIR_SEP), File::GetUserPath(D_GAMECONFIG_IDX)); File::CopyDir(std::string(SHARED_USER_DIR MAPS_DIR DIR_SEP), File::GetUserPath(D_MAPS_IDX)); File::CopyDir(std::string(SHARED_USER_DIR SHADERS_DIR DIR_SEP), File::GetUserPath(D_SHADERS_IDX)); File::CopyDir(std::string(SHARED_USER_DIR WII_USER_DIR DIR_SEP), File::GetUserPath(D_WIIUSER_IDX)); File::CopyDir(std::string(SHARED_USER_DIR OPENCL_DIR DIR_SEP), File::GetUserPath(D_OPENCL_IDX)); if (!File::Exists(File::GetUserPath(D_CONFIG_IDX))) File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); #endif LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); WiimoteReal::LoadSettings(); if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = std::string(videoBackendName.mb_str()); VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check HWND hDesktop = GetDesktopWindow(); RECT rc; GetWindowRect(hDesktop, &rc); if (rc.right < x + w || rc.bottom < y + h) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, wxString::FromAscii(svn_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); // Postpone final actions until event handler is running. // Updating the game list makes use of wxProgressDialog which may // only be run after OnInit() when the event handler is running. m_afterinit = new wxTimer(this, wxID_ANY); m_afterinit->Start(1, wxTIMER_ONE_SHOT); return true; }
bool DolphinApp::OnInit() { Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this); Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this); InitLanguageSupport(); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; wxString videoBackendName; wxString audioEmulationName; wxString userPath; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "h", "help", "Show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, "d", "debugger", "Opens the debugger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "l", "logger", "Opens the logger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "e", "exec", "Loads the specified file (ELF, DOL, GCM, ISO, WBFS, CISO, GCZ, WAD)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "b", "batch", "Exit Dolphin with emulator", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "V", "video_backend", "Specify a video backend", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "A", "audio_emulation", "Low level (LLE) or high level (HLE) audio", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "m", "movie", "Play a movie file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "U", "user", "User folder path", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); if (argc == 2 && File::Exists(argv[1].ToUTF8().data())) { LoadFile = true; FileToLoad = argv[1]; } else if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found("debugger"); UseLogger = parser.Found("logger"); if (!LoadFile) LoadFile = parser.Found("exec", &FileToLoad); BatchMode = parser.Found("batch"); selectVideoBackend = parser.Found("video_backend", &videoBackendName); selectAudioEmulation = parser.Found("audio_emulation", &audioEmulationName); playMovie = parser.Found("movie", &movieFile); if (parser.Found("user", &userPath)) { File::CreateFullPath(WxStrToStr(userPath) + DIR_SEP); File::GetUserPath(D_USER_IDX, userPath.ToStdString() + DIR_SEP); } #endif // wxUSE_CMDLINE_PARSER // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); // "ExtendedTrace" looks freakin' dangerous!!! #ifdef _WIN32 EXTENDEDTRACEINITIALIZE("."); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); #elif wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif #ifdef __APPLE__ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_7) { PanicAlertT("Hi,\n\nDolphin requires Mac OS X 10.7 or greater.\n" "Unfortunately you're running an old version of OS X.\n" "The last Dolphin version to support OS X 10.6 is Dolphin 3.5\n" "Please upgrade to 10.7 or greater to use the newest Dolphin version.\n\n" "Sayonara!\n"); return false; } #endif UICommon::CreateDirectories(); UICommon::Init(); if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = WxStrToStr(videoBackendName); if (selectAudioEmulation) { if (audioEmulationName == "HLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = true; else if (audioEmulationName == "LLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = false; } VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; if (File::Exists("www.dolphin-emulator.com.txt")) { File::Delete("www.dolphin-emulator.com.txt"); wxMessageDialog dlg(nullptr, _( "This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please " "download Dolphin from the official website instead: https://dolphin-emu.org/"), _("Unofficial version detected"), wxOK | wxICON_WARNING); dlg.ShowModal(); wxLaunchDefaultBrowser("https://dolphin-emu.org/?ref=badver"); exit(0); } // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN); int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN); int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(scm_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); AfterInit(); return true; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { #ifndef _DEBUG SingleInstance dcapp(_T("{AIRDC-AEE8350A-B49A-4753-AB4B-E55479A48351}")); #else SingleInstance dcapp(_T("{AIRDC-AEE8350A-B49A-4753-AB4B-E55479A48350}")); #endif if(dcapp.IsAnotherInstanceRunning()) { // Allow for more than one instance... bool multiple = false; if(_tcslen(lpstrCmdLine) == 0) { if (::MessageBox(NULL, _T("There is already an instance of AirDC++ running.\nDo you want to launch another instance anyway?"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) { multiple = true; } } if(multiple == false) { HWND hOther = NULL; EnumWindows(searchOtherInstance, (LPARAM)&hOther); if( hOther != NULL ) { // pop up ::SetForegroundWindow(hOther); if( IsIconic(hOther)) { // restore ::ShowWindow(hOther, SW_RESTORE); } sendCmdLine(hOther, lpstrCmdLine); } return FALSE; } } // For SHBrowseForFolder, UPnP_COM HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); #ifdef _DEBUG EXTENDEDTRACEINITIALIZE(Util::getPath(Util::PATH_RESOURCES).c_str()); #endif LPTOP_LEVEL_EXCEPTION_FILTER pOldSEHFilter = NULL; pOldSEHFilter = SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter); AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_STANDARD_CLASSES | ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); try { File f(WinUtil::getAppName(), File::READ, File::OPEN); TigerTree tth(TigerTree::calcBlockSize(f.getSize(), 1)); size_t n = 0; size_t n2 = DEBUG_BUFSIZE; while( (n = f.read(buf, n2)) > 0) { tth.update(buf, n); n2 = DEBUG_BUFSIZE; } tth.finalize(); strcpy(::tth, tth.getRoot().toBase32().c_str()); WinUtil::tth = Text::toT(::tth); } catch(const FileException&) { dcdebug("Failed reading exe\n"); } HINSTANCE hInstRich = ::LoadLibrary(_T("MSFTEDIT.DLL")); if (hInstRich == NULL) { MessageBox(NULL, _T("AirDC++ isn't supported in operating systems older than Microsoft Windows XP3"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), MB_OK | MB_ICONEXCLAMATION); return FALSE; } int nRet = Run(lpstrCmdLine, nCmdShow); if ( hInstRich ) { ::FreeLibrary(hInstRich); } // Return back old VS SEH handler if (pOldSEHFilter != NULL) SetUnhandledExceptionFilter(pOldSEHFilter); _Module.Term(); ::CoUninitialize(); #ifdef _DEBUG EXTENDEDTRACEUNINITIALIZE(); #endif return nRet; }
bool DolphinApp::OnInit() { InitLanguageSupport(); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; wxString videoBackendName; wxString audioEmulationName; wxString userPath; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "h", "help", "Show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, "d", "debugger", "Opens the debugger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "l", "logger", "Opens the logger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "e", "exec", "Loads the specified file (DOL,ELF,GCM,ISO,WAD)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "b", "batch", "Exit Dolphin with emulator", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "V", "video_backend", "Specify a video backend", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "A", "audio_emulation", "Low level (LLE) or high level (HLE) audio", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "m", "movie", "Play a movie file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "U", "user", "User folder path", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found("debugger"); UseLogger = parser.Found("logger"); LoadFile = parser.Found("exec", &FileToLoad); BatchMode = parser.Found("batch"); selectVideoBackend = parser.Found("video_backend", &videoBackendName); selectAudioEmulation = parser.Found("audio_emulation", &audioEmulationName); playMovie = parser.Found("movie", &movieFile); if (parser.Found("user", &userPath)) { File::CreateFullPath(WxStrToStr(userPath) + DIR_SEP); File::GetUserPath(D_USER_IDX, userPath.ToStdString() + DIR_SEP); } #endif // wxUSE_CMDLINE_PARSER // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); // "ExtendedTrace" looks freakin' dangerous!!! #ifdef _WIN32 EXTENDEDTRACEINITIALIZE("."); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); #elif wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif #ifndef _M_ARM // TODO: if First Boot if (!cpu_info.bSSE2) { PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" "Sayonara!\n"); return false; } #endif #ifdef __APPLE__ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_7) { PanicAlertT("Hi,\n\nDolphin requires Mac OS X 10.7 or greater.\n" "Unfortunately you're running an old version of OS X.\n" "The last Dolphin version to support OS X 10.6 is Dolphin 3.5\n" "Please upgrade to 10.7 or greater to use the newest Dolphin version.\n\n" "Sayonara!\n"); return false; } #endif // Copy initial Wii NAND data from Sys to User. File::CopyDir(File::GetSysDirectory() + WII_USER_DIR DIR_SEP, File::GetUserPath(D_WIIUSER_IDX)); File::CreateFullPath(File::GetUserPath(D_USER_IDX)); File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); File::CreateFullPath(File::GetUserPath(D_GAMESETTINGS_IDX)); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP); File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); File::CreateFullPath(File::GetUserPath(D_MAPS_IDX)); File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX)); File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); File::CreateFullPath(File::GetUserPath(D_THEMES_IDX)); LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); WiimoteReal::LoadSettings(); if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = WxStrToStr(videoBackendName); if (selectAudioEmulation) { if (audioEmulationName == "HLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = true; else if (audioEmulationName == "LLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = false; } VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; #ifdef _WIN32 if (File::Exists("www.dolphin-emulator.com.txt")) { File::Delete("www.dolphin-emulator.com.txt"); MessageBox(nullptr, L"This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please " L"download Dolphin from the official website instead: http://dolphin-emu.org/", L"Unofficial version detected", MB_OK | MB_ICONWARNING); ShellExecute(nullptr, L"open", L"http://dolphin-emu.org/?ref=badver", nullptr, nullptr, SW_SHOWDEFAULT); exit(0); } #endif // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN); int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN); int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame((wxFrame*)nullptr, wxID_ANY, StrToWxStr(scm_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); // Postpone final actions until event handler is running. // Updating the game list makes use of wxProgressDialog which may // only be run after OnInit() when the event handler is running. m_afterinit = new wxTimer(this, wxID_ANY); m_afterinit->Start(1, wxTIMER_ONE_SHOT); return true; }
LONG __stdcall DCUnhandledExceptionFilter( LPEXCEPTION_POINTERS e ) { Lock l(cs); if(recursion++ > 30) exit(-1); #ifndef _DEBUG #if _MSC_VER == 1200 __pfnDliFailureHook = FailHook; #elif _MSC_VER == 1300 || _MSC_VER == 1310 || _MSC_VER == 1400 || _MSC_VER == 1500 || _MSC_VER == 1600 __pfnDliFailureHook2 = FailHook; #else #error Unknown Compiler version #endif // The release version loads the dll and pdb:s here... EXTENDEDTRACEINITIALIZE( Util::getPath(Util::PATH_RESOURCES).c_str() ); #endif if(firstException) { File::deleteFile(Util::getPath(Util::PATH_RESOURCES) + "exceptioninfo.txt"); firstException = false; } if(File::getSize(Util::getPath(Util::PATH_RESOURCES) + "AirDC.pdb") == -1) { // No debug symbols, we're not interested... ::MessageBox(WinUtil::mainWnd, _T("AirDC++ has crashed and you don't have AirDC.pdb file installed. Hence, I can't find out why it crashed, so don't report this as a bug unless you find a solution..."), _T("AirDC++ has crashed"), MB_OK); #ifndef _DEBUG exit(1); #else return EXCEPTION_CONTINUE_SEARCH; #endif } File f(Util::getPath(Util::PATH_RESOURCES) + "exceptioninfo.txt", File::WRITE, File::OPEN | File::CREATE); f.setEndPos(0); DWORD exceptionCode = e->ExceptionRecord->ExceptionCode ; string archStr = "x32"; #ifdef _WIN64 archStr = "x64"; #endif sprintf(buf, "Code: %x ( %s )\r\nVersion: %s %s\r\n", exceptionCode, getExceptionName(exceptionCode).c_str(), VERSIONSTRING, archStr); f.write(buf, strlen(buf)); #if defined(SVNVERSION) sprintf(buf, "SVN: %s\r\n", SVNVERSION); f.write(buf, strlen(buf)); #endif OSVERSIONINFOEX ver; WinUtil::getVersionInfo(ver); sprintf(buf, "Major: %d\r\nMinor: %d\r\nBuild: %d\r\nSP: %d\r\nType: %d\r\n", (DWORD)ver.dwMajorVersion, (DWORD)ver.dwMinorVersion, (DWORD)ver.dwBuildNumber, (DWORD)ver.wServicePackMajor, (DWORD)ver.wProductType); f.write(buf, strlen(buf)); time_t now; time(&now); strftime(buf, DEBUG_BUFSIZE, "Time: %Y-%m-%d %H:%M:%S\r\n", localtime(&now)); f.write(buf, strlen(buf)); f.write(LIT("TTH: ")); f.write(tth, strlen(tth)); f.write(LIT("\r\n")); f.write(LIT("\r\n")); STACKTRACE(f, e->ContextRecord); f.write(LIT("\r\n")); f.close(); if ((!SETTING(SOUND_EXC).empty()) && (!BOOLSETTING(SOUNDS_DISABLED))) PlaySound(Text::toT(SETTING(SOUND_EXC)).c_str(), NULL, SND_FILENAME | SND_ASYNC); NOTIFYICONDATA m_nid; m_nid.cbSize = sizeof(NOTIFYICONDATA); m_nid.hWnd = MainFrame::getMainFrame()->m_hWnd; m_nid.uID = 0; m_nid.uFlags = NIF_INFO; m_nid.uTimeout = 5000; m_nid.dwInfoFlags = NIIF_WARNING; _tcscpy(m_nid.szInfo, _T("exceptioninfo.txt was generated")); _tcscpy(m_nid.szInfoTitle, _T("AirDC++ has crashed")); Shell_NotifyIcon(NIM_MODIFY, &m_nid); if(MessageBox(WinUtil::mainWnd, _T("AirDC++ just encountered a fatal bug and should have written an exceptioninfo.txt the same directory as the executable. You can upload this file at http://www.airdcpp.net to help us find out what happened. Go there now?"), _T("AirDC++ Has Crashed"), MB_YESNO | MB_ICONERROR) == IDYES) { WinUtil::openLink(_T("http://crash.airdcpp.net")); } #ifndef _DEBUG EXTENDEDTRACEUNINITIALIZE(); exit(-1); #else return EXCEPTION_CONTINUE_SEARCH; #endif }