use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class CDatabaseFunctions method refreshRawModules.
/**
* Refreshes the information about raw modules stored in the database.
*
* @param parent Parent frame used for dialogs.
* @param database The database where the raw modules are stored.
*/
public static void refreshRawModules(final JFrame parent, final IDatabase database) {
new Thread() {
@Override
public void run() {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", true, false);
try {
operation.getProgressPanel().setMaximum(1);
operation.getProgressPanel().setText("Refreshing modules");
try {
database.getContent().refreshRawModules();
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
final String message = "E00036: " + "Could not refresh raw modules";
final String description = CUtilityFunctions.createDescription("The list of raw modules could not be refreshed. " + "Try refreshing the raw modules again.", new String[] { "Database connection problems." }, new String[] { "More raw modules than those shown in " + "the raw modules list might exist in the database." });
NaviErrorDialog.show(parent, message, description, exception);
}
} finally {
operation.getProgressPanel().next();
operation.stop();
}
}
}.start();
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException 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);
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException 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();
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class CProjectFunctions method createProject.
/**
* Creates a new project.
*
* @param parent Parent window used for dialogs.
* @param database Database where the project is created.
* @param updater Responsible for updating the project tree after the project was created.
*/
public static void createProject(final JFrame parent, final IDatabase database, final INodeSelectionUpdater updater) {
new Thread() {
@Override
public void run() {
try {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
operation.getProgressPanel().setMaximum(3);
operation.getProgressPanel().setText("Creating new project");
final INaviProject newProject = database.getContent().addProject("New Project");
operation.getProgressPanel().next();
try {
newProject.load();
} catch (final LoadCancelledException e) {
// Do nothing
}
operation.getProgressPanel().next();
createDefaultAddressSpace(parent, newProject);
updater.setObject(newProject);
updater.update();
operation.getProgressPanel().next();
operation.stop();
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00140: " + "New project could not be created";
final String innerDescription = CUtilityFunctions.createDescription("It was not possible to create a new project in the selected database.", new String[] { "There was a problem with the database connection." }, new String[] { "No new project was created in the selected database." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00141: " + "New project could not be loaded";
final String innerDescription = CUtilityFunctions.createDescription("The new project could not be loaded.", new String[] { "There was a problem with the database connection." }, new String[] { "The new project was created but it could not be loaded." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
}
}
}.start();
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class ModuleHelpersTest method testGetFunction_1.
@Test
public void testGetFunction_1() {
final Database database = new Database(new MockDatabase());
@SuppressWarnings("unused") final MockModule mockModule = new MockModule();
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
try {
internalModule.load();
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
} catch (final LoadCancelledException exception) {
CUtilityFunctions.logException(exception);
}
@SuppressWarnings("unused") final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, internalModule, nodeTagManager, viewTagManager);
assertEquals(module.getFunctions().get(0), ModuleHelpers.getFunction(module, 0x123));
assertNull(ModuleHelpers.getFunction(module, 0x1235));
try {
ModuleHelpers.getFunction(null, -1);
fail();
} catch (final NullPointerException e) {
}
try {
ModuleHelpers.getFunction(module, -1);
fail();
} catch (final IllegalArgumentException e) {
}
}
Aggregations