diff --git a/NUS Downloader/Form1.Designer.cs b/NUS Downloader/Form1.Designer.cs index 3bd4403..4c5a548 100644 --- a/NUS Downloader/Form1.Designer.cs +++ b/NUS Downloader/Form1.Designer.cs @@ -30,7 +30,7 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); - this.TMDButton = new System.Windows.Forms.Button(); + this.Extrasbtn = new System.Windows.Forms.Button(); this.titleidbox = new System.Windows.Forms.TextBox(); this.downloadstartbtn = new System.Windows.Forms.Button(); this.statusbox = new System.Windows.Forms.TextBox(); @@ -65,6 +65,8 @@ this.WiiWareMenuList = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.RegionCodesList = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.updateDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.truchabox = new System.Windows.Forms.CheckBox(); this.tmdgpbox = new System.Windows.Forms.GroupBox(); this.tmdversiontrucha = new System.Windows.Forms.TextBox(); @@ -107,24 +109,31 @@ this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.button17 = new System.Windows.Forms.Button(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.updateDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.extrasStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.loadInfoFromTMDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.emulateUpdate = new System.Windows.Forms.ToolStripMenuItem(); + this.uSANTSCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.europePALToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.japanNTSCJToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.koreaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.databaseStrip.SuspendLayout(); this.tmdgpbox.SuspendLayout(); this.ticketgpbox.SuspendLayout(); this.contentModBox.SuspendLayout(); + this.extrasStrip.SuspendLayout(); this.SuspendLayout(); // - // TMDButton + // Extrasbtn // - this.TMDButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.TMDButton.Location = new System.Drawing.Point(128, 12); - this.TMDButton.Name = "TMDButton"; - this.TMDButton.Size = new System.Drawing.Size(50, 20); - this.TMDButton.TabIndex = 0; - this.TMDButton.Text = "TMD..."; - this.TMDButton.UseVisualStyleBackColor = true; - this.TMDButton.Click += new System.EventHandler(this.button1_Click); + this.Extrasbtn.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.Extrasbtn.Location = new System.Drawing.Point(125, 12); + this.Extrasbtn.Name = "Extrasbtn"; + this.Extrasbtn.Size = new System.Drawing.Size(55, 20); + this.Extrasbtn.TabIndex = 0; + this.Extrasbtn.Text = "Extras..."; + this.Extrasbtn.UseVisualStyleBackColor = true; + this.Extrasbtn.Click += new System.EventHandler(this.button1_Click); // // titleidbox // @@ -218,6 +227,7 @@ // label2 // this.label2.AutoSize = true; + this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Location = new System.Drawing.Point(9, 16); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(113, 13); @@ -281,9 +291,9 @@ // databaseButton // this.databaseButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.databaseButton.Location = new System.Drawing.Point(184, 12); + this.databaseButton.Location = new System.Drawing.Point(186, 12); this.databaseButton.Name = "databaseButton"; - this.databaseButton.Size = new System.Drawing.Size(78, 20); + this.databaseButton.Size = new System.Drawing.Size(76, 20); this.databaseButton.TabIndex = 20; this.databaseButton.Text = "Database..."; this.databaseButton.UseVisualStyleBackColor = true; @@ -302,7 +312,7 @@ this.updateDatabaseToolStripMenuItem}); this.databaseStrip.Name = "databaseStrip"; this.databaseStrip.ShowItemToolTips = false; - this.databaseStrip.Size = new System.Drawing.Size(164, 170); + this.databaseStrip.Size = new System.Drawing.Size(164, 148); // // SystemMenuList // @@ -419,6 +429,18 @@ this.RegionCodesList.Text = "Region Codes"; this.RegionCodesList.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.RegionCodesList_DropDownItemClicked); // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(160, 6); + // + // updateDatabaseToolStripMenuItem + // + this.updateDatabaseToolStripMenuItem.Name = "updateDatabaseToolStripMenuItem"; + this.updateDatabaseToolStripMenuItem.Size = new System.Drawing.Size(163, 22); + this.updateDatabaseToolStripMenuItem.Text = "Update Database"; + this.updateDatabaseToolStripMenuItem.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click); + // // truchabox // this.truchabox.AutoSize = true; @@ -877,17 +899,63 @@ this.button17.UseVisualStyleBackColor = true; this.button17.Click += new System.EventHandler(this.button17_Click); // - // toolStripSeparator2 + // extrasStrip // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(160, 6); + this.extrasStrip.AllowMerge = false; + this.extrasStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.loadInfoFromTMDToolStripMenuItem, + this.toolStripSeparator3, + this.emulateUpdate}); + this.extrasStrip.Name = "extrasStrip"; + this.extrasStrip.Size = new System.Drawing.Size(220, 76); // - // updateDatabaseToolStripMenuItem + // loadInfoFromTMDToolStripMenuItem // - this.updateDatabaseToolStripMenuItem.Name = "updateDatabaseToolStripMenuItem"; - this.updateDatabaseToolStripMenuItem.Size = new System.Drawing.Size(163, 22); - this.updateDatabaseToolStripMenuItem.Text = "Update Database"; - this.updateDatabaseToolStripMenuItem.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click); + this.loadInfoFromTMDToolStripMenuItem.Name = "loadInfoFromTMDToolStripMenuItem"; + this.loadInfoFromTMDToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.loadInfoFromTMDToolStripMenuItem.Text = "Load Info from TMD"; + this.loadInfoFromTMDToolStripMenuItem.Click += new System.EventHandler(this.loadInfoFromTMDToolStripMenuItem_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(216, 6); + // + // emulateUpdate + // + this.emulateUpdate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.uSANTSCToolStripMenuItem, + this.europePALToolStripMenuItem, + this.japanNTSCJToolStripMenuItem, + this.koreaToolStripMenuItem}); + this.emulateUpdate.Name = "emulateUpdate"; + this.emulateUpdate.Size = new System.Drawing.Size(219, 22); + this.emulateUpdate.Text = "Emulate Wii System Update"; + this.emulateUpdate.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.emulateUpdate_DropDownItemClicked); + // + // uSANTSCToolStripMenuItem + // + this.uSANTSCToolStripMenuItem.Name = "uSANTSCToolStripMenuItem"; + this.uSANTSCToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.uSANTSCToolStripMenuItem.Text = "USA (NTSC)"; + // + // europePALToolStripMenuItem + // + this.europePALToolStripMenuItem.Name = "europePALToolStripMenuItem"; + this.europePALToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.europePALToolStripMenuItem.Text = "Europe (PAL)"; + // + // japanNTSCJToolStripMenuItem + // + this.japanNTSCJToolStripMenuItem.Name = "japanNTSCJToolStripMenuItem"; + this.japanNTSCJToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.japanNTSCJToolStripMenuItem.Text = "Japan (NTSC-J)"; + // + // koreaToolStripMenuItem + // + this.koreaToolStripMenuItem.Name = "koreaToolStripMenuItem"; + this.koreaToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.koreaToolStripMenuItem.Text = "Korea"; // // Form1 // @@ -922,7 +990,7 @@ this.Controls.Add(this.statusbox); this.Controls.Add(this.downloadstartbtn); this.Controls.Add(this.titleidbox); - this.Controls.Add(this.TMDButton); + this.Controls.Add(this.Extrasbtn); this.Controls.Add(this.button6); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -938,6 +1006,7 @@ this.ticketgpbox.ResumeLayout(false); this.ticketgpbox.PerformLayout(); this.contentModBox.ResumeLayout(false); + this.extrasStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -945,7 +1014,7 @@ #endregion - private System.Windows.Forms.Button TMDButton; + private System.Windows.Forms.Button Extrasbtn; private System.Windows.Forms.TextBox titleidbox; private System.Windows.Forms.Button downloadstartbtn; private System.Windows.Forms.TextBox statusbox; @@ -1024,6 +1093,14 @@ private System.Windows.Forms.Button button17; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip extrasStrip; + private System.Windows.Forms.ToolStripMenuItem loadInfoFromTMDToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem emulateUpdate; + private System.Windows.Forms.ToolStripMenuItem uSANTSCToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem europePALToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem japanNTSCJToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem koreaToolStripMenuItem; } } diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index a2e4681..167e089 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -8,6 +8,7 @@ using System.Drawing; using System.Text.RegularExpressions; using System.ComponentModel; using System.Threading; +using System.Text; namespace NUS_Downloader @@ -17,7 +18,7 @@ namespace NUS_Downloader const string NUSURL = "http://nus.cdn.shop.wii.com/ccs/download/"; const string DSiNUSURL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/"; // TODO: Always remember to change version! - string version = "v1.2"; + string version = "v1.3"; WebClient generalWC = new WebClient(); static RijndaelManaged rijndaelCipher; static bool dsidecrypt = false; @@ -156,8 +157,6 @@ namespace NUS_Downloader { this.Text = "NUSD - " + version + " - WB3000"; this.Size = this.MinimumSize; - - } private bool BootChecks() @@ -235,8 +234,8 @@ namespace NUS_Downloader { WriteStatus("Database.xml not found. Title database not usable!"); databaseButton.Visible = false; - TMDButton.Size = new System.Drawing.Size(134, 20); - TMDButton.Anchor = AnchorStyles.Right; + Extrasbtn.Size = new System.Drawing.Size(134, 20); + Extrasbtn.Anchor = AnchorStyles.Right; } else { @@ -268,6 +267,12 @@ namespace NUS_Downloader } private void button1_Click(object sender, EventArgs e) + { + // Show extras menu + extrasStrip.Show(Extrasbtn, 2, 2); + } + + private void LoadTitleFromTMD() { // Show dialog for opening TMD file... OpenFileDialog opentmd = new OpenFileDialog(); @@ -324,7 +329,7 @@ namespace NUS_Downloader byte[] hash = new byte[20]; for (int x = 0; x < 20; x++) { - hash[x] = tmdhashes[(i*20)+x]; + hash[x] = tmdhashes[(i * 20) + x]; } WriteStatus(" - Hash: " + DisplayBytes(hash, "").Substring(0, 8) + "..."); WriteStatus(" - Index: " + tmdindices[i]); @@ -2207,7 +2212,7 @@ namespace NUS_Downloader downloadstartbtn.Enabled = enabled; titleidbox.Enabled = enabled; titleversion.Enabled = enabled; - TMDButton.Enabled = enabled; + Extrasbtn.Enabled = enabled; databaseButton.Enabled = enabled; packbox.Enabled = enabled; localuse.Enabled = enabled; @@ -3167,7 +3172,9 @@ namespace NUS_Downloader { // Retrieve Wiibrew database page source code WebClient databasedl = new WebClient(); + statusbox.Refresh(); string wiibrewsource = databasedl.DownloadString("http://www.wiibrew.org/wiki/NUS_Downloader/database"); + statusbox.Refresh(); // Strip out HTML wiibrewsource = Regex.Replace(wiibrewsource, @"<(.|\n)*?>", ""); @@ -3178,11 +3185,11 @@ namespace NUS_Downloader wiibrewsource = wiibrewsource.Substring(wiibrewsource.IndexOf(startofdatabase), wiibrewsource.Length - wiibrewsource.IndexOf(startofdatabase)); wiibrewsource = wiibrewsource.Substring(0, wiibrewsource.IndexOf(endofdatabase) + endofdatabase.Length); - // Fix ", <, and > + // Fix ", <, >, and spaces wiibrewsource = wiibrewsource.Replace("<","<"); wiibrewsource = wiibrewsource.Replace(">",">"); wiibrewsource = wiibrewsource.Replace(""",'"'.ToString()); - wiibrewsource = wiibrewsource.Replace(" ", ""); // Shouldn't occur, but they happen... + wiibrewsource = wiibrewsource.Replace(" ", " "); // Shouldn't occur, but they happen... // Return parsed xml database... return wiibrewsource; @@ -3192,13 +3199,13 @@ namespace NUS_Downloader { statusbox.Text = ""; WriteStatus("Updating your database.xml from Wiibrew.org"); - WriteStatus(" - Database successfully parsed!"); string database = RetrieveNewDatabase(); string currentversion = GetDatabaseVersion("database.xml"); string onlineversion = GetDatabaseVersion(database); - WriteStatus(" - Current Database Version: " + currentversion); - WriteStatus(" - Online Database Version: " + onlineversion); + WriteStatus(" - Database successfully parsed!"); + WriteStatus(" - Current Database Version: " + currentversion); + WriteStatus(" - Online Database Version: " + onlineversion); if (currentversion == onlineversion) { @@ -3216,5 +3223,114 @@ namespace NUS_Downloader WriteStatus("Database successfully updated!"); } + + private void loadInfoFromTMDToolStripMenuItem_Click(object sender, EventArgs e) + { + // Extras menu -> Load TMD... + LoadTitleFromTMD(); + } + + public string SendSOAPRequest(string soap_xml) + { + System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://nus.shop.wii.com:80/nus/services/NetUpdateSOAP"); + req.Method = "POST"; + req.UserAgent = "wii libnup/1.0"; + req.Headers.Add("SOAPAction", '"' + "urn:nus.wsapi.broadon.com/" + '"'); + Stream writeStream = req.GetRequestStream(); + + UTF8Encoding encoding = new UTF8Encoding(); + byte[] bytes = encoding.GetBytes(soap_xml); + req.ContentType = "text/xml; charset=utf-8"; + //req.ContentLength = bytes.Length; + writeStream.Write(bytes, 0, bytes.Length); + writeStream.Close(); + Application.DoEvents(); + try + { + string result; + System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse)req.GetResponse(); + + using (Stream responseStream = resp.GetResponseStream()) + { + using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8)) + { + result = readStream.ReadToEnd(); + } + } + req.Abort(); + Application.DoEvents(); + return result; + } + catch (Exception ex) + { + req.Abort(); + + return ex.Message.ToString(); + } + + } + + private void emulateUpdate_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + // Begin Wii System Update + WriteStatus("Starting Wii System Update..."); + + extrasStrip.Close(); + + string deviceID = "4362227770"; + string messageID = "13198105123219138"; + string attr = "2"; + string RegionID = "USA"; + string CountryCode = "US"; + + // TODO: Specific region/ccodes + + string soap_req = "\n" + + "\n\n" + + "1.0\n" + messageID + "\n" + deviceID + "\n" + + "" + RegionID + "\n" + CountryCode + "\n\n0000000100000001\n" + + "2\n\n\n0000000100000002\n" + + "33\n\n\n0000000100000009\n" + + "516\n\n" + attr + "\n\n" + + "\n\n"; + + WriteStatus(" - Sending SOAP Request to NUS..."); + string update_xml = SendSOAPRequest(soap_req); + if (update_xml != null) + WriteStatus(" - Recieved Update Info!"); + else + { + WriteStatus(" - Fail."); + return; + } + + XmlDocument xDoc = new XmlDocument(); + xDoc.LoadXml(update_xml); + XmlNodeList TitleList = xDoc.GetElementsByTagName("TitleVersion"); + for (int a = 0; a < TitleList.Count; a++) + { + XmlNodeList TitleInfo = TitleList[a].ChildNodes; + string TitleID = ""; + string Version = ""; + + for (int b = 0; b < TitleInfo.Count; b++) + { + switch (TitleInfo[b].Name) + { + case "TitleId": + TitleID = TitleInfo[b].InnerText; + break; + case "Version": + Version = TitleInfo[b].InnerText; + break; + default: + break; + } + } + WriteStatus(String.Format("{0}v{1}", TitleID, Version)); + } + } } } diff --git a/NUS Downloader/Form1.resx b/NUS Downloader/Form1.resx index 9b56599..c68816d 100644 --- a/NUS Downloader/Form1.resx +++ b/NUS Downloader/Form1.resx @@ -330,6 +330,9 @@ 1sV/DvoUn9RT8j8FdlkrvvDH+0eqk6iKjzT6K8x9ib8G3pPIf5i62eYpA0TWAAAAAElFTkSuQmCC + + 285, 17 + AAABAAUAEBAAAAAAIABoBAAAVgAAACAgAAAAACAAqBAAAL4EAAAwMAAAAAAgAKglAABmFQAAQEAAAAAA