use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CModuleTest method testAddresses.
@Test
public void testAddresses() throws CouldntSaveDataException {
assertEquals("00000555", m_module.getConfiguration().getFileBase().toHexString());
m_module.getConfiguration().setFileBase(new CAddress(0x02000000));
// Check listener events
assertEquals("changedFileBase=02000000/", m_listener.eventList);
// Check module
assertEquals("02000000", m_module.getConfiguration().getFileBase().toHexString());
m_module.getConfiguration().setFileBase(new CAddress(0x02000000));
// Check listener events
assertEquals("changedFileBase=02000000/", m_listener.eventList);
// ------------------------------------------ Image Base
// -------------------------------------------------
assertEquals("00000666", m_module.getConfiguration().getImageBase().toHexString());
m_module.getConfiguration().setImageBase(new CAddress(0xFFFFFFFFL));
// Check listener events
assertEquals("changedFileBase=02000000/changedImageBase=FFFFFFFF/", m_listener.eventList);
// Check module
assertEquals("FFFFFFFF", m_module.getConfiguration().getImageBase().toHexString());
m_module.getConfiguration().setImageBase(new CAddress(0xFFFFFFFFL));
// Check listener events
assertEquals("changedFileBase=02000000/changedImageBase=FFFFFFFF/", m_listener.eventList);
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class SectionContainerBackendTest method createSectionTest3.
@Test(expected = NullPointerException.class)
public void createSectionTest3() throws CouldntSaveDataException {
final SectionContainerBackend sectionContainerBackend = new SectionContainerBackend(provider, module);
Assert.assertNotNull(sectionContainerBackend);
sectionContainerBackend.createSection(".data2", new CAddress("100", 16), null, null, null);
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class SectionContainerBackendTest method createSectionTest6.
@Test
public void createSectionTest6() throws CouldntSaveDataException {
final SectionContainerBackend sectionContainerBackend = new SectionContainerBackend(provider, module);
Assert.assertNotNull(sectionContainerBackend);
final Section section = sectionContainerBackend.createSection(".data2", new CAddress("100", 16), new CAddress("200", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] { (byte) 0x90, (byte) 0xFF, (byte) 0x00 });
Assert.assertNotNull(section);
Assert.assertEquals(".data2", section.getName());
Assert.assertEquals(new CAddress("100", 16), section.getStartAddress());
Assert.assertEquals(new CAddress("200", 16), section.getEndAddress());
Assert.assertEquals(SectionPermission.READ_WRITE_EXECUTE, section.getSectionPermission());
org.junit.Assert.assertArrayEquals(new byte[] { (byte) 0x90, (byte) 0xFF, (byte) 0x00 }, section.getData());
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class SectionContainerTests method getSectionTest1.
@Test
public void getSectionTest1() throws CouldntLoadDataException, CouldntSaveDataException {
final SectionContainer sectionContainer = new SectionContainer(backend);
Assert.assertNotNull(sectionContainer);
final Section section = sectionContainer.createSection("SECTION1", new CAddress("100", 16), new CAddress("200", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] { (byte) 0x90, (byte) 0x00, (byte) 0xFF });
Assert.assertEquals(section, sectionContainer.getSection(section.getId()));
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class SectionContainerTests method findSectionsTest2.
@Test
public void findSectionsTest2() throws CouldntLoadDataException, CouldntSaveDataException {
final SectionContainer sectionContainer = new SectionContainer(backend);
Assert.assertNotNull(sectionContainer);
final int numberOfSections = sectionContainer.getSections().size();
final List<Section> checkForFirstSearch = sectionContainer.findSections(new CAddress("100", 16));
final List<Section> checkForSecondSearch = sectionContainer.findSections(new CAddress("200", 16));
final int numberOfFoundSectionsFirstSearch = checkForFirstSearch.size();
final Section section1 = sectionContainer.createSection("SECTION1", new CAddress("100", 16), new CAddress("200", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] { (byte) 0x90, (byte) 0x00, (byte) 0xFF });
final Section section2 = sectionContainer.createSection("SECTION2", new CAddress("199", 16), new CAddress("299", 16), SectionPermission.READ, new byte[] { (byte) 0x90, (byte) 0x00, (byte) 0xFF });
final Section section3 = sectionContainer.createSection("SECTION3", new CAddress("300", 16), new CAddress("400", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] { (byte) 0x90, (byte) 0x00, (byte) 0xFF });
final Section section4 = sectionContainer.createSection("SECTION4", new CAddress("100", 16), new CAddress("200", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] { (byte) 0x90, (byte) 0x00, (byte) 0xFF });
final Section section5 = sectionContainer.createSection("SECTION5", new CAddress("0", 16), new CAddress("800", 16), SectionPermission.READ_WRITE_EXECUTE, new byte[] { (byte) 0x90, (byte) 0x00, (byte) 0xFF });
final List<Section> secondSectionSearch = sectionContainer.findSections(new CAddress("100", 16));
Assert.assertEquals(numberOfSections + 5, sectionContainer.getSections().size());
Assert.assertEquals(numberOfFoundSectionsFirstSearch + 3, secondSectionSearch.size());
Assert.assertTrue(secondSectionSearch.contains(section1));
Assert.assertFalse(secondSectionSearch.contains(section2));
Assert.assertFalse(secondSectionSearch.contains(section3));
Assert.assertTrue(secondSectionSearch.contains(section4));
Assert.assertTrue(secondSectionSearch.contains(section5));
final List<Section> thirdSectionSearch = sectionContainer.findSections(new CAddress("200", 16));
Assert.assertEquals(checkForSecondSearch.size() + 4, thirdSectionSearch.size());
Assert.assertTrue(thirdSectionSearch.contains(section1));
Assert.assertTrue(thirdSectionSearch.contains(section2));
Assert.assertFalse(thirdSectionSearch.contains(section3));
Assert.assertTrue(thirdSectionSearch.contains(section4));
Assert.assertTrue(thirdSectionSearch.contains(section5));
}
Aggregations