public string GetTypeName(Il2CppType pType)
        {
            string ret;

            if (pType.type == Il2CppTypeEnum.IL2CPP_TYPE_CLASS || pType.type == Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE)
            {
                Il2CppTypeDefinition klass = Metadata.Types[pType.data.klassIndex];
                ret = Metadata.GetString(klass.nameIndex);
            }
            else if (pType.type == Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST)
            {
                Il2CppGenericClass   generic_class = Code.Image.ReadMappedObject <Il2CppGenericClass>(pType.data.generic_class);
                Il2CppTypeDefinition pMainDef      = Metadata.Types[generic_class.typeDefinitionIndex];
                ret = Metadata.GetString(pMainDef.nameIndex);
                var typeNames           = new List <string>();
                Il2CppGenericInst pInst = Code.Image.ReadMappedObject <Il2CppGenericInst>(generic_class.context.class_inst);
                var pointers            = Code.Image.ReadMappedArray <uint>(pInst.type_argv, (int)pInst.type_argc);
                for (int i = 0; i < pInst.type_argc; ++i)
                {
                    var pOriType = Code.Image.ReadMappedObject <Il2CppType>(pointers[i]);
                    pOriType.Init();
                    typeNames.Add(GetTypeName(pOriType));
                }
                ret += $"<{string.Join(", ", typeNames)}>";
            }
            else if (pType.type == Il2CppTypeEnum.IL2CPP_TYPE_ARRAY)
            {
                Il2CppArrayType arrayType = Code.Image.ReadMappedObject <Il2CppArrayType>(pType.data.array);
                var             type      = Code.Image.ReadMappedObject <Il2CppType>(arrayType.etype);
                type.Init();
                ret = $"{GetTypeName(type)}[]";
            }
            else if (pType.type == Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY)
            {
                var type = Code.Image.ReadMappedObject <Il2CppType>(pType.data.type);
                type.Init();
                ret = $"{GetTypeName(type)}[]";
            }
            else
            {
                if ((int)pType.type >= szTypeString.Length)
                {
                    ret = "unknow";
                }
                else
                {
                    ret = szTypeString[(int)pType.type];
                }
            }
            return(ret);
        }
Esempio n. 2
0
 public string GetFullTypeName(GenericIl2CppType pType)
 {
     if (pType.type == Il2CppTypeEnum.IL2CPP_TYPE_CLASS || pType.type == Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE)
     {
         var ret = "";
         Il2CppTypeDefinition klass = Metadata.Types[pType.klassIndex];
         if (klass.namespaceIndex >= 0)
         {
             ret = Metadata.GetString(klass.namespaceIndex);
             if (ret.Length > 0)
             {
                 ret += ".";
             }
         }
         ret += Metadata.GetString(klass.nameIndex);
         return(ret);
     }
     else
     {
         return(this.GetTypeName(pType));
     }
 }
Esempio n. 3
0
 public string GetTypeName(Il2CppTypeDefinition type) => GetString(type.nameIndex);