This commit is contained in:
恍兮惚兮 2024-09-30 11:58:04 +08:00
parent 446c78c892
commit 3eaa545f99
4 changed files with 76 additions and 2 deletions

View File

@ -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()

View File

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

37
LunaHook/engine64/MKXPZ.h Normal file
View File

@ -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();
};

View File

@ -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<ENGINE *> check_engines()
@ -48,6 +49,7 @@ std::vector<ENGINE *> check_engines()
new Kincaid,
new livecaptions,
new lua51,
new Ryujinx
new Ryujinx,
new MKXPZ
};
}