Find D3D device pointer programmaticaly?

Posts 1–5 of 5 · Page 1 of 1
Find D3D device pointer programmaticaly?
Hey! How can i find the D3D device pointer (which is stored in memory, and can be found with Olly easily) programmaticaly?
I already tried with creating a new device and grabbing his address.. But I always get a dynamic address, and not the real pointer :S

So how to find it? Is it even possible to get it programmaticaly?

mac
Quote Originally Posted by meldino View Post
Hey! How can i find the D3D device pointer (which is stored in memory, and can be found with Olly easily) programmaticaly?
I already tried with creating a new device and grabbing his address.. But I always get a dynamic address, and not the real pointer :S

So how to find it? Is it even possible to get it programmaticaly?

mac
Very much is this possible. The member functions of the class actually take the pointer as the first argument. So in reality this:

Code:
HRESULT DrawIndexedPrimitive(
  [in]  D3DPRIMITIVETYPE Type,
  [in]  INT BaseVertexIndex,
  [in]  UINT MinIndex,
  [in]  UINT NumVertices,
  [in]  UINT StartIndex,
  [in]  UINT PrimitiveCount
);
Is actually:

Code:
HRESULT DrawIndexedPrimitive(
  [in]  LPDIRECT3DDEVICE9 D3DDevice,
  [in]  D3DPRIMITIVETYPE Type,
  [in]  INT BaseVertexIndex,
  [in]  UINT MinIndex,
  [in]  UINT NumVertices,
  [in]  UINT StartIndex,
  [in]  UINT PrimitiveCount
);
So hook any member function of IDirect3DDevice9 in d3d9.dll and you will get the D3D Device pointer.
Code:
DWORD** FindDevice(DWORD base, DWORD len)
{
	unsigned long i = 0, n = 0;

	for( i = 0; i < len-0xD; i++ )
	{
		if(*(BYTE *)(base+i+0x00)==0xC7)
			n++;
		if(*(BYTE *)(base+i+0x01)==0x06)
			n++;
		if(*(BYTE *)(base+i+0x06)==0x89)
			n++;
	    	if(*(BYTE *)(base+i+0x07)==0x86)
			n++;
	        if(*(BYTE *)(base+i+0x0C)==0x89)
			n++;
		if(*(BYTE *)(base+i+0x0D)==0x86)
			n++;

		if(n == 6)
		{ 
			return (DWORD**)(base + i + 2);
		}
		n = 0;
	}
	return NULL;
}
Call it with d3d9.dll's address until address + length
Got it already Hooked endscene and logged the pointer
nvm, ty guys!
Quote Originally Posted by meldino View Post
Got it already Hooked endscene and logged the pointer
nvm, ty guys!
The pointer will change no?
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us