예제 #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            var success = true;

            xPackage.Header.ThisType = radioCON.Checked ? PackageType.SavedGame : PackageType.MarketPlace;
            xPackage.Header.MakeAnonymous();

            try
            {
                Log("Rebuilding CON file ... this might take a little while");
                var signature = radioCON.Checked ? new RSAParams(System.IO.Path.Combine(Application.StartupPath, "bin/KV.bin")) : new RSAParams(StrongSigned.LIVE);
                xPackage.RebuildPackage(signature);
                xPackage.FlushPackage(signature);
                xPackage.CloseIO();
            }
            catch
            {
                Log("Something went wrong with trying to rebuild CON file");
                success = false;
            }

            if (success)
            {
                Log("Trying to unlock CON file");
                if (Tools.UnlockCON(folder))
                {
                    Log("Unlocked CON file successfully");
                }
                else
                {
                    Log("Error unlocking CON file");
                    success = false;
                }
            }

            if (success)
            {
                //convert to CON if button checked, if not, leave as LIVE
                if (!radioCON.Checked)
                {
                    return;
                }
                Log("Trying to sign CON file");
                if (Tools.SignCON(folder))
                {
                    Log("CON file signed successfully");
                }
                else
                {
                    Log("Error signing CON file");
                    Log("If you just extracted CON file, this is a known bug");
                    Log("Close this form, open the song again, and try again.");
                    FailedSign = true;
                }
            }
            else
            {
                FailedSign = true;
            }
        }
예제 #2
0
        private bool makeCON(string rba)
        {
            if (backgroundWorker1.CancellationPending)
            {
                return(false);
            }
            var con = txtFolder.Text + "\\" + Path.GetFileNameWithoutExtension(rba).Replace("_rb3con", "") + "_rb3con";

            Tools.DeleteFile(con);
            var xsession = new CreateSTFS {
                HeaderData = { TitleID = 0x45410914 }
            };

            xsession.HeaderData.Title_Package = "Rock Band 3";
            xsession.HeaderData.SetLanguage(Languages.English);
            xsession.HeaderData.Publisher          = "";
            xsession.STFSType                      = STFSType.Type0;
            xsession.HeaderData.ThisType           = PackageType.SavedGame;
            xsession.HeaderData.PackageImageBinary = rB3IconTool.Checked || string.IsNullOrWhiteSpace(thumbnail) || !File.Exists(thumbnail) ?
                                                     Resources.RB3.ImageToBytes(ImageFormat.Png) : Tools.NemoLoadImage(thumbnail).ImageToBytes(ImageFormat.Png);
            xsession.HeaderData.ContentImageBinary = Resources.RB3.ImageToBytes(ImageFormat.Png);
            xsession.HeaderData.MakeAnonymous();
            var bOk = PackageCheckFiles(xsession);

            if (bOk)
            {
                bOk = PackageCreate(con, xsession);
            }
            if (bOk)
            {
                bOk = Tools.UnlockCON(con);
            }
            if (!bOk)
            {
                return(false);
            }
            Tools.SignCON(con);
            return(true);
        }
예제 #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            xsession.HeaderData.ContentImageBinary = picContent.Image.ImageToBytes(ImageFormat.Png);
            xsession.HeaderData.PackageImageBinary = picPackage.Image.ImageToBytes(ImageFormat.Png);
            switch (GameIndex)
            {
            case 0:
                xsession.HeaderData.TitleID = 0x45410829;
                break;

            case 1:
                xsession.HeaderData.TitleID = 0x45410869;
                break;

            case 2:
                xsession.HeaderData.TitleID = 0x45410914;
                break;
            }
            xsession.HeaderData.Publisher     = "";
            xsession.HeaderData.Title_Package = "Rock Band " + (GameIndex + 1);
            xsession.HeaderData.SetLanguage(Languages.English);
            xsession.HeaderData.Title_Display = Title;
            xsession.HeaderData.Description   = Description;
            xsession.STFSType = STFSType.Type0;
            xsession.HeaderData.MakeAnonymous();
            xsession.HeaderData.ThisType = radioCON.Checked ? PackageType.SavedGame : PackageType.MarketPlace;
            signature = radioCON.Checked ? new RSAParams(Application.StartupPath + "\\bin\\KV.bin") : new RSAParams(StrongSigned.LIVE);
            var xy = new STFSPackage(xsession, signature, xOut);

            xy.CloseIO();
            //now open and unlock
            if (!Tools.UnlockCON(xOut))
            {
                MessageBox.Show("There was an error unlocking CON file\nCan't finish", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //convert to CON if button checked, if not, leave as LIVE
            if (!radioCON.Checked)
            {
                return;
            }
            if (!Tools.SignCON(xOut))
            {
                MessageBox.Show("There was an error signing CON file\nCan't finish", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            if (!File.Exists(orig_con))
            {
                Log("CON file " + Path.GetFileName(orig_con) + " seems to have been deleted, can't continue without it");
                return;
            }

            var BundleFile = orig_con + " (bundled)";

            Tools.DeleteFile(BundleFile);
            File.Copy(orig_con, BundleFile);


            var xPackage = new STFSPackage(BundleFile);

            if (!xPackage.ParseSuccess)
            {
                Log("There was an error parsing CON file to bundle");
                xPackage.CloseIO();
                return;
            }

            var xent = xPackage.GetFile("/songs/songs.dta");

            if (xent != null)
            {
                if (xent.Replace(newDTA))
                {
                    Log("Bundled DTA file successfully");
                }
            }

            xent = xPackage.GetFile("/songs/" + Path.GetFileNameWithoutExtension(orig_midi) + "/" + Path.GetFileName(orig_midi));
            if (xent != null)
            {
                if (xent.Replace(newMIDI))
                {
                    Log("Bundled MIDI file successfully");
                }
            }

            xPackage.Header.MakeAnonymous();
            xPackage.Header.ThisType = PackageType.SavedGame;

            var success = false;

            try
            {
                Log("Rebuilding CON file ... this might take a little while");
                signature = new RSAParams(Application.StartupPath + "\\bin\\KV.bin");
                if (ChangeGameID.Checked)
                {
                    xPackage.Header.TitleID            = 0x45410914;
                    xPackage.Header.Title_Package      = "Rock Band 3";
                    xPackage.Header.ContentImageBinary = Resources.RB3.ImageToBytes(ImageFormat.Png);
                }
                xPackage.RebuildPackage(signature);
                xPackage.FlushPackage(signature);
                xPackage.CloseIO();
                success = true;
            }
            catch (Exception ex)
            {
                Log("There was an error: " + ex.Message);
                xPackage.CloseIO();
            }

            if (success)
            {
                Log("Trying to unlock CON file");
                if (Tools.UnlockCON(BundleFile))
                {
                    Log("Unlocked CON file successfully");
                }
                else
                {
                    Log("Error unlocking CON file");
                    success = false;
                }
            }

            if (success)
            {
                Log("Trying to sign CON file");
                if (Tools.SignCON(BundleFile))
                {
                    Log("CON file signed successfully");
                }
                else
                {
                    Log("Error signing CON file");
                    success = false;
                }
            }

            Log(success ? "Your files were bundled successfully!" : "Something went wrong along the way, sorry!");

            if (!cleanUpAfterBundlingFiles.Checked)
            {
                return;
            }
            Log("Cleaning up");
            CleanUp();
        }
예제 #5
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            foreach (var file in FilesToConvert)
            {
                if (backgroundWorker1.CancellationPending)
                {
                    return;
                }
                var replaced = 0;
                try
                {
                    var xFile = new STFSPackage(file);
                    if (!xFile.ParseSuccess)
                    {
                        ProblemFiles.Add(file);
                        continue;
                    }

                    var xent = xFile.GetFile("/songs/songs.dta");
                    if (xent == null)
                    {
                        xFile.CloseIO();
                        ProblemFiles.Add(file);
                        continue;
                    }

                    var dta1 = Application.StartupPath + "\\bin\\dta1.txt";
                    Tools.DeleteFile(dta1);

                    if (!xent.Extract(dta1))
                    {
                        xFile.CloseIO();
                        ProblemFiles.Add(file);
                        continue;
                    }

                    var dta2 = Application.StartupPath + "\\bin\\dta2.txt";
                    Tools.DeleteFile(dta2);

                    var sr = new StreamReader(dta1, Encoding.Default);
                    var sw = new StreamWriter(dta2, false, Encoding.Default);
                    while (sr.Peek() >= 0)
                    {
                        var line = sr.ReadLine();
                        if (string.IsNullOrEmpty(line.Trim()))
                        {
                            continue;
                        }

                        if (line.Contains(";ORIG_ID="))
                        {
                            if (DoReverseBatch)
                            {
                                var id = line.Replace(";", "").Replace("ORIG_ID=", "").Trim();
                                sw.WriteLine("   ('song_id' " + id + ")");
                                sr.ReadLine();//skip the old song_id line
                                line = sr.ReadLine();
                                TotalSongs++;
                                replaced++;
                            }
                            else
                            {
                                sw.WriteLine(line);
                                line = sr.ReadLine();
                                sw.WriteLine(line);
                                line = sr.ReadLine();
                            }
                        }
                        else if (line.Contains("song_id") && !DoReverseBatch)
                        {
                            if (!Parser.IsNumericID(line))
                            {
                                line = ";ORIG_ID=" + Parser.GetSongID(line);
                                sw.WriteLine(line);
                                line = "   ('song_id' " + mMainForm.GetNumericID() + ")";
                                TotalSongs++;
                                replaced++;
                            }
                            else
                            {
                                SkippedFiles.Add(file);
                            }
                        }

                        if (!string.IsNullOrEmpty(line.Trim()))
                        {
                            sw.WriteLine(line);
                        }
                    }
                    sr.Dispose();
                    sw.Dispose();

                    if (replaced == 0) //don't modify this CON file if nothing is edited in this DTA file
                    {
                        if (!SkippedFiles.Contains(file))
                        {
                            SkippedFiles.Add(file);
                        }
                        xFile.CloseIO();
                        continue;
                    }

                    if (backgroundWorker1.CancellationPending)
                    {
                        xFile.CloseIO();
                        return;
                    }
                    if (!xent.Replace(dta2))
                    {
                        xFile.CloseIO();
                        ProblemFiles.Add(file);
                        continue;
                    }

                    Tools.DeleteFile(dta1);
                    Tools.DeleteFile(dta2);

                    xFile.Header.MakeAnonymous();
                    xFile.Header.ThisType = PackageType.SavedGame;
                    var signature = new RSAParams(Application.StartupPath + "\\bin\\KV.bin");
                    xFile.RebuildPackage(signature);
                    xFile.FlushPackage(signature);
                    xFile.CloseIO();
                    Tools.UnlockCON(file);
                    Tools.SignCON(file);
                    xFile.CloseIO();
                }
                catch (Exception)
                {
                    ProblemFiles.Add(file);
                }
            }
        }
예제 #6
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Tools.CurrentFolder = Path.GetDirectoryName(con);
            Log("Reading CON file " + Path.GetFileName(con));

            var dta    = Path.GetTempPath() + "temp_dta.txt";
            var backup = con + "_backup";

            Tools.DeleteFile(backup);

            if (!Parser.ExtractDTA(con))//grab byte[] content of DTA
            {
                Log("Error extracting DTA file");
                ErrorOut();
                return;
            }
            if (!Parser.WriteDTAToFile(dta)) //write it out to file
            {
                Log("Error extracting DTA file");
                ErrorOut();
                return;
            }

            var song = new STFSPackage(con);

            if (backUpCONFile.Checked)
            {
                Log("Found songs.dta file, making a backup of your file before starting");
                Log("THIS STEP MAY TAKE A WHILE. DON'T CLOSE ME DOWN!");

                song.CloseIO();
                File.Copy(con, backup);
                song = new STFSPackage(con);
            }

            var xDTA = song.GetFile("/songs/songs.dta");

            Log("Opening DTA file...");

            var process = Process.Start(dta);

            Log("DTA file is being edited by the user ... waiting...");

            do
            {
                //wait while user has DTA file opened
            } while (!process.HasExited);

            process.Dispose();

            Log("DTA file closed by user, continuing...");
            Log("Replacing old DTA file with modified DTA file");
            Log("THIS STEP MAY TAKE A WHILE. DON'T CLOSE ME DOWN!");

            if (!xDTA.Replace(dta))
            {
                Log("Error replacing DTA file with modified one");
                Tools.DeleteFile(backup);
                ErrorOut();
                return;
            }

            Log("Replaced DTA file successfully");
            song.Header.MakeAnonymous();
            song.Header.ThisType = PackageType.SavedGame;

            var success = false;

            try
            {
                Log("Saving changes to pack ... sit tight");
                Log("THIS STEP MAY TAKE A WHILE. DON'T CLOSE ME DOWN!");

                signature = new RSAParams(Application.StartupPath + "\\bin\\KV.bin");
                song.RebuildPackage(signature);
                song.FlushPackage(signature);
                song.CloseIO();
                success = true;
            }
            catch (Exception ex)
            {
                Log("There was an error: " + ex.Message);
                song.CloseIO();
            }

            if (success)
            {
                Log("Trying to unlock CON file");
                if (Tools.UnlockCON(con))
                {
                    Log("Unlocked CON file successfully");
                }
                else
                {
                    Log("Error unlocking CON file");
                    success = false;
                }
            }

            if (success)
            {
                if (Tools.SignCON(con))
                {
                    Log("CON file signed successfully");
                }
                else
                {
                    Log("Error signing CON file");
                    success = false;
                }
            }

            Tools.DeleteFile(dta);

            Log(success ? "Process completed successfully!" : "Something went wrong along the way, sorry!");
            if (success)
            {
                return;
            }
            if (!backUpCONFile.Checked)
            {
                return;
            }
            Log("Restoring backup file");
            Tools.DeleteFile(con);
            Log(Tools.MoveFile(backup, con) ? "Backup file restored successfully, nothing was lost" : "Sorry, there was an error restoring the backup file");
        }
예제 #7
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            sOpenPackage = "";

            try
            {
                var files = Directory.GetFiles(txtFolder.Text);
                if (files.Count() != 0)
                {
                    if (!extractRBFiles())
                    {
                        Log("There was an error extracting the files ... stopping here");
                        return;
                    }
                }
                else
                {
                    Log("No new files found and no existing directory found ... there's nothing to do");
                    backgroundWorker1.CancelAsync();
                    return;
                }
            }
            catch
            {
                Log("Error retrieving files to extract");
            }

            var success = false;

            if (backgroundWorker1.CancellationPending)
            {
                goto Finish;
            }

            //check if the CON/LIVE files were actually RB songs or not
            //if not, end
            var isRbSong = Directory.Exists(tempFolder + "songs\\");

            if (!isRbSong)
            {
                Log("I can't find a 'songs' folder in the extracted files");
                Log("Are you sure these are Rock Band songs?");
                Log("Check the files and try again");
                return;
            }

            Log("Beginning to add the files");

            packfiles.HeaderData.TitleID       = 0x45410914;
            packfiles.HeaderData.Title_Package = "Rock Band 3";
            packfiles.HeaderData.SetLanguage(Languages.English);
            packfiles.HeaderData.Publisher          = "";
            packfiles.STFSType                      = STFSType.Type0;
            packfiles.HeaderData.ThisType           = PackageType.SavedGame;
            packfiles.HeaderData.Title_Display      = txtTitle.Text;
            packfiles.HeaderData.Description        = "Created with C3 CON Tools for video recording purposes ONLY.";
            packfiles.HeaderData.ContentImageBinary = Resources.RB3.ImageToBytes(ImageFormat.Png);
            packfiles.HeaderData.PackageImageBinary = Resources.RB3.ImageToBytes(ImageFormat.Png);
            packfiles.HeaderData.MakeAnonymous();

            songsFolder = tempFolder + "songs\\";
            success     = addFiles();
            if (success)
            {
                Log("All set, going to try to build the pack for you");
                Log("This may take a while, depending on how many songs");
                Log("Unless you get an error or I crash, assume that I'm working!");

                success = buildPackage();
            }

            if (success)
            {
                Log("Trying to unlock CON file");
                if (Tools.UnlockCON(xOut))
                {
                    Log("Unlocked CON file successfully");
                }
                else
                {
                    Log("Error unlocking CON file");
                    success = false;
                }
            }

            if (success)
            {
                Log("Trying to sign CON file");
                if (Tools.SignCON(xOut))
                {
                    Log("CON file signed successfully");
                }
                else
                {
                    Log("Error signing CON file");
                    success = false;
                }
            }

Finish:
            Log("Deleting temporary folder");
            if (Directory.Exists(tempFolder))
            {
                try
                {
                    Tools.SendtoTrash(tempFolder, true);   //send files to recycle bin
                    Directory.CreateDirectory(tempFolder); //restore empty extracted folder (requested by C16)
                }
                catch
                {
                    Log("Error deleting temporary folder");
                }
            }

            if (success)
            {
                Log("Done!");
                endTime = DateTime.Now;
                var timeDiff = endTime - startTime;
                Log("Process took " + timeDiff.Minutes + (timeDiff.Minutes == 1 ? " minute" : " minutes") + " and " + (timeDiff.Minutes == 0 && timeDiff.Seconds == 0 ? "1 second" : timeDiff.Seconds + " seconds"));
                Log("You can click View Package to close this form");
                Log("and open the new pack in CON Explorer");
                Log("Click reset to start again and create a new pack,");
                Log("or just close me down and enjoy your new pack!");

                sOpenPackage = xOut;
            }
            else
            {
                Log("Something went wrong and your pack was NOT created, sorry!");
            }
        }