Il2CppDumper/Il2CppDumper/MachoFat.cs
Perfare 195eef8d7c 完善Macho文件的处理
细节调整
2019-04-12 06:24:38 +08:00

40 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Il2CppDumper
{
public sealed class MachoFat : MyBinaryReader
{
public Fat[] fats;
public MachoFat(Stream stream) : base(stream)
{
//BigEndian
Position += 4;
var size = BitConverter.ToInt32(ReadBytes(4).Reverse().ToArray(), 0);
fats = new Fat[size];
for (var i = 0; i < size; i++)
{
Position += 8;
fats[i] = new Fat();
fats[i].offset = BitConverter.ToUInt32(ReadBytes(4).Reverse().ToArray(), 0);
fats[i].size = BitConverter.ToUInt32(ReadBytes(4).Reverse().ToArray(), 0);
Position += 4;
}
for (var i = 0; i < size; i++)
{
Position = fats[i].offset;
fats[i].magic = ReadUInt32();
}
}
public byte[] GetMacho(int index)
{
Position = fats[index].offset;
return ReadBytes((int)fats[index].size);
}
}
}