WindThunder Package File Format

WindThunder Package Files are used in *Heroine Anthem I&II*, and
possibly in a few other titles from WindThunder. They provide the
hulking beast of graphical power needed by WindThunder games. Their
proper extension is ".bin."

I have yet to see a WT Package File under 750MB, making these things
mammoth. Their offsets are defined by double values, making the
upper-limit of a WT Package File somewhere around 16 exabytes. As of
this document, the entire content of archive.org could fit in one
WT Package File.

The file format was made to cope with the massive amount of graphics
constantly pulled into *Heroine Anthem*. By putting all the graphics
into one file, WindThunder was able to cut down on disk space and
speed up it's graphic loading by keeping one file stream open
throughout the game instead of constantly opening new ones.


File Format

The structure of a WT Package File is detailed below:

ID Tag: 'WT Package File' [24 bytes, string]
File count [8 bytes, double]
(file loop)
  File name [24 bytes, string]
  File path [128 bytes, string]
  File size [4 bytes, long]
  File offset [8 bytes, double]
(end loop)
(data)


Proof of Concept

A proof of method capable of extracting any WT Package File follows:

$fd = fopen ('WTPack.bin', 'rb');
if(rtrim(fread($fd, 24)) != 'WT Package File') die;
list($junk, $count) = unpack('d*', fread($fd, 8 ));
$name = array();
$source = array();
$size = array();
$offset = array();
for($i=0; $i< $count; $i++) {
  $name[$i] = rtrim(fread($fd, 24));
  $source[$i] = rtrim(fread($fd, 128));
  list($junk, $size[$i]) = unpack('V*', fread($fd, 4));
  list($junk, $offset[$i]) = unpack('d*', fread($fd, 8 ));
}
for($i=0; $i<$count; $i++) {
  foreach(split('/',dirname($source[$i])) as $dirpart)
    mkdir($newdir=$newdir.$dirpart.'/');
  $fo = fopen($source[$i].$name[$i], 'w');
  fseek($fd, $offset[$i], SEEK_SET);
  fputs($fo, fread($fd, $size[$i]));
  fclose($fo);
}


Copyright (c) 2005 Derrick Sobodash. Some Rights Reserved.

This work is licensed under a CC Attribution-ShareAlike 4.0 International
License (http://creativecommons.org/licenses/by-sa/4.0/).