Java Code Examples for ghidra.program.model.symbol.RefType#UNCONDITIONAL_JUMP
The following examples show how to use
ghidra.program.model.symbol.RefType#UNCONDITIONAL_JUMP .
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: FunctionGraph.java From ghidra with Apache License 2.0 | 6 votes |
/** * A method to create dummy edges (with dummy vertices). This is used to add entry and * exit vertices as needed when a user grouping operation has consumed the entries or exits. * The returned edge will connect the current vertex containing the entry to a new dummy * vertex that is a source for the graph. Calling this method does not mutate this graph. * * @return the edge */ public Set<FGEdge> createDummySources() { Set<FGEdge> dummyEdges = new HashSet<>(); Set<FGVertex> entries = getEntryPoints(); for (FGVertex entry : entries) { AbstractFunctionGraphVertex abstractVertex = (AbstractFunctionGraphVertex) entry; FGController controller = abstractVertex.getController(); ListingFunctionGraphVertex newEntry = new DummyListingFGVertex(controller, abstractVertex.getAddresses(), RefType.UNCONDITIONAL_JUMP, true); newEntry.setVertexType(FGVertexType.ENTRY); FGVertex groupVertex = getVertexForAddress(entry.getVertexAddress()); FGEdgeImpl edge = new FGEdgeImpl(newEntry, groupVertex, RefType.UNCONDITIONAL_JUMP, options); dummyEdges.add(edge); } return dummyEdges; }
Example 2
Source File: FunctionGraph.java From ghidra with Apache License 2.0 | 6 votes |
/** * A method to create dummy edges (with dummy vertices). This is used to add entry and * exit vertices as needed when a user grouping operation has consumed the entries or exits. * The returned edge will connect the current vertex containing the exit to a new dummy * vertex that is a sink for the graph. Calling this method does not mutate this graph. * * @return the edge */ public Set<FGEdge> createDummySinks() { Set<FGEdge> dummyEdges = new HashSet<>(); Set<FGVertex> exits = getExitPoints(); for (FGVertex exit : exits) { AbstractFunctionGraphVertex abstractVertex = (AbstractFunctionGraphVertex) exit; FGController controller = abstractVertex.getController(); ListingFunctionGraphVertex newExit = new ListingFunctionGraphVertex(controller, abstractVertex.getAddresses(), RefType.UNCONDITIONAL_JUMP, true); newExit.setVertexType(FGVertexType.EXIT); FGVertex groupVertex = getVertexForAddress(exit.getVertexAddress()); FGEdgeImpl edge = new FGEdgeImpl(groupVertex, newExit, RefType.UNCONDITIONAL_JUMP, options); dummyEdges.add(edge); } return dummyEdges; }
Example 3
Source File: ConstructorInfo.java From ghidra with Apache License 2.0 | 5 votes |
FlowType getFlowType() { switch (flowFlags) { // Convert flags to a standard flowtype case 0: case BRANCH_TO_END: return RefType.FALL_THROUGH; case CALL: return RefType.UNCONDITIONAL_CALL; case CALL | BRANCH_TO_END: return RefType.CONDITIONAL_CALL; // This could be wrong but doesn't matter much case CALL_INDIRECT: return RefType.COMPUTED_CALL; case CALL_INDIRECT | BRANCH_TO_END: // This could be COMPUTED_CONDITIONAL? return RefType.COMPUTED_CALL; case BRANCH_INDIRECT | NO_FALLTHRU: return RefType.COMPUTED_JUMP; case BRANCH_INDIRECT | NO_FALLTHRU | BRANCH_TO_END: // This should be COMPUTED_CONDITONAL_JUMP but this doesn't exist // so we make it a fall thru so the disassembler can continue the flow return RefType.FALL_THROUGH; case RETURN | NO_FALLTHRU: return RefType.TERMINATOR; case RETURN | NO_FALLTHRU | BRANCH_TO_END: return RefType.CONDITIONAL_TERMINATOR; case JUMPOUT: return RefType.CONDITIONAL_JUMP; case JUMPOUT | NO_FALLTHRU: return RefType.UNCONDITIONAL_JUMP; case JUMPOUT | NO_FALLTHRU | BRANCH_TO_END: return RefType.CONDITIONAL_JUMP; case NO_FALLTHRU: return RefType.TERMINATOR; case BRANCH_TO_END | JUMPOUT: return RefType.CONDITIONAL_JUMP; case NO_FALLTHRU | BRANCH_TO_END: return RefType.FALL_THROUGH; default: break; } return RefType.INVALID; }
Example 4
Source File: FunctionGraphGroupVertices2Test.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testFindForwardScopedFlowWhenGroupRemovesSourceNode() { // // Test the case that grouping the entry node will create a group that has incoming // edges. In this case, there is no source node in the graph. This will cause an // exception if the code does not create a fake source node before passing the graph // the the algorithm for calculating dominance. // create12345GraphWithTransaction(); FGVertex entry = vertex("100415a"); FGVertex v2 = vertex("1004178"); FGVertex v3 = vertex("1004192"); FunctionGraph graph = getFunctionGraph(); FGEdgeImpl edge = new FGEdgeImpl(v3, v2, RefType.UNCONDITIONAL_JUMP, graph.getOptions()); graph.addEdge(edge); FGComponent graphComponent = getGraphComponent(); VisualGraphPathHighlighter<FGVertex, FGEdge> pathHighlighter = graphComponent.getPathHighlighter(); pathHighlighter.setHoveredVertex(entry); waitForPathHighligter(); Collection<FGEdge> edges = graph.getEdges(); assertHovered(edges); pathHighlighter.setHoveredVertex(null); assertHovered(Collections.emptySet()); GroupedFunctionGraphVertex group = group("Entry in Group", entry, v2); pathHighlighter.setHoveredVertex(group); waitForPathHighligter(); assertHovered(edges); }
Example 5
Source File: FunctionGraphGroupVertices2Test.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testFindForwardScopedFlow_WithoutGroup_IncomingEdgeToRoot() { // // Test the case that an ungrouped graph does not throw an exception if the root node // is hovered when it has incoming edges. // create12345GraphWithTransaction(); FGVertex entry = vertex("100415a"); FGVertex v2 = vertex("1004178"); FunctionGraph graph = getFunctionGraph(); FGEdgeImpl edge = new FGEdgeImpl(v2, entry, RefType.UNCONDITIONAL_JUMP, graph.getOptions()); graph.addEdge(edge); FGComponent graphComponent = getGraphComponent(); VisualGraphPathHighlighter<FGVertex, FGEdge> pathHighlighter = graphComponent.getPathHighlighter(); pathHighlighter.setHoveredVertex(entry); waitForPathHighligter(); Collection<FGEdge> edges = graph.getEdges(); assertHovered(edges); pathHighlighter.setHoveredVertex(null); assertHovered(Collections.emptySet()); }
Example 6
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
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 7
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
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 8
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
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 9
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
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 10
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
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 11
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
FlowType[] followOnlyPointers() { FlowType[] flowsNotToFollow = new FlowType[] { RefType.COMPUTED_CALL, RefType.CONDITIONAL_CALL, RefType.UNCONDITIONAL_CALL, RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP, RefType.UNCONDITIONAL_JUMP }; return flowsNotToFollow; }
Example 12
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 5 votes |
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 13
Source File: SleighInstructionPrototype.java From ghidra with Apache License 2.0 | 4 votes |
private static FlowType convertFlowFlags(int flowFlags) { if ((flowFlags & LABEL) != 0) flowFlags |= BRANCH_TO_END; flowFlags &= ~(CROSSBUILD | LABEL); // NOTE: If prototype has cross-build, flow must be determined dynamically switch (flowFlags) { // Convert flags to a standard flowtype case 0: case BRANCH_TO_END: return RefType.FALL_THROUGH; case CALL: return RefType.UNCONDITIONAL_CALL; case CALL | NO_FALLTHRU | RETURN: return RefType.CALL_TERMINATOR; case CALL_INDIRECT | NO_FALLTHRU | RETURN: return RefType.COMPUTED_CALL_TERMINATOR; case CALL | BRANCH_TO_END: return RefType.CONDITIONAL_CALL; // This could be wrong but doesn't matter much case CALL | NO_FALLTHRU | JUMPOUT: return RefType.COMPUTED_JUMP; case CALL | NO_FALLTHRU | BRANCH_TO_END | RETURN: return RefType.UNCONDITIONAL_CALL; case CALL_INDIRECT: return RefType.COMPUTED_CALL; case BRANCH_INDIRECT | NO_FALLTHRU: return RefType.COMPUTED_JUMP; case BRANCH_INDIRECT | BRANCH_TO_END: case BRANCH_INDIRECT | NO_FALLTHRU | BRANCH_TO_END: case BRANCH_INDIRECT | JUMPOUT | NO_FALLTHRU | BRANCH_TO_END: return RefType.CONDITIONAL_COMPUTED_JUMP; case CALL_INDIRECT | BRANCH_TO_END: case CALL_INDIRECT | NO_FALLTHRU | BRANCH_TO_END: return RefType.CONDITIONAL_COMPUTED_CALL; case RETURN | NO_FALLTHRU: return RefType.TERMINATOR; case RETURN | BRANCH_TO_END: case RETURN | NO_FALLTHRU | BRANCH_TO_END: return RefType.CONDITIONAL_TERMINATOR; case JUMPOUT: return RefType.CONDITIONAL_JUMP; case JUMPOUT | NO_FALLTHRU: return RefType.UNCONDITIONAL_JUMP; case JUMPOUT | NO_FALLTHRU | BRANCH_TO_END: return RefType.CONDITIONAL_JUMP; case JUMPOUT | NO_FALLTHRU | RETURN: return RefType.JUMP_TERMINATOR; case JUMPOUT | NO_FALLTHRU | BRANCH_INDIRECT: return RefType.COMPUTED_JUMP; //added for tableswitch in jvm case BRANCH_INDIRECT | NO_FALLTHRU | RETURN: return RefType.JUMP_TERMINATOR; case NO_FALLTHRU: return RefType.TERMINATOR; case BRANCH_TO_END | JUMPOUT: return RefType.CONDITIONAL_JUMP; case NO_FALLTHRU | BRANCH_TO_END: return RefType.FALL_THROUGH; default: break; } return RefType.INVALID; }
Example 14
Source File: SleighInstructionPrototype.java From ghidra with Apache License 2.0 | 4 votes |
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 15
Source File: SleighInstructionPrototype.java From ghidra with Apache License 2.0 | 4 votes |
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 16
Source File: AbstractFollowFlowTest.java From ghidra with Apache License 2.0 | 4 votes |
FlowType[] followAllCalls() { FlowType[] flowsNotToFollow = new FlowType[] { RefType.COMPUTED_JUMP, RefType.CONDITIONAL_JUMP, RefType.UNCONDITIONAL_JUMP, RefType.INDIRECTION }; return flowsNotToFollow; }