Search in sources :

Example 41 with Pair

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());
    }
}
Also used : CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) ArrayList(java.util.ArrayList) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Pair(com.google.security.zynamics.zylib.general.Pair) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)

Example 42 with Pair

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;
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ArrayList(java.util.ArrayList) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 43 with Pair

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) Pair(com.google.security.zynamics.zylib.general.Pair) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

Example 44 with Pair

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;
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) CCodeNodeComments(com.google.security.zynamics.binnavi.disassembly.CCodeNodeComments) ArrayList(java.util.ArrayList) Pair(com.google.security.zynamics.zylib.general.Pair) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 45 with Pair

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());
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) CodeDisplayCoordinate(com.google.security.zynamics.zylib.gui.CodeDisplay.CodeDisplayCoordinate) Pair(com.google.security.zynamics.zylib.general.Pair) FormattedCharacterBuffer(com.google.security.zynamics.zylib.gui.CodeDisplay.FormattedCharacterBuffer)

Aggregations

Pair (com.google.security.zynamics.zylib.general.Pair)55 ArrayList (java.util.ArrayList)26 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)7 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)6 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)6 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 Test (org.junit.Test)4 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)3 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)3 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)3 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 ReilBlock (com.google.security.zynamics.reil.ReilBlock)3 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)3 BigInteger (java.math.BigInteger)3 HashSet (java.util.HashSet)3