Skip to content

ristonecrackerlib

StoneCracker was a popular packer on the Amiga. This library handles data files packed with its version 4.04 (files that begin with the letters S404) inside a program; it cannot pack files, and it does not handle packed executables. Together with STCDecrunch of the RI STC Decrunch library it covers everything needed to use packed data.

A packed file is unpacked in place: the unpacked data end up a little behind the start of the buffer, at a “security offset” the file names. STCSafeLen gives the size the buffer needs for that, STCStart where the data begin, and STCLength their length. All three read only the header of a file that is already in memory and return 0 if the memory holds no StoneCracker 4.04 file.

STCLoad loads a file and unpacks it in one step, with dos.library, which the library opens when the program starts and closes at its end. The other functions use no operating system calls.

STCLoad unpacks a file only if it could read all of it and it is a whole StoneCracker 4.04 file. The unpacking code, the same as that of STCDecrunch, writes nothing outside the buffer for damaged data and then returns 0; it does not check what it reads. It is a little faster than the original’s, about 4 % on a large file.

The fixed bugs of the libraries are listed in Fixes in ristonecrackerlib and ristcdecrunchlib.

Based on the RI STC Lib guide by Reflective Images.

Library number 17.

Commands

STCLength

The unpacked length, in bytes, of the StoneCracker 4.04 file at address in memory; 0 if address holds no such file.

Function, result .l. Help text: address -- returns unpacked size
Arguments: .l

STCLoad

Loads the StoneCracker 4.04 file filename$ to the memory at address and unpacks it there in place. As a function it returns the address of the unpacked data, as STCStart does, or 0 if the file could not be locked, opened or read, or is no whole StoneCracker 4.04 file, or for damaged data that would write outside the buffer.

Statement or function, result .l. Help text: filename$,address
Arguments: $, .l

The program provides the buffer; it must hold STCSafeLen bytes and the whole file, which is read whatever its length.

STCSafeLen

The smallest buffer, in bytes, in which the StoneCracker 4.04 file at address can be unpacked in place; 0 if address holds no such file.

Function, result .l. Help text: address -- safe unpack buffer size
Arguments: .l

A smaller buffer is overwritten past its end when the file is unpacked.

STCStart

The address where the data of the StoneCracker 4.04 file at address begin once it is unpacked in place; 0 if address holds no such file.

Function, result .l. Help text: address -- returns address of unpacked data
Arguments: .l

Use it after STCDecrunch with one argument: unpacked in place, the data lie at a small offset behind the start of the file.