Advertisement Jump to content
Sign in to follow this  

Hook D3D9.DLL when loaded by another DLL

This topic is 3262 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 followed this thread: To try and hook D3D9.DLL. It turns out that the hl2.exe I'm trying to hook doesn't load D3D9, but one of its dependencies, shaderapidx9.dll, has it in its import table. No, I'm not trying to make a hack. The engine is limited in many areas and I'd like to get a hold of the ID3DDevice9 that it's using so I can make some surfaces with the formats that I need for my custom shaders. Since my client.dll (which is used for making mods, and the source code is public) is loaded by hl2.exe after shaderapidx.dll has been loaded, I think it's already gotten the ID3DDevice9 because the wrapper function never gets called. I did make sure to use GetModuleHandle( "shaderapidx9.dll" ) instead of GetModuleHandle(0) which is indeed allowing it to find Direct3DCreate9 and seems to be patching the table. Is there a way to get my DLL to load right after shaderapidx9.dll before it does anything? The only other thing I can think of is to hook the GetProcAddress function as well, so I can trap when shaderapidx9.dll is getting loaded... but even then I don't think there's a way to do something like CREATE_SUSPENDED. Especially since I assume DllMain is supposed to run on the same thread as that calling GetProcAddress. Is there a way to load a library and delay calling DllMain? Edit: Might as well point out that I'm not using DLL injection or anything, my DLL is part of the game and is loaded by the engine by default. [Edited by - coder0xff on February 14, 2010 2:44:25 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!