Skip to content

Commit

Permalink
fix(res): handle RES_TABLE_TYPE_OVERLAY (#1748) (PR #1804)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz authored Mar 18, 2023
1 parent 950fbba commit 6ba0e1d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ protected ParserConstants() {
protected static final int RES_TABLE_TYPE_SPEC_TYPE = 0x0202; // 514
protected static final int RES_TABLE_TYPE_LIBRARY = 0x0203; // 515
protected static final int RES_TABLE_TYPE_OVERLAY = 0x0204; // 516
protected static final int RES_TABLE_TYPE_STAGED_ALIAS = 0x0206; // 517
protected static final int RES_TABLE_TYPE_OVERLAY_POLICY = 0x0205; // 517
protected static final int RES_TABLE_TYPE_STAGED_ALIAS = 0x0206; // 518

/**
* Type constants
Expand Down
17 changes: 16 additions & 1 deletion jadx-core/src/main/java/jadx/core/xmlgen/ResTableParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ private PackageChunk parsePackage() throws IOException {
parseLibraryTypeChunk(chunkStart);
break;
case RES_TABLE_TYPE_OVERLAY: // 0x0204
parseOverlayTypeChunk(chunkStart);
break;
case RES_TABLE_TYPE_OVERLAY_POLICY: // 0x0205
throw new IOException(
String.format("Encountered unsupported chunk type TYPE_OVERLAY at offset 0x%x ", chunkStart));
String.format("Encountered unsupported chunk type RES_TABLE_TYPE_OVERLAY_POLICY at offset 0x%x ", chunkStart));
case RES_TABLE_TYPE_STAGED_ALIAS: // 0x0206
throw new IOException(
String.format("Encountered unsupported chunk type TYPE_STAGED_ALIAS at offset 0x%x ", chunkStart));
Expand Down Expand Up @@ -287,6 +290,18 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
}
}

private void parseOverlayTypeChunk(long chunkStart) throws IOException {
LOG.trace("parsing overlay type chunk starting at offset {}", chunkStart);
int headerSize = is.readInt16(); // usually 1032 bytes
int chunkSize = is.readInt32(); // e.g. 1056 bytes
long expectedEndPos = chunkStart + chunkSize;
String name = is.readString16Fixed(128); // 256 bytes
String actor = is.readString16Fixed(128); // 256 bytes
LOG.trace("Overlay header data: name={} actor={}", name, actor);
// the other data in the chunk header and body is unknown
is.skipToPos(expectedEndPos, "overlay chunk end");
}

private void parseEntry(PackageChunk pkg, int typeId, int entryId, String config) throws IOException {
int size = is.readInt16();
int flags = is.readInt16();
Expand Down

0 comments on commit 6ba0e1d

Please sign in to comment.