English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Releases

 
 
Thread Tools
Old 31 January 2019, 19:05   #1
kaffer
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 586
Cross-developer executable packer

I have just completed a tool for creating self-unpacking Amiga executables in a cross-development environment.

To build, you need bebbo's amiga-gcc6 installed. Then:
Code:
git clone https://github.com/keirf/Amiga-Stuff
cd Amiga-Stuff/inflate && make
To pack an executable:
Code:
python3 path/to/inflate/pack_exe.py original.exe packed.exe
This uses gzip -9 for the compression, so it's quite decent, and the unpack times aren't too bad.
kaffer is offline  
Old 01 February 2019, 12:30   #2
kaffer
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 586
I have applied some fixes and improved the script's compression summary. I'm using it for packing game executables as part of patching for FlashFloppy's auto-disk-swap feature. For example on Monkey Island 2:
Code:
python3 ../pack/pack_exe.py "Monkey2 Disk 1/monkey2" monkey2.pack
 [Nr] Type      File (   delta,      %)    Memory (delta)
-----------------------------------------------------------
 [--] Header     144 (      +4,  +2.9%)
 [00] Code     72060 (  -79024, -52.3%)    143432 (   +8)
 [01] Data       128 (    -128, -50.0%)       148 (   +4)
 [02] BSS          8 (      -4, -33.3%)         8 (   +0)
 [03] BSS          8 (      -4, -33.3%)         8 (   +0)
 [04] BSS          8 (      -4, -33.3%)      2048 (   +0)
 [05] Data       160 (    -208, -56.5%)       188 (   +4)
 [06] BSS          8 (      -4, -33.3%)         4 (   +0)
 [07] Data        20 (      -4, -16.7%)        12 (   +0)
 [08] BSS          8 (      -4, -33.3%)       208 (   +0)
 [09] Data        24 (     -20, -45.5%)        36 (   +4)
 [10] BSS          8 (      -4, -33.3%)       584 (   +0)
 [11] BSS          8 (      -4, -33.3%)       528 (   +0)
 [12] Data        32 (     -12, -27.3%)        36 (   +4)
 [13] BSS          8 (      -4, -33.3%)       912 (   +0)
 [14] BSS          8 (      -4, -33.3%)       148 (   +0)
 [15] BSS          8 (      -4, -33.3%)       396 (   +0)
 [16] Data        16 (      -4, -20.0%)         8 (   +0)
 [17] BSS          8 (      -4, -33.3%)       132 (   +0)
 [18] Data        32 (     -12, -27.3%)        36 (   +4)
 [19] BSS          8 (      -4, -33.3%)       960 (   +0)
 [20] Data        12 (      -4, -25.0%)         4 (   +0)
 [21] BSS          8 (      -4, -33.3%)       436 (   +0)
 [22] Data        76 (      -4,  -5.0%)        68 (   +0)
 [23] Data       248 (    -604, -70.9%)       844 (   +4)
 [24] Data        88 (     -44, -33.3%)       100 (   +4)
 [25] BSS          8 (      -4, -33.3%)      5072 (   +0)
 [26] Data        60 (     -24, -28.6%)        76 (   +4)
 [27] BSS          8 (      -4, -33.3%)        52 (   +0)
 [28] BSS          8 (      -4, -33.3%)         8 (   +0)
 [29] Data      2952 (   -5764, -66.1%)     30572 (   +0)
 [30] DEPACK    2448                         3980
-----------------------------------------------------------
               78628 (  -83468, -51.5%)    191044 (+4020)
After depack:                              187064 (  +40)

** RESULT:
** Original: Monkey2 Disk 1/monkey2 = 162096 bytes
** Compressed: monkey2.pack = 78628 bytes
** Shrunk 83468 bytes (51.5%)

Last edited by kaffer; 01 February 2019 at 12:55.
kaffer is offline  
Old 01 February 2019, 12:48   #3
WayneK
Registered User
 
Join Date: May 2004
Location: Somewhere secret
Age: 45
Posts: 299
Can we have a 'raw data' version of the unpacker, for use in cracks etc? I'm sure we can handle gzipping the files + altering headers, but if you wanted to add a 'raw' mode to the packer script too that would make it even easier
WayneK is offline  
Old 01 February 2019, 12:53   #4
kaffer
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 586
Quote:
Originally Posted by WayneK View Post
Can we have a 'raw data' version of the unpacker, for use in cracks etc? I'm sure we can handle gzipping the files + altering headers, but if you wanted to add a 'raw' mode to the packer script too that would make it even easier
The script shells out to another tool to extract the raw DEFLATE stream. See degzip in the same Amiga-Stuff/inflate dir as the script.

It also tells you the number of security bytes (aka leeway) that you need if you unpack in place (ie. with the packed data at the end of the unpack buffer, how many bytes longer than the unpacked data must the buffer be).
kaffer is offline  
Old 01 February 2019, 13:47   #5
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,425
Quote:
Originally Posted by kaffer View Post
I have just completed a tool for creating self-unpacking Amiga executables in a cross-development environment.


Quote:
This uses gzip -9 for the compression, so it's quite decent, and the unpack times aren't too bad.
Where you got the unpacker?
There is somewhere on board a very fast routine available.

Quote:
Originally Posted by kaffer View Post
It also tells you the number of security bytes (aka leeway) that you need if you unpack in place (ie. with the packed data at the end of the unpack buffer, how many bytes longer than the unpacked data must the buffer be).
What are the values on average for the leeway?
ross is offline  
Old 01 February 2019, 14:17   #6
kaffer
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 586
Quote:
Originally Posted by ross View Post
Where you got the unpacker?
There is somewhere on board a very fast routine available.
I use my own, it's fairly fast especially given its size and the complexity of DEFLATE stream handling. Let's say it processes on a basic A500: 25kB/s of compressed input stream, generating approx 50kB/s of output.
(EDIT: This approximately offsets the reduced disk-access time if reading from floppy.)

If there is a faster routine I would like to know, but it depends how big it is: my routine is about 930 bytes, or 630 bytes for a smaller but slower (50%) build.

Quote:
What are the values on average for the leeway?
It's almost always 2 bytes, which gets rounded up to a longword per compressed hunk.

EDIT: You can see this in the output example above, the last summary column is leeway added to each hunk. Where that is zero is usually because the hunk data did not exist or did not compress. The first hunk has +8 bytes because I need room at the end of the segment to write my epilogue code that jumps to the original exe (after the main Depacker segment has freed itself):
Code:
movem.l (sp)+,d0-d7/a0-a6
rts

Last edited by kaffer; 01 February 2019 at 14:29.
kaffer is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zip packer corrupting files ? Retroplay support.Apps 13 23 July 2011 13:17
old soundeditors and pt-packer Promax request.Apps 7 14 July 2010 14:21
Pierre Adane Packer Muerto request.Modules 15 21 October 2009 19:03
Power Packer PP Files HELP D4Ni3L3 support.Apps 2 30 September 2008 07:20
Cryptoburners graphics packer Ziaxx request.Apps 1 06 March 2007 11:30

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:31.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.09162 seconds with 15 queries