Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
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
ab8fa23f
Commit
ab8fa23f
authored
Aug 10, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: move specific code from common jadx args
parent
79854662
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
88 deletions
+93
-88
JadxCLI.java
jadx-cli/src/main/java/jadx/cli/JadxCLI.java
+40
-4
JadxCLIArgs.java
jadx-cli/src/main/java/jadx/cli/JadxCLIArgs.java
+38
-67
JadxGUI.java
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
+13
-14
MainWindow.java
jadx-gui/src/main/java/jadx/gui/MainWindow.java
+2
-3
No files found.
jadx-cli/src/main/java/jadx/cli/JadxCLI.java
View file @
ab8fa23f
package
jadx
.
cli
;
package
jadx
.
cli
;
import
jadx.api.Decompiler
;
import
jadx.api.Decompiler
;
import
jadx.core.utils.exceptions.JadxException
;
import
java.io.File
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
JadxCLI
{
public
class
JadxCLI
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JadxCLI
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
JadxArgs
jadxArgs
=
new
JadxArgs
(
args
,
true
);
try
{
JadxCLIArgs
jadxArgs
=
new
JadxCLIArgs
(
args
);
checkArgs
(
jadxArgs
);
Decompiler
jadx
=
new
Decompiler
(
jadxArgs
);
Decompiler
jadx
=
new
Decompiler
(
jadxArgs
);
jadx
.
processAndSaveAll
();
jadx
.
processAndSaveAll
();
System
.
exit
(
jadx
.
getErrorsCount
());
System
.
exit
(
jadx
.
getErrorsCount
());
}
catch
(
Throwable
e
)
{
LOG
.
error
(
e
.
getMessage
());
System
.
exit
(
1
);
}
}
private
static
void
checkArgs
(
JadxCLIArgs
jadxArgs
)
throws
JadxException
{
if
(
jadxArgs
.
getInput
().
isEmpty
())
throw
new
JadxException
(
"Please specify input file"
);
File
outputDir
=
jadxArgs
.
getOutDir
();
if
(
outputDir
==
null
)
{
String
outDirName
;
File
file
=
jadxArgs
.
getInput
().
get
(
0
);
String
name
=
file
.
getName
();
int
pos
=
name
.
lastIndexOf
(
'.'
);
if
(
pos
!=
-
1
)
outDirName
=
name
.
substring
(
0
,
pos
);
else
outDirName
=
name
+
"-jadx-out"
;
LOG
.
info
(
"output directory: "
+
outDirName
);
outputDir
=
new
File
(
outDirName
);
jadxArgs
.
setOutputDir
(
outputDir
);
}
if
(
outputDir
.
exists
()
&&
!
outputDir
.
isDirectory
())
throw
new
JadxException
(
"Output directory exists as file "
+
outputDir
);
}
}
}
}
jadx-cli/src/main/java/jadx/cli/JadxArgs.java
→
jadx-cli/src/main/java/jadx/cli/Jadx
CLI
Args.java
View file @
ab8fa23f
package
jadx
.
cli
;
package
jadx
.
cli
;
import
jadx.core.Consts
;
import
jadx.api.IJadxArgs
;
import
jadx.api.IJadxArgs
;
import
jadx.core.Consts
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.exceptions.JadxException
;
import
java.io.File
;
import
java.io.File
;
...
@@ -18,10 +18,9 @@ import com.beust.jcommander.Parameter;
...
@@ -18,10 +18,9 @@ import com.beust.jcommander.Parameter;
import
com.beust.jcommander.ParameterDescription
;
import
com.beust.jcommander.ParameterDescription
;
import
com.beust.jcommander.ParameterException
;
import
com.beust.jcommander.ParameterException
;
public
class
JadxArgs
implements
IJadxArgs
{
public
final
class
JadxCLIArgs
implements
IJadxArgs
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JadxArgs
.
class
);
@Parameter
(
description
=
"<input file
s
> (.dex, .apk, .jar or .class)"
)
@Parameter
(
description
=
"<input file> (.dex, .apk, .jar or .class)"
)
protected
List
<
String
>
files
;
protected
List
<
String
>
files
;
@Parameter
(
names
=
{
"-d"
,
"--output-dir"
},
description
=
"output directory"
)
@Parameter
(
names
=
{
"-d"
,
"--output-dir"
},
description
=
"output directory"
)
...
@@ -45,50 +44,30 @@ public class JadxArgs implements IJadxArgs {
...
@@ -45,50 +44,30 @@ public class JadxArgs implements IJadxArgs {
@Parameter
(
names
=
{
"-h"
,
"--help"
},
description
=
"print this help"
,
help
=
true
)
@Parameter
(
names
=
{
"-h"
,
"--help"
},
description
=
"print this help"
,
help
=
true
)
protected
boolean
printHelp
=
false
;
protected
boolean
printHelp
=
false
;
private
final
List
<
File
>
input
=
new
ArrayList
<
File
>();
private
final
List
<
File
>
input
=
new
ArrayList
<
File
>(
1
);
private
File
outputDir
;
private
File
outputDir
;
private
final
boolean
inputRequired
;
public
JadxCLIArgs
(
String
[]
args
)
{
public
JadxArgs
(
String
[]
args
,
boolean
inputRequired
)
{
this
.
inputRequired
=
inputRequired
;
parse
(
args
);
parse
(
args
);
checkArgument
s
();
processArg
s
();
}
}
private
void
parse
(
String
[]
args
)
{
private
void
parse
(
String
[]
args
)
{
try
{
try
{
new
JCommander
(
this
,
args
);
new
JCommander
(
this
,
args
);
}
catch
(
ParameterException
e
)
{
}
catch
(
ParameterException
e
)
{
System
.
out
.
println
(
"Arguments parse error: "
+
e
.
getMessage
());
System
.
err
.
println
(
"Arguments parse error: "
+
e
.
getMessage
());
System
.
out
.
println
();
printUsage
();
printHelp
=
true
;
System
.
exit
(
1
)
;
}
}
}
}
p
rivate
void
checkArgument
s
()
{
p
ublic
void
processArg
s
()
{
if
(
isPrintHelp
())
{
if
(
isPrintHelp
())
{
printUsage
();
printUsage
();
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
if
(
isVerbose
())
{
ch
.
qos
.
logback
.
classic
.
Logger
rootLogger
=
(
ch
.
qos
.
logback
.
classic
.
Logger
)
LoggerFactory
.
getLogger
(
Logger
.
ROOT_LOGGER_NAME
);
rootLogger
.
setLevel
(
ch
.
qos
.
logback
.
classic
.
Level
.
DEBUG
);
}
try
{
try
{
processArgs
();
}
catch
(
JadxException
e
)
{
LOG
.
error
(
e
.
getMessage
());
printUsage
();
System
.
exit
(
1
);
}
}
public
void
processArgs
()
throws
JadxException
{
if
(
printHelp
)
return
;
if
(
threadsCount
<=
0
)
if
(
threadsCount
<=
0
)
throw
new
JadxException
(
"Threads count must be positive"
);
throw
new
JadxException
(
"Threads count must be positive"
);
...
@@ -102,31 +81,22 @@ public class JadxArgs implements IJadxArgs {
...
@@ -102,31 +81,22 @@ public class JadxArgs implements IJadxArgs {
}
}
}
}
if
(
input
.
isEmpty
())
{
if
(
input
.
size
()
>
1
)
if
(
inputRequired
)
throw
new
JadxException
(
"Please specify input file"
);
else
return
;
}
if
(
input
.
size
()
>
1
)
{
throw
new
JadxException
(
"Only one input file is supported"
);
throw
new
JadxException
(
"Only one input file is supported"
);
}
if
(
outDirName
==
null
)
{
if
(
outDirName
!=
null
)
File
file
=
new
File
(
files
.
get
(
0
));
outputDir
=
new
File
(
outDirName
);
String
name
=
file
.
getName
();
int
pos
=
name
.
lastIndexOf
(
'.'
);
if
(
pos
!=
-
1
)
outDirName
=
name
.
substring
(
0
,
pos
);
else
outDirName
=
name
+
"-jadx-out"
;
LOG
.
info
(
"output directory: "
+
outDirName
);
if
(
isVerbose
())
{
ch
.
qos
.
logback
.
classic
.
Logger
rootLogger
=
(
ch
.
qos
.
logback
.
classic
.
Logger
)
LoggerFactory
.
getLogger
(
Logger
.
ROOT_LOGGER_NAME
);
rootLogger
.
setLevel
(
ch
.
qos
.
logback
.
classic
.
Level
.
DEBUG
);
}
}
catch
(
JadxException
e
)
{
System
.
err
.
println
(
"ERROR: "
+
e
.
getMessage
());
printUsage
();
System
.
exit
(
1
);
}
}
outputDir
=
new
File
(
outDirName
);
if
(
outputDir
.
exists
()
&&
!
outputDir
.
isDirectory
())
throw
new
JadxException
(
"Output directory exists as file "
+
outputDir
);
}
}
public
void
printUsage
()
{
public
void
printUsage
()
{
...
@@ -157,9 +127,6 @@ public class JadxArgs implements IJadxArgs {
...
@@ -157,9 +127,6 @@ public class JadxArgs implements IJadxArgs {
opt
.
append
(
' '
).
append
(
p
.
getNames
());
opt
.
append
(
' '
).
append
(
p
.
getNames
());
addSpaces
(
opt
,
maxNamesLen
-
opt
.
length
()
+
2
);
addSpaces
(
opt
,
maxNamesLen
-
opt
.
length
()
+
2
);
opt
.
append
(
"- "
).
append
(
p
.
getDescription
());
opt
.
append
(
"- "
).
append
(
p
.
getDescription
());
if
(
inputRequired
&&
name
.
equals
(
"files"
))
{
opt
.
append
(
" [required]"
);
}
out
.
println
(
opt
.
toString
());
out
.
println
(
opt
.
toString
());
break
;
break
;
}
}
...
@@ -179,6 +146,10 @@ public class JadxArgs implements IJadxArgs {
...
@@ -179,6 +146,10 @@ public class JadxArgs implements IJadxArgs {
return
outputDir
;
return
outputDir
;
}
}
public
void
setOutputDir
(
File
outputDir
)
{
this
.
outputDir
=
outputDir
;
}
@Override
@Override
public
int
getThreadsCount
()
{
public
int
getThreadsCount
()
{
return
threadsCount
;
return
threadsCount
;
...
...
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
View file @
ab8fa23f
package
jadx
.
gui
;
package
jadx
.
gui
;
import
jadx.cli.JadxArgs
;
import
jadx.cli.Jadx
CLI
Args
;
import
javax.swing.SwingUtilities
;
import
javax.swing.SwingUtilities
;
import
javax.swing.UIManager
;
import
javax.swing.UIManager
;
...
@@ -12,18 +12,13 @@ public class JadxGUI {
...
@@ -12,18 +12,13 @@ public class JadxGUI {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JadxGUI
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JadxGUI
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
final
JadxArgs
jadxArgs
=
new
JadxArgs
(
args
,
false
);
try
{
try
{
final
JadxCLIArgs
jadxArgs
=
new
JadxCLIArgs
(
args
);
UIManager
.
setLookAndFeel
(
UIManager
.
getSystemLookAndFeelClassName
());
UIManager
.
setLookAndFeel
(
UIManager
.
getSystemLookAndFeelClassName
());
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Error: "
+
e
.
getMessage
());
System
.
exit
(
1
);
}
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
MainWindow
mainWindow
=
new
MainWindow
(
jadxArgs
);
JadxWrapper
wrapper
=
new
JadxWrapper
(
jadxArgs
);
MainWindow
mainWindow
=
new
MainWindow
(
wrapper
);
mainWindow
.
setVisible
(
true
);
mainWindow
.
setVisible
(
true
);
if
(!
jadxArgs
.
getInput
().
isEmpty
())
{
if
(!
jadxArgs
.
getInput
().
isEmpty
())
{
...
@@ -31,6 +26,10 @@ public class JadxGUI {
...
@@ -31,6 +26,10 @@ public class JadxGUI {
}
}
}
}
});
});
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Error: "
+
e
.
getMessage
());
System
.
exit
(
1
);
}
}
}
}
}
jadx-gui/src/main/java/jadx/gui/MainWindow.java
View file @
ab8fa23f
package
jadx
.
gui
;
package
jadx
.
gui
;
import
jadx.cli.JadxArgs
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JRoot
;
import
jadx.gui.treemodel.JRoot
;
...
@@ -66,8 +65,8 @@ public class MainWindow extends JFrame {
...
@@ -66,8 +65,8 @@ public class MainWindow extends JFrame {
private
JToolBar
searchToolBar
;
private
JToolBar
searchToolBar
;
private
SearchBar
searchBar
;
private
SearchBar
searchBar
;
public
MainWindow
(
Jadx
Args
jadxArgs
)
{
public
MainWindow
(
Jadx
Wrapper
wrapper
)
{
this
.
wrapper
=
new
JadxWrapper
(
jadxArgs
)
;
this
.
wrapper
=
wrapper
;
initUI
();
initUI
();
initMenuAndToolbar
();
initMenuAndToolbar
();
...
...
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