Hi,
I'm trying to make some midfunction hooks for a game, specifically for EndScene, DrawIndexedPrimitive and SetTexture, but I'm having problems with some stuff and I hope you guys can help me pinpoint the problem (I'm really new hooks/hacks/directX etc. but I'm a quick learner and hopefully I can start contributing soon). I already asked this question at other forums, but couldn't get an answer.
Let me start by saying that most of the code is not mine. I collected it from several sources and added some stuff of my own.
I have Win7 x64 here and Visual Studio 2010.
Here is my code:
[C++] D3D Midfunction hooks - Pastebin.com
Basically I have two problems.
1.) When I rewrite the old opcodes to the previously hooked address of DrawIndexedPrimitive and call it, it doesn't do anything. See lines 102-106. I would expect it to render everything first as solid and then as a wireframe on top of the solid, but instead it only renders them as wireframe.
2.) MySetTexture never gets called. Line 129 is never reached.
Things I have tried:
@1.)
- Print opcodes at dwDrawIndexedPrimitive_hook to check if they are what they should be (they were).
@2.)
- Call SetTexture myself.
- Reduce the prologue and epilogue to a bare minimum.
- Look at the opcodes in OllyDbg and print them in my code.
- Set breakpoints in SetTexture in OllyDbg to see if it holds. It didn't.
- Replace the whole SetTexture function with NOPs in OllyDbg. The game still ran perfectly fine.
@1&2.)
- Print addresses of IDirect3DDevice9::DrawIndexedPrimitive and ::SetTexture (Got totally new stuff that I couldn't relate to anything else)
- Extensively research all the sources I could find on the topic.
- Try and trace the flow in OllyDbg to see WHAT does get called when I call those functions (I failed, I couldn't look at the asm of my own code, because it wasnt in the scope of the game)
I'm especially interested in a solution to #1, because frankly it renders the hook useless for me, if I can't call the original function at will.
Not to sound like a noob, but PLX PLX PLX H3LP M3 PLX!!!111
If it's of any relevance I will upload my d3d9.dll.