{"id":38583,"date":"2004-07-02T07:00:00","date_gmt":"2004-07-02T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/07\/02\/dont-name-your-dll-security-dll\/"},"modified":"2004-07-02T07:00:00","modified_gmt":"2004-07-02T07:00:00","slug":"dont-name-your-dll-security-dll","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040702-00\/?p=38583","title":{"rendered":"Don&#039;t name your DLL &quot;Security.dll&quot;"},"content":{"rendered":"<p>Reaching back into the history bucket&#8230;\n  Some people have discovered  <a href=\"http:\/\/weblogs.asp.net\/sjoseph\/archive\/2004\/01\/22\/62085.aspx\">  that strange things happen if you name your DLL &#8220;security.dll&#8221;<\/a>.\n  The reason is that there is already a system DLL called &#8220;security.dll&#8221;;  it&#8217;s the   <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/security\/security\/sspi.asp\">  Security Support Provider Interface<\/a> DLL,  and it used to go by the name &#8220;security.dll&#8221;, though nowadays  the name &#8220;secur32.dll&#8221; is preferred.  If you look into your system32 directory, you&#8217;ll see both  &#8220;security.dll&#8221; and &#8220;secur32.dll&#8221; in there.  And if you&#8217;re handy with an export dumper, you&#8217;ll see that &#8220;security.dll&#8221;  is just a bunch of forwarders to &#8220;secur32.dll&#8221;.  If you browse through the MSDN documentation, you&#8217;ll see that everybody  talks about &#8220;secur32.dll&#8221; and hardly any mention is made of its  doppelg&auml;nger &#8220;security.dll&#8221;.\n  Okay, here&#8217;s where the history comes in.  Wind back to Windows&nbsp;95.\n  Back in those days, the  Security Support Provider Interface was implemented in two different DLLs.  The one you wanted depended on whether you are running  Windows&nbsp;NT or Windows&nbsp;95.  On Windows&nbsp;95, it was called &#8220;secur32.dll&#8221;, but on Windows&nbsp;NT,  it was called &#8220;security.dll&#8221;.\n  This was obviously a messed-up state of affairs, so the Windows&nbsp;NT  folks decided to &#8220;go with the flow&#8221; and rename their security DLL to  &#8220;secur32.dll&#8221;.  This was probably for application compatibility reasons:  Applications that were written to run on Windows&nbsp;95 and were never  tested on Windows&nbsp;NT just went straight for &#8220;secur32.dll&#8221; instead of  loading the correct DLL based on the operating system.\n  Okay, so now pop back to the present day.  When you put a DLL called &#8220;Security.dll&#8221; in your application directory,  what happens?\n  Recall that  <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/dllproc\/base\/loadlibrary.asp\">  the rules for the order in which DLLs are searched for<\/a> checks  the application directory before it checks the system directory.  As a result, anybody in your application  who wants &#8220;Security.dll&#8221; will get your version  instead of the system version.\n  Even if the system version is the one they really wanted.\n  That&#8217;s why overriding the system&#8217;s Security.dll with your own  results in a bunch of SSPI errors.  Components you are using in your  program are trying to talk to SPPI by loading &#8220;security.dll&#8221; and  instead of getting the system one, they get yours.  But yours was never meant to be a replacement for &#8220;security.dll&#8221;;  it&#8217;s just some random DLL that happens to have the same name.<\/p>\n<p>  You would have had the same problem if you happened to name your DLL  something like &#8220;DDRAW.DLL&#8221; and some component in your program tried  to create a DirectDraw surface.  &#8220;Security.dll&#8221; has the disadvantage that it has a simple name  (which people are likely to want to name their own DLL), and its  importance to proper system functionality is not well-known.  (Whereas it would be more obvious that creating a DLL called  &#8220;kernel32.dll&#8221; and putting it in your application directory is going  to cause nothing but trouble.)  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reaching back into the history bucket&#8230; Some people have discovered that strange things happen if you name your DLL &#8220;security.dll&#8221;. The reason is that there is already a system DLL called &#8220;security.dll&#8221;; it&#8217;s the Security Support Provider Interface DLL, and it used to go by the name &#8220;security.dll&#8221;, though nowadays the name &#8220;secur32.dll&#8221; is preferred. [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2],"class_list":["post-38583","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Reaching back into the history bucket&#8230; Some people have discovered that strange things happen if you name your DLL &#8220;security.dll&#8221;. The reason is that there is already a system DLL called &#8220;security.dll&#8221;; it&#8217;s the Security Support Provider Interface DLL, and it used to go by the name &#8220;security.dll&#8221;, though nowadays the name &#8220;secur32.dll&#8221; is preferred. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/38583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=38583"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/38583\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=38583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=38583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=38583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}