mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-5764 added option to RecoverClassesFromRTTIScript enabling users to not force vfunctions to be thiscalls.
This commit is contained in:
parent
0bd8870da3
commit
cee04048cb
7 changed files with 30 additions and 18 deletions
|
@ -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();
|
||||
|
|
|
@ -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.");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
makeFunctionThiscall(vfunction);
|
||||
// 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue