I want to do some custom gui drawing and was trying to do that in my endscene detour hook.
I dont have the dx device pointer, so i tried to grab it in my hook like this (my hooks are using __declspec(naked) __stdcall so i just grab the calling params from the stack by declaring some extra params);
Half - pseudo code;
IDirect3DDevice9* d3ddev = null;
DWORD __declspec(naked) __stdcall EndSceneHook(void* returnAdress, void* dev)
{
save flags and registers ...
d3ddev = (IDirect3DDevice9*) dev;
d3ddev->SetRenderState(...);
restore flags and regs...
}
Code crashes when calling any methods with d3ddev, like d3ddev ->SetFVF() and so on.
d3ddev gets a fairly decent value, which happens to be the same as [[0x0123E908]+0x397C] (for 3.2.0a) which first bytes is pointer to the device functiontable, so it seems to be some object of any kind, and i thought it was the device...
Anyone knows what Im doing wrong here? like if it is IDirect3DDevice9** that is passed to endscene() calls or something like that. It would be great to know if its something very obvious before i rewrite and hook CreateDevice at startup in order to get the device, since Im lazy
Thanks in advance