use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class CodeNodeTest method setUp.
@Before
public void setUp() {
final Database database = new Database(new MockDatabase());
final MockModule mockModule = new MockModule();
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final MockView mockView = new MockView();
final View view = new View(module, mockView, nodeTagManager, viewTagManager);
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
final CFunction internalFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final CComment m_globalComment = new CComment(null, CommonTestObjects.TEST_USER_1, null, "Global Comment");
final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, Lists.<IComment>newArrayList(m_globalComment), internalFunction, new HashSet<CTag>(), new MockSqlProvider());
codeNode.addInstruction(new CInstruction(true, internalModule, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider), null);
m_node = new CodeNode(view, codeNode, nodeTagManager);
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class FunctionBlockTest method testLink.
@Test
public void testLink() {
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final Function function = new Function(ModuleFactory.get(), parentFunction);
final FunctionBlock block = new FunctionBlock(function);
final FunctionBlock childBlock = new FunctionBlock(function);
FunctionBlock.link(block, childBlock);
assertEquals(0, block.getParents().size());
assertEquals(1, block.getChildren().size());
assertEquals(childBlock, block.getChildren().get(0));
assertEquals(0, childBlock.getChildren().size());
assertEquals(1, childBlock.getParents().size());
assertEquals(block, childBlock.getParents().get(0));
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class CGraphDebuggerTest method testGetDebugger.
@Test
public void testGetDebugger() {
final MockModule module = new MockModule();
module.getConfiguration().setDebugger(m_debugger);
final DebugTargetSettings target = new ModuleTargetSettings(module);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
debuggerProvider.addDebugger(m_debugger);
final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
final CFunctionNode functionNode = new CFunctionNode(0, function, 0, 0, 0, 0, Color.RED, false, false, null, new HashSet<CTag>(), m_provider);
assertEquals(m_debugger, CGraphDebugger.getDebugger(debuggerProvider, functionNode));
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class CGraphDebuggerTest method testGetDebugger2.
@Test
public void testGetDebugger2() {
final MockModule module = new MockModule();
module.getConfiguration().setDebugger(m_debugger);
final DebugTargetSettings target = new ModuleTargetSettings(module);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
debuggerProvider.addDebugger(m_debugger);
final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Mock Comment"));
final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, comments, function, new HashSet<CTag>(), new MockSqlProvider());
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
assertEquals(m_debugger, CGraphDebugger.getDebugger(debuggerProvider, Iterables.getFirst(codeNode.getInstructions(), null)));
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction 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());
}
Aggregations