Search in sources :

Example 11 with INaviOperandTreeNode

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

the class PostgreSQLInstructionFunctions method createOperandExpression.

/**
 * Creates an operand expression tree in the database.
 *
 * @param provider The connection to the database.
 * @param rootNode The root node of the operand tree to crate.
 * @param parent ID of the parent node of the root node.
 * @param nodes Output operand for all created nodes.
 *
 * @throws SQLException Thrown if the creation of the operand expression tree
 *         failed.
 */
private static void createOperandExpression(final SQLProvider provider, final INaviOperandTreeNode rootNode, final int parent, final Set<INaviOperandTreeNode> nodes) throws SQLException {
    createOperandExpression(provider, rootNode, parent);
    nodes.add(rootNode);
    for (final INaviOperandTreeNode child : rootNode.getChildren()) {
        createOperandExpression(provider, child, rootNode.getId(), nodes);
    }
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)

Example 12 with INaviOperandTreeNode

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

the class PostgreSQLInstructionFunctions method createOperandTree.

/**
 * Creates an operand expression tree in the database.
 *
 * @param provider The provider used to access the database.
 * @param operand The operand to create.
 * @param position The position of the operand in the instruction.
 *
 * @throws SQLException Thrown if the creation of the operand failed.
 */
private static void createOperandTree(final SQLProvider provider, final COperandTree operand, final int position) throws SQLException {
    final Set<INaviOperandTreeNode> nodes = new HashSet<INaviOperandTreeNode>();
    createOperandExpression(provider, operand.getRootNode(), 0, nodes);
    final int expressionTreeId = createExpressionTree(provider, nodes, operand.getInstruction().getModule());
    final BigInteger address = operand.getInstruction().getAddress().toBigInteger();
    final int moduleId = operand.getInstruction().getModule().getConfiguration().getId();
    createOperand(provider, moduleId, address, position, expressionTreeId);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet)

Example 13 with INaviOperandTreeNode

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference1.

@Test
public void testInstructionFunctionsAddReference1() 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();
    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().getFunctions().get(1800);
    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());
}
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 14 with INaviOperandTreeNode

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference6.

@Test(expected = CouldntSaveDataException.class)
public void testInstructionFunctionsAddReference6() 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();
    final IAddress address = instruction.getAddress();
    final ReferenceType type = ReferenceType.DATA;
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
}
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 15 with INaviOperandTreeNode

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

the class TypeManagerTest method testNotifySubstitutionDeleted.

@Test
public void testNotifySubstitutionDeleted() throws CouldntDeleteException, CouldntSaveDataException {
    final CAddress address = new CAddress(0x1000);
    final INaviOperandTreeNode node = new MockOperandTreeNode();
    final TypeSubstitution substitution = typeManager.createTypeSubstitution(node, typeSystem.intType, 0, 0, address);
    final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
    typeManager.addListener(events);
    typeManager.deleteTypeSubstitution(node);
    final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
    expectedEvents.substitutionsDeleted(Sets.newHashSet(substitution));
    Assert.assertEquals(expectedEvents, events);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)25 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 Test (org.junit.Test)8 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)7 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)7 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)6 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)6 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)6 IBlockNode (com.google.security.zynamics.binnavi.disassembly.IBlockNode)5 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)5 BigInteger (java.math.BigInteger)4 MockOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode)3 ReferenceType (com.google.security.zynamics.zylib.disassembly.ReferenceType)3 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)2 INaviOperandTree (com.google.security.zynamics.binnavi.disassembly.INaviOperandTree)2 TypeInstanceContainer (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)2 OperandOrderIterator (com.google.security.zynamics.zylib.disassembly.OperandOrderIterator)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 CGotoOperandExpressionAction (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CGotoOperandExpressionAction)1