Jump to content
  • Advertisement
Sign in to follow this  
roby65

Direct3D 9 hooking

This topic is 3991 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

I need help :D i made a dll that gets injected as soon as a game starts, and then hooks the Direct3DCreate9 function from the import library with apihook, but seems not working :S here the code:
void myDirect3DCreate9(int version)
{
	fprintf(file,"myDirect3DCreate9(%d) called\r\n",version);
}
DllMain:
bool APIENTRY DllMain( HMODULE hModule, DWORD fdwReason, LPVOID lpvReserved )
{
	switch (fdwReason)

    {

      case DLL_PROCESS_ATTACH:
		hDll=hModule;
		file=fopen("debug.txt","w");
		fprintf(file,"Dll attached\r\n");
		hThread=CreateThread(0,0,(LPTHREAD_START_ROUTINE)hack,0,0,0);
		InitColors(); //change some cool colors :D
		//removeSplashScreen();
		//hook
		DisableThreadLibraryCalls( hModule );
		HookAPICalls( &D3DHook );
		//
        break;

 

      case DLL_PROCESS_DETACH:
		fprintf(file,"Dll detached\r\n");
		if(TerminateThread(hThread,0)&&file)
		fprintf(file,"Thread terminated\r\n");
		fclose(file);
        break;

 

      case DLL_THREAD_ATTACH:

        break;

 

      case DLL_THREAD_DETACH:

        break;

    }
    return TRUE;
}
this should work!!!! :-( EDIT: Please remember 'source' tags in future! [Edited by - jollyjeffers on August 12, 2007 1:28:21 PM]

Share this post


Link to post
Share on other sites
Advertisement
"seems not working" doesn't help us to help you. You need to provide a better description of errors, environment, results from debugging etc...

You might want to refer to [C++] Direct3D hooking sample. As far as I'm aware MH's code worked fine so you can compare it with yours and see where it differs...

hth
Jack

Share this post


Link to post
Share on other sites
i think the problem is that the game loads the d3d9.dll using loadlibrary, so i can't hook import functions...

ps:what debugger do you sugger me?
i need to find where the game calls direct3dcreate9!

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!