diff --git a/GlosSITarget/AppLauncher.cpp b/GlosSITarget/AppLauncher.cpp index 6f07ab2..af74b70 100644 --- a/GlosSITarget/AppLauncher.cpp +++ b/GlosSITarget/AppLauncher.cpp @@ -35,12 +35,10 @@ AppLauncher::AppLauncher(std::function shutdown) : shutdown_(std::move(s void AppLauncher::launchApp(const std::wstring& path, const std::wstring& args) { #ifdef _WIN32 - std::wsmatch m; - if (!std::regex_search(path, m, std::wregex(L"^.{1,3}:"))) { + if (Settings::launch.isUWP) { spdlog::info("LaunchApp is UWP, launching..."); launchUWPApp(path.data(), args); - } - else { + } else { spdlog::info("LaunchApp is Win32, launching..."); launchWin32App(path, args); } diff --git a/GlosSITarget/Settings.h b/GlosSITarget/Settings.h index 8c272c9..c565f98 100644 --- a/GlosSITarget/Settings.h +++ b/GlosSITarget/Settings.h @@ -16,6 +16,7 @@ limitations under the License. #pragma once #include +#include #include #include #include @@ -28,6 +29,7 @@ inline struct Launch { std::wstring launchPath; std::wstring launchAppArgs; bool closeOnExit = true; + bool isUWP = false; } launch; inline struct Devices { @@ -40,6 +42,15 @@ inline struct Window { float scale = 0.f; } window; +inline bool checkIsUwp(const std::wstring& launch_path) +{ + std::wsmatch m; + if (!std::regex_search(launch_path, m, std::wregex(L"^.{1,3}:"))) { + return true; + } + return false; +} + inline void Parse(std::string arg1) { if (!arg1.ends_with(".json")) { @@ -112,6 +123,11 @@ inline void Parse(std::string arg1) json_file.close(); spdlog::debug("Read config file \"{}\"", path.string()); + + if (launch.launch) { + launch.isUWP = checkIsUwp(launch.launchPath); + } + } } // namespace Settings diff --git a/GlosSITarget/SteamTarget.cpp b/GlosSITarget/SteamTarget.cpp index 65022f1..10c5933 100644 --- a/GlosSITarget/SteamTarget.cpp +++ b/GlosSITarget/SteamTarget.cpp @@ -47,7 +47,11 @@ SteamTarget::SteamTarget(int argc, char* argv[]) { target_window_handle_ = window_.getSystemHandle(); #ifdef _WIN32 - UWPOverlayEnabler::AddUwpOverlayOvWidget(); + if (Settings::launch.isUWP) { + UWPOverlayEnabler::EnableUwpOverlay(); + } else { + UWPOverlayEnabler::AddUwpOverlayOvWidget(); + } #endif } diff --git a/GlosSITarget/UWPOverlayEnabler.h b/GlosSITarget/UWPOverlayEnabler.h index a81170b..2a634b8 100644 --- a/GlosSITarget/UWPOverlayEnabler.h +++ b/GlosSITarget/UWPOverlayEnabler.h @@ -36,6 +36,28 @@ inline DWORD ExplorerPid() } +inline void EnableUwpOverlay() +{ + const auto enabler_path = internal::EnablerPath(); + if (std::filesystem::exists(enabler_path)) { + const auto explorer_pid = internal::ExplorerPid(); + if (explorer_pid != 0) { + if (DllInjector::TakeDebugPrivilege()) { + // No need to eject, as the dll is self-ejecting. + if (DllInjector::Inject(explorer_pid, enabler_path.wstring())) { + spdlog::info("Successfully injected UWPOverlay enabler into explorer.exe"); + } + } + } + else { + spdlog::error("explorer not found"); // needs loglevel WTF + } + } + else { + spdlog::error("UWPOverlayEnablerDLL not found"); + } +} + inline void AddUwpOverlayOvWidget() { Overlay::AddOverlayElem([]() { @@ -55,25 +77,7 @@ inline void AddUwpOverlayOvWidget() ImGui::Spacing(); if (ImGui::CollapsingHeader("I am sure!")) { if (ImGui::Button(/* just */ "DO IT!")) { // insert meme gif here >.< - const auto enabler_path = internal::EnablerPath(); - if (std::filesystem::exists(enabler_path)) { - const auto explorer_pid = internal::ExplorerPid(); - if (explorer_pid != 0) { - if (DllInjector::TakeDebugPrivilege()) { - // No need to eject, as the dll is self-ejecting. - if (DllInjector::Inject(explorer_pid, enabler_path.wstring())) { - spdlog::info("Successfully injected UWPOverlay enabler into explorer.exe"); - // Nesting level over 9000 - } - } - } - else { - spdlog::error("explorer not found"); // needs loglevel WTF - } - } - else { - spdlog::error("UWPOverlayEnablerDLL not found"); - } + EnableUwpOverlay(); } ImGui::Text("If the overlay isn't working right away:"); ImGui::Text("try opening Windows start menu, as this triggers the hook");