K0lb3 / UnityPy

UnityPy is python module that makes it possible to extract/unpack and edit Unity assets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decompression failed: corrupt input or insufficient space

StarHeartHunt opened this issue · comments

Code

import os
import UnityPy
import json


def unpack_all_assets(source_folder: str, destination_folder: str):
    # iterate over all files in source folder
    for root, dirs, files in os.walk(source_folder):
        for file_name in files:
            # generate file_path
            file_path = os.path.join(root, file_name)
            # load that file via UnityPy.load
            env = UnityPy.load(file_path)

unpack_all_assets("unitycn", "Exported")

Error

> python .\main4.py 
Error loading, reverting to EndianBinaryReader:
 Decompression failed: corrupt input or insufficient space in destination buffer. Error code: 16

Bug
Expectation: load normally
Actually: Error occurred and exit

To Reproduce

  • a copy of the file that causes the problem
    avprovideoicon.png.ab.zip

  • following data:

    • Python version: Python 3.10.4
    • UnityPy version: 1.9.26

And the Unity version is 2019.4.30f1, the issue could be related to the Unity CN decryption.

The game the file is from definitely uses custom "compression" that replaces lz4.
It's one of the features of Unity CN pro.

The devs can freely design this custom compression and can't be detected within the files themselves,
well, besides that, they produce this error.

Mind that this feature is not the same as Unity CN's build-in protection feature.

^
I was partially wrong with the previous answer; apparently, Unity also added stream alignment to BundleFiles in some Unity 2019.4 versions.
I added a hotfix for this for now.

commented

The game the file is from definitely uses custom "compression" that replaces lz4. It's one of the features of Unity CN pro.

The devs can freely design this custom compression and can't be detected within the files themselves, well, besides that, they produce this error.

Mind that this feature is not the same as Unity CN's build-in protection feature.

I think I encountered this issue, file doesn't seem to be encrypted but I still get the same error as the OP.
Unity Version is 2020.3.42f1 CN and UnityPy version is 1.10.2
File is https://files.catbox.moe/0v79bw.bundle
Any way to try different compressions?