Check your DLL search mode

Check your DLL search mode

As many of you know, most large Windows applications rely on libraries of shared code to make life a lot simpler for developers and to use system resources a lot more efficiently. There's no reason for each application on your system to use up hard drive space on its own copy of common code. And if you want to upgrade that piece of code, you don't want to do it individually for 50 different applications. So most of this shared code lives in .dll files, where DLL stands for Dynamic Link Libraries.

The trick to DLLs is that they can be in any directory, even though, as you probably noticed, most of them are in /system32. Thus, if two DLLs exist in separate directories, Windows needs a way to determine which one to use. By default, Windows searches the application's directory, then the current directory, then the system directory, and then it uses your path statement in that order to make this determination.

This makes it theoretically possible for someone to write his or her own DLL to do something evil, give it the same name as a DLL in the system directory, and place it in the current directory. (Hopefully, such persons don't have rights to the system directories.) Then, when you run your application, you inadvertently execute the malicious code.

As of SP1 on Windows XP, this order is changed to the application directory, then the system directory, then the current directory, then the path. This slightly reduces the exposure to this type of

    Requires Free Membership to View

    When you register, you’ll also receive targeted alerts from my team of editorial writers and independent industry experts with the latest news, tips, and advice to help you do your job more efficiently and effectively. Our goal is to keep you informed on the hottest topics and biggest challenges faced by IT professionals today working with desktop management and security technologies.

    Cathleen A. Gagne, Senior Editorial Director

    By submitting your registration information to SearchEnterpriseDesktop.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchEnterpriseDesktop.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

attack. However, if you're running something prior to SP1 on XP, you may be able to change this behavior with the following Registry Edit

HKLMSystemCurrentControlSetControlSession ManagerSafeDllSearchMode = 1

As usual, registry editing is not for the faint of heart, and can completely hose your system if you make a mistake. Always back up your registry and entire system before messing with it.


Thomas Alexander Lancaster IV is a consultant and author with over ten years experience in the networking industry, focused on Internet infrastructure.


This was first published in April 2003

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.