From fa2cf7f89c97b8cb31f205895ffc2f7e913858b8 Mon Sep 17 00:00:00 2001 From: Sajid Anwar Date: Fri, 15 Jun 2018 01:59:26 -0700 Subject: [PATCH] Update BSD service to handle libnx's 'smart IPC buffers' for address info --- Ryujinx.HLE/OsHle/Services/Bsd/IClient.cs | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Services/Bsd/IClient.cs b/Ryujinx.HLE/OsHle/Services/Bsd/IClient.cs index 15ce92a16..98b4b2988 100644 --- a/Ryujinx.HLE/OsHle/Services/Bsd/IClient.cs +++ b/Ryujinx.HLE/OsHle/Services/Bsd/IClient.cs @@ -180,8 +180,7 @@ namespace Ryujinx.HLE.OsHle.Services.Bsd byte[] SentBuffer = Context.Memory.ReadBytes(Context.Request.SendBuff[0].Position, Context.Request.SendBuff[0].Size); - byte[] AddressBuffer = Context.Memory.ReadBytes(Context.Request.SendBuff[1].Position, - Context.Request.SendBuff[1].Size); + byte[] AddressBuffer = ReadSmartBuffer(Context, 1); if (!Sockets[SocketId].Handle.Connected) { @@ -286,8 +285,7 @@ namespace Ryujinx.HLE.OsHle.Services.Bsd { int SocketId = Context.RequestData.ReadInt32(); - byte[] AddressBuffer = Context.Memory.ReadBytes(Context.Request.SendBuff[0].Position, - Context.Request.SendBuff[0].Size); + byte[] AddressBuffer = ReadSmartBuffer(Context, 0); try { @@ -310,8 +308,7 @@ namespace Ryujinx.HLE.OsHle.Services.Bsd { int SocketId = Context.RequestData.ReadInt32(); - byte[] AddressBuffer = Context.Memory.ReadBytes(Context.Request.SendBuff[0].Position, - Context.Request.SendBuff[0].Size); + byte[] AddressBuffer = ReadSmartBuffer(Context, 0); try { @@ -426,6 +423,21 @@ namespace Ryujinx.HLE.OsHle.Services.Bsd } } + private byte[] ReadSmartBuffer(ServiceCtx Context, int Index) + { + if (Context.Request.SendBuff[Index].Position != 0 && + Context.Request.SendBuff[Index].Size != 0) + { + return Context.Memory.ReadBytes(Context.Request.SendBuff[Index].Position, + Context.Request.SendBuff[Index].Size); + } + else + { + return Context.Memory.ReadBytes(Context.Request.PtrBuff[Index].Position, + Context.Request.PtrBuff[Index].Size); + } + } + private int Get16(byte[] Data, int Address) { return