Home > database >  How to prevent DLL from loading other standard DLLs?
How to prevent DLL from loading other standard DLLs?

Time:07-15

I was experimenting with DLL injection via CreateRemoteThread() (see my image

CodePudding user response:

The C runtime needs those DLLs and they're probably automatically mapped by the PE loader, not dynamically loaded. If you had written your code in assembly, those wouldn't have been loaded. You could perhaps strip C runtime completely with compiler/linker settings, but your capabilities in C would get significantly reduced.

CodePudding user response:

An option for cases where you only occasionally rely on a particular library is to treat it as delay-loaded.

In Visual Studio, this setting is found in the project properties window under Linker -> Input.

So, for example, if you expect to only sometimes call something from user32.dll you could add "user32.dll" to the Delay Loaded DLLs line (note that this does take .dll not .lib as for input libraries).

  • Related