33

Possible Duplicate:
How can a C++ windows dll be merged into a C# application exe?

Is anybody aware of a program that can pack several DLL and a .EXE into one executable. I am not talking about .NET case here, I am talking about general DLLs, some of which I generate in C++, some of others are external DLL I have no control over.

My specific case is a python program packaged with py2exe, where I would like to "hide" the other DLL by packing them. The question is general enough though.

The things that had a look at:

  • ILMerge: specific to .NET
  • NETZ: specific to .NET
  • UPX: does DLL compression but not multiple DLL + EXE packing
  • FileJoiner:
Almost got it. It can pack executable + anything into one exe but when opened, it will launch the default opener for every file that was packed. So, if the user user dlldepend installed, it will launch it (becaues that's the default dll opener).

Maybe that's not possible ?


Summary of the answers:

DLL opening is managed by the OS, so packing DLL into executable means that at some point, they need to be extracted to a place where the OS can find them. No magic bullet.

So, what I want is not possible.

Unless...

We change something in the OS. Thanks Conrad for pointing me to ThinInstall, which virtualise the application and the OS loading mechanism. With ThinInstall, it is possible to pack everything in one exe (DLL, registry settings, ...).

Community
  • 1
  • 1
Philippe F
  • 11,776
  • 5
  • 29
  • 30
  • You also can use boxedapppacker - similar to thinstall. – MastAvalons Jan 23 '12 at 20:46
  • or use BoxedApp SDK - developer's library for virtualization files and registry – MastAvalons Apr 10 '12 at 14:19
  • Recently PELock was updated with DLL binding capability https://www.pelock.com/img/en/products/pelock/virtual-dll-libraries/pelock-virtual-dll-binder.png – Bartosz Wójcik Jul 18 '16 at 13:03
  • 1
    I do not think this is a duplicate, since the source application is not in C# like the supposedly duplicate question ask. There is another free and simple solution. _(At least it worked for my simple project.)_: [See this answer on Superuser](https://superuser.com/a/1237060/315737) – Julo Apr 12 '19 at 12:17

9 Answers9

7

Have a look at BoxedApp. Good luck!

  • Unlike ThinApp and Evalaze, BoxedApp doesn't add 14MB to the application size, just a couple MB. Which is good. -- Four years ago I'd commented here saying it didn't work with UPX packed EXE files, but the author wrote me to say I should use "run in virtual environment" (I don't know if the option was there before or not)--and that worked. I had some other trouble when I tried with a packed Qt app then. But as the author wrote regarding the comment, he is willing to engage if you are having problems. So if you're all right using a commercial solution, this may work for you. – HostileFork says dont trust SE Feb 13 '19 at 02:07
  • BoxedApp also does some virtualization of the registry. Is it possible to do merge exe+dll without any other functionality? – pts Jul 07 '20 at 11:38
6

Have a look at Thinstall ThinApp

Rad
  • 8,336
  • 4
  • 46
  • 45
5

Try Powerpacker. Evalaze is another free virtualization solution. Enigma Virtual Box FREEWARE Edition

Kachwahed
  • 542
  • 7
  • 17
4

If the executable statically links to the DLL, i.e. there are no calls to LoadLibrary, then I don't think there are any mechanisms to pack the DLL into the executable since the DLL load is done by the OS application loader prior to the "main" function being called. The only way around this as far as I'm aware is to put the exe and the dlls into another exe. This wrapper exe unpacks the real exe and dlls into a temporary folder and starts the exe, deleting the files when the exe exits.

If you are calling LoadLibrary/Ex to load the dll, extract the dll from the exe resources to a file prior to the call to LoadLibrary/Ex.

The real problem is that the LoadLibrary function does a lot of fixing up of addresses when the library is loaded and only works when loading from a file.

Skizz
  • 69,698
  • 10
  • 71
  • 108
  • 1
    I suppose the question is 'is it possible to write a linker that grabs code from a DLL in the way code can be grabbed from a LIB file and add it to the EXE being linked'? – Skizz Dec 03 '08 at 14:13
  • The wrapper .EXE is the approach I use. Obviously nowadays you need to think a little bit about where you unpack everything to - don't assume you can unpack into \program files\... without needing to be run-as-admin – Will Dean Dec 03 '08 at 14:14
2

You can add the DLLs as binary resources in your EXE. At startup, your EXE can then extract the resources into a temporary folder, and LoadLibrary() the resulting DLLs.

Arnout
  • 2,780
  • 14
  • 12
1

Have you looked at my cheap-utility list?

There supposed to be several inexpensive (i.e., rather cheap) tools that would link non-net app's DLL(s) together, such as:

1.) Molebox Pro (eu 100) 2.) BitArt's Fusion ($160) 3.) VB Wrap ($100) 4.) PE Bundle ($30)

Additionally, at "www.oreans.com" you might find a protection-oriented program bundle for eu 320, that, as they claim, can link either Win32 or ".Net" files together; however, when I asked them for a specific scenarion, where I would use their "XBundler For Win32/.NET" in order to pack a ".Net" EXE, and then would try to run it on Windos 98 (without the framework), they said it wouldn't work. :-(

EXE Admirer

1

You can use valgrid, thinstall or boxedapp.... I prefer the latter.

John Smith
  • 4,111
  • 1
  • 15
  • 15
0

MoleBox Pro does exactly what you want, but it is shareware, and, unless you buy a full version, packed executables will show a Dialog Box at startup, saying something like "This file was packed by a trial version of MoleBox, please do not distribute it"

You can downliad it here: link

Unfortunately, I've been unable to find a fully satisfying and free solution

  • 2
    Note that [MoleBox was open-sourced](https://github.com/sudachen/Molebox). But at time of writing, it has not been maintained with any added commits since the time of its publication (August 2017). – HostileFork says dont trust SE Feb 13 '19 at 02:39
0

I was told it is possible to ask a shared object link to another shared object thus combine them into one in Linux

But it won't work for Windows native dlls, one thing occurrs to me is we can just use the linker to link all the objs together, regardless of which project they belongs to originally. Of course, they need to have similar link options.

Baiyan Huang
  • 6,463
  • 8
  • 45
  • 72