Merge remote-tracking branch 'Blu3train/System42EngineHook'

This commit is contained in:
Chenx221 2024-09-05 12:24:40 +08:00
commit cb2fcaa0c8
3 changed files with 56 additions and 5 deletions

View File

@ -6357,6 +6357,53 @@ bool InsertSystem43Hook()
return ok; return ok;
} }
bool System42Filter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
auto text = reinterpret_cast<LPSTR>(data);
auto len = reinterpret_cast<size_t *>(size);
if (*len == 1)
return false;
if (all_ascii(text, *len)) {
CharReplacer(text, len, '`', ' ');
CharReplacer(text, len, '\x7D', '-');
}
return true;
}
bool InsertSystem42Hook() {
//by Blu3train
/*
* Sample games:
* https://vndb.org/v1427
*/
const BYTE bytes[] = {
0x8B, 0x46, 0x04, // mov eax,[esi+04]
0x57, // push edi
0x52, // push edx
0x50, // push eax
0xE8, XX4 // call Sys42VM.DLL+4B5B0
};
HMODULE module = GetModuleHandleW(L"Sys42VM.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_edx_off -4;
hp.split = pusha_esp_off -4;
hp.type = NO_CONTEXT | USING_STRING | USING_SPLIT;
hp.filter_fun = System42Filter;
ConsoleOutput("vnreng: INSERT System42");
NewHook(hp, "System42");
return true;
}
/******************************************************************************************** /********************************************************************************************
AtelierKaguya hook: AtelierKaguya hook:
Game folder contains message.dat. Used by AtelierKaguya games. Game folder contains message.dat. Used by AtelierKaguya games.

View File

@ -143,6 +143,7 @@ bool InsertSiglusHook(); // SiglusEngine: SiglusEngine.exe
bool InsertSideBHook(); // SideB: Copyright side-B bool InsertSideBHook(); // SideB: Copyright side-B
bool InsertSilkysHooks(); // SilkysPlus bool InsertSilkysHooks(); // SilkysPlus
bool InsertSyuntadaHook(); // Syuntada: dSoh.dat bool InsertSyuntadaHook(); // Syuntada: dSoh.dat
bool InsertSystem42Hook(); // System42@AliceSoft: AliceStart.ini DLL/Sys42VM.dll
bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini
bool InsertSystemAoiHook(); // SystemAoi: *.vfs bool InsertSystemAoiHook(); // SystemAoi: *.vfs
bool InsertTamamoHook(); // Tamamo bool InsertTamamoHook(); // Tamamo

View File

@ -675,6 +675,14 @@ bool DetermineEngineByProcessName()
bool DetermineEngineOther() bool DetermineEngineOther()
{ {
// jichi 12/26/2013: Add this after alicehook
if (Util::CheckFile(L"AliceStart.ini")) {
if (Util::CheckFile(L"DLL/Sys42VM.dll"))
if (InsertSystem42Hook())
return true;
if (InsertSystem43Hook())
return true;
}
if (InsertAliceHook()) if (InsertAliceHook())
return true; return true;
// jichi 1/19/2015: Disable inserting Lstr for System40 // jichi 1/19/2015: Disable inserting Lstr for System40
@ -683,11 +691,6 @@ bool DetermineEngineOther()
ConsoleOutput("vnreng: IGNORE old System40.ini"); ConsoleOutput("vnreng: IGNORE old System40.ini");
return true; return true;
} }
// jichi 12/26/2013: Add this after alicehook
if (Util::CheckFile(L"AliceStart.ini")) {
InsertSystem43Hook();
return true;
}
// Artikash 7/16/2018: Uses node/libuv: likely v8 - sample game https://vndb.org/v22975 // Artikash 7/16/2018: Uses node/libuv: likely v8 - sample game https://vndb.org/v22975
//if (GetProcAddress(GetModuleHandleW(nullptr), "uv_uptime") || GetModuleHandleW(L"node.dll")) //if (GetProcAddress(GetModuleHandleW(nullptr), "uv_uptime") || GetModuleHandleW(L"node.dll"))