use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CEventTableModel method getValueAt.
@Override
public Object getValueAt(final int row, final int col) {
final ITraceEvent debugEvent = getEvents().get(row);
final BreakpointAddress address = debugEvent.getOffset();
switch(col) {
case INDEX_COLUMN:
return row + 1;
case THREAD_COLUMN:
return Long.valueOf(debugEvent.getThreadId());
case MODULE_COLUMN:
return address.getModule() == null ? "-" : address.getModule().getConfiguration().getName();
case ADDRESS_COLUMN:
{
if (address.getModule() == null) {
return address.getAddress().getAddress().toHexString();
} else {
final INaviFunction function = address.getModule().isLoaded() ? address.getModule().getContent().getFunctionContainer().getFunction(address.getAddress().getAddress()) : null;
if (function == null) {
return address.getAddress().getAddress().toHexString();
} else {
return function.getName();
}
}
}
default:
throw new IllegalStateException("IE01121: Unknown column");
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CTraceFilterExpression method evaluate.
@Override
public boolean evaluate(final CTraceEventWrapper element) {
final ITraceEvent event = element.unwrap();
final INaviModule currentModule = event.getOffset().getModule();
String functionName = "";
String moduleName = "";
if (currentModule != null) {
final INaviFunction function = currentModule.isLoaded() ? currentModule.getContent().getFunctionContainer().getFunction(event.getOffset().getAddress().getAddress()) : null;
if (function != null) {
functionName = function.getName();
}
moduleName = currentModule.getConfiguration().getName();
}
return String.valueOf(event.getThreadId()).contains(m_text) || event.getOffset().getAddress().getAddress().toHexString().contains(m_text) || moduleName.contains(m_text) || functionName.contains(m_text);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CEventTableMenu method addOpenFunction.
/**
* Adds a menu item to open the selected trace.
*
* @param parent Parent window of the menu.
* @param traces The selected traces.
*/
private void addOpenFunction(final Window parent, final List<ITraceEvent> traces) {
if (traces.size() == 1) {
final ITraceEvent trace = traces.get(0);
final INaviModule module = trace.getOffset().getModule();
if (module.isLoaded()) {
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(trace.getOffset().getAddress().getAddress());
if (function != null) {
final IViewContainer container = graphModel.getViewContainer();
final INaviView view = container.getView(function);
if (view != null) {
add(new JMenuItem(CActionProxy.proxy(new COpenInLastWindowAction(parent, container, new INaviView[] { view }))));
addSeparator();
}
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CViewOpener method showView.
/**
* Shows a view in a graph window.
*
* @param parent Parent window that is used as the parent of all dialogs.
* @param viewContainer View container that provides the context in which a view is opened.
* @param view The view to show.
* @param window Graph window where the graph is shown. If this value is null, the graph is shown
* in a new window.
*/
public static void showView(final Window parent, final IViewContainer viewContainer, final INaviView view, final CGraphWindow window) {
Preconditions.checkNotNull(parent, "IE00015: Parent argument can not be null");
Preconditions.checkNotNull(viewContainer, "IE00016: View container argument can not be null");
Preconditions.checkNotNull(view, "IE00018: View argument can not be null");
Preconditions.checkState(viewContainer.isLoaded(), "IE00017: View container must be loaded");
Preconditions.checkState(viewContainer.getViews().contains(view), "IE00019: View is not part of the given view container");
final INaviFunction function = viewContainer.getFunction(view);
if (isPureImportedFunction(function)) {
CMessageBox.showInformation(parent, "Imported functions are not part of a module and can not be opened.\n" + "Note that it is possible to open imported functions once they " + "are forwarded to real functions in other modules.");
return;
} else if (isForwardedImportedFunction(function)) {
// Imported functions must be treated specially, because a forwarded
// functions could be opened instead of the view.
showForwardedFunction(parent, viewContainer, view, function, window);
} else {
CGraphOpener.showGraph(viewContainer, view, window, parent);
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLCallgraphLoader method loadNodes.
/**
* Loads the nodes of a call graph.
*
* @param connection Connection to the database.
* @param callgraphId ID of the call graph view to load.
* @param functions List of functions in the module whose call graph is loaded.
*
* @return <Call graph nodes, Call graph node IDs => Call graph nodes>
*
* @throws SQLException Thrown if loading the nodes failed.
*/
private static Pair<List<ICallgraphNode>, Map<Integer, CCallgraphNode>> loadNodes(final CConnection connection, final int callgraphId, final Collection<INaviFunction> functions) throws SQLException {
// TODO: Simplify the return value of this method.
// For performance reasons, we need a quick way to look up functions by their address.
final Map<IAddress, INaviFunction> functionMap = getFunctionMap(functions);
final List<ICallgraphNode> nodes = new ArrayList<ICallgraphNode>();
final String nodeQuery = "SELECT nodes.id, function FROM " + CTableNames.NODES_TABLE + " AS nodes JOIN " + CTableNames.FUNCTION_NODES_TABLE + " AS function_nodes ON nodes.id = function_nodes.node_id WHERE nodes.view_id = " + callgraphId;
final ResultSet nodeResult = connection.executeQuery(nodeQuery, true);
final HashMap<Integer, CCallgraphNode> nodeMap = new HashMap<Integer, CCallgraphNode>();
try {
while (nodeResult.next()) {
final int nodeId = nodeResult.getInt("id");
final IAddress functionAddress = PostgreSQLHelpers.loadAddress(nodeResult, "function");
final INaviFunction function = functionMap.get(functionAddress);
final CCallgraphNode cgnode = new CCallgraphNode(function);
nodeMap.put(nodeId, cgnode);
nodes.add(cgnode);
}
} finally {
nodeResult.close();
}
return new Pair<List<ICallgraphNode>, Map<Integer, CCallgraphNode>>(nodes, nodeMap);
}
Aggregations