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
e54b7645
Commit
e54b7645
authored
Dec 07, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code style issues reported by sonar
parent
37f03bcf
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
115 additions
and
110 deletions
+115
-110
.travis.yml
.travis.yml
+2
-1
JadxCLI.java
jadx-cli/src/main/java/jadx/cli/JadxCLI.java
+3
-2
ClsSet.java
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
+21
-10
ClspGraph.java
jadx-core/src/main/java/jadx/core/clsp/ClspGraph.java
+6
-8
CodeWriter.java
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
+1
-1
MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+3
-3
NameMapper.java
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
+2
-2
AttributeType.java
...src/main/java/jadx/core/dex/attributes/AttributeType.java
+3
-3
InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+12
-12
IBlock.java
jadx-core/src/main/java/jadx/core/dex/nodes/IBlock.java
+1
-1
IContainer.java
jadx-core/src/main/java/jadx/core/dex/nodes/IContainer.java
+0
-5
ILoadable.java
jadx-core/src/main/java/jadx/core/dex/nodes/ILoadable.java
+2
-2
IRegion.java
jadx-core/src/main/java/jadx/core/dex/nodes/IRegion.java
+2
-2
MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+11
-11
RootNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
+1
-2
AnnotationsParser.java
...in/java/jadx/core/dex/nodes/parser/AnnotationsParser.java
+11
-11
DebugInfoParser.java
...main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
+6
-6
IfCondition.java
...core/src/main/java/jadx/core/dex/regions/IfCondition.java
+2
-1
BlockMakerVisitor.java
...c/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
+8
-8
IRegionVisitor.java
...n/java/jadx/core/dex/visitors/regions/IRegionVisitor.java
+3
-3
ErrorsCounter.java
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
+4
-4
InsnUtils.java
jadx-core/src/main/java/jadx/core/utils/InsnUtils.java
+2
-1
JavaToDex.java
jadx-core/src/main/java/jadx/core/utils/files/JavaToDex.java
+6
-8
OverlayIcon.java
jadx-gui/src/main/java/jadx/gui/utils/OverlayIcon.java
+3
-3
No files found.
.travis.yml
View file @
e54b7645
...
...
@@ -5,7 +5,8 @@ jdk:
-
openjdk6
before_install
:
-
chmod +x gradlew
script
:
./gradlew clean build dist
script
:
-
TERM=dumb ./gradlew clean build dist
notifications
:
email
:
-
skylot@gmail.com
jadx-cli/src/main/java/jadx/cli/JadxCLI.java
View file @
e54b7645
...
...
@@ -2,6 +2,7 @@ package jadx.cli;
import
jadx.api.Decompiler
;
import
jadx.core.utils.ErrorsCounter
;
import
jadx.core.utils.exceptions.JadxException
;
import
java.io.File
;
...
...
@@ -39,7 +40,7 @@ public class JadxCLI {
System
.
exit
(
errorsCount
);
}
private
static
void
checkArgs
(
JadxCLIArgs
jadxArgs
)
throws
Exception
{
private
static
void
checkArgs
(
JadxCLIArgs
jadxArgs
)
throws
Jadx
Exception
{
if
(
jadxArgs
.
getInput
().
isEmpty
())
{
LOG
.
error
(
"Please specify input file"
);
jadxArgs
.
printUsage
();
...
...
@@ -61,7 +62,7 @@ public class JadxCLI {
jadxArgs
.
setOutputDir
(
outputDir
);
}
if
(
outputDir
.
exists
()
&&
!
outputDir
.
isDirectory
())
{
throw
new
Exception
(
"Output directory exists as file "
+
outputDir
);
throw
new
Jadx
Exception
(
"Output directory exists as file "
+
outputDir
);
}
}
}
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
View file @
e54b7645
...
...
@@ -5,6 +5,7 @@ import jadx.core.dex.nodes.ClassNode;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.exceptions.DecodeException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.io.BufferedOutputStream
;
import
java.io.DataInputStream
;
...
...
@@ -39,6 +40,8 @@ public class ClsSet {
private
static
final
String
JADX_CLS_SET_HEADER
=
"jadx-cst"
;
private
static
final
int
VERSION
=
1
;
private
static
final
String
STRING_CHARSET
=
"US-ASCII"
;
private
NClass
[]
classes
;
public
void
load
(
RootNode
root
)
{
...
...
@@ -50,7 +53,7 @@ public class ClsSet {
if
(
cls
.
getAccessFlags
().
isPublic
())
{
NClass
nClass
=
new
NClass
(
clsRawName
,
k
);
if
(
names
.
put
(
clsRawName
,
nClass
)
!=
null
)
{
throw
new
RuntimeException
(
"Duplicate class: "
+
clsRawName
);
throw
new
Jadx
RuntimeException
(
"Duplicate class: "
+
clsRawName
);
}
k
++;
}
else
{
...
...
@@ -113,7 +116,7 @@ public class ClsSet {
outputStream
.
close
();
}
}
else
{
throw
new
RuntimeException
(
"Unknown file format: "
+
outputName
);
throw
new
Jadx
RuntimeException
(
"Unknown file format: "
+
outputName
);
}
}
...
...
@@ -139,7 +142,7 @@ public class ClsSet {
public
void
load
()
throws
IOException
,
DecodeException
{
InputStream
input
=
getClass
().
getResourceAsStream
(
CLST_FILENAME
);
if
(
input
==
null
)
{
throw
new
RuntimeException
(
"Can't load classpath file: "
+
CLST_FILENAME
);
throw
new
Jadx
RuntimeException
(
"Can't load classpath file: "
+
CLST_FILENAME
);
}
load
(
input
);
}
...
...
@@ -163,16 +166,18 @@ public class ClsSet {
in
.
close
();
}
}
else
{
throw
new
RuntimeException
(
"Unknown file format: "
+
name
);
throw
new
Jadx
RuntimeException
(
"Unknown file format: "
+
name
);
}
}
public
void
load
(
InputStream
input
)
throws
IOException
,
DecodeException
{
DataInputStream
in
=
new
DataInputStream
(
input
);
byte
[]
header
=
new
byte
[
JADX_CLS_SET_HEADER
.
length
()];
in
.
read
(
header
);
in
t
readHeaderLength
=
in
.
read
(
header
);
int
version
=
in
.
readByte
();
if
(!
JADX_CLS_SET_HEADER
.
equals
(
new
String
(
header
))
||
version
!=
VERSION
)
{
if
(
readHeaderLength
!=
JADX_CLS_SET_HEADER
.
length
()
||
!
JADX_CLS_SET_HEADER
.
equals
(
new
String
(
header
,
STRING_CHARSET
))
||
version
!=
VERSION
)
{
throw
new
DecodeException
(
"Wrong jadx class set header"
);
}
int
count
=
in
.
readInt
();
...
...
@@ -192,7 +197,7 @@ public class ClsSet {
}
private
void
writeString
(
DataOutputStream
out
,
String
name
)
throws
IOException
{
byte
[]
bytes
=
name
.
getBytes
();
byte
[]
bytes
=
name
.
getBytes
(
STRING_CHARSET
);
out
.
writeByte
(
bytes
.
length
);
out
.
write
(
bytes
);
}
...
...
@@ -209,10 +214,16 @@ public class ClsSet {
count
+=
res
;
}
}
return
new
String
(
bytes
);
return
new
String
(
bytes
,
STRING_CHARSET
);
}
public
int
getClassesCount
()
{
return
classes
.
length
;
}
public
NClass
[]
getClasses
()
{
return
classes
;
public
void
addToMap
(
Map
<
String
,
NClass
>
nameMap
)
{
for
(
NClass
cls
:
classes
)
{
nameMap
.
put
(
cls
.
getName
(),
cls
);
}
}
}
jadx-core/src/main/java/jadx/core/clsp/ClspGraph.java
View file @
e54b7645
...
...
@@ -2,6 +2,7 @@ package jadx.core.clsp;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.utils.exceptions.DecodeException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.io.IOException
;
import
java.util.HashMap
;
...
...
@@ -20,8 +21,8 @@ import org.slf4j.LoggerFactory;
public
class
ClspGraph
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ClspGraph
.
class
);
private
final
Map
<
String
,
Set
<
String
>>
ancestorCache
=
new
WeakHashMap
<
String
,
Set
<
String
>>();
private
Map
<
String
,
NClass
>
nameMap
;
private
Map
<
String
,
Set
<
String
>>
ancestorCache
=
new
WeakHashMap
<
String
,
Set
<
String
>>();
public
void
load
()
throws
IOException
,
DecodeException
{
ClsSet
set
=
new
ClsSet
();
...
...
@@ -30,20 +31,17 @@ public class ClspGraph {
}
public
void
addClasspath
(
ClsSet
set
)
{
NClass
[]
arr
=
set
.
getClasses
();
if
(
nameMap
==
null
)
{
nameMap
=
new
HashMap
<
String
,
NClass
>(
arr
.
length
);
for
(
NClass
cls
:
arr
)
{
nameMap
.
put
(
cls
.
getName
(),
cls
);
}
nameMap
=
new
HashMap
<
String
,
NClass
>(
set
.
getClassesCount
());
set
.
addToMap
(
nameMap
);
}
else
{
throw
new
RuntimeException
(
"Classpath already loaded"
);
throw
new
Jadx
RuntimeException
(
"Classpath already loaded"
);
}
}
public
void
addApp
(
List
<
ClassNode
>
classes
)
{
if
(
nameMap
==
null
)
{
throw
new
RuntimeException
(
"Classpath must be loaded first"
);
throw
new
Jadx
RuntimeException
(
"Classpath must be loaded first"
);
}
int
size
=
classes
.
size
();
NClass
[]
nClasses
=
new
NClass
[
size
];
...
...
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
View file @
e54b7645
...
...
@@ -19,7 +19,7 @@ public class CodeWriter {
public
static
final
String
NL
=
System
.
getProperty
(
"line.separator"
);
private
static
final
String
INDENT
=
"\t"
;
private
StringBuilder
buf
=
new
StringBuilder
();
private
final
StringBuilder
buf
=
new
StringBuilder
();
private
String
indentStr
;
private
int
indent
;
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
View file @
e54b7645
...
...
@@ -287,9 +287,9 @@ public class MethodGen {
}
try
{
if
(
insnGen
.
makeInsn
(
insn
,
code
))
{
CatchAttr
_catch
=
(
CatchAttr
)
attrs
.
get
(
AttributeType
.
CATCH_BLOCK
);
if
(
_catch
!=
null
)
code
.
add
(
"\t //"
+
_catch
);
CatchAttr
catchAttr
=
(
CatchAttr
)
attrs
.
get
(
AttributeType
.
CATCH_BLOCK
);
if
(
catchAttr
!=
null
)
code
.
add
(
"\t //"
+
catchAttr
);
}
}
catch
(
CodegenException
e
)
{
code
.
startLine
(
"// error: "
+
insn
);
...
...
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
View file @
e54b7645
...
...
@@ -6,7 +6,7 @@ import java.util.Set;
public
class
NameMapper
{
private
static
final
Set
<
String
>
reservedNames
=
new
HashSet
<
String
>(
private
static
final
Set
<
String
>
RESERVED_NAMES
=
new
HashSet
<
String
>(
Arrays
.
asList
(
new
String
[]{
"abstract"
,
"assert"
,
...
...
@@ -64,7 +64,7 @@ public class NameMapper {
}));
public
static
boolean
isReserved
(
String
str
)
{
return
reservedNames
.
contains
(
str
);
return
RESERVED_NAMES
.
contains
(
str
);
}
}
jadx-core/src/main/java/jadx/core/dex/attributes/AttributeType.java
View file @
e54b7645
...
...
@@ -29,7 +29,7 @@ public enum AttributeType {
DECLARE_VARIABLE
(
true
);
private
static
final
int
notUniqCount
;
private
static
final
int
NOT_UNIQ_COUNT
;
private
final
boolean
uniq
;
static
{
...
...
@@ -41,11 +41,11 @@ public enum AttributeType {
if
(
type
.
notUniq
())
last
=
i
;
}
notUniqCount
=
last
+
1
;
NOT_UNIQ_COUNT
=
last
+
1
;
}
public
static
int
getNotUniqCount
()
{
return
notUniqCount
;
return
NOT_UNIQ_COUNT
;
}
private
AttributeType
(
boolean
isUniq
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
View file @
e54b7645
...
...
@@ -146,7 +146,7 @@ public class InsnDecoder {
case
Opcodes
.
ADD_INT_LIT8
:
case
Opcodes
.
ADD_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
ADD
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
ADD
,
ArgType
.
INT
);
case
Opcodes
.
SUB_INT
:
case
Opcodes
.
SUB_INT_2ADDR
:
...
...
@@ -189,7 +189,7 @@ public class InsnDecoder {
case
Opcodes
.
MUL_INT_LIT8
:
case
Opcodes
.
MUL_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
MUL
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
MUL
,
ArgType
.
INT
);
case
Opcodes
.
DIV_INT
:
case
Opcodes
.
DIV_INT_2ADDR
:
...
...
@@ -225,11 +225,11 @@ public class InsnDecoder {
case
Opcodes
.
DIV_INT_LIT8
:
case
Opcodes
.
DIV_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
DIV
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
DIV
,
ArgType
.
INT
);
case
Opcodes
.
REM_INT_LIT8
:
case
Opcodes
.
REM_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
REM
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
REM
,
ArgType
.
INT
);
case
Opcodes
.
AND_INT
:
case
Opcodes
.
AND_INT_2ADDR
:
...
...
@@ -237,11 +237,11 @@ public class InsnDecoder {
case
Opcodes
.
AND_INT_LIT8
:
case
Opcodes
.
AND_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
AND
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
AND
,
ArgType
.
INT
);
case
Opcodes
.
XOR_INT_LIT8
:
case
Opcodes
.
XOR_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
XOR
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
XOR
,
ArgType
.
INT
);
case
Opcodes
.
AND_LONG
:
case
Opcodes
.
AND_LONG_2ADDR
:
...
...
@@ -253,7 +253,7 @@ public class InsnDecoder {
case
Opcodes
.
OR_INT_LIT8
:
case
Opcodes
.
OR_INT_LIT16
:
return
arith
_l
it
(
insn
,
ArithOp
.
OR
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
OR
,
ArgType
.
INT
);
case
Opcodes
.
XOR_INT
:
case
Opcodes
.
XOR_INT_2ADDR
:
...
...
@@ -292,11 +292,11 @@ public class InsnDecoder {
return
arith
(
insn
,
ArithOp
.
SHR
,
ArgType
.
LONG
);
case
Opcodes
.
SHL_INT_LIT8
:
return
arith
_l
it
(
insn
,
ArithOp
.
SHL
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
SHL
,
ArgType
.
INT
);
case
Opcodes
.
SHR_INT_LIT8
:
return
arith
_l
it
(
insn
,
ArithOp
.
SHR
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
SHR
,
ArgType
.
INT
);
case
Opcodes
.
USHR_INT_LIT8
:
return
arith
_l
it
(
insn
,
ArithOp
.
USHR
,
ArgType
.
INT
);
return
arith
L
it
(
insn
,
ArithOp
.
USHR
,
ArgType
.
INT
);
case
Opcodes
.
NEG_INT
:
return
neg
(
insn
,
ArgType
.
INT
);
...
...
@@ -661,7 +661,7 @@ public class InsnDecoder {
return
new
ArithNode
(
insn
,
op
,
type
,
false
);
}
private
InsnNode
arith
_l
it
(
DecodedInstruction
insn
,
ArithOp
op
,
ArgType
type
)
{
private
InsnNode
arith
L
it
(
DecodedInstruction
insn
,
ArithOp
op
,
ArgType
type
)
{
return
new
ArithNode
(
insn
,
op
,
type
,
true
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/IBlock.java
View file @
e54b7645
...
...
@@ -4,5 +4,5 @@ import java.util.List;
public
interface
IBlock
extends
IContainer
{
public
List
<
InsnNode
>
getInstructions
();
List
<
InsnNode
>
getInstructions
();
}
jadx-core/src/main/java/jadx/core/dex/nodes/IContainer.java
View file @
e54b7645
package
jadx
.
core
.
dex
.
nodes
;
import
jadx.core.dex.attributes.AttributesList
;
import
jadx.core.dex.attributes.IAttributeNode
;
public
interface
IContainer
extends
IAttributeNode
{
@Override
public
AttributesList
getAttributes
();
}
jadx-core/src/main/java/jadx/core/dex/nodes/ILoadable.java
View file @
e54b7645
...
...
@@ -9,11 +9,11 @@ public interface ILoadable {
*
* @throws DecodeException
*/
public
void
load
()
throws
DecodeException
;
void
load
()
throws
DecodeException
;
/**
* Free resources
*/
public
void
unload
();
void
unload
();
}
jadx-core/src/main/java/jadx/core/dex/nodes/IRegion.java
View file @
e54b7645
...
...
@@ -4,8 +4,8 @@ import java.util.List;
public
interface
IRegion
extends
IContainer
{
public
IRegion
getParent
();
IRegion
getParent
();
public
List
<
IContainer
>
getSubBlocks
();
List
<
IContainer
>
getSubBlocks
();
}
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
View file @
e54b7645
...
...
@@ -255,8 +255,8 @@ public class MethodNode extends LineAttrNode implements ILoadable {
// and we don't need this mapping anymore,
// but in maven repository still old version
Set
<
Integer
>
handlerSet
=
new
HashSet
<
Integer
>(
tries
.
length
);
for
(
Try
try_
:
tries
)
{
handlerSet
.
add
(
try_
.
getHandlerOffset
());
for
(
Try
aTry
:
tries
)
{
handlerSet
.
add
(
aTry
.
getHandlerOffset
());
}
List
<
Integer
>
handlerList
=
new
ArrayList
<
Integer
>(
catchBlocks
.
length
);
handlerList
.
addAll
(
handlerSet
);
...
...
@@ -268,17 +268,17 @@ public class MethodNode extends LineAttrNode implements ILoadable {
Set
<
Integer
>
addrs
=
new
HashSet
<
Integer
>();
List
<
TryCatchBlock
>
catches
=
new
ArrayList
<
TryCatchBlock
>(
catchBlocks
.
length
);
for
(
CatchHandler
catch_
:
catchBlocks
)
{
for
(
CatchHandler
handler
:
catchBlocks
)
{
TryCatchBlock
tcBlock
=
new
TryCatchBlock
();
catches
.
add
(
tcBlock
);
for
(
int
i
=
0
;
i
<
catch_
.
getAddresses
().
length
;
i
++)
{
int
addr
=
catch_
.
getAddresses
()[
i
];
ClassInfo
type
=
ClassInfo
.
fromDex
(
parentClass
.
dex
(),
catch_
.
getTypeIndexes
()[
i
]);
for
(
int
i
=
0
;
i
<
handler
.
getAddresses
().
length
;
i
++)
{
int
addr
=
handler
.
getAddresses
()[
i
];
ClassInfo
type
=
ClassInfo
.
fromDex
(
parentClass
.
dex
(),
handler
.
getTypeIndexes
()[
i
]);
tcBlock
.
addHandler
(
this
,
addr
,
type
);
addrs
.
add
(
addr
);
hc
++;
}
int
addr
=
catch_
.
getCatchAllAddress
();
int
addr
=
handler
.
getCatchAllAddress
();
if
(
addr
>=
0
)
{
tcBlock
.
addHandler
(
this
,
addr
,
null
);
addrs
.
add
(
addr
);
...
...
@@ -309,11 +309,11 @@ public class MethodNode extends LineAttrNode implements ILoadable {
}
// attach TRY_ENTER, TRY_LEAVE attributes to instructions
for
(
Try
try_
:
tries
)
{
int
catchNum
=
handlerList
.
indexOf
(
try_
.
getHandlerOffset
());
for
(
Try
aTry
:
tries
)
{
int
catchNum
=
handlerList
.
indexOf
(
aTry
.
getHandlerOffset
());
TryCatchBlock
block
=
catches
.
get
(
catchNum
);
int
offset
=
try_
.
getStartAddress
();
int
end
=
offset
+
try_
.
getInstructionCount
()
-
1
;
int
offset
=
aTry
.
getStartAddress
();
int
end
=
offset
+
aTry
.
getInstructionCount
()
-
1
;
insnByOffset
[
offset
].
getAttributes
().
add
(
AttributeFlag
.
TRY_ENTER
);
while
(
offset
<=
end
&&
offset
>=
0
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
View file @
e54b7645
...
...
@@ -15,7 +15,6 @@ import java.util.Map;
public
class
RootNode
{
private
final
Map
<
String
,
ClassNode
>
names
=
new
HashMap
<
String
,
ClassNode
>();
private
List
<
DexNode
>
dexNodes
;
private
ClspGraph
clsp
;
public
void
load
(
List
<
InputFile
>
dexFiles
)
throws
DecodeException
{
dexNodes
=
new
ArrayList
<
DexNode
>(
dexFiles
.
size
());
...
...
@@ -49,7 +48,7 @@ public class RootNode {
}
private
void
initClassPath
(
List
<
ClassNode
>
classes
)
throws
IOException
,
DecodeException
{
clsp
=
new
ClspGraph
();
ClspGraph
clsp
=
new
ClspGraph
();
clsp
.
load
();
clsp
.
addApp
(
classes
);
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/AnnotationsParser.java
View file @
e54b7645
...
...
@@ -26,26 +26,26 @@ public class AnnotationsParser {
Section
section
=
dex
.
openSection
(
offset
);
// TODO read as unsigned int
int
class
_annotations_off
=
section
.
readInt
();
int
fields
_size
=
section
.
readInt
();
int
annotated
_methods_size
=
section
.
readInt
();
int
annotated
_parameters_size
=
section
.
readInt
();
int
class
AnnotationsOffset
=
section
.
readInt
();
int
fields
Count
=
section
.
readInt
();
int
annotated
MethodsCount
=
section
.
readInt
();
int
annotated
ParametersCount
=
section
.
readInt
();
if
(
class
_annotations_off
!=
0
)
{
cls
.
getAttributes
().
add
(
readAnnotationSet
(
class
_annotations_off
));
if
(
class
AnnotationsOffset
!=
0
)
{
cls
.
getAttributes
().
add
(
readAnnotationSet
(
class
AnnotationsOffset
));
}
for
(
int
i
=
0
;
i
<
fields
_size
;
i
++)
{
for
(
int
i
=
0
;
i
<
fields
Count
;
i
++)
{
FieldNode
f
=
cls
.
searchFieldById
(
section
.
readInt
());
f
.
getAttributes
().
add
(
readAnnotationSet
(
section
.
readInt
()));
}
for
(
int
i
=
0
;
i
<
annotated
_methods_size
;
i
++)
{
for
(
int
i
=
0
;
i
<
annotated
MethodsCount
;
i
++)
{
MethodNode
m
=
cls
.
searchMethodById
(
section
.
readInt
());
m
.
getAttributes
().
add
(
readAnnotationSet
(
section
.
readInt
()));
}
for
(
int
i
=
0
;
i
<
annotated
_parameters_size
;
i
++)
{
for
(
int
i
=
0
;
i
<
annotated
ParametersCount
;
i
++)
{
MethodNode
mth
=
cls
.
searchMethodById
(
section
.
readInt
());
// read annotation ref list
Section
ss
=
dex
.
openSection
(
section
.
readInt
());
...
...
@@ -72,7 +72,7 @@ public class AnnotationsParser {
return
new
AnnotationsList
(
list
);
}
private
static
final
Annotation
.
Visibility
[]
visibilities
=
new
Annotation
.
Visibility
[]{
private
static
final
Annotation
.
Visibility
[]
VISIBILITIES
=
new
Annotation
.
Visibility
[]{
Annotation
.
Visibility
.
BUILD
,
Annotation
.
Visibility
.
RUNTIME
,
Annotation
.
Visibility
.
SYSTEM
...
...
@@ -82,7 +82,7 @@ public class AnnotationsParser {
EncValueParser
parser
=
new
EncValueParser
(
dex
,
s
);
Visibility
visibility
=
null
;
if
(
readVisibility
)
{
visibility
=
visibilities
[
s
.
readByte
()];
visibility
=
VISIBILITIES
[
s
.
readByte
()];
}
int
typeIndex
=
s
.
readUleb128
();
int
size
=
s
.
readUleb128
();
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java
View file @
e54b7645
...
...
@@ -51,11 +51,11 @@ public class DebugInfoParser {
int
addr
=
0
;
int
line
=
section
.
readUleb128
();
int
param
_size
=
section
.
readUleb128
();
// exclude 'this'
int
param
sCount
=
section
.
readUleb128
();
// exclude 'this'
List
<
RegisterArg
>
mthArgs
=
mth
.
getArguments
(
false
);
assert
param
_size
==
mthArgs
.
size
();
assert
param
sCount
==
mthArgs
.
size
();
for
(
int
i
=
0
;
i
<
param
_size
;
i
++)
{
for
(
int
i
=
0
;
i
<
param
sCount
;
i
++)
{
int
id
=
section
.
readUleb128
()
-
1
;
if
(
id
!=
DexNode
.
NO_INDEX
)
{
String
name
=
dex
.
getString
(
id
);
...
...
@@ -137,9 +137,9 @@ public class DebugInfoParser {
default
:
{
if
(
c
>=
DBG_FIRST_SPECIAL
)
{
int
adjusted
_o
pcode
=
c
-
DBG_FIRST_SPECIAL
;
line
+=
DBG_LINE_BASE
+
(
adjusted
_o
pcode
%
DBG_LINE_RANGE
);
int
addrInc
=
(
adjusted
_o
pcode
/
DBG_LINE_RANGE
);
int
adjusted
O
pcode
=
c
-
DBG_FIRST_SPECIAL
;
line
+=
DBG_LINE_BASE
+
(
adjusted
O
pcode
%
DBG_LINE_RANGE
);
int
addrInc
=
(
adjusted
O
pcode
/
DBG_LINE_RANGE
);
addr
=
addrChange
(
addr
,
addrInc
,
line
);
}
else
{
throw
new
DecodeException
(
"Unknown debug insn code: "
+
c
);
...
...
jadx-core/src/main/java/jadx/core/dex/regions/IfCondition.java
View file @
e54b7645
...
...
@@ -4,6 +4,7 @@ import jadx.core.dex.instructions.IfNode;
import
jadx.core.dex.instructions.IfOp
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -131,7 +132,7 @@ public final class IfCondition {
}
return
new
IfCondition
(
mode
==
Mode
.
AND
?
Mode
.
OR
:
Mode
.
AND
,
newArgs
);
}
throw
new
RuntimeException
(
"Unknown mode for invert: "
+
mode
);
throw
new
Jadx
RuntimeException
(
"Unknown mode for invert: "
+
mode
);
}
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
View file @
e54b7645
...
...
@@ -29,7 +29,7 @@ import java.util.Set;
public
class
BlockMakerVisitor
extends
AbstractVisitor
{
// leave these instructions alone in block node
private
static
final
Set
<
InsnType
>
separateInsns
=
EnumSet
.
of
(
private
static
final
Set
<
InsnType
>
SEPARATE_INSNS
=
EnumSet
.
of
(
InsnType
.
RETURN
,
InsnType
.
IF
,
InsnType
.
SWITCH
,
...
...
@@ -65,7 +65,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
if
(
type
==
InsnType
.
RETURN
||
type
==
InsnType
.
GOTO
||
type
==
InsnType
.
THROW
||
separateInsns
.
contains
(
type
))
{
||
SEPARATE_INSNS
.
contains
(
type
))
{
if
(
type
==
InsnType
.
RETURN
||
type
==
InsnType
.
THROW
)
mth
.
addExitBlock
(
curBlock
);
...
...
@@ -77,7 +77,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
startNew
=
true
;
}
else
{
type
=
insn
.
getType
();
startNew
=
separateInsns
.
contains
(
type
);
startNew
=
SEPARATE_INSNS
.
contains
(
type
);
List
<
IAttribute
>
pjumps
=
prevInsn
.
getAttributes
().
getAll
(
AttributeType
.
JUMP
);
if
(
pjumps
.
size
()
>
0
)
{
...
...
@@ -371,10 +371,11 @@ public class BlockMakerVisitor extends AbstractVisitor {
newRetBlock
=
startNewBlock
(
mth
,
block
.
getStartOffset
());
newRetBlock
.
getAttributes
().
add
(
AttributeFlag
.
SYNTHETIC
);
if
(
pred
.
getSuccessors
().
get
(
0
)
==
block
)
{
pred
.
getSuccessors
().
set
(
0
,
newRetBlock
);
}
else
if
(
pred
.
getSuccessors
().
get
(
1
)
==
block
){
pred
.
getSuccessors
().
set
(
1
,
newRetBlock
);
List
<
BlockNode
>
successors
=
pred
.
getSuccessors
();
if
(
successors
.
get
(
0
)
==
block
)
{
successors
.
set
(
0
,
newRetBlock
);
}
else
if
(
successors
.
get
(
1
)
==
block
){
successors
.
set
(
1
,
newRetBlock
);
}
block
.
getPredecessors
().
remove
(
pred
);
newRetBlock
.
getPredecessors
().
add
(
pred
);
...
...
@@ -427,5 +428,4 @@ public class BlockMakerVisitor extends AbstractVisitor {
block
.
getDominatesOn
().
clear
();
}
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IRegionVisitor.java
View file @
e54b7645
...
...
@@ -6,10 +6,10 @@ import jadx.core.dex.nodes.MethodNode;
public
interface
IRegionVisitor
{
public
void
processBlock
(
MethodNode
mth
,
IBlock
container
);
void
processBlock
(
MethodNode
mth
,
IBlock
container
);
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
);
void
enterRegion
(
MethodNode
mth
,
IRegion
region
);
public
void
leaveRegion
(
MethodNode
mth
,
IRegion
region
);
void
leaveRegion
(
MethodNode
mth
,
IRegion
region
);
}
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
View file @
e54b7645
...
...
@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
public
class
ErrorsCounter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ErrorsCounter
.
class
);
private
static
final
Set
<
Object
>
errorNodes
=
new
HashSet
<
Object
>();
private
static
final
Set
<
Object
>
ERROR_NODES
=
new
HashSet
<
Object
>();
private
static
int
errorsCount
=
0
;
public
static
int
getErrorCount
()
{
...
...
@@ -23,12 +23,12 @@ public class ErrorsCounter {
}
public
static
void
reset
()
{
errorNodes
.
clear
();
ERROR_NODES
.
clear
();
errorsCount
=
0
;
}
private
static
void
addError
(
IAttributeNode
node
,
String
msg
,
Throwable
e
)
{
errorNodes
.
add
(
node
);
ERROR_NODES
.
add
(
node
);
errorsCount
++;
if
(
e
!=
null
)
{
...
...
@@ -65,7 +65,7 @@ public class ErrorsCounter {
public
static
void
printReport
()
{
if
(
getErrorCount
()
>
0
)
{
LOG
.
error
(
getErrorCount
()
+
" errors occured in following nodes:"
);
for
(
Object
node
:
errorNodes
)
{
for
(
Object
node
:
ERROR_NODES
)
{
LOG
.
error
(
" "
+
node
.
getClass
().
getSimpleName
()
+
": "
+
node
);
}
// LOG.error("You can run jadx with '-f' option to view low level instructions");
...
...
jadx-core/src/main/java/jadx/core/utils/InsnUtils.java
View file @
e54b7645
package
jadx
.
core
.
utils
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
com.android.dx.io.instructions.DecodedInstruction
;
...
...
@@ -19,7 +20,7 @@ public class InsnUtils {
case
4
:
return
insn
.
getE
();
}
throw
new
RuntimeException
(
"Wrong argument number: "
+
arg
);
throw
new
Jadx
RuntimeException
(
"Wrong argument number: "
+
arg
);
}
public
static
String
formatOffset
(
int
offset
)
{
...
...
jadx-core/src/main/java/jadx/core/utils/files/JavaToDex.java
View file @
e54b7645
...
...
@@ -26,11 +26,10 @@ public class JavaToDex {
private
String
dxErrors
;
public
byte
[]
convert
(
String
javaFile
)
throws
JadxException
{
ByteArrayOutputStream
errOut
=
new
ByteArrayOutputStream
();
DxConsole
.
err
=
new
PrintStream
(
errOut
);
ByteArrayOutputStream
err_out
=
new
ByteArrayOutputStream
();
DxConsole
.
err
=
new
PrintStream
(
err_out
);
PrintStream
old_out
=
System
.
out
;
PrintStream
oldOut
=
System
.
out
;
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
{
System
.
setOut
(
new
PrintStream
(
baos
));
...
...
@@ -40,11 +39,10 @@ public class JavaToDex {
}
catch
(
Throwable
e
)
{
throw
new
JadxException
(
"dx exception: "
+
e
.
getMessage
(),
e
);
}
finally
{
System
.
setOut
(
old
_o
ut
);
System
.
setOut
(
old
O
ut
);
}
// err_out also contains warnings
dxErrors
=
err_out
.
toString
();
// errOut also contains warnings
dxErrors
=
errOut
.
toString
();
return
baos
.
toByteArray
();
}
...
...
jadx-gui/src/main/java/jadx/gui/utils/OverlayIcon.java
View file @
e54b7645
...
...
@@ -13,7 +13,7 @@ public class OverlayIcon implements Icon {
private
static
final
double
A
=
0.8
;
private
static
final
double
B
=
0.2
;
private
static
final
double
[]
pos
=
new
double
[]{
A
,
B
,
B
,
B
,
A
,
A
,
B
,
A
};
private
static
final
double
[]
OVERLAY_POS
=
new
double
[]{
A
,
B
,
B
,
B
,
A
,
A
,
B
,
A
};
public
OverlayIcon
(
Icon
icon
)
{
this
.
icon
=
icon
;
...
...
@@ -37,8 +37,8 @@ public class OverlayIcon implements Icon {
icon
.
paintIcon
(
c
,
g
,
x
,
y
);
int
k
=
0
;
for
(
Icon
icon
:
icons
)
{
int
dx
=
(
int
)
(
pos
[
k
++]
*
(
w
-
icon
.
getIconWidth
()));
int
dy
=
(
int
)
(
pos
[
k
++]
*
(
h
-
icon
.
getIconHeight
()));
int
dx
=
(
int
)
(
OVERLAY_POS
[
k
++]
*
(
w
-
icon
.
getIconWidth
()));
int
dy
=
(
int
)
(
OVERLAY_POS
[
k
++]
*
(
h
-
icon
.
getIconHeight
()));
icon
.
paintIcon
(
c
,
g
,
x
+
dx
,
y
+
dy
);
}
}
...
...
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