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
69494c92
Commit
69494c92
authored
Jun 27, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add method for copy instruction nodes
parent
b2f0f025
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
0 deletions
+70
-0
build.gradle
jadx-core/build.gradle
+1
-0
LineAttrNode.java
...ain/java/jadx/core/dex/attributes/nodes/LineAttrNode.java
+5
-0
ConstClassNode.java
.../main/java/jadx/core/dex/instructions/ConstClassNode.java
+5
-0
ConstStringNode.java
...main/java/jadx/core/dex/instructions/ConstStringNode.java
+5
-0
IndexInsnNode.java
...c/main/java/jadx/core/dex/instructions/IndexInsnNode.java
+5
-0
InvokeNode.java
.../src/main/java/jadx/core/dex/instructions/InvokeNode.java
+11
-0
InsnNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
+38
-0
No files found.
jadx-core/build.gradle
View file @
69494c92
...
@@ -9,6 +9,7 @@ dependencies {
...
@@ -9,6 +9,7 @@ dependencies {
compile
'commons-io:commons-io:2.4'
compile
'commons-io:commons-io:2.4'
compile
'org.ow2.asm:asm:5.0.3'
compile
'org.ow2.asm:asm:5.0.3'
compile
'com.intellij:annotations:12.0'
compile
'com.intellij:annotations:12.0'
compile
'uk.com.robust-it:cloning:1.9.2'
testCompile
'org.smali:smali:2.0.3'
testCompile
'org.smali:smali:2.0.3'
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/attributes/nodes/LineAttrNode.java
View file @
69494c92
...
@@ -23,4 +23,9 @@ public abstract class LineAttrNode extends AttrNode {
...
@@ -23,4 +23,9 @@ public abstract class LineAttrNode extends AttrNode {
public
void
setDecompiledLine
(
int
decompiledLine
)
{
public
void
setDecompiledLine
(
int
decompiledLine
)
{
this
.
decompiledLine
=
decompiledLine
;
this
.
decompiledLine
=
decompiledLine
;
}
}
public
void
copyLines
(
LineAttrNode
lineAttrNode
)
{
setSourceLine
(
lineAttrNode
.
getSourceLine
());
setDecompiledLine
(
lineAttrNode
.
getDecompiledLine
());
}
}
}
jadx-core/src/main/java/jadx/core/dex/instructions/ConstClassNode.java
View file @
69494c92
...
@@ -17,6 +17,11 @@ public final class ConstClassNode extends InsnNode {
...
@@ -17,6 +17,11 @@ public final class ConstClassNode extends InsnNode {
}
}
@Override
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
ConstClassNode
(
clsType
));
}
@Override
public
boolean
isSame
(
InsnNode
obj
)
{
public
boolean
isSame
(
InsnNode
obj
)
{
if
(
this
==
obj
)
{
if
(
this
==
obj
)
{
return
true
;
return
true
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/ConstStringNode.java
View file @
69494c92
...
@@ -16,6 +16,11 @@ public final class ConstStringNode extends InsnNode {
...
@@ -16,6 +16,11 @@ public final class ConstStringNode extends InsnNode {
}
}
@Override
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
ConstStringNode
(
str
));
}
@Override
public
boolean
isSame
(
InsnNode
obj
)
{
public
boolean
isSame
(
InsnNode
obj
)
{
if
(
this
==
obj
)
{
if
(
this
==
obj
)
{
return
true
;
return
true
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/IndexInsnNode.java
View file @
69494c92
...
@@ -17,6 +17,11 @@ public class IndexInsnNode extends InsnNode {
...
@@ -17,6 +17,11 @@ public class IndexInsnNode extends InsnNode {
}
}
@Override
@Override
public
IndexInsnNode
copy
()
{
return
copyCommonParams
(
new
IndexInsnNode
(
insnType
,
index
,
getArgsCount
()));
}
@Override
public
boolean
isSame
(
InsnNode
obj
)
{
public
boolean
isSame
(
InsnNode
obj
)
{
if
(
this
==
obj
)
{
if
(
this
==
obj
)
{
return
true
;
return
true
;
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/InvokeNode.java
View file @
69494c92
...
@@ -36,6 +36,12 @@ public class InvokeNode extends InsnNode {
...
@@ -36,6 +36,12 @@ public class InvokeNode extends InsnNode {
}
}
}
}
private
InvokeNode
(
MethodInfo
mth
,
InvokeType
invokeType
,
int
argsCount
)
{
super
(
InsnType
.
INVOKE
,
argsCount
);
this
.
mth
=
mth
;
this
.
type
=
invokeType
;
}
public
InvokeType
getInvokeType
()
{
public
InvokeType
getInvokeType
()
{
return
type
;
return
type
;
}
}
...
@@ -45,6 +51,11 @@ public class InvokeNode extends InsnNode {
...
@@ -45,6 +51,11 @@ public class InvokeNode extends InsnNode {
}
}
@Override
@Override
public
InsnNode
copy
()
{
return
copyCommonParams
(
new
InvokeNode
(
mth
,
type
,
getArgsCount
()));
}
@Override
public
boolean
isSame
(
InsnNode
obj
)
{
public
boolean
isSame
(
InsnNode
obj
)
{
if
(
this
==
obj
)
{
if
(
this
==
obj
)
{
return
true
;
return
true
;
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
View file @
69494c92
...
@@ -5,7 +5,10 @@ import jadx.core.dex.instructions.InsnType;
...
@@ -5,7 +5,10 @@ import jadx.core.dex.instructions.InsnType;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.InsnWrapArg
;
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.RegisterArg
;
import
jadx.core.dex.instructions.args.SSAVar
;
import
jadx.core.utils.InsnUtils
;
import
jadx.core.utils.InsnUtils
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.Utils
;
...
@@ -14,9 +17,17 @@ import java.util.Collections;
...
@@ -14,9 +17,17 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.List
;
import
com.android.dx.io.instructions.DecodedInstruction
;
import
com.android.dx.io.instructions.DecodedInstruction
;
import
com.rits.cloning.Cloner
;
public
class
InsnNode
extends
LineAttrNode
{
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
;
protected
final
InsnType
insnType
;
private
RegisterArg
result
;
private
RegisterArg
result
;
...
@@ -228,4 +239,31 @@ public class InsnNode extends LineAttrNode {
...
@@ -228,4 +239,31 @@ public class InsnNode extends LineAttrNode {
&&
arguments
.
size
()
==
other
.
arguments
.
size
();
&&
arguments
.
size
()
==
other
.
arguments
.
size
();
}
}
protected
<
T
extends
InsnNode
>
T
copyCommonParams
(
T
copy
)
{
copy
.
setResult
(
result
);
if
(
copy
.
getArgsCount
()
==
0
)
{
for
(
InsnArg
arg
:
this
.
getArguments
())
{
if
(
arg
.
isInsnWrap
())
{
InsnNode
wrapInsn
=
((
InsnWrapArg
)
arg
).
getWrapInsn
();
copy
.
addArg
(
InsnArg
.
wrapArg
(
wrapInsn
.
copy
()));
}
else
{
copy
.
addArg
(
arg
);
}
}
}
copy
.
copyAttributesFrom
(
this
);
copy
.
copyLines
(
this
);
copy
.
setOffset
(
this
.
getOffset
());
return
copy
;
}
/**
* Make copy of InsnNode object.
*/
public
InsnNode
copy
()
{
if
(
this
.
getClass
()
==
InsnNode
.
class
)
{
return
copyCommonParams
(
new
InsnNode
(
insnType
,
getArgsCount
()));
}
return
INSN_CLONER
.
deepClone
(
this
);
}
}
}
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