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