Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
d9b0365c
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,发现更多精彩内容 >>
提交
d9b0365c
编写于
2月 10, 2018
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix binary xml parser (#211)
上级
948f9456
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
15 deletion
+61
-15
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
...-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
+58
-15
jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java
...-core/src/main/java/jadx/core/xmlgen/ParserConstants.java
+3
-0
未找到文件。
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
浏览文件 @
d9b0365c
...
...
@@ -48,6 +48,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
private
ValuesParser
valuesParser
;
private
boolean
isLastEnd
=
true
;
private
boolean
isOneLine
=
true
;
private
int
[]
resourceIds
;
public
BinaryXMLParser
(
RootNode
root
)
{
try
{
...
...
@@ -145,10 +146,11 @@ public class BinaryXMLParser extends CommonBinaryParser {
if
(
is
.
readInt16
()
!=
0x8
)
{
die
(
"Header size of resmap is not 8!"
);
}
int
rhsize
=
is
.
readInt32
();
int
[]
ids
=
new
int
[(
rhsize
-
8
)
/
4
];
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
ids
[
i
]
=
is
.
readInt32
();
int
size
=
is
.
readInt32
();
int
len
=
(
size
-
8
)
/
4
;
resourceIds
=
new
int
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
resourceIds
[
i
]
=
is
.
readInt32
();
}
}
...
...
@@ -163,7 +165,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
int
comment
=
is
.
readInt32
();
int
beginPrefix
=
is
.
readInt32
();
int
beginURI
=
is
.
readInt32
();
nsMap
.
computeIfAbsent
(
strings
[
beginURI
],
k
->
strings
[
beginPrefix
]
);
nsMap
.
computeIfAbsent
(
getString
(
beginURI
),
k
->
getString
(
beginPrefix
)
);
}
private
void
parseNameSpaceEnd
()
throws
IOException
{
...
...
@@ -177,7 +179,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
int
comment
=
is
.
readInt32
();
int
endPrefix
=
is
.
readInt32
();
int
endURI
=
is
.
readInt32
();
nsMap
.
computeIfAbsent
(
strings
[
endURI
],
k
->
strings
[
endPrefix
]
);
nsMap
.
computeIfAbsent
(
getString
(
endURI
),
k
->
getString
(
endPrefix
)
);
}
private
void
parseCData
()
throws
IOException
{
...
...
@@ -191,7 +193,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
is
.
skip
(
4
);
int
strIndex
=
is
.
readInt32
();
String
str
=
strings
[
strIndex
]
;
String
str
=
getString
(
strIndex
)
;
writer
.
startLine
().
addIndent
();
writer
.
attachSourceLine
(
lineNumber
);
...
...
@@ -221,7 +223,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
isOneLine
=
true
;
isLastEnd
=
false
;
currentTag
=
strings
[
startNSName
]
;
currentTag
=
getString
(
startNSName
)
;
writer
.
startLine
(
"<"
).
add
(
currentTag
);
writer
.
attachSourceLine
(
elementBegLineNumber
);
int
attributeStart
=
is
.
readInt16
();
...
...
@@ -261,15 +263,15 @@ public class BinaryXMLParser extends CommonBinaryParser {
int
attrValDataType
=
is
.
readInt8
();
int
attrValData
=
is
.
readInt32
();
String
attrName
=
strings
[
attributeName
];
if
(
newLine
)
{
writer
.
startLine
().
addIndent
();
}
else
{
writer
.
add
(
' '
);
}
if
(
attributeNS
!=
-
1
)
{
writer
.
add
(
nsMap
.
get
(
strings
[
attributeNS
]
)).
add
(
':'
);
writer
.
add
(
getAttributeNS
(
attributeNS
)).
add
(
':'
);
}
String
attrName
=
getAttributeName
(
attributeName
);
writer
.
add
(
attrName
).
add
(
"=\""
);
String
decodedAttr
=
ManifestAttributes
.
getInstance
().
decode
(
attrName
,
attrValData
);
if
(
decodedAttr
!=
null
)
{
...
...
@@ -280,6 +282,47 @@ public class BinaryXMLParser extends CommonBinaryParser {
writer
.
add
(
'"'
);
}
private
String
getAttributeNS
(
int
attributeNS
)
{
String
attrUrl
=
getString
(
attributeNS
);
if
(
attrUrl
==
null
||
attrUrl
.
isEmpty
())
{
if
(
isResInternalId
(
attributeNS
))
{
return
null
;
}
else
{
attrUrl
=
ANDROID_NS_URL
;
}
}
String
attrName
=
nsMap
.
get
(
attrUrl
);
if
(
attrName
==
null
)
{
return
"NOT_FOUND_NS_0x"
+
Integer
.
toHexString
(
attributeNS
)
+
"_"
+
attrUrl
;
}
return
attrName
;
}
private
String
getAttributeName
(
int
id
)
{
String
str
=
getString
(
id
);
if
(
str
==
null
||
str
.
isEmpty
())
{
int
resId
=
resourceIds
[
id
];
str
=
ValuesParser
.
getAndroidResMap
().
get
(
resId
);
if
(
str
==
null
)
{
return
"NOT_FOUND_0x"
+
Integer
.
toHexString
(
id
);
}
// cut type before /
int
typeEnd
=
str
.
indexOf
(
'/'
);
if
(
typeEnd
!=
-
1
)
{
return
str
.
substring
(
typeEnd
+
1
);
}
return
str
;
}
return
str
;
}
private
String
getString
(
int
strId
)
{
if
(
0
<=
strId
&&
strId
<
strings
.
length
)
{
return
strings
[
strId
];
}
return
"NOT_FOUND_STR_0x"
+
Integer
.
toHexString
(
strId
);
}
private
void
decodeAttribute
(
int
attributeNS
,
int
attrValDataType
,
int
attrValData
)
{
if
(
attrValDataType
==
TYPE_REFERENCE
)
{
// reference custom processing
...
...
@@ -287,7 +330,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
if
(
name
!=
null
)
{
writer
.
add
(
"@"
);
if
(
attributeNS
!=
-
1
)
{
writer
.
add
(
nsMap
.
get
(
strings
[
attributeNS
]
)).
add
(
':'
);
writer
.
add
(
getAttributeNS
(
attributeNS
)).
add
(
':'
);
}
writer
.
add
(
"style/"
).
add
(
name
.
replaceAll
(
"_"
,
"."
));
}
else
{
...
...
@@ -336,15 +379,15 @@ public class BinaryXMLParser extends CommonBinaryParser {
int
comment
=
is
.
readInt32
();
int
elementNS
=
is
.
readInt32
();
int
elementName
=
is
.
readInt32
();
if
(
currentTag
.
equals
(
strings
[
elementName
]
)
&&
isOneLine
&&
!
isLastEnd
)
{
writer
.
add
(
"
/>"
);
if
(
currentTag
.
equals
(
getString
(
elementName
)
)
&&
isOneLine
&&
!
isLastEnd
)
{
writer
.
add
(
"/>"
);
}
else
{
writer
.
startLine
(
"</"
);
writer
.
attachSourceLine
(
endLineNumber
);
if
(
elementNS
!=
-
1
)
{
writer
.
add
(
strings
[
elementNS
]
).
add
(
':'
);
writer
.
add
(
getString
(
elementNS
)
).
add
(
':'
);
}
writer
.
add
(
strings
[
elementName
]
).
add
(
">"
);
writer
.
add
(
getString
(
elementName
)
).
add
(
">"
);
}
isLastEnd
=
true
;
if
(
writer
.
getIndent
()
!=
0
)
{
...
...
jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java
浏览文件 @
d9b0365c
...
...
@@ -8,6 +8,9 @@ public class ParserConstants {
protected
ParserConstants
()
{
}
protected
static
final
String
ANDROID_NS_URL
=
"http://schemas.android.com/apk/res/android"
;
/**
* Chunk types
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录