use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class ViewTest method testGraph.
@Test
public void testGraph() {
final List<INaviViewNode> nodes = new ArrayList<INaviViewNode>();
final List<INaviEdge> edges = new ArrayList<INaviEdge>();
final MutableDirectedGraph<INaviViewNode, INaviEdge> graph = new MutableDirectedGraph<INaviViewNode, INaviEdge>(nodes, edges);
final int viewId = new BigInteger(31, new SecureRandom()).intValue();
final INaviView internalView = new CView(viewId, internalModule, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, m_creationDate, m_modificationDate, graph, new HashSet<CTag>(), false, m_provider);
final INaviFunction internalFunction = internalModule.getContent().getFunctionContainer().getFunctions().get(0);
final CCodeNode codeNode = internalView.getContent().createCodeNode(internalFunction, Lists.newArrayList(new MockInstruction()));
final CFunctionNode functionNode = internalView.getContent().createFunctionNode(internalFunction);
@SuppressWarnings("unused") final CTextNode textNode = internalView.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Foo")));
@SuppressWarnings("unused") final CGroupNode groupNode = internalView.getContent().createGroupNode(internalView.getGraph().getNodes());
internalView.getContent().createEdge(codeNode, functionNode, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_UNCONDITIONAL);
final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
final MockViewListener listener = new MockViewListener();
final View view = new View(module, internalView, tagManager, m_viewTagManager);
view.addListener(listener);
assertEquals(4, view.getGraph().getNodes().size());
assertEquals(1, view.getGraph().getEdges().size());
internalView.getContent().deleteNodes(internalView.getContent().getGraph().getNodes());
assertEquals("deletedEdge;deletedNode;deletedNode;deletedNode;", listener.events);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class MockSqlProvider method loadFunctions.
@Override
public List<INaviFunction> loadFunctions(final INaviModule module, final List<IFlowgraphView> views) {
final INaviFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "", "", "", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, this);
functions.add(function);
return Lists.newArrayList(function);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLGroupNodeCommentTests method appendInstructionCommentInGroupNode.
@Test
public void appendInstructionCommentInGroupNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
assertEquals(42, view.getNodeCount());
final INaviViewNode node1 = view.getContent().getBasicBlocks().get(1);
final INaviViewNode node2 = view.getContent().getBasicBlocks().get(2);
view.getContent().createGroupNode(Lists.newArrayList(node1, node2));
final ZyGraph graph = CGraphBuilder.buildGraph(view);
final INaviView nonNativeView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST INSTRUCTION COMMENTS IN GROUP NODE ", " TESTING GROUP NODE COMMENTS ");
final INaviInstruction instruction = view.getContent().getBasicBlocks().get(0).getLastInstruction();
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final String firstCommentString = "TEST INSTRUCTION COMMENT PROPAGATION";
final int firstCommentId = getProvider().appendGlobalInstructionComment(instruction, firstCommentString, user.getUserId());
final IComment firstComment = new CComment(firstCommentId, user, null, firstCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(firstCommentId);
assertNotNull(commentsFromDatabase);
assertEquals(1, commentsFromDatabase.size());
assertTrue(commentsFromDatabase.contains(firstComment));
final INaviInstruction instruction2 = nonNativeView.getBasicBlocks().get(0).getLastInstruction();
assertEquals(1, instruction2.getGlobalComment().size());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CPostgreSQLZyGraphTest2 method setUp.
@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, FileReadException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, CPartialLoadException, LoadCancelledException, MaybeNullException {
ConfigManager.instance().read();
final ZyGraphViewSettings settings = ConfigManager.instance().getDefaultFlowGraphSettings();
settings.getProximitySettings().setProximityBrowsingActivationThreshold(50);
settings.getProximitySettings().setProximityBrowsingChildren(2);
settings.getProximitySettings().setProximityBrowsingParents(2);
ConfigManager.instance().updateFlowgraphSettings(settings);
final String[] parts = CConfigLoader.loadPostgreSQL();
m_database = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
m_database2 = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
m_database.connect();
m_database.load();
m_module = m_database.getContent().getModules().get(0);
m_module.load();
final INaviFunction function = m_module.getContent().getFunctionContainer().getFunction("sub_1002B87");
m_view = (IFlowgraphView) m_module.getContent().getViewContainer().getView(function);
m_view.load();
m_graph = CGraphBuilder.buildGraph(m_view);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CPostgreSQLDatabaseTest method testCalc.
@Test
public void testCalc() throws CouldntLoadDataException, InternalTranslationException, LoadCancelledException {
final INaviModule calc = m_database.getContent().getModule(2);
calc.load();
for (final INaviFunction function : calc.getContent().getFunctionContainer().getFunctions()) {
function.load();
m_translator.translate(new StandardEnvironment(), function);
function.close();
}
calc.close();
}
Aggregations