use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTree in project binnavi by google.
the class PostgreSQLTypesNotificationParser method findOperandTreeNode.
/**
* Only used internally to find the necessary {@link INaviOperandTreeNode operand node} where a
* {@link TypeSubstitution type substitution} is associated to.
*
* @param provider The {@link SQLProvider} used to differentiate between the different caches used
* for getting {@link INaviInstruction instructions}.
* @param moduleId The id of the {@link INaviModule module} this {@link TypeSubstitution type
* substitution} is associated to.
* @param address The {@link CAddress} of the {@link INaviInstruction instruction} where the
* {@link TypeSubstitution type substitution} is associated to.
* @param position The {@link INaviOperandTree operand tree} position where the
* {@link TypeSubstitution type substitution} is associated to.
* @param operandNodeId the id of the {@link INaviOperandTreeNode operand node} to which the
* {@link TypeSubstitution type substitution} is associated.
* @return A {@link INaviOperandTreeNode} if it is in the cache otherwise null;
*/
private INaviOperandTreeNode findOperandTreeNode(final SQLProvider provider, final int moduleId, final CAddress address, final int position, final int operandNodeId) {
final INaviInstruction instruction = InstructionCache.get(provider).getInstructionByAddress(address, moduleId);
if (instruction != null) {
final INaviOperandTree operandTree = instruction.getOperands().get(position);
final INaviOperandTreeNode root = operandTree.getRootNode();
final OperandOrderIterator iterator = new OperandOrderIterator(root);
while (iterator.next()) {
final INaviOperandTreeNode currentNode = (INaviOperandTreeNode) iterator.current();
if (currentNode.getId() == operandNodeId) {
return currentNode;
}
}
}
return null;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTree in project binnavi by google.
the class CNodeClickHandler method nodeClicked.
/**
* Handles clicks on nodes.
*
* @param node The clicked node.
* @param event The click event.
* @param x The x-coordinate of the click.
* @param y The y-coordinate of the click.
* @param extensions List of objects that extend code node context menus.
*/
public void nodeClicked(final NaviNode node, final MouseEvent event, final double x, final double y, final List<ICodeNodeExtension> extensions) {
if (event.getButton() == MouseEvent.BUTTON3) {
handleRightClick(node, event, x, y, extensions);
} else if ((event.getButton() == MouseEvent.BUTTON1) && (event.getClickCount() == 2) && event.isControlDown()) {
final INaviViewNode rawNode = node.getRawNode();
if (rawNode instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) rawNode).getFunction();
CGraphOpener.showFunction(m_model.getParent(), m_model.getViewContainer(), function);
} else if (rawNode instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) rawNode;
final int row = node.positionToRow(y - node.getY());
final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(cnode, row);
if (instruction == null) {
return;
}
final Set<IAddress> references = new HashSet<IAddress>();
for (final INaviOperandTree operand : instruction.getOperands()) {
collectReferences(operand.getRootNode(), references);
}
final List<INaviFunction> functions = m_model.getViewContainer().getFunctions();
for (final INaviFunction function : functions) {
for (final IAddress address : references) {
if (function.getAddress().equals(address)) {
CGraphOpener.showFunction(m_model.getParent(), m_model.getViewContainer(), function);
}
}
}
}
} else if (!m_model.getGraph().getEditMode().getLabelEventHandler().isActive() && (event.getButton() == MouseEvent.BUTTON1) && (event.getClickCount() == 2)) {
if ((node.getRawNode() instanceof INaviGroupNode) && event.isShiftDown()) {
final INaviGroupNode gnode = (INaviGroupNode) node.getRawNode();
gnode.setCollapsed(!gnode.isCollapsed());
} else {
CGraphZoomer.zoomNode(m_model.getGraph(), node);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTree in project binnavi by google.
the class ZyOperandBuilder method buildOperands.
/**
* Builds the operands of an instruction.
*
* @param instruction The instruction in question.
* @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).
*/
public static void buildOperands(final INaviInstruction instruction, final ZyGraphViewSettings graphSettings, final StringBuffer line, final List<CStyleRunData> styleRun, final INodeModifier modifier) {
int counter = 0;
for (final INaviOperandTree operandTree : instruction.getOperands()) {
buildOperand(instruction, operandTree, graphSettings, line, styleRun, modifier, counter);
counter++;
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTree in project binnavi by google.
the class PostgreSQLTypeInstancesNotificationParser method informExpressionTypeInstanceNotification.
/**
* This function informs the {@link TypeInstanceContainer} about changes related to expression
* type instances also known as cross references for type instances.
*
* @param container The {@link TypeInstancesNotificationContainer} holding the parsed information.
* @param provider The {@link SQLProvider} used to access the database.
* @throws CouldntLoadDataException
*/
private void informExpressionTypeInstanceNotification(final TypeInstancesNotificationContainer container, final SQLProvider provider) throws CouldntLoadDataException {
final TypeInstanceContainer typeContainer = provider.findModule(container.getModuleId()).getContent().getTypeInstanceContainer();
if (container.getDatabaseOperation().equals("INSERT")) {
final TypeInstanceReference reference = typeContainer.loadInstanceReference(container.getTypeInstanceId(), container.getAddress().get(), container.getPosition().get(), container.getExpressionId().get());
final INaviInstruction instruction = InstructionCache.get(provider).getInstructionByAddress(reference.getAddress(), reference.getTypeInstance().getModule().getConfiguration().getId());
if (instruction != null) {
final INaviOperandTree operandTree = instruction.getOperands().get(reference.getPosition());
final INaviOperandTreeNode root = operandTree.getRootNode();
final OperandOrderIterator iterator = new OperandOrderIterator(root);
while (iterator.next()) {
final INaviOperandTreeNode currentNode = (INaviOperandTreeNode) iterator.current();
if (currentNode.getId() == container.getExpressionId().get()) {
typeContainer.initializeTypeInstanceReference(reference.getAddress(), reference.getPosition(), container.getTypeInstanceId(), currentNode);
break;
}
}
}
} else if (container.getDatabaseOperation().equals("UPDATE")) {
// currently not be possible at all.
} else if (container.getDatabaseOperation().equals("DELETE")) {
typeContainer.deleteReference(container.getTypeInstanceId(), container.getAddress().get(), container.getPosition().get(), container.getExpressionId().get());
} else {
throw new IllegalStateException("Error: the database operation " + container.getDatabaseOperation() + " is currently not supported.");
}
}
Aggregations