Nitroplus System.dll engine hook

This commit is contained in:
Blu3train 2023-10-19 20:29:54 +02:00
parent f3fbe04409
commit 627a57806f
3 changed files with 55 additions and 0 deletions

View File

@ -21728,6 +21728,56 @@ bool InsertNamcoPS2Hook()
}
#endif // 0
bool NitroplusSysFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
if (*len <= 2) return false;
StringFilter(text, len, "\x81@", 2);
CharReplacer(text, len, '\r', ' ');
if (cpp_strnstr(text, "<", *len)) {
StringFilterBetween(text, len, "<", 1, ">", 1);
}
while (*len>1 && ::isspace(*text)) {
::memmove(text, text+1, --(*len));
}
return true;
}
bool InsertNitroplusSysHook() {
//by Blu3train
/*
* Sample games:
* https://vndb.org/r76679
*/
const BYTE bytes[] = {
0x0F, 0x84, XX4, // je system.dll+5B8CA <- hook here
0xEB, 0x04, // jmp system.dll+5A791
0x8B, 0x44, 0x24, 0x20, // mov eax,[esp+20]
0x8B, 0x4C, 0x24, 0x24 // mov ecx,[esp+24]
};
HMODULE module = GetModuleHandleW(L"system.dll");
auto [minAddress, maxAddress] = Util::QueryModuleLimits(module);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), minAddress, maxAddress);
if (!addr)
return false;
HookParam hp = {};
hp.address = addr;
hp.offset = pusha_eax_off -4;
hp.index = 0;
hp.type = USING_STRING;
hp.filter_fun = NitroplusSysFilter;
ConsoleOutput("vnreng: INSERT NitroplusSystem");
NewHook(hp, "NitroplusSystem");
return true;
}
} // 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 InsertNitroplusSysHook(); // NitroplusSystem: resource string && system.dll
// CIRCUS: avdata/
bool InsertCircusHook1();

View File

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