Class: ProgramHeader

Inherits:
Base
  • Object
show all
Defined in:
lib/elfcat/programheader.rb

Constant Summary collapse

PH =
{
  p_type:      [0x00, 4],
  p_offset:    [0x04, 4],
  p_vaddr:     [0x08, 4],
  p_paddr:     [0x0C, 4],
  p_filesz:    [0x10, 4],
  p_memsz:     [0x14, 4],
  p_flags:     [0x18, 4],
  p_align:     [0x1C, 4]
}

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#[], #method_missing, #parse_slice, #parse_struct

Constructor Details

#initialize(_fh, _st) ⇒ ProgramHeader

Returns a new instance of ProgramHeader.



13
14
15
16
17
# File 'lib/elfcat/programheader.rb', line 13

def initialize _fh, _st
  super()
  parse _fh
  populate _st
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Base

Instance Method Details

#debugObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/elfcat/programheader.rb', line 19

def debug
  @data.each_with_index do |(k, d), i|
    print_debug_header if i % 64 == 0
    index_s = sprintf("%4d", k)

    real_name_s = sprintf("%-16.16s", d.real_name)

    elf_address_s = CuteHex.x d.p_offset
    elf_size_s = sprintf("%8d", d.p_filesz)

    virtual_address_s = CuteHex.x d.p_vaddr
    physical_address_s = CuteHex.x d.p_paddr
    mem_size_s = sprintf("%8d", d.p_memsz)

    puts "#{index_s} | #{real_name_s} #{elf_address_s} (#{elf_size_s}) | #{virtual_address_s} (#{mem_size_s})"
  end
end