Archive for the ‘Wolf RPG Editor Games’ Category

DXExtract

Sunday, February 24th, 2013
TitleDXExtract (1.0)
Screenshot
Game(s)Gensokyo Shiki,Wolf RPG Editor Games
Year2013
Estimated date2013-02-21
Author(s)finale00
CategoryGame Resource Archives
PlatformPC
Description

Here is a general tool that I wrote for unpacking DX archives (don't know what they are called, but they start with DX so I just took that).
These archives are used in various programs/games, such as
Wolf RPG Editor (basically all games using this program) - viewtopic.php?f=21&t=7981
Gensokyo Shiki - viewtopic.php?f=21&t=9468

struct Header {
  char[2] "DX"
  int16 version
  int32 tableSize   // size of the whole file table
  int32 headerSize  // size of this header
  int32 tableOffset // where the table begins
  int32 nameSize    // size of the name section of the table
  int32 entrySize   // size of the entry section of the table

  ???               // more ints, depending on the size of the header
}

struct NameEntry {
  int16 len
  int16 ?
  char[len*4] uppercase name
  char[len*4] name
}

struct FileEntry {
  int32    nameOfs  //
  int32    type
  int32[6] ??       // could be shorts I'm not too sure
  int32    offset
  int32    size
  int32    zsize    // -1 if not compressed
}

struct DirEntry {
  int32 entryOfs    // offset of entry containing this directory's info
  int32 parentID    // divide by 16
  int32 entryCount  // number of entries in directory (file or folder)
  int32 ?           // some other offset
}

===============================================================================

The file table in this format is broken up into three sections:

1. Names
2. Entries
3. Directory structure

From the header, you can get the offsets to each section as follows

nameOffset = tableOffset
entryOffset = tableOffset + nameSize
dirOffset = entry_offset + nameOffset

[b]Directory Structure[/b]

You would probably start by getting the directory structure.
Just keep looping until you reach EOF.

Each directory entry (dirEntry) contains 4 integers. I don't know what the
first and last are, but it is sufficient to know the parent ID and the number of
entries in each directory.

The directories are stored in an array, where the root directory is the first element
with a parent ID of 0, and then you just keep appending to the array.

[0, 1, 2, 3, 4, 5, ... ]

One thing to note is that this array basically flattens the directory structure.
Consider the following directory structure. The first column of numbers is the dir ID, while the second column of numbers is the parent ID

[code]
Root        0 -1
  A         1  0
  B         2  0
    C       3  2
  D         4  0
    E       5  4
      F     6  5
  G         7  0
[/code]

The directory entries would be listed as

[Root, A, B, C, D, E, F, G]

Full paths for subdirectories can be built by recursing over parent ID's and concatenating the names together.

[b]Entries[/b]

After building the directory structure, you can basically begin extracting the files.
Again, you will just keep looping until you reach dirOffset.

The first file entry begins at entryOffset.
The first integer in an entry is the offset of the name. Simply add this to the  nameOfs and you will find it. Parse the name entry accordingly to get the filename. Note that each name is padded to 4 bytes.

There are two types of entries, given by the second integer:

0x10 = directory entry
0x20 = file entry

The root directory is considered a directory as well, and is the first entry. You will find it thas no name, which is normal.
Each entry is 44 bytes long.
The algorithm for getting all of the files in the correct order is

for each directory
  for i = 1 to entries in directory
    parse entry
    build path name
    export file
  end
end

[b]Compression format[/b]

I am not sure how it works
FileDownload
Forum linkView thread