use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CGlobalEdgeCommentSynchronizer method updateOpenViews.
/**
* Pushes a new global edge comment to all open views.
*
* @param edge The edge that has the new comment.
* @param comments The new comment of the code node.
*
* @throws CouldntSaveDataException Thrown if updating the edge comments failed.
*/
public static void updateOpenViews(final INaviEdge edge, final ArrayList<IComment> comments) throws CouldntSaveDataException {
try {
final Pair<INaviModule, INaviModule> modules = getModules(edge);
if (modules.first() != modules.second()) {
// TODO: Handle this
return;
}
if ((modules.first() != null) && (modules.second() != null) && modules.first().isLoaded()) {
final List<INaviEdge> edgelist = new ArrayList<INaviEdge>();
final Quad<Integer, IAddress, Integer, IAddress> refEdgeData = getEdgeData(edge);
for (final INaviView view : modules.first().getContent().getViewContainer().getViews()) {
edgelist.addAll(collectEdges(view, refEdgeData));
}
for (final INaviEdge updateEdge : edgelist) {
updateEdge.initializeGlobalComment(comments);
}
}
} catch (final MaybeNullException exception) {
// Trying to update global comments of code nodes without global comments.
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CGlobalEdgeCommentSynchronizer method getModules.
/**
* Returns the modules the nodes of the edge belong to.
*
* @param edge The edge to check.
*
* @return Source module and target module of the edge.
*
* @throws MaybeNullException Thrown if the edge does not have source module or target module.
*/
private static Pair<INaviModule, INaviModule> getModules(final INaviEdge edge) throws MaybeNullException {
INaviModule srcModule = null;
INaviModule tarModule = null;
if (edge.getSource() instanceof INaviCodeNode) {
srcModule = ((INaviCodeNode) edge.getSource()).getParentFunction().getModule();
} else if (edge.getSource() instanceof INaviFunctionNode) {
srcModule = ((INaviFunctionNode) edge.getSource()).getFunction().getModule();
}
if (edge.getTarget() instanceof INaviCodeNode) {
tarModule = ((INaviCodeNode) edge.getTarget()).getParentFunction().getModule();
} else if (edge.getTarget() instanceof INaviFunctionNode) {
tarModule = ((INaviFunctionNode) edge.getTarget()).getFunction().getModule();
}
return new Pair<INaviModule, INaviModule>(srcModule, tarModule);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CSteppingHelper method getAddress.
/**
* Determines the start address of a node.
*
* @param node Node whose address is determined.
*
* @return The start address of the given node or null if the node does not have an address.
*/
private static BreakpointAddress getAddress(final INaviViewNode node) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode ccnode = (INaviCodeNode) node;
final INaviInstruction instruction = Iterables.getFirst(ccnode.getInstructions(), null);
return new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
} else if (node instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node).getFunction();
final INaviModule module = function.getModule();
return new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
} else {
// Node types we can not step to
return null;
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CBreakpointFunctionsTest method test6removeFunctions.
@Test
public void test6removeFunctions() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockFunction mockFunction = new MockFunction();
final INaviModule mockModule = mockFunction.getModule();
CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), mockFunction);
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234)))));
@SuppressWarnings("unused") final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234))));
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
assertEquals(1, tableModel.getRowCount());
final IFilledList<Pair<IDebugger, INaviFunction>> targets = new FilledList<Pair<IDebugger, INaviFunction>>();
final Pair<IDebugger, INaviFunction> targetPair = new Pair<IDebugger, INaviFunction>(debugger, mockFunction);
targets.add(targetPair);
assertEquals(1, targets.size());
CBreakpointRemoveFunctions.removeBreakpoints(targets);
@SuppressWarnings("unused") final BreakpointManager manager = debugger.getBreakpointManager();
assertEquals(0, tableModel.getRowCount());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CBreakpointFunctionsTest method test7setBreakpoints.
@Test
public void test7setBreakpoints() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockFunction mockFunction = new MockFunction();
final INaviModule mockModule = mockFunction.getModule();
CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), mockFunction);
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234)))));
@SuppressWarnings("unused") final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234))));
// CBreakpointAddress address = new CBreakpointAddress(mockModule, new CUnrelocatedAddress(new
// CAddress(0x2c9)));
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
assertEquals(1, tableModel.getRowCount());
final IFilledList<Pair<IDebugger, INaviFunction>> targets = new FilledList<Pair<IDebugger, INaviFunction>>();
final Pair<IDebugger, INaviFunction> targetPair = new Pair<IDebugger, INaviFunction>(debugger, mockFunction);
targets.add(targetPair);
CBreakpointRemoveFunctions.removeBreakpoints(targets);
assertEquals(0, tableModel.getRowCount());
CBreakpointSetFunctions.setBreakpoints(targets);
assertEquals(1, tableModel.getRowCount());
}
Aggregations