Minori engine hooks

This commit is contained in:
Blu3train 2023-04-30 00:28:20 +02:00
parent f3fbe04409
commit a3b15d8701
3 changed files with 127 additions and 0 deletions

View File

@ -21728,6 +21728,128 @@ bool InsertNamcoPS2Hook()
}
#endif // 0
bool Minori1EngFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
StringCharReplacer(text, len, "\\n", 2, ' ');
StringFilter(text, len, "\\a", 2);
StringFilter(text, len, "\\v", 2);
CharReplacer(text, len, '\xC4', '-');
CharReplacer(text, len, '\x93', '"');
CharReplacer(text, len, '\x94', '"');
CharReplacer(text, len, '\x92', '\'');
StringCharReplacer(text, len, "\\I", 2, '\'');
StringCharReplacer(text, len, "\\P", 2, '\'');
return true;
}
bool Minori1JapFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
StringFilter(text, len, "\\a", 2);
StringFilter(text, len, "\\v", 2);
StringFilter(text, len, "\\N", 2);
if (cpp_strnstr(text, "{", *len)) {
StringFilterBetween(text, len, "{", 1, "}", 1);
}
return true;
}
bool InsertMinori1Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/v19644
* https://vndb.org/v12562
*/
const BYTE bytes[] = {
0x84, 0xC0, // test al,al << hook here
0x0F, 0x85, XX4, // jne trinoline_en_AA.exe+243E1
0x68, XX4, // push trinoline_en_AA.exe+118BF8 << alt eng hook
0x33, 0xFF // xor edi,edi
};
enum { alt_addr_offset = 8 };
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Minori1: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr;
hp.offset = pusha_edx_off -4;
hp.codepage = 932;
hp.type = USING_STRING;
hp.filter_fun = Minori1JapFilter;
ConsoleOutput("vnreng: INSERT Minori1");
NewHook(hp, "Minori1");
const BYTE bytes2[] = {
0x84, 0xC0, // test al,al
0x0F, 0x85, XX4, // jne trinoline_en_AA.exe+243E1
0x68, XX4, // push trinoline_en_AA.exe+118BF8
0x33, 0xFF // xor edi,edi
};
ULONG addr2 = MemDbg::findBytes(bytes2, sizeof(bytes2), processStartAddress, processStartAddress + range);
if (addr) {
HookParam hp = {};
hp.address = addr + alt_addr_offset;
hp.offset = pusha_edx_off -4;
hp.type = USING_STRING;
hp.filter_fun = Minori1EngFilter;
ConsoleOutput("vnreng: INSERT Minori1eng");
NewHook(hp, "Minori1eng");
}
return true;
}
bool InsertMinori2Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/v35
*/
const BYTE bytes[] = {
0x80, 0x38, 0x00, // cmp byte ptr [eax],00
0x0F, 0x84, XX4, // je WindRP.exe+2832A
0xB8, 0x20, 0x03, 0x00, 0x00, // mov eax,00000320
0x89, 0x44, 0x24, 0x10, // mov [esp+10],eax
0x89, 0x44, 0x24, 0x14, // mov [esp+14],eax
0x8B, 0x47, 0x20 // mov eax,[edi+20]
};
enum { addr_offset = 0 };
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:Minori2: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr + addr_offset;
hp.offset = pusha_eax_off -4;
hp.index = 0;
hp.length_offset = 1;
hp.type = NO_CONTEXT | DATA_INDIRECT;
ConsoleOutput("vnreng: INSERT Minori2");
NewHook(hp, "Minori2");
return true;
}
bool InsertMinoriHooks()
{ return InsertMinori1Hook() || InsertMinori2Hook();}
} // namespace Engine
// EOF

View File

@ -165,6 +165,7 @@ void InsertRealliveHook(); // RealLive: RealLive*.exe
void InsertStuffScriptHook(); // Stuff: *.mpk
bool InsertTinkerBellHook(); // TinkerBell: arc00.dat
bool InsertWaffleHook(); // WAFFLE: cg.pak
bool InsertMinoriHooks(); // Minori: *.paz
// CIRCUS: avdata/
bool InsertCircusHook1();

View File

@ -370,6 +370,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4()
{
if (Util::CheckFile(L"*.paz")) {
if (InsertMinoriHooks())
return true;
}
if (Util::CheckFile(L"EAGLS.dll")) { // jichi 3/24/2014: E.A.G.L.S
//ConsoleOutput("vnreng: IGNORE EAGLS");
InsertEaglsHook();