darkdragn / lz4tools

LZ4Frame Bindings and tools for Python
90 stars 30 forks source link

How can i compress xamarin DLL files using lz4? #22

Open flex0geek opened 2 years ago

flex0geek commented 2 years ago

I have a xamarin application and its files are compressed using lz4 I could easily decompress the files it using lz4.block.decompress but I couldn't compress it again, can anyone help me with that?

I used the following script to decompress the file and I could read the content of the DLL file but when I modified something and try to recompress it again to patch the APK file I couldn't compress the file in the right format.

with open(input_filepath, "rb") as xalz_file:
    data = xalz_file
    header = data.read(8)
    if header[:4] != b"XALZ":
        sys.exit("The input file does not contain the expected magic bytes, aborting ...")

    payload = data.read()
    decompressed = lz4.block.decompress(payload)

    with open(output_filepath, "wb") as output_file:
        output_file.write(decompressed)
        output_file.close()
    print("result written to file")

Note that I couldn't decompress or compress the DLL file using lz4tools.

flex0geek commented 2 years ago

xamarin apks use lz4 compress as shown here https://github.com/xamarin/xamarin-android/pull/4686