Class LoadCommand

java.lang.Object
ghidra.app.util.bin.format.macho.commands.LoadCommand
All Implemented Interfaces:
StructConverter
Direct Known Subclasses:
BuildVersionCommand, CorruptLoadCommand, DyldInfoCommand, DynamicLibraryCommand, DynamicLinkerCommand, DynamicSymbolTableCommand, EncryptedInformationCommand, EntryPointCommand, FileSetEntryCommand, FixedVirtualMemoryFileCommand, LinkEditDataCommand, LinkerOptionCommand, ObsoleteCommand, PrebindChecksumCommand, PreboundDynamicLibraryCommand, RoutinesCommand, RunPathCommand, SegmentCommand, SourceVersionCommand, SubClientCommand, SubFrameworkCommand, SubLibraryCommand, SubUmbrellaCommand, SymbolTableCommand, ThreadCommand, TwoLevelHintsCommand, UnsupportedLoadCommand, UuidCommand, VersionMinCommand

public abstract class LoadCommand extends Object implements StructConverter
Represents a load_command structure
See Also:
  • Constructor Details

  • Method Details

    • getStartIndex

      public long getStartIndex()
      Returns the binary start index of this load command
      Returns:
      the binary start index of this load command
    • getCommandType

      public int getCommandType()
      Gets the type of this load command
      Returns:
      The type of this load command
    • getCommandSize

      public int getCommandSize()
      Gets the size of this load command in bytes
      Returns:
      The size of this load command in bytes
    • getCommandName

      public abstract String getCommandName()
      Gets the name of this load command
      Returns:
      The name of this load command
    • getLinkerDataOffset

      public int getLinkerDataOffset()
      Gets the file offset of this load command's "linker data". Not all load commands with data will have linker data. Linker data typically resides in the __LINKEDIT segment.
      Returns:
      The file offset of this load command's "linker data", or 0 if it has no linker data
    • getLinkerDataSize

      public int getLinkerDataSize()
      Gets the file size of this load command's "linker data". Not all load commands with data will have linker data. Linker data typically resides in the __LINKEDIT segment.
      Returns:
      The file size of this load command's "linker data", or 0 if it has no linker data
    • markup

      public void markup(Program program, MachHeader header, String source, TaskMonitor monitor, MessageLog log) throws CancelledException
      Marks up this LoadCommand data with data structures and comments. Assumes the program was imported as a Mach-O.
      Parameters:
      program - The Program to mark up
      header - The Mach-O header
      source - A name that represents where the header came from (could be null)
      monitor - A cancellable task monitor
      log - The log
      Throws:
      CancelledException - if the user cancelled the operation
    • markupPlateComment

      protected void markupPlateComment(Program program, Address address, String source, String additionalDescription)
      Creates a plate comment at the given Address based on this LoadCommand's name
      Parameters:
      program - The Program to mark up
      address - The Address to put the comment at
      source - An optional string representing the source of the LoadCommand. Could be empty or null.
      additionalDescription - An optional string representing a sub-description of this LoadCommand. Could be empty or null.
    • getContextualName

      protected String getContextualName(String source, String additionalDescription)
      Gets the name of this LoadCommand which includes contextual information
      Parameters:
      source - The source of this LoadCommand (could be null or empty)
      additionalDescription - Additional information to associate with the LoadCommand name
      Returns:
      The name of this LoadCommand which includes contextual information
    • fileOffsetToAddress

      protected Address fileOffsetToAddress(Program program, MachHeader header, int fileOffset, int size)
      Converts the given Mach-O file offset to an Address
      Parameters:
      program - The Program
      header - The Mach-O header
      fileOffset - The file offset of the data (0 indicates no data)
      size - The size (actual size not important, but 0 will cause null to be returned)
      Returns:
      The converted Address, or null if there is no corresponding Address
    • setEndian

      public static void setEndian(Data data, boolean bigEndian) throws Exception
      Recursively sets the given Data and its components to big/little endian
      Parameters:
      data - The Data
      bigEndian - True to set to big endian; false to set to little endian
      Throws:
      Exception - if there was a problem setting the endianness
    • markupRawBinary

      public void markupRawBinary(MachHeader header, FlatProgramAPI api, Address baseAddress, ProgramModule parentModule, TaskMonitor monitor, MessageLog log)
      Marks-up this LoadCommand with data structures and comments. Assumes the program was imported as a Raw Binary.
      Parameters:
      header - The Mach-O header
      api - A FlatProgramAPI
      baseAddress - The base address of the program
      parentModule - The parent module to create fragments
      monitor - A cancellable task monitor
      log - The log
      See Also:
    • createFragment

      protected final ProgramFragment createFragment(FlatProgramAPI api, Address baseAddress, ProgramModule module) throws Exception
      Throws:
      Exception
    • createPlateComment

      protected final void createPlateComment(FlatProgramAPI api, Address addr)
    • updateMonitor

      protected final void updateMonitor(TaskMonitor monitor)