class MachO::Headers::MachHeader

32-bit Mach-O file header structure

Public Instance Methods

alignment() click to toggle source

@return [Integer] the file’s internal alignment

# File lib/macho/headers.rb, line 697
def alignment
  magic32? ? 4 : 8
end
bundle?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_BUNDLE`

# File lib/macho/headers.rb, line 667
def bundle?
  filetype == Headers::MH_BUNDLE
end
core?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_CORE`

# File lib/macho/headers.rb, line 647
def core?
  filetype == Headers::MH_CORE
end
dsym?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_DSYM`

# File lib/macho/headers.rb, line 672
def dsym?
  filetype == Headers::MH_DSYM
end
dylib?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_DYLIB`

# File lib/macho/headers.rb, line 657
def dylib?
  filetype == Headers::MH_DYLIB
end
dylinker?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_DYLINKER`

# File lib/macho/headers.rb, line 662
def dylinker?
  filetype == Headers::MH_DYLINKER
end
executable?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_EXECUTE`

# File lib/macho/headers.rb, line 637
def executable?
  filetype == Headers::MH_EXECUTE
end
fileset?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_FILESET`

# File lib/macho/headers.rb, line 682
def fileset?
  filetype == Headers::MH_FILESET
end
flag?(flag) click to toggle source

@example

puts "this mach-o has position-independent execution" if header.flag?(:MH_PIE)

@param flag [Symbol] a mach header flag symbol @return [Boolean] true if ‘flag` is present in the header’s flag section

# File lib/macho/headers.rb, line 623
def flag?(flag)
  flag = MH_FLAGS[flag]

  return false if flag.nil?

  flags & flag == flag
end
fvmlib?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_FVMLIB`

# File lib/macho/headers.rb, line 642
def fvmlib?
  filetype == Headers::MH_FVMLIB
end
kext?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_KEXT_BUNDLE`

# File lib/macho/headers.rb, line 677
def kext?
  filetype == Headers::MH_KEXT_BUNDLE
end
magic32?() click to toggle source

@return [Boolean] true if the Mach-O has 32-bit magic, false otherwise

# File lib/macho/headers.rb, line 687
def magic32?
  Utils.magic32?(magic)
end
magic64?() click to toggle source

@return [Boolean] true if the Mach-O has 64-bit magic, false otherwise

# File lib/macho/headers.rb, line 692
def magic64?
  Utils.magic64?(magic)
end
object?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_OBJECT`

# File lib/macho/headers.rb, line 632
def object?
  filetype == Headers::MH_OBJECT
end
preload?() click to toggle source

@return [Boolean] whether or not the file is of type ‘MH_PRELOAD`

# File lib/macho/headers.rb, line 652
def preload?
  filetype == Headers::MH_PRELOAD
end
to_h() click to toggle source

@return [Hash] a hash representation of this {MachHeader}

Calls superclass method
# File lib/macho/headers.rb, line 702
def to_h
  {
    "magic" => magic,
    "magic_sym" => MH_MAGICS[magic],
    "cputype" => cputype,
    "cputype_sym" => CPU_TYPES[cputype],
    "cpusubtype" => cpusubtype,
    "cpusubtype_sym" => CPU_SUBTYPES[cputype][cpusubtype],
    "filetype" => filetype,
    "filetype_sym" => MH_FILETYPES[filetype],
    "ncmds" => ncmds,
    "sizeofcmds" => sizeofcmds,
    "flags" => flags,
    "alignment" => alignment,
  }.merge super
end