Skip to content

Commit 26bc80b

Browse files
committed
Updated latest commits from skylot/jadx
1 parent b83c9ab commit 26bc80b

79 files changed

Lines changed: 1582 additions & 785 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ dependencies {
138138
compile 'org.slf4j:slf4j-api:1.7.12'
139139
compile 'uk.com.robust-it:cloning:1.9.2'
140140
compile files('libs/android-5.1-clst-core.jar')
141+
compile 'com.intellij:annotations:+@jar'
141142

142143
compile 'com.anjlab.android.iab.v3:library:1.0.+@aar'
143144
}

app/src/main/java/jadx/api/DefaultJadxArgs.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package jadx.api;
2+
3+
import java.io.File;
4+
5+
public class JadxArgs implements IJadxArgs {
6+
7+
private File outDir = new File("jadx-output");
8+
private int threadsCount = Math.max(1, Runtime.getRuntime().availableProcessors() - 1);
9+
10+
private boolean cfgOutput = false;
11+
private boolean rawCFGOutput = false;
12+
13+
private boolean isVerbose = false;
14+
private boolean fallbackMode = false;
15+
private boolean showInconsistentCode = false;
16+
17+
private boolean isSkipResources = false;
18+
private boolean isSkipSources = false;
19+
20+
private boolean isDeobfuscationOn = false;
21+
private boolean isDeobfuscationForceSave = false;
22+
private boolean useSourceNameAsClassAlias = false;
23+
24+
private int deobfuscationMinLength = 0;
25+
private int deobfuscationMaxLength = Integer.MAX_VALUE;
26+
27+
@Override
28+
public File getOutDir() {
29+
return outDir;
30+
}
31+
32+
public void setOutDir(File outDir) {
33+
this.outDir = outDir;
34+
}
35+
36+
@Override
37+
public int getThreadsCount() {
38+
return threadsCount;
39+
}
40+
41+
public void setThreadsCount(int threadsCount) {
42+
this.threadsCount = threadsCount;
43+
}
44+
45+
@Override
46+
public boolean isCFGOutput() {
47+
return cfgOutput;
48+
}
49+
50+
public void setCfgOutput(boolean cfgOutput) {
51+
this.cfgOutput = cfgOutput;
52+
}
53+
54+
@Override
55+
public boolean isRawCFGOutput() {
56+
return rawCFGOutput;
57+
}
58+
59+
public void setRawCFGOutput(boolean rawCFGOutput) {
60+
this.rawCFGOutput = rawCFGOutput;
61+
}
62+
63+
@Override
64+
public boolean isFallbackMode() {
65+
return fallbackMode;
66+
}
67+
68+
public void setFallbackMode(boolean fallbackMode) {
69+
this.fallbackMode = fallbackMode;
70+
}
71+
72+
@Override
73+
public boolean isShowInconsistentCode() {
74+
return showInconsistentCode;
75+
}
76+
77+
public void setShowInconsistentCode(boolean showInconsistentCode) {
78+
this.showInconsistentCode = showInconsistentCode;
79+
}
80+
81+
@Override
82+
public boolean isVerbose() {
83+
return isVerbose;
84+
}
85+
86+
public void setVerbose(boolean verbose) {
87+
isVerbose = verbose;
88+
}
89+
90+
@Override
91+
public boolean isSkipResources() {
92+
return isSkipResources;
93+
}
94+
95+
public void setSkipResources(boolean skipResources) {
96+
isSkipResources = skipResources;
97+
}
98+
99+
@Override
100+
public boolean isSkipSources() {
101+
return isSkipSources;
102+
}
103+
104+
public void setSkipSources(boolean skipSources) {
105+
isSkipSources = skipSources;
106+
}
107+
108+
@Override
109+
public boolean isDeobfuscationOn() {
110+
return isDeobfuscationOn;
111+
}
112+
113+
public void setDeobfuscationOn(boolean deobfuscationOn) {
114+
isDeobfuscationOn = deobfuscationOn;
115+
}
116+
117+
@Override
118+
public boolean isDeobfuscationForceSave() {
119+
return isDeobfuscationForceSave;
120+
}
121+
122+
public void setDeobfuscationForceSave(boolean deobfuscationForceSave) {
123+
isDeobfuscationForceSave = deobfuscationForceSave;
124+
}
125+
126+
@Override
127+
public boolean useSourceNameAsClassAlias() {
128+
return useSourceNameAsClassAlias;
129+
}
130+
131+
public void setUseSourceNameAsClassAlias(boolean useSourceNameAsClassAlias) {
132+
this.useSourceNameAsClassAlias = useSourceNameAsClassAlias;
133+
}
134+
135+
@Override
136+
public int getDeobfuscationMinLength() {
137+
return deobfuscationMinLength;
138+
}
139+
140+
public void setDeobfuscationMinLength(int deobfuscationMinLength) {
141+
this.deobfuscationMinLength = deobfuscationMinLength;
142+
}
143+
144+
@Override
145+
public int getDeobfuscationMaxLength() {
146+
return deobfuscationMaxLength;
147+
}
148+
149+
public void setDeobfuscationMaxLength(int deobfuscationMaxLength) {
150+
this.deobfuscationMaxLength = deobfuscationMaxLength;
151+
}
152+
}

app/src/main/java/jadx/api/JadxDecompiler.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import jadx.core.Jadx;
1919
import jadx.core.ProcessClass;
2020
import jadx.core.codegen.CodeGen;
21-
import jadx.core.codegen.CodeWriter;
2221
import jadx.core.dex.nodes.ClassNode;
2322
import jadx.core.dex.nodes.FieldNode;
2423
import jadx.core.dex.nodes.MethodNode;
@@ -30,6 +29,7 @@
3029
import jadx.core.utils.exceptions.JadxRuntimeException;
3130
import jadx.core.utils.files.InputFile;
3231
import jadx.core.xmlgen.BinaryXMLParser;
32+
import jadx.core.xmlgen.ResourcesSaver;
3333

3434
/**
3535
* Jadx API usage example:
@@ -69,7 +69,7 @@ public final class JadxDecompiler {
6969
private Map<FieldNode, JavaField> fieldsMap = new HashMap<FieldNode, JavaField>();
7070

7171
public JadxDecompiler() {
72-
this(new DefaultJadxArgs());
72+
this(new JadxArgs());
7373
}
7474

7575
public JadxDecompiler(IJadxArgs jadxArgs) {
@@ -86,7 +86,7 @@ public void setOutputDir(File outDir) {
8686

8787
void init() {
8888
if (outDir == null) {
89-
outDir = new DefaultJadxArgs().getOutDir();
89+
outDir = new JadxArgs().getOutDir();
9090
}
9191
this.passes = Jadx.getPassesList(args, outDir);
9292
this.codeGen = new CodeGen(args);
@@ -116,7 +116,12 @@ public void loadFiles(List<File> files) throws JadxException {
116116
inputFiles.clear();
117117
for (File file : files) {
118118
try {
119-
inputFiles.add(new InputFile(file));
119+
InputFile inputFile = new InputFile(file);
120+
inputFiles.add(inputFile);
121+
while (inputFile.nextDexIndex != -1) {
122+
inputFile = new InputFile(file, inputFile.nextDexIndex);
123+
inputFiles.add(inputFile);
124+
}
120125
} catch (IOException e) {
121126
throw new JadxException("Error load file: " + file, e);
122127
}
@@ -136,7 +141,7 @@ public void saveResources() {
136141
save(false, true);
137142
}
138143

139-
public void save(boolean saveSources, boolean saveResources) {
144+
private void save(boolean saveSources, boolean saveResources) {
140145
try {
141146
ExecutorService ex = getSaveExecutor(saveSources, saveResources);
142147
ex.shutdown();
@@ -150,12 +155,12 @@ public ExecutorService getSaveExecutor() {
150155
return getSaveExecutor(!args.isSkipSources(), !args.isSkipResources());
151156
}
152157

153-
private ExecutorService getSaveExecutor(boolean saveSources, boolean saveResources) {
158+
private ExecutorService getSaveExecutor(boolean saveSources, final boolean saveResources) {
154159
if (root == null) {
155160
throw new JadxRuntimeException("No loaded files");
156161
}
157162
int threadsCount = args.getThreadsCount();
158-
LOG.debug("processing threads count: " + threadsCount);
163+
LOG.debug("processing threads count: {}", threadsCount);
159164

160165
LOG.info("processing ...");
161166
ExecutorService executor = Executors.newFixedThreadPool(threadsCount);
@@ -165,26 +170,14 @@ private ExecutorService getSaveExecutor(boolean saveSources, boolean saveResourc
165170
@Override
166171
public void run() {
167172
cls.decompile();
168-
LOG.info("Processing " + cls.getFullName());
169173
SaveCode.save(outDir, args, cls.getClassNode());
170174
}
171175
});
172176
}
173177
}
174178
if (saveResources) {
175179
for (final ResourceFile resourceFile : getResources()) {
176-
executor.execute(new Runnable() {
177-
@Override
178-
public void run() {
179-
if (ResourceType.isSupportedForUnpack(resourceFile.getType())) {
180-
CodeWriter cw = resourceFile.getContent();
181-
if (cw != null) {
182-
cw.save(new File(outDir, resourceFile.getName()));
183-
LOG.info("Processing " + resourceFile.getName());
184-
}
185-
}
186-
}
187-
});
180+
executor.execute(new ResourcesSaver(outDir, resourceFile));
188181
}
189182
}
190183
return executor;
@@ -283,7 +276,7 @@ private void initVisitors() {
283276
try {
284277
pass.init(root);
285278
} catch (Exception e) {
286-
LOG.error("Visitor init failed: " + pass.getClass().getSimpleName() , e);
279+
LOG.error("Visitor init failed: {}", pass.getClass().getSimpleName(), e);
287280
}
288281
}
289282
}
@@ -296,7 +289,7 @@ RootNode getRoot() {
296289
return root;
297290
}
298291

299-
BinaryXMLParser getXmlParser() {
292+
synchronized BinaryXMLParser getXmlParser() {
300293
if (xmlParser == null) {
301294
xmlParser = new BinaryXMLParser(root);
302295
}
@@ -323,4 +316,5 @@ public IJadxArgs getArgs() {
323316
public String toString() {
324317
return "jadx decompiler " + getVersion();
325318
}
319+
326320
}

app/src/main/java/jadx/api/JavaClass.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
package jadx.api;
22

3-
import android.support.annotation.Nullable;
4-
5-
import java.util.ArrayList;
6-
import java.util.Collections;
7-
import java.util.Comparator;
8-
import java.util.HashMap;
9-
import java.util.List;
10-
import java.util.Map;
11-
123
import jadx.core.codegen.CodeWriter;
134
import jadx.core.dex.attributes.AFlag;
145
import jadx.core.dex.attributes.nodes.LineAttrNode;
@@ -17,6 +8,14 @@
178
import jadx.core.dex.nodes.FieldNode;
189
import jadx.core.dex.nodes.MethodNode;
1910

11+
import java.util.ArrayList;
12+
import java.util.Collections;
13+
import java.util.Comparator;
14+
import java.util.HashMap;
15+
import java.util.List;
16+
import java.util.Map;
17+
18+
import org.jetbrains.annotations.Nullable;
2019

2120
public final class JavaClass implements JavaNode {
2221

0 commit comments

Comments
 (0)