From 74aa7b20be5ef924f3e8cbde699fcf4f8431f750 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 12 Dec 2020 00:06:20 -0300 Subject: Rewrite size for fixed size buffers (#1808) --- Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Time') diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs index 8de3f726..dee3e476 100644 --- a/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs +++ b/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs @@ -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()); + 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()); + context.RequestData.BaseStream.Position += 7; SystemClockContext userContext = context.RequestData.ReadStruct(); @@ -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()); - - 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); } } } \ No newline at end of file -- cgit v1.2.3