use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class GlobalCodeNodeCommentSynchronizer method updateOpenViews.
/**
* Pushes a new global code node comment to all open views.
*
* @param module The module whose views require updating.
* @param codeNode The code node that has the new comment.
* @param comments The new comment of the code node.
*
* @throws CouldntSaveDataException Thrown if updating the code node comments failed.
*/
public static void updateOpenViews(final INaviModule module, final INaviCodeNode codeNode, final ArrayList<IComment> comments) throws CouldntSaveDataException {
if (module.isLoaded()) {
final List<INaviCodeNode> nodelist = new ArrayList<INaviCodeNode>();
for (final INaviView view : module.getContent().getViewContainer().getViews()) {
if (view.isLoaded()) {
nodelist.addAll(collectNodes(view, codeNode));
}
}
final List<IComment> codeNodeComments = codeNode.getComments().getGlobalCodeNodeComment();
for (final INaviCodeNode currentCodeNode : nodelist) {
final List<IComment> currentNodeComments = currentCodeNode.getComments().getGlobalCodeNodeComment();
if (codeNodeComments.equals(currentNodeComments)) {
continue;
} else {
currentCodeNode.getComments().initializeGlobalCodeNodeComment(comments);
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode 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.INaviCodeNode in project binnavi by google.
the class BreakpointableNodeCounter method next.
@Override
public IterationMode next(final NaviNode node) {
final INaviViewNode viewNode = node.getRawNode();
if (viewNode instanceof INaviCodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) viewNode;
final INaviInstruction instruction = Iterables.getFirst(codeNode.getInstructions(), null);
final INaviModule module = instruction.getModule();
final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(instruction.getAddress()));
if (EchoBreakpointCollector.isBlocked(breakpointManager, address)) {
return IterationMode.CONTINUE;
}
++breakpointAbleNodeCount;
} else if (viewNode instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) viewNode;
final INaviModule module = functionNode.getFunction().getModule();
final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(functionNode.getFunction().getAddress()));
if (EchoBreakpointCollector.isBlocked(breakpointManager, address)) {
return IterationMode.CONTINUE;
}
++breakpointAbleNodeCount;
}
return IterationMode.CONTINUE;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class EchoBreakpointCollector method next.
@Override
public IterationMode next(final NaviNode node) {
final INaviViewNode viewNode = node.getRawNode();
if (viewNode instanceof INaviCodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) viewNode;
final INaviInstruction instruction = Iterables.getFirst(codeNode.getInstructions(), null);
final INaviModule module = instruction.getModule();
final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(instruction.getAddress()));
if (isBlocked(manager, address)) {
return IterationMode.CONTINUE;
}
NaviLogger.info("Adding Echo breakpoint %s to the active list", address.getAddress().getAddress().toHexString());
// Add the echo breakpoint to the list of active echo breakpoints
echoBreakpointAbleAddresses.add(address);
} else if (viewNode instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) viewNode;
final INaviModule module = functionNode.getFunction().getModule();
final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(functionNode.getFunction().getAddress()));
if (isBlocked(manager, address)) {
return IterationMode.CONTINUE;
}
NaviLogger.info("Adding Echo breakpoint %s to the active list", address.getAddress().getAddress().toHexString());
// Add the echo breakpoint to the list of active echo breakpoints
echoBreakpointAbleAddresses.add(address);
}
return IterationMode.CONTINUE;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method setupTextNode.
private INaviTextNode setupTextNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("SetCommState");
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
final INaviCodeNode codeNode = view.getContent().getBasicBlocks().get(5);
final INaviTextNode textNode = view.getContent().createTextNode(null);
view.getContent().createEdge(codeNode, textNode, EdgeType.TEXTNODE_EDGE);
final ZyGraph graph = CGraphBuilder.buildGraph(view);
globalView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST TEXT NODE COMMENTS ", " TESTING TEXT NODE COMMENTS ");
INaviTextNode savedTextNode = null;
for (final INaviViewNode node : globalView.getGraph().getNodes()) {
if (node instanceof INaviTextNode) {
savedTextNode = (INaviTextNode) node;
}
}
return savedTextNode;
}
Aggregations