use of com.google.security.zynamics.binnavi.config.ColorsConfigItem in project binnavi by google.
the class ZyNodeBuilder method addCommentLines.
/**
* Adds the local and global comment strings to the label content.
*
* @param content The label content the comment strings are added to.
* @param edge The clicked edge.
* @param localComment The local comment string that is added to the label content.
* @param globalComment The global comment string that is added to the label content.
*/
public static void addCommentLines(final ZyLabelContent content, final INaviEdge edge, final List<IComment> localComment, final List<IComment> globalComment) {
Preconditions.checkNotNull(content, "IE00914: Content argument can't be null");
final ColorsConfigItem colors = ConfigManager.instance().getColorSettings();
if (localComment != null) {
addCommentLines(content, localComment, colors.getLocalCommentColor(), new CLocalEdgeCommentWrapper(edge));
}
if (globalComment != null) {
addCommentLines(content, globalComment, colors.getGlobalCommentColor(), new CGlobalEdgeCommentWrapper(edge));
}
}
use of com.google.security.zynamics.binnavi.config.ColorsConfigItem in project binnavi by google.
the class ZyOperandBuilder method buildOperand.
/**
* Builds a single operand.
*
* @param instruction The instruction in question.
* @param operandTree Provides information about the operand to build.
* @param graphSettings Provides the graph settings.
* @param line String buffer where the operands string is added.
* @param styleRun Style runs list where the formatting information is added.
* @param modifier Calculates the address string (this argument can be null).
* @param counter The index of the operand in the operands list of the instruction.
*/
private static void buildOperand(final INaviInstruction instruction, final INaviOperandTree operandTree, final ZyGraphViewSettings graphSettings, final StringBuffer line, final List<CStyleRunData> styleRun, final INodeModifier modifier, final int counter) {
// We use an iterator that gives us the individual operands in correct (printing) order.
final OperandOrderIterator iter = new OperandOrderIterator(operandTree.getRootNode());
final boolean isVariableAccess = graphSettings.getDisplaySettings().getSimplifiedVariableAccess() && isVariableAccess(operandTree.getRootNode());
boolean hasMemderef = false;
boolean hasExpressionList = false;
boolean needsComma = false;
boolean hasExclamationMark = false;
COperandTreeNode memParent = null;
final ColorsConfigItem colors = ConfigManager.instance().getColorSettings();
while (iter.next()) {
if (isVariableAccess) {
skipMemoryAccess(iter);
}
// Process the next operand part
final COperandTreeNode treeNode = (COperandTreeNode) iter.current();
hasExclamationMark = "!".equals(treeNode.getValue());
if (skipOperand(treeNode, hasExpressionList)) {
continue;
}
if (needsComma) {
styleRun.add(new CStyleRunData(line.length(), 1, colors.getOperandSeparatorColor()));
line.append(',');
}
if (hasExpressionList) {
needsComma = true;
}
if (hasMemderef && !isAncestor(treeNode, memParent)) {
// Since closing "]" characters are not part of the operand trees,
// we have to handle memory dereference brackets manually.
styleRun.add(new CStyleRunData(line.length(), 1, colors.getMemRefColor()));
line.append(']');
hasMemderef = false;
}
hasExpressionList = (treeNode.getType() == ExpressionType.EXPRESSION_LIST) || hasExpressionList;
if (treeNode.getType() == ExpressionType.MEMDEREF) {
memParent = treeNode;
hasMemderef = true;
}
addOperand(line, styleRun, treeNode, modifier);
}
addClosingDelimiters(line, styleRun, hasMemderef, hasExpressionList, hasExclamationMark);
addCommaSeparator(line, styleRun, instruction.getOperands(), counter);
}
use of com.google.security.zynamics.binnavi.config.ColorsConfigItem in project binnavi by google.
the class ZyOperandBuilder method addClosingDelimiters.
/**
* Adds closing delimiters to a line if necessary. This is necessary because for certain opening
* delimiters, the closing delimiter is not actually part of the operand tree as stored in the
* database.
*
* @param line The closing delimiter is added to this string.
* @param styleRuns The style run for the closing delimiter is added to this list.
* @param hasMemderef True, if a memory dereference delimiter should be added.
* @param hasExpressionList True, if an expression list delimiter should be added.
* @param hasExclamationMark True, if an exclamation mark delimiter should be added.
*/
private static void addClosingDelimiters(final StringBuffer line, final List<CStyleRunData> styleRuns, final boolean hasMemderef, final boolean hasExpressionList, final boolean hasExclamationMark) {
// TODO(timkornau): Figure out if more than one of the boolean arguments can be true at any
// given invocation.
final ColorsConfigItem colors = ConfigManager.instance().getColorSettings();
if (hasMemderef) {
// Since closing "]" characters are not part of the operand trees,
// we have to handle memory dereference brackets manually.
styleRuns.add(new CStyleRunData(line.length(), 1, colors.getMemRefColor()));
line.append(']');
}
if (hasExpressionList) {
// Since closing "}" characters are not part of the operand trees,
// we have to handle expression list braces manually.
styleRuns.add(new CStyleRunData(line.length(), 1, colors.getExpressionListColor()));
line.append('}');
}
if (hasExclamationMark) {
styleRuns.add(new CStyleRunData(line.length(), 1, colors.getOperatorColor()));
line.append('!');
}
}
use of com.google.security.zynamics.binnavi.config.ColorsConfigItem in project binnavi by google.
the class ZyOperandBuilder method addOperand.
/**
* Adds an operand to the instruction line.
*
* @param line The operand is added to this string.
* @param styleRuns The style run for the operand is added to this list.
* @param treeNode Provides the operand information.
* @param modifier Calculates the address string (this argument can be null).
*/
private static void addOperand(final StringBuffer line, final List<CStyleRunData> styleRuns, final COperandTreeNode treeNode, final INodeModifier modifier) {
final ColorsConfigItem colors = ConfigManager.instance().getColorSettings();
final String typeSubstitution = getTypeSubstitution(treeNode);
if (!typeSubstitution.isEmpty()) {
// TODO(jannewger): we might want to introduce an additional setting so the user is able to
// customize the way types are displayed.
styleRuns.add(new CStyleRunData(line.length(), typeSubstitution.length(), colors.getVariableColor(), treeNode));
line.append(typeSubstitution);
return;
}
final IReplacement replacement = treeNode.getDisplayStyle() == OperandDisplayStyle.OFFSET ? treeNode.getReplacement() : null;
// Colorize the current part of the operand
if (replacement == null) {
final Color color = getOperandColor(treeNode.getType());
final String value = adjustValue(treeNode, modifier);
styleRuns.add(new CStyleRunData(line.length(), value.length(), color, treeNode));
line.append(value);
} else {
final String replacementString = determineReplacementString(treeNode, replacement);
if (replacementString.equalsIgnoreCase("")) {
final Color color = getOperandColor(treeNode.getType());
final String value = adjustValue(treeNode, modifier);
styleRuns.add(new CStyleRunData(line.length(), value.length(), color, treeNode));
line.append(value);
return;
}
if (treeNode.getType() == ExpressionType.IMMEDIATE_INTEGER) {
if (replacement instanceof CFunctionReplacement) {
styleRuns.add(new CStyleRunData(line.length(), replacementString.length(), colors.getFunctionColor(), treeNode));
} else {
styleRuns.add(new CStyleRunData(line.length(), replacementString.length(), colors.getVariableColor(), treeNode));
}
} else {
final Color color = getOperandColor(treeNode.getType());
styleRuns.add(new CStyleRunData(line.length(), replacementString.length(), color, treeNode));
}
line.append(replacementString);
}
}
use of com.google.security.zynamics.binnavi.config.ColorsConfigItem in project binnavi by google.
the class CColorSettingsPanel method save.
@Override
protected boolean save() {
final ColorsConfigItem colors = ConfigManager.instance().getColorSettings();
colors.setNormalFunctionColor(m_normalFunctionColorPanel.getColor());
colors.setImportedFunctionColor(m_importFunctionColorPanel.getColor());
colors.setLibraryFunctionColor(m_libraryFunctionColorPanel.getColor());
colors.setThunkFunctionColor(m_thunkFunctionColorPanel.getColor());
colors.setAdjustorThunkFunctionColor(m_adjustorThunkFunctionColorPanel.getColor());
colors.setAddressColor(m_addressColorPanel.getColor());
colors.setMnemonicColor(m_mnemonicColorPanel.getColor());
colors.setImmediateColor(m_literalsColorPanel.getColor());
colors.setRegisterColor(m_registersColorPanel.getColor());
colors.setFunctionColor(m_functionColorPanel.getColor());
colors.setVariableColor(m_variableColorPanel.getColor());
colors.setExpressionListColor(m_expressionListColorPanel.getColor());
colors.setMemRefColor(m_memoryReferencesColorPanel.getColor());
colors.setOperatorColor(m_operatorColorPanel.getColor());
colors.setOperandSeperatorColor(m_operandSeparatorColorPanel.getColor());
colors.setPrefixColor(m_prefixColorPanel.getColor());
colors.setAddressColor(m_addressColorPanel.getColor());
colors.setBasicBlocksColor(m_basicblocksPanel.getColor());
colors.setUnconditionalJumpColor(m_unconditionalJumpsPanel.getColor());
colors.setConditionalJumpTrueColor(m_conditionalJumpsTakenPanel.getColor());
colors.setConditionalJumpFalseColor(m_conditionalJumpsNotTakenPanel.getColor());
colors.setEnterInlinedJumpColor(m_enterInlinedJumpsPanel.getColor());
colors.setLeaveInlinedJumpColor(m_leaveInlinedJumpsPanel.getColor());
colors.setSwitchJumpColor(m_switchPanel.getColor());
colors.setTextEdgeColor(m_textJumpsPanel.getColor());
final DebugColorsConfigItem debuggerColors = ConfigManager.instance().getDebuggerColorSettings();
debuggerColors.setActiveLine(m_activeLineColorPanel.getColor());
debuggerColors.setBreakpointActive(m_activeBreakpointColorPanel.getColor());
debuggerColors.setBreakpointInactive(m_inactiveBreakpointColorPanel.getColor());
debuggerColors.setBreakpointEnabled(m_enabledBreakpointColorPanel.getColor());
debuggerColors.setBreakpointDisabled(m_disabledBreakpointColorPanel.getColor());
debuggerColors.setBreakpointInvalid(m_invalidBreakpointColorPanel.getColor());
debuggerColors.setBreakpointDeleting(m_deletingBreakpointColorPanel.getColor());
debuggerColors.setBreakpointHit(m_hitBreakpointColorPanel.getColor());
return false;
}
Aggregations