Archived

This topic is now archived and is closed to further replies.

Creating self-extracting exes (coding)

This topic is 5109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know where I can find a tutorial on how to create self-extracting executables? I''m working on some encryption/decryption software and I would like to be able to create self-extracting (or self decrypting) executables. Googling only provided links to similar types of software... Any help would be appreciated.

Share this post


Link to post
Share on other sites
When I needed something like this, what I did was put every file that was to be extracted into the resource section of the exe.

I then wrote a function to find a specific file in the resource, lock it, get its size, and finally write the data to disk. You just compile a short program with the files in its resource and just call the extract function for every file in the resource .

If you wanted to do this automatically, you could use batch files to compile the res and exe, and then link them. You would also write a small scripting engine with LUA (not hard at all ) to script the extraction of the files.



Share this post


Link to post
Share on other sites
I''m pretty sure the OP wants to make a program that will generate the self-extracting exe''s based on other files. This is significantly different than having a project that will produce one self-extracting exe based on the project settings.

Share this post


Link to post
Share on other sites
quote:

I''m pretty sure the OP wants to make a program that will generate the self-extracting exe''s based on other files. This is significantly different than having a project that will produce one self-extracting exe based on the project settings.



This is exactly what I want to do.

downgraded - Thanks for the tip, I think this is what I''m after.

Share this post


Link to post
Share on other sites
I''ve looked into the PE headers a little bit...and it doesn''t seem like an easy approach. How exactly would I go about creating a self extracting exe? I''m guessing that I would have to...
1) Create the small exe program which is capable of doing the extraction
2) Have a program which can modify the header of this small exe, and append the files (files to extract) to the exe.
3) Have the small exe read its own header to find the location of the extra data and extract?

Am I on the right track?

Is there a way to just add a resource to an exe after the fact? That would be an easier approach for me...

Any help is appreciated.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Hoser
I''ve looked into the PE headers a little bit...and it doesn''t seem like an easy approach. How exactly would I go about creating a self extracting exe? I''m guessing that I would have to...
1) Create the small exe program which is capable of doing the extraction
2) Have a program which can modify the header of this small exe, and append the files (files to extract) to the exe.
3) Have the small exe read its own header to find the location of the extra data and extract?

Am I on the right track?

Is there a way to just add a resource to an exe after the fact? That would be an easier approach for me...

Any help is appreciated.



That sounds about right to me. Except you don''t have to modify the the header of the exe, you can just create a footer after you''d appended the extra data to your exe. Then it''s just matter of having the exe open it''s self as a binary input, seek the EOF minus the size of the footer then using the information contain in the footer to extract the extra data.

Share this post


Link to post
Share on other sites
quote:

Except you don''t have to modify the the header of the exe, you can just create a footer after you''d appended the extra data to your exe. Then it''s just matter of having the exe open it''s self as a binary input, seek the EOF minus the size of the footer then using the information contain in the footer to extract the extra data.



That''s the solution I had come up with. Anyone know off hand what windows function will give me the filename of the currently running exe?

quote:

Something wrong with winzip here..?



Yes. The application I''m working in is quite specialized...I need some custom software.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
this method:
quote:

1) Create the small exe program which is capable of doing the extraction
2) Have a program which can modify the header of this small exe, and append the files (files to extract) to the exe.
3) Have the small exe read its own header to find the location of the extra data and extract?



is just going to result in you _reinventing_ resources! that''s dumb. the win32 API provides functions for adding, removing, and generally modifying resources in an executable. since the functionality you''re looking for already exists, you should use it.



Share this post


Link to post
Share on other sites