| 9 | import cc.ioctl.tmoe.util.Utils; |
| 10 | |
| 11 | public class DexFlow { |
| 12 | |
| 13 | private static final byte[] OPCODE_LENGTH_TABLE = new byte[]{ |
| 14 | 1, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 1, 1, 1, 1, 1, |
| 15 | 1, 1, 1, 2, 3, 2, 2, 3, 5, 2, 2, 3, 2, 1, 1, 2, |
| 16 | 2, 1, 2, 2, 3, 3, 3, 1, 1, 2, 3, 3, 3, 2, 2, 2, |
| 17 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, |
| 18 | 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 19 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 20 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, |
| 21 | 3, 3, 3, 1, 3, 3, 3, 3, 3, 0, 0, 1, 1, 1, 1, 1, |
| 22 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 23 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 24 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 25 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 26 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 27 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 28 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, |
| 29 | 3, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2}; |
| 30 | |
| 31 | public static DexMethodDescriptor[] getDeclaredDexMethods(byte[] buf, String klass) { |
| 32 | int methodIdsSize = readLe32(buf, 0x58); |
| 33 | int methodIdsOff = readLe32(buf, 0x5c); |
| 34 | int classDefsSize = readLe32(buf, 0x60); |
| 35 | int classDefsOff = readLe32(buf, 0x64); |
| 36 | int dexCodeOffset = -1; |
| 37 | int[] p = new int[1]; |
| 38 | int[] ret = new int[1]; |
| 39 | int[] co = new int[1]; |
| 40 | for (int cn = 0; cn < classDefsSize; cn++) { |
| 41 | int classIdx = readLe32(buf, classDefsOff + cn * 32); |
| 42 | int classDataOff = readLe32(buf, classDefsOff + cn * 32 + 24); |
| 43 | if (!klass.equals(readType(buf, classIdx))) { |
| 44 | continue; |
| 45 | } |
| 46 | p[0] = classDataOff; |
| 47 | if (classDataOff == 0) { |
| 48 | continue; |
| 49 | } |
| 50 | int fieldIdx = 0; |
| 51 | ArrayList<DexMethodDescriptor> methods = new ArrayList<>(); |
| 52 | int staticFieldsSize = readUleb128(buf, p), |
| 53 | instanceFieldsSize = readUleb128(buf, p), |
| 54 | directMethodsSize = readUleb128(buf, p), |
| 55 | virtualMethodsSize = readUleb128(buf, p); |
| 56 | for (int fn = 0; fn < staticFieldsSize + instanceFieldsSize; fn++) { |
| 57 | fieldIdx += readUleb128(buf, p); |
| 58 | int accessFlags = readUleb128(buf, p); |
| 59 | } |
| 60 | int methodIdx = 0; |
| 61 | for (int mn = 0; mn < directMethodsSize; mn++) { |
| 62 | methodIdx += readUleb128(buf, p); |
| 63 | int accessFlags = readUleb128(buf, p); |
| 64 | int codeOff = co[0] = readUleb128(buf, p); |
| 65 | int pMethodId = methodIdsOff + 8 * methodIdx; |
| 66 | String name = readString(buf, readLe32(buf, pMethodId + 4)); |
| 67 | String sig = readProto(buf, readLe16(buf, pMethodId + 2)); |
| 68 | methods.add(new DexMethodDescriptor(klass, name, sig)); |
nothing calls this directly
no outgoing calls
no test coverage detected