Beispiel #1
0
 public override IEnumerable <ElfDynamicEntry> GetDynamicEntries(EndianImageReader rdr)
 {
     for (; ;)
     {
         var dyn = new Elf64_Dyn();
         if (!rdr.TryReadInt64(out dyn.d_tag))
         {
             break;
         }
         if (dyn.d_tag == ElfDynamicEntry.DT_NULL)
         {
             break;
         }
         if (!rdr.TryReadInt64(out long val))
         {
             break;
         }
         dyn.d_val = val;
         yield return(new ElfDynamicEntry(dyn.d_tag, dyn.d_ptr));;
     }
 }
        //00 00 00 01 00 00 00 01   needed      ........
        //00 00 00 01 00 00 02 DE   "
        //00 00 00 01 00 00 02 EE   "
        //00 00 00 01 00 00 03 06   "
        //00 00 00 01 00 00 03 10   "
        //00 00 00 01 00 00 03 6B   "
        //00 00 00 01 00 00 03 91   "
        //00 00 00 0C 10 00 29 CC   Init
        //00 00 00 0D 10 03 81 B0   Fini
        //00 00 00 04 10 00 01 A8   Hash
        //6F FF FE F5 10 00 07 E0   ?
        //00 00 00 05 10 00 14 AC   strtab
        //00 00 00 06 10 00 08 3C   symtab
        //00 00 00 0A 00 00 09 90   strsz
        //00 00 00 0B 00 00 00 10   syment
        //00 00 00 15 00 00 00 00   debug
        //00 00 00 03 10 06 60 00   pltgot   -> first byte in linkage table
        //00 00 00 02 00 00 08 D0   pltretsz
        //00 00 00 14 00 00 00 07   pltrel
        //00 00 00 17 10 00 20 FC   jmprel
        //70 00 00 00 10 06 5F F4   loproc
        //00 00 00 07 10 00 20 CC   rela
        //00 00 00 08 00 00 09 00   relasz
        //00 00 00 09 00 00 00 0C   relaent
        //6F FF FF FE 10 00 1F CC  ?
        //6F FF FF FF 00 00 00 04   ?
        //6F FF FF F0 10 00 1E 3C  ?


        protected virtual void RenderEntry(string name, DtFormat format, Elf64_Dyn entry, Formatter formatter)
        {
            formatter.Write("{0,-15} ", name);
            switch (format)
            {
            default:
            case DtFormat.Hexadecimal:
                formatter.Write("{0:X16}", entry.d_val);
                break;

            case DtFormat.Decimal:
                formatter.Write("{0,16}", entry.d_val);
                break;

            case DtFormat.Address:
                formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                break;

            case DtFormat.String:
                formatter.Write(loader.ReadAsciiString(strtabSection.FileOffset + entry.d_ptr));
                break;
            }
        }
Beispiel #3
0
        public override IEnumerable <ElfDynamicEntry> GetDynamicEntries(ulong offsetDynamic)
        {
            var rdr = imgLoader.CreateReader(offsetDynamic);

            for (; ;)
            {
                var dyn = new Elf64_Dyn();
                if (!rdr.TryReadInt64(out dyn.d_tag))
                {
                    break;
                }
                if (dyn.d_tag == ElfDynamicEntry.DT_NULL)
                {
                    break;
                }
                if (!rdr.TryReadInt64(out long val))
                {
                    break;
                }
                dyn.d_val = val;
                yield return(new ElfDynamicEntry(dyn.d_tag, dyn.d_ptr));;
            }
        }
Beispiel #4
0
 public IEnumerable<Elf64_Dyn> GetDynEntries64(ulong offset)
 {
     var rdr = CreateReader(offset);
     for (; ; )
     {
         var dyn = new Elf64_Dyn();
         if (!rdr.TryReadInt64(out dyn.d_tag))
             break;
         if (dyn.d_tag == DT_NULL)
             break;
         long val;
         if (!rdr.TryReadInt64(out val))
             break;
         dyn.d_val = val;
         yield return dyn;
     }
 }
Beispiel #5
0
        //00 00 00 01 00 00 00 01   needed      ........
        //00 00 00 01 00 00 02 DE   "
        //00 00 00 01 00 00 02 EE   "
        //00 00 00 01 00 00 03 06   "
        //00 00 00 01 00 00 03 10   "
        //00 00 00 01 00 00 03 6B   "
        //00 00 00 01 00 00 03 91   "
        //00 00 00 0C 10 00 29 CC   Init
        //00 00 00 0D 10 03 81 B0   Fini
        //00 00 00 04 10 00 01 A8   Hash
        //6F FF FE F5 10 00 07 E0   ?
        //00 00 00 05 10 00 14 AC   strtab
        //00 00 00 06 10 00 08 3C   symtab
        //00 00 00 0A 00 00 09 90   strsz
        //00 00 00 0B 00 00 00 10   syment
        //00 00 00 15 00 00 00 00   debug
        //00 00 00 03 10 06 60 00   pltgot   -> first byte in linkage table
        //00 00 00 02 00 00 08 D0   pltretsz
        //00 00 00 14 00 00 00 07   pltrel
        //00 00 00 17 10 00 20 FC   jmprel
        //70 00 00 00 10 06 5F F4   loproc
        //00 00 00 07 10 00 20 CC   rela
        //00 00 00 08 00 00 09 00   relasz
        //00 00 00 09 00 00 00 0C   relaent
        //6F FF FF FE 10 00 1F CC  ?
        //6F FF FF FF 00 00 00 04   ?
        //6F FF FF F0 10 00 1E 3C  ?


        protected virtual void RenderEntry(string name, DtFormat format, Elf64_Dyn entry, Formatter formatter)
        {
            formatter.Write("{0,-15} ", name);
            switch (format)
            {
            default:
            case DtFormat.Hexadecimal:
                formatter.Write("{0:X16}", entry.d_val);
                break;
            case DtFormat.Decimal:
                formatter.Write("{0,16}", entry.d_val);
                break;
            case DtFormat.Address:
                formatter.WriteHyperlink(string.Format("{0:X16}", entry.d_ptr), Address.Ptr64(entry.d_ptr));
                break;
            case DtFormat.String:
                formatter.Write(loader.ReadAsciiString(strtabSection.FileOffset + entry.d_ptr));
                break;
            }
        }