Sign in to follow this  

Reversing and injecting some D3D9 code

Recommended Posts

Hello !

 

First, thanks for this forum, as I got my answers here very often.

 

I'm trying to make some graphic modifications to an old 2D game, and because the .exe is not easily reverse-engineerable (nor the game data file) I succeeded by creating a d3d9.dll proxy.

 

The modifications were simple so far (removing some elements, adjusting screen size), I've done that by hooking the SetViewport function and the DrawIndexedPrimitiveUP (and checking textures of elements I wanted to remove).

 

Now what I wanted is to rotate some letters elements (drew by a DrawPrimitiveUP call).

I tried SetTransform methods with no luck.

 

Checking when letters are drawn gives this inside PIX:

 

FxAsTD1.jpg

 

I think I read somewhere that using a vertex shader may avoid SetTransform to work ? Is this correct ?

So I thought that I could create a new VertexShader that is the same as the disassembled one (as it is not too complex, I think I can do that) that also adds the rotation, and applying it in a proxy DrawPrimitiveUP method before drawing the letter.

 

Am I going in the right direction ?

How should I override the VertexShader ?

 

I've never done this before (directx programming, custom dll injection), so I'm maybe missing something obvious here.

 

Thanks for any help !

Share this post


Link to post
Share on other sites

Last question:

I want to get the D3DCOLOR_ARGB value in the "mesh" tab of PIX (here FF00DCFF):

 

Ej1WYN6.png

 

Knowing that the Vertex Declaration is this :

 

ugsDD07.png

I tried to do something like this but cannot to get the correct color value in the DrawPrimitiveUP proxy function:

HRESULT myIDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
	char buff[256];
        unsigned int color = 0;
	if (PrimitiveCount == 2 && VertexStreamZeroStride == 24) {
                // [0], [1], [2] are the floats, [3] is the color
                color = ((unsigned int *)pVertexStreamZeroData)[3] & 0xFFFFFF00 >> 8; // removing alpha value
		sprintf_s(buff, "color:  hex:%08x - int:%u", color, color);
		DEBUG_LOG(buff);
	}
        ... etc ...

Can this work that way ? Thanks !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this