Search in sources :

Example 6 with IAddress

use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.

the class CReferenceFinder method fetchReferenceMap.

/**
 * Fetch for outgoing code references of a tree node and all of its children.
 *
 * @param node The start node of the search.
 * @param instruction The instruction the operand tree belongs to.
 * @param functions The map of code references.
 */
private static void fetchReferenceMap(final IOperandTreeNode node, final INaviInstruction instruction, final Map<INaviInstruction, INaviFunction> functions) {
    final List<IReference> references = node.getReferences();
    for (final IReference reference : references) {
        if (ReferenceType.isCodeReference(reference.getType())) {
            final IAddress target = reference.getTarget();
            final INaviFunction function = instruction.getModule().getContent().getFunctionContainer().getFunction(target);
            if (function != null) {
                functions.put(instruction, function);
            }
        }
    }
    for (final IOperandTreeNode child : node.getChildren()) {
        fetchReferenceMap(child, instruction, functions);
    }
}
Also used : IReference(com.google.security.zynamics.zylib.disassembly.IReference) IOperandTreeNode(com.google.security.zynamics.zylib.disassembly.IOperandTreeNode) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 7 with IAddress

use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.

the class CBookmarksTableModelTest method test2getValueAt.

@Test
public void test2getValueAt() {
    final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
    final IAddress address = new MockAddress();
    final CBookmark bookmark = new CBookmark(address, "foo");
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_0_SET);
    debuggerProvider.addDebugger(debugger);
    final BookmarkManager bookmarkManager = debugger.getBookmarkManager();
    bookmarkManager.addBookmark(bookmark);
    assertEquals(1, bookmarkManager.getNumberOfBookmarks());
    assertEquals("foo", model.getValueAt(0, 2));
    assertEquals(address.toHexString(), model.getValueAt(0, 1));
    assertEquals(debugger.getPrintableString(), model.getValueAt(0, 0));
    final int[] rows = { 0 };
    CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
    assertEquals(0, bookmarkManager.getNumberOfBookmarks());
    model.dispose();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) CBookmarkTableModel(com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager) Test(org.junit.Test)

Example 8 with IAddress

use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.

the class CStackMemoryProvider method hasData.

@Override
public boolean hasData(final long startAddress, final long numberOfBytes) {
    if (m_debugger == null) {
        return false;
    }
    if (m_debugger.getProcessManager().getTargetInformation().getDebuggerOptions().canMemmap()) {
        return m_memoryProvider != null && m_memoryProvider.hasData(BigInteger.valueOf(startAddress), (int) numberOfBytes);
    } else {
        final CAddress stackStart = new CAddress(getStartAddress());
        final int stackSize = getNumberOfEntries() * 4;
        final CAddress stackEnd = new CAddress(getStartAddress() + stackSize);
        final Pair<IAddress, Integer> realRange = MemoryRangeCalculator.calculateRequestRange(BigInteger.valueOf(startAddress), (int) numberOfBytes, stackStart, stackEnd);
        final long realStart = realRange.first().toLong();
        final long realSize = realRange.second();
        return m_memoryProvider != null && m_memoryProvider.hasData(BigInteger.valueOf(startAddress), (int) numberOfBytes, BigInteger.valueOf(realStart), (int) realSize);
    }
}
Also used : BigInteger(java.math.BigInteger) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 9 with IAddress

use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.

the class CGraphInliner method prepareFunctionInlining.

/**
 * Prepares the function inlining by checking if the arguments are properly set and locating the
 * function to inline.
 *
 * @param parent The parent JFrame.
 * @param node The node where the inlining will take place.
 * @param instruction The instruction which is the function call.
 * @param function
 * @param viewContainer The view Container.
 *
 * @return The function to be inlined.
 */
private static INaviFunction prepareFunctionInlining(final JFrame parent, final INaviCodeNode node, final INaviInstruction instruction, final INaviFunction function, final IViewContainer viewContainer) {
    Preconditions.checkNotNull(parent, "IE00825: Parent argument can not be null");
    Preconditions.checkNotNull(viewContainer, "IE00915: View container argument can not be null");
    Preconditions.checkNotNull(node, "IE00916: Node argument can't be null");
    Preconditions.checkNotNull(instruction, "IE01153: Instruction argument can't be null");
    Preconditions.checkNotNull(function, "IE01173: Function argument can't be null");
    final int forwarderModuleId = function.getForwardedFunctionModuleId();
    final IAddress forwarderAddress = function.getForwardedFunctionAddress();
    return getFunctionToInline(parent, viewContainer, function, forwarderModuleId, forwarderAddress);
}
Also used : IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 10 with IAddress

use of com.google.security.zynamics.zylib.disassembly.IAddress in project binnavi by google.

the class CGotoAddressField method zoomToAddress.

/**
 * Zooms to the current address.
 */
private void zoomToAddress() {
    if (!"".equals(getText())) {
        add(getText());
        final IAddress address = new CAddress(Long.parseLong(getText(), 16));
        m_textField.setSuccessful(ZyZoomHelpers.zoomToAddress(m_graph, address, m_modules.get(0), true));
    }
}
Also used : IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)82 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)28 ArrayList (java.util.ArrayList)23 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)19 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)16 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)15 Test (org.junit.Test)14 SQLException (java.sql.SQLException)12 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)11 ResultSet (java.sql.ResultSet)11 BigInteger (java.math.BigInteger)10 HashMap (java.util.HashMap)10 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)9 COperandTree (com.google.security.zynamics.binnavi.disassembly.COperandTree)7 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)7 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)7 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)6 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)6 ReilFunction (com.google.security.zynamics.reil.ReilFunction)6 List (java.util.List)6