Re: OT: searching for DLL in current directory?
On Thu, 12 Jul 2007 09:53:04 -0700, "void.no.spam.com@gmail.com"
<void.no.spam.com@gmail.com> wrote:
Yeah, that's actually why I'm wondering about it. Because I'm running
Windows 2000 SP4, which has that SafeDllSearchMode setting disabled by
default, and I'd like to enable it to gain the security benefit. But
I want to be sure that enabling it won't break any applications that I
have.
So would it ever be possible for an application to need to load a DLL
from a directory that is not one of the following: the application
directory, system directory, system32 directory, Windows directory, or
any directory in the PATH env. var?
One thing I've learned from reading Raymond's blog is that Windows programs
explore all possibilities. :)
Is the current directory
necessary because if a DLL resides in a subdirectory of one of those
directories, then the application needs to change its current
directory to the subdirectory before the DLL can be loaded?
From the blog entry, some programs do this:
SetCurrentDirectory("somewhere");
LoadLibrary("somelibrary.dll");
I wouldn't do it, and you wouldn't do it, but somebody did it.
(Unfortunately, Raymond doesn't like to name names.) Of course, this is
unnecessary given that if you can set the current directory, you can
construct an absolute path as well, but I guess some people figured, "Why
not take advantage of the documented search algorithm instead of
reinventing it?"
--
Doug Harrison
Visual C++ MVP