Home Posts

BA2 archive format

Note: Work in progress.

There are two types of archives: general and texture. Generals may contain anything except textures. Texture archives oblivously containing textures.

Some things to note:
  • Everything is encoded as little endian.
  • No padding or aligning between structures or values.

All archives consist of (in order of appearance):

All archive types sharing same header and file declarations:

Archive Header
NameTypeSizeValueNotes
Magicchar[4]4BDTXMagic for all archives
Versionuint3241Archive version
Archive typechar[4]4GNRL or DX10GNRL — general archive, DX10 — texture archive
Total filesuint324
Name table offsetuint648Offset from archive beginning to name table
Struct size: 24 bytes

File declaration is defined for each file in archive (see header -> total files).

File Declaration (General)
NameTypeSizeValueNotes
Unknown 0uint324File hash?
Extensionchar[4]4File extension. Doesn't start with dot
Unknown 1uint324Directory hash?
Unknown 2uint324File flags?
Offsetuint648Offset from beginning of archive to file data
Packed lengthuint324zlib packed length. Equals to 0 if not packed
Unpacked lengthuint324Original file length
Unknown 3uint3240xBAADF00D
Struct size: 36 bytes

Textures are DDS without header. See ba2extract (fallout4tools).

File Declaration (Texture)
NameTypeSizeValueNotes
Unknown 0uint324File hash?
Extensionchar[4]4dds\0File extension. Doesn't start with dot
Unknown 1uint324Directory hash?
Unknown 2uint81
Number of chunksuint81
Chunk header sizeuint162
Texture heightuint162
Texture widthuint162
Number of mipmapsuint81
Formatuint81DXGI_FORMAT
Unknown 3uint1620x0800
Struct size: 24 bytes

Texture chunks is defined for each file declaration several times (see file declaration -> number of chunks).

Texture Chunk
NameTypeSizeNotes
Offsetuint648Offset from archive beginning to texture chunk data
Packed lengthuint324zlib packed length. Equals to 0 if not packed
Unpacked lengthuint324Original file length
Start mipmapuint162
End mipmapuint162
Unknown 0uint3240xBAADFOOD
Struct size: 24 bytes

Name table string is defined for each file in archive. Each string is null-terminated. This is basically Pascal string.

Name Table String
NameTypeSizeNotes
String lengthuint162
Charchar[][String length]Use string length to read all chars