Class: MachO::Headers::MachHeader
- Inherits:
-
MachOStructure
- Object
- MachOStructure
- MachO::Headers::MachHeader
- Defined in:
- lib/macho/headers.rb
Overview
32-bit Mach-O file header structure
Direct Known Subclasses
Instance Method Summary collapse
-
#alignment ⇒ Integer
The file's internal alignment.
-
#bundle? ⇒ Boolean
Whether or not the file is of type
MH_BUNDLE. -
#core? ⇒ Boolean
Whether or not the file is of type
MH_CORE. -
#cpusubtype ⇒ Integer
The CPU subtype of the Mach-O.
-
#cputype ⇒ Integer
The CPU type of the Mach-O.
-
#dsym? ⇒ Boolean
Whether or not the file is of type
MH_DSYM. -
#dylib? ⇒ Boolean
Whether or not the file is of type
MH_DYLIB. -
#dylinker? ⇒ Boolean
Whether or not the file is of type
MH_DYLINKER. -
#executable? ⇒ Boolean
Whether or not the file is of type
MH_EXECUTE. -
#fileset? ⇒ Boolean
Whether or not the file is of type
MH_FILESET. -
#filetype ⇒ Integer
The file type of the Mach-O.
-
#flag?(flag) ⇒ Boolean
True if
flagis present in the header's flag section. -
#flags ⇒ Integer
The header flags associated with the Mach-O.
-
#fvmlib? ⇒ Boolean
Whether or not the file is of type
MH_FVMLIB. -
#kext? ⇒ Boolean
Whether or not the file is of type
MH_KEXT_BUNDLE. -
#magic ⇒ Integer
The magic number.
-
#magic32? ⇒ Boolean
True if the Mach-O has 32-bit magic, false otherwise.
-
#magic64? ⇒ Boolean
True if the Mach-O has 64-bit magic, false otherwise.
-
#ncmds ⇒ Integer
The number of load commands in the Mach-O.
-
#object? ⇒ Boolean
Whether or not the file is of type
MH_OBJECT. -
#preload? ⇒ Boolean
Whether or not the file is of type
MH_PRELOAD. -
#sizeofcmds ⇒ Integer
The size of all load commands, in bytes, in the Mach-O.
-
#to_h ⇒ Hash
A hash representation of this MachHeader.
Methods inherited from MachOStructure
bytesize, format, #initialize, new_from_bin
Constructor Details
This class inherits a constructor from MachO::MachOStructure
Instance Method Details
#alignment ⇒ Integer
Returns the file's internal alignment.
709 710 711 |
# File 'lib/macho/headers.rb', line 709 def alignment magic32? ? 4 : 8 end |
#bundle? ⇒ Boolean
Returns whether or not the file is of type MH_BUNDLE.
679 680 681 |
# File 'lib/macho/headers.rb', line 679 def bundle? filetype == Headers::MH_BUNDLE end |
#core? ⇒ Boolean
Returns whether or not the file is of type MH_CORE.
659 660 661 |
# File 'lib/macho/headers.rb', line 659 def core? filetype == Headers::MH_CORE end |
#cpusubtype ⇒ Integer
Returns the CPU subtype of the Mach-O.
617 |
# File 'lib/macho/headers.rb', line 617 field :cpusubtype, :uint32, :mask => CPU_SUBTYPE_MASK |
#cputype ⇒ Integer
Returns the CPU type of the Mach-O.
614 |
# File 'lib/macho/headers.rb', line 614 field :cputype, :uint32 |
#dsym? ⇒ Boolean
Returns whether or not the file is of type MH_DSYM.
684 685 686 |
# File 'lib/macho/headers.rb', line 684 def dsym? filetype == Headers::MH_DSYM end |
#dylib? ⇒ Boolean
Returns whether or not the file is of type MH_DYLIB.
669 670 671 |
# File 'lib/macho/headers.rb', line 669 def dylib? filetype == Headers::MH_DYLIB end |
#dylinker? ⇒ Boolean
Returns whether or not the file is of type MH_DYLINKER.
674 675 676 |
# File 'lib/macho/headers.rb', line 674 def dylinker? filetype == Headers::MH_DYLINKER end |
#executable? ⇒ Boolean
Returns whether or not the file is of type MH_EXECUTE.
649 650 651 |
# File 'lib/macho/headers.rb', line 649 def executable? filetype == Headers::MH_EXECUTE end |
#fileset? ⇒ Boolean
Returns whether or not the file is of type MH_FILESET.
694 695 696 |
# File 'lib/macho/headers.rb', line 694 def fileset? filetype == Headers::MH_FILESET end |
#filetype ⇒ Integer
Returns the file type of the Mach-O.
620 |
# File 'lib/macho/headers.rb', line 620 field :filetype, :uint32 |
#flag?(flag) ⇒ Boolean
Returns true if flag is present in the header's flag section.
635 636 637 638 639 640 641 |
# File 'lib/macho/headers.rb', line 635 def flag?(flag) flag = MH_FLAGS[flag] return false if flag.nil? flags & flag == flag end |
#flags ⇒ Integer
Returns the header flags associated with the Mach-O.
629 |
# File 'lib/macho/headers.rb', line 629 field :flags, :uint32 |
#fvmlib? ⇒ Boolean
Returns whether or not the file is of type MH_FVMLIB.
654 655 656 |
# File 'lib/macho/headers.rb', line 654 def fvmlib? filetype == Headers::MH_FVMLIB end |
#kext? ⇒ Boolean
Returns whether or not the file is of type MH_KEXT_BUNDLE.
689 690 691 |
# File 'lib/macho/headers.rb', line 689 def kext? filetype == Headers::MH_KEXT_BUNDLE end |
#magic ⇒ Integer
Returns the magic number.
611 |
# File 'lib/macho/headers.rb', line 611 field :magic, :uint32 |
#magic32? ⇒ Boolean
Returns true if the Mach-O has 32-bit magic, false otherwise.
699 700 701 |
# File 'lib/macho/headers.rb', line 699 def magic32? Utils.magic32?(magic) end |
#magic64? ⇒ Boolean
Returns true if the Mach-O has 64-bit magic, false otherwise.
704 705 706 |
# File 'lib/macho/headers.rb', line 704 def magic64? Utils.magic64?(magic) end |
#ncmds ⇒ Integer
Returns the number of load commands in the Mach-O.
623 |
# File 'lib/macho/headers.rb', line 623 field :ncmds, :uint32 |
#object? ⇒ Boolean
Returns whether or not the file is of type MH_OBJECT.
644 645 646 |
# File 'lib/macho/headers.rb', line 644 def object? filetype == Headers::MH_OBJECT end |
#preload? ⇒ Boolean
Returns whether or not the file is of type MH_PRELOAD.
664 665 666 |
# File 'lib/macho/headers.rb', line 664 def preload? filetype == Headers::MH_PRELOAD end |
#sizeofcmds ⇒ Integer
Returns the size of all load commands, in bytes, in the Mach-O.
626 |
# File 'lib/macho/headers.rb', line 626 field :sizeofcmds, :uint32 |
#to_h ⇒ Hash
Returns a hash representation of this MachO::Headers::MachHeader.
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'lib/macho/headers.rb', line 714 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 |