mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-08-02 21:07:10 +02:00
Ipc refactor (#9)
* Start refactoring IPC objects (started with IFile and IFileSystem) * End refactoring IPC objects (#8) * End refactoring IPC objects * End refactoring IPC objects corrections
This commit is contained in:
parent
7f4a190665
commit
322f28668d
62 changed files with 935 additions and 619 deletions
68
Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs
Normal file
68
Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using ChocolArm64.Memory;
|
||||
using Ryujinx.OsHle.Ipc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.OsHle.Objects.Am
|
||||
{
|
||||
class IStorageAccessor : IIpcInterface
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IStorage Storage { get; private set; }
|
||||
|
||||
public IStorageAccessor(IStorage Storage)
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, GetSize },
|
||||
{ 11, Read }
|
||||
};
|
||||
|
||||
this.Storage = Storage;
|
||||
}
|
||||
|
||||
public long GetSize(ServiceCtx Context)
|
||||
{
|
||||
IStorageAccessor Accessor = Context.GetObject<IStorageAccessor>();
|
||||
|
||||
Context.ResponseData.Write((long)Accessor.Storage.Data.Length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long Read(ServiceCtx Context)
|
||||
{
|
||||
IStorageAccessor Accessor = Context.GetObject<IStorageAccessor>();
|
||||
|
||||
IStorage Storage = Accessor.Storage;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue