use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.
the class OperandTest method testCreate.
@Test
public void testCreate() {
final Database database = new Database(new MockDatabase());
final MockModule mockModule = new MockModule();
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final COperandTreeNode rootNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_SIZE_PREFIX_ID, "b4", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
final COperandTreeNode childNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
COperandTreeNode.link(rootNode, childNode);
final OperandExpression root = new OperandExpression(rootNode);
final Operand operand = Operand.create(module, root);
assertEquals("dword", operand.getRootNode().getValue());
assertEquals(1, operand.getRootNode().getChildren().size());
assertEquals("eax", operand.getRootNode().getChildren().get(0).getValue());
assertEquals("eax", operand.toString());
}
use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.
the class CReferenceFinder method fetchReferenceList.
/**
* Searches for outgoing references of a tree node and its children.
*
* @param node The start node of the search,
* @param instruction The instruction the node belongs to.
* @param functions List where the found references are stored.
*/
private static void fetchReferenceList(final IOperandTreeNode node, final INaviInstruction instruction, final List<Pair<INaviInstruction, INaviFunction>> functions) {
final List<IReference> references = node.getReferences();
for (final IReference reference : references) {
if (ReferenceType.isCodeReference(reference.getType())) {
final IAddress target = reference.getTarget();
final INaviFunction function = instruction.getModule().getContent().getFunctionContainer().getFunction(target);
if (function != null) {
functions.add(new Pair<INaviInstruction, INaviFunction>(instruction, function));
}
}
}
for (final IOperandTreeNode child : node.getChildren()) {
fetchReferenceList(child, instruction, functions);
}
}
Aggregations