Kirikiri3 engine hook
This commit is contained in:
parent
f3fbe04409
commit
38038029d8
@ -584,16 +584,70 @@ bool FindKiriKiriHook(DWORD fun, DWORD size, DWORD pt, DWORD flag) // jichi 10/2
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KiriKiri3Filter(LPVOID data, DWORD *size, HookParam *, BYTE)
|
||||||
|
{
|
||||||
|
auto text = reinterpret_cast<LPWSTR>(data);
|
||||||
|
auto len = reinterpret_cast<size_t *>(size);
|
||||||
|
static std::wstring prevText;
|
||||||
|
|
||||||
|
if (!*len)
|
||||||
|
return false;
|
||||||
|
text[*len/sizeof(wchar_t)] = L'\0'; // clean text
|
||||||
|
if (!prevText.compare(text))
|
||||||
|
return false;
|
||||||
|
prevText = text;
|
||||||
|
|
||||||
|
if (cpp_wcsnstr(text, L"[", *len/sizeof(wchar_t))) {
|
||||||
|
WideStringFilterBetween(text, len, L"[", 1, L"]\\", 2);
|
||||||
|
WideStringFilterBetween(text, len, L"[", 1, L"]", 1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InsertKiriKiri3Hook()
|
||||||
|
{
|
||||||
|
//by Blu3train
|
||||||
|
/*
|
||||||
|
* Sample games:
|
||||||
|
* https://vndb.org/v16190
|
||||||
|
*/
|
||||||
|
const BYTE bytes[] = {
|
||||||
|
0x66, 0x83, 0x3C, 0x41 , 0x5B, // cmp word ptr [ecx+eax*2],5B << hook here
|
||||||
|
0x75, 0x09, // jne LBK-30067.exe+1EB26F
|
||||||
|
0x8B, 0x85, XX4 // mov eax,[ebp-00000254]
|
||||||
|
};
|
||||||
|
|
||||||
|
ULONG range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
|
||||||
|
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStartAddress + range);
|
||||||
|
if (!addr) {
|
||||||
|
//ConsoleOutput("vnreng:KiriKiri3: pattern not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HookParam hp = {};
|
||||||
|
hp.address = addr;
|
||||||
|
hp.offset = pusha_ecx_off -4;
|
||||||
|
hp.index = 0;
|
||||||
|
//hp.split = -4 -4;
|
||||||
|
hp.split = 5 * 4; //arg5
|
||||||
|
hp.split_index = 0;
|
||||||
|
hp.type = USING_UNICODE | USING_STRING | USING_SPLIT;
|
||||||
|
hp.filter_fun = KiriKiri3Filter;
|
||||||
|
ConsoleOutput("vnreng: INSERT KiriKiri3");
|
||||||
|
NewHook(hp, "KiriKiri3");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool InsertKiriKiriHook() // 9/20/2014 jichi: change return type to bool
|
bool InsertKiriKiriHook() // 9/20/2014 jichi: change return type to bool
|
||||||
{
|
{
|
||||||
bool k1 = FindKiriKiriHook((DWORD)GetGlyphOutlineW, processStopAddress - processStartAddress, processStartAddress, 0), // KiriKiri1
|
bool k1 = FindKiriKiriHook((DWORD)GetGlyphOutlineW, processStopAddress - processStartAddress, processStartAddress, 0), // KiriKiri1
|
||||||
k2 = FindKiriKiriHook((DWORD)GetTextExtentPoint32W, processStopAddress - processStartAddress, processStartAddress, 1); // KiriKiri2
|
k2 = FindKiriKiriHook((DWORD)GetTextExtentPoint32W, processStopAddress - processStartAddress, processStartAddress, 1), // KiriKiri2
|
||||||
|
k3 = InsertKiriKiri3Hook(); // KiriKiri3
|
||||||
//RegisterEngineType(ENGINE_KIRIKIRI);
|
//RegisterEngineType(ENGINE_KIRIKIRI);
|
||||||
if (k1 && k2) {
|
if (k1 && k2) {
|
||||||
ConsoleOutput("vnreng:KiriKiri1: disable GDI hooks");
|
ConsoleOutput("vnreng:KiriKiri1: disable GDI hooks");
|
||||||
|
|
||||||
}
|
}
|
||||||
return k1 || k2;
|
return k1 || k2 || k3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 10/20/2014 jichi: KAGParser
|
/** 10/20/2014 jichi: KAGParser
|
||||||
|
Loading…
Reference in New Issue
Block a user