Hi,

attachment below is an example of creating a self extracting archive.

This one was coded using FASM. Uses .rar decompression.

Here's an overview how this works:

1. execute sfx.exe
2. unpack unrar.dll
3. unpack sfx.rar
4. extract sfx.rar
5. delete sfx.rar

you can get your copy of the library here: http://www.rarlabs.com/rar_add.htm UnRARDLL.exe - also includes examples for C, VB and Delphi

What's good about this, is that you can create your own custom installer. You will have full control over everything what the installer does.

Good Luck! :alright:




tested on win2k... rename to .exe ... I'll test this on win98 later...

and also when you see this line include '\dev\include\fasm\windows.inc' - you can get this include at the FASM forum... what I did here is: I joined all the includes(dtypes.inc, equates.inc...) to one file (windows.inc), so don't be surprised if you don't see the windows.inc

change the path btw!... :grin:
Posted on 2003-01-16 16:55:31 by arkane
what's really bad about this is... you have to include unrar.dll everytime... anyway, I'll create another sample without the use of dll's later... if I can find some "info"... :grin:

you can still use the code to create your own .rar decompression program. :grin:
Posted on 2003-01-16 17:53:28 by arkane
Nice to see some front-ends for unrar. :alright: But as far as an installation
system goes, im pretty satisfied with the one from Nullsoft.
http://www.nullsoft.com/free/nsis/ Its free and let you script
and define alot(looks good to). The installer doesnt support rar
tho! but it use zlib/bzip2 compression. For me that is sufficent
enough.
Posted on 2003-01-16 18:41:11 by natas
actually, I have a lot of free installers plus I have a wise installer pro but I hate it when you can't control everything from the coding of the .exe up to the design of the installer.

these installers are HLL to me. No offense to HLL coders, because I too code in HLL but sometimes you just don't feel safe with those "other" installers. ;)

ideas: Custom-windows, custom-buttons... even installers with DirectX or OpenGL intros... :alright:

anyway, I'm happy with visual studio installer for small installations...


p.s.: I hate installers personally... I think they are installing files I don't know and modifying the registry without consulting me :grin: ... the good 'ol .zip or .rar is still the best IMO. :alright:
Posted on 2003-01-16 18:48:01 by arkane
eeek, extracting archives and DLLs and... uff. Include decompression library statically in your app (there's free unrar source code out there that doesn't require DLLs), and extract .rar archive directly from your exe. There's no point in doing something in assembly if you don't do it better...
Posted on 2003-01-17 02:36:45 by f0dder
Hi Arkane,
I like it also the rar file format.
I was used to modify the resources of the rar.sfx modules and give the commands on the archive comments:
Posted on 2003-01-17 03:03:40 by pelaillo
How can I get a static library for unrar?

Regards,

Vortex
Posted on 2003-01-17 04:27:28 by Vortex
try googling. "unrar library", for instance.
Posted on 2003-01-17 07:41:11 by f0dder
f0dder:
eeek, extracting archives and DLLs and... uff. Include decompression library statically in your app (there's free unrar source code out there that doesn't require DLLs), and extract .rar archive directly from your exe. There's no point in doing something in assembly if you don't do it better...
yes I know there is one it's called Unique Rar Lib, this has been used on the demo scene but it only supports winrar 2.x not 3.x which I'm currently using.

Anyway, I'll try to downgrade to 2.x - not a big deal. :tongue: An exampe wouldn't hurt. :grin:


pelaillo:
But having the full control over it is better and will also useful as *own* file format. The main drawback of this is that the decompression is in the public domain but the compression is still propietary (I wonder if RarSoft will change this in the future, maybe this will help in the difussion of rar).
I hope it will change. :alright:




btw I think there is some source code on rar labs... I'll check it out but I have not time to go through all the source code since it has a dozens of files.
Posted on 2003-01-17 10:14:34 by arkane
Arkane,

you can try the static library from:

http://www.unrarlib.org/download.html

Regards,

Vortex
Posted on 2003-01-17 12:12:14 by Vortex
that library requires me to downgrade... to 2.x from 3.x :)

anyway, I'm using .zip on the next example, there are more info on zip format than .rar. :grin:

I'm having second thoughts on downgrading. :grin:

I'll probably change to PPMD if free time allows me. :grin:
Posted on 2003-01-17 13:01:24 by arkane
Arkane,

That library is suitable for practical works.
Sometimes,we are not forced to use the latest technology. :)

Regards,

Vortex
Posted on 2003-01-18 04:25:36 by Vortex
doesn't the source at rarlabs.com work with rar3 archives? Also, don't even consider going zip - nonsolid compression, ick!
Posted on 2003-01-18 04:37:16 by f0dder
That library is suitable for practical works.
Sometimes,we are not forced to use the latest technology.
ok! ok! I'll downgrade but I'll try it later cause I have other things to do. :grin:
doesn't the source at rarlabs.com work with rar3 archives? Also, don't even consider going zip - nonsolid compression, ick!
yes it works on rar3 - I still haven't checked the source code, I'll create a static library for it later.

I'll try the rarlabs source first but if I'm not "elite enough" :grin: to correct the codes to compile then I think I'll consider downgrading then use rar 2.x. + unrarlib :grin:
Posted on 2003-01-18 11:04:38 by arkane
Good luck Arkane! :)
:alright:

Regards,

Vortex
Posted on 2003-01-18 14:38:38 by Vortex
In the example of arkane he coded the following

icldata FILE "sfx.rar"

and

dlldata FILE "unrar.dll"

So, what I am searching for is the command that I have to use in MASM instead of FILE what is used in FASM only, I think. Because the FILE command doesn't seem to work with MASM.

thanx ChigpA
Posted on 2003-01-18 17:49:37 by ChigpA
You need bin2asm.exe - try searching google.

Binary 2 ASM Converter v1.00 (32bit) by : Peter Quiring
BIN2ASM <binary_filename> <asm_filename> <label>

bin2asm produces an include file.

edit the include file like this
rardata_start:

db 052h,061h, ...
...
db 019h,01eh, ...
rardata_end:
remove the .data directive if you plan to include the 'include' on the code section if not then probably using the 'label' directive will allow you to create labels on the data section - haven't tried using 'label'
[size=9];ml /c /coff sfx.asm

;link /section:.text,rwe /subsystem:windows sfx.obj

.686
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE

INCLUDE \dev\include\masm\windows.inc
INCLUDE \dev\include\masm\kernel32.inc
INCLUDELIB \dev\lib\masm\kernel32.lib
INCLUDE \dev\include\masm\user32.inc
INCLUDELIB \dev\lib\masm\user32.lib

.CODE

;=========================
;main application
;=========================

msgcaption DB "sfx",0
msgboxtext DB "Do you want to extract the file/s?",0
bytewritten DD ?

;=========================
;.rar details
;=========================

rarout DB "unrar_o.rar", 0
INCLUDE unrar.asm

start:

invoke MessageBox, NULL, OFFSET msgboxtext, OFFSET msgcaption, MB_YESNO or MB_ICONQUESTION
cmp eax, IDNO
je exit

;=========================
;unpack .rar
;=========================

invoke CreateFile, OFFSET rarout, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
push eax
invoke WriteFile, eax, rardata_start, (rardata_end - rardata_start), OFFSET bytewritten, NULL
call CloseHandle

;=========================
;extract .rar
;=========================

exit:

invoke ExitProcess, NULL

END start[/size]
Unrar.asm is the output created by bin2asm.

You know, I'm thinking of rewriting the rar library in assembly cause this is going nowhere. :grin:

The source code for unrar is so convoluted. I tried "dll to lib" but this softwares requires me to pay $99 and the static lib produced by the unregistered version :grin: includes an annoying message box everytime the app runs.

Anyway, I think converting to asm is fun :grin: plus I can add optimizations (I guess) :grin:
Posted on 2003-01-18 18:24:57 by arkane
7zip code is open source, and has better encryption algorithms.
Posted on 2003-01-18 19:10:26 by JCP
use my nifty bin2o instead of bin2inc :). fun to see somebody mention Peter Quiring, btw. I had a great time with qlib.

dll2lib is rather bugged. Ok, it's not _the_ easiest task to convert dll to lib, but still. I wouldn't register it.

Nice to see that they at least chose LGPL instead of the atrocious GPL.
Posted on 2003-01-19 09:59:09 by f0dder
Here is a an example of Self Extracting Archive.
The compression software belongs to Jeremy Collake.
Compared to zip,the JC routines provides better compression.




.386
.model flat,stdcall
option casemap:none

extractfile PROTO :DWORD, :DWORD, :DWORD
JCALG1_Decompress_Fast PROTO :DWORD, :DWORD
JCALG1_GetUncompressedSizeOfCompressedBlock PROTO :DWORD

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
savefile db 'Graph.exe',0
include graph.inc

.data?
fh dd ?
hMem dd ?
fSize dd ?

.code
start:
invoke JCALG1_GetUncompressedSizeOfCompressedBlock,addr graph
mov fSize,eax
invoke GlobalAlloc,GMEM_FIXED,eax
mov hMem,eax

invoke JCALG1_Decompress_Fast,addr graph,eax
invoke extractfile,addr savefile,hMem,fSize
invoke GlobalFree,hMem

invoke ExitProcess,0


extractfile PROC filename:dword,fileloc:dword,filelen:dword

LOCAL fHandle:dword
invoke _lcreat,filename,0
mov fHandle,eax
invoke _lwrite,fHandle,fileloc,filelen
invoke _lclose,fHandle
ret

extractfile ENDP

end start

Posted on 2003-01-20 02:42:32 by Vortex