Announcement

Collapse
No announcement yet.

Is it possible to embed a DLL within an EXE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is it possible to embed a DLL within an EXE

    In the opposite direction of my last post, can I incorporate a DLL in my EXE?

    I'd prefer that the DLL not be automatically extracted when the program runs, but for now I'm just trying to understand what is possible.

    It seems like I've seen info on it in the past, but my forum searches have come up short.

    #2
    Some Products

    Originally posted by Gary Beene View Post
    In the opposite direction of my last post, can I incorporate a DLL in my EXE?

    upx

    MoleBox

    PECompact


    Not all DLLs can be packaged. If a dll is already compacted, it can't compacted again. There are other limitations.

    Comment


      #3
      Code:
      //  myprog.rc resource script
      101   RT_RCDATA   "mydll.dll"
      At runtime, extract the resource data, save on disk, load into your program's space with LoadLibrary(). Remember to remove the file at end of program (that's just polite more than anything).

      That's what I did at One From Column A, One from Column B.. Works good.

      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


        #4
        Thanks guys,

        I'll follow up on your recommendations.

        Comment


          #5
          I think Gary was more looking for (can I embed a DLL in a resource, and use it, but not create the dll to use it, but rather use the function in memory so that the process is completely oblivious to the user at runtime)

          Gary the answer is YES (although depending on what you want to do you will need to use a small amount of Assembly, although that is my take on it so far)

          I did a look and could not find it, but give me a bit and I will see if I can post an example.
          Engineer's Motto: If it aint broke take it apart and fix it

          "If at 1st you don't succeed... call it version 1.0"

          "Half of Programming is coding"....."The other 90% is DEBUGGING"

          "Document my code????" .... "WHYYY??? do you think they call it CODE? "

          Comment


            #6
            Thanks Cliff, and yes, that was the thought.

            I'll watch for your next post.

            Comment


              #7
              I think Gary was more looking for (can I embed a DLL in a resource, and use it, but not create the dll to use it, but rather use the function in memory so that the process is completely oblivious to the user at runtime)
              Huh? That's what my suggestion accomplishes. The DLL I stored as a resource was not mine, it was the zlib DLL.

              The user never knows, unless he puts a monitor on his Temp folder and makes enough observations to conclude that because when the Tour Application starts a file is created, that file is "in use" until the tour application ends, and is deleted when the application ends, therefore the tour application must be creating and destroying that file. However, that's still only a guess.

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


                #8
                I've used this approach for one application where I wanted to ship a zlib DLL library inside my exe and load the dll directly from memory without touching the disk. The advantage being that there is nothing to tidy up afterwards on disk.


                ' load the ziplib directly
                ' return in a string the contents of the zip dll
                szRawZip = funReturnZiplib
                ' load the dll directly into memory and store its handle in zlib_hdll
                IF LoadPbDllFromMemory (STRPTR(szRawZip), LEN(szRawZip), ZLIB_hDll) THEN
                funGraphicUpdate("STATUS", "Unable to load Zip Dll")
                EXIT FUNCTION ' handle errors
                END IF
                szRawZip = "" ' We don't need it anymore

                Comment


                  #9
                  MCM
                  Huh? That's what my suggestion accomplishes. The DLL I stored as a resource was not mine, it was the zlib DLL.

                  The user never knows, unless he puts a monitor on his Temp folder and makes enough observations to conclude that because when the Tour Application starts a file is created, that file is "in use" until the tour application ends, and is deleted when the application ends, therefore the tour application must be creating and destroying that file. However, that's still only a guess.
                  Ummmmmkayyyyy, so that means you are creating and destroying a file.....correct??
                  I think Gary was more looking for (can I embed a DLL in a resource, and use it, but not create the dll to use it, but rather use the function in memory so that the process is completely oblivious to the user at runtime)
                  and Gary's answer was YES.....(There is no create/destroy that the user could see....but rather use the DLL in your resource just as you would if it were created)

                  MCM
                  The user never knows, unless he puts a monitor on his Temp folder and makes enough observations to conclude that because when the Tour Application starts a file is created, that file is "in use" until the tour application ends, and is deleted when the application ends, therefore the tour application must be creating and destroying that file. However, that's still only a guess
                  True, but if the user knows to watch (either programmaticly, or by the idea that they just happen to have that folder open in explorer, no matter how fast they will see something appear and disappear.

                  Usually not a problem, but for "Paranoids" (like me) that do not like seeing things happening that they did not expect, then could wreak some havoc.

                  Although I would suspect that zlib.dll would be the most likely used dll for this kind of use (I think I used it somewhere), I think there was some sort of problem about using it without recognition (Maybe it was a M$ lawsuit or something in the past) I will try to do a example using a plain DLL to demo.

                  I thought I had posted before, but the only code I can find is on my own machine and appears to be a "Work-in-progress" so I will see if I can clean it up and post shortly.
                  Engineer's Motto: If it aint broke take it apart and fix it

                  "If at 1st you don't succeed... call it version 1.0"

                  "Half of Programming is coding"....."The other 90% is DEBUGGING"

                  "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                  Comment


                    #10
                    Usually not a problem, but for "Paranoids" (like me) that do not like seeing things happening that they did not expect
                    I might be a tad more liberal on this than are you, but seems to me creating a temp file in the user's assigned temp folder and deleting it when I'm done with it is a not unreasonable thing to do.

                    Of course, maybe I'm just fixated on the concept that that's why there is such a thing as a "temp" folder in the first place.

                    MCM
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                      #11
                      That would do but when you wish to use declares pointing to a dll you cannot.
                      hellobasic

                      Comment


                        #12
                        >That would do but when you wish to use declares pointing to a dll you cannot.

                        What you do want? A free lunch?

                        If you want "no external DLL to ship but access to functions in that DLL" it costs you the convenience of "DECLARE FUNCTION...LIB .. ALIAS... " and you have to use LoadLibrary() + GetProcAddress() + CALL DWORD.

                        The little bit of extra effort is either worth it to you or it ain't.



                        MCM
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                          #13
                          So?

                          This may be his question isn't?
                          hellobasic

                          Comment


                            #14
                            See:http://www.powerbasic.com/support/pb...907#post319907

                            For an example of how I add embedded files to a resource.

                            James

                            Comment

                            Working...
                            X
                            😀
                            🥰
                            🤢
                            😎
                            😡
                            👍
                            👎