diff --git a/game_re/type_path_blacklist.txt b/game_re/type_path_blacklist.txt new file mode 100644 index 00000000..42968cf4 --- /dev/null +++ b/game_re/type_path_blacklist.txt @@ -0,0 +1,88 @@ +basetsd.h +bink.h +cderr.h +commdlg.h +crtdefs.h +ctype.h +d3d8.h +d3d8caps.h +d3d8types.h +dde.h +ddeml.h +dlgs.h +excpt.h +file.h +float.h +guiddef.h +imm.h +io.h +jmorecfg.h +jpeglib.h +LstDef2.h +Izexpand.h +malloc.h +math.h +mbstring.h +mcx.h +mmsystem.h +mswsock.h +msxml.h +nb30.h +oleidl.h +oaidl.h +objbase.h +oleauto.h +ole2.h +objidl.h +process.h +propidl.h +prsht.h +qos.h +rad.h +rpc.h +rpcasync.h +rpcdce.h +rpcdcep.h +rpcndr.h +rpcnsi.h +rpcnsip.h +rpcnterr.h +servprov.h +shellapi.h +snddef.h +sound.h +stdarg.h +stdint.h +stdio.h +stdlib.h +string.h +time.h +timer.h +tvout.h +unknwn.h +urlmon.h +vadefs.h +verrsrc.h +winbase.h +wincon.h +wincrypt.h +windef.h +WinDef.h +winefs.h +winerror.h +wingdi.h +winioctl.h +winnetwk.h +winnls.h +winnt.h +winperf.h +winreg.h +winscard.h +winsmcrd.h +winsock.h +winsock2.h +winspool.h +winsvc.h +winuser.h +winver.h +wtypes.h \ No newline at end of file diff --git a/scripts/re3lib/DataTypeWriter.java b/scripts/re3lib/DataTypeWriter.java index 180f15d3..11b9a554 100644 --- a/scripts/re3lib/DataTypeWriter.java +++ b/scripts/re3lib/DataTypeWriter.java @@ -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; diff --git a/scripts/re3lib/RecompileConfig.java b/scripts/re3lib/RecompileConfig.java index a4baf83e..7164ab02 100644 --- a/scripts/re3lib/RecompileConfig.java +++ b/scripts/re3lib/RecompileConfig.java @@ -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"); diff --git a/scripts/re3lib/TypeDumper.java b/scripts/re3lib/TypeDumper.java index 6dc25fdf..ef7048bb 100644 --- a/scripts/re3lib/TypeDumper.java +++ b/scripts/re3lib/TypeDumper.java @@ -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 typeBlacklist = Utils.loadStructBlacklist(RecompileConfig.INSTANCE.typeBlacklistPath); + HashSet typeBlacklist = Utils.loadSimpleBlacklist(RecompileConfig.INSTANCE.typeBlacklistPath); + HashSet 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 filteredTypes = new ArrayList<>(); + + // Iterator 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 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); } } diff --git a/scripts/re3lib/Utils.java b/scripts/re3lib/Utils.java index 27f1143a..e22c1ef7 100644 --- a/scripts/re3lib/Utils.java +++ b/scripts/re3lib/Utils.java @@ -25,7 +25,7 @@ public class Utils { return name.replaceAll("[^a-zA-Z0-9_]", "_"); } - public static HashSet loadStructBlacklist(String path) { + public static HashSet loadSimpleBlacklist(String path) { File file = new File(path); HashSet structBlacklist = new HashSet<>(); try (Scanner scanner = new Scanner(file)) {