예제 #1
0
        public void AddISOEntry(IsoEntry Entry)
        {
            ListViewItem item = new ListViewItem {
                Text = Entry.TitleName
            };

            item.SubItems.Add(Entry.ID.TitleID);
            item.SubItems.Add(Entry.ID.DiscNumber.ToString());
            double num = Math.Round((double)(((double)Entry.Size) / 1073741824.0), 2);

            item.SubItems.Add(num.ToString() + " GB");
            item.SubItems.Add(Entry.Padding.Type.ToString());
            item.SubItems.Add("");
            item.SubItems.Add(Entry.Path);
            item.Tag = Entry;
            this.listView1.Items.Add(item);
            this.listView1.AddEmbeddedControl(new ProgressBar(), 5, item.Index);
            long freeSpace = 0L;

            this.UpdateSpace(out freeSpace);
            if (freeSpace < Entry.Size)
            {
                this.tsStatus.Text = this.tsStatus.Text + ". You do not have enough free disk space to convert this ISO.";
            }
        }
예제 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (this.checkFields())
     {
         IsoEntryPadding padding = new IsoEntryPadding {
             Type     = (IsoEntryPaddingRemoval)((byte)this.cmbPaddingMode.SelectedIndex),
             TempPath = Path.GetTempPath(),
             IsoPath  = this.txtRebuiltIso.Text,
             KeepIso  = this.cbSaveRebuilt.Checked
         };
         if (!padding.TempPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
         {
             padding.TempPath = padding.TempPath + Path.DirectorySeparatorChar;
         }
         if (!padding.IsoPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
         {
             padding.IsoPath = padding.IsoPath + Path.DirectorySeparatorChar;
         }
         IsoEntryID iD    = new IsoEntryID(this.txtTitleID.Text, this.txtMediaID.Text, byte.Parse(this.txtDiscNum.Text), byte.Parse(this.txtDiscCount.Text), byte.Parse(this.txtPlatform.Text), byte.Parse(this.txtExType.Text));
         FileInfo   info  = new FileInfo(this.txtISO.Text);
         IsoEntry   entry = new IsoEntry(this.platform, this.txtISO.Text, this.txtDest.Text, info.Length, this.txtName.Text, iD, (byte[])this.pbThumb.Tag, padding);
         if (this.edit)
         {
             (base.Owner as Main).UpdateISOEntry(this.entryIndex, entry);
         }
         else
         {
             (base.Owner as Main).AddISOEntry(entry);
         }
         GC.Collect();
         base.Close();
     }
 }
예제 #3
0
 private void ftp_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     foreach (ListViewItem item in this.listView1.Items)
     {
         IsoEntry tag = (IsoEntry)item.Tag;
         if (tag.Status == IsoEntryStatus.Uploading)
         {
             tag.Status = IsoEntryStatus.Completed;
             ProgressBar embeddedControl = (ProgressBar)this.listView1.GetEmbeddedControl(5, item.Index);
             embeddedControl.Style = ProgressBarStyle.Continuous;
             embeddedControl.Value = 100;
             FlashWindow(base.Handle, false);
             if (this.ftp.Errors.Count == 0)
             {
                 item.ForeColor        = Color.Green;
                 item.SubItems[6].Text = "Uploaded";
             }
             else
             {
                 item.ForeColor = Color.Red;
                 foreach (Exception exception in this.ftp.Errors)
                 {
                     MessageBox.Show("Error while attempting to upload GOD container for '" + tag.TitleName + "':\n\n" + exception.Message);
                 }
                 item.SubItems[6].Text = "Failed to upload.";
             }
             item.Tag = tag;
             this.ftpCheck.Enabled = true;
             break;
         }
     }
 }
예제 #4
0
 private void i2g_Completed(object sender, Iso2GodCompletedArgs e)
 {
     foreach (ListViewItem item in this.listView1.Items)
     {
         IsoEntry tag = (IsoEntry)item.Tag;
         if (tag.Status == IsoEntryStatus.InProgress)
         {
             ProgressBar embeddedControl = (ProgressBar)this.listView1.GetEmbeddedControl(5, item.Index);
             if ((bool)Chilano.Iso2God.Properties.Settings.Default["FtpUpload"])
             {
                 tag.Status            = IsoEntryStatus.UploadQueue;
                 tag.ID.ContainerID    = e.ContainerId;
                 embeddedControl.Value = 0;
                 item.SubItems[6].Text = "Queued for upload.";
                 this.ftpCheck.Enabled = true;
             }
             else
             {
                 tag.Status            = IsoEntryStatus.Completed;
                 embeddedControl.Value = 100;
                 item.SubItems[6].Text = e.Message + ((e.Error != null) ? (". Error: " + e.Error.Message) : "");
                 FlashWindow(base.Handle, false);
             }
             this.jobCheck.Enabled = true;
             item.Tag       = tag;
             item.ForeColor = Color.Green;
             break;
         }
     }
 }
예제 #5
0
 private void ftpCheck_Tick(object sender, EventArgs e)
 {
     if (!this.ftp.IsBusy)
     {
         foreach (ListViewItem item in this.listView1.Items)
         {
             IsoEntry tag = (IsoEntry)item.Tag;
             if (tag.Status == IsoEntryStatus.UploadQueue)
             {
                 tag.Status = IsoEntryStatus.Uploading;
                 item.Tag   = tag;
                 this.ftp   = new FtpUploader();
                 this.ftp.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.ftp_RunWorkerCompleted);
                 this.ftp.ProgressChanged    += new ProgressChangedEventHandler(this.ftp_ProgressChanged);
                 string ip          = Chilano.Iso2God.Properties.Settings.Default["FtpIP"].ToString();
                 string user        = Chilano.Iso2God.Properties.Settings.Default["FtpUser"].ToString();
                 string pass        = Chilano.Iso2God.Properties.Settings.Default["FtpPass"].ToString();
                 string port        = Chilano.Iso2God.Properties.Settings.Default["FtpPort"].ToString();
                 string containerID = tag.ID.ContainerID;
                 this.ftp.RunWorkerAsync(new FtpUploaderArgs(ip, user, pass, port, tag.ID.TitleID, tag.ID.ContainerID, tag.Destination, tag.Platform));
                 this.ftpCheck.Enabled = false;
                 return;
             }
         }
         this.ftpCheck.Enabled = false;
     }
 }
예제 #6
0
        private static void Main()
        {
            Console.WriteLine("Iso2god-cli " + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion + " - " + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).LegalCopyright);
            Console.WriteLine("Ported to CLI by Elie CHARRA <elie [dot] charra [at] gmail.com>");
            Console.WriteLine("Usage : iso2god <source iso> <destination folder>");
            Console.WriteLine("");

            String[] arguments = Environment.GetCommandLineArgs();

            if (arguments.Length == 3)
            {
                String isoPath         = arguments[1];
                String destinationPath = arguments[2];

                Console.WriteLine("+ Computing ISO metadata ...");
                IsoDetails        iso = new IsoDetails(new IsoDetailsArgs(isoPath, Path.GetTempPath(), Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "xextool.exe"));
                IsoDetailsResults isoDetailsResults = iso.IsoDetails_DoWork();
                IsoEntryID        isoEntryID        = new IsoEntryID(isoDetailsResults.TitleID, isoDetailsResults.MediaID, Convert.ToByte(isoDetailsResults.DiscNumber[0]), Convert.ToByte(isoDetailsResults.DiscCount[0]), Convert.ToByte(isoDetailsResults.Platform[0]), Convert.ToByte(isoDetailsResults.ExType[0]));
                IsoEntry          isoEntry          = new IsoEntry(IsoEntryPlatform.Xbox360, isoPath, destinationPath, new FileInfo(isoPath).Length, isoDetailsResults.Name, isoEntryID);

                Console.WriteLine("-----------------------------------------------------------");
                Console.WriteLine("> Title    : " + isoEntry.TitleName);
                Console.WriteLine("> Title ID : " + isoEntry.ID.TitleID);
                Console.WriteLine("> Disc     : " + Char.ConvertFromUtf32(isoEntry.ID.DiscNumber) + " / " + Char.ConvertFromUtf32(isoEntry.ID.DiscCount));
                Console.WriteLine("> Media ID : " + isoEntry.ID.MediaID);
                Console.WriteLine("> Platform : " + isoEntry.Platform);
                Console.WriteLine("> Ex       : " + Char.ConvertFromUtf32(isoEntry.ID.ExType));
                Console.WriteLine("-----------------------------------------------------------");

                Console.WriteLine("+ Launching GOD conversion ...");
                Iso2God iso2god = new Iso2God();
                iso2god.Run(isoEntry);
            }
        }
예제 #7
0
        public void UpdateISOEntry(int Index, IsoEntry Entry)
        {
            ListViewItem item = this.listView1.Items[Index];

            item.Tag              = Entry;
            item.Text             = Entry.TitleName;
            item.SubItems[1].Text = Entry.ID.TitleID;
            item.SubItems[2].Text = Entry.ID.DiscNumber.ToString();
            item.SubItems[3].Text = Math.Round((double)(((double)Entry.Size) / 1073741824.0), 2).ToString() + " GB";
            item.SubItems[4].Text = Entry.Padding.Type.ToString();
            item.SubItems[6].Text = Entry.Path;
        }
예제 #8
0
 private void i2g_Progress(object sender, Iso2GodProgressArgs e)
 {
     foreach (ListViewItem item in this.listView1.Items)
     {
         IsoEntry tag = (IsoEntry)item.Tag;
         if (tag.Status == IsoEntryStatus.InProgress)
         {
             ((ProgressBar)this.listView1.GetEmbeddedControl(5, item.Index)).Value = (e.Percentage > 100) ? 100 : e.Percentage;
             item.SubItems[6].Text = e.Message;
             item.Tag = tag;
             break;
         }
     }
 }
예제 #9
0
        private void Iso2God_Full(object sender, DoWorkEventArgs e)
        {
            FileStream stream;
            FileStream stream2;

            base.ReportProgress((int)this.progress, "Preparing to rebuild ISO image...");
            IsoEntry argument = (IsoEntry)e.Argument;

            try
            {
                stream = new FileStream(argument.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            }
            catch (Exception exception)
            {
                base.ReportProgress(0, "Error! " + exception.Message);
                return;
            }
            using (GDF gdf = new GDF(stream))
            {
                uint lastSector = 0;
                gdf.ParseDirectory(gdf.RootDir, true, ref lastSector);
                base.ReportProgress((int)this.progress, "Generating new GDFS structures...");
                try
                {
                    stream2 = File.OpenWrite(argument.Padding.IsoPath + argument.Path.Substring(argument.Path.LastIndexOf(Path.DirectorySeparatorChar) + 1) + "_rebuilt.iso");
                }
                catch (Exception exception2)
                {
                    base.ReportProgress(0, "Error rebuilding GDF! " + exception2.Message);
                    return;
                }
                this.rootDir = (GDFDirTable)gdf.RootDir.Clone();
                this.RemapSectors(gdf);
                this.WriteGDF(gdf, stream2);
                this.WriteFiles(gdf, stream2);
            }
            if (stream2.Length > 0L)
            {
                base.ReportProgress((int)this.progress, "ISO image rebuilt.");
                argument.Path = stream2.Name;
                argument.Size = stream2.Length;
                stream2.Close();
                stream.Close();
                this.Iso2God_Partial(sender, e, false, argument);
            }
            else
            {
                base.ReportProgress(100, "Failed to rebuild ISO. Aborting.");
            }
        }
예제 #10
0
 private void ftp_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     foreach (ListViewItem item in this.listView1.Items)
     {
         IsoEntry tag = (IsoEntry)item.Tag;
         if (tag.Status == IsoEntryStatus.Uploading)
         {
             ProgressBar embeddedControl = (ProgressBar)this.listView1.GetEmbeddedControl(5, item.Index);
             embeddedControl.Value = (e.ProgressPercentage > 100) ? 100 : e.ProgressPercentage;
             item.ForeColor        = Color.Blue;
             item.SubItems[6].Text = e.UserState.ToString();
             item.Tag = tag;
             break;
         }
     }
 }
예제 #11
0
 private void restartFTPUploadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count == 1)
     {
         ListViewItem item = this.listView1.SelectedItems[0];
         IsoEntry     tag  = (IsoEntry)item.Tag;
         if ((tag.Status == IsoEntryStatus.Uploading) || (tag.Status == IsoEntryStatus.Completed))
         {
             tag.Status            = IsoEntryStatus.UploadQueue;
             item.Tag              = tag;
             item.ForeColor        = Color.Blue;
             item.SubItems[6].Text = "Queued for upload.";
             ((ProgressBar)this.listView1.GetEmbeddedControl(5, item.Index)).Value = 0;
             this.ftpCheck.Enabled = true;
         }
     }
 }
예제 #12
0
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count <= 1)
     {
         ListViewItem item = this.listView1.SelectedItems[0];
         IsoEntry     tag  = (IsoEntry)item.Tag;
         if (tag.Status == IsoEntryStatus.Idle)
         {
             using (AddISO diso = new AddISO(tag.Platform))
             {
                 diso.Edit(item.Index, tag);
                 diso.ShowDialog(this);
                 return;
             }
         }
         MessageBox.Show("Conversions that are currently in progress or have completed cannot be edited.");
     }
 }
예제 #13
0
        private string createUniqueName(IsoEntry Iso)
        {
            MemoryStream  s      = new MemoryStream();
            CBinaryWriter writer = new CBinaryWriter(EndianType.LittleEndian, s);

            writer.Write(Iso.ID.TitleID);
            writer.Write(Iso.ID.MediaID);
            writer.Write(Iso.ID.DiscNumber);
            writer.Write(Iso.ID.DiscCount);
            byte[] buffer = sha1.ComputeHash(s.ToArray());
            string str    = "";

            for (int i = 0; i < (buffer.Length / 2); i++)
            {
                str = str + buffer[i].ToString("X02");
            }
            return(str);
        }
예제 #14
0
 public void Edit(int Index, IsoEntry Entry)
 {
     this.edit                         = true;
     this.entry                        = Entry;
     this.entryIndex                   = Index;
     this.txtName.Text                 = this.entry.TitleName;
     this.txtTitleID.Text              = this.entry.ID.TitleID;
     this.txtMediaID.Text              = this.entry.ID.MediaID;
     this.txtPlatform.Text             = this.entry.ID.Platform.ToString();
     this.txtExType.Text               = this.entry.ID.ExType.ToString();
     this.txtDiscCount.Text            = this.entry.ID.DiscCount.ToString();
     this.txtDiscNum.Text              = this.entry.ID.DiscNumber.ToString();
     this.txtDest.Text                 = this.entry.Destination;
     this.txtISO.Text                  = this.entry.Path;
     this.txtRebuiltIso.Text           = (this.entry.Padding.Type == IsoEntryPaddingRemoval.Full) ? this.entry.Padding.IsoPath : Chilano.Iso2God.Properties.Settings.Default["RebuildPath"].ToString();
     this.cbSaveRebuilt.Checked        = this.entry.Padding.KeepIso;
     this.cmbPaddingMode.SelectedIndex = (int)this.entry.Padding.Type;
     this.pbThumb.Image                = (this.entry.Thumb == null) ? null : Image.FromStream(new MemoryStream(this.entry.Thumb));
     this.pbThumb.Tag                  = this.entry.Thumb;
     this.btnAddIso.Text               = "Save ISO";
 }
예제 #15
0
        private void Iso2God_Run(object sender, DoWorkEventArgs e)
        {
            this.Start = DateTime.Now;
            IsoEntry argument = (IsoEntry)e.Argument;

            this.uniqueName = this.createUniqueName(argument);
            switch (argument.Padding.Type)
            {
            case IsoEntryPaddingRemoval.None:
                this.Iso2God_Partial(sender, e, false, argument);
                return;

            case IsoEntryPaddingRemoval.Partial:
                this.Iso2God_Partial(sender, e, true, argument);
                return;

            case IsoEntryPaddingRemoval.Full:
                this.Iso2God_Full(sender, e);
                return;
            }
        }
예제 #16
0
 public void AddISOEntry(IsoEntry Entry)
 {
     ListViewItem item = new ListViewItem {
         Text = Entry.TitleName
     };
     item.SubItems.Add(Entry.ID.TitleID);
     item.SubItems.Add(Entry.ID.DiscNumber.ToString());
     double num = Math.Round((double) (((double) Entry.Size) / 1073741824.0), 2);
     item.SubItems.Add(num.ToString() + " GB");
     item.SubItems.Add(Entry.Padding.Type.ToString());
     item.SubItems.Add("");
     item.SubItems.Add(Entry.Path);
     item.Tag = Entry;
     this.listView1.Items.Add(item);
     this.listView1.AddEmbeddedControl(new ProgressBar(), 5, item.Index);
     long freeSpace = 0L;
     this.UpdateSpace(out freeSpace);
     if (freeSpace < Entry.Size)
     {
         this.tsStatus.Text = this.tsStatus.Text + ". You do not have enough free disk space to convert this ISO.";
     }
 }
예제 #17
0
        private void createConHeader(string path, IsoEntry iso, uint blocksAllocated, ushort blocksNotAllocated, uint totalParts, ulong sizeParts, byte[] mhtHash)
        {
            ConHeaderWriter writer = new ConHeaderWriter();

            writer.WriteIDs(iso.ID.TitleID, iso.ID.MediaID, iso.TitleName);
            writer.WriteExecutionDetails(iso.ID.DiscNumber, iso.ID.DiscCount, iso.ID.Platform, iso.ID.ExType);
            writer.WriteBlockCounts(blocksAllocated, blocksNotAllocated);
            writer.WriteDataPartsInfo(totalParts, sizeParts);
            switch (iso.Platform)
            {
            case IsoEntryPlatform.Xbox:
                writer.WriteContentType(ContentType.XboxOriginal);
                break;

            case IsoEntryPlatform.Xbox360:
                writer.WriteContentType(ContentType.GamesOnDemand);
                break;
            }
            writer.WriteMhtHash(mhtHash);
            writer.WriteHash();
            writer.Write(path);
        }
예제 #18
0
 private void jobCheck_Tick(object sender, EventArgs e)
 {
     if (!this.i2g.IsBusy)
     {
         foreach (ListViewItem item in this.listView1.Items)
         {
             IsoEntry tag = (IsoEntry)item.Tag;
             if (tag.Status == IsoEntryStatus.Idle)
             {
                 tag.Status          = IsoEntryStatus.InProgress;
                 item.Tag            = tag;
                 this.i2g            = new Chilano.Iso2God.Iso2God();
                 this.i2g.Completed += new Iso2GodCompletedEventHandler(this.i2g_Completed);
                 this.i2g.Progress  += new Iso2GodProgressEventHandler(this.i2g_Progress);
                 this.i2g.RunWorkerAsync(tag);
                 this.jobCheck.Enabled = false;
                 return;
             }
         }
         this.jobCheck.Enabled = false;
     }
 }
예제 #19
0
        private void createConHeader(string path, IsoEntry iso, uint blocksAllocated, ushort blocksNotAllocated, uint totalParts, ulong sizeParts, byte[] mhtHash)
        {
            ConHeaderWriter writer = new ConHeaderWriter();
            writer.WriteIDs(iso.ID.TitleID, iso.ID.MediaID, iso.TitleName);
            writer.WriteExecutionDetails(iso.ID.DiscNumber, iso.ID.DiscCount, iso.ID.Platform, iso.ID.ExType);
            writer.WriteBlockCounts(blocksAllocated, blocksNotAllocated);
            writer.WriteDataPartsInfo(totalParts, sizeParts);
            writer.WriteGameIcon(iso.Thumb);
            switch (iso.Platform)
            {
                case IsoEntryPlatform.Xbox:
                    writer.WriteContentType(ContentType.XboxOriginal);
                    break;

                case IsoEntryPlatform.Xbox360:
                    writer.WriteContentType(ContentType.GamesOnDemand);
                    break;
            }
            writer.WriteMhtHash(mhtHash);
            writer.WriteHash();
            writer.Write(path);
        }
예제 #20
0
 private void Iso2God_Partial(object sender, DoWorkEventArgs e, bool Crop, IsoEntry iso)
 {
     FileStream stream;
     GDF gdf;
     base.ReportProgress((int) this.progress, "Examining ISO image...");
     try
     {
         stream = new FileStream(iso.Path, FileMode.Open, FileAccess.Read, FileShare.Read);
     }
     catch (Exception)
     {
         base.ReportProgress(0, "Cannot access the ISO image because it is being accessed by another application.");
         return;
     }
     try
     {
         gdf = new GDF(stream);
     }
     catch (Exception exception)
     {
         base.ReportProgress(0, "Error while parsing GDF: " + exception.Message);
         return;
     }
     ulong num = 0L;
     if (Crop)
     {
         num = (((ulong) iso.Size) - gdf.RootOffset) - (((ulong) iso.Size) - (gdf.LastOffset + gdf.RootOffset));
     }
     else
     {
         num = ((ulong) iso.Size) - gdf.RootOffset;
     }
     uint blocksReq = (uint) Math.Ceiling((double) (((double) num) / ((double) this.blockSize)));
     uint partsReq = (uint) Math.Ceiling((double) (((double) blocksReq) / ((double) this.blockPerPart)));
     ContentType type = (iso.Platform == IsoEntryPlatform.Xbox360) ? ContentType.GamesOnDemand : ContentType.XboxOriginal;
     object[] objArray = new object[] { iso.Destination, iso.ID.TitleID, Path.DirectorySeparatorChar, "0000", ((uint) type).ToString("X02"), Path.DirectorySeparatorChar };
     string path = string.Concat(objArray) + ((this.uniqueName != null) ? this.uniqueName : iso.ID.TitleID) + ".data";
     if (Directory.Exists(path))
     {
         Directory.Delete(path, true);
     }
     Directory.CreateDirectory(path);
     base.ReportProgress((int) this.progress, "Beginning ISO conversion...");
     stream.Seek((long) gdf.RootOffset, SeekOrigin.Begin);
     this.writeParts(stream, path, iso, partsReq, blocksReq);
     base.ReportProgress((int) this.progress, "Calculating Master Hash Table chain...");
     byte[] lastMhtHash = new byte[20];
     uint lastPartSize = 0;
     this.calcMhtHashChain(path, partsReq, out lastPartSize, out lastMhtHash);
     ulong num6 = 0xa290L;
     ulong num7 = this.blockSize * num6;
     ulong sizeParts = lastPartSize + ((partsReq - 1) * num7);
     base.ReportProgress(0x5f, "Creating LIVE header...");
     this.createConHeader(path.Substring(0, path.Length - 5), iso, blocksReq, 0, partsReq, sizeParts, lastMhtHash);
     stream.Close();
     stream.Dispose();
     gdf.Dispose();
     if ((iso.Padding.Type == IsoEntryPaddingRemoval.Full) && !iso.Padding.KeepIso)
     {
         try
         {
             File.Delete(iso.Path);
         }
         catch (Exception)
         {
             base.ReportProgress(0x5f, "Unable to delete ISO temporary image.");
         }
     }
     this.Finish = DateTime.Now;
     TimeSpan span = (TimeSpan) (this.Finish - this.Start);
     base.ReportProgress(100, "Done!");
     e.Result = "Finished in " + span.Minutes.ToString() + "m" + span.Seconds.ToString() + "s. GOD package written to: " + path;
     GC.Collect();
 }
예제 #21
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;
         }
     }
 }
예제 #22
0
 public void UpdateISOEntry(int Index, IsoEntry Entry)
 {
     ListViewItem item = this.listView1.Items[Index];
     item.Tag = Entry;
     item.Text = Entry.TitleName;
     item.SubItems[1].Text = Entry.ID.TitleID;
     item.SubItems[2].Text = Entry.ID.DiscNumber.ToString();
     item.SubItems[3].Text = Math.Round((double) (((double) Entry.Size) / 1073741824.0), 2).ToString() + " GB";
     item.SubItems[4].Text = Entry.Padding.Type.ToString();
     item.SubItems[6].Text = Entry.Path;
 }
예제 #23
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;
                }
            }
        }
예제 #24
0
        private void Iso2God_Partial(object sender, DoWorkEventArgs e, bool Crop, IsoEntry iso)
        {
            FileStream stream;
            GDF        gdf;

            base.ReportProgress((int)this.progress, "Examining ISO image...");
            try
            {
                stream = new FileStream(iso.Path, FileMode.Open, FileAccess.Read, FileShare.Read);
            }
            catch (Exception)
            {
                base.ReportProgress(0, "Cannot access the ISO image because it is being accessed by another application.");
                return;
            }
            try
            {
                gdf = new GDF(stream);
            }
            catch (Exception exception)
            {
                base.ReportProgress(0, "Error while parsing GDF: " + exception.Message);
                return;
            }
            ulong num = 0L;

            if (Crop)
            {
                num = (((ulong)iso.Size) - gdf.RootOffset) - (((ulong)iso.Size) - (gdf.LastOffset + gdf.RootOffset));
            }
            else
            {
                num = ((ulong)iso.Size) - gdf.RootOffset;
            }
            uint        blocksReq = (uint)Math.Ceiling((double)(((double)num) / ((double)this.blockSize)));
            uint        partsReq  = (uint)Math.Ceiling((double)(((double)blocksReq) / ((double)this.blockPerPart)));
            ContentType type      = (iso.Platform == IsoEntryPlatform.Xbox360) ? ContentType.GamesOnDemand : ContentType.XboxOriginal;

            object[] objArray = new object[] { iso.Destination, iso.ID.TitleID, Path.DirectorySeparatorChar, "0000", ((uint)type).ToString("X02"), Path.DirectorySeparatorChar };
            string   path     = string.Concat(objArray) + ((this.uniqueName != null) ? this.uniqueName : iso.ID.TitleID) + ".data";

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            Directory.CreateDirectory(path);
            base.ReportProgress((int)this.progress, "Beginning ISO conversion...");
            stream.Seek((long)gdf.RootOffset, SeekOrigin.Begin);
            this.writeParts(stream, path, iso, partsReq, blocksReq);
            base.ReportProgress((int)this.progress, "Calculating Master Hash Table chain...");
            byte[] lastMhtHash  = new byte[20];
            uint   lastPartSize = 0;

            this.calcMhtHashChain(path, partsReq, out lastPartSize, out lastMhtHash);
            ulong num6      = 0xa290L;
            ulong num7      = this.blockSize * num6;
            ulong sizeParts = lastPartSize + ((partsReq - 1) * num7);

            base.ReportProgress(0x5f, "Creating LIVE header...");
            this.createConHeader(path.Substring(0, path.Length - 5), iso, blocksReq, 0, partsReq, sizeParts, lastMhtHash);
            stream.Close();
            stream.Dispose();
            gdf.Dispose();
            if ((iso.Padding.Type == IsoEntryPaddingRemoval.Full) && !iso.Padding.KeepIso)
            {
                try
                {
                    File.Delete(iso.Path);
                }
                catch (Exception)
                {
                    base.ReportProgress(0x5f, "Unable to delete ISO temporary image.");
                }
            }
            this.Finish = DateTime.Now;
            TimeSpan span = (TimeSpan)(this.Finish - this.Start);

            base.ReportProgress(100, "Done!");
            e.Result = "Finished in " + span.Minutes.ToString() + "m" + span.Seconds.ToString() + "s. GOD package written to: " + path;
            GC.Collect();
        }
예제 #25
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (this.checkFields())
     {
         IsoEntryPadding padding = new IsoEntryPadding {
             Type = (IsoEntryPaddingRemoval) ((byte) this.cmbPaddingMode.SelectedIndex),
             TempPath = Path.GetTempPath(),
             IsoPath = this.txtRebuiltIso.Text,
             KeepIso = this.cbSaveRebuilt.Checked
         };
         if (!padding.TempPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
         {
             padding.TempPath = padding.TempPath + Path.DirectorySeparatorChar;
         }
         if (!padding.IsoPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
         {
             padding.IsoPath = padding.IsoPath + Path.DirectorySeparatorChar;
         }
         IsoEntryID iD = new IsoEntryID(this.txtTitleID.Text, this.txtMediaID.Text, byte.Parse(this.txtDiscNum.Text), byte.Parse(this.txtDiscCount.Text), byte.Parse(this.txtPlatform.Text), byte.Parse(this.txtExType.Text));
         FileInfo info = new FileInfo(this.txtISO.Text);
         IsoEntry entry = new IsoEntry(this.platform, this.txtISO.Text, this.txtDest.Text, info.Length, this.txtName.Text, iD, (byte[]) this.pbThumb.Tag, padding);
         if (this.edit)
         {
             (base.Owner as Main).UpdateISOEntry(this.entryIndex, entry);
         }
         else
         {
             (base.Owner as Main).AddISOEntry(entry);
         }
         GC.Collect();
         base.Close();
     }
 }
예제 #26
0
 public void Edit(int Index, IsoEntry Entry)
 {
     this.edit = true;
     this.entry = Entry;
     this.entryIndex = Index;
     this.txtName.Text = this.entry.TitleName;
     this.txtTitleID.Text = this.entry.ID.TitleID;
     this.txtMediaID.Text = this.entry.ID.MediaID;
     this.txtPlatform.Text = this.entry.ID.Platform.ToString();
     this.txtExType.Text = this.entry.ID.ExType.ToString();
     this.txtDiscCount.Text = this.entry.ID.DiscCount.ToString();
     this.txtDiscNum.Text = this.entry.ID.DiscNumber.ToString();
     this.txtDest.Text = this.entry.Destination;
     this.txtISO.Text = this.entry.Path;
     this.txtRebuiltIso.Text = (this.entry.Padding.Type == IsoEntryPaddingRemoval.Full) ? this.entry.Padding.IsoPath : Chilano.Iso2God.Properties.Settings.Default["RebuildPath"].ToString();
     this.cbSaveRebuilt.Checked = this.entry.Padding.KeepIso;
     this.cmbPaddingMode.SelectedIndex = (int) this.entry.Padding.Type;
     this.pbThumb.Image = (this.entry.Thumb == null) ? null : Image.FromStream(new MemoryStream(this.entry.Thumb));
     this.pbThumb.Tag = this.entry.Thumb;
     this.btnAddIso.Text = "Save ISO";
 }
예제 #27
0
 private string createUniqueName(IsoEntry Iso)
 {
     MemoryStream s = new MemoryStream();
     CBinaryWriter writer = new CBinaryWriter(EndianType.LittleEndian, s);
     writer.Write(Iso.ID.TitleID);
     writer.Write(Iso.ID.MediaID);
     writer.Write(Iso.ID.DiscNumber);
     writer.Write(Iso.ID.DiscCount);
     byte[] buffer = this.sha1.ComputeHash(s.ToArray());
     string str = "";
     for (int i = 0; i < (buffer.Length / 2); i++)
     {
         str = str + buffer[i].ToString("X02");
     }
     return str;
 }
예제 #28
0
        private void Iso2God_Partial(bool Crop, IsoEntry iso, string ID)
        {
            FileStream stream;
            GDF        gdf;

            Console.WriteLine("+ Examining ISO image...");
            try
            {
                stream = new FileStream(iso.Path, FileMode.Open, FileAccess.Read, FileShare.Read);
            }
            catch (Exception)
            {
                Console.WriteLine("- Cannot access the ISO image because it is being accessed by another application.");
                return;
            }
            try
            {
                gdf = new GDF(stream);
            }
            catch (Exception exception)
            {
                Console.WriteLine("- Error while parsing GDF: " + exception.Message);
                return;
            }
            ulong num = 0L;

            if (Crop)
            {
                num = (((ulong)iso.Size) - gdf.RootOffset) - (((ulong)iso.Size) - (gdf.LastOffset + gdf.RootOffset));
            }
            else
            {
                num = ((ulong)iso.Size) - gdf.RootOffset;
            }
            uint        blocksReq    = (uint)Math.Ceiling(num / ((double)blockSize));
            uint        partsReq     = (uint)Math.Ceiling(blocksReq / ((double)blockPerPart));
            ContentType type         = (iso.Platform == IsoEntryPlatform.Xbox360) ? ContentType.GamesOnDemand : ContentType.XboxOriginal;
            string      gameTitle    = Get360TitleName.getFromDB(ID).ToString();
            var         invalidChars = new string[] { ":" };

            foreach (var i in invalidChars)
            {
                gameTitle = gameTitle.Replace(i, " ");
            }
            Console.WriteLine(gameTitle);
            object[] objArray = { iso.Destination, gameTitle, Path.DirectorySeparatorChar, "0000", ((uint)type).ToString("X02"), Path.DirectorySeparatorChar };
            string   path     = string.Concat(objArray) + ((uniqueName != null) ? uniqueName : iso.ID.TitleID) + ".data";

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            Directory.CreateDirectory(path);
            Console.WriteLine("+ Beginning ISO conversion...");
            Start = DateTime.Now;
            stream.Seek((long)gdf.RootOffset, SeekOrigin.Begin);
            writeParts(stream, path, partsReq, blocksReq);
            Console.WriteLine("+ Calculating Master Hash Table chain...");
            byte[] lastMhtHash  = new byte[20];
            uint   lastPartSize = 0;

            calcMhtHashChain(path, partsReq, out lastPartSize, out lastMhtHash);
            ulong num6      = 0xa290L;
            ulong num7      = blockSize * num6;
            ulong sizeParts = lastPartSize + ((partsReq - 1) * num7);

            Console.WriteLine("+ Creating LIVE header...");
            createConHeader(path.Substring(0, path.Length - 5), iso, blocksReq, 0, partsReq, sizeParts, lastMhtHash);
            stream.Close();
            stream.Dispose();
            gdf.Dispose();
            Finish = DateTime.Now;
            TimeSpan span = Finish - Start;

            Console.WriteLine("+ Done!");
            Console.WriteLine("+ Finished in " + span.Minutes + "m" + span.Seconds + "s. GOD package written to: " + path);
            GC.Collect();
        }
예제 #29
0
 public void Run(IsoEntry entry, string ID)
 {
     uniqueName = createUniqueName(entry);
     Iso2God_Partial(false, entry, ID);
 }