/// <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()); }
// SDK location: /user/pspiofilemgr.h:306 // SDK declaration: int sceIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen); public unsafe int sceIoDevctl(int dev, int cmd, int indata, int inlen, int outdata, int outlen) { // Usually callbacks are created right before this //Syscall: ThreadManForUser::sceKernelCreateCallback(08AE7638, 08A892D0, 00000000) from 0x08A87F70 //Syscall: IoFileMgrForUser::sceIoDevctl(08AE7628, 02415821, 08027BA4, 00000004, 00000000, 00000000) from 0x08A87FAC (NI) // Issue the last created callback? string name = _kernel.ReadString(( uint )dev); // We only support ms for now if ((name != "fatms0:") && (name != "mscmhc0:") && (name != "ms0:")) { Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceIoDevctl: device {0} not supported", name); return(0); } IMemoryStickDevice memoryStick = _kernel.Emulator.MemoryStick; Debug.Assert(memoryStick != null); byte *inp = ( byte * )0; byte *outp = ( byte * )0; if (indata != 0) { inp = _memorySystem.Translate(( uint )indata); } if (outdata != 0) { outp = _memorySystem.Translate(( uint )outdata); } switch (cmd) { case 0x02425818: // Write free space to indata Debug.Assert(inlen == 4); { uint capacity = ( uint )memoryStick.Capacity / (512 * 64); uint free = ( uint )memoryStick.Available / (512 * 64); // 0 * 3 * 4 = total bytes // 1 * 3 * 4 = total free bytes // 2 * 3 * 4 = slightly less than total free bytes? // 124958 42083 41968 512 64 if (indata != 0) { uint *p = ( uint * )_memorySystem.Translate(*( uint * )inp); p[0] = capacity; // total p[1] = free; // free p[2] = free - 115; p[3] = 512; // scalar 1 p[4] = 64; // scalar 2 } // Not sure if this is the right thing to do - outp seems to point to the // same address as *inp if (outdata != 0) { uint *p = ( uint * )outp; p[0] = capacity; // total p[1] = free; // free p[2] = free - 115; p[3] = 512; // scalar 1 p[4] = 64; // scalar 2 } } break; case 0x0240D81E: // Refresh directory listings - no params break; case 0x02025806: // Get insertion status // outdata should be pointer to dword to write 1 = in, 2 = out Debug.Assert(outlen == 4); *( uint * )outp = 1; break; case 0x02015804: // Some MS thing //Debug.Assert( inlen == 4 ); //{ // uint data = *( uint* )inp; //} //break; case 0x02415821: // Register insert/eject callback Debug.Assert(inlen == 4); { //Debug.Assert( _msInsertEjectCallback == null ); uint cbid = *( uint * )inp; _msInsertEjectCallback = _kernel.GetHandle <KCallback>(cbid); if (_msInsertEjectCallback != null) { Log.WriteLine(Verbosity.Normal, Feature.Bios, "Registered MemoryStick insert/eject callback: {0} ({1:X8})", _msInsertEjectCallback.Name, _msInsertEjectCallback.UID); _kernel.AddOneShotTimer(new KernelTimerCallback(this.MemoryStickInserted), _msInsertEjectCallback, 100); } else { Log.WriteLine(Verbosity.Critical, Feature.Bios, "sceIoDevctl: could not find callback {0} for MemoryStick insert/eject", cbid); } } break; case 0x02415822: // Unregister insert/eject callback Debug.Assert(inlen == 4); { uint cbid = *( uint * )inp; Debug.Assert(_msInsertEjectCallback != null); Debug.Assert(_msInsertEjectCallback.UID == cbid); // We may have multiple callbacks and stuff, but I don't care _msInsertEjectCallback = null; } break; case 0x02425823: // Unknown - guessing wait on MS insert/eject? Forever? if (outp != null) { *( uint * )outp = 1; } //return unchecked( ( int )0x80020325 ); break; case DevctlActivateUmd: // Activate the UMD drive for real? // Nothing? break; default: Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceIoDevctl: unknown command 0x" + cmd.ToString("X8") + " on device " + name); return(0); } return(0); }
/// <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(); }
public bool Create() { Debug.Assert( _isCreated == false ); if( _isCreated == true ) return true; _shutDown = false; _state = InstanceState.Idle; // Try to create all the components Debug.Assert( _params.BiosComponent != null ); Debug.Assert( _params.CpuComponent != null ); if( _params.AudioComponent != null ) { _audio = _params.AudioComponent.CreateInstance( this, _params[ _params.AudioComponent ] ) as IAudioDriver; _instances.Add( ( IComponentInstance )_audio ); } _cpu = _params.CpuComponent.CreateInstance( this, _params[ _params.CpuComponent ] ) as ICpu; _instances.Add( ( IComponentInstance )_cpu ); _bios = _params.BiosComponent.CreateInstance( this, _params[ _params.BiosComponent ] ) as IBios; _instances.Add( ( IComponentInstance )_bios ); foreach( IComponent component in _params.IOComponents ) { IIODriver driver = component.CreateInstance( this, _params[ component ] ) as IIODriver; _io.Add( driver ); _instances.Add( ( IComponentInstance )driver ); } if( _params.InputComponent != null ) { _input = _params.InputComponent.CreateInstance( this, _params[ _params.InputComponent ] ) as IInputDevice; _instances.Add( _input ); _input.WindowHandle = _host.Player.Handle; } if( _params.UmdComponent != null ) { _umd = _params.UmdComponent.CreateInstance( this, _params[ _params.UmdComponent ] ) as IUmdDevice; _instances.Add( _umd ); } if( _params.MemoryStickComponent != null ) { _memoryStick = _params.MemoryStickComponent.CreateInstance( this, _params[ _params.MemoryStickComponent ] ) as IMemoryStickDevice; _instances.Add( _memoryStick ); } if( _params.VideoComponent != null ) { _video = _params.VideoComponent.CreateInstance( this, _params[ _params.VideoComponent ] ) as IVideoDriver; _video.ControlHandle = _host.Player.ControlHandle; _instances.Add( ( IComponentInstance )_video ); } #if XMB _xmb = new CrossMediaBar.Manager( this, _host.Player.Handle, _host.Player.ControlHandle ); #else #endif // Create thread _thread = new Thread( new ThreadStart( this.RuntimeThread ) ); _thread.Name = "Host runtime thread"; _thread.IsBackground = true; _thread.Start(); _isCreated = true; return true; }
public bool Create() { Debug.Assert(_isCreated == false); if (_isCreated == true) { return(true); } _shutDown = false; _state = InstanceState.Idle; // Try to create all the components Debug.Assert(_params.BiosComponent != null); Debug.Assert(_params.CpuComponent != null); if (_params.AudioComponent != null) { _audio = _params.AudioComponent.CreateInstance(this, _params[_params.AudioComponent]) as IAudioDriver; _instances.Add(( IComponentInstance )_audio); } _cpu = _params.CpuComponent.CreateInstance(this, _params[_params.CpuComponent]) as ICpu; _instances.Add(( IComponentInstance )_cpu); _bios = _params.BiosComponent.CreateInstance(this, _params[_params.BiosComponent]) as IBios; _instances.Add(( IComponentInstance )_bios); foreach (IComponent component in _params.IOComponents) { IIODriver driver = component.CreateInstance(this, _params[component]) as IIODriver; _io.Add(driver); _instances.Add(( IComponentInstance )driver); } if (_params.InputComponent != null) { _input = _params.InputComponent.CreateInstance(this, _params[_params.InputComponent]) as IInputDevice; _instances.Add(_input); //_input.WindowHandle = _host.Player.Handle; } if (_params.UmdComponent != null) { _umd = _params.UmdComponent.CreateInstance(this, _params[_params.UmdComponent]) as IUmdDevice; _instances.Add(_umd); } if (_params.MemoryStickComponent != null) { _memoryStick = _params.MemoryStickComponent.CreateInstance(this, _params[_params.MemoryStickComponent]) as IMemoryStickDevice; _instances.Add(_memoryStick); } if (_params.VideoComponent != null) { _video = _params.VideoComponent.CreateInstance(this, _params[_params.VideoComponent]) as IVideoDriver; //_video.ControlHandle = _host.Player.ControlHandle; _instances.Add(( IComponentInstance )_video); } // Create thread _thread = new Thread(new ThreadStart(this.RuntimeThread)); _thread.Name = "Host runtime thread"; _thread.IsBackground = true; _thread.Start(); _isCreated = true; return(true); }