Announcement

Collapse
No announcement yet.

Is it possible to embed a DLL within an EXE

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

  • jcfuller
    replied
    See:http://www.powerbasic.com/support/pb...907#post319907

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

    James

    Leave a comment:


  • Edwin Knoppert
    replied
    So?

    This may be his question isn't?

    Leave a comment:


  • Michael Mattias
    replied
    >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

    Leave a comment:


  • Edwin Knoppert
    replied
    That would do but when you wish to use declares pointing to a dll you cannot.

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Cliff Nichols
    replied
    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.

    Leave a comment:


  • Graham McPhee
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Gary Beene
    replied
    Thanks Cliff, and yes, that was the thought.

    I'll watch for your next post.

    Leave a comment:


  • Cliff Nichols
    replied
    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.

    Leave a comment:


  • Gary Beene
    replied
    Thanks guys,

    I'll follow up on your recommendations.

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Brian Chirgwin
    replied
    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.

    Leave a comment:


  • Gary Beene
    started a topic Is it possible to embed a DLL within an EXE

    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.
Working...
X
😀
🥰
🤢
😎
😡
👍
👎