improved TanukiSoft engine hook and filtered furigana
This commit is contained in:
parent
e5f2b66ece
commit
c260bbfa1c
@ -9676,6 +9676,20 @@ bool InsertTanukiHook()
|
||||
ConsoleOutput("vnreng:TanukiSoft: failed");
|
||||
return false;
|
||||
}
|
||||
bool Tanuki2Filter(LPVOID data, DWORD *size, HookParam *, BYTE)
|
||||
{
|
||||
auto text = reinterpret_cast<LPSTR>(data);
|
||||
auto len = reinterpret_cast<size_t *>(size);
|
||||
|
||||
if (cpp_strnstr(text, "\x81\x81", *len)) {
|
||||
StringFilterBetween(text, len, "\x81\x81", 2, "\x81\x84", 2);
|
||||
StringFilter(text, len, "\x81\x83", 2);
|
||||
} else {
|
||||
StringFilterBetween(text, len, "\x81\x83", 2, "\x81\x84", 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool InsertTanuki2Hook()
|
||||
{
|
||||
//by Blu3train
|
||||
@ -9685,55 +9699,23 @@ bool InsertTanuki2Hook()
|
||||
* https://vndb.org/v10928
|
||||
*/
|
||||
const BYTE bytes[] = {
|
||||
0xCC, // int 3
|
||||
0x55, // push ebp << hook here
|
||||
0x8B, 0xEC, // mov ebp,esp
|
||||
0x6A, 0xFF, // push -01
|
||||
0x68, XX4, // push noshoujo.exe+33E932
|
||||
0x64, 0xA1, XX4, // mov eax,fs:[00000000]
|
||||
0x50, // push eax
|
||||
0x81, 0xEC, 0xD4, 0x00, 0x00, 0x00, // sub esp,000000D4
|
||||
0xA1, XX4, // mov eax,[noshoujo.exe+3DC650]
|
||||
0x33, 0xC5, // xor eax,ebp
|
||||
0x89, 0x45, 0xF0, // mov [ebp-10],eax
|
||||
0x56, // push esi
|
||||
0x57, // push edi
|
||||
0x50 // push eax
|
||||
};
|
||||
const BYTE bytes2[] = {
|
||||
0xCC, // int 3
|
||||
0x55, // push ebp << hook here
|
||||
0x8B, 0xEC, // mov ebp,esp
|
||||
0x6A, 0xFF, // push -01
|
||||
0x68, XX4, // push tonarino.exe+295DF8
|
||||
0x64, 0xA1, XX4, // mov eax,fs:[00000000]
|
||||
0x50, // push eax
|
||||
0x81, 0xEC, 0x94, 0x01, 0x00, 0x00, // sub esp,00000194
|
||||
0xA1, XX4, // mov eax,[tonarino.exe+3291D0]
|
||||
0x33, 0xC5, // xor eax,ebp
|
||||
0x89, 0x45, 0xF0, // mov [ebp-10],eax
|
||||
0x53, // push ebx
|
||||
0x56, // push esi
|
||||
0x57, // push edi
|
||||
0x50, // push eax
|
||||
0x8D, 0x45, 0xF4, // lea eax,[ebp-0C]
|
||||
0x64, 0xA3, XX4, // mov fs:[00000000],eax
|
||||
0x8B, 0x45, 0x08 // mov eax,[ebp+08]
|
||||
0xE8, XX4, // call noshoujo.exe+237500 << hook here
|
||||
0x8B, XX, // mov ecx,esi
|
||||
0x83, 0xC4, 0x0C, // add esp,0C
|
||||
0x8D, XX, 0x01 // lea edx,[ecx+01]
|
||||
};
|
||||
|
||||
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
|
||||
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
|
||||
if (!addr) {
|
||||
addr = MemDbg::findBytes(bytes2, sizeof(bytes2), processStartAddress, processStartAddress + range);
|
||||
if (!addr) {
|
||||
ConsoleOutput("vnreng:TanukiSoft2: pattern not found");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HookParam hp = {};
|
||||
hp.address = addr + 1;
|
||||
hp.offset = 4 * 2; // arg2
|
||||
hp.type = USING_STRING;
|
||||
hp.address = addr;
|
||||
hp.offset = pusha_esi_off -4;
|
||||
hp.type = USING_STRING | NO_CONTEXT;
|
||||
hp.filter_fun = Tanuki2Filter;
|
||||
ConsoleOutput("vnreng: INSERT TanukiSoft2");
|
||||
NewHook(hp, "TanukiSoft2");
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user