Jump to content
  • Advertisement
Sign in to follow this  
JasonBaldwin

Unity Hijacking a function in a dll which an exe loads

This topic is 3166 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've been trying to use this direct3d hooking sample to hook irrlicht to get stats about my games rendering. The sample only works if the exe itself loads d3d. In my case i use irrlicht for rendering so my app loads irrlicht which loads d3d9.dll Is there a way that i can modify this code to allow me to get the d3d9 device when an app loads d3d9 through another dll? I've tried plenty of googling but I could'nt find anything... Any help would be appreciated. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Google for IAT hooking (Import Address Table hooking).

The short answer is that suppose you have some exe called A.EXE which import from B.DLL, C.DLL, and D.DLL. Also, B.DLL and C.DLL both independently import from D.DLL. In this case, A.EXE, B.DLL, and C.DLL all have their own independent table that they do lookups through when mapping a function imported from D.DLL to an address that it can use to actually jump to

A robust IAT hooking solution accounts for this by recursively enumerating all possible modules and imports and hooking all of them, not just the one imported by the EXE.


To translate this to your above example, if you only apply an IAT hook to your EXE, you're not hooking irrlicht's copy of the IAT, only your EXEs. Since irrlicht is importing from d3d as well, it also has its own IAT that you need to hook.

Share this post


Link to post
Share on other sites
There shouldn't be any difference - the only thing I can think of is that irrlicht loads d3d9.dll from the Windows directory rather than the current directory for some reason. What does Process Monitor show?

EDIT: Never mind, I thought you were using a proxy DLL for some reason...

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.

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!