示例#1
0
        private void sfoFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var sfo  = new LibOrbisPkg.SFO.ParamSfo();
            var view = new Views.SFOView(sfo);

            OpenTab(view, "New file");
        }
示例#2
0
        public PkgView(IFile pkgFile)
        {
            InitializeComponent();
            if (pkgFile == null)
            {
                return;
            }
            this.pkgFile = pkgFile;
            using (var s = pkgFile.GetStream())
                ObjectPreview(new PkgReader(s).ReadHeader());
            using (var s = pkgFile.GetStream())
                pkg = new PkgReader(s).ReadPkg();
            var sfoEditor = new SFOView(pkg.ParamSfo.ParamSfo, true);

            sfoEditor.Dock = DockStyle.Fill;
            tabPage1.Controls.Add(sfoEditor);

            ekpfs = pkg.GetEkpfs();
            ReopenFileView();

            foreach (var e in pkg.Metas.Metas)
            {
                var lvi = new ListViewItem(new[] {
                    e.id.ToString(),
                    string.Format("0x{0:X}", e.DataSize),
                    string.Format("0x{0:X}", e.DataOffset),
                    e.Encrypted ? "Yes" : "No",
                    e.KeyIndex.ToString(),
                });
                lvi.Tag = e;
                entriesListView.Items.Add(lvi);
            }
        }
示例#3
0
        public PkgView(string path)
        {
            InitializeComponent();
            if (path == null)
            {
                return;
            }
            pkgFile = MemoryMappedFile.CreateFromFile(path);
            using (var s = pkgFile.CreateViewStream())
                ObjectPreview(new PkgReader(s).ReadHeader(), pkgHeaderTreeView);
            using (var s = pkgFile.CreateViewStream())
                pkg = new PkgReader(s).ReadPkg();
            try
            {
                using (var s = pkgFile.CreateViewStream((long)pkg.Header.pfs_image_offset, (long)pkg.Header.pfs_image_size))
                    ObjectPreview(PfsHeader.ReadFromStream(s), pfsHeaderTreeView);
            }
            catch (Exception e)
            {
                pkgHeaderTabControl.TabPages.Remove(outerPfsHeaderTabPage);
                MessageBox.Show("Error loading outer PFS: " + e.Message + Environment.NewLine + "Please report this issue at https://github.com/maxton/LibOrbisPkg/issues");
            }
            if (pkg.Metas.Metas.Where(entry => entry.id == EntryId.ICON0_PNG).FirstOrDefault() is MetaEntry icon0)
            {
                using (var s = pkgFile.CreateViewStream(icon0.DataOffset, icon0.DataSize))
                {
                    pictureBox1.Image = Image.FromStream(s);
                }
            }
            contentIdTextBox.Text = pkg.Header.content_id;
            titleTextBox.Text     = pkg.ParamSfo.ParamSfo["TITLE"]?.ToString();
            sizeLabel.Text        = FileView.HumanReadableFileSize((long)pkg.Header.package_size);
            var category = pkg.ParamSfo.ParamSfo["CATEGORY"].ToString();

            typeLabel.Text    = SFOView.SfoTypes.Where(x => x.Category == category).FirstOrDefault() is SFOView.SfoType t ? t.Description : "Unknown";
            versionLabel.Text = pkg.ParamSfo.ParamSfo["VERSION"]?.ToString();
            if (pkg.ParamSfo.ParamSfo["APP_VER"] is Utf8Value v)
            {
                appVerLabel.Text = v.Value;
            }
            else
            {
                appVerLabelLabel.Visible = false;
                appVerLabel.Visible      = false;
            }
            var sfoEditor = new SFOView(pkg.ParamSfo.ParamSfo, true);

            sfoEditor.Dock = DockStyle.Fill;
            tabPage1.Controls.Add(sfoEditor);


            if (pkg.CheckPasscode("00000000000000000000000000000000"))
            {
                passcode = "00000000000000000000000000000000";
                ekpfs    = Crypto.ComputeKeys(pkg.Header.content_id, passcode, 1);
            }
            else
            {
                ekpfs = pkg.GetEkpfs();
            }
            ReopenFileView();

            foreach (var e in pkg.Metas.Metas)
            {
                var lvi = new ListViewItem(new[] {
                    e.id.ToString(),
                    string.Format("0x{0:X}", e.DataSize),
                    string.Format("0x{0:X}", e.DataOffset),
                    e.Encrypted ? "Yes" : "No",
                    e.KeyIndex.ToString(),
                });
                lvi.Tag = e;
                entriesListView.Items.Add(lvi);
            }
        }
示例#4
0
        public PkgView(string path)
        {
            InitializeComponent();
            if (path == null)
            {
                return;
            }
            pkgFile = MemoryMappedFile.CreateFromFile(path, FileMode.Open, "pkgFile" + idx++, 0, MemoryMappedFileAccess.Read);
            using (var s = pkgFile.CreateViewStream(0, 0, MemoryMappedFileAccess.Read))
                ObjectPreview(new PkgReader(s).ReadHeader(), pkgHeaderTreeView);
            using (var s = pkgFile.CreateViewStream(0, 0, MemoryMappedFileAccess.Read))
                pkg = new PkgReader(s).ReadPkg();
            try
            {
                using (var s = pkgFile.CreateViewStream((long)pkg.Header.pfs_image_offset, (long)pkg.Header.pfs_image_size, MemoryMappedFileAccess.Read))
                    ObjectPreview(PfsHeader.ReadFromStream(s), pfsHeaderTreeView);
            }
            catch (Exception e)
            {
                pkgHeaderTabControl.TabPages.Remove(outerPfsHeaderTabPage);
                MessageBox.Show("Error loading outer PFS: " + e.Message + Environment.NewLine + "Please report this issue at https://github.com/maxton/LibOrbisPkg/issues");
            }
            if (pkg.Metas.Metas.Where(entry => entry.id == EntryId.ICON0_PNG).FirstOrDefault() is MetaEntry icon0)
            {
                using (var s = pkgFile.CreateViewStream(icon0.DataOffset, icon0.DataSize, MemoryMappedFileAccess.Read))
                {
                    pictureBox1.Image = Image.FromStream(s);
                }
            }
            contentIdTextBox.Text = pkg.Header.content_id;
            titleTextBox.Text     = pkg.ParamSfo.ParamSfo["TITLE"]?.ToString();
            sizeLabel.Text        = FileView.HumanReadableFileSize((long)pkg.Header.package_size);
            var category = pkg.ParamSfo.ParamSfo["CATEGORY"].ToString();

            typeLabel.Text    = SFOView.SfoTypes.Where(x => x.Category == category).FirstOrDefault() is SFOView.SfoType t ? t.Description : "Unknown";
            versionLabel.Text = pkg.ParamSfo.ParamSfo["VERSION"]?.ToString();
            if (pkg.ParamSfo.ParamSfo["APP_VER"] is Utf8Value v)
            {
                appVerLabel.Text = v.Value;
            }
            else
            {
                appVerLabelLabel.Visible = false;
                appVerLabel.Visible      = false;
            }
            var sfoEditor = new SFOView(pkg.ParamSfo.ParamSfo, true);

            sfoEditor.Dock = DockStyle.Fill;
            tabPage1.Controls.Add(sfoEditor);


            if (pkg.CheckPasscode("00000000000000000000000000000000"))
            {
                passcode = "00000000000000000000000000000000";
                ekpfs    = Crypto.ComputeKeys(pkg.Header.content_id, passcode, 1);
            }
            else if (KeyDB.Instance.Passcodes.TryGetValue(pkg.Header.content_id, out var keydbPasscode) &&
                     pkg.CheckPasscode(keydbPasscode))
            {
                passcode = keydbPasscode;
                ekpfs    = Crypto.ComputeKeys(pkg.Header.content_id, passcode, 1);
            }
            else if (pkg.GetEkpfs() is byte[] ek && ek != null)
            {
                ekpfs = ek;
            }