0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-25 00:55:46 +00:00
Ryujinx/Ryujinx.HLE/HOS/Services/Android/Parcel.cs
Ac_K a0720b5681 Refactoring HOS folder structure (#771)
* Refactoring HOS folder structure

Refactoring HOS folder structure:

- Added some subfolders when needed (Following structure decided in private).
- Added some `Types` folders when needed.
- Little cleanup here and there.
- Add services placeholders for every HOS services (close #766 and #753).

* Remove Types namespaces
2019-09-19 10:45:11 +10:00

58 lines
No EOL
1.5 KiB
C#

using System;
using System.IO;
namespace Ryujinx.HLE.HOS.Services.Android
{
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();
}
}
}
}