mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-24 05:22:00 +00:00
fb1d9493a3
* Rename enum fields
* Naming conventions
* Remove unneeded ".this"
* Remove unneeded semicolons
* Remove unused Usings
* Don't use var
* Remove unneeded enum underlying types
* Explicitly label class visibility
* Remove unneeded @ prefixes
* Remove unneeded commas
* Remove unneeded if expressions
* Method doesn't use unsafe code
* Remove unneeded casts
* Initialized objects don't need an empty constructor
* Remove settings from DotSettings
* Revert "Explicitly label class visibility"
This reverts commit ad5eb5787c
.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Apply previous refactorings to the merged code
58 lines
No EOL
1.5 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|
|
} |