Search in sources :

Example 11 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 12 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberStructType4.

@Test
public void testFindMemberStructType4() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.simpleStruct, 96);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertEquals(typeSystem.ssArrayMember, result.getMember());
    assertEquals(Lists.newArrayList(typeSystem.ssArrayMember), result.getPath());
    assertEquals("SimpleStruct.ss_array_member[1]", result.getPathString());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Example 13 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberNestedStructType3.

@Test
public void testFindMemberNestedStructType3() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.doubleNestedStruct, 64);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertEquals(typeSystem.ssUintMember, result.getMember());
    assertEquals("DoubleNestedStruct.dns_nested_struct_member.ns_simple_struct_member.ss_uint_member", result.getPathString());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Example 14 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberArguments2.

@Test
public void testFindMemberArguments2() {
    WalkResult result = BaseTypeHelpers.findMember(typeSystem.uintType, -1);
    assertEquals("", result.getPathString());
    assertFalse(result.isValid());
    assertNull(result.getPath());
    assertNull(result.getMember());
}
Also used : WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) Test(org.junit.Test)

Example 15 with WalkResult

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

the class BaseTypeHelpersTests method testFindMemberStructType3.

@Test
public void testFindMemberStructType3() {
    final WalkResult result = BaseTypeHelpers.findMember(typeSystem.simpleStruct, 64);
    assertNotNull(result);
    assertTrue(result.isValid());
    assertEquals(typeSystem.ssArrayMember, result.getMember());
    assertEquals(Lists.newArrayList(typeSystem.ssArrayMember), result.getPath());
    assertEquals("SimpleStruct.ss_array_member[0]", 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