Search in sources :

Example 21 with COperandTree

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

the class PostgreSQLProviderTest method testInstructionFunctionsDeleteReference4.

@Test
public void testInstructionFunctionsDeleteReference4() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, CouldntDeleteException, MaybeNullException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
    function.load();
    final IBlockNode basicBlock = function.getBasicBlocks().get(0);
    final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
    final COperandTree tree = instruction.getOperands().get(0);
    final INaviOperandTreeNode node = tree.getRootNode();
    final IAddress address = instruction.getAddress();
    final ReferenceType type = ReferenceType.DATA;
    final int references = node.getReferences().size();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
    final INaviModule module2 = getProvider().loadModules().get(1);
    module2.load();
    final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
    function2.load();
    final IBlockNode basicBlock2 = function2.getBasicBlocks().get(0);
    final INaviInstruction instruction2 = Iterables.get(basicBlock2.getInstructions(), 1);
    final COperandTree tree2 = instruction2.getOperands().get(0);
    final INaviOperandTreeNode node2 = tree2.getRootNode();
    assertEquals(references + 1, node2.getReferences().size());
    PostgreSQLInstructionFunctions.deleteReference(getProvider(), node2, address, type);
    final INaviModule module3 = getProvider().loadModules().get(1);
    module3.load();
    final INaviFunction function3 = module3.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
    function3.load();
    final IBlockNode basicBlock3 = function3.getBasicBlocks().get(0);
    final INaviInstruction instruction3 = Iterables.get(basicBlock3.getInstructions(), 1);
    final COperandTree tree3 = instruction3.getOperands().get(0);
    final INaviOperandTreeNode node3 = tree3.getRootNode();
    assertEquals(references, node3.getReferences().size());
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) ReferenceType(com.google.security.zynamics.zylib.disassembly.ReferenceType) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 22 with COperandTree

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference4.

@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
    function.load();
    final IBlockNode basicBlock = function.getBasicBlocks().get(0);
    final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
    final COperandTree tree = instruction.getOperands().get(0);
    final INaviOperandTreeNode node = tree.getRootNode();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, null, null);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 23 with COperandTree

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

the class ZyGraphTest method testAddedCodeNode.

@Test
public void testAddedCodeNode() {
    assertEquals(7, m_graph.visibleNodeCount());
    assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
    assertEquals(96, m_graph.getRawView().getNodeCount());
    final MockFunction function = new MockFunction(m_provider);
    final List<INaviInstruction> instructions = Lists.newArrayList((INaviInstruction) new MockInstruction(new CAddress(0x123456), "mov", new ArrayList<COperandTree>(), null, m_module));
    final CCodeNode codeNode = m_graph.getRawView().getContent().createCodeNode(function, instructions);
    assertEquals(8, m_graph.visibleNodeCount());
    assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
    assertEquals(97, m_graph.getRawView().getNodeCount());
    final List<NaviNode> nodes = GraphHelpers.getNodes(m_graph);
    final NaviNode cnn = searchNode(nodes, codeNode);
    assertEquals(codeNode, cnn.getRawNode());
    assertTrue(codeNode.isVisible());
    assertEquals(codeNode.isVisible(), cnn.isVisible());
    codeNode.setVisible(false);
    assertFalse(codeNode.isVisible());
    assertEquals(codeNode.isVisible(), cnn.isVisible());
    codeNode.setVisible(true);
    assertTrue(codeNode.isVisible());
    assertEquals(codeNode.isVisible(), cnn.isVisible());
    assertFalse(codeNode.isSelected());
    assertEquals(codeNode.isSelected(), cnn.isSelected());
    codeNode.setSelected(false);
    assertFalse(codeNode.isSelected());
    assertEquals(codeNode.isSelected(), cnn.isSelected());
    codeNode.setSelected(true);
    assertTrue(codeNode.isSelected());
    assertEquals(codeNode.isSelected(), cnn.isSelected());
    assertEquals(codeNode.getColor(), cnn.getRealizer().getFillColor());
    codeNode.setColor(Color.GREEN);
    assertEquals(Color.GREEN, codeNode.getColor());
    assertEquals(codeNode.getColor(), cnn.getRealizer().getFillColor());
    codeNode.setX(100);
    assertEquals(100, codeNode.getX(), 0.1);
    assertEquals(codeNode.getX(), cnn.getX(), 0.1);
    codeNode.setY(200);
    assertEquals(200, codeNode.getY(), 0.1);
    assertEquals(codeNode.getY(), cnn.getY(), 0.1);
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockInstruction(com.google.security.zynamics.binnavi.disassembly.MockInstruction) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Aggregations

COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)23 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)15 Test (org.junit.Test)14 COperandTreeNode (com.google.security.zynamics.binnavi.disassembly.COperandTreeNode)11 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)10 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)9 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)9 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)8 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)8 IReference (com.google.security.zynamics.zylib.disassembly.IReference)8 ArrayList (java.util.ArrayList)8 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)7 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)7 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)6 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)6 Date (java.util.Date)6 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)5 IBlockNode (com.google.security.zynamics.binnavi.disassembly.IBlockNode)5 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)5