Search in sources :

Example 1 with TypeSubstitution

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

the class TypeSubstitutionDialog method createOrUpdateSubstitution.

private void createOrUpdateSubstitution(final TypeSelectionPath path) throws CouldntSaveDataException {
    final int offset = path.determineTotalMemberOffset();
    final BaseType baseType = path.getRootType();
    final int position = selectedNode.getOperandPosition();
    final IAddress address = selectedNode.getInstructionAddress();
    final TypeSubstitution substitution = selectedNode.getTypeSubstitution();
    final List<TypeMember> memberPath = path.getMembers();
    if (substitution == null) {
        typeManager.createTypeSubstitution(selectedNode, baseType, memberPath, position, offset, address);
    } else {
        typeManager.updateTypeSubstitution(selectedNode, substitution, baseType, path.getMembers(), offset);
    }
}
Also used : TypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 2 with TypeSubstitution

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

the class BaseTypeTransferHandlerTest method testImportData_SubstitutionUpdated.

@Test
public void testImportData_SubstitutionUpdated() throws CouldntSaveDataException {
    initSubstitutionStubs();
    final TypeSubstitution substitution = mock(TypeSubstitution.class);
    when(node.getTypeSubstitution()).thenReturn(substitution);
    final BaseTypeTransferHandler handler = new BaseTypeTransferHandler(manager, wrapper);
    handler.importData(null);
    verify(manager).updateTypeSubstitution(node, substitution, baseType, new ArrayList<TypeMember>(), OFFSET);
}
Also used : TypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) Test(org.junit.Test)

Example 3 with TypeSubstitution

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

the class TypeSubstitutionsUpdater method rebuild.

/**
   * Rebuilds all affected nodes for the given {@link TypeSubstitution type substitutions}.
   *
   * @param typeSubstitutions A set of {@link TypeSubstitution type substitutions} from a listener
   *        event.
   */
private void rebuild(Set<TypeSubstitution> typeSubstitutions) {
    final IAddress startAddress = codeNode.getAddress();
    final IAddress endAddress = codeNode.getLastInstruction().getAddress();
    for (final TypeSubstitution substitution : typeSubstitutions) {
        if (substitution.getAddress().toLong() >= startAddress.toLong() && substitution.getAddress().toLong() <= endAddress.toLong()) {
            naviNode.getRealizer().regenerate();
            naviNode.getRealizer().repaint();
            return;
        }
    }
}
Also used : TypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 4 with TypeSubstitution

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

the class ViewReferencesTableModel method addTypeSubstitutionToTree.

/**
   * Adds a {@link TypeSubstitution type substitution} for the given {@link INaviInstruction
   * instruction} to the tree.
   *
   * @param operandNode The {@link INaviOperandTreeNode operand node} which holds the
   *        {@link TypeSubstitution type substitution}.
   * @param instruction The {@link INaviInstruction instruction} which holds the
   *        {@link INaviOperandTreeNode operand node}.
   */
private void addTypeSubstitutionToTree(final INaviOperandTreeNode operandNode, final INaviInstruction instruction) {
    final TypeSubstitution typeSubstitution = operandNode.getTypeSubstitution();
    final BaseTypeCategory category = typeSubstitution.getBaseType().getCategory();
    if (category == BaseTypeCategory.STRUCT || category == BaseTypeCategory.ARRAY || category == BaseTypeCategory.UNION) {
        addCompoundTypeSubstitutionToTree(operandNode, instruction, typeSubstitution);
    } else {
        addBaseType(typeSubstitution.getBaseType());
        BaseTypeTreeNode currentNode = baseTypeToTreeNode.get(typeSubstitution.getBaseType());
        insertNodeInto(multiIndex.putTypeSubstitution(typeSubstitution, instruction), currentNode, currentNode.getChildCount());
    }
}
Also used : TypeSubstitution(com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution) BaseTypeTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode) BaseTypeCategory(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeCategory)

Aggregations

TypeSubstitution (com.google.security.zynamics.binnavi.disassembly.types.TypeSubstitution)4 TypeMember (com.google.security.zynamics.binnavi.disassembly.types.TypeMember)2 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)2 BaseTypeTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode)1 BaseType (com.google.security.zynamics.binnavi.disassembly.types.BaseType)1 BaseTypeCategory (com.google.security.zynamics.binnavi.disassembly.types.BaseTypeCategory)1 Test (org.junit.Test)1