Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): handle RES_TABLE_TYPE_OVERLAY #1804

Merged
merged 1 commit into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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