public static void BuildXBox360Package(string songFileName, DLCPackageData info, IEnumerable<string> xboxFiles, GameVersion gameVersion, DLCPackageType dlcType = DLCPackageType.Song)
        {
            LogRecord x = new LogRecord();
            RSAParams xboxRSA = info.SignatureType == PackageMagic.CON ? new RSAParams(new DJsIO(Resources.XBox360_KV, true)) : new RSAParams(StrongSigned.LIVE);
            CreateSTFS xboxSTFS = new CreateSTFS();
            xboxSTFS.HeaderData = info.GetSTFSHeader(gameVersion, dlcType);
            foreach (string file in xboxFiles)
                xboxSTFS.AddFile(file, Path.GetFileName(file));

            STFSPackage xboxPackage = new STFSPackage(xboxSTFS, xboxRSA, songFileName, x);
            var generated = xboxPackage.RebuildPackage(xboxRSA);
            if (!generated)
                throw new InvalidOperationException("Error on create XBox360 package, details: \n" + x.Log);

            xboxPackage.FlushPackage(xboxRSA);
            xboxPackage.CloseIO();

            DirectoryExtension.SafeDelete(XBOX_WORKDIR);
        }
        public static void BuildXBox360Package(string packagePath, DLCPackageData info, IEnumerable<string> xboxFiles, PackageMagic? xboxPackageType)
        {
            LogRecord x = new LogRecord();
            RSAParams xboxRSA = xboxPackageType == PackageMagic.CON ? new RSAParams(new DJsIO(Resources.XBox360_KV, true)) : new RSAParams(StrongSigned.LIVE);
            CreateSTFS xboxSTFS = new CreateSTFS();
            xboxSTFS.HeaderData = info.GetSTFSHeader();
            foreach (string file in xboxFiles)
                xboxSTFS.AddFile(file, Path.GetFileName(file));

            STFSPackage xboxPackage = new STFSPackage(xboxSTFS, xboxRSA, packagePath, x);
            var generated = xboxPackage.RebuildPackage(xboxRSA);
            if (!generated)
                throw new InvalidOperationException("Error on create XBox360 package, details: \n\r" + x.Log);

            xboxPackage.FlushPackage(xboxRSA);
            xboxPackage.CloseIO();

            try
            {
                if (Directory.Exists(xboxWorkDir))
                    Directory.Delete(xboxWorkDir, true);
            }
            catch { /*Have no problem if don't delete*/ }
        }
Ejemplo n.º 3
0
 void fix(int i)
 {
     STFSPackage x = null;
     try { x = new STFSPackage((string)listBox1.Items[i], null); }
     catch { }
     if (x != null)
     {
         if (x.ParseSuccess)
         {
             if (checkBoxX1.Checked)
                 x.Header.MakeAnonymous();
             if (checkBoxX2.Checked)
                 x.FlushPackage(par.PublicKV);
             else x.UpdateHeader(par.PublicKV);
         }
         x.CloseIO();
     }
 }
Ejemplo n.º 4
0
        private void BuildXboxPackage(string packageFileName, string saveFileName)
        {
            CreateSTFS Package = new CreateSTFS();

            Package.STFSType = STFSType.Type1;
            Package.HeaderData.ProfileID = CurrentWSG.ProfileID;
            Package.HeaderData.DeviceID = CurrentWSG.DeviceID;

            Assembly newAssembly = Assembly.GetExecutingAssembly();
            Stream WT_Icon = newAssembly.GetManifestResourceStream("WillowTree.Resources.WT_CON.png");

            Package.HeaderData.ContentImage = System.Drawing.Image.FromStream(WT_Icon);
            Package.HeaderData.Title_Display = CurrentWSG.CharacterName + " - Level " + CurrentWSG.Level + " - " + CurrentLocation.Text;
            Package.HeaderData.Title_Package = "Borderlands";
            Package.HeaderData.TitleID = 1414793191;
            Package.AddFile(saveFileName, "SaveGame.sav");

            STFSPackage CON = new STFSPackage(Package, new RSAParams(AppDir + "\\Data\\KV.bin"), packageFileName, new X360.Other.LogRecord());

            CON.FlushPackage(new RSAParams(AppDir + "\\Data\\KV.bin"));
            CON.CloseIO();
            WT_Icon.Close();
        }
        ///////////////////////////////////////////
        //SPITFIRE1337 MODS
        ///////////////////////////////////////////
        public IEnumerable<IResult> WriteSaveXbox()
        {
            if (this.SaveFile == null)
            {
                yield break;
            }

            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            File.Delete(path + "/savegame.sav");

            //MessageBox.Show("A save file box will now appear, please select a EXISTING XBOX SAVE to overwrite. I can not emphasize this enough, ALWAYS KEEP A WORKING BACKUP. Once you have a backup press ok to continue");

            var saveFile = this.SaveFile;

            yield return new DelegateResult(() =>
            {
                Endian endian;
                this.General.ExportData(saveFile.SaveGame, out endian);
                this.CurrencyOnHand.ExportData(saveFile.SaveGame);
                this.Backpack.ExportData(saveFile.SaveGame);
                this.Bank.ExportData(saveFile.SaveGame);


                using (var output = File.Create(path + "/savegame.sav"))
                {
                    saveFile.Endian = endian;
                    saveFile.Serialize(output);
                }
            }).Rescue().Execute(
    x =>
    new MyMessageBox("An exception was thrown (press Ctrl+C to copy this text):\n\n" + x.ToString(), "Error")
        .WithIcon(MessageBoxImage.Error).AsCoroutine());

            string fileName = null;

            MySaveFileResult ofr;

            ofr = new MySaveFileResult()
                .PromptForOverwrite()
                .FilterFiles(
                    ffc => ffc.AddFilter("sav", true)
                               .WithDescription("Borderlands 2 Save Files")
                               .AddAllFilesFilter())
                .WithFileDo(s => fileName = s);

            if (string.IsNullOrEmpty(this._SavePath) == false &&
                Directory.Exists(this._SavePath) == true)
            {
                ofr = ofr.In(this._SavePath);
            }

            yield return ofr;

            if (fileName == null)
            {
                yield break;
            }
            if (File.Exists(fileName))
            {

                File.WriteAllBytes(fileName, Properties.Resources.Save0001);
            }
            else
            {
                File.Delete(fileName);
                File.WriteAllBytes(fileName, Properties.Resources.Save0001);
            }
            yield return new DelegateResult(() =>
            {


                string profileid = this.General.Profileid;
                DJsIO io = new DJsIO(fileName, DJFileMode.Open, true);

                io.Position = 0x371;
                io.WriteHexString(profileid);
                io.Close();
            }).Rescue().Execute(
                x =>
                new MyMessageBox("An exception was thrown (press Ctrl+C to copy this text):\n\n" + x.ToString(), "Error")
                    .WithIcon(MessageBoxImage.Error).AsCoroutine());
            yield return new DelegateResult(() =>
            {

                STFSPackage stfs = new STFSPackage(fileName, null);
                FileEntry item = stfs.GetFile("savegame.sav"); //Get's the account file



                if (!item.Replace(path + "\\savegame.sav"))
                {
                    //If Not xent.Extract(Application.StartupPath + "\" + "savegame.sav") Then
                    //MessageBoxEx.Show("Extraction Failed!", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                    throw new Exception("Failed to insert save file to xbox save. Please use a program like modio or horizon to insert your save");

                }
                else
                {
                    //MessageBox.Show("File Inserted");

                    //If Not  Then

                    //End If
                    //MessageBoxEx.Show("Extraction Complete!", "Complete!", MessageBoxButtons.OK, MessageBoxIcon.Information)
                }
                if (!File.Exists(path + "/kv.bin"))
                {
                    File.WriteAllBytes(path + "/kv.bin", Properties.Resources.KV);
                }



                stfs.FlushPackage(new RSAParams(path + "/kv.bin"));
                stfs.CloseIO();

            }).Rescue().Execute(
                x =>
                new MyMessageBox("An exception was thrown (press Ctrl+C to copy this text):\n\n" + x.ToString(), "Error")
                    .WithIcon(MessageBoxImage.Error).AsCoroutine());
        }