use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CBookmarkFunctions method deleteBookmarks.
/**
* Deletes a list of bookmarks.
*
* @param provider Contains the debuggers where bookmarks can be set.
* @param rows The rows of the bookmarks to delete.
*/
public static void deleteBookmarks(final BackEndDebuggerProvider provider, final int[] rows) {
Preconditions.checkNotNull(provider, "IE01329: Provider argument can not be null");
Preconditions.checkNotNull(rows, "IE01330: Rows argument can not be null");
final ArrayList<Pair<BookmarkManager, CBookmark>> bookmarks = new ArrayList<Pair<BookmarkManager, CBookmark>>();
for (final int row : rows) {
final Triple<IDebugger, BookmarkManager, Integer> bookmarkTriple = CBookmarkTableHelpers.findBookmark(provider, row);
final BookmarkManager manager = bookmarkTriple.second();
final int index = bookmarkTriple.third();
bookmarks.add(Pair.make(manager, manager.getBookmark(index)));
}
for (final Pair<BookmarkManager, CBookmark> p : bookmarks) {
p.first().removeBookmark(p.second());
}
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CRelocationNotifier method collectWronglyPlacedModules.
/**
* Finds wrongly relocated modules by comparing a snapshot of the modules in an address space
* being reported by the debug client with those configured in
* com.google.security.zynamics.binnavi.
*
* @param debugger The active debugger.
* @param viewContainer The view container that is being debugged.
* @param memoryModules The modules whose base addresses are checked.
*
* @return A list of wrongly relocated modules.
*/
private static List<Pair<INaviModule, MemoryModule>> collectWronglyPlacedModules(final IDebugger debugger, final IViewContainer viewContainer, final List<MemoryModule> memoryModules) {
final List<Pair<INaviModule, MemoryModule>> wronglyPlacedModules = new ArrayList<Pair<INaviModule, MemoryModule>>();
final List<INaviModule> modules = viewContainer.getModules();
for (final INaviModule module : modules) {
for (final MemoryModule memoryModule : memoryModules) {
if (module.getConfiguration().getName().equalsIgnoreCase(memoryModule.getName())) {
final RelocatedAddress assumedAddress = debugger.fileToMemory(module, new UnrelocatedAddress(module.getConfiguration().getFileBase()));
final IAddress memoryAddress = memoryModule.getBaseAddress().getAddress();
if (!assumedAddress.getAddress().equals(memoryAddress)) {
wronglyPlacedModules.add(new Pair<INaviModule, MemoryModule>(module, memoryModule));
}
}
}
}
return wronglyPlacedModules;
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CRelocationNotifier method checkBaseAddresses.
/**
* Tests the correctness of the base addresses of memory modules and displays corrected base
* addresses to the user.
*
* @param parent Parent window used for dialogs.
* @param debugger The active debugger.
* @param viewContainer The view container that is being debugged.
* @param memoryModules The modules whose base addresses are checked.
*/
public static void checkBaseAddresses(final JFrame parent, final IDebugger debugger, final IViewContainer viewContainer, final List<MemoryModule> memoryModules) {
final List<Pair<INaviModule, MemoryModule>> wronglyPlacedModules = collectWronglyPlacedModules(debugger, viewContainer, memoryModules);
if (!wronglyPlacedModules.isEmpty()) {
for (final Pair<INaviModule, MemoryModule> pair : wronglyPlacedModules) {
final INaviModule module = pair.first();
final MemoryModule memoryModule = pair.second();
final List<INaviAddressSpace> addressSpaces = viewContainer.getAddressSpaces();
if (addressSpaces == null) {
try {
module.getConfiguration().setImageBase(memoryModule.getBaseAddress().getAddress());
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
}
} else {
for (final INaviAddressSpace addressSpace : addressSpaces) {
if (addressSpace.getContent().getModules().contains(module)) {
try {
addressSpace.getContent().setImageBase(module, memoryModule.getBaseAddress().getAddress());
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
}
}
}
}
}
}
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CCommentUtilities method getLocalInstructionComments.
/**
* TODO (timkornau): either comment the function or find a better way on how the commenting for
* instructions can access all comments.
*/
public static List<Pair<INaviInstruction, IComment>> getLocalInstructionComments(final CCodeNode codeNode) {
Preconditions.checkNotNull(codeNode, "IE02633: codeNode argument can not be null");
final List<Pair<INaviInstruction, IComment>> values = new ArrayList<Pair<INaviInstruction, IComment>>();
final CCodeNodeComments currentComments = codeNode.getComments();
for (final INaviInstruction instruction : codeNode.getInstructions()) {
final List<IComment> comments = currentComments.getLocalInstructionComment(instruction);
if ((comments == null) || comments.isEmpty()) {
values.add(new Pair<INaviInstruction, IComment>(instruction, null));
continue;
} else {
for (final IComment comment : comments) {
values.add(new Pair<INaviInstruction, IComment>(instruction, comment));
}
}
}
return values;
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class InstructionCommentsDataModel method getCommentCharacterBuffer.
private FormattedCharacterBuffer getCommentCharacterBuffer(int rowIndex, int columnIndex, int lineIndex) {
// Return the actual comment.
CodeDisplayCoordinate coordinate = new CodeDisplayCoordinate(rowIndex, lineIndex, columnIndex, 0);
Pair<IComment, Pair<Integer, Integer>> commentAndIndex = getCommentAndIndexAtCoordinate(coordinate);
String finalComment = "";
if (commentAndIndex.first().getNumberOfCommentLines() > 0) {
String commentString = commentAndIndex.first().getComment();
Pair<Integer, Integer> indices = commentAndIndex.second();
finalComment = commentString.substring(indices.first(), indices.second());
}
finalComment = CodeDisplay.padRight(finalComment, getColumnWidthInCharacters(columnIndex));
return new FormattedCharacterBuffer(finalComment, STANDARD_FONT, columns[COMMENT_INDEX].getDefaultFontColor(), columns[COMMENT_INDEX].getDefaultBackgroundColor());
}
Aggregations