Example #1
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));
            }
        }
Example #2
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;
        }
Example #3
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 );
            }
        }
Example #4
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);
        }