Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
99768940
Commit
99768940
authored
Aug 29, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: skip decoding for plain text xml (fix #82)
parent
76a0608a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
+31
-9
ResourcesLoader.java
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
+4
-2
BinaryXMLParser.java
...-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
+16
-7
ParserStream.java
jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java
+11
-0
No files found.
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
View file @
99768940
...
...
@@ -53,6 +53,7 @@ public final class ResourcesLoader {
}
ZipFile
zipFile
=
null
;
InputStream
inputStream
=
null
;
Object
result
=
null
;
try
{
zipFile
=
new
ZipFile
(
zipRef
.
getZipFile
());
ZipEntry
entry
=
zipFile
.
getEntry
(
zipRef
.
getEntryName
());
...
...
@@ -60,7 +61,7 @@ public final class ResourcesLoader {
throw
new
IOException
(
"Zip entry not found: "
+
zipRef
);
}
inputStream
=
new
BufferedInputStream
(
zipFile
.
getInputStream
(
entry
));
re
turn
decoder
.
decode
(
entry
.
getSize
(),
inputStream
);
re
sult
=
decoder
.
decode
(
entry
.
getSize
(),
inputStream
);
}
catch
(
Exception
e
)
{
throw
new
JadxException
(
"Error decode: "
+
zipRef
.
getEntryName
(),
e
);
}
finally
{
...
...
@@ -75,6 +76,7 @@ public final class ResourcesLoader {
LOG
.
debug
(
"Error close zip file: {}"
,
zipRef
,
e
);
}
}
return
result
;
}
static
CodeWriter
loadContent
(
final
JadxDecompiler
jadxRef
,
final
ResourceFile
rf
)
{
...
...
@@ -148,7 +150,7 @@ public final class ResourcesLoader {
// LOG.debug("Add resource entry: {}, size: {}", name, entry.getSize());
}
p
rivate
static
CodeWriter
loadToCodeWriter
(
InputStream
is
)
throws
IOException
{
p
ublic
static
CodeWriter
loadToCodeWriter
(
InputStream
is
)
throws
IOException
{
CodeWriter
cw
=
new
CodeWriter
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
(
READ_BUFFER_SIZE
);
byte
[]
buffer
=
new
byte
[
READ_BUFFER_SIZE
];
...
...
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
View file @
99768940
package
jadx
.
core
.
xmlgen
;
import
jadx.api.ResourcesLoader
;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.nodes.DexNode
;
...
...
@@ -81,22 +82,30 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
public
synchronized
CodeWriter
parse
(
InputStream
inputStream
)
throws
IOException
{
is
=
new
ParserStream
(
inputStream
);
if
(!
isBinaryXml
())
{
return
ResourcesLoader
.
loadToCodeWriter
(
inputStream
);
}
writer
=
new
CodeWriter
();
writer
.
add
(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
);
is
=
new
ParserStream
(
inputStream
);
firstElement
=
true
;
decode
();
writer
.
finish
();
return
writer
;
}
void
decode
()
throws
IOException
{
i
f
(
is
.
readInt16
()
!=
0x0003
)
{
die
(
"Version is not 3"
);
}
if
(
is
.
readInt16
()
!
=
0x0008
)
{
die
(
"Size of header is not 8"
)
;
private
boolean
isBinaryXml
()
throws
IOException
{
i
s
.
mark
(
4
);
int
v
=
is
.
readInt16
();
// version
int
h
=
is
.
readInt16
();
// header size
if
(
v
==
0x0003
&&
h
=
=
0x0008
)
{
return
true
;
}
is
.
reset
();
return
false
;
}
void
decode
()
throws
IOException
{
int
size
=
is
.
readInt32
();
while
(
is
.
getPos
()
<
size
)
{
int
type
=
is
.
readInt16
();
...
...
jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java
View file @
99768940
...
...
@@ -132,6 +132,17 @@ public class ParserStream {
checkPos
(
expectedOffset
,
error
);
}
public
void
mark
(
int
len
)
throws
IOException
{
if
(!
input
.
markSupported
())
{
throw
new
IOException
(
"Mark not supported for input stream "
+
input
.
getClass
());
}
input
.
mark
(
len
);
}
public
void
reset
()
throws
IOException
{
input
.
reset
();
}
@Override
public
String
toString
()
{
return
"pos: 0x"
+
Long
.
toHexString
(
readPos
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment