use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class PostgreSQLProviderTest method testSetHost3.
@Test(expected = NullPointerException.class)
public void testSetHost3() throws CouldntSaveDataException, CouldntLoadDataException {
final DebuggerTemplate debuggerTemplate = getProvider().loadDebuggers().getDebugger(0);
getProvider().setHost(debuggerTemplate, null);
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class CDatabaseFunctions method addDebugger.
/**
* Adds a new debugger to the database.
*
* @param parent Parent window used for dialogs.
* @param database The database where the debugger is added.
* @param name The name of the new debugger.
* @param host The host information of the new debugger.
* @param port The port information of the new debugger.
* @param updater Updates the project tree after the action is complete.
*/
public static void addDebugger(final JFrame parent, final IDatabase database, final String name, final String host, final int port, final INodeSelectionUpdater updater) {
new Thread() {
@Override
public void run() {
final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
try {
operation.getProgressPanel().setMaximum(1);
operation.getProgressPanel().setText("Creating new debugger");
final DebuggerTemplate template = database.getContent().getDebuggerTemplateManager().createDebugger(name, host, port);
updater.setObject(template);
updater.update();
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
final String message = "E00028: " + "Debugger could not be created";
final String description = CUtilityFunctions.createDescription(String.format("The debugger '%s' could not be created. " + "Try creating the debugger again. " + "If the problem persists, disconnect from and reconnect " + "to the database, restart BinNavi, or contact the BinNavi support.", name), new String[] { "Database connection problems." }, new String[] { "The debugger was not created." });
NaviErrorDialog.show(parent, message, description, exception);
} finally {
operation.getProgressPanel().next();
operation.stop();
}
}
}.start();
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class ViewNodeTest method setUp.
@Before
public void setUp() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, FileReadException {
ConfigManager.instance().read();
final MockSqlProvider provider = new MockSqlProvider();
final Database database = new Database(new MockDatabase());
final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), CommonTestObjects.MD5, CommonTestObjects.SHA1, 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
internalModule.load();
final CTagManager mockTagManager = new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "Root", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider);
m_nodeTagManager = new TagManager(mockTagManager);
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final Function function = new Function(ModuleFactory.get(), parentFunction);
final Module module = new Module(database, internalModule, m_nodeTagManager, viewTagManager) {
@Override
public Function getFunction(final INaviFunction internalFunction) {
return function;
}
@Override
public boolean isLoaded() {
return true;
}
};
final CFunction internalFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "", "", "", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final ITreeNode<CTag> tag = mockTagManager.addTag(mockTagManager.getRootTag(), "Initial Tag");
m_initialTag = m_nodeTagManager.getRootTags().get(0);
final CView internalView = internalModule.getContent().getViewContainer().createView("", "");
final CFunctionNode node = internalView.getContent().createFunctionNode(internalFunction);
node.setColor(Color.MAGENTA);
node.setX(10);
node.setY(20);
node.tagNode(tag.getObject());
m_view = module.getViews().get(2);
m_node = (FunctionNode) m_view.getGraph().getNodes().get(0);
final CFunctionNode node2 = internalView.getContent().createFunctionNode(internalFunction);
internalView.getContent().createEdge(node, node2, EdgeType.INTER_MODULE);
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class InstructionTest method testReil.
@Test
public void testReil() throws InternalTranslationException, CouldntLoadDataException, LoadCancelledException {
final SQLProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
internalModule.load();
final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTree operand1 = new COperandTree(rootNode1, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTree operand2 = new COperandTree(rootNode2, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
final CInstruction internalInstruction = new CInstruction(false, internalModule, new CAddress(0x123), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", provider);
final Instruction instruction = new Instruction(internalInstruction);
instruction.getReilCode();
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.
the class InstructionTest method testCommentInitialization.
@Test
public void testCommentInitialization() throws CouldntLoadDataException, LoadCancelledException {
final SQLProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
internalModule.load();
final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTree operand1 = new COperandTree(rootNode1, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTree operand2 = new COperandTree(rootNode2, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
final CInstruction internalInstruction = new CInstruction(false, internalModule, new CAddress(0x123), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", provider);
final Instruction instruction = new Instruction(internalInstruction);
final MockInstructionListener listener = new MockInstructionListener();
instruction.addListener(listener);
final ArrayList<IComment> comment = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Hannes"));
instruction.initializeComment(comment);
assertEquals(comment, internalInstruction.getGlobalComment());
assertEquals(comment, instruction.getComment());
// TODO (timkornau): check if double messages are what we want here of rather not.
// assertEquals("InitializedComment;", listener.events);
instruction.removeListener(listener);
}
Aggregations