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)); }
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; }
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; }
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)); }
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); }
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))); }
public MacFileEntry(CompactProArchive archive, FileHdr hdr) { this.archive = archive; this.hdr = hdr; this.forks = new ForkFolder(archive, hdr); }
public MacFolderEntry(CompactProArchive archive, MacFolderEntry?parent, string name, ICollection <ArchiveDirectoryEntry> items) : base(archive, parent, name) { this.Entries = items; }
public MacFileEntry(CompactProArchive archive, MacFolderEntry?parent, FileHdr hdr) : base(archive, parent, hdr.fName !) { this.hdr = hdr; this.Entries = new ForkFolder(archive, this, hdr); }
protected CptEntry(CompactProArchive archive, CptEntry?parent, string name) { this.Archive = archive; this.Parent = parent; this.Name = name; }