create config folder

This commit is contained in:
Akash Mozumdar 2021-11-06 06:24:40 -06:00
parent 6ed3d9c951
commit 8fa937c409

View File

@ -80,6 +80,8 @@ namespace
Ui::MainWindow ui;
std::atomic<DWORD> selectedProcessId = 0;
ExtenWindow* extenWindow = nullptr;
concurrency::reader_writer_lock configFoldersMutex;
std::unordered_map<DWORD, std::wstring> configFolders;
std::unordered_set<DWORD> 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<std::wstring_view>()(S(process)));
if (!std::filesystem::exists(hash)) CreateDirectoryW(hash.c_str(), nullptr);
std::scoped_lock writeLock(configFoldersMutex);
configFolders[processId] = hash;
}
void ProcessDisconnected(DWORD processId)