use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException in project binnavi by google.
the class CGraphInliner method getFunctionToInline.
/**
* Determines the function to inline with consideration of function forwarding.
*
* @param parent Parent window used for dialogs.
* @param viewContainer Contains the function to inline.
* @param function The function to be inlined.
* @param forwarderModuleId Module ID of the module the function is forwarded to.
* @param forwarderAddress Address of the function the function is forwarded to. This argument can
* be null.
*
* @return The function to be inlined.
*/
private static INaviFunction getFunctionToInline(final JFrame parent, final IViewContainer viewContainer, final INaviFunction function, final int forwarderModuleId, final IAddress forwarderAddress) {
if (forwarderAddress == null) {
return function;
} else {
final IDatabase database = viewContainer.getDatabase();
final INaviModule module = database.getContent().getModule(forwarderModuleId);
if (!viewContainer.containsModule(module)) {
CMessageBox.showInformation(parent, String.format("You are trying to inline an external function into a module view. " + "This is not possible.\n" + "To inline external functions it is necessary to create projects."));
return null;
}
if (!module.isLoaded()) {
try {
module.load();
} catch (final CouldntLoadDataException | LoadCancelledException e) {
CUtilityFunctions.logException(e);
return null;
}
}
return module.getContent().getFunctionContainer().getFunction(forwarderAddress);
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException in project binnavi by google.
the class CProject method load.
@Override
public void load() throws CouldntLoadDataException, LoadCancelledException {
synchronized (m_loadReporter) {
if (isLoaded()) {
return;
}
m_isLoading = true;
try {
if (!m_loadReporter.report(ProjectLoadEvents.Starting)) {
throw new LoadCancelledException();
}
if (!m_loadReporter.report(ProjectLoadEvents.LoadingAddressSpaces)) {
throw new LoadCancelledException();
}
final List<CAddressSpace> addressSpaces = m_provider.loadAddressSpaces(this);
for (final CAddressSpace space : addressSpaces) {
space.load();
}
if (!m_loadReporter.report(ProjectLoadEvents.LoadingCallgraphViews)) {
throw new LoadCancelledException();
}
final List<ICallgraphView> userCallgraphs = m_provider.loadCallgraphViews(this);
if (!m_loadReporter.report(ProjectLoadEvents.LoadingFlowgraphViews)) {
throw new LoadCancelledException();
}
final List<IFlowgraphView> userFlowgraphs = m_provider.loadFlowgraphs(this);
if (!m_loadReporter.report(ProjectLoadEvents.LoadingMixedgraphViews)) {
throw new LoadCancelledException();
}
final List<INaviView> userMixedgraphs = m_provider.loadMixedgraphs(this);
if (!m_loadReporter.report(ProjectLoadEvents.LoadingTraces)) {
throw new LoadCancelledException();
}
final List<TraceList> traces = m_provider.loadTraces(this);
final ArrayList<INaviView> views = new ArrayList<INaviView>(userCallgraphs);
views.addAll(userFlowgraphs);
views.addAll(userMixedgraphs);
m_content = new CProjectContent(this, m_listeners, m_provider, addressSpaces, views, new FilledList<TraceList>(traces));
} catch (CouldntLoadDataException | LoadCancelledException e) {
m_isLoading = false;
throw e;
} finally {
m_loadReporter.report(ProjectLoadEvents.Finished);
}
for (final IProjectListener listener : m_listeners) {
try {
listener.loadedProject(this);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
m_isLoading = false;
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException in project binnavi by google.
the class CDatabase method connect.
@Override
public void connect() throws CouldntLoadDriverException, CouldntConnectException, InvalidDatabaseException, CouldntInitializeDatabaseException, InvalidExporterDatabaseFormatException, LoadCancelledException {
loadReporter.start();
isConnecting = true;
try {
final Pair<CConnection, SQLProvider> connectionData = CDatabaseConnection.connect(description, loadReporter);
provider = connectionData.second();
} catch (final CouldntLoadDriverException exception) {
loadReporter.report(LoadEvents.LOADING_FINISHED);
throw exception;
} catch (final CouldntConnectException exception) {
loadReporter.report(LoadEvents.LOADING_FINISHED);
throw exception;
} catch (final CouldntInitializeDatabaseException exception) {
loadReporter.report(LoadEvents.LOADING_FINISHED);
throw exception;
} catch (final InvalidDatabaseException exception) {
loadReporter.report(LoadEvents.LOADING_FINISHED);
throw exception;
} catch (final InvalidExporterDatabaseFormatException exception) {
loadReporter.report(LoadEvents.LOADING_FINISHED);
throw exception;
} catch (final LoadCancelledException exception) {
loadReporter.report(LoadEvents.LOADING_FINISHED);
throw exception;
} finally {
isConnecting = false;
}
for (final IDatabaseListener listener : listeners) {
try {
listener.openedDatabase(this);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
try {
final PostgreSQLNotificationProvider notificationProvider = PostgreSQLNotificationProvider.initialize(provider, description);
notificationProvider.listen(NotificationChannel.all());
notificationProvider.startPolling();
} catch (final SQLException exception) {
NaviLogger.severe("Error: Could not establish a channel for receiving notifications from the database %s", exception);
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException in project binnavi by google.
the class CModuleLoader method loadModuleInternal.
/**
* Loads a module inside a thread.
*
* @param parent Parent window used for dialogs.
* @param module Module to load.
* @param projectTree Project tree to expand on module loading. This argument can be null.
*/
private static void loadModuleInternal(final Window parent, final INaviModule module, final JTree projectTree) {
final CModuleLoaderOperation operation = new CModuleLoaderOperation(module);
boolean success = false;
try {
if (projectTree != null) {
// Make sure the lazy UI components responsible for displaying data etc.
// are properly initialized. Order is important - this has to happen
// BEFORE module.load() is called, so that all the listeners in the UI
// component already exist and can hence be filled by the module loading.
CNodeExpander.findNode(projectTree, module).getComponent();
}
module.load();
success = true;
if (projectTree != null) {
new SwingInvoker() {
@Override
protected void operation() {
CNodeExpander.expandNode(projectTree, module);
operation.stop();
}
}.invokeLater();
}
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
final String message = "E00177: " + "Module data could not be loaded";
final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not load the module '%s'.", module.getConfiguration().getName()), new String[] { "The connection dropped while the data was loaded." }, new String[] { "BinNavi can not open the module. To fix this situation try " + "to load the module again. Restart BinNavi if necessary and contact " + "the BinNavi support if the problem persists." });
NaviErrorDialog.show(parent, message, description, exception);
} catch (final LoadCancelledException e) {
// Don't show the user that he cancelled the operation.
} finally {
if (!success) {
operation.stop();
}
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException in project binnavi by google.
the class CModuleFunctions method copyView.
/**
* Copies a view into a module view.
*
* @param parent Parent window used for dialogs.
* @param module Module where the copied view is stored.
* @param view The view to copy.
*/
public static void copyView(final JFrame parent, final INaviModule module, final INaviView view) {
Preconditions.checkNotNull(parent, "IE01832: Parent argument can not be null");
Preconditions.checkNotNull(module, "IE01833: Module argument can not be null");
Preconditions.checkNotNull(view, "IE01834: View argument can not be null");
if (module.getContent().getViewContainer().hasView(view)) {
if (!view.isLoaded()) {
try {
view.load();
} catch (final CouldntLoadDataException e) {
CUtilityFunctions.logException(e);
final String innerMessage = "E00133: View could not be copied";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be copied because it could not be loaded.", view.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The new view was not created." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
return;
} catch (CPartialLoadException | LoadCancelledException e) {
CUtilityFunctions.logException(e);
return;
}
}
final CView newView = module.getContent().getViewContainer().createView(String.format("Copy of %s", view.getName()), null);
CViewInserter.insertView(view, newView);
}
}
Aggregations