From 5ba688d4c3b64d9482c00aea9b0b15ac02fc7371 Mon Sep 17 00:00:00 2001 From: "gb.luke" Date: Fri, 9 Jul 2010 17:54:13 +0000 Subject: [PATCH] Fixed IOS patching Unchecking all IOS patches now also unchecks main IOS patch checkbox Increased size of header, in hope that the date won't be cut off... Changed TODO list stuff VERIFIED UNDER: Windows TO VERIFY: Linux (not sure if outputting WADs correctly, should be checked) Mac OS X (not such a priority, as mono can be quite hard to set up on OS X) --- NUS Downloader/Database.cs | 9 +++- NUS Downloader/Form1.Designer.cs | 9 +++- NUS Downloader/Form1.cs | 70 +++++++++++++++++++++++++++----- NUS Downloader/NusClient.cs | 1 + NUS Downloader/Program.cs | 12 +++--- NUS Downloader/TODO | 15 ++++--- NUS Downloader/WADPacker.cs | 12 +++--- 7 files changed, 96 insertions(+), 32 deletions(-) diff --git a/NUS Downloader/Database.cs b/NUS Downloader/Database.cs index 7c5635e..6ea6b85 100644 --- a/NUS Downloader/Database.cs +++ b/NUS Downloader/Database.cs @@ -1,4 +1,11 @@ -using System; +/////////////////////////////////////////// +// NUS Downloader: Database.cs // +// $Rev:: $ // +// $Author:: $ // +// $Date:: $ // +/////////////////////////////////////////// + +using System; using System.Windows.Forms; using System.IO; using System.Xml; diff --git a/NUS Downloader/Form1.Designer.cs b/NUS Downloader/Form1.Designer.cs index 2c7c368..082c746 100644 --- a/NUS Downloader/Form1.Designer.cs +++ b/NUS Downloader/Form1.Designer.cs @@ -1,4 +1,11 @@ -namespace NUS_Downloader +/////////////////////////////////////////// +// NUS Downloader: Form1.Designer.cs // +// $Rev:: $ // +// $Author:: $ // +// $Date:: $ // +/////////////////////////////////////////// + +namespace NUS_Downloader { partial class Form1 { diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index dca064f..5081a2f 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -1,9 +1,9 @@ -/////////////////////////////////////// -// NUS Downloader: Form1.cs // -// $Rev:: $ // -// $Author:: $ // -// $Date:: $ // -/////////////////////////////////////// +/////////////////////////////////////////// +// NUS Downloader: Form1.cs // +// $Rev:: $ // +// $Author:: $ // +// $Date:: $ // +/////////////////////////////////////////// /////////////////////////////////////// // Copyright (C) 2010 @@ -515,9 +515,13 @@ namespace NUS_Downloader } if (iosPatchCheckbox.Checked == true) { // Apply patches then... + bool didpatch = false; + int noofpatches = 0; + string appendpatch = ""; // Okay, it's checked. libWiiSharp.IosPatcher iosp = new libWiiSharp.IosPatcher(); libWiiSharp.WAD ioswad = new libWiiSharp.WAD(); + wadName = wadName.Replace("[v]", nusClient.TitleVersion.ToString()); if (wadName.Contains(Path.DirectorySeparatorChar.ToString()) || wadName.Contains(Path.AltDirectorySeparatorChar.ToString())) ioswad.LoadFile(wadName); else @@ -537,20 +541,47 @@ namespace NUS_Downloader if (iosPatchesListBox.GetItemCheckState(iosPatchesListBox.Items.IndexOf(checkItem)).ToString() == "Checked") { switch (checkItem.ToString()) { case "Trucha bug": - if (iosp.PatchFakeSigning() > 0) - WriteStatus(" - Patched in fake-signing"); + noofpatches = iosp.PatchFakeSigning(); + if (noofpatches > 0) + { + WriteStatus(" - Patched in fake-signing:"); + if (noofpatches > 1) + appendpatch = "es"; + else + appendpatch = ""; + WriteStatus(String.Format(" {0} patch{1} applied.", noofpatches, appendpatch)); + didpatch = true; + } else WriteStatus(" - Could not patch fake-signing"); break; case "ES_Identify": - if (iosp.PatchEsIdentify() > 0) + noofpatches = iosp.PatchEsIdentify(); + if (noofpatches > 0) + { WriteStatus(" - Patched in ES_Identify"); + if (noofpatches > 1) + appendpatch = "es"; + else + appendpatch = ""; + WriteStatus(String.Format(" {0} patch{1} applied.", noofpatches, appendpatch)); + didpatch = true; + } else WriteStatus(" - Could not patch ES_Identify"); break; case "NAND permissions": - if (iosp.PatchNandPermissions() > 0) + noofpatches = iosp.PatchNandPermissions(); + if (noofpatches > 0) + { WriteStatus(" - Patched in NAND permissions"); + if (noofpatches > 1) + appendpatch = "es"; + else + appendpatch = ""; + WriteStatus(String.Format(" {0} patch{1} applied.", noofpatches, appendpatch)); + didpatch = true; + } else WriteStatus(" - Could not patch NAND permissions"); break; @@ -560,6 +591,22 @@ namespace NUS_Downloader // WriteStatus(iosPatchesListBox.GetItemCheckState(iosPatchesListBox.Items.IndexOf(checkItem)).ToString()); } } + if (didpatch) + { + wadName = wadName.Replace(".wad",".patched.wad"); + try + { + if (wadName.Contains(Path.DirectorySeparatorChar.ToString()) || wadName.Contains(Path.AltDirectorySeparatorChar.ToString())) + ioswad.Save(wadName); + else + ioswad.Save(Path.Combine(Path.Combine(Path.Combine(Path.Combine(CURRENT_DIR, "titles"), titleidbox.Text), nusClient.TitleVersion.ToString()), wadName)); + WriteStatus(String.Format("Patched WAD saved as: {0}", Path.GetFileName(wadName))); + } + catch (Exception ex) + { + WriteStatus(String.Format("Couldn't save patched WAD: \"{0}\" :(",ex.Message)); + } + } } WriteStatus("NUS Download Finished."); @@ -2247,6 +2294,9 @@ namespace NUS_Downloader { SetAllEnabled(true); iosPatchGroupBox.Visible = false; + if (iosPatchesListBox.CheckedIndices.Count == 0) + // Uncheck the checkbox to indicate no patches + iosPatchCheckbox.Checked = false; //packbox.Enabled = false; } } diff --git a/NUS Downloader/NusClient.cs b/NUS Downloader/NusClient.cs index 2404d7a..22dfe76 100644 --- a/NUS Downloader/NusClient.cs +++ b/NUS Downloader/NusClient.cs @@ -431,6 +431,7 @@ namespace libWiiSharp fireDebug(" Creating WAD..."); WAD wad = WAD.Create(cert, tik, tmd, contents); + wadName = wadName.Replace("[v]", this.TitleVersion.ToString()); if (wadName.Contains(Path.DirectorySeparatorChar.ToString()) || wadName.Contains(Path.AltDirectorySeparatorChar.ToString())) wad.Save(wadName); else diff --git a/NUS Downloader/Program.cs b/NUS Downloader/Program.cs index 98067c7..92eacc3 100644 --- a/NUS Downloader/Program.cs +++ b/NUS Downloader/Program.cs @@ -1,9 +1,9 @@ -/////////////////////////////////////// -// NUS Downloader: Program.cs // -// $Rev:: $ // -// $Author:: $ // -// $Date:: $ // -/////////////////////////////////////// +/////////////////////////////////////////// +// NUS Downloader: Program.cs // +// $Rev:: $ // +// $Author:: $ // +// $Date:: $ // +/////////////////////////////////////////// using System; diff --git a/NUS Downloader/TODO b/NUS Downloader/TODO index 9cdff22..5d608a1 100644 --- a/NUS Downloader/TODO +++ b/NUS Downloader/TODO @@ -1,15 +1,14 @@ -/////////////////////////////////////// -// NUS Downlodaer: TODO // -// $Rev:: $ // -// $Author:: $ // -// $Date:: $ // -/////////////////////////////////////// +/////////////////////////////////////////// +// NUS Downloader: TODO // +// $Rev:: $ // +// $Author:: $ // +// $Date:: $ // +/////////////////////////////////////////// Make more compatible with mono for Linux. Broken stuff: - - Downloading anything - - Bottom part of dialog cut off Working stuff: + - Downloading anything - Displaying Form1 - Loading database - Generating update scripts diff --git a/NUS Downloader/WADPacker.cs b/NUS Downloader/WADPacker.cs index cd494c1..1e1f656 100644 --- a/NUS Downloader/WADPacker.cs +++ b/NUS Downloader/WADPacker.cs @@ -1,9 +1,9 @@ -/////////////////////////////////////// -// NUS Downloader: WADPacker.cs // -// $Rev:: $ // -// $Author:: $ // -// $Date:: $ // -/////////////////////////////////////// +/////////////////////////////////////////// +// NUS Downloader: WADPacker.cs // +// $Rev:: $ // +// $Author:: $ // +// $Date:: $ // +/////////////////////////////////////////// /////////////////////////////////////// // Copyright (C) 2010