1 | static synchronized S loadDex(byte[] dex, bool run) ctex { |
2 | assertTrue("Not a dex file", isDex(dex)); |
3 | |
4 | Class j = getJavaX(); |
5 | |
6 | ClassLoader parentClassLoader = j.getClassLoader().getParent(); |
7 | |
8 | File dexDir = (File) call(j, "TempDirMaker_make"); |
9 | File dexFile = new File(dexDir, "spontaneous.dex"); |
10 | //File dexFile = prepareProgramFile("spontaneous.dex"); |
11 | |
12 | saveBinaryFile(dexFile, dex); |
13 | print("dexFile: " + dexFile.getAbsolutePath()); |
14 | assertEquals((long) dex.length, dexFile.length()); |
15 | print("Dex size: " + dex.length); |
16 | |
17 | // For Android's optimized class data (must be an app-local dir) |
18 | File dexOutputDir = makeAndroidTempDir(); |
19 | |
20 | Class dcl = Class.forName("dalvik.system.DexClassLoader"); |
21 | O classLoader = dcl.getConstructors()[0].newInstance(dexFile.getAbsolutePath(), dexOutputDir.getAbsolutePath(), null, |
22 | parentClassLoader); |
23 | |
24 | final Class<?> mainClass = (Class<?>) call(classLoader, "loadClass", "main"); |
25 | |
26 | hotwire_copyOver(mainClass); |
27 | |
28 | final O paa = nuObject(_getClass(j, j.getName() + "$PaA")); |
29 | S injectionID; |
30 | set(paa, "injectionID", injectionID = randomID(8)); |
31 | set(paa, "mainClass", mainClass); |
32 | call(j, "addInjection", paa); |
33 | |
34 | if (run) |
35 | thread "Spontaneous DEX" { |
36 | callMain(mainClass); |
37 | } |
38 | |
39 | ret format("OK, injection id: *", injectionID); |
40 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004178 |
Snippet name: | loadDex - load & optionally run a dex on Android |
Eternal ID of this version: | #1004178/1 |
Text MD5: | 4940c9aff9b3cc9809fdf3fc190c8eaf |
Author: | stefan |
Category: | javax / android |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-15 15:06:15 |
Source code size: | 1358 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 739 / 697 |
Referenced in: | [show references] |