diff --git a/LunaHook/CMakeLists.txt b/LunaHook/CMakeLists.txt index b383970..76b91ae 100644 --- a/LunaHook/CMakeLists.txt +++ b/LunaHook/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(. util engines) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(enginessrc Ryujinx livecaptions Kincaid vita3k rpcs3 yuzusuyu TYPEMOON ENTERGRAM AGES7 mono Godot 5pb lucasystem LightVN V8 pchooks Artemis KiriKiri YOX PPSSPP CMVS Suika2 ) + set(enginessrc MKXPZ Ryujinx livecaptions Kincaid vita3k rpcs3 yuzusuyu TYPEMOON ENTERGRAM AGES7 mono Godot 5pb lucasystem LightVN V8 pchooks Artemis KiriKiri YOX PPSSPP CMVS Suika2 ) set(enginepath "engine64") set(collector "enginecollection64.cpp") else() diff --git a/LunaHook/engine64/MKXPZ.cpp b/LunaHook/engine64/MKXPZ.cpp new file mode 100644 index 0000000..4fad1ff --- /dev/null +++ b/LunaHook/engine64/MKXPZ.cpp @@ -0,0 +1,35 @@ +#include "MKXPZ.h" + +bool MKXPZ::attach_function() +{ + auto hmod = GetModuleHandle(L"x64-msvcrt-ruby310.dll"); + if (!hmod) + return false; + + auto onigenc_get_right_adjust_char_head_with_prev = GetProcAddress(hmod, "onigenc_get_right_adjust_char_head_with_prev"); + auto onigenc_get_prev_char_head = GetProcAddress(hmod, "onigenc_get_prev_char_head"); + bool succ = false; + HookParam hp; + hp.type = CODEC_UTF8 | USING_STRING | FULL_STRING; + hp.offset = get_reg(regs::rdx); + hp.filter_fun = [](void *data, size_t *size, HookParam *) + { + auto s = std::string((char *)data, *size); + if (startWith(s, "Characters/")) + return false; + if (startWith(s, "Pictures/")) + return false; + if (startWith(s, "Graphics/")) + return false; + s = std::regex_replace(s, std::regex("<.*?>"), ""); + s = std::regex_replace(s, std::regex(R"(\\tg\[(.*?)\])"), "$1\n"); // 人名 + s = std::regex_replace(s, std::regex(R"(\\\w+\[\d+\])"), ""); + strReplace(s, "\\|", ""); + return write_string_overwrite((char *)data, size, s); + }; + hp.address = (uintptr_t)onigenc_get_right_adjust_char_head_with_prev; // 这个比较纯粹,但有时候会缺 + succ |= NewHook(hp, "MKXPZ"); + hp.address = (uintptr_t)onigenc_get_prev_char_head; + succ |= NewHook(hp, "MKXPZ"); + return succ; +} \ No newline at end of file diff --git a/LunaHook/engine64/MKXPZ.h b/LunaHook/engine64/MKXPZ.h new file mode 100644 index 0000000..51aec1e --- /dev/null +++ b/LunaHook/engine64/MKXPZ.h @@ -0,0 +1,37 @@ +/* +FILEVERSION 2,4,2,0 +PRODUCTVERSION 2,4,2,0 +FILEFLAGSMASK 0x0 +FILEFLAGS 0x0 +FILEOS VOS_UNKNOWN +FILETYPE VFT_UNKNOWN +FILESUBTYPE 0x0 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904b0" + { + VALUE "FileVersion", "2.4.2" + VALUE "OriginalFilename", "mkxp-z.exe" + VALUE "ProductName", "mkxp-z" + VALUE "ProductVersion", "2.4.2" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 1200 + } +} + +*/ + +class MKXPZ : public ENGINE +{ +public: + MKXPZ() + { + check_by = CHECK_BY::RESOURCE_STR; + check_by_target = L"mkxp-z"; + }; + bool attach_function(); +}; \ No newline at end of file diff --git a/LunaHook/enginecollection64.cpp b/LunaHook/enginecollection64.cpp index 375ad07..f42eabc 100644 --- a/LunaHook/enginecollection64.cpp +++ b/LunaHook/enginecollection64.cpp @@ -20,6 +20,7 @@ #include "engine64/Ryujinx.h" #include "engine64/vita3k.h" #include "engine64/rpcs3.h" +#include "engine64/MKXPZ.h" #include "engines/lua/lua51.h" #include "engines/python/Renpy.h" std::vector check_engines() @@ -48,6 +49,7 @@ std::vector check_engines() new Kincaid, new livecaptions, new lua51, - new Ryujinx + new Ryujinx, + new MKXPZ }; }