Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colcode
jadx
提交
6996f944
J
jadx
项目概览
colcode
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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 搜索 >>
提交
6996f944
编写于
5月 31, 2021
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod: disable assign inline, force multi returns, disable inline into 'if' (#1184)
上级
2acc14b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
29 deletion
+80
-29
jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockProcessor.java
...va/jadx/core/dex/visitors/blocksmaker/BlockProcessor.java
+6
-5
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+26
-24
jadx-core/src/main/java/jadx/core/dex/visitors/shrink/CodeShrinkVisitor.java
...java/jadx/core/dex/visitors/shrink/CodeShrinkVisitor.java
+4
-0
jadx-core/src/test/java/jadx/tests/integration/conditions/TestAssignInlineNegative.java
...ests/integration/conditions/TestAssignInlineNegative.java
+44
-0
未找到文件。
jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockProcessor.java
浏览文件 @
6996f944
...
...
@@ -740,11 +740,12 @@ public class BlockProcessor extends AbstractVisitor {
if
(
returnInsn
==
null
)
{
return
false
;
}
if
(
returnInsn
.
getArgsCount
()
==
1
&&
exitBlock
.
getInstructions
().
size
()
==
1
&&
!
isReturnArgAssignInPred
(
preds
,
returnInsn
))
{
return
false
;
}
// force multiple returns
// if (returnInsn.getArgsCount() == 1
// && exitBlock.getInstructions().size() == 1
// && !isReturnArgAssignInPred(preds, returnInsn)) {
// return false;
// }
boolean
first
=
true
;
for
(
BlockNode
pred
:
preds
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
浏览文件 @
6996f944
...
...
@@ -392,30 +392,32 @@ public class IfMakerHelper {
List
<
InsnNode
>
forceInlineInsns
=
new
ArrayList
<>();
if
(!
insns
.
isEmpty
())
{
// check that all instructions can be inlined
for
(
InsnNode
insn
:
insns
)
{
RegisterArg
res
=
insn
.
getResult
();
if
(
res
==
null
)
{
pass
=
false
;
break
;
}
List
<
RegisterArg
>
useList
=
res
.
getSVar
().
getUseList
();
int
useCount
=
useList
.
size
();
if
(
useCount
==
0
)
{
// TODO?
pass
=
false
;
break
;
}
InsnArg
arg
=
useList
.
get
(
0
);
InsnNode
usePlace
=
arg
.
getParentInsn
();
if
(!
BlockUtils
.
blockContains
(
block
,
usePlace
)
&&
!
BlockUtils
.
blockContains
(
next
,
usePlace
))
{
pass
=
false
;
break
;
}
if
(
useCount
>
1
)
{
forceInlineInsns
.
add
(
insn
);
}
}
// for (InsnNode insn : insns) {
// RegisterArg res = insn.getResult();
// if (res == null) {
// pass = false;
// break;
// }
// List<RegisterArg> useList = res.getSVar().getUseList();
// int useCount = useList.size();
// if (useCount == 0) {
// // TODO?
// pass = false;
// break;
// }
// InsnArg arg = useList.get(0);
// InsnNode usePlace = arg.getParentInsn();
// if (!BlockUtils.blockContains(block, usePlace)
// && !BlockUtils.blockContains(next, usePlace)) {
// pass = false;
// break;
// }
// if (useCount > 1) {
// forceInlineInsns.add(insn);
// }
// }
// disable assign inlining
pass
=
false
;
}
if
(!
pass
)
{
return
null
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/shrink/CodeShrinkVisitor.java
浏览文件 @
6996f944
...
...
@@ -104,6 +104,10 @@ public class CodeShrinkVisitor extends AbstractVisitor {
if
(
parentInsn
!=
null
&&
parentInsn
.
contains
(
AFlag
.
DONT_GENERATE
))
{
return
;
}
// don't inline vars into 'if'
if
(
parentInsn
!=
null
&&
parentInsn
.
getType
()
==
InsnType
.
IF
)
{
return
;
}
if
(!
assignInline
&&
useArg
.
contains
(
AFlag
.
DONT_INLINE_CONST
))
{
return
;
}
...
...
jadx-core/src/test/java/jadx/tests/integration/conditions/TestAssignInlineNegative.java
0 → 100644
浏览文件 @
6996f944
package
jadx.tests.integration.conditions
;
import
java.util.zip.ZipEntry
;
import
org.junit.jupiter.api.Test
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
public
class
TestAssignInlineNegative
extends
IntegrationTest
{
@SuppressWarnings
(
"ConstantConditions"
)
public
static
class
TestCls
{
public
final
ZipEntry
test
()
{
ZipEntry
nextEntry
=
getNextEntry
();
if
(
nextEntry
==
null
)
{
return
nextEntry
;
}
String
name
=
nextEntry
.
getName
();
if
(
name
==
null
)
{
return
nextEntry
;
}
if
(!
name
.
contains
(
"../"
)
&&
!
name
.
contains
(
"..\\"
))
{
return
nextEntry
;
}
throw
new
SecurityException
(
":"
+
nextEntry
.
getName
());
}
private
ZipEntry
getNextEntry
()
{
return
null
;
}
}
@Test
public
void
test
()
{
noDebugInfo
();
assertThat
(
getClassNode
(
TestCls
.
class
))
.
code
()
.
doesNotContain
(
"(name = nextEntry.getName()) == null"
)
.
containsOne
(
"if (name == null) {"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录