void BootLoader::InitInstance() { m_MDumpHandle.setTracerSharedMemoryName(g_Tracer.getSharedMemName()); UTIL::MISC::CMDArgs args(m_lpCmdLine); if (args.hasArg("waitfordebugger")) BootLoaderUtil::WaitForDebugger(); BootLoaderUtil::SetCurrentDir(); bool bRunUnitTests = args.hasArg("unittests"); if (!bRunUnitTests && !preLaunchCheck(args)) return; loadUICore(); if (!m_pUICore) return; if (bRunUnitTests) { m_iRetCode = m_pUICore->runUnitTests(args.getArgc(), const_cast<char**>(args.getArgv())); m_bRetCode = true; return; } m_pUICore->initWxWidgets(m_hInstance, m_nCmdShow, args.getArgc(), const_cast<char**>(args.getArgv())); }
void BootLoader::InitInstance() { if (BootLoaderUtil::GetOSId() == WINDOWS_PRE2000) { ::MessageBox(NULL, PRODUCT_NAME " needs Windows XP or better to run.", PRODUCT_NAME " Error: Old Windows", MB_OK); return; } loadUICore(); if (!m_pUICore) return; UTIL::MISC::CMDArgs args(m_lpCmdLine); args.addValue("-toolhelper"); m_pUICore->initWxWidgets(m_hInstance, m_nCmdShow, args.getArgc(), const_cast<char**>(args.getArgv())); }
void BootLoader::InitInstance() { UTIL::MISC::CMDArgs args(m_lpCmdLine); if (BootLoaderUtil::GetOSId() == WINDOWS_PRE2000) { ::MessageBox(nullptr, PRODUCT_NAME " needs Windows XP or better to run.", PRODUCT_NAME " Error: Old Windows", MB_OK); return; } if (args.hasArg("wait")) BootLoaderUtil::WaitForOtherInstance("desura.exe"); loadUICore(); if (!m_pUICore) return; m_pUICore->initWxWidgets(m_hInstance, m_nCmdShow, args.getArgc(), const_cast<char**>(args.getArgv())); }
int MainApp::run() { ERROR_OUTPUT("#########################################"); ERROR_OUTPUT("# DEBUG BUILD #"); ERROR_OUTPUT("#########################################"); if (!ChangeToAppDir()) return -1; bool usingGDB = false; #ifdef WITH_GTEST bool runGtest = false; #endif #ifdef DESURA_OFFICIAL_BUILD bool forceUpdate = false; bool skipUpdate = false; bool testDownload = false; bool testInstall = false; #endif for (int x=0; x<m_Argc; x++) { if (!m_Argv[x]) continue; if (strcasecmp(m_Argv[x], "-g") == 0 || strcasecmp(m_Argv[x], "--gdb") == 0) usingGDB = true; #ifdef WITH_GTEST if (strcasecmp(m_Argv[x], "-u") == 0 || strcasecmp(m_Argv[x], "--unittests") == 0) runGtest = true; #endif #ifdef DESURA_OFFICIAL_BUILD if (strcasecmp(m_Argv[x], "-td") == 0 || strcasecmp(m_Argv[x], "--testdownload") == 0) testDownload = true; if (strcasecmp(m_Argv[x], "-ti") == 0 || strcasecmp(m_Argv[x], "--testinstall") == 0) testInstall = true; if (strcasecmp(m_Argv[x], "-s") == 0 || strcasecmp(m_Argv[x], "--skipupdate") == 0 || strncasecmp(m_Argv[x], "desura://", 9) == 0) skipUpdate = true; if (strcasecmp(m_Argv[x], "-f") == 0 || strcasecmp(m_Argv[x], "--forceupdate") == 0) forceUpdate = true; #endif } #ifdef DESURA_OFFICIAL_BUILD #ifdef WIN32 if (testInstall) return InstallFilesForTest(); if (testDownload) return DownloadFilesForTest(); #endif #endif #ifndef DEBUG std::string lockPath = UTIL::LIN::expandPath("$XDG_RUNTIME_DIR/desura/lock"); if (!FileExists(lockPath.c_str())) // if desura isn't already running - simple check { #ifdef DESURA_OFFICIAL_BUILD if (CheckForUpdate(forceUpdate, skipUpdate)) return 0; #endif checkUnityWhitelist(); } #endif if (!loadUICore()) { ERROR_OUTPUT(dlerror()); return -1; } #ifdef WITH_GTEST if (runGtest) { return m_pUICore->runUnitTests(m_Argc, m_Argv); } #endif if (!m_pUICore->singleInstantCheck()) { sendArgs(); return 0; } #ifndef DEBUG if (!loadCrashHelper()) return -1; #endif m_pUICore->disableSingleInstanceLock(); if (usingGDB) { ERROR_OUTPUT("Running with GDB -- Not setting up dump handler"); } else { MiniDumpGenerator m_MDumpHandle; m_MDumpHandle.showMessageBox(true); m_MDumpHandle.setCrashCallback(&MainApp::onCrash); } return m_pUICore->initWxWidgets(m_Argc, m_Argv); }
BOOL BootLoader::InitInstance() { BootLoaderUtil::CMDArgs args(m_lpCmdLine); if (args.hasArg("waitfordebugger")) BootLoaderUtil::WaitForDebugger(); BootLoaderUtil::SetCurrentDir(); CWinApp::InitInstance(); #ifdef DESURA_OFFICAL_BUILD CheckForBadUninstaller(); #endif if (args.hasArg("urllink")) { std::string a(m_lpCmdLine); size_t pos = a.find("-urllink"); a.replace(pos, 8, ""); BootLoaderUtil::Restart(a.c_str(), false); return FALSE; } #ifdef DESURA_OFFICAL_BUILD if (args.hasArg("testinstall")) { m_bRetCode = true; m_iRetCode = InstallFilesForTest(); return FALSE; } if (args.hasArg("testdownload")) { m_bRetCode = true; m_iRetCode = DownloadFilesForTest(); return FALSE; } #endif if (args.hasArg("dumplevel")) { SetDumpLevel(args.getInt("dumplevel")); g_bLockDump = true; } if (args.hasArg("autostart")) { //need to wait for service to start Sleep(15*1000); BootLoaderUtil::RestartAsNormal("-wait"); return FALSE; } #ifdef DESURA_OFFICAL_BUILD #ifdef DEBUG if (args.hasArg("debugupdater")) { INT_PTR nResponse = DisplayUpdateWindow(-1); return FALSE; } if (args.hasArg("debuginstall")) { McfUpdate(); return FALSE; } if (args.hasArg("debugdownload")) { FullUpdate(); return FALSE; } if (args.hasArg("debugcheck")) { CheckInstall(); return FALSE; } #endif #endif if (args.hasArg("testcrash")) { BootLoader *ai = NULL; ai->AssertValid(); } unsigned int osid = BootLoaderUtil::GetOSId(); if (osid == WINDOWS_PRE2000) { ::MessageBox(NULL, PRODUCT_NAME " needs Windows XP or better to run.", PRODUCT_NAME " Error: Old Windows", MB_OK); return FALSE; } else if (osid == WINDOWS_XP || osid == WINDOWS_XP64) { hasAdminRights = true; } if (args.hasArg("admin")) { hasAdminRights = true; } //if the wait command is parsed in then we need to wait for all other instances of desura to exit. if (args.hasArg("wait")) { BootLoaderUtil::WaitForOtherInstance(m_hInstance); } else { if (BootLoaderUtil::CheckForOtherInstances(m_hInstance)) { sendArgs(); return FALSE; } else { //if windows uninstall software launches desura it will disable its window till it quits. //Work around for existing clients std::string a(m_lpCmdLine); size_t pos = a.find("desura://uninstall/"); if (pos != std::string::npos) { a.replace(pos+9, 9, "remove"); BootLoaderUtil::RestartAsNormal(a.c_str()); return FALSE; } } } #ifdef DESURA_OFFICAL_BUILD if (args.hasArg("forceupdate")) { if (!hasAdminRights) { restartAsAdmin(UPDATE_FORCED); return FALSE; } else { FullUpdate(); BootLoaderUtil::RestartAsNormal("-wait"); return FALSE; } } #endif #ifdef _DEBUG SetRegValues(); InstallService(); #else int nu = NeedUpdate(); if (nu != UPDATE_NONE) { if (nu == UPDATE_MCF) { Log("Updating from MCF.\n"); McfUpdate(); BootLoaderUtil::RestartAsNormal("-wait"); return FALSE; } else if (nu == UPDATE_SERVICE_PATH) { Log("Service update path [%s].\n", g_UpdateReasons[nu]); if (ServiceUpdate(true)) nu = UPDATE_NONE; } } if (nu != UPDATE_NONE) { if (!hasAdminRights) { restartAsAdmin(nu); return FALSE; } else if (nu == UPDATE_SERVICE_LOCATION || nu == UPDATE_SERVICE_HASH) { Log("Service update location [%s].\n", g_UpdateReasons[nu]); ServiceUpdate(false); } else if (nu == UPDATE_SERVICE_DISABLED) { if (FixServiceDisabled()) BootLoaderUtil::RestartAsNormal("-wait"); return FALSE; } else { Log("Full update [%s].\n", g_UpdateReasons[nu]); FullUpdate(); BootLoaderUtil::RestartAsNormal("-wait"); return FALSE; } } if (hasAdminRights && !(osid == WINDOWS_XP || osid == WINDOWS_XP64)) { BootLoaderUtil::RestartAsNormal("-wait"); return FALSE; } #endif loadUICore(); if (!m_pUICore) return FALSE; bool res = m_pUICore->initWxWidgets(m_hInstance, m_nCmdShow, args.getArgc(), const_cast<char**>(args.getArgv())); if (res) m_pMainWnd = new BootLoaderUtil::CDummyWindow(m_pUICore->getHWND()); return res?TRUE:FALSE; }