Search in sources :

Example 61 with IAddress

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

the class MemoryMapParser method parseSuccess.

@Override
public MemoryMapReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final IAddress[] addresses = new IAddress[argumentCount];
    for (int i = 0; i < argumentCount; i++) {
        addresses[i] = parseAddress();
    }
    final List<MemorySection> map = new ArrayList<>();
    for (int i = 0; i < addresses.length / 2; i++) {
        final IAddress startAddress = addresses[2 * i];
        final IAddress endAddress = addresses[2 * i + 1];
        map.add(new MemorySection(startAddress, endAddress));
    }
    return new MemoryMapReply(packetId, 0, new MemoryMap(map));
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) ArrayList(java.util.ArrayList) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 62 with IAddress

use of com.google.security.zynamics.zylib.disassembly.IAddress 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 63 with IAddress

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

the class CRefreshAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
    if (debugger != null) {
        CMemorySelectionFunctions.refreshMemory(m_parent, debugger, m_rangeProvider.getAddress(), m_rangeProvider.getSize());
        final IAddress stackAddress = m_stackRangeProvider.getAddress();
        final int size = m_stackRangeProvider.getSize();
        if (stackAddress != null && size != 0) {
            CMemorySelectionFunctions.refreshMemory(m_parent, debugger, stackAddress, size);
        }
    }
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

Example 64 with IAddress

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

the class CRegisterTrackingHelper method getInstructionMap.

/**
 * Creates an address -> instruction mapping for all instructions in a graph.
 *
 * @param view The input graph.
 * @return The created mapping.
 */
public static Map<IAddress, INaviInstruction> getInstructionMap(final INaviView view) {
    final Map<IAddress, INaviInstruction> instructionMap = new HashMap<IAddress, INaviInstruction>();
    final List<INaviViewNode> nodes = view.getGraph().getNodes();
    for (final INaviViewNode node : nodes) {
        if (node instanceof INaviCodeNode) {
            final INaviCodeNode cnode = (INaviCodeNode) node;
            for (final INaviInstruction instruction : cnode.getInstructions()) {
                instructionMap.put(instruction.getAddress(), instruction);
            }
        }
    }
    return instructionMap;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) HashMap(java.util.HashMap) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 65 with IAddress

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

the class CGlobalEdgeCommentSynchronizer method getEdgeData.

/**
 * Returns the edge data of a given edge.
 *
 * @param edge An edge.
 *
 * @return <Source Module ID, Source Address, Target Module ID, Target Address>
 *
 * @throws MaybeNullException Thrown if the edge data could not be determined.
 */
private static Quad<Integer, IAddress, Integer, IAddress> getEdgeData(final INaviEdge edge) throws MaybeNullException {
    IAddress srcAddr = null;
    IAddress dstAddr = null;
    int srcModuleId = -1;
    int dstModuleId = -1;
    if (edge.getSource() instanceof INaviCodeNode) {
        srcAddr = ((INaviCodeNode) edge.getSource()).getAddress();
        srcModuleId = ((INaviCodeNode) edge.getSource()).getParentFunction().getModule().getConfiguration().getId();
    } else if (edge.getSource() instanceof INaviFunctionNode) {
        srcAddr = ((INaviFunctionNode) edge.getSource()).getFunction().getAddress();
        srcModuleId = ((INaviFunctionNode) edge.getSource()).getFunction().getModule().getConfiguration().getId();
    }
    if (edge.getTarget() instanceof INaviCodeNode) {
        dstAddr = ((INaviCodeNode) edge.getTarget()).getAddress();
        dstModuleId = ((INaviCodeNode) edge.getTarget()).getParentFunction().getModule().getConfiguration().getId();
    } else if (edge.getTarget() instanceof INaviFunctionNode) {
        dstAddr = ((INaviFunctionNode) edge.getTarget()).getFunction().getAddress();
        dstModuleId = ((INaviFunctionNode) edge.getTarget()).getFunction().getModule().getConfiguration().getId();
    }
    return new Quad<Integer, IAddress, Integer, IAddress>(srcModuleId, srcAddr, dstModuleId, dstAddr);
}
Also used : Quad(com.google.security.zynamics.zylib.general.Quad) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress)

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