Пример #1
0
        private void UpdateSTFS(STFSPackage package, byte[] kvData)
        {
            if (package != null)
            {
                // Inject the new mmiof.bmf
                X360.STFS.FileEntry file = package.GetFile(_rawFileName);
                file.Inject(_rawPath);

                if (kvData != null)
                {
                    // Resign the package using the KV data
                    DJsIO kvStream = new DJsIO(kvData, true);
                    package.FlushPackage(new X360.STFS.RSAParams(kvStream));
                    kvStream.Close();
                }
            }
        }
Пример #2
0
        public void LoadSTFS(STFSPackage package, string rawFileName, string extractDir)
        {
            X360.STFS.FileEntry file = package.GetFile(rawFileName);

            // Create the extraction directory
            Directory.CreateDirectory(extractDir);
            string newRawPath = extractDir + rawFileName;

            // Extract the file and close the package
            if (!file.Extract(newRawPath))
            {
                throw new ArgumentException("Unable to extract " + rawFileName + " to \"" + extractDir + "\". Make sure that your save is not corrupt and that you reached a checkpoint first.");
            }

            // Load the mmiof.bmf file into the _saveData object
            _saveData    = _constructSave(newRawPath);
            _rawPath     = newRawPath;
            _rawFileName = rawFileName;
        }
Пример #3
0
 void killachievetab()
 {
     tabControlPanel10.Enabled = true;
     textBoxX4.Text = textBoxX5.Text =
         textBoxX6.Text = textBoxX7.Text = "";
     listBox2.Items.Clear();
     xLoadedEntry = null;
     xLoadedGPD = null;
     buttonX6.Enabled = false;
     pictureBox4.Image = pictureBox3.Image = null;
 }
Пример #4
0
 private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox3.SelectedIndex < 0)
         return;
     tabControl1.Enabled = false;
     buttonX12.Enabled = true;
     TitlePlayedEntry x = xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex];
     try { dateTimePicker3.Value = dateTimePicker4.Value = x.LastLoadedDT; }
     catch { dateTimePicker3.Value = dateTimePicker4.Value = DateTime.Now; }
     textBoxX14.Text = "Unlocked " + x.EarnedCount.ToString() + " of " + x.PossibleCount.ToString();
     textBoxX14.Text += Environment.NewLine + "Total of " + x.EarnedWorth.ToString() + " of " + x.PossibleWorth.ToString();
     string path = x.TitleID.ToString("X").ToUpper() + ".gpd";
     FileEntry xent = xPackage.GetFile(path);
     if (xent == null)
     {
         Log("Error: could not find GPD");
         killachievetab();
         tabControl1.Enabled = true;
         return;
     }
     string xOut = VariousFunctions.GetTempFileLocale();
     if (!xent.Extract(xOut))
     {
         Log("Extraction error");
         killachievetab();
         tabControl1.Enabled = true;
         return;
     }
     GameGPD xload = new GameGPD(xOut, x.TitleID);
     if (!xload.IsValid)
     {
         Log("Error when parsing GPD");
         xload.Close();
         try { VariousFunctions.DeleteFile(xOut); }
         catch { }
         xload = null;
         killachievetab();
         tabControl1.Enabled = true;
         return;
     }
     listBox2.Items.Clear();
     for (int i = 0; i < xload.Achievements.Length; i++)
         listBox2.Items.Add(xload.Achievements[i].Title);
     Image xTitleIMGS = xload.GetImageByID(0x8000);
     if (xTitleIMGS != null)
         pictureBox4.Image = xTitleIMGS;
     else pictureBox4.Image = PublicResources.NoImage;
     string xTitleStrings = xload.GetStringByID(0x8000);
     if (xTitleStrings != null)
         textBoxX4.Text = xTitleStrings;
     else textBoxX4.Text = "Unknown";
     xLoadedGPD = xload;
     xLoadedEntry = xent;
     if (listBox2.Items.Count > 0)
         listBox2.SelectedIndex = 0;
     listBox2_SelectedIndexChanged(null, null);
     buttonX11.Enabled =
     buttonX3.Enabled =
     buttonX10.Enabled =
     tabControl1.Enabled =
     buttonX6.Enabled =
     tabControlPanel10.Enabled = true;
     Log("GPD Loaded");
 }
 /// <summary>
 /// Reads a GPD from the Titles Played index of the User GPD
 /// </summary>
 /// <param name="ID"></param>
 /// <param name="xEntry"></param>
 /// <returns></returns>
 public GameGPD ReadGame(uint ID, out FileEntry xEntry)
 {
     xEntry = null;
     if (!ParseCheck())
         return null;
     if (UserGPD == null)
         return null;
     FileEntry x = GetFile(ID.ToString("X") + ".gpd");
     if (x == null)
         return null;
     DJsIO y = x.GetTempIO(true);
     if (y == null || !y.Accessed)
     {
         y.Close();
         VariousFunctions.DeleteFile(y.FileNameLong);
         return null;
     }
     y.Close();
     GameGPD z = new GameGPD(y.FileNameLong, ID);
     if (z.IsValid)
     {
         xEntry = x;
         return z;
     }
     return null;
 }
 /// <summary>
 /// Adds a file to the package
 /// </summary>
 /// <param name="xIOIn"></param>
 /// <param name="xFileName"></param>
 /// <param name="Folder"></param>
 /// <returns></returns>
 bool xAddFile(DJsIO xIOIn, string xFileName, ushort Folder)
 {
     try
     {
         if (xIOIn == null || !xIOIn.Accessed || xIOIn.Length > ((xSTFSStruct.SpaceBetween[2] - 1) << 0xC))
             return (xActive = false);
         foreach (FileEntry m in xFileDirectory)
         {
             if (m.FolderPointer == Folder && m.Name == xFileName)
                 return (xActive = false);
         }
         // Allocates blocks
         AddToLog("Allocating blocks");
         BlockRecord[] xEntAlloc = xAllocateBlocks(xNewEntBlckCnt(1), 0);
         BlockRecord[] xFileAlloc = xAllocateBlocks(xIOIn.BlockCountSTFS(), xEntAlloc[xEntAlloc.Length - 1].ThisBlock + 1);
         // Adds new file info
         AddToLog("Adding file information");
         ItemEntry x = new ItemEntry(xFileName, (int)xIOIn.Length, false, (ushort)(xFileDirectory.Count + xFolderDirectory.Count), Folder, this);
         FileEntry y = new FileEntry(x);
         y.xStartBlock = xFileAlloc[0].ThisBlock;
         xFileDirectory.Add(y);
         return xDoAdd(ref xIOIn, ref xEntAlloc, ref xFileAlloc);
     }
     catch (Exception x) { return (xActive = false); throw x; }
 }
 internal FileEntry Copy()
 {
     FileEntry x = new FileEntry(this);
     x.xBlocks = xBlocks;
     return x;
 }
        bool xAddFile(byte[] data, string xFileName, ushort Folder)
        {
            //try
            {

                foreach (FileEntry m in xFileDirectory)
                {
                    if (m.FolderPointer == Folder && m.Name == xFileName)
                        return (xActive = false);
                }
                // Allocates blocks
                //AddToLog("Allocating blocks");
                BlockRecord[] xEntAlloc = xAllocateBlocks(xNewEntBlckCnt(1), 0);
                BlockRecord[] xFileAlloc = xAllocateBlocks(FileEntry.BlockCountSTFS(data), xEntAlloc[xEntAlloc.Length - 1].ThisBlock + 1);
                // Adds new file info
                //AddToLog("Adding file information");
                ItemEntry x = new ItemEntry(xFileName, (int)data.Length, false, (ushort)(xFileDirectory.Count + xFolderDirectory.Count), Folder, this);
                FileEntry y = new FileEntry(x);
                y.xStartBlock = xFileAlloc[0].ThisBlock;
                xFileDirectory.Add(y);
                return xDoAdd(data, ref xEntAlloc, ref xFileAlloc);
            }
            //catch (Exception x) { return (xActive = false); throw x; }
        }
        public PackageFile(PackageFolder folder, FileEntry file, bool readData = true, Package pk = null)
        {
            this.FileEntry = file;
            this.Folder = folder;
            this.Package = pk;

                this.data = file.ExtractBytes(readData);
        }