Package ghidra.app.util.bin.format.macho.commands

# Class LoadCommand

java.lang.Object
ghidra.app.util.bin.format.macho.commands.LoadCommand

All Implemented Interfaces:
  `StructConverter`

Direct Known Subclasses:
  `BuildVersionCommand`, `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:
  - EXTERNAL_HEADERS/mach-o/loader.h

- ## Field Summary

  ### Fields inherited from interface ghidra.app.util.bin.StructConverter

  `ASCII, BYTE, DWORD, IBO32, IBO64, POINTER, QWORD, SLEB128, STRING, ULEB128, UTF16, UTF8, VOID, WORD`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LoadCommand(BinaryReader reader)`
  Creates a new `LoadCommand`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected final ProgramFragment`
  `createFragment(FlatProgramAPI api, Address baseAddress, ProgramModule module)`
  `protected final void`
  `createPlateComment(FlatProgramAPI api, Address addr)`
  `protected Address`
  `fileOffsetToAddress(Program program, MachHeader header, int fileOffset, int size)`
  Converts the given Mach-O file offset to an `Address`
  `abstract String`
  `getCommandName()`
  Gets the name of this load command
  `int`
  `getCommandSize()`
  Gets the size of this load command in bytes
  `int`
  `getCommandType()`
  Gets the type of this load command
  `protected String`
  `getContextualName(String source, String additionalDescription)`
  Gets the name of this `LoadCommand` which includes contextual information
  `int`
  `getLinkerDataOffset()`
  Gets the file offset of this load command's "linker data".
  `int`
  `getLinkerDataSize()`
  Gets the file size of this load command's "linker data".
  `long`
  `getStartIndex()`
  Returns the binary start index of this load command
  `void`
  `markup(Program program, MachHeader header, String source, TaskMonitor monitor, MessageLog log)`
  Marks up this `LoadCommand` data with data structures and comments.
  `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
  `void`
  `markupRawBinary(MachHeader header, FlatProgramAPI api, Address baseAddress, ProgramModule parentModule, TaskMonitor monitor, MessageLog log)`
  Marks-up this `LoadCommand` with data structures and comments.
  `static void`
  `setEndian(Data data, boolean bigEndian)`
  Recursively sets the given `Data` and its components to big/little endian
  `protected final void`
  `updateMonitor(TaskMonitor monitor)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ghidra.app.util.bin.StructConverter

  `toDataType`

- ## Constructor Details

  - ### LoadCommand

    public LoadCommand(BinaryReader reader) throws IOException
    Creates a new `LoadCommand`
    Parameters:
      `reader` - A `BinaryReader` that points to the start of the load command
    Throws:
      `IOException` - if there was an IO-related error

- ## 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:
      - `MachoBinaryAnalysisCommand`

  - ### 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)