Merge remote-tracking branch 'Blu3train/KaleidoEngineHooks'

This commit is contained in:
Chenx221 2024-09-05 11:49:19 +08:00
commit f1c908cffe
3 changed files with 57 additions and 0 deletions

View File

@ -22578,6 +22578,58 @@ bool InsertNamcoPS2Hook()
} }
#endif // 0 #endif // 0
bool KaleidoFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
// Unofficial eng TL with garbage newline spaces
StringCharReplacer(text, len, " \\n ", 4, ' ');
StringCharReplacer(text, len, " \\n", 3, ' ');
StringCharReplacer(text, len, "\\n", 2, ' ');
return true;
}
bool InsertKaleidoHook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/v29889
* https://vndb.org/r56675
*/
const BYTE bytes[] = {
0xFF, 0x75, 0xD4, // push [ebp-2C]
0xE8, XX4, // call 5toubun.exe+1DD0
0x83, 0xC4, 0x0C, // add esp,0C
0x8A, 0xC3, // mov al,bl
0x8B, 0x4D, 0xF4, // mov ecx,[ebp-0C]
0x64, 0x89, 0x0D, XX4, // mov fs:[00000000],ecx
0x59 // pop ecx << hook here
};
enum { addr_offset = sizeof(bytes) - 1 };
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Kaleido: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr + addr_offset;
hp.offset = pusha_esi_off -4;
hp.index = 0;
hp.split = 0x0C;
hp.split_index = 0;
hp.type = USING_UTF8 | USING_STRING | USING_SPLIT ;
hp.filter_fun = KaleidoFilter;
ConsoleOutput("vnreng: INSERT Kaleido");
NewHook(hp, "Kaleido");
return true;
}
bool InsertRpgmXPHook() bool InsertRpgmXPHook()
{ {
//by Blu3train //by Blu3train

View File

@ -165,6 +165,7 @@ void InsertRealliveHook(); // RealLive: RealLive*.exe
void InsertStuffScriptHook(); // Stuff: *.mpk void InsertStuffScriptHook(); // Stuff: *.mpk
bool InsertTinkerBellHook(); // TinkerBell: arc00.dat bool InsertTinkerBellHook(); // TinkerBell: arc00.dat
bool InsertWaffleHook(); // WAFFLE: cg.pak bool InsertWaffleHook(); // WAFFLE: cg.pak
bool InsertKaleidoHook(); // Kaleido ADV Workshop: windata/script_body.bin
bool InsertRpgmXPHook(); // Rpgm XP: *.rgssad bool InsertRpgmXPHook(); // Rpgm XP: *.rgssad
bool InsertMinoriHooks(); // Minori: *.paz bool InsertMinoriHooks(); // Minori: *.paz
bool InsertSystemNNNHooks(); // System-NNN: nya/configse.xtx bool InsertSystemNNNHooks(); // System-NNN: nya/configse.xtx

View File

@ -372,6 +372,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4() bool DetermineEngineByFile4()
{ {
if (Util::CheckFile(L"windata/script_body.bin")) {
if (InsertKaleidoHook())
return true;
}
if (Util::CheckFile(L"*.rgssad")) { if (Util::CheckFile(L"*.rgssad")) {
if (InsertRpgmXPHook()) if (InsertRpgmXPHook())
return true; return true;