forked from NationalSecurityAgency/ghidra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved generic graph interfaces to features graph module created graph service broker first commit of program graph module adapted to new graph api GT-3317 connected listeners, documented and prettied up code changed GhidraGraph to preserve order of created graph. Removed edge filtering from initial program graph display GT-3317 added exporters for supported formats GT-3317 fixed GhidraGraph bug where it lost edges updates changed to new action builder removed icons, improved AttributeFilters removed DialogComponentProviderBuilder fixed generic alphabet soup added vertex name updating. GT-3317 added threading to sugiyama adapted to take advantage of multi-threaded edge crossing reduction in circle layout eliminated parallel edges, improved sizing, updated jungrapht version GT-3317 fixing AST graph and moving modules and packages started help GT-3317 updated min-cross and color selections uses min-cross that optimizes for graph size GT-3317 help, javadocs changes from review comments and cleaning up warnings and simplifying exporter code fixing warnings, simplifying unnecessarily complicated code more changes from review more changes from review, simplifications. removed unnecessary threading, renamed vertex, edge, etc GT-3317 squashed many commits to make rebase easier. Mostly changes from first code review.
- Loading branch information
1 parent
0001ee2
commit 410af5a
Showing
112 changed files
with
8,717 additions
and
1,075 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ InstructionSkipper | |
DataTypeReferenceFinder | ||
ChecksumAlgorithm | ||
OverviewColorService | ||
|
131 changes: 131 additions & 0 deletions
131
Ghidra/Features/Base/developer_scripts/GenerateBrandesKopfGraphScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* ### | ||
* IP: GHIDRA | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import ghidra.app.script.GhidraScript; | ||
import ghidra.app.services.GraphDisplayBroker; | ||
import ghidra.framework.plugintool.PluginTool; | ||
import ghidra.service.graph.*; | ||
|
||
/** | ||
* Script to generate graph to test BrandesKopf algorithm | ||
*/ | ||
public class GenerateBrandesKopfGraphScript extends GhidraScript { | ||
private AttributedGraph graph = new AttributedGraph(); | ||
private int nextEdgeID = 1; | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
PluginTool tool = getState().getTool(); | ||
GraphDisplayBroker service = tool.getService(GraphDisplayBroker.class); | ||
GraphDisplay display = service.getDefaultGraphDisplay(false, monitor); | ||
generateGraph(); | ||
display.setGraph(graph, "Test2", false, monitor); | ||
} | ||
|
||
|
||
private void generateGraph() { | ||
|
||
AttributedVertex[] list = new AttributedVertex[24]; | ||
int i=1; | ||
list[i++] = vertex("1"); | ||
list[i++] = vertex("2"); | ||
list[i++] = vertex("3"); | ||
list[i++] = vertex("4"); | ||
list[i++] = vertex("5"); | ||
list[i++] = vertex("6"); | ||
list[i++] = vertex("7"); | ||
list[i++] = vertex("8"); | ||
list[i++] = vertex("9"); | ||
list[i++] = vertex("10"); | ||
list[i++] = vertex("11"); | ||
list[i++] = vertex("12"); | ||
list[i++] = vertex("13"); | ||
list[i++] = vertex("14"); | ||
list[i++] = vertex("15"); | ||
list[i++] = vertex("16"); | ||
list[i++] = vertex("17"); | ||
list[i++] = vertex("18"); | ||
list[i++] = vertex("19"); | ||
list[i++] = vertex("20"); | ||
list[i++] = vertex("21"); | ||
list[i++] = vertex("22"); | ||
list[i++] = vertex("23"); | ||
|
||
edge(list[1], list[3]); | ||
edge(list[1], list[4]); | ||
edge(list[1], list[13]); | ||
edge(list[1], list[21]); | ||
|
||
edge(list[2], list[3]); | ||
edge(list[2], list[20]); | ||
|
||
edge(list[3], list[4]); | ||
edge(list[3], list[5]); | ||
edge(list[3], list[23]); | ||
|
||
edge(list[4], list[6]); | ||
|
||
edge(list[5], list[7]); | ||
|
||
edge(list[6], list[8]); | ||
edge(list[6], list[16]); | ||
edge(list[6], list[23]); | ||
|
||
edge(list[7], list[9]); | ||
|
||
edge(list[8], list[10]); | ||
edge(list[8], list[11]); | ||
|
||
edge(list[9], list[12]); | ||
|
||
edge(list[10], list[13]); | ||
edge(list[10], list[14]); | ||
edge(list[10], list[15]); | ||
|
||
edge(list[11], list[15]); | ||
edge(list[11], list[16]); | ||
|
||
edge(list[12], list[20]); | ||
|
||
edge(list[13], list[17]); | ||
|
||
edge(list[14], list[17]); | ||
edge(list[14], list[18]); | ||
// no 15 targets | ||
|
||
edge(list[16], list[18]); | ||
edge(list[16], list[19]); | ||
edge(list[16], list[20]); | ||
|
||
edge(list[18], list[21]); | ||
|
||
edge(list[19], list[22]); | ||
|
||
edge(list[21], list[23]); | ||
|
||
edge(list[22], list[23]); | ||
|
||
} | ||
|
||
private AttributedVertex vertex(String name) { | ||
return graph.addVertex(name, name); | ||
} | ||
|
||
|
||
private AttributedEdge edge(AttributedVertex v1, AttributedVertex v2) { | ||
return graph.addEdge(v1, v2); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
Ghidra/Features/Base/developer_scripts/GenerateTestGraphScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* ### | ||
* IP: GHIDRA | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import ghidra.app.script.GhidraScript; | ||
import ghidra.app.services.GraphDisplayBroker; | ||
import ghidra.framework.plugintool.PluginTool; | ||
import ghidra.service.graph.*; | ||
|
||
/** | ||
* Sample script to test graph service | ||
*/ | ||
public class GenerateTestGraphScript extends GhidraScript { | ||
private AttributedGraph graph = new AttributedGraph(); | ||
private int nextEdgeID = 1; | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
PluginTool tool = getState().getTool(); | ||
GraphDisplayBroker service = tool.getService(GraphDisplayBroker.class); | ||
GraphDisplay display = service.getDefaultGraphDisplay(false, monitor); | ||
generateGraph(); | ||
display.setGraph(graph, "Test", false, monitor); | ||
} | ||
|
||
private void generateGraph() { | ||
|
||
AttributedVertex A = vertex("A"); | ||
AttributedVertex B = vertex("B"); | ||
AttributedVertex C = vertex("C"); | ||
AttributedVertex D = vertex("D"); | ||
|
||
edge(A, B); | ||
edge(A, C); | ||
edge(B, D); | ||
edge(C, D); | ||
edge(D, A); | ||
} | ||
|
||
private AttributedVertex vertex(String name) { | ||
return graph.addVertex(name, name); | ||
} | ||
|
||
private AttributedEdge edge(AttributedVertex v1, AttributedVertex v2) { | ||
return graph.addEdge(v1, v2); | ||
} | ||
|
||
|
||
} |
59 changes: 59 additions & 0 deletions
59
Ghidra/Features/Base/ghidra_scripts/ExampleGraphServiceScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* ### | ||
* IP: GHIDRA | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import ghidra.app.script.GhidraScript; | ||
import ghidra.app.services.GraphDisplayBroker; | ||
import ghidra.framework.plugintool.PluginTool; | ||
import ghidra.service.graph.*; | ||
|
||
/** | ||
* Example script for creating and displaying a graph in ghidra | ||
*/ | ||
public class ExampleGraphServiceScript extends GhidraScript { | ||
private AttributedGraph graph = new AttributedGraph(); | ||
private int nextEdgeID = 1; | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
PluginTool tool = getState().getTool(); | ||
GraphDisplayBroker service = tool.getService(GraphDisplayBroker.class); | ||
GraphDisplay display = service.getDefaultGraphDisplay(false, monitor); | ||
generateGraph(); | ||
display.setGraph(graph, "Test", false, monitor); | ||
} | ||
|
||
private void generateGraph() { | ||
|
||
AttributedVertex A = vertex("A"); | ||
AttributedVertex B = vertex("B"); | ||
AttributedVertex C = vertex("C"); | ||
AttributedVertex D = vertex("D"); | ||
|
||
edge(A, B); | ||
edge(A, C); | ||
edge(B, D); | ||
edge(C, D); | ||
edge(D, A); | ||
} | ||
|
||
private AttributedVertex vertex(String name) { | ||
return graph.addVertex(name, name); | ||
} | ||
|
||
private AttributedEdge edge(AttributedVertex v1, AttributedVertex v2) { | ||
return graph.addEdge(v1, v2); | ||
} | ||
|
||
} |
Oops, something went wrong.