Basically what I want to do is force a closed source application which uses a Direct3D9Ex
context (CreateD3D9Ex)
but a simple "non-ex" device (IDirect3DDevice9)
to use a Direct3DDevice9Ex
instead.
I placed a proxy dll inside the application directory which in general works fine. Now I am trying to redirect the call for CreateDevice
to the original dll's CreateDeviceEx
and then just return a "non-ex" pointer (so that the application uses an "Ex" device without knowing about it).
To my understanding this should work because the "Ex" device implements all methods the "non-ex" device also contains - but apparently there must be some difference, because the only thing which gets rendered if the hidden "Ex" device is in use is the cursor.
Q: Could somebody tell me what I am doing wrong or give some advice?
Background
I am using a D3D9
application of which I want to copy the depth buffer. Unfortunately its format is D24S8
which implicates that a direct copy is impossible.
So I decided to try if it is possible to create a shared depth/stencil 1-level texture and then access this texture with the D3D10/D3D11
methods that are in fact capable of copying depth/stencil surfaces. However, only D3D9Ex
devices are able to create textures with shared handles...
Appendix
Due to the fact Direct3D9Ex does not support the managed pool it is not possible. Thanks @VuVirt
I think the problem is mainly caused by the fact that the D3D9Ex device doesn't support D3DPOOL_MANAGED resources. That's the reason why you don't see anything rendered on the screen. The resource creation with D3DPOOL_MANAGED will actually fail. You may want to hook all the resource creation routines as well and remove the D3DPOOL_MANAGED flag from the calls and optionally add D3DUSAGE_DYNAMIC if someone wants to Lock them. This however, might cause another set of problems. Search for "Differences between Direct3D 9 and Direct3D 9Ex" in the provided MSDN links.