use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class ViewTest method setUp.
@SuppressWarnings("deprecation")
@Before
public void setUp() throws LoadCancelledException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException, FileReadException, CouldntLoadDataException {
ConfigManager.instance().read();
final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
final CTagManager internalTagManager = new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, m_provider))), TagType.VIEW_TAG, m_provider);
m_viewTagManager = new TagManager(internalTagManager);
final Database database = new Database(new MockDatabase());
internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, m_provider);
internalModule.load();
module = new Module(database, internalModule, tagManager, m_viewTagManager);
final Calendar cal = Calendar.getInstance();
cal.setTime(module.getModificationDate());
cal.add(Calendar.DATE, 1);
m_modificationDate = cal.getTime();
m_creationDate = new Date();
final ITreeNode<CTag> tag = internalTagManager.addTag(internalTagManager.getRootTag(), "foo");
final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, internalModule);
final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, m_creationDate, m_modificationDate, 1, 2, Sets.newHashSet(tag.getObject()), new HashSet<CTag>(), false);
m_view = new View(module, internalView, tagManager, m_viewTagManager);
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLViewNotificationParser method informProjectNotification.
/**
* The inform function for notifications from the bn_project_views table. This function is used
* when a project view is created or deleted.
*
* @param projectNotificationContainer The {@link ViewNotificationContainer} to use as data
* source.
* @param provider The {@link SQLProvider} to access the database.
* @throws CouldntLoadDataException if the information could not be loaded from the database.
*/
private void informProjectNotification(final ViewNotificationContainer projectNotificationContainer, final SQLProvider provider) throws CouldntLoadDataException {
if (projectNotificationContainer.getDatabaseOperation().equals("INSERT")) {
final INaviProject project = projectNotificationContainer.getNotificationProject().get();
if (!project.isLoaded()) {
return;
}
final Integer viewId = projectNotificationContainer.getViewId();
final ImmutableNaviViewConfiguration databaseViewConfiguration = provider.loadFlowGraphInformation(project, viewId);
final CProjectViewGenerator generator = new CProjectViewGenerator(provider, project);
final INaviView view = generator.generate(databaseViewConfiguration);
project.getContent().addView(view);
}
if (projectNotificationContainer.getDatabaseOperation().equals("UPDATE")) {
// updates will not happen as this is only a mapping of id to id.
return;
}
if (projectNotificationContainer.getDatabaseOperation().equals("DELETE")) {
final INaviProject project = projectNotificationContainer.getNotificationProject().get();
if (!project.isLoaded()) {
return;
}
final Integer viewId = projectNotificationContainer.getViewId();
final INaviView view = ViewManager.get(provider).getView(viewId);
project.getContent().deleteViewInternal(view);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView 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.views.INaviView in project binnavi by google.
the class PostgreSQLViewNotificationParser method parseViewNotification.
/**
* Parser for a bn_views notification. The function uses the viewNotificationPattern 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 parseViewNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = viewNotificationPattern.matcher(notification.getParameter());
if (!matcher.find()) {
throw new IllegalStateException("IE02742: compiled pattern: " + viewNotificationPattern.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 String databaseOperation = matcher.group(2);
return new ViewNotificationContainer(viewId, view, Optional.<Integer>absent(), Optional.<INaviModule>absent(), Optional.<INaviProject>absent(), databaseOperation);
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CCodeNodeMenu method addFunctionOperandMenu.
private void addFunctionOperandMenu(final CGraphModel model, final INaviReplacement replacement) {
final INaviFunction function = ((CFunctionReplacement) replacement).getFunction();
final INaviView view = function.getModule().getContent().getViewContainer().getView(function);
add(new CChangeFunctionNameAction(model.getParent(), view));
addSeparator();
}
Aggregations