private static DumpAttribute[] GetCustomAttributes(Il2CppImageDefinition image, int customAttributeIndex, uint token, string padding = "") { if (!config.DumpAttribute || il2cpp.version < 21) { return(null); } var index = metadata.GetCustomAttributeIndex(image, customAttributeIndex, token); if (index >= 0) { var attributeTypeRange = metadata.attributeTypeRanges[index]; var attributes = new List <DumpAttribute>(); for (var i = 0; i < attributeTypeRange.count; i++) { var typeIndex = metadata.attributeTypes[attributeTypeRange.start + i]; var methodPointer = il2cpp.customAttributeGenerators[index]; var address = il2cpp.MapVATR(methodPointer); attributes.Add(new DumpAttribute { Address = address, Name = $"[{GetTypeName(il2cpp.types[typeIndex])}]" }); } return(attributes.ToArray()); } else { return(null); } }
public static List <(TypeDefinition type, List <CppMethodData> methods)> ProcessAssemblyTypes(Il2CppMetadata metadata, PE theDll, Il2CppImageDefinition imageDef) { var firstTypeDefinition = SharedState.TypeDefsByIndex[imageDef.firstTypeIndex]; var currentAssembly = firstTypeDefinition.Module.Assembly; InjectCustomAttributes(currentAssembly); //Ensure type directory exists if (!Program.CommandLineOptions.SkipMetadataTextFiles && !Program.CommandLineOptions.SkipAnalysis) { Directory.CreateDirectory(Path.Combine(Path.GetFullPath("cpp2il_out"), "types", currentAssembly.Name.Name)); } var lastTypeIndex = imageDef.firstTypeIndex + imageDef.typeCount; var methods = new List <(TypeDefinition type, List <CppMethodData> methods)>(); for (var index = imageDef.firstTypeIndex; index < lastTypeIndex; index++) { var typeDef = metadata.typeDefs[index]; var typeDefinition = SharedState.TypeDefsByIndex[index]; SharedState.MonoToCppTypeDefs[typeDefinition] = typeDef; methods.Add((type: typeDefinition, methods: ProcessTypeContents(metadata, theDll, typeDef, typeDefinition, imageDef))); } return(methods); }