// 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));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 // Token: 0x06002B3A RID: 11066 RVA: 0x000A7A20 File Offset: 0x000A5C20
 private static void smethod_1(EventHandler <EventArgs9> progressChanged, string installPath, Class136 mf, Class337 index, int total, ref int count)
 {
     foreach (KeyValuePair <string, Class337.Struct34> keyValuePair in index)
     {
         string text = Path.Combine(installPath, keyValuePair.Key);
         if (!File.Exists(text) || Class234.smethod_11(text) != keyValuePair.Value.ExpectedSize || Struct43.smethod_6(Class513.smethod_0(text), keyValuePair.Value.ExpectedHash))
         {
             if (mf.method_6(keyValuePair.Key))
             {
                 Class338 @class = mf[keyValuePair.Key];
                 mf.method_15(@class);
                 @class.smethod_0(text);
                 @class.Data = null;
                 Class110.Instance.CreatedFileArchive.method_4(text);
             }
             count++;
             if (progressChanged != null)
             {
                 progressChanged(null, new EventArgs9((long)count, (long)total));
             }
         }
     }
 }
        // Token: 0x0600263D RID: 9789 RVA: 0x00087018 File Offset: 0x00085218
        public void method_5()
        {
            this.DateInstalled = DateTime.Now;
            HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            lock (((ICollection)this.dictionary_0).SyncRoot)
            {
                using (Class132 @class = new Class132(this.FileName, false, false))
                {
                    foreach (KeyValuePair <string, Struct43> keyValuePair in @class.ItemIndex)
                    {
                        if (this.dictionary_0.ContainsKey(keyValuePair.Key))
                        {
                            if (Struct43.smethod_6(keyValuePair.Value, this.dictionary_0[keyValuePair.Key].struct43_0))
                            {
                                if (this.dictionary_0[keyValuePair.Key].enum76_0 == Enum76.const_1)
                                {
                                    this.dictionary_0[keyValuePair.Key].enum76_0 = Enum76.const_3;
                                }
                                this.dictionary_0[keyValuePair.Key].struct43_0 = keyValuePair.Value;
                            }
                        }
                        else if (Class136.smethod_8(keyValuePair.Key))
                        {
                            if (this.method_4(keyValuePair.Key))
                            {
                                this.dictionary_0.Add(keyValuePair.Key, new Class102.Class403(keyValuePair.Value, Enum76.const_0));
                            }
                            else
                            {
                                this.dictionary_0.Add(keyValuePair.Key, new Class102.Class403(keyValuePair.Value, Enum76.const_3));
                                this.InstallState = Enum76.const_3;
                            }
                        }
                    }
                    foreach (KeyValuePair <string, Class102.Class403> keyValuePair2 in this.dictionary_0)
                    {
                        if ([email protected](keyValuePair2.Key))
                        {
                            Enum76 @enum = keyValuePair2.Value.enum76_0;
                            if (@enum == Enum76.const_1)
                            {
                                keyValuePair2.Value.enum76_0 = Enum76.const_4;
                            }
                            else
                            {
                                hashSet.Add(keyValuePair2.Key);
                            }
                        }
                    }
                    this.Name               = @class.Name;
                    this.UpdateUri          = @class.UpdateUri;
                    this.VersionType        = @class.Type;
                    this.ContentPackVersion = @class.Version;
                    this.LoaderPack         = @class.LoaderPack;
                    if (this.VersionType == Enum82.const_0)
                    {
                        this.DataHash = @class.DataHash;
                    }
                }
                if (this.VersionType != Enum82.const_0)
                {
                    using (Stream stream = File.Open(this.FileName, FileMode.Open, FileAccess.Read, FileShare.None))
                    {
                        this.DataHash = stream.smethod_2();
                    }
                }
                this.dictionary_0.smethod_8(hashSet);
            }
        }