Search in sources :

Example 91 with CAddress

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);
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 92 with CAddress

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()));
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockCodeNodeData(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeData) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) MockCodeNodeProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeProvider) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 93 with CAddress

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()));
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockCodeNodeData(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeData) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CReference(com.google.security.zynamics.binnavi.disassembly.CReference) MockCodeNodeProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeProvider) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 94 with CAddress

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());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 95 with CAddress

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());
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CodeNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)315 Test (org.junit.Test)221 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)55 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)51 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)48 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)47 ArrayList (java.util.ArrayList)46 Date (java.util.Date)46 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)45 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)40 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)32 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)28 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)27 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)27 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)26 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)24 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)24