Jump to content
  • Advertisement
Sign in to follow this  

Direct draw create hook

Recommended Posts

Hello folks! I created my own ddraw.dll and FakeDirectDrawCreate() func. When I tried to get IID_IDirectDrawSurface3 pointer my app don't work. What is the problem? Thanks in advance.

__declspec(dllexport) HRESULT WINAPI  FakeDirectDrawCreate(GUID FAR *lpGUID, LPVOID *lplpDD, IUnknown FAR *pUnkOuter )
	DirectDrawCreate_Type OldFn = (DirectDrawCreate_Type)ddraw.DirectDrawCreate;
	HRESULT hr = OldFn( lpGUID, lplpDD, pUnkOuter );
	*lplpDD =(LPDIRECTDRAW) new MyDirectDraw((LPDIRECTDRAW)*lplpDD);

	return hr;

//MyDirectDraw class
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObj)
	m_device->QueryInterface(riid, ppvObj);

	if (riid==IID_IDirectDraw2)
		*ppvObj =(LPDIRECTDRAW2) new MyDirectDraw2((LPDIRECTDRAW2)*ppvObj);
	return S_OK;

//MyDirectDraw class
	IUnknown FAR *pUnkOuter)

	m_device2->CreateSurface(lpDDSurfaceDesc2, lplpDDSurface,  pUnkOuter   ); 
	*lplpDDSurface =(LPDIRECTDRAWSURFACE) new MyDirectDrawSurface((LPDIRECTDRAW2)m_device2, *lplpDDSurface);


//MyDirectDrawSurface class
HRESULT STDMETHODCALLTYPE QueryInterface ( REFIID riid, void** ppvObj)

	else if(riid==IID_IDirectDrawSurface3)
		*ppvObj =(LPDIRECTDRAWSURFACE3) new MyDirectDrawSurface3((LPDIRECTDRAW2)m_device, (LPDIRECTDRAWSURFACE3)*ppvObj);
class MyDirectDraw :  public IDirectDraw
class MyDirectDraw2 :  public IDirectDraw2
class MyDirectDrawSurface : public IDirectDrawSurface
class MyDirectDrawSurface3 : public IDirectDrawSurface3


Edited by kurlyak

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  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!