Beispiel #1
0
        /// <summary>
        /// Get <see cref="GameInformation"/> from the given UMD device.
        /// </summary>
        /// <param name="device">The device containing the game.</param>
        /// <returns>A <see cref="GameInformation"/> instance representing the game, or <c>null</c> if an error occurred.</returns>
        public static GameInformation GetUmdGameInformation(IMediaDevice device)
        {
            IMediaFolder folder  = device.Root;
            IMediaFile   umdData = folder["UMD_DATA.BIN"] as IMediaFile;

            //[4 alpha country code]-[4 digit game id]|16 digit binhex|0001|G
            // Get code from SFO
            string uniqueId;

            using (StreamReader reader = new StreamReader(umdData.OpenRead()))
            {
                string   line = reader.ReadToEnd().Trim();
                string[] ps   = line.Split('|');
                uniqueId = ps[1];
            }

            IMediaFile sfoData = folder.FindFile(@"PSP_GAME\PARAM.SFO");

            GameParameters gameParams;

            using (Stream stream = sfoData.OpenRead())
                gameParams = ReadSfo(stream);

            // Only accept games
            if ((gameParams.Category != GameCategory.MemoryStickGame) &&
                (gameParams.Category != GameCategory.UmdGame))
            {
                return(null);
            }

            Stream     icon       = null;
            Stream     background = null;
            IMediaFile iconData   = folder.FindFile(@"PSP_GAME\ICON0.PNG");

            if (iconData != null)
            {
                icon = iconData.OpenRead();
            }
            IMediaFile bgData = folder.FindFile(@"PSP_GAME\PIC1.PNG");

            if (bgData != null)
            {
                background = bgData.OpenRead();
            }

            return(new GameInformation(GameType.UmdGame, folder, gameParams, icon, background, uniqueId));
        }
Beispiel #2
0
        // SDK location: /user/pspmodulemgr.h:68
        // SDK declaration: SceUID sceKernelLoadModule(const char *path, int flags, SceKernelLMOption *option);
        public int sceKernelLoadModule(int path, int flags, int option)
        {
            string     modulePath = _kernel.ReadString(( uint )path);
            IMediaFile file       = ( IMediaFile )_kernel.FindPath(modulePath);

            if (file == null)
            {
                Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceKernelLoadModule: module not found: {0}", modulePath);
                return(-1);
            }

            Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceKernelLoadModule: loading module {0}", modulePath);

            Stream stream = file.OpenRead();

            return(this.LoadModule(file, stream, flags, option));
        }
Beispiel #3
0
        public void SetupGame(GameInformation game, Stream bootStream)
        {
            // Attempt to load symbols from game information
            bool debugInfoLoaded = false;

            if (bootStream != null)
            {
                debugInfoLoaded = this.LoadDebugData(DebugDataType.Symbols, bootStream);
            }

            // If nothing loaded, give the user a choice
            bool       skipLoadInfo = debugInfoLoaded;
            DebugSetup setup        = null;

            if (debugInfoLoaded == false)
            {
                setup = new DebugSetup();
                if (setup.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    skipLoadInfo = true;
                }
            }

            if (skipLoadInfo == false)
            {
                bool result = false;
                if (setup.UseElfDebug == true)
                {
                    IMediaFolder folder = game.Folder;
                    IMediaFile   file   = folder.FindFile("BOOT.BIN");
                    using (Stream stream = file.OpenRead())
                        result = this.LoadDebugData(DebugDataType.Elf, stream);
                }
                else
                {
                    Debug.Assert(false);
                }
                Debug.Assert(result == true);
                if (result == false)
                {
                    throw new InvalidOperationException("Could not load debugging data - cannot continue.");
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Get <see cref="GameInformation"/> from the given EBOOT folder.
        /// </summary>
        /// <param name="folder">The folder containing the EBOOT.</param>
        /// <returns>A <see cref="GameInformation"/> instance representing the game, or <c>null</c> if an error occurred.</returns>
        public static GameInformation GetEbootGameInformation(IMediaFolder folder)
        {
            Debug.Assert(folder != null);
            if (folder == null)
            {
                return(null);
            }

            IMediaFile file = folder["EBOOT.PBP"] as IMediaFile;

            if (file == null)
            {
                return(null);
            }

            using (Stream stream = file.OpenRead())
            {
                PbpReader reader = new PbpReader(stream);

                GameParameters gameParams;
                using (Stream pdbStream = reader.Read(stream, PbpReader.PbpEntryType.Param))
                    gameParams = ReadSfo(pdbStream);

                // Only accept games
                if ((gameParams.Category != GameCategory.MemoryStickGame) &&
                    (gameParams.Category != GameCategory.UmdGame))
                {
                    return(null);
                }

                Stream icon       = null;
                Stream background = null;
                if (reader.ContainsEntry(PbpReader.PbpEntryType.Icon0) == true)
                {
                    icon = reader.Read(stream, PbpReader.PbpEntryType.Icon0);
                }
                //if( reader.ContainsEntry( PbpReader.PbpEntryType.Pic1 ) == true )
                //	background = reader.Read( stream, PbpReader.PbpEntryType.Pic1 );

                return(new GameInformation(GameType.Eboot, folder, gameParams, icon, background, null));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Find and retrieve the boot stream for the given game.
        /// </summary>
        /// <param name="game">Game to look for.</param>
        /// <param name="filePath">The path of the boot file.</param>
        /// <returns>The games boot stream (from BOOT.BIN, etc) or <c>null</c> if it could not be found.</returns>
        public static Stream FindBootStream(GameInformation game, out string filePath)
        {
            filePath = null;
            Debug.Assert(game != null);
            if (game == null)
            {
                return(null);
            }

            Stream bootStream = null;

            string kernelLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string prxLocation    = Path.Combine(kernelLocation, "BOOT");
            // DiscID might be more appropriate than Title
            string lookasideBoot = Path.Combine(Path.Combine(prxLocation, game.Parameters.Title), "BOOT.BIN");

            if (File.Exists(lookasideBoot) == true)
            {
                // Load ours instead
                Log.WriteLine(Verbosity.Normal, Feature.Bios, "Lookaside boot found at {0}", lookasideBoot);
                bootStream = File.OpenRead(lookasideBoot);
                filePath   = lookasideBoot;
            }
            else
            {
                IMediaFolder folder = game.Folder;
                if (folder["PSP_GAME"] != null)
                {
                    folder = folder["PSP_GAME"] as IMediaFolder;
                }
                if (folder["SYSDIR"] != null)
                {
                    folder = folder["SYSDIR"] as IMediaFolder;
                }
                IMediaFile bootBin = null;
                bootBin = folder["BOOT.BIN"] as IMediaFile;
                if (bootBin == null)
                {
                    bootBin = folder["EBOOT.BIN"] as IMediaFile;
                }
                if (bootBin == null)
                {
                    bootBin = folder["BOOT.ELF"] as IMediaFile;
                }
                if (bootBin == null)
                {
                    bootBin = folder["EBOOT.ELF"] as IMediaFile;
                }

                if (bootBin == null)
                {
                    // Probably in PBP - unless exploited!
                    if (folder.Name.Contains("__SCE__") == true)
                    {
                        // If this is exploited, the eboot.pbp IS the elf!
                        IMediaFile pbp = folder["EBOOT.PBP"] as IMediaFile;
                        filePath   = pbp.AbsolutePath;
                        bootStream = pbp.OpenRead();
                    }
                    else
                    {
                        IMediaFile pbp = folder["EBOOT.PBP"] as IMediaFile;
                        using (Stream stream = pbp.OpenRead())
                        {
                            PbpReader reader = new PbpReader(stream);
                            if (reader.ContainsEntry(PbpReader.PbpEntryType.DataPsp) == true)
                            {
                                filePath   = pbp.AbsolutePath;
                                bootStream = reader.Read(stream, PbpReader.PbpEntryType.DataPsp);
                            }
                        }
                    }
                }
                else
                {
                    filePath   = bootBin.AbsolutePath;
                    bootStream = bootBin.OpenRead();
                }
            }

            return(bootStream);
        }