Merge remote-tracking branch 'Blu3train/ClielHook'

This commit is contained in:
Chenx221 2024-09-05 11:54:07 +08:00
commit 59f1fc0100
3 changed files with 90 additions and 0 deletions

View File

@ -23025,6 +23025,91 @@ bool InsertNamcoPS2Hook()
} }
#endif // 0 #endif // 0
bool CielFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
if (*len == 1) return false;
return true;
}
bool InsertCiel1Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r26480
* https://vndb.org/v1648
* https://vndb.org/v10392
*/
const BYTE bytes[] = {
0x50, // push eax << hook here
0xE8, XX4, // call FaultA.exe+81032
0x83, 0xC4, 0x04, // add esp,04
0x85, 0xC0, // test eax,eax
0x74, 0x32, // je FaultA.exe+41FA6
0x81, 0x7C, 0x24, 0x10, XX4 // cmp [esp+10],000003FE
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Ciel1: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr;
hp.offset = pusha_edi_off -4;
hp.index = 0;
hp.length_offset = 1;
hp.type = DATA_INDIRECT;
hp.filter_fun = CielFilter;
ConsoleOutput("vnreng: INSERT Ciel1");
NewHook(hp, "Ciel1");
return true;
}
bool InsertCiel2Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r5101
*/
const BYTE bytes[] = {
0x68, XX4, // push after.exe+94518 << hook here
0x50, // push eax
0xE8, XX4, // call after.exe+711F0
0x83, 0xC4, 0x0C, // add esp,0C
0x85, 0xC0, // test eax,eax
0x0F, 0x85, XX4, // jne after.exe+A2E4
0x8B, 0x93, XX4 // mov edx,[ebx+000BE000]
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Ciel2: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr;
hp.offset = pusha_eax_off -4;
hp.index = 0;
hp.length_offset = 1;
hp.type = DATA_INDIRECT;
ConsoleOutput("vnreng: INSERT Ciel2");
NewHook(hp, "Ciel2");
return true;
}
bool InsertCielHooks()
{ return InsertCiel1Hook() || InsertCiel2Hook();}
bool InsertA98sysHook() bool InsertA98sysHook()
{ {
//by Blu3train //by Blu3train

View File

@ -168,6 +168,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 InsertCielHooks(); // Ciel: sys/kidoku.dat
bool InsertA98sysHook(); // A98sys: A98SYS.PAK bool InsertA98sysHook(); // A98sys: A98SYS.PAK
bool InsertKaleidoHook(); // Kaleido ADV Workshop: windata/script_body.bin bool InsertKaleidoHook(); // Kaleido ADV Workshop: windata/script_body.bin
bool InsertRpgmXPHook(); // Rpgm XP: *.rgssad bool InsertRpgmXPHook(); // Rpgm XP: *.rgssad

View File

@ -372,6 +372,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4() bool DetermineEngineByFile4()
{ {
if (Util::CheckFile(L"sys/kidoku.dat")) {
if (InsertCielHooks())
return true;
}
if (Util::CheckFile(L"A98SYS.PAK")) { if (Util::CheckFile(L"A98SYS.PAK")) {
if (InsertA98sysHook()) if (InsertA98sysHook())
return true; return true;