use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.
the class PostgreSQLProjectFunctions method readAddressSpace.
/**
* Loads an address space from the database.
*
* The address space ID must belong to an address space in the database connected to by the
* provider argument.
*
* @param provider The connection to the database.
* @param addressSpaceId The ID of the address space to load.
* @param project The optional project for the address space.
* @return The loaded address space.
*
* @throws SQLException Thrown if loading the address space failed.
*/
public static CAddressSpace readAddressSpace(final AbstractSQLProvider provider, final int addressSpaceId, final INaviProject project) throws SQLException {
final String query = "SELECT name, description, creation_date, modification_date " + " FROM " + CTableNames.ADDRESS_SPACES_TABLE + " WHERE id = " + addressSpaceId;
final ResultSet resultSet = provider.getConnection().executeQuery(query, true);
try {
while (resultSet.next()) {
final String name = PostgreSQLHelpers.readString(resultSet, "name");
final String description = PostgreSQLHelpers.readString(resultSet, "description");
final Timestamp creationDate = resultSet.getTimestamp("creation_date");
final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
return new CAddressSpace(addressSpaceId, name, description == null ? "" : description, creationDate, modificationDate, new HashMap<INaviModule, IAddress>(), null, provider, project);
}
} finally {
resultSet.close();
}
return null;
}
use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.
the class InstructionConverter method createInstruction.
/**
* This line creates an instruction from the information of a raw instruction line.
*
* @param line The instruction line.
* @param provider The connection to the database.
*
* @return The instruction object generated from the instruction line.
*/
public static CInstruction createInstruction(final InstructionLine line, final SQLProvider provider) {
final ArrayList<COperandTree> operands = new ArrayList<COperandTree>();
final INaviModule module = line.getModule();
for (final OperandTree rawTree : line.getOperands()) {
operands.add(generateTree(rawTree, provider, module));
}
final IAddress address = line.getAddress();
final String mnemonic = line.getMnemonic();
final String architecture = line.getArchitecture();
final CInstruction instruction = new CInstruction(true, module, address, mnemonic, operands, line.getData(), architecture, provider);
return instruction;
}
use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.
the class CMemorySelectionFunctions method askMemoryRange.
/**
* Asks the user for a memory range and displays it afterwards.
*
* @param dlg Dialog where the user can select a range.
* @param debugPerspectiveModel Describes the debug GUI perspective where the refresh action takes
* place.
*/
public static void askMemoryRange(final CMemoryRangeDialog dlg, final CDebugPerspectiveModel debugPerspectiveModel) {
final IDebugger debugger = debugPerspectiveModel.getCurrentSelectedDebugger();
if (debugger == null) {
return;
}
dlg.setVisible(true);
final IAddress start = dlg.getStart();
final IAddress numberOfBytes = dlg.getBytes();
if (start != null && numberOfBytes != null) {
debugPerspectiveModel.setActiveMemoryAddress(start, true);
final ProcessManager pmanager = debugger.getProcessManager();
pmanager.setMemoryMap(new MemoryMap(new FilledList<MemorySection>()));
pmanager.getMemory().clear();
final ArrayList<MemorySection> sections = new ArrayList<MemorySection>();
sections.add(new MemorySection(start, new CAddress(start.toBigInteger().add(numberOfBytes.toBigInteger()).subtract(BigInteger.ONE))));
final MemoryMap map = new MemoryMap(sections);
pmanager.setMemoryMap(map);
}
}
use of com.google.security.zynamics.zylib.disassembly.IAddress 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.zylib.disassembly.IAddress in project binnavi by google.
the class CFunctionViewsModel method getForwarderColumnText.
/**
* Calculates the content of the forwarder column for a given function.
*
* @param function The function to check.
*
* @return The text shown in the table for the forwarder column of the given function.
*/
private String getForwarderColumnText(final INaviFunction function) {
final IAddress address = function.getForwardedFunctionAddress();
if (address == null) {
return "-";
}
final int moduleId = function.getForwardedFunctionModuleId();
final INaviModule forwardedModule = m_database.getContent().getModule(moduleId);
if (forwardedModule == null) {
return "INVALID";
} else if (!forwardedModule.isLoaded()) {
return String.format("%s:%s", forwardedModule.getConfiguration().getName(), address.toHexString());
}
final INaviFunction forwardedFunction = forwardedModule.getContent().getFunctionContainer().getFunction(address);
if (forwardedFunction == null) {
return "INVALID";
} else {
return String.format("%s:%s", forwardedModule.getConfiguration().getName(), forwardedFunction.getName());
}
}
Aggregations