Beispiel #1
0
        private void ReadFile(BinaryReaderBigEndian reader)
        {
            var magic = reader.ReadUInt32();

            if (magic == 0xCAFEBABE)
            {
                ReadFatFile(reader);
                foreach (var entry in _fatEntries)
                {
                    Console.WriteLine($"Details for {entry.cputype}");
                    reader.BaseStream.Seek(entry.offset, SeekOrigin.Begin);
                    ReadFile(reader);
                    entry.path      = _path;
                    entry.archentry = _entry;
                    _entry          = null;
                }
            }
            else if (magic == 0xCEFAEDFE)
            {
                ReadFileArch32(reader);
            }
            else if (magic == 0xCFFAEDFE)
            {
                ReadFileArch64(reader);
            }
            else
            {
                throw new ApplicationException($"File {_path} contains unknown Mach-O header");
            }
        }
Beispiel #2
0
        private void ReadFileArch32(BinaryReader reader)
        {
            _entry = new MachOArchEntry
            {
                cputype    = (MachOCpuType)reader.ReadUInt32(),
                cpusubtype = (MachOCpuSubType)reader.ReadUInt32(),
                filetype   = reader.ReadUInt32(),
                ncmds      = reader.ReadUInt32(),
                sizeofcmds = reader.ReadUInt32(),
                flags      = reader.ReadUInt32()
            };

            Console.WriteLine($"Found {_entry.cputype} filetype {_entry.filetype} flags {_entry.flags}");
        }