Sign in to follow this  
coder0xff

Hook D3D9.DLL when loaded by another DLL

Recommended Posts

I followed this thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=359794&PageSize=25&WhichPage=1 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

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