# SoftAction Resource Files #

These files are used in some games by Korean publisher SoftAction SDT.
More specifically, they are used in SoftAction's *Langrisser I&II*
remakes, where I encountered them. Their extension is .RES.

SoftAction Resource Files are just another package format very similar
to Microsoft Fastfile. They were designed to speed up games depending
on DirectX 6.0.

The file begins with a long value telling the file count, then loops
through a file table based on DOS 8.3 file names.

Surprisingly, despite being used to stream data off the game CD,
the files aren't padded out to begin at even sectors.


## File Format ##

The file loop is detailed below. All values are stored in
little endian ordering, and strings are padded by 0x00:

<pre>File count [4 bytes, long]
(File loop)
  File name [16 bytes, string]
  File offset [4 bytes, long]
  File size [4 bytes, long]
(End loop)
(Data)</pre>


## Proof of Concept ##

A proof of method to extract a resource file is shown below:

<pre class="line-numbers"><code class="language-php">$fd = fopen('tdat.res', 'rb');
$count = unpack('V*', fread($fd, 4));
$filename = array();
$offset = array();
$size = array();
for($i=0; $i< $count; $i++) {
  $filename[$i] = rtrim(fread($fd, 16));
  $offset[$i] = unpack('V*', fread($fd, 4));
  $size[$i] = unpack('V*', fread($fd, 4));
}
for($i=0; $i<$count; $i++) {
  fseek($fd, $offset[$i], SEEK_SET);
  $fo = fopen($filename[$i], 'w');
  fputs($fo, fread($fd, $size[$i]));
  fcolse($fo);
}
fclose($fd);</code></pre>


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/).