Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76393173
jadx
提交
4fb6ada5
J
jadx
项目概览
2301_76393173
/
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,发现更多精彩内容 >>
提交
4fb6ada5
编写于
9月 26, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix type inference for phi nodes
上级
ab924faa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
149 addition
and
16 deletion
+149
-16
jadx-core/src/main/java/jadx/core/dex/visitors/ssa/EliminatePhiNodes.java
...in/java/jadx/core/dex/visitors/ssa/EliminatePhiNodes.java
+18
-6
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/PostTypeInference.java
...dx/core/dex/visitors/typeinference/PostTypeInference.java
+16
-0
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInference.java
...a/jadx/core/dex/visitors/typeinference/TypeInference.java
+6
-10
jadx-core/src/test/java/jadx/tests/smali/TestN21.java
jadx-core/src/test/java/jadx/tests/smali/TestN21.java
+16
-0
jadx-core/src/test/smali/TestN21.smali
jadx-core/src/test/smali/TestN21.smali
+93
-0
未找到文件。
jadx-core/src/main/java/jadx/core/dex/visitors/ssa/EliminatePhiNodes.java
浏览文件 @
4fb6ada5
...
...
@@ -12,7 +12,12 @@ import jadx.core.utils.exceptions.JadxException;
import
java.util.Iterator
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
EliminatePhiNodes
extends
AbstractVisitor
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EliminatePhiNodes
.
class
);
@Override
public
void
visit
(
MethodNode
mth
)
throws
JadxException
{
if
(
mth
.
isNoCode
())
{
...
...
@@ -29,13 +34,20 @@ public class EliminatePhiNodes extends AbstractVisitor {
}
List
<
PhiInsn
>
list
=
phiList
.
getList
();
for
(
PhiInsn
phiInsn
:
list
)
{
for
(
Iterator
<
InsnNode
>
iterator
=
block
.
getInstructions
().
iterator
();
iterator
.
hasNext
();
)
{
InsnNode
insn
=
iterator
.
next
();
if
(
insn
==
phiInsn
)
{
iterator
.
remove
();
}
}
removeInsn
(
mth
,
block
,
phiInsn
);
}
}
}
private
static
void
removeInsn
(
MethodNode
mth
,
BlockNode
block
,
PhiInsn
phiInsn
)
{
Iterator
<
InsnNode
>
it
=
block
.
getInstructions
().
iterator
();
while
(
it
.
hasNext
())
{
InsnNode
insn
=
it
.
next
();
if
(
insn
==
phiInsn
)
{
it
.
remove
();
return
;
}
}
LOG
.
warn
(
"Phi node not removed: {}, mth: {}"
,
phiInsn
,
mth
);
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/PostTypeInference.java
浏览文件 @
4fb6ada5
...
...
@@ -3,6 +3,7 @@ package jadx.core.dex.visitors.typeinference;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.IndexInsnNode
;
import
jadx.core.dex.instructions.InvokeNode
;
import
jadx.core.dex.instructions.PhiInsn
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
import
jadx.core.dex.instructions.args.LiteralArg
;
...
...
@@ -94,6 +95,21 @@ public class PostTypeInference {
return
true
;
}
case
PHI:
{
PhiInsn
phi
=
(
PhiInsn
)
insn
;
SSAVar
resultSVar
=
phi
.
getResult
().
getSVar
();
if
(
resultSVar
!=
null
&&
!
resultSVar
.
getType
().
isTypeKnown
())
{
for
(
InsnArg
arg
:
phi
.
getArguments
())
{
ArgType
argType
=
arg
.
getType
();
if
(
argType
.
isTypeKnown
())
{
resultSVar
.
setType
(
argType
);
return
true
;
}
}
}
return
false
;
}
default
:
break
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInference.java
浏览文件 @
4fb6ada5
package
jadx.core.dex.visitors.typeinference
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.instructions.PhiInsn
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.InsnArg
;
...
...
@@ -9,7 +8,6 @@ import jadx.core.dex.instructions.args.SSAVar;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.List
;
...
...
@@ -43,7 +41,7 @@ public class TypeInference extends AbstractVisitor {
}
}
private
ArgType
processType
(
SSAVar
var
)
{
private
static
ArgType
processType
(
SSAVar
var
)
{
RegisterArg
assign
=
var
.
getAssign
();
List
<
RegisterArg
>
useList
=
var
.
getUseList
();
if
(
assign
!=
null
...
...
@@ -58,17 +56,15 @@ public class TypeInference extends AbstractVisitor {
}
for
(
RegisterArg
arg
:
useList
)
{
ArgType
useType
=
arg
.
getType
();
if
(
useType
.
isTypeKnown
())
{
type
=
ArgType
.
merge
(
type
,
useType
);
}
if
(
arg
.
getParentInsn
().
contains
(
AFlag
.
INCONSISTENT_CODE
))
{
throw
new
JadxRuntimeException
(
"not removed arg"
);
ArgType
newType
=
ArgType
.
merge
(
type
,
useType
);
if
(
newType
!=
null
)
{
type
=
newType
;
}
}
return
type
;
}
private
void
processPhiNode
(
PhiInsn
phi
)
{
private
static
void
processPhiNode
(
PhiInsn
phi
)
{
ArgType
type
=
phi
.
getResult
().
getType
();
if
(!
type
.
isTypeKnown
())
{
for
(
InsnArg
arg
:
phi
.
getArguments
())
{
...
...
@@ -86,7 +82,7 @@ public class TypeInference extends AbstractVisitor {
}
}
private
String
processVarName
(
SSAVar
var
)
{
private
static
String
processVarName
(
SSAVar
var
)
{
String
name
=
null
;
if
(
var
.
getAssign
()
!=
null
)
{
name
=
var
.
getAssign
().
getName
();
...
...
jadx-core/src/test/java/jadx/tests/smali/TestN21.java
0 → 100644
浏览文件 @
4fb6ada5
package
jadx.tests.smali
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.SmaliTest
;
import
org.junit.Test
;
public
class
TestN21
extends
SmaliTest
{
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNodeFromSmali
(
"TestN21"
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
}
}
jadx-core/src/test/smali/TestN21.smali
0 → 100644
浏览文件 @
4fb6ada5
.class public LTestN21;
.super Ljava/lang/Object;
.method private static test([BI)I
.locals 5
const/4 v1, 0x0
const/16 v0, 0xe
aget-byte v0, p0, v0
shl-int/lit8 v0, v0, 0x10
move v2, v1
:goto_0
if-nez v2, :cond_1
const/4 v2, 0x3
and-int/lit16 v3, p1, 0xff
:try_start_0
aget-byte v3, p0, v3
and-int/lit16 v3, v3, 0xff
shr-int/lit8 v4, p1, 0x8
and-int/lit16 v4, v4, 0xff
aget-byte v4, p0, v4
and-int/lit16 v4, v4, 0xff
shl-int/lit8 v4, v4, 0x8
or-int/2addr v3, v4
shr-int/lit8 v4, p1, 0x10
and-int/lit16 v4, v4, 0xff
aget-byte v4, p0, v4
and-int/lit16 v4, v4, 0xff
shl-int/lit8 v4, v4, 0x10
or-int/2addr v3, v4
shr-int/lit8 v4, p1, 0x18
and-int/lit16 v4, v4, 0xff
aget-byte v0, p0, v4
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1
shl-int/lit8 v0, v0, 0x18
or-int/2addr v0, v3
:cond_0
:goto_1
return v0
:catch_0
move-exception v2
:cond_1
if-nez v1, :cond_0
const/4 v1, 0x2
and-int/lit8 v2, p1, 0x7f
:try_start_1
aget-byte v0, p0, v2
:try_end_1
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
shr-int/lit8 v0, v0, 0x8
goto :goto_1
:catch_1
move-exception v3
goto :goto_0
.end method
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录