void IInjectInitialize.Initialize() { var Iso = IsoLoader.GetIso("../../../pspautotests/input/iotest.iso"); var Umd = new HleIoDriverIso(Iso); HleIoManager.SetDriver("disc:", Umd); HleIoManager.Chdir("disc0:/PSP_GAME/USRDIR"); BootBinFileHandle = IoFileMgrForUser.sceIoOpen("disc0:/PSP_GAME/SYSDIR/BOOT.BIN", HleIoFlags.Read, SceMode.All); }
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; }
static unsafe void Main(string[] Arguments) { //Console.WriteLine(GL.GetConstantString(GL.GL_TEXTURE_2D)); //_MainData(); //_MainData2(); if (!IsNet45OrNewer()) { MessageBox.Show(".NET 4.5 required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new ThreadExceptionEventHandler(Form1_UIThreadException); // Set the unhandled exception mode to force all Windows Forms errors to go through // our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Logger.OnGlobalLog += (LogName, Level, Text, StackFrame) => { if (Level >= Logger.Level.Info) { var Method = StackFrame.GetMethod(); Console.WriteLine("{0} : {1} : {2}.{3} : {4}", LogName, Level, (Method.DeclaringType != null) ? Method.DeclaringType.Name : null, Method.Name, Text); } }; #if false Console.WriteLine(CSPspEmu.Resources.Translations.GetString("extra", "UnknownGame")); Console.ReadKey(); Environment.Exit(0); #endif #if RUN_TESTS RunTests(Arguments); #endif string FileToLoad = null; bool RunTestsViewOut = false; int RunTestsTimeout = 60; var Getopt = new Getopt(Arguments); { Getopt.AddRule(new[] { "/help", "/?", "-h", "--help", "-?" }, () => { Console.WriteLine("Soywiz's Psp Emulator - {0} - r{1} - {2}", PspGlobalConfiguration.CurrentVersion, PspGlobalConfiguration.CurrentVersionNumeric, PspGlobalConfiguration.GitRevision); Console.WriteLine(""); Console.WriteLine(" Switches:"); Console.WriteLine(" /version - Outputs the program version"); Console.WriteLine(" /version2 - Outputs the program numeric version"); Console.WriteLine(" /decrypt <EBOOT.BIN> - Decrypts an EBOOT.BIN"); Console.WriteLine(" /gitrevision - Outputs the git revision"); Console.WriteLine(" /associate - Associates extensions with the program. Requires be launched with administrative rights."); Console.WriteLine(" /viewout /timeout X /tests - Run integration tests."); Console.WriteLine(" "); Console.WriteLine(" /isolist <pathto.iso|cso|dax> - Lists the content of an iso."); Console.WriteLine(" /isoextract <in.iso> <outfolder> - Extracts the content of an iso."); Console.WriteLine(" /isoconvert <in.xxx> <out.yyy> - Converts a iso/cso/dax file into other format."); Console.WriteLine(""); Console.WriteLine(" Examples:"); Console.WriteLine(" cspspemu.exe <path_to_psp_executable>"); Console.WriteLine(""); Environment.Exit(0); }); Getopt.AddRule("/version", () => { Console.Write("{0}", PspGlobalConfiguration.CurrentVersion); Environment.Exit(0); }); Getopt.AddRule("/version2", () => { Console.Write("{0}", PspGlobalConfiguration.CurrentVersionNumeric); Environment.Exit(0); }); Getopt.AddRule("/isoconvert", () => { var IsoInPath = Getopt.DequeueNext(); var IsoOutPath = Getopt.DequeueNext(); if (Path.GetExtension(IsoOutPath) != ".iso") { Console.WriteLine("Just support outputing .iso files"); Environment.Exit(-1); } var IsoInFile = IsoLoader.GetIso(IsoInPath); var Stopwatch = new Stopwatch(); Stopwatch.Start(); Console.Write("{0} -> {1}...", IsoInPath, IsoOutPath); IsoInFile.Stream.Slice().CopyToFile(IsoOutPath); Console.WriteLine("Ok ({0})", Stopwatch.Elapsed); Environment.Exit(0); }); Getopt.AddRule("/isolist", () => { var IsoPath = Getopt.DequeueNext(); var IsoFile = IsoLoader.GetIso(IsoPath); var IsoFileSystem = new HleIoDriverIso(IsoFile); foreach (var FileName in IsoFileSystem.ListDirRecursive("/")) { var Stat = IsoFileSystem.GetStat(FileName); Console.WriteLine("{0} : {1}", FileName, Stat.Size); } //Console.Write("{0}", PspGlobalConfiguration.CurrentVersionNumeric); Environment.Exit(0); }); Getopt.AddRule("/isoextract", () => { var IsoPath = Getopt.DequeueNext(); var OutputPath = Getopt.DequeueNext(); var IsoFile = IsoLoader.GetIso(IsoPath); var IsoFileSystem = new HleIoDriverIso(IsoFile); foreach (var FileName in IsoFileSystem.ListDirRecursive("/")) { var Stat = IsoFileSystem.GetStat(FileName); var OutputFileName = OutputPath + "/" + FileName; Console.Write("{0} : {1}...", FileName, Stat.Size); if (!Stat.Attributes.HasFlag(Hle.Vfs.IOFileModes.Directory)) { var ParentDirectory = Directory.GetParent(OutputFileName).FullName; //Console.WriteLine(ParentDirectory); try { Directory.CreateDirectory(ParentDirectory); } catch { } using (var InputStream = IsoFileSystem.OpenRead(FileName)) { InputStream.CopyToFile(OutputFileName); } } Console.WriteLine("Ok"); } //Console.Write("{0}", PspGlobalConfiguration.CurrentVersionNumeric); Environment.Exit(0); }); Getopt.AddRule("/decrypt", (string EncryptedFile) => { try { using (var EncryptedStream = File.OpenRead(EncryptedFile)) { var DecryptedFile = String.Format("{0}.decrypted", EncryptedFile); Console.Write("'{0}' -> '{1}'...", EncryptedFile, DecryptedFile); var EncryptedData = EncryptedStream.ReadAll(); var DecryptedData = new EncryptedPrx().Decrypt(EncryptedData); File.WriteAllBytes(DecryptedFile, DecryptedData); Console.WriteLine("Ok"); Environment.Exit(0); } } catch (Exception Exception) { Console.Error.WriteLine(Exception); Environment.Exit(-1); } }); Getopt.AddRule("/gitrevision", () => { Console.Write("{0}", PspGlobalConfiguration.GitRevision); Environment.Exit(0); }); Getopt.AddRule("/associate", () => { try { Registry.ClassesRoot.CreateSubKey(".pbp").SetValue(null, "cspspemu.executable"); Registry.ClassesRoot.CreateSubKey(".elf").SetValue(null, "cspspemu.executable"); Registry.ClassesRoot.CreateSubKey(".prx").SetValue(null, "cspspemu.executable"); Registry.ClassesRoot.CreateSubKey(".cso").SetValue(null, "cspspemu.executable"); Registry.ClassesRoot.CreateSubKey(".dax").SetValue(null, "cspspemu.executable"); var Reg = Registry.ClassesRoot.CreateSubKey("cspspemu.executable"); Reg.SetValue(null, "PSP executable file (.elf, .pbp, .cso, .prx, .dax)"); Reg.SetValue("DefaultIcon", @"""" + ApplicationPaths.ExecutablePath + @""",0"); Reg.CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command").SetValue(null, @"""" + ApplicationPaths.ExecutablePath + @""" ""%1"""); Environment.Exit(0); } catch (Exception Exception) { Console.Error.WriteLine(Exception); Environment.Exit(-1); } }); Getopt.AddRule("/viewout", () => { RunTestsViewOut = true; }); Getopt.AddRule("/timeout", (int seconds) => { RunTestsTimeout = seconds; }); Getopt.AddRule("/tests", () => { RunTests(RunTestsViewOut, Getopt.DequeueAllNext(), RunTestsTimeout); }); Getopt.AddRule((Name) => { FileToLoad = Name; }); } try { Getopt.Process(); } catch (Exception Exception) { Console.Error.WriteLine(Exception); Environment.Exit(-1); } Logger.Info("Running ... plat:{0} ... int*:{1}", Environment.Is64BitProcess ? "64bit" : "32bit", sizeof(int*)); { var MonoRuntimeType = Type.GetType("Mono.Runtime"); if (MonoRuntimeType != null) { var GetDisplayNameMethod = MonoRuntimeType.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (GetDisplayNameMethod != null) Console.WriteLine("Mono: {0}", GetDisplayNameMethod.Invoke(null, null)); } } Console.WriteLine("ImageRuntimeVersion: {0}", Assembly.GetExecutingAssembly().ImageRuntimeVersion); #if !RELEASE try { Console.OutputEncoding = Encoding.UTF8; Console.SetWindowSize(160, 60); Console.SetBufferSize(160, 2000); } catch { } #endif /* foreach (var NI in NetworkInterface.GetAllNetworkInterfaces()) { if (NI.SupportsMulticast && NI.OperationalStatus == OperationalStatus.Up) { var IPProperties = NI.GetIPProperties(); Console.WriteLine("[A]:{0}", NI.ToStringDefault()); foreach (var Item in IPProperties.DhcpServerAddresses) { Console.WriteLine("[B]:{0},{1}", Item.ToString(), Item.IsIPv6Multicast); } foreach (var Item in IPProperties.AnycastAddresses) { Console.WriteLine("[D]:{0}", Item.Address.ToString()); } foreach (var Item in IPProperties.MulticastAddresses) { Console.WriteLine("[E]:{0}", Item.Address.ToString()); } foreach (var Item in IPProperties.UnicastAddresses) { Console.WriteLine("[F]:{0}", Item.Address.ToString()); } Console.WriteLine("[G]:{0}", NI.GetPhysicalAddress()); } else { Console.WriteLine("-"); } } */ using (var PspEmulator = new PspEmulator()) { //PspEmulator.UseFastMemory = true; var CodeBase = Assembly.GetExecutingAssembly().Location; var Base = Path.GetDirectoryName(CodeBase) + @"\" + Path.GetFileNameWithoutExtension(CodeBase); foreach (var TryExtension in new[] { "iso", "cso", "elf", "pbp" }) { var TryIsoFile = Base + "." + TryExtension; //Console.WriteLine(TryIsoFile); //Console.ReadKey(); if (File.Exists(TryIsoFile)) { Platform.HideConsole(); PspEmulator.StartAndLoad(TryIsoFile, TraceSyscalls: false, ShowMenus: false); return; } } if (FileToLoad != null) { PspEmulator.StartAndLoad(FileToLoad, TraceSyscalls: false); } else { //StartWithoutArguments(PspEmulator); PspEmulator.Start(); } } }
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; }