From b5c435523a847df81b055a30b5341870054bfbde Mon Sep 17 00:00:00 2001 From: Dimitris Chatzis Date: Sun, 11 Oct 2026 12:44:36 +0300 Subject: [PATCH] fix(getclass): reach non-BMP class names by encoding the query as MUTF-8 --- droidasc/asc_client/apk_handler.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/droidasc/asc_client/apk_handler.py b/droidasc/asc_client/apk_handler.py index 864aaea..b648eff 100644 --- a/droidasc/asc_client/apk_handler.py +++ b/droidasc/asc_client/apk_handler.py @@ -359,7 +359,20 @@ def _open_apk(self): return fp, mm def get_class_dex(self, dalvik_class : str): + # string_data_item is MUTF-8, not UTF-8: a code point above the BMP is + # stored as a surrogate pair (CESU-8), so a UTF-8-encoded query can never + # byte-match it and such a class was unreachable. MUTF-8 also keeps byte + # order aligned with the table's UTF-16 code-unit order, which the binary + # search in _find_type_idx relies on. + # + # The two encodings differ only above the BMP (and for an embedded NUL, + # which a descriptor cannot hold), so only such a name pays for the + # encoder - a compiled extension costing ~19ms to import, which every + # ordinary lookup would otherwise drag in on this path. target_bytes = dalvik_class.encode("utf-8") + if any(ord(ch) > 0xFFFF for ch in dalvik_class): + from mutf8 import encode_modified_utf8 + target_bytes = encode_modified_utf8(dalvik_class) t_start = time.perf_counter() fp, mm = self._open_apk() try: