예제 #1
0
        public static XciItem GetXciInfo(string filePath, XciLocation location)
        {
            XciItem xci = new XciItem(filePath);

            Log($"GetXciInfo {filePath}");

            if (!File.Exists(filePath))
            {
                return(null);
            }

            XCI_Explorer.MainForm mainForm = new XCI_Explorer.MainForm(false);
            mainForm.IgnoreFileCorruptErrors = Helpers.Settings.config.ignoreFileCorruptErrors;

            //xci_header header = hac.GetXCIHeader(xci.xciFilePath);

            //xci.packageId = header.PackageID;

            xci.uniqueId = GetXciIdentifier(filePath);

            mainForm.SGM_ProcessFile(filePath);

            xci.gameName         = mainForm.TB_Name.Text.Trim().TrimEnd('\0');
            xci.gameDeveloper    = mainForm.TB_Dev.Text.Trim().TrimEnd('\0');
            xci.gameCardCapacity = mainForm.TB_Capacity.Text.Trim().TrimEnd('\0');

            if ((Bitmap)mainForm.PB_GameIcon.BackgroundImage == null)
            {
                xci.gameIcon = GetDefaultIcon();
            }
            else
            {
                xci.gameIcon = (Bitmap)mainForm.PB_GameIcon.BackgroundImage;
            }
            xci.contentType = mainForm.ContentType;

            if (xci.contentType == null || xci.contentType.Length == 0)
            {
                xci.contentType = "NSP Game";
            }

            xci.gameRevision      = mainForm.TB_GameRev.Text.Trim().TrimEnd('\0');
            xci.masterKeyRevision = mainForm.TB_MKeyRev.Text.Trim().TrimEnd('\0');
            xci.sdkVersion        = mainForm.TB_SDKVer.Text.Trim().TrimEnd('\0');
            xci.titleId           = mainForm.TB_TID.Text.Trim().TrimEnd('\0');
            if (xci.titleId.Length != 16)
            {
                xci.titleId = 0 + xci.titleId;
            }
            xci.gameSize     = mainForm.ExactSize;
            xci.gameUsedSize = mainForm.UsedSize;
            xci.productCode  = mainForm.TB_ProdCode.Text.Trim().TrimEnd('\0');
            xci.gameCert     = ReadXciCert(xci.xciFilePath);
            xci.xciFileSize  = new System.IO.FileInfo(xci.xciFilePath).Length;

            if (xci.gameName.Length == 0 && xci.gameUsedSize == 0)
            {
                xci.gameName = Path.GetFileName(xci.xciFilePath) + " (Corrupt?)";
            }

            if (location == XciLocation.PC)
            {
                xci.xciLocation = XciLocation.PC;
                xci.isGameOnPc  = true;
            }
            else
            {
                xci.xciLocation = XciLocation.SD;
                xci.isGameOnSd  = true;
            }

            // compare the expected size with the actual size
            xci.isXciTrimmed = (xci.gameSize == xci.gameUsedSize);

            // compare the first byte of the cert to the rest of the cert if they're all the same,
            // it's not unique. ex 255 for all
            xci.isUniqueCert = !xci.gameCert.All(s => s.Equals(xci.gameCert[0]));

            mainForm.Close();
            mainForm = null;

            return(xci);
        }
예제 #2
0
        private void UpdateToolMenus()
        {
            //happens on right click to ContextMenu.
            //Update the ContextMenu's text items

            XciLocation destination = new XciLocation();
            XciLocation source      = new XciLocation();

            if (Helpers.Settings.config.defaultView == XciLocation.PC)
            {
                destination = XciLocation.SD;
                source      = XciLocation.PC;
            }
            else
            {
                destination = XciLocation.PC;
                source      = XciLocation.SD;
            }

            if (IsListIndexUsable(true))
            {
                ToolStripMenuItem toolStripMenu = (ToolStripMenuItem)contextMenuStrip.Items[0];
                gameManagementToolStripMenuItem.Enabled = true;
                contextMenuStrip.Enabled = true;

                copyToolStripMenuItem.Text   = $"Copy to {destination}";
                moveToolStripMenuItem.Text   = $"Move to {destination}";
                deleteToolStripMenuItem.Text = $"Delete from {source}";

                XciItem selected = (XciItem)olvList.SelectedObject;
                if (olvList.SelectedIndices.Count > 1)
                {
                    trimGameToolStripMenuItem.Text              = $"Trim {olvList.SelectedIndices.Count} Games";
                    copyToolStripMenuItem.Text                  = $"Copy {olvList.SelectedIndices.Count} Games to {destination}";
                    moveToolStripMenuItem.Text                  = $"Move {olvList.SelectedIndices.Count} Games to {destination}";
                    deleteToolStripMenuItem.Text                = $"Delete {olvList.SelectedIndices.Count} Games from {source}";
                    showInXCIExplorerToolStripMenuItem.Text     = $"Show {olvList.SelectedIndices.Count} Games in XCI Explorer";
                    showInWindowsExplorerToolStripMenuItem.Text = $"Show {olvList.SelectedIndices.Count} Games in Windows Explorer";
                    showXCICertificateToolStripMenuItem.Text    = $"Show {olvList.SelectedIndices.Count} XCI Certificates";
                }
                else
                {
                    trimGameToolStripMenuItem.Text              = $"Trim {selected.gameName}";
                    copyToolStripMenuItem.Text                  = $"Copy {selected.gameName} to {destination}";
                    moveToolStripMenuItem.Text                  = $"Move {selected.gameName} to {destination}";
                    deleteToolStripMenuItem.Text                = $"Delete {selected.gameName} from {source}";
                    showInXCIExplorerToolStripMenuItem.Text     = $"Show {selected.gameName} in XCI Explorer";
                    showInWindowsExplorerToolStripMenuItem.Text = $"Show {selected.gameName} in Windows Explorer";
                    showXCICertificateToolStripMenuItem.Text    = $"Show {selected.gameName} XCI Certificate";
                }

                contextMenuStrip.Items[2].Text = trimGameToolStripMenuItem.Text;
                contextMenuStrip.Items[4].Text = showXCICertificateToolStripMenuItem.Text;
                contextMenuStrip.Items[5].Text = showInXCIExplorerToolStripMenuItem.Text;
                contextMenuStrip.Items[6].Text = showInWindowsExplorerToolStripMenuItem.Text;

                toolStripMenu.DropDownItems[0].Text = copyToolStripMenuItem.Text;
                toolStripMenu.DropDownItems[1].Text = moveToolStripMenuItem.Text;
                toolStripMenu.DropDownItems[2].Text = deleteToolStripMenuItem.Text;
            }
            else
            {
                gameManagementToolStripMenuItem.Enabled = false;
                contextMenuStrip.Enabled = false;
            }
        }