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. The Lounge
  3. Recommended DLL programming books

Recommended DLL programming books

Scheduled Pinned Locked Moved The Lounge
csharpc++helpdiscussion
9 Posts 5 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.
  • S Offline
    S Offline
    Stick
    wrote on last edited by
    #1

    Hi, I'm trying to learn more about dll programming, and wonder if anyone can recommend any good books on the subject. I program in C++ and C#. I really want to understand writing them, using them, as it will help me in my projects. Thanks for your thoughts, Patrick

    J J 2 Replies Last reply
    0
    • S Stick

      Hi, I'm trying to learn more about dll programming, and wonder if anyone can recommend any good books on the subject. I program in C++ and C#. I really want to understand writing them, using them, as it will help me in my projects. Thanks for your thoughts, Patrick

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      Programming DLLs aren't much harder than writing apps. Acquaint yourself with __declspec(dllimport) and __declspec(dllexport) (or equivalent method if dealing with a non-Microsoft compiler). Also refrain from doing anything in DllMain(). Many functions can't safely be called from DllMain() as it may very well cause lockups. I would imagine Raymond Chen[^] has an entry or two on pitfalls in the land of DLLs.

      -- Painstakingly Drawn Before a Live Audience

      J 1 Reply Last reply
      0
      • J Jorgen Sigvardsson

        Programming DLLs aren't much harder than writing apps. Acquaint yourself with __declspec(dllimport) and __declspec(dllexport) (or equivalent method if dealing with a non-Microsoft compiler). Also refrain from doing anything in DllMain(). Many functions can't safely be called from DllMain() as it may very well cause lockups. I would imagine Raymond Chen[^] has an entry or two on pitfalls in the land of DLLs.

        -- Painstakingly Drawn Before a Live Audience

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #3

        Jörgen Sigvardsson wrote:

        Also refrain from doing anything in DllMain().

        Um... say what? I've always put init routines and clean ups in DLLMain and I have never once had a problem with lockups. The only thing I could think of is not accounting for thread safety, but that's not the fault of DLLMain() - it's just an entry point. You gotta start somewhere.

        Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

        M 1 Reply Last reply
        0
        • S Stick

          Hi, I'm trying to learn more about dll programming, and wonder if anyone can recommend any good books on the subject. I program in C++ and C#. I really want to understand writing them, using them, as it will help me in my projects. Thanks for your thoughts, Patrick

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          If you want to cover *almost* the entire of gamut of what you'll be doing with Windows programming more times than not (including writing DLLs), I still recommend this book[^]. It is a bit dated now, but still has plenty of great info that's not too difficult to apply to Win64 dev. But, in the end, it's not that much different. You have to think differently though in that a DLL is meant to be shared, but at least it gets mapped to the process space that loads it, so even that isn't that big of a deal. I would definitely, have a few reads on how linkers and name decoration/mangling works before you do anything else. It'll save you needless headaches down the road.

          Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

          S L 2 Replies Last reply
          0
          • J Jeremy Falcon

            Jörgen Sigvardsson wrote:

            Also refrain from doing anything in DllMain().

            Um... say what? I've always put init routines and clean ups in DLLMain and I have never once had a problem with lockups. The only thing I could think of is not accounting for thread safety, but that's not the fault of DLLMain() - it's just an entry point. You gotta start somewhere.

            Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

            M Offline
            M Offline
            Mike Dimmick
            wrote on last edited by
            #5

            The problem is that the loader takes a process-wide lock just before entering DllMain. It also doesn't guarantee an order for calling different DLL's DllMain functions. That reduces the set of reliably callable functions to those that the loader will definitely have processed before calling your DllMain, which basically means most things in kernel32.dll are OK, but anything else is risky. For more, see Michael Grier's blog[^]. He was one of the developers to work on the loader in the Windows XP product cycle.

            Stability. What an interesting concept. -- Chris Maunder

            1 Reply Last reply
            0
            • J Jeremy Falcon

              If you want to cover *almost* the entire of gamut of what you'll be doing with Windows programming more times than not (including writing DLLs), I still recommend this book[^]. It is a bit dated now, but still has plenty of great info that's not too difficult to apply to Win64 dev. But, in the end, it's not that much different. You have to think differently though in that a DLL is meant to be shared, but at least it gets mapped to the process space that loads it, so even that isn't that big of a deal. I would definitely, have a few reads on how linkers and name decoration/mangling works before you do anything else. It'll save you needless headaches down the road.

              Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

              S Offline
              S Offline
              Stick
              wrote on last edited by
              #6

              Jeremy Falcon wrote:

              I would definitely, have a few reads on how linkers and name decoration/mangling works before you do anything else. It'll save you needless headaches down the road.

              Yes, I understand the basic concepts of name mangling and decoration. Thanks for the tips.

              J 1 Reply Last reply
              0
              • S Stick

                Jeremy Falcon wrote:

                I would definitely, have a few reads on how linkers and name decoration/mangling works before you do anything else. It'll save you needless headaches down the road.

                Yes, I understand the basic concepts of name mangling and decoration. Thanks for the tips.

                J Offline
                J Offline
                Jeremy Falcon
                wrote on last edited by
                #7

                Stick^ wrote:

                Thanks for the tips.

                BTW, since I'm in the middle of writing a DLL lib myself; I needed to know just what was being said about avoiding DLLMain() usage. This whitepaper (by far) was the best explanation of it and is a very worthy read if you want to write DLLs also. Best Practices for Creating DLLs[^] Make a long story short, in DLLMain() stay away from launching other processes, threads, working with global memory, etc. Although, that's really a duh. The non duh part is to watch out for relying on calls to other DLLs (even stuff like user32.dll) because you're not gauranteed it'll be loaded (practially speaking yeah (if the serializer does its job right) but no garuantees because that's life). Point is, limit the scope of DLLMain to initilization routines that your DLL needs (allocation, configs, etc.), but make sure you don't accidently call something that references something that uses an API, etc. outside of your DLL that may not loaded.

                Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                1 Reply Last reply
                0
                • J Jeremy Falcon

                  If you want to cover *almost* the entire of gamut of what you'll be doing with Windows programming more times than not (including writing DLLs), I still recommend this book[^]. It is a bit dated now, but still has plenty of great info that's not too difficult to apply to Win64 dev. But, in the end, it's not that much different. You have to think differently though in that a DLL is meant to be shared, but at least it gets mapped to the process space that loads it, so even that isn't that big of a deal. I would definitely, have a few reads on how linkers and name decoration/mangling works before you do anything else. It'll save you needless headaches down the road.

                  Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Jeremy Falcon wrote:

                  I still recommend this book[^].

                  Got it, amongst others. All I need to do now is save up some dollars, buy VS2005 and start coding again.

                  Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash 24/04/2004

                  J 1 Reply Last reply
                  0
                  • L Lost User

                    Jeremy Falcon wrote:

                    I still recommend this book[^].

                    Got it, amongst others. All I need to do now is save up some dollars, buy VS2005 and start coding again.

                    Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash 24/04/2004

                    J Offline
                    J Offline
                    Jeremy Falcon
                    wrote on last edited by
                    #9

                    Michael Martin wrote:

                    Got it, amongst others.

                    The only thing I don't like about the book is the installer for the source code samples craps out every time you use it. But oh well, it happens. :laugh:

                    Jeremy Falcon A multithreaded, OpenGL-enabled application.[^]

                    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