Merge remote-tracking branch 'Blu3train/KidHook'

This commit is contained in:
Chenx221 2024-09-05 12:10:54 +08:00
commit b28e80a5be
3 changed files with 57 additions and 0 deletions

View File

@ -23655,6 +23655,58 @@ bool InsertNamcoPS2Hook()
} }
#endif // 0 #endif // 0
bool KidFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
static std::string prevText;
if (LPSTR endText=cpp_strnstr(text, "\x02\x03", *len)) {
*endText = '\0';
*len = endText - text;
}
CharReplacer(text, len, '\x01', ' ');
StringReplacer(text, len, "\x87\x4c", 2, "--", 2);
if (prevText.find(text, 0, *len) != std::string::npos) // Check if the string is present in the previous one
return false;
prevText.assign(text, *len);
return true;
}
bool InsertKidHook() {
//by Blu3train
/*
* Sample games:
* https://vndb.org/r60521
*/
const BYTE bytes[] = {
0xBF, 0x01, 0x00, 0x00, 0x00, // mov edi,00000001 <- hook here
0x8A, 0x08, // mov cl,[eax]
0x40, // inc eax
0xF6, 0xC1, 0x80 // test cl,-80
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Kid: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr;
hp.offset = pusha_eax_off -4;
hp.index = 0;
hp.type = USING_STRING;
hp.filter_fun = KidFilter;
ConsoleOutput("vnreng: INSERT Kid");
NewHook(hp, "Kid");
return true;
}
bool ISMscriptFilter(LPVOID data, DWORD *size, HookParam *, BYTE) bool ISMscriptFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{ {
auto text = reinterpret_cast<LPWSTR>(data); auto text = reinterpret_cast<LPWSTR>(data);

View File

@ -156,6 +156,7 @@ bool InsertWillPlusHook(); // WillPlus: Rio.arc
bool InsertWolfHook(); // Wolf: Data.wolf bool InsertWolfHook(); // Wolf: Data.wolf
bool InsertYukaSystemHooks(); // YukaSystem2: *.ykc bool InsertYukaSystemHooks(); // YukaSystem2: *.ykc
bool InsertYurisHook(); // YU-RIS: *.ypf bool InsertYurisHook(); // YU-RIS: *.ypf
bool InsertKidHook(); // Kid: resource string
bool InsertISMscriptHooks(); // ISM script Engine: ism.dll bool InsertISMscriptHooks(); // ISM script Engine: ism.dll
bool InsertTrianglePixHook(); // Triangle Pix: pix.bin bool InsertTrianglePixHook(); // Triangle Pix: pix.bin
bool InsertOtomeHook(); // Otome: fsroot* bool InsertOtomeHook(); // Otome: fsroot*

View File

@ -380,6 +380,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4() bool DetermineEngineByFile4()
{ {
if (Util::SearchResourceString(L" KID")) {
if (InsertKidHook())
return true;
}
if (Util::CheckFile(L"ism.dll")) { if (Util::CheckFile(L"ism.dll")) {
if (InsertISMscriptHooks()) if (InsertISMscriptHooks())
return true; return true;