DLL Search order

  • Thread starter Thread starter Sasha
  • Start date Start date
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?
 
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
 
Back
Top