Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System42 engine hook #1221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions texthook/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5539,6 +5539,53 @@ bool InsertSystem43Hook()
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:
Game folder contains message.dat. Used by AtelierKaguya games.
Expand Down
1 change: 1 addition & 0 deletions texthook/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ bool InsertSiglusHook(); // SiglusEngine: SiglusEngine.exe
bool InsertSideBHook(); // SideB: Copyright side-B
bool InsertSilkysHook(); // SilkysPlus
bool InsertSyuntadaHook(); // Syuntada: dSoh.dat
bool InsertSystem42Hook(); // System42@AliceSoft: AliceStart.ini DLL/Sys42VM.dll
bool InsertSystem43Hook(); // System43@AliceSoft: AliceStart.ini
bool InsertSystemAoiHook(); // SystemAoi: *.vfs
bool InsertTamamoHook(); // Tamamo
Expand Down
13 changes: 8 additions & 5 deletions texthook/engine/match32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ bool DetermineEngineByProcessName()

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())
return true;
// jichi 1/19/2015: Disable inserting Lstr for System40
Expand All @@ -565,11 +573,6 @@ bool DetermineEngineOther()
ConsoleOutput("vnreng: IGNORE old System40.ini");
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
//if (GetProcAddress(GetModuleHandleW(nullptr), "uv_uptime") || GetModuleHandleW(L"node.dll"))
Expand Down