MCPcopy Create free account
hub / github.com/cinit/TMoe / DexKit

Class DexKit

app/src/main/java/cc/ioctl/tmoe/util/dex/DexKit.java:27–676  ·  view source on GitHub ↗

I hadn't obfuscated the source code. I just don't want to name it, leaving it a()

Source from the content-addressed store, hash-verified

25 * I hadn't obfuscated the source code. I just don't want to name it, leaving it a()
26 */
27public class DexKit {
28
29 static final String NO_SUCH_CLASS = "Lcc/ioctl/tmoe/util/dex/DexKit$NoSuchClass;";
30 static final DexMethodDescriptor NO_SUCH_METHOD = new DexMethodDescriptor(NO_SUCH_CLASS, "a", "()V");
31
32 // WARN: NEVER change the index!
33 public static final int C_THEME = 1;
34 // the last index
35 public static final int DEOBF_NUM_C = 1;
36
37 public static final int DEOBF_NUM_N = 0;
38
39 /**
40 * Run the dex deobfuscation.
41 *
42 * @param i the dex class index
43 * @return true if the dex class is deobfuscated successfully.
44 */
45 public static boolean prepareFor(int i) {
46 if (i / 10000 == 0) {
47 return doFindClass(i) != null;
48 } else {
49 return doFindMethod(i) != null;
50 }
51 }
52
53 /**
54 * Test whether we should run the dex deobfuscation. Note that if a dex class is tried to deobfuscate before, but
55 * failed, its failed result will be cached, which means that the same dex class will not be deobfuscated again.
56 *
57 * @param i the dex class index
58 * @return true if the dex class is deobfuscated and cached(regardless of success or failure), false if debfuscation is required.
59 */
60 public static boolean isDeobfuscationRequiredFor(int i) {
61 if (i / 10000 == 0) {
62 // for class
63 if (loadClassFromCache(i) != null) {
64 return false;
65 }
66 DexMethodDescriptor desc = getMethodDescFromCache(i);
67 return desc == null;
68 } else {
69 // for method
70 DexMethodDescriptor desc = getMethodDescFromCache(i);
71 return desc == null;
72 }
73 }
74
75 /**
76 * Try to load the obfuscated class from deobfuscation cache. This method does not take much time and may be called
77 * in main thread.
78 *
79 * @param i the dex class index
80 * @return null if the dex class is not in deobfuscation cache, otherwise the target class object.
81 */
82 @Nullable
83 public static Class<?> loadClassFromCache(int i) {
84 Class<?> ret = Initiator.load(getOriginalClassNameForIndex(i));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected