Java Code Examples for ghidra.program.model.symbol.RefType#INDIRECTION

The following examples show how to use ghidra.program.model.symbol.RefType#INDIRECTION . 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: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followOnlyComputedCalls() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.CONDITIONAL_CALL, RefType.UNCONDITIONAL_CALL,
			RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP, RefType.UNCONDITIONAL_JUMP,
			RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 2
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followOnlyConditionalCalls() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.UNCONDITIONAL_CALL,
			RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP, RefType.UNCONDITIONAL_JUMP,
			RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 3
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followOnlyUnconditionalCalls() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP, RefType.UNCONDITIONAL_JUMP,
			RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 4
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followOnlyComputedJumps() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.UNCONDITIONAL_CALL, RefType.CONDITIONAL_JUMP, RefType.UNCONDITIONAL_JUMP,
			RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 5
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followOnlyConditionalJumps() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.UNCONDITIONAL_CALL, RefType.COMPUTED_JUMP, RefType.UNCONDITIONAL_JUMP,
			RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 6
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followOnlyUnconditionalJumps() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.UNCONDITIONAL_CALL, RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP,
			RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 7
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
FlowType[] followNoFlows() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.UNCONDITIONAL_CALL, RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP,
			RefType.UNCONDITIONAL_JUMP, RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 8
Source File: SleighInstructionPrototype.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private RefType getStaticOperandRefType(Varnode var, PcodeOp[] pcode) {
	if (var.isConstant()) {
		return RefType.DATA;
	}
	boolean isRead = false;
	boolean isWrite = false;
	for (PcodeOp element : pcode) {
		Varnode[] inputs = element.getInputs();
		switch (element.getOpcode()) {

			case PcodeOp.BRANCHIND:
			case PcodeOp.CALLIND:
			case PcodeOp.RETURN:
				if (inputs[0].equals(var)) {
					return RefType.INDIRECTION;
				}
				break;

			case PcodeOp.BRANCH:
				if (inputs[0].equals(var)) {
					return RefType.UNCONDITIONAL_JUMP;
				}
				break;

			case PcodeOp.CBRANCH:
				if (inputs[0].equals(var)) {
					return RefType.CONDITIONAL_JUMP;
				}
				break;

			case PcodeOp.CALL:
				if (inputs[0].equals(var)) {
					return RefType.UNCONDITIONAL_CALL;
				}
				break;

		}
		if (!var.isUnique()) {
			if (var.equals(element.getOutput())) {
				isWrite = true;
			}
			for (Varnode input : element.getInputs()) {
				if (var.equals(input)) {
					isRead = true;
				}
			}
		}
	}
	if (isRead && isWrite) {
		return RefType.READ_WRITE;
	}
	if (isRead) {
		return RefType.READ;
	}
	if (isWrite) {
		return RefType.WRITE;
	}
	return RefType.DATA;
}
 
Example 9
Source File: SleighInstructionPrototype.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private RefType getDynamicOperandRefType(FixedHandle hand, PcodeOp[] pcode) {
	Varnode offset = hand.getDynamicOffset();
	Varnode staticAddr = hand.getStaticVarnode();
	Varnode temp = hand.getDynamicTemp();
	boolean isRead = false;
	boolean isWrite = false;
	for (PcodeOp element : pcode) {
		Varnode[] inputs = element.getInputs();
		switch (element.getOpcode()) {

			case PcodeOp.LOAD:
				if (temp.equals(element.getOutput())) {
					isRead = true;
				}
				break;

			case PcodeOp.STORE:
				if (offset.equals(inputs[1]) && temp.equals(inputs[2])) {
					isWrite = true;
				}
				break;

			case PcodeOp.BRANCHIND:
			case PcodeOp.CALLIND:
			case PcodeOp.RETURN:
				if (inputs[0].equals(temp) || inputs[0].equals(staticAddr)) {
					return RefType.INDIRECTION;
				}
				break;

			case PcodeOp.BRANCH:
				if (inputs[0].equals(staticAddr)) {
					return RefType.UNCONDITIONAL_JUMP;
				}
				break;

			case PcodeOp.CBRANCH:
				if (inputs[0].equals(staticAddr)) {
					return RefType.CONDITIONAL_JUMP;
				}
				break;

			case PcodeOp.CALL:
				if (inputs[0].equals(staticAddr)) {
					return RefType.UNCONDITIONAL_CALL;
				}
				break;

		}
	}
	if (isRead && isWrite) {
		return RefType.READ_WRITE;
	}
	if (isRead) {
		return RefType.READ;
	}
	if (isWrite) {
		return RefType.WRITE;
	}
	return RefType.DATA;
}
 
Example 10
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
FlowType[] followConditionalAndUnconditionalJumps() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.UNCONDITIONAL_CALL, RefType.COMPUTED_JUMP, RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 11
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
FlowType[] followAllJumps() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL,
			RefType.UNCONDITIONAL_CALL, RefType.INDIRECTION };
	return flowsNotToFollow;
}
 
Example 12
Source File: AbstractFollowFlowTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
FlowType[] followAllCalls() {
	FlowType[] flowsNotToFollow =
		new FlowType[] { RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP,
			RefType.UNCONDITIONAL_JUMP, RefType.INDIRECTION };
	return flowsNotToFollow;
}