Skip to content

Instantly share code, notes, and snippets.

@Kein
Created November 14, 2022 21:32
Show Gist options
  • Save Kein/d9abc94c9e34883d91063d2f0d16bded to your computer and use it in GitHub Desktop.
Save Kein/d9abc94c9e34883d91063d2f0d16bded to your computer and use it in GitHub Desktop.
General overview of modern encrypted FMOD bank/fbs files
//===================
// DEFINITIONS
//===================
typedef struct
{
char MAGIC[4];
uint32 FullSize;
char FMTMAGIC[8];
uint32 Unk1;
uint32 Unk2;
uint32 Unk3;
} RIFF <optimize=false>;
typedef struct
{
char MAGIC[4];
uint32 Size;
byte Blob[Size];
} LSTCHUNK <optimize=false>;
typedef struct
{
char MAGIC[4];
uint32 Size;
byte Blob[Size - Skip0Bytes(FTell())];
} SNDCHUNK <optimize=false>;
//===================
// HELPERS
//===================
void EnsureFormat(RIFF &header) {
local string error = "Not a valid/supported BANK file";
Assert(header.MAGIC == "RIFF", error);
Assert(header.FullSize + 8 == FileSize(), error);
Assert(header.FMTMAGIC == "FEV FMT ", error);
}
int Skip0Bytes(uint64 pos) {
local ubyte b = 0;
local int c = 0;
while (b == 0)
b = ReadUByte(++c + pos);
FSeek(pos+c);
return c;
}
//===================
// PARSING
//===================
struct BANK
{
RIFF header;
EnsureFormat(header);
LSTCHUNK LIST0;
if (FileSize() - FTell() > 8)
SNDCHUNK SND;
} BankData <optimize=false>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment