Fix ILibraryAppletCreator CreateStorage, implement Write on IStorageAccessor

This commit is contained in:
gdkchan 2018-06-04 02:09:41 -03:00
parent e7efee7909
commit 741ec27b1d
5 changed files with 43 additions and 29 deletions

View File

@ -4,8 +4,8 @@ namespace Ryujinx.Core.OsHle.Ipc
{
struct IpcRecvListBuffDesc
{
public long Position { get; private set; }
public short Size { get; private set; }
public long Position { get; private set; }
public long Size { get; private set; }
public IpcRecvListBuffDesc(BinaryReader Reader)
{
@ -13,7 +13,7 @@ namespace Ryujinx.Core.OsHle.Ipc
Position = Value & 0xffffffffffff;
Size = (short)(Value >> 48);
Size = (ushort)(Value >> 48);
}
}
}

View File

@ -27,7 +27,9 @@ namespace Ryujinx.Core.OsHle.Services.Am
public long CreateStorage(ServiceCtx Context)
{
MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams()));
long Size = Context.RequestData.ReadInt64();
MakeObject(Context, new IStorage(new byte[Size]));
return 0;
}

View File

@ -35,35 +35,49 @@ namespace Ryujinx.Core.OsHle.Services.Am
public long Write(ServiceCtx Context)
{
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
//TODO: Error conditions.
long WritePosition = Context.RequestData.ReadInt64();
(long Position, long Size) = Context.Request.GetBufferType0x21();
if (Size > 0)
{
long MaxSize = Storage.Data.Length - WritePosition;
if (Size > MaxSize)
{
Size = MaxSize;
}
byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, Position, Size);
Buffer.BlockCopy(Data, 0, Storage.Data, (int)WritePosition, (int)Size);
}
return 0;
}
public long Read(ServiceCtx Context)
{
//TODO: Error conditions.
long ReadPosition = Context.RequestData.ReadInt64();
if (Context.Request.RecvListBuff.Count > 0)
(long Position, long Size) = Context.Request.GetBufferType0x22();
byte[] Data;
if (Storage.Data.Length > Size)
{
long Position = Context.Request.RecvListBuff[0].Position;
short Size = Context.Request.RecvListBuff[0].Size;
Data = new byte[Size];
byte[] Data;
if (Storage.Data.Length > Size)
{
Data = new byte[Size];
Buffer.BlockCopy(Storage.Data, 0, Data, 0, Size);
}
else
{
Data = Storage.Data;
}
AMemoryHelper.WriteBytes(Context.Memory, Position, Data);
Buffer.BlockCopy(Storage.Data, 0, Data, 0, (int)Size);
}
else
{
Data = Storage.Data;
}
AMemoryHelper.WriteBytes(Context.Memory, Position, Data);
return 0;
}

View File

@ -158,8 +158,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud
{
float Volume = Context.RequestData.ReadSingle();
long Position = Context.Request.SendBuff[0].Position;
long Size = Context.Request.SendBuff[0].Size;
(long Position, long Size) = Context.Request.GetBufferType0x21();
byte[] DeviceNameBuffer = AMemoryHelper.ReadBytes(Context.Memory, Position, Size);
@ -183,8 +182,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud
{
string Name = Context.Ns.Os.SystemState.ActiveAudioOutput;
long Position = Context.Request.RecvListBuff[0].Position;
long Size = Context.Request.RecvListBuff[0].Size;
(long Position, long Size) = Context.Request.GetBufferType0x22();
byte[] DeviceNameBuffer = Encoding.UTF8.GetBytes(Name + '\0');

View File

@ -28,10 +28,10 @@ namespace Ryujinx.Core.OsHle.Services.Set
public static long GetAvailableLanguageCodes(ServiceCtx Context)
{
long Position = Context.Request.RecvListBuff[0].Position;
short Size = Context.Request.RecvListBuff[0].Size;
long Position = Context.Request.RecvListBuff[0].Position;
long Size = Context.Request.RecvListBuff[0].Size;
int Count = (int)((uint)Size / 8);
int Count = (int)(Size / 8);
if (Count > SystemStateMgr.LanguageCodes.Length)
{