Search in sources :

Example 1 with TypeInstanceReference

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

the class CCodeNodeMenu method addInstanceReferenceMenu.

private void addInstanceReferenceMenu(final CGraphModel model, final COperandTreeNode treeNode) {
    // We can possibly have more than one reference for a single tree node if we have multiple
    // instances of the same section.
    final INaviModule module = model.getViewContainer().getModules().get(0);
    final List<TypeInstanceReference> references = treeNode.getTypeInstanceReferences();
    add(new ShowTypeInstanceReferencesAction(model.getParent(), references, module));
    add(new GotoTypeInstanceAction(references.get(0).getTypeInstance()));
    add(new RenameTypeInstanceAction(model.getParent(), module.getContent().getTypeInstanceContainer(), references.get(0).getTypeInstance()));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference)

Example 2 with TypeInstanceReference

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

the class PostgreSQLTypeInstanceFunctionsTests method createTypeInstanceReference5.

@Test
public void createTypeInstanceReference5() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
    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(1).getInstructions().iterator().next();
    Assert.assertNotNull(typeInstance);
    provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(0)), 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());
    Assert.assertEquals(instruction.getAddress(), references.get(0).getAddress());
    Assert.assertEquals(instruction.getOperandPosition(instruction.getOperands().get(0)), references.get(0).getPosition());
    Assert.assertEquals(instruction.getOperands().get(0).getNodes().get(0).getId(), references.get(0).getTreeNode().get().getId());
    Assert.assertEquals(typeInstance.getId(), references.get(0).getTypeInstance().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)

Example 3 with TypeInstanceReference

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

the class ViewReferencesTableModel method addTypeInstancesToTree.

/**
 * Adds the list of {@link TypeInstanceReference type instance references} for the given
 * {@link INaviInstruction instruction} to the tree.
 *
 * @param typeInstanceReferences A List of {@link TypeInstanceReference type instance references}.
 * @param instruction The {@link INaviInstruction instruction} to which the list of references
 *        belongs.
 */
private void addTypeInstancesToTree(final List<TypeInstanceReference> typeInstanceReferences, final INaviInstruction instruction) {
    for (TypeInstanceReference typeInstanceReference : typeInstanceReferences) {
        final BaseType baseType = typeInstanceReference.getTypeInstance().getBaseType();
        addBaseType(baseType);
        insertNodeInto(multiIndex.putTypeReference(typeInstanceReference, instruction), baseTypeToTreeNode.get(baseType), baseTypeToTreeNode.get(baseType).getChildCount());
    }
}
Also used : TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType)

Example 4 with TypeInstanceReference

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

the class TypeInstanceTableDatamodel method getLineFormatted.

@Override
public FormattedCharacterBuffer getLineFormatted(int rowIndex, int columnIndex, int lineIndex) {
    Color backgroundColor = getBackgroundColor(rowIndex, columnIndex);
    switch(columnIndex) {
        case ADDRESS_INDEX:
            TypeInstance type = typesToDisplay.get(rowIndex);
            String addressString = "";
            if (lineIndex == 0) {
                addressString = TypeInstanceAddressTableCellRenderer.getStringToDisplay(false, type.getAddress());
            }
            return stringToFormattedCharacterBuffer(addressString, rowIndex, columnIndex);
        case NAME_INDEX:
            String typeName = "";
            if (lineIndex == 0) {
                typeName = typesToDisplay.get(rowIndex).getName();
            }
            return new FormattedCharacterBuffer(Strings.padEnd(typeName, columns[columnIndex].getWidth(), ' '), STANDARD_FONT, columns[columnIndex].getDefaultFontColor(), backgroundColor);
        case TYPE_INDEX:
            FormattedCharacterBuffer typeDeclaration = typeDeclarations.get(rowIndex);
            if (typeDeclaration.getNumberOfLines() > lineIndex) {
                return typeDeclarations.get(rowIndex).getLine(lineIndex).setBackgroundColor(backgroundColor);
            }
            return stringToFormattedCharacterBuffer("", rowIndex, columnIndex);
        case XREFS_INDEX:
            TypeInstanceReference reference = getTypeInstanceReference(rowIndex, lineIndex);
            String xrefString = "";
            if (reference != null) {
                xrefString = TypeInstanceCrossReferenceRenderer.renderText(reference);
            }
            return stringToFormattedCharacterBuffer(xrefString, rowIndex, columnIndex);
        case COMMENTS_INDEX:
            FormattedCharacterBuffer comment = generateFormattedComment(typeContainer.getComments(typesToDisplay.get(rowIndex)));
            if (lineIndex < comment.getNumberOfLines()) {
                // wasteful, clean it up eventually.
                return comment.getLine(lineIndex).setBackgroundColor(backgroundColor);
            }
            // Return empty buffers for empty lines.
            return stringToFormattedCharacterBuffer("", rowIndex, columnIndex);
        default:
            Logger.warning("Invalid column index, investigate.");
            break;
    }
    return null;
}
Also used : TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) Color(java.awt.Color) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) FormattedCharacterBuffer(com.google.security.zynamics.zylib.gui.CodeDisplay.FormattedCharacterBuffer)

Example 5 with TypeInstanceReference

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

the class COperandTreeNode method close.

@Override
public void close() {
    if (replacement != null) {
        replacement.close();
        replacement.removeListener(listener);
    }
    if (substitution != null) {
        operandTree.getInstruction().getModule().getTypeManager().removeTypeSubstitutionInstance(substitution);
    }
    if (instanceReferences != null && !instanceReferences.isEmpty()) {
        final TypeInstanceContainer container = operandTree.getInstruction().getModule().getContent().getTypeInstanceContainer();
        for (final TypeInstanceReference reference : instanceReferences) {
            container.deactivateTypeInstanceReference(reference);
        }
    }
}
Also used : TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)

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