use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method createTypeInstanceReference5.
@Test
public void createTypeInstanceReference5() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
module.load();
final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
final TypeInstanceAddress address1 = typeInstance.getAddress();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress("1001929", 16));
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
final INaviInstruction instruction = view.getBasicBlocks().get(1).getInstructions().iterator().next();
Assert.assertNotNull(typeInstance);
provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(0)), instruction.getOperands().get(0).getNodes().get(0).getId(), typeInstance.getId());
view.close();
module.close();
module.load();
view.load();
final TypeInstance typeInstance2 = module.getContent().getTypeInstanceContainer().getTypeInstance(typeInstance.getAddress());
Assert.assertEquals(address1, typeInstance2.getAddress());
final List<TypeInstanceReference> references = module.getContent().getTypeInstanceContainer().getReferences(typeInstance2);
Assert.assertTrue(!references.isEmpty());
Assert.assertEquals(instruction.getAddress(), references.get(0).getAddress());
Assert.assertEquals(instruction.getOperandPosition(instruction.getOperands().get(0)), references.get(0).getPosition());
Assert.assertEquals(instruction.getOperands().get(0).getNodes().get(0).getId(), references.get(0).getTreeNode().get().getId());
Assert.assertEquals(typeInstance.getId(), references.get(0).getTypeInstance().getId());
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method setTypeInstanceNameTest4.
@Test
public void setTypeInstanceNameTest4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
module.load();
final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
final TypeInstanceAddress address = typeInstance.getAddress();
provider.setTypeInstanceName(module.getConfiguration().getId(), typeInstance.getId(), " SUPER NEW NAME ");
module.close();
module.load();
final TypeInstance loadedInstance = module.getContent().getTypeInstanceContainer().getTypeInstance(address);
Assert.assertEquals(" SUPER NEW NAME ", loadedInstance.getName());
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceAddress in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method deleteTypeInstanceReferenceTest5.
@Test
public void deleteTypeInstanceReferenceTest5() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, CouldntSaveDataException {
module.load();
final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
final TypeInstanceAddress address1 = typeInstance.getAddress();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress("1001929", 16));
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
final INaviInstruction instruction = view.getBasicBlocks().get(2).getInstructions().iterator().next();
Assert.assertNotNull(typeInstance);
provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(1)), instruction.getOperands().get(0).getNodes().get(0).getId(), typeInstance.getId());
view.close();
module.close();
module.load();
view.load();
final TypeInstance typeInstance2 = module.getContent().getTypeInstanceContainer().getTypeInstance(typeInstance.getAddress());
Assert.assertEquals(address1, typeInstance2.getAddress());
final List<TypeInstanceReference> references = module.getContent().getTypeInstanceContainer().getReferences(typeInstance2);
Assert.assertTrue(!references.isEmpty());
final TypeInstanceReference reference = Iterables.find(references, new Predicate<TypeInstanceReference>() {
@Override
public boolean apply(final TypeInstanceReference reference) {
return reference.getAddress().equals(instruction.getAddress());
}
});
Assert.assertNotNull(reference);
provider.deleteTypeInstanceReference(module.getConfiguration().getId(), reference.getAddress().toBigInteger(), reference.getPosition(), reference.getTreeNode().get().getId());
}
Aggregations