use of com.google.security.zynamics.binnavi.disassembly.views.INaviView 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());
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLVerifyCalcTest method verifyViews.
private static void verifyViews(final INaviModule module) throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
final List<INaviView> views = module.getContent().getViewContainer().getViews();
final INaviView callgraph = views.get(0);
assertEquals(null, module.getContent().getViewContainer().getFunction(callgraph));
assertEquals(ViewType.Native, callgraph.getType());
assertEquals(GraphType.CALLGRAPH, callgraph.getGraphType());
callgraph.load();
callgraph.close();
for (int i = 1; i < views.size(); i++) {
final INaviView view = views.get(i);
final INaviFunction function = module.getContent().getViewContainer().getFunction(view);
assertEquals(view.getName(), function.getName());
assertEquals(ViewType.Native, view.getType());
assertEquals(GraphType.FLOWGRAPH, view.getGraphType());
assertEquals(view.getNodeCount(), function.getBasicBlockCount());
assertEquals(view.getEdgeCount(), function.getEdgeCount());
view.load();
function.load();
assertEquals(view.getNodeCount(), function.getBasicBlockCount());
assertEquals(view.getEdgeCount(), function.getEdgeCount());
view.close();
function.close();
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLVerifyNotepadTest method verifyViews.
@Test
public void verifyViews() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final SQLProvider provider = (SQLProvider) ReflectionHelpers.getField(m_database, "provider");
final INaviModule module = m_database.getContent().getModules().get(0);
module.load();
final List<INaviView> views = module.getContent().getViewContainer().getViews();
final INaviView callgraph = views.get(0);
assertEquals(null, module.getContent().getViewContainer().getFunction(callgraph));
assertEquals(ViewType.Native, callgraph.getType());
assertEquals(GraphType.CALLGRAPH, callgraph.getGraphType());
assertEquals(287, callgraph.getNodeCount());
assertEquals(848, callgraph.getEdgeCount());
callgraph.load();
assertEquals(287, callgraph.getNodeCount());
assertEquals(848, callgraph.getEdgeCount());
callgraph.close();
final LinkedHashSet<?> cgListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(CommentManager.get(provider), "listeners"), "m_listeners");
assertEquals(module.getContent().getFunctionContainer().getFunctions().size() + 1, // the +1 here is the listener in the type instance container.
cgListeners.size());
for (int i = 1; i < views.size(); i++) {
final INaviView view = views.get(i);
final INaviFunction function = module.getContent().getViewContainer().getFunction(view);
assertEquals(view.getName(), function.getName());
assertEquals(ViewType.Native, view.getType());
assertEquals(GraphType.FLOWGRAPH, view.getGraphType());
assertEquals(view.getNodeCount(), function.getBasicBlockCount());
assertEquals(view.getEdgeCount(), function.getEdgeCount());
view.load();
function.load();
assertEquals(view.getNodeCount(), function.getBasicBlockCount());
assertEquals(view.getEdgeCount(), function.getEdgeCount());
if (function.getAddress().toBigInteger().equals(BigInteger.valueOf(0x1001929))) {
assertEquals(view.getNodeCount(), 5);
assertEquals(view.getEdgeCount(), 6);
} else if (function.getAddress().toBigInteger().equals(BigInteger.valueOf(16790571))) {
assertEquals(view.getNodeCount(), 92);
assertEquals(view.getEdgeCount(), 144);
} else if (i == 1) {
assertEquals(view.getNodeCount(), 0);
assertEquals(view.getEdgeCount(), 0);
}
view.close();
function.close();
}
module.close();
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLProviderTest method testCModuleFunctionsgetViewsWithAddresses1.
@Test
public void testCModuleFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
List<INaviView> views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
assertEquals(0, views.size());
addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
assertEquals(1, views.size());
addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
assertEquals(0, views.size());
views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, false);
assertEquals(2, views.size());
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLProviderTest method testCProjectFunctionsgetViewsWithAddresses1.
@Test
public void testCProjectFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
final INaviProject project = getProvider().loadProjects().get(0);
project.load();
final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
List<INaviView> views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
assertEquals(0, views.size());
addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
assertEquals(0, views.size());
addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, true);
assertEquals(0, views.size());
views = PostgreSQLProjectFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), project, addresses, false);
assertEquals(0, views.size());
}
Aggregations