Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LZMA decompression #250

Closed
wants to merge 1 commit into from
Closed

Fix LZMA decompression #250

wants to merge 1 commit into from

Conversation

0x07E5
Copy link
Contributor

@0x07E5 0x07E5 commented Aug 18, 2024

In Unity LZMA file, headers [5:13] is decompressed size, should be skipped.
This PR solves the decompression issue #237

@0x07E5 0x07E5 marked this pull request as draft August 18, 2024 07:01
@K0lb3 K0lb3 marked this pull request as ready for review August 30, 2024 21:51
@K0lb3
Copy link
Owner

K0lb3 commented Aug 30, 2024

You're right,
going by the lzma specs it should be [13:].

I guess that fixing this for good requires looking a bit into the lzma code of the python package.

@AXiX-official
Copy link
Contributor

AXiX-official commented Aug 31, 2024

In LZMA1, headers [5:13] is decompressed size, that's right
but in unity, decompressed wouldnt be write into compressed data
witch means there‘s no need to skip and there was a slight problem with the previous lzma compress fixes

@K0lb3
Copy link
Owner

K0lb3 commented Sep 1, 2024

Hm, I guess one simply solution to the issue would be simply checking if 8:13 contains the decompressed length.
If it does, start at 13, if not, start at 8.
This would have to be stored somewhere for saving afterwards.

@AXiX-official
Copy link
Contributor

Sorry I may not have a complete understanding of the problem before commenting
Did you encounter a file with decompressed length saved in the lzma data that failed to read?
My understanding of this part is basically from AssetStudio and AssetsTools.NET, at least for BundleFile, AssetsTools.NET encodes as LZMA1(in cpp use func lzma_alone_decoder) and indeed does not keep the decompressed length in the compressed data.
And the format of the lzma compressed ab file I exported using Unity is also like this
I don't know much about the rest, is there a sample file that causes the problem?

@K0lb3 K0lb3 closed this in #257 Sep 4, 2024
K0lb3 added a commit that referenced this pull request Sep 4, 2024
* CompressionHelper - lzma - add option to read/save length and use better params for compression
* BundleFile - web - decompress lzma with decompressed size
* CompresseionHelper - lzma - use the size of the compressed_data for the struct string formating



closes #250
closes #253
solves #237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants