Search in sources :

Example 46 with CAddress

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);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 47 with CAddress

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);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 48 with CAddress

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());
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 49 with CAddress

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()));
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 50 with CAddress

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));
}
Also used : 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