Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
5502d93c
J
jadx
项目概览
Quincy379
/
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,体验更适合开发者的 AI 搜索 >>
提交
5502d93c
编写于
2月 04, 2020
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: additional checks before insert move to help type inference (#843)
上级
073fd76a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
33 deletion
+52
-33
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+4
-4
jadx-core/src/main/java/jadx/core/dex/visitors/debuginfo/DebugInfoApplyVisitor.java
...dx/core/dex/visitors/debuginfo/DebugInfoApplyVisitor.java
+1
-1
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java
...core/dex/visitors/typeinference/TypeInferenceVisitor.java
+47
-28
未找到文件。
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
浏览文件 @
5502d93c
...
...
@@ -208,7 +208,7 @@ public class MethodNode extends LineAttrNode implements ILoadable, ICodeNode {
}
return
argsTypes
;
}
catch
(
Exception
e
)
{
addWarn
ing
Comment
(
"Failed to parse method signature: "
+
sp
.
getSignature
(),
e
);
addWarnComment
(
"Failed to parse method signature: "
+
sp
.
getSignature
(),
e
);
return
null
;
}
}
...
...
@@ -698,11 +698,11 @@ public class MethodNode extends LineAttrNode implements ILoadable, ICodeNode {
ErrorsCounter
.
methodWarn
(
this
,
warnStr
);
}
public
void
addWarn
ing
Comment
(
String
warn
)
{
addWarn
ing
Comment
(
warn
,
null
);
public
void
addWarnComment
(
String
warn
)
{
addWarnComment
(
warn
,
null
);
}
public
void
addWarn
ing
Comment
(
String
warn
,
@Nullable
Throwable
exc
)
{
public
void
addWarnComment
(
String
warn
,
@Nullable
Throwable
exc
)
{
String
commentStr
=
"JADX WARN: "
+
warn
;
addAttr
(
AType
.
COMMENTS
,
commentStr
);
if
(
exc
!=
null
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/debuginfo/DebugInfoApplyVisitor.java
浏览文件 @
5502d93c
...
...
@@ -64,7 +64,7 @@ public class DebugInfoApplyVisitor extends AbstractVisitor {
mth
.
getSVars
().
forEach
(
var
->
{
ArgType
type
=
var
.
getTypeInfo
().
getType
();
if
(!
type
.
isTypeKnown
())
{
mth
.
add
Comment
(
"JADX WARNING: t
ype inference failed for: "
+
var
.
getDetailedVarInfo
(
mth
));
mth
.
add
WarnComment
(
"T
ype inference failed for: "
+
var
.
getDetailedVarInfo
(
mth
));
}
});
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java
浏览文件 @
5502d93c
...
...
@@ -72,7 +72,9 @@ public final class TypeInferenceVisitor extends AbstractVisitor {
if
(!
resolved
)
{
boolean
moveAdded
=
false
;
for
(
SSAVar
var
:
new
ArrayList
<>(
mth
.
getSVars
()))
{
moveAdded
|=
tryInsertAdditionalInsn
(
mth
,
var
);
if
(
tryInsertAdditionalInsn
(
mth
,
var
))
{
moveAdded
=
true
;
}
}
if
(
moveAdded
)
{
InitCodeVariables
.
rerun
(
mth
);
...
...
@@ -361,50 +363,67 @@ public final class TypeInferenceVisitor extends AbstractVisitor {
}
}
for
(
PhiInsn
phiInsn
:
usedInPhiList
)
{
if
(!
insertMoveForPhi
(
mth
,
phiInsn
,
var
))
{
if
(!
insertMoveForPhi
(
mth
,
phiInsn
,
var
,
false
))
{
return
false
;
}
}
// all check passed => apply
for
(
PhiInsn
phiInsn
:
usedInPhiList
)
{
insertMoveForPhi
(
mth
,
phiInsn
,
var
,
true
);
}
mth
.
addComment
(
"JADX INFO: additional move instructions added ("
+
usedInPhiList
.
size
()
+
") to help type inference"
);
return
true
;
}
private
boolean
insertMoveForPhi
(
MethodNode
mth
,
PhiInsn
phiInsn
,
SSAVar
var
)
{
private
boolean
insertMoveForPhi
(
MethodNode
mth
,
PhiInsn
phiInsn
,
SSAVar
var
,
boolean
apply
)
{
int
argsCount
=
phiInsn
.
getArgsCount
();
for
(
int
argIndex
=
0
;
argIndex
<
argsCount
;
argIndex
++)
{
RegisterArg
reg
=
phiInsn
.
getArg
(
argIndex
);
if
(
reg
.
getSVar
()
==
var
)
{
BlockNode
blockNode
=
phiInsn
.
getBlockByArgIndex
(
argIndex
);
InsnNode
lastInsn
=
BlockUtils
.
getLastInsn
(
blockNode
);
if
(
lastInsn
!=
null
&&
BlockSplitter
.
isSeparate
(
lastInsn
.
getType
()))
{
// can't insert move in block with separate instruction
// trying previous block
List
<
BlockNode
>
preds
=
blockNode
.
getPredecessors
();
if
(
preds
.
size
()
==
1
)
{
blockNode
=
preds
.
get
(
0
);
}
else
{
mth
.
addWarn
(
"Failed to insert additional move for type inference"
);
return
false
;
}
BlockNode
startBlock
=
phiInsn
.
getBlockByArgIndex
(
argIndex
);
BlockNode
blockNode
=
checkBlockForInsnInsert
(
startBlock
);
if
(
blockNode
==
null
)
{
mth
.
addWarnComment
(
"Failed to insert an additional move for type inference into block "
+
startBlock
);
return
false
;
}
if
(
apply
)
{
int
regNum
=
reg
.
getRegNum
();
RegisterArg
resultArg
=
reg
.
duplicate
(
regNum
,
null
);
SSAVar
newSsaVar
=
mth
.
makeNewSVar
(
regNum
,
resultArg
);
RegisterArg
arg
=
reg
.
duplicate
(
regNum
,
var
);
InsnNode
moveInsn
=
new
InsnNode
(
InsnType
.
MOVE
,
1
);
moveInsn
.
setResult
(
resultArg
);
moveInsn
.
addArg
(
arg
);
moveInsn
.
add
(
AFlag
.
SYNTHETIC
);
blockNode
.
getInstructions
().
add
(
moveInsn
);
phiInsn
.
replaceArg
(
reg
,
reg
.
duplicate
(
regNum
,
newSsaVar
));
}
int
regNum
=
reg
.
getRegNum
();
RegisterArg
resultArg
=
reg
.
duplicate
(
regNum
,
null
);
SSAVar
newSsaVar
=
mth
.
makeNewSVar
(
regNum
,
resultArg
);
RegisterArg
arg
=
reg
.
duplicate
(
regNum
,
var
);
InsnNode
moveInsn
=
new
InsnNode
(
InsnType
.
MOVE
,
1
);
moveInsn
.
setResult
(
resultArg
);
moveInsn
.
addArg
(
arg
);
moveInsn
.
add
(
AFlag
.
SYNTHETIC
);
blockNode
.
getInstructions
().
add
(
moveInsn
);
phiInsn
.
replaceArg
(
reg
,
reg
.
duplicate
(
regNum
,
newSsaVar
));
return
true
;
}
}
return
false
;
}
@Nullable
private
BlockNode
checkBlockForInsnInsert
(
BlockNode
blockNode
)
{
if
(
blockNode
.
isSynthetic
())
{
return
null
;
}
InsnNode
lastInsn
=
BlockUtils
.
getLastInsn
(
blockNode
);
if
(
lastInsn
!=
null
&&
BlockSplitter
.
isSeparate
(
lastInsn
.
getType
()))
{
// can't insert move in a block with 'separate' instruction => try previous block by simple path
List
<
BlockNode
>
preds
=
blockNode
.
getPredecessors
();
if
(
preds
.
size
()
==
1
)
{
return
checkBlockForInsnInsert
(
preds
.
get
(
0
));
}
return
null
;
}
return
blockNode
;
}
private
boolean
tryWiderObjects
(
MethodNode
mth
,
SSAVar
var
)
{
Set
<
ArgType
>
objTypes
=
new
LinkedHashSet
<>();
for
(
ITypeBound
bound
:
var
.
getTypeInfo
().
getBounds
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录