Class: Rex::PeParsey::PeBase::FileHeader

Inherits:
GenericHeader show all
Defined in:
lib/rex/peparsey/pebase.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) ⇒ FileHeader

Returns a new instance of FileHeader.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/rex/peparsey/pebase.rb', line 182

def initialize(rawdata)
  file_header = IMAGE_FILE_HEADER.make_struct

  if !file_header.from_s(rawdata)
    raise FileHeaderError, "Couldn't parse IMAGE_FILE_HEADER", caller
  end

  if file_header.v['NtSignature'] != IMAGE_NT_SIGNATURE
    raise FileHeaderError, "Couldn't find the PE magic!"
  end

  if SUPPORTED_MACHINES.include?(file_header.v['Machine']) == false
    raise FileHeaderError, "Unsupported machine type: #{file_header.v['Machine']}", caller
  end

  self.struct = file_header
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rex::PeParsey::PeBase::GenericStruct

Instance Method Details

#MachineObject



200
201
202
# File 'lib/rex/peparsey/pebase.rb', line 200

def Machine
  v['Machine']
end

#NumberOfSectionsObject



208
209
210
# File 'lib/rex/peparsey/pebase.rb', line 208

def NumberOfSections
  v['NumberOfSections']
end

#SizeOfOptionalHeaderObject



204
205
206
# File 'lib/rex/peparsey/pebase.rb', line 204

def SizeOfOptionalHeader
  v['SizeOfOptionalHeader']
end