加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

unity3d的LZ4压缩算法解读

(2017-07-26 16:31:07)
标签:

365

unity3d

andriod

crack

分类: 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进制文件头
unity3d的LZ4压缩算法解读

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) 

解压方法:
unity3d的LZ4压缩算法解读


解压数据

unity3d的LZ4压缩算法解读

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
unity3d的LZ4压缩算法解读

jump2
unity3d的LZ4压缩算法解读

jump3
unity3d的LZ4压缩算法解读

jump4
unity3d的LZ4压缩算法解读

获取索引表地址:
最终获得包裹的index table offset位置
0x19AD 就是index table offset位置

索引表
unity3d的LZ4压缩算法解读
索引表包含了4个文件的x64位pid信息8bytes,offset信息4bytes,size信息4bytes,calss id信息8bytes,rev 4bytes。
每个索引28字节来描述。

-完-

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有