void parseSection64(uint protection, SegmentMap segmentMap) { var abSectname = rdr.ReadBytes(16); var abSegname = rdr.ReadBytes(16); ulong addr; ulong size; uint offset; uint align; uint reloff; uint nreloc; uint flags; uint reserved1; uint reserved2; uint reserved3; if (!rdr.TryReadUInt64(out addr) || !rdr.TryReadUInt64(out size) || !rdr.TryReadUInt32(out offset) || !rdr.TryReadUInt32(out align) || !rdr.TryReadUInt32(out reloff) || !rdr.TryReadUInt32(out nreloc) || !rdr.TryReadUInt32(out flags) || !rdr.TryReadUInt32(out reserved1) || !rdr.TryReadUInt32(out reserved2) || !rdr.TryReadUInt32(out reserved3)) { throw new BadImageFormatException("Could not read Mach-O section."); } var sectionName = GetAsciizString(abSectname); var segmentName = GetAsciizString(abSegname); Debug.Print("Found section '{0}' in segment '{1}, addr = 0x{2:X}, size = 0x{3:X}.", sectionName, segmentName, addr, size); AccessMode am = 0; if ((protection & VM_PROT_READ) != 0) { am |= AccessMode.Read; } if ((protection & VM_PROT_WRITE) != 0) { am |= AccessMode.Write; } if ((protection & VM_PROT_EXECUTE) != 0) { am |= AccessMode.Execute; } var bytes = rdr.CreateNew(this.ldr.RawImage, offset); var mem = new MemoryArea( Address.Ptr64(addr), bytes.ReadBytes((uint)size)); var imageSection = new ImageSegment( string.Format("{0},{1}", segmentName, sectionName), mem, am); //imageSection.setBss((section.flags & SECTION_TYPE) == S_ZEROFILL); //if (!imageSection.isBss()) { // auto pos = source_->pos(); // if (!source_->seek(section.offset)) { // throw ParseError("Could not seek to the beginning of the section's content."); // } // auto bytes = source_->read(section.size); // if (checked_cast<uint>(bytes.size()) != section.size) { // log_.warning("Could not read all the section's content."); // } else { // imageSection->setContent(std::move(bytes)); // } // source_->seek(pos); //} //sections_.push_back(imageSection.get()); //image_->addSection(std::move(imageSection)); segmentMap.AddSegment(imageSection); }