Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
cc2ae80e
Commit
cc2ae80e
authored
Jan 15, 2018
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #204
parent
b921f609
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
9 deletions
+92
-9
JadxCLIArgs.java
jadx-cli/src/main/java/jadx/cli/JadxCLIArgs.java
+31
-0
IJadxArgs.java
jadx-core/src/main/java/jadx/api/IJadxArgs.java
+4
-0
JadxArgs.java
jadx-core/src/main/java/jadx/api/JadxArgs.java
+20
-0
JadxDecompiler.java
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
+35
-8
IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+2
-1
No files found.
jadx-cli/src/main/java/jadx/cli/JadxCLIArgs.java
View file @
cc2ae80e
...
...
@@ -32,6 +32,12 @@ public class JadxCLIArgs implements IJadxArgs {
@Parameter
(
names
=
{
"-d"
,
"--output-dir"
},
description
=
"output directory"
)
protected
String
outDirName
;
@Parameter
(
names
=
{
"-ds"
,
"--output-dir-src"
},
description
=
"output directory for sources"
)
protected
String
outDirNameSrc
;
@Parameter
(
names
=
{
"-dr"
,
"--output-dir-res"
},
description
=
"output directory for resources"
)
protected
String
outDirNameRes
;
@Parameter
(
names
=
{
"-j"
,
"--threads-count"
},
description
=
"processing threads count"
)
protected
int
threadsCount
=
DEFAULT_THREADS_COUNT
;
...
...
@@ -90,6 +96,8 @@ public class JadxCLIArgs implements IJadxArgs {
private
final
List
<
File
>
input
=
new
ArrayList
<>(
1
);
private
File
outputDir
;
private
File
outputDirSrc
;
private
File
outputDirRes
;
public
boolean
processArgs
(
String
[]
args
)
{
return
parse
(
args
)
&&
process
();
...
...
@@ -128,9 +136,22 @@ public class JadxCLIArgs implements IJadxArgs {
if
(
input
.
size
()
>
1
)
{
throw
new
JadxException
(
"Only one input file is supported"
);
}
if
(
outDirNameSrc
!=
null
)
{
outputDirSrc
=
new
File
(
outDirNameSrc
);
}
if
(
outDirNameRes
!=
null
)
{
outputDirRes
=
new
File
(
outDirNameRes
);
}
if
(
outDirName
!=
null
)
{
outputDir
=
new
File
(
outDirName
);
if
(
outputDirSrc
==
null
)
{
outputDirSrc
=
new
File
(
outputDir
,
"source"
);
}
if
(
outputDirRes
==
null
)
{
outputDirRes
=
new
File
(
outputDir
,
"res"
);
}
}
if
(
isVerbose
())
{
ch
.
qos
.
logback
.
classic
.
Logger
rootLogger
=
(
ch
.
qos
.
logback
.
classic
.
Logger
)
LoggerFactory
.
getLogger
(
Logger
.
ROOT_LOGGER_NAME
);
...
...
@@ -207,6 +228,16 @@ public class JadxCLIArgs implements IJadxArgs {
return
outputDir
;
}
@Override
public
File
getOutDirSrc
()
{
return
outputDirSrc
;
}
@Override
public
File
getOutDirRes
()
{
return
outputDirRes
;
}
public
void
setOutputDir
(
File
outputDir
)
{
this
.
outputDir
=
outputDir
;
}
...
...
jadx-core/src/main/java/jadx/api/IJadxArgs.java
View file @
cc2ae80e
...
...
@@ -4,6 +4,10 @@ import java.io.File;
public
interface
IJadxArgs
{
File
getOutDir
();
File
getOutDirSrc
();
File
getOutDirRes
();
int
getThreadsCount
();
...
...
jadx-core/src/main/java/jadx/api/JadxArgs.java
View file @
cc2ae80e
...
...
@@ -5,6 +5,8 @@ import java.io.File;
public
class
JadxArgs
implements
IJadxArgs
{
private
File
outDir
=
new
File
(
"jadx-output"
);
private
File
outDirSrc
=
new
File
(
outDir
,
"source"
);
private
File
outDirRes
=
new
File
(
outDir
,
"res"
);
private
int
threadsCount
=
Math
.
max
(
1
,
Runtime
.
getRuntime
().
availableProcessors
()
-
1
);
private
boolean
cfgOutput
=
false
;
...
...
@@ -40,6 +42,24 @@ public class JadxArgs implements IJadxArgs {
}
@Override
public
File
getOutDirSrc
()
{
return
outDirSrc
;
}
public
void
setOutDirSrc
(
File
outDirSrc
)
{
this
.
outDirSrc
=
outDirSrc
;
}
@Override
public
File
getOutDirRes
()
{
return
outDirRes
;
}
public
void
setOutDirRes
(
File
outDirRes
)
{
this
.
outDirRes
=
outDirRes
;
}
@Override
public
int
getThreadsCount
()
{
return
threadsCount
;
}
...
...
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
View file @
cc2ae80e
...
...
@@ -11,7 +11,6 @@ import jadx.core.dex.nodes.RootNode;
import
jadx.core.dex.visitors.IDexTreeVisitor
;
import
jadx.core.dex.visitors.SaveCode
;
import
jadx.core.export.ExportGradleProject
;
import
jadx.core.utils.exceptions.DecodeException
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.core.utils.files.InputFile
;
...
...
@@ -57,6 +56,8 @@ public final class JadxDecompiler {
private
final
List
<
InputFile
>
inputFiles
=
new
ArrayList
<>();
private
File
outDir
;
private
File
outDirRes
;
private
File
outDirSrc
;
private
RootNode
root
;
private
List
<
IDexTreeVisitor
>
passes
;
...
...
@@ -71,26 +72,52 @@ public final class JadxDecompiler {
private
Map
<
MethodNode
,
JavaMethod
>
methodsMap
=
new
ConcurrentHashMap
<>();
private
Map
<
FieldNode
,
JavaField
>
fieldsMap
=
new
ConcurrentHashMap
<>();
public
JadxDecompiler
()
{
public
JadxDecompiler
()
throws
JadxException
{
this
(
new
JadxArgs
());
}
public
JadxDecompiler
(
IJadxArgs
jadxArgs
)
{
public
JadxDecompiler
(
IJadxArgs
jadxArgs
)
throws
JadxException
{
this
.
args
=
jadxArgs
;
this
.
outDir
=
jadxArgs
.
getOutDir
();
this
.
outDirSrc
=
jadxArgs
.
getOutDirSrc
();
this
.
outDirRes
=
jadxArgs
.
getOutDirRes
();
reset
();
init
();
}
public
void
setOutputDir
(
File
outDir
)
{
public
void
setOutputDir
(
File
outDir
)
throws
JadxException
{
this
.
outDir
=
outDir
;
init
();
}
void
init
()
{
public
void
setOutputDirSrc
(
File
outDirSrc
)
throws
JadxException
{
this
.
outDirSrc
=
outDirSrc
;
init
();
}
public
void
setOutputDirRes
(
File
outDirRes
)
throws
JadxException
{
this
.
outDirRes
=
outDirRes
;
init
();
}
void
init
()
throws
JadxException
{
if
(
outDir
==
null
&&
outDirSrc
==
null
)
{
outDirSrc
=
new
JadxArgs
().
getOutDirSrc
();
}
if
(
outDir
==
null
&&
outDirRes
==
null
)
{
outDirRes
=
new
JadxArgs
().
getOutDirRes
();
}
if
(
outDir
==
null
)
{
outDir
=
new
JadxArgs
().
getOutDir
();
}
else
{
if
(
outDirSrc
==
null
&&
outDirRes
!=
null
&&
!
args
.
isSkipSources
())
{
throw
new
JadxException
(
"--output-dir-src must be specified"
);
}
if
(
outDirSrc
!=
null
&&
outDirRes
==
null
&&
!
args
.
isSkipResources
())
{
throw
new
JadxException
(
"--output-dir-res must be specified"
);
}
}
this
.
passes
=
Jadx
.
getPassesList
(
args
,
outDir
);
this
.
codeGen
=
new
CodeGen
(
args
);
}
...
...
@@ -172,8 +199,8 @@ public final class JadxDecompiler {
sourcesOutDir
=
export
.
getSrcOutDir
();
resOutDir
=
export
.
getResOutDir
();
}
else
{
sourcesOutDir
=
outDir
;
resOutDir
=
outDir
;
sourcesOutDir
=
outDir
Src
;
resOutDir
=
outDir
Res
;
}
if
(
saveSources
)
{
appendSourcesSave
(
executor
,
sourcesOutDir
);
...
...
@@ -267,7 +294,7 @@ public final class JadxDecompiler {
root
.
getErrorsCounter
().
printReport
();
}
void
parse
()
throws
Decode
Exception
{
void
parse
()
throws
Jadx
Exception
{
reset
();
init
();
...
...
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
View file @
cc2ae80e
...
...
@@ -83,8 +83,9 @@ public abstract class IntegrationTest extends TestUtils {
}
public
ClassNode
getClassNodeFromFile
(
File
file
,
String
clsName
)
{
JadxDecompiler
d
=
n
ew
JadxDecompiler
(
args
)
;
JadxDecompiler
d
=
n
ull
;
try
{
d
=
new
JadxDecompiler
(
args
);
d
.
loadFile
(
file
);
}
catch
(
JadxException
e
)
{
e
.
printStackTrace
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment