use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLProviderTest method testFunctionFunctionsSetDescriptionConstructor2.
@Test(expected = NullPointerException.class)
public void testFunctionFunctionsSetDescriptionConstructor2() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviModule module1 = getProvider().loadModules().get(0);
module1.load();
final INaviFunction function1 = module1.getContent().getFunctionContainer().getFunctions().get(25);
getProvider().setDescription(function1, null);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class Module method convertData.
/**
* Converts internal module data to API module data.
*/
private void convertData() {
m_traces = new ArrayList<Trace>();
for (final TraceList trace : m_module.getContent().getTraceContainer().getTraces()) {
m_traces.add(new Trace(trace));
}
m_module.getContent().getTraceContainer().addListener(m_traceListener);
m_functions = new ArrayList<Function>();
for (final INaviFunction function : m_module.getContent().getFunctionContainer().getFunctions()) {
m_functions.add(new Function(this, function));
}
for (final Function function : m_functions) {
m_functionMap.put(function.getNative(), function);
}
m_views = new ArrayList<View>();
for (final INaviView view : m_module.getContent().getViewContainer().getViews()) {
m_views.add(new View(this, view, m_nodeTagManager, m_viewTagManager));
}
createCallgraph();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CViewOpener method showForwardedFunction.
/**
* Shows a forwarded function in a graph window.
*
* @param parent Parent window that is used as the parent of all dialogs.
* @param container View container that provides the context in which a view is opened.
* @param view The view to show.
* @param function The imported function to show.
* @param window Graph window where the graph is shown. If this value is null, the graph is shown
* in a new window.
*/
private static void showForwardedFunction(final Window parent, final IViewContainer container, final INaviView view, final INaviFunction function, final CGraphWindow window) {
if (container instanceof CModuleContainer) {
CMessageBox.showInformation(parent, "Please open forwarded views from inside a project.");
return;
}
final IDatabase database = container.getDatabase();
final int moduleId = function.getForwardedFunctionModuleId();
final INaviModule forwardedModule = database.getContent().getModule(moduleId);
if (forwardedModule == null) {
final String message = "E00019: " + "Forwarded view can not be loaded (Unknown module)";
final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the module of " + "the forwarding target is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the " + "forwarding target again. Restart BinNavi if the view " + "can still not be opened. Contact the BinNavi support if necessary." });
NaviErrorDialog.show(parent, message, description);
} else if (forwardedModule.isLoaded()) {
final IAddress address = function.getForwardedFunctionAddress();
final INaviFunction forwardedFunction = forwardedModule.getContent().getFunctionContainer().getFunction(address);
if (forwardedFunction == null) {
final String message = "E00020: " + "Forwarded view can not be loaded (Unknown function)";
final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the target function is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the forwarding target " + "again. Restart BinNavi if the view can still not be opened. Contact the " + "BinNavi support if necessary." });
NaviErrorDialog.show(parent, message, description);
} else {
final INaviView forwardedView = forwardedModule.getContent().getViewContainer().getView(forwardedFunction);
if (forwardedView == null) {
final String message = "E00107: " + "Forwarded view can not be loaded (Unknown view)";
final String description = CUtilityFunctions.createDescription("BinNavi could not open the forwarded view because the target view is unknown.", new String[] { "Probably the result of a bug in BinNavi" }, new String[] { "The view can not be opened. Try to update the forwarding target " + "again. Restart BinNavi if the view can still not be opened. Contact the " + "BinNavi support if necessary." });
NaviErrorDialog.show(parent, message, description);
} else {
CGraphOpener.showGraph(container, forwardedView, window, parent);
}
}
} else {
if (CMessageBox.showYesNoQuestion(parent, "The view can not be opened because it is forwarded to an unloaded module.\n\n" + "Do you want to load the forwarded module now?") == JOptionPane.YES_OPTION) {
CModuleLoader.loadModule(parent, forwardedModule);
if (forwardedModule.isLoaded()) {
// Just call this function recursively now that the module is loaded.
showForwardedFunction(parent, container, view, function, window);
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CCallgraphCombiner method createCombinedCallgraph.
/**
* Combines the call graphs of the modules of an address space.
*
* @param project The project where the combined view is created.
* @param addressSpace Provides the modules whose call graphs are combined.
*
* @return The view that contains the combined call graph.
*/
public static INaviView createCombinedCallgraph(final INaviProject project, final INaviAddressSpace addressSpace) {
final INaviView view = project.getContent().createView("Combined Callgraph", "");
final Map<INaviFunction, CFunctionNode> nodeMap = new HashMap<INaviFunction, CFunctionNode>();
final Map<INaviFunction, INaviFunction> resolvedMap = new HashMap<INaviFunction, INaviFunction>();
final List<INaviModule> modules = addressSpace.getContent().getModules();
// functions that are not forwarded.
for (final INaviModule module : modules) {
final CCallgraph callgraph = module.getContent().getNativeCallgraph();
for (final ICallgraphNode callgraphNode : callgraph) {
final INaviFunction function = callgraphNode.getFunction();
final INaviFunction resolvedFunction = getResolvedFunction(function, modules);
if (resolvedFunction == null) {
final CFunctionNode node = view.getContent().createFunctionNode(function);
node.setColor(CFunctionNodeColorizer.getFunctionColor(function.getType()));
nodeMap.put(function, node);
} else {
resolvedMap.put(function, resolvedFunction);
}
}
}
// for the forwarded functions.
for (final INaviModule module : modules) {
final CCallgraph callgraph = module.getContent().getNativeCallgraph();
for (final ICallgraphEdge callgraphEdge : callgraph.getEdges()) {
final INaviFunction source = resolvedMap.containsKey(callgraphEdge.getSource().getFunction()) ? resolvedMap.get(callgraphEdge.getSource().getFunction()) : callgraphEdge.getSource().getFunction();
final INaviFunction target = resolvedMap.containsKey(callgraphEdge.getTarget().getFunction()) ? resolvedMap.get(callgraphEdge.getTarget().getFunction()) : callgraphEdge.getTarget().getFunction();
view.getContent().createEdge(nodeMap.get(source), nodeMap.get(target), EdgeType.JUMP_UNCONDITIONAL);
}
}
return view;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CFunctionHelpers method resolveFunction.
/**
* Shows a dialog where the user can resolve a function.
*
* @param parent Parent window used for dialogs.
* @param database Database the function belongs to.
* @param function Function to be forwarded to another module.
*/
public static void resolveFunction(final Window parent, final IDatabase database, final INaviFunction function) {
final CFunctionSelectionDialog dlg = new CFunctionSelectionDialog(parent, database);
GuiHelper.centerChildToParent(parent, dlg, true);
dlg.setVisible(true);
final INaviFunction selectedFunction = dlg.getSelectedFunction();
if (selectedFunction != null) {
try {
function.setForwardedFunction(selectedFunction);
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
}
}
}
Aggregations