mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
create config folder
This commit is contained in:
parent
6ed3d9c951
commit
8fa937c409
@ -80,6 +80,8 @@ namespace
|
|||||||
Ui::MainWindow ui;
|
Ui::MainWindow ui;
|
||||||
std::atomic<DWORD> selectedProcessId = 0;
|
std::atomic<DWORD> selectedProcessId = 0;
|
||||||
ExtenWindow* extenWindow = nullptr;
|
ExtenWindow* extenWindow = nullptr;
|
||||||
|
concurrency::reader_writer_lock configFoldersMutex;
|
||||||
|
std::unordered_map<DWORD, std::wstring> configFolders;
|
||||||
std::unordered_set<DWORD> alreadyAttached;
|
std::unordered_set<DWORD> alreadyAttached;
|
||||||
bool autoAttach = false, autoAttachSavedOnly = true;
|
bool autoAttach = false, autoAttachSavedOnly = true;
|
||||||
bool showSystemProcesses = false;
|
bool showSystemProcesses = false;
|
||||||
@ -118,6 +120,7 @@ namespace
|
|||||||
};
|
};
|
||||||
DWORD (*GetSelectedProcessId)() = [] { return selectedProcessId.load(); };
|
DWORD (*GetSelectedProcessId)() = [] { return selectedProcessId.load(); };
|
||||||
|
|
||||||
|
concurrency::reader_writer_lock::scoped_lock_read readLock(configFoldersMutex);
|
||||||
return
|
return
|
||||||
{ {
|
{ {
|
||||||
{ "current select", &thread == current },
|
{ "current select", &thread == current },
|
||||||
@ -126,6 +129,7 @@ namespace
|
|||||||
{ "hook address", (int64_t)thread.tp.addr },
|
{ "hook address", (int64_t)thread.tp.addr },
|
||||||
{ "text handle", thread.handle },
|
{ "text handle", thread.handle },
|
||||||
{ "text name", (int64_t)thread.name.c_str() },
|
{ "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 sentence", (int64_t)AddSentence },
|
||||||
{ "add text", (int64_t)AddText },
|
{ "add text", (int64_t)AddText },
|
||||||
{ "get selected process id", (int64_t)GetSelectedProcessId },
|
{ "get selected process id", (int64_t)GetSelectedProcessId },
|
||||||
@ -242,6 +246,7 @@ namespace
|
|||||||
|
|
||||||
void ConfigureProcess()
|
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)
|
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);
|
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(" , "))
|
for (auto hookInfo : hookList->split(" , "))
|
||||||
if (auto hp = HookCode::Parse(S(hookInfo))) Host::InsertHook(processId, hp.value());
|
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));
|
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)
|
void ProcessDisconnected(DWORD processId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user