diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java index 52941fbf3..fc10cc55c 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java @@ -65,7 +65,7 @@ public class BinaryXMLParser extends CommonBinaryParser { resourceIds = null; is = new ParserStream(inputStream); if (!isBinaryXml()) { - return ResourcesLoader.loadToCodeWriter(inputStream); + return ResourcesLoader.loadToCodeWriter(is); } nsMapGenerated = new HashSet<>(); nsMap = new HashMap<>(); diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java b/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java index e84459d32..7b19fa079 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java @@ -9,7 +9,7 @@ import java.nio.charset.StandardCharsets; import org.jetbrains.annotations.NotNull; -public class ParserStream { +public class ParserStream extends InputStream { protected static final Charset STRING_CHARSET_UTF16 = StandardCharsets.UTF_16LE; protected static final Charset STRING_CHARSET_UTF8 = StandardCharsets.UTF_8; @@ -88,7 +88,8 @@ public class ParserStream { return arr; } - public void skip(long count) throws IOException { + @Override + public long skip(long count) throws IOException { readPos += count; long pos = input.skip(count); while (pos < count) { @@ -98,6 +99,7 @@ public class ParserStream { } pos += skipped; } + return pos; } public void checkInt8(int expected, String error) throws IOException { @@ -140,14 +142,16 @@ public class ParserStream { checkPos(expectedOffset, error); } - public void mark(int len) throws IOException { + @Override + public void mark(int len) { if (!input.markSupported()) { - throw new IOException("Mark not supported for input stream " + input.getClass()); + throw new RuntimeException("Mark not supported for input stream " + input.getClass()); } input.mark(len); markPos = readPos; } + @Override public void reset() throws IOException { input.reset(); readPos = markPos; @@ -172,6 +176,16 @@ public class ParserStream { } } + @Override + public int read() throws IOException { + return input.read(); + } + + @Override + public int read(@NotNull byte[] b, int off, int len) throws IOException { + return input.read(b, off, len); + } + @Override public String toString() { return "pos: 0x" + Long.toHexString(readPos);