diff --git a/CMakeSettings.json b/CMakeSettings.json index 70f0a9e..1505c9a 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -13,6 +13,12 @@ "configurationType": "RelWithDebInfo", "inheritEnvironments": [ "msvc_x86" ] }, + { + "name": "x86-Release", + "generator": "Ninja", + "configurationType": "Release", + "inheritEnvironments": [ "msvc_x86" ] + }, { "name": "x64-Debug", "generator": "Ninja", @@ -24,6 +30,12 @@ "generator": "Ninja", "configurationType": "RelWithDebInfo", "inheritEnvironments": [ "msvc_x64" ] + }, + { + "name": "x64-Release", + "generator": "Ninja", + "configurationType": "Release", + "inheritEnvironments": [ "msvc_x64" ] } ] } diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index eed044b..86ea2bf 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -5,7 +5,7 @@ find_qt5(Core Widgets) add_executable(Textractor WIN32 main.cpp mainwindow.cpp - extenwindow.cpp + extenwindow.cpp host/exception.cpp host/host.cpp host/textthread.cpp diff --git a/GUI/host/hookcode.cpp b/GUI/host/hookcode.cpp index 1b02273..b49e4ec 100644 --- a/GUI/host/hookcode.cpp +++ b/GUI/host/hookcode.cpp @@ -88,7 +88,7 @@ namespace } HCode.erase(0, 1); - if ((hp.type & USING_STRING)) + if (hp.type & USING_STRING) { if (HCode[0] == L'F') { diff --git a/include/common.h b/include/common.h index 10f97e7..13803bf 100644 --- a/include/common.h +++ b/include/common.h @@ -145,6 +145,9 @@ inline std::string WideStringToString(const std::wstring& text) template inline void TEXTRACTOR_MESSAGE(const wchar_t* format, const Args&... args) { MessageBoxW(NULL, FormatString(format, args...).c_str(), L"Textractor", MB_OK); } +template +inline void TEXTRACTOR_DEBUG(const wchar_t* format, const Args&... args) { std::thread([=] { TEXTRACTOR_MESSAGE(format, args...); }).detach(); } + #ifdef _DEBUG #define TEST(...) static auto _ = CreateThread(nullptr, 0, [](auto) { __VA_ARGS__; return 0UL; }, NULL, 0, nullptr); #else diff --git a/include/qtcommon.h b/include/qtcommon.h index f80b133..f0278cd 100644 --- a/include/qtcommon.h +++ b/include/qtcommon.h @@ -31,4 +31,4 @@ inline QString S(const std::string& s) { return QString::fromStdString(s); } inline QString S(const std::wstring& s) { return QString::fromStdWString(s); } // TODO: allow paired surrogates inline void sanitize(QString& s) { s.chop(std::distance(std::remove_if(s.begin(), s.end(), [](QChar ch) { return ch.isSurrogate(); }), s.end())); } -inline QString sanitize(QString&& s) { sanitize(s); return s; } +inline QString sanitize(QString&& s) { sanitize(s); return std::move(s); } diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 362ac40..12713c8 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -10095,7 +10095,7 @@ BYTE JIS_tableL[0x80] = { 0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x00, }; -void SpecialHookAnex86(DWORD esp_base, HookParam *hp, BYTE, DWORD *data, DWORD *split, DWORD *len) +void SpecialHookAnex86(DWORD esp_base, HookParam*, BYTE, DWORD *data, DWORD *split, DWORD *len) { __asm { @@ -10134,19 +10134,28 @@ _fin: } // unnamed namespace bool InsertAnex86Hook() { - const DWORD dwords[] = {0x618ac033,0x0d418a0c}; // jichi 12/25/2013: Remove static keyword - for (DWORD i = processStartAddress + 0x1000; i < processStopAddress - 8; i++) - if (*(DWORD *)i == dwords[0]) - if (*(DWORD *)(i + 4) == dwords[1]) { + const BYTE bytes[] = { + 0x8a, XX, 0x0c, // mov ??,[ecx+0C] + 0x8a, XX, 0x0d // mov ??,[ecx+0D] + }; + bool found = false; + for (auto addr : Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStopAddress)) { + //const DWORD dwords[] = {0x618ac033,0x0d418a0c}; // jichi 12/25/2013: Remove static keyword + //for (DWORD i = processStartAddress + 0x1000; i < processStopAddress - 8; i++) + //if (*(DWORD *)i == dwords[0]) + //if (*(DWORD *)(i + 4) == dwords[1]) { HookParam hp = {}; - hp.address = i; + if (*(BYTE*)(addr - 2) == 0x33 || *(BYTE*)(addr - 2) == 0x31) addr = addr - 2; + hp.address = addr; + hp.offset = pusha_ecx_off - 4; hp.text_fun = SpecialHookAnex86; //hp.type = EXTERN_HOOK; hp.length_offset = 1; ConsoleOutput("vnreng: INSERT Anex86"); NewHook(hp, "Anex86"); - return true; + found = true; } + if (found) return true; ConsoleOutput("vnreng:Anex86: failed"); return false; }