Rewrite size for fixed size buffers (#1808)

This commit is contained in:
gdkchan 2020-12-12 00:06:20 -03:00 committed by GitHub
parent 06057a99a6
commit 74aa7b20be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 21 deletions

View file

@ -1,4 +1,5 @@
using Ryujinx.Common;
using Ryujinx.Cpu;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
@ -245,6 +246,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
{
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);
if (result == ResultCode.Success)
@ -271,6 +274,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
{
byte type = context.RequestData.ReadByte();
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(Marshal.SizeOf<ClockSnapshot>());
context.RequestData.BaseStream.Position += 7;
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)
{
Debug.Assert(ipcDesc.Size == Marshal.SizeOf<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();
MemoryHelper.Write(context.Memory, ipcDesc.Position, clockSnapshot);
}
}
}