DWORD dwOriginal = 0x0;
__declspec(naked) void hook()
{
__asm pushad
__asm pushfd
Log("work");
__asm popfd
__asm popad
__asm jmp[dwOriginal]
}
void init()
{
Log("init");
while ((*(IDirect3DDevice9 **)0xC97C28) == nullptr)
Sleep(100);
IDirect3DDevice9 *Device = *(IDirect3DDevice9 **)0xC97C28;
Log("%X", Device);
DWORD *VTable = (DWORD *)*(DWORD *)Device;
Log("%X", VTable);
MEMORY_BASIC_INFORMATION mbi;
VirtualQuery((LPCVOID)VTable, &mbi, sizeof(mbi));
VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &mbi.Protect);
Log("Start hook.");
dwOriginal = VTable[17];
VTable[17] = (DWORD)hook;
Log("Finish hook.");
VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &mbi.Protect);
}