Search in sources :

Example 36 with CView

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

the class PostgreSQLProviderTest method testCViewLoaderLoadView4.

@Test(expected = NullPointerException.class)
public void testCViewLoaderLoadView4() throws CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
    final INaviModule module = getProvider().loadModules().get(0);
    final List<INaviModule> modules = new ArrayList<INaviModule>();
    module.load();
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
    PostgreSQLViewLoader.loadView((AbstractSQLProvider) getProvider(), view, modules, null);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ArrayList(java.util.ArrayList) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 37 with CView

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

the class PostgreSQLProviderTest method testTagView1.

@Test
public void testTagView1() throws CouldntSaveDataException, CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
    view.load();
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    final CTag tag = tagManager.getRootTag().getChildren().get(0).getObject();
    getProvider().tagView(view, tag);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 38 with CView

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

the class PostgreSQLProviderTest method testTagView3.

@Test(expected = NullPointerException.class)
public void testTagView3() throws CouldntLoadDataException, CouldntSaveDataException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
    getProvider().tagView(view, null);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 39 with CView

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

the class CModuleFunctions method copyView.

/**
   * Copies a view into a module view.
   * 
   * @param parent Parent window used for dialogs.
   * @param module Module where the copied view is stored.
   * @param view The view to copy.
   */
public static void copyView(final JFrame parent, final INaviModule module, final INaviView view) {
    Preconditions.checkNotNull(parent, "IE01832: Parent argument can not be null");
    Preconditions.checkNotNull(module, "IE01833: Module argument can not be null");
    Preconditions.checkNotNull(view, "IE01834: View argument can not be null");
    if (module.getContent().getViewContainer().hasView(view)) {
        if (!view.isLoaded()) {
            try {
                view.load();
            } catch (final CouldntLoadDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00133: View could not be copied";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be copied because it could not be loaded.", view.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The new view was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
                return;
            } catch (CPartialLoadException | LoadCancelledException e) {
                CUtilityFunctions.logException(e);
                return;
            }
        }
        final CView newView = module.getContent().getViewContainer().createView(String.format("Copy of %s", view.getName()), null);
        CViewInserter.insertView(view, newView);
    }
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Example 40 with CView

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

the class ViewNodeTest method setUp.

@Before
public void setUp() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, FileReadException {
    ConfigManager.instance().read();
    final MockSqlProvider provider = new MockSqlProvider();
    final Database database = new Database(new MockDatabase());
    final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), CommonTestObjects.MD5, CommonTestObjects.SHA1, 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 CTagManager mockTagManager = new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "Root", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider);
    m_nodeTagManager = new TagManager(mockTagManager);
    final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
    final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    final Function function = new Function(ModuleFactory.get(), parentFunction);
    final Module module = new Module(database, internalModule, m_nodeTagManager, viewTagManager) {

        @Override
        public Function getFunction(final INaviFunction internalFunction) {
            return function;
        }

        @Override
        public boolean isLoaded() {
            return true;
        }
    };
    final CFunction internalFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "", "", "", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    final ITreeNode<CTag> tag = mockTagManager.addTag(mockTagManager.getRootTag(), "Initial Tag");
    m_initialTag = m_nodeTagManager.getRootTags().get(0);
    final CView internalView = internalModule.getContent().getViewContainer().createView("", "");
    final CFunctionNode node = internalView.getContent().createFunctionNode(internalFunction);
    node.setColor(Color.MAGENTA);
    node.setX(10);
    node.setY(20);
    node.tagNode(tag.getObject());
    m_view = module.getViews().get(2);
    m_node = (FunctionNode) m_view.getGraph().getNodes().get(0);
    final CFunctionNode node2 = internalView.getContent().createFunctionNode(internalFunction);
    internalView.getContent().createEdge(node, node2, EdgeType.INTER_MODULE);
}
Also used : CFunctionNode(com.google.security.zynamics.binnavi.disassembly.CFunctionNode) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Before(org.junit.Before)

Aggregations

CView (com.google.security.zynamics.binnavi.disassembly.views.CView)45 Test (org.junit.Test)36 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)16 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)15 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)13 Date (java.util.Date)13 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)9 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)8 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)7 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)7 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)6 ArrayList (java.util.ArrayList)6 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)5 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)4 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)4 BigInteger (java.math.BigInteger)4 CModuleViewGenerator (com.google.security.zynamics.binnavi.Database.CModuleViewGenerator)3