Merge remote-tracking branch 'Blu3train/DmmEngineHooks'

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

View File

@ -21993,6 +21993,103 @@ bool InsertNamcoPS2Hook()
}
#endif // 0
bool DmmFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
StringCharReplacer(text, len, "\\n", 2, ' ');
StringCharReplacer(text, len, "\\k", 2, ' ');
if (cpp_strnstr(text, "{", *len)) {
StringFilterBetween(text, len, "{", 1, "}", 1);
}
return true;
}
bool InsertDmm1Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r76933
* https://vndb.org/v18717
*/
bool found = false;
const BYTE pattern[] = {
0x8A, 0x02,
0x42,
0x84, 0xC0,
0x75, 0xF9,
0x2B, 0xD6,
0x8D, 0xBB, XX4,
0x8A, 0x47, 0x01,
0x47,
0x84, 0xC0,
0x75, 0xF8,
0x8B, 0xCA,
0xC1, 0xE9, 0x02, // <--
0xF3, 0xA5,
0x8B, 0xCA
};
enum { addr_offset = 25 };
for (auto addr : Util::SearchMemory(pattern, sizeof(pattern), PAGE_EXECUTE, processStartAddress, processStopAddress))
{
HookParam hp = {};
hp.address = addr+addr_offset;
hp.offset = pusha_esi_off - 4;
hp.codepage = 65001;
hp.type = USING_STRING | NO_CONTEXT;
hp.filter_fun = DmmFilter;
ConsoleOutput("Textractor: INSERT DMM1");
NewHook(hp, "DMM1");
found = true;
}
if (!found) ConsoleOutput("Textractor:DMM1: pattern not found");
return found;
}
bool InsertDmm2Hook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/r76933
*/
bool found = false;
const BYTE pattern[] = {
0x52,
0xFF, 0x71, 0x24,
0x50,
0xFF, 0xB7, 0x38, 0x02, 0x00, 0x00,
0xE8, 0x17, 0x66, 0xFF, 0xFF,
0x5F, // <--
0xB0, 0x01,
0x5E,
0xC3,
0x51
};
enum { addr_offset = 16 };
for (auto addr : Util::SearchMemory(pattern, sizeof(pattern), PAGE_EXECUTE, processStartAddress, processStopAddress))
{
HookParam hp = {};
hp.address = addr+addr_offset;
hp.offset = pusha_ebp_off - 4;
hp.codepage = 65001;
hp.type = USING_STRING | NO_CONTEXT;
hp.filter_fun = DmmFilter;
ConsoleOutput("Textractor: INSERT DMM2");
NewHook(hp, "DMM2");
found = true;
}
if (!found) ConsoleOutput("Textractor:DMM2: pattern not found");
return found;
}
bool InsertDmmHooks()
{ return InsertDmm1Hook() || InsertDmm2Hook();}
bool Ages7Filter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPWSTR>(data);

View File

@ -172,6 +172,8 @@ bool InsertAges7Hook(); // AGES 7.0: Ages3ResT.dll
bool InsertCircusHook1();
bool InsertCircusHook2();
bool InsertDmmHooks(); // DMM: Data/Exi_UT2.sdat
} // namespace Engine
// EOF

View File

@ -371,6 +371,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4()
{
if (Util::CheckFile(L"Data/Exi_UT2.sdat")) {
if (InsertDmmHooks())
return true;
}
if (Util::CheckFile(L"Ages3ResT.dll")) {
if (InsertAges7Hook())
return true;