Search in sources :

Example 11 with CFunction

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

the class FunctionBlockTest method testConstructor.

@Test
public void testConstructor() {
    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);
    final Function function = new Function(ModuleFactory.get(), parentFunction);
    final FunctionBlock block = new FunctionBlock(function);
    assertEquals(function, block.getFunction());
    assertEquals("Function Block ['123 Mock Function']", block.toString());
}
Also used : CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 12 with CFunction

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

the class FunctionEdgeTest method testConstructor.

@Test
public void testConstructor() {
    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);
    final Function function = new Function(ModuleFactory.get(), parentFunction);
    final FunctionBlock block = new FunctionBlock(function);
    final FunctionBlock childBlock = new FunctionBlock(function);
    final FunctionEdge edge = new FunctionEdge(block, childBlock);
    assertEquals("Function Edge [Mock Function -> Mock Function]", edge.toString());
    assertEquals(block, edge.getSource());
    assertEquals(childBlock, edge.getTarget());
    assertEquals(0, block.getParents().size());
    assertEquals(1, block.getChildren().size());
    assertEquals(childBlock, block.getChildren().get(0));
    assertEquals(0, childBlock.getChildren().size());
    assertEquals(1, childBlock.getParents().size());
    assertEquals(block, childBlock.getParents().get(0));
}
Also used : CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 13 with CFunction

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

the class PostgreSQLProviderTest method testSetDescription1.

@Test
public void testSetDescription1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviProject project = getProvider().loadProjects().get(0);
    final CAddressSpace addressSpace = getProvider().createAddressSpace(project, "SOME_OTHER_ADDRESS_SPACE");
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CFunction function = (CFunction) module.getContent().getFunctionContainer().getFunctions().get(0);
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(0);
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    final ITreeNode<CTag> tag = tagManager.getRootTag().getChildren().get(0);
    getProvider().setDescription(addressSpace, "New Description");
    getProvider().setDescription(function, "New Description");
    getProvider().setDescription(module, "New Description");
    getProvider().setDescription(project, "New Description");
    getProvider().setDescription(tag.getObject(), "New Description");
    getProvider().setDescription(module.getContent().getTraceContainer().getTraces().get(0), "New Description");
    getProvider().setDescription(view, "New Description");
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 14 with CFunction

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

the class GraphSearcherTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final Graph2D g = new Graph2D();
    m_ynode = g.createNode();
    final MockSqlProvider sql = new MockSqlProvider();
    final CModule module = MockCreator.createModule(sql);
    module.load();
    final CFunction function = MockCreator.createFunction(module, sql);
    final CView m_view = MockCreator.createView(sql, module);
    final CInstruction instruction1 = MockCreator.createInstruction(module, sql);
    final CInstruction instruction2 = MockCreator.createInstruction(module, sql);
    final CInstruction instruction3 = MockCreator.createInstruction(module, sql);
    m_view.load();
    m_codeNode1 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
    m_content = new ZyLabelContent(null);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Graph2D(y.view.Graph2D) Before(org.junit.Before)

Example 15 with CFunction

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

the class CGraphDebuggerTest method testToggleBreakpoint3.

@Test
public void testToggleBreakpoint3() {
    final MockModule module = new MockModule();
    module.getConfiguration().setDebugger(m_debugger);
    m_debugger.setAddressTranslator(module, m_fileBase, m_imageBase);
    final DebugTargetSettings target = new ModuleTargetSettings(module);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    debuggerProvider.addDebugger(m_debugger);
    final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
    final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Mock Comment"));
    final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, comments, function, new HashSet<CTag>(), new MockSqlProvider());
    codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
    codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
    CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
    assertEquals(1, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
    assertEquals(0x124, m_debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, 0).getAddress().getAddress().getAddress().toLong());
    assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_debugger.getBreakpointManager().getBreakpointStatus(BreakpointType.REGULAR, 0));
    CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
    assertEquals(0, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) ArrayList(java.util.ArrayList) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Test(org.junit.Test)

Aggregations

CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)30 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)26 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)25 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)24 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)23 Test (org.junit.Test)23 Date (java.util.Date)21 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)11 ArrayList (java.util.ArrayList)10 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)9 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)9 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)9 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)6 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)6 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)6 MockInstruction (com.google.security.zynamics.binnavi.disassembly.MockInstruction)6 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)6 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)5 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)5 Before (org.junit.Before)5