AppModel: Handle .NET unmapped pointer type definitions

This commit is contained in:
Katy Coe
2020-07-14 16:56:30 +02:00
parent b9612676ed
commit ef043383fc
2 changed files with 21 additions and 4 deletions

View File

@@ -518,8 +518,8 @@ namespace Il2CppInspector.Cpp
// Get all of the types in a logical group // Get all of the types in a logical group
public IEnumerable<CppType> GetTypeGroup(string groupName) => Types.Values.Where(t => t.Group == groupName); public IEnumerable<CppType> GetTypeGroup(string groupName) => Types.Values.Where(t => t.Group == groupName);
// Add a type externally // Add a type
public void Add(CppType type) { private void Add(CppType type) {
type.Group = currentGroup; type.Group = currentGroup;
Types.Add(type.Name, type); Types.Add(type.Name, type);
} }

View File

@@ -7,6 +7,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using Aron.Weiler; using Aron.Weiler;
using Il2CppInspector.Cpp; using Il2CppInspector.Cpp;
@@ -160,9 +161,25 @@ namespace Il2CppInspector.Model
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
if (usage.Type == MetadataUsageType.TypeInfo) if (usage.Type == MetadataUsageType.TypeInfo)
Types[type].TypeClassAddress = address; // .NET unsafe pointer type that has not been mapped by IL2CPP to a C type
// (often void* or byte* in metadata v23 and v24.0)
if (!Types.ContainsKey(type)) {
Debug.Assert(type.IsPointer);
// TODO: This should really be handled by CppDeclarationGenerator, and doesn't generate the full definition
var cppType = CppTypeCollection.Struct(declarationGenerator.TypeNamer.GetName(type) + "__TypeInfo");
var cppObjectType = (CppComplexType) CppTypeCollection["Il2CppObject"];
cppType.Fields = new SortedDictionary<int, List<CppField>>(cppObjectType.Fields);
DependencyOrderedCppTypes.Add(cppType);
Types.Add(type, cppType, new AppType(type, cppType, cppClassPtr: address));
}
else
// Regular type definition
Types[type].TypeClassAddress = address;
else if (!Types.ContainsKey(type)) else if (!Types.ContainsKey(type))
// Generic type definition has no associated C++ type, therefore no dictionary subkey // Generic type definition has no associated C++ type, therefore no dictionary sub-key
Types.Add(type, new AppType(type, null, cppTypeRefPtr: address)); Types.Add(type, new AppType(type, null, cppTypeRefPtr: address));
else else
// Regular type reference // Regular type reference