private List <ImageSegment> LoadPrimarySections() { List <ImageSegment> segments = new List <ImageSegment>((int)hdr.NumberOfSections + 1); int i; for (i = 0; i < hdr.NumberOfSections; i++) { XbeSectionHeader sectionHeader = rdr.ReadStruct <XbeSectionHeader>(); XbeSection section = new XbeSection(sectionHeader); string sectionName = rdr.ReadAt <string>(section.NameAddress - ctx.BaseAddress, (rdr) => { return(rdr.ReadCString(PrimitiveType.Char, Encoding.ASCII).ToString()); }); long sectionOffset = section.Address - ctx.EntryPointAddress; AccessMode accessFlgs = AccessMode.Read; if (sectionHeader.Flags.HasFlag(XbeSectionFlags.Executable)) { accessFlgs |= AccessMode.Execute; } if (sectionHeader.Flags.HasFlag(XbeSectionFlags.Writable)) { accessFlgs |= AccessMode.Write; } ImageSegment segment = new ImageSegment( sectionName, new ByteMemoryArea(section.Address, rdr.ReadAt <byte[]>(sectionOffset, (rdr) => { return(rdr.CreateBinaryReader().ReadBytes((int)sectionHeader.RawSize)); })), accessFlgs); segments.Add(segment); } return(segments); }
public XbeSection(XbeSectionHeader hdr) { SectionHeader = hdr; Address = Address.Ptr32(SectionHeader.RawAddress); NameAddress = Address.Ptr32(SectionHeader.SectionNameAddress); }
public XbeSection(XbeSectionHeader hdr) { SectionHeader = hdr; VirtualAddress = Address.Ptr32(SectionHeader.VirtualAddress); NameAddress = Address.Ptr32(SectionHeader.SectionNameAddress); }