Asset Storage

From Genshin Impact Technical Wiki
Revision as of 08:53, 30 August 2024 by NikunoMenura (talk | contribs) (Add more information regarding Blb3)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Genshin Impact stores its game assets within encrypted Unity AssetBundles, a standard format that has been documented extremely well. To make things difficult, the encryption used has evolved over time, being entirely overhauled in version 4.6. Music and cutscenes and stored in a different format, and are documented on their respective articles: Music Storage and Cutscene Storage.

Genshin Impact stores asset files in the StreamingAssets/AssetBundles/blocks directory, with each numbered directory representing a different AssetBundle. Each AssetBundle is divided up into blocks, usually around ~2-5MB in size for the legacy version, and ~50MB for the modern version.

Despite both the legacy and modern version of asset blocks sharing the file extension of .blk, they are entirely different.

Legacy (Pre 4.6)

Prior to version 4.6, blocks were encrypted with a combination of static AES256 encryption and dynamic XOR encryption, the latter changing every patch. This format of asset block can be identified by the mark 62 6C 6B ("blk") at the start of the file, and a smaller file size of <10MB.

TODO: Document this in depth, maybe with code snippets

Modern (Post 4.6)

TODO: All of this information is being gatekept. Figure it out and document it here.

TODO: Apparently, Blb2 is also a thing (magic 42 6C 62 02, notice it ends in 0x02 not 0x03), but I was unable to find any info on when it was used, and it appears that no release version uses it.

TODO: It is not known how encryption actually works, we just know what the file "layout" looks like.

In version 4.6, Genshin Impact completely revamped the asset block file format. Even though this format still keeps the extension of .blk, it is codenamed Blb3.

This format of asset block can be identified by the magic string 42 6C 62 03 ("Blb" and the 0x03 byte) at the start of the file, and a considerably larger file size of around 50MB.

The layout of the file is as follows:

  • The literal bytes 42 6C 62 03, known as the magic (see Magic number).
  • 4 bytes, interpreted as an Unsigned Integer, known as the size.
  • 4 bytes, whose use is currently unknown.
  • 16 bytes, used for decryption, known as the header.
  • Then, you have to take the amount of bytes specified by size. This is known as the buffer.
  • After this, we do not know how the file continues, but the rest of the contents are (presumably) all data.