use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference in project binnavi by google.
the class CCodeNodeMenu method addInstanceReferenceMenu.
private void addInstanceReferenceMenu(final CGraphModel model, final COperandTreeNode treeNode) {
// We can possibly have more than one reference for a single tree node if we have multiple
// instances of the same section.
final INaviModule module = model.getViewContainer().getModules().get(0);
final List<TypeInstanceReference> references = treeNode.getTypeInstanceReferences();
add(new ShowTypeInstanceReferencesAction(model.getParent(), references, module));
add(new GotoTypeInstanceAction(references.get(0).getTypeInstance()));
add(new RenameTypeInstanceAction(model.getParent(), module.getContent().getTypeInstanceContainer(), references.get(0).getTypeInstance()));
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference 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.TypeInstanceReference in project binnavi by google.
the class ViewReferencesTableModel method addTypeInstancesToTree.
/**
* Adds the list of {@link TypeInstanceReference type instance references} for the given
* {@link INaviInstruction instruction} to the tree.
*
* @param typeInstanceReferences A List of {@link TypeInstanceReference type instance references}.
* @param instruction The {@link INaviInstruction instruction} to which the list of references
* belongs.
*/
private void addTypeInstancesToTree(final List<TypeInstanceReference> typeInstanceReferences, final INaviInstruction instruction) {
for (TypeInstanceReference typeInstanceReference : typeInstanceReferences) {
final BaseType baseType = typeInstanceReference.getTypeInstance().getBaseType();
addBaseType(baseType);
insertNodeInto(multiIndex.putTypeReference(typeInstanceReference, instruction), baseTypeToTreeNode.get(baseType), baseTypeToTreeNode.get(baseType).getChildCount());
}
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference in project binnavi by google.
the class TypeInstanceTableDatamodel method getLineFormatted.
@Override
public FormattedCharacterBuffer getLineFormatted(int rowIndex, int columnIndex, int lineIndex) {
Color backgroundColor = getBackgroundColor(rowIndex, columnIndex);
switch(columnIndex) {
case ADDRESS_INDEX:
TypeInstance type = typesToDisplay.get(rowIndex);
String addressString = "";
if (lineIndex == 0) {
addressString = TypeInstanceAddressTableCellRenderer.getStringToDisplay(false, type.getAddress());
}
return stringToFormattedCharacterBuffer(addressString, rowIndex, columnIndex);
case NAME_INDEX:
String typeName = "";
if (lineIndex == 0) {
typeName = typesToDisplay.get(rowIndex).getName();
}
return new FormattedCharacterBuffer(Strings.padEnd(typeName, columns[columnIndex].getWidth(), ' '), STANDARD_FONT, columns[columnIndex].getDefaultFontColor(), backgroundColor);
case TYPE_INDEX:
FormattedCharacterBuffer typeDeclaration = typeDeclarations.get(rowIndex);
if (typeDeclaration.getNumberOfLines() > lineIndex) {
return typeDeclarations.get(rowIndex).getLine(lineIndex).setBackgroundColor(backgroundColor);
}
return stringToFormattedCharacterBuffer("", rowIndex, columnIndex);
case XREFS_INDEX:
TypeInstanceReference reference = getTypeInstanceReference(rowIndex, lineIndex);
String xrefString = "";
if (reference != null) {
xrefString = TypeInstanceCrossReferenceRenderer.renderText(reference);
}
return stringToFormattedCharacterBuffer(xrefString, rowIndex, columnIndex);
case COMMENTS_INDEX:
FormattedCharacterBuffer comment = generateFormattedComment(typeContainer.getComments(typesToDisplay.get(rowIndex)));
if (lineIndex < comment.getNumberOfLines()) {
// wasteful, clean it up eventually.
return comment.getLine(lineIndex).setBackgroundColor(backgroundColor);
}
// Return empty buffers for empty lines.
return stringToFormattedCharacterBuffer("", rowIndex, columnIndex);
default:
Logger.warning("Invalid column index, investigate.");
break;
}
return null;
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceReference in project binnavi by google.
the class COperandTreeNode method close.
@Override
public void close() {
if (replacement != null) {
replacement.close();
replacement.removeListener(listener);
}
if (substitution != null) {
operandTree.getInstruction().getModule().getTypeManager().removeTypeSubstitutionInstance(substitution);
}
if (instanceReferences != null && !instanceReferences.isEmpty()) {
final TypeInstanceContainer container = operandTree.getInstruction().getModule().getContent().getTypeInstanceContainer();
for (final TypeInstanceReference reference : instanceReferences) {
container.deactivateTypeInstanceReference(reference);
}
}
}
Aggregations