Search in sources :

Example 21 with MemoryModule

use of com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule 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)

Aggregations

MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)21 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)15 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)13 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)12 Test (org.junit.Test)12 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)10 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)9 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)9 ArrayList (java.util.ArrayList)8 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)7 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)7 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)7 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)6 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)6 ProcessStart (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessStart)5 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)5 ModuleLoadedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleLoadedReply)4 ModuleUnloadedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleUnloadedReply)4 ProcessStartReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ProcessStartReply)3