public static GameEntry HandleIso(string IsoFile) { var IsoFileInfo = new FileInfo(IsoFile); Psf ParamSfo; var Entry = new GameEntry(); byte[] Icon0Png; string UmdData = string.Empty; if (DefaultIcon == null) { var TempMemoryStream = new MemoryStream(); Properties.Resources.icon0.Save(TempMemoryStream, ImageFormat.Png); DefaultIcon = TempMemoryStream.ToArray(); } using (var IsoStream = File.OpenRead(IsoFile)) { switch (new FormatDetector().DetectSubType(IsoStream)) { case FormatDetector.SubType.Pbp: var PBP = new Pbp().Load(File.OpenRead(IsoFile)); ParamSfo = new Psf(PBP[Pbp.Types.ParamSfo]); Icon0Png = PBP.ContainsKey(Pbp.Types.Icon0Png) ? PBP[Pbp.Types.Icon0Png].ReadAll() : DefaultIcon; UmdData = "---"; break; case FormatDetector.SubType.Iso: case FormatDetector.SubType.Cso: case FormatDetector.SubType.Dax: using (var Iso = IsoLoader.GetIso(IsoFile)) { var FileSystem = new HleIoDriverIso(Iso); if (!FileSystem.FileExists("/PSP_GAME/PARAM.SFO")) { throw (new Exception(String.Format("Not a PSP ISO '{0}'", IsoFile))); } ParamSfo = new Psf(new MemoryStream(FileSystem.OpenRead("/PSP_GAME/PARAM.SFO").ReadAll())); if (FileSystem.FileExists("/UMD_DATA.BIN")) UmdData = FileSystem.OpenRead("/UMD_DATA.BIN").ReadAllContentsAsString(); Icon0Png = FileSystem.FileExists("/PSP_GAME/ICON0.PNG") ? FileSystem.OpenRead("/PSP_GAME/ICON0.PNG").ReadAll() : DefaultIcon; Entry.PatchedWithPrometheus = FileSystem.FileExists("/PSP_GAME/SYSDIR/prometheus.prx") || FileSystem.FileExists("/PSP_GAME/SYSDIR/EBOOT.OLD"); } break; default: return null; } } FillGameEntryFromSfo(Entry, ParamSfo); Entry.IsoSize = IsoFileInfo.Length; Entry.Hash = GetHash(IsoFile); Entry.IsoFile = IsoFile; Entry.DiscId0 = UmdData.Split('|')[0]; Entry.Icon0Png = Icon0Png; return Entry; }
public GameEntry HandleIso(string IsoFile) { var IsoFileInfo = new FileInfo(IsoFile); var Iso = IsoLoader.GetIso(IsoFile); var FileSystem = new HleIoDriverIso(Iso); var UmdData = FileSystem.OpenRead("/UMD_DATA.BIN").ReadAllContentsAsString(); var ParamSfo = new Psf(new MemoryStream(FileSystem.OpenRead("/PSP_GAME/PARAM.SFO").ReadAll())); var Icon0Png = FileSystem.OpenRead("/PSP_GAME/ICON0.PNG").ReadAll(); var Entries = ParamSfo.EntryDictionary; var Entry = new GameEntry(); Entry.IsoSize = IsoFileInfo.Length; Entry.Hash = GetHash(IsoFile); Entry.IsoFile = IsoFile; Entry.DiscId0 = UmdData.Split('|')[0]; try { Entry.APP_VER = (string)Entries["APP_VER"]; } catch { } try { Entry.BOOTABLE = ((int)Entries["BOOTABLE"]) != 0; } catch { } try { Entry.CATEGORY = (string)Entries["CATEGORY"]; } catch { } try { Entry.DISC_ID = (string)Entries["DISC_ID"]; } catch { } try { Entry.DISC_NUMBER = (int)Entries["DISC_NUMBER"]; } catch { } try { Entry.DISC_TOTAL = (int)Entries["DISC_TOTAL"]; } catch { } try { Entry.DISC_VERSION = (string)Entries["DISC_VERSION"]; } catch { } try { Entry.DRIVER_PATH = (string)Entries["DRIVER_PATH"]; } catch { } try { Entry.GAMEDATA_ID = (string)Entries["GAMEDATA_ID"]; } catch { } try { Entry.HRKGMP_VER = (int)Entries["HRKGMP_VER"]; } catch { } try { Entry.PARENTAL_LEVEL = (int)Entries["PARENTAL_LEVEL"]; } catch { } try { Entry.PSP_SYSTEM_VER = (string)Entries["PSP_SYSTEM_VER"]; } catch { } try { Entry.REGION = (int)Entries["REGION"]; } catch { } try { Entry.TITLE = (string)Entries["TITLE"]; } catch { } try { Entry.USE_USB = ((int)Entries["USE_USB"]) != 0; } catch { } try { Entry.Icon0Png = Icon0Png; } catch { } /** GameId: ULJM-05753 APP_VER : 01.00 BOOTABLE : 1 CATEGORY : UG DISC_ID : ULJM05753 DISC_NUMBER : 1 DISC_TOTAL : 1 DISC_VERSION : 1.02 DRIVER_PATH : GAMEDATA_ID : ULJM05753 HRKGMP_VER : 19 PARENTAL_LEVEL : 5 PSP_SYSTEM_VER : 6.31 REGION : 32768 TITLE : タクティクスオウガ 運命の輪 USE_USB : 0 */ return Entry; }
public void LoadTest() { var Psf = new Psf(); Psf.Load(File.OpenRead("../../../TestInput/PARAM.SFO")); foreach (var Pair in Psf.EntryDictionary) { Console.WriteLine("{0}:{1}", Pair.Key, Pair.Value); } Assert.AreEqual(Psf.EntryDictionary["BOOTABLE"], 1); Assert.AreEqual(Psf.EntryDictionary["CATEGORY"], "UG"); Assert.AreEqual(Psf.EntryDictionary["DISC_ID"], "TEST99999"); Assert.AreEqual(Psf.EntryDictionary["DISC_NUMBER"], 1); Assert.AreEqual(Psf.EntryDictionary["DISC_TOTAL"], 1); Assert.AreEqual(Psf.EntryDictionary["DISC_VERSION"], "9.99"); Assert.AreEqual(Psf.EntryDictionary["PARENTAL_LEVEL"], 5); Assert.AreEqual(Psf.EntryDictionary["PSP_SYSTEM_VER"], "3.33"); Assert.AreEqual(Psf.EntryDictionary["REGION"], 32768); Assert.AreEqual(Psf.EntryDictionary["TITLE"], "GAME TITLE TITLE"); }
public static GameEntry HandleIso(string IsoFile) { var IsoFileInfo = new FileInfo(IsoFile); var Iso = IsoLoader.GetIso(IsoFile); var FileSystem = new HleIoDriverIso(Iso); string UmdData = string.Empty; if (FileSystem.FileExists("/UMD_DATA.BIN")) UmdData = FileSystem.OpenRead("/UMD_DATA.BIN").ReadAllContentsAsString(); var ParamSfo = new Psf(new MemoryStream(FileSystem.OpenRead("/PSP_GAME/PARAM.SFO").ReadAll())); byte[] Icon0Png ; if (FileSystem.FileExists("/PSP_GAME/ICON0.PNG")) Icon0Png = FileSystem.OpenRead("/PSP_GAME/ICON0.PNG").ReadAll(); else Icon0Png = (byte[])System.ComponentModel.TypeDescriptor.GetConverter(Properties.Resources.icon0).ConvertTo(Properties.Resources.icon0, typeof(byte[])); var Entries = ParamSfo.EntryDictionary; var Entry = new GameEntry(); if ( FileSystem.FileExists("/PSP_GAME/SYSDIR/prometheus.prx") || FileSystem.FileExists("/PSP_GAME/SYSDIR/EBOOT.OLD") ) { Entry.PatchedWithPrometheus = true; } else { Entry.PatchedWithPrometheus = false; } Entry.IsoSize = IsoFileInfo.Length; Entry.Hash = GetHash(IsoFile); Entry.IsoFile = IsoFile; Entry.DiscId0 = UmdData.Split('|')[0]; try { Entry.APP_VER = (string)Entries["APP_VER"]; } catch { } try { Entry.BOOTABLE = ((int)Entries["BOOTABLE"]) != 0; } catch { } try { Entry.CATEGORY = (string)Entries["CATEGORY"]; } catch { } try { Entry.DISC_ID = (string)Entries["DISC_ID"]; if (string.IsNullOrWhiteSpace(Entry.DiscId0)) Entry.DiscId0 = Entry.DISC_ID.Substring(0, 4) +"-"+ Entry.DISC_ID.Substring(4); } catch { } try { Entry.DISC_NUMBER = (int)Entries["DISC_NUMBER"]; } catch { } try { Entry.DISC_TOTAL = (int)Entries["DISC_TOTAL"]; } catch { } try { Entry.DISC_VERSION = (string)Entries["DISC_VERSION"]; } catch { } try { Entry.DRIVER_PATH = (string)Entries["DRIVER_PATH"]; } catch { } try { Entry.GAMEDATA_ID = (string)Entries["GAMEDATA_ID"]; } catch { } try { Entry.HRKGMP_VER = (int)Entries["HRKGMP_VER"]; } catch { } try { Entry.PARENTAL_LEVEL = (int)Entries["PARENTAL_LEVEL"]; } catch { } try { Entry.PSP_SYSTEM_VER = (string)Entries["PSP_SYSTEM_VER"]; } catch { } try { Entry.REGION = (int)Entries["REGION"]; } catch { } try { Entry.TITLE = (string)Entries["TITLE"]; } catch { } try { Entry.USE_USB = ((int)Entries["USE_USB"]) != 0; } catch { } try { Entry.Icon0Png = Icon0Png; } catch { } /** GameId: ULJM-05753 APP_VER : 01.00 BOOTABLE : 1 CATEGORY : UG DISC_ID : ULJM05753 DISC_NUMBER : 1 DISC_TOTAL : 1 DISC_VERSION : 1.02 DRIVER_PATH : GAMEDATA_ID : ULJM05753 HRKGMP_VER : 19 PARENTAL_LEVEL : 5 PSP_SYSTEM_VER : 6.31 REGION : 32768 TITLE : タクティクスオウガ 運命の輪 USE_USB : 0 */ return Entry; }
private static void FillGameEntryFromSfo(GameEntry Entry, Psf ParamSfo) { var Entries = ParamSfo.EntryDictionary; Entry.APP_VER = (string)Entries.GetOrDefault("APP_VER", "01.00"); Entry.BOOTABLE = (int)Entries.GetOrDefault("BOOTABLE", 1) != 0; Entry.CATEGORY = (string)Entries.GetOrDefault("CATEGORY", "UG"); Entry.DISC_ID = (string)Entries.GetOrDefault("DISC_ID", "XXXX99999"); if (string.IsNullOrWhiteSpace(Entry.DiscId0)) Entry.DiscId0 = Entry.DISC_ID.Substring(0, 4) + "-" + Entry.DISC_ID.Substring(4); Entry.DISC_NUMBER = (int)Entries.GetOrDefault("DISC_NUMBER", 1); Entry.DISC_TOTAL = (int)Entries.GetOrDefault("DISC_TOTAL", 1); Entry.DISC_VERSION = (string)Entries.GetOrDefault("DISC_VERSION", "1.00"); Entry.DRIVER_PATH = (string)Entries.GetOrDefault("DRIVER_PATH", ""); Entry.GAMEDATA_ID = (string)Entries.GetOrDefault("GAMEDATA_ID", "XXXX99999"); Entry.HRKGMP_VER = (int)Entries.GetOrDefault("HRKGMP_VER", 19); Entry.PARENTAL_LEVEL = (int)Entries.GetOrDefault("PARENTAL_LEVEL", 5); Entry.PSP_SYSTEM_VER = (string)Entries.GetOrDefault("PSP_SYSTEM_VER", "1.00"); Entry.REGION = (int)Entries.GetOrDefault("REGION", 32768); Entry.TITLE = (string)Entries.GetOrDefault("TITLE", "Unknown Title"); Entry.USE_USB = ((int)Entries.GetOrDefault("USE_USB", 0)) != 0; }