use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class CCodeNodeMenu method addOpenOriginalFunctionMenu.
private void addOpenOriginalFunctionMenu(final CGraphModel model, final NaviNode node) {
final INaviCodeNode rawNode = (INaviCodeNode) node.getRawNode();
try {
final INaviFunction nodeFunction = rawNode.getParentFunction();
final INaviFunction viewFunction = model.getViewContainer().getFunction(model.getGraph().getRawView());
if (nodeFunction != viewFunction) {
add(CActionProxy.proxy(new COpenOriginalFunction(model.getParent(), model.getViewContainer(), nodeFunction)));
}
} catch (final MaybeNullException e) {
// If there is no original function then we can not open it.
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class InternalNodeCallBack method zoomToAddress.
/**
* Zooms to the first occurrence of an address in a graph.
*
* @param graph The graph where the zoom operation takes place.
* @param address The address to zoom to.
*/
public static void zoomToAddress(final ZyGraph graph, final IAddress address) {
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
if (node.getRawNode() instanceof INaviCodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
for (final INaviInstruction instruction : codeNode.getInstructions()) {
if (instruction.getAddress().equals(address)) {
uncollapseParents(codeNode);
graph.showNode(node, true);
ZoomFunctions.zoomToNode(graph, node);
return IterationMode.STOP;
}
}
} else if (node.getRawNode() instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) node.getRawNode();
if (functionNode.getFunction().getAddress().equals(address)) {
uncollapseParents(functionNode);
graph.showNode(node, true);
ZoomFunctions.zoomToNode(graph, node);
return IterationMode.STOP;
}
}
return IterationMode.CONTINUE;
}
});
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class CDebuggerPainter method updateDebuggerHighlighting.
/**
* Updates the program counter highlighting in a whole graph.
*
* @param graph The graph where the highlighting is updated.
* @param address The address of the program counter to be highlighted.
* @param module The module in which the address is located.
*/
public static void updateDebuggerHighlighting(final ZyGraph graph, final UnrelocatedAddress address, final INaviModule module) {
Preconditions.checkNotNull(graph, "IE02187: Graph argument can not be null");
Preconditions.checkNotNull(address, "IE02188: Address argument can not be null");
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
final INaviViewNode rawNode = node.getRawNode();
if (rawNode instanceof ICodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) rawNode;
try {
if (module.equals(codeNode.getParentFunction().getModule())) {
updateDebuggerHighlighting(graph, address, node, codeNode);
}
} catch (final MaybeNullException exception) {
CUtilityFunctions.logException(exception);
}
} else if (rawNode instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) rawNode;
if (module.equals(functionNode.getFunction().getModule())) {
updateDebuggerHighlighting(address, node, functionNode);
}
}
return IterationMode.CONTINUE;
}
});
ZyZoomHelpers.zoomToAddress(graph, address.getAddress(), module, false);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class CNodeClickHandler method handleRegisterTracking.
private void handleRegisterTracking(final NaviNode node, final double y, final COperandTreeNode operand, final AnalysisDirection direction) {
if (!(node.getRawNode() instanceof INaviCodeNode)) {
// register tracking is only possible on code nodes.
return;
}
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
final double yPos = y - node.getY();
final int row = node.positionToRow(yPos);
final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, row);
if (instruction == null) {
return;
}
if (!operand.getType().equals(ExpressionType.REGISTER)) {
return;
}
final Set<String> clearedRegisters = Sets.newHashSet();
if (instruction.getArchitecture().equalsIgnoreCase("x86-32")) {
clearedRegisters.add("eax");
} else if (instruction.getArchitecture().equalsIgnoreCase("x86-64")) {
clearedRegisters.add("rax");
} else if (instruction.getArchitecture().equalsIgnoreCase("PowerPC-32")) {
clearedRegisters.addAll(Lists.newArrayList("R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12"));
} else if (instruction.getArchitecture().equalsIgnoreCase("ARM-32")) {
clearedRegisters.addAll(Lists.newArrayList("r0", "r1", "r2", "r3", "r12", "r14"));
} else if (instruction.getArchitecture().equalsIgnoreCase("MIPS-32")) {
clearedRegisters.addAll(Lists.newArrayList("$a0", "$a1", "$a2", "$a3", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$v0", "$v1"));
} else {
return;
}
final boolean trackIncoming = instruction.getOperandPosition(operand.getOperand()) != 0;
final RegisterTrackingOptions options = new RegisterTrackingOptions(false, clearedRegisters, trackIncoming, direction);
try {
// TODO(timkornau): comment this code in once we know how to access the bottom panel.
// final CTrackingResult result =
CTracking.track(m_model.getGraph().getRawView(), instruction, operand.getValue(), options);
} catch (final InternalTranslationException exception) {
CUtilityFunctions.logException(exception);
}
// TODO: (timkornau@google) there is currently no way to access the bottom panel to display the
// results. We need to somehow get access to the register tracking results container which
// exposes a method to set a new result.
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode 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));
}
Aggregations