diff --git a/Il2CppInspector.Common/Cpp/CppDeclarationGenerator.cs b/Il2CppInspector.Common/Cpp/CppDeclarationGenerator.cs index 874d301..c84188e 100644 --- a/Il2CppInspector.Common/Cpp/CppDeclarationGenerator.cs +++ b/Il2CppInspector.Common/Cpp/CppDeclarationGenerator.cs @@ -20,7 +20,7 @@ namespace Il2CppInspector.Cpp { private readonly AppModel appModel; - private TypeModel model => appModel.ILModel; + private TypeModel model => appModel.TypeModel; private CppTypeCollection types => appModel.CppTypeCollection; // Word size (32/64-bit) for this generator diff --git a/Il2CppInspector.Common/Model/AddressMap.cs b/Il2CppInspector.Common/Model/AddressMap.cs index df98511..c0ed195 100644 --- a/Il2CppInspector.Common/Model/AddressMap.cs +++ b/Il2CppInspector.Common/Model/AddressMap.cs @@ -72,11 +72,11 @@ namespace Il2CppInspector.Model // Add all custom attributes generators // The compiler might perform ICF which will cause duplicates with the above - foreach (var cag in Model.ILModel.CustomAttributeGeneratorsByAddress) + foreach (var cag in Model.TypeModel.CustomAttributeGeneratorsByAddress) TryAdd(cag.Key, cag.Value); // Add all method invokers. Multiple invoker indices may reference the same function address - foreach (var mi in Model.ILModel.MethodInvokers.Where(m => m != null)) + foreach (var mi in Model.TypeModel.MethodInvokers.Where(m => m != null)) TryAdd(mi.VirtualAddress.Start, mi); // String literals (metadata >= 19) diff --git a/Il2CppInspector.Common/Model/AppModel.cs b/Il2CppInspector.Common/Model/AppModel.cs index 380faa5..551579c 100644 --- a/Il2CppInspector.Common/Model/AppModel.cs +++ b/Il2CppInspector.Common/Model/AppModel.cs @@ -53,7 +53,7 @@ namespace Il2CppInspector.Model public bool StringIndexesAreOrdinals => Package.MetadataUsages == null; // The .NET type model for the application - public TypeModel ILModel { get; } + public TypeModel TypeModel { get; } // All of the exports (including function exports) for the binary public List Exports { get; } @@ -75,10 +75,10 @@ namespace Il2CppInspector.Model // Convenience properties // The word size of the binary in bits - public int WordSize => ILModel.Package.BinaryImage.Bits; + public int WordSize => TypeModel.Package.BinaryImage.Bits; // The IL2CPP package for this application - public Il2CppInspector Package => ILModel.Package; + public Il2CppInspector Package => TypeModel.Package; // The compiler used to build the binary public CppCompilerType SourceCompiler => declarationGenerator.InheritanceStyle; @@ -96,7 +96,7 @@ namespace Il2CppInspector.Model // Initialize public AppModel(TypeModel model) { // Save .NET type model - ILModel = model; + TypeModel = model; // Get addresses of all exports Exports = Package.BinaryImage.GetExports()?.ToList() ?? new List(); @@ -117,18 +117,18 @@ namespace Il2CppInspector.Model Strings.Clear(); // Set target compiler - TargetCompiler = compiler == CppCompilerType.BinaryFormat ? CppCompiler.GuessFromImage(ILModel.Package.BinaryImage) : compiler; + TargetCompiler = compiler == CppCompilerType.BinaryFormat ? CppCompiler.GuessFromImage(TypeModel.Package.BinaryImage) : compiler; // Determine Unity version and get headers - UnityHeaders = unityVersion != null ? UnityHeaders.GetHeadersForVersion(unityVersion) : UnityHeaders.GuessHeadersForBinary(ILModel.Package.Binary).Last(); + UnityHeaders = unityVersion != null ? UnityHeaders.GetHeadersForVersion(unityVersion) : UnityHeaders.GuessHeadersForBinary(TypeModel.Package.Binary).Last(); UnityVersion = unityVersion ?? UnityHeaders.VersionRange.Min; Console.WriteLine($"Selected Unity version(s) {UnityHeaders.VersionRange} (types: {UnityHeaders.TypeHeaderResource.VersionRange}, APIs: {UnityHeaders.APIHeaderResource.VersionRange})"); // Check for matching metadata and binary versions - if (UnityHeaders.MetadataVersion != ILModel.Package.BinaryImage.Version) { + if (UnityHeaders.MetadataVersion != TypeModel.Package.BinaryImage.Version) { Console.WriteLine($"Warning: selected version {UnityVersion} (metadata version {UnityHeaders.MetadataVersion})" + - $" does not match metadata version {ILModel.Package.BinaryImage.Version}."); + $" does not match metadata version {TypeModel.Package.BinaryImage.Version}."); } // Initialize declaration generator to process every type in the binary @@ -141,7 +141,7 @@ namespace Il2CppInspector.Model // Populate AvailableAPIs with actual API symbols from Binary.GetAPIExports() and their matching header signatures // NOTE: This will only be filled with exports that actually exist in both the binary and the API header, // and have a mappable address. This prevents exceptions when cross-querying the header and binary APIs. - var exports = ILModel.Package.Binary.GetAPIExports() + var exports = TypeModel.Package.Binary.GetAPIExports() .Where(e => CppTypeCollection.TypedefAliases.ContainsKey(e.Key)) .Select(e => new { VirtualAddress = e.Value, @@ -158,7 +158,7 @@ namespace Il2CppInspector.Model // Add method definitions and types used by them to C++ type model Group = "types_from_methods"; - foreach (var method in ILModel.MethodsByDefinitionIndex.Where(m => m.VirtualAddress.HasValue)) { + foreach (var method in TypeModel.MethodsByDefinitionIndex.Where(m => m.VirtualAddress.HasValue)) { declarationGenerator.IncludeMethod(method); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); @@ -169,7 +169,7 @@ namespace Il2CppInspector.Model // Add generic methods definitions and types used by them to C++ type model Group = "types_from_generic_methods"; - foreach (var method in ILModel.GenericMethods.Values.Where(m => m.VirtualAddress.HasValue)) { + foreach (var method in TypeModel.GenericMethods.Values.Where(m => m.VirtualAddress.HasValue)) { declarationGenerator.IncludeMethod(method); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); @@ -187,13 +187,13 @@ namespace Il2CppInspector.Model switch (usage.Type) { case MetadataUsageType.StringLiteral: - var str = ILModel.GetMetadataUsageName(usage); + var str = TypeModel.GetMetadataUsageName(usage); Strings.Add(address, str); break; case MetadataUsageType.Type: case MetadataUsageType.TypeInfo: - var type = ILModel.GetMetadataUsageType(usage); + var type = TypeModel.GetMetadataUsageType(usage); declarationGenerator.IncludeType(type); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); @@ -210,7 +210,7 @@ namespace Il2CppInspector.Model break; case MetadataUsageType.MethodDef: case MetadataUsageType.MethodRef: - var method = ILModel.GetMetadataUsageMethod(usage); + var method = TypeModel.GetMetadataUsageMethod(usage); declarationGenerator.IncludeMethod(method); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); diff --git a/Il2CppInspector.Common/Outputs/JSONMetadata.cs b/Il2CppInspector.Common/Outputs/JSONMetadata.cs index 0ae58ba..e559753 100644 --- a/Il2CppInspector.Common/Outputs/JSONMetadata.cs +++ b/Il2CppInspector.Common/Outputs/JSONMetadata.cs @@ -55,13 +55,13 @@ namespace Il2CppInspector.Outputs // We could use ILModel.CustomAttributeGenerators here to ensure uniqueness but then we lose function name information // TODO: Merge CAG names that deal with multiple attribute types to reflect all of the attribute type names (solving the above) writeArray("customAttributesGenerators", () => { - foreach (var method in model.ILModel.AttributesByIndices.Values) { + foreach (var method in model.TypeModel.AttributesByIndices.Values) { writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.Signature, method.Name)); } }, "Custom attributes generators"); writeArray("methodInvokers", () => { - foreach (var method in model.ILModel.MethodInvokers.Where(m => m != null)) { + foreach (var method in model.TypeModel.MethodInvokers.Where(m => m != null)) { writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.GetSignature(model.UnityVersion), method.Name)); } }, "Method.Invoke thunks"); diff --git a/Il2CppInspector.GUI/MainWindow.xaml.cs b/Il2CppInspector.GUI/MainWindow.xaml.cs index 3afc91c..4477217 100644 --- a/Il2CppInspector.GUI/MainWindow.xaml.cs +++ b/Il2CppInspector.GUI/MainWindow.xaml.cs @@ -195,7 +195,7 @@ namespace Il2CppInspectorGUI var model = (AppModel)((ListBox)sender).SelectedItem; // Get namespaces - var namespaces = model.ILModel.Assemblies.SelectMany(x => x.DefinedTypes).GroupBy(t => t.Namespace).Select(n => n.Key); + var namespaces = model.TypeModel.Assemblies.SelectMany(x => x.DefinedTypes).GroupBy(t => t.Namespace).Select(n => n.Key); // Break namespaces down into a tree var namespaceTree = deconstructNamespaces(namespaces); @@ -347,7 +347,7 @@ namespace Il2CppInspectorGUI // Get options var excludedNamespaces = constructExcludedNamespaces((IEnumerable) trvNamespaces.ItemsSource); - var writer = new CSharpCodeStubs(model.ILModel) { + var writer = new CSharpCodeStubs(model.TypeModel) { ExcludedNamespaces = excludedNamespaces.ToList(), SuppressMetadata = cbSuppressMetadata.IsChecked == true, MustCompile = cbMustCompile.IsChecked == true