Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2025-07-28 12:34:13 +00:00
commit 89534eecaf
7 changed files with 30 additions and 18 deletions

View file

@ -47,7 +47,7 @@ public class ApplyClassFunctionDefinitionUpdatesScript extends GhidraScript {
}
RecoveredClassHelper classHelper = new RecoveredClassHelper(currentProgram, state.getTool(),
this, false, false, false, monitor);
this, false, false, false, true, monitor);
DataTypeManagerService dtms = state.getTool().getService(DataTypeManagerService.class);
List<DataType> selectedDatatypes = dtms.getSelectedDatatypes();

View file

@ -47,7 +47,7 @@ public class ApplyClassFunctionSignatureUpdatesScript extends GhidraScript {
}
RecoveredClassHelper classHelper = new RecoveredClassHelper(currentProgram, state.getTool(),
this, false, false, false, monitor);
this, false, false, false, true, monitor);
if (currentAddress == null) {
println("Cursor must be in a class function.");

View file

@ -123,6 +123,9 @@ public class RecoverClassesFromRTTIScript extends GhidraScript {
// bookmark all constructor/destructor functions recognized by script
private static final boolean BOOKMARK_FOUND_FUNCTIONS = true;
// make vfunctions this calls
private static final boolean MAKE_VFUNCTIONS_THISCALLS = true;
// show a graph of class hierarchies after script is complete
// no parent = blue vertex
// single parent = green vertex
@ -193,7 +196,7 @@ public class RecoverClassesFromRTTIScript extends GhidraScript {
nameVfunctions = !hasDebugSymbols;
recoverClassesFromRTTI = new RTTIWindowsClassRecoverer(currentProgram, state.getTool(),
this, BOOKMARK_FOUND_FUNCTIONS, USE_SHORT_TEMPLATE_NAMES_IN_STRUCTURE_FIELDS,
nameVfunctions, hasDebugSymbols, monitor);
nameVfunctions, MAKE_VFUNCTIONS_THISCALLS, hasDebugSymbols, monitor);
}
else if (isPE() && isGcc()) {
@ -214,7 +217,7 @@ public class RecoverClassesFromRTTIScript extends GhidraScript {
recoverClassesFromRTTI = new RTTIGccClassRecoverer(currentProgram, state.getTool(),
this, BOOKMARK_FOUND_FUNCTIONS, USE_SHORT_TEMPLATE_NAMES_IN_STRUCTURE_FIELDS,
nameVfunctions, hasDebugSymbols, monitor);
nameVfunctions, MAKE_VFUNCTIONS_THISCALLS, hasDebugSymbols, monitor);
}
else if (isGcc()) {
@ -242,7 +245,7 @@ public class RecoverClassesFromRTTIScript extends GhidraScript {
nameVfunctions = !hasDebugSymbols;
recoverClassesFromRTTI = new RTTIGccClassRecoverer(currentProgram, state.getTool(),
this, BOOKMARK_FOUND_FUNCTIONS, USE_SHORT_TEMPLATE_NAMES_IN_STRUCTURE_FIELDS,
nameVfunctions, hasDebugSymbols, monitor);
nameVfunctions, MAKE_VFUNCTIONS_THISCALLS, hasDebugSymbols, monitor);
}
else {
println("This script will not work on this program type");

View file

@ -41,10 +41,11 @@ public class RTTIClassRecoverer extends RecoveredClassHelper {
RTTIClassRecoverer(Program program, ServiceProvider serviceProvider, FlatProgramAPI api,
boolean createBookmarks, boolean useShortTemplates, boolean nameVfunctions,
boolean hasDebugSymbols, TaskMonitor monitor) throws Exception {
boolean makeVfunctionsThisCalls,boolean hasDebugSymbols, TaskMonitor monitor)
throws Exception {
super(program, serviceProvider, api, createBookmarks, useShortTemplates, nameVfunctions,
monitor);
makeVfunctionsThisCalls,monitor);
this.hasDebugSymbols = hasDebugSymbols;

View file

@ -107,10 +107,11 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer {
public RTTIGccClassRecoverer(Program program, ServiceProvider serviceProvider,
FlatProgramAPI api, boolean createBookmarks, boolean useShortTemplates,
boolean nameVfunctions, boolean isDwarfLoaded, TaskMonitor monitor) throws Exception {
boolean nameVfunctions, boolean makeVfunctionsThisCalls, boolean isDwarfLoaded,
TaskMonitor monitor) throws Exception {
super(program, serviceProvider, api, createBookmarks, useShortTemplates, nameVfunctions,
isDwarfLoaded, monitor);
makeVfunctionsThisCalls,isDwarfLoaded, monitor);
this.isDwarfLoaded = isDwarfLoaded;

View file

@ -72,10 +72,11 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
public RTTIWindowsClassRecoverer(Program program, ServiceProvider serviceProvider,
FlatProgramAPI api, boolean createBookmarks, boolean useShortTemplates,
boolean nameVFunctions, boolean isPDBLoaded, TaskMonitor monitor) throws Exception {
boolean nameVFunctions, boolean makeVfunctionsThisCalls, boolean isPDBLoaded,
TaskMonitor monitor) throws Exception {
super(program, serviceProvider, api, createBookmarks, useShortTemplates, nameVFunctions,
isPDBLoaded, monitor);
makeVfunctionsThisCalls, isPDBLoaded, monitor);
this.isPDBLoaded = isPDBLoaded;
}

View file

@ -137,11 +137,14 @@ public class RecoveredClassHelper {
protected final boolean createBookmarks;
protected final boolean useShortTemplates;
protected final boolean nameVfunctions;
protected final boolean makeVfunctionsThisCalls;
public HashMap<Address, Set<Function>> allVfunctions = new HashMap<>();
public RecoveredClassHelper(Program program, ServiceProvider serviceProvider,
FlatProgramAPI api, boolean createBookmarks, boolean useShortTemplates,
boolean nameVunctions, TaskMonitor monitor) throws Exception {
boolean nameVunctions, boolean makeVfunctionsThisCalls, TaskMonitor monitor)
throws Exception {
this.monitor = monitor;
this.program = program;
@ -156,6 +159,7 @@ public class RecoveredClassHelper {
this.createBookmarks = createBookmarks;
this.useShortTemplates = useShortTemplates;
this.nameVfunctions = nameVunctions;
this.makeVfunctionsThisCalls = makeVfunctionsThisCalls;
globalNamespace = (GlobalNamespace) program.getGlobalNamespace();
@ -4770,8 +4774,10 @@ public class RecoveredClassHelper {
// can't put external functions into a namespace from this program
if (!vfunction.isExternal()) {
// if not already, make it a this call
// check script option and if not already, make it a this call
if (makeVfunctionsThisCalls) {
makeFunctionThiscall(vfunction);
}
// put symbol on the virtual function
Symbol vfunctionSymbol = vfunction.getSymbol();