public static Annotation readAnnotation(DexNode dex, Section s, boolean readVisibility) throws DecodeException { EncValueParser parser = new EncValueParser(dex, s); Visibility visibility = null; if (readVisibility) { byte v = s.readByte(); visibility = VISIBILITIES[v]; } int typeIndex = s.readUleb128(); int size = s.readUleb128(); Map<String, Object> values = new LinkedHashMap<>(size); for (int i = 0; i < size; i++) { String name = dex.getString(s.readUleb128()); values.put(name, parser.parseValue()); } ArgType type = dex.getType(typeIndex); Annotation annotation = new Annotation(visibility, type, values); if (!type.isObject()) { throw new DecodeException("Incorrect type for annotation: " + annotation); } return annotation; } }
public void process() throws DecodeException { int addr = 0; int line = section.readUleb128(); int paramsCount = section.readUleb128(); List<RegisterArg> mthArgs = mth.getArguments(false); for (int i = 0; i < paramsCount; i++) { int id = section.readUleb128() - 1; if (id != DexNode.NO_INDEX) { String name = dex.getString(id); switch (c) { case DBG_ADVANCE_PC: { int addrInc = section.readUleb128(); addr = addrChange(addr, addrInc, line); setLine(addr, line); int regNum = section.readUleb128(); int nameId = section.readUleb128() - 1; int type = section.readUleb128() - 1; LocalVar var = new LocalVar(dex, regNum, nameId, type, DexNode.NO_INDEX); startVar(var, addr, line); int regNum = section.readUleb128(); int nameId = section.readUleb128() - 1; int type = section.readUleb128() - 1; int sign = section.readUleb128() - 1; LocalVar var = new LocalVar(dex, regNum, nameId, type, sign); startVar(var, addr, line);
public String readString() { int offset = readInt(); int savedPosition = data.position(); int savedLimit = data.limit(); data.position(offset); data.limit(data.capacity()); try { int expectedLength = readUleb128(); String result = Mutf8.decode(this, new char[expectedLength]); if (result.length() != expectedLength) { throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length()); } return result; } catch (UTFDataFormatException e) { throw new DexException(e); } finally { data.position(savedPosition); data.limit(savedLimit); } }
public String readString() { int offset = readInt(); int savedPosition = data.position(); int savedLimit = data.limit(); data.position(offset); data.limit(data.capacity()); try { int expectedLength = readUleb128(); String result = Mutf8.decode(this, new char[expectedLength]); if (result.length() != expectedLength) { throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length()); } return result; } catch (UTFDataFormatException e) { throw new DexException(e); } finally { data.position(savedPosition); data.limit(savedLimit); } }
public String readString() { int offset = readInt(); int savedPosition = data.position(); int savedLimit = data.limit(); data.position(offset); data.limit(data.capacity()); try { int expectedLength = readUleb128(); String result = Mutf8.decode(this, new char[expectedLength]); if (result.length() != expectedLength) { throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length()); } return result; } catch (UTFDataFormatException e) { throw new DexException(e); } finally { data.position(savedPosition); data.limit(savedLimit); } }
private ClassData.Field[] readFields(int count) { ClassData.Field[] result = new ClassData.Field[count]; int fieldIndex = 0; for (int i = 0; i < count; i++) { fieldIndex += readUleb128(); // field index diff int accessFlags = readUleb128(); result[i] = new ClassData.Field(fieldIndex, accessFlags); } return result; }
private CatchHandler readCatchHandler(int offset) { int size = readSleb128(); int handlersCount = Math.abs(size); int[] typeIndexes = new int[handlersCount]; int[] addresses = new int[handlersCount]; for (int i = 0; i < handlersCount; i++) { typeIndexes[i] = readUleb128(); addresses[i] = readUleb128(); } int catchAllAddress = size <= 0 ? readUleb128() : -1; return new CatchHandler(typeIndexes, addresses, catchAllAddress, offset); }
private CatchHandler[] readCatchHandlers() { int baseOffset = data.position(); int catchHandlersSize = readUleb128(); CatchHandler[] result = new CatchHandler[catchHandlersSize]; for (int i = 0; i < catchHandlersSize; i++) { int offset = data.position() - baseOffset; result[i] = readCatchHandler(offset); } return result; }
private ClassData.Method[] readMethods(int count) { ClassData.Method[] result = new ClassData.Method[count]; int methodIndex = 0; for (int i = 0; i < count; i++) { methodIndex += readUleb128(); // method index diff int accessFlags = readUleb128(); int codeOff = readUleb128(); result[i] = new ClassData.Method(methodIndex, accessFlags, codeOff); } return result; }
private ClassData.Field[] readFields(int count) { ClassData.Field[] result = new ClassData.Field[count]; int fieldIndex = 0; for (int i = 0; i < count; i++) { fieldIndex += readUleb128(); // field index diff int accessFlags = readUleb128(); result[i] = new ClassData.Field(fieldIndex, accessFlags); } return result; }
private ClassData readClassData() { int staticFieldsSize = readUleb128(); int instanceFieldsSize = readUleb128(); int directMethodsSize = readUleb128(); int virtualMethodsSize = readUleb128(); ClassData.Field[] staticFields = readFields(staticFieldsSize); ClassData.Field[] instanceFields = readFields(instanceFieldsSize); ClassData.Method[] directMethods = readMethods(directMethodsSize); ClassData.Method[] virtualMethods = readMethods(virtualMethodsSize); return new ClassData(staticFields, instanceFields, directMethods, virtualMethods); }
private ClassData.Field[] readFields(int count) { ClassData.Field[] result = new ClassData.Field[count]; int fieldIndex = 0; for (int i = 0; i < count; i++) { fieldIndex += readUleb128(); // field index diff int accessFlags = readUleb128(); result[i] = new ClassData.Field(fieldIndex, accessFlags); } return result; }
private CatchHandler readCatchHandler(int offset) { int size = readSleb128(); int handlersCount = Math.abs(size); int[] typeIndexes = new int[handlersCount]; int[] addresses = new int[handlersCount]; for (int i = 0; i < handlersCount; i++) { typeIndexes[i] = readUleb128(); addresses[i] = readUleb128(); } int catchAllAddress = size <= 0 ? readUleb128() : -1; return new CatchHandler(typeIndexes, addresses, catchAllAddress, offset); }
private CatchHandler[] readCatchHandlers() { int baseOffset = data.position(); int catchHandlersSize = readUleb128(); CatchHandler[] result = new CatchHandler[catchHandlersSize]; for (int i = 0; i < catchHandlersSize; i++) { int offset = data.position() - baseOffset; result[i] = readCatchHandler(offset); } return result; }
private CatchHandler[] readCatchHandlers() { int baseOffset = data.position(); int catchHandlersSize = readUleb128(); CatchHandler[] result = new CatchHandler[catchHandlersSize]; for (int i = 0; i < catchHandlersSize; i++) { int offset = data.position() - baseOffset; result[i] = readCatchHandler(offset); } return result; }
private ClassData.Method[] readMethods(int count) { ClassData.Method[] result = new ClassData.Method[count]; int methodIndex = 0; for (int i = 0; i < count; i++) { methodIndex += readUleb128(); // method index diff int accessFlags = readUleb128(); int codeOff = readUleb128(); result[i] = new ClassData.Method(methodIndex, accessFlags, codeOff); } return result; }
private ClassData.Method[] readMethods(int count) { ClassData.Method[] result = new ClassData.Method[count]; int methodIndex = 0; for (int i = 0; i < count; i++) { methodIndex += readUleb128(); // method index diff int accessFlags = readUleb128(); int codeOff = readUleb128(); result[i] = new ClassData.Method(methodIndex, accessFlags, codeOff); } return result; }
private CatchHandler readCatchHandler(int offset) { int size = readSleb128(); int handlersCount = Math.abs(size); int[] typeIndexes = new int[handlersCount]; int[] addresses = new int[handlersCount]; for (int i = 0; i < handlersCount; i++) { typeIndexes[i] = readUleb128(); addresses[i] = readUleb128(); } int catchAllAddress = size <= 0 ? readUleb128() : -1; return new CatchHandler(typeIndexes, addresses, catchAllAddress, offset); }
private ClassData readClassData() { int staticFieldsSize = readUleb128(); int instanceFieldsSize = readUleb128(); int directMethodsSize = readUleb128(); int virtualMethodsSize = readUleb128(); ClassData.Field[] staticFields = readFields(staticFieldsSize); ClassData.Field[] instanceFields = readFields(instanceFieldsSize); ClassData.Method[] directMethods = readMethods(directMethodsSize); ClassData.Method[] virtualMethods = readMethods(virtualMethodsSize); return new ClassData(staticFields, instanceFields, directMethods, virtualMethods); }
private ClassData readClassData() { int staticFieldsSize = readUleb128(); int instanceFieldsSize = readUleb128(); int directMethodsSize = readUleb128(); int virtualMethodsSize = readUleb128(); ClassData.Field[] staticFields = readFields(staticFieldsSize); ClassData.Field[] instanceFields = readFields(instanceFieldsSize); ClassData.Method[] directMethods = readMethods(directMethodsSize); ClassData.Method[] virtualMethods = readMethods(virtualMethodsSize); return new ClassData(staticFields, instanceFields, directMethods, virtualMethods); }