mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-1601 Fixed the ApplyClassFunctionDefinitionUpdatesScript and the ApplyClassFunctionSignatureUpdatesScript and related methods in RecoveredClassHelper to work with new 10.1 function definition changes.
This commit is contained in:
parent
0e9792ac45
commit
eeee6c1ba4
4 changed files with 662 additions and 701 deletions
|
@ -18,13 +18,17 @@
|
|||
// desired class in the listing then run the script. For each function definition in the given class
|
||||
// that differs from the associated function signature in the listing, the script will update the
|
||||
// listing function signatures of any related virtual functions belonging to parent and children
|
||||
// classes. It will also update related data types including function definitions and vftable structures.
|
||||
// classes.
|
||||
// Note: The script will not work if the vftable structures were not originally applied to
|
||||
// the vftables using the RecoverClassesFromRTTIScript.
|
||||
// At some point, the Ghidra API will be updated to do this automatically instead of needing the
|
||||
// script to do so.
|
||||
// script to do so. For now, to make it a bit easier, you can use the below listed key binding
|
||||
// or menupath if you have the "In Tool" checkbox checked for this script in the script manager.
|
||||
//@category C++
|
||||
//@menupath Scripts.ApplyClassFunctionDefinitions
|
||||
//@keybinding shift D
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import classrecovery.RecoveredClassHelper;
|
||||
|
@ -63,41 +67,54 @@ public class ApplyClassFunctionDefinitionUpdatesScript extends GhidraScript {
|
|||
println(
|
||||
"Applying differing function definitions for class " + classNamespace.getName(true));
|
||||
|
||||
List<Object> changedItems =
|
||||
classHelper.applyNewFunctionDefinitions(classNamespace, classVftableSymbols);
|
||||
List<FunctionDefinition> classFunctionDefinitions =
|
||||
classHelper.getClassFunctionDefinitions(classNamespace);
|
||||
if (classFunctionDefinitions.isEmpty()) {
|
||||
println("Class " + classNamespace.getName() + " has no function definitions to apply.");
|
||||
return;
|
||||
}
|
||||
List<Object> changedItems = new ArrayList<Object>();
|
||||
|
||||
for (FunctionDefinition functionDef : classFunctionDefinitions) {
|
||||
monitor.checkCanceled();
|
||||
|
||||
List<Object> newChangedItems = classHelper.applyNewFunctionDefinition(functionDef);
|
||||
|
||||
changedItems = classHelper.updateList(changedItems, newChangedItems);
|
||||
|
||||
}
|
||||
|
||||
if (changedItems == null) {
|
||||
println("Class " + classNamespace.getName() + " has no function definitions to apply.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (changedItems.isEmpty()) {
|
||||
println("No differences found for class " + classNamespace.getName(true) +
|
||||
" between the vftable listing function signatures and their associated data type manager function definition data types");
|
||||
" between its function definition data types and the associated function signatures in the listing.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Structure> structuresOnList = classHelper.getStructuresOnList(changedItems);
|
||||
List<FunctionDefinition> functionDefinitionsOnList =
|
||||
classHelper.getFunctionDefinitionsOnList(changedItems);
|
||||
List<Function> functionsOnList = classHelper.getFunctionsOnList(changedItems);
|
||||
|
||||
println();
|
||||
println("Updated structures:");
|
||||
for (Structure structure : structuresOnList) {
|
||||
monitor.checkCanceled();
|
||||
println(structure.getPathName());
|
||||
if (!structuresOnList.isEmpty()) {
|
||||
println();
|
||||
println("Updated structures:");
|
||||
for (Structure structure : structuresOnList) {
|
||||
monitor.checkCanceled();
|
||||
println(structure.getPathName());
|
||||
}
|
||||
}
|
||||
|
||||
println();
|
||||
println("Updated function definitions:");
|
||||
for (FunctionDefinition functionDef : functionDefinitionsOnList) {
|
||||
monitor.checkCanceled();
|
||||
println(functionDef.getPathName());
|
||||
if (!functionsOnList.isEmpty()) {
|
||||
println();
|
||||
println("Updated functions:");
|
||||
for (Function function : functionsOnList) {
|
||||
monitor.checkCanceled();
|
||||
println(function.getEntryPoint().toString());
|
||||
}
|
||||
}
|
||||
|
||||
println();
|
||||
println("Updated functions:");
|
||||
for (Function function : functionsOnList) {
|
||||
monitor.checkCanceled();
|
||||
println(function.getEntryPoint().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue