Пример #1
0
        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);
        }
Пример #2
0
 public XbeSection(XbeSectionHeader hdr)
 {
     SectionHeader = hdr;
     Address       = Address.Ptr32(SectionHeader.RawAddress);
     NameAddress   = Address.Ptr32(SectionHeader.SectionNameAddress);
 }
Пример #3
0
 public XbeSection(XbeSectionHeader hdr)
 {
     SectionHeader  = hdr;
     VirtualAddress = Address.Ptr32(SectionHeader.VirtualAddress);
     NameAddress    = Address.Ptr32(SectionHeader.SectionNameAddress);
 }