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())); }
int BootLoader::ExitInstance() { int ret=0; if (m_pUICore) m_pUICore->exitApp(&ret); return ret; }
void BootLoader::loadUICore() { if (!BootLoaderUtil::SetDllDir(".\\bin")) { ::MessageBox(nullptr, "Failed to set the DLL path to the bin folder.", PRODUCT_NAME ": ERROR!", MB_OK); exit(-100); } preReadImages(); const char* dllname = "uicore.dll"; if (!m_hUICore.load(dllname)) { DWORD err = GetLastError(); ::MessageBox(nullptr, "Failed to load uicore.dll", PRODUCT_NAME ": ERROR!", MB_OK); exit(-200); } UICoreFP UICoreGetInterface = m_hUICore.getFunction<UICoreFP>("GetInterface"); if (!UICoreGetInterface) { ::MessageBox(nullptr, "Failed to load wxWidgets mappings in uicore.dll", PRODUCT_NAME ": ERROR!", MB_OK); exit(-500); } m_pUICore = UICoreGetInterface(); char version[100] = {0}; _snprintf_s(version, 100, _TRUNCATE, "%d.%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILDNO, VERSION_EXTEND); m_pUICore->setDesuraVersion(version); m_pUICore->setRestartFunction(&UiCoreRestart); m_pUICore->setCrashDumpSettings(&SetDumpArgs); m_pUICore->setCrashDumpLevel(&SetDumpLevel); m_pUICore->setTracer(&g_Tracer); }
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())); }
int BootLoader::ExitInstance() { int ret = 0; if (m_pUICore) m_pUICore->exitApp(&ret); if (g_bRestart) { if (g_szArgs && strstr(g_szArgs, "-setcachedir")) BootLoaderUtil::StartProcess("utility.exe", g_szArgs); else BootLoaderUtil::Restart(g_szArgs); } if (m_bRetCode) return m_iRetCode; return ret; }
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 BootLoader::ExitInstance() { delete m_pMainWnd; int ret = CWinApp::ExitInstance(); if (m_pUICore) m_pUICore->exitApp(&ret); if (g_bRestart) { if (g_szArgs && strstr(g_szArgs, "-setcachedir")) #ifdef DEBUG BootLoaderUtil::StartProcess("utility-d.exe", g_szArgs); #else BootLoaderUtil::StartProcess("utility.exe", g_szArgs); #endif else BootLoaderUtil::Restart(g_szArgs); }
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; }