0

I'm currently in the process of developing a small multi utilities tool in C# and one of the tools I am wanting to implement is a tool that will bind (File binder) one executable with another so that executing one executable will execute both of them in a way of merging the executables into one file.

Please take a look at this screenshot to understand more.

Figure 1:

screenshot

Button 1 is the button which you click to select the first executable.

Button 2 is the button which you click to select the executable you want to bind with the first executable

button 3 is the button which you click to bind the executables and save the newly built executable to the desktop.

I need some advice on how I can do this, I am going to use codedom to build the file.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Feivism
  • 7
  • 7
  • 2
    Sounds like a lot of work for little gain, why not just use 2 lines in a batch file, or a launcher which takes commandline arguments – TheGeneral May 25 '18 at 05:45
  • What have you tried? Any on-topic search? Any ideas how to proceed? This seems a little "general" and "opinion-based" question. – Tatranskymedved May 25 '18 at 05:48
  • I've looked at many forums as well as searched for sources to look for information off of but couldn't find any. I do not want to use a batch file to launch both files I want to merge them into one executable. Still looking for suggestions. – Feivism May 25 '18 at 05:51
  • 1
    Possible duplicate of [Load an EXE file and run it from memory](https://stackoverflow.com/questions/3553875/load-an-exe-file-and-run-it-from-memory) – ProgrammingLlama May 25 '18 at 06:03
  • I'm not wanting to use RunPE I'm wanting to merge the executables in a way. – Feivism May 25 '18 at 06:07
  • 1
    Compile a 3rd executable that embeds the first two, that loads those two dynamically and invokes the main method. – Lasse V. Karlsen May 25 '18 at 06:12
  • 1
    If those are not necessarily .NET assemblies, you will have to either figure out how to load Win32 PE executables dynamically, or you will have to temporarily extract them to disk before executing them. – Lasse V. Karlsen May 25 '18 at 06:13

1 Answers1

0

If by binding you mean chain-launching, then TheGeneral gave you the most simple suggestion in the comments, which to to generate a batch file with 2 lines of code (possibly more, for usability reasons):

Start "C:\...\...\executable1.exe"
Start "C:\...\...\executable2.exe"

Or better yet, use relative direcotries, which will start the executables that are in the working directory of the bat file:

Start "executable1.exe"
Start "executable2.exe"

Also, keep in mind that it might fail (if it needs admin rights at any point at all) without any errors on Windows 10, unless launched as administrator.

If you are looking for a method to modify an executable to launch a second executable, I don't believe you can tackle this project if you have no idea where to begin. If you want to modify executables to work on any system, you need to decompile the first file, modify it to launch the second one and recompile it, which is probably not difficult to do manually, but not easy to create an algorithm for.

Your 3rd option is to look into executable embedding (essentially creating a program, that contains your main and "bound" program, and when executed copies them out and launches them). After a quick google search, I've found that it is possible, but much like modification of executable, will require some effort to learn and implement.

Zero
  • 1,562
  • 1
  • 13
  • 29