DLL Injection

s0beit s0beit at myg0t.com
Mon Dec 3 08:37:37 PST 2012


On Monday, 3 December 2012 at 11:08:34 UTC, maarten van damme 
wrote:
> Strangely, the main in my dll is getting executed multiple 
> times and
> msvcr71.dll gets injected too. Is this normal?

mcvcr71.dll is probably loaded by your library, I don't know if D 
uses visual studio dependencies... one would think not... What 
are you injecting into?

Your DLL should only be executed once, I would go as far as to 
say it's impossible that it's being executed multiple times 
because calling LoadLibrary multiple times will not invoke the 
DLL_PROCESS_ATTACH action multiple times, after the initial load 
it will only return the pre-existing handle.

Are you making sure to check if the "dwReason" in DllMain is 
DLL_PROCESS_ATTACH? If you aren't, it will seem like it's being 
called multiple times when new threads are created.


More information about the Digitalmars-d-learn mailing list