Class: Pliney::MachO::FatHeaderReader

Inherits:
Reader
  • Object
show all
Defined in:
lib/pliney/macho.rb

Instance Attribute Summary collapse

Attributes inherited from Reader

#fh, #startpos

Instance Method Summary collapse

Methods inherited from Reader

#initialize, parse, #rewind

Constructor Details

This class inherits a constructor from Pliney::MachO::Reader

Instance Attribute Details

#fat_archesObject (readonly)

Returns the value of attribute fat_arches.



159
160
161
# File 'lib/pliney/macho.rb', line 159

def fat_arches
  @fat_arches
end

#magicObject (readonly)

Returns the value of attribute magic.



159
160
161
# File 'lib/pliney/macho.rb', line 159

def magic
  @magic
end

#nfat_archObject (readonly)

Returns the value of attribute nfat_arch.



159
160
161
# File 'lib/pliney/macho.rb', line 159

def nfat_arch
  @nfat_arch
end

Instance Method Details

#each_machoObject



178
179
180
181
182
183
# File 'lib/pliney/macho.rb', line 178

def each_macho()
    @fat_arches.each do |arch|
        @fh.pos = @startpos + arch.offset
        yield arch.macho_reader.parse(@fh)
    end
end

#machosObject



172
173
174
175
176
# File 'lib/pliney/macho.rb', line 172

def machos()
    a = []
    each_macho {|mh| a << mh}
    return a
end

#parseObject



161
162
163
164
165
166
167
168
169
170
# File 'lib/pliney/macho.rb', line 161

def parse()
    super()
    @magic = @fh.read_uint32
    @nfat_arch = @fh.read_uint32
    @fat_arches = Array.new(@nfat_arch) { FatArchReader.parse(@fh) }

    unless MachO::is_fat_magic(@magic)
        raise(ReaderError, "Unexpected magic value for FAT header: 0x%0.8x" % @magic)
    end
end