Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Why do DLLs get loaded...

Why do DLLs get loaded...

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomsalesquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dontknowitall
    wrote on last edited by
    #1

    ...from system32 even if it is copied to the directory the application starts from? I just dealt with a customer over a bug due to this very issue. Two DLLs with the same name were on the system. One DLL was loaded by one application and then the other application loaded the first application's DLL instead of its own. Result? Confusing "ordinal/export not found" messages and the second application refused to start. The Windows loader should be smarter than that. I'd love to hear the rationale behind why Windows can't run a quick check for the DLL in the application's directory BEFORE looking for a cached DLL of the same name elsewhere. Caching systems, by definition, must reflect the equivalent non-cached system 1-to-1. Non-cached DLL search order[^]

    M D CPalliniC 3 Replies Last reply
    0
    • D dontknowitall

      ...from system32 even if it is copied to the directory the application starts from? I just dealt with a customer over a bug due to this very issue. Two DLLs with the same name were on the system. One DLL was loaded by one application and then the other application loaded the first application's DLL instead of its own. Result? Confusing "ordinal/export not found" messages and the second application refused to start. The Windows loader should be smarter than that. I'd love to hear the rationale behind why Windows can't run a quick check for the DLL in the application's directory BEFORE looking for a cached DLL of the same name elsewhere. Caching systems, by definition, must reflect the equivalent non-cached system 1-to-1. Non-cached DLL search order[^]

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      I suppose that's why MS tacks version numbers on to runtime DLL names :) Sorry for your lost time debugging! Unique DLL names are a good idea :sigh: Mark

      "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

      1 Reply Last reply
      0
      • D dontknowitall

        ...from system32 even if it is copied to the directory the application starts from? I just dealt with a customer over a bug due to this very issue. Two DLLs with the same name were on the system. One DLL was loaded by one application and then the other application loaded the first application's DLL instead of its own. Result? Confusing "ordinal/export not found" messages and the second application refused to start. The Windows loader should be smarter than that. I'd love to hear the rationale behind why Windows can't run a quick check for the DLL in the application's directory BEFORE looking for a cached DLL of the same name elsewhere. Caching systems, by definition, must reflect the equivalent non-cached system 1-to-1. Non-cached DLL search order[^]

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        dontknowitall wrote:

        I'd love to hear the rationale behind why Windows can't run a quick check for the DLL in the application's directory BEFORE looking for a cached DLL of the same name elsewhere.

        Wouldn't that sort of defeat the purpose of cached DLLs? After all, RAM is much faster than the HDD.


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        D 1 Reply Last reply
        0
        • D dontknowitall

          ...from system32 even if it is copied to the directory the application starts from? I just dealt with a customer over a bug due to this very issue. Two DLLs with the same name were on the system. One DLL was loaded by one application and then the other application loaded the first application's DLL instead of its own. Result? Confusing "ordinal/export not found" messages and the second application refused to start. The Windows loader should be smarter than that. I'd love to hear the rationale behind why Windows can't run a quick check for the DLL in the application's directory BEFORE looking for a cached DLL of the same name elsewhere. Caching systems, by definition, must reflect the equivalent non-cached system 1-to-1. Non-cached DLL search order[^]

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Thank you for posting, I don't knew about that behaviour. On the overall, I agree with you. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • D David Crow

            dontknowitall wrote:

            I'd love to hear the rationale behind why Windows can't run a quick check for the DLL in the application's directory BEFORE looking for a cached DLL of the same name elsewhere.

            Wouldn't that sort of defeat the purpose of cached DLLs? After all, RAM is much faster than the HDD.


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            D Offline
            D Offline
            dontknowitall
            wrote on last edited by
            #5

            DavidCrow wrote:

            Wouldn't that sort of defeat the purpose of cached DLLs? After all, RAM is much faster than the HDD.

            No - it wouldn't defeat the purpose. The point of caching DLLs is to reduce the amount of RAM used. If two applications happen to have a DLL of the same name and one is running and the other is started, the second application will attempt to use the first application's DLL. Checking for a file's existence in the application's directory before looking at the loaded DLL cache takes almost no time (and could potentially be done in RAM altogether because the file system caches information like that in RAM). A cache, by definition, should return the same exact result as the method used to generate the cached information. To deviate from the definition will cause bugs to appear. Windows does not do this and therefore has "bugs". LoadLibrary() documents this weird behavior but that doesn't make the behavior right/correct.

            M 1 Reply Last reply
            0
            • D dontknowitall

              DavidCrow wrote:

              Wouldn't that sort of defeat the purpose of cached DLLs? After all, RAM is much faster than the HDD.

              No - it wouldn't defeat the purpose. The point of caching DLLs is to reduce the amount of RAM used. If two applications happen to have a DLL of the same name and one is running and the other is started, the second application will attempt to use the first application's DLL. Checking for a file's existence in the application's directory before looking at the loaded DLL cache takes almost no time (and could potentially be done in RAM altogether because the file system caches information like that in RAM). A cache, by definition, should return the same exact result as the method used to generate the cached information. To deviate from the definition will cause bugs to appear. Windows does not do this and therefore has "bugs". LoadLibrary() documents this weird behavior but that doesn't make the behavior right/correct.

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              It's been this way since the beginning. IMO a part of the whole DLL hell thing. It's one of those backward compatible things that couldn't be changed and we have to live with it. The caching works fine. It is IMO appropriate to look for an already-loaded DLL before going to disk to get it. The problem is, it's done by NAME ONLY. I think it should look at name and VERSION at least. But it doesn't. Complain to Microsoft...good luck ;) Mark

              "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups