diff --git a/GlosSIConfig/UIModel.cpp b/GlosSIConfig/UIModel.cpp index 04e1371..70817a8 100644 --- a/GlosSIConfig/UIModel.cpp +++ b/GlosSIConfig/UIModel.cpp @@ -28,13 +28,21 @@ limitations under the License. #ifdef _WIN32 #include "UWPFetch.h" #include +#include #endif #include "../version.hpp" UIModel::UIModel() : QObject(nullptr) { - auto path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; @@ -307,7 +315,14 @@ void UIModel::updateCheck() QVariantMap UIModel::getDefaultConf() const { - auto path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; @@ -371,8 +386,14 @@ QVariantMap UIModel::getDefaultConf() const void UIModel::saveDefaultConf(QVariantMap conf) const { - auto path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); - + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; path /= "default.json"; diff --git a/GlosSIConfig/main.cpp b/GlosSIConfig/main.cpp index 98388b8..8ad85de 100644 --- a/GlosSIConfig/main.cpp +++ b/GlosSIConfig/main.cpp @@ -26,6 +26,7 @@ limitations under the License. #include #include #include +#include #pragma comment(lib, "Dwmapi.lib") #include "ExeImageProvider.h" #endif @@ -89,10 +90,14 @@ void myMessageHandler(QtMsgType type, const QMessageLogContext&, const QString& break; } - auto path = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; @@ -115,11 +120,14 @@ int main(int argc, char* argv[]) #endif if (argc < 3) { - auto path = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); - + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; if (!std::filesystem::exists(path)) diff --git a/GlosSITarget/Overlay.cpp b/GlosSITarget/Overlay.cpp index a7451a5..39b3d31 100644 --- a/GlosSITarget/Overlay.cpp +++ b/GlosSITarget/Overlay.cpp @@ -20,6 +20,7 @@ limitations under the License. #include #include #include +#include #include "Roboto.h" #include "Settings.h" @@ -51,10 +52,14 @@ Overlay::Overlay( ImGui::SFML::UpdateFontTexture(); #ifdef _WIN32 - auto config_path = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path config_path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + config_path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + config_path = std::filesystem::path(localAppDataFolder).parent_path(); + } config_path /= "Roaming"; config_path /= "GlosSI"; diff --git a/GlosSITarget/Settings.h b/GlosSITarget/Settings.h index f5ada8c..eaef719 100644 --- a/GlosSITarget/Settings.h +++ b/GlosSITarget/Settings.h @@ -26,6 +26,8 @@ limitations under the License. #ifdef WIN32 #define NOMINMAX #include +#include +#include #endif namespace Settings { @@ -122,10 +124,14 @@ inline void Parse(std::wstring arg1) arg1 += L".json"; } } - std::filesystem::path path = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; diff --git a/GlosSITarget/SteamTarget.cpp b/GlosSITarget/SteamTarget.cpp index 5e05f98..45d79a1 100644 --- a/GlosSITarget/SteamTarget.cpp +++ b/GlosSITarget/SteamTarget.cpp @@ -74,8 +74,8 @@ Application will not function!"); if (!overlay_.expired()) overlay_.lock()->setEnabled(false); steam_overlay_present_ = true; - launcher_.launchWatchdog(); } + launcher_.launchWatchdog(); getXBCRebindingEnabled(); run_ = true; diff --git a/GlosSITarget/main.cpp b/GlosSITarget/main.cpp index 347bbf0..6ce5a1e 100644 --- a/GlosSITarget/main.cpp +++ b/GlosSITarget/main.cpp @@ -17,6 +17,7 @@ limitations under the License. #define NOMINMAX #include #include +#include #endif #include @@ -67,10 +68,14 @@ LONG Win32FaultHandler(struct _EXCEPTION_POINTERS* ExInfo) MINIDUMP_EXCEPTION_INFORMATION M; HANDLE hDump_File; - auto path = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; @@ -119,10 +124,14 @@ int main(int argc, char* argv[]) const auto console_sink = std::make_shared(); console_sink->set_level(spdlog::level::trace); #ifdef _WIN32 - auto path = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path path; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + path = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + path = std::filesystem::path(localAppDataFolder).parent_path(); + } path /= "Roaming"; path /= "GlosSI"; diff --git a/GlosSIWatchdog/main.cpp b/GlosSIWatchdog/main.cpp index 2de92ba..67bb052 100644 --- a/GlosSIWatchdog/main.cpp +++ b/GlosSIWatchdog/main.cpp @@ -16,6 +16,7 @@ limitations under the License. #define NOMINMAX #include +#include #include @@ -34,10 +35,14 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); - auto configDirPath = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path configDirPath; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + configDirPath = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + configDirPath = std::filesystem::path(localAppDataFolder).parent_path(); + } configDirPath /= "Roaming"; configDirPath /= "GlosSI"; diff --git a/UWPOverlayEnablerDLL/dllmain.cpp b/UWPOverlayEnablerDLL/dllmain.cpp index e657f0d..21bd67a 100644 --- a/UWPOverlayEnablerDLL/dllmain.cpp +++ b/UWPOverlayEnablerDLL/dllmain.cpp @@ -44,6 +44,7 @@ There are two (known to me, at time of writing) ways to get a working overlay fo #define WIN32_LEAN_AND_MEAN #include +#include #define SUBHOOK_STATIC #include @@ -140,11 +141,14 @@ BOOL APIENTRY DllMain( HMODULE hModule, { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { - - auto configDirPath = std::filesystem::temp_directory_path() - .parent_path() - .parent_path() - .parent_path(); + wchar_t* localAppDataFolder; + std::filesystem::path configDirPath; + if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &localAppDataFolder) != S_OK) { + configDirPath = std::filesystem::temp_directory_path().parent_path().parent_path().parent_path(); + } + else { + configDirPath = std::filesystem::path(localAppDataFolder).parent_path(); + } configDirPath /= "Roaming"; configDirPath /= "GlosSI";