diff --git a/GUI/extenwindow.cpp b/GUI/extenwindow.cpp index bac4c1a..fb09bd9 100644 --- a/GUI/extenwindow.cpp +++ b/GUI/extenwindow.cpp @@ -1,7 +1,6 @@ #include "extenwindow.h" #include "ui_extenwindow.h" #include "defs.h" -#include "text.h" #include "misc.h" #include #include @@ -10,6 +9,9 @@ #include #include +extern const char* EXTENSIONS; +extern const char* EXTEN_WINDOW_INSTRUCTIONS; + namespace { struct Extension diff --git a/GUI/host/host.cpp b/GUI/host/host.cpp index 7f5c455..d595331 100644 --- a/GUI/host/host.cpp +++ b/GUI/host/host.cpp @@ -1,9 +1,14 @@ #include "host.h" -#include "text.h" #include "defs.h" #include "util.h" #include "../vnrhook/texthook.h" +extern const wchar_t* ALREADY_INJECTED; +extern const wchar_t* ARCHITECTURE_MISMATCH; +extern const wchar_t* INJECT_FAILED; +extern const wchar_t* CONSOLE; +extern const wchar_t* CLIPBOARD; + namespace { class ProcessRecord diff --git a/GUI/host/textthread.cpp b/GUI/host/textthread.cpp index 63b8848..df3b796 100644 --- a/GUI/host/textthread.cpp +++ b/GUI/host/textthread.cpp @@ -1,8 +1,9 @@ #include "textthread.h" -#include "text.h" #include "host.h" #include "util.h" +extern const wchar_t* INVALID_CODEPAGE; + TextThread::TextThread(ThreadParam tp, HookParam hp, std::optional name) : handle(threadCounter++), name(name.value_or(Util::StringToWideString(hp.name).value())), diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index c7aeeba..6fd3145 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -1,7 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" #include "defs.h" -#include "text.h" #include "extenwindow.h" #include "misc.h" #include "host/util.h" @@ -15,6 +14,30 @@ #include #include +extern const char* ATTACH; +extern const char* LAUNCH; +extern const char* DETACH; +extern const char* ADD_HOOK; +extern const char* SAVE_HOOKS; +extern const char* SETTINGS; +extern const char* EXTENSIONS; +extern const char* SELECT_PROCESS; +extern const char* ATTACH_INFO; +extern const char* SEARCH_GAME; +extern const char* PROCESSES; +extern const char* CODE_INFODUMP; +extern const char* SAVE_SETTINGS; +extern const char* USE_JP_LOCALE; +extern const char* FILTER_REPETITION; +extern const char* DEFAULT_CODEPAGE; +extern const char* FLUSH_DELAY; +extern const char* MAX_BUFFER_SIZE; +extern const wchar_t* ABOUT; +extern const wchar_t* CL_OPTIONS; +extern const wchar_t* UPDATE_AVAILABLE; +extern const wchar_t* LAUNCH_FAILED; +extern const wchar_t* INVALID_CODE; + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -121,7 +144,7 @@ void MainWindow::ProcessConnected(DWORD processId) if (hookList != allProcesses.rend()) for (auto hookInfo : hookList->split(" , ")) if (auto hp = Util::ParseCode(S(hookInfo))) Host::InsertHook(processId, hp.value()); - else swscanf_s(S(hookInfo).c_str(), L"|%I64d:%I64d:%[^\n]", &savedThreadCtx.first, &savedThreadCtx.second, savedThreadCode, std::size(savedThreadCode)); + else swscanf_s(S(hookInfo).c_str(), L"|%I64d:%I64d:%[^\n]", &savedThreadCtx.first, &savedThreadCtx.second, savedThreadCode, (unsigned)std::size(savedThreadCode)); } void MainWindow::ProcessDisconnected(DWORD processId) diff --git a/extensions/bingtranslate.cpp b/extensions/bingtranslate.cpp index 63acd78..082b8a7 100644 --- a/extensions/bingtranslate.cpp +++ b/extensions/bingtranslate.cpp @@ -1,9 +1,13 @@ #include "extension.h" -#include "text.h" #include "network.h" #include #include +extern const char* SELECT_LANGUAGE; +extern const wchar_t* TOO_MANY_TRANS_REQUESTS; +extern const wchar_t* TRANSLATION_ERROR; +extern const char* BING_PROMPT; + QStringList languages { "English: en", diff --git a/extensions/extrawindow.cpp b/extensions/extrawindow.cpp index ae80b93..d0f9508 100644 --- a/extensions/extrawindow.cpp +++ b/extensions/extrawindow.cpp @@ -1,6 +1,5 @@ #include "extension.h" #include "defs.h" -#include "text.h" #include #include #include @@ -12,6 +11,13 @@ #include #include +extern const char* EXTRA_WINDOW_INFO; +extern const char* TOPMOST; +extern const char* SIZE_LOCK; +extern const char* BG_COLOR; +extern const char* TEXT_COLOR; +extern const char* FONT_SIZE; + std::mutex m; struct : QDialog diff --git a/extensions/googletranslate.cpp b/extensions/googletranslate.cpp index e334fee..b4051c5 100644 --- a/extensions/googletranslate.cpp +++ b/extensions/googletranslate.cpp @@ -1,11 +1,15 @@ #include "extension.h" -#include "text.h" #include "util.h" #include "network.h" #include #include #include +extern const char* SELECT_LANGUAGE; +extern const wchar_t* TOO_MANY_TRANS_REQUESTS; +extern const wchar_t* TRANSLATION_ERROR; +extern const char* GOOGLE_PROMPT; + QStringList languages { "English: en", diff --git a/extensions/lua.cpp b/extensions/lua.cpp index ea2539e..0b930d5 100644 --- a/extensions/lua.cpp +++ b/extensions/lua.cpp @@ -1,6 +1,5 @@ #include "extension.h" #include "util.h" -#include "text.h" #include #include #include @@ -8,6 +7,10 @@ #include #include +extern const char* LUA_INTRO; +extern const char* LOAD_LUA_SCRIPT; +extern const wchar_t* LUA_ERROR; + constexpr auto LUA_SAVE_FILE = u8"Textractor.lua"; extern "C" // Lua library diff --git a/extensions/regexfilter.cpp b/extensions/regexfilter.cpp index ce28900..f2b782e 100644 --- a/extensions/regexfilter.cpp +++ b/extensions/regexfilter.cpp @@ -1,11 +1,14 @@ #include "extension.h" -#include "text.h" #include #include #include #include #include +extern const char* REGEX_FILTER; +extern const char* INVALID_REGEX; +extern const char* CURRENT_FILTER; + std::wregex regex; std::shared_mutex m; diff --git a/extensions/replacer.cpp b/extensions/replacer.cpp index d92aa67..b519b67 100644 --- a/extensions/replacer.cpp +++ b/extensions/replacer.cpp @@ -1,11 +1,11 @@ #include "extension.h" -#include "text.h" #include #include #include #include #include +extern const wchar_t* REPLACER_INSTRUCTIONS; constexpr auto REPLACE_SAVE_FILE = u8"SavedReplacements.txt"; std::atomic replaceFileLastWrite; diff --git a/extensions/threadlinker.cpp b/extensions/threadlinker.cpp index 00dc0ea..e55ff2b 100644 --- a/extensions/threadlinker.cpp +++ b/extensions/threadlinker.cpp @@ -1,5 +1,4 @@ #include "extension.h" -#include "text.h" #include #include #include @@ -8,6 +7,11 @@ #include #include +extern const char* THREAD_LINKER; +extern const char* LINK; +extern const char* THREAD_LINK_FROM; +extern const char* THREAD_LINK_TO; + std::mutex m; std::unordered_map> linkedTextHandles; diff --git a/include/defs.h b/include/defs.h index f9a7f00..fe7f69b 100644 --- a/include/defs.h +++ b/include/defs.h @@ -29,5 +29,7 @@ constexpr auto CONFIG_FILE = u8"Textractor.ini"; // Misc constexpr auto DEFAULT_EXTENSIONS = u8"Remove Repetition>Lua>Copy to Clipboard>Bing Translate>Extra Window>Extra Newlines"; +constexpr auto WINDOW = u8"Window"; +#define CURRENT_VERSION "3.0.0" // EOF diff --git a/include/text.h b/include/text.h deleted file mode 100644 index 212b353..0000000 --- a/include/text.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -#define CURRENT_VERSION "3.0.0" - -extern const char* ATTACH; -extern const char* LAUNCH; -extern const char* DETACH; -extern const char* ADD_HOOK; -extern const char* SAVE_HOOKS; -extern const char* SETTINGS; -extern const char* EXTENSIONS; -extern const char* SELECT_PROCESS; -extern const char* ATTACH_INFO; -extern const char* SEARCH_GAME; -extern const char* PROCESSES; -extern const char* CODE_INFODUMP; -extern const char* SAVE_SETTINGS; -extern const char* EXTEN_WINDOW_INSTRUCTIONS; -extern const char* WINDOW; -extern const char* USE_JP_LOCALE; -extern const char* FILTER_REPETITION; -extern const char* DEFAULT_CODEPAGE; -extern const char* FLUSH_DELAY; -extern const char* MAX_BUFFER_SIZE; -extern const wchar_t* CONSOLE; -extern const wchar_t* CLIPBOARD; -extern const wchar_t* ABOUT; -extern const wchar_t* CL_OPTIONS; -extern const wchar_t* UPDATE_AVAILABLE; -extern const wchar_t* ALREADY_INJECTED; -extern const wchar_t* ARCHITECTURE_MISMATCH; -extern const wchar_t* INJECT_FAILED; -extern const wchar_t* LAUNCH_FAILED; -extern const wchar_t* INVALID_CODE; -extern const wchar_t* INVALID_CODEPAGE; -extern const char* PIPE_CONNECTED; -extern const char* INSERTING_HOOK; -extern const char* REMOVING_HOOK; -extern const char* HOOK_FAILED; -extern const char* TOO_MANY_HOOKS; -extern const char* NOT_ENOUGH_TEXT; -extern const char* FUNC_MISSING; -extern const char* MODULE_MISSING; -extern const char* GARBAGE_MEMORY; -extern const char* SEND_ERROR; -extern const char* READ_ERROR; -extern const char* HIJACK_ERROR; -extern const char* COULD_NOT_FIND; -extern const char* SELECT_LANGUAGE; -extern const char* BING_PROMPT; -extern const char* GOOGLE_PROMPT; -extern const wchar_t* TOO_MANY_TRANS_REQUESTS; -extern const wchar_t* TRANSLATION_ERROR; -extern const char* EXTRA_WINDOW_INFO; -extern const char* TOPMOST; -extern const char* SIZE_LOCK; -extern const char* BG_COLOR; -extern const char* TEXT_COLOR; -extern const char* FONT_SIZE; -extern const char* LUA_INTRO; -extern const char* LOAD_LUA_SCRIPT; -extern const wchar_t* LUA_ERROR; -extern const char* REGEX_FILTER; -extern const char* INVALID_REGEX; -extern const char* CURRENT_FILTER; -extern const wchar_t* REPLACER_INSTRUCTIONS; -extern const char* THREAD_LINKER; -extern const char* LINK; -extern const char* THREAD_LINK_FROM; -extern const char* THREAD_LINK_TO; diff --git a/text.cpp b/text.cpp index 8e989c1..37edbfc 100644 --- a/text.cpp +++ b/text.cpp @@ -1,4 +1,4 @@ -#include "text.h" +#include "defs.h" //#define TURKISH //#define SPANISH @@ -37,7 +37,6 @@ const char* EXTEN_WINDOW_INSTRUCTIONS = u8R"(Drag and drop extension (.dll) file (Does not work if running as administrator) Drag and drop within the list to reorder Press delete with an extension selected to remove it)"; -const char* WINDOW = u8"Window"; const char* USE_JP_LOCALE = u8"Emulate japanese locale?"; const char* FILTER_REPETITION = u8"Repetition Filter"; const char* DEFAULT_CODEPAGE = u8"Default Codepage"; @@ -133,7 +132,6 @@ inline auto _ = [] EXTENSIONS = u8"Uzantılar"; SELECT_PROCESS = u8"İşlem Seçin"; ATTACH_INFO = u8"Bağlanmak istediğiniz işlemi görmüyorsanız yönetici olarak çalıştırmayı deneyin"; - WINDOW = u8"Pencere"; DEFAULT_CODEPAGE = u8"Varsayılan Kod Sayfası"; FLUSH_DELAY = u8"Temizleme Gecikmesi"; MAX_BUFFER_SIZE = u8"Maksimum Arabellek Boyu"; @@ -192,7 +190,6 @@ Negatives for data/split offset refer to registers EXTEN_WINDOW_INSTRUCTIONS = u8R"(Arrrastra y suelta la extension (.dll) aquí desde tu computadora para añadirlos Arrastra y suelta la lista para reordenar Presiona supr en una extension seleccionada para removerla)"; - WINDOW = u8"Ventana"; USE_JP_LOCALE = u8"¿Emular idioma japonés?"; DEFAULT_CODEPAGE = u8"Default Codepage"; FLUSH_DELAY = u8"Flush Delay"; @@ -276,7 +273,6 @@ S/Q/V: 代码页/UTF-16/UTF-8 字符串 (如果使用超级管理员运行,则无法工作) 在列表中拖拽来重新排序 使用 delete 键移除选中的扩展)"; - WINDOW = u8"窗口"; USE_JP_LOCALE = u8"模拟日本区域设置?"; DEFAULT_CODEPAGE = u8"默认代码页"; FLUSH_DELAY = u8"刷新延迟"; diff --git a/vnrhook/engine/match.cc b/vnrhook/engine/match.cc index f302a45..61bf640 100644 --- a/vnrhook/engine/match.cc +++ b/vnrhook/engine/match.cc @@ -13,9 +13,10 @@ #include "util/growl.h" #include "util/util.h" #include "main.h" -#include "text.h" #include "ithsys/ithsys.h" +extern const char* HIJACK_ERROR; + //#define ConsoleOutput(...) (void)0 // jichi 8/18/2013: I don't need ConsoleOutput enum { MAX_REL_ADDR = 0x200000 }; // jichi 8/18/2013: maximum relative address diff --git a/vnrhook/engine/match64.cc b/vnrhook/engine/match64.cc index bfece13..d5bbbe6 100644 --- a/vnrhook/engine/match64.cc +++ b/vnrhook/engine/match64.cc @@ -1,8 +1,9 @@ #include "match.h" #include "main.h" -#include "text.h" #include "native/pchooks.h" +extern const char* HIJACK_ERROR; + namespace Engine { void HookDirectX() diff --git a/vnrhook/main.cc b/vnrhook/main.cc index e2aa384..b3889f4 100644 --- a/vnrhook/main.cc +++ b/vnrhook/main.cc @@ -5,11 +5,18 @@ #include "main.h" #include "defs.h" -#include "text.h" #include "engine/match.h" #include "texthook.h" #include "util.h" +extern const char* PIPE_CONNECTED; +extern const char* INSERTING_HOOK; +extern const char* REMOVING_HOOK; +extern const char* HOOK_FAILED; +extern const char* TOO_MANY_HOOKS; +extern const char* NOT_ENOUGH_TEXT; +extern const char* COULD_NOT_FIND; + WinMutex viewMutex; namespace @@ -88,8 +95,9 @@ void ConsoleOutput(LPCSTR text, ...) WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); } -void NotifyHookRemove(uint64_t addr) +void NotifyHookRemove(uint64_t addr, LPCSTR name) { + if (name) ConsoleOutput(REMOVING_HOOK, name); HookRemovedNotif buffer(addr); WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); } diff --git a/vnrhook/main.h b/vnrhook/main.h index be7ec8d..274df34 100644 --- a/vnrhook/main.h +++ b/vnrhook/main.h @@ -9,7 +9,7 @@ void TextOutput(ThreadParam tp, BYTE* text, int len); void ConsoleOutput(LPCSTR text, ...); -void NotifyHookRemove(uint64_t addr); +void NotifyHookRemove(uint64_t addr, LPCSTR name); void NewHook(HookParam hp, LPCSTR name, DWORD flag = HOOK_ENGINE); void RemoveHook(uint64_t addr, int maxOffset = 9); diff --git a/vnrhook/texthook.cc b/vnrhook/texthook.cc index 10363b1..6ea9357 100644 --- a/vnrhook/texthook.cc +++ b/vnrhook/texthook.cc @@ -4,11 +4,16 @@ // 8/24/2013 TODO: Clean up this file #include "texthook.h" -#include "engine/match.h" #include "main.h" -#include "text.h" +#include "engine/match.h" #include "ithsys/ithsys.h" +extern const char* FUNC_MISSING; +extern const char* MODULE_MISSING; +extern const char* GARBAGE_MEMORY; +extern const char* SEND_ERROR; +extern const char* READ_ERROR; + extern WinMutex viewMutex; // - Unnamed helpers - @@ -282,10 +287,9 @@ void TextHook::RemoveReadCode() void TextHook::Clear() { std::scoped_lock lock(viewMutex); - if (*hp.name) ConsoleOutput(REMOVING_HOOK, hp.name); if (hp.type & DIRECT_READ) RemoveReadCode(); else RemoveHookCode(); - NotifyHookRemove(address); + NotifyHookRemove(address, hp.name); memset(this, 0, sizeof(TextHook)); // jichi 11/30/2013: This is the original code of ITH }