use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CallgraphTest method testConstructor.
@Test
public void testConstructor() {
final List<FunctionBlock> nodes = new ArrayList<FunctionBlock>();
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 FunctionBlock b1 = new FunctionBlock(new Function(ModuleFactory.get(), parentFunction));
final FunctionBlock b2 = new FunctionBlock(new Function(ModuleFactory.get(), parentFunction));
nodes.add(b1);
nodes.add(b2);
final List<FunctionEdge> edges = new ArrayList<FunctionEdge>();
final FunctionEdge e1 = new FunctionEdge(b1, b2);
edges.add(e1);
final Callgraph cg = new Callgraph(nodes, edges);
assertEquals(2, cg.getNodes().size());
assertEquals(b1, cg.getNodes().get(0));
assertEquals(b2, cg.getNodes().get(1));
assertEquals(1, cg.getEdges().size());
assertEquals(e1, cg.getEdges().get(0));
assertEquals("Callgraph [2 function nodes, 1 edges]", cg.toString());
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class BreakpointHelpersTest method testGetEchoBreakpointsNode.
@Test
public void testGetEchoBreakpointsNode() {
assertTrue(BreakpointHelpers.getEchoBreakpoints(m_debugger, m_node).isEmpty());
m_debugger.getBreakpointManager().getNative().addBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x1234)))));
final List<Address> breakpoints = BreakpointHelpers.getEchoBreakpoints(m_debugger, m_node);
assertEquals(1, breakpoints.size());
assertEquals(0x1234, breakpoints.get(0).toLong());
try {
BreakpointHelpers.getEchoBreakpoints(null, m_node);
fail();
} catch (final NullPointerException exception) {
}
try {
BreakpointHelpers.getEchoBreakpoints(m_debugger, (CodeNode) null);
fail();
} catch (final NullPointerException exception) {
}
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class BreakpointHelpersTest method setUp.
@Before
public void setUp() throws DebugExceptionWrapper, CouldntLoadDataException, LoadCancelledException, FileReadException {
ConfigManager.instance().read();
final CDatabase database = new CDatabase("", "", "", "", "", "", "", false, false);
final Database apiDatabase = new Database(database);
final SQLProvider mockProvider = new MockSqlProvider();
final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
m_module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, mockProvider);
m_module.load();
m_mockDebugger = new MockDebugger(m_moduleDebugSettings);
m_mockDebugger.connect();
m_debugger = new Debugger(m_mockDebugger);
final INaviFunction parentFunction = m_module.getContent().getFunctionContainer().getFunctions().get(0);
m_mockDebugger.setAddressTranslator(m_module, new CAddress(0), new CAddress(0x1000));
final ViewContainer viewContainer = new Module(apiDatabase, m_module, nodeTagManager, viewTagManager);
final INaviView naviView = new MockView(mockProvider);
final Function apiFunction = new Function(ModuleFactory.get(), parentFunction);
final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final COperandTree operand1 = new COperandTree(rootNode1, mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final COperandTree operand2 = new COperandTree(rootNode2, mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
final CInstruction internalInstruction = new CInstruction(true, m_module, new CAddress(0x1234), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", mockProvider);
m_view = new View(viewContainer, naviView, nodeTagManager, viewTagManager);
m_node = m_view.createCodeNode(apiFunction, Lists.newArrayList(new Instruction(internalInstruction)));
setM_functionNode(m_view.createFunctionNode(apiFunction));
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class BreakpointHelpersTest method testGetBreakpointsNode.
@Test
public void testGetBreakpointsNode() {
assertTrue(BreakpointHelpers.getBreakpoints(m_debugger, m_node).isEmpty());
m_debugger.getBreakpointManager().getNative().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x1234)))));
final List<Address> breakpoints = BreakpointHelpers.getBreakpoints(m_debugger, m_node);
assertEquals(1, breakpoints.size());
assertEquals(0x1234, breakpoints.get(0).toLong());
try {
BreakpointHelpers.getBreakpoints(null, m_node);
fail();
} catch (final NullPointerException exception) {
}
try {
BreakpointHelpers.getBreakpoints(m_debugger, (CodeNode) null);
fail();
} catch (final NullPointerException exception) {
}
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class BreakpointHelpersTest method testGetBreakpointsView.
@Test
public void testGetBreakpointsView() {
assertTrue(BreakpointHelpers.getBreakpoints(m_debugger, m_view).isEmpty());
m_debugger.getBreakpointManager().getNative().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x1234)))));
m_debugger.getBreakpointManager().getNative().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x123)))));
final List<Address> breakpoints = BreakpointHelpers.getBreakpoints(m_debugger, m_view);
assertEquals(2, breakpoints.size());
assertEquals(0x1234, breakpoints.get(0).toLong());
assertEquals(0x123, breakpoints.get(1).toLong());
try {
BreakpointHelpers.getBreakpoints(null, m_view);
fail();
} catch (final NullPointerException exception) {
}
try {
BreakpointHelpers.getBreakpoints(m_debugger, (View) null);
fail();
} catch (final NullPointerException exception) {
}
}
Aggregations