示例#1
0
        private void writeParts(FileStream src, string destPath, uint partsReq, uint blocksReq)
        {
            uint num = 0;

            for (uint i = 0; i < partsReq; i++)
            {
                Console.Write("+ Writing Part " + i + " / " + partsReq + "...\r");
                string path = destPath + Path.DirectorySeparatorChar + "Data";
                if (i < 10)
                {
                    path = path + "000" + i;
                }
                else if (i < 100)
                {
                    path = path + "00" + i;
                }
                else if (i < 0x3e8)
                {
                    path = path + "0" + i;
                }
                else if (i < 0x2710)
                {
                    path = path + i;
                }
                FileStream      f         = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                MasterHashtable hashtable = new MasterHashtable();
                hashtable.WriteBlank(f);
                for (int j = 0; j < shtPerMHT; j++)
                {
                    SubHashTable table = new SubHashTable();
                    table.WriteBlank(f);
                    uint num4 = 0;
                    while ((num < blocksReq) && (num4 < blockPerSHT))
                    {
                        byte[] buffer = new byte[blockSize];
                        src.Read(buffer, 0, buffer.Length);
                        byte[] buffer2 = new byte[20];
                        buffer2 = sha1.ComputeHash(buffer, 0, (int)blockSize);
                        table.Add(buffer2);
                        f.Write(buffer, 0, buffer.Length);
                        num++;
                        num4++;
                    }
                    long position = f.Position;
                    f.Seek(-(((num4 + 1) * blockSize)), SeekOrigin.Current);
                    table.Write(f);
                    f.Seek(position, SeekOrigin.Begin);
                    byte[] item = new byte[20];
                    item = sha1.ComputeHash(table.ToByteArray(), 0, (int)blockSize);
                    hashtable.Add(item);
                    if (num >= blocksReq)
                    {
                        break;
                    }
                }
                f.Seek(0L, SeekOrigin.Begin);
                hashtable.Write(f);
                f.Close();
                if (num >= blocksReq)
                {
                    return;
                }
            }
        }
示例#2
0
 private void calcMhtHashChain(string Destination, uint TotalPartsReq, out uint lastPartSize, out byte[] lastMhtHash)
 {
     lastPartSize = 0;
     lastMhtHash  = new byte[20];
     for (uint i = TotalPartsReq - 1; i > 0; i--)
     {
         string path = Destination + Path.DirectorySeparatorChar + "Data";
         if (i < 10)
         {
             path = path + "000" + i;
         }
         else if (i < 100)
         {
             path = path + "00" + i;
         }
         else if (i < 0x3e8)
         {
             path = path + "0" + i;
         }
         else if (i < 0x2710)
         {
             path = path + i;
         }
         string str2 = Destination + Path.DirectorySeparatorChar + "Data";
         if ((i - 1) < 10)
         {
             str2 = str2 + "000" + ((i - 1));
         }
         else if ((i - 1) < 100)
         {
             str2 = str2 + "00" + ((i - 1));
         }
         else if ((i - 1) < 0x3e8)
         {
             str2 = str2 + "0" + ((i - 1));
         }
         else if ((i - 1) < 0x2710)
         {
             str2 = str2 + ((i - 1));
         }
         FileStream f       = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
         FileStream stream2 = new FileStream(str2, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
         if (i == (TotalPartsReq - 1))
         {
             lastPartSize = (uint)f.Length;
         }
         MasterHashtable hashtable = new MasterHashtable();
         hashtable.ReadMHT(f);
         byte[] array = new byte[blockSize];
         hashtable.ToByteArray().CopyTo(array, 0);
         byte[] item = new byte[20];
         item = sha1.ComputeHash(array);
         MasterHashtable hashtable2 = new MasterHashtable();
         hashtable2.ReadMHT(stream2);
         hashtable2.Add(item);
         stream2.Seek(0L, SeekOrigin.Begin);
         hashtable2.Write(stream2);
         if ((i - 1) == 0)
         {
             lastMhtHash = sha1.ComputeHash(hashtable2.ToByteArray());
         }
         f.Close();
         stream2.Close();
     }
 }
示例#3
0
 private void writeParts(FileStream src, string destPath, IsoEntry iso, uint partsReq, uint blocksReq)
 {
     uint num = 0;
     for (uint i = 0; i < partsReq; i++)
     {
         this.progress += ((1f / ((float) partsReq)) * ((iso.Padding.Type == IsoEntryPaddingRemoval.Full) ? 0.45f : 0.9f)) * 100f;
         base.ReportProgress((int) this.progress, "Writing Part " + i.ToString() + " / " + partsReq.ToString() + "...");
         string path = destPath + Path.DirectorySeparatorChar + "Data";
         if (i < 10)
         {
             path = path + "000" + i.ToString();
         }
         else if (i < 100)
         {
             path = path + "00" + i.ToString();
         }
         else if (i < 0x3e8)
         {
             path = path + "0" + i.ToString();
         }
         else if (i < 0x2710)
         {
             path = path + i.ToString();
         }
         FileStream f = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
         MasterHashtable hashtable = new MasterHashtable();
         hashtable.WriteBlank(f);
         for (int j = 0; j < this.shtPerMHT; j++)
         {
             SubHashTable table = new SubHashTable();
             table.WriteBlank(f);
             uint num4 = 0;
             while ((num < blocksReq) && (num4 < this.blockPerSHT))
             {
                 byte[] buffer = new byte[this.blockSize];
                 src.Read(buffer, 0, buffer.Length);
                 byte[] buffer2 = new byte[20];
                 buffer2 = this.sha1.ComputeHash(buffer, 0, (int) this.blockSize);
                 table.Add(buffer2);
                 f.Write(buffer, 0, buffer.Length);
                 num++;
                 num4++;
             }
             long position = f.Position;
             f.Seek((long) -((ulong) ((num4 + 1) * this.blockSize)), SeekOrigin.Current);
             table.Write(f);
             f.Seek(position, SeekOrigin.Begin);
             byte[] item = new byte[20];
             item = this.sha1.ComputeHash(table.ToByteArray(), 0, (int) this.blockSize);
             hashtable.Add(item);
             if (num >= blocksReq)
             {
                 break;
             }
         }
         f.Seek(0L, SeekOrigin.Begin);
         hashtable.Write(f);
         f.Close();
         if (num >= blocksReq)
         {
             return;
         }
     }
 }
示例#4
0
        private void writeParts(FileStream src, string destPath, IsoEntry iso, uint partsReq, uint blocksReq)
        {
            uint num = 0;

            for (uint i = 0; i < partsReq; i++)
            {
                this.progress += ((1f / ((float)partsReq)) * ((iso.Padding.Type == IsoEntryPaddingRemoval.Full) ? 0.45f : 0.9f)) * 100f;
                base.ReportProgress((int)this.progress, "Writing Part " + i.ToString() + " / " + partsReq.ToString() + "...");
                string path = destPath + Path.DirectorySeparatorChar + "Data";
                if (i < 10)
                {
                    path = path + "000" + i.ToString();
                }
                else if (i < 100)
                {
                    path = path + "00" + i.ToString();
                }
                else if (i < 0x3e8)
                {
                    path = path + "0" + i.ToString();
                }
                else if (i < 0x2710)
                {
                    path = path + i.ToString();
                }
                FileStream      f         = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                MasterHashtable hashtable = new MasterHashtable();
                hashtable.WriteBlank(f);
                for (int j = 0; j < this.shtPerMHT; j++)
                {
                    SubHashTable table = new SubHashTable();
                    table.WriteBlank(f);
                    uint num4 = 0;
                    while ((num < blocksReq) && (num4 < this.blockPerSHT))
                    {
                        byte[] buffer = new byte[this.blockSize];
                        src.Read(buffer, 0, buffer.Length);
                        byte[] buffer2 = new byte[20];
                        buffer2 = this.sha1.ComputeHash(buffer, 0, (int)this.blockSize);
                        table.Add(buffer2);
                        f.Write(buffer, 0, buffer.Length);
                        num++;
                        num4++;
                    }
                    long position = f.Position;
                    f.Seek((long)-((ulong)((num4 + 1) * this.blockSize)), SeekOrigin.Current);
                    table.Write(f);
                    f.Seek(position, SeekOrigin.Begin);
                    byte[] item = new byte[20];
                    item = this.sha1.ComputeHash(table.ToByteArray(), 0, (int)this.blockSize);
                    hashtable.Add(item);
                    if (num >= blocksReq)
                    {
                        break;
                    }
                }
                f.Seek(0L, SeekOrigin.Begin);
                hashtable.Write(f);
                f.Close();
                if (num >= blocksReq)
                {
                    return;
                }
            }
        }
示例#5
0
 private void calcMhtHashChain(string Destination, uint TotalPartsReq, out uint lastPartSize, out byte[] lastMhtHash)
 {
     lastPartSize = 0;
     lastMhtHash = new byte[20];
     for (uint i = TotalPartsReq - 1; i > 0; i--)
     {
         string path = Destination + Path.DirectorySeparatorChar + "Data";
         if (i < 10)
         {
             path = path + "000" + i.ToString();
         }
         else if (i < 100)
         {
             path = path + "00" + i.ToString();
         }
         else if (i < 0x3e8)
         {
             path = path + "0" + i.ToString();
         }
         else if (i < 0x2710)
         {
             path = path + i.ToString();
         }
         string str2 = Destination + Path.DirectorySeparatorChar + "Data";
         if ((i - 1) < 10)
         {
             str2 = str2 + "000" + ((i - 1)).ToString();
         }
         else if ((i - 1) < 100)
         {
             str2 = str2 + "00" + ((i - 1)).ToString();
         }
         else if ((i - 1) < 0x3e8)
         {
             str2 = str2 + "0" + ((i - 1)).ToString();
         }
         else if ((i - 1) < 0x2710)
         {
             str2 = str2 + ((i - 1)).ToString();
         }
         FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
         FileStream stream2 = new FileStream(str2, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
         if (i == (TotalPartsReq - 1))
         {
             lastPartSize = (uint) f.Length;
         }
         MasterHashtable hashtable = new MasterHashtable();
         hashtable.ReadMHT(f);
         byte[] array = new byte[this.blockSize];
         hashtable.ToByteArray().CopyTo(array, 0);
         byte[] item = new byte[20];
         item = this.sha1.ComputeHash(array);
         MasterHashtable hashtable2 = new MasterHashtable();
         hashtable2.ReadMHT(stream2);
         hashtable2.Add(item);
         stream2.Seek(0L, SeekOrigin.Begin);
         hashtable2.Write(stream2);
         if ((i - 1) == 0)
         {
             lastMhtHash = this.sha1.ComputeHash(hashtable2.ToByteArray());
         }
         f.Close();
         stream2.Close();
     }
 }