Java Code Examples for ghidra.app.util.bin.BinaryReader#clone()

The following examples show how to use ghidra.app.util.bin.BinaryReader#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectiveC1_ProtocolList.java    From ghidra with Apache License 2.0 6 votes vote down vote up
ObjectiveC1_ProtocolList(ObjectiveC1_State state, BinaryReader reader) throws IOException {
	this._state = state;
	this._index = reader.getPointerIndex();
	if (_index == 0) {
		return;
	}

	next = new ObjectiveC1_ProtocolList(state, reader.clone( reader.readNextInt() ));

	count = reader.readNextInt();

	for (int i = 0 ; i < count ; ++i) {
		int protocolIndex = reader.readNextInt();
		long oldProtocolIndex = reader.getPointerIndex();
		reader.setPointerIndex(protocolIndex);
		protocols.add(new ObjectiveC1_Protocol(state, reader));
		reader.setPointerIndex(oldProtocolIndex);
	}
}
 
Example 2
Source File: ObjectiveC1_Class.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public ObjectiveC1_Class(ObjectiveC1_State state, BinaryReader reader) throws IOException {
	this._state = state;
	this._index = reader.getPointerIndex();

	isa = new ObjectiveC1_MetaClass(state, reader.clone(reader.readNextInt()));
	super_class = ObjectiveC1_Utilities.dereferenceAsciiString(reader, state.is32bit);
	name = reader.readAsciiString(reader.readNextInt());
	version = reader.readNextInt();
	info = reader.readNextInt();
	instance_size = reader.readNextInt();
	variable_list =
		new ObjectiveC1_InstanceVariableList(state, reader.clone(reader.readNextInt()));
	method_list =
		new ObjectiveC1_MethodList(state, reader.clone(reader.readNextInt()),
			ObjectiveC_MethodType.INSTANCE);
	cache = reader.readNextInt();
	protocols = new ObjectiveC1_ProtocolList(state, reader.clone(reader.readNextInt()));
	unknown0 = reader.readNextInt();
	unknown1 = reader.readNextInt();
}
 
Example 3
Source File: ObjectiveC1_MetaClass.java    From ghidra with Apache License 2.0 6 votes vote down vote up
ObjectiveC1_MetaClass(ObjectiveC1_State state, BinaryReader reader) throws IOException {
	this._state = state;
	this._index = reader.getPointerIndex();

	isa                = ObjectiveC1_Utilities.dereferenceAsciiString(reader, state.is32bit);
	super_class        = ObjectiveC1_Utilities.dereferenceAsciiString(reader, state.is32bit);
	name               = ObjectiveC1_Utilities.dereferenceAsciiString(reader, state.is32bit);
	version            = reader.readNextInt();
	info               = reader.readNextInt();
	instance_size      = reader.readNextInt();
	variable_list      = new ObjectiveC1_InstanceVariableList(state, reader.clone(reader.readNextInt()));
	method_list        = new ObjectiveC1_MethodList(state, reader.clone(reader.readNextInt()), ObjectiveC_MethodType.INSTANCE);
	cache              = reader.readNextInt();
	protocols          = new ObjectiveC1_ProtocolList(state, reader.clone(reader.readNextInt()));
	unknown0           = reader.readNextInt();
	unknown1           = reader.readNextInt();
}
 
Example 4
Source File: ObjectiveC1_Module.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public ObjectiveC1_Module(ObjectiveC1_State state, BinaryReader reader) throws IOException {
	this._state = state;
	_index = reader.getPointerIndex();

	version = reader.readNextInt();
	size = reader.readNextInt();
	name = ObjectiveC1_Utilities.dereferenceAsciiString(reader, state.is32bit);

	int symbolTableIndex = reader.readNextInt();

	if (symbolTableIndex != 0) {
		symbolTable = new ObjectiveC1_SymbolTable(state, reader.clone(symbolTableIndex));
	}
}
 
Example 5
Source File: ObjectiveC1_Category.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public ObjectiveC1_Category(ObjectiveC1_State state, BinaryReader reader) throws IOException {
	this._state = state;
	this._index = reader.getPointerIndex();

	category_name    = reader.readAsciiString( reader.readNextInt() );
	class_name       = reader.readAsciiString( reader.readNextInt() );
	instance_methods = new ObjectiveC1_MethodList(state, reader.clone(reader.readNextInt()), ObjectiveC_MethodType.INSTANCE);
	class_methods    = new ObjectiveC1_MethodList(state, reader.clone(reader.readNextInt()), ObjectiveC_MethodType.CLASS);
	protocols        = new ObjectiveC1_ProtocolList(state, reader.clone( reader.readNextInt() ));

	if (state.isARM) {
		unknown0     = reader.readNextInt();
		unknown1     = reader.readNextInt();
	}
}
 
Example 6
Source File: ObjectiveC1_MethodList.java    From ghidra with Apache License 2.0 5 votes vote down vote up
ObjectiveC1_MethodList(ObjectiveC1_State state, BinaryReader reader, ObjectiveC_MethodType methodType) throws IOException {
	super(state, reader, NAME);

	if (_index == 0) {
		return;
	}

	obsolete = new ObjectiveC1_MethodList(state, reader.clone(reader.readNextInt()), methodType );

	method_count = reader.readNextInt();

	for (int i = 0 ; i < method_count ; ++i) {
		methods.add(new ObjectiveC1_Method(state, reader, methodType));
	}
}
 
Example 7
Source File: ObjectiveC1_Protocol.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public ObjectiveC1_Protocol(ObjectiveC1_State state, BinaryReader reader) throws IOException {
	this._state = state;
	this._index = reader.getPointerIndex();

	isa             = reader.readNextInt();
	name            = ObjectiveC1_Utilities.dereferenceAsciiString(reader, state.is32bit);
	protocolList    = new ObjectiveC1_ProtocolList(state, reader.clone(reader.readNextInt()));
	instanceMethods = new ObjectiveC1_ProtocolMethodList(state, reader.clone(reader.readNextInt()), ObjectiveC_MethodType.INSTANCE);
	classMethods    = new ObjectiveC1_ProtocolMethodList(state, reader.clone(reader.readNextInt()), ObjectiveC_MethodType.CLASS);
}