protected override void UnpackageData(ReadingContext SR, int CommandSize) { // Read the segment SegmentName = SR.ReadFixedASCII(16); VirtualAddress = SR.ReadUInt(AddressSize); VirtualSize = SR.ReadUInt(AddressSize); FileOffset = SR.ReadUInt(AddressSize); FileSize = SR.ReadUInt(AddressSize); MaxProt = SR.ReadUInt32(); InitProt = SR.ReadUInt32(); UInt32 SectionCount = SR.ReadUInt32(); Flags = SR.ReadUInt32(); // Read the segment data //SR.PushPositionAndJump(FileOffset); //FileData = SR.ReadBytes(FileSize); //SR.PopPosition(); // Read the sections belonging to the segment for (int SectionIndex = 0; SectionIndex < SectionCount; ++SectionIndex) { MachSection Section = new MachSection(AddressSize); Section.Read(SR); Sections.Add(Section); } }
public void Read(ReadingContext SR) { SectionName = SR.ReadFixedASCII(16); SegmentName = SR.ReadFixedASCII(16); Addr = SR.ReadUInt(AddressSize); Size = SR.ReadUInt(AddressSize); UInt32 FileOffset = SR.ReadUInt32(); LogAlignment = SR.ReadUInt32(); RelocationOffset = SR.ReadUInt32(); NumRelocations = SR.ReadUInt32(); Flags = (int)SR.ReadUInt32(); Reserved1 = SR.ReadUInt32(); Reserved2 = SR.ReadUInt32(); if (AddressSize == Bits.Num._64) Reserved3 = SR.ReadUInt32(); if ((SectionType == S_ZEROFILL) || (SectionType == S_GB_ZEROFILL)) { Debug.Assert(FileOffset == 0); SectionData = null; } else { SR.PushPositionAndJump((long)FileOffset); SectionData = SR.ReadBytes((int)Size); SR.PopPosition(); } if (Config.bCodeSignVerbose) { Console.WriteLine(" v Read Section '{0}' in segment '{1}' with size {2} and offset 0x{3:X} and align {4} and flags {5:X}", SectionName, SegmentName, Size, FileOffset, 1 << (byte)LogAlignment, Flags); } }