Пример #1
0
 public Tree(SimpleZip.DeflaterHuffman dh, int elems, int minCodes, int maxLength)
 {
     this.dh = dh;
     this.minNumCodes = minCodes;
     this.maxLength = maxLength;
     this.freqs = new short[elems];
     this.bl_counts = new int[maxLength];
 }
Пример #2
0
 public DeflaterEngine(SimpleZip.DeflaterPending pending)
 {
     this.pending = pending;
     this.huffman = new SimpleZip.DeflaterHuffman(pending);
     this.window = new byte[0x10000];
     this.head = new short[0x8000];
     this.prev = new short[0x8000];
     this.blockStart = this.strstart = 1;
 }
Пример #3
0
 public DeflaterHuffman(SimpleZip.DeflaterPending pending)
 {
     this.pending = pending;
     this.literalTree = new Tree(this, 0x11e, 0x101, 15);
     this.distTree = new Tree(this, 30, 1, 15);
     this.blTree = new Tree(this, 0x13, 4, 7);
     this.d_buf = new short[0x4000];
     this.l_buf = new byte[0x4000];
 }
Пример #4
0
 public int GetSymbol(SimpleZip.StreamManipulator input)
 {
     int num2;
     int index = input.PeekBits(9);
     if (index >= 0)
     {
         num2 = this.tree[index];
         if (num2 >= 0)
         {
             input.DropBits(num2 & 15);
             return (num2 >> 4);
         }
         int num3 = -(num2 >> 4);
         int n = num2 & 15;
         index = input.PeekBits(n);
         if (index >= 0)
         {
             num2 = this.tree[num3 | (index >> 9)];
             input.DropBits(num2 & 15);
             return (num2 >> 4);
         }
         int num5 = input.AvailableBits;
         index = input.PeekBits(num5);
         num2 = this.tree[num3 | (index >> 9)];
         if ((num2 & 15) <= num5)
         {
             input.DropBits(num2 & 15);
             return (num2 >> 4);
         }
         return -1;
     }
     int availableBits = input.AvailableBits;
     index = input.PeekBits(availableBits);
     num2 = this.tree[index];
     if ((num2 >= 0) && ((num2 & 15) <= availableBits))
     {
         input.DropBits(num2 & 15);
         return (num2 >> 4);
     }
     return -1;
 }
Пример #5
0
 public int CopyStored(SimpleZip.StreamManipulator input, int len)
 {
     int num;
     len = Math.Min(Math.Min(len, 0x8000 - this.windowFilled), input.AvailableBytes);
     int length = 0x8000 - this.windowEnd;
     if (len > length)
     {
         num = input.CopyBytes(this.window, this.windowEnd, length);
         if (num == length)
         {
             num += input.CopyBytes(this.window, 0, len - length);
         }
     }
     else
     {
         num = input.CopyBytes(this.window, this.windowEnd, len);
     }
     this.windowEnd = (this.windowEnd + num) & 0x7fff;
     this.windowFilled += num;
     return num;
 }
Пример #6
0
            public bool Decode(SimpleZip.StreamManipulator input)
            {
                int num2;
                int num3;
            Label_0000:
                switch (this.mode)
                {
                    case 0:
                        this.lnum = input.PeekBits(5);
                        if (this.lnum >= 0)
                        {
                            this.lnum += 0x101;
                            input.DropBits(5);
                            this.mode = 1;
                            break;
                        }
                        return false;

                    case 1:
                        break;

                    case 2:
                        goto Label_00B9;

                    case 3:
                        goto Label_013B;

                    case 4:
                        goto Label_01A8;

                    case 5:
                        goto Label_01DE;

                    default:
                        goto Label_0000;
                }
                this.dnum = input.PeekBits(5);
                if (this.dnum < 0)
                {
                    return false;
                }
                this.dnum++;
                input.DropBits(5);
                this.num = this.lnum + this.dnum;
                this.litdistLens = new byte[this.num];
                this.mode = 2;
            Label_00B9:
                this.blnum = input.PeekBits(4);
                if (this.blnum < 0)
                {
                    return false;
                }
                this.blnum += 4;
                input.DropBits(4);
                this.blLens = new byte[0x13];
                this.ptr = 0;
                this.mode = 3;
            Label_013B:
                while (this.ptr < this.blnum)
                {
                    int num = input.PeekBits(3);
                    if (num < 0)
                    {
                        return false;
                    }
                    input.DropBits(3);
                    this.blLens[BL_ORDER[this.ptr]] = (byte) num;
                    this.ptr++;
                }
                this.blTree = new SimpleZip.InflaterHuffmanTree(this.blLens);
                this.blLens = null;
                this.ptr = 0;
                this.mode = 4;
            Label_01A8:
                while (((num2 = this.blTree.GetSymbol(input)) & -16) == 0)
                {
                    this.litdistLens[this.ptr++] = this.lastLen = (byte) num2;
                    if (this.ptr == this.num)
                    {
                        return true;
                    }
                }
                if (num2 < 0)
                {
                    return false;
                }
                if (num2 >= 0x11)
                {
                    this.lastLen = 0;
                }
                this.repSymbol = num2 - 0x10;
                this.mode = 5;
            Label_01DE:
                num3 = repBits[this.repSymbol];
                int num4 = input.PeekBits(num3);
                if (num4 < 0)
                {
                    return false;
                }
                input.DropBits(num3);
                num4 += repMin[this.repSymbol];
                while (num4-- > 0)
                {
                    this.litdistLens[this.ptr++] = this.lastLen;
                }
                if (this.ptr == this.num)
                {
                    return true;
                }
                this.mode = 4;
                goto Label_0000;
            }
Пример #7
0
 public void WriteTree(SimpleZip.DeflaterHuffman.Tree blTree)
 {
     int code = -1;
     int index = 0;
     while (index < this.numCodes)
     {
         int num;
         int num2;
         int num3 = 1;
         int num6 = this.length[index];
         if (num6 == 0)
         {
             num = 0x8a;
             num2 = 3;
         }
         else
         {
             num = 6;
             num2 = 3;
             if (code != num6)
             {
                 blTree.WriteSymbol(num6);
                 num3 = 0;
             }
         }
         code = num6;
         index++;
         while ((index < this.numCodes) && (code == this.length[index]))
         {
             index++;
             if (++num3 >= num)
             {
                 break;
             }
         }
         if (num3 < num2)
         {
             while (num3-- > 0)
             {
                 blTree.WriteSymbol(code);
             }
         }
         else if (code != 0)
         {
             blTree.WriteSymbol(0x10);
             this.dh.pending.WriteBits(num3 - 3, 2);
         }
         else
         {
             if (num3 <= 10)
             {
                 blTree.WriteSymbol(0x11);
                 this.dh.pending.WriteBits(num3 - 3, 3);
                 continue;
             }
             blTree.WriteSymbol(0x12);
             this.dh.pending.WriteBits(num3 - 11, 7);
         }
     }
 }
Пример #8
0
 public void CalcBLFreq(SimpleZip.DeflaterHuffman.Tree blTree)
 {
     int index = -1;
     int num5 = 0;
     while (num5 < this.numCodes)
     {
         int num;
         int num2;
         int num3 = 1;
         int num6 = this.length[num5];
         if (num6 == 0)
         {
             num = 0x8a;
             num2 = 3;
         }
         else
         {
             num = 6;
             num2 = 3;
             if (index != num6)
             {
                 blTree.freqs[num6] = (short) (blTree.freqs[num6] + 1);
                 num3 = 0;
             }
         }
         index = num6;
         num5++;
         while ((num5 < this.numCodes) && (index == this.length[num5]))
         {
             num5++;
             if (++num3 >= num)
             {
                 break;
             }
         }
         if (num3 < num2)
         {
             blTree.freqs[index] = (short) (blTree.freqs[index] + ((short) num3));
         }
         else
         {
             if (index != 0)
             {
                 blTree.freqs[0x10] = (short) (blTree.freqs[0x10] + 1);
                 continue;
             }
             if (num3 <= 10)
             {
                 blTree.freqs[0x11] = (short) (blTree.freqs[0x11] + 1);
                 continue;
             }
             blTree.freqs[0x12] = (short) (blTree.freqs[0x12] + 1);
         }
     }
 }
Пример #9
0
        // Token: 0x060002CA RID: 714 RVA: 0x0002807C File Offset: 0x0002627C
        public static byte[] Unzip(byte[] byte_0)
        {
            Assembly callingAssembly   = Assembly.GetCallingAssembly();
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            if (callingAssembly != executingAssembly && !SimpleZip.PublicKeysMatch(executingAssembly, callingAssembly))
            {
                return(null);
            }
            SimpleZip.ZipStream zipStream = new SimpleZip.ZipStream(byte_0);
            byte[] array = new byte[0];
            int    num   = zipStream.ReadInt();

            if (num == 67324752)
            {
                short num2 = (short)zipStream.ReadShort();
                int   num3 = zipStream.ReadShort();
                int   num4 = zipStream.ReadShort();
                if (num == 67324752 && num2 == 20 && num3 == 0)
                {
                    if (num4 == 8)
                    {
                        zipStream.ReadInt();
                        zipStream.ReadInt();
                        zipStream.ReadInt();
                        int num5 = zipStream.ReadInt();
                        int num6 = zipStream.ReadShort();
                        int num7 = zipStream.ReadShort();
                        if (num6 > 0)
                        {
                            byte[] buffer = new byte[num6];
                            zipStream.Read(buffer, 0, num6);
                        }
                        if (num7 > 0)
                        {
                            byte[] buffer2 = new byte[num7];
                            zipStream.Read(buffer2, 0, num7);
                        }
                        byte[] array2 = new byte[zipStream.Length - zipStream.Position];
                        zipStream.Read(array2, 0, array2.Length);
                        SimpleZip.Inflater inflater = new SimpleZip.Inflater(array2);
                        array = new byte[num5];
                        inflater.Inflate(array, 0, array.Length);
                        goto IL_265;
                    }
                }
                throw new FormatException("Wrong Header Signature");
            }
            int num8 = num >> 24;

            num -= num8 << 24;
            if (num == 8223355)
            {
                if (num8 == 1)
                {
                    int num9 = zipStream.ReadInt();
                    array = new byte[num9];
                    int num11;
                    for (int i = 0; i < num9; i += num11)
                    {
                        int num10 = zipStream.ReadInt();
                        num11 = zipStream.ReadInt();
                        byte[] array3 = new byte[num10];
                        zipStream.Read(array3, 0, array3.Length);
                        new SimpleZip.Inflater(array3).Inflate(array, i, num11);
                    }
                }
                if (num8 == 2)
                {
                    byte[] byte_ = new byte[]
                    {
                        72,
                        196,
                        226,
                        220,
                        77,
                        90,
                        77,
                        41
                    };
                    byte[] byte_2 = new byte[]
                    {
                        17,
                        242,
                        176,
                        1,
                        248,
                        117,
                        118,
                        164
                    };
                    using (ICryptoTransform desTransform = SimpleZip.GetDesTransform(byte_, byte_2, true))
                    {
                        array = SimpleZip.Unzip(desTransform.TransformFinalBlock(byte_0, 4, byte_0.Length - 4));
                    }
                }
                if (num8 != 3)
                {
                    goto IL_265;
                }
                byte[] byte_3 = new byte[]
                {
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1
                };
                byte[] byte_4 = new byte[]
                {
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2
                };
                using (ICryptoTransform aesTransform = SimpleZip.GetAesTransform(byte_3, byte_4, true))
                {
                    array = SimpleZip.Unzip(aesTransform.TransformFinalBlock(byte_0, 4, byte_0.Length - 4));
                    goto IL_265;
                }
            }
            throw new FormatException("Unknown Header");
IL_265:
            zipStream.Close();
            zipStream = null;
            return(array);
        }
Пример #10
0
        // Token: 0x06000252 RID: 594 RVA: 0x00012F88 File Offset: 0x00011188
        public static byte[] Unzip(byte[] A_0)
        {
            Assembly callingAssembly   = Assembly.GetCallingAssembly();
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            if (callingAssembly != executingAssembly && !SimpleZip.PublicKeysMatch(executingAssembly, callingAssembly))
            {
                return(null);
            }
            SimpleZip.ZipStream zipStream = new SimpleZip.ZipStream(A_0);
            byte[] array = new byte[0];
            int    num   = zipStream.ReadInt();

            if (num != 67324752)
            {
                int num2 = num >> 24;
                num -= num2 << 24;
                if (num == 8223355)
                {
                    if (num2 == 1)
                    {
                        int num3 = zipStream.ReadInt();
                        array = new byte[num3];
                        int num5;
                        for (int i = 0; i < num3; i += num5)
                        {
                            int num4 = zipStream.ReadInt();
                            num5 = zipStream.ReadInt();
                            byte[] array2 = new byte[num4];
                            zipStream.Read(array2, 0, array2.Length);
                            new SimpleZip.Inflater(array2).Inflate(array, i, num5);
                        }
                    }
                    if (num2 == 2)
                    {
                        byte[] array3 = new byte[]
                        {
                            72,
                            196,
                            226,
                            220,
                            77,
                            90,
                            77,
                            41
                        };
                        byte[] array4 = new byte[]
                        {
                            17,
                            242,
                            176,
                            1,
                            248,
                            117,
                            118,
                            164
                        };
                        using (ICryptoTransform desTransform = SimpleZip.GetDesTransform(array3, array4, true))
                        {
                            array = SimpleZip.Unzip(desTransform.TransformFinalBlock(A_0, 4, A_0.Length - 4));
                        }
                    }
                    if (num2 != 3)
                    {
                        goto IL_287;
                    }
                    byte[] array5 = new byte[]
                    {
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1,
                        1
                    };
                    byte[] array6 = new byte[]
                    {
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2
                    };
                    using (ICryptoTransform aesTransform = SimpleZip.GetAesTransform(array5, array6, true))
                    {
                        array = SimpleZip.Unzip(aesTransform.TransformFinalBlock(A_0, 4, A_0.Length - 4));
                        goto IL_287;
                    }
                }
                throw new FormatException("Unknown Header");
            }
            short num6 = (short)zipStream.ReadShort();
            int   num7 = zipStream.ReadShort();
            int   num8 = zipStream.ReadShort();

            if (num != 67324752 || num6 != 20 || num7 != 0 || num8 != 8)
            {
                throw new FormatException("Wrong Header Signature");
            }
            zipStream.ReadInt();
            zipStream.ReadInt();
            zipStream.ReadInt();
            int num9  = zipStream.ReadInt();
            int num10 = zipStream.ReadShort();
            int num11 = zipStream.ReadShort();

            if (num10 > 0)
            {
                byte[] buffer = new byte[num10];
                zipStream.Read(buffer, 0, num10);
            }
            if (num11 > 0)
            {
                byte[] buffer2 = new byte[num11];
                zipStream.Read(buffer2, 0, num11);
            }
            byte[] array7 = new byte[zipStream.Length - zipStream.Position];
            zipStream.Read(array7, 0, array7.Length);
            SimpleZip.Inflater inflater = new SimpleZip.Inflater(array7);
            array = new byte[num9];
            inflater.Inflate(array, 0, array.Length);
IL_287:
            zipStream.Close();
            zipStream = null;
            return(array);
        }