GlosSITarget: More EGS Hacks/workarounds

CloseOnExit: Ignore EpicGamesLauncher.exe, EpicWebHelper.exe in detection if GlosSITarget should quit
pull/192/head
Peter Repukat 2 years ago
parent 138dd98c59
commit 96d8f24c93

@ -106,6 +106,7 @@ void AppLauncher::update()
}
}
if (Settings::launch.waitForChildProcs) {
std::erase_if(pids_, [](auto pid) {
if (pid == 0) {
return true;
@ -115,9 +116,25 @@ void AppLauncher::update()
spdlog::trace(L"Child process \"{}\" with PID \"{}\" died", glossi_util::GetProcName(pid), pid);
return !running;
});
if (Settings::launch.closeOnExit && pids_.empty() && Settings::launch.launch) {
spdlog::info("Configured to close on all children exit. Shutting down...");
shutdown_();
auto filtered_pids = pids_ | std::ranges::views::filter([](DWORD pid) {
return std::ranges::find(EGS_LAUNCHER_PROCNAMES_, glossi_util::GetProcName(pid)) == EGS_LAUNCHER_PROCNAMES_.end();
});
if (was_egs_launch_ && !filtered_pids.empty()) {
egs_has_launched_game_ = true;
}
if (Settings::launch.closeOnExit && Settings::launch.launch) {
if (was_egs_launch_) {
if (egs_has_launched_game_ && filtered_pids.empty()) {
spdlog::info("Configured to close on all children exit. Shutting down after game launched via EGS quit...");
shutdown_();
}
} else {
if (pids_.empty()) {
spdlog::info("Configured to close on all children exit. Shutting down...");
shutdown_();
}
}
}
}
getProcessHwnds();
@ -346,6 +363,9 @@ void AppLauncher::launchURL(const std::wstring& url, const std::wstring& args, c
}
CoUninitialize();
if (url.find(L"epicgames.launcher") != std::wstring::npos) {
was_egs_launch_ = true;
}
if (execute_info.hProcess != nullptr) {
if (const auto pid = GetProcessId(execute_info.hProcess); pid > 0) {
pid_mutex_.lock();
@ -356,8 +376,7 @@ void AppLauncher::launchURL(const std::wstring& url, const std::wstring& args, c
}
}
if (url.find(L"epicgames.launcher") != std::wstring::npos) {
was_egs_launch_ = true;
if (was_egs_launch_) {
spdlog::debug("Epic Games launch; Couldn't find egs launcher PID");
pid_mutex_.lock();

@ -22,6 +22,7 @@ limitations under the License.
#endif
#include <functional>
#include <mutex>
#include <array>
#include <string>
#include <unordered_set>
#include <SFML/System/Clock.hpp>
@ -49,8 +50,14 @@ class AppLauncher {
void getProcessHwnds();
std::vector<HWND>& process_hwnds_;
static inline const std::array<std::wstring_view, 2> EGS_LAUNCHER_PROCNAMES_{
L"EpicGamesLauncher.exe",
L"EpicWebHelper.exe",
};
bool was_egs_launch_ = false;
bool egs_has_launched_game_ = false;
bool findEgsPid();

Loading…
Cancel
Save