use of com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace 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.disassembly.AddressSpaces.CAddressSpace in project binnavi by google.
the class PostgreSQLProjectFunctions method readAddressSpace.
/**
* Loads an address space from the database.
*
* The address space ID must belong to an address space in the database connected to by the
* provider argument.
*
* @param provider The connection to the database.
* @param addressSpaceId The ID of the address space to load.
* @param project The optional project for the address space.
* @return The loaded address space.
*
* @throws SQLException Thrown if loading the address space failed.
*/
public static CAddressSpace readAddressSpace(final AbstractSQLProvider provider, final int addressSpaceId, final INaviProject project) throws SQLException {
final String query = "SELECT name, description, creation_date, modification_date " + " FROM " + CTableNames.ADDRESS_SPACES_TABLE + " WHERE id = " + addressSpaceId;
final ResultSet resultSet = provider.getConnection().executeQuery(query, true);
try {
while (resultSet.next()) {
final String name = PostgreSQLHelpers.readString(resultSet, "name");
final String description = PostgreSQLHelpers.readString(resultSet, "description");
final Timestamp creationDate = resultSet.getTimestamp("creation_date");
final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
return new CAddressSpace(addressSpaceId, name, description == null ? "" : description, creationDate, modificationDate, new HashMap<INaviModule, IAddress>(), null, provider, project);
}
} finally {
resultSet.close();
}
return null;
}
use of com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace in project binnavi by google.
the class CProjectFunctions method addAddressSpace.
/**
* Adds a new address space with a default name to a given project.
*
* @param parent Parent window used for dialogs.
* @param project The project where the new address space is added.
* @param updater Updates the project tree after the execution is complete.
*/
public static void addAddressSpace(final Window parent, final INaviProject project, final INodeSelectionUpdater updater) {
new Thread() {
@Override
public void run() {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
operation.getProgressPanel().setMaximum(2);
try {
operation.getProgressPanel().setText("Creating new address space");
operation.getProgressPanel().next();
final CAddressSpace addressSpace = project.getContent().createAddressSpace("New Address Space");
operation.getProgressPanel().setText("Loading new address space");
addressSpace.load();
operation.getProgressPanel().next();
operation.stop();
updater.setObject(addressSpace);
updater.update();
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00136: " + "Could not add address space";
final String innerDescription = CUtilityFunctions.createDescription(String.format("It was not possible to add a new address space to the project '%s'.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The address space was not created." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00137: " + "Could not load the new address space";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The new address space in project '%s' was created but it could not be loaded.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The address space was created but not loaded." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
} catch (final LoadCancelledException e) {
// Do nothing
}
}
}.start();
}
Aggregations