1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-24 04:22:01 +00:00

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

@ -5,7 +5,7 @@ namespace Ryujinx.Core.OsHle.Ipc
struct IpcRecvListBuffDesc struct IpcRecvListBuffDesc
{ {
public long Position { get; private set; } public long Position { get; private set; }
public short Size { get; private set; } public long Size { get; private set; }
public IpcRecvListBuffDesc(BinaryReader Reader) public IpcRecvListBuffDesc(BinaryReader Reader)
{ {
@ -13,7 +13,7 @@ namespace Ryujinx.Core.OsHle.Ipc
Position = Value & 0xffffffffffff; 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) 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; return 0;
} }

View file

@ -35,19 +35,34 @@ namespace Ryujinx.Core.OsHle.Services.Am
public long Write(ServiceCtx Context) 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; return 0;
} }
public long Read(ServiceCtx Context) public long Read(ServiceCtx Context)
{ {
//TODO: Error conditions.
long ReadPosition = Context.RequestData.ReadInt64(); long ReadPosition = Context.RequestData.ReadInt64();
if (Context.Request.RecvListBuff.Count > 0) (long Position, long Size) = Context.Request.GetBufferType0x22();
{
long Position = Context.Request.RecvListBuff[0].Position;
short Size = Context.Request.RecvListBuff[0].Size;
byte[] Data; byte[] Data;
@ -55,7 +70,7 @@ namespace Ryujinx.Core.OsHle.Services.Am
{ {
Data = new byte[Size]; Data = new byte[Size];
Buffer.BlockCopy(Storage.Data, 0, Data, 0, Size); Buffer.BlockCopy(Storage.Data, 0, Data, 0, (int)Size);
} }
else else
{ {
@ -63,7 +78,6 @@ namespace Ryujinx.Core.OsHle.Services.Am
} }
AMemoryHelper.WriteBytes(Context.Memory, Position, Data); AMemoryHelper.WriteBytes(Context.Memory, Position, Data);
}
return 0; return 0;
} }

View file

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

View file

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