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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected longcheckCount(long count) Checks to make sure the given count value isn't larger thanInteger.MAX_VALUE.protected final ProgramFragmentcreateFragment(FlatProgramAPI api, Address baseAddress, ProgramModule module) protected final voidcreatePlateComment(FlatProgramAPI api, Address addr) protected AddressfileOffsetToAddress(Program program, MachHeader header, long fileOffset, long size) Converts the given Mach-O file offset to anAddressabstract StringGets the name of this load commandintGets the size of this load command in bytesintGets the type of this load commandprotected StringgetContextualName(String source, String additionalDescription) Gets the name of thisLoadCommandwhich includes contextual informationlongGets the file offset of this load command's "linker data".longGets the file size of this load command's "linker data".longReturns the binary start index of this load commandvoidmarkup(Program program, MachHeader header, String source, TaskMonitor monitor, MessageLog log) Marks up thisLoadCommanddata with data structures and comments.protected voidmarkupPlateComment(Program program, Address address, String source, String additionalDescription) Creates a plate comment at the givenAddressbased on thisLoadCommand's namevoidmarkupRawBinary(MachHeader header, FlatProgramAPI api, Address baseAddress, ProgramModule parentModule, TaskMonitor monitor, MessageLog log) Marks-up thisLoadCommandwith data structures and comments.protected final voidupdateMonitor(TaskMonitor monitor) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.app.util.bin.StructConverter
toDataType
-
Constructor Details
-
LoadCommand
Creates a newLoadCommand- Parameters:
reader- ABinaryReaderthat 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 long 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 long 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 thisLoadCommanddata with data structures and comments. Assumes the program was imported as a Mach-O.- Parameters:
program- TheProgramto 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 givenAddressbased on thisLoadCommand's name- Parameters:
program- TheProgramto mark upaddress- TheAddressto 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 thisLoadCommandwhich includes contextual information- Parameters:
source- The source of thisLoadCommand(could be null or empty)additionalDescription- Additional information to associate with theLoadCommandname- Returns:
- The name of this
LoadCommandwhich includes contextual information
-
fileOffsetToAddress
protected Address fileOffsetToAddress(Program program, MachHeader header, long fileOffset, long size) Converts the given Mach-O file offset to anAddress -
checkCount
Checks to make sure the given count value isn't larger thanInteger.MAX_VALUE.Count values are typically
uint32_t, so we store them aslongs. But, we usually end up storing the items in an array orArrayList, which can't exceed the size of anint.- Parameters:
count- The count value to check- Returns:
- The original count value
- Throws:
IOException- if the given count value exceedsInteger.MAX_VALUE
-
markupRawBinary
public void markupRawBinary(MachHeader header, FlatProgramAPI api, Address baseAddress, ProgramModule parentModule, TaskMonitor monitor, MessageLog log) Marks-up thisLoadCommandwith data structures and comments. Assumes the program was imported as a Raw Binary.- Parameters:
header- The Mach-O headerapi- AFlatProgramAPIbaseAddress- The base address of the programparentModule- The parentmoduleto 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
-