All hooks work, except for Reset (D3D9)

Posts 1–7 of 7 · Page 1 of 1
All hooks work, except for Reset (D3D9)
Hi all,

I did a vTable hook, by changing the functions the vTable points to, to my own. Everything is working fine, all hooks are working (Begin/EndScene, DIP, CreateQuery, ...), except for Reset. I hook Reset the same way I do with the rest. I have no clue why it isn't working!

I searched all day and couldn't find a solution, that's why I'm here now . I found out that this might be Windows 8 related? Cause that's the OS I'm using.

Any help is appreciated. Thanks!
Without seeing code not much anyone can do but guess the issues. So here's a quick guess list:

- Are you sure the vtable offset is correct that you are attempting to hook?
- Are you sure the calling convention on your hook callback is correct?
- Are you sure the application/game isn't undoing the Reset hook?
- Are you sure the hook is properly being placed onto the vtable? (i.e. did you debug and confirm the pointer has changed to your function)

As for 'not working', does this mean its never called? Does it crash?
Thanks for the quick reply!

The same for the other hooks. The thing is, the other hooks work just fine, except for this one.
I tried putting the replacing original VTable with new VTable part in a loop, but it didn't change a thing. So I don't think the game is undoing it (and since the other hooks keep on working fine...)

Thanks!
You aren't overwriting Resets pointer in the vtable anywhere in that code..
Oh, I'm sorry. I commented out the reset pointer because it wasn't working and forgot to copy it too. The code actually includes this as well:

newVTable[16] = (DWORD)hReset;

I'm not at home right now, but above the mentioned code I also save the original pointers in oFunction, so that's not the problem either.

My reset function never gets called.
Also, pDevice->TestCooperativeLevel() never returns D3DERR_DEVICELOST. Could this be related?

Thanks
If the device has no reason to call reset it wont get called.

TestCooperativeLevel should return D3DERR_DEVICENOTRESET if the device needs to be reset. If it returns D3DERR_DEVICELOST then the device can't be reset yet since the application hasn't regained focus/control of the device.

Outsideof that, D3DERR_DEVICELOST will be returned from Present if it has lost access to the rendering device. This typically happens with fullscreen games being minimized, the screensaver on the machine starts, etc.
You're probably right. Reset doesn't get called because the game doesn't have to. TestCooperativeLevel() always returns D3D_OK. This leaves me confused though, why the text I'm drawing disappears after a split second after hooking. I thought this was due to the reset hook not working, but apparently it's another reason.

I create my font in BeginScene (if font == NULL).
In EndScene:
Code:
    static DWORD renderState = 0;
    pDevice->GetRenderState( D3DRS_ZFUNC, &renderState );
    pDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );

    //Drawing here

    pDevice->SetRenderState( D3DRS_ZFUNC, renderState );
In Reset I release the font and make it NULL so it gets created again. DrawTextA keeps returning 12 (even when you don't see the text anymore), and font never equals NULL, so I don't see the problem.

Maybe the game draws over my font? But the funny thing is, if I create the font in the beginning of EndScene, and release it at the end, then everything is working fine??

Thanks for your help so far!

Edit:
I'm releasing and recreating the font everytime in BeginScene now. Not that efficient but at least it works. Thanks!
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?