Search in sources :

Example 21 with INaviOperandTreeNode

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference5.

@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference5() 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();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, 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) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 22 with INaviOperandTreeNode

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

the class TypeInstanceContainerBackend method loadTypeInstanceReferences.

/**
 * Loads all type instance references for the module this {@link TypeInstanceContainerBackend} was
 * initialized with.
 *
 * @return A {@link List} of {@link TypeInstanceReference references} loaded from the database.
 *
 * @throws CouldntLoadDataException if the data could not be loaded from the database.
 */
public List<TypeInstanceReference> loadTypeInstanceReferences() throws CouldntLoadDataException {
    final List<RawTypeInstanceReference> rawReferences = provider.loadTypeInstanceReferences(module);
    final List<TypeInstanceReference> references = Lists.newArrayList();
    for (final RawTypeInstanceReference rawReference : rawReferences) {
        final TypeInstance typeInstance = instancesById.get(rawReference.getTypeInstanceId());
        final INaviView view = ViewManager.get(provider).getView(rawReference.getViewId());
        if (view != null) {
            final Optional<INaviOperandTreeNode> node = Optional.absent();
            final IAddress address = rawReference.getAddress();
            final int position = rawReference.getOperandPosition();
            final int expressionId = rawReference.getExpressionId();
            final TypeInstanceReference reference = new TypeInstanceReference(address, position, node, typeInstance, view);
            references.add(reference);
            referenceLookup.put(new InstanceReferenceLookup(address, position, expressionId), reference);
        }
    }
    return references;
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 23 with INaviOperandTreeNode

use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode 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 24 with INaviOperandTreeNode

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

the class ZyGraphDragAndDropSupport method handleDragOver.

private void handleDragOver(final Point location) {
    final DragOverState state = getDragOverState(graph, location);
    final NaviNode node = state.getNode();
    if (node != null && state.getDragOverObject() != null) {
        final Object object = state.getDragOverObject().getObject();
        if (object instanceof INaviOperandTreeNode && ((INaviOperandTreeNode) object).getType() == ExpressionType.REGISTER) {
            final int row = node.positionToRow(graph.getView().toWorldCoordY(location.y) - node.getY());
            if (row != -1) {
                clearHighlighting(node);
                lastRow = row;
                final ObjectWrapper wrapper = state.getDragOverObject();
                node.setHighlighting(HIGHLIGHTING_LEVEL, row, wrapper.getStart(), wrapper.getLength(), HIGHLIGHTING_COLOR);
            }
        }
    } else {
        clearHighlighting(null);
    }
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) ObjectWrapper(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent.ObjectWrapper) Point(java.awt.Point)

Example 25 with INaviOperandTreeNode

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

the class PostgreSQLTypeInstancesNotificationParser method informExpressionTypeInstanceNotification.

/**
 * This function informs the {@link TypeInstanceContainer} about changes related to expression
 * type instances also known as cross references for type instances.
 *
 * @param container The {@link TypeInstancesNotificationContainer} holding the parsed information.
 * @param provider The {@link SQLProvider} used to access the database.
 * @throws CouldntLoadDataException
 */
private void informExpressionTypeInstanceNotification(final TypeInstancesNotificationContainer container, final SQLProvider provider) throws CouldntLoadDataException {
    final TypeInstanceContainer typeContainer = provider.findModule(container.getModuleId()).getContent().getTypeInstanceContainer();
    if (container.getDatabaseOperation().equals("INSERT")) {
        final TypeInstanceReference reference = typeContainer.loadInstanceReference(container.getTypeInstanceId(), container.getAddress().get(), container.getPosition().get(), container.getExpressionId().get());
        final INaviInstruction instruction = InstructionCache.get(provider).getInstructionByAddress(reference.getAddress(), reference.getTypeInstance().getModule().getConfiguration().getId());
        if (instruction != null) {
            final INaviOperandTree operandTree = instruction.getOperands().get(reference.getPosition());
            final INaviOperandTreeNode root = operandTree.getRootNode();
            final OperandOrderIterator iterator = new OperandOrderIterator(root);
            while (iterator.next()) {
                final INaviOperandTreeNode currentNode = (INaviOperandTreeNode) iterator.current();
                if (currentNode.getId() == container.getExpressionId().get()) {
                    typeContainer.initializeTypeInstanceReference(reference.getAddress(), reference.getPosition(), container.getTypeInstanceId(), currentNode);
                    break;
                }
            }
        }
    } else if (container.getDatabaseOperation().equals("UPDATE")) {
    // currently not be possible at all.
    } else if (container.getDatabaseOperation().equals("DELETE")) {
        typeContainer.deleteReference(container.getTypeInstanceId(), container.getAddress().get(), container.getPosition().get(), container.getExpressionId().get());
    } else {
        throw new IllegalStateException("Error: the database operation " + container.getDatabaseOperation() + " is currently not supported.");
    }
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) INaviOperandTree(com.google.security.zynamics.binnavi.disassembly.INaviOperandTree) OperandOrderIterator(com.google.security.zynamics.zylib.disassembly.OperandOrderIterator) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

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