/// <summary> /// Create a copy of the <see cref="GameInformation"/> instance. /// </summary> /// <returns>A copy of the <see cref="GameInformation"/> instance.</returns> public object Clone() { GameInformation g = new GameInformation(this.GameType, null, ( GameParameters )this.Parameters.Clone(), null, null, this.UniqueID); g.HostPath = this.HostPath; return(g); }
public SubmitGame( GameInformation game ) : this() { Debug.Assert( game != null ); if( game == null ) throw new ArgumentNullException( "game" ); _game = game; this.Icon = IconUtilities.ConvertToIcon( Properties.Resources.ReportIcon ); _googleIcon = Properties.Resources.Google; _service = new Service(); _service.ListGamesCompleted += new ListGamesCompletedEventHandler( ServiceListGamesCompleted ); _service.AddGameCompleted += new AddGameCompletedEventHandler( ServiceAddGameCompleted ); _service.AddReleaseCompleted += new AddReleaseCompletedEventHandler( ServiceAddReleaseCompleted ); if( _gameList == null ) { _service.ListGamesAsync(); _outstandingRefresh = true; } else { this.ServiceListGamesCompleted( null, null ); } this.titleLabel.Text = _game.Parameters.Title; this.discIdLabel.Text = _game.Parameters.DiscID; this.firmwareLabel.Text = _game.Parameters.SystemVersion.ToString(); this.regionLabel.Text = _game.Parameters.Region.ToString(); this.versionLabel.Text = _game.Parameters.GameVersion.ToString(); Image gameImage; if( _game.Icon != null ) { _game.Icon.Position = 0; gameImage = Image.FromStream( _game.Icon ); } else gameImage = Image.FromStream( new MemoryStream( Resources.InvalidIcon, false ) ); this.iconPictureBox.Image = gameImage; _release = new GameRelease(); _release.Title = _game.Parameters.Title; _release.DiscID = _game.Parameters.DiscID; _release.Region = _game.Parameters.Region; _release.SystemVersion = VersionToSingle( _game.Parameters.SystemVersion ); _release.GameVersion = VersionToSingle( _game.Parameters.GameVersion ); if( _game.Icon != null ) { _game.Icon.Position = 0; using( BinaryReader reader = new BinaryReader( _game.Icon ) ) _iconBytes = reader.ReadBytes( ( int )_game.Icon.Length ); } }
/// <summary> /// Find the game on the given UMD device. /// </summary> /// <param name="device">The UMD to search.</param> /// <returns>The game found on the device, or <c>null</c> if none was found.</returns> public static GameInformation FindGame(IUmdDevice device) { Debug.Assert(device != null); if (device == null) { return(null); } GameInformation info = GameLoader.GetUmdGameInformation(device); Debug.Assert(info != null); return(info); }
public static Bitmap BuildGameImage( GameInformation game ) { Bitmap gameImage; if( game.Icon != null ) gameImage = ( Bitmap )Bitmap.FromStream( game.Icon ); else gameImage = ( Bitmap )Bitmap.FromStream( new MemoryStream( Resources.InvalidIcon, false ) ); //Image mediaImage; //switch( game.GameType ) //{ // default: // case GameType.Eboot: // mediaImage = Resources.SmallMemoryStickIcon; // break; // case GameType.UmdGame: // mediaImage = Resources.SmallUmdIcon; // break; //} Bitmap regionImage = null; if( game.GameType == GameType.UmdGame ) { string regionChar = game.Parameters.DiscID.Substring( 2, 1 ); if( _regionImages.ContainsKey( regionChar ) == true ) regionImage = _regionImages[ regionChar ]; else regionImage = _regionImages[ "?" ]; } Bitmap combined = new Bitmap( IconWidth, IconHeight ); using( Graphics g = Graphics.FromImage( combined ) ) { g.DrawImage( gameImage, 0, 0, combined.Width, combined.Height ); //g.DrawImage( mediaImage, combined.Width - mediaImage.Width, combined.Height - mediaImage.Height ); if( regionImage != null ) g.DrawImageUnscaled( regionImage, combined.Width - regionImage.Width - 2, combined.Height - regionImage.Height - 2 ); } gameImage.Dispose(); return combined; }
/// <summary> /// Find all games on the current Memory Stick. /// </summary> /// <param name="device">The Memory Stick to search.</param> /// <returns>A list of games found.</returns> public static GameInformation[] FindGames(IMemoryStickDevice device) { List <GameInformation> infos = new List <GameInformation>(); Debug.Assert(device != null); if ((device != null) && (device.State == MediaState.Present)) { // Eboots in PSP\GAME\* IMediaFolder rootFolder = device.Root.FindFolder(@"PSP\GAME\"); foreach (IMediaFolder folder in rootFolder) { // kxploit check IMediaFolder realFolder = folder; bool wasExploited = false; if (folder.Name.StartsWith("__SCE__") == true) { // Find the %__SCE__... folder realFolder = folder.Parent["%" + folder.Name] as IMediaFolder; Debug.Assert(realFolder != null); wasExploited = true; } else if (folder.Name[0] == '%') { continue; } GameInformation info = GameLoader.GetEbootGameInformation(realFolder); if (wasExploited == true) { info.Folder = folder; } if (info != null) { infos.Add(info); } } } return(infos.ToArray()); }
/// <summary> /// Generate a load report XML file and write it to the disk. /// </summary> /// <param name="instance">The current emulation instance.</param> /// <param name="game">The game being loaded.</param> /// <param name="results">The results of the load.</param> /// <param name="outputPath">The path to write the result data to.</param> public static void GenerateReport( IEmulationInstance instance, GameInformation game, LoadResults results, string outputPath ) { Debug.Assert( game != null ); if( game == null ) return; Debug.Assert( results != null ); if( results == null ) return; XmlDocument doc = new XmlDocument(); doc.AppendChild( doc.CreateXmlDeclaration( "1.0", null, "yes" ) ); XmlElement root = doc.CreateElement( "loadResults" ); root.SetAttribute( "successful", results.Successful.ToString() ); XmlElement gameRoot = doc.CreateElement( "game" ); gameRoot.SetAttribute( "type", game.GameType.ToString() ); //gameRoot.SetAttribute( "path", EscapeFilePath( game.Folder.AbsolutePath ) ); { XmlElement sfoRoot = doc.CreateElement( "parameters" ); if( game.Parameters.Title != null ) sfoRoot.SetAttribute( "title", game.Parameters.Title ); if( game.Parameters.SystemVersion != new Version() ) sfoRoot.SetAttribute( "systemVersion", game.Parameters.SystemVersion.ToString() ); if( game.Parameters.GameVersion != new Version() ) sfoRoot.SetAttribute( "gameVersion", game.Parameters.GameVersion.ToString() ); if( game.Parameters.DiscID != null ) sfoRoot.SetAttribute( "discId", game.Parameters.DiscID ); if( game.Parameters.Region >= 0 ) sfoRoot.SetAttribute( "region", game.Parameters.Region.ToString( "X" ) ); if( game.Parameters.Language != null ) sfoRoot.SetAttribute( "language", game.Parameters.Language ); sfoRoot.SetAttribute( "category", game.Parameters.Category.ToString() ); gameRoot.AppendChild( sfoRoot ); } root.AppendChild( gameRoot ); XmlElement biosRoot = doc.CreateElement( "bios" ); { IComponent factory = Activator.CreateInstance( instance.Bios.Factory ) as IComponent; if( factory != null ) { biosRoot.SetAttribute( "name", factory.Name ); biosRoot.SetAttribute( "version", factory.Version.ToString() ); biosRoot.SetAttribute( "build", factory.Build.ToString() ); if( factory.Author != null ) biosRoot.SetAttribute( "author", factory.Author ); if( factory.Website != null ) biosRoot.SetAttribute( "website", factory.Website ); } } root.AppendChild( biosRoot ); XmlElement importsRoot = doc.CreateElement( "imports" ); foreach( StubImport import in results.Imports ) { XmlElement importRoot = doc.CreateElement( "import" ); importRoot.SetAttribute( "result", import.Result.ToString() ); importRoot.SetAttribute( "module", import.ModuleName ); importRoot.SetAttribute( "nid", string.Format( "{0:X8}", import.NID ) ); if( import.Function != null ) { XmlElement functionRoot = doc.CreateElement( "function" ); functionRoot.SetAttribute( "name", import.Function.Name ); functionRoot.SetAttribute( "isImplemented", import.Function.IsImplemented.ToString() ); //functionRoot.SetAttribute( "hasNative", ( import.Function.NativeMethod != IntPtr.Zero ) ? true.ToString() : false.ToString() ); importRoot.AppendChild( functionRoot ); } importsRoot.AppendChild( importRoot ); } root.AppendChild( importsRoot ); doc.AppendChild( root ); string fileName; if( game.GameType == GameType.Eboot ) { string title = game.Parameters.Title; title = title.Replace( "\n", "" ); // All it takes is one moron fileName = string.Format( "LoadResult-Eboot-{0}.xml", title ); } else fileName = string.Format( "LoadResult-{0}.xml", game.Parameters.DiscID ); using( FileStream stream = File.Open( Path.Combine( outputPath, fileName ), FileMode.Create ) ) doc.Save( stream ); }
private void AddGame( GameInformation game, bool batch ) { _games.Add( game ); ListViewItem item = new ListViewItem(); item.Tag = game; Image gameImage; if( _cache != null ) gameImage = _cache.GetImage( game ); else gameImage = GameCache.BuildGameImage( game ); gamesImageList.Images.Add( gameImage ); item.ImageIndex = gamesImageList.Images.Count - 1; _imageLookup.Add( game, item.ImageIndex ); string regionName = string.Empty; if( game.GameType == GameType.UmdGame ) { string regionChar = game.Parameters.DiscID.Substring( 2, 1 ); switch( regionChar ) { case "U": regionName = "US"; break; case "E": regionName = "UK"; break; case "J": regionName = "JP"; break; case "K": regionName = "KR"; break; case "A": regionName = "CN"; break; default: regionName = "??"; break; } } item.SubItems.AddRange( new ListViewItem.ListViewSubItem[]{ new ListViewItem.ListViewSubItem( item, game.Parameters.Title ), new ListViewItem.ListViewSubItem( item, regionName ), } ); item.ToolTipText = Path.GetFileName( game.HostPath ); _items.Add( game, item ); }
public void RemoveGame( GameInformation game ) { ListViewItem item = _items[ game ]; int imageIndex = _imageLookup[ game ]; _games.Remove( game ); _imageLookup.Remove( game ); _items.Remove( game ); listView.BeginUpdate(); if( listView.Items.Contains( item ) == true ) listView.Items.Remove( item ); listView.EndUpdate(); //gamesImageList.Images.RemoveAt( imageIndex ); }
public void AddGame( GameInformation game ) { Debug.Assert( game != null ); this.AddGame( game, true ); this.PostChange(); }
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." ); } }
public void OnStarted( GameInformation game, Stream bootStream ) { // Need to marshal all UI calls to the proper thread DummyDelegate del = delegate { this.Log.OnStarted(); this.Statistics.OnStarted(); this.View.SetStatusText( Verbosity.Normal, "Connection to emulator {0} established.", this.Host.HostString ); this.State = DebuggerState.Running; this.OnStateChanged(); }; this.View.Invoke( del ); // TEST Breakpoint bp = new Breakpoint( this.AllocateID(), BreakpointType.CodeExecute, 0x08900334 ); //this.Breakpoints.Add( bp ); }
public void LaunchGame( GameInformation game ) { game.IgnoreDispose = true; if( game.HostPath != null ) { // Need to have the UMD instance reload to the game string gamePath = game.HostPath; Debug.Assert( gamePath != null ); _emulator.Umd.Eject(); if( _emulator.Umd.Load( gamePath, false ) == false ) { // Failed to load } // Regrab game info game = GameLoader.FindGame( _emulator.Umd ); Properties.Settings.Default.LastPlayedGame = gamePath; Properties.Settings.Default.Save(); } _emulator.SwitchToGame( game ); this.DialogResult = DialogResult.OK; this.Close(); }
/// <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; }
/// <summary> /// Generate a load report XML file and write it to the disk. /// </summary> /// <param name="instance">The current emulation instance.</param> /// <param name="game">The game being loaded.</param> /// <param name="results">The results of the load.</param> /// <param name="outputPath">The path to write the result data to.</param> public static void GenerateReport(IEmulationInstance instance, GameInformation game, LoadResults results, string outputPath) { Debug.Assert(game != null); if (game == null) { return; } Debug.Assert(results != null); if (results == null) { return; } XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", null, "yes")); XmlElement root = doc.CreateElement("loadResults"); root.SetAttribute("successful", results.Successful.ToString()); XmlElement gameRoot = doc.CreateElement("game"); gameRoot.SetAttribute("type", game.GameType.ToString()); //gameRoot.SetAttribute( "path", EscapeFilePath( game.Folder.AbsolutePath ) ); { XmlElement sfoRoot = doc.CreateElement("parameters"); if (game.Parameters.Title != null) { sfoRoot.SetAttribute("title", game.Parameters.Title); } if (game.Parameters.SystemVersion != new Version()) { sfoRoot.SetAttribute("systemVersion", game.Parameters.SystemVersion.ToString()); } if (game.Parameters.GameVersion != new Version()) { sfoRoot.SetAttribute("gameVersion", game.Parameters.GameVersion.ToString()); } if (game.Parameters.DiscID != null) { sfoRoot.SetAttribute("discId", game.Parameters.DiscID); } if (game.Parameters.Region >= 0) { sfoRoot.SetAttribute("region", game.Parameters.Region.ToString("X")); } if (game.Parameters.Language != null) { sfoRoot.SetAttribute("language", game.Parameters.Language); } sfoRoot.SetAttribute("category", game.Parameters.Category.ToString()); gameRoot.AppendChild(sfoRoot); } root.AppendChild(gameRoot); XmlElement biosRoot = doc.CreateElement("bios"); { IComponent factory = Activator.CreateInstance(instance.Bios.Factory) as IComponent; if (factory != null) { biosRoot.SetAttribute("name", factory.Name); biosRoot.SetAttribute("version", factory.Version.ToString()); biosRoot.SetAttribute("build", factory.Build.ToString()); if (factory.Author != null) { biosRoot.SetAttribute("author", factory.Author); } if (factory.Website != null) { biosRoot.SetAttribute("website", factory.Website); } } } root.AppendChild(biosRoot); XmlElement importsRoot = doc.CreateElement("imports"); foreach (StubImport import in results.Imports) { XmlElement importRoot = doc.CreateElement("import"); importRoot.SetAttribute("result", import.Result.ToString()); importRoot.SetAttribute("module", import.ModuleName); importRoot.SetAttribute("nid", string.Format("{0:X8}", import.NID)); if (import.Function != null) { XmlElement functionRoot = doc.CreateElement("function"); functionRoot.SetAttribute("name", import.Function.Name); functionRoot.SetAttribute("isImplemented", import.Function.IsImplemented.ToString()); //functionRoot.SetAttribute( "hasNative", ( import.Function.NativeMethod != IntPtr.Zero ) ? true.ToString() : false.ToString() ); importRoot.AppendChild(functionRoot); } importsRoot.AppendChild(importRoot); } root.AppendChild(importsRoot); doc.AppendChild(root); string fileName; if (game.GameType == GameType.Eboot) { string title = game.Parameters.Title; title = title.Replace("\n", ""); // All it takes is one moron fileName = string.Format("LoadResult-Eboot-{0}.xml", title); } else { fileName = string.Format("LoadResult-{0}.xml", game.Parameters.DiscID); } using (FileStream stream = File.Open(Path.Combine(outputPath, fileName), FileMode.Create)) doc.Save(stream); }
private string GetIconPath( GameInformation game ) { string iconsPath = Path.Combine( _cachePath, "Icons" ); try { if( Directory.Exists( iconsPath ) == false ) Directory.CreateDirectory( iconsPath ); } catch { } return Path.Combine( iconsPath, game.Parameters.DiscID ) + ".png"; }
public void Remove( GameInformation game ) { Debug.Assert( game.HostPath != null ); this.Remove( game.HostPath ); }
public Bitmap GetImage( GameInformation game ) { if( game.GameType == GameType.Eboot ) return BuildGameImage( game ); else { string iconPath = GetIconPath( game ); if( File.Exists( iconPath ) == true ) return ( Bitmap )Bitmap.FromFile( iconPath ); else { Bitmap b = BuildGameImage( game ); b.Save( iconPath, ImageFormat.Png ); return b; } } }
public void Add( GameInformation game ) { Debug.Assert( game.GameType != GameType.Eboot ); GameInformation copy = ( GameInformation )game.Clone(); _list.Add( copy ); _lookup.Add( copy.HostPath, copy ); // We build the image off the real game, which should have the icon stream using( Bitmap b = this.GetImage( game ) ) { } }
/// <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); }
/// <summary> /// Create a copy of the <see cref="GameInformation"/> instance. /// </summary> /// <returns>A copy of the <see cref="GameInformation"/> instance.</returns> public object Clone() { GameInformation g = new GameInformation( this.GameType, null, ( GameParameters )this.Parameters.Clone(), null, null, this.UniqueID ); g.HostPath = this.HostPath; return g; }
public void OnStarted( GameInformation game, Stream bootStream ) { // Need to marshal all UI calls to the proper thread DummyDelegate del = delegate { this.State = DebuggerState.Running; this.OnStateChanged(); foreach( DebuggerTool tool in this.Tools ) tool.OnStarted(); }; this.Window.Invoke( del ); }