Class ObjectiveC1_Utilities
- java.lang.Object
-
- ghidra.app.util.bin.format.objectiveC.ObjectiveC1_Utilities
-
public final class ObjectiveC1_Utilities extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ObjectiveC1_Utilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
applyData(Program program, DataType dt, Address address)
Applies the data type at the specified address.static void
clear(ObjectiveC2_State state, MemoryBlock block)
Clears the code units defined in the given memory block.static void
createInstanceVariablesC2_OBJC2(ObjectiveC2_State state)
static void
createMethods(ObjectiveC1_State state)
static Namespace
createNamespace(Program program, java.lang.String... namespacePath)
Creates a namespace hierarchy using the list of strings specified in namespacePath.static Data
createPointer(Program program, Address address)
Applies a pointer data type at the specified address and returns the newly created data object.static Address
createPointerAndReturnAddressBeingReferenced(Program program, Address address)
Applies a pointer data type at the specified address and returns the address being referenced.static java.lang.String
createString(Program program, Address address)
Applies a string data type at the specified address and returns the string object.static Symbol
createSymbol(Program program, Namespace parentNamespace, java.lang.String symbolName, Address symbolAddress)
Creates a symbol.static java.lang.String
dereferenceAsciiString(BinaryReader reader, boolean is32bit)
Dereferences a string pointer and returns the string.static void
fixupReferences(ObjectiveC1_State state)
This method will remove references to the NULL address and it will adjust THUMB references to no longer be offcut.static java.lang.String
formatAsObjectiveC(Function function, ObjectiveC_MethodType methodType)
static java.lang.String
formatAsObjectiveC(FunctionSignature signature, ObjectiveC_MethodType methodType, boolean appendSemicolon)
static Namespace
getClassNamespace(Program program, Namespace parentNamespace, java.lang.String namespaceName)
Returns the class inside the given parent name space.static boolean
isNull(Address address)
Returns true if the given address is zero.static boolean
isThumb(Program program, long address)
Returns true if the address is THUMB code.static boolean
isThumb(Program program, Address address)
Returns true if the address is THUMB code.static long
readNextIndex(BinaryReader reader, boolean is32bit)
Reads the next index value.static void
setThumbBit(ObjectiveC1_State state, Address address)
If needed, sets the TMode bit at the specified address.static Address
toAddress(Program program, long offset)
Manufactures an address from the given long.
-
-
-
Method Detail
-
clear
public static void clear(ObjectiveC2_State state, MemoryBlock block) throws java.lang.Exception
Clears the code units defined in the given memory block.- Throws:
java.lang.Exception
-
readNextIndex
public static long readNextIndex(BinaryReader reader, boolean is32bit) throws java.io.IOException
Reads the next index value. If is32bit is true, then 4 bytes will be read to form index. Otherwise, 8 bytes will be read to form index.- Throws:
java.io.IOException
-
dereferenceAsciiString
public static java.lang.String dereferenceAsciiString(BinaryReader reader, boolean is32bit) throws java.io.IOException
Dereferences a string pointer and returns the string. If 32-bit only reads a 32-bit pointer.- Throws:
java.io.IOException
-
isNull
public static boolean isNull(Address address)
Returns true if the given address is zero.
-
isThumb
public static boolean isThumb(Program program, Address address)
Returns true if the address is THUMB code.
-
isThumb
public static boolean isThumb(Program program, long address)
Returns true if the address is THUMB code.
-
setThumbBit
public static void setThumbBit(ObjectiveC1_State state, Address address)
If needed, sets the TMode bit at the specified address.
-
toAddress
public static Address toAddress(Program program, long offset)
Manufactures an address from the given long.
-
applyData
public static void applyData(Program program, DataType dt, Address address) throws CodeUnitInsertionException, DataTypeConflictException
Applies the data type at the specified address.
-
createString
public static java.lang.String createString(Program program, Address address)
Applies a string data type at the specified address and returns the string object.
-
createPointerAndReturnAddressBeingReferenced
public static Address createPointerAndReturnAddressBeingReferenced(Program program, Address address) throws CodeUnitInsertionException, DataTypeConflictException
Applies a pointer data type at the specified address and returns the address being referenced.
-
createPointer
public static Data createPointer(Program program, Address address)
Applies a pointer data type at the specified address and returns the newly created data object.
-
getClassNamespace
public static Namespace getClassNamespace(Program program, Namespace parentNamespace, java.lang.String namespaceName) throws DuplicateNameException, InvalidInputException
Returns the class inside the given parent name space. If it does not exist, then create it and return it.
-
createSymbol
public static Symbol createSymbol(Program program, Namespace parentNamespace, java.lang.String symbolName, Address symbolAddress) throws InvalidInputException
Creates a symbol. TODO - make symbols primary?- Throws:
InvalidInputException
-
createNamespace
public static Namespace createNamespace(Program program, java.lang.String... namespacePath) throws DuplicateNameException, InvalidInputException
Creates a namespace hierarchy using the list of strings specified in namespacePath.
-
formatAsObjectiveC
public static final java.lang.String formatAsObjectiveC(Function function, ObjectiveC_MethodType methodType)
-
formatAsObjectiveC
public static final java.lang.String formatAsObjectiveC(FunctionSignature signature, ObjectiveC_MethodType methodType, boolean appendSemicolon) throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
createMethods
public static final void createMethods(ObjectiveC1_State state)
-
createInstanceVariablesC2_OBJC2
public static final void createInstanceVariablesC2_OBJC2(ObjectiveC2_State state)
-
fixupReferences
public static final void fixupReferences(ObjectiveC1_State state)
This method will remove references to the NULL address and it will adjust THUMB references to no longer be offcut.
-
-