From 69abc36737e440a14edb2a4605a1ec7f4902934c Mon Sep 17 00:00:00 2001 From: Perfare Date: Sun, 7 Apr 2019 09:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Il2CppDumper/DummyAssemblyCreator.cs | 84 ++++++++++++++-------------- Il2CppDumper/Il2Cpp.cs | 8 +-- Il2CppDumper/Metadata.cs | 74 +++++++++--------------- Il2CppDumper/Program.cs | 58 +++++++++---------- 4 files changed, 100 insertions(+), 124 deletions(-) diff --git a/Il2CppDumper/DummyAssemblyCreator.cs b/Il2CppDumper/DummyAssemblyCreator.cs index 2b01779..9b988c0 100644 --- a/Il2CppDumper/DummyAssemblyCreator.cs +++ b/Il2CppDumper/DummyAssemblyCreator.cs @@ -71,7 +71,7 @@ namespace Il2CppDumper } } //先单独处理,因为不知道会不会有问题 - for (var index = 0; index < metadata.uiNumTypes; ++index) + for (var index = 0; index < metadata.typeDefs.Length; ++index) { var typeDef = metadata.typeDefs[index]; var typeDefinition = typeDefinitionDic[index]; @@ -91,7 +91,7 @@ namespace Il2CppDumper } } //处理field, method, property等等 - for (var index = 0; index < metadata.uiNumTypes; ++index) + for (var index = 0; index < metadata.typeDefs.Length; ++index) { var typeDef = metadata.typeDefs[index]; var typeDefinition = typeDefinitionDic[index]; @@ -297,81 +297,81 @@ namespace Il2CppDumper } } - private TypeReference GetTypeReference(MemberReference memberReference, Il2CppType pType) + private TypeReference GetTypeReference(MemberReference memberReference, Il2CppType il2CppType) { var moduleDefinition = memberReference.Module; - switch (pType.type) + switch (il2CppType.type) { case Il2CppTypeEnum.IL2CPP_TYPE_OBJECT: - return moduleDefinition.Import(typeof(Object)); + return moduleDefinition.Import(typeof(object)); case Il2CppTypeEnum.IL2CPP_TYPE_VOID: return moduleDefinition.Import(typeof(void)); case Il2CppTypeEnum.IL2CPP_TYPE_BOOLEAN: - return moduleDefinition.Import(typeof(Boolean)); + return moduleDefinition.Import(typeof(bool)); case Il2CppTypeEnum.IL2CPP_TYPE_CHAR: - return moduleDefinition.Import(typeof(Char)); + return moduleDefinition.Import(typeof(char)); case Il2CppTypeEnum.IL2CPP_TYPE_I1: - return moduleDefinition.Import(typeof(SByte)); + return moduleDefinition.Import(typeof(sbyte)); case Il2CppTypeEnum.IL2CPP_TYPE_U1: - return moduleDefinition.Import(typeof(Byte)); + return moduleDefinition.Import(typeof(byte)); case Il2CppTypeEnum.IL2CPP_TYPE_I2: - return moduleDefinition.Import(typeof(Int16)); + return moduleDefinition.Import(typeof(short)); case Il2CppTypeEnum.IL2CPP_TYPE_U2: - return moduleDefinition.Import(typeof(UInt16)); + return moduleDefinition.Import(typeof(ushort)); case Il2CppTypeEnum.IL2CPP_TYPE_I4: - return moduleDefinition.Import(typeof(Int32)); + return moduleDefinition.Import(typeof(int)); case Il2CppTypeEnum.IL2CPP_TYPE_U4: - return moduleDefinition.Import(typeof(UInt32)); + return moduleDefinition.Import(typeof(uint)); case Il2CppTypeEnum.IL2CPP_TYPE_I: return moduleDefinition.Import(typeof(IntPtr)); case Il2CppTypeEnum.IL2CPP_TYPE_U: return moduleDefinition.Import(typeof(UIntPtr)); case Il2CppTypeEnum.IL2CPP_TYPE_I8: - return moduleDefinition.Import(typeof(Int64)); + return moduleDefinition.Import(typeof(long)); case Il2CppTypeEnum.IL2CPP_TYPE_U8: - return moduleDefinition.Import(typeof(UInt64)); + return moduleDefinition.Import(typeof(ulong)); case Il2CppTypeEnum.IL2CPP_TYPE_R4: - return moduleDefinition.Import(typeof(Single)); + return moduleDefinition.Import(typeof(float)); case Il2CppTypeEnum.IL2CPP_TYPE_R8: - return moduleDefinition.Import(typeof(Double)); + return moduleDefinition.Import(typeof(double)); case Il2CppTypeEnum.IL2CPP_TYPE_STRING: - return moduleDefinition.Import(typeof(String)); + return moduleDefinition.Import(typeof(string)); case Il2CppTypeEnum.IL2CPP_TYPE_TYPEDBYREF: return moduleDefinition.Import(typeof(TypedReference)); case Il2CppTypeEnum.IL2CPP_TYPE_CLASS: case Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE: { - var typeDefinition = typeDefinitionDic[pType.data.klassIndex]; + var typeDefinition = typeDefinitionDic[il2CppType.data.klassIndex]; return moduleDefinition.Import(typeDefinition); } case Il2CppTypeEnum.IL2CPP_TYPE_ARRAY: { - var arrayType = il2cpp.MapVATR(pType.data.array); - var type = il2cpp.GetIl2CppType(arrayType.etype); - return new ArrayType(GetTypeReference(memberReference, type), arrayType.rank); + var arrayType = il2cpp.MapVATR(il2CppType.data.array); + var oriType = il2cpp.GetIl2CppType(arrayType.etype); + return new ArrayType(GetTypeReference(memberReference, oriType), arrayType.rank); } case Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST: { - var generic_class = il2cpp.MapVATR(pType.data.generic_class); - var typeDefinition = typeDefinitionDic[generic_class.typeDefinitionIndex]; + var genericClass = il2cpp.MapVATR(il2CppType.data.generic_class); + var typeDefinition = typeDefinitionDic[genericClass.typeDefinitionIndex]; var genericInstanceType = new GenericInstanceType(moduleDefinition.Import(typeDefinition)); - var pInst = il2cpp.MapVATR(generic_class.context.class_inst); - var pointers = il2cpp.GetPointers(pInst.type_argv, (long)pInst.type_argc); + var genericInst = il2cpp.MapVATR(genericClass.context.class_inst); + var pointers = il2cpp.GetPointers(genericInst.type_argv, (long)genericInst.type_argc); foreach (var pointer in pointers) { - var pOriType = il2cpp.GetIl2CppType(pointer); - genericInstanceType.GenericArguments.Add(GetTypeReference(memberReference, pOriType)); + var oriType = il2cpp.GetIl2CppType(pointer); + genericInstanceType.GenericArguments.Add(GetTypeReference(memberReference, oriType)); } return genericInstanceType; } case Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY: { - var type = il2cpp.GetIl2CppType(pType.data.type); - return new ArrayType(GetTypeReference(memberReference, type)); + var oriType = il2cpp.GetIl2CppType(il2CppType.data.type); + return new ArrayType(GetTypeReference(memberReference, oriType)); } case Il2CppTypeEnum.IL2CPP_TYPE_VAR: { - if (genericParameterDic.TryGetValue(pType, out var genericParameter)) + if (genericParameterDic.TryGetValue(il2CppType, out var genericParameter)) { return genericParameter; } @@ -380,19 +380,19 @@ namespace Il2CppDumper var genericName = "T" + (methodDefinition.DeclaringType.GenericParameters.Count + 1); genericParameter = new GenericParameter(genericName, methodDefinition.DeclaringType); methodDefinition.DeclaringType.GenericParameters.Add(genericParameter); - genericParameterDic.Add(pType, genericParameter); + genericParameterDic.Add(il2CppType, genericParameter); return genericParameter; } var typeDefinition = (TypeDefinition)memberReference; var genericName2 = "T" + (typeDefinition.GenericParameters.Count + 1); genericParameter = new GenericParameter(genericName2, typeDefinition); typeDefinition.GenericParameters.Add(genericParameter); - genericParameterDic.Add(pType, genericParameter); + genericParameterDic.Add(il2CppType, genericParameter); return genericParameter; } case Il2CppTypeEnum.IL2CPP_TYPE_MVAR: { - if (genericParameterDic.TryGetValue(pType, out var genericParameter)) + if (genericParameterDic.TryGetValue(il2CppType, out var genericParameter)) { return genericParameter; } @@ -400,16 +400,16 @@ namespace Il2CppDumper var genericName = "T" + (methodDefinition.GenericParameters.Count + 1); genericParameter = new GenericParameter(genericName, methodDefinition); methodDefinition.GenericParameters.Add(genericParameter); - genericParameterDic.Add(pType, genericParameter); + genericParameterDic.Add(il2CppType, genericParameter); return genericParameter; } case Il2CppTypeEnum.IL2CPP_TYPE_PTR: { - var type = il2cpp.GetIl2CppType(pType.data.type); - return new PointerType(GetTypeReference(memberReference, type)); + var oriType = il2cpp.GetIl2CppType(il2CppType.data.type); + return new PointerType(GetTypeReference(memberReference, oriType)); } default: - return moduleDefinition.Import(typeof(Object)); + return moduleDefinition.Import(typeof(object)); } } @@ -418,9 +418,9 @@ namespace Il2CppDumper var pointer = metadata.GetDefaultValueFromIndex(dataIndex); if (pointer > 0) { - var pTypeToUse = il2cpp.types[typeIndex]; + var defaultValueType = il2cpp.types[typeIndex]; metadata.Position = pointer; - switch (pTypeToUse.type) + switch (defaultValueType.type) { case Il2CppTypeEnum.IL2CPP_TYPE_BOOLEAN: return metadata.ReadBoolean(); @@ -447,8 +447,8 @@ namespace Il2CppDumper case Il2CppTypeEnum.IL2CPP_TYPE_R8: return metadata.ReadDouble(); case Il2CppTypeEnum.IL2CPP_TYPE_STRING: - var uiLen = metadata.ReadInt32(); - return Encoding.UTF8.GetString(metadata.ReadBytes(uiLen)); + var len = metadata.ReadInt32(); + return Encoding.UTF8.GetString(metadata.ReadBytes(len)); } } return null; diff --git a/Il2CppDumper/Il2Cpp.cs b/Il2CppDumper/Il2Cpp.cs index 31915e0..ca8641e 100644 --- a/Il2CppDumper/Il2Cpp.cs +++ b/Il2CppDumper/Il2Cpp.cs @@ -130,14 +130,14 @@ namespace Il2CppDumper return fieldOffsets[fieldIndex]; } - public T[] MapVATR(dynamic uiAddr, long count) where T : new() + public T[] MapVATR(dynamic addr, long count) where T : new() { - return ReadClassArray(MapVATR(uiAddr), count); + return ReadClassArray(MapVATR(addr), count); } - public T MapVATR(dynamic uiAddr) where T : new() + public T MapVATR(dynamic addr) where T : new() { - return ReadClass(MapVATR(uiAddr)); + return ReadClass(MapVATR(addr)); } public Il2CppType GetIl2CppType(ulong pointer) diff --git a/Il2CppDumper/Metadata.cs b/Il2CppDumper/Metadata.cs index c8011c0..3b1e530 100644 --- a/Il2CppDumper/Metadata.cs +++ b/Il2CppDumper/Metadata.cs @@ -8,9 +8,7 @@ namespace Il2CppDumper { public sealed class Metadata : MyBinaryReader { - private Il2CppGlobalMetadataHeader pMetadataHdr; - public int uiImageCount; - public int uiNumTypes; + private Il2CppGlobalMetadataHeader metadataHeader; public Il2CppImageDefinition[] imageDefs; public Il2CppTypeDefinition[] typeDefs; public Il2CppMethodDefinition[] methodDefs; @@ -35,13 +33,12 @@ namespace Il2CppDumper public Metadata(Stream stream, float version) : base(stream) { this.version = version; - //pMetadataHdr - pMetadataHdr = ReadClass(); - if (pMetadataHdr.sanity != 0xFAB11BAF) + metadataHeader = ReadClass(); + if (metadataHeader.sanity != 0xFAB11BAF) { throw new Exception("ERROR: Metadata file supplied is not valid metadata file."); } - switch (pMetadataHdr.version) + switch (metadataHeader.version) { case 16: case 19: @@ -54,52 +51,32 @@ namespace Il2CppDumper default: throw new Exception($"ERROR: Metadata file supplied is not a supported version[{version}]."); } - //ImageDefinition - uiImageCount = pMetadataHdr.imagesCount / MySizeOf(typeof(Il2CppImageDefinition)); - uiNumTypes = pMetadataHdr.typeDefinitionsCount / MySizeOf(typeof(Il2CppTypeDefinition)); - imageDefs = ReadClassArray(pMetadataHdr.imagesOffset, uiImageCount); - //GetTypeDefinitionFromIndex - typeDefs = ReadClassArray(pMetadataHdr.typeDefinitionsOffset, uiNumTypes); - //GetMethodDefinitionFromIndex - methodDefs = ReadClassArray(pMetadataHdr.methodsOffset, pMetadataHdr.methodsCount / MySizeOf(typeof(Il2CppMethodDefinition))); - //GetParameterDefinitionFromIndex - parameterDefs = ReadClassArray(pMetadataHdr.parametersOffset, pMetadataHdr.parametersCount / MySizeOf(typeof(Il2CppParameterDefinition))); - //GetFieldDefinitionFromIndex - fieldDefs = ReadClassArray(pMetadataHdr.fieldsOffset, pMetadataHdr.fieldsCount / MySizeOf(typeof(Il2CppFieldDefinition))); - //FieldDefaultValue - fieldDefaultValues = ReadClassArray(pMetadataHdr.fieldDefaultValuesOffset, pMetadataHdr.fieldDefaultValuesCount / MySizeOf(typeof(Il2CppFieldDefaultValue))); - //ParameterDefaultValue - parameterDefaultValues = ReadClassArray(pMetadataHdr.parameterDefaultValuesOffset, pMetadataHdr.parameterDefaultValuesCount / MySizeOf(typeof(Il2CppParameterDefaultValue))); - //GetPropertyDefinitionFromIndex - propertyDefs = ReadClassArray(pMetadataHdr.propertiesOffset, pMetadataHdr.propertiesCount / MySizeOf(typeof(Il2CppPropertyDefinition))); - //GetInterfaceFromIndex - interfaceIndices = ReadClassArray(pMetadataHdr.interfacesOffset, pMetadataHdr.interfacesCount / 4); - //GetNestedTypeFromIndex - nestedTypeIndices = ReadClassArray(pMetadataHdr.nestedTypesOffset, pMetadataHdr.nestedTypesCount / 4); - //GetEventDefinitionFromIndex - eventDefs = ReadClassArray(pMetadataHdr.eventsOffset, pMetadataHdr.eventsCount / MySizeOf(typeof(Il2CppEventDefinition))); - //GetGenericContainerFromIndex - genericContainers = ReadClassArray(pMetadataHdr.genericContainersOffset, pMetadataHdr.genericContainersCount / MySizeOf(typeof(Il2CppGenericContainer))); + imageDefs = ReadMetadataClassArray(metadataHeader.imagesOffset, metadataHeader.imagesCount); + typeDefs = ReadMetadataClassArray(metadataHeader.typeDefinitionsOffset, metadataHeader.typeDefinitionsCount); + methodDefs = ReadMetadataClassArray(metadataHeader.methodsOffset, metadataHeader.methodsCount); + parameterDefs = ReadMetadataClassArray(metadataHeader.parametersOffset, metadataHeader.parametersCount); + fieldDefs = ReadMetadataClassArray(metadataHeader.fieldsOffset, metadataHeader.fieldsCount); + fieldDefaultValues = ReadMetadataClassArray(metadataHeader.fieldDefaultValuesOffset, metadataHeader.fieldDefaultValuesCount); + parameterDefaultValues = ReadMetadataClassArray(metadataHeader.parameterDefaultValuesOffset, metadataHeader.parameterDefaultValuesCount); + propertyDefs = ReadMetadataClassArray(metadataHeader.propertiesOffset, metadataHeader.propertiesCount); + interfaceIndices = ReadClassArray(metadataHeader.interfacesOffset, metadataHeader.interfacesCount / 4); + nestedTypeIndices = ReadClassArray(metadataHeader.nestedTypesOffset, metadataHeader.nestedTypesCount / 4); + eventDefs = ReadMetadataClassArray(metadataHeader.eventsOffset, metadataHeader.eventsCount); + genericContainers = ReadMetadataClassArray(metadataHeader.genericContainersOffset, metadataHeader.genericContainersCount); if (version > 16) { - //Il2CppStringLiteral - stringLiterals = ReadClassArray(pMetadataHdr.stringLiteralOffset, pMetadataHdr.stringLiteralCount / MySizeOf(typeof(Il2CppStringLiteral))); - //Il2CppMetadataUsageList - metadataUsageLists = ReadClassArray(pMetadataHdr.metadataUsageListsOffset, pMetadataHdr.metadataUsageListsCount / MySizeOf(typeof(Il2CppMetadataUsageList))); - //Il2CppMetadataUsagePair - metadataUsagePairs = ReadClassArray(pMetadataHdr.metadataUsagePairsOffset, pMetadataHdr.metadataUsagePairsCount / MySizeOf(typeof(Il2CppMetadataUsagePair))); + stringLiterals = ReadMetadataClassArray(metadataHeader.stringLiteralOffset, metadataHeader.stringLiteralCount); + metadataUsageLists = ReadMetadataClassArray(metadataHeader.metadataUsageListsOffset, metadataHeader.metadataUsageListsCount); + metadataUsagePairs = ReadMetadataClassArray(metadataHeader.metadataUsagePairsOffset, metadataHeader.metadataUsagePairsCount); CreateStringLiteralDic(); - //Il2CppFieldRef - fieldRefs = ReadMetadataClassArray(pMetadataHdr.fieldRefsOffset, pMetadataHdr.fieldRefsCount); + fieldRefs = ReadMetadataClassArray(metadataHeader.fieldRefsOffset, metadataHeader.fieldRefsCount); } if (version > 20) { - //CustomAttributeTypeRange - attributeTypeRanges = ReadClassArray(pMetadataHdr.attributesInfoOffset, pMetadataHdr.attributesInfoCount / MySizeOf(typeof(Il2CppCustomAttributeTypeRange))); - //AttributeTypes - attributeTypes = ReadClassArray(pMetadataHdr.attributeTypesOffset, pMetadataHdr.attributeTypesCount / 4); + attributeTypeRanges = ReadMetadataClassArray(metadataHeader.attributesInfoOffset, metadataHeader.attributesInfoCount); + attributeTypes = ReadClassArray(metadataHeader.attributeTypesOffset, metadataHeader.attributeTypesCount / 4); } } @@ -120,12 +97,12 @@ namespace Il2CppDumper public int GetDefaultValueFromIndex(int index) { - return pMetadataHdr.fieldAndParameterDefaultValueDataOffset + index; + return metadataHeader.fieldAndParameterDefaultValueDataOffset + index; } public string GetStringFromIndex(int index) { - return ReadStringToNull(pMetadataHdr.stringOffset + index); + return ReadStringToNull(metadataHeader.stringOffset + index); } public int GetCustomAttributeIndex(Il2CppImageDefinition imageDef, int customAttributeIndex, uint token) @@ -151,7 +128,7 @@ namespace Il2CppDumper public string GetStringLiteralFromIndex(uint index) { var stringLiteral = stringLiterals[index]; - Position = pMetadataHdr.stringLiteralDataOffset + stringLiteral.dataIndex; + Position = metadataHeader.stringLiteralDataOffset + stringLiteral.dataIndex; return Encoding.UTF8.GetString(ReadBytes((int)stringLiteral.length)); } @@ -176,7 +153,6 @@ namespace Il2CppDumper maxMetadataUsages = metadataUsageDic[5].Last().Key + 1; } - private uint GetEncodedIndexType(uint index) { return (index & 0xE0000000) >> 29; diff --git a/Il2CppDumper/Program.cs b/Il2CppDumper/Program.cs index 056f4a8..7821ad2 100644 --- a/Il2CppDumper/Program.cs +++ b/Il2CppDumper/Program.cs @@ -33,14 +33,14 @@ namespace Il2CppDumper { if (args[0] == "-h" || args[0] == "--help" || args[0] == "/?" || args[0] == "/h") { - ShowHelp(System.AppDomain.CurrentDomain.FriendlyName); + ShowHelp(AppDomain.CurrentDomain.FriendlyName); return; } } if (args.Length > 2) { - ShowHelp(System.AppDomain.CurrentDomain.FriendlyName); + ShowHelp(AppDomain.CurrentDomain.FriendlyName); return; } @@ -236,7 +236,7 @@ namespace Il2CppDumper var scriptwriter = new StreamWriter(new FileStream("script.py", FileMode.Create), new UTF8Encoding(false)); scriptwriter.WriteLine(Resource1.ida); //dump image - for (var imageIndex = 0; imageIndex < metadata.uiImageCount; imageIndex++) + for (var imageIndex = 0; imageIndex < metadata.imageDefs.Length; imageIndex++) { var imageDef = metadata.imageDefs[imageIndex]; writer.Write($"// Image {imageIndex}: {metadata.GetStringFromIndex(imageDef.nameIndex)} - {imageDef.typeStart}\n"); @@ -331,7 +331,7 @@ namespace Il2CppDumper //dump_field(i, idx, i - typeDef.fieldStart); var fieldDef = metadata.fieldDefs[i]; var fieldType = il2cpp.types[fieldDef.typeIndex]; - var fieldDefault = metadata.GetFieldDefaultValueFromIndex(i); + var fieldDefaultValue = metadata.GetFieldDefaultValueFromIndex(i); writer.Write(GetCustomAttribute(imageDef, fieldDef.customAttributeIndex, fieldDef.token, "\t")); writer.Write("\t"); var access = fieldType.attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK; @@ -366,15 +366,15 @@ namespace Il2CppDumper writer.Write("readonly "); } writer.Write($"{GetTypeName(fieldType)} {metadata.GetStringFromIndex(fieldDef.nameIndex)}"); - if (fieldDefault != null && fieldDefault.dataIndex != -1) + if (fieldDefaultValue != null && fieldDefaultValue.dataIndex != -1) { - var pointer = metadata.GetDefaultValueFromIndex(fieldDefault.dataIndex); + var pointer = metadata.GetDefaultValueFromIndex(fieldDefaultValue.dataIndex); if (pointer > 0) { - var fieldDefaultType = il2cpp.types[fieldDefault.typeIndex]; + var fieldDefaultValueType = il2cpp.types[fieldDefaultValue.typeIndex]; metadata.Position = pointer; object val = null; - switch (fieldDefaultType.type) + switch (fieldDefaultValueType.type) { case Il2CppTypeEnum.IL2CPP_TYPE_BOOLEAN: val = metadata.ReadBoolean(); @@ -543,9 +543,9 @@ namespace Il2CppDumper } scriptwriter.WriteLine("print('Make method name done')"); //Script - MetadataUsage - scriptwriter.WriteLine("print('Setting MetadataUsage...')"); if (il2cpp.version > 16) { + scriptwriter.WriteLine("print('Setting MetadataUsage...')"); foreach (var i in metadata.metadataUsageDic[1]) //kIl2CppMetadataUsageTypeInfo { var type = il2cpp.types[i.Value]; @@ -614,8 +614,8 @@ namespace Il2CppDumper } scriptwriter.WriteLine($"idc.MakeComm(0x{il2cpp.metadataUsages[i.Key]:X}, r'0x{methodPointer:X}')"); } + scriptwriter.WriteLine("print('Set MetadataUsage done')"); } - scriptwriter.WriteLine("print('Set MetadataUsage done')"); //Script - MakeFunction if (config.MakeFunction) { @@ -656,15 +656,15 @@ namespace Il2CppDumper } } - private static string GetTypeName(Il2CppType pType, bool fullName = false) + private static string GetTypeName(Il2CppType type, bool fullName = false) { string ret; - switch (pType.type) + switch (type.type) { case Il2CppTypeEnum.IL2CPP_TYPE_CLASS: case Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE: { - var typeDef = metadata.typeDefs[pType.data.klassIndex]; + var typeDef = metadata.typeDefs[type.data.klassIndex]; ret = string.Empty; if (fullName) { @@ -679,41 +679,41 @@ namespace Il2CppDumper } case Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST: { - var generic_class = il2cpp.MapVATR(pType.data.generic_class); - var pMainDef = metadata.typeDefs[generic_class.typeDefinitionIndex]; - ret = metadata.GetStringFromIndex(pMainDef.nameIndex); + var generic_class = il2cpp.MapVATR(type.data.generic_class); + var typeDef = metadata.typeDefs[generic_class.typeDefinitionIndex]; + ret = metadata.GetStringFromIndex(typeDef.nameIndex); var typeNames = new List(); - var pInst = il2cpp.MapVATR(generic_class.context.class_inst); - var pointers = il2cpp.GetPointers(pInst.type_argv, (long)pInst.type_argc); - for (uint i = 0; i < pInst.type_argc; ++i) + var genericInst = il2cpp.MapVATR(generic_class.context.class_inst); + var pointers = il2cpp.GetPointers(genericInst.type_argv, (long)genericInst.type_argc); + for (uint i = 0; i < genericInst.type_argc; ++i) { - var pOriType = il2cpp.GetIl2CppType(pointers[i]); - typeNames.Add(GetTypeName(pOriType)); + var oriType = il2cpp.GetIl2CppType(pointers[i]); + typeNames.Add(GetTypeName(oriType)); } ret += $"<{string.Join(", ", typeNames)}>"; break; } case Il2CppTypeEnum.IL2CPP_TYPE_ARRAY: { - var arrayType = il2cpp.MapVATR(pType.data.array); - var type = il2cpp.GetIl2CppType(arrayType.etype); - ret = $"{GetTypeName(type)}[{new string(',', arrayType.rank - 1)}]"; + var arrayType = il2cpp.MapVATR(type.data.array); + var oriType = il2cpp.GetIl2CppType(arrayType.etype); + ret = $"{GetTypeName(oriType)}[{new string(',', arrayType.rank - 1)}]"; break; } case Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY: { - var type = il2cpp.GetIl2CppType(pType.data.type); - ret = $"{GetTypeName(type)}[]"; + var oriType = il2cpp.GetIl2CppType(type.data.type); + ret = $"{GetTypeName(oriType)}[]"; break; } case Il2CppTypeEnum.IL2CPP_TYPE_PTR: { - var type = il2cpp.GetIl2CppType(pType.data.type); - ret = $"{GetTypeName(type)}*"; + var oriType = il2cpp.GetIl2CppType(type.data.type); + ret = $"{GetTypeName(oriType)}*"; break; } default: - ret = TypeString[(int)pType.type]; + ret = TypeString[(int)type.type]; break; }