Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
20bf85b1
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,发现更多精彩内容 >>
提交
20bf85b1
编写于
1月 27, 2018
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: ignore bogus opcode decode (#214)
上级
f02b99a1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
20 deletion
+36
-20
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+36
-20
未找到文件。
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
浏览文件 @
20bf85b1
package
jadx.core.dex.instructions
;
import
java.io.EOFException
;
import
com.android.dex.Code
;
import
com.android.dx.io.OpcodeInfo
;
import
com.android.dx.io.Opcodes
;
import
com.android.dx.io.instructions.DecodedInstruction
;
import
com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction
;
import
com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction
;
import
com.android.dx.io.instructions.ShortArrayCodeInput
;
import
com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction
;
import
org.jetbrains.annotations.NotNull
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
...
...
@@ -12,16 +26,8 @@ import jadx.core.dex.nodes.MethodNode;
import
jadx.core.utils.InsnUtils
;
import
jadx.core.utils.exceptions.DecodeException
;
import
com.android.dex.Code
;
import
com.android.dx.io.OpcodeInfo
;
import
com.android.dx.io.Opcodes
;
import
com.android.dx.io.instructions.DecodedInstruction
;
import
com.android.dx.io.instructions.FillArrayDataPayloadDecodedInstruction
;
import
com.android.dx.io.instructions.PackedSwitchPayloadDecodedInstruction
;
import
com.android.dx.io.instructions.ShortArrayCodeInput
;
import
com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction
;
public
class
InsnDecoder
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
InsnDecoder
.
class
);
private
final
MethodNode
method
;
private
final
DexNode
dex
;
...
...
@@ -37,26 +43,36 @@ public class InsnDecoder {
int
size
=
encodedInstructions
.
length
;
DecodedInstruction
[]
decoded
=
new
DecodedInstruction
[
size
];
ShortArrayCodeInput
in
=
new
ShortArrayCodeInput
(
encodedInstructions
);
try
{
while
(
in
.
hasMore
())
{
decoded
[
in
.
cursor
()]
=
DecodedInstruction
.
decode
(
in
);
decoded
[
in
.
cursor
()]
=
decodeRawInsn
(
in
);
}
}
catch
(
Exception
e
)
{
throw
new
DecodeException
(
method
,
""
,
e
);
throw
new
DecodeException
(
method
,
e
.
getMessage
()
,
e
);
}
insnArr
=
decoded
;
}
private
DecodedInstruction
decodeRawInsn
(
ShortArrayCodeInput
in
)
throws
EOFException
{
int
opcodeUnit
=
in
.
read
();
int
opcode
=
Opcodes
.
extractOpcodeFromUnit
(
opcodeUnit
);
OpcodeInfo
.
Info
opcodeInfo
;
try
{
opcodeInfo
=
OpcodeInfo
.
get
(
opcode
);
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
warn
(
"Ignore decode error: '{}', replace with NOP instruction"
,
e
.
getMessage
());
opcodeInfo
=
OpcodeInfo
.
NOP
;
}
return
opcodeInfo
.
getFormat
().
decode
(
opcodeUnit
,
in
);
}
public
InsnNode
[]
process
()
throws
DecodeException
{
InsnNode
[]
instructions
=
new
InsnNode
[
insnArr
.
length
];
for
(
int
i
=
0
;
i
<
insnArr
.
length
;
i
++)
{
DecodedInstruction
rawInsn
=
insnArr
[
i
];
if
(
rawInsn
!=
null
)
{
InsnNode
insn
=
decode
(
rawInsn
,
i
);
if
(
insn
!=
null
)
{
insn
.
setOffset
(
i
);
}
insn
.
setOffset
(
i
);
instructions
[
i
]
=
insn
;
}
else
{
instructions
[
i
]
=
null
;
...
...
@@ -66,15 +82,14 @@ public class InsnDecoder {
return
instructions
;
}
@NotNull
private
InsnNode
decode
(
DecodedInstruction
insn
,
int
offset
)
throws
DecodeException
{
switch
(
insn
.
getOpcode
())
{
case
Opcodes
.
NOP
:
return
new
InsnNode
(
InsnType
.
NOP
,
0
);
case
Opcodes
.
PACKED_SWITCH_PAYLOAD
:
case
Opcodes
.
SPARSE_SWITCH_PAYLOAD
:
case
Opcodes
.
FILL_ARRAY_DATA_PAYLOAD
:
return
n
ull
;
return
n
ew
InsnNode
(
InsnType
.
NOP
,
0
)
;
// move-result will be process in invoke and filled-new-array instructions
case
Opcodes
.
MOVE_RESULT
:
...
...
@@ -565,9 +580,10 @@ public class InsnDecoder {
return
insn
(
InsnType
.
MONITOR_EXIT
,
null
,
InsnArg
.
reg
(
insn
,
0
,
ArgType
.
UNKNOWN_OBJECT
));
}
throw
new
DecodeException
(
"Unknown instruction: '"
+
OpcodeInfo
.
getName
(
insn
.
getOpcode
())
+
"'"
);
default
:
throw
new
DecodeException
(
"Unknown instruction: '"
+
OpcodeInfo
.
getName
(
insn
.
getOpcode
())
+
"'"
);
}
}
private
InsnNode
decodeSwitch
(
DecodedInstruction
insn
,
int
offset
,
boolean
packed
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录