class MachO::Headers::MachHeader
32-bit Mach-O file header structure
Public Instance Methods
@return [Integer] the file’s internal alignment
# File lib/macho/headers.rb, line 697 def alignment magic32? ? 4 : 8 end
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@return [Hash] a hash representation of this {MachHeader}
# 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