Class: FileHeader

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

Constant Summary collapse

FH =
{
  ei_magic_number:        [0x00,4],
  ei_class:               [0x04],
  ei_data:                [0x05],
  ei_version:             [0x06],
  ei_osabi:               [0x07],
  ei_abiversion:          [0x08],
  e_type:                 [0x10,2],
  e_machine:              [0x12,2],
  e_version:              [0x14,4],
  e_entry:                [0x18,4],
  e_phoff:                [0x1C,4],
  e_shoff:                [0x20,4],
  e_flags:                [0x24,4],
  e_ehsize:               [0x28,2],
  e_phentsize:            [0x2A,2],
  e_phnum:                [0x2C,2],
  e_shentsize:            [0x2E,2],
  e_shnum:                [0x30,2],
  e_shstrndx:             [0x32,2]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_x) ⇒ FileHeader



26
27
28
29
30
31
32
33
# File 'lib/elfcat/fileheader.rb', line 26

def initialize _x
  @data = Hash.new
  @debug = Proc.new{self.debug}

  FH.each do |k, v|
    @data[k] = Util.concatenate(_x, v[0], v[1] || 1)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(_method) ⇒ Object



35
36
37
38
# File 'lib/elfcat/fileheader.rb', line 35

def method_missing _method
  puts "i'm called"
  return @data[_method][:data]
end

Instance Attribute Details

#file_headerObject (readonly)

Returns the value of attribute file_header.



2
3
4
# File 'lib/elfcat/fileheader.rb', line 2

def file_header
  @file_header
end

Instance Method Details

#[](_name) ⇒ Object



40
41
42
# File 'lib/elfcat/fileheader.rb', line 40

def [](_name)
  return @data[_name]
end

#debugObject



44
45
46
47
48
49
# File 'lib/elfcat/fileheader.rb', line 44

def debug
  @data.each do |k, d|
    k_s = sprintf("%32s", k)
    puts "#{k_s} #{CuteHex.x d.data}"
  end
end