Rewrite size for fixed size buffers (#1808)
This commit is contained in:
parent
06057a99a6
commit
74aa7b20be
@ -37,7 +37,7 @@ namespace Ryujinx.Cpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe static void Write<T>(IVirtualMemoryManager memory, long position, T value) where T : struct
|
public unsafe static long Write<T>(IVirtualMemoryManager memory, long position, T value) where T : struct
|
||||||
{
|
{
|
||||||
long size = Marshal.SizeOf<T>();
|
long size = Marshal.SizeOf<T>();
|
||||||
|
|
||||||
@ -49,6 +49,8 @@ namespace Ryujinx.Cpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
memory.Write((ulong)position, data);
|
memory.Write((ulong)position, data);
|
||||||
|
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadAsciiString(IVirtualMemoryManager memory, long position, long maxSize = -1)
|
public static string ReadAsciiString(IVirtualMemoryManager memory, long position, long maxSize = -1)
|
||||||
|
@ -30,6 +30,11 @@ namespace Ryujinx.HLE.HOS.Ipc
|
|||||||
Size = (ushort)(word0 >> 16);
|
Size = (ushort)(word0 >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IpcPtrBuffDesc WithSize(long size)
|
||||||
|
{
|
||||||
|
return new IpcPtrBuffDesc(Position, Index, size);
|
||||||
|
}
|
||||||
|
|
||||||
public uint GetWord0()
|
public uint GetWord0()
|
||||||
{
|
{
|
||||||
uint word0;
|
uint word0;
|
||||||
|
@ -122,6 +122,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
|||||||
|
|
||||||
context.ResponseData.Write(NetworkServiceAccountId);
|
context.ResponseData.Write(NetworkServiceAccountId);
|
||||||
|
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0L);
|
||||||
|
|
||||||
// TODO: determine and fill the two output IPC buffers.
|
// TODO: determine and fill the two output IPC buffers.
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -24,6 +24,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
|||||||
{
|
{
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceAcc);
|
Logger.Stub?.PrintStub(LogClass.ServiceAcc);
|
||||||
|
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x80L);
|
||||||
|
|
||||||
long position = context.Request.ReceiveBuff[0].Position;
|
long position = context.Request.ReceiveBuff[0].Position;
|
||||||
|
|
||||||
MemoryHelper.FillWithZeros(context.Memory, position, 0x80);
|
MemoryHelper.FillWithZeros(context.Memory, position, 0x80);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Cpu;
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
@ -48,21 +49,17 @@ namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
|||||||
Result = 0
|
Result = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
WriteDeliveryCacheProgressImpl(context, context.Request.RecvListBuff[0], deliveryCacheProgress);
|
long dcpSize = WriteDeliveryCacheProgressImpl(context, context.Request.RecvListBuff[0], deliveryCacheProgress);
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(dcpSize);
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteDeliveryCacheProgressImpl(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, DeliveryCacheProgressImpl deliveryCacheProgress)
|
private long WriteDeliveryCacheProgressImpl(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, DeliveryCacheProgressImpl deliveryCacheProgress)
|
||||||
{
|
{
|
||||||
using (MemoryStream memory = new MemoryStream((int)ipcDesc.Size))
|
return MemoryHelper.Write(context.Memory, ipcDesc.Position, deliveryCacheProgress);
|
||||||
using (BinaryWriter bufferWriter = new BinaryWriter(memory))
|
|
||||||
{
|
|
||||||
bufferWriter.WriteStruct(deliveryCacheProgress);
|
|
||||||
context.Memory.Write((ulong)ipcDesc.Position, memory.ToArray());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -221,6 +221,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
|
|||||||
bool unknownBool = context.RequestData.ReadBoolean();
|
bool unknownBool = context.RequestData.ReadBoolean();
|
||||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||||
|
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x40L);
|
||||||
|
|
||||||
long bufferPosition = context.Request.RecvListBuff[0].Position;
|
long bufferPosition = context.Request.RecvListBuff[0].Position;
|
||||||
|
|
||||||
if (userId.IsNull)
|
if (userId.IsNull)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
|
using Ryujinx.Cpu;
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
@ -245,6 +246,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||||||
{
|
{
|
||||||
byte type = context.RequestData.ReadByte();
|
byte type = context.RequestData.ReadByte();
|
||||||
|
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(Marshal.SizeOf<ClockSnapshot>());
|
||||||
|
|
||||||
ResultCode result = _timeManager.StandardUserSystemClock.GetClockContext(context.Thread, out SystemClockContext userContext);
|
ResultCode result = _timeManager.StandardUserSystemClock.GetClockContext(context.Thread, out SystemClockContext userContext);
|
||||||
|
|
||||||
if (result == ResultCode.Success)
|
if (result == ResultCode.Success)
|
||||||
@ -271,6 +274,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||||||
{
|
{
|
||||||
byte type = context.RequestData.ReadByte();
|
byte type = context.RequestData.ReadByte();
|
||||||
|
|
||||||
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(Marshal.SizeOf<ClockSnapshot>());
|
||||||
|
|
||||||
context.RequestData.BaseStream.Position += 7;
|
context.RequestData.BaseStream.Position += 7;
|
||||||
|
|
||||||
SystemClockContext userContext = context.RequestData.ReadStruct<SystemClockContext>();
|
SystemClockContext userContext = context.RequestData.ReadStruct<SystemClockContext>();
|
||||||
@ -413,17 +418,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||||||
|
|
||||||
private void WriteClockSnapshotFromBuffer(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, ClockSnapshot clockSnapshot)
|
private void WriteClockSnapshotFromBuffer(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, ClockSnapshot clockSnapshot)
|
||||||
{
|
{
|
||||||
Debug.Assert(ipcDesc.Size == Marshal.SizeOf<ClockSnapshot>());
|
MemoryHelper.Write(context.Memory, ipcDesc.Position, clockSnapshot);
|
||||||
|
|
||||||
MemoryStream memory = new MemoryStream((int)ipcDesc.Size);
|
|
||||||
|
|
||||||
using (BinaryWriter bufferWriter = new BinaryWriter(memory))
|
|
||||||
{
|
|
||||||
bufferWriter.WriteStruct(clockSnapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Memory.Write((ulong)ipcDesc.Position, memory.ToArray());
|
|
||||||
memory.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user