neosophaux / amta-decompressor Goto Github PK
View Code? Open in Web Editor NEWDecompresses AMTA archives for games like Battle for the Galaxy and other titles by AMT Games.
Decompresses AMTA archives for games like Battle for the Galaxy and other titles by AMT Games.
AMTA decompression for "Battle for the Galaxy" by AMTGames Ltd. Documentation by https://github.com/neosophaux: A simple compression algorithm that wraps the data stream generated by another compression algorithm known as LZO(Lempel–Ziv–Oberhumer) using an XOR technique. Note: The AMTA files I analyzed are in little-endian format. Before the algorithm inflates it's data, a series of checks must be performed to ensure the full recovery of the data. The first of those checks is a size check on the file data itself. If the size of the file is <= 8, then the algorithm stops due to a lack of data(8 bytes is the header length). Next, the algorithm then processes the file header. First, it ensures that the first 4 bytes of the file contains the following magic bytes: [0x61, 0x6d, 0x74, 0x61] ('a', 'm', 't', 'a'). If those bytes are not found, then the algorithm quits due to a mismatching header. The algorithm then reads the next 4 bytes of the file as an unsigned integer that is meant to be the size of the original decompressed file. If it is 0, >= 0x6400001, or if the size doesn't match the uncompressed data, then the algorithm will stop and raise an error. The first byte that comes after the header is then read and XOR'd with 0x56. The purpose of it is unknown but my current assumption is it's to make the LZO stream valid. After the inflation to an LZO stream, the original byte within the file data must be replaced with the XOR'd version. The rest of the file data is then processed in a loop that only iterates when a variable I will call 'offset' is > 0. The offset variable is initiated with the data size of the AMTA archive. On successful iteration of the loop, the offset variable is decremented by 1. In the loop, the file is read 1 byte at a time, but operations are performed on two neighboring bytes called byte 'a' and byte 'b'. The first byte, byte 'a', is located by seeking to the value of the offset variable(mentioned above) and then seeking 1 byte backwards. Byte 'b' is located in a similar fashion, but instead of seeking 1 byte backwards, the algorithm will seek 2 bytes backwards. To inflate, byte 'a' and byte 'b' are XOR'd together; the resulting byte is then placed where byte 'a' once was. Finally, the inflated LZO stream is decompressed using the lzo1x decompression algorithm and the length of the decompressed LZO stream is checked against the size determined in the AMTA header. If it fails, then the decompressed data is invalid.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.