Search in sources :

Example 1 with WalkResult

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

the class ViewReferencesTableModel method addCompoundTypeSubstitutionToTree.

/**
   * Adds a {@link TypeSubstitution type substitution} for the given {@link INaviInstruction
   * instruction} to the tree. The types passed to this function need to be compund types.
   *
   * @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}.
   * @param typeSubstitution A {@link TypeSubstitution type substitution} which is a compound type.
   *        Must be of a compound {@link BaseTypeCategory base type category}.
   */
private void addCompoundTypeSubstitutionToTree(final INaviOperandTreeNode operandNode, final INaviInstruction instruction, final TypeSubstitution typeSubstitution) {
    final long completeOffset = operandNode.hasAddendSibling() ? (operandNode.determineAddendValue() * 8 + typeSubstitution.getOffset()) : typeSubstitution.getOffset();
    final WalkResult walkResult = BaseTypeHelpers.findMember(typeSubstitution.getBaseType(), completeOffset);
    if (!walkResult.isValid()) {
        return;
    }
    addBaseType(typeSubstitution.getBaseType());
    DefaultMutableTreeNode currentNode = baseTypeToTreeNode.get(typeSubstitution.getBaseType());
    for (TypeMember typeMember : walkResult.getPath()) {
        TypeMemberTreeNode nextNode = checkTypeMemberNodeExists(typeMember, currentNode);
        if (nextNode == null) {
            nextNode = new TypeMemberTreeNode(typeMember);
            typeMemberToTreeNode.put(typeMember, nextNode);
            insertNodeInto(nextNode, currentNode, currentNode.getChildCount());
        }
        currentNode = nextNode;
    }
    insertNodeInto(multiIndex.putTypeSubstitution(typeSubstitution, instruction), currentNode, currentNode.getChildCount());
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) TypeMemberTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)

Example 2 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberArrayType1.

@Test
public void testFindMemberArrayType1() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.uintArrayType, 0);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertNotNull(result.getMember());
    assertNotNull(result.getPath());
    assertEquals(typeSystem.uintArrayTypeMember, result.getMember());
    assertEquals(Lists.newArrayList(typeSystem.uintArrayType), result.getPath());
    assertEquals("unsigned int[0]", result.getPathString());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Example 3 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberNestedStructType4.

@Test
public void testFindMemberNestedStructType4() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.doubleNestedStruct, 96);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertEquals(typeSystem.ssArrayMember, result.getMember());
    assertEquals(Lists.newArrayList(typeSystem.dnsNestedStructMember, typeSystem.nsSimpleStructMember, typeSystem.ssArrayMember), result.getPath());
    assertEquals(typeSystem.doubleNestedStruct.getName() + "." + typeSystem.dnsNestedStructMember.getName() + "." + typeSystem.nsSimpleStructMember.getName() + "." + typeSystem.ssArrayMember.getName() + "[0]", result.getPathString());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Example 4 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberStructType2.

@Test
public void testFindMemberStructType2() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.simpleStruct, 32);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertEquals(typeSystem.ssUintMember, result.getMember());
    assertEquals(Lists.newArrayList(typeSystem.ssUintMember), result.getPath());
    assertEquals("SimpleStruct.ss_uint_member", result.getPathString());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Example 5 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberNestedStructType2.

@Test
public void testFindMemberNestedStructType2() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.doubleNestedStruct, 32);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertEquals(typeSystem.ssIntMember, result.getMember());
    assertEquals(Lists.newArrayList(typeSystem.dnsNestedStructMember, typeSystem.nsSimpleStructMember, typeSystem.ssIntMember), result.getPath());
    assertEquals("DoubleNestedStruct.dns_nested_struct_member.ns_simple_struct_member.ss_int_member", result.getPathString());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Aggregations

WalkResult (com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult)20 Test (org.junit.Test)19 TypeMemberTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)1 TypeMember (com.google.security.zynamics.binnavi.disassembly.types.TypeMember)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1