use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class ExpensiveBaseTest method loadView.
public INaviView loadView(final INaviModule module, final String name) throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, MaybeNullException {
final INaviView view = module.getContent().getViewContainer().getView(module.getContent().getFunctionContainer().getFunction(name));
view.load();
return view;
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CPostgreSQLZyGraphTest2 method testSave.
@Test
public void testSave() throws CouldntSaveDataException, CouldntLoadDriverException, CouldntConnectException, InvalidDatabaseException, CouldntInitializeDatabaseException, CouldntLoadDataException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, CPartialLoadException, LoadCancelledException {
m_view.getGraph().getNodes().get(0).setSelected(true);
m_view.getGraph().getNodes().get(1).setColor(new Color(123));
m_view.getGraph().getNodes().get(2).setX(456);
m_view.getGraph().getNodes().get(3).setY(789);
final INaviView newView = m_graph.saveAs(new CModuleContainer(m_database, m_module), "New View", "New View Description");
m_database2.connect();
m_database2.load();
final INaviModule module = m_database2.getContent().getModules().get(0);
module.load();
final Iterable<INaviView> views = CViewFilter.getFlowgraphViews(module.getContent().getViewContainer().getViews());
final INaviView loadedNewView = Iterables.getLast(views);
loadedNewView.load();
assertEquals(loadedNewView.getNodeCount(), newView.getNodeCount());
assertEquals(true, loadedNewView.getGraph().getNodes().get(0).isSelected());
assertEquals(0xFF00007B, loadedNewView.getGraph().getNodes().get(1).getColor().getRGB());
assertEquals(456, loadedNewView.getGraph().getNodes().get(2).getX(), 0);
assertEquals(789, loadedNewView.getGraph().getNodes().get(3).getY(), 0);
m_database2.close();
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class PostgreSQLFunctionsLoader method parseFunctionInformation.
/**
* This function parses a {@link ResultSet result set} from a database query and generates a
* {@link List} of {@link INaviFunction} from it.
*
* @param resultSet The {@link ResultSet} in which the result from the database query is stored.
* @param provider The {@link SQLProvider} to access the database with.
* @param module The {@link INaviModule} to which the {@link INaviFunction function(s)} are
* associated.
*
* @return A {@link List} of {@link INaviFunction functions} parsed from the {@link ResultSet
* resultSet}.
*
* @throws SQLException if the {@link ResultSet} could not be parsed.
* @throws CouldntLoadDataException if the associated comments could not be loaded from the
* database.
*/
private static List<INaviFunction> parseFunctionInformation(final ResultSet resultSet, final SQLProvider provider, final INaviModule module) throws SQLException, CouldntLoadDataException {
final List<INaviFunction> functions = Lists.newArrayList();
final Map<Integer, INaviFunction> commentIdToFunction = new HashMap<Integer, INaviFunction>();
try {
while (resultSet.next()) {
final IAddress address = PostgreSQLHelpers.loadAddress(resultSet, "address");
final String name = resultSet.getString("name");
final String originalName = resultSet.getString("original_name");
Integer globalCommentId = resultSet.getInt("global_comment");
if (resultSet.wasNull()) {
globalCommentId = null;
}
final String description = resultSet.getString("description");
final FunctionType type = FunctionType.valueOf(resultSet.getString("type").toUpperCase());
final String parentModuleName = resultSet.getString("parent_module_name");
final int parentModuleId = resultSet.getInt("parent_module_id");
final IAddress parentModuleFunction = resultSet.wasNull() ? null : PostgreSQLHelpers.loadAddress(resultSet, "parent_module_function");
final Integer nodeCount = resultSet.getInt("bbcount");
final Integer edgeCount = resultSet.getInt("edgeCount");
final Integer indegree = resultSet.getInt("incount");
final Integer outdegree = resultSet.getInt("outcount");
Integer stackFrameId = resultSet.getInt("stack_frame");
if (resultSet.wasNull()) {
stackFrameId = null;
}
Integer prototypeId = resultSet.getInt("prototype");
if (resultSet.wasNull()) {
prototypeId = null;
}
final INaviView view = ViewManager.get(provider).getView(resultSet.getInt("view_id"));
final BaseType stackFrame = stackFrameId == null ? null : module.getTypeManager().getBaseType(stackFrameId);
if (stackFrameId != null) {
module.getTypeManager().setStackFrame(stackFrame);
}
final BaseType prototype = prototypeId == null ? null : module.getTypeManager().getBaseType(prototypeId);
final CFunction function = new CFunction(module, view, address, name, originalName, description, indegree, outdegree, nodeCount, edgeCount, type, parentModuleName, parentModuleId, parentModuleFunction, stackFrame, prototype, provider);
if (globalCommentId != null) {
commentIdToFunction.put(globalCommentId, function);
}
functions.add(function);
}
} finally {
resultSet.close();
}
if (!commentIdToFunction.isEmpty()) {
final HashMap<Integer, ArrayList<IComment>> commentIdToComments = PostgreSQLCommentFunctions.loadMultipleCommentsById(provider, commentIdToFunction.keySet());
for (final Entry<Integer, ArrayList<IComment>> commentIdToComment : commentIdToComments.entrySet()) {
CommentManager.get(provider).initializeGlobalFunctionComment(commentIdToFunction.get(commentIdToComment.getKey()), commentIdToComment.getValue());
}
}
return functions;
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class TypeInstanceContainerBackend method loadTypeInstanceReference.
/**
* Load a single type instance reference from the database.
*
* @param typeInstanceId the id of the {@link TypeInstanceReference reference}.
* @param address The address of the {@link INaviInstruction instruction} where the
* {@link TypeInstanceReference reference} is associated.
* @param position The {@link OperandTree operand tree} position in the {@link INaviInstruction
* instruction} the {@link TypeInstanceReference reference} is associated to.
* @param expressionId The {@link OperandTreeNode operand tree node} id within the
* {@link OperandTree operand tree}.
*
* @return The {@link TypeInstanceReference} loaded from the database.
* @throws CouldntLoadDataException
*/
public TypeInstanceReference loadTypeInstanceReference(final Integer typeInstanceId, final BigInteger address, final Integer position, final Integer expressionId) throws CouldntLoadDataException {
Preconditions.checkNotNull(typeInstanceId, "Error: typeInstanceId argument can not be null");
Preconditions.checkNotNull(address, "Error: address argument can not be null");
Preconditions.checkNotNull(position, "Error: position argument can not be null");
Preconditions.checkNotNull(expressionId, "Error: expressionId argument can not be null");
final RawTypeInstanceReference rawReference = provider.loadTypeInstanceReference(module, typeInstanceId, address, position, expressionId);
final TypeInstance typeInstance = instancesById.get(rawReference.getTypeInstanceId());
final INaviView view = module.getContent().getViewContainer().getView(rawReference.getViewId());
final TypeInstanceReference reference = new TypeInstanceReference(new CAddress(address), position, Optional.<INaviOperandTreeNode>absent(), typeInstance, view);
referenceLookup.put(new InstanceReferenceLookup(new CAddress(address), position, expressionId), reference);
return reference;
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CViewContainer method delete.
private void delete(final INaviView view) {
final INaviView currentStoredView = m_customViews.get(m_customViews.indexOf(view));
m_customViews.remove(currentStoredView);
viewIdView.remove(view.getConfiguration().getId());
currentStoredView.removeListener(m_viewListener);
for (final IModuleListener listener : m_listeners) {
try {
listener.deletedView(m_module, currentStoredView);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
}
Aggregations