Neverwinter Nights:Encapsulated Resource File Format

From TBotR Wiki


The Encapsulated Resource File (ERF) format is one of BioWare's methods of packing multiple files into a single file so that they may be treated as a single unit. In this regard, it is similar to .zip, .tar or .rar.

BioWare Aurora Engine/Toolset files that use the ERF format include the following: .erf, .hak, .mod and .nwm.


Localized String List
Key List
Resource List
Resource Data


(size 160 bytes)

Offset Value Type Description
0 FileType CHAR [4] "ERF ", "MOD ", "SAV ", "HAK " as appropriate
4 Version CHAR [4] "V1.0"
8 LanguageCount UINT32 Number of strings in the Localized String List
12 LocalizedStringSize UINT32 Total size (bytes) of Localized String List
16 EntryCount UINT32 Number of files packed into the ERF
20 OffsetToLocalizaedStringList UINT32 From beginning of file
24 OffsetToKeyList UINT32 From beginning of file
28 OffsetToResourceList UINT32 From beginning of file
32 BuildYear UINT32 Since 1900
36 BuildDay UINT32 Since January 1
40 DescriptionStrRef UINT32 StrRef file description
44 Reserved BYTE [116] Reserved for future use

The Reserved part of the ERF header allows for additional properties to be added to the file format later while maintaining backward compatibility with older ERFs.

Localized String List

The Localized String List is used to provide a description of the ERF. In .mod files, this is where the module description is stored.

String List Format

The String List contains a series of ERF String elements one after another. Note that each element has a variable size, encoded within the element itself. The LanguageCount from the ERF Header specifies the number of String List Elements.

In .erf and .hak files, the String portion of the structure is a NULL-terminated character string. In .mod files, the String portion of the structure is a non-NULL-terminated character string. Consequently, when reading the String, a program should rely on the StringSize, not on the presence of a null terminator.

Offset Value Type Description
0 LanguageID UINT32 Language ID
4 StringSize UINT32 Length of the String
8 String CHAR [varies] Variable size as specified by the StringSize field

Key List

(size 24 bytes * EntryCount)

The ERF Key List specifies the filename and file type of all the files packed into the ERF.

Key List Format

The Key List consists of a series of Key structures one after another. The EntryCount in the ERF Header specifies the number of Keys.

The ResRef is the name of the file with no null terminator and in lower case. A ResRef can only contain alphanumeric characters or underscores. It must have 1 to 16 characters, and if it contains less than 16 characters, the remaining ones are nulls.

The ResID in the key structure is redundant, because then it's possible to get the ResID for any ERF Key by subtracting the OffsetToKeyList from its starting address and dividing by the size of a Key List Structure.

When a file is extracted from an ERF, the ResRef is the name of the file after it is extracted, and the ResType specifies its file extension. For a list ResTypes see Resource Types.

Offset Value Type Description
0 ResRef CHAR [16] FileName
16 ResID UINT32 Resource ID, starts at 0 and increments
20 ResType UINT16 File type
22 Unused BYTE [2] NULLs

Resource List

(size 8 bytes * EntryCount)

The Resource List specifies where the data for each is located and the size of the data.

Resource List Format

The Resource List looks just like the Key List, except that it has Resource List elements instead of Key List elements. The EntryCount in the ERF Header specifies the number of elements in both the Key List and the Resource List, and there is a one-to-one correspondence between Keys and Resources.

Each Resource List element corresponds to a single file packed into the ERF. The Resource structure specifies where the data for the file begins inside the ERF, and how many bytes of data there are.

Offset Value Type Description
0 OffsetToResource UINT32 Offset to file data from the beginning of the file
4 ResourceSize UINT32 Number of bytes

Resource Data

After the Resource List, all the data in an ERF consists of raw data for all the files that the ERF contains. The data for one file is packed right up against the data for the next file. The offsets and sizes in the Resource List specify where one file ends and another begins.

Resource Types

In an ERF file, the ResType field specifies the file type of the associated file. See Resource Types for a table containing ResType values and their meanings.

Language IDs

The following is a list of languages and their IDs.

ID Language
0 English
1 French
2 German
3 Italian
4 Spanish
5 Polish
128 Korean
129 Chinese Traditional
130 Chinese Simplified
131 Japanese

Note: The LanguageID actually stored in an ERF does not match up exactly to the LanguageIDs shown above. Instead, it is 2 times the LanguageID, plus the Gender (0 for neutral or masculine, 1 for feminine).

Personal tools