use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.
the class CTagFunctions method insertTag.
/**
* Inserts a tag into the tag hierarchy. The new tag is used as the parent tag of the child tags
* of the old parent tag.
*
* @param parent Parent window used for dialogs.
* @param tagManager The tag manager that manages the old parent tag and the new tag.
* @param parentTag The parent tag of the new tag.
* @param name The name of the new tag.
*/
public static void insertTag(final JFrame parent, final ITagManager tagManager, final TreeNode<CTag> parentTag, final String name) {
new Thread() {
@Override
public void run() {
try {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
operation.getProgressPanel().setMaximum(1);
operation.getProgressPanel().setText("Inserting new tag" + ": " + name);
tagManager.insertTag(parentTag, name);
operation.getProgressPanel().next();
operation.stop();
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00147: " + "Could not insert tag";
final String innerDescription = CUtilityFunctions.createDescription(String.format("BinNavi could not insert a new tag with the name '%s'.", name), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not created." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
}
}
}.start();
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.
the class CTagFunctions method addTag.
/**
* Adds a new tag to the database.
*
* @param parent Parent window used for dialogs.
* @param tagManager The tag manager where the tag is stored.
* @param parentTag The parent tag of the tag. This parameter can be null for root tags.
* @param name The name of the tag.
*/
public static void addTag(final JFrame parent, final ITagManager tagManager, final ITreeNode<CTag> parentTag, final String name) {
new Thread() {
@Override
public void run() {
try {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
operation.getProgressPanel().setMaximum(1);
operation.getProgressPanel().setText("Creating new tag" + ": " + name);
tagManager.addTag(parentTag, name);
operation.getProgressPanel().next();
operation.stop();
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00144: " + "Could not create tag";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The new tag '%s' could not be created.", name), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not created." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
}
}
}.start();
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.
the class CReilViewCreator method create.
/**
* Creates a REIL view from a view.
*
* @param container The container in which the new REIL view is created.
* @param view The view to be translated to REIL code.
*
* @return The created REIL code view.
*
* @throws InternalTranslationException Thrown if the view could not be translated to REIL code.
* @throws CouldntLoadDataException
*/
public static INaviView create(final INaviModule container, final INaviView view) throws InternalTranslationException, CouldntLoadDataException {
Preconditions.checkNotNull(container, "IE01768: Container argument can not be null");
Preconditions.checkNotNull(view, "IE01769: View argument can not be null");
final Map<IAddress, String> textMap = new HashMap<IAddress, String>();
for (final CCodeNode node : view.getBasicBlocks()) {
for (final INaviInstruction instruction : node.getInstructions()) {
textMap.put(instruction.getAddress(), instruction.toString());
}
}
final INaviView reilView = CReilViewCreator.create(container, view.getContent().getReilCode().getGraph());
for (final CCodeNode node : reilView.getBasicBlocks()) {
for (final INaviInstruction reilInstruction : node.getInstructions()) {
if ((reilInstruction.getAddress().toLong() & 0xFF) == 0) {
try {
node.getComments().appendLocalInstructionComment(reilInstruction, textMap.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())));
} catch (final CouldntSaveDataException e) {
// Not possible for unsaved views.
CUtilityFunctions.logException(e);
}
}
}
}
return reilView;
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.
the class CUserManager method addUser.
/**
* Adds a user to the user management and saves the information to the database
*
* @param userName The name of the user to be added to user management.
*
* @return The user.
* @throws CouldntSaveDataException
*/
public synchronized IUser addUser(final String userName) throws CouldntSaveDataException {
Preconditions.checkNotNull(userName, "IE02718: user name argument can not be null.");
if (containsUserName(userName)) {
throw new IllegalStateException("IE02719: User is already known to user management.");
}
final IUser user = provider.addUser(userName);
users.add(user);
for (final IUserManagerListener listener : listeners) {
try {
listener.addedUser(user);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
return user;
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.
the class CDatabaseContent method addProject.
/**
* Adds a new project to the database.
*
* This function is guaranteed to be thread-safe. If the new project could not be saved to the
* database, the state of the database object remains unchanged.
*
* @param name The name of the new project.
*
* @return The added project.
*
* @throws IllegalArgumentException Thrown if the name of the new project is null.
* @throws CouldntSaveDataException Thrown if the new project could not be saved to the database.
*/
@Override
public INaviProject addProject(final String name) throws CouldntSaveDataException {
Preconditions.checkNotNull(name, "IE00661: Project name can not be null");
Preconditions.checkArgument(m_database.isConnected(), "IE00662: Database must be connected before a project can be added");
Preconditions.checkArgument(m_database.isLoaded(), "IE00663: Database must be loaded before a project can be added");
final CProject newProject = m_provider.createProject(name);
m_projects.add(newProject);
for (final IDatabaseListener listener : m_listeners) {
try {
listener.addedProject(m_database, newProject);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
return newProject;
}
Aggregations