예제 #1
0
        public void relocate32(int hunk_no, byte[] data, uint offset, uint hunk_addr)
        {
            var delta = LoadedImage.ReadBeUInt32(data, offset);
            var addr  = hunk_addr + delta;

            LoadedImage.WriteBeUInt32(data, offset, addr);
            Debug.WriteIf(Trace.TraceVerbose, string.Format("#{0,2} + {1:X8}: {2:X6} (delta) + {3:X6} (hunk_addr) -> {4:X6}", hunk_no, offset, delta, hunk_addr, addr));
        }
예제 #2
0
        public ResourceFork(byte[] bytes, IProcessorArchitecture arch)
        {
            this.image = bytes;
            this.arch  = arch;

            rsrcDataOff = LoadedImage.ReadBeUInt32(bytes, 0);
            rsrcMapOff  = LoadedImage.ReadBeUInt32(bytes, 4);
            dataSize    = LoadedImage.ReadBeUInt32(bytes, 8);
            mapSize     = LoadedImage.ReadBeUInt32(bytes, 0x0C);

            rsrcTypes = new ResourceTypeCollection(image, rsrcMapOff, mapSize);
        }
예제 #3
0
        public virtual void ParseOverlay(Action <Hunk> h)
        {
            OverlayHunk hunk = new OverlayHunk();

            h(hunk);
            // read size of overlay hunk
            var ov_size = this.read_long();

            if (ov_size < 0)
            {
                throw new BadImageFormatException(string.Format("{0} has invalid size.", hunk.HunkType));
            }

            // read data of overlay
            var byte_size = (ov_size + 1) * 4;
            var ov_data   = f.ReadBytes(byte_size);

            hunk.ov_data = ov_data;
            // check: first get header hunk
            var hdr_hunk = this.hunks[0];

            if (hdr_hunk.HunkType != HunkType.HUNK_HEADER)
            {
                throw new BadImageFormatException(string.Format("{0} has no header hunk.", hunk.HunkType));
            }

            // first find the code segment of the overlay manager
            var overlayManagerHunk = this.FindFirstCodeHunk();

            if (overlayManagerHunk == null)
            {
                throw new BadImageFormatException(string.Format("{0} has no overlay manager hunk.", hunk.HunkType));
            }

            // check overlay manager
            var  overlay_mgr_data = overlayManagerHunk.Data;
            uint magic            = LoadedImage.ReadBeUInt32(overlay_mgr_data, 4);

            if (magic != 0xABCD)
            {
                throw new BadImageFormatException("No valid overlay manager found.");
            }

            // check for standard overlay manager
            var magic2      = LoadedImage.ReadBeUInt32(overlay_mgr_data, 24);
            var magic3      = LoadedImage.ReadBeUInt32(overlay_mgr_data, 20);
            var magic4      = LoadedImage.ReadBeUInt32(overlay_mgr_data, 32);
            var std_overlay = magic2 == 23456 && magic3 == 122648165 && magic4 == 1919705465;

            hunk.ov_std = std_overlay;
        }
예제 #4
0
            public IEnumerator <ResourceReference> GetEnumerator()
            {
                var offset = this.offset;

                for (int i = 0; i < count; ++i)
                {
                    ushort rsrcID  = LoadedImage.ReadBeUInt16(bytes, offset);
                    string name    = ReadName(LoadedImage.ReadBeUInt16(bytes, offset + 2));
                    uint   dataOff = LoadedImage.ReadBeUInt32(bytes, offset + 4) & 0x00FFFFFFU;
                    yield return(new ResourceReference(rsrcID, name, dataOff));

                    offset += 0x0C;
                }
            }