How to tell when a dll is loaded
I have some c++ code that loads debug symbols on Windows the first time its called, but (obviously) delay loaded dlls aren't being picked up if they're loaded after the first time the c开发者_如何学编程ode is hit. Its not feasible for me to reload the symbols every time my routine is hit, so I was hoping there was some sort of callback where I could be notified if a dll is delay loaded.
This is possible, you can write your own delay load helper function instead of using the default one. Not much point in going into detail in this question, it is well explained in the MSDN Library. The starting page is here, things get interesting at "Understanding the helper function" section.
Well, you have two ways of catching mostly everything (mostly cause this won't get manually mapped files), you can place a system wide hook on LoadLibraryA\W
and LoadLibraryEx
(or the kernel mapping and PEB linking functions from Ldr*) and check if the calling process matches your process. Else, you can make your program attach to itsself and wait for the dll load debug event: http://msdn.microsoft.com/en-us/library/ms679302(v=vs.85).aspx
Maybe you're looking for Debugging Events http://msdn.microsoft.com/en-us/library/ms679302(v=VS.85).aspx
Seems like you're looking for LOAD_DLL_DEBUG_EVENT.
Your question doesn't seem to be very cleary. But still I assume that what you're looking for is DllMain()
. Its the entry point of DLL. Read the documentation for details.
And since you're talking about delay load, maybe you need to look at LoadLibraryEx()
as well. Its used to load DLL into the proccess memory.
精彩评论