Sign in to follow this  
roby65

Direct3D 9 hooking

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
"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

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