Search in sources :

Example 16 with IReference

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());
}
Also used : MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) IReference(com.google.security.zynamics.zylib.disassembly.IReference) Test(org.junit.Test)

Example 17 with IReference

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);
    }
}
Also used : IReference(com.google.security.zynamics.zylib.disassembly.IReference) IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Aggregations

IReference (com.google.security.zynamics.zylib.disassembly.IReference)17 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)11 Test (org.junit.Test)11 COperandTreeNode (com.google.security.zynamics.binnavi.disassembly.COperandTreeNode)10 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)9 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)8 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)6 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)5 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)5 Date (java.util.Date)5 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)4 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 ArrayList (java.util.ArrayList)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 CInstructionResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.BottomPanel.RegisterTracker.CInstructionResult)2 CTrackingResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.BottomPanel.RegisterTracker.CTrackingResult)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2