Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
a27ba3ff
J
jadx
项目概览
qq_39073359
/
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,发现更多精彩内容 >>
未验证
提交
a27ba3ff
编写于
2月 05, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(res): skip '.9.png' decode if patch data not found (#1112)
上级
4684207b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
9 deletion
+19
-9
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
+3
-2
jadx-core/src/main/java/jadx/core/utils/android/Res9patchStreamDecoder.java
.../java/jadx/core/utils/android/Res9patchStreamDecoder.java
+15
-6
jadx-gui/src/main/java/jadx/gui/utils/search/ResourceIndex.java
...ui/src/main/java/jadx/gui/utils/search/ResourceIndex.java
+1
-1
未找到文件。
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
浏览文件 @
a27ba3ff
...
...
@@ -126,8 +126,9 @@ public final class ResourcesLoader {
if
(
name
.
endsWith
(
".9.png"
))
{
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
Res9patchStreamDecoder
decoder
=
new
Res9patchStreamDecoder
();
decoder
.
decode
(
inputStream
,
os
);
return
ResContainer
.
decodedData
(
rf
.
getDeobfName
(),
os
.
toByteArray
());
if
(
decoder
.
decode
(
inputStream
,
os
))
{
return
ResContainer
.
decodedData
(
rf
.
getDeobfName
(),
os
.
toByteArray
());
}
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to decode 9-patch png image, path: {}"
,
name
,
e
);
}
...
...
jadx-core/src/main/java/jadx/core/utils/android/Res9patchStreamDecoder.java
浏览文件 @
a27ba3ff
...
...
@@ -24,6 +24,8 @@ import java.io.OutputStream;
import
javax.imageio.ImageIO
;
import
org.jetbrains.annotations.Nullable
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
/**
...
...
@@ -31,16 +33,19 @@ import jadx.core.utils.exceptions.JadxRuntimeException;
*/
public
class
Res9patchStreamDecoder
{
public
void
decode
(
InputStream
in
,
OutputStream
out
)
{
public
boolean
decode
(
InputStream
in
,
OutputStream
out
)
{
try
{
BufferedImage
im
=
ImageIO
.
read
(
in
);
NinePatch
np
=
getNinePatch
(
in
);
if
(
np
==
null
)
{
return
false
;
}
int
w
=
im
.
getWidth
();
int
h
=
im
.
getHeight
();
BufferedImage
im2
=
new
BufferedImage
(
w
+
2
,
h
+
2
,
BufferedImage
.
TYPE_INT_ARGB
);
im2
.
createGraphics
().
drawImage
(
im
,
1
,
1
,
w
,
h
,
null
);
NinePatch
np
=
getNinePatch
(
in
);
drawHLine
(
im2
,
h
+
1
,
np
.
padLeft
+
1
,
w
-
np
.
padRight
);
drawVLine
(
im2
,
w
+
1
,
np
.
padTop
+
1
,
h
-
np
.
padBottom
);
...
...
@@ -55,28 +60,32 @@ public class Res9patchStreamDecoder {
}
ImageIO
.
write
(
im2
,
"png"
,
out
);
return
true
;
}
catch
(
Exception
e
)
{
throw
new
JadxRuntimeException
(
"9patch image decode error"
,
e
);
}
}
@Nullable
private
NinePatch
getNinePatch
(
InputStream
in
)
throws
IOException
{
ExtDataInput
di
=
new
ExtDataInput
(
in
);
find9patchChunk
(
di
);
if
(!
find9patchChunk
(
di
))
{
return
null
;
}
return
NinePatch
.
decode
(
di
);
}
private
void
find9patchChunk
(
DataInput
di
)
throws
IOException
{
private
boolean
find9patchChunk
(
DataInput
di
)
throws
IOException
{
di
.
skipBytes
(
8
);
while
(
true
)
{
int
size
;
try
{
size
=
di
.
readInt
();
}
catch
(
IOException
ex
)
{
throw
new
JadxRuntimeException
(
"Cant find nine patch chunk"
,
ex
)
;
return
false
;
}
if
(
di
.
readInt
()
==
NP_CHUNK_TYPE
)
{
return
;
return
true
;
}
di
.
skipBytes
(
size
+
4
);
}
...
...
jadx-gui/src/main/java/jadx/gui/utils/search/ResourceIndex.java
浏览文件 @
a27ba3ff
...
...
@@ -203,7 +203,7 @@ public class ResourceIndex {
resNodes
.
add
(
resNode
);
}
}
else
{
LOG
.
debug
(
"Resource skipped because of size limit: {} res size {} bytes"
,
resNode
,
size
);
LOG
.
debug
(
"Resource
index
skipped because of size limit: {} res size {} bytes"
,
resNode
,
size
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录