Jump to content
  • Advertisement
Sign in to follow this  
vika

Reversing and injecting some D3D9 code

This topic is 667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

I guess you could hook the dx function they use to set uniform variables (transformation) and change the transformation matrix to yours.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!