use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class CNameListGenerators method getNameList.
/**
* Generates a name list from the names of the given modules.
*
* @param modules The modules that provide the names.
*
* @return The generated name list.
*/
public static String getNameList(final INaviModule[] modules) {
int count = 0;
final StringBuilder list = new StringBuilder();
for (final INaviModule module : modules) {
list.append("- ");
list.append(module.getConfiguration().getName());
list.append('\n');
count++;
if ((count == MAX_LIST_LENGTH) && (modules.length != MAX_LIST_LENGTH)) {
list.append("\n... ");
list.append(String.format("%d others ...", modules.length - count));
break;
}
}
return list.toString();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class ProjectTest method testCreateAddressSpace.
@Test
public void testCreateAddressSpace() throws CouldntLoadDataException, CouldntSaveDataException {
final MockProjectListener listener = new MockProjectListener();
m_project.load();
m_project.addListener(listener);
final AddressSpace space = m_project.createAddressSpace("Hannes Space");
space.load();
final INaviModule nativeModule = new MockModule(provider);
internalDatabase.getContent().addModule(nativeModule);
final Module module = ModuleFactory.get(nativeModule, provider);
module.load();
space.addModule(module);
assertEquals(space, m_project.getAddressSpaces().get(1));
assertEquals("Hannes Space", m_internalProject.getContent().getAddressSpaces().get(1).getConfiguration().getName());
assertEquals("addedAddressSpace;changedModificationDate;", listener.events);
assertEquals(0, m_project.getFunctions().size());
m_project.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testTypeInstanceCommentParsingDeleteComment.
@Test
public void testTypeInstanceCommentParsingDeleteComment() throws CouldntSaveDataException, CouldntLoadDataException {
final INaviModule module = new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
module.getContent().getSections().createSection("A", new CAddress(0), new CAddress(1234), SectionPermission.READ, null);
final TypeInstance fakeInstance = module.getContent().getTypeInstanceContainer().createInstance("TYPE INSTANCE", null, module.getTypeManager().getTypes().get(0), module.getContent().getSections().getSection(0), 0);
final PGNotification notification = new MockPGNotification("comment_changes", "bn_type_instances UPDATE 1 " + fakeInstance.getId() + " null");
final CommentNotification result = PostgreSQLCommentNotificationParser.processTypeInstanceCommentNotification(notification, provider);
assertNotNull(result);
final TypeInstanceCommentNotificationContainer container = (TypeInstanceCommentNotificationContainer) result;
assertNotNull(container);
final TypeInstance instance = container.getInstance();
assertEquals(fakeInstance.getId(), instance.getId());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class MockSqlProvider method createSection.
@Override
public int createSection(final int moduleId, final String name, final Integer commentId, final BigInteger startAddress, final BigInteger endAddress, final SectionPermission permission, final byte[] data) throws CouldntSaveDataException {
INaviModule sectionModule = null;
for (final INaviModule module : modules) {
if (module.getConfiguration().getId() == moduleId) {
sectionModule = module;
}
}
final Section section = new Section(sectionId++, name, CommentManager.get(this), sectionModule, new CAddress(startAddress), new CAddress(endAddress), permission, data);
sections.put(moduleId, section);
return section.getId();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testTypeInstanceCommentParsingAppendComment.
@Test
public void testTypeInstanceCommentParsingAppendComment() throws CouldntSaveDataException, CouldntLoadDataException {
final INaviModule module = new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
module.getContent().getSections().createSection("A", new CAddress(0), new CAddress(1234), SectionPermission.READ, null);
final TypeInstance fakeInstance = module.getContent().getTypeInstanceContainer().createInstance("TYPE INSTANCE", null, module.getTypeManager().getTypes().get(0), module.getContent().getSections().getSection(0), 0);
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_type_instances UPDATE 1 " + fakeInstance.getId() + " 3333");
final CommentNotification result = PostgreSQLCommentNotificationParser.processTypeInstanceCommentNotification(notification, provider);
assertNotNull(result);
final TypeInstanceCommentNotificationContainer container = (TypeInstanceCommentNotificationContainer) result;
assertNotNull(container);
final TypeInstance instance = container.getInstance();
assertEquals(fakeInstance.getId(), instance.getId());
assertEquals(CommentOperation.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
}
Aggregations