Пример #1
0
 private void ProcessTypeFixed(CompressionStream zip, InflaterBlocksContext state)
 {
     int[]   bl = new int[1];
     int[]   bd = new int[1];
     int[][] tl = new int[1][];
     int[][] td = new int[1][];
     InflaterTree.InflateTreeFixed(bl, bd, tl, td, zip);
     this.codes = new InflaterCodes(bl[0], bd[0], tl[0], td[0], zip);
     state.ShiftRight(3);
     this.mode = 6;
 }
Пример #2
0
 private int Reset(CompressionStream stream)
 {
     if (stream == null)
     {
         return(-2);
     }
     stream.InputTotal   = 0L;
     stream.OutputTotal  = 0L;
     stream.ErrorMessage = (string)null;
     this.state          = this.nowrap != 0 ? InflaterState.Blocks : InflaterState.Method;
     this.blocks.Reset(stream, (long[])null);
     return(0);
 }
Пример #3
0
 internal static int InflateTreeFixed(
     int[] bl,
     int[] bd,
     int[][] tl,
     int[][] td,
     CompressionStream z)
 {
     bl[0] = 9;
     bd[0] = 5;
     tl[0] = InflaterTreeConstants.FixedTl;
     td[0] = InflaterTreeConstants.FixedTd;
     return(0);
 }
Пример #4
0
 public void End()
 {
     if (this.compress)
     {
         this.zip.DeflateEnd();
     }
     else
     {
         this.zip.InflateEnd();
     }
     this.zip.Free();
     this.zip = (CompressionStream)null;
 }
Пример #5
0
 private int ProcessStored(CompressionStream zip, InflaterBlocksContext state, int res)
 {
     if (state.BytesCount == 0)
     {
         this.TransferBlocksState(zip, state);
         state.IsReturn = true;
         return(this.InflateFlush(zip, res));
     }
     if (state.EndBytes == 0)
     {
         if (state.Output == this.WindowEnd && this.WindowRead != 0)
         {
             state.Output   = 0;
             state.EndBytes = this.GetEndBytes(state);
         }
         if (state.EndBytes == 0)
         {
             this.WindowWrite = state.Output;
             res            = this.InflateFlush(zip, res);
             state.Output   = this.WindowWrite;
             state.EndBytes = this.GetEndBytes(state);
             if (state.Output == this.WindowEnd && this.WindowRead != 0)
             {
                 state.Output   = 0;
                 state.EndBytes = this.GetEndBytes(state);
             }
             if (state.EndBytes == 0)
             {
                 this.TransferBlocksState(zip, state);
                 state.IsReturn = true;
                 return(this.InflateFlush(zip, res));
             }
         }
     }
     res        = 0;
     state.Temp = this.left;
     if (state.Temp > state.BytesCount)
     {
         state.Temp = state.BytesCount;
     }
     if (state.Temp > state.EndBytes)
     {
         state.Temp = state.EndBytes;
     }
     Array.Copy((Array)zip.Input, state.Input, (Array)this.Window, state.Output, state.Temp);
     state.Input      += state.Temp;
     state.BytesCount -= state.Temp;
     state.Output     += state.Temp;
     state.EndBytes   -= state.Temp;
     return(0);
 }
Пример #6
0
        public int Sync(CompressionStream stream)
        {
            if (stream == null)
            {
                return(-2);
            }
            if (this.state != InflaterState.Error)
            {
                this.state  = InflaterState.Error;
                this.marker = 0;
            }
            int inputCount = stream.InputCount;

            if (inputCount == 0)
            {
                return(-5);
            }
            int inputIndex = stream.InputIndex;
            int index;

            for (index = this.marker; inputCount != 0 && index < 4; --inputCount)
            {
                if ((int)stream.Input[inputIndex] == (int)Inflater.mark[index])
                {
                    ++index;
                }
                else
                {
                    index = stream.Input[inputIndex] == (byte)0 ? 4 - index : 0;
                }
                ++inputIndex;
            }
            stream.InputTotal += (long)(inputIndex - stream.InputIndex);
            stream.InputIndex  = inputIndex;
            stream.InputCount  = inputCount;
            this.marker        = index;
            if (index != 4)
            {
                return(-3);
            }
            long inputTotal  = stream.InputTotal;
            long outputTotal = stream.OutputTotal;

            this.Reset(stream);
            stream.InputTotal  = inputTotal;
            stream.OutputTotal = outputTotal;
            this.state         = InflaterState.Blocks;
            return(0);
        }
Пример #7
0
 private bool HandleCheckTwoState(CompressionStream stream, out ErrorCode result)
 {
     result = ErrorCode.Ok;
     if (stream.InputCount == 0)
     {
         result = this.error;
         return(false);
     }
     this.error = this.startError;
     --stream.InputCount;
     ++stream.InputTotal;
     this.need += (uint)((ulong)(((int)stream.Input[stream.InputIndex++] & (int)byte.MaxValue) << 8) & 65280UL);
     this.state = InflaterState.CheckOne;
     return(true);
 }
Пример #8
0
 private bool HandleCheckFourState(CompressionStream stream, out ErrorCode result)
 {
     result = ErrorCode.Ok;
     if (stream.InputCount == 0)
     {
         result = this.error;
         return(false);
     }
     this.error = this.startError;
     --stream.InputCount;
     ++stream.InputTotal;
     this.need  = (uint)(((int)stream.Input[stream.InputIndex++] & (int)byte.MaxValue) << 24 & -16777216);
     this.state = InflaterState.CheckThree;
     return(true);
 }
Пример #9
0
 private bool HandleDictionaryThreeState(CompressionStream stream, out ErrorCode result)
 {
     result = ErrorCode.Ok;
     if (stream.InputCount == 0)
     {
         result = this.error;
         return(false);
     }
     this.error = this.startError;
     --stream.InputCount;
     ++stream.InputTotal;
     this.need += (uint)((ulong)(((int)stream.Input[stream.InputIndex++] & (int)byte.MaxValue) << 16) & 16711680UL);
     this.state = InflaterState.DictionaryTwo;
     return(true);
 }
Пример #10
0
 internal InflaterCodes(
     int bl,
     int bd,
     int[] tl,
     int tlIndex,
     int[] td,
     int tdIndex,
     CompressionStream z)
 {
     this.mode       = 0;
     this.lbits      = (byte)bl;
     this.dbits      = (byte)bd;
     this.ltree      = tl;
     this.ltreeIndex = tlIndex;
     this.dtree      = td;
     this.dtreeIndex = tdIndex;
 }
Пример #11
0
 private bool HandleDictionaryOneState(CompressionStream stream, out ErrorCode result)
 {
     result = ErrorCode.Ok;
     if (stream.InputCount == 0)
     {
         result = this.error;
         return(false);
     }
     this.error = this.startError;
     --stream.InputCount;
     ++stream.InputTotal;
     this.need      += (uint)((ulong)stream.Input[stream.InputIndex++] & (ulong)byte.MaxValue);
     stream.Checksum = new Adler32(this.need);
     this.state      = InflaterState.DictionaryZero;
     result          = ErrorCode.NeedsDictionary;
     return(false);
 }
Пример #12
0
        private int Initialize(
            CompressionStream strm,
            int level,
            int method,
            int windowBits,
            int memLevel,
            int strategy)
        {
            int num = 0;

            strm.ErrorMessage = (string)null;
            if (level == -1)
            {
                level = 6;
            }
            if (windowBits < 0)
            {
                num        = 1;
                windowBits = -windowBits;
            }
            if (memLevel < 1 || memLevel > 9 || (method != 8 || windowBits < 9) || (windowBits > 15 || level < 0 || (level > 9 || strategy < 0)) || strategy > 2)
            {
                return(-2);
            }
            strm.Deflater          = this;
            this.noheader          = num;
            this.wBits             = windowBits;
            this.wSize             = 1 << this.wBits;
            this.wMask             = this.wSize - 1;
            this.hashBits          = memLevel + 7;
            this.hashSize          = 1 << this.hashBits;
            this.hashMask          = this.hashSize - 1;
            this.hashShift         = (this.hashBits + 3 - 1) / 3;
            this.window            = new byte[this.wSize * 2];
            this.prev              = new short[this.wSize];
            this.head              = new short[this.hashSize];
            this.litBufsize        = 1 << memLevel + 6;
            this.pendingBuffer     = new byte[this.litBufsize * 4];
            this.pendingBufferSize = this.litBufsize * 4;
            this.d_buf             = this.litBufsize;
            this.litBuf            = 3 * this.litBufsize;
            this.level             = (int)level;
            this.strategy          = strategy;
            this.method            = (byte)method;
            return(this.Reset(strm));
        }
Пример #13
0
 private int ProcessTable(CompressionStream zip, InflaterBlocksContext state, int res)
 {
     for (; state.Bits < 14; state.Bits += 8)
     {
         if (state.BytesCount != 0)
         {
             res = 0;
             --state.BytesCount;
             state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
         }
         else
         {
             this.TransferBlocksState(zip, state);
             state.IsReturn = true;
             return(this.InflateFlush(zip, res));
         }
     }
     this.table = state.Temp = state.BitBuf & 16383;
     if ((state.Temp & 31) > 29 || (state.Temp >> 5 & 31) > 29)
     {
         this.mode        = 9;
         zip.ErrorMessage = "too many length or distance symbols";
         res = -3;
         this.TransferBlocksState(zip, state);
         state.IsReturn = true;
         return(this.InflateFlush(zip, res));
     }
     state.Temp = 258 + (state.Temp & 31) + (state.Temp >> 5 & 31);
     this.blens = new int[state.Temp];
     if (this.blens == null || this.blens.Length < state.Temp)
     {
         this.blens = new int[state.Temp];
     }
     else
     {
         for (int index = 0; index < state.Temp; ++index)
         {
             this.blens[index] = 0;
         }
     }
     state.ShiftRight(14);
     this.index = 0;
     this.mode  = 4;
     return(0);
 }
Пример #14
0
 private int Reset(CompressionStream strm)
 {
     strm.InputTotal    = strm.OutputTotal = 0L;
     strm.ErrorMessage  = (string)null;
     strm.DataType      = 2;
     this.pending       = 0;
     this.pendingOutput = 0;
     if (this.noheader < 0)
     {
         this.noheader = 0;
     }
     this.status    = this.noheader != 0 ? 113 : 42;
     strm.Checksum  = new Adler32();
     this.lastFlush = 0;
     this.InitializeTree();
     this.InitializeMatch();
     return(0);
 }
Пример #15
0
        private int ProcessType(CompressionStream zip, InflaterBlocksContext state, int res)
        {
            for (; state.Bits < 3; state.Bits += 8)
            {
                if (state.BytesCount != 0)
                {
                    res = 0;
                    --state.BytesCount;
                    state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
                }
                else
                {
                    this.TransferBlocksState(zip, state);
                    state.IsReturn = true;
                    return(this.InflateFlush(zip, res));
                }
            }
            state.Temp = state.BitBuf & 7;
            this.last  = state.Temp & 1;
            switch (Utils.ShiftRight(state.Temp, 1))
            {
            case 0:
                this.ProcessTypeStored(state);
                break;

            case 1:
                this.ProcessTypeFixed(zip, state);
                break;

            case 2:
                this.ProcessTypeDynamic(state);
                break;

            case 3:
                state.ShiftRight(3);
                this.mode        = 9;
                zip.ErrorMessage = "invalid block type";
                res = -3;
                this.TransferBlocksState(zip, state);
                state.IsReturn = true;
                return(this.InflateFlush(zip, res));
            }
            return(0);
        }
Пример #16
0
 private int ProcessBTree(CompressionStream zip, InflaterBlocksContext state, int res)
 {
     while (this.index < 4 + Utils.ShiftRight(this.table, 10))
     {
         for (; state.Bits < 3; state.Bits += 8)
         {
             if (state.BytesCount != 0)
             {
                 res = 0;
                 --state.BytesCount;
                 state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
             }
             else
             {
                 this.TransferBlocksState(zip, state);
                 state.IsReturn = true;
                 return(this.InflateFlush(zip, res));
             }
         }
         this.blens[InflaterBlocks.border[this.index++]] = state.BitBuf & 7;
         state.ShiftRight(3);
     }
     while (this.index < 19)
     {
         this.blens[InflaterBlocks.border[this.index++]] = 0;
     }
     this.bitLengthTreeDepth[0] = 7;
     state.Temp = InflaterTree.InflateTreeBits(this.blens, this.bitLengthTreeDepth, this.bitLengthDecodeTree, this.hufts, zip);
     if (state.Temp != 0)
     {
         res = state.Temp;
         if (res == -3)
         {
             this.blens = (int[])null;
             this.mode  = 9;
         }
         this.TransferBlocksState(zip, state);
         state.IsReturn = true;
         return(this.InflateFlush(zip, res));
     }
     this.index = 0;
     this.mode  = 5;
     return(0);
 }
Пример #17
0
 private bool HandleCheckOneState(CompressionStream stream, out ErrorCode result)
 {
     result = ErrorCode.Ok;
     if (stream.InputCount == 0)
     {
         result = this.error;
         return(false);
     }
     this.error = this.startError;
     --stream.InputCount;
     ++stream.InputTotal;
     this.need += (uint)((ulong)stream.Input[stream.InputIndex++] & (ulong)byte.MaxValue);
     if ((int)this.was[0] != (int)this.need)
     {
         this.state          = InflaterState.Error;
         stream.ErrorMessage = "incorrect data check";
         this.marker         = 5;
         return(true);
     }
     this.state = InflaterState.Done;
     return(true);
 }
Пример #18
0
        public int Initialize(CompressionStream stream, int windowSize)
        {
            stream.ErrorMessage = (string)null;
            this.blocks         = (InflaterBlocks)null;
            this.nowrap         = 0;
            if (windowSize < 0)
            {
                windowSize  = -windowSize;
                this.nowrap = 1;
            }
            if (windowSize < 8 || windowSize > 15)
            {
                this.End(stream);
                return(-2);
            }
            this.wbits = windowSize;
            Inflater inflater = this.nowrap != 0 ? (Inflater)null : this;

            this.blocks = new InflaterBlocks(stream, (object)inflater, 1 << windowSize);
            this.Reset(stream);
            return(0);
        }
Пример #19
0
        public int SetDictionary(CompressionStream stream, byte[] dictionary, int dictLength)
        {
            int start = 0;
            int n     = dictLength;

            if (stream == null || this.state != InflaterState.DictionaryZero)
            {
                return(-2);
            }
            if (Adler32.Get(dictionary, 0, dictLength) != stream.Checksum.Get())
            {
                return(-3);
            }
            stream.Checksum = new Adler32();
            if (n >= 1 << this.wbits)
            {
                n     = (1 << this.wbits) - 1;
                start = dictLength - n;
            }
            this.blocks.SetDictionary(dictionary, start, n);
            this.state = InflaterState.Blocks;
            return(0);
        }
Пример #20
0
        public int Inflate(CompressionStream stream, int flush)
        {
            if (stream == null || stream.Input == null)
            {
                return(-2);
            }
            this.startError = flush == 4 ? ErrorCode.BufferError : ErrorCode.Ok;
            this.error      = ErrorCode.BufferError;
            ErrorCode result = ErrorCode.Ok;

            while (true)
            {
                switch (this.state)
                {
                case InflaterState.Method:
                    if (this.HandleMethodState(stream, out result))
                    {
                        break;
                    }
                    goto label_4;

                case InflaterState.Flag:
                    if (this.HandleFlagState(stream, out result))
                    {
                        break;
                    }
                    goto label_6;

                case InflaterState.DictionaryFour:
                    if (this.HandleDictionaryFourState(stream, out result))
                    {
                        break;
                    }
                    goto label_8;

                case InflaterState.DictionaryThree:
                    if (this.HandleDictionaryThreeState(stream, out result))
                    {
                        break;
                    }
                    goto label_10;

                case InflaterState.DictionaryTwo:
                    if (this.HandleDictionaryTwoState(stream, out result))
                    {
                        break;
                    }
                    goto label_12;

                case InflaterState.DictionaryOne:
                    if (this.HandleDictionaryOneState(stream, out result))
                    {
                        break;
                    }
                    goto label_14;

                case InflaterState.DictionaryZero:
                    if (this.HandleDictionaryZeroState(stream, out result))
                    {
                        break;
                    }
                    goto label_16;

                case InflaterState.Blocks:
                    if (this.HandleBlocksState(stream, out result))
                    {
                        break;
                    }
                    goto label_18;

                case InflaterState.CheckFour:
                    if (this.HandleCheckFourState(stream, out result))
                    {
                        break;
                    }
                    goto label_20;

                case InflaterState.CheckThree:
                    if (this.HandleCheckThreeState(stream, out result))
                    {
                        break;
                    }
                    goto label_22;

                case InflaterState.CheckTwo:
                    if (this.HandleCheckThreeState(stream, out result))
                    {
                        break;
                    }
                    goto label_24;

                case InflaterState.CheckOne:
                    if (this.HandleCheckOneState(stream, out result))
                    {
                        break;
                    }
                    goto label_26;

                case InflaterState.Done:
                    goto label_27;

                case InflaterState.Error:
                    goto label_28;

                default:
                    goto label_29;
                }
            }
label_4:
            return((int)result);

label_6:
            return((int)result);

label_8:
            return((int)result);

label_10:
            return((int)result);

label_12:
            return((int)result);

label_14:
            return((int)result);

label_16:
            return((int)result);

label_18:
            return((int)result);

label_20:
            return((int)result);

label_22:
            return((int)result);

label_24:
            return((int)result);

label_26:
            return((int)result);

label_27:
            return(1);

label_28:
            return(-3);

label_29:
            return(-2);
        }
Пример #21
0
        internal int Process(CompressionStream zip, int res)
        {
            InflaterBlocksContext state = new InflaterBlocksContext()
            {
                Input      = zip.InputIndex,
                BytesCount = zip.InputCount,
                BitBuf     = this.BitBuffer,
                Bits       = this.BitBufferLength,
                Output     = this.WindowWrite
            };

            state.EndBytes = this.GetEndBytes(state);
            int num1;
            int num2;
            int num3;
            int num4;
            int num5;
            int num6;

            while (true)
            {
                switch (this.mode)
                {
                case 0:
                    state.IsReturn = false;
                    num1           = this.ProcessType(zip, state, res);
                    if (!state.IsReturn)
                    {
                        break;
                    }
                    goto label_2;

                case 1:
                    state.IsReturn = false;
                    num2           = this.ProcessLens(zip, state, ref res);
                    if (!state.IsReturn)
                    {
                        break;
                    }
                    goto label_4;

                case 2:
                    state.IsReturn = false;
                    num3           = this.ProcessStored(zip, state, res);
                    if (!state.IsReturn)
                    {
                        if ((this.left -= state.Temp) == 0)
                        {
                            this.mode = this.last == 0 ? 0 : 7;
                            break;
                        }
                        break;
                    }
                    goto label_6;

                case 3:
                    state.IsReturn = false;
                    num4           = this.ProcessTable(zip, state, res);
                    if (!state.IsReturn)
                    {
                        goto case 4;
                    }
                    else
                    {
                        goto label_10;
                    }

                case 4:
                    state.IsReturn = false;
                    num5           = this.ProcessBTree(zip, state, res);
                    if (!state.IsReturn)
                    {
                        goto case 5;
                    }
                    else
                    {
                        goto label_12;
                    }

                case 5:
                    state.IsReturn = false;
                    num6           = this.ProcessDTree(zip, state, res);
                    if (!state.IsReturn)
                    {
                        goto case 6;
                    }
                    else
                    {
                        goto label_14;
                    }

                case 6:
                    this.TransferBlocksState(zip, state);
                    if ((res = this.codes.Process(this, zip, res)) == 1)
                    {
                        res = 0;
                        this.codes.Free(zip);
                        state.Input      = zip.InputIndex;
                        state.BytesCount = zip.InputCount;
                        state.BitBuf     = this.BitBuffer;
                        state.Bits       = this.BitBufferLength;
                        state.Output     = this.WindowWrite;
                        state.EndBytes   = this.GetEndBytes(state);
                        if (this.last == 0)
                        {
                            this.mode = 0;
                            break;
                        }
                        goto label_19;
                    }
                    else
                    {
                        goto label_16;
                    }

                case 7:
                    goto label_20;

                case 8:
                    goto label_23;

                case 9:
                    goto label_24;

                default:
                    goto label_25;
                }
            }
label_2:
            return(num1);

label_4:
            return(num2);

label_6:
            return(num3);

label_10:
            return(num4);

label_12:
            return(num5);

label_14:
            return(num6);

label_16:
            return(this.InflateFlush(zip, res));

label_19:
            this.mode = 7;
label_20:
            this.WindowWrite = state.Output;
            res            = this.InflateFlush(zip, res);
            state.Output   = this.WindowWrite;
            state.EndBytes = this.GetEndBytes(state);
            if (this.WindowRead != this.WindowWrite)
            {
                this.TransferBlocksState(zip, state);
                return(this.InflateFlush(zip, res));
            }
            this.mode = 8;
label_23:
            res = 1;
            this.TransferBlocksState(zip, state);
            return(this.InflateFlush(zip, res));

label_24:
            res = -3;
            this.TransferBlocksState(zip, state);
            return(this.InflateFlush(zip, res));

label_25:
            res = -2;
            this.TransferBlocksState(zip, state);
            return(this.InflateFlush(zip, res));
        }
Пример #22
0
        public int Deflate(CompressionStream strm, int flush)
        {
            if (flush > 4 || flush < 0)
            {
                return(-2);
            }
            if (strm.Output == null || strm.Input == null && strm.InputCount != 0 || this.status == 666 && flush != 4)
            {
                strm.ErrorMessage = Deflater.errmsg[4];
                return(-2);
            }
            if (strm.OutputCount == 0)
            {
                strm.ErrorMessage = Deflater.errmsg[7];
                return(-5);
            }
            this.stream = strm;
            int lastFlush = this.lastFlush;

            this.lastFlush = flush;
            if (this.status == 42)
            {
                int num1 = 8 + (this.wBits - 8 << 4) << 8;
                int num2 = (this.level - 1 & (int)byte.MaxValue) >> 1;
                if (num2 > 3)
                {
                    num2 = 3;
                }
                int num3 = num1 | num2 << 6;
                if (this.strstart != 0)
                {
                    num3 |= 32;
                }
                int b = num3 + (31 - num3 % 31);
                this.status = 113;
                this.WriteShortMSB(b);
                if (this.strstart != 0)
                {
                    this.WriteShortMSB((int)Utils.ShiftRight(strm.Checksum.Get(), 16));
                    this.WriteShortMSB((int)(strm.Checksum.Get() & (long)ushort.MaxValue));
                }
                strm.Checksum = new Adler32();
            }
            if (this.pending != 0)
            {
                strm.FlushPending();
                if (strm.OutputCount == 0)
                {
                    this.lastFlush = -1;
                    return(0);
                }
            }
            else if (strm.InputCount == 0 && flush <= lastFlush && flush != 4)
            {
                strm.ErrorMessage = Deflater.errmsg[7];
                return(-5);
            }
            if (this.status == 666 && strm.InputCount != 0)
            {
                strm.ErrorMessage = Deflater.errmsg[7];
                return(-5);
            }
            if (strm.InputCount != 0 || this.lookahead != 0 || flush != 0 && this.status != 666)
            {
                int num = -1;
                switch (Deflater.Options[this.level].Function)
                {
                case DeflaterFunction.Stored:
                    num = this.DeflateStored(flush);
                    break;

                case DeflaterFunction.Fast:
                    num = this.DeflateFast(flush);
                    break;

                case DeflaterFunction.Slow:
                    num = this.DeflateSlow(flush);
                    break;
                }
                if (num == 2 || num == 3)
                {
                    this.status = 666;
                }
                if (num == 0 || num == 2)
                {
                    if (strm.OutputCount == 0)
                    {
                        this.lastFlush = -1;
                    }
                    return(0);
                }
                if (num == 1)
                {
                    if (flush == 1)
                    {
                        this.AlignTree();
                    }
                    else
                    {
                        this.TreeSendStoredBlock(0, 0, false);
                        if (flush == 3)
                        {
                            for (int index = 0; index < this.hashSize; ++index)
                            {
                                this.head[index] = (short)0;
                            }
                        }
                    }
                    strm.FlushPending();
                    if (strm.OutputCount == 0)
                    {
                        this.lastFlush = -1;
                        return(0);
                    }
                }
            }
            if (flush != 4)
            {
                return(0);
            }
            if (this.noheader != 0)
            {
                return(1);
            }
            this.WriteShortMSB((int)Utils.ShiftRight(strm.Checksum.Get(), 16));
            this.WriteShortMSB((int)(strm.Checksum.Get() & (long)ushort.MaxValue));
            strm.FlushPending();
            this.noheader = -1;
            return(this.pending != 0 ? 0 : 1);
        }
Пример #23
0
 public int Initialize(CompressionStream strm, CompressionLevel level)
 {
     return(this.Initialize(strm, level, 15));
 }
Пример #24
0
 public int Initialize(CompressionStream strm, CompressionLevel level, int bits)
 {
     return(this.Initialize(strm, (int)level, (int)CompressionMethod.Deflated, bits, 8, 0));
 }
Пример #25
0
 internal void Free(CompressionStream z)
 {
     this.Reset(z, (long[])null);
     this.Window = (byte[])null;
     this.hufts  = (int[])null;
 }
Пример #26
0
        internal int Process(InflaterBlocks s, CompressionStream z, int r)
        {
            int inputIndex      = z.InputIndex;
            int inputCount      = z.InputCount;
            int number          = s.BitBuffer;
            int bitBufferLength = s.BitBufferLength;
            int num1            = s.WindowWrite;
            int num2            = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;

            while (true)
            {
                switch (this.mode)
                {
                case 0:
                    if (num2 >= 258 && inputCount >= 10)
                    {
                        s.BitBuffer       = number;
                        s.BitBufferLength = bitBufferLength;
                        z.InputCount      = inputCount;
                        z.InputTotal     += (long)(inputIndex - z.InputIndex);
                        z.InputIndex      = inputIndex;
                        s.WindowWrite     = num1;
                        r               = this.InflateFast((int)this.lbits, (int)this.dbits, this.ltree, this.ltreeIndex, this.dtree, this.dtreeIndex, s, z);
                        inputIndex      = z.InputIndex;
                        inputCount      = z.InputCount;
                        number          = s.BitBuffer;
                        bitBufferLength = s.BitBufferLength;
                        num1            = s.WindowWrite;
                        num2            = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                        int num3;
                        switch (r)
                        {
                        case 0:
                            goto label_6;

                        case 1:
                            num3 = 7;
                            break;

                        default:
                            num3 = 9;
                            break;
                        }
                        this.mode = num3;
                        break;
                    }
label_6:
                    this.need      = (int)this.lbits;
                    this.tree      = this.ltree;
                    this.treeIndex = this.ltreeIndex;
                    this.mode      = 1;
                    goto case 1;

                case 1:
                    int need1;
                    for (need1 = this.need; bitBufferLength < need1; bitBufferLength += 8)
                    {
                        if (inputCount != 0)
                        {
                            r = 0;
                            --inputCount;
                            number |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << bitBufferLength;
                        }
                        else
                        {
                            s.BitBuffer       = number;
                            s.BitBufferLength = bitBufferLength;
                            z.InputCount      = inputCount;
                            z.InputTotal     += (long)(inputIndex - z.InputIndex);
                            z.InputIndex      = inputIndex;
                            s.WindowWrite     = num1;
                            return(s.InflateFlush(z, r));
                        }
                    }
                    int index1 = (this.treeIndex + (number & InflaterCodes.inflateMask[need1])) * 3;
                    number           = Utils.ShiftRight(number, this.tree[index1 + 1]);
                    bitBufferLength -= this.tree[index1 + 1];
                    int num4 = this.tree[index1];
                    if (num4 == 0)
                    {
                        this.lit  = this.tree[index1 + 2];
                        this.mode = 6;
                        break;
                    }
                    if ((num4 & 16) != 0)
                    {
                        this.getBits = num4 & 15;
                        this.len     = this.tree[index1 + 2];
                        this.mode    = 2;
                        break;
                    }
                    if ((num4 & 64) == 0)
                    {
                        this.need      = num4;
                        this.treeIndex = index1 / 3 + this.tree[index1 + 2];
                        break;
                    }
                    if ((num4 & 32) != 0)
                    {
                        this.mode = 7;
                        break;
                    }
                    goto label_20;

                case 2:
                    int getBits1;
                    for (getBits1 = this.getBits; bitBufferLength < getBits1; bitBufferLength += 8)
                    {
                        if (inputCount != 0)
                        {
                            r = 0;
                            --inputCount;
                            number |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << bitBufferLength;
                        }
                        else
                        {
                            s.BitBuffer       = number;
                            s.BitBufferLength = bitBufferLength;
                            z.InputCount      = inputCount;
                            z.InputTotal     += (long)(inputIndex - z.InputIndex);
                            z.InputIndex      = inputIndex;
                            s.WindowWrite     = num1;
                            return(s.InflateFlush(z, r));
                        }
                    }
                    this.len        += number & InflaterCodes.inflateMask[getBits1];
                    number         >>= getBits1;
                    bitBufferLength -= getBits1;
                    this.need        = (int)this.dbits;
                    this.tree        = this.dtree;
                    this.treeIndex   = this.dtreeIndex;
                    this.mode        = 3;
                    goto case 3;

                case 3:
                    int need2;
                    for (need2 = this.need; bitBufferLength < need2; bitBufferLength += 8)
                    {
                        if (inputCount != 0)
                        {
                            r = 0;
                            --inputCount;
                            number |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << bitBufferLength;
                        }
                        else
                        {
                            s.BitBuffer       = number;
                            s.BitBufferLength = bitBufferLength;
                            z.InputCount      = inputCount;
                            z.InputTotal     += (long)(inputIndex - z.InputIndex);
                            z.InputIndex      = inputIndex;
                            s.WindowWrite     = num1;
                            return(s.InflateFlush(z, r));
                        }
                    }
                    int index2 = (this.treeIndex + (number & InflaterCodes.inflateMask[need2])) * 3;
                    number         >>= this.tree[index2 + 1];
                    bitBufferLength -= this.tree[index2 + 1];
                    int num5 = this.tree[index2];
                    if ((num5 & 16) != 0)
                    {
                        this.getBits = num5 & 15;
                        this.dist    = this.tree[index2 + 2];
                        this.mode    = 4;
                        break;
                    }
                    if ((num5 & 64) == 0)
                    {
                        this.need      = num5;
                        this.treeIndex = index2 / 3 + this.tree[index2 + 2];
                        break;
                    }
                    goto label_36;

                case 4:
                    int getBits2;
                    for (getBits2 = this.getBits; bitBufferLength < getBits2; bitBufferLength += 8)
                    {
                        if (inputCount != 0)
                        {
                            r = 0;
                            --inputCount;
                            number |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << bitBufferLength;
                        }
                        else
                        {
                            s.BitBuffer       = number;
                            s.BitBufferLength = bitBufferLength;
                            z.InputCount      = inputCount;
                            z.InputTotal     += (long)(inputIndex - z.InputIndex);
                            z.InputIndex      = inputIndex;
                            s.WindowWrite     = num1;
                            return(s.InflateFlush(z, r));
                        }
                    }
                    this.dist       += number & InflaterCodes.inflateMask[getBits2];
                    number         >>= getBits2;
                    bitBufferLength -= getBits2;
                    this.mode        = 5;
                    goto case 5;

                case 5:
                    int num6 = num1 - this.dist;
                    while (num6 < 0)
                    {
                        num6 += s.WindowEnd;
                    }
                    for (; this.len != 0; --this.len)
                    {
                        if (num2 == 0)
                        {
                            if (num1 == s.WindowEnd && s.WindowRead != 0)
                            {
                                num1 = 0;
                                num2 = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                            }
                            if (num2 == 0)
                            {
                                s.WindowWrite = num1;
                                r             = s.InflateFlush(z, r);
                                num1          = s.WindowWrite;
                                num2          = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                                if (num1 == s.WindowEnd && s.WindowRead != 0)
                                {
                                    num1 = 0;
                                    num2 = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                                }
                                if (num2 == 0)
                                {
                                    s.BitBuffer       = number;
                                    s.BitBufferLength = bitBufferLength;
                                    z.InputCount      = inputCount;
                                    z.InputTotal     += (long)(inputIndex - z.InputIndex);
                                    z.InputIndex      = inputIndex;
                                    s.WindowWrite     = num1;
                                    return(s.InflateFlush(z, r));
                                }
                            }
                        }
                        s.Window[num1++] = s.Window[num6++];
                        --num2;
                        if (num6 == s.WindowEnd)
                        {
                            num6 = 0;
                        }
                    }
                    this.mode = 0;
                    break;

                case 6:
                    if (num2 == 0)
                    {
                        if (num1 == s.WindowEnd && s.WindowRead != 0)
                        {
                            num1 = 0;
                            num2 = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                        }
                        if (num2 == 0)
                        {
                            s.WindowWrite = num1;
                            r             = s.InflateFlush(z, r);
                            num1          = s.WindowWrite;
                            num2          = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                            if (num1 == s.WindowEnd && s.WindowRead != 0)
                            {
                                num1 = 0;
                                num2 = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;
                            }
                            if (num2 == 0)
                            {
                                goto label_67;
                            }
                        }
                    }
                    r = 0;
                    s.Window[num1++] = (byte)this.lit;
                    --num2;
                    this.mode = 0;
                    break;

                case 7:
                    goto label_70;

                case 8:
                    goto label_75;

                case 9:
                    goto label_76;

                default:
                    goto label_77;
                }
            }
label_20:
            this.mode      = 9;
            z.ErrorMessage = "invalid literal/length code";
            r                 = -3;
            s.BitBuffer       = number;
            s.BitBufferLength = bitBufferLength;
            z.InputCount      = inputCount;
            z.InputTotal     += (long)(inputIndex - z.InputIndex);
            z.InputIndex      = inputIndex;
            s.WindowWrite     = num1;
            return(s.InflateFlush(z, r));

label_36:
            this.mode      = 9;
            z.ErrorMessage = "invalid distance code";
            r                 = -3;
            s.BitBuffer       = number;
            s.BitBufferLength = bitBufferLength;
            z.InputCount      = inputCount;
            z.InputTotal     += (long)(inputIndex - z.InputIndex);
            z.InputIndex      = inputIndex;
            s.WindowWrite     = num1;
            return(s.InflateFlush(z, r));

label_67:
            s.BitBuffer       = number;
            s.BitBufferLength = bitBufferLength;
            z.InputCount      = inputCount;
            z.InputTotal     += (long)(inputIndex - z.InputIndex);
            z.InputIndex      = inputIndex;
            s.WindowWrite     = num1;
            return(s.InflateFlush(z, r));

label_70:
            if (bitBufferLength > 7)
            {
                bitBufferLength -= 8;
                ++inputCount;
                --inputIndex;
            }
            s.WindowWrite = num1;
            r             = s.InflateFlush(z, r);
            num1          = s.WindowWrite;
            int num7 = num1 < s.WindowRead ? s.WindowRead - num1 - 1 : s.WindowEnd - num1;

            if (s.WindowRead != s.WindowWrite)
            {
                s.BitBuffer       = number;
                s.BitBufferLength = bitBufferLength;
                z.InputCount      = inputCount;
                z.InputTotal     += (long)(inputIndex - z.InputIndex);
                z.InputIndex      = inputIndex;
                s.WindowWrite     = num1;
                return(s.InflateFlush(z, r));
            }
            this.mode = 8;
label_75:
            r                 = 1;
            s.BitBuffer       = number;
            s.BitBufferLength = bitBufferLength;
            z.InputCount      = inputCount;
            z.InputTotal     += (long)(inputIndex - z.InputIndex);
            z.InputIndex      = inputIndex;
            s.WindowWrite     = num1;
            return(s.InflateFlush(z, r));

label_76:
            r                 = -3;
            s.BitBuffer       = number;
            s.BitBufferLength = bitBufferLength;
            z.InputCount      = inputCount;
            z.InputTotal     += (long)(inputIndex - z.InputIndex);
            z.InputIndex      = inputIndex;
            s.WindowWrite     = num1;
            return(s.InflateFlush(z, r));

label_77:
            r                 = -2;
            s.BitBuffer       = number;
            s.BitBufferLength = bitBufferLength;
            z.InputCount      = inputCount;
            z.InputTotal     += (long)(inputIndex - z.InputIndex);
            z.InputIndex      = inputIndex;
            s.WindowWrite     = num1;
            return(s.InflateFlush(z, r));
        }
Пример #27
0
        internal int InflateFast(
            int bl,
            int bd,
            int[] tl,
            int tlIndex,
            int[] td,
            int tdIndex,
            InflaterBlocks s,
            CompressionStream z)
        {
            int inputIndex       = z.InputIndex;
            int inputCount       = z.InputCount;
            int num1             = s.BitBuffer;
            int num2             = s.BitBufferLength;
            int destinationIndex = s.WindowWrite;
            int num3             = destinationIndex < s.WindowRead ? s.WindowRead - destinationIndex - 1 : s.WindowEnd - destinationIndex;
            int num4             = InflaterCodes.inflateMask[bl];
            int num5             = InflaterCodes.inflateMask[bd];

            do
            {
                for (; num2 < 20; num2 += 8)
                {
                    --inputCount;
                    num1 |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << num2;
                }
                int   num6      = num1 & num4;
                int[] numArray1 = tl;
                int   num7      = tlIndex;
                int   index1    = (num7 + num6) * 3;
                int   index2;
                if ((index2 = numArray1[index1]) == 0)
                {
                    num1 >>= numArray1[index1 + 1];
                    num2  -= numArray1[index1 + 1];
                    s.Window[destinationIndex++] = (byte)numArray1[index1 + 2];
                    --num3;
                }
                else
                {
                    bool flag;
                    while (true)
                    {
                        num1 >>= numArray1[index1 + 1];
                        num2  -= numArray1[index1 + 1];
                        if ((index2 & 16) == 0)
                        {
                            if ((index2 & 64) == 0)
                            {
                                num6   = num6 + numArray1[index1 + 2] + (num1 & InflaterCodes.inflateMask[index2]);
                                index1 = (num7 + num6) * 3;
                                if ((index2 = numArray1[index1]) != 0)
                                {
                                    flag = true;
                                }
                                else
                                {
                                    goto label_34;
                                }
                            }
                            else
                            {
                                goto label_35;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    int index3  = index2 & 15;
                    int length1 = numArray1[index1 + 2] + (num1 & InflaterCodes.inflateMask[index3]);
                    int num8    = num1 >> index3;
                    int num9;
                    for (num9 = num2 - index3; num9 < 15; num9 += 8)
                    {
                        --inputCount;
                        num8 |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << num9;
                    }
                    int   num10     = num8 & num5;
                    int[] numArray2 = td;
                    int   num11     = tdIndex;
                    int   index4    = (num11 + num10) * 3;
                    int   index5    = numArray2[index4];
                    while (true)
                    {
                        num8 >>= numArray2[index4 + 1];
                        num9  -= numArray2[index4 + 1];
                        if ((index5 & 16) == 0)
                        {
                            if ((index5 & 64) == 0)
                            {
                                num10  = num10 + numArray2[index4 + 2] + (num8 & InflaterCodes.inflateMask[index5]);
                                index4 = (num11 + num10) * 3;
                                index5 = numArray2[index4];
                                flag   = true;
                            }
                            else
                            {
                                goto label_31;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    int index6;
                    for (index6 = index5 & 15; num9 < index6; num9 += 8)
                    {
                        --inputCount;
                        num8 |= ((int)z.Input[inputIndex++] & (int)byte.MaxValue) << num9;
                    }
                    int num12 = numArray2[index4 + 2] + (num8 & InflaterCodes.inflateMask[index6]);
                    num1  = num8 >> index6;
                    num2  = num9 - index6;
                    num3 -= length1;
                    int sourceIndex1;
                    int num13;
                    if (destinationIndex >= num12)
                    {
                        int sourceIndex2 = destinationIndex - num12;
                        if (destinationIndex - sourceIndex2 > 0 && 2 > destinationIndex - sourceIndex2)
                        {
                            byte[] window1 = s.Window;
                            int    index7  = destinationIndex;
                            int    num14   = index7 + 1;
                            byte[] window2 = s.Window;
                            int    index8  = sourceIndex2;
                            int    num15   = index8 + 1;
                            int    num16   = (int)window2[index8];
                            window1[index7] = (byte)num16;
                            byte[] window3 = s.Window;
                            int    index9  = num14;
                            destinationIndex = index9 + 1;
                            byte[] window4 = s.Window;
                            int    index10 = num15;
                            sourceIndex1 = index10 + 1;
                            int num17 = (int)window4[index10];
                            window3[index9] = (byte)num17;
                            length1        -= 2;
                        }
                        else
                        {
                            Array.Copy((Array)s.Window, sourceIndex2, (Array)s.Window, destinationIndex, 2);
                            destinationIndex += 2;
                            sourceIndex1      = sourceIndex2 + 2;
                            length1          -= 2;
                        }
                    }
                    else
                    {
                        sourceIndex1 = destinationIndex - num12;
                        do
                        {
                            sourceIndex1 += s.WindowEnd;
                        }while (sourceIndex1 < 0);
                        int length2 = s.WindowEnd - sourceIndex1;
                        if (length1 > length2)
                        {
                            length1 -= length2;
                            if (destinationIndex - sourceIndex1 > 0 && length2 > destinationIndex - sourceIndex1)
                            {
                                do
                                {
                                    s.Window[destinationIndex++] = s.Window[sourceIndex1++];
                                }while (--length2 != 0);
                            }
                            else
                            {
                                Array.Copy((Array)s.Window, sourceIndex1, (Array)s.Window, destinationIndex, length2);
                                destinationIndex += length2;
                                num13             = sourceIndex1 + length2;
                            }
                            sourceIndex1 = 0;
                        }
                    }
                    if (destinationIndex - sourceIndex1 > 0 && length1 > destinationIndex - sourceIndex1)
                    {
                        do
                        {
                            s.Window[destinationIndex++] = s.Window[sourceIndex1++];
                        }while (--length1 != 0);
                        goto label_39;
                    }
                    else
                    {
                        Array.Copy((Array)s.Window, sourceIndex1, (Array)s.Window, destinationIndex, length1);
                        destinationIndex += length1;
                        num13             = sourceIndex1 + length1;
                        goto label_39;
                    }
label_31:
                    z.ErrorMessage = "invalid distance code";
                    int num18 = z.InputCount - inputCount;
                    int num19 = num9 >> 3 < num18 ? num9 >> 3 : num18;
                    int num20 = inputCount + num19;
                    int num21 = inputIndex - num19;
                    int num22 = num9 - (num19 << 3);
                    s.BitBuffer       = num8;
                    s.BitBufferLength = num22;
                    z.InputCount      = num20;
                    z.InputTotal     += (long)(num21 - z.InputIndex);
                    z.InputIndex      = num21;
                    s.WindowWrite     = destinationIndex;
                    return(-3);

label_34:
                    num1 >>= numArray1[index1 + 1];
                    num2  -= numArray1[index1 + 1];
                    s.Window[destinationIndex++] = (byte)numArray1[index1 + 2];
                    --num3;
                    goto label_39;
label_35:
                    if ((index2 & 32) != 0)
                    {
                        int num14 = z.InputCount - inputCount;
                        int num15 = num2 >> 3 < num14 ? num2 >> 3 : num14;
                        int num16 = inputCount + num15;
                        int num17 = inputIndex - num15;
                        int num23 = num2 - (num15 << 3);
                        s.BitBuffer       = num1;
                        s.BitBufferLength = num23;
                        z.InputCount      = num16;
                        z.InputTotal     += (long)(num17 - z.InputIndex);
                        z.InputIndex      = num17;
                        s.WindowWrite     = destinationIndex;
                        return(1);
                    }
                    z.ErrorMessage = "invalid literal/length code";
                    int num24 = z.InputCount - inputCount;
                    int num25 = num2 >> 3 < num24 ? num2 >> 3 : num24;
                    int num26 = inputCount + num25;
                    int num27 = inputIndex - num25;
                    int num28 = num2 - (num25 << 3);
                    s.BitBuffer       = num1;
                    s.BitBufferLength = num28;
                    z.InputCount      = num26;
                    z.InputTotal     += (long)(num27 - z.InputIndex);
                    z.InputIndex      = num27;
                    s.WindowWrite     = destinationIndex;
                    return(-3);

                    label_39 :;
                }
            }while (num3 >= 258 && inputCount >= 10);
            int num29 = z.InputCount - inputCount;
            int num30 = num2 >> 3 < num29 ? num2 >> 3 : num29;
            int num31 = inputCount + num30;
            int num32 = inputIndex - num30;
            int num33 = num2 - (num30 << 3);

            s.BitBuffer       = num1;
            s.BitBufferLength = num33;
            z.InputCount      = num31;
            z.InputTotal     += (long)(num32 - z.InputIndex);
            z.InputIndex      = num32;
            s.WindowWrite     = destinationIndex;
            return(0);
        }
Пример #28
0
 internal void Free(CompressionStream z)
 {
 }
Пример #29
0
        private int ProcessDTree(CompressionStream zip, InflaterBlocksContext state, int res)
        {
            while (true)
            {
                state.Temp = this.table;
                if (this.index < 258 + (state.Temp & 31) + (state.Temp >> 5 & 31))
                {
                    for (state.Temp = this.bitLengthTreeDepth[0]; state.Bits < state.Temp; state.Bits += 8)
                    {
                        if (state.BytesCount != 0)
                        {
                            res = 0;
                            --state.BytesCount;
                            state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
                        }
                        else
                        {
                            this.TransferBlocksState(zip, state);
                            state.IsReturn = true;
                            return(this.InflateFlush(zip, res));
                        }
                    }
                    state.Temp = this.hufts[(this.bitLengthDecodeTree[0] + (state.BitBuf & InflaterBlocks.inflateMask[state.Temp])) * 3 + 1];
                    int huft = this.hufts[(this.bitLengthDecodeTree[0] + (state.BitBuf & InflaterBlocks.inflateMask[state.Temp])) * 3 + 2];
                    if (huft < 16)
                    {
                        state.ShiftRight(state.Temp);
                        this.blens[this.index++] = huft;
                    }
                    else
                    {
                        int v    = huft == 18 ? 7 : huft - 14;
                        int num1 = huft == 18 ? 11 : 3;
                        for (; state.Bits < state.Temp + v; state.Bits += 8)
                        {
                            if (state.BytesCount != 0)
                            {
                                res = 0;
                                --state.BytesCount;
                                state.BitBuf |= ((int)zip.Input[state.Input++] & (int)byte.MaxValue) << state.Bits;
                            }
                            else
                            {
                                this.TransferBlocksState(zip, state);
                                state.IsReturn = true;
                                return(this.InflateFlush(zip, res));
                            }
                        }
                        state.ShiftRight(state.Temp);
                        int num2 = num1 + (state.BitBuf & InflaterBlocks.inflateMask[v]);
                        state.ShiftRight(v);
                        int index = this.index;
                        state.Temp = this.table;
                        if (index + num2 <= 258 + (state.Temp & 31) + (state.Temp >> 5 & 31) && (huft != 16 || index >= 1))
                        {
                            int num3 = huft == 16 ? this.blens[index - 1] : 0;
                            do
                            {
                                this.blens[index++] = num3;
                            }while (--num2 != 0);
                            this.index = index;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    goto label_20;
                }
            }
            this.blens       = (int[])null;
            this.mode        = 9;
            zip.ErrorMessage = "invalid bit length repeat";
            res = -3;
            this.TransferBlocksState(zip, state);
            state.IsReturn = true;
            return(this.InflateFlush(zip, res));

label_20:
            this.bitLengthDecodeTree[0] = -1;
            int[] bl = new int[1];
            int[] bd = new int[1];
            int[] tl = new int[1];
            int[] td = new int[1];
            bl[0]      = 9;
            bd[0]      = 6;
            state.Temp = this.table;
            state.Temp = InflaterTree.InflateTreeDynamic(257 + (state.Temp & 31), 1 + (state.Temp >> 5 & 31), this.blens, bl, bd, tl, td, this.hufts, zip);
            if (state.Temp != 0)
            {
                if (state.Temp == -3)
                {
                    this.blens = (int[])null;
                    this.mode  = 9;
                }
                res = state.Temp;
                this.TransferBlocksState(zip, state);
                state.IsReturn = true;
                return(this.InflateFlush(zip, res));
            }
            this.codes = new InflaterCodes(bl[0], bd[0], this.hufts, tl[0], this.hufts, td[0], zip);
            this.mode  = 6;
            return(0);
        }