Search in sources :

Example 6 with Section

use of com.google.security.zynamics.binnavi.disassembly.types.Section in project binnavi by google.

the class PostgreSQLSectionFunctionsTests method testCreateSection6.

@Test
public void testCreateSection6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviModule module = getKernel32Module();
    final String sectionName = " SECTION NAME ";
    final BigInteger startAddress = new BigInteger("10000", 16);
    final BigInteger endAddress = new BigInteger("20000", 16);
    final int sectionId = getProvider().createSection(module.getConfiguration().getId(), sectionName, null, startAddress, endAddress, SectionPermission.READ_WRITE_EXECUTE, new byte[] {});
    module.close();
    module.load();
    final Section section = module.getContent().getSections().getSection(sectionId);
    Assert.assertEquals(section.getName(), sectionName);
    Assert.assertEquals(section.getStartAddress().toBigInteger(), startAddress);
    Assert.assertEquals(section.getEndAddress().toBigInteger(), endAddress);
    Assert.assertEquals(section.getSectionPermission(), SectionPermission.READ_WRITE_EXECUTE);
    module.close();
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) BigInteger(java.math.BigInteger) Section(com.google.security.zynamics.binnavi.disassembly.types.Section) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 7 with Section

use of com.google.security.zynamics.binnavi.disassembly.types.Section in project binnavi by google.

the class PostgreSQLTypeInstanceFunctionsTests method createTypeInstance6.

@Test
public void createTypeInstance6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final String typeInstanceName = " TYPE INSTANCE NAME ";
    module.load();
    final Section section = module.getContent().getSections().getSections().get(0);
    final BaseType type = module.getTypeManager().getTypes().get(0);
    final int typeInstanceId = provider.createTypeInstance(module.getConfiguration().getId(), typeInstanceName, null, type.getId(), section.getId(), 0);
    module.close();
    module.load();
    final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstanceById(typeInstanceId);
    Assert.assertEquals(typeInstanceId, typeInstance.getId());
    Assert.assertEquals(typeInstanceName, typeInstance.getName());
    Assert.assertEquals(module, typeInstance.getModule());
    Assert.assertEquals(section.getId(), typeInstance.getSection().getId());
}
Also used : BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) RawTypeInstance(com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) Section(com.google.security.zynamics.binnavi.disassembly.types.Section) Test(org.junit.Test)

Example 8 with Section

use of com.google.security.zynamics.binnavi.disassembly.types.Section in project binnavi by google.

the class PostgreSQLTypeInstancesNotificationParserTest method setUp.

@Before
public void setUp() throws NumberFormatException, CouldntSaveDataException, CouldntLoadDataException {
    view = MockViewGenerator.generate(provider, module, function);
    baseType = module.getTypeManager().getTypes().get(0);
    final Section section = module.getContent().getSections().createSection("TEST_SECTION", new CAddress("01000000", 16), new CAddress("0100FFFF", 16), SectionPermission.READ_WRITE_EXECUTE, null);
    final TypeInstanceContainer container = module.getContent().getTypeInstanceContainer();
    instance = container.createInstance("TEST_INSTANCE", null, baseType, section, new Long("11143"));
    final CCodeNode node = view.getBasicBlocks().get(0);
    final INaviInstruction instruction = node.getInstructions().iterator().next();
    final INaviOperandTreeNode operandNode = instruction.getOperands().get(0).getNodes().get(0);
    reference = container.createReference(instruction.getAddress(), 0, operandNode, instance, view);
    assertNotNull(reference);
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) Section(com.google.security.zynamics.binnavi.disassembly.types.Section) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Before(org.junit.Before)

Example 9 with Section

use of com.google.security.zynamics.binnavi.disassembly.types.Section in project binnavi by google.

the class MockSqlProvider method setSectionName.

@Override
public void setSectionName(final int moduleId, final int sectionId, final String name) throws CouldntSaveDataException {
    Section oldSection = null;
    for (final Section section : sections.get(moduleId)) {
        if (section.getId() == sectionId) {
            oldSection = section;
            break;
        }
    }
    if (oldSection != null) {
        final Section newSection = new Section(oldSection.getId(), name, CommentManager.get(this), oldSection.getModule(), oldSection.getStartAddress(), oldSection.getEndAddress(), oldSection.getSectionPermission(), oldSection.getData());
        sections.remove(moduleId, oldSection);
        sections.put(moduleId, newSection);
    }
}
Also used : Section(com.google.security.zynamics.binnavi.disassembly.types.Section)

Example 10 with Section

use of com.google.security.zynamics.binnavi.disassembly.types.Section in project binnavi by google.

the class MockSqlProvider method deleteSection.

@Override
public void deleteSection(final Section section) {
    final Section currentSection = Iterables.find(sections.get(section.getModule().getConfiguration().getId()), new Predicate<Section>() {

        @Override
        public boolean apply(final Section currentSection) {
            return section.getId() == currentSection.getId();
        }
    });
    sections.remove(section.getModule().getConfiguration().getId(), currentSection);
}
Also used : Section(com.google.security.zynamics.binnavi.disassembly.types.Section)

Aggregations

Section (com.google.security.zynamics.binnavi.disassembly.types.Section)10 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 BigInteger (java.math.BigInteger)4 Test (org.junit.Test)4 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)3 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)1 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)1 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)1 BaseType (com.google.security.zynamics.binnavi.disassembly.types.BaseType)1 RawTypeInstance (com.google.security.zynamics.binnavi.disassembly.types.RawTypeInstance)1 SectionPermission (com.google.security.zynamics.binnavi.disassembly.types.SectionPermission)1 TypeInstance (com.google.security.zynamics.binnavi.disassembly.types.TypeInstance)1 TypeInstanceContainer (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)1 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Before (org.junit.Before)1