From 8fa937c40938b8e139208eafe8320717f04265f9 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 6 Nov 2021 06:24:40 -0600 Subject: [PATCH] create config folder --- GUI/mainwindow.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index 1f0437d..3c46742 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -80,6 +80,8 @@ namespace Ui::MainWindow ui; std::atomic selectedProcessId = 0; ExtenWindow* extenWindow = nullptr; + concurrency::reader_writer_lock configFoldersMutex; + std::unordered_map configFolders; std::unordered_set alreadyAttached; bool autoAttach = false, autoAttachSavedOnly = true; bool showSystemProcesses = false; @@ -118,6 +120,7 @@ namespace }; DWORD (*GetSelectedProcessId)() = [] { return selectedProcessId.load(); }; + concurrency::reader_writer_lock::scoped_lock_read readLock(configFoldersMutex); return { { { "current select", &thread == current }, @@ -126,6 +129,7 @@ namespace { "hook address", (int64_t)thread.tp.addr }, { "text handle", thread.handle }, { "text name", (int64_t)thread.name.c_str() }, + { "config folder", (int64_t)configFolders.at(thread.tp.processId).c_str() }, { "add sentence", (int64_t)AddSentence }, { "add text", (int64_t)AddText }, { "get selected process id", (int64_t)GetSelectedProcessId }, @@ -242,6 +246,7 @@ namespace void ConfigureProcess() { + // TODO: move this file into config folder (need to coordinate with texthook dll if (auto processName = GetModuleFilename(selectedProcessId)) if (int last = processName->rfind(L'\\') + 1) { std::wstring configFile = std::wstring(processName.value()).replace(last, std::string::npos, GAME_CONFIG_FILE); @@ -559,6 +564,12 @@ namespace for (auto hookInfo : hookList->split(" , ")) if (auto hp = HookCode::Parse(S(hookInfo))) Host::InsertHook(processId, hp.value()); else swscanf_s(S(hookInfo).c_str(), L"|%I64d:%I64d:%[^\n]", &savedThreadCtx, &savedThreadCtx2, savedThreadCode, (unsigned)std::size(savedThreadCode)); + + std::wstring hash; + hash = L"./" + std::to_wstring(std::hash()(S(process))); + if (!std::filesystem::exists(hash)) CreateDirectoryW(hash.c_str(), nullptr); + std::scoped_lock writeLock(configFoldersMutex); + configFolders[processId] = hash; } void ProcessDisconnected(DWORD processId)