Better type blacklisting
This commit is contained in:
@@ -517,7 +517,7 @@ public class DataTypeWriter {
|
||||
this.writer.write(EOL);
|
||||
this.writer.write(EOL);
|
||||
} else {
|
||||
this.writer.write("typedef enum " + enumName + " {");
|
||||
this.writer.write("typedef enum " + enumName + "_ {");
|
||||
String description = enumm.getDescription();
|
||||
if (description != null && description.length() != 0) {
|
||||
var10000 = this.writer;
|
||||
|
@@ -18,6 +18,7 @@ public class RecompileConfig {
|
||||
// The output directory for the recompiled game
|
||||
public final String outputDir;
|
||||
public final String typeBlacklistPath;
|
||||
public final String categoryPathBlacklistPath;
|
||||
public final String functionBlacklistPath;
|
||||
// The static memory block
|
||||
public final Address staticMemoryBlockStart;
|
||||
@@ -60,6 +61,7 @@ public class RecompileConfig {
|
||||
script.println("Output path: " + outputDir);
|
||||
|
||||
typeBlacklistPath = new File(outputDir, "type_blacklist.txt").toString();
|
||||
categoryPathBlacklistPath = new File(outputDir, "type_path_blacklist.txt").toString();
|
||||
functionBlacklistPath = new File(outputDir, "function_blacklist.txt").toString();
|
||||
|
||||
dirDecompAuto = new File(outputDir, "gh_auto");
|
||||
|
@@ -8,10 +8,13 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.data.CategoryPath;
|
||||
import ghidra.program.model.data.Composite;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.EnumDataType;
|
||||
import ghidra.program.model.data.ProgramBasedDataTypeManager;
|
||||
import ghidra.program.model.data.Structure;
|
||||
import ghidra.program.model.data.TypeDef;
|
||||
import ghidra.program.model.data.TypedefDataType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
@@ -28,7 +31,9 @@ public class TypeDumper {
|
||||
public void run() throws Exception {
|
||||
ProgramBasedDataTypeManager dtm = currentProgram.getDataTypeManager();
|
||||
|
||||
HashSet<String> typeBlacklist = Utils.loadStructBlacklist(RecompileConfig.INSTANCE.typeBlacklistPath);
|
||||
HashSet<String> typeBlacklist = Utils.loadSimpleBlacklist(RecompileConfig.INSTANCE.typeBlacklistPath);
|
||||
HashSet<String> categoryPathBlacklist = Utils
|
||||
.loadSimpleBlacklist(RecompileConfig.INSTANCE.categoryPathBlacklistPath);
|
||||
|
||||
if (typeBlacklist == null) {
|
||||
script.println("Building struct blacklist from existing data types");
|
||||
@@ -44,15 +49,45 @@ public class TypeDumper {
|
||||
}
|
||||
|
||||
List<DataType> filteredTypes = new ArrayList<>();
|
||||
|
||||
// Iterator<DataType> compIt = dtm.getAllDataTypes();
|
||||
// while (compIt.hasNext()) {
|
||||
// DataType comp = compIt.next();
|
||||
// // script.println("Found: " + comp.getDisplayName() + " - " +
|
||||
// // comp.getClass().getSimpleName());
|
||||
|
||||
// if (comp instanceof TypeDef) {
|
||||
// if (comp.getDisplayName().startsWith("FIL_")) {
|
||||
// script.println("Found: " + comp.getDisplayName() + " - " + comp.getName() + "
|
||||
// - " + comp.getClass().getSimpleName());
|
||||
// }
|
||||
// }
|
||||
|
||||
// // if (comp.getName() == "FIL_tdstConcatFile") {
|
||||
// // // script.println("Found: " + dt.getDisplayName() + " - " +
|
||||
// // // dt.getClass().getSimpleName());
|
||||
// // throw new Exception("Found: " + comp.getDisplayName() + " - " +
|
||||
// comp.getClass().getSimpleName());
|
||||
// // }
|
||||
// }
|
||||
|
||||
Iterator<DataType> it = dtm.getAllDataTypes();
|
||||
while (it.hasNext()) {
|
||||
DataType dt = it.next();
|
||||
if (dt instanceof Structure || dt instanceof TypedefDataType || dt instanceof EnumDataType) {
|
||||
if (typeBlacklist.contains(dt.getDisplayName()))
|
||||
continue;
|
||||
script.println("Adding: " + dt.getDisplayName() + " - " +
|
||||
dt.getClass().getSimpleName());
|
||||
if (typeBlacklist.contains(dt.getDisplayName()))
|
||||
continue;
|
||||
CategoryPath catPath = dt.getCategoryPath();
|
||||
if (catPath.getPathElements().length > 0 && categoryPathBlacklist.contains(catPath.getPathElements()[0]))
|
||||
continue;
|
||||
|
||||
script.println("Type: " + dt.getDisplayName() + " - CatPath: " + dt.getCategoryPath());
|
||||
|
||||
// if (dt.getName().equals("ImageBaseOffset32"))
|
||||
// throw new Exception("Found: " + dt.getDisplayName() + " - " + catPath.getPathElements()[0] + " - " + dt.getClass().getSimpleName());
|
||||
|
||||
if (dt instanceof Structure || dt instanceof TypeDef || dt instanceof EnumDataType) {
|
||||
// script.println("Adding: " + dt.getDisplayName() + " - " +
|
||||
// dt.getClass().getSimpleName());
|
||||
filteredTypes.add(dt);
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ public class Utils {
|
||||
return name.replaceAll("[^a-zA-Z0-9_]", "_");
|
||||
}
|
||||
|
||||
public static HashSet<String> loadStructBlacklist(String path) {
|
||||
public static HashSet<String> loadSimpleBlacklist(String path) {
|
||||
File file = new File(path);
|
||||
HashSet<String> structBlacklist = new HashSet<>();
|
||||
try (Scanner scanner = new Scanner(file)) {
|
||||
|
Reference in New Issue
Block a user