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
7f4da306
Commit
7f4da306
authored
Jul 05, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove cloning library dependency
parent
424a8ffa
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
100 additions
and
30 deletions
+100
-30
build.gradle
jadx-core/build.gradle
+0
-1
ArithNode.java
...e/src/main/java/jadx/core/dex/instructions/ArithNode.java
+5
-0
FillArrayNode.java
...c/main/java/jadx/core/dex/instructions/FillArrayNode.java
+13
-6
FilledNewArrayNode.java
...n/java/jadx/core/dex/instructions/FilledNewArrayNode.java
+5
-0
GotoNode.java
...re/src/main/java/jadx/core/dex/instructions/GotoNode.java
+6
-0
IfNode.java
...core/src/main/java/jadx/core/dex/instructions/IfNode.java
+14
-2
NewArrayNode.java
...rc/main/java/jadx/core/dex/instructions/NewArrayNode.java
+11
-2
PhiInsn.java
...ore/src/main/java/jadx/core/dex/instructions/PhiInsn.java
+11
-2
SwitchNode.java
.../src/main/java/jadx/core/dex/instructions/SwitchNode.java
+13
-1
ConstructorInsn.java
...java/jadx/core/dex/instructions/mods/ConstructorInsn.java
+5
-0
TernaryInsn.java
...ain/java/jadx/core/dex/instructions/mods/TernaryInsn.java
+12
-1
InsnNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
+5
-15
No files found.
jadx-core/build.gradle
View file @
7f4da306
...
...
@@ -7,7 +7,6 @@ dependencies {
compile
'org.ow2.asm:asm:7.1'
compile
'org.jetbrains:annotations:17.0.0'
compile
'uk.com.robust-it:cloning:1.9.12'
compile
'com.google.code.gson:gson:2.8.5'
compile
'org.smali:baksmali:2.2.7'
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/ArithNode.java
View file @
7f4da306
...
...
@@ -72,6 +72,11 @@ public class ArithNode extends InsnNode {
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
ArithNode
(
op
,
getResult
(),
getArg
(
0
),
getArg
(
1
)));
}
@Override
public
String
toString
()
{
return
InsnUtils
.
formatOffset
(
offset
)
+
": "
+
InsnUtils
.
insnTypeToString
(
insnType
)
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/FillArrayNode.java
View file @
7f4da306
...
...
@@ -25,13 +25,15 @@ public final class FillArrayNode extends InsnNode {
private
ArgType
elemType
;
public
FillArrayNode
(
int
resReg
,
FillArrayDataPayloadDecodedInstruction
payload
)
{
super
(
InsnType
.
FILL_ARRAY
,
1
);
ArgType
elType
=
getElementType
(
payload
.
getElementWidthUnit
(
));
addArg
(
InsnArg
.
reg
(
resReg
,
ArgType
.
array
(
elType
)));
this
(
payload
.
getData
(),
payload
.
getSize
(),
getElementType
(
payload
.
getElementWidthUnit
())
);
addArg
(
InsnArg
.
reg
(
resReg
,
ArgType
.
array
(
elemType
)
));
}
this
.
data
=
payload
.
getData
();
this
.
size
=
payload
.
getSize
();
this
.
elemType
=
elType
;
private
FillArrayNode
(
Object
data
,
int
size
,
ArgType
elemType
)
{
super
(
InsnType
.
FILL_ARRAY
,
1
);
this
.
data
=
data
;
this
.
size
=
size
;
this
.
elemType
=
elemType
;
}
private
static
ArgType
getElementType
(
short
elementWidthUnit
)
{
...
...
@@ -98,6 +100,11 @@ public final class FillArrayNode extends InsnNode {
return
elemType
.
equals
(
other
.
elemType
)
&&
data
==
other
.
data
;
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
FillArrayNode
(
data
,
size
,
elemType
));
}
public
String
dataToString
()
{
if
(
data
instanceof
int
[])
{
return
Arrays
.
toString
((
int
[])
data
);
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/FilledNewArrayNode.java
View file @
7f4da306
...
...
@@ -35,6 +35,11 @@ public class FilledNewArrayNode extends InsnNode {
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
FilledNewArrayNode
(
elemType
,
getArgsCount
()));
}
@Override
public
String
toString
()
{
return
super
.
toString
()
+
" elemType: "
+
elemType
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/GotoNode.java
View file @
7f4da306
package
jadx
.
core
.
dex
.
instructions
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.utils.InsnUtils
;
public
class
GotoNode
extends
TargetInsnNode
{
...
...
@@ -20,6 +21,11 @@ public class GotoNode extends TargetInsnNode {
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
GotoNode
(
target
));
}
@Override
public
String
toString
()
{
return
super
.
toString
()
+
"-> "
+
InsnUtils
.
formatOffset
(
target
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/IfNode.java
View file @
7f4da306
...
...
@@ -34,12 +34,16 @@ public class IfNode extends GotoNode {
}
public
IfNode
(
IfOp
op
,
int
targetOffset
,
InsnArg
arg1
,
InsnArg
arg2
)
{
super
(
InsnType
.
IF
,
targetOffset
,
2
);
this
.
op
=
op
;
this
(
op
,
targetOffset
);
addArg
(
arg1
);
addArg
(
arg2
);
}
private
IfNode
(
IfOp
op
,
int
targetOffset
)
{
super
(
InsnType
.
IF
,
targetOffset
,
2
);
this
.
op
=
op
;
}
// change default types priority
private
static
final
ArgType
WIDE_TYPE
=
ArgType
.
unknown
(
PrimitiveType
.
INT
,
PrimitiveType
.
BOOLEAN
,
...
...
@@ -124,6 +128,14 @@ public class IfNode extends GotoNode {
}
@Override
public
InsnNode
copy
()
{
IfNode
copy
=
new
IfNode
(
op
,
target
);
copy
.
thenBlock
=
thenBlock
;
copy
.
elseBlock
=
elseBlock
;
return
copyCommonParams
(
copy
);
}
@Override
public
String
toString
()
{
return
InsnUtils
.
formatOffset
(
offset
)
+
": "
+
InsnUtils
.
insnTypeToString
(
insnType
)
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/NewArrayNode.java
View file @
7f4da306
...
...
@@ -12,12 +12,16 @@ public class NewArrayNode extends InsnNode {
private
final
ArgType
arrType
;
public
NewArrayNode
(
@NotNull
ArgType
arrType
,
RegisterArg
res
,
InsnArg
size
)
{
super
(
InsnType
.
NEW_ARRAY
,
1
);
this
.
arrType
=
arrType
;
this
(
arrType
);
setResult
(
res
);
addArg
(
size
);
}
private
NewArrayNode
(
ArgType
arrType
)
{
super
(
InsnType
.
NEW_ARRAY
,
1
);
this
.
arrType
=
arrType
;
}
public
ArgType
getArrayType
()
{
return
arrType
;
}
...
...
@@ -35,6 +39,11 @@ public class NewArrayNode extends InsnNode {
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
NewArrayNode
(
arrType
));
}
@Override
public
String
toString
()
{
return
super
.
toString
()
+
" type: "
+
arrType
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/PhiInsn.java
View file @
7f4da306
...
...
@@ -21,13 +21,17 @@ public final class PhiInsn extends InsnNode {
private
final
List
<
BlockNode
>
blockBinds
;
public
PhiInsn
(
int
regNum
,
int
predecessors
)
{
super
(
InsnType
.
PHI
,
predecessors
);
this
.
blockBinds
=
new
ArrayList
<>(
predecessors
);
this
(
predecessors
);
setResult
(
InsnArg
.
reg
(
regNum
,
ArgType
.
UNKNOWN
));
add
(
AFlag
.
DONT_INLINE
);
add
(
AFlag
.
DONT_GENERATE
);
}
private
PhiInsn
(
int
argsCount
)
{
super
(
InsnType
.
PHI
,
argsCount
);
this
.
blockBinds
=
new
ArrayList
<>(
argsCount
);
}
public
RegisterArg
bindArg
(
BlockNode
pred
)
{
RegisterArg
arg
=
InsnArg
.
reg
(
getResult
().
getRegNum
(),
getResult
().
getInitType
());
bindArg
(
arg
,
pred
);
...
...
@@ -112,6 +116,11 @@ public final class PhiInsn extends InsnNode {
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
PhiInsn
(
getArgsCount
()));
}
@Override
public
String
toString
()
{
return
"PHI: "
+
getResult
()
+
" = "
+
Utils
.
listToString
(
getArguments
())
+
" binds: "
+
blockBinds
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/SwitchNode.java
View file @
7f4da306
...
...
@@ -20,11 +20,15 @@ public class SwitchNode extends TargetInsnNode {
private
BlockNode
defTargetBlock
;
public
SwitchNode
(
InsnArg
arg
,
Object
[]
keys
,
int
[]
targets
,
int
def
)
{
this
(
keys
,
targets
,
def
);
addArg
(
arg
);
}
private
SwitchNode
(
Object
[]
keys
,
int
[]
targets
,
int
def
)
{
super
(
InsnType
.
SWITCH
,
1
);
this
.
keys
=
keys
;
this
.
targets
=
targets
;
this
.
def
=
def
;
addArg
(
arg
);
}
public
int
getCasesCount
()
{
...
...
@@ -97,6 +101,14 @@ public class SwitchNode extends TargetInsnNode {
}
@Override
public
InsnNode
copy
()
{
SwitchNode
copy
=
new
SwitchNode
(
keys
,
targets
,
def
);
copy
.
targetBlocks
=
targetBlocks
;
copy
.
defTargetBlock
=
defTargetBlock
;
return
copyCommonParams
(
copy
);
}
@Override
public
String
toString
()
{
StringBuilder
targ
=
new
StringBuilder
();
targ
.
append
(
'['
);
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/mods/ConstructorInsn.java
View file @
7f4da306
...
...
@@ -105,6 +105,11 @@ public class ConstructorInsn extends InsnNode implements CallMthInterface {
}
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
ConstructorInsn
(
callMth
,
callType
,
instanceArg
));
}
@Override
public
String
toString
()
{
return
super
.
toString
()
+
' '
+
callMth
+
' '
+
callType
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/mods/TernaryInsn.java
View file @
7f4da306
...
...
@@ -16,7 +16,7 @@ public final class TernaryInsn extends InsnNode {
private
IfCondition
condition
;
public
TernaryInsn
(
IfCondition
condition
,
RegisterArg
result
,
InsnArg
th
,
InsnArg
els
)
{
super
(
InsnType
.
TERNARY
,
2
);
this
(
);
setResult
(
result
);
if
(
th
.
equals
(
LiteralArg
.
FALSE
)
&&
els
.
equals
(
LiteralArg
.
TRUE
))
{
...
...
@@ -31,6 +31,10 @@ public final class TernaryInsn extends InsnNode {
}
}
private
TernaryInsn
()
{
super
(
InsnType
.
TERNARY
,
2
);
}
public
IfCondition
getCondition
()
{
return
condition
;
}
...
...
@@ -68,6 +72,13 @@ public final class TernaryInsn extends InsnNode {
}
@Override
public
InsnNode
copy
()
{
TernaryInsn
copy
=
new
TernaryInsn
();
copy
.
condition
=
condition
;
return
copyCommonParams
(
copy
);
}
@Override
public
String
toString
()
{
return
InsnUtils
.
formatOffset
(
offset
)
+
": TERNARY"
+
getResult
()
+
" = "
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
View file @
7f4da306
...
...
@@ -9,7 +9,6 @@ import java.util.Objects;
import
org.jetbrains.annotations.Nullable
;
import
com.android.dx.io.instructions.DecodedInstruction
;
import
com.rits.cloning.Cloner
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.nodes.LineAttrNode
;
...
...
@@ -17,23 +16,14 @@ import jadx.core.dex.instructions.InsnType;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
import
jadx.core.dex.instructions.args.LiteralArg
;
import
jadx.core.dex.instructions.args.NamedArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.SSAVar
;
import
jadx.core.utils.InsnRemover
;
import
jadx.core.utils.InsnUtils
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
public
class
InsnNode
extends
LineAttrNode
{
private
static
final
Cloner
INSN_CLONER
=
new
Cloner
();
static
{
INSN_CLONER
.
dontClone
(
ArgType
.
class
,
SSAVar
.
class
,
LiteralArg
.
class
,
NamedArg
.
class
);
INSN_CLONER
.
dontCloneInstanceOf
(
RegisterArg
.
class
);
}
protected
final
InsnType
insnType
;
private
RegisterArg
result
;
...
...
@@ -324,7 +314,7 @@ public class InsnNode extends LineAttrNode {
&&
Objects
.
equals
(
arguments
,
other
.
arguments
);
}
protected
<
T
extends
InsnNode
>
T
copyCommonParams
(
T
copy
)
{
protected
final
<
T
extends
InsnNode
>
T
copyCommonParams
(
T
copy
)
{
copy
.
setResult
(
result
);
if
(
copy
.
getArgsCount
()
==
0
)
{
for
(
InsnArg
arg
:
this
.
getArguments
())
{
...
...
@@ -346,10 +336,10 @@ public class InsnNode extends LineAttrNode {
* Make copy of InsnNode object.
*/
public
InsnNode
copy
()
{
if
(
this
.
getClass
()
=
=
InsnNode
.
class
)
{
return
copyCommonParams
(
new
InsnNode
(
insnType
,
getArgsCount
()
));
if
(
this
.
getClass
()
!
=
InsnNode
.
class
)
{
throw
new
JadxRuntimeException
(
"Copy method not implemented in insn class "
+
this
.
getClass
().
getSimpleName
(
));
}
return
INSN_CLONER
.
deepClone
(
this
);
return
copyCommonParams
(
new
InsnNode
(
insnType
,
getArgsCount
())
);
}
public
boolean
canThrowException
()
{
...
...
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