From 937dd20794c66dccb3a284160876b3875759ce65 Mon Sep 17 00:00:00 2001 From: pubiqq <82187521+pubiqq@users.noreply.github.com> Date: Sat, 7 Sep 2024 01:21:21 +0300 Subject: [PATCH] feat(res): support 16-bit entry offsets (PR #2269) --- .../java/jadx/core/xmlgen/ResTableBinaryParser.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 f06e4208c..a7c4381a9 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java @@ -279,10 +279,6 @@ public class ResTableBinaryParser extends CommonBinaryParser implements IResTabl boolean isSparse = (flags & FLAG_SPARSE) != 0; boolean isOffset16 = (flags & FLAG_OFFSET16) != 0; - if (isOffset16) { - throw new JadxRuntimeException("16-bit entry offsets are not supported yet"); - } - is.checkInt16(0, "type chunk, reserved"); int entryCount = is.readInt32(); long entriesStart = start + is.readInt32(); @@ -301,6 +297,12 @@ public class ResTableBinaryParser extends CommonBinaryParser implements IResTabl int offset = is.readInt16() * 4; // The offset in ResTable_sparseTypeEntry::offset is stored divided by 4. entryOffsetMap.put(idx, offset); } + } else if (isOffset16) { + for (int i = 0; i < entryCount; i++) { + int offset = is.readInt16(); + int realOffset = offset == 0xFFFF ? NO_ENTRY : offset * 4; + entryOffsetMap.put(i, realOffset); + } } else { for (int i = 0; i < entryCount; i++) { entryOffsetMap.put(i, is.readInt32());