示例#1
0
        public void VisitPointer(Pointer ptr)
        {
            switch (ptr.Size)
            {
            case 2:
                fmt.WriteKeyword("dw");
                fmt.Write("\t");
                fmt.Write(string.Format("0x{0:X4}", rdr.ReadByte()));
                fmt.WriteLine();
                return;

            case 4:
                fmt.WriteKeyword("dd");
                fmt.Write("\t");
                fmt.Write(string.Format("0x{0:X8}", rdr.ReadUInt32()));
                fmt.WriteLine();
                return;

            case 8:
                fmt.WriteKeyword("dq");
                fmt.Write("\t");
                fmt.Write(string.Format("0x{0:X16}", rdr.ReadUInt64()));
                fmt.WriteLine();
                return;
            }
        }
示例#2
0
        public ulong r_info;   // Symbol table index and type of relocation to apply.

        public static Elf64_Rel Read(EndianImageReader rdr)
        {
            var o = rdr.ReadUInt64();
            var i = rdr.ReadUInt64();

            return(new Elf64_Rel
            {
                r_offset = o,
                r_info = i
            });
        }
示例#3
0
        public static Elf64_Sym Load(EndianImageReader rdr)
        {
            var sym = new Elf64_Sym();

            sym.st_name  = rdr.ReadUInt32();
            sym.st_info  = rdr.ReadByte();
            sym.st_other = rdr.ReadByte();
            sym.st_shndx = rdr.ReadUInt16();
            sym.st_value = rdr.ReadUInt64();
            sym.st_size  = rdr.ReadUInt64();
            return(sym);
        }
示例#4
0
        public static Elf64_Rela Read(EndianImageReader rdr)
        {
            var o = rdr.ReadUInt64();
            var i = rdr.ReadUInt64();
            var a = rdr.ReadInt64();

            return(new Elf64_Rela
            {
                r_offset = o,
                r_info = i,
                r_addend = a
            });
        }
示例#5
0
        public ushort e_shstrndx;       // section name string table index

        public static Elf64_EHdr Load(EndianImageReader rdr)
        {
            return(new Elf64_EHdr
            {
                e_type = rdr.ReadUInt16(),
                e_machine = rdr.ReadUInt16(),
                e_version = rdr.ReadUInt32(),

                e_entry = rdr.ReadUInt64(),
                e_phoff = rdr.ReadUInt64(),
                e_shoff = rdr.ReadUInt64(),

                e_flags = rdr.ReadUInt32(),
                e_ehsize = rdr.ReadUInt16(),
                e_phentsize = rdr.ReadUInt16(),
                e_phnum = rdr.ReadUInt16(),
                e_shentsize = rdr.ReadUInt16(),
                e_shnum = rdr.ReadUInt16(),
                e_shstrndx = rdr.ReadUInt16(),
            });
        }
示例#6
0
        public static Elf64_PHdr Load(EndianImageReader rdr)
        {
            var hdr = new Elf64_PHdr
            {
                p_type   = (ProgramHeaderType)rdr.ReadUInt32(),
                p_flags  = rdr.ReadUInt32(),
                p_offset = rdr.ReadUInt64(),
                p_vaddr  = rdr.ReadUInt64(),
                p_paddr  = rdr.ReadUInt64(),
                p_filesz = rdr.ReadUInt64(),
                p_pmemsz = rdr.ReadUInt64(),
                p_align  = rdr.ReadUInt64(),
            };

            return(hdr);
        }
示例#7
0
 public static Elf64_SHdr Load(EndianImageReader rdr)
 {
     return(new Elf64_SHdr
     {
         sh_name = rdr.ReadUInt32(),
         sh_type = (SectionHeaderType)rdr.ReadUInt32(),
         sh_flags = rdr.ReadUInt64(),
         sh_addr = rdr.ReadUInt64(),        // Address
         sh_offset = rdr.ReadUInt64(),
         sh_size = rdr.ReadUInt64(),
         sh_link = rdr.ReadUInt32(),
         sh_info = rdr.ReadUInt32(),
         sh_addralign = rdr.ReadUInt64(),
         sh_entsize = rdr.ReadUInt64(),
     });
 }