GithubHelp home page GithubHelp logo

Comments (6)

DerPopo avatar DerPopo commented on May 14, 2024

The AssetsTools API (also in the releases) contains all the structures of .assets and bundle files. Also make sure the endianess is correct (there is both big endian and little endian, should be indicated by comments in the API)

from uabe.

kbranigan avatar kbranigan commented on May 14, 2024

AssetsBundleFileFormat.h seems to be close to what I'm looking for, but when trying to write code that reads from an asset bundle, the file seems to quickly diverge after the AssetsBundleHeader06 struct. When you create AssetBundles, do you set the Unity BuildTarget to something specific for this to work? Do you use the manifest text file that Unity creates?

from uabe.

DerPopo avatar DerPopo commented on May 14, 2024

The file most likely is compressed (at least the file table is). Use true for allowCompressed in the Read function, check if the header's or any of the blocks' flags field has a compression set (flags & 0x3F != 0) and use the Unpack method (writing to a file or to a memory buffer, see AssetsFileReader.h).
That's definitely something to improve. I should also replace the assetsLists3 / bundleInf6 arrays because there's never more than one of these.

from uabe.

ixalon avatar ixalon commented on May 14, 2024

Hi @DerPopo, I too would love to know more about the file format. I'm trying parse v6 (UnityFS) files on a platform where I can't use your API (just for fun!), so having to write my own parser. I've got the headers parsed (thanks to your header files!) but getting stuck when it comes to decompression of data.

The file I'm parsing contains one block and one directory info. The single AssetsBundleBlockInfo06.flags equals 0x41, so I'm trying to LZMA decompress the data starting from immediately after the end of the compressed header, however liblzma does not like this (returns a data error).

The bytes for the header, block and directory structs are:
55 6E 69 74 79 46 53 00 00 00 00 06 35 2E 78 2E 78 00 35 2E 33 2E 35 66 31 00 00 00 00 00 00 04 EC 16 00 00 00 42 00 00 00 5B 00 00 00 43 1E 00 01 00 B1 01 00 1B 80 0F 00 04 EB A6 00 41 0E 00 08 01 00 00 1A 00 F0 19 00 00 04 43 41 42 2D 30 66 66 34 33 34 31 34 63 66 62 37 38 39 31 30 61 66 37 34 38 62 33 62 35 64 37 35 31 30 63 30 00

The first bytes after this (where I'm trying to start decompressing liblzma data) is:
5D 00 00 08 00 00 00 63 6F E4 3A 46 8F C1 55 6F 72 47 B6 74 46 9D A7 EC

This looks like a LZMA header + data, but the uncompressed size looks wrong. Properties=0x5D, dictSize=2048, uncompressedSize=109332221544079(!). According to the block/dir info structs, the decompressed size should be 1477232.

UABE manages to decompress the same files, so not sure where I'm going wrong. What LZMA library/code do you use?

from uabe.

DerPopo avatar DerPopo commented on May 14, 2024

The compressed blocks in the v6 bundle files don't contain an additional uncompressedSize, so there is only the 5 byte header with properties and dictSize. Older bundle file versions do contain the uncompressedSize after the LZMA header.
I'm using LzmaDec.h (functions LzmaDec_Allocate and LzmaDec_DecodeToBuf) from the Windows LZMA SDK. I'm not sure whether liblzma has directly ported these functions.

from uabe.

ixalon avatar ixalon commented on May 14, 2024

Thanks @DerPopo that helped. By inserting the extra QWORD (based on the decompressed size of the block info struct) liblzma starts to decode the buffer - however it still fails after decompressing the first 5993 bytes into the output buffer. Is the bundle file chunked somehow? i.e. do I have to call the decode method multiple times (with a set size), or should one call be able to decompress the entire file? ~~Scratch that, fixed a bug and now it's decoding all but the final byte. ~~

All fixed (had to swap the byte order of the decompressed size but no that of the dictionary size). Many thanks for the pointer! 👍

from uabe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.