mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-1692 added recursive form of Function.getFunctionThunkAddresses method
This commit is contained in:
parent
66c0b49b87
commit
c34a26c24b
6 changed files with 74 additions and 22 deletions
|
@ -165,23 +165,36 @@ public class FunctionDB extends DatabaseObject implements Function {
|
|||
}
|
||||
}
|
||||
|
||||
private List<Address> getFunctionThunkAddresses(long functionId, boolean recursive) {
|
||||
List<Long> functionIds = manager.getThunkFunctionIds(functionId);
|
||||
if (functionIds == null) {
|
||||
return null;
|
||||
}
|
||||
SymbolTable symMgr = program.getSymbolTable();
|
||||
List<Address> thunkAddrList = new ArrayList<>();
|
||||
for (long id : functionIds) {
|
||||
Symbol s = symMgr.getSymbol(id);
|
||||
thunkAddrList.add(s.getAddress());
|
||||
if (recursive) {
|
||||
List<Address> thunkAddrs = getFunctionThunkAddresses(id, true);
|
||||
if (thunkAddrs != null) {
|
||||
thunkAddrList.addAll(thunkAddrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return thunkAddrList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address[] getFunctionThunkAddresses() {
|
||||
public Address[] getFunctionThunkAddresses(boolean recursive) {
|
||||
manager.lock.acquire();
|
||||
try {
|
||||
checkIsValid();
|
||||
List<Long> functionIds = manager.getThunkFunctionIds(key);
|
||||
if (functionIds == null) {
|
||||
List<Address> thunkAddrList = getFunctionThunkAddresses(key, recursive);
|
||||
if (thunkAddrList == null) {
|
||||
return null;
|
||||
}
|
||||
SymbolTable symMgr = program.getSymbolTable();
|
||||
Address[] addresses = new Address[functionIds.size()];
|
||||
int index = 0;
|
||||
for (long functionId : functionIds) {
|
||||
Symbol s = symMgr.getSymbol(functionId);
|
||||
addresses[index++] = s.getAddress();
|
||||
}
|
||||
return addresses;
|
||||
return thunkAddrList.toArray(new Address[thunkAddrList.size()]);
|
||||
}
|
||||
finally {
|
||||
manager.lock.release();
|
||||
|
|
|
@ -661,10 +661,24 @@ public interface Function extends Namespace {
|
|||
public Function getThunkedFunction(boolean recursive);
|
||||
|
||||
/**
|
||||
* If this function is "Thunked", an array of Thunk Function entry points is returned
|
||||
* If this function is "Thunked", an array of Thunk Function entry points is returned.
|
||||
* A non-recursive search is performed (i.e., first-hop only).
|
||||
* @return associated thunk function entry points or null if this is not a "Thunked" function.
|
||||
* @deprecated since many use cases will likely want a complete list of thunk functions
|
||||
* a recursive search is generally needed (see {@link #getFunctionThunkAddresses(boolean)}).
|
||||
* This method form may be removed in a future release.
|
||||
*/
|
||||
public default Address[] getFunctionThunkAddresses() {
|
||||
return getFunctionThunkAddresses(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this function is "Thunked", an array of Thunk Function entry points is returned.
|
||||
* @param recursive if true a recursive search is performed returning all effective thunks
|
||||
* of this function, else if false only the first-hop (i.e., direct thunks) are returned.
|
||||
* @return associated thunk function entry points or null if this is not a "Thunked" function.
|
||||
*/
|
||||
public Address[] getFunctionThunkAddresses();
|
||||
public Address[] getFunctionThunkAddresses(boolean recursive);
|
||||
|
||||
/**
|
||||
* Set the currently Thunked Function or null to convert to a normal function
|
||||
|
|
|
@ -407,7 +407,7 @@ public class FunctionTestDouble implements Function {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Address[] getFunctionThunkAddresses() {
|
||||
public Address[] getFunctionThunkAddresses(boolean recursive) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue