use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CCodeNodeMenu method addFunctionOperandMenu.
private void addFunctionOperandMenu(final CGraphModel model, final INaviReplacement replacement) {
final INaviFunction function = ((CFunctionReplacement) replacement).getFunction();
final INaviView view = function.getModule().getContent().getViewContainer().getView(function);
add(new CChangeFunctionNameAction(model.getParent(), view));
addSeparator();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CCodeNodeMenu method addRenameFunctionMenu.
private void addRenameFunctionMenu(final INaviCodeNode codeNode, final CGraphModel model) {
try {
final INaviFunction function = codeNode.getParentFunction();
final INaviView view = function.getModule().getContent().getViewContainer().getView(function);
add(new CChangeFunctionNameAction(model.getParent(), view));
} catch (final MaybeNullException e) {
// no parent function no menu entry we are ok with this.
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CBreakpointPainter method paintBreakpoints.
/**
* Paints breakpoints into a function node.
*
* @param manager The breakpoint manager that provides breakpoint information.
* @param node The visible BinNavi node where the breakpoint is painted.
* @param functionNode The function node that contains the raw data for the BinNavi node.
*/
public static void paintBreakpoints(final BreakpointManager manager, final NaviNode node, final INaviFunctionNode functionNode) {
Preconditions.checkNotNull(manager, "IE02374: Manager argument can not be null");
Preconditions.checkNotNull(node, "IE02375: Node argument can not be null");
Preconditions.checkNotNull(functionNode, "IE02376: Code node argument can not be null");
final INaviFunction function = functionNode.getFunction();
final INaviModule module = function.getModule();
final int FUNCTION_BREAKPOINT_LINE = 1;
final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
node.setHighlighting(CHighlightLayers.BREAKPOINT_LAYER, FUNCTION_BREAKPOINT_LINE, BreakpointManager.getBreakpointColor(manager.getBreakpointStatus(address, BreakpointType.REGULAR)));
} else {
// If there is no breakpoint, clear potential older breakpoint line.
node.clearHighlighting(500, FUNCTION_BREAKPOINT_LINE);
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class ZyCodeNodeBuilder method buildFunctionLine.
/**
* Builds the function line of a code node. This line gives information about the function from
* where the code node originally came from.
*
* @param node The node that provides the raw data.
* @param content The node content where the function line is added.
* @param modifier Calculates the address strings. This argument can be null.
*/
private static void buildFunctionLine(final INaviCodeNode node, final ZyLabelContent content, final INodeModifier modifier) {
try {
final INaviFunction parentFunction = node.getParentFunction();
final String address = modifier == null ? parentFunction.getAddress().toHexString() : modifier.getAddress(parentFunction.getModule(), new UnrelocatedAddress(parentFunction.getAddress()), true);
final String name = parentFunction.getName();
content.addLineContent(new ZyLineContent(address + PADDING_AFTER_FUNCTION_ADDRESS + parentFunction.getModule().getConfiguration().getName() + "::" + name, BOLD_FONT, Lists.newArrayList(new CStyleRunData(0, -1, Color.BLACK)), null));
} catch (final MaybeNullException exception) {
// If there is no parent function, the parent function is not shown in the code node.
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class ZyCodeNodeBuilder method createLines.
/**
* Creates the instructions lines for a code node.
*
* @param node The node that provides the instructions.
* @param lines The created lines will be stored here.
* @param commentsToLineAssociation Information about the required comments is stored here.
* @param graphSettings Provides settings that influence node formatting.
* @param modifier Calculates the address strings. This argument can be null.
*
* @return The maximum size in characters of all lines put into the lines list.
*/
private static int createLines(final INaviCodeNode node, final List<Pair<String, List<CStyleRunData>>> lines, final HashMap<Pair<String, List<CStyleRunData>>, ArrayList<CommentContainer>> commentsToLineAssociation, final ZyGraphViewSettings graphSettings, final INodeModifier modifier) {
int maxLineWidth = 0;
final Map<INaviInstruction, INaviFunction> instructionToFunctionReferences = CReferenceFinder.getCodeReferenceMap(node);
for (final INaviInstruction instruction : node.getInstructions()) {
final Pair<String, List<CStyleRunData>> zyLineContent = ZyInstructionBuilder.buildInstructionLine(instruction, graphSettings, modifier);
final ArrayList<CommentContainer> commentLineContainerList = new ArrayList<CommentContainer>();
final List<IComment> localComments = node.getComments().getLocalInstructionComment(instruction);
if (localComments != null) {
for (final IComment localComment : localComments) {
commentLineContainerList.add(new CommentContainer(localComment));
}
}
final List<IComment> globalComments = instruction.getGlobalComment();
if (globalComments != null) {
for (final IComment globalComment : globalComments) {
commentLineContainerList.add(new CommentContainer(globalComment));
}
}
final List<IComment> functionComments = instructionToFunctionReferences.get(instruction) == null ? null : instructionToFunctionReferences.get(instruction).getGlobalComment();
if (functionComments != null) {
for (final IComment functionComment : functionComments) {
commentLineContainerList.add(new CommentContainer(functionComment));
}
}
commentsToLineAssociation.put(zyLineContent, commentLineContainerList);
final int lineWidth = zyLineContent.first().length();
if (lineWidth > maxLineWidth) {
maxLineWidth = lineWidth;
}
lines.add(zyLineContent);
}
return maxLineWidth;
}
Aggregations