Skip to main content
GameDev.net gamedev.net
🔒 Locked

Direct3D 9 hooking

Started by roby65 Aug 12, 2007 at 11:01 AM 1 replies 1.1k views
Original Post
roby65
roby65
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]
jollyjeffers
jollyjeffers
"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
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
roby65
roby65
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.