use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CCommentUtilities method getLocalInstructionComments.
/**
* TODO (timkornau): either comment the function or find a better way on how the commenting for
* instructions can access all comments.
*/
public static List<Pair<INaviInstruction, IComment>> getLocalInstructionComments(final CCodeNode codeNode) {
Preconditions.checkNotNull(codeNode, "IE02633: codeNode argument can not be null");
final List<Pair<INaviInstruction, IComment>> values = new ArrayList<Pair<INaviInstruction, IComment>>();
final CCodeNodeComments currentComments = codeNode.getComments();
for (final INaviInstruction instruction : codeNode.getInstructions()) {
final List<IComment> comments = currentComments.getLocalInstructionComment(instruction);
if ((comments == null) || comments.isEmpty()) {
values.add(new Pair<INaviInstruction, IComment>(instruction, null));
continue;
} else {
for (final IComment comment : comments) {
values.add(new Pair<INaviInstruction, IComment>(instruction, comment));
}
}
}
return values;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CRegisterTrackingHelper method getInstructionMap.
/**
* Creates an address -> instruction mapping for all instructions in a graph.
*
* @param view The input graph.
* @return The created mapping.
*/
public static Map<IAddress, INaviInstruction> getInstructionMap(final INaviView view) {
final Map<IAddress, INaviInstruction> instructionMap = new HashMap<IAddress, INaviInstruction>();
final List<INaviViewNode> nodes = view.getGraph().getNodes();
for (final INaviViewNode node : nodes) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) node;
for (final INaviInstruction instruction : cnode.getInstructions()) {
instructionMap.put(instruction.getAddress(), instruction);
}
}
}
return instructionMap;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class InstructionCommentsDataModel method keyPressedOrTyped.
@Override
public /**
* Please read the comment in the base class regarding this method - it is somewhat counter-
* intuitive for people used to the Swing keyboard handling model.
*/
void keyPressedOrTyped(CodeDisplayCoordinate coordinate, KeyEvent event) {
if (!isEditable(coordinate)) {
return;
}
// Are there any existing comments?
INaviInstruction instruction = internalData.get(coordinate.getRow()).first();
Pair<IComment, Pair<Integer, Integer>> commentAndIndex = getCommentAndIndexAtCoordinate(coordinate);
IComment comment = commentAndIndex.first();
Pair<Integer, Integer> indices = commentAndIndex.second();
switch(event.getKeyCode()) {
// VK_UNDEFINED implies that this was a KEY_TYPED event.
case KeyEvent.VK_UNDEFINED:
switch(event.getKeyChar()) {
case java.awt.Event.ENTER:
handleRegularKeyInComment(instruction, comment, indices, coordinate, event);
coordinate.setLine(coordinate.getLine() + 1);
coordinate.setFieldIndex(0);
break;
case java.awt.Event.BACK_SPACE:
handleBackspaceKeyInComment(instruction, comment, indices, coordinate);
break;
case java.awt.Event.DELETE:
handleDeleteKeyInComment(instruction, comment, indices, coordinate);
break;
default:
handleRegularKeyInComment(instruction, comment, indices, coordinate, event);
coordinate.setFieldIndex(coordinate.getFieldIndex() + 1);
break;
}
break;
case KeyEvent.VK_HOME:
coordinate.setFieldIndex(0);
break;
case KeyEvent.VK_END:
coordinate.setFieldIndex(indices.second() - indices.first());
break;
default:
Logger.warning("Default case in keyTyped hit, investigate why.");
break;
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class InstructionCommentsDataModel method updateDataRepresentation.
private void updateDataRepresentation() {
internalData.clear();
for (INaviInstruction instruction : node.getInstructions()) {
internalData.add(new Pair<INaviInstruction, ArrayList<IComment>>(instruction, new ArrayList<IComment>()));
}
int currentIndex = 0;
for (Pair<INaviInstruction, IComment> dataPair : commentAccessor.getAllComments()) {
// Is this the right instruction?
while (dataPair.first() != internalData.get(currentIndex).first()) {
currentIndex++;
}
internalData.get(currentIndex).second().add(dataPair.second());
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CReferenceFinder method fetchReferenceList.
/**
* Searches for outgoing references of a tree node and its children.
*
* @param node The start node of the search,
* @param instruction The instruction the node belongs to.
* @param functions List where the found references are stored.
*/
private static void fetchReferenceList(final IOperandTreeNode node, final INaviInstruction instruction, final List<Pair<INaviInstruction, INaviFunction>> functions) {
final List<IReference> references = node.getReferences();
for (final IReference reference : references) {
if (ReferenceType.isCodeReference(reference.getType())) {
final IAddress target = reference.getTarget();
final INaviFunction function = instruction.getModule().getContent().getFunctionContainer().getFunction(target);
if (function != null) {
functions.add(new Pair<INaviInstruction, INaviFunction>(instruction, function));
}
}
}
for (final IOperandTreeNode child : node.getChildren()) {
fetchReferenceList(child, instruction, functions);
}
}
Aggregations