Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameter to exe downloaded from web?

I have .Net desktop app which users can download from my website. I want to customize this app to per user basis. Is there way to modify exe before downloading, just to change few strings with appropriate for the users downloading ? Or it is possible to pass command line parameters to this exe via URL ?

like image 399
Primoz Avatar asked Dec 13 '10 13:12

Primoz


1 Answers

The .exe file needs to be customized for it to behave differently for certain downloads.

Skip below to find the solution I found tolerable.

Add section to the .EXE file – Not ideal.

The .exe file has sections one after the other. You could add a section with your data in it, which the executable would then read. This requires you to modify (have access to) the source code of the executable for it to do anything meaningful with the data. Also getting familiar with the .exe file format and modifying it on the web server side as well al playing with it in the program's source code is somewhat tedious.

Change resources section of the .EXE file – Not ideal.

A dedicated "resources" section exists in the executable. You could add custom strings or blob of data to it. Same cons as the first one.

Overwrite data in the .EXE at a fixed position – Passable.

Have the executable read data from itself from a fixed position in the file, which is overwritten with the customization data when serving the .exe file. Requires modifying the executable's source code.

Append data to the .EXE – Passable.

Append data to the executable. Again, reading it and doing anything special with it requires the executable itself doing so.


☑ Wrap the .EXE in another .EXE and append your data to it – Tolerable.

Create a program to which the original executable and the custom data will be appended to. When this custom program is then executed, it will extract the embedded executable and launch it with the custom data as it arguments.

This kind of a bundle-executable is also easy to produce on most server-side (scripting) languages. When the download is requested, the server sends the wrapper-exe, the original exe, the customized data and of course some statically-sized data fields denoting the sizes of both of those data blocks so it can extract them.

Cons: Requires such a wrapper program to be created, unless someone already has.

Related links:
1. Best practices to let my web users download custom .exe from my site using PHP
2. Modifying executable upon download (Like Ninite)

like image 200
Gima Avatar answered Oct 14 '22 20:10

Gima