Fix Rename* functions on FspSrv, add a separate class do hold system settings on Switch

This commit is contained in:
gdkchan 2018-03-03 14:04:58 -03:00
parent 646af2498c
commit 7d48886750
5 changed files with 44 additions and 27 deletions

View file

@ -50,7 +50,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
long Mode = Context.RequestData.ReadInt64();
int Size = Context.RequestData.ReadInt32();
@ -84,7 +84,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -107,7 +107,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
string DirName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -145,7 +145,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
string DirName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -166,11 +166,8 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
public long RenameFile(ServiceCtx Context)
{
long OldPosition = Context.Request.PtrBuff[0].Position;
long NewPosition = Context.Request.PtrBuff[0].Position;
string OldName = ReadUtf8String(Context.Memory, OldPosition);
string NewName = ReadUtf8String(Context.Memory, NewPosition);
string OldName = ReadUtf8String(Context, 0);
string NewName = ReadUtf8String(Context, 1);
string OldFileName = Context.Ns.VFs.GetFullPath(Path, OldName);
string NewFileName = Context.Ns.VFs.GetFullPath(Path, NewName);
@ -197,11 +194,8 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
public long RenameDirectory(ServiceCtx Context)
{
long OldPosition = Context.Request.PtrBuff[0].Position;
long NewPosition = Context.Request.PtrBuff[0].Position;
string OldName = ReadUtf8String(Context.Memory, OldPosition);
string NewName = ReadUtf8String(Context.Memory, NewPosition);
string OldName = ReadUtf8String(Context, 0);
string NewName = ReadUtf8String(Context, 1);
string OldDirName = Context.Ns.VFs.GetFullPath(Path, OldName);
string NewDirName = Context.Ns.VFs.GetFullPath(Path, NewName);
@ -230,7 +224,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -258,7 +252,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
int FilterFlags = Context.RequestData.ReadInt32();
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -294,7 +288,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
int FilterFlags = Context.RequestData.ReadInt32();
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
string DirName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -331,7 +325,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
Context.ResponseData.Write(Context.Ns.VFs.GetDrive().AvailableFreeSpace);
@ -342,7 +336,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context.Memory, Position);
string Name = ReadUtf8String(Context);
Context.ResponseData.Write(Context.Ns.VFs.GetDrive().TotalSize);
@ -381,13 +375,16 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
}
}
private string ReadUtf8String(AMemory Memory, long Position)
private string ReadUtf8String(ServiceCtx Context, int Index = 0)
{
long Position = Context.Request.PtrBuff[Index].Position;
long Size = Context.Request.PtrBuff[Index].Size;
using (MemoryStream MS = new MemoryStream())
{
while (true)
while (Size-- > 0)
{
byte Value = Memory.ReadByte(Position++);
byte Value = Context.Memory.ReadByte(Position++);
if (Value == 0)
{

View file

@ -22,8 +22,8 @@ namespace Ryujinx.Core.OsHle.IpcServices.Set
public static long GetColorSetId(ServiceCtx Context)
{
//Use white system theme
Context.ResponseData.Write(1);
Context.ResponseData.Write((int)Context.Ns.Settings.ThemeColor);
return 0;
}

View file

@ -0,0 +1,8 @@
namespace Ryujinx.Core.Settings
{
public enum ColorSet
{
BasicWhite = 0,
BasicBlack = 1
}
}

View file

@ -0,0 +1,7 @@
namespace Ryujinx.Core.Settings
{
public class SetSys
{
public ColorSet ThemeColor;
}
}

View file

@ -1,6 +1,7 @@
using ChocolArm64.Memory;
using Ryujinx.Core.Input;
using Ryujinx.Core.OsHle;
using Ryujinx.Core.Settings;
using Ryujinx.Graphics.Gal;
using Ryujinx.Graphics.Gpu;
using System;
@ -15,7 +16,9 @@ namespace Ryujinx.Core
internal NsGpu Gpu { get; private set; }
internal Horizon Os { get; private set; }
internal VirtualFs VFs { get; private set; }
public Hid Hid { get; private set; }
public Hid Hid { get; private set; }
public SetSys Settings { get; private set; }
public event EventHandler Finish;
@ -24,9 +27,11 @@ namespace Ryujinx.Core
Ram = Marshal.AllocHGlobal((IntPtr)AMemoryMgr.RamSize);
Gpu = new NsGpu(Renderer);
Os = new Horizon(this);
VFs = new VirtualFs();
Hid = new Hid(this);
Hid = new Hid(this);
Os = new Horizon(this);
Settings = new SetSys();
}
public void FinalizeAllProcesses()