use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class StepBreakpointHitSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final StepBreakpointHitReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final ProcessManager processManager = getDebugger().getProcessManager();
RelocatedAddress breakpointAddress = null;
final RegisterValues registerValues = reply.getRegisterValues();
final long tid = reply.getThreadId();
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
for (final RegisterValue registerValue : threadRegisters) {
if (registerValue.isPc()) {
breakpointAddress = new RelocatedAddress(new CAddress(registerValue.getValue()));
break;
}
}
}
}
manager.clearBreakpointsPassive(BreakpointType.STEP);
try {
final TargetProcessThread thread = processManager.getThread(tid);
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
// Update the thread with the new register values.
thread.setRegisterValues(threadRegisters.getRegisters());
}
}
processManager.setActiveThread(thread);
thread.setCurrentAddress(breakpointAddress);
} catch (final MaybeNullException exception) {
// Apparently there is no thread with the specified TID.
// This is not necessarily an error because the thread might have
// been closed while this handler was active.
// Nevertheless this should be logged.
NaviLogger.info("Error: Process manager could not get thread. Exception %s", exception);
return;
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class HaltSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final HaltReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
try {
final TargetProcessThread thread = processManager.getThread(reply.getTid());
processManager.setActiveThread(thread);
} catch (final MaybeNullException e) {
NaviLogger.severe("Error: Process manager could not set active threads. Exception %s", e);
// Apparently there is no thread with the specified TID.
// This is not necessarily an error because the thread might have
// been closed while this handler was active.
// Nevertheless this should be logged.
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class ModuleLoadedSynchronizer method setActiveThreadById.
/**
* Sets the currently active thread in the process manager.
*
* @param threadId The thread id to be activated.
*/
private static void setActiveThreadById(final ProcessManager processManager, final long threadId) {
try {
final TargetProcessThread thread = processManager.getThread(threadId);
processManager.setActiveThread(thread);
} catch (final MaybeNullException exception) {
CUtilityFunctions.logException(exception);
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class CViewPruner method convertNodes.
/**
* Converts the nodes from the original view to the pruned view.
*
* @param view The original view.
* @param prunedView The pruned view.
* @param keptInstructions Instructions to add to the new view.
*
* @return A mapping between nodes of the original view and nodes of the pruned view.
*/
private static Map<INaviViewNode, INaviViewNode> convertNodes(final INaviView view, final INaviView prunedView, final List<INaviInstruction> keptInstructions) {
final Map<INaviViewNode, INaviViewNode> nodeMap = new HashMap<INaviViewNode, INaviViewNode>();
for (final INaviViewNode node : view.getGraph().getNodes()) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) node;
final ArrayList<INaviInstruction> newInstructions = Lists.newArrayList(cnode.getInstructions());
newInstructions.retainAll(keptInstructions);
if (!newInstructions.isEmpty()) {
CCodeNode newNode;
try {
newNode = prunedView.getContent().createCodeNode(cnode.getParentFunction(), newInstructions);
} catch (final MaybeNullException e) {
newNode = prunedView.getContent().createCodeNode(null, newInstructions);
}
newNode.setBorderColor(node.getBorderColor());
newNode.setColor(node.getColor());
nodeMap.put(node, newNode);
}
} else if (node instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node).getFunction();
final CFunctionNode newNode = prunedView.getContent().createFunctionNode(function);
nodeMap.put(node, newNode);
}
}
return nodeMap;
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class CGlobalEdgeCommentSynchronizer method updateOpenViews.
/**
* Pushes a new global edge comment to all open views.
*
* @param edge The edge that has the new comment.
* @param comments The new comment of the code node.
*
* @throws CouldntSaveDataException Thrown if updating the edge comments failed.
*/
public static void updateOpenViews(final INaviEdge edge, final ArrayList<IComment> comments) throws CouldntSaveDataException {
try {
final Pair<INaviModule, INaviModule> modules = getModules(edge);
if (modules.first() != modules.second()) {
// TODO: Handle this
return;
}
if ((modules.first() != null) && (modules.second() != null) && modules.first().isLoaded()) {
final List<INaviEdge> edgelist = new ArrayList<INaviEdge>();
final Quad<Integer, IAddress, Integer, IAddress> refEdgeData = getEdgeData(edge);
for (final INaviView view : modules.first().getContent().getViewContainer().getViews()) {
edgelist.addAll(collectEdges(view, refEdgeData));
}
for (final INaviEdge updateEdge : edgelist) {
updateEdge.initializeGlobalComment(comments);
}
}
} catch (final MaybeNullException exception) {
// Trying to update global comments of code nodes without global comments.
}
}
Aggregations