コード例 #1
0
ファイル: HunkFile.cs プロジェクト: killbug2004/reko
        public HunkFile()
        {
            this.type = FileType.TYPE_UNKNOWN;
            this.hunks = new List<Hunk>();
            this.header = null;
            this.segments = new List<List<Hunk>>();
            this.overlay = null;
            this.overlay_headers = null;
            this.overlay_segments = null;
            this.libs = null;
            this.units = null;

        }
コード例 #2
0
ファイル: HunkShow.cs プロジェクト: gitter-badger/reko
 public HunkShow(HunkFile hunk_file, bool show_relocs, bool show_debug, bool disassemble, uint disassemble_start, bool hexdump, bool brief, bool use_objdump, string cpu)
 {
     this.hunk_file = hunk_file;
     // clone file refs
     this.header = hunk_file.header;
     this.segments = hunk_file.segments;
     this.overlay = hunk_file.overlay;
     this.overlay_headers = hunk_file.overlay_headers;
     this.overlay_segments = hunk_file.overlay_segments;
     this.libs = hunk_file.libs;
     this.units = hunk_file.units;
     this.show_relocs = show_relocs;
     this.show_debug = show_debug;
     this.disassemble = disassemble;
     this.disassemble_start = disassemble_start;
     this.use_objdump = use_objdump;
     this.cpu = cpu;
     this.hexdump = hexdump;
     this.brief = brief;
 }
コード例 #3
0
ファイル: HunkShow.cs プロジェクト: gitter-badger/reko
 // ----- printing -----
 public virtual void print_header(HeaderHunk hdr)
 {
     Console.WriteLine(String.Format("\t      header (segments: first={0}, last={1}, table size={2})", hdr.FirstHunkId, hdr.LastHunkId, hdr.table_size));
 }
コード例 #4
0
ファイル: HunkFileParser.cs プロジェクト: killbug2004/reko
        public HeaderHunk ParseHeader(Action<Hunk> h)
        {
            var hunk = new HeaderHunk();
            h(hunk);
            var names = new List<string>();
            hunk.HunkNames = names;
            while (true)
            {
                var t = this.ReadString();
                if (t == null)
                    throw new BadImageFormatException("Error parsing header hunk names.");
                else if (t.Length == 0)
                {
                    break;
                }
                names.Add(t);
            }

            // Table size and hunk range
            var table_size = f.ReadBeInt32();
            var first_hunk = f.ReadBeInt32();
            var last_hunk = f.ReadBeInt32();
            if (table_size < 0 || first_hunk < 0 || last_hunk < 0)
                throw new BadImageFormatException("Invalid header hunk.");
            
            hunk.table_size = table_size;
            hunk.FirstHunkId = first_hunk;
            hunk.LastHunkId = last_hunk;

            // Determine number of hunks in size table
            int num_hunks = last_hunk - first_hunk + 1;
            var hunkInfos = new List<HunkInfo>();
            for (int a = 0; a < num_hunks; ++a)
            {
                var hunk_info = new HunkInfo();
                int hunk_size = this.read_long();
                hunk_size &= 0x3FFFFFFF;           // Top 2 bits not handled yet.
                if (hunk_size < 0)
                    throw new BadImageFormatException("Head hunk contains invalid hunk_size.");
                int hunk_bytes = (hunk_size & ~Hunk.HUNKF_ALL) * 4;
                hunk_info.Size = hunk_bytes;
                hunk_info.Flags = this.SetMemoryFlags(hunk_size & Hunk.HUNKF_ALL, 30);
                hunkInfos.Add(hunk_info);
            }
            hunk.HunkInfos = hunkInfos;
            return hunk;
        }