use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class TypeManagerTest method testNotifySubstitutionUpdated.
@Test
public void testNotifySubstitutionUpdated() throws CouldntSaveDataException {
final IAddress address = new CAddress(0x1000);
final INaviOperandTreeNode node = new MockOperandTreeNode();
final TypeSubstitution substitution = typeManager.createTypeSubstitution(node, typeSystem.intType, 0, 0, address);
final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
typeManager.addListener(events);
typeManager.updateTypeSubstitution(node, substitution, typeSystem.uintType, new ArrayList<TypeMember>(), 0);
typeManager.updateTypeSubstitution(node, typeSystem.uintType.getId(), new Integer[0], 0);
final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
expectedEvents.substitutionsChanged(Sets.newHashSet(substitution));
expectedEvents.substitutionsChanged(Sets.newHashSet(substitution));
Assert.assertEquals(expectedEvents, events);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class CFollowInDumpMenu method addFollowInDumpMenu.
/**
* Checks what follow in dump menus are needed and adds those that are missing.
*
* @param menu The popup menu to extend.
* @param viewModel Debug perspective model that shows the memory.
* @param debugger Provides the register values.
* @param activeThread The thread whose register values should be considered.
* @param module Needed for relocation information.
* @param treeNode The clicked operand tree node.
*
* @return True, if at least one menu was added. False, otherwise.
*/
private static boolean addFollowInDumpMenu(final JPopupMenu menu, final CDebugPerspectiveModel viewModel, final IDebugger debugger, final TargetProcessThread activeThread, final INaviModule module, final COperandTreeNode treeNode) {
final BigInteger simpleAddress = getSimpleAddress(treeNode, activeThread.getRegisterValues(), debugger, module);
if ((simpleAddress != null) && needsSimpleFollowMenu(debugger, treeNode, simpleAddress)) {
menu.add(new CGotoOperandExpressionAction(viewModel, treeNode.getValue(), simpleAddress));
return true;
}
final BigInteger expressionAddress = getExpressionAddress(treeNode, activeThread.getRegisterValues(), debugger, module);
// Don't show menu twice for instructions like "mov eax, [someSymbol]"
if ((expressionAddress != null) && !expressionAddress.equals(simpleAddress) && needsAddressExpressionMenu(debugger, treeNode, expressionAddress)) {
final INaviOperandTreeNode addressExpression = getAddressExpression(treeNode);
menu.add(new CGotoOperandExpressionAction(viewModel, toString(addressExpression), expressionAddress));
return true;
}
return false;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLTypeInstancesNotificationParserTest method setUp.
@Before
public void setUp() throws NumberFormatException, CouldntSaveDataException, CouldntLoadDataException {
view = MockViewGenerator.generate(provider, module, function);
baseType = module.getTypeManager().getTypes().get(0);
final Section section = module.getContent().getSections().createSection("TEST_SECTION", new CAddress("01000000", 16), new CAddress("0100FFFF", 16), SectionPermission.READ_WRITE_EXECUTE, null);
final TypeInstanceContainer container = module.getContent().getTypeInstanceContainer();
instance = container.createInstance("TEST_INSTANCE", null, baseType, section, new Long("11143"));
final CCodeNode node = view.getBasicBlocks().get(0);
final INaviInstruction instruction = node.getInstructions().iterator().next();
final INaviOperandTreeNode operandNode = instruction.getOperands().get(0).getNodes().get(0);
reference = container.createReference(instruction.getAddress(), 0, operandNode, instance, view);
assertNotNull(reference);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsDeleteReference4.
@Test
public void testInstructionFunctionsDeleteReference4() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, CouldntDeleteException, MaybeNullException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
final IAddress address = instruction.getAddress();
final ReferenceType type = ReferenceType.DATA;
final int references = node.getReferences().size();
PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
final INaviModule module2 = getProvider().loadModules().get(1);
module2.load();
final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
function2.load();
final IBlockNode basicBlock2 = function2.getBasicBlocks().get(0);
final INaviInstruction instruction2 = Iterables.get(basicBlock2.getInstructions(), 1);
final COperandTree tree2 = instruction2.getOperands().get(0);
final INaviOperandTreeNode node2 = tree2.getRootNode();
assertEquals(references + 1, node2.getReferences().size());
PostgreSQLInstructionFunctions.deleteReference(getProvider(), node2, address, type);
final INaviModule module3 = getProvider().loadModules().get(1);
module3.load();
final INaviFunction function3 = module3.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
function3.load();
final IBlockNode basicBlock3 = function3.getBasicBlocks().get(0);
final INaviInstruction instruction3 = Iterables.get(basicBlock3.getInstructions(), 1);
final COperandTree tree3 = instruction3.getOperands().get(0);
final INaviOperandTreeNode node3 = tree3.getRootNode();
assertEquals(references, node3.getReferences().size());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionSetGlobalReplacement1.
@Test
public void testInstructionFunctionSetGlobalReplacement1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, MaybeNullException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
final IInstruction instruction = Iterables.get(view.getContent().getBasicBlocks().get(0).getInstructions(), 4);
final INaviOperandTreeNode node = (INaviOperandTreeNode) instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0);
getProvider().setGlobalReplacement(node, "replacement");
view.close();
final INaviModule module2 = getProvider().loadModules().get(0);
module2.load();
final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunction("sub_1004565");
final INaviView view2 = module2.getContent().getViewContainer().getView(function2);
view2.load();
final IInstruction instruction2 = Iterables.get(view2.getContent().getBasicBlocks().get(0).getInstructions(), 4);
instruction2.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(0).getChildren().get(0);
}
Aggregations