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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations