Search in sources :

Example 46 with INaviInstruction

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

the class PostgreSQLVerifyNotepadTest method verifyInstructions.

@Test
public void verifyInstructions() throws CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = m_database.getContent().getModules().get(0);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress(BigInteger.valueOf(0x0100195D)));
    function.load();
    final List<IBlockNode> blocks = function.getBasicBlocks();
    final IBlockNode block = blocks.get(0);
    assertEquals(BigInteger.valueOf(0x0100195D), block.getAddress().toBigInteger());
    final Iterable<INaviInstruction> instructions = block.getInstructions();
    Iterables.get(instructions, 0).toString();
    assertEquals("0100195D mov edi, edi", Iterables.get(instructions, 0).toString());
    assertEquals("0100195F push ebp", Iterables.get(instructions, 1).toString());
    assertEquals("01001960 mov ebp, esp", Iterables.get(instructions, 2).toString());
    assertEquals("01001962 push ecx", Iterables.get(instructions, 3).toString());
    assertEquals("01001963 push 2", Iterables.get(instructions, 4).toString());
    assertEquals("01001965 lea eax, ss: [ebp + LCData]", Iterables.get(instructions, 5).toString());
    assertEquals("01001968 push eax", Iterables.get(instructions, 6).toString());
    assertEquals("01001969 push 13", Iterables.get(instructions, 7).toString());
    assertEquals("0100196B push 1024", Iterables.get(instructions, 8).toString());
    assertEquals("01001970 mov ds: [16819428], sub_1005F63", Iterables.get(instructions, 9).toString());
    assertEquals("0100197A mov ds: [16819436], 12", Iterables.get(instructions, 10).toString());
    assertEquals("01001984 call ds: [GetLocaleInfoW]", Iterables.get(instructions, 11).toString());
    assertEquals("0100198A cmp word ss: [ebp + LCData], word 49", Iterables.get(instructions, 12).toString());
    assertEquals("0100198F jnz loc_10019B1", Iterables.get(instructions, 13).toString());
    module.close();
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Example 47 with INaviInstruction

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

the class PostgreSQLProviderTest method testInstructionFunctionsAddReference4.

@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
    function.load();
    final IBlockNode basicBlock = function.getBasicBlocks().get(0);
    final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
    final COperandTree tree = instruction.getOperands().get(0);
    final INaviOperandTreeNode node = tree.getRootNode();
    PostgreSQLInstructionFunctions.addReference(getProvider(), node, null, null);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 48 with INaviInstruction

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

the class PostgreSQLNotificationParserTest method testGlobalInstructionCommentParsingAppend.

@Test
public void testGlobalInstructionCommentParsingAppend() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_instructions UPDATE 1 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processInstructionGlobalCommentNotification(notification, provider);
    assertNotNull(result);
    final InstructionCommentNotificationContainer container = (InstructionCommentNotificationContainer) result;
    final INaviInstruction instruction = container.getInstruction();
    assertEquals(new CAddress(4608), instruction.getAddress());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
    assertEquals(CommentScope.GLOBAL, container.getScope());
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) InstructionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.InstructionCommentNotificationContainer) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 49 with INaviInstruction

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

the class PostgreSQLTypeInstancesNotificationParserTest method setUp.

@Before
public void setUp() throws NumberFormatException, CouldntSaveDataException, CouldntLoadDataException {
    view = MockViewGenerator.generate(provider, module, function);
    baseType = module.getTypeManager().getTypes().get(0);
    final Section section = module.getContent().getSections().createSection("TEST_SECTION", new CAddress("01000000", 16), new CAddress("0100FFFF", 16), SectionPermission.READ_WRITE_EXECUTE, null);
    final TypeInstanceContainer container = module.getContent().getTypeInstanceContainer();
    instance = container.createInstance("TEST_INSTANCE", null, baseType, section, new Long("11143"));
    final CCodeNode node = view.getBasicBlocks().get(0);
    final INaviInstruction instruction = node.getInstructions().iterator().next();
    final INaviOperandTreeNode operandNode = instruction.getOperands().get(0).getNodes().get(0);
    reference = container.createReference(instruction.getAddress(), 0, operandNode, instance, view);
    assertNotNull(reference);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) Section(com.google.security.zynamics.binnavi.disassembly.types.Section) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Before(org.junit.Before)

Example 50 with INaviInstruction

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

the class PostgreSQLTypeInstanceFunctionsTests method deleteTypeInstanceReferenceTest5.

@Test
public void deleteTypeInstanceReferenceTest5() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, CouldntSaveDataException {
    module.load();
    final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
    final TypeInstanceAddress address1 = typeInstance.getAddress();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress("1001929", 16));
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final INaviInstruction instruction = view.getBasicBlocks().get(2).getInstructions().iterator().next();
    Assert.assertNotNull(typeInstance);
    provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(1)), instruction.getOperands().get(0).getNodes().get(0).getId(), typeInstance.getId());
    view.close();
    module.close();
    module.load();
    view.load();
    final TypeInstance typeInstance2 = module.getContent().getTypeInstanceContainer().getTypeInstance(typeInstance.getAddress());
    Assert.assertEquals(address1, typeInstance2.getAddress());
    final List<TypeInstanceReference> references = module.getContent().getTypeInstanceContainer().getReferences(typeInstance2);
    Assert.assertTrue(!references.isEmpty());
    final TypeInstanceReference reference = Iterables.find(references, new Predicate<TypeInstanceReference>() {

        @Override
        public boolean apply(final TypeInstanceReference reference) {
            return reference.getAddress().equals(instruction.getAddress());
        }
    });
    Assert.assertNotNull(reference);
    provider.deleteTypeInstanceReference(module.getConfiguration().getId(), reference.getAddress().toBigInteger(), reference.getPosition(), reference.getTreeNode().get().getId());
}
Also used : TypeInstanceAddress(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) TypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference) RawTypeInstanceReference(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstanceReference) RawTypeInstance(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Aggregations

INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)82 Test (org.junit.Test)27 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)26 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)24 ArrayList (java.util.ArrayList)24 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)20 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)18 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)16 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)15 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)15 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)10 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)10 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)9 IBlockNode (com.google.security.zynamics.binnavi.disassembly.IBlockNode)9 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)9 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)9 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)9 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)8 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)8 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)7