Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-7370 Windows RTTI script updated to skip processing of class namespaces that contain duplicate RTTI Base Class Arrays since they must only contain one to process correctly.

ghidra00757d4fa4b69aa
diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIWindowsClassRecoverer.java b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIWindowsClassRecoverer.java
index ab818f4ac1..388f8bf544 100644
--- a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIWindowsClassRecoverer.java
+++ b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIWindowsClassRecoverer.java
@@ -862,6 +862,7 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
List<Symbol> vftableSymbols) throws CancelledException, Exception {
List<RecoveredClass> recoveredClasses = new ArrayList<RecoveredClass>();
+ Set<String> dupes = new HashSet<>();
List<Symbol> classHierarchyDescriptorList = getListOfClassHierarchyDescriptors();
@@ -877,6 +878,13 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
"this class");
continue;
}
+
+ // NEW CHECK: don't process invalid classes that have more than one Base Class Array
+ List<Symbol> symbols = symbolTable.getSymbols("RTTI_Base_Class_Array", classNamespace);
+ if (symbols.size() > 1) {
+ dupes.add(classNamespace.getName(true));
+ continue;
+ }
// get the data type category associated with the given class namespace
Category category = getDataTypeCategory(classNamespace);
@@ -937,6 +945,17 @@ public class RTTIWindowsClassRecoverer extends RTTIClassRecoverer {
}
}
+ // If there are any classes with dupes print out list of them to the log
+ if (dupes.size() > 0) {
+ String errorOutput =
+ "Cannot process classes in the following " + dupes.size() + " namespaces because " +
+ "there are duplicate RTTI_Base_Class_Array's in them.\n";
+ for (String dupe : dupes) {
+ monitor.checkCancelled();
+ errorOutput += "\t" + dupe + "\n";
+ }
+ Msg.error(this, errorOutput);
+ }
return recoveredClasses;
}