diff options
Diffstat (limited to 'Ryujinx.HLE/HOS/Ipc/IpcMessage.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Ipc/IpcMessage.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs b/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs index c99ad622..e5b9bf04 100644 --- a/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs +++ b/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics; using System.IO; namespace Ryujinx.HLE.HOS.Ipc @@ -185,6 +186,53 @@ namespace Ryujinx.HLE.HOS.Ipc } } + public byte[] GetBytesTipc() + { + Debug.Assert(PtrBuff.Count == 0); + + using (MemoryStream ms = new MemoryStream()) + { + BinaryWriter writer = new BinaryWriter(ms); + + int word0; + int word1; + + word0 = (int)Type; + word0 |= (SendBuff.Count & 0xf) << 20; + word0 |= (ReceiveBuff.Count & 0xf) << 24; + word0 |= (ExchangeBuff.Count & 0xf) << 28; + + byte[] handleData = new byte[0]; + + if (HandleDesc != null) + { + handleData = HandleDesc.GetBytes(); + } + + int dataLength = RawData?.Length ?? 0; + + dataLength = ((dataLength + 3) & ~3) / 4; + + word1 = (dataLength & 0x3ff); + + if (HandleDesc != null) + { + word1 |= 1 << 31; + } + + writer.Write(word0); + writer.Write(word1); + writer.Write(handleData); + + if (RawData != null) + { + writer.Write(RawData); + } + + return ms.ToArray(); + } + } + private long GetPadSize16(long position) { if ((position & 0xf) != 0) |