use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class CAddressSpaceNodeComponentTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, CouldntSaveDataException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException, LoadCancelledException {
final JTree tree = new JTree();
m_database = new MockDatabase(m_provider);
m_project = new CProject(1, "Mock Project", "Mock Project Description", new Date(), new Date(), 0, new ArrayList<DebuggerTemplate>(), m_provider);
m_project.load();
m_addressSpace = m_project.getContent().createAddressSpace("Address Space");
m_component = new CAddressSpaceNodeComponent(tree, m_database, m_project, m_addressSpace);
m_saveButton = (JButton) ReflectionHelpers.getField(m_component, "m_saveButton");
m_editPanel = (CStandardEditPanel) ReflectionHelpers.getField(m_component, "m_stdEditPanel");
m_titledBorder = (TitledBorder) ReflectionHelpers.getField(m_component, "m_titledBorder");
m_debuggerCombo = (CDebuggerComboBox) ReflectionHelpers.getField(m_component, "m_debuggerCombo");
}
use of com.google.security.zynamics.binnavi.disassembly.CProject 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;
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLProjectCreator method loadProject.
/**
* Loads a project from the database.
*
* @param provider The connection to the database.
* @param projectId The ID of the project to load.
*
* @return The loaded project.
*
* @throws SQLException Thrown if the project could not be loaded.
*/
protected static CProject loadProject(final AbstractSQLProvider provider, final int projectId) throws SQLException {
final String query = "select id, name, description, creation_date, modification_date from " + CTableNames.PROJECTS_TABLE + " where id = " + projectId;
try (ResultSet resultSet = provider.getConnection().executeQuery(query, true)) {
while (resultSet.next()) {
final String name = PostgreSQLHelpers.readString(resultSet, "name");
final String description = PostgreSQLHelpers.readString(resultSet, "description");
final int addressSpaceCount = 0;
final Timestamp creationDate = resultSet.getTimestamp("creation_date");
final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
return new CProject(projectId, name, description, creationDate, modificationDate, addressSpaceCount, new ArrayList<DebuggerTemplate>(), provider);
}
}
return null;
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLProviderTest method testGetModificationDate1.
@Test
public void testGetModificationDate1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final CProject project = getProvider().createProject("TEST_PROJECT");
getProvider().createAddressSpace(project, "SOME_ADDRESS_SPACE_12455");
assertNotNull(getProvider().getModificationDate(getProvider().loadAddressSpaces(project).get(0)));
assertNotNull(getProvider().getModificationDate(getProvider().loadModules().get(0)));
assertNotNull(getProvider().getModificationDate(getProvider().loadProjects().get(0)));
final INaviModule module = getProvider().loadModules().get(0);
module.load();
assertNotNull(getProvider().getModificationDate(module.getContent().getViewContainer().getViews().get(0)));
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLProviderTest method testCAddressSpaceLoaderLoadAddressSpaces1.
@Test
public void testCAddressSpaceLoaderLoadAddressSpaces1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final DebuggerTemplateManager debuggerManager = new DebuggerTemplateManager(getProvider());
final CProject project = getProvider().createProject("PROJECT_234");
getProvider().createAddressSpace(project, "ADDRESS_SPACE_234");
final List<INaviModule> modules = getProvider().loadModules();
final List<INaviModule> convertedModules = new ArrayList<INaviModule>();
convertedModules.add(modules.get(0));
final List<CAddressSpace> addressSpaces = PostgreSQLAddressSpaceLoader.loadAddressSpaces((AbstractSQLProvider) getProvider(), project, debuggerManager, convertedModules);
final CAddressSpace addressSpace = addressSpaces.get(0);
addressSpace.load();
addressSpace.getContent().addModule(modules.get(0));
addressSpace.getContent().setImageBase(modules.get(0), new CAddress(0x1234));
@SuppressWarnings("unused") final List<CAddressSpace> addressSpaces2 = PostgreSQLAddressSpaceLoader.loadAddressSpaces((AbstractSQLProvider) getProvider(), project, debuggerManager, convertedModules);
}
Aggregations