Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (pkg.CheckPasscode(passcodeTextBox.Text))
     {
         ekpfs = Crypto.ComputeKeys(pkg.Header.content_id, passcodeTextBox.Text, 1);
         ReopenFileView();
     }
     else
     {
         MessageBox.Show("Invalid passcode!");
     }
 }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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;
            }