Java Code Examples for ghidra.program.model.address.Address#getAddressSpace()
The following examples show how to use
ghidra.program.model.address.Address#getAddressSpace() .
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: ListingDisplaySearchAddressIterator.java From ghidra with Apache License 2.0 | 6 votes |
private void updateLastAddress(Address startAddress) { if (startAddress == null) { return; } if (forward) { if (startAddress.getOffset() > 0) { lastAddress = startAddress.subtract(1); } } else { // don't add past the address range AddressSpace addressSpace = startAddress.getAddressSpace(); Address maxAddress = addressSpace.getMaxAddress(); long maxOffset = maxAddress.getOffset(); long startOffset = startAddress.getOffset(); long result = startOffset + 1; if (result > startOffset && result < maxOffset) { lastAddress = startAddress.add(1); } } }
Example 2
Source File: EditReferencesModel.java From ghidra with Apache License 2.0 | 6 votes |
static RefType[] getAllowedRefTypes(Program program, Reference ref) { Address toAddr = ref.getToAddress(); if (toAddr.isStackAddress()) { return RefTypeFactory.getStackRefTypes(); } if (toAddr.isRegisterAddress()) { return RefTypeFactory.getDataRefTypes(); } if (toAddr.isMemoryAddress()) { if (program.getAddressFactory().getDefaultAddressSpace() == toAddr.getAddressSpace() || isComputedFlow(program, ref)) { return RefTypeFactory.getMemoryRefTypes(); } return RefTypeFactory.getDataRefTypes(); } if (toAddr.isExternalAddress()) { return RefTypeFactory.getExternalRefTypes(); } throw new IllegalArgumentException("Unsupported reference"); }
Example 3
Source File: JavaAnalyzer.java From ghidra with Apache License 2.0 | 5 votes |
private boolean setEolComment(Program program, Address address, String comment) { if (address.getAddressSpace() != program.getAddressFactory().getDefaultAddressSpace()) { return false; } SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.EOL_COMMENT, comment); return cmd.applyTo(program); }
Example 4
Source File: StringEvent.java From ghidra with Apache License 2.0 | 5 votes |
private int subtract(Address bigAddress, Address smallAddress) { if (bigAddress.getAddressSpace() != smallAddress.getAddressSpace()) { return Integer.MAX_VALUE; } long diff = bigAddress.subtract(smallAddress); if (diff > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) diff; }
Example 5
Source File: AddressFieldFactory.java From ghidra with Apache License 2.0 | 5 votes |
private String getAddressString(CodeUnit cu) { Address addr = cu.getMinAddress(); AddressSpace space = addr.getAddressSpace(); if (displayBlockName) { String text = addr.toString(false, padZeros ? 16 : minHexDigits); MemoryBlock block = cu.getProgram().getMemory().getBlock(addr); if (block != null) { return block.getName() + ":" + text; } } return addr.toString(space.showSpaceName(), padZeros ? 16 : minHexDigits); }
Example 6
Source File: SetRegisterCmd.java From ghidra with Apache License 2.0 | 5 votes |
/** * Constructor for SetRegisterCmd. * @param register the register to change. * @param start the starting address of the range. * @param end the ending address of the range. * @param value the value to associated over the range. * A null value indicates that no value should be associated over the range. */ public SetRegisterCmd(Register register, Address start, Address end, BigInteger value) { if (start.getAddressSpace() != end.getAddressSpace()) { throw new IllegalArgumentException( "start and end address must be in the same address space"); } this.register = register; this.start = start; this.end = end; this.value = value; }
Example 7
Source File: AddressBasedLocation.java From ghidra with Apache License 2.0 | 5 votes |
@Override public int compareTo(AddressBasedLocation otherLocation) { Address otherAddress = otherLocation.address; // handle possible presence of null address if (address == null) { if (otherAddress == null) { return 0; } return -1; } if (otherAddress == null) { return 1; } AddressSpace mySpace = address.getAddressSpace(); AddressSpace otherSpace = otherAddress.getAddressSpace(); // compare on address space name first int rc = mySpace.getName().compareTo(otherSpace.getName()); if (rc != 0) { return rc; } return compareAddressSameSpace(otherLocation); }