Merge remote-tracking branch 'Blu3train/DxLibEngineHooks'

This commit is contained in:
Chenx221 2024-09-05 11:50:38 +08:00
commit 2d5213cfc7
3 changed files with 53 additions and 0 deletions

View File

@ -22578,6 +22578,54 @@ bool InsertNamcoPS2Hook()
}
#endif // 0
bool DxLibFilter(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, "%K", 2);
StringFilter(text, len, "%P", 2);
return true;
}
bool InsertDxLibHook()
{
//by Blu3train
/*
* Sample games:
* https://vndb.org/v7849
* https://vndb.org/v10231
*/
const BYTE bytes[] = {
0xF7, 0xC6, XX4, // test esi,00000003 << hook here
0x75, XX, // jne BookofShadows.exe+15FE54
0x8B, 0xD9, // mov ebx,ecx
0xC1, 0xE9, 0x02, // shr ecx,02
0x75, XX, // jne BookofShadows.exe+15FEAE
0xEB, XX // jmp BookofShadows.exe+15FE76
};
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
if (!addr) {
ConsoleOutput("vnreng:DxLib: pattern not found");
return false;
}
HookParam hp = {};
hp.address = addr;
//hp.offset = pusha_edx_off -4;
hp.offset = pusha_esi_off -4;
hp.index = 0;
hp.type = USING_STRING;
hp.filter_fun = DxLibFilter;
ConsoleOutput("vnreng: INSERT DxLib");
NewHook(hp, "DxLib");
return true;
}
bool GameMakerFilter(LPVOID data, DWORD *size, HookParam *, BYTE)
{
CharFilter(reinterpret_cast<LPSTR>(data), reinterpret_cast<size_t*>(size), '#');

View File

@ -156,6 +156,7 @@ bool InsertWillPlusHook(); // WillPlus: Rio.arc
bool InsertWolfHook(); // Wolf: Data.wolf
bool InsertYukaSystem2Hook(); // YukaSystem2: *.ykc
bool InsertYurisHook(); // YU-RIS: *.ypf
bool InsertDxLibHook(); // DxLib: *.bcx
bool InsertGameMakerHook(); // GameMaker: GMResource.dll
void InsertBrunsHook(); // Bruns: bruns.exe

View File

@ -372,6 +372,10 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4()
{
if (Util::CheckFile(L"*.bcx")) {
if (InsertDxLibHook())
return true;
}
if (Util::CheckFile(L"GMResource.dll")) {
if (InsertGameMakerHook())
return true;