unity3d的LZ4压缩算法解读

标签:
365unity3dandriodcrack |
分类: Crack |
从unity3d版本号5.3开始,支持包裹容器assetbundle的lz4压缩算法。
引用官方说明:
Upgrading to Unity
5.3
AssetBundles
AssetBundle's container format was changed in order to support new LZ4 compression and have a basis for further improvements. Bundles created in earlier version (2.x, 3.x) are deprecated and not supported. Bundles created in Unity 4.x, 5.0–5.2 are supported and could be loaded. But, if they were already cached on a user device using WWW.LoadFromCacheOrDownload method, they will be redownloaded. Also take in mind that data in such bundles might be a subject to change (see e.g. Global Illumination section).
解读:
下面是一个unity3d 5.3.6版本打包的assetbundle的16进制文件头
0x00-0x06 7bytes,文件头标识unityFS,典型的新包格式。
0x0B
1bytes , 文件flag
0x1E-0x21 4bytes,文件打包总容量,big-endian
0x22-0x25 4bytes,lz4块压缩后容量,big-endian
0x26-0x29 4bytes,lz4块压缩前容量,big-endian
0x2A-0x2D
4bytes,压缩标记,big-endian,mod 0x40 = 3 lz4压缩
0x2E-0xD3
4bytes,第1个索引压缩块数据,165bytes(0xA5)
解压方法:
解压数据
0x2E-0x151 291bytes(0x123)即为第1组解压后数据。
0x15D-0x160 4bytes 打包第一个文件起始offset,big-endian。
0x172-0x175 4byte 打包文件数量,little-endian。
0x176-0x179 4byte unity class
ID,little-endian。
0x18A-0x18D
4byte unity Type tree
node,little-endian。
0x18E-0x192
4byte unity Type tree string lengh,little-endian。
jump 计算:
next Type tree =
unity Type tree node
*(0x18)+ unity Type tree string lengh
循环4次读取
jump1
jump2
jump3
jump4
获取索引表地址:
最终获得包裹的index table offset位置
0x19AD 就是index table
offset位置
索引表
每个索引28字节来描述。
-完-