private int readByte() { return in.readByte() & 0xFF; } }
public Section openSection(int offset) { return dexBuf.open(offset); }
public Code readCode(Method mth) { return dexBuf.readCode(mth); }
private MethodInfo(DexNode dex, int mthIndex) { MethodId mthId = dex.getMethodId(mthIndex); name = dex.getString(mthId.getNameIndex()); alias = name; aliasFromPreset = false; declClass = ClassInfo.fromDex(dex, mthId.getDeclaringClassIndex()); ProtoId proto = dex.getProtoId(mthId.getProtoIndex()); retType = dex.getType(proto.getReturnTypeIndex()); args = dex.readParamList(proto.getParametersOffset()); shortId = makeSignature(true); }
public MethodNode(ClassNode classNode, Method mthData, boolean isVirtual) { this.mthInfo = MethodInfo.fromDex(classNode.dex(), mthData.getMethodIndex()); this.parentClass = classNode; this.accFlags = new AccessInfo(mthData.getAccessFlags(), AFType.METHOD); this.noCode = mthData.getCodeOffset() == 0; this.methodData = noCode ? null : mthData; this.methodIsVirtual = isVirtual; }
public static FieldInfo fromDex(DexNode dex, int index) { FieldId field = dex.getFieldId(index); return from(dex, ClassInfo.fromDex(dex, field.getDeclaringClassIndex()), dex.getString(field.getNameIndex()), dex.getType(field.getTypeIndex())); }
public List<ArgType> readParamList(int parametersOffset) { TypeList paramList = dexBuf.readTypeList(parametersOffset); List<ArgType> args = new ArrayList<>(paramList.getTypes().length); for (short t : paramList.getTypes()) { args.add(getType(t)); } return Collections.unmodifiableList(args); }
public FieldNode(ClassNode cls, Field field) { this(cls, FieldInfo.fromDex(cls.dex(), field.getFieldIndex()), field.getAccessFlags()); }
public ProtoId getProtoId(int protoIndex) { return dexBuf.protoIds().get(protoIndex); }
public String getString(int index) { return dexBuf.strings().get(index); }
@Nullable private Dex makeDexBuf(String entryName, InputStream inputStream) { try { return new Dex(inputStream); } catch (Exception e) { LOG.error("Failed to load file: {}, error: {}", entryName, e.getMessage(), e); return null; } }
public ClassData readClassData(ClassDef cls) { return dexBuf.readClassData(cls); }
public boolean checkOffset(int dataOffset) { return dataOffset >= 0 && dataOffset < dexBuf.getLength(); }
public int processFields(List<FieldNode> fields) throws DecodeException { int count = Leb128.readUnsignedLeb128(in); for (int i = 0; i < count; i++) { Object value = parseValue(); if (i < fields.size()) { fields.get(i).addAttr(FieldInitAttr.constValue(value)); } } return count; } }
public void test(Code mthCode) throws DecodeException { short[] encodedInstructions = mthCode.getInstructions(); int size = encodedInstructions.length; DecodedInstruction[] decoded = new DecodedInstruction[size]; ShortArrayCodeInput in = new ShortArrayCodeInput(encodedInstructions); try { while (in.hasMore()) { decoded[in.cursor()] = DecodedInstruction.decode(in); } } catch (EOFException e) { throw new DecodeException(method, "", e); } insnArr = decoded; } }
public MethodId getMethodId(int mthIndex) { return dexBuf.methodIds().get(mthIndex); }
public FieldId getFieldId(int fieldIndex) { return dexBuf.fieldIds().get(fieldIndex); }
private void loadAnnotations(ClassDef cls) { int offset = cls.getAnnotationsOffset(); if (offset != 0) { try { new AnnotationsParser(this).parse(offset); } catch (Exception e) { LOG.error("Error parsing annotations in {}", this, e); } } }
public void loadClasses() { for (ClassDef cls : dexBuf.classDefs()) { addClassNode(new ClassNode(this, cls)); } }
public ArgType getType(int index) { return ArgType.parse(getString(dexBuf.typeIds().get(index))); }