use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLViewNotificationParser method parseProjectViewNotification.
/**
* Parser for the bn_project_views notification. The function uses the
* projectViewNotificationPattern 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.
*/
private ViewNotificationContainer parseProjectViewNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = projectViewNotificationPattern.matcher(notification.getParameter());
if (!matcher.find()) {
throw new IllegalStateException("IE02744: compiled pattern: " + projectViewNotificationPattern.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> projectId = Optional.fromNullable(Integer.parseInt(matcher.group(4)));
final Optional<INaviProject> project = Optional.fromNullable(provider.findProject(projectId.get()));
final String databaseOperation = matcher.group(2);
return new ViewNotificationContainer(viewId, view, projectId, Optional.<INaviModule>absent(), project, databaseOperation);
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLHelpers method getViewsWithAddress.
/**
* Searches for the views with a given address.
*
* @param connection Connection to a SQL database.
* @param query SQL query to issue for the search.
* @param columnName Name of the column from which the container ID is read.
* @param finder Finder object that is used to find the view object from a view ID.
*
* @return A list of views that was found by the query.
*
* @throws CouldntLoadDataException Thrown if the search failed with an error.
*/
// TODO (timkornau): find out if there is a better way to have the sql query build in here rather
// then in the caller.
// It just seems to be wrong like this.
public static IFilledList<INaviView> getViewsWithAddress(final CConnection connection, final String query, final String columnName, final ContainerFinder finder) throws CouldntLoadDataException {
Preconditions.checkNotNull(finder, "IE00607: Finder argument can not be null");
Preconditions.checkNotNull(columnName, "IE00608: Column name argument can not be null");
Preconditions.checkNotNull(query, "IE00627: Query argument can not be null");
Preconditions.checkNotNull(connection, "IE00628: Connection argument can not be null");
final IFilledList<INaviView> views = new FilledList<INaviView>();
try (ResultSet resultSet = connection.executeQuery(query, true)) {
while (resultSet.next()) {
final int containerId = resultSet.getInt(columnName);
final int viewId = resultSet.getInt("view_id");
final INaviView view = finder.findView(containerId, viewId);
views.add(view);
}
return views;
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CGraphOpener method showFunction.
/**
* Opens a function in a new graph window.
*
* @param parent The window where the new graph is shown.
* @param container The container the new graph belongs to.
* @param function The function to be shown.
*/
public static void showFunction(final CGraphWindow parent, final IViewContainer container, final INaviFunction function) {
final INaviModule module = function.getModule();
final INaviView view = module.getContent().getViewContainer().getView(function);
CViewOpener.showView(parent, container, view, parent);
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CGraphSaver method saveAs.
/**
* Prompts the user for a new graph description and stores a copy of the graph in the database.
*
* @param parent Parent window used to display dialogs.
* @param graph Graph to be written to the database.
* @param container View container the graph is written to.
*
* @return Information about the save progress.
*/
public static CSaveProgress saveAs(final Window parent, final ZyGraph graph, final IViewContainer container) {
Preconditions.checkNotNull(parent, "IE01754: Parent argument can not be null");
Preconditions.checkNotNull(graph, "IE01755: Graph argument can not be null");
final INaviView view = graph.getRawView();
final CViewCommentDialog dlg = new CViewCommentDialog(parent, "Save", view.getName(), view.getConfiguration().getDescription());
dlg.setVisible(true);
if (dlg.wasCancelled()) {
return new CSaveProgress(true);
}
final String newName = dlg.getName();
final String newDescription = dlg.getComment();
final CSaveProgress progress = new CSaveProgress(false);
new Thread() {
@Override
public void run() {
final CViewSaverOperation operation = new CViewSaverOperation(String.format("Saving view '%s'", newName));
try {
if (graph.saveAs(container, newName, newDescription) == null) {
throw new CouldntSaveDataException("Failure saving the view.");
}
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00121: " + "Could not save graph";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be saved.", newName), new String[] { "There was a problem with the database connection." }, new String[] { "The new view was not created." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
} finally {
operation.stop();
progress.setDone();
}
}
}.start();
return progress;
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CGraphFunctions method showDataflowGraph.
/**
* Creates a new view that shows the data flow graph of a view.
*
* @param parent Window where the new view is shown.
* @param container Container where the new view is created.
* @param view The view whose data flow graph is created.
*/
public static void showDataflowGraph(final CGraphWindow parent, final IViewContainer container, final INaviView view) {
try {
final INaviView dataflowView = CDataflowViewCreator.create(container, view);
CViewOpener.showView(parent, container, dataflowView, parent);
} catch (final InternalTranslationException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00110: " + "Could not create dataflow graph";
final String innerDescription = CUtilityFunctions.createDescription(String.format("BinNavi could not create the data flow graph of view '%s'.", view.getName()), new String[] { "An error occurred in the REIL translator code." }, new String[] { "This is an internal error which you can not fix yourself. " + "Please report the bug to the zynamics support team." });
NaviErrorDialog.show(parent, innerMessage, innerDescription);
}
}
Aggregations