Results 1 to 12 of 12

Thread: [RESOLVED] Embed .dll files inside .exe file

  1. #1

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Resolved [RESOLVED] Embed .dll files inside .exe file

    How would I go about embeding .dll files that are being used by my .exe, inside the .exe file?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Embed .dll files inside .exe file

    You can add it to your project as an embedded resource, but this will mean that whenever the application is run, it will need to extract the DLL then dynamically load it and set the references required for it to run. Why would you want to do this?

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Embed .dll files inside .exe file

    The other possible interpretation is static linking of .LIBs rather than .DLLs but VB6 doesn't support this and I'd think VB.Net is even less likely to.

    There are various "pack and run" schemes out there but most people don't use them. You'd usually create some sort of installer package, even if it is little more than a self-extracting archive.

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Embed .dll files inside .exe file

    That is one of the worst schemes that one can do, especially if one doesn't understand the installation process. You can overwrite good dll's with possible bad ones (out of date) as well as appearing with virus like activity. You may not install everything that is needed (more than highly likely, you won't install everything that is needed).

    Just create a complete installation package and be done with it without attempting to use smoke and mirrors.

  5. #5

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: Embed .dll files inside .exe file

    mendhak, I am looking to do this because I am working on a code security project and didn't want someone who had Visual Studio on their machine to be able to set a reference to a .dll and use it.

    If the .dlls were embedded, they would be able to do this.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Embed .dll files inside .exe file

    Simply because someone can set a reference to a DLL it doesn't mean they can use it.

    In order to use it, they would have to know what it does, how it does it, and what is required in their code to utilize the code compiled in the DLL

    For that, they would either need access to the source code, which the compiled DLL isn't going to give them or brib the programmer.

  7. #7
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: Embed .dll files inside .exe file

    i have asked this question before found a software called ElMerge they say that he do this things but doesnt work for me
    i still search also for something about it

  8. #8
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Embed .dll files inside .exe file

    Quote Originally Posted by mday2792
    mendhak, I am looking to do this because I am working on a code security project and didn't want someone who had Visual Studio on their machine to be able to set a reference to a .dll and use it.

    If the .dlls were embedded, they would be able to do this.
    I've got news for you. If this was developed in .Net then you can reference an executable in any project as if it were a DLL. Not only that but it's insanely easy to extract data from an executable (especially if it's a resource).

    What's in the DLL you don't want others referencing? It sounds like you're trying to do security through obscurity which is not security at all.

    You can take a look at signing your assembilies if this is .Net which helps to prevent tampering but not usage.
    Quote Originally Posted by Hack
    Simply because someone can set a reference to a DLL it doesn't mean they can use it.

    In order to use it, they would have to know what it does, how it does it, and what is required in their code to utilize the code compiled in the DLL

    For that, they would either need access to the source code, which the compiled DLL isn't going to give them or brib the programmer.
    If it's written in .Net then you can set a reference to any DLL, see it's methods either through reflector or intellisense and use them as per how they're made (i.e. you can tell a funciton returns a string so you test it out to see what it does).

    If it's a COM Object then you can easily transverse those as well. I believe there are also applications to get exposed methods, properties, etc from native DLLs as well.

    DLLs are very easy to hook into which is why they're a Dynamically Linked Library. What the OP wants to do is NOT what a DLL is meant to do.
    Last edited by Kasracer; May 14th, 2008 at 10:30 AM.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Embed .dll files inside .exe file

    Quote Originally Posted by mday2792
    mendhak, I am looking to do this because I am working on a code security project and didn't want someone who had Visual Studio on their machine to be able to set a reference to a .dll and use it.

    If the .dlls were embedded, they would be able to do this.
    That's not true. Anyone with Reflector and sufficient time and patience can look at it, understand that there's an assembly embedded in there somewhere and extract it, then use it. Your code will always be visible, which is why there are products to obfuscate code out there. They can make the code not-easy-for-human readable so that it's a little more difficult to understand the code, but not entirely impossible.

  10. #10
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Embed .dll files inside .exe file

    Quote Originally Posted by kasracer
    I've got news for you. If this was developed in .Net then you can reference an executable in any project as if it were a DLL. Not only that but it's insanely easy to extract data from an executable (especially if it's a resource).
    So far i haven't seen him say this is .net though.
    Quote Originally Posted by kasracer
    DLLs are very easy to hook into which is why they're a Dynamically Linked Library. What the OP wants to do is NOT what a DLL is meant to do.
    Which is why I mentioned static libraries, but this isn't a trivial matter when programming in VB6, let alone .Net!

  11. #11

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: Embed .dll files inside .exe file

    FYI - This is .NET

    I found this product from Microsoft called ILMerge. It works for what I am looking to do.

    http://www.codeproject.com/KB/dotnet...ssemblies.aspx

  12. #12
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Embed .dll files inside .exe file

    Quote Originally Posted by dilettante
    So far i haven't seen him say this is .net though.
    Hence the If
    Quote Originally Posted by dilettante
    Which is why I mentioned static libraries, but this isn't a trivial matter when programming in VB6, let alone .Net!
    Static libraries are a great solution but only for native languages such as C or C++. Is there a way to use a static library and built it into a VB6 application? I know it's not possible in .Net but I wasn't sure about VB6.
    Quote Originally Posted by mday2792
    I found this product from Microsoft called ILMerge. It works for what I am looking to do.

    http://www.codeproject.com/KB/dotnet...ssemblies.aspx
    That only works if you have the source code since you can't use a typical assembly.

    So if you already have the source code why are you not just compiling it into the exe yourself?

    Also, it doesn't quite do what you wanted as once everything is merged into an executable, anyone can still reference your exe and use any public classes, methods, etc.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width