// Token: 0x060020A8 RID: 8360 RVA: 0x0006DF14 File Offset: 0x0006C114
        private void method_6(Stream file_stream, BinaryReader reader, bool loadIcon, bool populateData)
        {
            this.ID             = reader.smethod_29();
            this.DataHash       = reader.smethod_24();
            this.LoaderPack     = Struct43.smethod_5(this.DataHash, Struct43.struct43_0);
            this.UpdateUri      = reader.smethod_32();
            this.Name           = reader.ReadString();
            this.Author         = reader.ReadString();
            this.Description    = reader.ReadString();
            this.Version        = reader.smethod_27();
            this.MinimumVersion = reader.smethod_27();
            this.PasswordHash   = reader.smethod_24();
            int num = reader.ReadInt32();

            if (num > 0)
            {
                if (loadIcon)
                {
                    using (Stream3 stream = new Stream3(file_stream, file_stream.Position, (long)num + file_stream.Position))
                    {
                        this.memoryStream_0 = new MemoryStream();
                        stream.CopyTo(this.memoryStream_0);
                        this.Icon = (Bitmap)Image.FromStream(this.memoryStream_0);
                        goto IL_EE;
                    }
                }
                file_stream.Position += (long)num;
            }
IL_EE:
            if (this.LoaderPack)
            {
                if (populateData)
                {
                    this.Data = new Class136();
                    return;
                }
            }
            else
            {
                int num2 = reader.ReadInt32();
                for (int i = 0; i < num2; i++)
                {
                    this.ItemIndex.Add(reader.ReadString(), reader.smethod_24());
                }
                int num3 = reader.ReadInt32();
                if (populateData)
                {
                    using (Stream3 stream2 = new Stream3(file_stream, file_stream.Position, (long)num3 + file_stream.Position))
                    {
                        this.Data = new Class136(stream2);
                        this.Data.method_12();
                        return;
                    }
                }
                file_stream.Position += (long)num3;
            }
        }
 // Token: 0x060019BB RID: 6587 RVA: 0x00008F60 File Offset: 0x00007160
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (!(destinationType == typeof(string)))
     {
         return(base.ConvertTo(context, culture, value, destinationType));
     }
     if (Struct43.smethod_5((Struct43)value, Struct43.struct43_0))
     {
         return(Class195.string_0);
     }
     return(value.ToString());
 }
Exemple #3
0
 // Token: 0x0600261C RID: 9756 RVA: 0x00086AFC File Offset: 0x00084CFC
 public bool method_0(Struct43 currentHash, Version currentVersion, out int startIndex)
 {
     for (int i = 0; i < this.list_0.Count; i++)
     {
         KeyValuePair <Struct43, Class319> keyValuePair = this.list_0[i];
         if (Struct43.smethod_5(keyValuePair.Key, currentHash) && keyValuePair.Value.ExpectedContentPackVersion == currentVersion)
         {
             startIndex = i;
             return(true);
         }
     }
     startIndex = -1;
     return(false);
 }
Exemple #4
0
 // Token: 0x060018C5 RID: 6341 RVA: 0x00043388 File Offset: 0x00041588
 public bool method_2(Struct43 hash)
 {
     lock (((ICollection)this.Patches).SyncRoot)
     {
         foreach (Class282 @class in this.Patches)
         {
             if (Struct43.smethod_5(@class.ExpectedHash, hash))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #5
0
        // Token: 0x0600243F RID: 9279 RVA: 0x0007AE64 File Offset: 0x00079064
        private static void smethod_1(Class321 pd, BinaryWriter write_stream, uint offset_orig, uint offset_new, string filename, Stream stream_orig, uint orig_start, uint orig_end, Stream stream_new, uint new_start, uint new_end)
        {
            uint num  = new_end - new_start;
            uint num2 = orig_end - orig_start;

            using (Stream3 stream = new Stream3(stream_orig, (long)((ulong)orig_start), (long)((ulong)orig_end)))
            {
                using (Stream3 stream2 = new Stream3(stream_new, (long)((ulong)new_start), (long)((ulong)new_end)))
                {
                    if (num == num2 && Struct43.smethod_5(stream.smethod_2(), stream2.smethod_2()))
                    {
                        Class292.smethod_4(pd, write_stream, 0U, null, 0U, num2, offset_orig + orig_start);
                    }
                    else
                    {
                        Class292.smethod_12(pd, Class292.smethod_15(filename), write_stream, offset_orig + orig_start, offset_new + new_start, stream, stream2);
                    }
                }
            }
        }
Exemple #6
0
        // Token: 0x060018C4 RID: 6340 RVA: 0x000432E0 File Offset: 0x000414E0
        public Class186 method_1(Struct43 expectedHash)
        {
            Class186 @class = this.method_0();

            lock (((ICollection)this.Patches).SyncRoot)
            {
                for (int i = this.Patches.Count - 1; i >= 0; i--)
                {
                    if (Struct43.smethod_5(expectedHash, this.Patches[i].ExpectedHash))
                    {
                        while (i < this.Patches.Count)
                        {
                            @class.Patches.Add(this.Patches[i].imethod_0());
                            i++;
                        }
                        break;
                    }
                }
            }
            return(@class);
        }
Exemple #7
0
        // Token: 0x060018C7 RID: 6343 RVA: 0x00043434 File Offset: 0x00041634
        public Enum23 method_4(string filename, out Struct43 actualFileHash, out long actualFileSize)
        {
            actualFileSize = 0L;
            actualFileHash = default(Struct43);
            Enum23 result;

            try
            {
                if (File.Exists(filename))
                {
                    actualFileHash = Class513.smethod_0(filename);
                    if (this.ExpectedSize == (actualFileSize = Class234.smethod_11(filename)))
                    {
                        if (Struct43.smethod_5(this.ExpectedHash, actualFileHash))
                        {
                            result = Enum23.const_2;
                        }
                        else
                        {
                            result = Enum23.const_1;
                        }
                    }
                    else
                    {
                        result = Enum23.const_1;
                    }
                }
                else
                {
                    result = Enum23.const_0;
                }
            }
            finally
            {
                this.ForceRecheck = false;
            }
            return(result);
        }
 // Token: 0x060020A7 RID: 8359 RVA: 0x0006DE08 File Offset: 0x0006C008
 private static void smethod_3(Stream stream, out uint index, out uint data_length)
 {
     using (Stream3 stream2 = new Stream3(stream))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream2))
         {
             binaryReader.ReadBytes(Class132.byte_0.Length);
             binaryReader.ReadInt32();
             binaryReader.smethod_29();
             Struct43 val = binaryReader.smethod_24();
             if (Struct43.smethod_5(val, Struct43.struct43_0))
             {
                 throw new LoaderPackNotSupported();
             }
             if (binaryReader.ReadBoolean())
             {
                 binaryReader.ReadString();
             }
             binaryReader.ReadString();
             binaryReader.ReadString();
             binaryReader.ReadString();
             binaryReader.smethod_27();
             binaryReader.smethod_27();
             binaryReader.smethod_24();
             int num = binaryReader.ReadInt32();
             stream.Position += (long)num;
             int num2 = binaryReader.ReadInt32();
             for (int i = 0; i < num2; i++)
             {
                 binaryReader.ReadString();
                 binaryReader.smethod_24();
             }
             data_length = (uint)binaryReader.ReadInt32();
             index       = (uint)stream.Position;
         }
     }
 }
Exemple #9
0
        // Token: 0x060018C8 RID: 6344 RVA: 0x000434B8 File Offset: 0x000416B8
        public Enum23 method_5(Class186 lastFile, string filename, out Struct43 actualFileHash)
        {
            actualFileHash = default(Struct43);
            Enum23 result;

            try
            {
                if (File.Exists(filename))
                {
                    if (!this.ForceRecheck && !lastFile.ForceRecheck && !(this.Version != lastFile.Version))
                    {
                        if (this.ExpectedSize == Class234.smethod_11(filename))
                        {
                            return(Enum23.const_2);
                        }
                    }
                    actualFileHash = Class513.smethod_0(filename);
                    if (Struct43.smethod_5(this.ExpectedHash, actualFileHash))
                    {
                        result = Enum23.const_2;
                    }
                    else
                    {
                        result = Enum23.const_1;
                    }
                }
                else
                {
                    result = Enum23.const_0;
                }
            }
            finally
            {
                this.ForceRecheck = false;
            }
            return(result);
        }
        // Token: 0x060020A9 RID: 8361 RVA: 0x0006E0CC File Offset: 0x0006C2CC
        private void method_7(Stream file_stream, BinaryReader reader, bool loadIcon, bool populateData)
        {
            Encoding encoding = Encoding.GetEncoding(1252);
            int      num      = reader.ReadInt32();

            if (num != 1)
            {
                throw new InvalidFileVersion <int>(1, 1, num);
            }
            decimal num2 = reader.ReadDecimal();
            decimal d    = reader.ReadDecimal();
            int     num3 = (int)Math.Floor(num2);

            this.MinimumVersion = new Version(num3, (int)((num2 - num3) * 100m), (int)(d * 100m), 0);
            this.Name           = Class132.smethod_4(reader, encoding);
            this.Description    = Class132.smethod_4(reader, encoding);
            this.Author         = Class132.smethod_4(reader, encoding);
            this.PasswordHash   = new Struct43(Class132.smethod_4(reader, encoding));
            if (Struct43.smethod_5(this.PasswordHash, Class132.struct43_0))
            {
                this.PasswordHash = Struct43.struct43_0;
            }
            Class132.smethod_4(reader, encoding);
            string text = Class132.smethod_4(reader, encoding);

            if (!string.IsNullOrEmpty(text))
            {
                this.ObsoleteDownloadURL = new Uri(text);
            }
            string text2 = Class132.smethod_4(reader, encoding);

            if (!string.IsNullOrEmpty(text2))
            {
                this.UpdateUri = new Uri(text2);
            }
            this.ID       = new Guid(Class132.smethod_4(reader, encoding));
            this.DataHash = new Struct43(Class132.smethod_4(reader, encoding));
            int num4 = reader.ReadInt32();

            if (num4 > 0)
            {
                if (loadIcon)
                {
                    using (Stream3 stream = new Stream3(file_stream, file_stream.Position, file_stream.Position + (long)num4))
                    {
                        this.memoryStream_0 = new MemoryStream();
                        stream.CopyTo(this.memoryStream_0);
                        this.Icon = (Bitmap)Image.FromStream(this.memoryStream_0);
                        goto IL_1AC;
                    }
                }
                file_stream.Position += (long)num4;
            }
IL_1AC:
            this.LoaderPack = reader.ReadBoolean();
            if (this.LoaderPack)
            {
                this.DataHash = Struct43.struct43_0;
            }
            if (this.LoaderPack)
            {
                if (populateData)
                {
                    this.Data = new Class136();
                    return;
                }
            }
            else
            {
                int num5 = reader.ReadInt32();
                for (int i = 0; i < num5; i++)
                {
                    this.ItemIndex.Add(Class132.smethod_4(reader, encoding), new Struct43(Class132.smethod_4(reader, encoding)));
                }
                int num6 = reader.ReadInt32();
                if (populateData)
                {
                    using (Stream3 stream2 = new Stream3(file_stream, file_stream.Position, file_stream.Position + (long)num6))
                    {
                        this.Data = new Class136(stream2);
                        this.Data.method_12();
                        return;
                    }
                }
                file_stream.Position += (long)num6;
            }
        }
        // Token: 0x06001E4A RID: 7754 RVA: 0x000624D8 File Offset: 0x000606D8
        public void method_1(Stream stream_orig, Stream stream_patch, Stream stream_dest, uint?overrideExpectedStartingFileLength, Struct43 overrideExpectedStartingHash, uint?overrideExpectedResultingFileLength, Struct43 overrideExpectedResultingHash, bool validate_expected, bool validate_result)
        {
            using (Stream3 stream = new Stream3(stream_orig))
            {
                using (Stream3 stream2 = new Stream3(stream_patch))
                {
                    using (Stream3 stream3 = new Stream3(stream_dest))
                    {
                        using (BinaryReader binaryReader = new BinaryReader(stream))
                        {
                            using (BinaryReader binaryReader2 = new BinaryReader(stream2))
                            {
                                using (BinaryWriter binaryWriter = new BinaryWriter(stream3))
                                {
                                    binaryReader2.ReadUInt32();
                                    ushort   num     = binaryReader2.ReadUInt16();
                                    uint     num2    = binaryReader2.ReadUInt32();
                                    Struct43 @struct = binaryReader2.BaseStream.smethod_22();
                                    uint     num3    = binaryReader2.ReadUInt32();
                                    Struct43 struct2 = binaryReader2.BaseStream.smethod_22();
                                    uint     num4    = 0U;
                                    if (validate_expected)
                                    {
                                        if (stream.Length != (long)((ulong)num2) && (overrideExpectedStartingFileLength == null || overrideExpectedStartingFileLength.Value != num2))
                                        {
                                            throw new InvalidDataException(string.Format("The starting file size: '{0}' does not match the expected file size: '{1}'.", stream.Length, num2));
                                        }
                                        Struct43 struct3 = stream_orig.smethod_2();
                                        if (Struct43.smethod_6(struct3, @struct) && (Struct43.smethod_5(overrideExpectedStartingHash, Struct43.struct43_0) || Struct43.smethod_6(overrideExpectedStartingHash, struct3)))
                                        {
                                            throw new InvalidDataException(string.Format("The actual starting hash: '{0}' does not match the expected hash: '{1}'.", struct3, @struct));
                                        }
                                    }
                                    byte[] buffer = new byte[4096];
                                    int    num5   = 0;
                                    uint   num7;
                                    uint   num10;
                                    do
                                    {
                                        ushort num6 = (ushort)(num7 = (uint)binaryReader2.ReadUInt16());
                                        while (num6 > 0 && !binaryReader2.smethod_3())
                                        {
                                            int num8 = binaryReader2.Read(buffer, 0, (int)((num6 > 4096) ? 4096 : num6));
                                            binaryWriter.Write(buffer, 0, num8);
                                            num6 -= (ushort)num8;
                                            num4 += (uint)((ushort)num8);
                                            if (this.eventHandler_0 != null)
                                            {
                                                int num9 = EventArgs9.smethod_0((long)((ulong)num4), (long)((ulong)num3));
                                                if (num5 != num9)
                                                {
                                                    num5 = num9;
                                                    this.eventHandler_0(this, new EventArgs9((long)((ulong)num4), (long)((ulong)num3)));
                                                }
                                            }
                                        }
                                        num6 = (ushort)(num10 = (uint)binaryReader2.ReadUInt16());
                                        if (num6 > 0)
                                        {
                                            int num11 = binaryReader2.ReadInt32();
                                            if (num < 2)
                                            {
                                                binaryReader.BaseStream.Seek((long)num11, SeekOrigin.Begin);
                                            }
                                            else
                                            {
                                                binaryReader.BaseStream.Seek((long)num11, SeekOrigin.Current);
                                            }
                                            while (num6 > 0 && !binaryReader2.smethod_3())
                                            {
                                                int num8 = binaryReader.Read(buffer, 0, (int)((num6 > 4096) ? 4096 : num6));
                                                binaryWriter.Write(buffer, 0, num8);
                                                num6 -= (ushort)num8;
                                                num4 += (uint)((ushort)num8);
                                                if (this.eventHandler_0 != null)
                                                {
                                                    int num9 = EventArgs9.smethod_0((long)((ulong)num4), (long)((ulong)num3));
                                                    if (num5 != num9)
                                                    {
                                                        num5 = num9;
                                                        this.eventHandler_0(this, new EventArgs9((long)((ulong)num4), (long)((ulong)num3)));
                                                    }
                                                }
                                            }
                                        }
                                    }while (num10 != 0U || num7 != 0U);
                                    if (validate_result)
                                    {
                                        if (stream3.Length != (long)((ulong)num3))
                                        {
                                            if (overrideExpectedResultingFileLength != null)
                                            {
                                                uint?num12  = overrideExpectedResultingFileLength;
                                                long length = stream3.Length;
                                                if ((ulong)num12.GetValueOrDefault() == (ulong)length && num12 != null)
                                                {
                                                    goto IL_2D7;
                                                }
                                            }
                                            throw new InvalidDataException(string.Format("The resulting file length: '{0}' does not match the expected data length: '{1}'.", stream3.Length, num3));
                                        }
IL_2D7:
                                        Struct43 struct4 = stream3.smethod_2();
                                        if (Struct43.smethod_6(struct4, struct2) && (Struct43.smethod_5(overrideExpectedResultingHash, Struct43.struct43_0) || Struct43.smethod_6(overrideExpectedResultingHash, struct4)))
                                        {
                                            throw new InvalidDataException(string.Format("The resulting hash: '{0}' does not match the expected hash: '{1}'.", struct4, struct2));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }