use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLTypesNotificationParser method informExpressionTypesNotification.
/**
* Informs about necessary state changes related to {@link TypeSubstitution type substitutions}.
*
* @param container The {@link TypesNotificationContainer} holding the parsed
* {@link PGNotification notification} information.
* @param provider The {@link SQLProvider} used to access the database with.
*
* @throws CouldntLoadDataException if the required information could not be loaded from the
* database.
*/
private void informExpressionTypesNotification(final TypesNotificationContainer container, final SQLProvider provider) throws CouldntLoadDataException {
final INaviModule module = provider.findModule(container.getModuleId());
final TypeManager typeManager = module.getTypeManager();
final INaviOperandTreeNode node = findOperandTreeNode(provider, container.getModuleId(), new CAddress(container.getAddress().get()), container.position().get(), container.expressionId().get());
if (node == null) {
return;
}
if (container.getDatabaseOperation().equals("INSERT")) {
final RawTypeSubstitution rawSubstitution = provider.loadTypeSubstitution(module, container.getAddress().get(), container.position().get(), container.expressionId().get());
typeManager.initializeTypeSubstitution(node, rawSubstitution);
} else if (container.getDatabaseOperation().equals("UPDATE")) {
final RawTypeSubstitution rawSubstitution = provider.loadTypeSubstitution(module, container.getAddress().get(), container.position().get(), container.expressionId().get());
typeManager.updateTypeSubstitution(node, rawSubstitution.getBaseTypeId(), rawSubstitution.getPath(), rawSubstitution.getOffset());
} else if (container.getDatabaseOperation().equals("DELETE")) {
typeManager.removeTypeSubstitutionInstance(node.getTypeSubstitution());
} else {
throw new IllegalStateException("Error: the database operation " + container.getDatabaseOperation() + " is currently not supported.");
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLViewNotificationParser method parseModuleViewNotification.
/**
* Parser for a bn_module_views notification. The function uses the moduleViewNotificationPattern
* to parse the incoming {@link PGNotification} into a {@link ViewNotificationContainer}.
*
* @param notification The {@link PGNotification} to parse.
* @param provider The {@link SQLProvider} to access the database.
*
* @return A {@link ViewNotificationContainer} with the parsed information.
*/
private ViewNotificationContainer parseModuleViewNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = moduleViewNotificationPattern.matcher(notification.getParameter());
if (!matcher.find()) {
throw new IllegalStateException("IE02743: compiled pattern: " + moduleViewNotificationPattern.toString() + " did not match notification: " + notification.getParameter());
}
final Integer viewId = Integer.parseInt(matcher.group(3));
final Optional<INaviView> view = Optional.fromNullable(ViewManager.get(provider).getView(viewId));
final Optional<Integer> moduleId = Optional.fromNullable(Integer.parseInt(matcher.group(4)));
final Optional<INaviModule> module = Optional.fromNullable(provider.findModule(moduleId.get()));
final String databaseOperation = matcher.group(2);
return new ViewNotificationContainer(viewId, view, moduleId, module, Optional.<INaviProject>absent(), databaseOperation);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CCodeNodeMenu method addOperandTreeNodeMenu.
/**
* Adds menus for the clicked operand.
*
* @param model The graph model that provides information about the graph.
* @param treeNode The clicked operand node.
* @param extensions The extension menu items for the "Operands" menu.
* @param instruction The instruction that was clicked.
* @param node The basic block that contains the clicked instruction.
*/
private void addOperandTreeNodeMenu(final CGraphModel model, final COperandTreeNode treeNode, final NaviNode node, final INaviInstruction instruction, final List<ICodeNodeExtension> extensions) {
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
final INaviModule module = model.getViewContainer().getModules().get(0);
// We only show the goto address if we have no associated type instance for the given immediate.
if (treeNode.getType() == ExpressionType.IMMEDIATE_INTEGER && treeNode.getTypeInstanceReferences().isEmpty()) {
addImmediateOperandMenu(treeNode, module.getContent().getSections(), module);
}
if (treeNode.getType() == ExpressionType.REGISTER) {
addRegisterOperandMenu(model, treeNode, instruction, extensions, codeNode);
}
final INaviReplacement replacement = treeNode.getReplacement();
// precedence over type instances.
if (!treeNode.getTypeInstanceReferences().isEmpty() && !(replacement instanceof CFunctionReplacement)) {
addInstanceReferenceMenu(model, treeNode);
}
if (replacement instanceof CFunctionReplacement) {
addFunctionOperandMenu(model, replacement);
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CCodeNodeMenu method addInstanceReferenceMenu.
private void addInstanceReferenceMenu(final CGraphModel model, final COperandTreeNode treeNode) {
// We can possibly have more than one reference for a single tree node if we have multiple
// instances of the same section.
final INaviModule module = model.getViewContainer().getModules().get(0);
final List<TypeInstanceReference> references = treeNode.getTypeInstanceReferences();
add(new ShowTypeInstanceReferencesAction(model.getParent(), references, module));
add(new GotoTypeInstanceAction(references.get(0).getTypeInstance()));
add(new RenameTypeInstanceAction(model.getParent(), module.getContent().getTypeInstanceContainer(), references.get(0).getTypeInstance()));
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule 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);
}
}
Aggregations