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));
}
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;
}
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);
}
}
}
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;
}
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);
}
Aggregations