mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
fix(android): report method disassembly failure as unavailable body (#12090)
* fix(android): report method disassembly failure as unavailable body Catch JADX bridge get_method_body failures in inspectMethod and project as an unavailable body with disassembly_failed marker, avoiding generic execution_failure with irrelevant rea doctor remediation. Fixes #10482 * fix(android): preserve method identity when disassembly is unavailable * fix(android): retain method identity when smali generation fails --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
1 parent
486470ec9b
commit
dc6799d488
10 files changed
+251
-65
No files matched your search
@@ -713,10 +713,19 @@ class ReaJadxBridge {
|
||||
TextUtilKt.truncateToBytes(block, current.getMaxSourceBytes()), "smali", true, markers);
|
||||
}
|
||||
|
||||
private static final class MethodDisassemblyUnavailable extends IllegalArgumentException {
|
||||
MethodDisassemblyUnavailable(String message) { super(message); }
|
||||
}
|
||||
|
||||
private static String selectMethodSmali(JadxSession.MethodSmali smali, String shortId) {
|
||||
if (!smali.getFound())
|
||||
throw new IllegalArgumentException("JADX could not disassemble " + shortId
|
||||
+ (smali.getNote() == null ? "" : ": " + smali.getNote()));
|
||||
if (!smali.getFound()) {
|
||||
String reason = "JADX could not disassemble " + shortId
|
||||
+ (smali.getNote() == null ? "" : ": " + smali.getNote());
|
||||
// JADX folds caller interruption into the same result as failed generation
|
||||
// and missing blocks, but leaves the interrupt flag set.
|
||||
if (Thread.currentThread().isInterrupted()) throw new IllegalArgumentException(reason);
|
||||
throw new MethodDisassemblyUnavailable(reason);
|
||||
}
|
||||
// Upstream returns every same-name overload, and can return an unterminated
|
||||
// trailing block. Match the full original identity before applying output limits.
|
||||
List<String> matches = smali.getBlocks().stream().filter(block -> {
|
||||
@@ -724,10 +733,10 @@ class ReaJadxBridge {
|
||||
return header.startsWith(".method ") && header.endsWith(" " + shortId);
|
||||
}).toList();
|
||||
if (matches.size() != 1)
|
||||
throw new IllegalArgumentException("Disassembly could not establish one selected method: " + shortId);
|
||||
throw new MethodDisassemblyUnavailable("Disassembly could not establish one selected method: " + shortId);
|
||||
String block = matches.get(0);
|
||||
if (!block.stripTrailing().endsWith("\n.end method"))
|
||||
throw new IllegalArgumentException("Selected method disassembly is incomplete: " + shortId);
|
||||
throw new MethodDisassemblyUnavailable("Selected method disassembly is incomplete: " + shortId);
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -1003,14 +1012,22 @@ class ReaJadxBridge {
|
||||
List<MethodSnapshot> overloads = methods(cls, args);
|
||||
int index = integer(args, "overload_index", 0);
|
||||
if (index >= overloads.size()) throw new InputFailure("overload_index", "overload_index out of range: " + index);
|
||||
JavaMethod method = method(cls, overloads.get(index));
|
||||
JadxSession.SmartCode code = methodBody(current, cls, overloads.get(index), method);
|
||||
return json(Map.of("class_name", cls.summary().get("full_name"),
|
||||
"method_name", overloads.get(index).name(), "full_name", method.getFullName(),
|
||||
"dex_descriptor", overloads.get(index).summary().get("dex_descriptor"),
|
||||
"overload_index", index, "overload_count", overloads.size(),
|
||||
"mode", code.getKind(), "fell_back", code.getFellBack(),
|
||||
"markers", code.getMarkers(), "body", code.getText()));
|
||||
MethodSnapshot selected = overloads.get(index);
|
||||
JavaMethod method = method(cls, selected);
|
||||
Map<String, Object> result = new LinkedHashMap<>(Map.of(
|
||||
"class_name", cls.summary().get("full_name"),
|
||||
"method_name", selected.name(), "full_name", method.getFullName(),
|
||||
"dex_descriptor", selected.summary().get("dex_descriptor"),
|
||||
"overload_index", index, "overload_count", overloads.size()));
|
||||
try {
|
||||
JadxSession.SmartCode code = methodBody(current, cls, selected, method);
|
||||
result.putAll(Map.of("mode", code.getKind(), "fell_back", code.getFellBack(),
|
||||
"markers", code.getMarkers(), "body", code.getText()));
|
||||
} catch (MethodDisassemblyUnavailable failure) {
|
||||
result.put("mode", "unavailable");
|
||||
result.put("body_unavailable_reason", failure.getMessage());
|
||||
}
|
||||
return json(result);
|
||||
}
|
||||
List<JavaNode> uses;
|
||||
String target = (String) cls.summary().get("full_name");
|
||||
|
||||
Reference in new issue
Block a user