Search in sources :

Example 11 with IReference

use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.

the class COperandTreeNodeTest method testAddReference.

@Test
public void testAddReference() throws CouldntSaveDataException {
    final COperandTreeNode node = new COperandTreeNode(1, 1, "value", m_replacement, m_references, m_provider, module.getTypeManager(), module.getContent().getTypeInstanceContainer());
    assertNotNull(node);
    final INaviOperandTreeNodeListener listener = new CNaviOperandTreeNodeListenerAdapter();
    node.addListener(listener);
    final IReference reference = new CReference(new CAddress(0x2132321L), ReferenceType.DATA_STRING);
    node.addReference(reference);
    try {
        node.addReference(null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        node.addReference(reference);
        fail();
    } catch (final IllegalArgumentException e) {
    }
}
Also used : IReference(com.google.security.zynamics.zylib.disassembly.IReference) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 12 with IReference

use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.

the class COperandTreeNodeTest method testDeleteReference.

@Test
public void testDeleteReference() throws CouldntSaveDataException, CouldntDeleteException {
    final COperandTreeNode node = new COperandTreeNode(1, 1, "value", m_replacement, m_references, m_provider, module.getTypeManager(), module.getContent().getTypeInstanceContainer());
    assertNotNull(node);
    final INaviOperandTreeNodeListener listener = new CNaviOperandTreeNodeListenerAdapter();
    node.addListener(listener);
    final IReference reference = new CReference(new CAddress(0x2132321L), ReferenceType.DATA_STRING);
    node.addReference(reference);
    assertEquals(2, node.getReferences().size());
    node.deleteReference(reference);
    assertEquals(1, node.getReferences().size());
    try {
        node.deleteReference(null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        node.deleteReference(reference);
        fail();
    } catch (final IllegalArgumentException e) {
    }
}
Also used : IReference(com.google.security.zynamics.zylib.disassembly.IReference) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 13 with IReference

use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.

the class COperandTreeNodeTest method testMiscFunctions.

@Test
public void testMiscFunctions() throws CouldntSaveDataException {
    final COperandTreeNode node = new COperandTreeNode(1, 1, "value", m_replacement, m_references, m_provider, module.getTypeManager(), module.getContent().getTypeInstanceContainer());
    assertNotNull(node);
    final INaviOperandTreeNodeListener listener = new CNaviOperandTreeNodeListenerAdapter();
    node.addListener(listener);
    final IReference reference = new CReference(new CAddress(0x2132321L), ReferenceType.DATA_STRING);
    node.addReference(reference);
    assertNotNull(node.getDisplayStyle());
    assertEquals(1, node.getId());
    assertNull(node.getOperand());
    assertEquals("value", node.getValue());
    node.setDisplayStyle(OperandDisplayStyle.UNSIGNED_HEXADECIMAL);
    try {
        node.setDisplayStyle(null);
        fail();
    } catch (final NullPointerException e) {
    }
    node.setDisplayStyle(OperandDisplayStyle.UNSIGNED_HEXADECIMAL);
    node.setId(12345678);
    node.removeListener(listener);
    node.toString();
}
Also used : IReference(com.google.security.zynamics.zylib.disassembly.IReference) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 14 with IReference

use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.

the class InstructionTest method testReil.

@Test
public void testReil() throws InternalTranslationException, CouldntLoadDataException, LoadCancelledException {
    final SQLProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    internalModule.load();
    final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final COperandTree operand1 = new COperandTree(rootNode1, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final COperandTree operand2 = new COperandTree(rootNode2, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
    final CInstruction internalInstruction = new CInstruction(false, internalModule, new CAddress(0x123), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", provider);
    final Instruction instruction = new Instruction(internalInstruction);
    instruction.getReilCode();
}
Also used : DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) IReference(com.google.security.zynamics.zylib.disassembly.IReference) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Test(org.junit.Test)

Example 15 with IReference

use of com.google.security.zynamics.zylib.disassembly.IReference in project binnavi by google.

the class InstructionTest method testCommentInitialization.

@Test
public void testCommentInitialization() throws CouldntLoadDataException, LoadCancelledException {
    final SQLProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    internalModule.load();
    final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final COperandTree operand1 = new COperandTree(rootNode1, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final COperandTree operand2 = new COperandTree(rootNode2, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
    final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
    final CInstruction internalInstruction = new CInstruction(false, internalModule, new CAddress(0x123), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", provider);
    final Instruction instruction = new Instruction(internalInstruction);
    final MockInstructionListener listener = new MockInstructionListener();
    instruction.addListener(listener);
    final ArrayList<IComment> comment = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Hannes"));
    instruction.initializeComment(comment);
    assertEquals(comment, internalInstruction.getGlobalComment());
    assertEquals(comment, instruction.getComment());
    // TODO (timkornau): check if double messages are what we want here of rather not.
    // assertEquals("InitializedComment;", listener.events);
    instruction.removeListener(listener);
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) IReference(com.google.security.zynamics.zylib.disassembly.IReference) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Test(org.junit.Test)

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