Beispiel #1
0
        private void NUSDownloader_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false; // this function would need major rewriting to get rid of this...
            
            WriteStatus("Starting NUS Download. Please be patient!", infocolor);
            SetEnableforDownload(false);
            downloadstartbtn.Text = "Starting NUS Download!";

            // WebClient configuration
            WebClient nusWC = new WebClient();
            nusWC = ConfigureWithProxy(nusWC);
            
            // Create\Configure NusClient
            libWiiSharp.NusClient nusClient = new libWiiSharp.NusClient();
            nusClient.ConfigureNusClient(nusWC);
            nusClient.UseLocalFiles = localuse.Checked;
            nusClient.ContinueWithoutTicket = true;

            // Server
            if (serverLbl.Text == "Wii")
                nusClient.SetToWiiServer();
            else if (serverLbl.Text == "DSi")
                nusClient.SetToDSiServer();

            // Events
            nusClient.Debug += new EventHandler<libWiiSharp.MessageEventArgs>(nusClient_Debug);
            nusClient.Progress += new EventHandler<ProgressChangedEventArgs>(nusClient_Progress);

            libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[3];
            if (packbox.Checked) storeTypes[0] = libWiiSharp.StoreType.WAD; else storeTypes[0] = libWiiSharp.StoreType.Empty;
            if (decryptbox.Checked) storeTypes[1] = libWiiSharp.StoreType.DecryptedContent; else storeTypes[1] = libWiiSharp.StoreType.Empty;
            if (keepenccontents.Checked) storeTypes[2] = libWiiSharp.StoreType.EncryptedContent; else storeTypes[2] = libWiiSharp.StoreType.Empty;

            string wadName;
            if (String.IsNullOrEmpty(WAD_Saveas_Filename))
                wadName = wadnamebox.Text;
            else
                wadName = WAD_Saveas_Filename;

            try
            {
                nusClient.DownloadTitle(titleidbox.Text, titleversion.Text, Path.Combine(CURRENT_DIR, "titles"), wadName, storeTypes);
            }
            catch (Exception ex)
            {
                WriteStatus("Download failed: \"" + ex.Message + " ):\"", errorcolor);
            }

            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
                    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.", infocolor);
                    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":
                                noofpatches = iosp.PatchFakeSigning();
                                if (noofpatches > 0)
                                {
                                    WriteStatus(" - Patched in fake-signing:", infocolor);
                                    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", errorcolor);
                                break;
                            case "ES_Identify":
                                noofpatches = iosp.PatchEsIdentify();
                                if (noofpatches > 0)
                                {
                                    WriteStatus(" - Patched in ES_Identify:", infocolor);
                                    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", errorcolor);
                                break;
                            case "NAND permissions":
                                noofpatches = iosp.PatchNandPermissions();
                                if (noofpatches > 0)
                                {
                                    WriteStatus(" - Patched in NAND permissions:", infocolor);
                                    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", errorcolor);
                                break;
                        }
                    }
                    else {
                    //    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)), infocolor);
                    }
                    catch (Exception ex)
                    {
                        WriteStatus(String.Format("Couldn't save patched WAD: \"{0}\" :(",ex.Message), errorcolor);
                    }
                }
            }

            WriteStatus("NUS Download Finished.");

        }
Beispiel #2
0
        private void nus_downloadthread_DoWork(object sender, DoWorkEventArgs e) {
            WriteStatus(uwiz_langtext[45]); // "Starting NUS Download. Please be patient!"

            // WebClient configuration
            System.Net.WebClient nusWC = new System.Net.WebClient();

            // Create\Configure NusClient
            nusClient = new libWiiSharp.NusClient();
            nusClient.ConfigureNusClient(nusWC);
            nusClient.UseLocalFiles = true;
            nusClient.ContinueWithoutTicket = true;

            nusClient.SetToWiiServer();

            // Events
            nusClient.Debug += new EventHandler<libWiiSharp.MessageEventArgs>(nusClient_Debug);

            libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[3];
            storeTypes[0] = libWiiSharp.StoreType.Empty;
            storeTypes[1] = libWiiSharp.StoreType.Empty;
            storeTypes[2] = libWiiSharp.StoreType.EncryptedContent;

            nusClient.pbs = nus_pbarsingle;
            nusClient.pbt = nus_pbartotal;

            nusClient.cancelnusd = false;

            try {
                nusClient.DownloadTitle(nus_titleid.Text, nus_titlever.Text, System.IO.Path.Combine(Environment.CurrentDirectory, "nus_content"), "", storeTypes);
                e.Result = true;
                WriteStatus(uwiz_langtext[46]); // "NUS Download Finished."
            } catch (Exception ex) {
                WriteStatus(uwiz_langtext[47] + "\"" + ex.Message + "\""); // "Download failed: \"" + ex.Message + "\""
                e.Result = false;
            }
        }
Beispiel #3
0
        private void RunScript(string scriptstr, string scriptname)
        {
            // Form and folder stuffs
            SetTextThreadSafe(statusbox, "");
            WriteStatus("Starting script download. Please be patient!");
            string scriptdir;
            if (scriptname == "random")
                scriptdir = Path.Combine(Path.Combine(CURRENT_DIR, "scripts"), RandomString(7) + "_output");
            else
                scriptdir = Path.Combine(Path.Combine(CURRENT_DIR, "scripts"), scriptname + "_output");

            if (!File.Exists(scriptdir))
                Directory.CreateDirectory(scriptdir);

            // Parse entries
            string[] NUS_Entries = scriptstr.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            
            WriteStatus(String.Format(" - Script loaded ({0} Titles)", NUS_Entries.Length));
            WriteStatus(" - Output: " + scriptdir.Replace(CURRENT_DIR, ""));

            for (int a = 0; a < NUS_Entries.Length; a++)
            {
                // Download the title
                WriteStatus(String.Format("===== Running Download ({0}/{1}) =====", a + 1, NUS_Entries.Length));
                string[] title_info = NUS_Entries[a].Split(' ');
                // don't let the delete issue reappear...
                if (string.IsNullOrEmpty(title_info[0]))
                    continue;

                // WebClient configuration
                WebClient nusWC = new WebClient();
                nusWC = ConfigureWithProxy(nusWC);
                nusWC.Headers.Add("User-Agent", "wii libnup/1.0"); // Set UserAgent to Wii value

                // Create\Configure NusClient
                libWiiSharp.NusClient nusClient = new libWiiSharp.NusClient();
                nusClient.ConfigureNusClient(nusWC);
                nusClient.UseLocalFiles = localuse.Checked;
                nusClient.ContinueWithoutTicket = true;
                nusClient.Debug += new EventHandler<libWiiSharp.MessageEventArgs>(nusClient_Debug);

                libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[1];
                // There's no harm in outputting everything i suppose
                storeTypes[0] = libWiiSharp.StoreType.All;

                int title_version = int.Parse(title_info[1], System.Globalization.NumberStyles.HexNumber);

                string wadName = NameFromDatabase(title_info[0]);
                if (wadName != null)
                    wadName = OfficialWADNaming(wadName);
                else
                    wadName = title_info[0] + "-NUS-v" + title_version + ".wad";

                nusClient.DownloadTitle(title_info[0], title_version.ToString(), scriptdir, wadName, storeTypes);

            }
            WriteStatus("Script completed!");
        }
Beispiel #4
0
        private void NUSDownloader_DoWork()
        {
            CheckForIllegalCrossThreadCalls = false; // this function would need major rewriting to get rid of this...

            WriteStatus("Starting NUS Download. Please be patient!", infocolor);
            SetEnableforDownload(false);
            downloadstartbtn.Text = "Cancel NUS Download!";

            // WebClient configuration
            WebClient nusWC = new WebClient();

            nusWC = ConfigureWithProxy(nusWC);

            // Create\Configure NusClient
            libWiiSharp.NusClient nusClient = new libWiiSharp.NusClient();
            nusClient.ConfigureNusClient(nusWC);
            nusClient.UseLocalFiles         = localuse.Checked;
            nusClient.ContinueWithoutTicket = true;

            // Server
            if (serverLbl.Text == "Wii")
            {
                nusClient.SetToWiiServer();
            }
            else if (serverLbl.Text == "3DS")
            {
                nusClient.SetToDSiServer();
            }

            // Events
            nusClient.Debug    += new EventHandler <libWiiSharp.MessageEventArgs>(NusClient_Debug);
            nusClient.Progress += new EventHandler <ProgressChangedEventArgs>(NusClient_Progress);

            var empty = libWiiSharp.StoreType.Empty;

            libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[3] {
                empty, empty, empty
            };
            if (decryptbox.Checked)
            {
                storeTypes[1] = libWiiSharp.StoreType.DecryptedContent;
            }
            else
            {
                storeTypes[1] = libWiiSharp.StoreType.Empty;
            }
            if (keepenccontents.Checked)
            {
                storeTypes[2] = libWiiSharp.StoreType.EncryptedContent;
            }
            else
            {
                storeTypes[2] = libWiiSharp.StoreType.Empty;
            }

            try
            {
                nusClient.DownloadTitle(titleidbox.Text, titleversion.Text, CURRENT_DIR, storeTypes);
            }
            catch (Exception ex)
            {
                WriteStatus("Download failed: \"" + ex.Message + "\"", errorcolor);
            }

            WriteStatus("NUS Download Finished.");

            Task.Run(() => NUSDownloader_RunWorkerCompleted());
        }