STEINS;GATE unpacker (Steam edition)

A bit of a deviation from the normal posts, I've just released an unpacker tool for the Steam edition of the game STEINS;GATE. It can be used to extract the raw files out of the game's proprietary mpk archives. The game itself is not really my kinda thing, but a friend wanted an obscure track* from it and - given it's the holidays - the challenge of reverse engineering a proprietary data format was too good to pass up.

As it turns out, the MPAK format is super simple. I hadn't done anything like this before, but the hex editor in Visual Studio and the excellent output capabilities of LINQPad made it a breeze. The format appears be as follows:

0x00000000 format indicator (always 'MPK')  
0x00000008 entry count (short)  
0x00000040 start of entry listings (length is 256b per entry)  
0xnnnnnnnn start of data (follows the listings)  

The entry listing format is:

# offsets relative to the beginning of the listing
0x00000000 unknown, always 0?  
0x00000008 offset indicator  
0x00000010 length  
0x00000018 length (same as previous)  
0x00000020 filename (up to 224 bytes)  

My guess is that the two lengths are intended to differentiate between compressed and uncompressed size, and that the first unknown flag is meant to indicate whether the file is compressed, but none of the files I was given to test exhibited this.

The unpacker has a few command line flags that you can use to control what is extracted, and it looks like much of the content is in known formats, like .ogg for the audio and .png for the backgrounds. So, if you happen to need an unpacker for STEINS;GATE, now you have one!

* The track ended up being BGM23, which I actually really like.

Edit:
After some more searching, I found a script for a tool called QuickBMS apparently written by one of the game's developer. It confirms the hypothesis that the initial entry indicator determines whether the files are compressed and that one of the lengths is the compressed size, and that I was more or less on the money with the format. QuickBMS looks like the right approach to this kind of extraction en-masse but this was a fun task nonetheless!