diff --git a/Il2CppInspector.Common/Cpp/CppTypeCollection.cs b/Il2CppInspector.Common/Cpp/CppTypeCollection.cs index 867e68f..87bc1c1 100644 --- a/Il2CppInspector.Common/Cpp/CppTypeCollection.cs +++ b/Il2CppInspector.Common/Cpp/CppTypeCollection.cs @@ -497,6 +497,7 @@ namespace Il2CppInspector.Cpp // Allow auto-generation of forward declarations // This will break type generation unless the ultimate wanted type is a pointer // Note this can still be the case with indirectionCount == 0 if .AsPointer() is called afterwards + if (!Types.ContainsKey(baseName)) Struct(baseName); diff --git a/Il2CppInspector.Common/Cpp/CppTypeDependencyGraph.cs b/Il2CppInspector.Common/Cpp/CppTypeDependencyGraph.cs index b92665a..6a28f65 100644 --- a/Il2CppInspector.Common/Cpp/CppTypeDependencyGraph.cs +++ b/Il2CppInspector.Common/Cpp/CppTypeDependencyGraph.cs @@ -82,7 +82,24 @@ public class CppTypeDependencyGraph // finally, process all instance fields. // the reference type depends on the type of the field foreach (var field in typeInfo.DeclaredFields.Where(f => f.IsInstanceField)) - AddReference(typeNode, GetNode(field.FieldType), field.FieldType.IsPassedByReference); + { + // if the field type is a pointer and the element type an enum, we have to add a reference to the enum. + // this is a workaround for type emitting only being able to generate forward definitions for *struct* types, and not enum types + if (field.FieldType.IsPointer) + { + // support multiple pointer levels + var type = field.FieldType; + while (type.IsPointer) + type = type.ElementType; + + if (type.IsEnum) + AddReference(typeNode, GetNode(type), false); + } + else + { + AddReference(typeNode, GetNode(field.FieldType), field.FieldType.IsPassedByReference); + } + } } public List DeriveDependencyOrderedTypes(TypeInfo typeInfo)