Package ghidra.app.util.bin.format.objc
Class ObjcUtils
java.lang.Object
ghidra.app.util.bin.format.objc.ObjcUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateData(Program program, DataType dt, Address address) Applies the data type at the specified addressstatic final voidcreateMethods(Program program, ObjcState state, MessageLog log, TaskMonitor monitor) Creates methodsstatic NamespacecreateNamespace(Program program, String... namespacePath) Returns a newly created namespace hierarchy formed from the list of given strings.static StringcreateString(Program program, Address address) Creates a string data type at the given addressstatic SymbolcreateSymbol(Program program, Namespace parentNamespace, String symbolName, Address symbolAddress) Returns a newly created primarySymbol.static StringdereferenceAsciiString(BinaryReader reader, boolean is32bit) Returns the string referenced at the next read pointer, ornullif the pointer is 0.static final voidfixupReferences(List<String> sectionNames, Program program, TaskMonitor monitor) Removes references to the NULL address and adjusts THUMB references to no longer be offcutstatic NamespacegetClassNamespace(Program program, Namespace parentNamespace, String namespaceName) Returns the class inside the given parent namespace, or a newly created one if it doesn't exist.static List<MemoryBlock> getObjcBlocks(String section, Program program) Returns aListofMemoryBlocks that match the given section name.static booleanReturns whether or not the given address is THUMB code.static booleanReturns whether or not the given address is THUMB code.static longreadNextIndex(BinaryReader reader, boolean is32bit) Returns the next read index value.static voidsetBlocksReadOnly(Memory memory, List<String> blockNames) Sets the given block names as read-onlystatic voidsetThumbBit(Program program, ObjcState state, Address address) If needed, sets the TMode bit at the specified addressstatic AddressReturns anAddressthat corresponds to the given offset in the default address space.
-
Constructor Details
-
ObjcUtils
public ObjcUtils()
-
-
Method Details
-
readNextIndex
Returns the next read index value.If
is32bitis true, then 4 bytes will be read to form the index. Otherwise, 8 bytes will be read to form the index.- Parameters:
reader- ABinaryReaderpositioned at the start of the index to readis32bit- True if the index is 32-bit; false if 64-bit;- Returns:
- the next read index value
- Throws:
IOException- if an IO-related error occurred
-
dereferenceAsciiString
public static String dereferenceAsciiString(BinaryReader reader, boolean is32bit) throws IOException Returns the string referenced at the next read pointer, ornullif the pointer is 0.If
is32bitis true, then 4 bytes will be read to form the pointer. Otherwise, 8 bytes will be read to form the pointer.- Parameters:
reader- ABinaryReaderpositioned at the start of the string pointer to readis32bit- True if the string pointer is 32-bit; false if 64-bit;- Returns:
- the string referenced at the next read pointer, or
nullif the pointer is 0 - Throws:
IOException- if an IO-related error occurred
-
isThumb
Returns whether or not the given address is THUMB code. -
isThumb
Returns whether or not the given address is THUMB code.- Parameters:
program- TheProgramaddress- The address to check- Returns:
- whether or not the given address is THUMB code
-
setThumbBit
If needed, sets the TMode bit at the specified address -
toAddress
Returns anAddressthat corresponds to the given offset in the default address space. -
createData
public static void createData(Program program, DataType dt, Address address) throws CodeUnitInsertionException Applies the data type at the specified address- Parameters:
program- TheProgramdt- TheDataTypeto applyaddress- TheAddressto apply the data type at- Throws:
CodeUnitInsertionException- if data creation failed
-
createString
Creates a string data type at the given address -
getClassNamespace
public static Namespace getClassNamespace(Program program, Namespace parentNamespace, String namespaceName) throws DuplicateNameException, InvalidInputException Returns the class inside the given parent namespace, or a newly created one if it doesn't exist.- Parameters:
program- TheProgramparentNamespace- The parent namespacenamespaceName- The name of the class namespace to get/create- Returns:
- the class inside the given parent namespace, or a newly created one if it doesn't exist
- Throws:
DuplicateNameException- if another label exists with the given nameInvalidInputException- if the given name is invalid
-
createSymbol
public static Symbol createSymbol(Program program, Namespace parentNamespace, String symbolName, Address symbolAddress) throws InvalidInputException Returns a newly created primarySymbol.- Parameters:
program- TheProgramparentNamespace- The parent namespacesymbolName- The symbol namesymbolAddress- The symbolAddress- Returns:
- a newly created primary
Symbol - Throws:
InvalidInputException- if the given name is invalid
-
createNamespace
public static Namespace createNamespace(Program program, String... namespacePath) throws DuplicateNameException, InvalidInputException Returns a newly created namespace hierarchy formed from the list of given strings.- Parameters:
program- TheProgramnamespacePath- The namespace path- Returns:
- a newly created namespace hierarchy formed from the list of given strings
- Throws:
DuplicateNameException- if another label exists with the given nameInvalidInputException- if the given name is invalid
-
createMethods
public static final void createMethods(Program program, ObjcState state, MessageLog log, TaskMonitor monitor) Creates methods -
fixupReferences
public static final void fixupReferences(List<String> sectionNames, Program program, TaskMonitor monitor) Removes references to the NULL address and adjusts THUMB references to no longer be offcut- Parameters:
sectionNames- The names of the sections to fixprogram- TheProgrammonitor- A cancellable monitor
-
setBlocksReadOnly
Sets the given block names as read-only -
getObjcBlocks
Returns aListofMemoryBlocks that match the given section name.- Parameters:
section- The section nameprogram- TheProgram- Returns:
- a
ListofMemoryBlocks that match the given section name
-