From 7db9b5337b475b04c82558ed2327bc1d574bc032 Mon Sep 17 00:00:00 2001 From: Jan Peter Stotz Date: Sat, 6 Jul 2024 18:03:02 +0200 Subject: [PATCH 1/3] log and ignore decodeValue errors --- .../src/main/java/jadx/core/xmlgen/BinaryXMLParser.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 203f127e6cc..5c7fec7d8ea 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java @@ -441,7 +441,13 @@ private void decodeAttribute(int attributeNS, int attrValDataType, int attrValDa } } } else { - String str = valuesParser.decodeValue(attrValDataType, attrValData); + String str; + try { + str = valuesParser.decodeValue(attrValDataType, attrValData); + } catch (JadxRuntimeException e) { + LOG.error("Failed to decode attribute value of \"{}\"", attrFullName, e); + str = null; + } memorizePackageName(attrFullName, str); if (isDeobfCandidateAttr(attrFullName)) { str = deobfClassName(str); From 76471da8c52811a7a1d4b3e122bce0748a31370f Mon Sep 17 00:00:00 2001 From: Jan Peter Stotz Date: Sat, 25 May 2024 16:12:53 +0200 Subject: [PATCH 2/3] skip extra data in package header --- .../main/java/jadx/core/xmlgen/ResTableBinaryParser.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java index d69acfb7af4..dd6049c1a7e 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java @@ -123,8 +123,8 @@ private PackageChunk parsePackage() throws IOException { long start = is.getPos(); is.checkInt16(RES_TABLE_PACKAGE_TYPE, "Not a table chunk"); int headerSize = is.readInt16(); - if (headerSize != 0x011c && headerSize != 0x0120) { - die("Unexpected package header size"); + if (headerSize < 0x011c) { + die("Package header size too small"); } long size = is.readUInt32(); long endPos = start + size; @@ -138,10 +138,12 @@ private PackageChunk parsePackage() throws IOException { long keyStringsOffset = start + is.readInt32(); /* int lastPublicKey = */ is.readInt32(); - if (headerSize == 0x0120) { + + if (headerSize >= 0x0120) { /* int typeIdOffset = */ is.readInt32(); } + is.skipToPos(start + headerSize, "package header end"); BinaryXMLStrings typeStrings = null; if (typeStringsOffset != 0) { From 4b29a1498fcbe67c5544dd965e6b12c1340cb056 Mon Sep 17 00:00:00 2001 From: Jan Peter Stotz Date: Sat, 6 Jul 2024 17:48:49 +0200 Subject: [PATCH 3/3] ResourceTypes.h --- jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java b/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java index 239b832e1bc..bef8dc58e00 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java @@ -12,7 +12,7 @@ protected ParserConstants() { protected static final String ANDROID_NS_VALUE = "android"; /** - * Chunk types + * Chunk types as defined in frameworks/base/libs/androidfw/include/androidfw/ResourceTypes.h (AOSP) */ protected static final int RES_NULL_TYPE = 0x0000; protected static final int RES_STRING_POOL_TYPE = 0x0001;