mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-10-19 21:21:41 +00:00
e174100474
* Implement many objects, improve logging. Change and rename folders of Services Add Logging of IpcMessage. Add "lm" Log Service. Parse Errors of SetTerminateResult Add Svc Calls. Add many object implementations. * Corrections Forgotten Debug Conf * Corrections 2 * Corrections 3 * Corrections 4
62 lines
No EOL
1.6 KiB
C#
62 lines
No EOL
1.6 KiB
C#
using ChocolArm64.Memory;
|
|
using Ryujinx.Core.OsHle.Ipc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
|
{
|
|
class IStorageAccessor : IIpcService
|
|
{
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
|
|
|
private IStorage Storage;
|
|
|
|
public IStorageAccessor(IStorage Storage)
|
|
{
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
{
|
|
{ 0, GetSize },
|
|
{ 11, Read }
|
|
};
|
|
|
|
this.Storage = Storage;
|
|
}
|
|
|
|
public long GetSize(ServiceCtx Context)
|
|
{
|
|
Context.ResponseData.Write((long)Storage.Data.Length);
|
|
|
|
return 0;
|
|
}
|
|
|
|
public long Read(ServiceCtx Context)
|
|
{
|
|
long ReadPosition = Context.RequestData.ReadInt64();
|
|
|
|
if (Context.Request.RecvListBuff.Count > 0)
|
|
{
|
|
long Position = Context.Request.RecvListBuff[0].Position;
|
|
short Size = Context.Request.RecvListBuff[0].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);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
} |