예제 #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 ForkEntry(
     CompactProArchive archive,
     string name,
     uint offsetCompressed,
     uint lengthCompressed,
     uint lengthUncompressed,
     ushort type)
 {
     this.archive            = archive;
     this.name               = name;
     this.offsetCompressed   = offsetCompressed;
     this.lengthCompressed   = lengthCompressed;
     this.lengthUncompressed = lengthUncompressed;
     this.type               = type;
 }
예제 #3
0
 public ForkEntry(
     CompactProArchive archive,
     MacFileEntry parent,
     string name,
     uint offsetCompressed,
     uint lengthCompressed,
     uint lengthUncompressed,
     ushort type)
     : base(archive, parent, name)
 {
     this.offsetCompressed   = offsetCompressed;
     this.lengthCompressed   = lengthCompressed;
     this.lengthUncompressed = lengthUncompressed;
     this.type = type;
 }
예제 #4
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));
        }
예제 #5
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);
        }
예제 #6
0
 public ForkFolder(CompactProArchive archive, FileHdr hdr)
 {
     rsrcFork = new ForkEntry(archive, "rsrc", hdr.filepos, hdr.compRLength, hdr.rsrcLength, ((ushort)(hdr.cptFlag & 2)));
     dataFork = new ForkEntry(archive, "data", hdr.filepos + hdr.compRLength, hdr.compDLength, hdr.dataLength, ((ushort)(hdr.cptFlag & 4)));
 }
예제 #7
0
 public MacFileEntry(CompactProArchive archive, FileHdr hdr)
 {
     this.archive = archive;
     this.hdr     = hdr;
     this.forks   = new ForkFolder(archive, hdr);
 }
예제 #8
0
 public MacFolderEntry(CompactProArchive archive, MacFolderEntry?parent, string name, ICollection <ArchiveDirectoryEntry> items)
     : base(archive, parent, name)
 {
     this.Entries = items;
 }
예제 #9
0
 public MacFileEntry(CompactProArchive archive, MacFolderEntry?parent, FileHdr hdr)
     : base(archive, parent, hdr.fName !)
 {
     this.hdr     = hdr;
     this.Entries = new ForkFolder(archive, this, hdr);
 }
예제 #10
0
 protected CptEntry(CompactProArchive archive, CptEntry?parent, string name)
 {
     this.Archive = archive;
     this.Parent  = parent;
     this.Name    = name;
 }