UnityPack icon indicating copy to clipboard operation
UnityPack copied to clipboard

_block.LZ4BlockError: Decompression failed (Error code: 30236)

Open davispuh opened this issue 4 years ago • 4 comments

Hi,

I'm trying to extract images from UnityFS bundles but unfortunately it fails

Header is

00000000  55 6e 69 74 79 46 53 00  00 00 00 07 35 2e 78 2e  |UnityFS.....5.x.|
00000010  78 00 32 30 32 31 2e 32  2e 30 62 39 00 00 00 00  |x.2021.2.0b9....|
00000020  00 03 69 cb dd 00 00 12  5f 00 00 12 5f 00 00 00  |..i....._..._...|
00000030  c0 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
$ unityextract --images -o /tmp/ __data
Traceback (most recent call last):
  File "/usr/bin/unityextract", line 159, in <module>
    main()
  File "/usr/bin/unityextract", line 155, in main
    exit(app.run())
  File "/usr/bin/unityextract", line 54, in run
    bundle = unitypack.load(f)
  File "/usr/lib/python3.9/site-packages/unitypack/__init__.py", line 12, in load
    return env.load(file)
  File "/usr/lib/python3.9/site-packages/unitypack/environment.py", line 28, in load
    ret.load(file)
  File "/usr/lib/python3.9/site-packages/unitypack/assetbundle.py", line 49, in load
    self.load_unityfs(buf)
  File "/usr/lib/python3.9/site-packages/unitypack/assetbundle.py", line 128, in load_unityfs
    storage = ArchiveBlockStorage(blocks, buf)
  File "/usr/lib/python3.9/site-packages/unitypack/assetbundle.py", line 197, in __init__
    self._seek(0)
  File "/usr/lib/python3.9/site-packages/unitypack/assetbundle.py", line 230, in _seek
    self.seek_to_block(new_cursor)
  File "/usr/lib/python3.9/site-packages/unitypack/assetbundle.py", line 256, in seek_to_block
    self.current_stream = self.current_block.decompress(buf)
  File "/usr/lib/python3.9/site-packages/unitypack/assetbundle.py", line 181, in decompress
    res = lz4_decompress(buf.read(self.compressed_size), self.uncompressed_size)
  File "/usr/lib/python3.9/site-packages/unitypack/utils.py", line 11, in lz4_decompress
    return decompress(data, size)
_block.LZ4BlockError: Decompression failed: corrupt input or insufficient space in destination buffer. Error code: 30236

Any ideas?

davispuh avatar Oct 31 '21 22:10 davispuh

I'm also having the issue _block.LZ4BlockError: Decompression failed: corrupt input or insufficient space in destination buffer. Error code: 16 ever since hearthstone update to 21.6 where they updated the unity engine. Does anyone have a solution

Zedragon avatar Nov 10 '21 21:11 Zedragon

I switched to UnityPy. I had to update my code, but the project is actively maintained and has an active Discord community, so it felt like a worthy investment.

sebastientromp avatar Nov 10 '21 23:11 sebastientromp

diff --git a/unitypack/assetbundle.py b/unitypack/assetbundle.py
index 4c5a77c..8c6f7a1 100644
--- a/unitypack/assetbundle.py
+++ b/unitypack/assetbundle.py
@@ -98,6 +98,8 @@ class AssetBundle:
                self.ciblock_size = buf.read_uint()
                self.uiblock_size = buf.read_uint()
                flags = buf.read_uint()
+               if self.format_version >= 7:
+                       buf.seek((buf.tell() + 15) // 16 * 16)
                compression = CompressionType(flags & 0x3F)
                eof_metadata = flags & 0x80
                if eof_metadata:

(note that there are other differences in asset format that it still doesn't work fully, but I was only interested in block format)

Milek7 avatar Dec 09 '21 13:12 Milek7

maybe you can try to use this fork: https://github.com/CancerGary/UnityPack/tree/fix/2020.1

hitfzyangdianshi avatar Jun 26 '24 17:06 hitfzyangdianshi