示例#1
0
        public override Program Load(Address addrLoad)
        {
            BinHexDecoder dec = new BinHexDecoder(new StringReader(Encoding.ASCII.GetString(RawImage)));
            IEnumerator<byte> stm = dec.GetBytes().GetEnumerator();
            BinHexHeader hdr = LoadBinHexHeader(stm);
            byte[] dataFork = LoadFork(hdr.DataForkLength, stm);
            byte[] rsrcFork = LoadFork(hdr.ResourceForkLength, stm);

            var arch = new M68kArchitecture();
            var platform = new MacOSClassic(Services, arch);
            if (hdr.FileType == "PACT")
            {
                Cpt.CompactProArchive archive = new Cpt.CompactProArchive();
                List<ArchiveDirectoryEntry> items = archive.Load(new MemoryStream(dataFork));
                IArchiveBrowserService abSvc = Services.GetService<IArchiveBrowserService>();
                if (abSvc != null)
                {
                    var selectedFile = abSvc.UserSelectFileFromArchive(items);
                    if (selectedFile != null)
                    {
                        var image = selectedFile.GetBytes();
                        this.rsrcFork = new ResourceFork(image, arch);
                        this.image = new LoadedImage(addrLoad, image);
                        this.imageMap = new ImageMap(addrLoad, image.Length);
                        return new Program(this.image, this.imageMap, arch, platform);
                    }
                }
            }

            var li = new LoadedImage(addrLoad, dataFork);
            return new Program(li, li.CreateImageMap(), arch, platform);
        }
示例#2
0
        public override Program Load(Address addrLoad)
        {
            BinHexDecoder      dec = new BinHexDecoder(new StringReader(Encoding.ASCII.GetString(RawImage)));
            IEnumerator <byte> stm = dec.GetBytes().GetEnumerator();
            BinHexHeader       hdr = LoadBinHexHeader(stm);

            byte[] dataFork = LoadFork(hdr.DataForkLength, stm);
            byte[] rsrcFork = LoadFork(hdr.ResourceForkLength, stm);

            var arch     = new M68kArchitecture();
            var platform = new MacOSClassic(Services, arch);

            if (hdr.FileType == "PACT")
            {
                Cpt.CompactProArchive        archive = new Cpt.CompactProArchive();
                List <ArchiveDirectoryEntry> items   = archive.Load(new MemoryStream(dataFork));
                IArchiveBrowserService       abSvc   = Services.GetService <IArchiveBrowserService>();
                if (abSvc != null)
                {
                    var selectedFile = abSvc.UserSelectFileFromArchive(items);
                    if (selectedFile != null)
                    {
                        var image = selectedFile.GetBytes();
                        this.rsrcFork = new ResourceFork(image, arch);
                        this.image    = new LoadedImage(addrLoad, image);
                        this.imageMap = new ImageMap(addrLoad, image.Length);
                        return(new Program(this.image, this.imageMap, arch, platform));
                    }
                }
            }

            var li = new LoadedImage(addrLoad, dataFork);

            return(new Program(li, li.CreateImageMap(), arch, platform));
        }
示例#3
0
        public override Program Load(Address?addrLoad)
        {
            addrLoad ??= PreferredBaseAddress;
            BinHexDecoder      dec = new BinHexDecoder(new StringReader(Encoding.ASCII.GetString(RawImage)));
            IEnumerator <byte> stm = dec.GetBytes().GetEnumerator();
            BinHexHeader       hdr = LoadBinHexHeader(stm);

            byte[] dataFork = LoadFork(hdr.DataForkLength, stm);
            byte[] rsrcFork = LoadFork(hdr.ResourceForkLength, stm);

            var cfgSvc   = Services.RequireService <IConfigurationService>();
            var arch     = cfgSvc.GetArchitecture("m68k") !;
            var platform = (MacOSClassic)cfgSvc.GetEnvironment("macOs").Load(Services, arch);

            if (hdr.FileType == "PACT")
            {
                Cpt.CompactProArchive        archive = new Cpt.CompactProArchive();
                List <ArchiveDirectoryEntry> items   = archive.Load(new MemoryStream(dataFork));
                IArchiveBrowserService       abSvc   = Services.GetService <IArchiveBrowserService>();
                if (abSvc != null)
                {
                    var selectedFile = abSvc.UserSelectFileFromArchive(items);
                    if (selectedFile != null)
                    {
                        var image = selectedFile.GetBytes();
                        this.rsrcFork   = new ResourceFork(platform, image);
                        this.bmem       = new ByteMemoryArea(addrLoad, image);
                        this.segmentMap = new SegmentMap(addrLoad);
                        return(new Program(this.segmentMap, arch, platform));
                    }
                }
            }
            if (hdr.FileType == "MPST" || hdr.FileType == "APPL")
            {
                this.bmem       = new ByteMemoryArea(addrLoad, rsrcFork);
                this.rsrcFork   = new ResourceFork(platform, rsrcFork);
                this.segmentMap = new SegmentMap(addrLoad);
                return(new Program(this.segmentMap, arch, platform));
            }
            this.bmem = new ByteMemoryArea(addrLoad, dataFork);
            return(new Program(
                       new SegmentMap(bmem.BaseAddress,
                                      new ImageSegment("", bmem, AccessMode.ReadWriteExecute)),
                       arch,
                       platform));
        }
示例#4
0
        public override ILoadedImage Load(Address?addrLoad)
        {
            addrLoad ??= PreferredBaseAddress;
            BinHexDecoder      dec = new BinHexDecoder(new StringReader(Encoding.ASCII.GetString(RawImage)));
            IEnumerator <byte> stm = dec.GetBytes().GetEnumerator();
            BinHexHeader       hdr = LoadBinHexHeader(stm);

            byte[] dataBytes = LoadFork(hdr.DataForkLength, stm);
            byte[] rsrcBytes = LoadFork(hdr.ResourceForkLength, stm);

            var cfgSvc   = Services.RequireService <IConfigurationService>();
            var arch     = cfgSvc.GetArchitecture("m68k") !;
            var platform = (MacOSClassic)cfgSvc.GetEnvironment("macOs").Load(Services, arch);

            if (hdr.FileType == "PACT")
            {
                Cpt.CompactProArchive archive = new Cpt.CompactProArchive(base.ImageLocation, arch, platform);
                archive.Load(new MemoryStream(dataBytes));
                return(archive);
            }
            var     rsrcFork = new ResourceFork(platform, rsrcBytes);
            var     bmem     = new ByteMemoryArea(addrLoad, rsrcBytes);
            Program program;

            if (hdr.FileType == "MPST" || hdr.FileType == "APPL")
            {
                var segmentMap = new SegmentMap(addrLoad);
                program = new Program(segmentMap, arch, platform);
            }
            else
            {
                program = new Program(
                    new SegmentMap(bmem.BaseAddress,
                                   new ImageSegment("", bmem, AccessMode.ReadWriteExecute)),
                    arch,
                    platform);
            }
            rsrcFork.AddResourcesToImageMap(addrLoad, bmem, program);
            return(program);
        }