I am going crazy over this.
I've had it working in the past (many patches ago) but coming back to it can't get it to work.
Code:
typedef HRESULT (_stdcall *m_D3D_EndScene) (IDirect3DDevice9 *Device);
m_D3D_EndScene m_ofEndScene;
Direct3D9__Device = 0xABF47C, // 4.3.4_15595
Direct3D9__Device__OffsetA = 0x2800, // 4.3.4_15595
Direct3D9__Device__OffsetB = 0xA8, // 4.3.4_15595
HRESULT _stdcall MyEndScene(IDirect3DDevice9 *Device)
{
return 0;
}
void applyHook(DWORD baseAddress)
{
DWORD D3D9_Device;
D3D9_Device = readMem<DWORD>(baseAddress + Direct3D9__Device);
D3D9_Device = readMem<DWORD>(D3D9_Device + Direct3D9__Device__OffsetA);
D3D9_Device = readMem<DWORD>(D3D9_Device);
D3D9_Device = readMem<DWORD>(D3D9_Device + Direct3D9__Device__OffsetB);
m_ofEndScene = (m_D3D_EndScene)DetourFunction((PBYTE)D3D9_Device, (PBYTE)MyEndScene);
}
I would expect a black screen (as I'm not calling original function from mine, but am instead getting a crash, any help would be appreciated.
EDIT :
I have obtained the same pointer from creating a new window, obtaining the device and using the VTable, so I'm fairly confident my pointer is good. I've also tried using ms detours 1.5 and 3 with no success.
So is it something wrong with my function?
Code:
HRESULT _stdcall MyEndScene(IDirect3DDevice9* Device)
If I understand correctly it's really a thiscall, but a thiscall works by passing 'this' on ecx, where stdcall passes the first param on ecx, so that should work?