From abeca3eb816a66c57b3c9aaf17676430117b9cbf Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Fri, 23 Sep 2022 21:29:01 +0200 Subject: [PATCH] UwpOverlayEnabler: Config to set WindowBand create file %appdata%\GlosSI\UWPOverlayEnabler.cfg and fill with one of those ZBID values ZBID_DEFAULT ZBID_DESKTOP ZBID_UIACCESS ZBID_IMMERSIVE_IHM ZBID_IMMERSIVE_NOTIFICATION ZBID_IMMERSIVE_APPCHROME ZBID_IMMERSIVE_MOGO ZBID_IMMERSIVE_EDGY ZBID_IMMERSIVE_INACTIVEMOBODY ZBID_IMMERSIVE_INACTIVEDOCK ZBID_IMMERSIVE_ACTIVEMOBODY ZBID_IMMERSIVE_ACTIVEDOCK ZBID_IMMERSIVE_BACKGROUND ZBID_IMMERSIVE_SEARCH ZBID_GENUINE_WINDOWS ZBID_IMMERSIVE_RESTRICTED ZBID_SYSTEM_TOOLS ZBID_LOCK ZBID_ABOVELOCK_UX --- UWPOverlayEnablerDLL/dllmain.cpp | 80 ++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 10 deletions(-) diff --git a/UWPOverlayEnablerDLL/dllmain.cpp b/UWPOverlayEnablerDLL/dllmain.cpp index 1ce6e6a..2e2f1a3 100644 --- a/UWPOverlayEnablerDLL/dllmain.cpp +++ b/UWPOverlayEnablerDLL/dllmain.cpp @@ -54,6 +54,7 @@ There are two (known to me, at time of writing) ways to get a working overlay fo #include #include +#include enum ZBID { @@ -77,6 +78,7 @@ enum ZBID ZBID_LOCK = 17, ZBID_ABOVELOCK_UX = 18, }; + typedef BOOL(WINAPI* fSetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand); @@ -85,6 +87,8 @@ fSetWindowBand SetWindowBand; std::atomic allow_exit = false; +std::atomic to_set_window_band = ZBID_SYSTEM_TOOLS; + BOOL WINAPI SetGlosSIWindowBand(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand) { subhook::ScopedHookRemove remove(&SetWindowBandHook); @@ -96,11 +100,10 @@ BOOL WINAPI SetGlosSIWindowBand(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand) // However, notification and system_tools does! // use system tools, as that allows the steam overlay to be interacted with // without UWP apps minimizing - SetWindowBand(glossi_hwnd, nullptr, ZBID_SYSTEM_TOOLS); + auto success = SetWindowBand(glossi_hwnd, nullptr, to_set_window_band); allow_exit = true; - spdlog::info("Set GlosSI Window Band to ZBID_SYSTEM_TOOLS"); + spdlog::info("Set GlosSI Window Band to {}; success: {}", static_cast(to_set_window_band), success); } - spdlog::info("Calling original"); return SetWindowBand(hWnd, hwndInsertAfter, dwBand); } @@ -126,17 +129,21 @@ BOOL APIENTRY DllMain( HMODULE hModule, if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - auto path = std::filesystem::temp_directory_path() + auto configDirPath = std::filesystem::temp_directory_path() .parent_path() .parent_path() .parent_path(); - path /= "Roaming"; - path /= "GlosSI"; - if (!std::filesystem::exists(path)) - std::filesystem::create_directories(path); - path /= "UWPOverlayEnabler.log"; - const auto file_sink = std::make_shared(path.string(), true); + configDirPath /= "Roaming"; + configDirPath /= "GlosSI"; + if (!std::filesystem::exists(configDirPath)) + std::filesystem::create_directories(configDirPath); + + + + auto logPath = configDirPath; + logPath /= "UWPOverlayEnabler.log"; + const auto file_sink = std::make_shared(logPath.string(), true); std::vector sinks{ file_sink }; auto logger = std::make_shared("log", sinks.begin(), sinks.end()); logger->set_level(spdlog::level::trace); @@ -145,6 +152,59 @@ BOOL APIENTRY DllMain( HMODULE hModule, spdlog::info("UWPOverlayEnabler loaded"); + auto configPath = configDirPath; + configPath /= "UWPOverlayEnabler.cfg"; + if (std::filesystem::exists(configPath)) + { + std::ifstream config(configPath); + std::string line; + while (std::getline(config, line)) + { + // github copilot, lol + // i take it! + if (line == "ZBID_DEFAULT") + to_set_window_band = ZBID_DEFAULT; + else if (line == "ZBID_DESKTOP") + to_set_window_band = ZBID_DESKTOP; + else if (line == "ZBID_UIACCESS") + to_set_window_band = ZBID_UIACCESS; + else if (line == "ZBID_IMMERSIVE_IHM") + to_set_window_band = ZBID_IMMERSIVE_IHM; + else if (line == "ZBID_IMMERSIVE_NOTIFICATION") + to_set_window_band = ZBID_IMMERSIVE_NOTIFICATION; + else if (line == "ZBID_IMMERSIVE_APPCHROME") + to_set_window_band = ZBID_IMMERSIVE_APPCHROME; + else if (line == "ZBID_IMMERSIVE_MOGO") + to_set_window_band = ZBID_IMMERSIVE_MOGO; + else if (line == "ZBID_IMMERSIVE_EDGY") + to_set_window_band = ZBID_IMMERSIVE_EDGY; + else if (line == "ZBID_IMMERSIVE_INACTIVEMOBODY") + to_set_window_band = ZBID_IMMERSIVE_INACTIVEMOBODY; + else if (line == "ZBID_IMMERSIVE_INACTIVEDOCK") + to_set_window_band = ZBID_IMMERSIVE_INACTIVEDOCK; + else if (line == "ZBID_IMMERSIVE_ACTIVEMOBODY") + to_set_window_band = ZBID_IMMERSIVE_ACTIVEMOBODY; + else if (line == "ZBID_IMMERSIVE_ACTIVEDOCK") + to_set_window_band = ZBID_IMMERSIVE_ACTIVEDOCK; + else if (line == "ZBID_IMMERSIVE_BACKGROUND") + to_set_window_band = ZBID_IMMERSIVE_BACKGROUND; + else if (line == "ZBID_IMMERSIVE_SEARCH") + to_set_window_band = ZBID_IMMERSIVE_SEARCH; + else if (line == "ZBID_GENUINE_WINDOWS") + to_set_window_band = ZBID_GENUINE_WINDOWS; + else if (line == "ZBID_IMMERSIVE_RESTRICTED") + to_set_window_band = ZBID_IMMERSIVE_RESTRICTED; + else if (line == "ZBID_SYSTEM_TOOLS") + to_set_window_band = ZBID_SYSTEM_TOOLS; + else if (line == "ZBID_LOCK") + to_set_window_band = ZBID_LOCK; + else if (line == "ZBID_ABOVELOCK_UX") + to_set_window_band = ZBID_ABOVELOCK_UX; + + } + spdlog::info("Read window band from config: {}", static_cast(to_set_window_band)); + } + const auto hpath = LoadLibrary(L"user32.dll"); if (hpath) {