diff --git a/UWPOverlayEnablerDLL/UWPOverlayEnablerDLL.vcxproj b/UWPOverlayEnablerDLL/UWPOverlayEnablerDLL.vcxproj index 9d0ad5a..34e5567 100644 --- a/UWPOverlayEnablerDLL/UWPOverlayEnablerDLL.vcxproj +++ b/UWPOverlayEnablerDLL/UWPOverlayEnablerDLL.vcxproj @@ -78,11 +78,11 @@ true - ..\deps\subhook;$(IncludePath) + ..\deps\subhook;..\deps\spdlog\include;$(IncludePath) false - ..\deps\subhook;$(IncludePath) + ..\deps\subhook;..\deps\spdlog\include;$(IncludePath) @@ -126,6 +126,7 @@ true NotUsing pch.h + stdcpp20 Windows @@ -143,6 +144,7 @@ true NotUsing pch.h + stdcpp20 Windows diff --git a/UWPOverlayEnablerDLL/dllmain.cpp b/UWPOverlayEnablerDLL/dllmain.cpp index fe4dd04..1ce6e6a 100644 --- a/UWPOverlayEnablerDLL/dllmain.cpp +++ b/UWPOverlayEnablerDLL/dllmain.cpp @@ -47,8 +47,14 @@ There are two (known to me, at time of writing) ways to get a working overlay fo #define SUBHOOK_STATIC #include +#include #include +#include +#include +#include + + enum ZBID { ZBID_DEFAULT = 0, @@ -85,13 +91,16 @@ BOOL WINAPI SetGlosSIWindowBand(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand) const auto glossi_hwnd = FindWindowA(nullptr, "GlosSITarget"); if (glossi_hwnd) { + spdlog::info("Found GlosSI Window"); // Most window bands don't really seem to work. // 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); allow_exit = true; + spdlog::info("Set GlosSI Window Band to ZBID_SYSTEM_TOOLS"); } + spdlog::info("Calling original"); return SetWindowBand(hWnd, hwndInsertAfter, dwBand); } @@ -102,7 +111,10 @@ DWORD WINAPI WaitThread(HMODULE hModule) Sleep(10); } if (SetWindowBandHook.IsInstalled()) + { + spdlog::debug("Uninstalling SetWindowBand hook"); SetWindowBandHook.Remove(); + } FreeLibraryAndExitThread(hModule, 0); } @@ -113,17 +125,47 @@ BOOL APIENTRY DllMain( HMODULE hModule, { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { + + auto path = 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); + std::vector sinks{ file_sink }; + auto logger = std::make_shared("log", sinks.begin(), sinks.end()); + logger->set_level(spdlog::level::trace); + logger->flush_on(spdlog::level::trace); + spdlog::set_default_logger(logger); + + spdlog::info("UWPOverlayEnabler loaded"); + const auto hpath = LoadLibrary(L"user32.dll"); if (hpath) { + spdlog::debug("Loaded user32.dll"); + spdlog::debug("Installing SetWindowBand hook"); SetWindowBand = reinterpret_cast(GetProcAddress(hpath, "SetWindowBand")); SetWindowBandHook.Install(GetProcAddress(hpath, "SetWindowBand"), &SetGlosSIWindowBand, subhook::HookFlags::HookFlag64BitOffset); + spdlog::debug("Creating wait thread"); CloseHandle(CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)WaitThread, hModule, 0, nullptr)); + } else + { + spdlog::error("Loaded user32.dll"); } } else if (ul_reason_for_call == DLL_PROCESS_DETACH) { + spdlog::info("unloading UWPOverlayEnabler"); if (SetWindowBandHook.IsInstalled()) + { + spdlog::debug("Uninstalling SetWindowBand hook"); SetWindowBandHook.Remove(); + } } return TRUE; }