split text declarations

This commit is contained in:
Akash Mozumdar 2019-02-27 11:33:17 -05:00
parent cf423fa525
commit 0345181484
19 changed files with 93 additions and 96 deletions

View File

@ -1,7 +1,6 @@
#include "extenwindow.h" #include "extenwindow.h"
#include "ui_extenwindow.h" #include "ui_extenwindow.h"
#include "defs.h" #include "defs.h"
#include "text.h"
#include "misc.h" #include "misc.h"
#include <concrt.h> #include <concrt.h>
#include <QDragEnterEvent> #include <QDragEnterEvent>
@ -10,6 +9,9 @@
#include <QUrl> #include <QUrl>
#include <QLabel> #include <QLabel>
extern const char* EXTENSIONS;
extern const char* EXTEN_WINDOW_INSTRUCTIONS;
namespace namespace
{ {
struct Extension struct Extension

View File

@ -1,9 +1,14 @@
#include "host.h" #include "host.h"
#include "text.h"
#include "defs.h" #include "defs.h"
#include "util.h" #include "util.h"
#include "../vnrhook/texthook.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 namespace
{ {
class ProcessRecord class ProcessRecord

View File

@ -1,8 +1,9 @@
#include "textthread.h" #include "textthread.h"
#include "text.h"
#include "host.h" #include "host.h"
#include "util.h" #include "util.h"
extern const wchar_t* INVALID_CODEPAGE;
TextThread::TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name) : TextThread::TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name) :
handle(threadCounter++), handle(threadCounter++),
name(name.value_or(Util::StringToWideString(hp.name).value())), name(name.value_or(Util::StringToWideString(hp.name).value())),

View File

@ -1,7 +1,6 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "defs.h" #include "defs.h"
#include "text.h"
#include "extenwindow.h" #include "extenwindow.h"
#include "misc.h" #include "misc.h"
#include "host/util.h" #include "host/util.h"
@ -15,6 +14,30 @@
#include <QInputDialog> #include <QInputDialog>
#include <QFileDialog> #include <QFileDialog>
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) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow), ui(new Ui::MainWindow),
@ -121,7 +144,7 @@ void MainWindow::ProcessConnected(DWORD processId)
if (hookList != allProcesses.rend()) if (hookList != allProcesses.rend())
for (auto hookInfo : hookList->split(" , ")) for (auto hookInfo : hookList->split(" , "))
if (auto hp = Util::ParseCode(S(hookInfo))) Host::InsertHook(processId, hp.value()); 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) void MainWindow::ProcessDisconnected(DWORD processId)

View File

@ -1,9 +1,13 @@
#include "extension.h" #include "extension.h"
#include "text.h"
#include "network.h" #include "network.h"
#include <QInputDialog> #include <QInputDialog>
#include <QTimer> #include <QTimer>
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 QStringList languages
{ {
"English: en", "English: en",

View File

@ -1,6 +1,5 @@
#include "extension.h" #include "extension.h"
#include "defs.h" #include "defs.h"
#include "text.h"
#include <QDialog> #include <QDialog>
#include <QInputDialog> #include <QInputDialog>
#include <QColorDialog> #include <QColorDialog>
@ -12,6 +11,13 @@
#include <QSettings> #include <QSettings>
#include <QTimer> #include <QTimer>
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; std::mutex m;
struct : QDialog struct : QDialog

View File

@ -1,11 +1,15 @@
#include "extension.h" #include "extension.h"
#include "text.h"
#include "util.h" #include "util.h"
#include "network.h" #include "network.h"
#include <ctime> #include <ctime>
#include <QInputDialog> #include <QInputDialog>
#include <QTimer> #include <QTimer>
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 QStringList languages
{ {
"English: en", "English: en",

View File

@ -1,6 +1,5 @@
#include "extension.h" #include "extension.h"
#include "util.h" #include "util.h"
#include "text.h"
#include <fstream> #include <fstream>
#include <QMainWindow> #include <QMainWindow>
#include <QLayout> #include <QLayout>
@ -8,6 +7,10 @@
#include <QPushButton> #include <QPushButton>
#include <QTimer> #include <QTimer>
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"; constexpr auto LUA_SAVE_FILE = u8"Textractor.lua";
extern "C" // Lua library extern "C" // Lua library

View File

@ -1,11 +1,14 @@
#include "extension.h" #include "extension.h"
#include "text.h"
#include <QMainWindow> #include <QMainWindow>
#include <QLayout> #include <QLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QTimer> #include <QTimer>
extern const char* REGEX_FILTER;
extern const char* INVALID_REGEX;
extern const char* CURRENT_FILTER;
std::wregex regex; std::wregex regex;
std::shared_mutex m; std::shared_mutex m;

View File

@ -1,11 +1,11 @@
#include "extension.h" #include "extension.h"
#include "text.h"
#include <cwctype> #include <cwctype>
#include <fstream> #include <fstream>
#include <atomic> #include <atomic>
#include <filesystem> #include <filesystem>
#include <process.h> #include <process.h>
extern const wchar_t* REPLACER_INSTRUCTIONS;
constexpr auto REPLACE_SAVE_FILE = u8"SavedReplacements.txt"; constexpr auto REPLACE_SAVE_FILE = u8"SavedReplacements.txt";
std::atomic<std::filesystem::file_time_type> replaceFileLastWrite; std::atomic<std::filesystem::file_time_type> replaceFileLastWrite;

View File

@ -1,5 +1,4 @@
#include "extension.h" #include "extension.h"
#include "text.h"
#include <QMainWindow> #include <QMainWindow>
#include <QLayout> #include <QLayout>
#include <QPushButton> #include <QPushButton>
@ -8,6 +7,11 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QTimer> #include <QTimer>
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::mutex m;
std::unordered_map<int64_t, std::unordered_multiset<int64_t>> linkedTextHandles; std::unordered_map<int64_t, std::unordered_multiset<int64_t>> linkedTextHandles;

View File

@ -29,5 +29,7 @@ constexpr auto CONFIG_FILE = u8"Textractor.ini";
// Misc // Misc
constexpr auto DEFAULT_EXTENSIONS = u8"Remove Repetition>Lua>Copy to Clipboard>Bing Translate>Extra Window>Extra Newlines"; 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 // EOF

View File

@ -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;

View File

@ -1,4 +1,4 @@
#include "text.h" #include "defs.h"
//#define TURKISH //#define TURKISH
//#define SPANISH //#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) (Does not work if running as administrator)
Drag and drop within the list to reorder Drag and drop within the list to reorder
Press delete with an extension selected to remove it)"; 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* USE_JP_LOCALE = u8"Emulate japanese locale?";
const char* FILTER_REPETITION = u8"Repetition Filter"; const char* FILTER_REPETITION = u8"Repetition Filter";
const char* DEFAULT_CODEPAGE = u8"Default Codepage"; const char* DEFAULT_CODEPAGE = u8"Default Codepage";
@ -133,7 +132,6 @@ inline auto _ = []
EXTENSIONS = u8"Uzantılar"; EXTENSIONS = u8"Uzantılar";
SELECT_PROCESS = u8"İşlem Seçin"; 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"; 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ı"; DEFAULT_CODEPAGE = u8"Varsayılan Kod Sayfası";
FLUSH_DELAY = u8"Temizleme Gecikmesi"; FLUSH_DELAY = u8"Temizleme Gecikmesi";
MAX_BUFFER_SIZE = u8"Maksimum Arabellek Boyu"; 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 EXTEN_WINDOW_INSTRUCTIONS = u8R"(Arrrastra y suelta la extension (.dll) aquí desde tu computadora para añadirlos
Arrastra y suelta la lista para reordenar Arrastra y suelta la lista para reordenar
Presiona supr en una extension seleccionada para removerla)"; Presiona supr en una extension seleccionada para removerla)";
WINDOW = u8"Ventana";
USE_JP_LOCALE = u8"¿Emular idioma japonés?"; USE_JP_LOCALE = u8"¿Emular idioma japonés?";
DEFAULT_CODEPAGE = u8"Default Codepage"; DEFAULT_CODEPAGE = u8"Default Codepage";
FLUSH_DELAY = u8"Flush Delay"; FLUSH_DELAY = u8"Flush Delay";
@ -276,7 +273,6 @@ S/Q/V: 代码页/UTF-16/UTF-8 字符串
(使) (使)
使 delete )"; 使 delete )";
WINDOW = u8"窗口";
USE_JP_LOCALE = u8"模拟日本区域设置?"; USE_JP_LOCALE = u8"模拟日本区域设置?";
DEFAULT_CODEPAGE = u8"默认代码页"; DEFAULT_CODEPAGE = u8"默认代码页";
FLUSH_DELAY = u8"刷新延迟"; FLUSH_DELAY = u8"刷新延迟";

View File

@ -13,9 +13,10 @@
#include "util/growl.h" #include "util/growl.h"
#include "util/util.h" #include "util/util.h"
#include "main.h" #include "main.h"
#include "text.h"
#include "ithsys/ithsys.h" #include "ithsys/ithsys.h"
extern const char* HIJACK_ERROR;
//#define ConsoleOutput(...) (void)0 // jichi 8/18/2013: I don't need ConsoleOutput //#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 enum { MAX_REL_ADDR = 0x200000 }; // jichi 8/18/2013: maximum relative address

View File

@ -1,8 +1,9 @@
#include "match.h" #include "match.h"
#include "main.h" #include "main.h"
#include "text.h"
#include "native/pchooks.h" #include "native/pchooks.h"
extern const char* HIJACK_ERROR;
namespace Engine namespace Engine
{ {
void HookDirectX() void HookDirectX()

View File

@ -5,11 +5,18 @@
#include "main.h" #include "main.h"
#include "defs.h" #include "defs.h"
#include "text.h"
#include "engine/match.h" #include "engine/match.h"
#include "texthook.h" #include "texthook.h"
#include "util.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; WinMutex viewMutex;
namespace namespace
@ -88,8 +95,9 @@ void ConsoleOutput(LPCSTR text, ...)
WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); 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); HookRemovedNotif buffer(addr);
WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr);
} }

View File

@ -9,7 +9,7 @@
void TextOutput(ThreadParam tp, BYTE* text, int len); void TextOutput(ThreadParam tp, BYTE* text, int len);
void ConsoleOutput(LPCSTR text, ...); 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 NewHook(HookParam hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
void RemoveHook(uint64_t addr, int maxOffset = 9); void RemoveHook(uint64_t addr, int maxOffset = 9);

View File

@ -4,11 +4,16 @@
// 8/24/2013 TODO: Clean up this file // 8/24/2013 TODO: Clean up this file
#include "texthook.h" #include "texthook.h"
#include "engine/match.h"
#include "main.h" #include "main.h"
#include "text.h" #include "engine/match.h"
#include "ithsys/ithsys.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; extern WinMutex viewMutex;
// - Unnamed helpers - // - Unnamed helpers -
@ -282,10 +287,9 @@ void TextHook::RemoveReadCode()
void TextHook::Clear() void TextHook::Clear()
{ {
std::scoped_lock lock(viewMutex); std::scoped_lock lock(viewMutex);
if (*hp.name) ConsoleOutput(REMOVING_HOOK, hp.name);
if (hp.type & DIRECT_READ) RemoveReadCode(); if (hp.type & DIRECT_READ) RemoveReadCode();
else RemoveHookCode(); else RemoveHookCode();
NotifyHookRemove(address); NotifyHookRemove(address, hp.name);
memset(this, 0, sizeof(TextHook)); // jichi 11/30/2013: This is the original code of ITH memset(this, 0, sizeof(TextHook)); // jichi 11/30/2013: This is the original code of ITH
} }