add d3dx hooks

This commit is contained in:
Akash Mozumdar 2019-01-27 03:04:16 -05:00
parent 7e4cc13bcf
commit b873ecbc96
3 changed files with 52 additions and 0 deletions

View File

@ -84,6 +84,11 @@ bool DeterminePCEngine()
// return true; // return true;
//} //}
for (std::wstring DXVersion : { L"d3dx9", L"d3dx10" })
if (HMODULE module = GetModuleHandleW(DXVersion.c_str())) PcHooks::hookD3DXFunctions(module);
else for (int i = 0; i < 50; ++i)
if (HMODULE module = GetModuleHandleW((DXVersion + L"_" + std::to_wstring(i)).c_str())) PcHooks::hookD3DXFunctions(module);
if (GetProcAddress((HMODULE)processStartAddress, "?Write@String@v8@@QBEHPAGHHH@Z")) if (GetProcAddress((HMODULE)processStartAddress, "?Write@String@v8@@QBEHPAGHHH@Z"))
InsertV8Hook((HMODULE)processStartAddress); InsertV8Hook((HMODULE)processStartAddress);
if (HMODULE module = GetModuleHandleW(L"node.dll")) if (HMODULE module = GetModuleHandleW(L"node.dll"))

View File

@ -153,6 +153,52 @@ void PcHooks::hookGDIPlusFunctions()
NEW_MODULE_HOOK(hModule, GdipMeasureDriverString, s_arg1, 0,s_arg3,0, USING_UNICODE|USING_STRING, s_arg2 / arg_sz) NEW_MODULE_HOOK(hModule, GdipMeasureDriverString, s_arg1, 0,s_arg3,0, USING_UNICODE|USING_STRING, s_arg2 / arg_sz)
} }
bool PcHooks::hookD3DXFunctions(HMODULE d3dxModule)
{
ConsoleOutput("Textractor: inserting Direct3D hooks (EXPERIMENTAL)");
uintptr_t createFont = (uintptr_t)GetProcAddress(d3dxModule, "D3DXCreateFontIndirectA");
if (!createFont) createFont = (uintptr_t)GetProcAddress(d3dxModule, "D3DX10CreateFontIndirectA");
if (!createFont)
{
ConsoleOutput("Textractor: D3DX failed: couldn't find entry function");
return false;
}
struct D3DXFont
{
uintptr_t(*vtable)[20];
DWORD data[2000];
} font;
for (int i = 0, calls = 0; i < 100; ++i)
{
if (*(BYTE*)(createFont + i) == 0xe8) ++calls;
if (calls == 2)
{
union
{
void(D3DXFont::*ctor)();
uintptr_t addr;
} fuckTheTypeSystem;
fuckTheTypeSystem.addr = *(uintptr_t*)(createFont + i + 1) + createFont + i + 5;
(font.*(fuckTheTypeSystem.ctor))();
HookParam hp = {};
hp.address = (*font.vtable)[14];
hp.offset = s_arg3;
hp.length_offset = s_arg4 / arg_sz;
hp.type = USING_STRING;
NewHook(hp, "ID3DXFont::DrawTextA");
hp.address = (*font.vtable)[15];
hp.type = USING_STRING | USING_UNICODE;
NewHook(hp, "ID3DXFont::DrawTextW");
return true;
}
}
ConsoleOutput("Textractor: D3DX failed: couldn't find vtable");
return false;
}
// jichi 10/2/2013 // jichi 10/2/2013
// Note: All functions does not have NO_CONTEXT attribute and will be filtered. // Note: All functions does not have NO_CONTEXT attribute and will be filtered.
void PcHooks::hookOtherPcFunctions() void PcHooks::hookOtherPcFunctions()

View File

@ -7,6 +7,7 @@ namespace PcHooks {
void hookGDIFunctions(); void hookGDIFunctions();
void hookGDIPlusFunctions(); void hookGDIPlusFunctions();
void hookD3DXFunctions(HMODULE d3dxModule);
void hookOtherPcFunctions(); void hookOtherPcFunctions();
} // namespace PcHooks } // namespace PcHooks