use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsAddReference5.
@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference5() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
final IAddress address = instruction.getAddress();
PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, null);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class TypeInstanceContainerBackend method loadTypeInstanceReferences.
/**
* Loads all type instance references for the module this {@link TypeInstanceContainerBackend} was
* initialized with.
*
* @return A {@link List} of {@link TypeInstanceReference references} loaded from the database.
*
* @throws CouldntLoadDataException if the data could not be loaded from the database.
*/
public List<TypeInstanceReference> loadTypeInstanceReferences() throws CouldntLoadDataException {
final List<RawTypeInstanceReference> rawReferences = provider.loadTypeInstanceReferences(module);
final List<TypeInstanceReference> references = Lists.newArrayList();
for (final RawTypeInstanceReference rawReference : rawReferences) {
final TypeInstance typeInstance = instancesById.get(rawReference.getTypeInstanceId());
final INaviView view = ViewManager.get(provider).getView(rawReference.getViewId());
if (view != null) {
final Optional<INaviOperandTreeNode> node = Optional.absent();
final IAddress address = rawReference.getAddress();
final int position = rawReference.getOperandPosition();
final int expressionId = rawReference.getExpressionId();
final TypeInstanceReference reference = new TypeInstanceReference(address, position, node, typeInstance, view);
references.add(reference);
referenceLookup.put(new InstanceReferenceLookup(address, position, expressionId), reference);
}
}
return references;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsAddReference4.
@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
PostgreSQLInstructionFunctions.addReference(getProvider(), node, null, null);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class ZyGraphDragAndDropSupport method handleDragOver.
private void handleDragOver(final Point location) {
final DragOverState state = getDragOverState(graph, location);
final NaviNode node = state.getNode();
if (node != null && state.getDragOverObject() != null) {
final Object object = state.getDragOverObject().getObject();
if (object instanceof INaviOperandTreeNode && ((INaviOperandTreeNode) object).getType() == ExpressionType.REGISTER) {
final int row = node.positionToRow(graph.getView().toWorldCoordY(location.y) - node.getY());
if (row != -1) {
clearHighlighting(node);
lastRow = row;
final ObjectWrapper wrapper = state.getDragOverObject();
node.setHighlighting(HIGHLIGHTING_LEVEL, row, wrapper.getStart(), wrapper.getLength(), HIGHLIGHTING_COLOR);
}
}
} else {
clearHighlighting(null);
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode 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