Exemplo n.º 1
0
 public Stream Decompress(Stream stream)
 {
     using (var reader = new FileReader(stream, true))
     {
         reader.SeekBegin(4);
         uint decompSize = reader.ReadUInt32();
         var  acesComp   = new STLibraryCompression.MTA_CUSTOM();
         return(new MemoryStream(acesComp.Decompress(stream.ToArray(), decompSize)));
     }
 }
Exemplo n.º 2
0
            private byte[] DecompressBlock()
            {
                byte[] data = GetBlock();

                var reader = new FileReader(data);

                reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;

                byte compType = reader.ReadByte();

                if (compType == 0x50)
                {
                    reader.Seek(4, System.IO.SeekOrigin.Begin);
                    uint decompSize = reader.ReadUInt32();
                    uint compSize   = (uint)reader.BaseStream.Length - 8;

                    var comp = new STLibraryCompression.MTA_CUSTOM();
                    return(comp.Decompress(data, decompSize));
                }
                else if (compType == 0x30 || compType == 0x20)
                {
                    uint decompSize = reader.ReadUInt32();
                    uint compSize   = (uint)reader.BaseStream.Length - 16;

                    reader.SeekBegin(16);
                    ushort signature = reader.ReadUInt16();
                    bool   IsGZIP    = signature == 0x1F8B;
                    bool   IsZLIB    = signature == 0x789C || signature == 0x78DA;

                    byte[] filedata = reader.getSection(16, (int)compSize);
                    reader.Close();
                    reader.Dispose();

                    if (IsGZIP)
                    {
                        data = STLibraryCompression.GZIP.Decompress(filedata);
                    }
                    else
                    {
                        data = STLibraryCompression.ZLIB.Decompress(filedata, false);
                    }
                }

                return(data);
            }