Skip to content

Conversation

@snowyegret23
Copy link
Contributor

Problem

Saving UnityFS bundles with UnityPy could produce corrupted block info metadata. In some cases (e.g., Unity 2019.3.x),
UnityPy wrote header-only flags into block info entries. This could cause block info size/parsing mismatches on reload
and lead to struct.error during BundleFile.read_fs().

Root cause:

save() passed block_info_flag=64 for the “none” packer, and save_fs() used that flag directly for block info entries.
The 0x40 bit is a header/layout flag (BlocksAndDirectoryInfoCombined) and should not appear in block info compression
flags. Block info entries should only carry compression-type bits (0x3F).

Changes:

  • Default “none” packer now uses data_flag=0x40 and block_info_flag=0.
  • save_fs() masks block_info_flag with 0x3F before building block info.
  • Each block info entry writes block_flag & 0x3F.

Impact:

  • Prevents invalid block info flags from being written.
  • Fixes reload failures caused by block info size mismatches.
  • Behavior is unchanged for original, lz4, and lzma packers except for safe masking.

Testing:

  • Reproduced load failure on Unity 2019.3.x AssetBundle when saved with packer="none".
  • After the fix, saved bundles reload successfully with UnityPy.

@snowyegret23 snowyegret23 closed this by deleting the head repository Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant