2018-02-04 15:08:20 -08:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
|
2018-08-16 16:47:36 -07:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Android
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
|
|
|
static class Parcel
|
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
public static byte[] GetParcelData(byte[] Parcel)
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
if (Parcel == null)
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
throw new ArgumentNullException(nameof(Parcel));
|
2018-02-04 15:08:20 -08:00
|
|
|
}
|
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
using (MemoryStream MS = new MemoryStream(Parcel))
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
BinaryReader Reader = new BinaryReader(MS);
|
2018-02-04 15:08:20 -08:00
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
int DataSize = Reader.ReadInt32();
|
|
|
|
int DataOffset = Reader.ReadInt32();
|
|
|
|
int ObjsSize = Reader.ReadInt32();
|
|
|
|
int ObjsOffset = Reader.ReadInt32();
|
2018-02-04 15:08:20 -08:00
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
MS.Seek(DataOffset - 0x10, SeekOrigin.Current);
|
2018-02-04 15:08:20 -08:00
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
return Reader.ReadBytes(DataSize);
|
2018-02-04 15:08:20 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
public static byte[] MakeParcel(byte[] Data, byte[] Objs)
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
if (Data == null)
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
throw new ArgumentNullException(nameof(Data));
|
2018-02-04 15:08:20 -08:00
|
|
|
}
|
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
if (Objs == null)
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
throw new ArgumentNullException(nameof(Objs));
|
2018-02-04 15:08:20 -08:00
|
|
|
}
|
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
using (MemoryStream MS = new MemoryStream())
|
2018-02-04 15:08:20 -08:00
|
|
|
{
|
2018-12-04 16:52:39 -08:00
|
|
|
BinaryWriter Writer = new BinaryWriter(MS);
|
2018-02-04 15:08:20 -08:00
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
Writer.Write(Data.Length);
|
|
|
|
Writer.Write(0x10);
|
|
|
|
Writer.Write(Objs.Length);
|
|
|
|
Writer.Write(Data.Length + 0x10);
|
2018-02-04 15:08:20 -08:00
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
Writer.Write(Data);
|
|
|
|
Writer.Write(Objs);
|
2018-02-04 15:08:20 -08:00
|
|
|
|
2018-12-04 16:52:39 -08:00
|
|
|
return MS.ToArray();
|
2018-02-04 15:08:20 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|