Graphics directory
From Worms Knowledge Base
Revision as of 20:01, 4 July 2006 by CyberShadow (Talk | contribs)
Worms directories usually act as a file archive, containing (usually graphics) files. Its built-in hash table allows fast access to files by the file name.
The DIR file format, as well as others, was first reverse-engineered by Skeet.
File format is as follows:
- a 12-byte header, consisting of:
- a 4-byte signature - "DIR\x1A"
- complete file length, including header and table of contents (4 bytes)
- address (file offset) of the directory table of contents (4 bytes)
- the actual data of the files stored in the directory;
- the table of contents, which consists of:
- a signature (?) DWORD, 0x0000000A (4 bytes);
- a 1024-entry DWORD hash table (4096 bytes). Each entry is an offset (relative to the start of the TOC) to the first file entry, whose filename matches this hash, or 0 for no matching file entries;
- the list of files stored in the directory. Each list entry consists of:
- offset (relative to the start of the TOC) to the next entry for this hash value, of 0 for none (4 bytes)
- offset within DIR file of this file entry's data (4 bytes)
- length of file (4 bytes)
- the filename, padded to a multiple of 4 characters (with at least one after trailing \0).