Merge remote-tracking branch 'Blu3train/SekaiProjectHooks'

This commit is contained in:
Chenx221 2024-09-05 12:07:15 +08:00
commit 23a5537558
3 changed files with 108 additions and 0 deletions

View File

@ -23612,6 +23612,109 @@ bool InsertNamcoPS2Hook()
} }
#endif // 0 #endif // 0
bool InsertSekaiProject1Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/v1193
*/
const BYTE bytes[] = {
0xCC, // int 3
0x83, 0xEC, 0x10, // sub esp,10 << hook here
0x8B, 0x44, 0x24, 0x14, // mov eax,[esp+14]
0x53, // push ebx
0x56, // push esi
0x50, // push eax
0x8B, 0xD9 // mov ebx,ecx
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:SekaiProject1: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr + 1;
hp.offset = 0x4 * 1; //arg1
hp.index = 0;
hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT;
ConsoleOutput("vnreng: INSERT SekaiProject1");
NewHook(hp, "SekaiProject1");
return true;
}
bool InsertSekaiProject2Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r21174
*/
const BYTE bytes[] = {
0xC7, 0x45, 0xDC, 0x00, 0x00, 0x00, 0x00, // mov [ebp-24],00000000 << hook here
0xEB, 0x09, // jmp "SCHOOLDAYS HQ.exe"+4C821
0x8B, 0x45, 0xDC, // mov eax,[ebp-24]
0x83, 0xC0, 0x01, // add eax,01
0x89, 0x45, 0xDC // mov [ebp-24],eax
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:SekaiProject2: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr;
hp.offset = 0x4 * 21; //arg21
hp.index = 0;
hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT;
ConsoleOutput("vnreng: INSERT SekaiProject2");
NewHook(hp, "SekaiProject2");
return true;
}
bool InsertSekaiProject3Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r39989
*/
const BYTE bytes[] = {
0xCC, // int 3
0x8B, 0x44, 0x24, 0x04, // mov eax,[esp+04] << hook here
0x83, 0xEC, 0x14, // sub esp,14
0x55, // push ebp
0x56, // push esi
0x57, // push edi
0x8B, 0xF9 // mov edi,ecx
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:SekaiProject3: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr + 1;
hp.offset = 0x4 * 1; //arg1
hp.index = 0;
hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT;
ConsoleOutput("vnreng: INSERT SekaiProject3");
NewHook(hp, "SekaiProject3");
return true;
}
bool InsertSekaiProjectHooks()
{ return InsertSekaiProject1Hook() || InsertSekaiProject2Hook() || InsertSekaiProject3Hook();}
bool NitroplusSysFilter(LPVOID data, DWORD *size, HookParam *, BYTE) bool NitroplusSysFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{ {
auto text = reinterpret_cast<LPSTR>(data); auto text = reinterpret_cast<LPSTR>(data);

View File

@ -171,6 +171,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 InsertSekaiProjectHooks(); // Sekai Project: Packs/*.GPK
bool InsertNitroplusSysHook(); // NitroplusSystem: resource string && system.dll bool InsertNitroplusSysHook(); // NitroplusSystem: resource string && system.dll
bool InsertAtelierGSHooks(); // Atelier GAME_SYS: game_sys.exe, resource string bool InsertAtelierGSHooks(); // Atelier GAME_SYS: game_sys.exe, resource string
bool InsertAtelierADV10Hook(); // Atelier ADV10: ADV10.EXE, resource string bool InsertAtelierADV10Hook(); // Atelier ADV10: ADV10.EXE, resource string

View File

@ -380,6 +380,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4() bool DetermineEngineByFile4()
{ {
if (Util::CheckFile(L"Packs/*.GPK")) {
if (InsertSekaiProjectHooks())
return true;
}
if (Util::SearchResourceString(L"Nitro+") && Util::CheckFile(L"system.dll")) { if (Util::SearchResourceString(L"Nitro+") && Util::CheckFile(L"system.dll")) {
if (InsertNitroplusSysHook()) if (InsertNitroplusSysHook())
return true; return true;