Пример #1
0
        public override object Unmarshal(LittleEndianByteBuffer buffer, ref int offset)
        {
            var result = new LZNT1_UncompressedChunk();

            result.Chunk_header = Unmarshal <LZNT1_ChunkHeader>(buffer, ref offset);
            int  value      = result.Chunk_header.Value;
            bool compressed = (value & 0x8000) != 0;

            if (compressed)
            {
                throw new XcaException("Unreachable code!");
            }
            int signature = (value & 0x7000) >> 12;

            if (signature != 3)
            {
                throw new XcaException("[Data error]: Wrong signature!");
            }
            int size = (value & 0x0FFF) + 1;

            result.Uncompressed_data = new byte[size];
            for (int i = 0; i < size; i++)
            {
                result.Uncompressed_data[i] = (byte)buffer.ReadBytes(offset + i, 1);
            }
            offset += size;
            return(result);
        }
Пример #2
0
        public override object Unmarshal(LittleEndianByteBuffer buffer, ref int offset)
        {
            var result = new LZNT1_FlagData();

            result.Flag_byte = (byte)buffer.ReadBytes(offset, 1);
            offset++;

            var data = new List <LZNT1_Data>();

            for (int i = 0; i < 8; i++)
            {
                if (offset < buffer.Count)
                {
                    bool compressed = (result.Flag_byte & (1 << i)) != 0;

                    if (compressed)
                    {
                        data.Add(Unmarshal <LZNT1_CompressedWord>(buffer, ref offset));
                    }
                    else
                    {
                        data.Add(Unmarshal <LZNT1_Literal>(buffer, ref offset));
                    }
                }
            }

            result.Data = data.ToArray();

            return(result);
        }
Пример #3
0
        public override object Unmarshal(LittleEndianByteBuffer buffer, ref int offset)
        {
            var result = new LZNT1_ChunkHeader();

            result.Value = buffer.ReadBytes(offset, 2);
            offset      += 2;
            return(result);
        }
Пример #4
0
 public override void Decode(LittleEndianByteBuffer buffer, ref int offset)
 {
     for (int i = 0; i < Length; i++)
     {
         int matchByte = buffer.ReadBytes(offset - Distance + i, 1);
         buffer.WriteBytes(offset + i, matchByte, 1);
     }
     offset += Length;
 }
Пример #5
0
        public override object Unmarshal(LittleEndianByteBuffer buffer, ref int offset)
        {
            var result = new LZNT1_Literal();

            result.Literal = (byte)buffer.ReadBytes(offset, 1);
            offset++;

            return(result);
        }