From 0938351d9769d5be92914cd5cfc916336fe64d1f Mon Sep 17 00:00:00 2001 From: Skylot <118523+skylot@users.noreply.github.com> Date: Fri, 6 Sep 2024 22:48:04 +0100 Subject: [PATCH] feat(res): support compact resource entries (#2268) --- .../jadx/core/xmlgen/ResTableBinaryParser.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 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 a7c4381a997..44d8e6c210b 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java @@ -308,7 +308,7 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException { entryOffsetMap.put(i, is.readInt32()); } } - is.checkPos(entriesStart, "Expected first entry start"); + is.skipToPos(entriesStart, "Failed to skip to entries start"); int processed = 0; for (int index : entryOffsetMap.keySet()) { int offset = entryOffsetMap.get(index); @@ -365,16 +365,11 @@ private void parseStagedAliasChunk(long chunkStart) throws IOException { private void parseEntry(PackageChunk pkg, int typeId, int entryId, String config) throws IOException { int size = is.readInt16(); - int flags = is.readInt16(); boolean isComplex = (flags & FLAG_COMPLEX) != 0; boolean isCompact = (flags & FLAG_COMPACT) != 0; - if (isCompact) { - throw new JadxRuntimeException("Compact resource entries are not supported yet"); - } - - int key = is.readInt32(); + int key = isCompact ? size : is.readInt32(); if (key == -1) { return; } @@ -384,7 +379,11 @@ private void parseEntry(PackageChunk pkg, int typeId, int entryId, String config String origKeyName = pkg.getKeyStrings().get(key); ResourceEntry newResEntry = buildResourceEntry(pkg, config, resRef, typeName, origKeyName); - if (isComplex || size == 16) { + if (isCompact) { + int dataType = flags >> 8; + int data = is.readInt32(); + newResEntry.setSimpleValue(new RawValue(dataType, data)); + } else if (isComplex || size == 16) { int parentRef = is.readInt32(); int count = is.readInt32(); newResEntry.setParentRef(parentRef);