Method: Rex::MachParsey::Fat#initialize

Defined in:
lib/rex/machparsey/mach.rb

#initialize(isource, offset = 0) ⇒ Fat

Returns a new instance of Fat.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/rex/machparsey/mach.rb', line 107

def initialize(isource, offset = 0)
  self.fat_archs = []
  self.machos = []
  self.isource = isource
  self.fat_header = FatHeader.new(isource.read(offset, FAT_HEADER_SIZE))

  if !self.fat_header
    raise FatHeaderError, "Could not parse FAT header"
  end

  print "Detected " +  self.fat_header.nfat_arch.to_s +  " archs in binary.\n"

  offset += FAT_HEADER_SIZE

  self.fat_header.nfat_arch.times do
    fat_arch = FatArch.new(isource.read(offset, FAT_ARCH_SIZE), self.fat_header.endian)
    self.fat_archs << fat_arch
    self.machos << Mach.new(isource, fat_arch.offset, true)
    offset += FAT_ARCH_SIZE
  end


end