From fd4e61bacdab9a835c6f98dad0f8531123426637 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 5 Sep 2020 11:42:58 +0200 Subject: [PATCH] AppModel/C++: Unused concrete value types were not included --- Il2CppInspector.Common/Model/AppModel.cs | 11 +++++++++++ Il2CppInspector.Common/Outputs/CppScaffolding.cs | 1 + 2 files changed, 12 insertions(+) diff --git a/Il2CppInspector.Common/Model/AppModel.cs b/Il2CppInspector.Common/Model/AppModel.cs index 42b9938..dc70fe9 100644 --- a/Il2CppInspector.Common/Model/AppModel.cs +++ b/Il2CppInspector.Common/Model/AppModel.cs @@ -252,6 +252,17 @@ namespace Il2CppInspector.Model } } + // Find unused concrete value types + var usedTypes = Types.Values.Select(t => t.Type); + var unusedTypes = TypeModel.Types.Except(usedTypes); + var unusedValueTypes = unusedTypes.Where(t => t.IsValueType && !t.IsGenericType && !t.IsGenericParameter); + + Group = "unused_value_types"; + + foreach (var type in unusedValueTypes) + declarationGenerator.IncludeType(type); + AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); + // Restore stdout Console.SetOut(stdout); diff --git a/Il2CppInspector.Common/Outputs/CppScaffolding.cs b/Il2CppInspector.Common/Outputs/CppScaffolding.cs index 4bf6976..e46157f 100644 --- a/Il2CppInspector.Common/Outputs/CppScaffolding.cs +++ b/Il2CppInspector.Common/Outputs/CppScaffolding.cs @@ -72,6 +72,7 @@ typedef size_t uintptr_t; writeTypesForGroup("Application types from method calls", "types_from_methods"); writeTypesForGroup("Application types from generic methods", "types_from_generic_methods"); writeTypesForGroup("Application types from usages", "types_from_usages"); + writeTypesForGroup("Application unused value types", "unused_value_types"); writeCode("#if !defined(_GHIDRA_) && !defined(_IDA_)"); writeCode("}");