diff --git a/Il2CppDumper/Il2CppDumper.cs b/Il2CppDumper/Il2CppDumper.cs index a613fb7..2841daf 100644 --- a/Il2CppDumper/Il2CppDumper.cs +++ b/Il2CppDumper/Il2CppDumper.cs @@ -15,6 +15,9 @@ namespace Il2CppInspector { private readonly Il2CppReflector model; + // Namespace prefixes whose contents should be skipped + public List ExcludedNamespaces { get; set; } + public Il2CppDumper(Il2CppInspector proc) { model = new Il2CppReflector(proc); } @@ -31,6 +34,10 @@ namespace Il2CppInspector foreach (var type in model.Assemblies.SelectMany(x => x.DefinedTypes)) { + // Skip namespace and any children if requested + if (ExcludedNamespaces?.Any(x => x == type.Namespace || type.Namespace.StartsWith(x + ".")) ?? false) + continue; + // Type declaration writer.Write($"\n// Namespace: {type.Namespace}\n"); diff --git a/Il2CppDumper/Program.cs b/Il2CppDumper/Program.cs index af4ace5..92d200b 100644 --- a/Il2CppDumper/Program.cs +++ b/Il2CppDumper/Program.cs @@ -2,6 +2,7 @@ // All rights reserved using System; +using System.Collections.Generic; using System.IO; namespace Il2CppInspector @@ -49,10 +50,18 @@ namespace Il2CppInspector if (il2cppInspectors == null) Environment.Exit(1); + // Exclusions + var excludedNamespaces = new List { + "System", + "UnityEngine", + "Mono", + "Microsoft.Win32" + }; + // Write output file int i = 0; foreach (var il2cpp in il2cppInspectors) - new Il2CppDumper(il2cpp).WriteFile(outFile + (i++ > 0 ? "-" + (i-1) : "")); + new Il2CppDumper(il2cpp) {ExcludedNamespaces = excludedNamespaces}.WriteFile(outFile + (i++ > 0 ? "-" + (i-1) : "")); } } } diff --git a/Il2CppTests/TestRunner.cs b/Il2CppTests/TestRunner.cs index 0811836..2992b6c 100644 --- a/Il2CppTests/TestRunner.cs +++ b/Il2CppTests/TestRunner.cs @@ -5,6 +5,7 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using NUnit.Framework; @@ -38,10 +39,18 @@ namespace Il2CppInspector if (inspectors.Count == 0) throw new Exception("Could not find any images in the IL2CPP binary"); + // Exclusions + var excludedNamespaces = new List { + "System", + "UnityEngine", + "Mono", + "Microsoft.Win32", + }; + // Dump each image in the binary separately int i = 0; foreach (var il2cpp in inspectors) - new Il2CppDumper(il2cpp).WriteFile(testPath + @"\test-result" + (i++ > 0 ? "-" + (i - 1) : "") + ".cs"); + new Il2CppDumper(il2cpp) {ExcludedNamespaces = excludedNamespaces}.WriteFile(testPath + @"\test-result" + (i++ > 0 ? "-" + (i - 1) : "") + ".cs"); // Compare test result with expected result for (i = 0; i < inspectors.Count; i++) {