Class MachHeader

    • Constructor Detail

      • MachHeader

        public MachHeader()
        DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
    • Method Detail

      • createMachHeader

        public static MachHeader createMachHeader​(GenericFactory factory,
                                                  ByteProvider provider)
                                           throws java.io.IOException,
                                                  MachException
        Assumes the MachHeader starts at index 0 in the ByteProvider.
        Parameters:
        provider - the ByteProvider
        Throws:
        java.io.IOException - if an I/O error occurs while reading from the ByteProvider
        MachException - if an invalid MachHeader is detected
      • createMachHeader

        public static MachHeader createMachHeader​(GenericFactory factory,
                                                  ByteProvider provider,
                                                  long machHeaderStartIndexInProvider)
                                           throws java.io.IOException,
                                                  MachException
        Assumes the MachHeader starts at index machHeaderStartIndexInProvider in the ByteProvider.
        Parameters:
        provider - the ByteProvider
        machHeaderStartIndexInProvider - the index into the ByteProvider where the MachHeader begins.
        Throws:
        java.io.IOException - if an I/O error occurs while reading from the ByteProvider
        MachException - if an invalid MachHeader is detected
      • createMachHeader

        public static MachHeader createMachHeader​(GenericFactory factory,
                                                  ByteProvider provider,
                                                  long machHeaderStartIndexInProvider,
                                                  boolean isRemainingMachoRelativeToStartIndex)
                                           throws java.io.IOException,
                                                  MachException
        Assumes the MachHeader starts at index machHeaderStartIndexInProvider in the ByteProvider.
        Parameters:
        provider - the ByteProvider
        machHeaderStartIndexInProvider - the index into the ByteProvider where the MachHeader begins.
        isRemainingMachoRelativeToStartIndex - TRUE if the rest of the macho uses relative indexing. This is common in UBI and kernel cache files. FALSE if the rest of the file uses absolute indexing from 0. This is common in DYLD cache files.
        Throws:
        java.io.IOException - if an I/O error occurs while reading from the ByteProvider
        MachException - if an invalid MachHeader is detected
      • getMagic

        public int getMagic()
      • getCpuType

        public int getCpuType()
      • getImageBase

        public long getImageBase()
      • getCpuSubType

        public int getCpuSubType()
      • getFileType

        public int getFileType()
      • getNumberOfCommands

        public int getNumberOfCommands()
      • getSizeOfCommands

        public int getSizeOfCommands()
      • getFlags

        public int getFlags()
      • toDataType

        public DataType toDataType()
                            throws DuplicateNameException,
                                   java.io.IOException
        Description copied from interface: StructConverter
        Returns a structure datatype representing the contents of the implementor of this interface.

        For example, given:

         class A {
             int foo;
             double bar;
         }
         

        The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.

        Specified by:
        toDataType in interface StructConverter
        Returns:
        returns a structure datatype representing the implementor of this interface
        Throws:
        DuplicateNameException - when a datatype of the same name already exists
        java.io.IOException
        See Also:
        StructureDataType
      • getStartIndexInProvider

        public long getStartIndexInProvider()
      • is32bit

        public boolean is32bit()
      • getAddressSize

        public int getAddressSize()
      • getAllSegments

        public java.util.List<SegmentCommand> getAllSegments()
      • getSegment

        public SegmentCommand getSegment​(java.lang.String segmentName)
      • getSection

        public Section getSection​(java.lang.String segmentName,
                                  java.lang.String sectionName)
      • getAllSections

        public java.util.List<Section> getAllSections()
      • getLoadCommands

        public java.util.List<LoadCommand> getLoadCommands()
      • getLoadCommands

        public <T> java.util.List<T> getLoadCommands​(java.lang.Class<T> classType)
      • getFirstLoadCommand

        public <T> T getFirstLoadCommand​(java.lang.Class<T> classType)
      • isLittleEndian

        public boolean isLittleEndian()
      • getDescription

        public java.lang.String getDescription()
      • getDataStream

        public java.io.InputStream getDataStream()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object