Search in sources :

Example 56 with CModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.

the class CModuleContainerNodeTest method testLoaded.

@Test
public void testLoaded() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CRawModule rawModule = new CRawModule(1, "", 0, false, m_provider);
    final CModule module1 = new CModule(123, "Module 1", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, m_provider), rawModule, Integer.MAX_VALUE, false, m_provider);
    final CModule module2 = new CModule(123, "Module 2", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, m_provider), rawModule, Integer.MAX_VALUE, false, m_provider);
    m_database.getContent().addModule(module1);
    m_database.getContent().addModule(module2);
    final CModuleContainerNode node = new CModuleContainerNode(m_tree, m_database);
    assertEquals("Modules (2)", node.toString());
    assertEquals(2, node.getChildCount());
    assertEquals("Module 1 (55/66)", node.getChildAt(0).toString());
    assertEquals("Module 2 (55/66)", node.getChildAt(1).toString());
    node.dispose();
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")).isEmpty());
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database.getContent().getDebuggerTemplateManager(), "listeners"), "m_listeners")) == null);
}
Also used : DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CRawModule(com.google.security.zynamics.binnavi.disassembly.CRawModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 57 with CModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.

the class GraphSearcherTest method testSearchVisible.

@Test
public void testSearchVisible() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final MockSqlProvider sql = new MockSqlProvider();
    final CModule module = MockCreator.createModule(sql);
    module.load();
    final CFunction function = MockCreator.createFunction(module, sql);
    final CView m_view = MockCreator.createView(sql, module);
    final CInstruction instruction1 = MockCreator.createInstruction(module, sql);
    final CInstruction instruction2 = MockCreator.createInstruction(module, sql);
    final CInstruction instruction3 = MockCreator.createInstruction(module, sql);
    m_view.load();
    final CCodeNode node1 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    final CCodeNode node2 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    final CCodeNode node3 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    final ZyNodeRealizer<NaviNode> r1 = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final ZyNodeRealizer<NaviNode> r2 = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final ZyNodeRealizer<NaviNode> r3 = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final Graph2D g = new Graph2D();
    g.setHierarchyManager(new HierarchyManager(g));
    final NaviNode m_node1 = new NaviNode(g.createNode(), r1, node1);
    final NaviNode m_node2 = new NaviNode(g.createNode(), r2, node2);
    final NaviNode m_node3 = new NaviNode(g.createNode(), r3, node3);
    assertTrue(m_node1.isVisible());
    final GraphSearcher searcher = new GraphSearcher();
    searcher.getSettings().setOnlyVisible(true);
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1, m_node2, m_node3), new ArrayList<NaviEdge>(), "my");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    searcher.getCursor().next();
    assertEquals(m_node2, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    searcher.getCursor().next();
    assertEquals(m_node3, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    m_node2.getRawNode().setVisible(false);
    searcher.search(Lists.newArrayList(m_node1, m_node2, m_node3), new ArrayList<NaviEdge>(), "my");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    searcher.getCursor().next();
    assertEquals(m_node3, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) Graph2D(y.view.Graph2D) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) HierarchyManager(y.view.hierarchy.HierarchyManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Aggregations

CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)57 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)47 Date (java.util.Date)46 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)40 Test (org.junit.Test)36 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)23 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)23 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)22 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)19 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)16 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)14 Before (org.junit.Before)14 ArrayList (java.util.ArrayList)12 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)11 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)9 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)8 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)8 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)7 MockInstruction (com.google.security.zynamics.binnavi.disassembly.MockInstruction)7 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)6