diff --git a/NUS Downloader/Form1.Designer.cs b/NUS Downloader/Form1.Designer.cs index 187b51e..a735bad 100644 --- a/NUS Downloader/Form1.Designer.cs +++ b/NUS Downloader/Form1.Designer.cs @@ -99,6 +99,10 @@ this.decryptbox = new System.Windows.Forms.CheckBox(); this.localuse = new System.Windows.Forms.CheckBox(); this.iosPatchCheckbox = new System.Windows.Forms.CheckBox(); + this.iosPatchGroupBox = new System.Windows.Forms.GroupBox(); + this.iosPatchGroupBoxOKbtn = new System.Windows.Forms.Button(); + this.iosPatchesListBox = new System.Windows.Forms.CheckedListBox(); + this.label2 = new System.Windows.Forms.Label(); this.titleversion = new wmgCMS.WaterMarkTextBox(); this.titleidbox = new wmgCMS.WaterMarkTextBox(); this.dlprogress = new wyDay.Controls.Windows7ProgressBar(); @@ -107,6 +111,7 @@ this.proxyBox.SuspendLayout(); this.ProxyVerifyBox.SuspendLayout(); this.scriptsStrip.SuspendLayout(); + this.iosPatchGroupBox.SuspendLayout(); this.SuspendLayout(); // // Extrasbtn @@ -752,6 +757,54 @@ this.iosPatchCheckbox.Text = "Patch IOS..."; this.iosPatchCheckbox.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.iosPatchCheckbox.UseVisualStyleBackColor = true; + this.iosPatchCheckbox.CheckedChanged += new System.EventHandler(this.iosPatchCheckbox_CheckedChanged); + // + // iosPatchGroupBox + // + this.iosPatchGroupBox.Controls.Add(this.label2); + this.iosPatchGroupBox.Controls.Add(this.iosPatchesListBox); + this.iosPatchGroupBox.Controls.Add(this.iosPatchGroupBoxOKbtn); + this.iosPatchGroupBox.Location = new System.Drawing.Point(31, 146); + this.iosPatchGroupBox.Name = "iosPatchGroupBox"; + this.iosPatchGroupBox.Size = new System.Drawing.Size(212, 142); + this.iosPatchGroupBox.TabIndex = 55; + this.iosPatchGroupBox.TabStop = false; + this.iosPatchGroupBox.Text = "IOS Patches"; + this.iosPatchGroupBox.Visible = false; + // + // iosPatchGroupBoxOKbtn + // + this.iosPatchGroupBoxOKbtn.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.iosPatchGroupBoxOKbtn.Location = new System.Drawing.Point(131, 113); + this.iosPatchGroupBoxOKbtn.Name = "iosPatchGroupBoxOKbtn"; + this.iosPatchGroupBoxOKbtn.Size = new System.Drawing.Size(75, 23); + this.iosPatchGroupBoxOKbtn.TabIndex = 0; + this.iosPatchGroupBoxOKbtn.Text = "OK"; + this.iosPatchGroupBoxOKbtn.UseVisualStyleBackColor = true; + this.iosPatchGroupBoxOKbtn.Click += new System.EventHandler(this.iosPatchGroupBoxOKbtn_Click); + // + // iosPatchesListBox + // + this.iosPatchesListBox.BackColor = System.Drawing.SystemColors.Menu; + this.iosPatchesListBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.iosPatchesListBox.FormattingEnabled = true; + this.iosPatchesListBox.Items.AddRange(new object[] { + "Trucha bug", + "ES_Identify", + "NAND permissions"}); + this.iosPatchesListBox.Location = new System.Drawing.Point(6, 62); + this.iosPatchesListBox.Name = "iosPatchesListBox"; + this.iosPatchesListBox.Size = new System.Drawing.Size(197, 45); + this.iosPatchesListBox.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(9, 16); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(184, 26); + this.label2.TabIndex = 2; + this.label2.Text = "Patch the following bugs into any IOS\r\nI download:"; // // titleversion // @@ -791,6 +844,7 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(274, 516); + this.Controls.Add(this.iosPatchGroupBox); this.Controls.Add(this.iosPatchCheckbox); this.Controls.Add(this.ProxyVerifyBox); this.Controls.Add(this.proxyBox); @@ -825,6 +879,8 @@ this.ProxyVerifyBox.ResumeLayout(false); this.ProxyVerifyBox.PerformLayout(); this.scriptsStrip.ResumeLayout(false); + this.iosPatchGroupBox.ResumeLayout(false); + this.iosPatchGroupBox.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -907,6 +963,10 @@ private System.Windows.Forms.CheckBox keepenccontents; private System.Windows.Forms.Button saveaswadbtn; private System.Windows.Forms.CheckBox iosPatchCheckbox; + private System.Windows.Forms.GroupBox iosPatchGroupBox; + private System.Windows.Forms.CheckedListBox iosPatchesListBox; + private System.Windows.Forms.Button iosPatchGroupBoxOKbtn; + private System.Windows.Forms.Label label2; } } diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index 0286447..db6403e 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -896,6 +896,54 @@ namespace NUS_Downloader WriteStatus("Uhoh, the download bombed: \"" + ex.Message + " ):\""); } + if (iosPatchCheckbox.Checked == true) { // Apply patches then... + // Okay, it's checked. + libWiiSharp.IosPatcher iosp = new libWiiSharp.IosPatcher(); + libWiiSharp.WAD ioswad = new libWiiSharp.WAD(); + if (wadName.Contains(Path.DirectorySeparatorChar.ToString()) || wadName.Contains(Path.AltDirectorySeparatorChar.ToString())) + ioswad.LoadFile(wadName); + else + ioswad.LoadFile(Path.Combine(Path.Combine(Path.Combine(Path.Combine(CURRENT_DIR, "titles"), titleidbox.Text), nusClient.TitleVersion.ToString()), wadName)); + try + { + iosp.LoadIOS(ref ioswad); + } + catch (Exception) + { + WriteStatus("NUS Download Finished."); + return; + } + foreach (object checkItem in iosPatchesListBox.CheckedItems) + { + // ensure not 'indeterminate' + if (iosPatchesListBox.GetItemCheckState(iosPatchesListBox.Items.IndexOf(checkItem)).ToString() == "Checked") { + switch (checkItem.ToString()) { + case "Trucha bug": + if (iosp.PatchFakeSigning() > 0) + WriteStatus(" - Patched in fake-signing"); + else + WriteStatus(" - Could not patch fake-signing"); + break; + case "ES_Identify": + if (iosp.PatchEsIdentify() > 0) + WriteStatus(" - Patched in ES_Identify"); + else + WriteStatus(" - Could not patch ES_Identify"); + break; + case "NAND permissions": + if (iosp.PatchNandPermissions() > 0) + WriteStatus(" - Patched in NAND permissions"); + else + WriteStatus(" - Could not patch NAND permissions"); + break; + } + } + else { + // WriteStatus(iosPatchesListBox.GetItemCheckState(iosPatchesListBox.Items.IndexOf(checkItem)).ToString()); + } + } + } + WriteStatus("NUS Download Finished."); } @@ -1927,6 +1975,7 @@ namespace NUS_Downloader keepenccontents.Enabled = enabled; scriptsbutton.Enabled = enabled; consoleCBox.Enabled = enabled; + iosPatchCheckbox.Enabled = enabled; } /// @@ -3096,5 +3145,30 @@ namespace NUS_Downloader // This is also probably not the best way to accomplish this... Environment.Exit(0); } + + private void iosPatchCheckbox_CheckedChanged(object sender, EventArgs e) + { + if (iosPatchCheckbox.Checked == true) + { + packbox.Enabled = false; + packbox.Checked = true; + SetAllEnabled(false); + iosPatchGroupBox.Visible = true; + iosPatchGroupBox.Enabled = true; + iosPatchesListBox.Enabled = true; + iosPatchGroupBoxOKbtn.Enabled = true; + } + else + { + packbox.Enabled = true; + } + } + + private void iosPatchGroupBoxOKbtn_Click(object sender, EventArgs e) + { + SetAllEnabled(true); + iosPatchGroupBox.Visible = false; + packbox.Enabled = false; + } } } \ No newline at end of file diff --git a/NUS Downloader/NusClient.cs b/NUS Downloader/NusClient.cs index ebfa49a..2404d7a 100644 --- a/NUS Downloader/NusClient.cs +++ b/NUS Downloader/NusClient.cs @@ -42,6 +42,10 @@ namespace libWiiSharp private bool useLocalFiles = false; private bool continueWithoutTicket = false; + private int titleversion; + + public int TitleVersion { get { return titleversion; } } + /// /// If true, existing local files will be used. /// @@ -336,6 +340,8 @@ namespace libWiiSharp if (!Directory.Exists(Path.Combine(outputDir, tmd.TitleVersion.ToString()))) Directory.CreateDirectory(Path.Combine(outputDir, tmd.TitleVersion.ToString())); outputDir = Path.Combine(outputDir, tmd.TitleVersion.ToString()); + this.titleversion = tmd.TitleVersion; + File.WriteAllBytes(Path.Combine(outputDir, tmdFile), tmd.ToByteArray()); fireProgress(5);