DLL Search order

S

Sasha

Hello,
It appears that the dll search order has somehow changed on my system.
When i use either static linking or LoadLibrary, it first searches for
the dll in the \system32 dir instead of the local directory.
Can i modify the search order?
 
G

Guest

Hi,

You are right, no longer is the current directory searched first when
loading DLLs! This change was also made in Windows XP SP1. The default
behavior now is to look in all the system locations first, then the current
directory, and finally any user-defined paths.

The reason this change was made was to mitigate some kinds of trojaning
attacks. An attacker may be able to sneak a bad DLL into your application
directory or a directory that has files associated with your application. The
DLL search order change removes this attack vector.

The SetDllDirectory function modifies the search path used to locate DLLs
for the application. The Syntax and more information on SetDllDirectory
function is available on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setdlldirectory.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top