headedtomexico 0 Junior Poster in Training

Is there a way to detour a class method to a static function by passing the implicit "this" manually?

I'm specifically trying to detour endscene, i've done it with a class member, and writing the address to the new class member into the vtable, but i'm trying to see if I can get it to work with static functions. I've tried finding info on various resources, but stuff this low always seems to be poorly documented (or i'm just looking in the wrong place).

I may be describing this wrong, but it would be something like this:

HRESULT __stdcall Trampoline_EndScene(IDirect3DDevice9*); 

HRESULT __stdcall Detour_EndScene(IDirect3DDevice9 * This) 
{ 
    return Trampoline_EndScene(This); 
} 

void Enter() 
{ 
    MyDetour(&HookedD3DDevice9->lpVtbl->EndScene, &Detour_EndScene, &Trampoline_EndScene);
} 

void Exit() 
{ 
    MyDetourRemove(&HookedDevice->lpVtbl->EndScene); 
}

I'm really curious how this all works...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.