Skip to content

bug: AssetRipper cannot read asset bundles written by AssetsTools.NET with BlockInfoNeedPaddingAtStart flag#161

Open
loukylor wants to merge 1 commit intonesrak1:mainfrom
loukylor:main
Open

bug: AssetRipper cannot read asset bundles written by AssetsTools.NET with BlockInfoNeedPaddingAtStart flag#161
loukylor wants to merge 1 commit intonesrak1:mainfrom
loukylor:main

Conversation

@loukylor
Copy link
Copy Markdown

@loukylor loukylor commented Apr 4, 2026

I noticed that AssetRipper will fail to read AssetsTools.NET asset bundles created with the BlockInfoNeedPaddingAtStart flag because AssetRipper expects the blocks info length to not be aligned to the next multiple of 16 bytes.

You can see that in these lines:

AssetRipper will not attempt to increase the blocks info length to the next multiple of 16 before validating that the number of bytes read is correct. This contrasts with AssetsTools.NET which does align to the next multiple of 16 before calculating length. I'm not sure which tool's behavior is correct, but I figured I'd just open a PR for whichever fix was easier.

Here's the minimum reproducible code:

AssetBundleDirectoryInfo dirInfo = AssetBundleDirectoryInfo.Create("test", true);
dirInfo.SetNewData(Encoding.ASCII.GetBytes("this is test data"));
AssetBundleFile bundleFile = new()
{
    Header = new AssetBundleHeader
    {
        Signature = "UnityFS",
        Version = 7,
        GenerationVersion = "5.x.x",
        EngineVersion = "2020.3.36f1",
        FileStreamHeader = new AssetBundleFSHeader()
        {
            Flags = AssetBundleFSHeaderFlags.BlockInfoNeedPaddingAtStart | AssetBundleFSHeaderFlags.HasDirectoryInfo
        }
    },
    BlockAndDirInfo = new AssetBundleBlockAndDirInfo
    {
        DirectoryInfos = 
        [
            dirInfo,
        ],
    }
};

using (FileStream stream = File.OpenWrite("test.unity3d"))
using (AssetsFileWriter writer = new(stream))
{
    bundleFile.Write(writer);
}

The bundle this generates will fail to load in AssetRipper, but if you change the uncompressed blocks info length to 59 (0x3B) using a hex editor, it will load in AssetRipper just fine.

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