Enable UWP overlay by default if launch app is UWP

main
Peter Repukat 3 years ago
parent f5b71bf9c9
commit 1eb8c135d2

@ -35,12 +35,10 @@ AppLauncher::AppLauncher(std::function<void()> 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);
}

@ -16,6 +16,7 @@ limitations under the License.
#pragma once
#include <fstream>
#include <regex>
#include <string>
#include <nlohmann/json.hpp>
#include <spdlog/spdlog.h>
@ -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

@ -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
}

@ -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");

Loading…
Cancel
Save