Search in sources :

Example 6 with TypeInstanceReference

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

the class TypeInstanceTableDatamodel method getTypeInstanceReference.

public TypeInstanceReference getTypeInstanceReference(int row, int line) {
    TypeInstance typeInstance = typesToDisplay.get(row);
    List<TypeInstanceReference> references = typeContainer.getReferences(typeInstance);
    if (line < references.size()) {
        return references.get(line);
    }
    return null;
}
Also used : TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance)

Example 7 with TypeInstanceReference

use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference 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)

Example 8 with TypeInstanceReference

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

the class PostgreSQLTypeInstanceFunctionsTests method loadSingleTypeInstanceReference6.

@Test
public void loadSingleTypeInstanceReference6() throws CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
    module.load();
    for (final INaviView view : module.getContent().getViewContainer().getViews().subList(10, 20)) {
        view.load();
        final TypeInstanceContainer container = module.getContent().getTypeInstanceContainer();
        for (final TypeInstance typeInstance : container.getTypeInstances()) {
            for (final TypeInstanceReference reference : container.getReferences(typeInstance)) {
                if (reference.getTreeNode().isPresent()) {
                    final RawTypeInstanceReference rawReference = provider.loadTypeInstanceReference(module, typeInstance.getId(), reference.getAddress().toBigInteger(), reference.getPosition(), reference.getTreeNode().get().getId());
                    Assert.assertEquals(reference.getAddress(), rawReference.getAddress());
                }
            }
        }
        view.close();
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) RawTypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstanceReference) RawTypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstanceReference) RawTypeInstance(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) Test(org.junit.Test)

Example 9 with TypeInstanceReference

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

the class PostgreSQLTypeInstanceFunctionsTests method deleteTypeInstanceReferenceTest5.

@Test
public void deleteTypeInstanceReferenceTest5() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, CouldntSaveDataException {
    module.load();
    final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
    final TypeInstanceAddress address1 = typeInstance.getAddress();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress("1001929", 16));
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final INaviInstruction instruction = view.getBasicBlocks().get(2).getInstructions().iterator().next();
    Assert.assertNotNull(typeInstance);
    provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(1)), instruction.getOperands().get(0).getNodes().get(0).getId(), typeInstance.getId());
    view.close();
    module.close();
    module.load();
    view.load();
    final TypeInstance typeInstance2 = module.getContent().getTypeInstanceContainer().getTypeInstance(typeInstance.getAddress());
    Assert.assertEquals(address1, typeInstance2.getAddress());
    final List<TypeInstanceReference> references = module.getContent().getTypeInstanceContainer().getReferences(typeInstance2);
    Assert.assertTrue(!references.isEmpty());
    final TypeInstanceReference reference = Iterables.find(references, new Predicate<TypeInstanceReference>() {

        @Override
        public boolean apply(final TypeInstanceReference reference) {
            return reference.getAddress().equals(instruction.getAddress());
        }
    });
    Assert.assertNotNull(reference);
    provider.deleteTypeInstanceReference(module.getConfiguration().getId(), reference.getAddress().toBigInteger(), reference.getPosition(), reference.getTreeNode().get().getId());
}
Also used : TypeInstanceAddress(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) RawTypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstanceReference) RawTypeInstance(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Aggregations

TypeInstanceReference (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference)9 TypeInstance (com.google.security.zynamics.binnavi.disassembly.types.TypeInstance)5 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)3 RawTypeInstance (com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance)3 RawTypeInstanceReference (com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstanceReference)3 TypeInstanceContainer (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 Test (org.junit.Test)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 TypeInstanceAddress (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress)2 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 INaviOperandTree (com.google.security.zynamics.binnavi.disassembly.INaviOperandTree)1 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)1 BaseType (com.google.security.zynamics.binnavi.disassembly.types.BaseType)1 OperandOrderIterator (com.google.security.zynamics.zylib.disassembly.OperandOrderIterator)1 FormattedCharacterBuffer (com.google.security.zynamics.zylib.gui.CodeDisplay.FormattedCharacterBuffer)1 Color (java.awt.Color)1