static object ReadFile(BinaryReader reader, string filename) { var magic = reader.ReadUInt32(); reader.BaseStream.Position = 0; switch (magic) { case MH_MAGIC: case MH_MAGIC_64: var mf = new MachOFile(filename); mf.Read(reader); return(mf); case FAT_MAGIC: // little-endian fat binary case FAT_CIGAM: // big-endian fat binary { var f = new FatFile(filename); f.Read(reader); return(f); } default: if (StaticLibrary.IsStaticLibrary(reader)) { var sl = new StaticLibrary(); sl.Read(filename, reader, reader.BaseStream.Length); return(sl); } throw new Exception(string.Format("File format not recognized: {0} (magic: 0x{1})", filename, magic.ToString("X"))); } }
internal void Read(FatFile parent, BinaryReader reader) { this.parent = parent; cputype = reader.ReadInt32 (); cpusubtype = reader.ReadInt32 (); offset = reader.ReadUInt32 (); size = reader.ReadUInt32 (); align = reader.ReadUInt32 (); if (parent.is_big_endian) { cputype = MachO.FromBigEndian (cputype); cpusubtype = MachO.FromBigEndian (cpusubtype); offset = MachO.FromBigEndian (offset); size = MachO.FromBigEndian (size); align = MachO.FromBigEndian (align); } }
internal void Read(FatFile parent, BinaryReader reader) { this.parent = parent; cputype = reader.ReadInt32(); cpusubtype = reader.ReadInt32(); offset = reader.ReadUInt32(); size = reader.ReadUInt32(); align = reader.ReadUInt32(); if (parent.is_big_endian) { cputype = MachO.FromBigEndian(cputype); cpusubtype = MachO.FromBigEndian(cpusubtype); offset = MachO.FromBigEndian(offset); size = MachO.FromBigEndian(size); align = MachO.FromBigEndian(align); } }
static object ReadFile(BinaryReader reader, string filename) { var magic = reader.ReadUInt32 (); reader.BaseStream.Position = 0; switch (magic) { case MH_MAGIC: case MH_MAGIC_64: var mf = new MachOFile (filename); mf.Read (reader); return mf; case FAT_MAGIC: // little-endian fat binary case FAT_CIGAM: // big-endian fat binary { var f = new FatFile (filename); f.Read (reader); return f; } default: if (StaticLibrary.IsStaticLibrary (reader)) { var sl = new StaticLibrary (); sl.Read (reader); return sl; } throw new Exception (string.Format ("File format not recognized: {0} (magic: 0x{1})", filename, magic.ToString ("X"))); } }