diff options
| author | Thomas Guillemard <me@thog.eu> | 2019-11-03 18:26:29 +0100 |
|---|---|---|
| committer | Ac_K <Acoustik666@gmail.com> | 2019-11-03 18:26:29 +0100 |
| commit | b29950dbd6657f6f6511bc2df2efc4b0ff40e8b9 (patch) | |
| tree | 204cba19b5fd54744d247119c0b725c89d524cc0 /Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs | |
| parent | 9426ef3f06916f4206213b28b1ca162c851d4e07 (diff) | |
hle: Fix some inconsistencies in namespace naming in Services (#808)
Also fix IShopServiceAccessSystemInterface being in the wrong namespace.
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs new file mode 100644 index 00000000..f5d93423 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs @@ -0,0 +1,58 @@ +using System; +using System.IO; + +namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger +{ + static class Parcel + { + public static byte[] GetParcelData(byte[] parcel) + { + if (parcel == null) + { + throw new ArgumentNullException(nameof(parcel)); + } + + using (MemoryStream ms = new MemoryStream(parcel)) + { + BinaryReader reader = new BinaryReader(ms); + + int dataSize = reader.ReadInt32(); + int dataOffset = reader.ReadInt32(); + int objsSize = reader.ReadInt32(); + int objsOffset = reader.ReadInt32(); + + ms.Seek(dataOffset - 0x10, SeekOrigin.Current); + + return reader.ReadBytes(dataSize); + } + } + + public static byte[] MakeParcel(byte[] data, byte[] objs) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (objs == null) + { + throw new ArgumentNullException(nameof(objs)); + } + + using (MemoryStream ms = new MemoryStream()) + { + BinaryWriter writer = new BinaryWriter(ms); + + writer.Write(data.Length); + writer.Write(0x10); + writer.Write(objs.Length); + writer.Write(data.Length + 0x10); + + writer.Write(data); + writer.Write(objs); + + return ms.ToArray(); + } + } + } +}
\ No newline at end of file |
