Author Topic: ICE! 2.4 and more. Unpacker for packed files from AtariST. Example + static lib  (Read 1946 times)

0 Members and 1 Guest are viewing this topic.

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 978
  • Karma: 258
    • View Profile
Ok, this is probably a very specific thing only a hand full of people might find useful. But here it is anyway.
What is this?
This is a static lib which uses C codes by Hans Wessels (also included in the zip file) and a PB usage example to unpack ICE! 2.1 and 2.4 as well as Atomik 3.5 packed files. These were quite popular packers on the Atari ST and ICE! 2.4 is still used for packing SNDH (Atari ST music) files and even SC68 (Amiga/ST music) files, if I'm not mistaken.
What is it good for?
Well, for example for unpacking Atari executables on Windows to rip text from, unpack music files etc.
Or you could pack your files with one of the aforementioned packers in an Emulator (it's a shame there isn't any public Windows code to repack such files, at least I don't know of any) and have a nice (sort of) protection for you data in games etc. Well, it'll at least scare away script kiddies running a ripper... :D

Here's the example:

example.pb
Code: [Select]
;******************************************************************************************
;* This unpack example uses public domain C routines by Hans Wessels to unpack ICE 2.1,   *
;* ICE 2.4 and Atomik 3.5 files. These were popular packers on the Atari ST and are still *
;* used to pack SNDH files for example. The example only checks for ICE! 2.4 packed files.*
;* Have a look in the include file "unice.pbi" for the appropriate commands to unpack     *
;* Ice 2.1 and Atomik 3.5.                                                                *
;* Static lib compilation and small PureBasic usage example by Padman.       .            *
;******************************************************************************************



; RUN WITH DEBUGGER ON!



IncludeFile "unicelib.pbi"
 


File$ = "Monster_Business.sndh"                     ;input file
File1$ = "Monster_Business_unpacked.sndh"           ;output file



If _ReadFile(0,File$)                                    ;!!! remove the underscore, if you want to compile it in the PB editor !!!

length=Lof(0)

*MemoryID=AllocateMemory(length)                  ;allocate memory to read file to
If *memoryID
memory=ReadData(0,*MemoryID,length)
EndIf

EndIf

If Memory
   Debug "File completely written to address: " + Hex(Memory)
Else
   Debug "Error!"
   End
EndIf



h=ice_24_header(*memoryID)                        ;check for ICE! header

If h <> 0                                         ;only proceed if header <> 0
  c=ice_24_origsize(*memoryID)                    ;original size of the file
  d=ice_24_packedsize(*memoryID)                  ;packed size

Debug "Original size: "+Str(c)                    ;show original and packed file size in debugger
Debug "Packed size: "+Str(d)       



*Dest=AllocateMemory(c)                          ;reserve memory to unpack file to (c=original filesize)

 ice_24_depack(*memoryID,*dest)                  ; depack file to *dest   


CreateFile(1,File1$)                             ;create a new file on harddisk to write memory contents to

If  WriteData(1,*dest,c)                         ;write it all in there
  Debug "Unpacked file saved!"
Else
   Debug "Error!"
End
EndIf

Else
Debug "This File is not ICE! packed."            ; you get to see this if there is no ICE! header (h=0)
EndIf

And the include:

unicelib.pbi
Code: [Select]
ImportC "unicelib.lib"
  ;atm_35_get_long() As "_atm_35_get_long"
  ;atm_35_getbits() As "_atm_35_getbits"
  ;-Atomik Packer 3.5
  atm_35_header(src) As "_atm_35_header"
  atm_35_packedsize(src) As "_atm_35_packedsize"
  atm_35_origsize(src) As "_atm_35_origsize"
  atm_35_depack(src,dest) As "_atm_35_depack"
  ;get_long() As "_get_long"
  ;ice_get_long() As "_ice_get_long"
  ;ice_getbits() As "_ice_getbits"
  ;-Pack Ice 2.1
  ice_21_header(src) As "_ice_21_header"
  ice_21_packedsize(src) As "_ice_21_packedsize"
  ice_21_origsize(src) As "_ice_21_origsize"
  ice_21_depack(src,dest) As "_ice_21_depack"
  ;get24_long() As "_get24_long"
  ;ice24_get_long() As "_ice24_get_long"
  ;ice24_getbits() As "_ice24_getbits"
  ;-Pack Ice 2.4
  ice_24_header(src) As "_ice_24_header"
  ice_24_packedsize(src) As "_ice_24_packedsize"
  ice_24_origsize(src) As "_ice_24_origsize"
  ice_24_depack(src,dest) As "_ice_24_depack"
EndImport

In the zip you'll also find the compiled static lib, an example Ice! packed SNDH file and the original C sources for further exploration.

Pad :)
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17378
  • Karma: 497
  • evil/good
    • View Profile
    • My Homepage
K+ for sharing.

Useful for anyone who wants to make ST remakes!
Shockwave ^ Codigos
Challenge Trophies Won: