Java Code Examples for ghidra.program.model.address.AddressSet#isEmpty()
The following examples show how to use
ghidra.program.model.address.AddressSet#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateDiffTask.java From ghidra with Apache License 2.0 | 6 votes |
private String getMemoryDifferenceMessage(final boolean noFilteredDifferencesFound, ProgramMemoryComparator programMemoryComparator) { String message; message = "The memory addresses defined by the two programs are not the same.\n \n" + (noFilteredDifferencesFound ? "However, no differences were found " : "Differences are highlighted ") + "for the addresses that are compatible between" + "\nthe two programs for the types of program information being compared by this Diff."; AddressSet addressesOnlyInOne = programMemoryComparator.getAddressesOnlyInOne(); if (!addressesOnlyInOne.isEmpty()) { message += "\n \nSome addresses are only in program 1 : " + addressesOnlyInOne.toString(); } AddressSet addressesOnlyInTwo = programMemoryComparator.getAddressesOnlyInTwo(); if (!addressesOnlyInTwo.isEmpty()) { message += "\n \nSome addresses are only in program 2 : " + addressesOnlyInTwo.toString(); } return message; }
Example 2
Source File: AddressTableDialog.java From ghidra with Apache License 2.0 | 6 votes |
private void doMakeSelection() { Program program = plugin.getProgram(); AddressSet set = new AddressSet(); AutoTableDisassemblerModel model = plugin.getModel(); int[] selectedRows = resultsTable.getSelectedRows(); for (int selectedRow : selectedRows) { Address selectedAddress = model.getAddress(selectedRow); AddressTable addrTab = model.get(selectedAddress); if (addrTab != null) { set.addRange(selectedAddress, selectedAddress.add(addrTab.getByteLength() - 1)); } } if (!set.isEmpty()) { plugin.firePluginEvent(new ProgramSelectionPluginEvent(plugin.getName(), new ProgramSelection(set), program)); } }
Example 3
Source File: MultiInstructionMemReference.java From ghidra with Apache License 2.0 | 6 votes |
@Override public void run() throws Exception { long numInstructions = currentProgram.getListing().getNumInstructions(); monitor.initialize((int) (numInstructions)); monitor.setMessage("Multi-Instruction Reference Markup"); int currentOpIndex = -1; Address start = currentLocation.getAddress(); if ((currentSelection == null || currentSelection.isEmpty()) && currentLocation instanceof OperandFieldLocation) { OperandFieldLocation operandLocation = (OperandFieldLocation) currentLocation; currentOpIndex = operandLocation.getOperandIndex(); int subOpIndex = operandLocation.getSubOperandIndex(); singleRegister = getRegister(start, currentOpIndex, subOpIndex); } // set up the address set to restrict processing AddressSet refLocationsSet = new AddressSet(currentSelection); if (refLocationsSet.isEmpty()) { refLocationsSet.addRange(start, start); } findMemRefAtOperand(currentOpIndex, refLocationsSet); }
Example 4
Source File: AddressTableDialog.java From ghidra with Apache License 2.0 | 5 votes |
private void createAction() { DockingAction selectAction = new MakeProgramSelectionAction(plugin, resultsTable) { @Override protected ProgramSelection makeSelection(ActionContext context) { Program program = plugin.getProgram(); AddressSet set = new AddressSet(); AutoTableDisassemblerModel model = plugin.getModel(); int[] selectedRows = resultsTable.getSelectedRows(); for (int selectedRow : selectedRows) { Address selectedAddress = model.getAddress(selectedRow); AddressTable addrTab = model.get(selectedAddress); if (addrTab != null) { set.addRange(selectedAddress, selectedAddress.add(addrTab.getByteLength() - 1)); } } ProgramSelection selection = new ProgramSelection(set); if (!set.isEmpty()) { plugin.firePluginEvent( new ProgramSelectionPluginEvent(plugin.getName(), selection, program)); } return selection; } }; selectionNavigationAction = new SelectionNavigationAction(plugin, resultsTable); selectionNavigationAction.setHelpLocation( new HelpLocation(HelpTopics.SEARCH, "AddressTables_Selection_Navigation")); addAction(selectionNavigationAction); addAction(selectAction); }
Example 5
Source File: SelectionAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(SymbolTreeActionContext context) { AddressSet set = new AddressSet(); for (Symbol symbol : context.getSymbols()) { if (symbol.isExternal()) { continue; } Object symbolObject = symbol.getObject(); if (symbolObject instanceof Namespace) { Namespace namespace = (Namespace) symbolObject; set.add(namespace.getBody()); } else if (symbolObject instanceof Variable) { ProgramLocation loc = symbol.getProgramLocation(); set.addRange(loc.getAddress(), loc.getAddress()); } else if (symbolObject instanceof CodeUnit) { CodeUnit cu = (CodeUnit) symbolObject; set.addRange(cu.getMinAddress(), cu.getMaxAddress()); } } if (!set.isEmpty()) { plugin.firePluginEvent(new ProgramSelectionPluginEvent(plugin.getName(), new ProgramSelection(set), context.getProgram())); } }
Example 6
Source File: SampleProgramTreePlugin.java From ghidra with Apache License 2.0 | 4 votes |
@Override public boolean applyTo(DomainObject obj, TaskMonitor monitor) { Program program = (Program) obj; listing = program.getListing(); createDefaultTreeView(program, programTreeName); Memory mem = program.getMemory(); ProgramModule root_module = listing.getRootModule(programTreeName); AddressSet set = new AddressSet(mem); try { root_module.createModule("Fragments"); } catch (DuplicateNameException e) { // don't care??? } ProgramModule frags = listing.getModule(programTreeName, "Fragments"); long startCount = set.getNumAddresses(); monitor.initialize(startCount); while (!monitor.isCancelled() && !set.isEmpty()) { MemoryBlock block = mem.getBlock(set.getMinAddress()); Address start = block.getStart(); Address end = block.getEnd(); set.deleteRange(block.getStart(), block.getEnd()); long numLeft = set.getNumAddresses(); monitor.setProgress(startCount - numLeft); String mod_name = block.getName(); monitor.setMessage("Module " + start + " : " + mod_name); ProgramModule mod = make_module(mod_name, frags); makeFragment(start, end, "frag_" + fragment_count, mod); fragment_count++; } return true; }