<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx</link><description>At the end of this blog entry , I mentioned that when I drop a new version of winmm.dll on my machine, I need to reboot it. Cesar Eduardo Barros asked: Why do you have to reboot? Can't you just reopen the application that's using the dll, or restart the</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#174572</link><pubDate>Wed, 07 Jul 2004 01:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:174572</guid><dc:creator>John Sands</dc:creator><description>Am I right in assuming that the OS knows it's the same DLL because it's loaded  from the same location on disk? So a copy of the DLL in another location is treated like another DLL? How does this affect the decision whether to copy shared .NET assemblies into each exe's directory, or put them in a common location, like the GAC?</description></item><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#175135</link><pubDate>Wed, 07 Jul 2004 11:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:175135</guid><dc:creator>Simon</dc:creator><description>Curious on the same topic but somewhat unrelated can't you make it access the DLL's from a shadow volume copy made when the DLL is first accessed.&lt;br&gt;&lt;br&gt;The file is then immediately replacable - you can then make available an API call to notify the system to reload the new DLL for any new processes - once done both the old and new processes are happy until you kill the old ones and restart them with the new DLL...  At which point the system is in a similar state to if it was restarted.</description></item><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#175218</link><pubDate>Wed, 07 Jul 2004 12:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:175218</guid><dc:creator>Mike Dimmick</dc:creator><description>From my studies, it depends whether you load a DLL using an explicit path or whether you just provide the filename. Implicit loading through static imports or delay loading just uses the module name.&lt;br&gt;&lt;br&gt;DLLs loaded using explicit paths are treated independently of each other, even if they have the same name. However, it appears that DLLs loaded using the name only will use the first DLL loaded with that name. Only if a DLL with that name is not already loaded will Windows then look for the DLL using the rules listed in the documentation for LoadLibrary.&lt;br&gt;&lt;br&gt;This bit a poster on CodeProject's forums. He a number of web applications on the same server, one of which had a managed DLL called Security.dll. In another, he was using a .NET Framework feature (I forget which exactly) which required the cryptography DLL, which the framework loads using the old name - security.dll. Whether his application worked or not depended on which application started first.&lt;br&gt;&lt;br&gt;The reason for this, I concluded, was that when the system tried to load security.dll for the second application, it discovered that the first app's security.dll was already loaded, and used that. That DLL didn't export the required entry point, so the framework threw a MissingMethodException. Surprising, to say the least.&lt;br&gt;&lt;br&gt;IMO, the Framework should have a way to indicate whether the target of a DllImport is supposed to be a system DLL, and to load the DLL explicitly using the computed path if so. Yes, this stops the administrator being able to substitute a different DLL - but that opens you up to Trojan DLL attacks, precisely the point of the directory search changes in XP SP1 and Server 2003.&lt;br&gt;&lt;br&gt;On the issue of shutting down apps versus replacing DLLs in place: what if you have a DLL which implements some features but, to cut down on working set and startup time, puts other features into another DLL. Say that we want to replace these DLLs. Say that an application has loaded A.DLL, but hasn't yet needed B.DLL. Our installer overwrites A.DLL and B.DLL, but our application keeps running with A.DLL (v1). Now the application uses the extended feature: A.DLL (v1) loads B.DLL (v2). We have a version mismatch. If the developers haven't explicitly guarded for this case, anything could happen. It's always recommended to upgrade DLLs as a matched set (e.g. MDAC, C run-time).&lt;br&gt;&lt;br&gt;Shutting down the process is safer. Some processes critical to Windows security can't be shut down since there's no way to start them back up. For example, LSASS.EXE, the Local Security Authority subsystem, talks to the kernel security driver, ksecdd.sys, using a local RPC port - this allows the kernel to authenticate security principals. To prevent processes attaching to this port, the first thing LSASS does (IIRC - I might have this the wrong way round) is to create two new anonymous ports and tells the other half what they are. ksecdd then opens those anonymous ports, then both sides close and destroy the original port. If you stopped LSASS, there's no way for ksecdd to reconnect.&lt;br&gt;&lt;br&gt;I may have some of the details on that wrong, since I'm doing it from memory. The details are in &amp;quot;Inside Windows 2000&amp;quot; by David Solomon and Mark Russinovich.</description></item><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#175234</link><pubDate>Wed, 07 Jul 2004 12:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:175234</guid><dc:creator>Mike Dimmick</dc:creator><description>Oh, and SysInternals' Process Explorer is a good tool for seeing what processes have a DLL loaded. The reason Larry has to reboot is that winmm.dll is loaded by the WinLogon process, which can't be shut down because it's too highly trusted. If WinLogon crashes, XP deliberately blue-screens.&lt;br&gt;&lt;br&gt;There's a whole bunch of DLLs loaded into WinLogon which therefore can't be replaced on the fly.</description></item><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#175322</link><pubDate>Wed, 07 Jul 2004 14:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:175322</guid><dc:creator>Larry Osterman</dc:creator><description>Actually Mike, WINMM.DLL being loaded by winlogon isn't the issue.  I originally thought that, and it turns out that I was wrong (you can try it on XP and see - try renaming winmm.dll on a running machine).  In my case it's because on longhorn, a dll that's used by one of the known dll's (but that's not explicitly on the known dlls list) was changed to have a static link to winmm, and that static link caused winmm to be considered a known dll.&lt;br&gt;</description></item><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#177439</link><pubDate>Thu, 08 Jul 2004 16:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:177439</guid><dc:creator>Cesar Eduardo Barros</dc:creator><description>Larry, why not using position independent code? Then it wouldn't need a base address (and would need a fixup only for things like vtables).</description></item><item><title>re: Why should I even bother to use DLL's in my system?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#177456</link><pubDate>Thu, 08 Jul 2004 16:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:177456</guid><dc:creator>Larry Osterman</dc:creator><description>That is an option Cesar, but it's my understanding that it's very very difficult to truely have position independent code - for instance C++ vtables are inherently position dependent, so that rules out using C++.&lt;br&gt;</description></item><item><title>What are Known DLLs anyway?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#187753</link><pubDate>Mon, 19 Jul 2004 22:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:187753</guid><dc:creator>Larry Osterman's WebLog</dc:creator><description /></item><item><title>How did Windows 95 rebase DLLs?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/07/06/174516.aspx#323557</link><pubDate>Fri, 17 Dec 2004 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:323557</guid><dc:creator>The Old New Thing</dc:creator><description>Instead of doing it en masse, Windows 95 did it incrementally.</description></item></channel></rss>