Ejemplo n.º 1
0
        private Program MakeProgram(EndianByteImageReader rdr)
        {
            if (container == null)
            {
                throw new InvalidOperationException();
            }

            var cfgSvc   = Services.RequireService <IConfigurationService>();
            var arch     = GetArchitecture(cfgSvc);
            var platform = GetPlatform(cfgSvc, arch);

            var pefSegments = container.GetImageSegments(rdr, PreferredBaseAddress !).ToArray();

            var segments = pefSegments.Select(s => s.Segment);
            var addrBase = pefSegments.Min(s => s.Segment.Address);
            var segMap   = new SegmentMap(addrBase, segments.ToArray());

            var pefFile     = PefFile.Load(container, pefSegments);
            var entryPoints = pefFile.GetEntryPoints(arch).ToSortedList(s => s.Address);
            var symbols     = pefFile.GetSymbols(arch).ToArray();

            var program = new Program(segMap, arch, platform)
            {
                EntryPoints = entryPoints
            };

            foreach (var sym in symbols)
            {
                program.ImageSymbols.Add(sym.Address, sym);
            }
            return(program);
        }
Ejemplo n.º 2
0
        public static PefFile Load(
            PefContainer container,
            PefImageSegment[] imageSegments
            )
        {
            var loaderInfo = ProcessLoaderSection(imageSegments);
            var obj        = new PefFile(container, imageSegments, loaderInfo);

            return(obj);
        }