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
flag
is 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.
697 698 699 |
# File 'lib/macho/headers.rb', line 697 def alignment magic32? ? 4 : 8 end |
#bundle? ⇒ Boolean
Returns whether or not the file is of type MH_BUNDLE
.
667 668 669 |
# File 'lib/macho/headers.rb', line 667 def bundle? filetype == Headers::MH_BUNDLE end |
#core? ⇒ Boolean
Returns whether or not the file is of type MH_CORE
.
647 648 649 |
# File 'lib/macho/headers.rb', line 647 def core? filetype == Headers::MH_CORE end |
#cpusubtype ⇒ Integer
Returns the CPU subtype of the Mach-O.
605 |
# File 'lib/macho/headers.rb', line 605 field :cpusubtype, :uint32, :mask => CPU_SUBTYPE_MASK |
#cputype ⇒ Integer
Returns the CPU type of the Mach-O.
602 |
# File 'lib/macho/headers.rb', line 602 field :cputype, :uint32 |
#dsym? ⇒ Boolean
Returns whether or not the file is of type MH_DSYM
.
672 673 674 |
# File 'lib/macho/headers.rb', line 672 def dsym? filetype == Headers::MH_DSYM end |
#dylib? ⇒ Boolean
Returns whether or not the file is of type MH_DYLIB
.
657 658 659 |
# File 'lib/macho/headers.rb', line 657 def dylib? filetype == Headers::MH_DYLIB end |
#dylinker? ⇒ Boolean
Returns whether or not the file is of type MH_DYLINKER
.
662 663 664 |
# File 'lib/macho/headers.rb', line 662 def dylinker? filetype == Headers::MH_DYLINKER end |
#executable? ⇒ Boolean
Returns whether or not the file is of type MH_EXECUTE
.
637 638 639 |
# File 'lib/macho/headers.rb', line 637 def executable? filetype == Headers::MH_EXECUTE end |
#fileset? ⇒ Boolean
Returns whether or not the file is of type MH_FILESET
.
682 683 684 |
# File 'lib/macho/headers.rb', line 682 def fileset? filetype == Headers::MH_FILESET end |
#filetype ⇒ Integer
Returns the file type of the Mach-O.
608 |
# File 'lib/macho/headers.rb', line 608 field :filetype, :uint32 |
#flag?(flag) ⇒ Boolean
Returns true if flag
is present in the header's flag section.
623 624 625 626 627 628 629 |
# File 'lib/macho/headers.rb', line 623 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.
617 |
# File 'lib/macho/headers.rb', line 617 field :flags, :uint32 |
#fvmlib? ⇒ Boolean
Returns whether or not the file is of type MH_FVMLIB
.
642 643 644 |
# File 'lib/macho/headers.rb', line 642 def fvmlib? filetype == Headers::MH_FVMLIB end |
#kext? ⇒ Boolean
Returns whether or not the file is of type MH_KEXT_BUNDLE
.
677 678 679 |
# File 'lib/macho/headers.rb', line 677 def kext? filetype == Headers::MH_KEXT_BUNDLE end |
#magic ⇒ Integer
Returns the magic number.
599 |
# File 'lib/macho/headers.rb', line 599 field :magic, :uint32 |
#magic32? ⇒ Boolean
Returns true if the Mach-O has 32-bit magic, false otherwise.
687 688 689 |
# File 'lib/macho/headers.rb', line 687 def magic32? Utils.magic32?(magic) end |
#magic64? ⇒ Boolean
Returns true if the Mach-O has 64-bit magic, false otherwise.
692 693 694 |
# File 'lib/macho/headers.rb', line 692 def magic64? Utils.magic64?(magic) end |
#ncmds ⇒ Integer
Returns the number of load commands in the Mach-O.
611 |
# File 'lib/macho/headers.rb', line 611 field :ncmds, :uint32 |
#object? ⇒ Boolean
Returns whether or not the file is of type MH_OBJECT
.
632 633 634 |
# File 'lib/macho/headers.rb', line 632 def object? filetype == Headers::MH_OBJECT end |
#preload? ⇒ Boolean
Returns whether or not the file is of type MH_PRELOAD
.
652 653 654 |
# File 'lib/macho/headers.rb', line 652 def preload? filetype == Headers::MH_PRELOAD end |
#sizeofcmds ⇒ Integer
Returns the size of all load commands, in bytes, in the Mach-O.
614 |
# File 'lib/macho/headers.rb', line 614 field :sizeofcmds, :uint32 |
#to_h ⇒ Hash
Returns a hash representation of this MachO::Headers::MachHeader.
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
# 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 |