lib/macho/macho_file.rb
# The file's Mach-O header structure.
# @return [Headers::MachHeader] if the Mach-O is 32-bit
# @return [Headers::MachHeader64] if the Mach-O is 64-bit
# @raise [TruncatedFileError] if the file is too small to have a valid header
# @api private
The file's Mach-O header structure.
The file ' s Mach - O header structure .
def populate_mach_header
      raise TruncatedFileError if @raw_data.size < 28
      magic = @raw_data[0..3].unpack1("N")
      populate_prelinked_kernel_header if Utils.compressed_magic?(magic)
      magic = populate_and_check_magic
      mh_klass = Utils.magic32?(magic) ? Headers::MachHeader : Headers::MachHeader64
      mh = mh_klass.new_from_bin(endianness, @raw_data[0, mh_klass.bytesize])
      check_cputype(mh.cputype)
      check_cpusubtype(mh.cputype, mh.cpusubtype)
      check_filetype(mh.filetype)
      mh
    end
def populate_mach_header raise TruncatedFileError if @raw_data . size < 28 magic = @raw_data [ 0 .. 3 ] . unpack1 ( "N" ) populate_prelinked_kernel_header if Utils . compressed_magic? ( magic ) magic = populate_and_check_magic mh_klass = Utils . magic32? ( magic ) ? Headers :: MachHeader : Headers :: MachHeader64 mh = mh_klass . new_from_bin ( endianness , @raw_data [ 0 , mh_klass . bytesize ] ) check_cputype ( mh . cputype ) check_cpusubtype ( mh . cputype , mh . cpusubtype ) check_filetype ( mh . filetype ) mh end
The file's Mach-O header structure.
The file ' s Mach - O header structure .
# the smallest Mach-O header is 28 bytes
if the Mach-O is 32-bit
if the Mach - O is 32 - bit
Headers::MachHeader
if the Mach-O is 64-bit
if the Mach - O is 64 - bit
Headers::MachHeader64
[TruncatedFileError] if the file is too small to have a valid header
[ TruncatedFileError ] if the file is too small to have a valid header
api
None