BND
BND are standalone archive files, storing uncompressed and named files, with a relative or absolute virtual path. BND probably stands for Binder.
BND archives are structured as follows:
- Header
- File entries
- 0-terminated string contiguous block
- File data block
Header
struct BndHeader { /* 0x00 */ char magic[12]; // magic, 'BND3' + stuff, see above /* 0x0C */ uint32_t flags; // infos about BND structure /* 0x10 */ uint32_t num_entries; // number of file entries /* 0x14 */ uint32_t data_position; // position to file data block /* 0x18 */ uint32_t unk1; /* 0x1C */ uint32_t unk2; }
Data position points right after the last string terminator, but entries data position are 16-byte padded.
Flag | Meaning |
---|---|
0x01 | ? |
0x02 | ? |
0x04 | Use 24 bytes data entries |
0x08 | ? |
0x10 | ? |
0x20 | ? |
0x40 | ? |
0x80 | ? |
File entries
The file entry structure is different if BndHeader.flags & 0x4
. If
the flag is set, the BND uses BndFileEntry24 structures (24 bytes), else it uses
BndFileEntry20 structures (20 bytes). The additional uint32 seems to always be
equals to data_size.
Besides, it's quite similar to BhfFileEntry. Offsets are absolute.
struct BndFileEntry24 { /* 0x00 */ uint32_t unk1; // always 64 ? /* 0x04 */ uint32_t data_size; // file size /* 0x08 */ uint32_t data_offset; // offset to data in file data block /* 0x0C */ uint32_t id; // /* 0x10 */ uint32_t name_offset; // offset to file name in string block /* 0x14 */ uint32_t unk2; // ? same as data_size }
struct BndFileEntry20 { /* 0x00 */ uint32_t unk1; // always 64 ? /* 0x04 */ uint32_t data_size; // file size /* 0x08 */ uint32_t data_offset; // offset to data in file data block /* 0x0C */ uint32_t id; // /* 0x10 */ uint32_t name_offset; // offset to file name in string block }
I'm not sure what the uint32_t at 0x0C stands for. It looks like it's always a big unique round integer (e.g. 4000000). As this struct is similar to BhfFileEntry and its 0x0C uint32_t is some kind of ID, I suspect it's the same thing going on here.
String block
Classic 0-terminated string contiguous block. 16-byte padded at its end. File names can be absolute Windows file names (with single backslashes), located on a "N" drive. They can also be relative (to what?) and *may* start with a backslash. I don't understand the logic there.
File data block
16-byte padded file data.