internal EncodedArray(BinaryReader reader) { Count = Leb128.ReadUleb(reader); EncodedValues = new EncodedValue[Count]; for (ulong i = 0; i < Count; i++) { EncodedValues[i] = EncodedValue.parse(reader); } }
/// <summary> /// Constructor /// </summary> /// <param name='dex'> /// Pointer to the DEX file this class was loaded from /// </param> internal Class(Dex dex, BinaryReader reader) { Dex = dex; ClassIndex = reader.ReadUInt32(); AccessFlags = (AccessFlag)reader.ReadUInt32(); SuperClassIndex = reader.ReadUInt32(); var interfacesOffset = reader.ReadUInt32(); SourceFileIndex = reader.ReadUInt32(); var annotationsOffset = reader.ReadUInt32(); var classDataOffset = reader.ReadUInt32(); var staticValuesOffset = reader.ReadUInt32(); Interfaces = dex.ReadTypeList(interfacesOffset); var fieldAnnotations = new Dictionary <uint, List <Annotation> >(); var methodAnnotations = new Dictionary <uint, List <Annotation> >(); var parameterAnnotations = new Dictionary <uint, List <Annotation> >(); if (annotationsOffset != 0) { reader.BaseStream.Position = annotationsOffset; // annotations_directory_item var classAnnotationsOffset = reader.ReadUInt32(); var annotatedFieldsCount = reader.ReadUInt32(); var annotatedMethodsCount = reader.ReadUInt32(); var annotatedParametersCount = reader.ReadUInt32(); for (int i = 0; i < annotatedFieldsCount; i++) { // field_annotation var fieldIndex = reader.ReadUInt32(); var annotations = Annotation.ReadAnnotations(reader); fieldAnnotations.Add(fieldIndex, annotations); } for (int i = 0; i < annotatedMethodsCount; i++) { // method_annotation var methodIndex = reader.ReadUInt32(); var annotations = Annotation.ReadAnnotations(reader); methodAnnotations.Add(methodIndex, annotations); } for (int i = 0; i < annotatedParametersCount; i++) { // parameter_annotation var methodIndex = reader.ReadUInt32(); var annotations = Annotation.ReadAnnotations(reader); parameterAnnotations.Add(methodIndex, annotations); } if (classAnnotationsOffset > 0) { reader.BaseStream.Position = classAnnotationsOffset; Annotations = Annotation.ReadAnnotationSetItem(reader); } } if (classDataOffset != 0) { reader.BaseStream.Position = classDataOffset; var staticFieldsCount = Leb128.ReadUleb(reader); var instanceFieldsCount = Leb128.ReadUleb(reader); var directMethodsCount = Leb128.ReadUleb(reader); var virtualMethodsCount = Leb128.ReadUleb(reader); StaticFields = ReadFields(staticFieldsCount, reader, fieldAnnotations); InstanceFields = ReadFields(instanceFieldsCount, reader, fieldAnnotations); DirectMethods = ReadMethods(directMethodsCount, reader, methodAnnotations, parameterAnnotations); VirtualMethods = ReadMethods(virtualMethodsCount, reader, methodAnnotations, parameterAnnotations); } else { StaticFields = new Field[0]; InstanceFields = new Field[0]; DirectMethods = new Method[0]; VirtualMethods = new Method[0]; } if (staticValuesOffset != 0) { reader.BaseStream.Position = staticValuesOffset; var size = Leb128.ReadUleb(reader); var values = new EncodedValue[size]; for (int i = 0; i < (int)size; i++) { values[i] = EncodedValue.parse(reader); } StaticFieldsValues = values; } else { StaticFieldsValues = new EncodedValue[0]; } }
public AnnotationElement(BinaryReader reader) { NameIdx = (uint)Leb128.ReadUleb(reader); Value = EncodedValue.parse(reader); }