Search in sources :

Example 6 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class ProjectTest method testUnloaded.

@Test
public void testUnloaded() throws CouldntSaveDataException, CouldntLoadDataException {
    try {
        m_project.createAddressSpace("Hannes");
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_project.createView("", "");
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        final MockSqlProvider provider = new MockSqlProvider();
        final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
        final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
        final View view = new View(m_project, new MockView(), nodeTagManager, viewTagManager);
        m_project.createView(view, "", "");
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_project.getAddressSpaces();
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        final MockSqlProvider provider = new MockSqlProvider();
        final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
        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);
        m_project.getFunction(parentFunction);
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_project.getTraces();
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_project.getViews();
        fail();
    } catch (final IllegalStateException exception) {
    }
}
Also used : 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) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Tree(com.google.security.zynamics.zylib.types.trees.Tree) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Test(org.junit.Test)

Example 7 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class TagManagerTest method testGetTag.

@Test
public void testGetTag() throws com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException {
    final TreeNode<CTag> rootNode = new TreeNode<CTag>(new CTag(1, "root", "", TagType.NODE_TAG, m_provider));
    final Tree<CTag> tree = new Tree<CTag>(rootNode);
    final ITagManager manager = new CTagManager(tree, TagType.NODE_TAG, m_provider);
    final ITreeNode<CTag> secondNode = manager.addTag(rootNode, "2nd");
    final ITreeNode<CTag> thirdNode = manager.addTag(rootNode, "3rd");
    final TagManager tagManager = new TagManager(manager);
    assertNotNull(tagManager.getTag(rootNode.getObject()));
    assertNotNull(tagManager.getTag(secondNode.getObject()));
    assertNotNull(tagManager.getTag(thirdNode.getObject()));
}
Also used : ITagManager(com.google.security.zynamics.binnavi.Tagging.ITagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ITagManager(com.google.security.zynamics.binnavi.Tagging.ITagManager) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Tree(com.google.security.zynamics.zylib.types.trees.Tree) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) Test(org.junit.Test)

Example 8 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class ViewTest method setUp.

@SuppressWarnings("deprecation")
@Before
public void setUp() throws LoadCancelledException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException, FileReadException, CouldntLoadDataException {
    ConfigManager.instance().read();
    final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
    final CTagManager internalTagManager = new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, m_provider))), TagType.VIEW_TAG, m_provider);
    m_viewTagManager = new TagManager(internalTagManager);
    final Database database = new Database(new MockDatabase());
    internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, m_provider);
    internalModule.load();
    module = new Module(database, internalModule, tagManager, m_viewTagManager);
    final Calendar cal = Calendar.getInstance();
    cal.setTime(module.getModificationDate());
    cal.add(Calendar.DATE, 1);
    m_modificationDate = cal.getTime();
    m_creationDate = new Date();
    final ITreeNode<CTag> tag = internalTagManager.addTag(internalTagManager.getRootTag(), "foo");
    final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, internalModule);
    final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, m_creationDate, m_modificationDate, 1, 2, Sets.newHashSet(tag.getObject()), new HashSet<CTag>(), false);
    m_view = new View(module, internalView, tagManager, m_viewTagManager);
}
Also used : CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) Calendar(java.util.Calendar) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) 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) Before(org.junit.Before)

Example 9 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class ModuleFactory method get.

public static Module get(final INaviModule module) {
    final MockSqlProvider provider = new MockSqlProvider();
    final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database db = new Database(new MockDatabase());
    return new Module(db, module, nodeTagManager, viewTagManager);
}
Also used : TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule)

Example 10 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class ModuleFactory method get.

public static Module get(final INaviModule module, final SQLProvider provider) {
    final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database db = new Database(new MockDatabase());
    return new Module(db, module, nodeTagManager, viewTagManager);
}
Also used : TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule)

Aggregations

CTag (com.google.security.zynamics.binnavi.Tagging.CTag)113 Test (org.junit.Test)55 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)42 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)35 Date (java.util.Date)28 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)24 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)24 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)21 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)20 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)18 ArrayList (java.util.ArrayList)17 Tree (com.google.security.zynamics.zylib.types.trees.Tree)15 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)14 TreeNode (com.google.security.zynamics.zylib.types.trees.TreeNode)14 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)13 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)13 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)13 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)13 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)13 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)12