public override Program Load(Address?addrLoad) { var rdr = new BeImageReader(RawImage); var header = rdr.ReadStruct <filehdr>(); if (header.f_opthdr != 0) { var sectionOffset = rdr.Offset + header.f_opthdr; opthdr = rdr.ReadStruct <aouthdr>(); rdr.Offset = sectionOffset; } var sections = new scnhdr[header.f_nscns]; for (int i = 0; i < sections.Length; ++i) { sections[i] = rdr.ReadStruct <scnhdr>(); } var imgSegments = new ImageSegment[header.f_nscns]; for (int i = 0; i < sections.Length; ++i) { imgSegments[i] = LoadImageSegment(sections[i]); } var arch = LoadArchitecture(header.f_magic); var platform = new DefaultPlatform(Services, arch); var segmap = new SegmentMap(imgSegments); return(new Program(segmap, arch, platform)); }
public override Program LoadProgram(Address?addrLoad) { var rdr = new BeImageReader(RawImage); var header = rdr.ReadStruct <filehdr>(); if (header.f_opthdr != 0) { var sectionOffset = rdr.Offset + header.f_opthdr; opthdr = rdr.ReadStruct <aouthdr>(); rdr.Offset = sectionOffset; } var sections = new scnhdr[header.f_nscns]; for (int i = 0; i < sections.Length; ++i) { sections[i] = rdr.ReadStruct <scnhdr>(); } var imgSegments = new ImageSegment[header.f_nscns]; for (int i = 0; i < sections.Length; ++i) { imgSegments[i] = LoadImageSegment(sections[i]); } var arch = LoadArchitecture(header.f_magic); var platform = new DefaultPlatform(Services, arch); var segmap = new SegmentMap(imgSegments); var program = new Program(segmap, arch, platform); if (this.opthdr.HasValue) { var addrEntry = Address.Ptr32(opthdr.Value.entry); //$64 var ep = ImageSymbol.Procedure(program.Architecture, addrEntry, "_start"); program.EntryPoints.Add(ep.Address, ep); } return(program); }