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
Represents a load_command structure
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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 anAddress
abstract String
Gets the name of this load commandint
Gets the size of this load command in bytesint
Gets the type of this load commandprotected String
getContextualName
(String source, String additionalDescription) Gets the name of thisLoadCommand
which includes contextual informationint
Gets the file offset of this load command's "linker data".int
Gets the file size of this load command's "linker data".long
Returns the binary start index of this load commandvoid
markup
(Program program, MachHeader header, String source, TaskMonitor monitor, MessageLog log) Marks up thisLoadCommand
data with data structures and comments.protected void
markupPlateComment
(Program program, Address address, String source, String additionalDescription) Creates a plate comment at the givenAddress
based on thisLoadCommand
's namevoid
markupRawBinary
(MachHeader header, FlatProgramAPI api, Address baseAddress, ProgramModule parentModule, TaskMonitor monitor, MessageLog log) Marks-up thisLoadCommand
with data structures and comments.static void
Recursively sets the givenData
and its components to big/little endianprotected 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
Creates a newLoadCommand
- Parameters:
reader
- ABinaryReader
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
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 thisLoadCommand
data with data structures and comments. Assumes the program was imported as a Mach-O.- Parameters:
program
- TheProgram
to mark upheader
- The Mach-O headersource
- A name that represents where the header came from (could be null)monitor
- A cancellable task monitorlog
- 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 givenAddress
based on thisLoadCommand
's name- Parameters:
program
- TheProgram
to mark upaddress
- TheAddress
to put the comment atsource
- An optional string representing the source of theLoadCommand
. Could be empty or null.additionalDescription
- An optional string representing a sub-description of thisLoadCommand
. Could be empty or null.
-
getContextualName
Gets the name of thisLoadCommand
which includes contextual information- Parameters:
source
- The source of thisLoadCommand
(could be null or empty)additionalDescription
- Additional information to associate with theLoadCommand
name- Returns:
- The name of this
LoadCommand
which includes contextual information
-
fileOffsetToAddress
Converts the given Mach-O file offset to anAddress
-
setEndian
Recursively sets the givenData
and its components to big/little endian -
markupRawBinary
public void markupRawBinary(MachHeader header, FlatProgramAPI api, Address baseAddress, ProgramModule parentModule, TaskMonitor monitor, MessageLog log) Marks-up thisLoadCommand
with data structures and comments. Assumes the program was imported as a Raw Binary.- Parameters:
header
- The Mach-O headerapi
- AFlatProgramAPI
baseAddress
- The base address of the programparentModule
- The parentmodule
to create fragmentsmonitor
- A cancellable task monitorlog
- The log- See Also:
-
createFragment
protected final ProgramFragment createFragment(FlatProgramAPI api, Address baseAddress, ProgramModule module) throws Exception - Throws:
Exception
-
createPlateComment
-
updateMonitor
-