Class: Rex::ElfParsey::ElfBase::ProgramHeader

Inherits:
GenericHeader show all
Defined in:
lib/rex/elfparsey/elfbase.rb

Instance Attribute Summary

Attributes inherited from GenericStruct

#struct

Instance Method Summary collapse

Methods inherited from GenericStruct

#[], #keys, #method_missing, #v

Constructor Details

#initialize(rawdata, ei_data) ⇒ ProgramHeader

Returns a new instance of ProgramHeader.



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/rex/elfparsey/elfbase.rb', line 244

def initialize(rawdata, ei_data)
  # Identify the data encoding and parse Program Header
  if ei_data == ELFDATA2LSB
    program_header = ELF32_PHDR_LSB.make_struct
  elsif ei_data == ELFDATA2MSB
    program_header = ELF32_PHDR_MSB.make_struct
  else
    raise ElfHeaderError, "Invalid data encoding", caller
  end

  if !program_header.from_s(rawdata)
    raise ProgramHeaderError, "Couldn't parse Program Header", caller
  end

  self.struct = program_header
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rex::ElfParsey::ElfBase::GenericStruct