x64 v8/javascript/tyranobuilder hook

This commit is contained in:
Akash Mozumdar 2019-06-27 12:41:15 +05:30
parent f87da8aedf
commit 68c65bbea6
2 changed files with 37 additions and 2 deletions

View File

@ -66,11 +66,21 @@ bool DeterminePCEngine()
if (HMODULE module = GetModuleHandleW((DXVersion + L"_" + std::to_wstring(i)).c_str())) PcHooks::hookD3DXFunctions(module);
if (GetProcAddress((HMODULE)processStartAddress, "?Write@String@v8@@QBEHPAGHHH@Z"))
{
InsertV8Hook((HMODULE)processStartAddress);
return true;
}
if (HMODULE module = GetModuleHandleW(L"node.dll"))
{
InsertV8Hook(module);
return true;
}
if (HMODULE module = GetModuleHandleW(L"nw.dll"))
{
InsertV8Hook(module);
return true;
}
if (InsertMonoHooks()) {
return true;

View File

@ -90,7 +90,7 @@ namespace Engine
HookParam hp = {};
hp.address = addr;
hp.type = USING_STRING | USING_UNICODE;
hp.offset = -0x20;
hp.offset = -0x20; // rcx
hp.padding = 20;
hp.length_fun = [](uintptr_t, uintptr_t data)
{
@ -115,10 +115,35 @@ namespace Engine
return ret;
}
// Artikash 6/23/2019: V8 (JavaScript runtime) has rcx = string** at v8::String::Write
// sample game https://www.freem.ne.jp/dl/win/18963
bool InsertV8Hook(HMODULE module)
{
if (uint64_t addr = (uint64_t)GetProcAddress(module, "?Write@String@v8@@QEBAHPEAGHHH@Z"))
{
HookParam hp = {};
hp.type = USING_STRING | USING_UNICODE | DATA_INDIRECT;
hp.address = addr;
hp.offset = -0x20; // rcx
hp.index = 0;
hp.padding = 23;
hp.length_fun = [](uintptr_t, uintptr_t data)
{
int len = *(int*)(data - 4);
return len > 0 && len < 1000 ? len * 2 : 0;
};
NewHook(hp, "JavaScript");
return true;
}
return false;
}
bool UnsafeDetermineEngineType()
{
if (Util::CheckFile(L"PPSSPP*.exe") && FindPPSSPP()) return true;
for (const wchar_t* moduleName : { (const wchar_t*)NULL, L"node.dll", L"nw.dll" }) if (InsertV8Hook(GetModuleHandleW(moduleName))) return true;
for (const wchar_t* monoName : { L"mono", L"mono-2.0-bdwgc" }) if (HMODULE module = GetModuleHandleW(monoName)) if (InsertMonoHooks(module)) return true;
for (std::wstring DXVersion : { L"d3dx9", L"d3dx10" })