Package ghidra.program.model.address
Class DefaultAddressFactory
java.lang.Object
ghidra.program.model.address.DefaultAddressFactory
- All Implemented Interfaces:
AddressFactory
- Direct Known Subclasses:
ProgramAddressFactory
Keeps track of all the Address spaces in the program and provides
methods for parsing address strings.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultAddressFactory(AddressSpace[] addrSpaces) Constructs a new DefaultAddressFactory.DefaultAddressFactory(AddressSpace[] addrSpaces, AddressSpace defaultSpace) Constructs a new DefaultAddressFactory with the given spaces and default space. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAddressSpace(AddressSpace space) Adds an AddressSpace to this factorybooleangetAddress(int spaceID, long offset) Get an address using the addressSpace with the given id and having the given offset.getAddress(String addrString) Create an address from String.Returns an addressSet containing all possible "real" addresses for this address factory.getAddressSet(Address min, Address max) Computes an address set from a start and end address that may span address spaces.getAddressSpace(int spaceID) Returns the space with the given spaceID or null if none existsgetAddressSpace(String name) Returns the space with the given name or null if no space exists with that name.Get the array of all "physical" AddressSpaces.Address[]getAllAddresses(String addrString) Generates all reasonable addresses that can be interpreted from the given string.Address[]getAllAddresses(String addrString, boolean caseSensitive) Generates all reasonable addresses that can be interpreted from the given string.Returns an array of all address spaces, including analysis spaces.getConstantAddress(long offset) Returns an address in "constant" space with the given offset.Returns the "constant" address space.Returns the default AddressSpacelongReturns the index (old encoding) for the given address.intReturns the number of physical AddressSpaces.getPhysicalSpace(AddressSpace space) Gets the physical address space associated with the given address space.Returns an array of all the physical address spaces.Returns the "register" address space.Returns the "stack" address space.Returns the "unique" address space.booleanReturns true if there is more than one memory address spacebooleanisValidAddress(Address addr) Tests if the given address is valid for at least one of the Address Spaces in this factoryoldGetAddressFromLong(long value) Returns the address using the old encoding format.protected OverlayAddressSpaceoverlaySpaceRenamed(String oldOverlaySpaceName, String newName) Update address factory map following the rename of an overlay address space instance.protected voidremoveAddressSpace(String spaceName) Removes the AddressSpace from this factoryMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.program.model.address.AddressFactory
hasStaleOverlayCondition
-
Constructor Details
-
DefaultAddressFactory
Constructs a new DefaultAddressFactory. The default space is assumed to be the first space in the array.- Parameters:
addrSpaces- array of address spaces for the Program
-
DefaultAddressFactory
Constructs a new DefaultAddressFactory with the given spaces and default space.- Parameters:
addrSpaces- the set of addressSpaces to managedefaultSpace- the space to use as the default space. The default space should be one of the spaces provided in the addrSpaces array.
-
-
Method Details
-
getAddress
Description copied from interface:AddressFactoryCreate an address from String. Attempts to use the "default" address space first. Otherwise loops through each addressSpace, returning the first valid address that any addressSpace creates from the string. Returns an Address if the string is valid, otherwise null.- Specified by:
getAddressin interfaceAddressFactory- See Also:
-
getAllAddresses
Description copied from interface:AddressFactoryGenerates all reasonable addresses that can be interpreted from the given string. Each Address Space is given a change to parse the string and all the valid results are return in the array.- Specified by:
getAllAddressesin interfaceAddressFactory- Parameters:
addrString- the address string to parse.- Returns:
- Address[] The list of addresses generated from the string.
-
getAllAddresses
Description copied from interface:AddressFactoryGenerates all reasonable addresses that can be interpreted from the given string. Each Address Space is given a change to parse the string and all the valid results are return in the array.- Specified by:
getAllAddressesin interfaceAddressFactory- Parameters:
addrString- the address string to parse.caseSensitive- determines if addressSpace names must be case sensitive to match.- Returns:
- Address[] The list of addresses generated from the string.
-
getDefaultAddressSpace
Description copied from interface:AddressFactoryReturns the default AddressSpace- Specified by:
getDefaultAddressSpacein interfaceAddressFactory
-
getAddressSpaces
Description copied from interface:AddressFactoryGet the array of all "physical" AddressSpaces.- Specified by:
getAddressSpacesin interfaceAddressFactory
-
getAllAddressSpaces
Description copied from interface:AddressFactoryReturns an array of all address spaces, including analysis spaces.- Specified by:
getAllAddressSpacesin interfaceAddressFactory- Returns:
- an array of all the address spaces.
-
getAddressSpace
Description copied from interface:AddressFactoryReturns the space with the given name or null if no space exists with that name.- Specified by:
getAddressSpacein interfaceAddressFactory
-
getAddressSpace
Description copied from interface:AddressFactoryReturns the space with the given spaceID or null if none exists- Specified by:
getAddressSpacein interfaceAddressFactory
-
getNumAddressSpaces
public int getNumAddressSpaces()Description copied from interface:AddressFactoryReturns the number of physical AddressSpaces.- Specified by:
getNumAddressSpacesin interfaceAddressFactory
-
isValidAddress
Description copied from interface:AddressFactoryTests if the given address is valid for at least one of the Address Spaces in this factory- Specified by:
isValidAddressin interfaceAddressFactory- Parameters:
addr- The address to test- Returns:
- boolean true if the address valid, false otherwise
-
equals
- Specified by:
equalsin interfaceAddressFactory- Overrides:
equalsin classObject- See Also:
-
getIndex
Description copied from interface:AddressFactoryReturns the index (old encoding) for the given address.- Specified by:
getIndexin interfaceAddressFactory- Parameters:
addr- the address to encode.
-
getPhysicalSpace
Description copied from interface:AddressFactoryGets the physical address space associated with the given address space. If the given space is physical, then it will be returned.- Specified by:
getPhysicalSpacein interfaceAddressFactory- Parameters:
space- the addressSpace for which the physical space is requested.- Returns:
- the physical address space associated with the given address space.
-
getPhysicalSpaces
Description copied from interface:AddressFactoryReturns an array of all the physical address spaces.- Specified by:
getPhysicalSpacesin interfaceAddressFactory- Returns:
- an array of all the physical address spaces.
-
getAddress
Description copied from interface:AddressFactoryGet an address using the addressSpace with the given id and having the given offset.- Specified by:
getAddressin interfaceAddressFactory- Parameters:
spaceID- the id of the address space to use to create the new address.offset- the offset of the new address to be created.- Returns:
- the new address.
-
getConstantSpace
Description copied from interface:AddressFactoryReturns the "constant" address space.- Specified by:
getConstantSpacein interfaceAddressFactory
-
getUniqueSpace
Description copied from interface:AddressFactoryReturns the "unique" address space.- Specified by:
getUniqueSpacein interfaceAddressFactory
-
getStackSpace
Description copied from interface:AddressFactoryReturns the "stack" address space.- Specified by:
getStackSpacein interfaceAddressFactory
-
getRegisterSpace
Description copied from interface:AddressFactoryReturns the "register" address space.- Specified by:
getRegisterSpacein interfaceAddressFactory
-
getConstantAddress
Description copied from interface:AddressFactoryReturns an address in "constant" space with the given offset.- Specified by:
getConstantAddressin interfaceAddressFactory- Parameters:
offset- the offset in "constant" space for the new address.- Returns:
- a new address in the "constant" space with the given offset.
-
getAddressSet
Description copied from interface:AddressFactoryComputes an address set from a start and end address that may span address spaces. Although in general, it is not meaningful to compare addresses from multiple spaces, but since there is an absolute ordering of address spaces it can be useful for iterating over all addresses in a program with multiple address spaces.- Specified by:
getAddressSetin interfaceAddressFactory- Parameters:
min- the start addressmax- the end address.- Returns:
- an addressSet containing ranges that don't span address spaces.
-
getAddressSet
Description copied from interface:AddressFactoryReturns an addressSet containing all possible "real" addresses for this address factory.- Specified by:
getAddressSetin interfaceAddressFactory
-
oldGetAddressFromLong
Description copied from interface:AddressFactoryReturns the address using the old encoding format.- Specified by:
oldGetAddressFromLongin interfaceAddressFactory- Parameters:
value- to decode into an address.
-
addAddressSpace
Adds an AddressSpace to this factory- Parameters:
space- the address space being added.- Throws:
DuplicateNameException- if an address space with the given name already exists
-
overlaySpaceRenamed
Update address factory map following the rename of an overlay address space instance. The caller is reponsible for the actual renaming of the existing overlay space instance and must ensure the newName is not already assigned to another space.- Parameters:
oldOverlaySpaceName- previous name of existing overlay spacenewName- new name for existing overlay space- Returns:
- overlay space instance which was renamed
-
removeAddressSpace
Removes the AddressSpace from this factory- Parameters:
spaceName- the name of the space to remove.
-
hasMultipleMemorySpaces
public boolean hasMultipleMemorySpaces()Description copied from interface:AddressFactoryReturns true if there is more than one memory address space- Specified by:
hasMultipleMemorySpacesin interfaceAddressFactory
-