use of com.google.security.zynamics.binnavi.disassembly.CTextNode in project binnavi by google.
the class View2DTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, FileReadException {
ConfigManager.instance().read();
final MockDatabase database = new MockDatabase();
final CModule module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, new MockSqlProvider());
database.getContent().addModule(module);
manager.addDatabase(database);
module.load();
m_view = module.getContent().getViewContainer().createView("name", "description");
final ZyGraphViewSettings settings = new ZyGraphViewSettings(new CallGraphSettingsConfigItem());
settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
final ZyGraph2DView g2dView = new ZyGraph2DView();
final LinkedHashMap<Node, NaviNode> nodeMap = new LinkedHashMap<Node, NaviNode>();
final LinkedHashMap<Edge, NaviEdge> edgeMap = new LinkedHashMap<Edge, NaviEdge>();
final Node node1 = g2dView.getGraph2D().createNode();
final CTextNode rawNode1 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT NODE ")));
nodeMap.put(node1, new NaviNode(node1, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode1));
final Node node2 = g2dView.getGraph2D().createNode();
final CTextNode rawNode2 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT COMMENT ")));
nodeMap.put(node2, new NaviNode(node2, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode2));
final Edge edge = g2dView.getGraph2D().createEdge(node1, node2);
final INaviEdge rawEdge = m_view.getContent().createEdge(rawNode1, rawNode2, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_CONDITIONAL_FALSE);
edgeMap.put(edge, new NaviEdge(nodeMap.get(node1), nodeMap.get(node2), edge, new ZyEdgeRealizer<NaviEdge>(new ZyLabelContent(null), null), rawEdge));
final ZyGraph graph = new ZyGraph(m_view, nodeMap, edgeMap, settings, g2dView);
m_view2d = new View2D(database, new CModuleContainer(database, module), graph, pluginInterface);
}
use of com.google.security.zynamics.binnavi.disassembly.CTextNode in project binnavi by google.
the class CUnInlinerTest method testUninlineSingleBlock.
@Test
public void testUninlineSingleBlock() {
final List<INaviViewNode> nodes = new FilledList<INaviViewNode>();
final List<INaviEdge> edges = new FilledList<INaviEdge>();
final INaviFunction mockFunction = new MockFunction(m_provider);
final INaviFunction mockFunction2 = new MockFunction(m_provider);
final MockInstruction mi1 = new MockInstruction(0x123);
final MockInstruction mi2 = new MockInstruction(0x124);
final MockInstruction mi3 = new MockInstruction(0x125);
final CCodeNode upperNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
final CCodeNode inlinedNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction2, new HashSet<CTag>(), m_provider);
final CCodeNode lowerNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
final CTextNode textNode = new CTextNode(0, 0, 0, 0, 0, Color.RED, false, true, new HashSet<CTag>(), null, m_provider);
upperNode.addInstruction(mi1, null);
inlinedNode.addInstruction(mi2, null);
lowerNode.addInstruction(mi3, null);
nodes.add(upperNode);
nodes.add(inlinedNode);
nodes.add(textNode);
nodes.add(lowerNode);
final CNaviViewEdge enteringEdge = new CNaviViewEdge(0, upperNode, inlinedNode, EdgeType.ENTER_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge leavingEdge = new CNaviViewEdge(0, inlinedNode, lowerNode, EdgeType.LEAVE_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge textEdge = new CNaviViewEdge(0, textNode, inlinedNode, EdgeType.TEXTNODE_EDGE, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
edges.add(enteringEdge);
edges.add(leavingEdge);
edges.add(textEdge);
connect(upperNode, inlinedNode, enteringEdge);
connect(inlinedNode, lowerNode, leavingEdge);
connect(textNode, inlinedNode, textEdge);
final MockView view = new MockView(nodes, edges, m_provider);
CUnInliner.unInline(view, inlinedNode);
assertEquals(1, view.getNodeCount());
assertEquals(0, view.getEdgeCount());
final INaviCodeNode cnode = (INaviCodeNode) view.getGraph().getNodes().get(0);
assertEquals(2, Iterables.size(cnode.getInstructions()));
assertEquals(mi1.toString(), Iterables.get(cnode.getInstructions(), 0).toString());
assertEquals(mi3.toString(), Iterables.get(cnode.getInstructions(), 1).toString());
}
use of com.google.security.zynamics.binnavi.disassembly.CTextNode in project binnavi by google.
the class CViewInserterTest method test.
@Test
public void test() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, FileReadException, CouldntSaveDataException {
ConfigManager.instance().read();
final INaviModule mockModule = new MockModule();
final MockSqlProvider mockProvider = new MockSqlProvider();
final CUserManager userManager = CUserManager.get(mockProvider);
final IUser user = userManager.addUser(" VIEW INSERTER USER ");
userManager.setCurrentActiveUser(user);
final CModuleViewGenerator generator = new CModuleViewGenerator(mockProvider, mockModule);
final CView view = generator.generate(1, "", "", ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
view.load();
final MockFunction mockFunction = new MockFunction(mockProvider);
final CFunctionNode fnode1 = view.getContent().createFunctionNode(mockFunction);
final CFunctionNode fnode2 = view.getContent().createFunctionNode(mockFunction);
@SuppressWarnings("unused") final CNaviViewEdge edge1 = view.getContent().createEdge(fnode1, fnode2, EdgeType.JUMP_UNCONDITIONAL);
final MockInstruction instruction1 = new MockInstruction();
final CCodeNode cnode1 = view.getContent().createCodeNode(mockFunction, Lists.newArrayList(instruction1));
final CCodeNode cnode2 = view.getContent().createCodeNode(mockFunction, Lists.newArrayList(instruction1));
@SuppressWarnings("unused") final CNaviViewEdge edge2 = view.getContent().createEdge(cnode1, cnode2, EdgeType.JUMP_UNCONDITIONAL);
final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Foo"));
final CTextNode tnode1 = view.getContent().createTextNode(comments);
@SuppressWarnings("unused") final CNaviViewEdge edge3 = view.getContent().createEdge(cnode1, tnode1, EdgeType.JUMP_UNCONDITIONAL);
final CGroupNode gnode1 = view.getContent().createGroupNode(Lists.newArrayList((INaviViewNode) fnode1, (INaviViewNode) fnode2));
gnode1.appendComment("TEST GROUP NODE COMMENT 1");
final CView view2 = generator.generate(2, "", "", ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
view2.load();
CViewInserter.insertView(view, view2);
final List<INaviViewNode> nodes = view2.getGraph().getNodes();
assertEquals(view2.getNodeCount(), 6);
assertEquals(mockFunction, ((INaviFunctionNode) nodes.get(0)).getFunction());
assertEquals(nodes.get(5), ((INaviFunctionNode) nodes.get(0)).getParentGroup());
}
use of com.google.security.zynamics.binnavi.disassembly.CTextNode in project binnavi by google.
the class CNaviNodeFactory method get.
public static NaviNode get() {
final Graph2D graph = new Graph2D();
final CTextNode node = CTextNodeFactory.get();
final ZyLabelContent content = ZyTextNodeBuilder.buildContent(node);
final IZyNodeRealizer realizer = new ZyNormalNodeRealizer<NaviNode>(content);
return new NaviNode(graph.createNode(), realizer, node);
}
use of com.google.security.zynamics.binnavi.disassembly.CTextNode in project binnavi by google.
the class CViewContent method createTextNode.
@Override
public CTextNode createTextNode(final List<IComment> comments) {
final CTextNode textNode = new CTextNode(-1, 0, 0, 0, 0, TEXTNODE_COLOR, false, true, new HashSet<CTag>(), comments, provider);
addNode(textNode);
// Do not bother to update the graph type because text nodes have no effect on graph types.
textNode.addListener(m_internalNodeListener);
return textNode;
}
Aggregations