Beispiel #1
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            = MemoryArea.ReadBeUInt32(overlay_mgr_data, 4);

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

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

            hunk.ov_std = std_overlay;
        }
Beispiel #2
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;
        }