WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

SFX Stub for Installer with full source code, a simple installation program with the ability to customise things exactly as I want them.

andrew_k
Quote Post


Active Member
***

Group: Members
Posts: 41
Member No.: 34
Joined: 25-May 04


Sponsored Links
Hi All,

Most commercial installation programs consist of a compressed installation executable appended to a stub program, resulting in some form of self-extracting archive. The stub has the offset in the archive to the compressed data programmed in. When it is run it writes a copy of the compressed data to disc, unpacks it and then runs the actual installation routine. Finally it deletes whatever files it created along the way.

I needed a simple installation program plus the ability to customise things exactly as I wanted them, hence I decided to write my own. Though the actual installer isn't included in this zip it is easy enough to write one of these yourself using a property sheet with the files to install simply added as (custom) resources. What is included here is the stub program. I have used Microsofts cab file format for compression as it meant the decompressing code is available as an API, further reducing the stub size (which is why I wrote it in assembler in the first place).

It is absolutely vital that you check the size of the assembled stub executable and check that it matches the FILESIZE equ declared in Stub.inc. FILESIZE is the offset to the compressed data. It is calculated as:

SizeOfAssembledProgram (Kb) * 1024

Once assembled, you create a self extracting archive by using the DOS Cop command.
I've included a .bat file (AppendCab.bat) to show how I went about doing this. The /b switch is essential, telling Copy that the source and destination files are binary files. Without this things simply won't work (the PE header won't be modified).

To create a cab file modify the Cab.DDF file included. This is a text file that tells the MakeCab utility how to create the cab. There is a batch file for cab creation included as well.


The C++ project I am working on at the moment needed an installer. However its requirements were minimal so I decided to write it myself. There are 2 parts:

1. A compressed dll, which contains the actual installation routine (created using property pages and not included in the zip).
2. A stub program.

The compressed dll is appended to the stub using the DOS Copy command, with the stub simply copying it to a temporary directory, decompressing it and then loading the dll. The actual installation routine starts in response to the DLL_PROCESS_ATTACH message. Compression is done via MakeCab, meaning decompression can be done using an API further reducing the size of the stub.

Attached here is the stub code plus a minimal dll that displays message boxes on load/unload etc.

Any further comments or suggestions would be most welcome.

Thanks all,
Andrew_K

Attached File ( Number of downloads: 494 )
 Login or Register to download
PMEmail Poster
Top
akyprian
Quote Post


Administrator
******

Group: Admins
Posts: 2328
Member No.: 1
Joined: 12-May 04


Hi,

Nice piece of work. Thanks for sharing. You are very fast!

I 'll study it carefully and If I have any ideas/suggestions/questions I will let you know.

Regards,

Antonis
PMEmail PosterUsers Website
Top
andrew_k
Quote Post


Active Member
***

Group: Members
Posts: 41
Member No.: 34
Joined: 25-May 04


Hi Akyprian,
Thanks for moving this. I actually should have asked where to place the thread as I had no idea which category it actually fit into!

If anyone has any suggestions I really would love to hear. Though I did enjoy writing it this is not something I have done purely for fun. We have already pre-sold a few copies of the software this is installing so I need to make sure I have it right. I knew I could more than trust advice from anyone on this forum.

Thanks again,
Andrew_K
PMEmail Poster
Top
rliuwa
Quote Post


New Member
*

Group: Members
Posts: 1
Member No.: 46636
Joined: 2-October 11


Hi Andrew,

In search of a similar topic, I run into this article you posted 7 years ago. Although it is an old thread posting, it is exactly I have been looking for.

I downloaded your code sample. Unfortunately, I am not a C++ programmer. I had a hard time to understand the logic. I am wondering if you have a C# or VB.Net version of the same code.

I have programmed my own stub and a zip file. I can easily join the two files together using

Copy /b myStub.exe+My.zip mySFX.exe

Now the problem is how to copy My.zip out of mySFX.exe. I understand I can copy part of mySFX.exe starting at offset that equals the size of myStub.exe. But I do not know how to implement it in VB.NET. Should I use file stream to read mySFX.exe then seek for the offset, or use Open File for Input/Open File for Output? I have spent a while for this but no luck so far.

I would highly appreciate if you could share any of your thought on this!

Thanks a lot!
PMEmail Poster
Top
anand mishra
Quote Post


New Member
*

Group: Members
Posts: 1
Member No.: 49445
Joined: 8-February 12


Hi Andrew,

i want to create my own stub which extract the zip file in temp folder and run a setup file from that. how can i do this.


I would highly appreciate if you share the stub source code ideas.
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google