Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ql04210214
jadx
提交
e4dde3f4
J
jadx
项目概览
ql04210214
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e4dde3f4
编写于
6月 15, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix class cast exception
上级
9c90699c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
69 addition
and
22 deletion
+69
-22
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
+1
-1
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+1
-1
jadx-core/src/main/java/jadx/core/dex/instructions/args/FieldArg.java
...c/main/java/jadx/core/dex/instructions/args/FieldArg.java
+9
-9
jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java
...src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java
+2
-3
jadx-core/src/main/java/jadx/core/utils/InstructionRemover.java
...ore/src/main/java/jadx/core/utils/InstructionRemover.java
+15
-7
jadx-core/src/test/java/jadx/tests/internal/arith/TestFieldIncrement.java
...st/java/jadx/tests/internal/arith/TestFieldIncrement.java
+1
-1
jadx-core/src/test/java/jadx/tests/internal/arith/TestFieldIncrement2.java
...t/java/jadx/tests/internal/arith/TestFieldIncrement2.java
+40
-0
未找到文件。
jadx-core/src/main/java/jadx/api/JadxDecompiler.java
浏览文件 @
e4dde3f4
...
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
...
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
/**
/**
* Jadx API usage example:
* Jadx API usage example:
* <pre><code>
* <pre><code>
*
Decompiler jadx = new
Decompiler();
*
JadxDecompiler jadx = new Jadx
Decompiler();
* jadx.loadFile(new File("classes.dex"));
* jadx.loadFile(new File("classes.dex"));
* jadx.setOutputDir(new File("out"));
* jadx.setOutputDir(new File("out"));
* jadx.save();
* jadx.save();
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
e4dde3f4
...
@@ -101,7 +101,7 @@ public class InsnGen {
...
@@ -101,7 +101,7 @@ public class InsnGen {
if
(
f
.
isStatic
())
{
if
(
f
.
isStatic
())
{
staticField
(
code
,
f
.
getField
());
staticField
(
code
,
f
.
getField
());
}
else
{
}
else
{
instanceField
(
code
,
f
.
getField
(),
f
.
get
Register
Arg
());
instanceField
(
code
,
f
.
getField
(),
f
.
get
Instance
Arg
());
}
}
}
else
{
}
else
{
throw
new
CodegenException
(
"Unknown arg type "
+
arg
);
throw
new
CodegenException
(
"Unknown arg type "
+
arg
);
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/FieldArg.java
浏览文件 @
e4dde3f4
...
@@ -6,12 +6,12 @@ import jadx.core.dex.info.FieldInfo;
...
@@ -6,12 +6,12 @@ import jadx.core.dex.info.FieldInfo;
public
final
class
FieldArg
extends
RegisterArg
{
public
final
class
FieldArg
extends
RegisterArg
{
private
final
FieldInfo
field
;
private
final
FieldInfo
field
;
//
reg
Arg equal 'null' for static fields
//
inst
Arg equal 'null' for static fields
private
final
RegisterArg
reg
Arg
;
private
final
InsnArg
inst
Arg
;
public
FieldArg
(
FieldInfo
field
,
Register
Arg
reg
)
{
public
FieldArg
(
FieldInfo
field
,
Insn
Arg
reg
)
{
super
(-
1
);
super
(-
1
);
this
.
reg
Arg
=
reg
;
this
.
inst
Arg
=
reg
;
this
.
field
=
field
;
this
.
field
=
field
;
}
}
...
@@ -19,12 +19,12 @@ public final class FieldArg extends RegisterArg {
...
@@ -19,12 +19,12 @@ public final class FieldArg extends RegisterArg {
return
field
;
return
field
;
}
}
public
RegisterArg
getRegister
Arg
()
{
public
InsnArg
getInstance
Arg
()
{
return
reg
Arg
;
return
inst
Arg
;
}
}
public
boolean
isStatic
()
{
public
boolean
isStatic
()
{
return
reg
Arg
==
null
;
return
inst
Arg
==
null
;
}
}
@Override
@Override
...
@@ -54,7 +54,7 @@ public final class FieldArg extends RegisterArg {
...
@@ -54,7 +54,7 @@ public final class FieldArg extends RegisterArg {
if
(!
field
.
equals
(
fieldArg
.
field
))
{
if
(!
field
.
equals
(
fieldArg
.
field
))
{
return
false
;
return
false
;
}
}
if
(
regArg
!=
null
?
!
regArg
.
equals
(
fieldArg
.
regArg
)
:
fieldArg
.
reg
Arg
!=
null
)
{
if
(
instArg
!=
null
?
!
instArg
.
equals
(
fieldArg
.
instArg
)
:
fieldArg
.
inst
Arg
!=
null
)
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -64,7 +64,7 @@ public final class FieldArg extends RegisterArg {
...
@@ -64,7 +64,7 @@ public final class FieldArg extends RegisterArg {
public
int
hashCode
()
{
public
int
hashCode
()
{
int
result
=
super
.
hashCode
();
int
result
=
super
.
hashCode
();
result
=
31
*
result
+
field
.
hashCode
();
result
=
31
*
result
+
field
.
hashCode
();
result
=
31
*
result
+
(
regArg
!=
null
?
reg
Arg
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
instArg
!=
null
?
inst
Arg
.
hashCode
()
:
0
);
return
result
;
return
result
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java
浏览文件 @
e4dde3f4
...
@@ -14,7 +14,6 @@ import jadx.core.dex.instructions.args.FieldArg;
...
@@ -14,7 +14,6 @@ import jadx.core.dex.instructions.args.FieldArg;
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.LiteralArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
import
jadx.core.dex.instructions.mods.ConstructorInsn
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.InsnNode
;
...
@@ -186,9 +185,9 @@ public class SimplifyVisitor extends AbstractVisitor {
...
@@ -186,9 +185,9 @@ public class SimplifyVisitor extends AbstractVisitor {
return
null
;
return
null
;
}
}
try
{
try
{
Register
Arg
reg
=
null
;
Insn
Arg
reg
=
null
;
if
(
getType
==
InsnType
.
IGET
)
{
if
(
getType
==
InsnType
.
IGET
)
{
reg
=
((
RegisterArg
)
get
.
getArg
(
0
)
);
reg
=
get
.
getArg
(
0
);
}
}
FieldArg
fArg
=
new
FieldArg
(
field
,
reg
);
FieldArg
fArg
=
new
FieldArg
(
field
,
reg
);
if
(
reg
!=
null
)
{
if
(
reg
!=
null
)
{
...
...
jadx-core/src/main/java/jadx/core/utils/InstructionRemover.java
浏览文件 @
e4dde3f4
...
@@ -3,6 +3,7 @@ package jadx.core.utils;
...
@@ -3,6 +3,7 @@ package jadx.core.utils;
import
jadx.core.Consts
;
import
jadx.core.Consts
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.AFlag
;
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.RegisterArg
;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.instructions.args.SSAVar
;
import
jadx.core.dex.instructions.args.SSAVar
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.BlockNode
;
...
@@ -65,17 +66,24 @@ public class InstructionRemover {
...
@@ -65,17 +66,24 @@ public class InstructionRemover {
mth
.
removeSVar
(
r
.
getSVar
());
mth
.
removeSVar
(
r
.
getSVar
());
}
}
for
(
InsnArg
arg
:
insn
.
getArguments
())
{
for
(
InsnArg
arg
:
insn
.
getArguments
())
{
if
(
arg
instanceof
RegisterArg
)
{
unbindArgUsage
(
mth
,
arg
);
RegisterArg
reg
=
(
RegisterArg
)
arg
;
SSAVar
sVar
=
reg
.
getSVar
();
if
(
sVar
!=
null
)
{
sVar
.
removeUse
(
reg
);
}
}
}
}
insn
.
add
(
AFlag
.
INCONSISTENT_CODE
);
insn
.
add
(
AFlag
.
INCONSISTENT_CODE
);
}
}
public
static
void
unbindArgUsage
(
MethodNode
mth
,
InsnArg
arg
)
{
if
(
arg
instanceof
RegisterArg
)
{
RegisterArg
reg
=
(
RegisterArg
)
arg
;
SSAVar
sVar
=
reg
.
getSVar
();
if
(
sVar
!=
null
)
{
sVar
.
removeUse
(
reg
);
}
}
else
if
(
arg
instanceof
InsnWrapArg
)
{
InsnWrapArg
wrap
=
(
InsnWrapArg
)
arg
;
unbindInsn
(
mth
,
wrap
.
getWrapInsn
());
}
}
// Don't use 'insns.removeAll(toRemove)' because it will remove instructions by content
// Don't use 'insns.removeAll(toRemove)' because it will remove instructions by content
// and here can be several instructions with same content
// and here can be several instructions with same content
private
void
removeAll
(
List
<
InsnNode
>
insns
,
List
<
InsnNode
>
toRemove
)
{
private
void
removeAll
(
List
<
InsnNode
>
insns
,
List
<
InsnNode
>
toRemove
)
{
...
...
jadx-core/src/test/java/jadx/tests/internal/TestFieldIncrement.java
→
jadx-core/src/test/java/jadx/tests/internal/
arith/
TestFieldIncrement.java
浏览文件 @
e4dde3f4
package
jadx.tests.internal
;
package
jadx.tests.internal
.arith
;
import
jadx.api.InternalJadxTest
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.ClassNode
;
...
...
jadx-core/src/test/java/jadx/tests/internal/arith/TestFieldIncrement2.java
0 → 100644
浏览文件 @
e4dde3f4
package
jadx.tests.internal.arith
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestFieldIncrement2
extends
InternalJadxTest
{
class
A
{
int
f
=
5
;
}
public
static
class
TestCls
{
public
A
a
;
public
void
test1
(
int
n
)
{
this
.
a
.
f
=
this
.
a
.
f
+
n
;
}
public
void
test2
(
int
n
)
{
this
.
a
.
f
*=
n
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsString
(
"this.a.f += n;"
));
assertThat
(
code
,
containsString
(
"a.f *= n;"
));
// TODO
// assertThat(code, containsString("this.a.f *= n;"));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录