use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CModuleOverviewPanel method saveFileBase.
/**
* Saves the module file base to the database.
*/
private void saveFileBase() {
try {
final CAddress fileBase = new CAddress(Convert.hexStringToLong(m_debuggerPanel.getFileBase()));
m_module.getConfiguration().setFileBase(new CAddress(fileBase));
} catch (final CouldntSaveDataException e) {
CUtilityFunctions.logException(e);
final String message = "E00165: " + "Could not change the module file base";
final String description = CUtilityFunctions.createDescription("The new module file base could not be saved to the database.", new String[] { "There was a problem with the connection to the database while the module file base was saved" }, new String[] { "The module file base was not saved. Please try to find out what went wrong with the database connection and try to save the module file base again." });
NaviErrorDialog.show(SwingUtilities.getWindowAncestor(this), message, description, e);
}
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CCodeNodeParserTest method testSameOperandTwice.
@Test
public void testSameOperandTwice() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
// 00000000: jz eax
// 00000001: jg eax
final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
final MockCodeNodeData instruction1 = new MockCodeNodeData();
instruction1.nodeId = 0;
instruction1.expressionId = 0;
instruction1.expressionType = 5;
instruction1.operandPosition = 0;
instruction1.symbol = "eax";
final MockCodeNodeData instruction2 = new MockCodeNodeData();
instruction2.address = new CAddress(BigInteger.ONE);
instruction2.nodeId = 1;
instruction2.expressionId = 0;
instruction2.expressionType = 5;
instruction2.operandPosition = 0;
instruction2.symbol = "eax";
cnProvider.data.add(instruction1);
cnProvider.data.add(instruction2);
final MockSqlProvider provider = new MockSqlProvider();
final MockModule module = new MockModule();
CFunctionContainerHelper.addFunction(module.getContent().getFunctionContainer(), new MockFunction(0));
final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(module), provider);
final List<CCodeNode> result = p.parse();
assertEquals(2, result.size());
assertEquals(1, Iterables.size(result.get(0).getInstructions()));
assertEquals(1, Iterables.size(result.get(1).getInstructions()));
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CCodeNodeParserTest method testReference.
@Test
public void testReference() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
// 00000000: jz 123
final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
final MockCodeNodeData instruction1 = new MockCodeNodeData();
instruction1.reference = new CReference(new CAddress(BigInteger.valueOf(123)), ReferenceType.CONDITIONAL_TRUE);
instruction1.nodeId = 0;
instruction1.expressionId = 0;
instruction1.expressionType = 2;
instruction1.operandPosition = 0;
instruction1.immediate = "123";
cnProvider.data.add(instruction1);
final MockSqlProvider provider = new MockSqlProvider();
final MockModule module = new MockModule();
CFunctionContainerHelper.addFunction(module.getContent().getFunctionContainer(), new MockFunction(0));
final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(module), provider);
final List<CCodeNode> result = p.parse();
assertEquals(1, result.size());
assertEquals(1, Iterables.size(result.get(0).getInstructions()));
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class PostgreSQLFunctionNotificationParserTest method testParser.
private void testParser(final String table, final String databaseOperation, final String address, final String moduleId) {
final String notification = table + " " + databaseOperation + " " + moduleId + " " + address;
notifications.add(new MockPGNotification("function_changes", notification));
final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
final Collection<FunctionNotificationContainer> result = parser.parse(notifications, provider);
assertNotNull(result);
assertTrue(!result.isEmpty());
assertTrue(result.size() == 1);
final FunctionNotificationContainer container = Iterables.getFirst(result, null);
assertNotNull(container);
assertEquals(databaseOperation, container.getDatabaseOperation());
assertEquals(new CAddress(address, 10), container.getFunctionAddress());
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGlobalCodeNodeCommentParsingAppendNewComment.
@Test
public void testGlobalCodeNodeCommentParsingAppendNewComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_node_comments UPDATE 1 4608 3333");
final Collection<CommentNotification> result = PostgreSQLCommentNotificationParser.processNodeGlobalCommentNotification(notification, provider);
assertEquals(1, result.size());
final CodeNodeCommentNotificationContainer container = (CodeNodeCommentNotificationContainer) Iterables.getFirst(result, null);
final INaviCodeNode node = container.getNode();
assertEquals(1111, node.getId());
assertEquals(new CAddress(4608), node.getAddress());
assertEquals(CommentOperation.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
assertEquals(CommentScope.GLOBAL, container.getScope());
}
Aggregations